avc_api.h 12 KB

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