]> sigrok.org Git - libsigrok.git/blobdiff - hardware/hantek-dso/api.c
hantek-dso: minor fixes
[libsigrok.git] / hardware / hantek-dso / api.c
index 7c2eaa954f00471e223dfac021be341f22468d90..e648fa4e639cf8433d8ca79427ba0656decddc49 100644 (file)
@@ -37,9 +37,9 @@
 /* TODO tune this properly */
 #define TICK 1
 
-static const int hwcaps[] = {
+static const int devopts[] = {
        SR_CONF_OSCILLOSCOPE,
-       SR_CONF_LIMIT_SAMPLES,
+       SR_CONF_LIMIT_FRAMES,
        SR_CONF_CONTINUOUS,
        SR_CONF_TIMEBASE,
        SR_CONF_BUFFERSIZE,
@@ -259,17 +259,7 @@ static int clear_instances(void)
 
 static int hw_init(struct sr_context *sr_ctx)
 {
-       struct drv_context *drvc;
-
-       if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
-               sr_err("Driver context malloc failed.");
-               return SR_ERR_MALLOC;
-       }
-
-       drvc->sr_ctx = sr_ctx;
-       di->priv = drvc;
-
-       return SR_OK;
+       return std_hw_init(sr_ctx, di, DRIVER_LOG_DOMAIN);
 }
 
 static GSList *hw_scan(GSList *options)
@@ -285,11 +275,12 @@ static GSList *hw_scan(GSList *options)
 
        (void)options;
 
-       devcnt = 0;
-       devices = 0;
        drvc = di->priv;
        drvc->instances = NULL;
 
+       devcnt = 0;
+       devices = 0;
+
        clear_instances();
 
        /* Find all Hantek DSO devices and upload firmware to all of them. */
@@ -350,11 +341,7 @@ static GSList *hw_scan(GSList *options)
 
 static GSList *hw_dev_list(void)
 {
-       struct drv_context *drvc;
-
-       drvc = di->priv;
-
-       return drvc->instances;
+       return ((struct drv_context *)(di->priv))->instances;
 }
 
 static int hw_dev_open(struct sr_dev_inst *sdi)
@@ -548,7 +535,7 @@ static int config_list(int key, const void **data, const struct sr_dev_inst *sdi
 
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
-               *data = hwcaps;
+               *data = devopts;
                break;
        case SR_CONF_BUFFERSIZE:
                *data = buffersizes;
@@ -843,8 +830,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
                                    void *cb_data)
 {
        const struct libusb_pollfd **lupfd;
-       struct sr_datafeed_packet packet;
-       struct sr_datafeed_header header;
        struct dev_context *devc;
        struct drv_context *drvc = di->priv;
        int i;
@@ -874,11 +859,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
        free(lupfd);
 
        /* Send header packet to the session bus. */
-       packet.type = SR_DF_HEADER;
-       packet.payload = (unsigned char *)&header;
-       header.feed_version = 1;
-       gettimeofday(&header.starttime, NULL);
-       sr_session_send(cb_data, &packet);
+       std_session_send_df_header(cb_data, DRIVER_LOG_DOMAIN);
 
        return SR_OK;
 }
@@ -907,6 +888,7 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
        .scan = hw_scan,
        .dev_list = hw_dev_list,
        .dev_clear = clear_instances,
+       .config_get = NULL,
        .config_set = config_set,
        .config_list = config_list,
        .dev_open = hw_dev_open,