bcm3510_priv.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*
  2. * Support for the Broadcom BCM3510 ATSC demodulator (1st generation Air2PC)
  3. *
  4. * Copyright (C) 2001-5, B2C2 inc.
  5. *
  6. * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #ifndef __BCM3510_PRIV_H__
  23. #define __BCM3510_PRIV_H__
  24. #define PACKED __attribute__((packed))
  25. #undef err
  26. #define err(format, arg...) printk(KERN_ERR "bcm3510: " format "\n" , ## arg)
  27. #undef info
  28. #define info(format, arg...) printk(KERN_INFO "bcm3510: " format "\n" , ## arg)
  29. #undef warn
  30. #define warn(format, arg...) printk(KERN_WARNING "bcm3510: " format "\n" , ## arg)
  31. #define PANASONIC_FIRST_IF_BASE_IN_KHz 1407500
  32. #define BCM3510_SYMBOL_RATE 5381000
  33. typedef union {
  34. u8 raw;
  35. struct {
  36. u8 CTL :8;
  37. } TSTCTL_2e;
  38. u8 LDCERC_4e;
  39. u8 LDUERC_4f;
  40. u8 LD_BER0_65;
  41. u8 LD_BER1_66;
  42. u8 LD_BER2_67;
  43. u8 LD_BER3_68;
  44. struct {
  45. u8 RESET :1;
  46. u8 IDLE :1;
  47. u8 STOP :1;
  48. u8 HIRQ0 :1;
  49. u8 HIRQ1 :1;
  50. u8 na0 :1;
  51. u8 HABAV :1;
  52. u8 na1 :1;
  53. } HCTL1_a0;
  54. struct {
  55. u8 na0 :1;
  56. u8 IDLMSK :1;
  57. u8 STMSK :1;
  58. u8 I0MSK :1;
  59. u8 I1MSK :1;
  60. u8 na1 :1;
  61. u8 HABMSK :1;
  62. u8 na2 :1;
  63. } HCTLMSK_a1;
  64. struct {
  65. u8 RESET :1;
  66. u8 IDLE :1;
  67. u8 STOP :1;
  68. u8 RUN :1;
  69. u8 HABAV :1;
  70. u8 MEMAV :1;
  71. u8 ALDONE :1;
  72. u8 REIRQ :1;
  73. } APSTAT1_a2;
  74. struct {
  75. u8 RSTMSK :1;
  76. u8 IMSK :1;
  77. u8 SMSK :1;
  78. u8 RMSK :1;
  79. u8 HABMSK :1;
  80. u8 MAVMSK :1;
  81. u8 ALDMSK :1;
  82. u8 REMSK :1;
  83. } APMSK1_a3;
  84. u8 APSTAT2_a4;
  85. u8 APMSK2_a5;
  86. struct {
  87. u8 HABADR :7;
  88. u8 na :1;
  89. } HABADR_a6;
  90. u8 HABDATA_a7;
  91. struct {
  92. u8 HABR :1;
  93. u8 LDHABR :1;
  94. u8 APMSK :1;
  95. u8 HMSK :1;
  96. u8 LDMSK :1;
  97. u8 na :3;
  98. } HABSTAT_a8;
  99. u8 MADRH_a9;
  100. u8 MADRL_aa;
  101. u8 MDATA_ab;
  102. struct {
  103. #define JDEC_WAIT_AT_RAM 0x7
  104. #define JDEC_EEPROM_LOAD_WAIT 0x4
  105. u8 JDEC :3;
  106. u8 na :5;
  107. } JDEC_ca;
  108. struct {
  109. u8 REV :4;
  110. u8 LAYER :4;
  111. } REVID_e0;
  112. struct {
  113. u8 unk0 :1;
  114. u8 CNTCTL :1;
  115. u8 BITCNT :1;
  116. u8 unk1 :1;
  117. u8 RESYNC :1;
  118. u8 unk2 :3;
  119. } BERCTL_fa;
  120. struct {
  121. u8 CSEL0 :1;
  122. u8 CLKED0 :1;
  123. u8 CSEL1 :1;
  124. u8 CLKED1 :1;
  125. u8 CLKLEV :1;
  126. u8 SPIVAR :1;
  127. u8 na :2;
  128. } TUNSET_fc;
  129. struct {
  130. u8 CLK :1;
  131. u8 DATA :1;
  132. u8 CS0 :1;
  133. u8 CS1 :1;
  134. u8 AGCSEL :1;
  135. u8 na0 :1;
  136. u8 TUNSEL :1;
  137. u8 na1 :1;
  138. } TUNCTL_fd;
  139. u8 TUNSEL0_fe;
  140. u8 TUNSEL1_ff;
  141. } bcm3510_register_value;
  142. /* HAB commands */
  143. /* version */
  144. #define CMD_GET_VERSION_INFO 0x3D
  145. #define MSGID_GET_VERSION_INFO 0x15
  146. struct bcm3510_hab_cmd_get_version_info {
  147. u8 microcode_version;
  148. u8 script_version;
  149. u8 config_version;
  150. u8 demod_version;
  151. } PACKED;
  152. #define BCM3510_DEF_MICROCODE_VERSION 0x0E
  153. #define BCM3510_DEF_SCRIPT_VERSION 0x06
  154. #define BCM3510_DEF_CONFIG_VERSION 0x01
  155. #define BCM3510_DEF_DEMOD_VERSION 0xB1
  156. /* acquire */
  157. #define CMD_ACQUIRE 0x38
  158. #define MSGID_EXT_TUNER_ACQUIRE 0x0A
  159. struct bcm3510_hab_cmd_ext_acquire {
  160. struct {
  161. u8 MODE :4;
  162. u8 BW :1;
  163. u8 FA :1;
  164. u8 NTSCSWEEP :1;
  165. u8 OFFSET :1;
  166. } PACKED ACQUIRE0; /* control_byte */
  167. struct {
  168. u8 IF_FREQ :3;
  169. u8 zero0 :1;
  170. u8 SYM_RATE :3;
  171. u8 zero1 :1;
  172. } PACKED ACQUIRE1; /* sym_if */
  173. u8 IF_OFFSET0; /* IF_Offset_10hz */
  174. u8 IF_OFFSET1;
  175. u8 SYM_OFFSET0; /* SymbolRateOffset */
  176. u8 SYM_OFFSET1;
  177. u8 NTSC_OFFSET0; /* NTSC_Offset_10hz */
  178. u8 NTSC_OFFSET1;
  179. } PACKED;
  180. #define MSGID_INT_TUNER_ACQUIRE 0x0B
  181. struct bcm3510_hab_cmd_int_acquire {
  182. struct {
  183. u8 MODE :4;
  184. u8 BW :1;
  185. u8 FA :1;
  186. u8 NTSCSWEEP :1;
  187. u8 OFFSET :1;
  188. } PACKED ACQUIRE0; /* control_byte */
  189. struct {
  190. u8 IF_FREQ :3;
  191. u8 zero0 :1;
  192. u8 SYM_RATE :3;
  193. u8 zero1 :1;
  194. } PACKED ACQUIRE1; /* sym_if */
  195. u8 TUNER_FREQ0;
  196. u8 TUNER_FREQ1;
  197. u8 TUNER_FREQ2;
  198. u8 TUNER_FREQ3;
  199. u8 IF_OFFSET0; /* IF_Offset_10hz */
  200. u8 IF_OFFSET1;
  201. u8 SYM_OFFSET0; /* SymbolRateOffset */
  202. u8 SYM_OFFSET1;
  203. u8 NTSC_OFFSET0; /* NTSC_Offset_10hz */
  204. u8 NTSC_OFFSET1;
  205. } PACKED;
  206. /* modes */
  207. #define BCM3510_QAM16 = 0x01
  208. #define BCM3510_QAM32 = 0x02
  209. #define BCM3510_QAM64 = 0x03
  210. #define BCM3510_QAM128 = 0x04
  211. #define BCM3510_QAM256 = 0x05
  212. #define BCM3510_8VSB = 0x0B
  213. #define BCM3510_16VSB = 0x0D
  214. /* IF_FREQS */
  215. #define BCM3510_IF_TERRESTRIAL 0x0
  216. #define BCM3510_IF_CABLE 0x1
  217. #define BCM3510_IF_USE_CMD 0x7
  218. /* SYM_RATE */
  219. #define BCM3510_SR_8VSB 0x0 /* 5381119 s/sec */
  220. #define BCM3510_SR_256QAM 0x1 /* 5360537 s/sec */
  221. #define BCM3510_SR_16QAM 0x2 /* 5056971 s/sec */
  222. #define BCM3510_SR_MISC 0x3 /* 5000000 s/sec */
  223. #define BCM3510_SR_USE_CMD 0x7
  224. /* special symbol rate */
  225. #define CMD_SET_VALUE_NOT_LISTED 0x2d
  226. #define MSGID_SET_SYMBOL_RATE_NOT_LISTED 0x0c
  227. struct bcm3510_hab_cmd_set_sr_not_listed {
  228. u8 HOST_SYM_RATE0;
  229. u8 HOST_SYM_RATE1;
  230. u8 HOST_SYM_RATE2;
  231. u8 HOST_SYM_RATE3;
  232. } PACKED;
  233. /* special IF */
  234. #define MSGID_SET_IF_FREQ_NOT_LISTED 0x0d
  235. struct bcm3510_hab_cmd_set_if_freq_not_listed {
  236. u8 HOST_IF_FREQ0;
  237. u8 HOST_IF_FREQ1;
  238. u8 HOST_IF_FREQ2;
  239. u8 HOST_IF_FREQ3;
  240. } PACKED;
  241. /* auto reacquire */
  242. #define CMD_AUTO_PARAM 0x2a
  243. #define MSGID_AUTO_REACQUIRE 0x0e
  244. struct bcm3510_hab_cmd_auto_reacquire {
  245. u8 ACQ :1; /* on/off*/
  246. u8 unused :7;
  247. } PACKED;
  248. #define MSGID_SET_RF_AGC_SEL 0x12
  249. struct bcm3510_hab_cmd_set_agc {
  250. u8 LVL :1;
  251. u8 unused :6;
  252. u8 SEL :1;
  253. } PACKED;
  254. #define MSGID_SET_AUTO_INVERSION 0x14
  255. struct bcm3510_hab_cmd_auto_inversion {
  256. u8 AI :1;
  257. u8 unused :7;
  258. } PACKED;
  259. /* bert control */
  260. #define CMD_STATE_CONTROL 0x12
  261. #define MSGID_BERT_CONTROL 0x0e
  262. #define MSGID_BERT_SET 0xfa
  263. struct bcm3510_hab_cmd_bert_control {
  264. u8 BE :1;
  265. u8 unused :7;
  266. } PACKED;
  267. #define MSGID_TRI_STATE 0x2e
  268. struct bcm3510_hab_cmd_tri_state {
  269. u8 RE :1; /* a/d ram port pins */
  270. u8 PE :1; /* baud clock pin */
  271. u8 AC :1; /* a/d clock pin */
  272. u8 BE :1; /* baud clock pin */
  273. u8 unused :4;
  274. } PACKED;
  275. /* tune */
  276. #define CMD_TUNE 0x38
  277. #define MSGID_TUNE 0x16
  278. struct bcm3510_hab_cmd_tune_ctrl_data_pair {
  279. struct {
  280. #define BITS_8 0x07
  281. #define BITS_7 0x06
  282. #define BITS_6 0x05
  283. #define BITS_5 0x04
  284. #define BITS_4 0x03
  285. #define BITS_3 0x02
  286. #define BITS_2 0x01
  287. #define BITS_1 0x00
  288. u8 size :3;
  289. u8 unk :2;
  290. u8 clk_off :1;
  291. u8 cs0 :1;
  292. u8 cs1 :1;
  293. } PACKED ctrl;
  294. u8 data;
  295. } PACKED;
  296. struct bcm3510_hab_cmd_tune {
  297. u8 length;
  298. u8 clock_width;
  299. u8 misc;
  300. u8 TUNCTL_state;
  301. struct bcm3510_hab_cmd_tune_ctrl_data_pair ctl_dat[16];
  302. } PACKED;
  303. #define CMD_STATUS 0x38
  304. #define MSGID_STATUS1 0x08
  305. struct bcm3510_hab_cmd_status1 {
  306. struct {
  307. u8 EQ_MODE :4;
  308. u8 reserved :2;
  309. u8 QRE :1; /* if QSE and the spectrum is inversed */
  310. u8 QSE :1; /* automatic spectral inversion */
  311. } PACKED STATUS0;
  312. struct {
  313. u8 RECEIVER_LOCK :1;
  314. u8 FEC_LOCK :1;
  315. u8 OUT_PLL_LOCK :1;
  316. u8 reserved :5;
  317. } PACKED STATUS1;
  318. struct {
  319. u8 reserved :2;
  320. u8 BW :1;
  321. u8 NTE :1; /* NTSC filter sweep enabled */
  322. u8 AQI :1; /* currently acquiring */
  323. u8 FA :1; /* fast acquisition */
  324. u8 ARI :1; /* auto reacquire */
  325. u8 TI :1; /* programming the tuner */
  326. } PACKED STATUS2;
  327. u8 STATUS3;
  328. u8 SNR_EST0;
  329. u8 SNR_EST1;
  330. u8 TUNER_FREQ0;
  331. u8 TUNER_FREQ1;
  332. u8 TUNER_FREQ2;
  333. u8 TUNER_FREQ3;
  334. u8 SYM_RATE0;
  335. u8 SYM_RATE1;
  336. u8 SYM_RATE2;
  337. u8 SYM_RATE3;
  338. u8 SYM_OFFSET0;
  339. u8 SYM_OFFSET1;
  340. u8 SYM_ERROR0;
  341. u8 SYM_ERROR1;
  342. u8 IF_FREQ0;
  343. u8 IF_FREQ1;
  344. u8 IF_FREQ2;
  345. u8 IF_FREQ3;
  346. u8 IF_OFFSET0;
  347. u8 IF_OFFSET1;
  348. u8 IF_ERROR0;
  349. u8 IF_ERROR1;
  350. u8 NTSC_FILTER0;
  351. u8 NTSC_FILTER1;
  352. u8 NTSC_FILTER2;
  353. u8 NTSC_FILTER3;
  354. u8 NTSC_OFFSET0;
  355. u8 NTSC_OFFSET1;
  356. u8 NTSC_ERROR0;
  357. u8 NTSC_ERROR1;
  358. u8 INT_AGC_LEVEL0;
  359. u8 INT_AGC_LEVEL1;
  360. u8 EXT_AGC_LEVEL0;
  361. u8 EXT_AGC_LEVEL1;
  362. } PACKED;
  363. #define MSGID_STATUS2 0x14
  364. struct bcm3510_hab_cmd_status2 {
  365. struct {
  366. u8 EQ_MODE :4;
  367. u8 reserved :2;
  368. u8 QRE :1;
  369. u8 QSR :1;
  370. } PACKED STATUS0;
  371. struct {
  372. u8 RL :1;
  373. u8 FL :1;
  374. u8 OL :1;
  375. u8 reserved :5;
  376. } PACKED STATUS1;
  377. u8 SYMBOL_RATE0;
  378. u8 SYMBOL_RATE1;
  379. u8 SYMBOL_RATE2;
  380. u8 SYMBOL_RATE3;
  381. u8 LDCERC0;
  382. u8 LDCERC1;
  383. u8 LDCERC2;
  384. u8 LDCERC3;
  385. u8 LDUERC0;
  386. u8 LDUERC1;
  387. u8 LDUERC2;
  388. u8 LDUERC3;
  389. u8 LDBER0;
  390. u8 LDBER1;
  391. u8 LDBER2;
  392. u8 LDBER3;
  393. struct {
  394. u8 MODE_TYPE :4; /* acquire mode 0 */
  395. u8 reservd :4;
  396. } MODE_TYPE;
  397. u8 SNR_EST0;
  398. u8 SNR_EST1;
  399. u8 SIGNAL;
  400. } PACKED;
  401. #define CMD_SET_RF_BW_NOT_LISTED 0x3f
  402. #define MSGID_SET_RF_BW_NOT_LISTED 0x11
  403. /* TODO */
  404. #endif