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