1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _AS10X_CMD_H_
16#define _AS10X_CMD_H_
17
18#include <linux/kernel.h>
19
20#include "as102_fe_types.h"
21
22
23
24
25#define AS10X_CMD_ERROR -1
26
27#define SERVICE_PROG_ID 0x0002
28#define SERVICE_PROG_VERSION 0x0001
29
30#define HIER_NONE 0x00
31#define HIER_LOW_PRIORITY 0x01
32
33#define HEADER_SIZE (sizeof(struct as10x_cmd_header_t))
34
35
36#define GET_CONTEXT_DATA 1
37#define SET_CONTEXT_DATA 2
38
39
40#define CFG_MODE_ODSP_RESUME 0
41#define CFG_MODE_ODSP_SUSPEND 1
42
43
44#define DUMP_BLOCK_SIZE_MAX 0x20
45
46
47
48
49enum control_proc {
50 CONTROL_PROC_TURNON = 0x0001,
51 CONTROL_PROC_TURNON_RSP = 0x0100,
52 CONTROL_PROC_SET_REGISTER = 0x0002,
53 CONTROL_PROC_SET_REGISTER_RSP = 0x0200,
54 CONTROL_PROC_GET_REGISTER = 0x0003,
55 CONTROL_PROC_GET_REGISTER_RSP = 0x0300,
56 CONTROL_PROC_SETTUNE = 0x000A,
57 CONTROL_PROC_SETTUNE_RSP = 0x0A00,
58 CONTROL_PROC_GETTUNESTAT = 0x000B,
59 CONTROL_PROC_GETTUNESTAT_RSP = 0x0B00,
60 CONTROL_PROC_GETTPS = 0x000D,
61 CONTROL_PROC_GETTPS_RSP = 0x0D00,
62 CONTROL_PROC_SETFILTER = 0x000E,
63 CONTROL_PROC_SETFILTER_RSP = 0x0E00,
64 CONTROL_PROC_REMOVEFILTER = 0x000F,
65 CONTROL_PROC_REMOVEFILTER_RSP = 0x0F00,
66 CONTROL_PROC_GET_IMPULSE_RESP = 0x0012,
67 CONTROL_PROC_GET_IMPULSE_RESP_RSP = 0x1200,
68 CONTROL_PROC_START_STREAMING = 0x0013,
69 CONTROL_PROC_START_STREAMING_RSP = 0x1300,
70 CONTROL_PROC_STOP_STREAMING = 0x0014,
71 CONTROL_PROC_STOP_STREAMING_RSP = 0x1400,
72 CONTROL_PROC_GET_DEMOD_STATS = 0x0015,
73 CONTROL_PROC_GET_DEMOD_STATS_RSP = 0x1500,
74 CONTROL_PROC_ELNA_CHANGE_MODE = 0x0016,
75 CONTROL_PROC_ELNA_CHANGE_MODE_RSP = 0x1600,
76 CONTROL_PROC_ODSP_CHANGE_MODE = 0x0017,
77 CONTROL_PROC_ODSP_CHANGE_MODE_RSP = 0x1700,
78 CONTROL_PROC_AGC_CHANGE_MODE = 0x0018,
79 CONTROL_PROC_AGC_CHANGE_MODE_RSP = 0x1800,
80
81 CONTROL_PROC_CONTEXT = 0x00FC,
82 CONTROL_PROC_CONTEXT_RSP = 0xFC00,
83 CONTROL_PROC_DUMP_MEMORY = 0x00FD,
84 CONTROL_PROC_DUMP_MEMORY_RSP = 0xFD00,
85 CONTROL_PROC_DUMPLOG_MEMORY = 0x00FE,
86 CONTROL_PROC_DUMPLOG_MEMORY_RSP = 0xFE00,
87 CONTROL_PROC_TURNOFF = 0x00FF,
88 CONTROL_PROC_TURNOFF_RSP = 0xFF00
89};
90
91union as10x_turn_on {
92
93 struct {
94
95 __le16 proc_id;
96 } __packed req;
97
98 struct {
99
100 __le16 proc_id;
101
102 uint8_t error;
103 } __packed rsp;
104} __packed;
105
106union as10x_turn_off {
107
108 struct {
109
110 __le16 proc_id;
111 } __packed req;
112
113 struct {
114
115 __le16 proc_id;
116
117 uint8_t err;
118 } __packed rsp;
119} __packed;
120
121union as10x_set_tune {
122
123 struct {
124
125 __le16 proc_id;
126
127 struct as10x_tune_args args;
128 } __packed req;
129
130 struct {
131
132 __le16 proc_id;
133
134 uint8_t error;
135 } __packed rsp;
136} __packed;
137
138union as10x_get_tune_status {
139
140 struct {
141
142 __le16 proc_id;
143 } __packed req;
144
145 struct {
146
147 __le16 proc_id;
148
149 uint8_t error;
150
151 struct as10x_tune_status sts;
152 } __packed rsp;
153} __packed;
154
155union as10x_get_tps {
156
157 struct {
158
159 __le16 proc_id;
160 } __packed req;
161
162 struct {
163
164 __le16 proc_id;
165
166 uint8_t error;
167
168 struct as10x_tps tps;
169 } __packed rsp;
170} __packed;
171
172union as10x_common {
173
174 struct {
175
176 __le16 proc_id;
177 } __packed req;
178
179 struct {
180
181 __le16 proc_id;
182
183 uint8_t error;
184 } __packed rsp;
185} __packed;
186
187union as10x_add_pid_filter {
188
189 struct {
190
191 __le16 proc_id;
192
193 __le16 pid;
194
195 uint8_t stream_type;
196
197 uint8_t idx;
198 } __packed req;
199
200 struct {
201
202 __le16 proc_id;
203
204 uint8_t error;
205
206 uint8_t filter_id;
207 } __packed rsp;
208} __packed;
209
210union as10x_del_pid_filter {
211
212 struct {
213
214 __le16 proc_id;
215
216 __le16 pid;
217 } __packed req;
218
219 struct {
220
221 __le16 proc_id;
222
223 uint8_t error;
224 } __packed rsp;
225} __packed;
226
227union as10x_start_streaming {
228
229 struct {
230
231 __le16 proc_id;
232 } __packed req;
233
234 struct {
235
236 __le16 proc_id;
237
238 uint8_t error;
239 } __packed rsp;
240} __packed;
241
242union as10x_stop_streaming {
243
244 struct {
245
246 __le16 proc_id;
247 } __packed req;
248
249 struct {
250
251 __le16 proc_id;
252
253 uint8_t error;
254 } __packed rsp;
255} __packed;
256
257union as10x_get_demod_stats {
258
259 struct {
260
261 __le16 proc_id;
262 } __packed req;
263
264 struct {
265
266 __le16 proc_id;
267
268 uint8_t error;
269
270 struct as10x_demod_stats stats;
271 } __packed rsp;
272} __packed;
273
274union as10x_get_impulse_resp {
275
276 struct {
277
278 __le16 proc_id;
279 } __packed req;
280
281 struct {
282
283 __le16 proc_id;
284
285 uint8_t error;
286
287 uint8_t is_ready;
288 } __packed rsp;
289} __packed;
290
291union as10x_fw_context {
292
293 struct {
294
295 __le16 proc_id;
296
297 struct as10x_register_value reg_val;
298
299 __le16 tag;
300
301 __le16 type;
302 } __packed req;
303
304 struct {
305
306 __le16 proc_id;
307
308 struct as10x_register_value reg_val;
309
310 __le16 type;
311
312 uint8_t error;
313 } __packed rsp;
314} __packed;
315
316union as10x_set_register {
317
318 struct {
319
320 __le16 proc_id;
321
322 struct as10x_register_addr reg_addr;
323
324 struct as10x_register_value reg_val;
325 } __packed req;
326
327 struct {
328
329 __le16 proc_id;
330
331 uint8_t error;
332 } __packed rsp;
333} __packed;
334
335union as10x_get_register {
336
337 struct {
338
339 __le16 proc_id;
340
341 struct as10x_register_addr reg_addr;
342 } __packed req;
343
344 struct {
345
346 __le16 proc_id;
347
348 uint8_t error;
349
350 struct as10x_register_value reg_val;
351 } __packed rsp;
352} __packed;
353
354union as10x_cfg_change_mode {
355
356 struct {
357
358 __le16 proc_id;
359
360 uint8_t mode;
361 } __packed req;
362
363 struct {
364
365 __le16 proc_id;
366
367 uint8_t error;
368 } __packed rsp;
369} __packed;
370
371struct as10x_cmd_header_t {
372 __le16 req_id;
373 __le16 prog;
374 __le16 version;
375 __le16 data_len;
376} __packed;
377
378#define DUMP_BLOCK_SIZE 16
379
380union as10x_dump_memory {
381
382 struct {
383
384 __le16 proc_id;
385
386 uint8_t dump_req;
387
388 struct as10x_register_addr reg_addr;
389
390 __le16 num_blocks;
391 } __packed req;
392
393 struct {
394
395 __le16 proc_id;
396
397 uint8_t error;
398
399 uint8_t dump_rsp;
400
401 union {
402 uint8_t data8[DUMP_BLOCK_SIZE];
403 __le16 data16[DUMP_BLOCK_SIZE / sizeof(__le16)];
404 __le32 data32[DUMP_BLOCK_SIZE / sizeof(__le32)];
405 } __packed u;
406 } __packed rsp;
407} __packed;
408
409union as10x_dumplog_memory {
410 struct {
411
412 __le16 proc_id;
413
414 uint8_t dump_req;
415 } __packed req;
416 struct {
417
418 __le16 proc_id;
419
420 uint8_t error;
421
422 uint8_t dump_rsp;
423
424 uint8_t data[DUMP_BLOCK_SIZE];
425 } __packed rsp;
426} __packed;
427
428union as10x_raw_data {
429
430 struct {
431 __le16 proc_id;
432 uint8_t data[64 - sizeof(struct as10x_cmd_header_t)
433 - 2 ];
434 } __packed req;
435
436 struct {
437 __le16 proc_id;
438 uint8_t error;
439 uint8_t data[64 - sizeof(struct as10x_cmd_header_t)
440 - 2 - 1 ];
441 } __packed rsp;
442} __packed;
443
444struct as10x_cmd_t {
445 struct as10x_cmd_header_t header;
446 union {
447 union as10x_turn_on turn_on;
448 union as10x_turn_off turn_off;
449 union as10x_set_tune set_tune;
450 union as10x_get_tune_status get_tune_status;
451 union as10x_get_tps get_tps;
452 union as10x_common common;
453 union as10x_add_pid_filter add_pid_filter;
454 union as10x_del_pid_filter del_pid_filter;
455 union as10x_start_streaming start_streaming;
456 union as10x_stop_streaming stop_streaming;
457 union as10x_get_demod_stats get_demod_stats;
458 union as10x_get_impulse_resp get_impulse_rsp;
459 union as10x_fw_context context;
460 union as10x_set_register set_register;
461 union as10x_get_register get_register;
462 union as10x_cfg_change_mode cfg_change_mode;
463 union as10x_dump_memory dump_memory;
464 union as10x_dumplog_memory dumplog_memory;
465 union as10x_raw_data raw_data;
466 } __packed body;
467} __packed;
468
469struct as10x_token_cmd_t {
470
471 struct as10x_cmd_t c;
472
473 struct as10x_cmd_t r;
474} __packed;
475
476
477
478
479
480
481void as10x_cmd_build(struct as10x_cmd_t *pcmd, uint16_t proc_id,
482 uint16_t cmd_len);
483int as10x_rsp_parse(struct as10x_cmd_t *r, uint16_t proc_id);
484
485
486int as10x_cmd_turn_on(struct as10x_bus_adapter_t *adap);
487int as10x_cmd_turn_off(struct as10x_bus_adapter_t *adap);
488
489int as10x_cmd_set_tune(struct as10x_bus_adapter_t *adap,
490 struct as10x_tune_args *ptune);
491
492int as10x_cmd_get_tune_status(struct as10x_bus_adapter_t *adap,
493 struct as10x_tune_status *pstatus);
494
495int as10x_cmd_get_tps(struct as10x_bus_adapter_t *adap,
496 struct as10x_tps *ptps);
497
498int as10x_cmd_get_demod_stats(struct as10x_bus_adapter_t *adap,
499 struct as10x_demod_stats *pdemod_stats);
500
501int as10x_cmd_get_impulse_resp(struct as10x_bus_adapter_t *adap,
502 uint8_t *is_ready);
503
504
505int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
506 struct as10x_ts_filter *filter);
507int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
508 uint16_t pid_value);
509
510int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap);
511int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap);
512
513
514int as10x_cmd_set_context(struct as10x_bus_adapter_t *adap,
515 uint16_t tag,
516 uint32_t value);
517int as10x_cmd_get_context(struct as10x_bus_adapter_t *adap,
518 uint16_t tag,
519 uint32_t *pvalue);
520
521int as10x_cmd_eLNA_change_mode(struct as10x_bus_adapter_t *adap, uint8_t mode);
522int as10x_context_rsp_parse(struct as10x_cmd_t *prsp, uint16_t proc_id);
523#endif
524