2 * This file is part of the libsigrok project.
4 * Copyright (C) ${year} ${author} <${email}>
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 3 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, see <http://www.gnu.org/licenses/>.
21 #include "libsigrok.h"
22 #include "libsigrok-internal.h"
25 SR_PRIV struct sr_dev_driver ${lib}_driver_info;
26 static struct sr_dev_driver *di = &${lib}_driver_info;
28 /* Properly close and free all devices. */
29 static int clear_instances(void)
31 struct sr_dev_inst *sdi;
32 struct drv_context *drvc;
33 struct dev_context *devc;
36 if (!(drvc = di->priv))
39 for (l = drvc->instances; l; l = l->next) {
42 if (!(devc = sdi->priv))
47 sr_dev_inst_free(sdi);
50 g_slist_free(drvc->instances);
51 drvc->instances = NULL;
56 static int hw_init(struct sr_context *sr_ctx)
58 return std_hw_init(sr_ctx, di, DRIVER_LOG_DOMAIN);
61 static GSList *hw_scan(GSList *options)
63 struct drv_context *drvc;
70 drvc->instances = NULL;
77 static GSList *hw_dev_list(void)
79 struct drv_context *drvc;
83 return drvc->instances;
86 static int hw_dev_open(struct sr_dev_inst *sdi)
95 static int hw_dev_close(struct sr_dev_inst *sdi)
104 static int hw_cleanup(void)
113 static int hw_config_get(int id, const void **value,
114 const struct sr_dev_inst *sdi)
128 static int hw_config_set(int id, const void *value,
129 const struct sr_dev_inst *sdi)
135 if (sdi->status != SR_ST_ACTIVE) {
136 sr_err("Device inactive, can't set config options.");
144 sr_err("Unknown hardware capability: %d.", id);
151 static int hw_config_list(int key, const void **data,
152 const struct sr_dev_inst *sdi)
165 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
176 static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
180 if (sdi->status != SR_ST_ACTIVE) {
181 sr_err("Device inactive, can't stop acquisition.");
190 SR_PRIV struct sr_dev_driver ${lib}_driver_info = {
192 .longname = "${name}",
195 .cleanup = hw_cleanup,
197 .dev_list = hw_dev_list,
198 .dev_clear = clear_instances,
199 .config_get = hw_config_get,
200 .config_set = hw_config_set,
201 .config_list = hw_config_list,
202 .dev_open = hw_dev_open,
203 .dev_close = hw_dev_close,
204 .dev_acquisition_start = hw_dev_acquisition_start,
205 .dev_acquisition_stop = hw_dev_acquisition_stop,