sigrok-cross-mingw: group and sort libusb1 patches for MXE
[sigrok-util.git] / source / drv-api.c
blob6a1c20c70b8328a7fa2fcb7e6a1cdc237dc78562
1 /*
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/>.
20 #include <config.h>
21 #include "protocol.h"
23 static struct sr_dev_driver {lib}_driver_info;
25 static GSList *scan(struct sr_dev_driver *di, GSList *options)
27 struct drv_context *drvc;
28 GSList *devices;
30 (void)options;
32 devices = NULL;
33 drvc = di->context;
34 drvc->instances = NULL;
36 /* TODO: scan for devices, either based on a SR_CONF_CONN option
37 * or on a USB scan. */
39 return devices;
42 static int dev_open(struct sr_dev_inst *sdi)
44 (void)sdi;
46 /* TODO: get handle from sdi->conn and open it. */
48 return SR_OK;
51 static int dev_close(struct sr_dev_inst *sdi)
53 (void)sdi;
55 /* TODO: get handle from sdi->conn and close it. */
57 return SR_OK;
60 static int config_get(uint32_t key, GVariant **data,
61 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
63 int ret;
65 (void)sdi;
66 (void)data;
67 (void)cg;
69 ret = SR_OK;
70 switch (key) {{
71 /* TODO */
72 default:
73 return SR_ERR_NA;
76 return ret;
79 static int config_set(uint32_t key, GVariant *data,
80 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
82 int ret;
84 (void)sdi;
85 (void)data;
86 (void)cg;
88 ret = SR_OK;
89 switch (key) {{
90 /* TODO */
91 default:
92 ret = SR_ERR_NA;
95 return ret;
98 static int config_list(uint32_t key, GVariant **data,
99 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
101 int ret;
103 (void)sdi;
104 (void)data;
105 (void)cg;
107 ret = SR_OK;
108 switch (key) {{
109 /* TODO */
110 default:
111 return SR_ERR_NA;
114 return ret;
117 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
119 /* TODO: configure hardware, reset acquisition state, set up
120 * callbacks and send header packet. */
122 (void)sdi;
124 return SR_OK;
127 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
129 /* TODO: stop acquisition. */
131 (void)sdi;
133 return SR_OK;
136 static struct sr_dev_driver {lib}_driver_info = {{
137 .name = "{short}",
138 .longname = "{name}",
139 .api_version = 1,
140 .init = std_init,
141 .cleanup = std_cleanup,
142 .scan = scan,
143 .dev_list = std_dev_list,
144 .dev_clear = std_dev_clear,
145 .config_get = config_get,
146 .config_set = config_set,
147 .config_list = config_list,
148 .dev_open = dev_open,
149 .dev_close = dev_close,
150 .dev_acquisition_start = dev_acquisition_start,
151 .dev_acquisition_stop = dev_acquisition_stop,
152 .context = NULL,
154 SR_REGISTER_DEV_DRIVER({lib}_driver_info);