2 * Abilis Systems Single DVB-T Receiver
3 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
18 #include <linux/kernel.h>
20 #include "as102_fe_types.h"
22 /*********************************/
23 /* MACRO DEFINITIONS */
24 /*********************************/
25 #define AS10X_CMD_ERROR -1
27 #define SERVICE_PROG_ID 0x0002
28 #define SERVICE_PROG_VERSION 0x0001
30 #define HIER_NONE 0x00
31 #define HIER_LOW_PRIORITY 0x01
33 #define HEADER_SIZE (sizeof(struct as10x_cmd_header_t))
35 /* context request types */
36 #define GET_CONTEXT_DATA 1
37 #define SET_CONTEXT_DATA 2
39 /* ODSP suspend modes */
40 #define CFG_MODE_ODSP_RESUME 0
41 #define CFG_MODE_ODSP_SUSPEND 1
43 /* Dump memory size */
44 #define DUMP_BLOCK_SIZE_MAX 0x20
46 /*********************************/
48 /*********************************/
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,
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
94 /* request identifier */
99 /* response identifier */
106 union as10x_turn_off
{
109 /* request identifier */
114 /* response identifier */
121 union as10x_set_tune
{
124 /* request identifier */
127 struct as10x_tune_args args
;
131 /* response identifier */
138 union as10x_get_tune_status
{
141 /* request identifier */
146 /* response identifier */
151 struct as10x_tune_status sts
;
155 union as10x_get_tps
{
158 /* request identifier */
163 /* response identifier */
168 struct as10x_tps tps
;
175 /* request identifier */
180 /* response identifier */
187 union as10x_add_pid_filter
{
190 /* request identifier */
194 /* stream type (MPE, PSI/SI or PES )*/
196 /* PID index in filter table */
201 /* response identifier */
210 union as10x_del_pid_filter
{
213 /* request identifier */
220 /* response identifier */
227 union as10x_start_streaming
{
230 /* request identifier */
235 /* response identifier */
242 union as10x_stop_streaming
{
245 /* request identifier */
250 /* response identifier */
257 union as10x_get_demod_stats
{
260 /* request identifier */
265 /* response identifier */
270 struct as10x_demod_stats stats
;
274 union as10x_get_impulse_resp
{
277 /* request identifier */
282 /* response identifier */
286 /* impulse response ready */
291 union as10x_fw_context
{
294 /* request identifier */
296 /* value to write (for set context)*/
297 struct as10x_register_value reg_val
;
300 /* context request type */
305 /* response identifier */
307 /* value read (for get context) */
308 struct as10x_register_value reg_val
;
309 /* context request type */
316 union as10x_set_register
{
319 /* response identifier */
321 /* register description */
322 struct as10x_register_addr reg_addr
;
323 /* register content */
324 struct as10x_register_value reg_val
;
328 /* response identifier */
335 union as10x_get_register
{
338 /* response identifier */
340 /* register description */
341 struct as10x_register_addr reg_addr
;
345 /* response identifier */
349 /* register content */
350 struct as10x_register_value reg_val
;
354 union as10x_cfg_change_mode
{
357 /* request identifier */
364 /* response identifier */
371 struct as10x_cmd_header_t
{
378 #define DUMP_BLOCK_SIZE 16
380 union as10x_dump_memory
{
383 /* request identifier */
385 /* dump memory type request */
387 /* register description */
388 struct as10x_register_addr reg_addr
;
389 /* nb blocks to read */
394 /* response identifier */
402 uint8_t data8
[DUMP_BLOCK_SIZE
];
403 __le16 data16
[DUMP_BLOCK_SIZE
/ sizeof(__le16
)];
404 __le32 data32
[DUMP_BLOCK_SIZE
/ sizeof(__le32
)];
409 union as10x_dumplog_memory
{
411 /* request identifier */
413 /* dump memory type request */
417 /* request identifier */
424 uint8_t data
[DUMP_BLOCK_SIZE
];
428 union as10x_raw_data
{
432 uint8_t data
[64 - sizeof(struct as10x_cmd_header_t
)
439 uint8_t data
[64 - sizeof(struct as10x_cmd_header_t
)
440 - 2 /* proc_id */ - 1 /* rc */];
445 struct as10x_cmd_header_t header
;
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
;
469 struct as10x_token_cmd_t
{
471 struct as10x_cmd_t c
;
473 struct as10x_cmd_t r
;
477 /**************************/
478 /* FUNCTION DECLARATION */
479 /**************************/
481 void as10x_cmd_build(struct as10x_cmd_t
*pcmd
, uint16_t proc_id
,
483 int as10x_rsp_parse(struct as10x_cmd_t
*r
, uint16_t proc_id
);
486 int as10x_cmd_turn_on(struct as10x_bus_adapter_t
*adap
);
487 int as10x_cmd_turn_off(struct as10x_bus_adapter_t
*adap
);
489 int as10x_cmd_set_tune(struct as10x_bus_adapter_t
*adap
,
490 struct as10x_tune_args
*ptune
);
492 int as10x_cmd_get_tune_status(struct as10x_bus_adapter_t
*adap
,
493 struct as10x_tune_status
*pstatus
);
495 int as10x_cmd_get_tps(struct as10x_bus_adapter_t
*adap
,
496 struct as10x_tps
*ptps
);
498 int as10x_cmd_get_demod_stats(struct as10x_bus_adapter_t
*adap
,
499 struct as10x_demod_stats
*pdemod_stats
);
501 int as10x_cmd_get_impulse_resp(struct as10x_bus_adapter_t
*adap
,
504 /* as10x cmd stream */
505 int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t
*adap
,
506 struct as10x_ts_filter
*filter
);
507 int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t
*adap
,
510 int as10x_cmd_start_streaming(struct as10x_bus_adapter_t
*adap
);
511 int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t
*adap
);
514 int as10x_cmd_set_context(struct as10x_bus_adapter_t
*adap
,
517 int as10x_cmd_get_context(struct as10x_bus_adapter_t
*adap
,
521 int as10x_cmd_eLNA_change_mode(struct as10x_bus_adapter_t
*adap
, uint8_t mode
);
522 int as10x_context_rsp_parse(struct as10x_cmd_t
*prsp
, uint16_t proc_id
);