drivers: rename and reorganize config get/set

The driver API calls info_get() and dev_config_set() have been renamed
to config_get() and config_set(), respectively.
This commit is contained in:
Bert Vermeulen 2013-01-24 19:19:09 +01:00
parent 69e19dd769
commit 035a1078fd
32 changed files with 171 additions and 212 deletions

View File

@ -173,12 +173,12 @@ static int sanity_check_all_drivers(void)
sr_err("No dev_close in driver %d ('%s').", i, d);
errors++;
}
if (!drivers[i]->info_get) {
sr_err("No info_get in driver %d ('%s').", i, d);
if (!drivers[i]->config_get) {
sr_err("No config_get in driver %d ('%s').", i, d);
errors++;
}
if (!drivers[i]->dev_config_set) {
sr_err("No dev_config_set in driver %d ('%s').", i, d);
if (!drivers[i]->config_set) {
sr_err("No config_set in driver %d ('%s').", i, d);
errors++;
}
if (!drivers[i]->dev_acquisition_start) {

View File

@ -198,7 +198,7 @@ SR_API gboolean sr_dev_has_hwcap(const struct sr_dev_inst *sdi, int hwcap)
if (!sdi || !sdi->driver)
return FALSE;
if (sdi->driver->info_get(SR_DI_HWCAPS,
if (sdi->driver->config_get(SR_DI_HWCAPS,
(const void **)&hwcaps, NULL) != SR_OK)
return FALSE;
@ -334,12 +334,12 @@ SR_API int sr_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
{
int ret;
if (!sdi || !sdi->driver || !sdi->driver->dev_config_set) {
if (!sdi || !sdi->driver || !sdi->driver->config_set) {
sr_err("Unable to set config option.");
return SR_ERR;
}
ret = sdi->driver->dev_config_set(sdi, hwcap, value);
ret = sdi->driver->config_set(hwcap, value, sdi);
return ret;
}

View File

@ -247,12 +247,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -266,8 +265,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -279,7 +277,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
return SR_ERR_BUG;
}
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_MSEC:
/* TODO: not yet implemented */
if (*(const uint64_t *)value == 0) {
@ -296,7 +294,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc->limit_samples);
break;
default:
sr_err("Unknown capability: %d.", hwcap);
sr_err("Unknown capability: %d.", id);
return SR_ERR;
break;
}
@ -370,10 +368,10 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -140,15 +140,14 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
if (info_id != SR_DI_HWCAPS) /* For SR_DI_HWCAPS sdi will be NULL. */
if (id != SR_DI_HWCAPS) /* For SR_DI_HWCAPS sdi will be NULL. */
devc = sdi->priv;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -169,14 +168,13 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
devc = sdi->priv;
switch (hwcap) {
switch (id) {
case SR_CONF_SAMPLERATE:
alsa_set_samplerate(sdi, *(const uint64_t *)value);
break;
@ -184,7 +182,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc->limit_samples = *(const uint64_t *)value;
break;
default:
sr_err("Unknown capability: %d.", hwcap);
sr_err("Unknown capability: %d.", id);
return SR_ERR;
}
@ -322,10 +320,10 @@ SR_PRIV struct sr_dev_driver alsa_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -787,12 +787,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -816,23 +815,22 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
int ret;
devc = sdi->priv;
if (hwcap == SR_CONF_SAMPLERATE) {
if (id == SR_CONF_SAMPLERATE) {
ret = set_samplerate(sdi, *(const uint64_t *)value);
} else if (hwcap == SR_CONF_LIMIT_MSEC) {
} else if (id == SR_CONF_LIMIT_MSEC) {
devc->limit_msec = *(const uint64_t *)value;
if (devc->limit_msec > 0)
ret = SR_OK;
else
ret = SR_ERR;
} else if (hwcap == SR_CONF_CAPTURE_RATIO) {
} else if (id == SR_CONF_CAPTURE_RATIO) {
devc->capture_ratio = *(const uint64_t *)value;
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
ret = SR_ERR;
@ -1438,10 +1436,10 @@ SR_PRIV struct sr_dev_driver asix_sigma_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -288,12 +288,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -323,8 +322,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -333,7 +331,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
return SR_ERR_BUG;
}
switch (hwcap) {
switch (id) {
case SR_CONF_SAMPLERATE:
if (set_samplerate(sdi, *(const uint64_t *)value) == SR_ERR) {
sr_err("%s: setting samplerate failed.", __func__);
@ -359,7 +357,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
break;
default:
/* Unknown capability, return SR_ERR. */
sr_err("%s: Unknown capability: %d.", __func__, hwcap);
sr_err("%s: Unknown capability: %d.", __func__, id);
return SR_ERR;
break;
}
@ -514,10 +512,10 @@ SR_PRIV struct sr_dev_driver chronovu_la8_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -191,12 +191,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -210,8 +209,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -223,7 +221,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
return SR_ERR_BUG;
}
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_MSEC:
/* TODO: not yet implemented */
if (*(const uint64_t *)value == 0) {
@ -240,7 +238,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc->limit_samples);
break;
default:
sr_err("Unknown capability: %d.", hwcap);
sr_err("Unknown capability: %d.", id);
return SR_ERR;
break;
}
@ -314,10 +312,10 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -226,12 +226,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -251,32 +250,31 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
int ret;
const char *stropt;
(void)sdi;
if (hwcap == SR_CONF_SAMPLERATE) {
if (id == SR_CONF_SAMPLERATE) {
cur_samplerate = *(const uint64_t *)value;
sr_dbg("%s: setting samplerate to %" PRIu64, __func__,
cur_samplerate);
ret = SR_OK;
} else if (hwcap == SR_CONF_LIMIT_SAMPLES) {
} else if (id == SR_CONF_LIMIT_SAMPLES) {
limit_msec = 0;
limit_samples = *(const uint64_t *)value;
sr_dbg("%s: setting limit_samples to %" PRIu64, __func__,
limit_samples);
ret = SR_OK;
} else if (hwcap == SR_CONF_LIMIT_MSEC) {
} else if (id == SR_CONF_LIMIT_MSEC) {
limit_msec = *(const uint64_t *)value;
limit_samples = 0;
sr_dbg("%s: setting limit_msec to %" PRIu64, __func__,
limit_msec);
ret = SR_OK;
} else if (hwcap == SR_CONF_PATTERN_MODE) {
} else if (id == SR_CONF_PATTERN_MODE) {
stropt = value;
ret = SR_OK;
if (!strcmp(stropt, "sigrok")) {
@ -490,10 +488,10 @@ SR_PRIV struct sr_dev_driver demo_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -281,12 +281,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -300,8 +299,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -313,7 +311,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
return SR_ERR_BUG;
}
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_MSEC:
/* TODO: not yet implemented */
if (*(const uint64_t *)value == 0) {
@ -330,7 +328,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc->limit_samples);
break;
default:
sr_err("Unknown capability: %d.", hwcap);
sr_err("Unknown capability: %d.", id);
return SR_ERR;
break;
}
@ -410,10 +408,10 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -127,8 +127,7 @@ static const struct sr_samplerates samplerates = {
SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
static struct sr_dev_driver *di = &fx2lafw_driver_info;
static int hw_dev_close(struct sr_dev_inst *sdi);
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value);
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi);
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
/**
@ -561,8 +560,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
if (devc->cur_samplerate == 0) {
/* Samplerate hasn't been set; default to the slowest one. */
if (hw_dev_config_set(sdi, SR_CONF_SAMPLERATE,
&supported_samplerates[0]) == SR_ERR)
if (config_set(SR_CONF_SAMPLERATE, &supported_samplerates[0],
sdi) == SR_ERR)
return SR_ERR;
}
@ -603,12 +602,11 @@ static int hw_cleanup(void)
return ret;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -632,18 +630,17 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
int ret;
devc = sdi->priv;
if (hwcap == SR_CONF_SAMPLERATE) {
if (id == SR_CONF_SAMPLERATE) {
devc->cur_samplerate = *(const uint64_t *)value;
ret = SR_OK;
} else if (hwcap == SR_CONF_LIMIT_SAMPLES) {
} else if (id == SR_CONF_LIMIT_SAMPLES) {
devc->limit_samples = *(const uint64_t *)value;
ret = SR_OK;
} else {
@ -1025,10 +1022,10 @@ SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -422,14 +422,13 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
uint64_t tmp;
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -462,8 +461,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_rational tmp_rat;
@ -477,7 +475,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
ret = SR_OK;
devc = sdi->priv;
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_FRAMES:
devc->limit_frames = *(const uint64_t *)value;
break;
@ -914,10 +912,10 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -213,12 +213,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -232,8 +231,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
int ret;
@ -249,14 +247,14 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc = sdi->priv;
ret = SR_OK;
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = *(const uint64_t *)value;
sr_dbg("Setting sample limit to %" PRIu64 ".",
devc->limit_samples);
break;
default:
sr_err("Unknown hardware capability: %d.", hwcap);
sr_err("Unknown hardware capability: %d.", id);
ret = SR_ERR_ARG;
}
@ -480,10 +478,10 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -298,12 +298,11 @@ static int hw_cleanup(void)
return ret;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -327,8 +326,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
int ret;
struct dev_context *devc;
@ -341,7 +339,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
switch (hwcap) {
switch (id) {
case SR_CONF_SAMPLERATE:
// FIXME
return mso_configure_rate(sdi, *(const uint64_t *)value);
@ -493,10 +491,10 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = hw_cleanup,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -265,14 +265,13 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
/* TODO */
(void)data;
(void)sdi;
switch (info_id) {
switch (id) {
default:
return SR_ERR_ARG;
}
@ -280,8 +279,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
int ret;
@ -294,10 +292,10 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
}
ret = SR_OK;
switch (hwcap) {
switch (id) {
default:
sr_err("Unknown hardware capability: %d.", hwcap);
sr_err("Unknown hardware capability: %d.", id);
ret = SR_ERR_ARG;
}
@ -337,10 +335,10 @@ SR_PRIV struct sr_dev_driver nexus_osciprime_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -250,12 +250,11 @@ static int hw_cleanup(void)
return ret;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -282,8 +281,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
int ret;
@ -294,7 +292,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
switch (hwcap) {
switch (id) {
case SR_CONF_SAMPLERATE:
ret = ols_set_samplerate(sdi, *(const uint64_t *)value,
&samplerates);
@ -504,10 +502,10 @@ SR_PRIV struct sr_dev_driver ols_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = hw_cleanup,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -324,12 +324,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -352,8 +351,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
uint64_t tmp_u64;
@ -370,7 +368,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
}
ret = SR_OK;
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_FRAMES:
devc->limit_frames = *(const uint64_t *)value;
break;
@ -433,7 +431,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
ret = SR_ERR_ARG;
break;
default:
sr_err("Unknown hardware capability: %d.", hwcap);
sr_err("Unknown hardware capability: %d.", id);
ret = SR_ERR_ARG;
break;
}
@ -509,10 +507,10 @@ SR_PRIV struct sr_dev_driver rigol_ds1xx2_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -373,12 +373,11 @@ static int hw_cleanup(int dmm)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -392,8 +391,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -405,7 +403,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
return SR_ERR_BUG;
}
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = *(const uint64_t *)value;
sr_dbg("Setting sample limit to %" PRIu64 ".",
@ -417,7 +415,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc->limit_msec);
break;
default:
sr_err("Unknown capability: %d.", hwcap);
sr_err("Unknown capability: %d.", id);
return SR_ERR;
break;
}
@ -522,10 +520,10 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
.scan = hw_scan_##ID_UPPER, \
.dev_list = hw_dev_list_##ID_UPPER, \
.dev_clear = clear_instances_##ID_UPPER, \
.config_get = config_get, \
.config_set = config_set, \
.dev_open = hw_dev_open, \
.dev_close = hw_dev_close, \
.info_get = hw_info_get, \
.dev_config_set = hw_dev_config_set, \
.dev_acquisition_start = hw_dev_acquisition_start_##ID_UPPER, \
.dev_acquisition_stop = hw_dev_acquisition_stop, \
.priv = NULL, \

View File

@ -195,12 +195,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -214,8 +213,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -226,14 +224,14 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc = sdi->priv;
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = *(const uint64_t *)value;
sr_dbg("Setting sample limit to %" PRIu64 ".",
devc->limit_samples);
break;
default:
sr_err("Unknown hardware capability: %d.", hwcap);
sr_err("Unknown hardware capability: %d.", id);
return SR_ERR_ARG;
}
@ -307,10 +305,10 @@ SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -186,14 +186,13 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
sr_spew("Backend requested info_id %d.", info_id);
sr_spew("Backend requested info_id %d.", id);
switch (info_id) {
switch (id) {
case SR_DI_HWOPTS:
*data = hwopts;
break;
@ -221,14 +220,13 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
devc = sdi->priv;
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_MSEC:
/* TODO: Not yet implemented. */
if (*(const uint64_t *)value == 0) {
@ -249,7 +247,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc->limit_samples);
break;
default:
sr_err("Unknown capability: %d.", hwcap);
sr_err("Unknown capability: %d.", id);
return SR_ERR;
break;
}
@ -317,10 +315,10 @@ SR_PRIV struct sr_dev_driver uni_t_ut61d_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,
@ -335,10 +333,10 @@ SR_PRIV struct sr_dev_driver voltcraft_vc820_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -244,12 +244,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -260,8 +259,7 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
gint64 now;
@ -279,7 +277,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc = sdi->priv;
ret = SR_OK;
switch (hwcap) {
switch (id) {
case SR_CONF_LIMIT_MSEC:
devc->limit_msec = *(const int64_t *)value;
now = g_get_monotonic_time() / 1000;
@ -293,7 +291,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
devc->limit_samples);
break;
default:
sr_err("Unknown hardware capability: %d.", hwcap);
sr_err("Unknown hardware capability: %d.", id);
ret = SR_ERR_ARG;
}
@ -466,10 +464,10 @@ SR_PRIV struct sr_dev_driver victor_dmm_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = clear_instances,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -529,12 +529,11 @@ static int hw_cleanup(void)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -624,8 +623,7 @@ static int set_capture_ratio(struct dev_context *devc, uint64_t ratio)
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -639,7 +637,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
return SR_ERR_ARG;
}
switch (hwcap) {
switch (id) {
case SR_CONF_SAMPLERATE:
return set_samplerate(devc, *(const uint64_t *)value);
case SR_CONF_LIMIT_SAMPLES:
@ -787,10 +785,10 @@ SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
.scan = hw_scan,
.dev_list = hw_dev_list,
.dev_clear = hw_cleanup,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,
.priv = NULL,

View File

@ -324,7 +324,7 @@ SR_API int sr_info_get(struct sr_dev_driver *driver, int id,
if (driver == NULL || data == NULL)
return SR_ERR;
ret = driver->info_get(id, data, sdi);
ret = driver->config_get(id, data, sdi);
return ret;
}
@ -349,7 +349,7 @@ SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap)
return FALSE;
}
if (driver->info_get(SR_DI_HWCAPS, (const void **)&hwcaps, NULL) != SR_OK)
if (driver->config_get(SR_DI_HWCAPS, (const void **)&hwcaps, NULL) != SR_OK)
return FALSE;
for (i = 0; hwcaps[i]; i++) {

View File

@ -595,14 +595,14 @@ struct sr_dev_driver {
GSList *(*scan) (GSList *options);
GSList *(*dev_list) (void);
int (*dev_clear) (void);
int (*config_get) (int id, const void **value,
const struct sr_dev_inst *sdi);
int (*config_set) (int id, const void *value,
const struct sr_dev_inst *sdi);
/* Device-specific */
int (*dev_open) (struct sr_dev_inst *sdi);
int (*dev_close) (struct sr_dev_inst *sdi);
int (*info_get) (int info_id, const void **data,
const struct sr_dev_inst *sdi);
int (*dev_config_set) (const struct sr_dev_inst *sdi, int hwcap,
const void *value);
int (*dev_acquisition_start) (const struct sr_dev_inst *sdi,
void *cb_data);
int (*dev_acquisition_stop) (struct sr_dev_inst *sdi,

View File

@ -129,7 +129,7 @@ static int init(struct sr_output *o)
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
if (sr_dev_has_hwcap(o->sdi, SR_CONF_SAMPLERATE)) {
o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
o->sdi->driver->config_get(SR_DI_CUR_SAMPLERATE,
(const void **)&samplerate, o->sdi);
ctx->samplerate = *samplerate;
} else

View File

@ -100,7 +100,7 @@ static int init(struct sr_output *o)
num_probes = g_slist_length(o->sdi->probes);
if (sr_dev_has_hwcap(o->sdi, SR_CONF_SAMPLERATE)) {
o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
o->sdi->driver->config_get(SR_DI_CUR_SAMPLERATE,
(const void **)&samplerate, o->sdi);
ctx->samplerate = *samplerate;
} else

View File

@ -110,7 +110,7 @@ static int init(struct sr_output *o)
num_probes = g_slist_length(o->sdi->probes);
comment[0] = '\0';
if (sr_dev_has_hwcap(o->sdi, SR_CONF_SAMPLERATE)) {
o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
o->sdi->driver->config_get(SR_DI_CUR_SAMPLERATE,
(const void **)&samplerate, o->sdi);
if (!(frequency_s = sr_samplerate_string(*samplerate))) {
sr_err("%s: sr_samplerate_string failed", __func__);

View File

@ -70,7 +70,7 @@ static int init(struct sr_output *o)
ctx->unitsize = (num_enabled_probes + 7) / 8;
if (o->sdi->driver && sr_dev_has_hwcap(o->sdi, SR_CONF_SAMPLERATE))
o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
o->sdi->driver->config_get(SR_DI_CUR_SAMPLERATE,
(const void **)&samplerate, o->sdi);
else {
tmp = 0;

View File

@ -124,7 +124,7 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
num_probes = g_slist_length(o->sdi->probes);
if (o->sdi->driver || sr_dev_has_hwcap(o->sdi, SR_CONF_SAMPLERATE)) {
ret = o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
ret = o->sdi->driver->config_get(SR_DI_CUR_SAMPLERATE,
(const void **)&samplerate, o->sdi);
if (ret != SR_OK)
goto err;

View File

@ -95,7 +95,7 @@ static int init(struct sr_output *o)
PACKAGE, PACKAGE_VERSION);
if (o->sdi->driver && sr_dev_has_hwcap(o->sdi, SR_CONF_SAMPLERATE)) {
o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
o->sdi->driver->config_get(SR_DI_CUR_SAMPLERATE,
(const void **)&samplerate, o->sdi);
ctx->samplerate = *samplerate;
if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {

View File

@ -148,12 +148,11 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
return SR_OK;
}
static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
{
struct session_vdev *vdev;
switch (info_id) {
switch (id) {
case SR_DI_HWCAPS:
*data = hwcaps;
break;
@ -171,15 +170,14 @@ static int hw_info_get(int info_id, const void **data,
return SR_OK;
}
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value)
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
{
struct session_vdev *vdev;
const uint64_t *tmp_u64;
vdev = sdi->priv;
switch (hwcap) {
switch (id) {
case SR_CONF_SAMPLERATE:
tmp_u64 = value;
vdev->samplerate = *tmp_u64;
@ -202,7 +200,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
vdev->num_probes = *tmp_u64;
break;
default:
sr_err("Unknown capability: %d.", hwcap);
sr_err("Unknown capability: %d.", id);
return SR_ERR;
}
@ -274,10 +272,10 @@ SR_PRIV struct sr_dev_driver session_driver = {
.api_version = 1,
.init = hw_init,
.cleanup = hw_cleanup,
.config_get = config_get,
.config_set = config_set,
.dev_open = hw_dev_open,
.dev_close = NULL,
.info_get = hw_info_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = NULL,
};

View File

@ -146,18 +146,18 @@ SR_API int sr_session_load(const char *filename)
/* first device, init the driver */
sdi->driver->init(NULL);
sr_session_dev_add(sdi);
sdi->driver->dev_config_set(sdi, SR_CONF_SESSIONFILE, filename);
sdi->driver->dev_config_set(sdi, SR_CONF_CAPTUREFILE, val);
sdi->driver->config_set(SR_CONF_SESSIONFILE, filename, sdi);
sdi->driver->config_set(SR_CONF_CAPTUREFILE, val, sdi);
g_ptr_array_add(capturefiles, val);
} else if (!strcmp(keys[j], "samplerate")) {
sr_parse_sizestring(val, &tmp_u64);
sdi->driver->dev_config_set(sdi, SR_CONF_SAMPLERATE, &tmp_u64);
sdi->driver->config_set(SR_CONF_SAMPLERATE, &tmp_u64, sdi);
} else if (!strcmp(keys[j], "unitsize")) {
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->dev_config_set(sdi, SR_CONF_CAPTURE_UNITSIZE, &tmp_u64);
sdi->driver->config_set(SR_CONF_CAPTURE_UNITSIZE, &tmp_u64, sdi);
} else if (!strcmp(keys[j], "total probes")) {
total_probes = strtoull(val, NULL, 10);
sdi->driver->dev_config_set(sdi, SR_CONF_CAPTURE_NUM_PROBES, &total_probes);
sdi->driver->config_set(SR_CONF_CAPTURE_NUM_PROBES, &total_probes, sdi);
for (p = 0; p < total_probes; p++) {
snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p);
if (!(probe = sr_probe_new(p, SR_PROBE_LOGIC, TRUE,

View File

@ -230,7 +230,7 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
return NULL;
}
if (sdi->driver->info_get(SR_DI_TRIGGER_TYPES,
if (sdi->driver->config_get(SR_DI_TRIGGER_TYPES,
(const void **)&trigger_types, sdi) != SR_OK) {
sr_err("%s: Device doesn't support any triggers.", __func__);
return NULL;