libsigrok  0.4.0
sigrok hardware access and backend library
Functions
Hardware drivers

Hardware driver handling in libsigrok. More...

Functions

SR_PRIV const GVariantType * sr_variant_type_get (int datatype)
 
SR_PRIV int sr_variant_type_check (uint32_t key, GVariant *value)
 
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_infosr_key_info_get (int keytype, uint32_t key)
 Get information about a key, by key. More...
 
const struct sr_key_infosr_key_info_name_get (int keytype, const char *keyid)
 Get information about a key, by name. More...
 

Detailed Description

Hardware driver handling in libsigrok.

Function Documentation

int sr_config_commit ( const struct sr_dev_inst *  sdi)

Apply configuration settings to the device hardware.

Parameters
sdiThe device instance.
Returns
SR_OK upon success or SR_ERR in case of error.
Since
0.3.0

Definition at line 764 of file hwdriver.c.

References SR_ERR, and SR_OK.

Referenced by sr_session_dev_add(), and sr_session_start().

+ Here is the caller graph for this function:

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.

Parameters
[in]driverThe sr_dev_driver struct to query.
[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.
[in]cgThe channel group on the device for which to list the values, or NULL.
[in]keyThe configuration key (SR_CONF_*).
[in,out]dataPointer 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.
Return values
SR_OKSuccess.
SR_ERRError.
SR_ERR_ARGThe 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.
Since
0.3.0

Definition at line 686 of file hwdriver.c.

References sr_dev_driver::config_get, SR_CONF_GET, SR_ERR, SR_ERR_ARG, 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.

Parameters
[in]driverThe sr_dev_driver struct to query.
[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.
[in]cgThe channel group on the device for which to list the values, or NULL.
[in]keyThe configuration key (SR_CONF_*).
[in,out]dataA 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.
Return values
SR_OKSuccess.
SR_ERRError.
SR_ERR_ARGThe 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.
Since
0.3.0

Definition at line 801 of file hwdriver.c.

References sr_dev_driver::config_list, SR_CONF_LIST, SR_ERR, SR_ERR_ARG, and SR_OK.

Referenced by sr_driver_scan_options_list().

+ Here is the caller graph for this function:

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.

Parameters
[in]sdiThe device instance.
[in]cgThe channel group on the device for which to list the values, or NULL.
[in]keyThe configuration key (SR_CONF_*).
dataThe 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.
Return values
SR_OKSuccess.
SR_ERRError.
SR_ERR_ARGThe 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.
Since
0.3.0

Definition at line 731 of file hwdriver.c.

References SR_CONF_SET, SR_ERR, SR_ERR_ARG, SR_OK, and sr_variant_type_check().

Referenced by sr_session_load().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
ctxA libsigrok context object allocated by a previous call to sr_init(). Must not be NULL.
driverThe driver to initialize. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL.
Return values
SR_OKSuccess
SR_ERR_ARGInvalid parameter(s).
SR_ERR_BUGInternal errors.
otherAnother negative error code upon other errors.
Since
0.2.0

Definition at line 370 of file hwdriver.c.

References sr_dev_driver::init, sr_dev_driver::name, and SR_ERR_ARG.

struct sr_dev_driver** sr_driver_list ( const struct sr_context ctx)

Return the list of supported hardware drivers.

Parameters
[in]ctxPointer to a libsigrok context struct. Must not be NULL.
Return values
NULLThe ctx argument was NULL, or there are no supported drivers.
OtherPointer to the NULL-terminated list of hardware drivers. The user should NOT g_free() this list, sr_exit() will do that.
Since
0.4.0

Definition at line 343 of file hwdriver.c.

Referenced by sr_exit().

+ Here is the caller graph for this function:

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().

Parameters
driverThe driver that should scan. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL.
optionsA list of 'struct sr_hwopt' options to pass to the driver's scanner. Can be NULL/empty.
Returns
A GSList * of 'struct sr_dev_inst', or NULL if no devices were found (or errors were encountered). This list must be freed by the caller using g_slist_free(), but without freeing the data pointed to in the list.
Since
0.2.0

Definition at line 497 of file hwdriver.c.

References sr_dev_driver::context, sr_dev_driver::name, sr_dev_driver::scan, and SR_OK.

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().

Parameters
driverThe driver to enumerate options for. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL.
Returns
A GArray * of uint32_t entries, or NULL on invalid arguments. Each entry is a configuration key that is supported as a scan option. The array must be freed by the caller using g_array_free().
Since
0.4.0

Definition at line 407 of file hwdriver.c.

References sr_config_list(), and SR_OK.

+ Here is the call graph for this function:

const struct sr_key_info* sr_key_info_get ( int  keytype,
uint32_t  key 
)

Get information about a key, by key.

Parameters
[in]keytypeThe namespace the key is in.
[in]keyThe key to find.
Returns
A pointer to a struct sr_key_info, or NULL if the key was not found.
Since
0.3.0

Definition at line 857 of file hwdriver.c.

References sr_key_info::key.

Referenced by sr_variant_type_check().

+ Here is the caller graph for this function:

const struct sr_key_info* sr_key_info_name_get ( int  keytype,
const char *  keyid 
)

Get information about a key, by name.

Parameters
[in]keytypeThe namespace the key is in.
[in]keyidThe key id string.
Returns
A pointer to a struct sr_key_info, or NULL if the key was not found.
Since
0.2.0

Definition at line 884 of file hwdriver.c.

References sr_key_info::key.

SR_PRIV int sr_variant_type_check ( uint32_t  key,
GVariant *  value 
)

Definition at line 306 of file hwdriver.c.

References sr_key_info::datatype, sr_key_info::name, SR_ERR_ARG, SR_KEY_CONFIG, sr_key_info_get(), SR_OK, and sr_variant_type_get().

Referenced by sr_config_set().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SR_PRIV const GVariantType* sr_variant_type_get ( int  datatype)

Definition at line 279 of file hwdriver.c.

References SR_T_BOOL, SR_T_DOUBLE_RANGE, SR_T_FLOAT, SR_T_INT32, SR_T_KEYVALUE, SR_T_MQ, SR_T_RATIONAL_PERIOD, SR_T_RATIONAL_VOLT, SR_T_STRING, SR_T_UINT64, and SR_T_UINT64_RANGE.

Referenced by sr_variant_type_check().

+ Here is the caller graph for this function: