X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Flink-mso19%2Fapi.c;h=98e253fee3e77593d7b6f44e447960d546f799c5;hb=dcd438ee3523098201c7937e75e55775da3b506f;hp=13c2972001a506627ea325f1c35467606d751a14;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index 13c29720..98e253fe 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -21,16 +21,16 @@ #include "protocol.h" -static const int32_t hwcaps[] = { +static const uint32_t devopts[] = { SR_CONF_OSCILLOSCOPE, SR_CONF_LOGIC_ANALYZER, - SR_CONF_SAMPLERATE, - SR_CONF_TRIGGER_TYPE, - SR_CONF_TRIGGER_SLOPE, - SR_CONF_HORIZ_TRIGGERPOS, -// SR_CONF_CAPTURE_RATIO, - SR_CONF_LIMIT_SAMPLES, -// SR_CONF_RLE, + SR_CONF_LIMIT_SAMPLES | SR_CONF_SET, + SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_TRIGGER_TYPE | SR_CONF_LIST, + SR_CONF_TRIGGER_SLOPE | SR_CONF_SET, + SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_SET, + SR_CONF_CAPTURE_RATIO | SR_CONF_SET, + SR_CONF_RLE | SR_CONF_SET, }; /* @@ -38,7 +38,7 @@ static const int32_t hwcaps[] = { * * See also: http://www.linkinstruments.com/images/mso19_1113.gif */ -SR_PRIV const char *mso19_channel_names[NUM_CHANNELS + 1] = { +SR_PRIV const char *mso19_channel_names[] = { /* Note: DSO needs to be first. */ "DSO", "0", "1", "2", "3", "4", "5", "6", "7", NULL, }; @@ -50,10 +50,9 @@ static const uint64_t samplerates[] = { }; SR_PRIV struct sr_dev_driver link_mso19_driver_info; -static struct sr_dev_driver *di = &link_mso19_driver_info; /* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */ -static int dev_clear(void) +static int dev_clear(const struct sr_dev_driver *di) { GSList *l; struct sr_dev_inst *sdi; @@ -88,12 +87,12 @@ static int dev_clear(void) return ret; } -static int init(struct sr_context *sr_ctx) +static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { return std_init(sr_ctx, di, LOG_PREFIX); } -static GSList *scan(GSList *options) +static GSList *scan(struct sr_dev_driver *di, GSList *options) { int i; GSList *devices = NULL; @@ -178,10 +177,7 @@ static GSList *scan(GSList *options) //Create the device context and set its params struct dev_context *devc; - if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) { - sr_err("Device context malloc failed."); - return devices; - } + devc = g_malloc0(sizeof(struct dev_context)); if (mso_parse_serial(iSerial, iProduct, devc) != SR_OK) { sr_err("Invalid iSerial: %s.", iSerial); @@ -198,13 +194,13 @@ static GSList *scan(GSList *options) devc->protocol_trigger.mask[i] = 0xff; } - if (!(devc->serial = sr_serial_dev_inst_new(conn, serialcomm))) { - g_free(devc); - return devices; - } + devc->serial = sr_serial_dev_inst_new(conn, serialcomm); - struct sr_dev_inst *sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, - manufacturer, product, hwrev); + struct sr_dev_inst *sdi = g_malloc0(sizeof(struct sr_dev_inst)); + sdi->status = SR_ST_INACTIVE; + sdi->vendor = g_strdup(manufacturer); + sdi->model = g_strdup(product); + sdi->version = g_strdup(hwrev); if (!sdi) { sr_err("Unable to create device instance for %s", @@ -218,12 +214,9 @@ static GSList *scan(GSList *options) sdi->priv = devc; for (i = 0; i < NUM_CHANNELS; i++) { - struct sr_channel *ch; chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC; - if (!(ch = sr_channel_new(i, chtype, TRUE, - mso19_channel_names[i]))) - return 0; - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, i, chtype, TRUE, + mso19_channel_names[i]); } //Add the driver @@ -235,7 +228,7 @@ static GSList *scan(GSList *options) return devices; } -static GSList *dev_list(void) +static GSList *dev_list(const struct sr_dev_driver *di) { return ((struct drv_context *)(di->priv))->instances; } @@ -271,7 +264,7 @@ static int dev_open(struct sr_dev_inst *sdi) return SR_OK; } -static int cleanup(void) +static int cleanup(const struct sr_dev_driver *di) { return dev_clear(); } @@ -327,8 +320,6 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, ret = SR_ERR_ARG; } else { devc->limit_samples = num_samples; - sr_dbg("setting limit_samples to %i\n", - num_samples); ret = SR_OK; } break; @@ -380,8 +371,8 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, switch (key) { 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}"));