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