]> sigrok.org Git - libsigrok.git/blame - src/hardware/hung-chang-dso-2100/api.c
hung-chang-dso-2100: Initial driver skeleton.
[libsigrok.git] / src / hardware / hung-chang-dso-2100 / api.c
CommitLineData
05ac4a98
DG
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2015 Daniel Glöckner <daniel-gl@gmx.net>
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
20#include "protocol.h"
21
22SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info;
23
24static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
25{
26 return std_init(sr_ctx, di, LOG_PREFIX);
27}
28
29static GSList *scan(struct sr_dev_driver *di, GSList *options)
30{
31 struct drv_context *drvc;
32 GSList *devices;
33
34 (void)options;
35
36 devices = NULL;
37 drvc = di->context;
38 drvc->instances = NULL;
39
40 /* TODO: scan for devices, either based on a SR_CONF_CONN option
41 * or on a USB scan. */
42
43 return devices;
44}
45
46static GSList *dev_list(const struct sr_dev_driver *di)
47{
48 return ((struct drv_context *)(di->context))->instances;
49}
50
51static int dev_clear(const struct sr_dev_driver *di)
52{
53 return std_dev_clear(di, NULL);
54}
55
56static int dev_open(struct sr_dev_inst *sdi)
57{
58 (void)sdi;
59
60 /* TODO: get handle from sdi->conn and open it. */
61
62 sdi->status = SR_ST_ACTIVE;
63
64 return SR_OK;
65}
66
67static int dev_close(struct sr_dev_inst *sdi)
68{
69 (void)sdi;
70
71 /* TODO: get handle from sdi->conn and close it. */
72
73 sdi->status = SR_ST_INACTIVE;
74
75 return SR_OK;
76}
77
78static int cleanup(const struct sr_dev_driver *di)
79{
80 dev_clear(di);
81
82 /* TODO: free other driver resources, if any. */
83
84 return SR_OK;
85}
86
87static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
88 const struct sr_channel_group *cg)
89{
90 int ret;
91
92 (void)sdi;
93 (void)data;
94 (void)cg;
95
96 ret = SR_OK;
97 switch (key) {
98 /* TODO */
99 default:
100 return SR_ERR_NA;
101 }
102
103 return ret;
104}
105
106static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
107 const struct sr_channel_group *cg)
108{
109 int ret;
110
111 (void)data;
112 (void)cg;
113
114 if (sdi->status != SR_ST_ACTIVE)
115 return SR_ERR_DEV_CLOSED;
116
117 ret = SR_OK;
118 switch (key) {
119 /* TODO */
120 default:
121 ret = SR_ERR_NA;
122 }
123
124 return ret;
125}
126
127static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
128 const struct sr_channel_group *cg)
129{
130 int ret;
131
132 (void)sdi;
133 (void)data;
134 (void)cg;
135
136 ret = SR_OK;
137 switch (key) {
138 /* TODO */
139 default:
140 return SR_ERR_NA;
141 }
142
143 return ret;
144}
145
146static int dev_acquisition_start(const struct sr_dev_inst *sdi,
147 void *cb_data)
148{
149 (void)sdi;
150 (void)cb_data;
151
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. */
157
158 return SR_OK;
159}
160
161static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
162{
163 (void)cb_data;
164
165 if (sdi->status != SR_ST_ACTIVE)
166 return SR_ERR_DEV_CLOSED;
167
168 /* TODO: stop acquisition. */
169
170 return SR_OK;
171}
172
173SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = {
174 .name = "hung-chang-dso-2100",
175 .longname = "Hung-Chang DSO-2100",
176 .api_version = 1,
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,
189 .context = NULL,
190};