]>
Commit | Line | Data |
---|---|---|
a65d66c0 | 1 | /* |
4b527a01 | 2 | * This file is part of the libsigrok project. |
a65d66c0 | 3 | * |
bc02c2bf | 4 | * Copyright (C) {year} {author} <{email}> |
a65d66c0 BV |
5 | * |
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. | |
10 | * | |
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. | |
15 | * | |
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/>. | |
18 | */ | |
19 | ||
4dfd6ece | 20 | #include <config.h> |
a65d66c0 BV |
21 | #include "protocol.h" |
22 | ||
bc02c2bf | 23 | SR_PRIV struct sr_dev_driver {lib}_driver_info; |
a65d66c0 | 24 | |
87604b0c | 25 | static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) |
bc02c2bf | 26 | {{ |
5b10d8fd | 27 | return std_init(sr_ctx, di, LOG_PREFIX); |
bc02c2bf | 28 | }} |
a65d66c0 | 29 | |
87604b0c | 30 | static GSList *scan(struct sr_dev_driver *di, GSList *options) |
bc02c2bf | 31 | {{ |
a65d66c0 BV |
32 | struct drv_context *drvc; |
33 | GSList *devices; | |
34 | ||
35 | (void)options; | |
126eded0 | 36 | |
a65d66c0 | 37 | devices = NULL; |
f03716cf | 38 | drvc = di->context; |
a65d66c0 BV |
39 | drvc->instances = NULL; |
40 | ||
87c5b243 BV |
41 | /* TODO: scan for devices, either based on a SR_CONF_CONN option |
42 | * or on a USB scan. */ | |
a65d66c0 BV |
43 | |
44 | return devices; | |
bc02c2bf | 45 | }} |
a65d66c0 | 46 | |
87604b0c | 47 | static GSList *dev_list(const struct sr_dev_driver *di) |
bc02c2bf | 48 | {{ |
f03716cf | 49 | return ((struct drv_context *)(di->context))->instances; |
bc02c2bf | 50 | }} |
a65d66c0 | 51 | |
87604b0c | 52 | static int dev_clear(const struct sr_dev_driver *di) |
bc02c2bf | 53 | {{ |
87c5b243 | 54 | return std_dev_clear(di, NULL); |
bc02c2bf | 55 | }} |
87c5b243 BV |
56 | |
57 | static int dev_open(struct sr_dev_inst *sdi) | |
bc02c2bf | 58 | {{ |
3aef82b3 UH |
59 | (void)sdi; |
60 | ||
87c5b243 BV |
61 | /* TODO: get handle from sdi->conn and open it. */ |
62 | ||
63 | sdi->status = SR_ST_ACTIVE; | |
a65d66c0 BV |
64 | |
65 | return SR_OK; | |
bc02c2bf | 66 | }} |
a65d66c0 | 67 | |
87c5b243 | 68 | static int dev_close(struct sr_dev_inst *sdi) |
bc02c2bf | 69 | {{ |
3aef82b3 UH |
70 | (void)sdi; |
71 | ||
87c5b243 BV |
72 | /* TODO: get handle from sdi->conn and close it. */ |
73 | ||
74 | sdi->status = SR_ST_INACTIVE; | |
a65d66c0 BV |
75 | |
76 | return SR_OK; | |
bc02c2bf | 77 | }} |
a65d66c0 | 78 | |
87604b0c | 79 | static int cleanup(const struct sr_dev_driver *di) |
bc02c2bf | 80 | {{ |
87604b0c | 81 | dev_clear(di); |
a65d66c0 | 82 | |
87c5b243 | 83 | /* TODO: free other driver resources, if any. */ |
a65d66c0 BV |
84 | |
85 | return SR_OK; | |
bc02c2bf | 86 | }} |
a65d66c0 | 87 | |
df382df5 UH |
88 | static int config_get(uint32_t key, GVariant **data, |
89 | const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | |
bc02c2bf | 90 | {{ |
87c5b243 BV |
91 | int ret; |
92 | ||
3aef82b3 | 93 | (void)sdi; |
87c5b243 | 94 | (void)data; |
d73e0933 | 95 | (void)cg; |
3aef82b3 | 96 | |
87c5b243 | 97 | ret = SR_OK; |
bc02c2bf | 98 | switch (key) {{ |
a65d66c0 BV |
99 | /* TODO */ |
100 | default: | |
87c5b243 | 101 | return SR_ERR_NA; |
bc02c2bf | 102 | }} |
a65d66c0 | 103 | |
87c5b243 | 104 | return ret; |
bc02c2bf | 105 | }} |
a65d66c0 | 106 | |
df382df5 UH |
107 | static int config_set(uint32_t key, GVariant *data, |
108 | const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | |
bc02c2bf | 109 | {{ |
a65d66c0 BV |
110 | int ret; |
111 | ||
87c5b243 | 112 | (void)data; |
d73e0933 | 113 | (void)cg; |
87c5b243 BV |
114 | |
115 | if (sdi->status != SR_ST_ACTIVE) | |
116 | return SR_ERR_DEV_CLOSED; | |
a65d66c0 BV |
117 | |
118 | ret = SR_OK; | |
bc02c2bf | 119 | switch (key) {{ |
a65d66c0 BV |
120 | /* TODO */ |
121 | default: | |
87c5b243 | 122 | ret = SR_ERR_NA; |
bc02c2bf | 123 | }} |
a65d66c0 BV |
124 | |
125 | return ret; | |
bc02c2bf | 126 | }} |
a65d66c0 | 127 | |
df382df5 UH |
128 | static int config_list(uint32_t key, GVariant **data, |
129 | const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | |
bc02c2bf | 130 | {{ |
87c5b243 BV |
131 | int ret; |
132 | ||
3aef82b3 UH |
133 | (void)sdi; |
134 | (void)data; | |
d73e0933 | 135 | (void)cg; |
3aef82b3 | 136 | |
87c5b243 | 137 | ret = SR_OK; |
bc02c2bf | 138 | switch (key) {{ |
87c5b243 | 139 | /* TODO */ |
3aef82b3 | 140 | default: |
87c5b243 | 141 | return SR_ERR_NA; |
bc02c2bf | 142 | }} |
3aef82b3 | 143 | |
87c5b243 | 144 | return ret; |
bc02c2bf | 145 | }} |
3aef82b3 | 146 | |
d79664f0 | 147 | static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) |
bc02c2bf | 148 | {{ |
3aef82b3 UH |
149 | (void)sdi; |
150 | (void)cb_data; | |
151 | ||
87c5b243 BV |
152 | if (sdi->status != SR_ST_ACTIVE) |
153 | return SR_ERR_DEV_CLOSED; | |
154 | ||
155 | /* TODO: configure hardware, reset acquisition state, set up | |
156 | * callbacks and send header packet. */ | |
a65d66c0 BV |
157 | |
158 | return SR_OK; | |
bc02c2bf | 159 | }} |
a65d66c0 | 160 | |
87c5b243 | 161 | static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) |
bc02c2bf | 162 | {{ |
a65d66c0 BV |
163 | (void)cb_data; |
164 | ||
87c5b243 BV |
165 | if (sdi->status != SR_ST_ACTIVE) |
166 | return SR_ERR_DEV_CLOSED; | |
a65d66c0 | 167 | |
87c5b243 | 168 | /* TODO: stop acquisition. */ |
a65d66c0 BV |
169 | |
170 | return SR_OK; | |
bc02c2bf | 171 | }} |
a65d66c0 | 172 | |
bc02c2bf DD |
173 | SR_PRIV struct sr_dev_driver {lib}_driver_info = {{ |
174 | .name = "{short}", | |
175 | .longname = "{name}", | |
a65d66c0 | 176 | .api_version = 1, |
87c5b243 BV |
177 | .init = init, |
178 | .cleanup = cleanup, | |
179 | .scan = scan, | |
180 | .dev_list = dev_list, | |
181 | .dev_clear = dev_clear, | |
182 | .config_get = config_get, | |
183 | .config_set = config_set, | |
184 | .config_list = config_list, | |
185 | .dev_open = dev_open, | |
186 | .dev_close = dev_close, | |
187 | .dev_acquisition_start = dev_acquisition_start, | |
188 | .dev_acquisition_stop = dev_acquisition_stop, | |
f03716cf | 189 | .context = NULL, |
bc02c2bf | 190 | }}; |
466005f1 DD |
191 | |
192 | SR_REGISTER_DEV_DRIVER({lib}_driver_info); |