firedtv: cleanups and minor fixes
[linux-2.6/mini2440.git] / drivers / media / dvb / firesat / avc_api.h
blob9d2efd8ff17b3af318a3ea1138b6846a35d7ddc9
1 /*
2 * AV/C API
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>
10 * This is based on code written by Peter Halwachs, Thomas Groiss and
11 * Andreas Monitzer.
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.
19 #ifndef _AVC_API_H
20 #define _AVC_API_H
22 #include <linux/types.h>
24 /*************************************************************
25 Constants from EN510221
26 **************************************************************/
27 #define LIST_MANAGEMENT_ONLY 0x03
29 /************************************************************
30 definition of structures
31 *************************************************************/
32 typedef struct {
33 int Nr_SourcePlugs;
34 int Nr_DestinationPlugs;
35 } TunerInfo;
38 /***********************************************
40 supported cts
42 ************************************************/
44 #define AVC 0x0
46 // FCP command frame with ctype = 0x0 is AVC command frame
48 #ifdef __LITTLE_ENDIAN
50 // Definition FCP Command Frame
51 typedef struct _AVCCmdFrm
53 // AV/C command frame
54 __u8 ctype : 4 ; // command type
55 __u8 cts : 4 ; // always 0x0 for AVC
56 __u8 suid : 3 ; // subunit ID
57 __u8 sutyp : 5 ; // subunit_typ
58 __u8 opcode : 8 ; // opcode
59 __u8 operand[509] ; // array of operands [1-507]
60 int length; //length of the command frame
61 } AVCCmdFrm ;
63 // Definition FCP Response Frame
64 typedef struct _AVCRspFrm
66 // AV/C response frame
67 __u8 resp : 4 ; // response type
68 __u8 cts : 4 ; // always 0x0 for AVC
69 __u8 suid : 3 ; // subunit ID
70 __u8 sutyp : 5 ; // subunit_typ
71 __u8 opcode : 8 ; // opcode
72 __u8 operand[509] ; // array of operands [1-507]
73 int length; //length of the response frame
74 } AVCRspFrm ;
76 #else
78 typedef struct _AVCCmdFrm
80 __u8 cts:4;
81 __u8 ctype:4;
82 __u8 sutyp:5;
83 __u8 suid:3;
84 __u8 opcode;
85 __u8 operand[509];
86 int length;
87 } AVCCmdFrm;
89 typedef struct _AVCRspFrm
91 __u8 cts:4;
92 __u8 resp:4;
93 __u8 sutyp:5;
94 __u8 suid:3;
95 __u8 opcode;
96 __u8 operand[509];
97 int length;
98 } AVCRspFrm;
100 #endif
102 /*************************************************************
103 AVC command types (ctype)
104 **************************************************************///
105 #define CONTROL 0x00
106 #define STATUS 0x01
107 #define INQUIRY 0x02
108 #define NOTIFY 0x03
110 /*************************************************************
111 AVC respond types
112 **************************************************************///
113 #define NOT_IMPLEMENTED 0x8
114 #define ACCEPTED 0x9
115 #define REJECTED 0xA
116 #define STABLE 0xC
117 #define CHANGED 0xD
118 #define INTERIM 0xF
120 /*************************************************************
121 AVC opcodes
122 **************************************************************///
123 #define CONNECT 0x24
124 #define DISCONNECT 0x25
125 #define UNIT_INFO 0x30
126 #define SUBUNIT_Info 0x31
127 #define VENDOR 0x00
129 #define PLUG_INFO 0x02
130 #define OPEN_DESCRIPTOR 0x08
131 #define READ_DESCRIPTOR 0x09
132 #define OBJECT_NUMBER_SELECT 0x0D
134 /*************************************************************
135 AVCTuner opcodes
136 **************************************************************/
138 #define DSIT 0xC8
139 #define DSD 0xCB
140 #define DESCRIPTOR_TUNER_STATUS 0x80
141 #define DESCRIPTOR_SUBUNIT_IDENTIFIER 0x00
143 /*************************************************************
144 AVCTuner list types
145 **************************************************************/
146 #define Multiplex_List 0x80
147 #define Service_List 0x82
149 /*************************************************************
150 AVCTuner object entries
151 **************************************************************/
152 #define Multiplex 0x80
153 #define Service 0x82
154 #define Service_with_specified_components 0x83
155 #define Preferred_components 0x90
156 #define Component 0x84
158 /*************************************************************
159 Vendor-specific commands
160 **************************************************************/
162 // digital everywhere vendor ID
163 #define SFE_VENDOR_DE_COMPANYID_0 0x00
164 #define SFE_VENDOR_DE_COMPANYID_1 0x12
165 #define SFE_VENDOR_DE_COMPANYID_2 0x87
167 #define SFE_VENDOR_MAX_NR_COMPONENTS 0x4
168 #define SFE_VENDOR_MAX_NR_SERVICES 0x3
169 #define SFE_VENDOR_MAX_NR_DSD_ELEMENTS 0x10
171 // vendor commands
172 #define SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL 0x0A
173 #define SFE_VENDOR_OPCODE_LNB_CONTROL 0x52
174 #define SFE_VENDOR_OPCODE_TUNE_QPSK 0x58 // QPSK command for DVB-S
176 // TODO: following vendor specific commands needs to be implemented
177 #define SFE_VENDOR_OPCODE_GET_FIRMWARE_VERSION 0x00
178 #define SFE_VENDOR_OPCODE_HOST2CA 0x56
179 #define SFE_VENDOR_OPCODE_CA2HOST 0x57
180 #define SFE_VENDOR_OPCODE_CISTATUS 0x59
181 #define SFE_VENDOR_OPCODE_TUNE_QPSK2 0x60 // QPSK command for DVB-S2 devices
183 // CA Tags
184 #define SFE_VENDOR_TAG_CA_RESET 0x00
185 #define SFE_VENDOR_TAG_CA_APPLICATION_INFO 0x01
186 #define SFE_VENDOR_TAG_CA_PMT 0x02
187 #define SFE_VENDOR_TAG_CA_DATE_TIME 0x04
188 #define SFE_VENDOR_TAG_CA_MMI 0x05
189 #define SFE_VENDOR_TAG_CA_ENTER_MENU 0x07
192 //AVCTuner DVB identifier service_ID
193 #define DVB 0x20
195 /*************************************************************
196 AVC descriptor types
197 **************************************************************/
199 #define Subunit_Identifier_Descriptor 0x00
200 #define Tuner_Status_Descriptor 0x80
202 typedef struct {
203 __u8 Subunit_Type;
204 __u8 Max_Subunit_ID;
205 } SUBUNIT_INFO;
207 /*************************************************************
209 AVCTuner DVB object IDs are 6 byte long
211 **************************************************************/
213 typedef struct {
214 __u8 Byte0;
215 __u8 Byte1;
216 __u8 Byte2;
217 __u8 Byte3;
218 __u8 Byte4;
219 __u8 Byte5;
220 }OBJECT_ID;
222 /*************************************************************
223 MULIPLEX Structs
224 **************************************************************/
225 typedef struct
227 #ifdef __LITTLE_ENDIAN
228 __u8 RF_frequency_hByte:6;
229 __u8 raster_Frequency:2;//Bit7,6 raster frequency
230 #else
231 __u8 raster_Frequency:2;
232 __u8 RF_frequency_hByte:6;
233 #endif
234 __u8 RF_frequency_mByte;
235 __u8 RF_frequency_lByte;
237 }FREQUENCY;
239 #ifdef __LITTLE_ENDIAN
241 typedef struct
243 __u8 Modulation :1;
244 __u8 FEC_inner :1;
245 __u8 FEC_outer :1;
246 __u8 Symbol_Rate :1;
247 __u8 Frequency :1;
248 __u8 Orbital_Pos :1;
249 __u8 Polarisation :1;
250 __u8 reserved_fields :1;
251 __u8 reserved1 :7;
252 __u8 Network_ID :1;
254 }MULTIPLEX_VALID_FLAGS;
256 typedef struct
258 __u8 GuardInterval:1;
259 __u8 CodeRateLPStream:1;
260 __u8 CodeRateHPStream:1;
261 __u8 HierarchyInfo:1;
262 __u8 Constellation:1;
263 __u8 Bandwidth:1;
264 __u8 CenterFrequency:1;
265 __u8 reserved1:1;
266 __u8 reserved2:5;
267 __u8 OtherFrequencyFlag:1;
268 __u8 TransmissionMode:1;
269 __u8 NetworkId:1;
270 }MULTIPLEX_VALID_FLAGS_DVBT;
272 #else
274 typedef struct {
275 __u8 reserved_fields:1;
276 __u8 Polarisation:1;
277 __u8 Orbital_Pos:1;
278 __u8 Frequency:1;
279 __u8 Symbol_Rate:1;
280 __u8 FEC_outer:1;
281 __u8 FEC_inner:1;
282 __u8 Modulation:1;
283 __u8 Network_ID:1;
284 __u8 reserved1:7;
285 }MULTIPLEX_VALID_FLAGS;
287 typedef struct {
288 __u8 reserved1:1;
289 __u8 CenterFrequency:1;
290 __u8 Bandwidth:1;
291 __u8 Constellation:1;
292 __u8 HierarchyInfo:1;
293 __u8 CodeRateHPStream:1;
294 __u8 CodeRateLPStream:1;
295 __u8 GuardInterval:1;
296 __u8 NetworkId:1;
297 __u8 TransmissionMode:1;
298 __u8 OtherFrequencyFlag:1;
299 __u8 reserved2:5;
300 }MULTIPLEX_VALID_FLAGS_DVBT;
302 #endif
304 typedef union {
305 MULTIPLEX_VALID_FLAGS Bits;
306 MULTIPLEX_VALID_FLAGS_DVBT Bits_T;
307 struct {
308 __u8 ByteHi;
309 __u8 ByteLo;
310 } Valid_Word;
311 } M_VALID_FLAGS;
313 typedef struct
315 #ifdef __LITTLE_ENDIAN
316 __u8 ActiveSystem;
317 __u8 reserved:5;
318 __u8 NoRF:1;
319 __u8 Moving:1;
320 __u8 Searching:1;
322 __u8 SelectedAntenna:7;
323 __u8 Input:1;
325 __u8 BER[4];
327 __u8 SignalStrength;
328 FREQUENCY Frequency;
330 __u8 ManDepInfoLength;
332 __u8 PowerSupply:1;
333 __u8 FrontEndPowerStatus:1;
334 __u8 reserved3:1;
335 __u8 AntennaError:1;
336 __u8 FrontEndError:1;
337 __u8 reserved2:3;
339 __u8 CarrierNoiseRatio[2];
340 __u8 reserved4[2];
341 __u8 PowerSupplyVoltage;
342 __u8 AntennaVoltage;
343 __u8 FirewireBusVoltage;
345 __u8 CaMmi:1;
346 __u8 reserved5:7;
348 __u8 reserved6:1;
349 __u8 CaInitializationStatus:1;
350 __u8 CaErrorFlag:1;
351 __u8 CaDvbFlag:1;
352 __u8 CaModulePresentStatus:1;
353 __u8 CaApplicationInfo:1;
354 __u8 CaDateTimeRequest:1;
355 __u8 CaPmtReply:1;
357 #else
358 __u8 ActiveSystem;
359 __u8 Searching:1;
360 __u8 Moving:1;
361 __u8 NoRF:1;
362 __u8 reserved:5;
364 __u8 Input:1;
365 __u8 SelectedAntenna:7;
367 __u8 BER[4];
369 __u8 SignalStrength;
370 FREQUENCY Frequency;
372 __u8 ManDepInfoLength;
374 __u8 reserved2:3;
375 __u8 FrontEndError:1;
376 __u8 AntennaError:1;
377 __u8 reserved3:1;
378 __u8 FrontEndPowerStatus:1;
379 __u8 PowerSupply:1;
381 __u8 CarrierNoiseRatio[2];
382 __u8 reserved4[2];
383 __u8 PowerSupplyVoltage;
384 __u8 AntennaVoltage;
385 __u8 FirewireBusVoltage;
387 __u8 reserved5:7;
388 __u8 CaMmi:1;
389 __u8 CaPmtReply:1;
390 __u8 CaDateTimeRequest:1;
391 __u8 CaApplicationInfo:1;
392 __u8 CaModulePresentStatus:1;
393 __u8 CaDvbFlag:1;
394 __u8 CaErrorFlag:1;
395 __u8 CaInitializationStatus:1;
396 __u8 reserved6:1;
398 #endif
399 } ANTENNA_INPUT_INFO; // 22 Byte
401 #define LNBCONTROL_DONTCARE 0xff
403 struct dvb_diseqc_master_cmd;
404 struct dvb_frontend_parameters;
405 struct firesat;
407 int avc_recv(struct firesat *firesat, u8 *data, size_t length);
409 int AVCTuner_DSIT(struct firesat *firesat, int Source_Plug,
410 struct dvb_frontend_parameters *params, __u8 *status);
412 int avc_tuner_status(struct firesat *firesat,
413 ANTENNA_INPUT_INFO *antenna_input_info);
414 int avc_tuner_dsd(struct firesat *firesat,
415 struct dvb_frontend_parameters *params);
416 int avc_tuner_set_pids(struct firesat *firesat, unsigned char pidc, u16 pid[]);
417 int avc_tuner_get_ts(struct firesat *firesat);
418 int avc_identify_subunit(struct firesat *firesat);
419 int avc_lnb_control(struct firesat *firesat, char voltage, char burst,
420 char conttone, char nrdiseq,
421 struct dvb_diseqc_master_cmd *diseqcmd);
422 void avc_remote_ctrl_work(struct work_struct *work);
423 int avc_register_remote_control(struct firesat *firesat);
424 int avc_ca_app_info(struct firesat *firesat, char *app_info, unsigned int *len);
425 int avc_ca_info(struct firesat *firesat, char *app_info, unsigned int *len);
426 int avc_ca_reset(struct firesat *firesat);
427 int avc_ca_pmt(struct firesat *firesat, char *app_info, int length);
428 int avc_ca_get_time_date(struct firesat *firesat, int *interval);
429 int avc_ca_enter_menu(struct firesat *firesat);
430 int avc_ca_get_mmi(struct firesat *firesat, char *mmi_object, unsigned int *len);
432 #endif /* _AVC_API_H */