2 * This file is part of the sigrok project.
4 * Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libsigrok.h"
23 #include "libsigrok-internal.h"
26 SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info;
27 static struct sr_dev_driver *di = &tondaj_sl_814_driver_info;
29 /* Properly close and free all devices. */
30 static int clear_instances(void)
32 struct sr_dev_inst *sdi;
33 struct drv_context *drvc;
34 struct dev_context *devc;
37 if (!(drvc = di->priv))
40 for (l = drvc->instances; l; l = l->next) {
43 if (!(devc = sdi->priv))
48 sr_dev_inst_free(sdi);
51 g_slist_free(drvc->instances);
52 drvc->instances = NULL;
57 static int hw_init(void)
59 struct drv_context *drvc;
61 if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
62 sr_err("Driver context malloc failed.");
73 static GSList *hw_scan(GSList *options)
75 struct drv_context *drvc;
82 drvc->instances = NULL;
89 static GSList *hw_dev_list(void)
91 struct drv_context *drvc;
95 return drvc->instances;
98 static int hw_dev_open(struct sr_dev_inst *sdi)
105 static int hw_dev_close(struct sr_dev_inst *sdi)
112 static int hw_cleanup(void)
121 static int hw_info_get(int info_id, const void **data,
122 const struct sr_dev_inst *sdi)
127 sr_err("Unknown info_id: %d.", info_id);
134 static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
139 if (sdi->status != SR_ST_ACTIVE) {
140 sr_err("Device inactive, can't set config options.");
148 sr_err("Unknown hardware capability: %d.", hwcap);
155 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
163 static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
168 if (sdi->status != SR_ST_ACTIVE) {
169 sr_err("Device inactive, can't stop acquisition.");
178 SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = {
179 .name = "tondaj-sl-814",
180 .longname = "Tondaj SL-814",
183 .cleanup = hw_cleanup,
185 .dev_list = hw_dev_list,
186 .dev_clear = clear_instances,
187 .dev_open = hw_dev_open,
188 .dev_close = hw_dev_close,
189 .info_get = hw_info_get,
190 .dev_config_set = hw_dev_config_set,
191 .dev_acquisition_start = hw_dev_acquisition_start,
192 .dev_acquisition_stop = hw_dev_acquisition_stop,