avc.h 11 KB

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