[SCSI] libfc: remove redundant timer init for fcp
[sfrench/cifs-2.6.git] / 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 typedef enum {
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 } control_proc;
96
97
98 #pragma pack(1)
99 typedef union {
100    /* request */
101    struct {
102       /* request identifier */
103       uint16_t proc_id;
104    } req;
105    /* response */
106    struct {
107       /* response identifier */
108       uint16_t proc_id;
109       /* error */
110       uint8_t error;
111    } rsp;
112 } TURN_ON;
113
114 typedef union {
115    /* request */
116    struct {
117       /* request identifier */
118       uint16_t proc_id;
119    } req;
120    /* response */
121    struct {
122       /* response identifier */
123       uint16_t proc_id;
124       /* error */
125       uint8_t err;
126    } rsp;
127 } TURN_OFF;
128
129 typedef union {
130    /* request */
131    struct {
132       /* request identifier */
133       uint16_t proc_id;
134       /* tune params */
135       struct as10x_tune_args args;
136    } req;
137    /* response */
138    struct {
139       /* response identifier */
140       uint16_t proc_id;
141       /* response error */
142       uint8_t error;
143    } rsp;
144 } SET_TUNE;
145
146 typedef union {
147    /* request */
148    struct {
149       /* request identifier */
150       uint16_t proc_id;
151    } req;
152    /* response */
153    struct {
154       /* response identifier */
155       uint16_t proc_id;
156       /* response error */
157       uint8_t error;
158       /* tune status */
159       struct as10x_tune_status sts;
160    } rsp;
161 } GET_TUNE_STATUS;
162
163 typedef union {
164    /* request */
165    struct {
166       /* request identifier */
167       uint16_t proc_id;
168    } req;
169    /* response */
170    struct {
171       /* response identifier */
172       uint16_t proc_id;
173       /* response error */
174       uint8_t error;
175       /* tps details */
176       struct as10x_tps tps;
177    } rsp;
178 } GET_TPS;
179
180 typedef union {
181    /* request */
182    struct {
183       /* request identifier */
184       uint16_t  proc_id;
185    } req;
186    /* response */
187    struct {
188       /* response identifier */
189       uint16_t proc_id;
190       /* response error */
191       uint8_t error;
192    } rsp;
193 } COMMON;
194
195 typedef union {
196    /* request */
197    struct {
198       /* request identifier */
199       uint16_t  proc_id;
200       /* PID to filter */
201       uint16_t  pid;
202       /* stream type (MPE, PSI/SI or PES )*/
203       uint8_t stream_type;
204       /* PID index in filter table */
205       uint8_t idx;
206    } req;
207    /* response */
208    struct {
209       /* response identifier */
210       uint16_t proc_id;
211       /* response error */
212       uint8_t error;
213       /* Filter id */
214       uint8_t filter_id;
215    } rsp;
216 } ADD_PID_FILTER;
217
218 typedef union {
219    /* request */
220    struct {
221       /* request identifier */
222       uint16_t  proc_id;
223       /* PID to remove */
224       uint16_t  pid;
225    } req;
226    /* response */
227    struct {
228       /* response identifier */
229       uint16_t proc_id;
230       /* response error */
231       uint8_t error;
232    } rsp;
233 } DEL_PID_FILTER;
234
235 typedef union {
236    /* request */
237    struct {
238       /* request identifier */
239       uint16_t proc_id;
240    } req;
241    /* response */
242    struct {
243       /* response identifier */
244       uint16_t proc_id;
245       /* error */
246       uint8_t error;
247    } rsp;
248 } START_STREAMING;
249
250 typedef union {
251    /* request */
252    struct {
253       /* request identifier */
254       uint16_t proc_id;
255    } req;
256    /* response */
257    struct {
258       /* response identifier */
259       uint16_t proc_id;
260       /* error */
261       uint8_t error;
262    } rsp;
263 } STOP_STREAMING;
264
265 typedef union {
266    /* request */
267    struct {
268       /* request identifier */
269       uint16_t proc_id;
270    } req;
271    /* response */
272    struct {
273       /* response identifier */
274       uint16_t proc_id;
275       /* error */
276       uint8_t error;
277       /* demod stats */
278       struct as10x_demod_stats stats;
279    } rsp;
280 } GET_DEMOD_STATS;
281
282 typedef union {
283    /* request */
284    struct {
285       /* request identifier */
286       uint16_t proc_id;
287    } req;
288    /* response */
289    struct {
290       /* response identifier */
291       uint16_t proc_id;
292       /* error */
293       uint8_t error;
294       /* impulse response ready */
295       uint8_t is_ready;
296    } rsp;
297 } GET_IMPULSE_RESP;
298
299 typedef union {
300    /* request */
301    struct {
302       /* request identifier */
303       uint16_t proc_id;
304       /* value to write (for set context)*/
305       struct as10x_register_value reg_val;
306       /* context tag */
307       uint16_t tag;
308       /* context request type */
309       uint16_t type;
310    } req;
311    /* response */
312    struct {
313       /* response identifier */
314       uint16_t proc_id;
315       /* value read (for get context) */
316       struct as10x_register_value reg_val;
317       /* context request type */
318       uint16_t type;
319       /* error */
320       uint8_t error;
321    } rsp;
322 } FW_CONTEXT;
323
324 typedef union {
325    /* request */
326    struct {
327       /* response identifier */
328       uint16_t proc_id;
329       /* register description */
330       struct as10x_register_addr reg_addr;
331       /* register content */
332       struct as10x_register_value reg_val;
333    } req;
334    /* response */
335    struct {
336       /* response identifier */
337       uint16_t proc_id;
338       /* error */
339       uint8_t error;
340    } rsp;
341 } SET_REGISTER;
342
343 typedef union {
344    /* request */
345    struct {
346       /* response identifier */
347       uint16_t proc_id;
348       /* register description */
349       struct as10x_register_addr reg_addr;
350    } req;
351    /* response */
352    struct {
353       /* response identifier */
354       uint16_t proc_id;
355       /* error */
356       uint8_t error;
357       /* register content */
358       struct as10x_register_value reg_val;
359    } rsp;
360 } GET_REGISTER;
361
362 typedef union {
363    /* request */
364    struct {
365       /* request identifier */
366       uint16_t proc_id;
367       /* mode */
368       uint8_t mode;
369    } req;
370    /* response */
371    struct {
372       /* response identifier */
373       uint16_t proc_id;
374       /* error */
375       uint8_t error;
376    } rsp;
377 } CFG_CHANGE_MODE;
378
379 struct as10x_cmd_header_t {
380    uint16_t req_id;
381    uint16_t prog;
382    uint16_t version;
383    uint16_t data_len;
384 };
385
386 #define DUMP_BLOCK_SIZE 16
387 typedef union {
388    /* request */
389    struct {
390       /* request identifier */
391       uint16_t proc_id;
392       /* dump memory type request */
393       uint8_t dump_req;
394       /* register description */
395       struct as10x_register_addr reg_addr;
396       /* nb blocks to read */
397       uint16_t num_blocks;
398    } req;
399    /* response */
400    struct {
401       /* response identifier */
402       uint16_t proc_id;
403       /* error */
404       uint8_t error;
405       /* dump response */
406       uint8_t dump_rsp;
407       /* data */
408       union {
409          uint8_t  data8[DUMP_BLOCK_SIZE];
410          uint16_t data16[DUMP_BLOCK_SIZE / sizeof(uint16_t)];
411          uint32_t data32[DUMP_BLOCK_SIZE / sizeof(uint32_t)];
412       } u;
413    } rsp;
414 } DUMP_MEMORY;
415
416 typedef union {
417    struct {
418       /* request identifier */
419       uint16_t proc_id;
420       /* dump memory type request */
421       uint8_t dump_req;
422    } req;
423    struct {
424       /* request identifier */
425       uint16_t proc_id;
426       /* error */
427       uint8_t error;
428       /* dump response */
429       uint8_t dump_rsp;
430       /* dump data */
431       uint8_t data[DUMP_BLOCK_SIZE];
432    } rsp;
433 } DUMPLOG_MEMORY;
434
435 typedef union {
436    /* request */
437    struct {
438       uint16_t proc_id;
439       uint8_t data[64 - sizeof(struct as10x_cmd_header_t) -2 /* proc_id */];
440    } 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) /* header */
446                       - 2 /* proc_id */ - 1 /* rc */];
447    } rsp;
448 } RAW_DATA;
449
450 struct as10x_cmd_t {
451    /* header */
452    struct as10x_cmd_header_t header;
453    /* body */
454    union {
455       TURN_ON           turn_on;
456       TURN_OFF          turn_off;
457       SET_TUNE          set_tune;
458       GET_TUNE_STATUS   get_tune_status;
459       GET_TPS           get_tps;
460       COMMON            common;
461       ADD_PID_FILTER    add_pid_filter;
462       DEL_PID_FILTER    del_pid_filter;
463       START_STREAMING   start_streaming;
464       STOP_STREAMING    stop_streaming;
465       GET_DEMOD_STATS   get_demod_stats;
466       GET_IMPULSE_RESP  get_impulse_rsp;
467       FW_CONTEXT        context;
468       SET_REGISTER      set_register;
469       GET_REGISTER      get_register;
470       CFG_CHANGE_MODE   cfg_change_mode;
471       DUMP_MEMORY       dump_memory;
472       DUMPLOG_MEMORY    dumplog_memory;
473       RAW_DATA          raw_data;
474    } body;
475 };
476
477 struct as10x_token_cmd_t {
478    /* token cmd */
479    struct as10x_cmd_t c;
480    /* token response */
481    struct as10x_cmd_t r;
482 };
483 #pragma pack()
484
485
486 /**************************/
487 /* FUNCTION DECLARATION   */
488 /**************************/
489
490 void as10x_cmd_build(struct as10x_cmd_t *pcmd, uint16_t proc_id,
491                       uint16_t cmd_len);
492 int as10x_rsp_parse(struct as10x_cmd_t *r, uint16_t proc_id);
493
494 #ifdef __cplusplus
495 extern "C" {
496 #endif
497
498 /* as10x cmd */
499 int as10x_cmd_turn_on(as10x_handle_t *phandle);
500 int as10x_cmd_turn_off(as10x_handle_t *phandle);
501
502 int as10x_cmd_set_tune(as10x_handle_t *phandle,
503                        struct as10x_tune_args *ptune);
504
505 int as10x_cmd_get_tune_status(as10x_handle_t *phandle,
506                               struct as10x_tune_status *pstatus);
507
508 int as10x_cmd_get_tps(as10x_handle_t *phandle,
509                       struct as10x_tps *ptps);
510
511 int as10x_cmd_get_demod_stats(as10x_handle_t  *phandle,
512                               struct as10x_demod_stats *pdemod_stats);
513
514 int as10x_cmd_get_impulse_resp(as10x_handle_t *phandle,
515                                uint8_t *is_ready);
516
517 /* as10x cmd stream */
518 int as10x_cmd_add_PID_filter(as10x_handle_t *phandle,
519                              struct as10x_ts_filter *filter);
520 int as10x_cmd_del_PID_filter(as10x_handle_t *phandle,
521                              uint16_t pid_value);
522
523 int as10x_cmd_start_streaming(as10x_handle_t *phandle);
524 int as10x_cmd_stop_streaming(as10x_handle_t *phandle);
525
526 /* as10x cmd cfg */
527 int as10x_cmd_set_context(as10x_handle_t *phandle,
528                           uint16_t tag,
529                           uint32_t value);
530 int as10x_cmd_get_context(as10x_handle_t *phandle,
531                           uint16_t tag,
532                           uint32_t *pvalue);
533
534 int as10x_cmd_eLNA_change_mode(as10x_handle_t *phandle, uint8_t mode);
535 int as10x_context_rsp_parse(struct as10x_cmd_t *prsp, uint16_t proc_id);
536 #ifdef __cplusplus
537 }
538 #endif
539 #endif
540 /* EOF - vim: set textwidth=80 ts=3 sw=3 sts=3 et: */