saa7164-cards.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. /*
  2. * Driver for the NXP SAA7164 PCIe bridge
  3. *
  4. * Copyright (c) 2010 Steven Toth <stoth@kernellabs.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. *
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <linux/init.h>
  22. #include <linux/module.h>
  23. #include <linux/pci.h>
  24. #include <linux/delay.h>
  25. #include "saa7164.h"
  26. /* The Bridge API needs to understand register widths (in bytes) for the
  27. * attached I2C devices, so we can simplify the virtual i2c mechansms
  28. * and keep the -i2c.c implementation clean.
  29. */
  30. #define REGLEN_8bit 1
  31. #define REGLEN_16bit 2
  32. struct saa7164_board saa7164_boards[] = {
  33. [SAA7164_BOARD_UNKNOWN] = {
  34. /* Bridge will not load any firmware, without knowing
  35. * the rev this would be fatal. */
  36. .name = "Unknown",
  37. },
  38. [SAA7164_BOARD_UNKNOWN_REV2] = {
  39. /* Bridge will load the v2 f/w and dump descriptors */
  40. /* Required during new board bringup */
  41. .name = "Generic Rev2",
  42. .chiprev = SAA7164_CHIP_REV2,
  43. },
  44. [SAA7164_BOARD_UNKNOWN_REV3] = {
  45. /* Bridge will load the v2 f/w and dump descriptors */
  46. /* Required during new board bringup */
  47. .name = "Generic Rev3",
  48. .chiprev = SAA7164_CHIP_REV3,
  49. },
  50. [SAA7164_BOARD_HAUPPAUGE_HVR2200] = {
  51. .name = "Hauppauge WinTV-HVR2200",
  52. .porta = SAA7164_MPEG_DVB,
  53. .portb = SAA7164_MPEG_DVB,
  54. .portc = SAA7164_MPEG_ENCODER,
  55. .portd = SAA7164_MPEG_ENCODER,
  56. .porte = SAA7164_MPEG_VBI,
  57. .portf = SAA7164_MPEG_VBI,
  58. .chiprev = SAA7164_CHIP_REV3,
  59. .unit = {{
  60. .id = 0x1d,
  61. .type = SAA7164_UNIT_EEPROM,
  62. .name = "4K EEPROM",
  63. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  64. .i2c_bus_addr = 0xa0 >> 1,
  65. .i2c_reg_len = REGLEN_8bit,
  66. }, {
  67. .id = 0x04,
  68. .type = SAA7164_UNIT_TUNER,
  69. .name = "TDA18271-1",
  70. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  71. .i2c_bus_addr = 0xc0 >> 1,
  72. .i2c_reg_len = REGLEN_8bit,
  73. }, {
  74. .id = 0x1b,
  75. .type = SAA7164_UNIT_TUNER,
  76. .name = "TDA18271-2",
  77. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  78. .i2c_bus_addr = 0xc0 >> 1,
  79. .i2c_reg_len = REGLEN_8bit,
  80. }, {
  81. .id = 0x1e,
  82. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  83. .name = "TDA10048-1",
  84. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  85. .i2c_bus_addr = 0x10 >> 1,
  86. .i2c_reg_len = REGLEN_8bit,
  87. }, {
  88. .id = 0x1f,
  89. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  90. .name = "TDA10048-2",
  91. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  92. .i2c_bus_addr = 0x12 >> 1,
  93. .i2c_reg_len = REGLEN_8bit,
  94. } },
  95. },
  96. [SAA7164_BOARD_HAUPPAUGE_HVR2200_2] = {
  97. .name = "Hauppauge WinTV-HVR2200",
  98. .porta = SAA7164_MPEG_DVB,
  99. .portb = SAA7164_MPEG_DVB,
  100. .portc = SAA7164_MPEG_ENCODER,
  101. .portd = SAA7164_MPEG_ENCODER,
  102. .porte = SAA7164_MPEG_VBI,
  103. .portf = SAA7164_MPEG_VBI,
  104. .chiprev = SAA7164_CHIP_REV2,
  105. .unit = {{
  106. .id = 0x06,
  107. .type = SAA7164_UNIT_EEPROM,
  108. .name = "4K EEPROM",
  109. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  110. .i2c_bus_addr = 0xa0 >> 1,
  111. .i2c_reg_len = REGLEN_8bit,
  112. }, {
  113. .id = 0x04,
  114. .type = SAA7164_UNIT_TUNER,
  115. .name = "TDA18271-1",
  116. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  117. .i2c_bus_addr = 0xc0 >> 1,
  118. .i2c_reg_len = REGLEN_8bit,
  119. }, {
  120. .id = 0x05,
  121. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  122. .name = "TDA10048-1",
  123. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  124. .i2c_bus_addr = 0x10 >> 1,
  125. .i2c_reg_len = REGLEN_8bit,
  126. }, {
  127. .id = 0x1e,
  128. .type = SAA7164_UNIT_TUNER,
  129. .name = "TDA18271-2",
  130. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  131. .i2c_bus_addr = 0xc0 >> 1,
  132. .i2c_reg_len = REGLEN_8bit,
  133. }, {
  134. .id = 0x1f,
  135. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  136. .name = "TDA10048-2",
  137. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  138. .i2c_bus_addr = 0x12 >> 1,
  139. .i2c_reg_len = REGLEN_8bit,
  140. } },
  141. },
  142. [SAA7164_BOARD_HAUPPAUGE_HVR2200_3] = {
  143. .name = "Hauppauge WinTV-HVR2200",
  144. .porta = SAA7164_MPEG_DVB,
  145. .portb = SAA7164_MPEG_DVB,
  146. .portc = SAA7164_MPEG_ENCODER,
  147. .portd = SAA7164_MPEG_ENCODER,
  148. .porte = SAA7164_MPEG_VBI,
  149. .portf = SAA7164_MPEG_VBI,
  150. .chiprev = SAA7164_CHIP_REV2,
  151. .unit = {{
  152. .id = 0x1d,
  153. .type = SAA7164_UNIT_EEPROM,
  154. .name = "4K EEPROM",
  155. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  156. .i2c_bus_addr = 0xa0 >> 1,
  157. .i2c_reg_len = REGLEN_8bit,
  158. }, {
  159. .id = 0x04,
  160. .type = SAA7164_UNIT_TUNER,
  161. .name = "TDA18271-1",
  162. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  163. .i2c_bus_addr = 0xc0 >> 1,
  164. .i2c_reg_len = REGLEN_8bit,
  165. }, {
  166. .id = 0x05,
  167. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  168. .name = "TDA8290-1",
  169. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  170. .i2c_bus_addr = 0x84 >> 1,
  171. .i2c_reg_len = REGLEN_8bit,
  172. }, {
  173. .id = 0x1b,
  174. .type = SAA7164_UNIT_TUNER,
  175. .name = "TDA18271-2",
  176. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  177. .i2c_bus_addr = 0xc0 >> 1,
  178. .i2c_reg_len = REGLEN_8bit,
  179. }, {
  180. .id = 0x1c,
  181. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  182. .name = "TDA8290-2",
  183. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  184. .i2c_bus_addr = 0x84 >> 1,
  185. .i2c_reg_len = REGLEN_8bit,
  186. }, {
  187. .id = 0x1e,
  188. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  189. .name = "TDA10048-1",
  190. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  191. .i2c_bus_addr = 0x10 >> 1,
  192. .i2c_reg_len = REGLEN_8bit,
  193. }, {
  194. .id = 0x1f,
  195. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  196. .name = "TDA10048-2",
  197. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  198. .i2c_bus_addr = 0x12 >> 1,
  199. .i2c_reg_len = REGLEN_8bit,
  200. } },
  201. },
  202. [SAA7164_BOARD_HAUPPAUGE_HVR2200_4] = {
  203. .name = "Hauppauge WinTV-HVR2200",
  204. .porta = SAA7164_MPEG_DVB,
  205. .portb = SAA7164_MPEG_DVB,
  206. .portc = SAA7164_MPEG_ENCODER,
  207. .portd = SAA7164_MPEG_ENCODER,
  208. .porte = SAA7164_MPEG_VBI,
  209. .portf = SAA7164_MPEG_VBI,
  210. .chiprev = SAA7164_CHIP_REV3,
  211. .unit = {{
  212. .id = 0x1d,
  213. .type = SAA7164_UNIT_EEPROM,
  214. .name = "4K EEPROM",
  215. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  216. .i2c_bus_addr = 0xa0 >> 1,
  217. .i2c_reg_len = REGLEN_8bit,
  218. }, {
  219. .id = 0x04,
  220. .type = SAA7164_UNIT_TUNER,
  221. .name = "TDA18271-1",
  222. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  223. .i2c_bus_addr = 0xc0 >> 1,
  224. .i2c_reg_len = REGLEN_8bit,
  225. }, {
  226. .id = 0x05,
  227. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  228. .name = "TDA8290-1",
  229. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  230. .i2c_bus_addr = 0x84 >> 1,
  231. .i2c_reg_len = REGLEN_8bit,
  232. }, {
  233. .id = 0x1b,
  234. .type = SAA7164_UNIT_TUNER,
  235. .name = "TDA18271-2",
  236. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  237. .i2c_bus_addr = 0xc0 >> 1,
  238. .i2c_reg_len = REGLEN_8bit,
  239. }, {
  240. .id = 0x1c,
  241. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  242. .name = "TDA8290-2",
  243. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  244. .i2c_bus_addr = 0x84 >> 1,
  245. .i2c_reg_len = REGLEN_8bit,
  246. }, {
  247. .id = 0x1e,
  248. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  249. .name = "TDA10048-1",
  250. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  251. .i2c_bus_addr = 0x10 >> 1,
  252. .i2c_reg_len = REGLEN_8bit,
  253. }, {
  254. .id = 0x1f,
  255. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  256. .name = "TDA10048-2",
  257. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  258. .i2c_bus_addr = 0x12 >> 1,
  259. .i2c_reg_len = REGLEN_8bit,
  260. } },
  261. },
  262. [SAA7164_BOARD_HAUPPAUGE_HVR2250] = {
  263. .name = "Hauppauge WinTV-HVR2250",
  264. .porta = SAA7164_MPEG_DVB,
  265. .portb = SAA7164_MPEG_DVB,
  266. .portc = SAA7164_MPEG_ENCODER,
  267. .portd = SAA7164_MPEG_ENCODER,
  268. .portc = SAA7164_MPEG_ENCODER,
  269. .portd = SAA7164_MPEG_ENCODER,
  270. .porte = SAA7164_MPEG_VBI,
  271. .portf = SAA7164_MPEG_VBI,
  272. .chiprev = SAA7164_CHIP_REV3,
  273. .unit = {{
  274. .id = 0x22,
  275. .type = SAA7164_UNIT_EEPROM,
  276. .name = "4K EEPROM",
  277. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  278. .i2c_bus_addr = 0xa0 >> 1,
  279. .i2c_reg_len = REGLEN_8bit,
  280. }, {
  281. .id = 0x04,
  282. .type = SAA7164_UNIT_TUNER,
  283. .name = "TDA18271-1",
  284. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  285. .i2c_bus_addr = 0xc0 >> 1,
  286. .i2c_reg_len = REGLEN_8bit,
  287. }, {
  288. .id = 0x07,
  289. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  290. .name = "CX24228/S5H1411-1 (TOP)",
  291. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  292. .i2c_bus_addr = 0x32 >> 1,
  293. .i2c_reg_len = REGLEN_8bit,
  294. }, {
  295. .id = 0x08,
  296. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  297. .name = "CX24228/S5H1411-1 (QAM)",
  298. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  299. .i2c_bus_addr = 0x34 >> 1,
  300. .i2c_reg_len = REGLEN_8bit,
  301. }, {
  302. .id = 0x1e,
  303. .type = SAA7164_UNIT_TUNER,
  304. .name = "TDA18271-2",
  305. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  306. .i2c_bus_addr = 0xc0 >> 1,
  307. .i2c_reg_len = REGLEN_8bit,
  308. }, {
  309. .id = 0x20,
  310. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  311. .name = "CX24228/S5H1411-2 (TOP)",
  312. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  313. .i2c_bus_addr = 0x32 >> 1,
  314. .i2c_reg_len = REGLEN_8bit,
  315. }, {
  316. .id = 0x23,
  317. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  318. .name = "CX24228/S5H1411-2 (QAM)",
  319. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  320. .i2c_bus_addr = 0x34 >> 1,
  321. .i2c_reg_len = REGLEN_8bit,
  322. } },
  323. },
  324. [SAA7164_BOARD_HAUPPAUGE_HVR2250_2] = {
  325. .name = "Hauppauge WinTV-HVR2250",
  326. .porta = SAA7164_MPEG_DVB,
  327. .portb = SAA7164_MPEG_DVB,
  328. .portc = SAA7164_MPEG_ENCODER,
  329. .portd = SAA7164_MPEG_ENCODER,
  330. .porte = SAA7164_MPEG_VBI,
  331. .portf = SAA7164_MPEG_VBI,
  332. .porte = SAA7164_MPEG_VBI,
  333. .portf = SAA7164_MPEG_VBI,
  334. .chiprev = SAA7164_CHIP_REV3,
  335. .unit = {{
  336. .id = 0x28,
  337. .type = SAA7164_UNIT_EEPROM,
  338. .name = "4K EEPROM",
  339. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  340. .i2c_bus_addr = 0xa0 >> 1,
  341. .i2c_reg_len = REGLEN_8bit,
  342. }, {
  343. .id = 0x04,
  344. .type = SAA7164_UNIT_TUNER,
  345. .name = "TDA18271-1",
  346. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  347. .i2c_bus_addr = 0xc0 >> 1,
  348. .i2c_reg_len = REGLEN_8bit,
  349. }, {
  350. .id = 0x07,
  351. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  352. .name = "CX24228/S5H1411-1 (TOP)",
  353. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  354. .i2c_bus_addr = 0x32 >> 1,
  355. .i2c_reg_len = REGLEN_8bit,
  356. }, {
  357. .id = 0x08,
  358. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  359. .name = "CX24228/S5H1411-1 (QAM)",
  360. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  361. .i2c_bus_addr = 0x34 >> 1,
  362. .i2c_reg_len = REGLEN_8bit,
  363. }, {
  364. .id = 0x24,
  365. .type = SAA7164_UNIT_TUNER,
  366. .name = "TDA18271-2",
  367. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  368. .i2c_bus_addr = 0xc0 >> 1,
  369. .i2c_reg_len = REGLEN_8bit,
  370. }, {
  371. .id = 0x26,
  372. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  373. .name = "CX24228/S5H1411-2 (TOP)",
  374. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  375. .i2c_bus_addr = 0x32 >> 1,
  376. .i2c_reg_len = REGLEN_8bit,
  377. }, {
  378. .id = 0x29,
  379. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  380. .name = "CX24228/S5H1411-2 (QAM)",
  381. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  382. .i2c_bus_addr = 0x34 >> 1,
  383. .i2c_reg_len = REGLEN_8bit,
  384. } },
  385. },
  386. [SAA7164_BOARD_HAUPPAUGE_HVR2250_3] = {
  387. .name = "Hauppauge WinTV-HVR2250",
  388. .porta = SAA7164_MPEG_DVB,
  389. .portb = SAA7164_MPEG_DVB,
  390. .portc = SAA7164_MPEG_ENCODER,
  391. .portd = SAA7164_MPEG_ENCODER,
  392. .porte = SAA7164_MPEG_VBI,
  393. .portf = SAA7164_MPEG_VBI,
  394. .chiprev = SAA7164_CHIP_REV3,
  395. .unit = {{
  396. .id = 0x26,
  397. .type = SAA7164_UNIT_EEPROM,
  398. .name = "4K EEPROM",
  399. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  400. .i2c_bus_addr = 0xa0 >> 1,
  401. .i2c_reg_len = REGLEN_8bit,
  402. }, {
  403. .id = 0x04,
  404. .type = SAA7164_UNIT_TUNER,
  405. .name = "TDA18271-1",
  406. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  407. .i2c_bus_addr = 0xc0 >> 1,
  408. .i2c_reg_len = REGLEN_8bit,
  409. }, {
  410. .id = 0x07,
  411. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  412. .name = "CX24228/S5H1411-1 (TOP)",
  413. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  414. .i2c_bus_addr = 0x32 >> 1,
  415. .i2c_reg_len = REGLEN_8bit,
  416. }, {
  417. .id = 0x08,
  418. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  419. .name = "CX24228/S5H1411-1 (QAM)",
  420. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  421. .i2c_bus_addr = 0x34 >> 1,
  422. .i2c_reg_len = REGLEN_8bit,
  423. }, {
  424. .id = 0x22,
  425. .type = SAA7164_UNIT_TUNER,
  426. .name = "TDA18271-2",
  427. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  428. .i2c_bus_addr = 0xc0 >> 1,
  429. .i2c_reg_len = REGLEN_8bit,
  430. }, {
  431. .id = 0x24,
  432. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  433. .name = "CX24228/S5H1411-2 (TOP)",
  434. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  435. .i2c_bus_addr = 0x32 >> 1,
  436. .i2c_reg_len = REGLEN_8bit,
  437. }, {
  438. .id = 0x27,
  439. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  440. .name = "CX24228/S5H1411-2 (QAM)",
  441. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  442. .i2c_bus_addr = 0x34 >> 1,
  443. .i2c_reg_len = REGLEN_8bit,
  444. } },
  445. },
  446. [SAA7164_BOARD_HAUPPAUGE_HVR2200_5] = {
  447. .name = "Hauppauge WinTV-HVR2200",
  448. .porta = SAA7164_MPEG_DVB,
  449. .portb = SAA7164_MPEG_DVB,
  450. .chiprev = SAA7164_CHIP_REV3,
  451. .unit = {{
  452. .id = 0x23,
  453. .type = SAA7164_UNIT_EEPROM,
  454. .name = "4K EEPROM",
  455. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  456. .i2c_bus_addr = 0xa0 >> 1,
  457. .i2c_reg_len = REGLEN_8bit,
  458. }, {
  459. .id = 0x04,
  460. .type = SAA7164_UNIT_TUNER,
  461. .name = "TDA18271-1",
  462. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  463. .i2c_bus_addr = 0xc0 >> 1,
  464. .i2c_reg_len = REGLEN_8bit,
  465. }, {
  466. .id = 0x05,
  467. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  468. .name = "TDA8290-1",
  469. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  470. .i2c_bus_addr = 0x84 >> 1,
  471. .i2c_reg_len = REGLEN_8bit,
  472. }, {
  473. .id = 0x21,
  474. .type = SAA7164_UNIT_TUNER,
  475. .name = "TDA18271-2",
  476. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  477. .i2c_bus_addr = 0xc0 >> 1,
  478. .i2c_reg_len = REGLEN_8bit,
  479. }, {
  480. .id = 0x22,
  481. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  482. .name = "TDA8290-2",
  483. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  484. .i2c_bus_addr = 0x84 >> 1,
  485. .i2c_reg_len = REGLEN_8bit,
  486. }, {
  487. .id = 0x24,
  488. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  489. .name = "TDA10048-1",
  490. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  491. .i2c_bus_addr = 0x10 >> 1,
  492. .i2c_reg_len = REGLEN_8bit,
  493. }, {
  494. .id = 0x25,
  495. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  496. .name = "TDA10048-2",
  497. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  498. .i2c_bus_addr = 0x12 >> 1,
  499. .i2c_reg_len = REGLEN_8bit,
  500. } },
  501. },
  502. };
  503. const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
  504. /* ------------------------------------------------------------------ */
  505. /* PCI subsystem IDs */
  506. struct saa7164_subid saa7164_subids[] = {
  507. {
  508. .subvendor = 0x0070,
  509. .subdevice = 0x8880,
  510. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  511. }, {
  512. .subvendor = 0x0070,
  513. .subdevice = 0x8810,
  514. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  515. }, {
  516. .subvendor = 0x0070,
  517. .subdevice = 0x8980,
  518. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200,
  519. }, {
  520. .subvendor = 0x0070,
  521. .subdevice = 0x8900,
  522. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_2,
  523. }, {
  524. .subvendor = 0x0070,
  525. .subdevice = 0x8901,
  526. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_3,
  527. }, {
  528. .subvendor = 0x0070,
  529. .subdevice = 0x88A1,
  530. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_3,
  531. }, {
  532. .subvendor = 0x0070,
  533. .subdevice = 0x8891,
  534. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  535. }, {
  536. .subvendor = 0x0070,
  537. .subdevice = 0x8851,
  538. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  539. }, {
  540. .subvendor = 0x0070,
  541. .subdevice = 0x8940,
  542. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_4,
  543. }, {
  544. .subvendor = 0x0070,
  545. .subdevice = 0x8953,
  546. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_5,
  547. },
  548. };
  549. const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
  550. void saa7164_card_list(struct saa7164_dev *dev)
  551. {
  552. int i;
  553. if (0 == dev->pci->subsystem_vendor &&
  554. 0 == dev->pci->subsystem_device) {
  555. printk(KERN_ERR
  556. "%s: Board has no valid PCIe Subsystem ID and can't\n"
  557. "%s: be autodetected. Pass card=<n> insmod option to\n"
  558. "%s: workaround that. Send complaints to the vendor\n"
  559. "%s: of the TV card. Best regards,\n"
  560. "%s: -- tux\n",
  561. dev->name, dev->name, dev->name, dev->name, dev->name);
  562. } else {
  563. printk(KERN_ERR
  564. "%s: Your board isn't known (yet) to the driver.\n"
  565. "%s: Try to pick one of the existing card configs via\n"
  566. "%s: card=<n> insmod option. Updating to the latest\n"
  567. "%s: version might help as well.\n",
  568. dev->name, dev->name, dev->name, dev->name);
  569. }
  570. printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod "
  571. "option:\n", dev->name);
  572. for (i = 0; i < saa7164_bcount; i++)
  573. printk(KERN_ERR "%s: card=%d -> %s\n",
  574. dev->name, i, saa7164_boards[i].name);
  575. }
  576. /* TODO: clean this define up into the -cards.c structs */
  577. #define PCIEBRIDGE_UNITID 2
  578. void saa7164_gpio_setup(struct saa7164_dev *dev)
  579. {
  580. switch (dev->board) {
  581. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  582. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  583. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  584. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  585. case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
  586. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  587. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  588. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  589. /*
  590. GPIO 2: s5h1411 / tda10048-1 demod reset
  591. GPIO 3: s5h1411 / tda10048-2 demod reset
  592. GPIO 7: IRBlaster Zilog reset
  593. */
  594. /* Reset parts by going in and out of reset */
  595. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  596. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  597. msleep(20);
  598. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  599. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  600. break;
  601. }
  602. }
  603. static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
  604. {
  605. struct tveeprom tv;
  606. /* TODO: Assumption: eeprom on bus 0 */
  607. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
  608. eeprom_data);
  609. /* Make sure we support the board model */
  610. switch (tv.model) {
  611. case 88001:
  612. /* Development board - Limit circulation */
  613. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  614. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  615. case 88021:
  616. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  617. * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
  618. break;
  619. case 88041:
  620. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  621. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  622. break;
  623. case 88061:
  624. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  625. * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
  626. break;
  627. case 89519:
  628. case 89609:
  629. /* WinTV-HVR2200 (PCIe, Retail, full-height)
  630. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  631. break;
  632. case 89619:
  633. /* WinTV-HVR2200 (PCIe, Retail, half-height)
  634. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  635. break;
  636. default:
  637. printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
  638. dev->name, tv.model);
  639. break;
  640. }
  641. printk(KERN_INFO "%s: Hauppauge eeprom: model=%d\n", dev->name,
  642. tv.model);
  643. }
  644. void saa7164_card_setup(struct saa7164_dev *dev)
  645. {
  646. static u8 eeprom[256];
  647. if (dev->i2c_bus[0].i2c_rc == 0) {
  648. if (saa7164_api_read_eeprom(dev, &eeprom[0],
  649. sizeof(eeprom)) < 0)
  650. return;
  651. }
  652. switch (dev->board) {
  653. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  654. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  655. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  656. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  657. case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
  658. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  659. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  660. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  661. hauppauge_eeprom(dev, &eeprom[0]);
  662. break;
  663. }
  664. }
  665. /* With most other drivers, the kernel expects to communicate with subdrivers
  666. * through i2c. This bridge does not allow that, it does not expose any direct
  667. * access to I2C. Instead we have to communicate through the device f/w for
  668. * register access to 'processing units'. Each unit has a unique
  669. * id, regardless of how the physical implementation occurs across
  670. * the three physical i2c busses. The being said if we want leverge of
  671. * the existing kernel drivers for tuners and demods we have to 'speak i2c',
  672. * to this bridge implements 3 virtual i2c buses. This is a helper function
  673. * for those.
  674. *
  675. * Description: Translate the kernels notion of an i2c address and bus into
  676. * the appropriate unitid.
  677. */
  678. int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr)
  679. {
  680. /* For a given bus and i2c device address, return the saa7164 unique
  681. * unitid. < 0 on error */
  682. struct saa7164_dev *dev = bus->dev;
  683. struct saa7164_unit *unit;
  684. int i;
  685. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  686. unit = &saa7164_boards[dev->board].unit[i];
  687. if (unit->type == SAA7164_UNIT_UNDEFINED)
  688. continue;
  689. if ((bus->nr == unit->i2c_bus_nr) &&
  690. (addr == unit->i2c_bus_addr))
  691. return unit->id;
  692. }
  693. return -1;
  694. }
  695. /* The 7164 API needs to know the i2c register length in advance.
  696. * this is a helper function. Based on a specific chip addr and bus return the
  697. * reg length.
  698. */
  699. int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr)
  700. {
  701. /* For a given bus and i2c device address, return the
  702. * saa7164 registry address width. < 0 on error
  703. */
  704. struct saa7164_dev *dev = bus->dev;
  705. struct saa7164_unit *unit;
  706. int i;
  707. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  708. unit = &saa7164_boards[dev->board].unit[i];
  709. if (unit->type == SAA7164_UNIT_UNDEFINED)
  710. continue;
  711. if ((bus->nr == unit->i2c_bus_nr) &&
  712. (addr == unit->i2c_bus_addr))
  713. return unit->i2c_reg_len;
  714. }
  715. return -1;
  716. }
  717. /* TODO: implement a 'findeeprom' functio like the above and fix any other
  718. * eeprom related todo's in -api.c.
  719. */
  720. /* Translate a unitid into a x readable device name, for display purposes. */
  721. char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid)
  722. {
  723. char *undefed = "UNDEFINED";
  724. char *bridge = "BRIDGE";
  725. struct saa7164_unit *unit;
  726. int i;
  727. if (unitid == 0)
  728. return bridge;
  729. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  730. unit = &saa7164_boards[dev->board].unit[i];
  731. if (unit->type == SAA7164_UNIT_UNDEFINED)
  732. continue;
  733. if (unitid == unit->id)
  734. return unit->name;
  735. }
  736. return undefed;
  737. }