1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Abilis Systems Single DVB-T Receiver
4 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
9 #include <linux/kernel.h>
11 #include "as102_fe_types.h"
13 /*********************************/
14 /* MACRO DEFINITIONS */
15 /*********************************/
16 #define AS10X_CMD_ERROR -1
18 #define SERVICE_PROG_ID 0x0002
19 #define SERVICE_PROG_VERSION 0x0001
21 #define HIER_NONE 0x00
22 #define HIER_LOW_PRIORITY 0x01
24 #define HEADER_SIZE (sizeof(struct as10x_cmd_header_t))
26 /* context request types */
27 #define GET_CONTEXT_DATA 1
28 #define SET_CONTEXT_DATA 2
30 /* ODSP suspend modes */
31 #define CFG_MODE_ODSP_RESUME 0
32 #define CFG_MODE_ODSP_SUSPEND 1
34 /* Dump memory size */
35 #define DUMP_BLOCK_SIZE_MAX 0x20
37 /*********************************/
39 /*********************************/
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,
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
85 /* request identifier */
90 /* response identifier */
97 union as10x_turn_off
{
100 /* request identifier */
105 /* response identifier */
112 union as10x_set_tune
{
115 /* request identifier */
118 struct as10x_tune_args args
;
122 /* response identifier */
129 union as10x_get_tune_status
{
132 /* request identifier */
137 /* response identifier */
142 struct as10x_tune_status sts
;
146 union as10x_get_tps
{
149 /* request identifier */
154 /* response identifier */
159 struct as10x_tps tps
;
166 /* request identifier */
171 /* response identifier */
178 union as10x_add_pid_filter
{
181 /* request identifier */
185 /* stream type (MPE, PSI/SI or PES )*/
187 /* PID index in filter table */
192 /* response identifier */
201 union as10x_del_pid_filter
{
204 /* request identifier */
211 /* response identifier */
218 union as10x_start_streaming
{
221 /* request identifier */
226 /* response identifier */
233 union as10x_stop_streaming
{
236 /* request identifier */
241 /* response identifier */
248 union as10x_get_demod_stats
{
251 /* request identifier */
256 /* response identifier */
261 struct as10x_demod_stats stats
;
265 union as10x_get_impulse_resp
{
268 /* request identifier */
273 /* response identifier */
277 /* impulse response ready */
282 union as10x_fw_context
{
285 /* request identifier */
287 /* value to write (for set context)*/
288 struct as10x_register_value reg_val
;
291 /* context request type */
296 /* response identifier */
298 /* value read (for get context) */
299 struct as10x_register_value reg_val
;
300 /* context request type */
307 union as10x_set_register
{
310 /* response identifier */
312 /* register description */
313 struct as10x_register_addr reg_addr
;
314 /* register content */
315 struct as10x_register_value reg_val
;
319 /* response identifier */
326 union as10x_get_register
{
329 /* response identifier */
331 /* register description */
332 struct as10x_register_addr reg_addr
;
336 /* response identifier */
340 /* register content */
341 struct as10x_register_value reg_val
;
345 union as10x_cfg_change_mode
{
348 /* request identifier */
355 /* response identifier */
362 struct as10x_cmd_header_t
{
369 #define DUMP_BLOCK_SIZE 16
371 union as10x_dump_memory
{
374 /* request identifier */
376 /* dump memory type request */
378 /* register description */
379 struct as10x_register_addr reg_addr
;
380 /* nb blocks to read */
385 /* response identifier */
393 uint8_t data8
[DUMP_BLOCK_SIZE
];
394 __le16 data16
[DUMP_BLOCK_SIZE
/ sizeof(__le16
)];
395 __le32 data32
[DUMP_BLOCK_SIZE
/ sizeof(__le32
)];
400 union as10x_dumplog_memory
{
402 /* request identifier */
404 /* dump memory type request */
408 /* request identifier */
415 uint8_t data
[DUMP_BLOCK_SIZE
];
419 union as10x_raw_data
{
423 uint8_t data
[64 - sizeof(struct as10x_cmd_header_t
)
430 uint8_t data
[64 - sizeof(struct as10x_cmd_header_t
)
431 - 2 /* proc_id */ - 1 /* rc */];
436 struct as10x_cmd_header_t header
;
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
;
460 struct as10x_token_cmd_t
{
462 struct as10x_cmd_t c
;
464 struct as10x_cmd_t r
;
468 /**************************/
469 /* FUNCTION DECLARATION */
470 /**************************/
472 void as10x_cmd_build(struct as10x_cmd_t
*pcmd
, uint16_t proc_id
,
474 int as10x_rsp_parse(struct as10x_cmd_t
*r
, uint16_t proc_id
);
477 int as10x_cmd_turn_on(struct as10x_bus_adapter_t
*adap
);
478 int as10x_cmd_turn_off(struct as10x_bus_adapter_t
*adap
);
480 int as10x_cmd_set_tune(struct as10x_bus_adapter_t
*adap
,
481 struct as10x_tune_args
*ptune
);
483 int as10x_cmd_get_tune_status(struct as10x_bus_adapter_t
*adap
,
484 struct as10x_tune_status
*pstatus
);
486 int as10x_cmd_get_tps(struct as10x_bus_adapter_t
*adap
,
487 struct as10x_tps
*ptps
);
489 int as10x_cmd_get_demod_stats(struct as10x_bus_adapter_t
*adap
,
490 struct as10x_demod_stats
*pdemod_stats
);
492 int as10x_cmd_get_impulse_resp(struct as10x_bus_adapter_t
*adap
,
495 /* as10x cmd stream */
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
,
501 int as10x_cmd_start_streaming(struct as10x_bus_adapter_t
*adap
);
502 int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t
*adap
);
505 int as10x_cmd_set_context(struct as10x_bus_adapter_t
*adap
,
508 int as10x_cmd_get_context(struct as10x_bus_adapter_t
*adap
,
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
);