avc_api.h 11 KB

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