drivers: Remove some uneeded 'ret' variables.
This commit is contained in:
parent
b4fde527b6
commit
a9010323dd
|
@ -151,7 +151,6 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Always available. */
|
/* Always available. */
|
||||||
if (key == SR_CONF_SCAN_OPTIONS) {
|
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||||
|
@ -169,8 +168,6 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
if (!sdi)
|
if (!sdi)
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
/* No channel group: global options. */
|
/* No channel group: global options. */
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -200,14 +197,13 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_get(uint32_t key, GVariant **data,
|
static int config_get(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
|
||||||
float fvalue;
|
float fvalue;
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
@ -223,7 +219,6 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
* - SR_CONF_ENABLED (state cannot be queried, only set)
|
* - SR_CONF_ENABLED (state cannot be queried, only set)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
|
@ -267,7 +262,7 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_set(uint32_t key, GVariant *data,
|
static int config_set(uint32_t key, GVariant *data,
|
||||||
|
|
|
@ -187,14 +187,13 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_channel *ch;
|
struct sr_channel *ch;
|
||||||
int channel, ret;
|
int channel;
|
||||||
|
|
||||||
if (!sdi)
|
if (!sdi)
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
/* No channel group: global options. */
|
/* No channel group: global options. */
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -233,7 +232,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_str(const char *str, const char **strings, int array_size)
|
static int find_str(const char *str, const char **strings, int array_size)
|
||||||
|
@ -338,7 +337,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
struct sr_channel *ch;
|
struct sr_channel *ch;
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int channel, ret, i;
|
int channel, i;
|
||||||
|
|
||||||
/* Always available. */
|
/* Always available. */
|
||||||
if (key == SR_CONF_SCAN_OPTIONS) {
|
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||||
|
@ -357,7 +356,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
ret = SR_OK;
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
/* No channel group: global options. */
|
/* No channel group: global options. */
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -413,7 +412,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_close(struct sr_dev_inst *sdi)
|
static int dev_close(struct sr_dev_inst *sdi)
|
||||||
|
|
|
@ -217,12 +217,11 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
uint32_t devopts_cg[MAX_DEVOPTS_CG];
|
uint32_t devopts_cg[MAX_DEVOPTS_CG];
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int ret, num_devopts_cg = 0;
|
int num_devopts_cg = 0;
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
|
@ -256,7 +255,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dev_acquisition_close(const struct sr_dev_inst *sdi)
|
static void dev_acquisition_close(const struct sr_dev_inst *sdi)
|
||||||
|
|
|
@ -242,14 +242,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
|
@ -275,7 +273,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get a sane timeout for poll() */
|
/* get a sane timeout for poll() */
|
||||||
|
|
|
@ -287,11 +287,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
GVariant *tuple, *range[2];
|
GVariant *tuple, *range[2];
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret;
|
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
if (!sdi) {
|
if (!sdi) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
|
@ -335,7 +333,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
|
|
|
@ -136,12 +136,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
|
@ -155,7 +152,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
|
static struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
|
||||||
|
|
|
@ -264,13 +264,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
struct analog_gen *ag;
|
struct analog_gen *ag;
|
||||||
struct sr_channel *ch;
|
struct sr_channel *ch;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
int logic_pattern, analog_pattern, ret;
|
int logic_pattern, analog_pattern;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const char *stropt;
|
const char *stropt;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
devc->cur_samplerate = g_variant_get_uint64(data);
|
devc->cur_samplerate = g_variant_get_uint64(data);
|
||||||
|
@ -346,10 +345,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
|
|
|
@ -323,7 +323,6 @@ static int dev_close(struct sr_dev_inst *sdi)
|
||||||
static int config_get(uint32_t key, GVariant **data,
|
static int config_get(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
char str[128];
|
char str[128];
|
||||||
|
@ -332,7 +331,6 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
*data = g_variant_new_uint64(devc->cur_samplerate);
|
*data = g_variant_new_uint64(devc->cur_samplerate);
|
||||||
|
@ -348,13 +346,12 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_set(uint32_t key, GVariant *data,
|
static int config_set(uint32_t key, GVariant *data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
|
|
||||||
|
@ -362,13 +359,11 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
value = g_variant_get_uint64(data);
|
value = g_variant_get_uint64(data);
|
||||||
/* TODO: Implement. */
|
/* TODO: Implement. */
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
break;
|
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
if (g_variant_get_uint64(data) == 0)
|
if (g_variant_get_uint64(data) == 0)
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
@ -381,23 +376,21 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
devc->cur_samplerate = value;
|
devc->cur_samplerate = value;
|
||||||
return ftdi_la_set_samplerate(devc);
|
return ftdi_la_set_samplerate(devc);
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_list(uint32_t key, GVariant **data,
|
static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
|
@ -418,7 +411,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
|
|
|
@ -338,7 +338,6 @@ static int dev_close(struct sr_dev_inst *sdi)
|
||||||
static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
@ -348,7 +347,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
|
@ -360,7 +358,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Implementation of config_list, auxiliary function for common parts. */
|
/** Implementation of config_list, auxiliary function for common parts. */
|
||||||
|
|
|
@ -393,11 +393,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
uint64_t p, q;
|
uint64_t p, q;
|
||||||
int tmp_int, ch_idx, ret;
|
int tmp_int, ch_idx;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const char *tmp_str;
|
const char *tmp_str;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -412,8 +411,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
devc->limit_samples = g_variant_get_uint64(data);
|
devc->limit_samples = g_variant_get_uint64(data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sdi->channel_groups->data == cg)
|
if (sdi->channel_groups->data == cg)
|
||||||
|
@ -436,7 +434,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
devc->voltage[ch_idx] = tmp_int;
|
devc->voltage[ch_idx] = tmp_int;
|
||||||
hantek_6xxx_update_vdiv(sdi);
|
hantek_6xxx_update_vdiv(sdi);
|
||||||
} else
|
} else
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_COUPLING:
|
case SR_CONF_COUPLING:
|
||||||
tmp_str = g_variant_get_string(data, NULL);
|
tmp_str = g_variant_get_string(data, NULL);
|
||||||
|
@ -447,15 +445,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == devc->coupling_tab_size)
|
if (i == devc->coupling_tab_size)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
|
|
|
@ -483,11 +483,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
double tmp_double;
|
double tmp_double;
|
||||||
uint64_t tmp_u64, p, q;
|
uint64_t tmp_u64, p, q;
|
||||||
int tmp_int, ch_idx, ret;
|
int tmp_int, ch_idx;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const char *tmp_str;
|
const char *tmp_str;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -505,7 +504,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
tmp_double = g_variant_get_double(data);
|
tmp_double = g_variant_get_double(data);
|
||||||
if (tmp_double < 0.0 || tmp_double > 1.0) {
|
if (tmp_double < 0.0 || tmp_double > 1.0) {
|
||||||
sr_err("Trigger position should be between 0.0 and 1.0.");
|
sr_err("Trigger position should be between 0.0 and 1.0.");
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
} else
|
} else
|
||||||
devc->triggerposition = tmp_double;
|
devc->triggerposition = tmp_double;
|
||||||
break;
|
break;
|
||||||
|
@ -518,7 +517,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == NUM_BUFFER_SIZES)
|
if (i == NUM_BUFFER_SIZES)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TIMEBASE:
|
case SR_CONF_TIMEBASE:
|
||||||
g_variant_get(data, "(tt)", &p, &q);
|
g_variant_get(data, "(tt)", &p, &q);
|
||||||
|
@ -532,7 +531,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
if (tmp_int >= 0)
|
if (tmp_int >= 0)
|
||||||
devc->timebase = tmp_int;
|
devc->timebase = tmp_int;
|
||||||
else
|
else
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_SOURCE:
|
case SR_CONF_TRIGGER_SOURCE:
|
||||||
tmp_str = g_variant_get_string(data, NULL);
|
tmp_str = g_variant_get_string(data, NULL);
|
||||||
|
@ -543,11 +542,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (trigger_sources[i] == 0)
|
if (trigger_sources[i] == 0)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sdi->channel_groups->data == cg)
|
if (sdi->channel_groups->data == cg)
|
||||||
|
@ -572,7 +570,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
if (tmp_int >= 0) {
|
if (tmp_int >= 0) {
|
||||||
devc->voltage[ch_idx] = tmp_int;
|
devc->voltage[ch_idx] = tmp_int;
|
||||||
} else
|
} else
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_COUPLING:
|
case SR_CONF_COUPLING:
|
||||||
tmp_str = g_variant_get_string(data, NULL);
|
tmp_str = g_variant_get_string(data, NULL);
|
||||||
|
@ -583,15 +581,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (coupling[i] == 0)
|
if (coupling[i] == 0)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
|
|
|
@ -225,14 +225,12 @@ static int dev_close(struct sr_dev_inst *sdi)
|
||||||
static int config_get(uint32_t key, GVariant **data,
|
static int config_get(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_ADC_POWERLINE_CYCLES:
|
case SR_CONF_ADC_POWERLINE_CYCLES:
|
||||||
*data = g_variant_new_double(devc->nplc);
|
*data = g_variant_new_double(devc->nplc);
|
||||||
|
@ -241,7 +239,7 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_set(uint32_t key, GVariant *data,
|
static int config_set(uint32_t key, GVariant *data,
|
||||||
|
@ -284,8 +282,6 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
static int config_list(uint32_t key, GVariant **data,
|
static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (key == SR_CONF_SCAN_OPTIONS) {
|
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
|
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
|
||||||
|
@ -309,13 +305,12 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
* plug-in cards.
|
* plug-in cards.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_channel_index_list(GSList *channels, GArray **arr)
|
static void create_channel_index_list(GSList *channels, GArray **arr)
|
||||||
|
|
|
@ -341,12 +341,11 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
{
|
{
|
||||||
struct dev_context *devc = sdi->priv;
|
struct dev_context *devc = sdi->priv;
|
||||||
struct parport *port;
|
struct parport *port;
|
||||||
int ret, i, ch = -1;
|
int i, ch = -1;
|
||||||
|
|
||||||
if (cg) /* sr_config_get will validate cg using config_list */
|
if (cg) /* sr_config_get will validate cg using config_list */
|
||||||
ch = ((struct sr_channel *)cg->channels->data)->index;
|
ch = ((struct sr_channel *)cg->channels->data)->index;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_CONN:
|
case SR_CONF_CONN:
|
||||||
port = sdi->conn;
|
port = sdi->conn;
|
||||||
|
@ -362,13 +361,13 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
i = reverse_map(devc->cctl[0] & 0xC0, trigger_sources_map,
|
i = reverse_map(devc->cctl[0] & 0xC0, trigger_sources_map,
|
||||||
ARRAY_SIZE(trigger_sources_map));
|
ARRAY_SIZE(trigger_sources_map));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR;
|
return SR_ERR;
|
||||||
else
|
else
|
||||||
*data = g_variant_new_string(trigger_sources[i]);
|
*data = g_variant_new_string(trigger_sources[i]);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_SLOPE:
|
case SR_CONF_TRIGGER_SLOPE:
|
||||||
if (devc->edge >= ARRAY_SIZE(trigger_slopes))
|
if (devc->edge >= ARRAY_SIZE(trigger_slopes))
|
||||||
ret = SR_ERR;
|
return SR_ERR;
|
||||||
else
|
else
|
||||||
*data = g_variant_new_string(trigger_slopes[devc->edge]);
|
*data = g_variant_new_string(trigger_slopes[devc->edge]);
|
||||||
break;
|
break;
|
||||||
|
@ -377,12 +376,12 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VDIV:
|
case SR_CONF_VDIV:
|
||||||
if (ch == -1) {
|
if (ch == -1) {
|
||||||
ret = SR_ERR_CHANNEL_GROUP;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
} else {
|
} else {
|
||||||
i = reverse_map(devc->cctl[ch] & 0x33, vdivs_map,
|
i = reverse_map(devc->cctl[ch] & 0x33, vdivs_map,
|
||||||
ARRAY_SIZE(vdivs_map));
|
ARRAY_SIZE(vdivs_map));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR;
|
return SR_ERR;
|
||||||
else
|
else
|
||||||
*data = g_variant_new("(tt)", vdivs[i][0],
|
*data = g_variant_new("(tt)", vdivs[i][0],
|
||||||
vdivs[i][1]);
|
vdivs[i][1]);
|
||||||
|
@ -390,40 +389,39 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
break;
|
break;
|
||||||
case SR_CONF_COUPLING:
|
case SR_CONF_COUPLING:
|
||||||
if (ch == -1) {
|
if (ch == -1) {
|
||||||
ret = SR_ERR_CHANNEL_GROUP;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
} else {
|
} else {
|
||||||
i = reverse_map(devc->cctl[ch] & 0x0C, coupling_map,
|
i = reverse_map(devc->cctl[ch] & 0x0C, coupling_map,
|
||||||
ARRAY_SIZE(coupling_map));
|
ARRAY_SIZE(coupling_map));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR;
|
return SR_ERR;
|
||||||
else
|
else
|
||||||
*data = g_variant_new_string(coupling[i]);
|
*data = g_variant_new_string(coupling[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_PROBE_FACTOR:
|
case SR_CONF_PROBE_FACTOR:
|
||||||
if (ch == -1)
|
if (ch == -1)
|
||||||
ret = SR_ERR_CHANNEL_GROUP;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
else
|
else
|
||||||
*data = g_variant_new_uint64(devc->probe[ch]);
|
*data = g_variant_new_uint64(devc->probe[ch]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
|
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc = sdi->priv;
|
struct dev_context *devc = sdi->priv;
|
||||||
int ret, i, ch = -1;
|
int i, ch = -1;
|
||||||
uint64_t u, v;
|
uint64_t u, v;
|
||||||
|
|
||||||
if (cg) /* sr_config_set will validate cg using config_list */
|
if (cg) /* sr_config_set will validate cg using config_list */
|
||||||
ch = ((struct sr_channel *)cg->channels->data)->index;
|
ch = ((struct sr_channel *)cg->channels->data)->index;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_LIMIT_FRAMES:
|
case SR_CONF_LIMIT_FRAMES:
|
||||||
devc->frame_limit = g_variant_get_uint64(data);
|
devc->frame_limit = g_variant_get_uint64(data);
|
||||||
|
@ -432,7 +430,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
||||||
samplerates, ARRAY_SIZE(samplerates));
|
samplerates, ARRAY_SIZE(samplerates));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
else
|
else
|
||||||
devc->rate = i;
|
devc->rate = i;
|
||||||
break;
|
break;
|
||||||
|
@ -440,7 +438,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||||
trigger_sources, ARRAY_SIZE(trigger_sources));
|
trigger_sources, ARRAY_SIZE(trigger_sources));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
else
|
else
|
||||||
devc->cctl[0] = (devc->cctl[0] & 0x3F)
|
devc->cctl[0] = (devc->cctl[0] & 0x3F)
|
||||||
| trigger_sources_map[i];
|
| trigger_sources_map[i];
|
||||||
|
@ -449,7 +447,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||||
trigger_slopes, ARRAY_SIZE(trigger_slopes));
|
trigger_slopes, ARRAY_SIZE(trigger_slopes));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
else
|
else
|
||||||
devc->edge = i;
|
devc->edge = i;
|
||||||
break;
|
break;
|
||||||
|
@ -457,22 +455,22 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
i = find_in_array(data, G_VARIANT_TYPE_UINT64,
|
||||||
buffersizes, ARRAY_SIZE(buffersizes));
|
buffersizes, ARRAY_SIZE(buffersizes));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
else
|
else
|
||||||
devc->last_step = i;
|
devc->last_step = i;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VDIV:
|
case SR_CONF_VDIV:
|
||||||
if (ch == -1) {
|
if (ch == -1) {
|
||||||
ret = SR_ERR_CHANNEL_GROUP;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
} else if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) {
|
} else if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) {
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
} else {
|
} else {
|
||||||
g_variant_get(data, "(tt)", &u, &v);
|
g_variant_get(data, "(tt)", &u, &v);
|
||||||
for (i = 0; i < (int)ARRAY_SIZE(vdivs); i++)
|
for (i = 0; i < (int)ARRAY_SIZE(vdivs); i++)
|
||||||
if (vdivs[i][0] == u && vdivs[i][1] == v)
|
if (vdivs[i][0] == u && vdivs[i][1] == v)
|
||||||
break;
|
break;
|
||||||
if (i == ARRAY_SIZE(vdivs))
|
if (i == ARRAY_SIZE(vdivs))
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
else
|
else
|
||||||
devc->cctl[ch] = (devc->cctl[ch] & 0xCC)
|
devc->cctl[ch] = (devc->cctl[ch] & 0xCC)
|
||||||
| vdivs_map[i];
|
| vdivs_map[i];
|
||||||
|
@ -480,12 +478,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
break;
|
break;
|
||||||
case SR_CONF_COUPLING:
|
case SR_CONF_COUPLING:
|
||||||
if (ch == -1) {
|
if (ch == -1) {
|
||||||
ret = SR_ERR_CHANNEL_GROUP;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
} else {
|
} else {
|
||||||
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
i = find_in_array(data, G_VARIANT_TYPE_STRING,
|
||||||
coupling, ARRAY_SIZE(coupling));
|
coupling, ARRAY_SIZE(coupling));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
else
|
else
|
||||||
devc->cctl[ch] = (devc->cctl[ch] & 0xF3)
|
devc->cctl[ch] = (devc->cctl[ch] & 0xF3)
|
||||||
| coupling_map[i];
|
| coupling_map[i];
|
||||||
|
@ -493,20 +491,20 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
break;
|
break;
|
||||||
case SR_CONF_PROBE_FACTOR:
|
case SR_CONF_PROBE_FACTOR:
|
||||||
if (ch == -1) {
|
if (ch == -1) {
|
||||||
ret = SR_ERR_CHANNEL_GROUP;
|
return SR_ERR_CHANNEL_GROUP;
|
||||||
} else {
|
} else {
|
||||||
u = g_variant_get_uint64(data);
|
u = g_variant_get_uint64(data);
|
||||||
if (!u)
|
if (!u)
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
else
|
else
|
||||||
devc->probe[ch] = u;
|
devc->probe[ch] = u;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_channel_set(const struct sr_dev_inst *sdi,
|
static int config_channel_set(const struct sr_dev_inst *sdi,
|
||||||
|
|
|
@ -303,12 +303,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
{
|
{
|
||||||
GVariant *gvar, *grange[2];
|
GVariant *gvar, *grange[2];
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int ret;
|
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
|
@ -336,7 +334,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
|
|
|
@ -253,13 +253,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
uint64_t p, q;
|
uint64_t p, q;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int tmp, ret;
|
int tmp;
|
||||||
const char *tmp_str;
|
const char *tmp_str;
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
devc->limit_samples = g_variant_get_uint64(data);
|
devc->limit_samples = g_variant_get_uint64(data);
|
||||||
|
@ -276,7 +275,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == ARRAY_SIZE(kecheng_kc_330b_sample_intervals))
|
if (i == ARRAY_SIZE(kecheng_kc_330b_sample_intervals))
|
||||||
ret = SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SPL_WEIGHT_FREQ:
|
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||||
tmp_str = g_variant_get_string(data, NULL);
|
tmp_str = g_variant_get_string(data, NULL);
|
||||||
|
@ -313,10 +312,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
devc->config_dirty = TRUE;
|
devc->config_dirty = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
|
|
|
@ -145,7 +145,6 @@ static int dev_close(struct sr_dev_inst *sdi)
|
||||||
static int config_get(uint32_t key, GVariant **data,
|
static int config_get(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
const struct scope_config *model;
|
const struct scope_config *model;
|
||||||
|
@ -156,7 +155,6 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_ERR_NA;
|
|
||||||
model = devc->model_config;
|
model = devc->model_config;
|
||||||
state = devc->model_state;
|
state = devc->model_state;
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
|
@ -164,20 +162,17 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_NUM_HDIV:
|
case SR_CONF_NUM_HDIV:
|
||||||
*data = g_variant_new_int32(model->num_xdivs);
|
*data = g_variant_new_int32(model->num_xdivs);
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TIMEBASE:
|
case SR_CONF_TIMEBASE:
|
||||||
*data = g_variant_new("(tt)",
|
*data = g_variant_new("(tt)",
|
||||||
model->timebases[state->timebase].p,
|
model->timebases[state->timebase].p,
|
||||||
model->timebases[state->timebase].q);
|
model->timebases[state->timebase].q);
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_NUM_VDIV:
|
case SR_CONF_NUM_VDIV:
|
||||||
for (i = 0; i < model->analog_channels; i++) {
|
for (i = 0; i < model->analog_channels; i++) {
|
||||||
if (cg != devc->analog_groups[i])
|
if (cg != devc->analog_groups[i])
|
||||||
continue;
|
continue;
|
||||||
*data = g_variant_new_int32(model->num_ydivs);
|
*data = g_variant_new_int32(model->num_ydivs);
|
||||||
ret = SR_OK;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VDIV:
|
case SR_CONF_VDIV:
|
||||||
|
@ -187,42 +182,35 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
*data = g_variant_new("(tt)",
|
*data = g_variant_new("(tt)",
|
||||||
model->vdivs[state->analog_channels[i].vdiv].p,
|
model->vdivs[state->analog_channels[i].vdiv].p,
|
||||||
model->vdivs[state->analog_channels[i].vdiv].q);
|
model->vdivs[state->analog_channels[i].vdiv].q);
|
||||||
ret = SR_OK;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_SOURCE:
|
case SR_CONF_TRIGGER_SOURCE:
|
||||||
*data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
|
*data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_SLOPE:
|
case SR_CONF_TRIGGER_SLOPE:
|
||||||
*data = g_variant_new_string((*model->trigger_slopes)[state->trigger_slope]);
|
*data = g_variant_new_string((*model->trigger_slopes)[state->trigger_slope]);
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_HORIZ_TRIGGERPOS:
|
case SR_CONF_HORIZ_TRIGGERPOS:
|
||||||
*data = g_variant_new_double(state->horiz_triggerpos);
|
*data = g_variant_new_double(state->horiz_triggerpos);
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_COUPLING:
|
case SR_CONF_COUPLING:
|
||||||
for (i = 0; i < model->analog_channels; i++) {
|
for (i = 0; i < model->analog_channels; i++) {
|
||||||
if (cg != devc->analog_groups[i])
|
if (cg != devc->analog_groups[i])
|
||||||
continue;
|
continue;
|
||||||
*data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
|
*data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
|
||||||
ret = SR_OK;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
*data = g_variant_new_uint64(state->sample_rate);
|
*data = g_variant_new_uint64(state->sample_rate);
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_ENABLED:
|
case SR_CONF_ENABLED:
|
||||||
*data = g_variant_new_boolean(FALSE);
|
*data = g_variant_new_boolean(FALSE);
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GVariant *build_tuples(const struct sr_rational *array, unsigned int n)
|
static GVariant *build_tuples(const struct sr_rational *array, unsigned int n)
|
||||||
|
|
|
@ -236,24 +236,21 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
ret = SR_OK;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
// FIXME
|
// FIXME
|
||||||
return mso_configure_rate(sdi, g_variant_get_uint64(data));
|
return mso_configure_rate(sdi, g_variant_get_uint64(data));
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
num_samples = g_variant_get_uint64(data);
|
num_samples = g_variant_get_uint64(data);
|
||||||
if (num_samples != 1024) {
|
if (num_samples != 1024) {
|
||||||
sr_err("Only 1024 samples are supported.");
|
sr_err("Only 1024 samples are supported.");
|
||||||
ret = SR_ERR_ARG;
|
ret = SR_ERR_ARG;
|
||||||
} else {
|
break;
|
||||||
devc->limit_samples = num_samples;
|
};
|
||||||
ret = SR_OK;
|
devc->limit_samples = num_samples;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_SLOPE:
|
case SR_CONF_TRIGGER_SLOPE:
|
||||||
slope = g_variant_get_string(data, NULL);
|
slope = g_variant_get_string(data, NULL);
|
||||||
|
@ -261,29 +258,25 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||||
if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
|
if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
|
||||||
sr_err("Invalid trigger slope");
|
sr_err("Invalid trigger slope");
|
||||||
ret = SR_ERR_ARG;
|
ret = SR_ERR_ARG;
|
||||||
} else {
|
break;
|
||||||
devc->trigger_slope = (slope[0] == 'r')
|
|
||||||
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
|
|
||||||
ret = SR_OK;
|
|
||||||
}
|
}
|
||||||
|
devc->trigger_slope = (slope[0] == 'r')
|
||||||
|
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_HORIZ_TRIGGERPOS:
|
case SR_CONF_HORIZ_TRIGGERPOS:
|
||||||
pos = g_variant_get_double(data);
|
pos = g_variant_get_double(data);
|
||||||
if (pos < 0 || pos > 255) {
|
if (pos < 0 || pos > 255) {
|
||||||
sr_err("Trigger position (%f) should be between 0 and 255.", pos);
|
sr_err("Trigger position (%f) should be between 0 and 255.", pos);
|
||||||
ret = SR_ERR_ARG;
|
ret = SR_ERR_ARG;
|
||||||
} else {
|
break;
|
||||||
trigger_pos = (int)pos;
|
|
||||||
devc->trigger_holdoff[0] = trigger_pos & 0xff;
|
|
||||||
ret = SR_OK;
|
|
||||||
}
|
}
|
||||||
|
trigger_pos = (int)pos;
|
||||||
|
devc->trigger_holdoff[0] = trigger_pos & 0xff;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_RLE:
|
case SR_CONF_RLE:
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
ret = SR_ERR_NA;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -361,7 +361,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Always available, even without sdi. */
|
/* Always available, even without sdi. */
|
||||||
if (key == SR_CONF_SCAN_OPTIONS) {
|
if (key == SR_CONF_SCAN_OPTIONS) {
|
||||||
|
@ -378,7 +377,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
/* No channel group: global options. */
|
/* No channel group: global options. */
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -416,7 +414,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
|
|
|
@ -215,11 +215,9 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
{
|
{
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_CONN:
|
case SR_CONF_CONN:
|
||||||
if (!sdi || !sdi->conn)
|
if (!sdi || !sdi->conn)
|
||||||
|
@ -237,29 +235,27 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_set(uint32_t key, GVariant *data,
|
static int config_set(uint32_t key, GVariant *data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
devc->dig_samplerate = g_variant_get_uint64(data);
|
devc->dig_samplerate = g_variant_get_uint64(data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_list(uint32_t key, GVariant **data,
|
static int config_list(uint32_t key, GVariant **data,
|
||||||
|
@ -267,12 +263,10 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
{
|
{
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int ret;
|
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
|
@ -298,7 +292,7 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dev_acquisition_abort(const struct sr_dev_inst *sdi)
|
static void dev_acquisition_abort(const struct sr_dev_inst *sdi)
|
||||||
|
|
|
@ -501,13 +501,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
{
|
{
|
||||||
GVariant *gvar, *range[2];
|
GVariant *gvar, *range[2];
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int ret;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
(void)sdi;
|
(void)sdi;
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_SCAN_OPTIONS:
|
case SR_CONF_SCAN_OPTIONS:
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
|
@ -543,7 +541,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void abort_acquisition(struct dev_context *devc)
|
static void abort_acquisition(struct dev_context *devc)
|
||||||
|
|
|
@ -517,7 +517,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
const struct channel_spec *ch_spec;
|
const struct channel_spec *ch_spec;
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
int ret, i;
|
int i;
|
||||||
const char *s[16];
|
const char *s[16];
|
||||||
|
|
||||||
/* Always available, even without sdi. */
|
/* Always available, even without sdi. */
|
||||||
|
@ -535,7 +535,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
ret = SR_OK;
|
|
||||||
if (!cg) {
|
if (!cg) {
|
||||||
/* No channel group: global options. */
|
/* No channel group: global options. */
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -616,7 +615,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
|
|
Loading…
Reference in New Issue