X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ffx2lafw%2Fapi.c;h=18a34df659ab5daed4fe71b1529a1a81b27ceab4;hb=50276118ca45dc3dbf91f2fc77fc1f611cf1e57d;hp=3242afcead486cb01dc4a7490d37101f6f4a4871;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 3242afce..18a34df6 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -73,18 +73,17 @@ static const struct fx2lafw_profile supported_fx2[] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; -static const int32_t hwopts[] = { +static const uint32_t scanopts[] = { SR_CONF_CONN, }; -static const int32_t hwcaps[] = { +static const uint32_t devopts[] = { SR_CONF_LOGIC_ANALYZER, - SR_CONF_TRIGGER_MATCH, - SR_CONF_SAMPLERATE, - - /* These are really implemented in the driver, not the hardware. */ - SR_CONF_LIMIT_SAMPLES, SR_CONF_CONTINUOUS, + SR_CONF_CONN | SR_CONF_GET, + SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_TRIGGER_MATCH | SR_CONF_LIST, }; static const char *channel_names[] = { @@ -385,7 +384,7 @@ static int cleanup(void) return ret; } -static int config_get(int id, 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) { struct dev_context *devc; @@ -399,7 +398,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, devc = sdi->priv; - switch (id) { + switch (key) { case SR_CONF_CONN: if (!sdi->conn) return SR_ERR_ARG; @@ -424,10 +423,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, return SR_OK; } -static int config_set(int id, 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) { struct dev_context *devc; + uint64_t arg; + unsigned int i; int ret; (void)cg; @@ -442,10 +443,17 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, ret = SR_OK; - switch (id) - { + switch (key) { case SR_CONF_SAMPLERATE: - devc->cur_samplerate = g_variant_get_uint64(data); + arg = g_variant_get_uint64(data); + for (i = 0; i < ARRAY_SIZE(samplerates); i++) { + if (samplerates[i] == arg) { + devc->cur_samplerate = arg; + break; + } + } + if (i == ARRAY_SIZE(samplerates)) + ret = SR_ERR_ARG; break; case SR_CONF_LIMIT_SAMPLES: devc->limit_samples = g_variant_get_uint64(data); @@ -457,7 +465,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, return ret; } -static int config_list(int 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) { GVariant *gvar; @@ -468,12 +476,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, switch (key) { case SR_CONF_SCAN_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, - hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t)); + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); break; case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, - hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); break; case SR_CONF_SAMPLERATE: g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));