avc_api.h 10.7 KB
Newer Older
G
Greg Kroah-Hartman 已提交
1
/*
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 * AV/C API
 *
 * Copyright (C) 2000 Manfred Weihs
 * Copyright (C) 2003 Philipp Gutgsell <0014guph@edu.fh-kaernten.ac.at>
 * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
 * Copyright (C) 2008 Ben Backx <ben@bbackx.com>
 * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
 *
 * This is based on code written by Peter Halwachs, Thomas Groiss and
 * Andreas Monitzer.
 *
 *	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.
 */

#ifndef _AVC_API_H
#define _AVC_API_H

#include <linux/types.h>
G
Greg Kroah-Hartman 已提交
23

24 25 26 27
/*************************************************************
	Constants from EN510221
**************************************************************/
#define LIST_MANAGEMENT_ONLY 0x03
G
Greg Kroah-Hartman 已提交
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

/************************************************************
	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
54 55 56 57 58 59
	__u8 ctype  : 4 ;   // command type
	__u8 cts    : 4 ;   // always 0x0 for AVC
	__u8 suid   : 3 ;   // subunit ID
	__u8 sutyp  : 5 ;   // subunit_typ
	__u8 opcode : 8 ;   // opcode
	__u8 operand[509] ; // array of operands [1-507]
G
Greg Kroah-Hartman 已提交
60 61 62 63 64 65 66
	int length;         //length of the command frame
} AVCCmdFrm ;

// Definition FCP Response Frame
typedef struct _AVCRspFrm
{
        // AV/C response frame
67 68 69 70 71 72
	__u8 resp		: 4 ;   // response type
	__u8 cts		: 4 ;   // always 0x0 for AVC
	__u8 suid		: 3 ;   // subunit ID
	__u8 sutyp	: 5 ;   // subunit_typ
	__u8 opcode	: 8 ;   // opcode
	__u8 operand[509] ; // array of operands [1-507]
G
Greg Kroah-Hartman 已提交
73 74 75 76 77 78 79
	int length;         //length of the response frame
} AVCRspFrm ;

#else

typedef struct _AVCCmdFrm
{
80 81 82 83 84 85
	__u8 cts:4;
	__u8 ctype:4;
	__u8 sutyp:5;
	__u8 suid:3;
	__u8 opcode;
	__u8 operand[509];
G
Greg Kroah-Hartman 已提交
86 87 88 89 90
	int length;
} AVCCmdFrm;

typedef struct _AVCRspFrm
{
91 92 93 94 95 96
	__u8 cts:4;
	__u8 resp:4;
	__u8 sutyp:5;
	__u8 suid:3;
	__u8 opcode;
	__u8 operand[509];
G
Greg Kroah-Hartman 已提交
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
	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

183 184 185 186 187 188 189 190
// CA Tags
#define SFE_VENDOR_TAG_CA_RESET			0x00
#define SFE_VENDOR_TAG_CA_APPLICATION_INFO	0x01
#define SFE_VENDOR_TAG_CA_PMT			0x02
#define SFE_VENDOR_TAG_CA_DATE_TIME		0x04
#define SFE_VENDOR_TAG_CA_MMI			0x05
#define SFE_VENDOR_TAG_CA_ENTER_MENU		0x07

G
Greg Kroah-Hartman 已提交
191 192 193 194 195 196 197 198 199 200 201 202

//AVCTuner DVB identifier service_ID
#define DVB 0x20

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

#define Subunit_Identifier_Descriptor		 0x00
#define Tuner_Status_Descriptor				 0x80

typedef struct {
203 204
	__u8          Subunit_Type;
	__u8          Max_Subunit_ID;
G
Greg Kroah-Hartman 已提交
205 206 207 208 209 210 211 212 213
} SUBUNIT_INFO;

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

		AVCTuner DVB object IDs are 6 byte long

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

typedef struct {
214 215 216 217 218 219
	__u8  Byte0;
	__u8  Byte1;
	__u8  Byte2;
	__u8  Byte3;
	__u8  Byte4;
	__u8  Byte5;
G
Greg Kroah-Hartman 已提交
220 221 222 223 224 225 226 227
}OBJECT_ID;

/*************************************************************
						MULIPLEX Structs
**************************************************************/
typedef struct
{
#ifdef __LITTLE_ENDIAN
228 229
	__u8       RF_frequency_hByte:6;
	__u8       raster_Frequency:2;//Bit7,6 raster frequency
G
Greg Kroah-Hartman 已提交
230
#else
231 232
	__u8 raster_Frequency:2;
	__u8 RF_frequency_hByte:6;
G
Greg Kroah-Hartman 已提交
233
#endif
234 235
	__u8       RF_frequency_mByte;
	__u8       RF_frequency_lByte;
G
Greg Kroah-Hartman 已提交
236 237 238 239 240 241 242

}FREQUENCY;

#ifdef __LITTLE_ENDIAN

typedef struct
{
243 244 245 246 247 248 249 250 251 252
		 __u8        Modulation	    :1;
		 __u8        FEC_inner	    :1;
		 __u8        FEC_outer	    :1;
		 __u8        Symbol_Rate    :1;
		 __u8        Frequency	    :1;
		 __u8        Orbital_Pos	:1;
		 __u8        Polarisation	:1;
		 __u8        reserved_fields :1;
		 __u8        reserved1		:7;
		 __u8        Network_ID	:1;
G
Greg Kroah-Hartman 已提交
253 254 255 256 257

}MULTIPLEX_VALID_FLAGS;

typedef struct
{
258 259 260 261 262 263 264 265 266 267 268 269
	__u8	GuardInterval:1;
	__u8	CodeRateLPStream:1;
	__u8	CodeRateHPStream:1;
	__u8	HierarchyInfo:1;
	__u8	Constellation:1;
	__u8	Bandwidth:1;
	__u8	CenterFrequency:1;
	__u8	reserved1:1;
	__u8	reserved2:5;
	__u8	OtherFrequencyFlag:1;
	__u8	TransmissionMode:1;
	__u8	NetworkId:1;
G
Greg Kroah-Hartman 已提交
270 271 272 273 274
}MULTIPLEX_VALID_FLAGS_DVBT;

#else

typedef struct {
275 276 277 278 279 280 281 282 283 284
	__u8 reserved_fields:1;
	__u8 Polarisation:1;
	__u8 Orbital_Pos:1;
	__u8 Frequency:1;
	__u8 Symbol_Rate:1;
	__u8 FEC_outer:1;
	__u8 FEC_inner:1;
	__u8 Modulation:1;
	__u8 Network_ID:1;
	__u8 reserved1:7;
G
Greg Kroah-Hartman 已提交
285 286 287
}MULTIPLEX_VALID_FLAGS;

typedef struct {
288 289 290 291 292 293 294 295 296 297 298 299
	__u8 reserved1:1;
	__u8 CenterFrequency:1;
	__u8 Bandwidth:1;
	__u8 Constellation:1;
	__u8 HierarchyInfo:1;
	__u8 CodeRateHPStream:1;
	__u8 CodeRateLPStream:1;
	__u8 GuardInterval:1;
	__u8 NetworkId:1;
	__u8 TransmissionMode:1;
	__u8 OtherFrequencyFlag:1;
	__u8 reserved2:5;
G
Greg Kroah-Hartman 已提交
300 301 302 303 304 305 306 307
}MULTIPLEX_VALID_FLAGS_DVBT;

#endif

typedef union {
	MULTIPLEX_VALID_FLAGS Bits;
	MULTIPLEX_VALID_FLAGS_DVBT Bits_T;
	struct {
308 309
		__u8	ByteHi;
		__u8	ByteLo;
G
Greg Kroah-Hartman 已提交
310 311 312 313 314 315
	} Valid_Word;
} M_VALID_FLAGS;

typedef struct
{
#ifdef __LITTLE_ENDIAN
316 317 318 319 320
  __u8      ActiveSystem;
  __u8      reserved:5;
  __u8      NoRF:1;
  __u8      Moving:1;
  __u8      Searching:1;
G
Greg Kroah-Hartman 已提交
321

322 323
  __u8      SelectedAntenna:7;
  __u8      Input:1;
G
Greg Kroah-Hartman 已提交
324

325
  __u8      BER[4];
G
Greg Kroah-Hartman 已提交
326

327
  __u8      SignalStrength;
G
Greg Kroah-Hartman 已提交
328 329
  FREQUENCY Frequency;

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
  __u8      ManDepInfoLength;

  __u8 PowerSupply:1;
  __u8 FrontEndPowerStatus:1;
  __u8 reserved3:1;
  __u8 AntennaError:1;
  __u8 FrontEndError:1;
  __u8 reserved2:3;

  __u8 CarrierNoiseRatio[2];
  __u8 reserved4[2];
  __u8 PowerSupplyVoltage;
  __u8 AntennaVoltage;
  __u8 FirewireBusVoltage;

  __u8 CaMmi:1;
  __u8 reserved5:7;

  __u8 reserved6:1;
  __u8 CaInitializationStatus:1;
  __u8 CaErrorFlag:1;
  __u8 CaDvbFlag:1;
  __u8 CaModulePresentStatus:1;
  __u8 CaApplicationInfo:1;
  __u8 CaDateTimeRequest:1;
  __u8 CaPmtReply:1;

G
Greg Kroah-Hartman 已提交
357
#else
358 359 360 361 362
  __u8 ActiveSystem;
  __u8 Searching:1;
  __u8 Moving:1;
  __u8 NoRF:1;
  __u8 reserved:5;
G
Greg Kroah-Hartman 已提交
363

364 365
  __u8 Input:1;
  __u8 SelectedAntenna:7;
G
Greg Kroah-Hartman 已提交
366

367
  __u8 BER[4];
G
Greg Kroah-Hartman 已提交
368

369
  __u8 SignalStrength;
G
Greg Kroah-Hartman 已提交
370 371
  FREQUENCY Frequency;

372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
  __u8 ManDepInfoLength;

  __u8 reserved2:3;
  __u8 FrontEndError:1;
  __u8 AntennaError:1;
  __u8 reserved3:1;
  __u8 FrontEndPowerStatus:1;
  __u8 PowerSupply:1;

  __u8 CarrierNoiseRatio[2];
  __u8 reserved4[2];
  __u8 PowerSupplyVoltage;
  __u8 AntennaVoltage;
  __u8 FirewireBusVoltage;

  __u8 reserved5:7;
  __u8 CaMmi:1;
  __u8 CaPmtReply:1;
  __u8 CaDateTimeRequest:1;
  __u8 CaApplicationInfo:1;
  __u8 CaModulePresentStatus:1;
  __u8 CaDvbFlag:1;
  __u8 CaErrorFlag:1;
  __u8 CaInitializationStatus:1;
  __u8 reserved6:1;

G
Greg Kroah-Hartman 已提交
398
#endif
399
} ANTENNA_INPUT_INFO; // 22 Byte
G
Greg Kroah-Hartman 已提交
400 401 402

#define LNBCONTROL_DONTCARE 0xff

403 404 405 406
struct dvb_diseqc_master_cmd;
struct dvb_frontend_parameters;
struct firesat;

407
int avc_recv(struct firesat *firesat, u8 *data, size_t length);
408 409 410 411

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

412
int avc_tuner_status(struct firesat *firesat,
413
		ANTENNA_INPUT_INFO *antenna_input_info);
414 415 416 417 418 419
int avc_tuner_dsd(struct firesat *firesat,
		struct dvb_frontend_parameters *params);
int avc_tuner_set_pids(struct firesat *firesat, unsigned char pidc, u16 pid[]);
int avc_tuner_get_ts(struct firesat *firesat);
int avc_identify_subunit(struct firesat *firesat);
int avc_lnb_control(struct firesat *firesat, char voltage, char burst,
420 421 422
		char conttone, char nrdiseq,
		struct dvb_diseqc_master_cmd *diseqcmd);
void avc_remote_ctrl_work(struct work_struct *work);
423 424 425
int avc_register_remote_control(struct firesat *firesat);
int avc_ca_app_info(struct firesat *firesat, char *app_info, unsigned int *len);
int avc_ca_info(struct firesat *firesat, char *app_info, unsigned int *len);
426 427 428 429
int avc_ca_reset(struct firesat *firesat);
int avc_ca_pmt(struct firesat *firesat, char *app_info, int length);
int avc_ca_get_time_date(struct firesat *firesat, int *interval);
int avc_ca_enter_menu(struct firesat *firesat);
430
int avc_ca_get_mmi(struct firesat *firesat, char *mmi_object, unsigned int *len);
431 432

#endif /* _AVC_API_H */