2 * This file is part of the sigrok 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"
27 SR_PRIV struct sr_dev_driver driver_info;
28 static struct sr_dev_driver *di = &${lib}_driver_info;
31 /* Properly close and free all devices. */
32 static int clear_instances(void)
34 struct sr_dev_inst *sdi;
35 struct drv_context *drvc;
36 struct dev_context *devc;
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("${short}: driver context malloc failed.");
73 static GSList *hw_scan(GSList *options)
75 struct drv_context *drvc;
81 drvc->instances = NULL;
88 static GSList *hw_dev_list(void)
90 struct drv_context *drvc;
94 return drvc->instances;
97 static int hw_dev_open(struct sr_dev_inst *sdi)
105 static int hw_dev_close(struct sr_dev_inst *sdi)
113 static int hw_cleanup(void)
123 static int hw_info_get(int info_id, const void **data,
124 const struct sr_dev_inst *sdi)
137 static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
142 if (sdi->status != SR_ST_ACTIVE)
155 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
164 static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
170 if (sdi->status != SR_ST_ACTIVE)
178 SR_PRIV struct sr_dev_driver ${lib}_driver_info = {
180 .longname = "${name}",
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,