libsigrok
unreleased development snapshot
sigrok hardware access and backend library
|
Hardware driver handling in libsigrok. More...
Functions | |
struct sr_dev_driver ** | sr_driver_list (const struct sr_context *ctx) |
Return the list of supported hardware drivers. More... | |
int | sr_driver_init (struct sr_context *ctx, struct sr_dev_driver *driver) |
Initialize a hardware driver. More... | |
GArray * | sr_driver_scan_options_list (const struct sr_dev_driver *driver) |
Enumerate scan options supported by this driver. More... | |
GSList * | sr_driver_scan (struct sr_dev_driver *driver, GSList *options) |
Tell a hardware driver to scan for devices. More... | |
int | sr_config_get (const struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg, uint32_t key, GVariant **data) |
Query value of a configuration key at the given driver or device instance. More... | |
int | sr_config_set (const struct sr_dev_inst *sdi, const struct sr_channel_group *cg, uint32_t key, GVariant *data) |
Set value of a configuration key in a device instance. More... | |
int | sr_config_commit (const struct sr_dev_inst *sdi) |
Apply configuration settings to the device hardware. More... | |
int | sr_config_list (const struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg, uint32_t key, GVariant **data) |
List all possible values for a configuration key. More... | |
const struct sr_key_info * | sr_key_info_get (int keytype, uint32_t key) |
Get information about a key, by key. More... | |
const struct sr_key_info * | sr_key_info_name_get (int keytype, const char *keyid) |
Get information about a key, by name. More... | |
Hardware driver handling in libsigrok.
int sr_config_commit | ( | const struct sr_dev_inst * | sdi | ) |
Apply configuration settings to the device hardware.
sdi | The device instance. |
Definition at line 900 of file hwdriver.c.
References SR_ERR, SR_ERR_DEV_CLOSED, SR_OK, and SR_ST_ACTIVE.
Referenced by sr_session_dev_add(), and sr_session_start().
int sr_config_get | ( | const struct sr_dev_driver * | driver, |
const struct sr_dev_inst * | sdi, | ||
const struct sr_channel_group * | cg, | ||
uint32_t | key, | ||
GVariant ** | data | ||
) |
Query value of a configuration key at the given driver or device instance.
[in] | driver | The sr_dev_driver struct to query. Must not be NULL. |
[in] | sdi | (optional) If the key is specific to a device, this must contain a pointer to the struct sr_dev_inst to be checked. Otherwise it must be NULL. If sdi is != NULL, sdi->priv must also be != NULL. |
[in] | cg | The channel group on the device for which to list the values, or NULL. |
[in] | key | The configuration key (SR_CONF_*). |
[in,out] | data | Pointer to a GVariant where the value will be stored. Must not be NULL. The caller is given ownership of the GVariant and must thus decrease the refcount after use. However if this function returns an error code, the field should be considered unused, and should not be unreferenced. |
SR_OK | Success. |
SR_ERR | Error. |
SR_ERR_ARG | The driver doesn't know that key, but this is not to be interpreted as an error by the caller; merely as an indication that it's not applicable. |
Definition at line 804 of file hwdriver.c.
References sr_dev_driver::config_get, SR_CONF_GET, SR_ERR, SR_ERR_ARG, SR_ERR_CHANNEL_GROUP, and SR_OK.
int sr_config_list | ( | const struct sr_dev_driver * | driver, |
const struct sr_dev_inst * | sdi, | ||
const struct sr_channel_group * | cg, | ||
uint32_t | key, | ||
GVariant ** | data | ||
) |
List all possible values for a configuration key.
[in] | driver | The sr_dev_driver struct to query. Must not be NULL. |
[in] | sdi | (optional) If the key is specific to a device instance, this must contain a pointer to the struct sr_dev_inst to be checked. Otherwise it must be NULL. If sdi is != NULL, sdi->priv must also be != NULL. |
[in] | cg | The channel group on the device instance for which to list the values, or NULL. If this device instance doesn't have channel groups, this must not be != NULL. If cg is NULL, this function will return the "common" device instance options that are channel-group independent. Otherwise it will return the channel-group specific options. |
[in] | key | The configuration key (SR_CONF_*). |
[in,out] | data | A pointer to a GVariant where the list will be stored. The caller is given ownership of the GVariant and must thus unref the GVariant after use. However if this function returns an error code, the field should be considered unused, and should not be unreferenced. |
SR_OK | Success. |
SR_ERR | Error. |
SR_ERR_ARG | The driver doesn't know that key, but this is not to be interpreted as an error by the caller; merely as an indication that it's not applicable. |
Definition at line 947 of file hwdriver.c.
References sr_dev_driver::config_list, SR_CONF_LIST, SR_ERR, SR_ERR_ARG, SR_ERR_CHANNEL_GROUP, SR_KEY_CONFIG, SR_KEY_MQ, SR_KEY_MQFLAGS, and SR_OK.
Referenced by sr_driver_scan(), and sr_driver_scan_options_list().
int sr_config_set | ( | const struct sr_dev_inst * | sdi, |
const struct sr_channel_group * | cg, | ||
uint32_t | key, | ||
GVariant * | data | ||
) |
Set value of a configuration key in a device instance.
[in] | sdi | The device instance. Must not be NULL. sdi->driver and sdi->priv must not be NULL either. |
[in] | cg | The channel group on the device for which to list the values, or NULL. |
[in] | key | The configuration key (SR_CONF_*). |
data | The new value for the key, as a GVariant with GVariantType appropriate to that key. A floating reference can be passed in; its refcount will be sunk and unreferenced after use. |
SR_OK | Success. |
SR_ERR | Error. |
SR_ERR_ARG | The driver doesn't know that key, but this is not to be interpreted as an error by the caller; merely as an indication that it's not applicable. |
Definition at line 859 of file hwdriver.c.
References SR_CONF_SET, SR_ERR, SR_ERR_ARG, SR_ERR_CHANNEL_GROUP, SR_ERR_DEV_CLOSED, SR_OK, and SR_ST_ACTIVE.
Referenced by sr_session_load().
int sr_driver_init | ( | struct sr_context * | ctx, |
struct sr_dev_driver * | driver | ||
) |
Initialize a hardware driver.
This usually involves memory allocations and variable initializations within the driver, but not scanning for attached devices. The API call sr_driver_scan() is used for that.
ctx | A libsigrok context object allocated by a previous call to sr_init(). Must not be NULL. |
driver | The driver to initialize. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL. |
SR_OK | Success |
SR_ERR_ARG | Invalid parameter(s). |
SR_ERR_BUG | Internal errors. |
other | Another negative error code upon other errors. |
Definition at line 425 of file hwdriver.c.
References sr_dev_driver::init, and SR_ERR_ARG.
struct sr_dev_driver** sr_driver_list | ( | const struct sr_context * | ctx | ) |
Return the list of supported hardware drivers.
[in] | ctx | Pointer to a libsigrok context struct. Must not be NULL. |
NULL | The ctx argument was NULL, or there are no supported drivers. |
Other | Pointer to the NULL-terminated list of hardware drivers. The user should NOT g_free() this list, sr_exit() will do that. |
Definition at line 398 of file hwdriver.c.
Referenced by sr_buildinfo_scpi_backends_get(), sr_driver_scan(), and sr_exit().
GSList* sr_driver_scan | ( | struct sr_dev_driver * | driver, |
GSList * | options | ||
) |
Tell a hardware driver to scan for devices.
In addition to the detection, the devices that are found are also initialized automatically. On some devices, this involves a firmware upload, or other such measures.
The order in which the system is scanned for devices is not specified. The caller should not assume or rely on any specific order.
Before calling sr_driver_scan(), the user must have previously initialized the driver by calling sr_driver_init().
driver | The driver that should scan. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL. |
options | A list of 'struct sr_hwopt' options to pass to the driver's scanner. Can be NULL/empty. |
Definition at line 553 of file hwdriver.c.
References sr_dev_driver::cleanup, sr_dev_driver::context, sr_config::data, sr_key_info::id, sr_config::key, sr_channel_group::name, sr_dev_driver::name, sr_dev_driver::scan, SR_CONF_CAPTURE_RATIO, SR_CONF_GET, SR_CONF_LIMIT_MSEC, SR_CONF_LIMIT_SAMPLES, SR_CONF_SAMPLERATE, SR_CONF_SET, sr_config_list(), sr_driver_list(), SR_ERR_ARG, SR_ERR_DEV_CLOSED, SR_KEY_CONFIG, sr_key_info_get(), SR_OK, SR_PRIV, and SR_ST_ACTIVE.
GArray* sr_driver_scan_options_list | ( | const struct sr_dev_driver * | driver | ) |
Enumerate scan options supported by this driver.
Before calling sr_driver_scan_options_list(), the user must have previously initialized the driver by calling sr_driver_init().
driver | The driver to enumerate options for. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL. |
Definition at line 463 of file hwdriver.c.
References sr_config::data, sr_key_info::id, sr_config::key, sr_config_list(), SR_ERR, SR_ERR_ARG, SR_KEY_CONFIG, sr_key_info_get(), and SR_OK.
const struct sr_key_info* sr_key_info_get | ( | int | keytype, |
uint32_t | key | ||
) |
Get information about a key, by key.
[in] | keytype | The namespace the key is in. |
[in] | key | The key to find. |
Definition at line 1036 of file hwdriver.c.
References sr_key_info::key.
Referenced by sr_driver_scan(), and sr_driver_scan_options_list().
const struct sr_key_info* sr_key_info_name_get | ( | int | keytype, |
const char * | keyid | ||
) |
Get information about a key, by name.
[in] | keytype | The namespace the key is in. |
[in] | keyid | The key id string. |
Definition at line 1063 of file hwdriver.c.
References sr_key_info::key.