66f419a6f7c68123ab1da3bd22a923a1a5284848
[linux-2.6-block.git] / drivers / media / dvb / firesat / avc_api.h
1 /*
2  * AV/C API
3  *
4  * Copyright (C) 2000 Manfred Weihs
5  * Copyright (C) 2003 Philipp Gutgsell <0014guph@edu.fh-kaernten.ac.at>
6  * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
7  * Copyright (C) 2008 Ben Backx <ben@bbackx.com>
8  * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
9  *
10  * This is based on code written by Peter Halwachs, Thomas Groiss and
11  * Andreas Monitzer.
12  *
13  *      This program is free software; you can redistribute it and/or
14  *      modify it under the terms of the GNU General Public License as
15  *      published by the Free Software Foundation; either version 2 of
16  *      the License, or (at your option) any later version.
17  */
18
19 #ifndef _AVC_API_H
20 #define _AVC_API_H
21
22 #include <linux/types.h>
23
24 /*************************************************************
25         Constants from EN510221
26 **************************************************************/
27 #define LIST_MANAGEMENT_ONLY 0x03
28
29 /*************************************************************
30         FCP Address range
31 **************************************************************/
32
33 #define RESPONSE_REGISTER       0xFFFFF0000D00ULL
34 #define COMMAND_REGISTER        0xFFFFF0000B00ULL
35 #define PCR_BASE_ADDRESS        0xFFFFF0000900ULL
36
37
38 /************************************************************
39         definition of structures
40 *************************************************************/
41 typedef struct {
42            int           Nr_SourcePlugs;
43            int           Nr_DestinationPlugs;
44 } TunerInfo;
45
46
47 /***********************************************
48
49          supported cts
50
51 ************************************************/
52
53 #define AVC  0x0
54
55 // FCP command frame with ctype = 0x0 is AVC command frame
56
57 #ifdef __LITTLE_ENDIAN
58
59 // Definition FCP Command Frame
60 typedef struct _AVCCmdFrm
61 {
62                 // AV/C command frame
63         __u8 ctype  : 4 ;   // command type
64         __u8 cts    : 4 ;   // always 0x0 for AVC
65         __u8 suid   : 3 ;   // subunit ID
66         __u8 sutyp  : 5 ;   // subunit_typ
67         __u8 opcode : 8 ;   // opcode
68         __u8 operand[509] ; // array of operands [1-507]
69         int length;         //length of the command frame
70 } AVCCmdFrm ;
71
72 // Definition FCP Response Frame
73 typedef struct _AVCRspFrm
74 {
75         // AV/C response frame
76         __u8 resp               : 4 ;   // response type
77         __u8 cts                : 4 ;   // always 0x0 for AVC
78         __u8 suid               : 3 ;   // subunit ID
79         __u8 sutyp      : 5 ;   // subunit_typ
80         __u8 opcode     : 8 ;   // opcode
81         __u8 operand[509] ; // array of operands [1-507]
82         int length;         //length of the response frame
83 } AVCRspFrm ;
84
85 #else
86
87 typedef struct _AVCCmdFrm
88 {
89         __u8 cts:4;
90         __u8 ctype:4;
91         __u8 sutyp:5;
92         __u8 suid:3;
93         __u8 opcode;
94         __u8 operand[509];
95         int length;
96 } AVCCmdFrm;
97
98 typedef struct _AVCRspFrm
99 {
100         __u8 cts:4;
101         __u8 resp:4;
102         __u8 sutyp:5;
103         __u8 suid:3;
104         __u8 opcode;
105         __u8 operand[509];
106         int length;
107 } AVCRspFrm;
108
109 #endif
110
111 /*************************************************************
112         AVC command types (ctype)
113 **************************************************************///
114 #define CONTROL    0x00
115 #define STATUS     0x01
116 #define INQUIRY    0x02
117 #define NOTIFY     0x03
118
119 /*************************************************************
120         AVC respond types
121 **************************************************************///
122 #define NOT_IMPLEMENTED 0x8
123 #define ACCEPTED        0x9
124 #define REJECTED        0xA
125 #define STABLE          0xC
126 #define CHANGED         0xD
127 #define INTERIM         0xF
128
129 /*************************************************************
130         AVC opcodes
131 **************************************************************///
132 #define CONNECT                 0x24
133 #define DISCONNECT              0x25
134 #define UNIT_INFO               0x30
135 #define SUBUNIT_Info            0x31
136 #define VENDOR                  0x00
137
138 #define PLUG_INFO               0x02
139 #define OPEN_DESCRIPTOR         0x08
140 #define READ_DESCRIPTOR         0x09
141 #define OBJECT_NUMBER_SELECT    0x0D
142
143 /*************************************************************
144         AVCTuner opcodes
145 **************************************************************/
146
147 #define DSIT                            0xC8
148 #define DSD                             0xCB
149 #define DESCRIPTOR_TUNER_STATUS         0x80
150 #define DESCRIPTOR_SUBUNIT_IDENTIFIER   0x00
151
152 /*************************************************************
153         AVCTuner list types
154 **************************************************************/
155 #define Multiplex_List   0x80
156 #define Service_List     0x82
157
158 /*************************************************************
159         AVCTuner object entries
160 **************************************************************/
161 #define Multiplex                               0x80
162 #define Service                                 0x82
163 #define Service_with_specified_components       0x83
164 #define Preferred_components                    0x90
165 #define Component                               0x84
166
167 /*************************************************************
168         Vendor-specific commands
169 **************************************************************/
170
171 // digital everywhere vendor ID
172 #define SFE_VENDOR_DE_COMPANYID_0                       0x00
173 #define SFE_VENDOR_DE_COMPANYID_1                       0x12
174 #define SFE_VENDOR_DE_COMPANYID_2                       0x87
175
176 #define SFE_VENDOR_MAX_NR_COMPONENTS            0x4
177 #define SFE_VENDOR_MAX_NR_SERVICES                      0x3
178 #define SFE_VENDOR_MAX_NR_DSD_ELEMENTS          0x10
179
180 // vendor commands
181 #define SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL       0x0A
182 #define SFE_VENDOR_OPCODE_LNB_CONTROL           0x52
183 #define SFE_VENDOR_OPCODE_TUNE_QPSK                     0x58    // QPSK command for DVB-S
184
185 // TODO: following vendor specific commands needs to be implemented
186 #define SFE_VENDOR_OPCODE_GET_FIRMWARE_VERSION  0x00
187 #define SFE_VENDOR_OPCODE_HOST2CA                               0x56
188 #define SFE_VENDOR_OPCODE_CA2HOST                               0x57
189 #define SFE_VENDOR_OPCODE_CISTATUS                              0x59
190 #define SFE_VENDOR_OPCODE_TUNE_QPSK2                    0x60 // QPSK command for DVB-S2 devices
191
192 // CA Tags
193 #define SFE_VENDOR_TAG_CA_RESET                 0x00
194 #define SFE_VENDOR_TAG_CA_APPLICATION_INFO      0x01
195 #define SFE_VENDOR_TAG_CA_PMT                   0x02
196 #define SFE_VENDOR_TAG_CA_DATE_TIME             0x04
197 #define SFE_VENDOR_TAG_CA_MMI                   0x05
198 #define SFE_VENDOR_TAG_CA_ENTER_MENU            0x07
199
200
201 //AVCTuner DVB identifier service_ID
202 #define DVB 0x20
203
204 /*************************************************************
205                                                 AVC descriptor types
206 **************************************************************/
207
208 #define Subunit_Identifier_Descriptor            0x00
209 #define Tuner_Status_Descriptor                          0x80
210
211 typedef struct {
212         __u8          Subunit_Type;
213         __u8          Max_Subunit_ID;
214 } SUBUNIT_INFO;
215
216 /*************************************************************
217
218                 AVCTuner DVB object IDs are 6 byte long
219
220 **************************************************************/
221
222 typedef struct {
223         __u8  Byte0;
224         __u8  Byte1;
225         __u8  Byte2;
226         __u8  Byte3;
227         __u8  Byte4;
228         __u8  Byte5;
229 }OBJECT_ID;
230
231 /*************************************************************
232                                                 MULIPLEX Structs
233 **************************************************************/
234 typedef struct
235 {
236 #ifdef __LITTLE_ENDIAN
237         __u8       RF_frequency_hByte:6;
238         __u8       raster_Frequency:2;//Bit7,6 raster frequency
239 #else
240         __u8 raster_Frequency:2;
241         __u8 RF_frequency_hByte:6;
242 #endif
243         __u8       RF_frequency_mByte;
244         __u8       RF_frequency_lByte;
245
246 }FREQUENCY;
247
248 #ifdef __LITTLE_ENDIAN
249
250 typedef struct
251 {
252                  __u8        Modulation     :1;
253                  __u8        FEC_inner      :1;
254                  __u8        FEC_outer      :1;
255                  __u8        Symbol_Rate    :1;
256                  __u8        Frequency      :1;
257                  __u8        Orbital_Pos        :1;
258                  __u8        Polarisation       :1;
259                  __u8        reserved_fields :1;
260                  __u8        reserved1          :7;
261                  __u8        Network_ID :1;
262
263 }MULTIPLEX_VALID_FLAGS;
264
265 typedef struct
266 {
267         __u8    GuardInterval:1;
268         __u8    CodeRateLPStream:1;
269         __u8    CodeRateHPStream:1;
270         __u8    HierarchyInfo:1;
271         __u8    Constellation:1;
272         __u8    Bandwidth:1;
273         __u8    CenterFrequency:1;
274         __u8    reserved1:1;
275         __u8    reserved2:5;
276         __u8    OtherFrequencyFlag:1;
277         __u8    TransmissionMode:1;
278         __u8    NetworkId:1;
279 }MULTIPLEX_VALID_FLAGS_DVBT;
280
281 #else
282
283 typedef struct {
284         __u8 reserved_fields:1;
285         __u8 Polarisation:1;
286         __u8 Orbital_Pos:1;
287         __u8 Frequency:1;
288         __u8 Symbol_Rate:1;
289         __u8 FEC_outer:1;
290         __u8 FEC_inner:1;
291         __u8 Modulation:1;
292         __u8 Network_ID:1;
293         __u8 reserved1:7;
294 }MULTIPLEX_VALID_FLAGS;
295
296 typedef struct {
297         __u8 reserved1:1;
298         __u8 CenterFrequency:1;
299         __u8 Bandwidth:1;
300         __u8 Constellation:1;
301         __u8 HierarchyInfo:1;
302         __u8 CodeRateHPStream:1;
303         __u8 CodeRateLPStream:1;
304         __u8 GuardInterval:1;
305         __u8 NetworkId:1;
306         __u8 TransmissionMode:1;
307         __u8 OtherFrequencyFlag:1;
308         __u8 reserved2:5;
309 }MULTIPLEX_VALID_FLAGS_DVBT;
310
311 #endif
312
313 typedef union {
314         MULTIPLEX_VALID_FLAGS Bits;
315         MULTIPLEX_VALID_FLAGS_DVBT Bits_T;
316         struct {
317                 __u8    ByteHi;
318                 __u8    ByteLo;
319         } Valid_Word;
320 } M_VALID_FLAGS;
321
322 typedef struct
323 {
324 #ifdef __LITTLE_ENDIAN
325   __u8      ActiveSystem;
326   __u8      reserved:5;
327   __u8      NoRF:1;
328   __u8      Moving:1;
329   __u8      Searching:1;
330
331   __u8      SelectedAntenna:7;
332   __u8      Input:1;
333
334   __u8      BER[4];
335
336   __u8      SignalStrength;
337   FREQUENCY Frequency;
338
339   __u8      ManDepInfoLength;
340
341   __u8 PowerSupply:1;
342   __u8 FrontEndPowerStatus:1;
343   __u8 reserved3:1;
344   __u8 AntennaError:1;
345   __u8 FrontEndError:1;
346   __u8 reserved2:3;
347
348   __u8 CarrierNoiseRatio[2];
349   __u8 reserved4[2];
350   __u8 PowerSupplyVoltage;
351   __u8 AntennaVoltage;
352   __u8 FirewireBusVoltage;
353
354   __u8 CaMmi:1;
355   __u8 reserved5:7;
356
357   __u8 reserved6:1;
358   __u8 CaInitializationStatus:1;
359   __u8 CaErrorFlag:1;
360   __u8 CaDvbFlag:1;
361   __u8 CaModulePresentStatus:1;
362   __u8 CaApplicationInfo:1;
363   __u8 CaDateTimeRequest:1;
364   __u8 CaPmtReply:1;
365
366 #else
367   __u8 ActiveSystem;
368   __u8 Searching:1;
369   __u8 Moving:1;
370   __u8 NoRF:1;
371   __u8 reserved:5;
372
373   __u8 Input:1;
374   __u8 SelectedAntenna:7;
375
376   __u8 BER[4];
377
378   __u8 SignalStrength;
379   FREQUENCY Frequency;
380
381   __u8 ManDepInfoLength;
382
383   __u8 reserved2:3;
384   __u8 FrontEndError:1;
385   __u8 AntennaError:1;
386   __u8 reserved3:1;
387   __u8 FrontEndPowerStatus:1;
388   __u8 PowerSupply:1;
389
390   __u8 CarrierNoiseRatio[2];
391   __u8 reserved4[2];
392   __u8 PowerSupplyVoltage;
393   __u8 AntennaVoltage;
394   __u8 FirewireBusVoltage;
395
396   __u8 reserved5:7;
397   __u8 CaMmi:1;
398   __u8 CaPmtReply:1;
399   __u8 CaDateTimeRequest:1;
400   __u8 CaApplicationInfo:1;
401   __u8 CaModulePresentStatus:1;
402   __u8 CaDvbFlag:1;
403   __u8 CaErrorFlag:1;
404   __u8 CaInitializationStatus:1;
405   __u8 reserved6:1;
406
407 #endif
408 } ANTENNA_INPUT_INFO; // 22 Byte
409
410 #define LNBCONTROL_DONTCARE 0xff
411
412 struct dvb_diseqc_master_cmd;
413 struct dvb_frontend_parameters;
414 struct firesat;
415
416 int AVCWrite(struct firesat *firesat, const AVCCmdFrm *CmdFrm,
417                 AVCRspFrm *RspFrm);
418 int AVCRecv(struct firesat *firesat, u8 *data, size_t length);
419
420 int AVCTuner_DSIT(struct firesat *firesat, int Source_Plug,
421                 struct dvb_frontend_parameters *params, __u8 *status);
422
423 int AVCTunerStatus(struct firesat *firesat,
424                 ANTENNA_INPUT_INFO *antenna_input_info);
425 int AVCTuner_DSD(struct firesat *firesat,
426                 struct dvb_frontend_parameters *params, __u8 *status);
427 int AVCTuner_SetPIDs(struct firesat *firesat, unsigned char pidc, u16 pid[]);
428 int AVCTuner_GetTS(struct firesat *firesat);
429
430 int AVCIdentifySubunit(struct firesat *firesat);
431 int AVCLNBControl(struct firesat *firesat, char voltage, char burst,
432                 char conttone, char nrdiseq,
433                 struct dvb_diseqc_master_cmd *diseqcmd);
434 int AVCSubUnitInfo(struct firesat *firesat, char *subunitcount);
435 void avc_remote_ctrl_work(struct work_struct *work);
436 int AVCRegisterRemoteControl(struct firesat *firesat);
437 int AVCTuner_Host2Ca(struct firesat *firesat);
438 int avc_ca_app_info(struct firesat *firesat, char *app_info, int *length);
439 int avc_ca_info(struct firesat *firesat, char *app_info, int *length);
440 int avc_ca_reset(struct firesat *firesat);
441 int avc_ca_pmt(struct firesat *firesat, char *app_info, int length);
442 int avc_ca_get_time_date(struct firesat *firesat, int *interval);
443 int avc_ca_enter_menu(struct firesat *firesat);
444 int avc_ca_get_mmi(struct firesat *firesat, char *mmi_object, int *length);
445
446 #endif /* _AVC_API_H */