Top | ![]() |
![]() |
![]() |
![]() |
const gchar * | ldm_device_get_modalias () |
const gchar * | ldm_device_get_name () |
const gchar * | ldm_device_get_path () |
gint | ldm_device_get_product_id () |
const gchar * | ldm_device_get_vendor () |
gint | ldm_device_get_vendor_id () |
LdmDeviceType | ldm_device_get_device_type () |
LdmDeviceAttribute | ldm_device_get_attributes () |
gboolean | ldm_device_has_type () |
gboolean | ldm_device_has_attribute () |
LdmDevice * | ldm_device_get_parent () |
GList * | ldm_device_get_children () |
gint | ldm_device_get_priority () |
LdmDeviceAttribute | attributes | Read |
LdmDeviceType | device-type | Read |
gchar * | modalias | Read |
gchar * | name | Read |
gpointer | parent | Read / Write / Construct Only |
gchar * | path | Read |
gint | priority | Read / Write |
gint | product-id | Read |
gchar * | vendor | Read |
gint | vendor-id | Read |
GEnum ╰── LdmPCIVendorID GFlags ├── LdmDeviceAttribute ╰── LdmDeviceType GObject ╰── GInitiallyUnowned ╰── LdmDevice ├── LdmBluetoothDevice ├── LdmDMIDevice ├── LdmHIDDevice ├── LdmPCIDevice ╰── LdmUSBDevice
An LdmDevice is not directly created, it is owned and constructed by an LdmManager instance. Each LdmDevice may either be a PCI or USB device, and is in reality an abstraction of an underlying udev device.
This object provides easy access to system devices, allowing the end user to easily introspect basic properties such as the “name”, “vendor-id” or even the “modalias”.
Each device returned by the LdmManager is a composite toplevel device, that is to say, it is the sum of all of its properties. This is particularly helpful when dealing with LdmUSBDevice, whereby the root level properties of the device are the sum of all child parts. This allows users of the library to ignore USB interface internals and directly query an LdmDevice to determine what capabilities and classes it supports, such as a composite device with LDM_DEVICE_TYPE_VIDEO | LDM_DEVICE_TYPE_AUDIO capabilities.
const gchar *
ldm_device_get_modalias (LdmDevice *device
);
The modalias is unique to the device and is used in identifying potential driver candidates.
The Linux kernel will assign each device (or interface) a modalias, which can be matched via LdmModalias and LdmModaliasPlugin to determine which package provides the drivers required to enable this device.
const gchar *
ldm_device_get_name (LdmDevice *device
);
This function will return the name (model) of this device, suitable for presentation to a user.
const gchar *
ldm_device_get_path (LdmDevice *device
);
This function will return the system-specific path for this device.
This is the fully qualified /sys
path.
gint
ldm_device_get_product_id (LdmDevice *device
);
This function will return the product ID (model) of this device, suitable for comparison with known models.
const gchar *
ldm_device_get_vendor (LdmDevice *device
);
This function will return the vendor (manufacturer) of this device, suitable for presentation to a user.
gint
ldm_device_get_vendor_id (LdmDevice *device
);
This function will return the vendor ID (manufacturer) of this device, suitable for comparison with known vendors.
This is especially useful with the predefined LdmPCIVendorID IDs
C example:
1 2 3 |
if (ldm_device_get_vendor_id(device) == LDM_PCI_VENDOR_ID_NVIDIA) { g_message("Found an NVIDIA device!"); } |
LdmDeviceType
ldm_device_get_device_type (LdmDevice *device
);
Return the device type (bitwise field)
LdmDeviceAttribute
ldm_device_get_attributes (LdmDevice *device
);
Return the device type (bitwise field)
gboolean ldm_device_has_type (LdmDevice *device
,LdmDeviceType mask
);
Test whether this device has the given type(s) by testing the mask against our known types.
C example:
1 2 3 |
if (ldm_device_has_type(device, LDM_DEVICE_TYPE_USB | LDM_DEVICE_TYPE_PRINTER) { g_message("Found a USB printer!"); } |
gboolean ldm_device_has_attribute (LdmDevice *device
,LdmDeviceAttribute mask
);
Test whether this device has the given attribute(s) by testing the mask against our known attributes
C example:
1 2 3 |
if (ldm_device_has_attribute(device, LDM_DEVICE_ATTRIBUTE_BOOT_VGA)) { g_message("User booted with this GPU: %s", ldm_device_get_name(device)); } |
LdmDevice *
ldm_device_get_parent (LdmDevice *device
);
Get the parent device, if any
GList *
ldm_device_get_children (LdmDevice *device
);
Return any child devices, if any
Well known vendor IDs that are statically defined here to make future lookup and comparisons simpler to users of libldm.
Any device known to LDM may have one or more "types", defining the primary use-case for these devices. Simple devices will tend to have a single distinct type, such as "GPU". Composite devices, such as a USB camera, may have multiple types, such s HID|IMAGE.
As such - each LdmDevice stores a composite type which may be queried by the API.
Device type is either unknown or unhandled |
||
Audio device |
||
Bluetooth communication device |
||
A graphics device (onboard, NVIDIA, etc.) |
||
Human interface device (mouse, keyboard, etc.) |
||
Imaging device such as a camera |
||
The device is connected via PCI |
||
Printer |
||
Storage device |
||
Video device, perhaps a webcam |
||
A wireless device, i.e. dongle or mouse |
||
The device is connected via USB |
||
A device have one or more special attributes that need to be queried beyond the initial DeviceType search.
“attributes”
property“attributes” LdmDeviceAttribute
The composite attributes of this device, which is a bitwise combination of multiple attribute (such as BOOT_VGA)
Flags: Read
“device-type”
property“device-type” LdmDeviceType
The composite type of this device, which is a bitwise combination of multiple device types (such as PCI|GPU)
Flags: Read
“modalias”
property “modalias” gchar *
The modalias reported by the kernel for this device.
Flags: Read
Default value: NULL
“name”
property “name” gchar *
The name used to display this device to users, i.e. the model.
Flags: Read
Default value: NULL
“parent”
property “parent” gpointer
Parent device for this device instance
[transfer none]
Flags: Read / Write / Construct Only
“path”
property “path” gchar *
The system path for this device. On Linux this is the sysfs path.
Flags: Read
Default value: NULL
“priority”
property “priority” gint
Used to ensure stable device sorting.
Flags: Read / Write
Allowed values: [0,1000]
Default value: 0
Since: 1.0.2
“product-id”
property “product-id” gint
The product ID for this device.
Flags: Read
Allowed values: [0,0]
Default value: 0
“vendor”
property “vendor” gchar *
The vendor string to display the users, i.e. the manufacturer.
Flags: Read
Default value: NULL