aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/dvb/firesat/avc_api.h
blob: f9a190adcd37c2b79996d0c7f3c386c913375d68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/***************************************************************************
                          avc_api.h  -  description
                             -------------------
    begin                : Wed May 1 2000
    copyright            : (C) 2000 by Manfred Weihs
    copyright            : (C) 2003 by Philipp Gutgsell
    email                : 0014guph@edu.fh-kaernten.ac.at
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

/*
 This is based on code written by Peter Halwachs,
 Thomas Groiss and Andreas Monitzer.
*/


#ifndef __AVC_API_H__
#define __AVC_API_H__

#include <linux/dvb/frontend.h>

#define BYTE	unsigned char
#define WORD	unsigned short
#define DWORD	unsigned long
#define ULONG	unsigned long
#define LONG	long


/*************************************************************
	FCP Address range
**************************************************************/

#define RESPONSE_REGISTER	0xFFFFF0000D00ULL
#define COMMAND_REGISTER	0xFFFFF0000B00ULL
#define PCR_BASE_ADDRESS	0xFFFFF0000900ULL


/************************************************************
	definition of structures
*************************************************************/
typedef struct {
	   int           Nr_SourcePlugs;
	   int 	         Nr_DestinationPlugs;
} TunerInfo;


/***********************************************

         supported cts

************************************************/

#define AVC  0x0

// FCP command frame with ctype = 0x0 is AVC command frame

#ifdef __LITTLE_ENDIAN

// Definition FCP Command Frame
typedef struct _AVCCmdFrm
{
		// AV/C command frame
	BYTE ctype  : 4 ;   // command type
	BYTE cts    : 4 ;   // always 0x0 for AVC
	BYTE suid   : 3 ;   // subunit ID
	BYTE sutyp  : 5 ;   // subunit_typ
	BYTE opcode : 8 ;   // opcode
	BYTE operand[509] ; // array of operands [1-507]
	int length;         //length of the command frame
} AVCCmdFrm ;

// Definition FCP Response Frame
typedef struct _AVCRspFrm
{
        // AV/C response frame
	BYTE resp		: 4 ;   // response type
	BYTE cts		: 4 ;   // always 0x0 for AVC
	BYTE suid		: 3 ;   // subunit ID
	BYTE sutyp	: 5 ;   // subunit_typ
	BYTE opcode	: 8 ;   // opcode
	BYTE operand[509] ; // array of operands [1-507]
	int length;         //length of the response frame
} AVCRspFrm ;

#else

typedef struct _AVCCmdFrm
{
	BYTE cts:4;
	BYTE ctype:4;
	BYTE sutyp:5;
	BYTE suid:3;
	BYTE opcode;
	BYTE operand[509];
	int length;
} AVCCmdFrm;

typedef struct _AVCRspFrm
{
	BYTE cts:4;
	BYTE resp:4;
	BYTE sutyp:5;
	BYTE suid:3;
	BYTE opcode;
	BYTE operand[509];
	int length;
} AVCRspFrm;

#endif

/*************************************************************
	AVC command types (ctype)
**************************************************************///
#define CONTROL    0x00
#define STATUS     0x01
#define INQUIRY    0x02
#define NOTIFY     0x03

/*************************************************************
	AVC respond types
**************************************************************///
#define NOT_IMPLEMENTED 0x8
#define ACCEPTED        0x9
#define REJECTED        0xA
#define STABLE          0xC
#define CHANGED         0xD
#define INTERIM         0xF

/*************************************************************
	AVC opcodes
**************************************************************///
#define CONNECT			0x24
#define DISCONNECT		0x25
#define UNIT_INFO		0x30
#define SUBUNIT_Info		0x31
#define VENDOR			0x00

#define PLUG_INFO		0x02
#define OPEN_DESCRIPTOR		0x08
#define READ_DESCRIPTOR		0x09
#define OBJECT_NUMBER_SELECT	0x0D

/*************************************************************
	AVCTuner opcodes
**************************************************************/

#define DSIT				0xC8
#define DSD				0xCB
#define DESCRIPTOR_TUNER_STATUS 	0x80
#define DESCRIPTOR_SUBUNIT_IDENTIFIER	0x00

/*************************************************************
	AVCTuner list types
**************************************************************/
#define Multiplex_List   0x80
#define Service_List     0x82

/*************************************************************
	AVCTuner object entries
**************************************************************/
#define Multiplex	 			0x80
#define Service 	 			0x82
#define Service_with_specified_components	0x83
#define Preferred_components			0x90
#define Component				0x84

/*************************************************************
	Vendor-specific commands
**************************************************************/

// digital everywhere vendor ID
#define SFE_VENDOR_DE_COMPANYID_0			0x00
#define SFE_VENDOR_DE_COMPANYID_1			0x12
#define SFE_VENDOR_DE_COMPANYID_2			0x87

#define SFE_VENDOR_MAX_NR_COMPONENTS		0x4
#define SFE_VENDOR_MAX_NR_SERVICES			0x3
#define SFE_VENDOR_MAX_NR_DSD_ELEMENTS		0x10

// vendor commands
#define SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL	0x0A
#define SFE_VENDOR_OPCODE_LNB_CONTROL		0x52
#define SFE_VENDOR_OPCODE_TUNE_QPSK			0x58	// QPSK command for DVB-S

// TODO: following vendor specific commands needs to be implemented
#define SFE_VENDOR_OPCODE_GET_FIRMWARE_VERSION	0x00
#define SFE_VENDOR_OPCODE_HOST2CA				0x56
#define SFE_VENDOR_OPCODE_CA2HOST				0x57
#define SFE_VENDOR_OPCODE_CISTATUS				0x59
#define SFE_VENDOR_OPCODE_TUNE_QPSK2			0x60 // QPSK command for DVB-S2 devices


//AVCTuner DVB identifier service_ID
#define DVB 0x20

/*************************************************************
						AVC descriptor types
**************************************************************/

#define Subunit_Identifier_Descriptor		 0x00
#define Tuner_Status_Descriptor				 0x80

typedef struct {
	BYTE          Subunit_Type;
	BYTE          Max_Subunit_ID;
} SUBUNIT_INFO;

/*************************************************************

		AVCTuner DVB object IDs are 6 byte long

**************************************************************/

typedef struct {
	BYTE  Byte0;
	BYTE  Byte1;
	BYTE  Byte2;
	BYTE  Byte3;
	BYTE  Byte4;
	BYTE  Byte5;
}OBJECT_ID;

/*************************************************************
						MULIPLEX Structs
**************************************************************/
typedef struct
{
#ifdef __LITTLE_ENDIAN
	BYTE       RF_frequency_hByte:6;
	BYTE       raster_Frequency:2;//Bit7,6 raster frequency
#else
	BYTE raster_Frequency:2;
	BYTE RF_frequency_hByte:6;
#endif
	BYTE       RF_frequency_mByte;
	BYTE       RF_frequency_lByte;

}FREQUENCY;

#ifdef __LITTLE_ENDIAN

typedef struct
{
		 BYTE        Modulation	    :1;
		 BYTE        FEC_inner	    :1;
		 BYTE        FEC_outer	    :1;
		 BYTE        Symbol_Rate    :1;
		 BYTE        Frequency	    :1;
		 BYTE        Orbital_Pos	:1;
		 BYTE        Polarisation	:1;
		 BYTE        reserved_fields :1;
		 BYTE        reserved1		:7;
		 BYTE        Network_ID	:1;

}MULTIPLEX_VALID_FLAGS;

typedef struct
{
	BYTE	GuardInterval:1;
	BYTE	CodeRateLPStream:1;
	BYTE	CodeRateHPStream:1;
	BYTE	HierarchyInfo:1;
	BYTE	Constellation:1;
	BYTE	Bandwidth:1;
	BYTE	CenterFrequency:1;
	BYTE	reserved1:1;
	BYTE	reserved2:5;
	BYTE	OtherFrequencyFlag:1;
	BYTE	TransmissionMode:1;
	BYTE	NetworkId:1;
}MULTIPLEX_VALID_FLAGS_DVBT;

#else

typedef struct {
	BYTE reserved_fields:1;
	BYTE Polarisation:1;
	BYTE Orbital_Pos:1;
	BYTE Frequency:1;
	BYTE Symbol_Rate:1;
	BYTE FEC_outer:1;
	BYTE FEC_inner:1;
	BYTE Modulation:1;
	BYTE Network_ID:1;
	BYTE reserved1:7;
}MULTIPLEX_VALID_FLAGS;

typedef struct {
	BYTE reserved1:1;
	BYTE CenterFrequency:1;
	BYTE Bandwidth:1;
	BYTE Constellation:1;
	BYTE HierarchyInfo:1;
	BYTE CodeRateHPStream:1;
	BYTE CodeRateLPStream:1;
	BYTE GuardInterval:1;
	BYTE NetworkId:1;
	BYTE TransmissionMode:1;
	BYTE OtherFrequencyFlag:1;
	BYTE reserved2:5;
}MULTIPLEX_VALID_FLAGS_DVBT;

#endif

typedef union {
	MULTIPLEX_VALID_FLAGS Bits;
	MULTIPLEX_VALID_FLAGS_DVBT Bits_T;
	struct {
		BYTE	ByteHi;
		BYTE	ByteLo;
	} Valid_Word;
} M_VALID_FLAGS;

typedef struct
{
#ifdef __LITTLE_ENDIAN
  BYTE      ActiveSystem;
  BYTE      reserved:5;
  BYTE      NoRF:1;
  BYTE      Moving:1;
  BYTE      Searching:1;

  BYTE      SelectedAntenna:7;
  BYTE      Input:1;

  BYTE      BER[4];

  BYTE      SignalStrength;
  FREQUENCY Frequency;

  BYTE      ManDepInfoLength;
#else
  BYTE ActiveSystem;
  BYTE Searching:1;
  BYTE Moving:1;
  BYTE NoRF:1;
  BYTE reserved:5;

  BYTE Input:1;
  BYTE SelectedAntenna:7;

  BYTE BER[4];

  BYTE SignalStrength;
  FREQUENCY Frequency;

  BYTE ManDepInfoLength;
#endif
} ANTENNA_INPUT_INFO; // 11 Byte

#define LNBCONTROL_DONTCARE 0xff


extern int AVCWrite(struct firesat *firesat, const AVCCmdFrm *CmdFrm, AVCRspFrm *RspFrm);
extern int AVCRecv(struct firesat *firesat, u8 *data, size_t length);

extern int AVCTuner_DSIT(struct firesat *firesat,
                           int Source_Plug,
						   struct dvb_frontend_parameters *params,
                           BYTE *status);

extern int AVCTunerStatus(struct firesat *firesat, ANTENNA_INPUT_INFO *antenna_input_info);
extern int AVCTuner_DSD(struct firesat *firesat, struct dvb_frontend_parameters *params, BYTE *status);
extern int AVCTuner_SetPIDs(struct firesat *firesat, unsigned char pidc, u16 pid[]);
extern int AVCTuner_GetTS(struct firesat *firesat);

extern int AVCIdentifySubunit(struct firesat *firesat, unsigned char *systemId, int *transport, int *has_ci);
extern int AVCLNBControl(struct firesat *firesat, char voltage, char burst, char conttone, char nrdiseq, struct dvb_diseqc_master_cmd *diseqcmd);
extern int AVCSubUnitInfo(struct firesat *firesat, char *subunitcount);
extern int AVCRegisterRemoteControl(struct firesat *firesat);

#endif