firedtv: cleanups and minor fixes
[linux-2.6-block.git] / drivers / media / dvb / firesat / avc_api.h
CommitLineData
c81c8b68 1/*
612262a5
SR
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>
c81c8b68 23
df4846c3
HK
24/*************************************************************
25 Constants from EN510221
26**************************************************************/
27#define LIST_MANAGEMENT_ONLY 0x03
c81c8b68 28
c81c8b68
GKH
29/************************************************************
30 definition of structures
31*************************************************************/
32typedef struct {
33 int Nr_SourcePlugs;
34 int Nr_DestinationPlugs;
35} TunerInfo;
36
37
38/***********************************************
39
40 supported cts
41
42************************************************/
43
44#define AVC 0x0
45
46// FCP command frame with ctype = 0x0 is AVC command frame
47
48#ifdef __LITTLE_ENDIAN
49
50// Definition FCP Command Frame
51typedef struct _AVCCmdFrm
52{
53 // AV/C command frame
df4846c3
HK
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]
c81c8b68
GKH
60 int length; //length of the command frame
61} AVCCmdFrm ;
62
63// Definition FCP Response Frame
64typedef struct _AVCRspFrm
65{
66 // AV/C response frame
df4846c3
HK
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]
c81c8b68
GKH
73 int length; //length of the response frame
74} AVCRspFrm ;
75
76#else
77
78typedef struct _AVCCmdFrm
79{
df4846c3
HK
80 __u8 cts:4;
81 __u8 ctype:4;
82 __u8 sutyp:5;
83 __u8 suid:3;
84 __u8 opcode;
85 __u8 operand[509];
c81c8b68
GKH
86 int length;
87} AVCCmdFrm;
88
89typedef struct _AVCRspFrm
90{
df4846c3
HK
91 __u8 cts:4;
92 __u8 resp:4;
93 __u8 sutyp:5;
94 __u8 suid:3;
95 __u8 opcode;
96 __u8 operand[509];
c81c8b68
GKH
97 int length;
98} AVCRspFrm;
99
100#endif
101
102/*************************************************************
103 AVC command types (ctype)
104**************************************************************///
105#define CONTROL 0x00
106#define STATUS 0x01
107#define INQUIRY 0x02
108#define NOTIFY 0x03
109
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
119
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
128
129#define PLUG_INFO 0x02
130#define OPEN_DESCRIPTOR 0x08
131#define READ_DESCRIPTOR 0x09
132#define OBJECT_NUMBER_SELECT 0x0D
133
134/*************************************************************
135 AVCTuner opcodes
136**************************************************************/
137
138#define DSIT 0xC8
139#define DSD 0xCB
140#define DESCRIPTOR_TUNER_STATUS 0x80
141#define DESCRIPTOR_SUBUNIT_IDENTIFIER 0x00
142
143/*************************************************************
144 AVCTuner list types
145**************************************************************/
146#define Multiplex_List 0x80
147#define Service_List 0x82
148
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
157
158/*************************************************************
159 Vendor-specific commands
160**************************************************************/
161
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
166
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
170
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
175
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
182
df4846c3
HK
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
190
c81c8b68
GKH
191
192//AVCTuner DVB identifier service_ID
193#define DVB 0x20
194
195/*************************************************************
196 AVC descriptor types
197**************************************************************/
198
199#define Subunit_Identifier_Descriptor 0x00
200#define Tuner_Status_Descriptor 0x80
201
202typedef struct {
df4846c3
HK
203 __u8 Subunit_Type;
204 __u8 Max_Subunit_ID;
c81c8b68
GKH
205} SUBUNIT_INFO;
206
207/*************************************************************
208
209 AVCTuner DVB object IDs are 6 byte long
210
211**************************************************************/
212
213typedef struct {
df4846c3
HK
214 __u8 Byte0;
215 __u8 Byte1;
216 __u8 Byte2;
217 __u8 Byte3;
218 __u8 Byte4;
219 __u8 Byte5;
c81c8b68
GKH
220}OBJECT_ID;
221
222/*************************************************************
223 MULIPLEX Structs
224**************************************************************/
225typedef struct
226{
227#ifdef __LITTLE_ENDIAN
df4846c3
HK
228 __u8 RF_frequency_hByte:6;
229 __u8 raster_Frequency:2;//Bit7,6 raster frequency
c81c8b68 230#else
df4846c3
HK
231 __u8 raster_Frequency:2;
232 __u8 RF_frequency_hByte:6;
c81c8b68 233#endif
df4846c3
HK
234 __u8 RF_frequency_mByte;
235 __u8 RF_frequency_lByte;
c81c8b68
GKH
236
237}FREQUENCY;
238
239#ifdef __LITTLE_ENDIAN
240
241typedef struct
242{
df4846c3
HK
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;
c81c8b68
GKH
253
254}MULTIPLEX_VALID_FLAGS;
255
256typedef struct
257{
df4846c3
HK
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;
c81c8b68
GKH
270}MULTIPLEX_VALID_FLAGS_DVBT;
271
272#else
273
274typedef struct {
df4846c3
HK
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;
c81c8b68
GKH
285}MULTIPLEX_VALID_FLAGS;
286
287typedef struct {
df4846c3
HK
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;
c81c8b68
GKH
300}MULTIPLEX_VALID_FLAGS_DVBT;
301
302#endif
303
304typedef union {
305 MULTIPLEX_VALID_FLAGS Bits;
306 MULTIPLEX_VALID_FLAGS_DVBT Bits_T;
307 struct {
df4846c3
HK
308 __u8 ByteHi;
309 __u8 ByteLo;
c81c8b68
GKH
310 } Valid_Word;
311} M_VALID_FLAGS;
312
313typedef struct
314{
315#ifdef __LITTLE_ENDIAN
df4846c3
HK
316 __u8 ActiveSystem;
317 __u8 reserved:5;
318 __u8 NoRF:1;
319 __u8 Moving:1;
320 __u8 Searching:1;
c81c8b68 321
df4846c3
HK
322 __u8 SelectedAntenna:7;
323 __u8 Input:1;
c81c8b68 324
df4846c3 325 __u8 BER[4];
c81c8b68 326
df4846c3 327 __u8 SignalStrength;
c81c8b68
GKH
328 FREQUENCY Frequency;
329
df4846c3
HK
330 __u8 ManDepInfoLength;
331
332 __u8 PowerSupply:1;
333 __u8 FrontEndPowerStatus:1;
334 __u8 reserved3:1;
335 __u8 AntennaError:1;
336 __u8 FrontEndError:1;
337 __u8 reserved2:3;
338
339 __u8 CarrierNoiseRatio[2];
340 __u8 reserved4[2];
341 __u8 PowerSupplyVoltage;
342 __u8 AntennaVoltage;
343 __u8 FirewireBusVoltage;
344
345 __u8 CaMmi:1;
346 __u8 reserved5:7;
347
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;
356
c81c8b68 357#else
df4846c3
HK
358 __u8 ActiveSystem;
359 __u8 Searching:1;
360 __u8 Moving:1;
361 __u8 NoRF:1;
362 __u8 reserved:5;
c81c8b68 363
df4846c3
HK
364 __u8 Input:1;
365 __u8 SelectedAntenna:7;
c81c8b68 366
df4846c3 367 __u8 BER[4];
c81c8b68 368
df4846c3 369 __u8 SignalStrength;
c81c8b68
GKH
370 FREQUENCY Frequency;
371
df4846c3
HK
372 __u8 ManDepInfoLength;
373
374 __u8 reserved2:3;
375 __u8 FrontEndError:1;
376 __u8 AntennaError:1;
377 __u8 reserved3:1;
378 __u8 FrontEndPowerStatus:1;
379 __u8 PowerSupply:1;
380
381 __u8 CarrierNoiseRatio[2];
382 __u8 reserved4[2];
383 __u8 PowerSupplyVoltage;
384 __u8 AntennaVoltage;
385 __u8 FirewireBusVoltage;
386
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;
397
c81c8b68 398#endif
df4846c3 399} ANTENNA_INPUT_INFO; // 22 Byte
c81c8b68
GKH
400
401#define LNBCONTROL_DONTCARE 0xff
402
612262a5
SR
403struct dvb_diseqc_master_cmd;
404struct dvb_frontend_parameters;
405struct firesat;
406
8ae83cdf 407int avc_recv(struct firesat *firesat, u8 *data, size_t length);
612262a5
SR
408
409int AVCTuner_DSIT(struct firesat *firesat, int Source_Plug,
410 struct dvb_frontend_parameters *params, __u8 *status);
411
8ae83cdf 412int avc_tuner_status(struct firesat *firesat,
612262a5 413 ANTENNA_INPUT_INFO *antenna_input_info);
8ae83cdf
SR
414int avc_tuner_dsd(struct firesat *firesat,
415 struct dvb_frontend_parameters *params);
416int avc_tuner_set_pids(struct firesat *firesat, unsigned char pidc, u16 pid[]);
417int avc_tuner_get_ts(struct firesat *firesat);
418int avc_identify_subunit(struct firesat *firesat);
419int avc_lnb_control(struct firesat *firesat, char voltage, char burst,
612262a5
SR
420 char conttone, char nrdiseq,
421 struct dvb_diseqc_master_cmd *diseqcmd);
612262a5 422void avc_remote_ctrl_work(struct work_struct *work);
8ae83cdf
SR
423int avc_register_remote_control(struct firesat *firesat);
424int avc_ca_app_info(struct firesat *firesat, char *app_info, unsigned int *len);
425int avc_ca_info(struct firesat *firesat, char *app_info, unsigned int *len);
612262a5
SR
426int avc_ca_reset(struct firesat *firesat);
427int avc_ca_pmt(struct firesat *firesat, char *app_info, int length);
428int avc_ca_get_time_date(struct firesat *firesat, int *interval);
429int avc_ca_enter_menu(struct firesat *firesat);
8ae83cdf 430int avc_ca_get_mmi(struct firesat *firesat, char *mmi_object, unsigned int *len);
612262a5
SR
431
432#endif /* _AVC_API_H */