saa7164-cards.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * Driver for the NXP SAA7164 PCIe bridge
  3. *
  4. * Copyright (c) 2009 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. .chiprev = SAA7164_CHIP_REV3,
  55. .unit = {{
  56. .id = 0x1d,
  57. .type = SAA7164_UNIT_EEPROM,
  58. .name = "4K EEPROM",
  59. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  60. .i2c_bus_addr = 0xa0 >> 1,
  61. .i2c_reg_len = REGLEN_8bit,
  62. }, {
  63. .id = 0x04,
  64. .type = SAA7164_UNIT_TUNER,
  65. .name = "TDA18271-1",
  66. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  67. .i2c_bus_addr = 0xc0 >> 1,
  68. .i2c_reg_len = REGLEN_8bit,
  69. }, {
  70. .id = 0x1b,
  71. .type = SAA7164_UNIT_TUNER,
  72. .name = "TDA18271-2",
  73. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  74. .i2c_bus_addr = 0xc0 >> 1,
  75. .i2c_reg_len = REGLEN_8bit,
  76. }, {
  77. .id = 0x1e,
  78. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  79. .name = "TDA10048-1",
  80. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  81. .i2c_bus_addr = 0x10 >> 1,
  82. .i2c_reg_len = REGLEN_8bit,
  83. }, {
  84. .id = 0x1f,
  85. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  86. .name = "TDA10048-2",
  87. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  88. .i2c_bus_addr = 0x12 >> 1,
  89. .i2c_reg_len = REGLEN_8bit,
  90. } },
  91. },
  92. [SAA7164_BOARD_HAUPPAUGE_HVR2200_2] = {
  93. .name = "Hauppauge WinTV-HVR2200",
  94. .porta = SAA7164_MPEG_DVB,
  95. .portb = SAA7164_MPEG_DVB,
  96. .chiprev = SAA7164_CHIP_REV2,
  97. .unit = {{
  98. .id = 0x06,
  99. .type = SAA7164_UNIT_EEPROM,
  100. .name = "4K EEPROM",
  101. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  102. .i2c_bus_addr = 0xa0 >> 1,
  103. .i2c_reg_len = REGLEN_8bit,
  104. }, {
  105. .id = 0x04,
  106. .type = SAA7164_UNIT_TUNER,
  107. .name = "TDA18271-1",
  108. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  109. .i2c_bus_addr = 0xc0 >> 1,
  110. .i2c_reg_len = REGLEN_8bit,
  111. }, {
  112. .id = 0x05,
  113. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  114. .name = "TDA10048-1",
  115. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  116. .i2c_bus_addr = 0x10 >> 1,
  117. .i2c_reg_len = REGLEN_8bit,
  118. }, {
  119. .id = 0x1e,
  120. .type = SAA7164_UNIT_TUNER,
  121. .name = "TDA18271-2",
  122. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  123. .i2c_bus_addr = 0xc0 >> 1,
  124. .i2c_reg_len = REGLEN_8bit,
  125. }, {
  126. .id = 0x1f,
  127. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  128. .name = "TDA10048-2",
  129. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  130. .i2c_bus_addr = 0x12 >> 1,
  131. .i2c_reg_len = REGLEN_8bit,
  132. } },
  133. },
  134. [SAA7164_BOARD_HAUPPAUGE_HVR2200_3] = {
  135. .name = "Hauppauge WinTV-HVR2200",
  136. .porta = SAA7164_MPEG_DVB,
  137. .portb = SAA7164_MPEG_DVB,
  138. .chiprev = SAA7164_CHIP_REV2,
  139. .unit = {{
  140. .id = 0x1d,
  141. .type = SAA7164_UNIT_EEPROM,
  142. .name = "4K EEPROM",
  143. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  144. .i2c_bus_addr = 0xa0 >> 1,
  145. .i2c_reg_len = REGLEN_8bit,
  146. }, {
  147. .id = 0x04,
  148. .type = SAA7164_UNIT_TUNER,
  149. .name = "TDA18271-1",
  150. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  151. .i2c_bus_addr = 0xc0 >> 1,
  152. .i2c_reg_len = REGLEN_8bit,
  153. }, {
  154. .id = 0x05,
  155. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  156. .name = "TDA8290-1",
  157. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  158. .i2c_bus_addr = 0x84 >> 1,
  159. .i2c_reg_len = REGLEN_8bit,
  160. }, {
  161. .id = 0x1b,
  162. .type = SAA7164_UNIT_TUNER,
  163. .name = "TDA18271-2",
  164. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  165. .i2c_bus_addr = 0xc0 >> 1,
  166. .i2c_reg_len = REGLEN_8bit,
  167. }, {
  168. .id = 0x1c,
  169. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  170. .name = "TDA8290-2",
  171. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  172. .i2c_bus_addr = 0x84 >> 1,
  173. .i2c_reg_len = REGLEN_8bit,
  174. }, {
  175. .id = 0x1e,
  176. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  177. .name = "TDA10048-1",
  178. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  179. .i2c_bus_addr = 0x10 >> 1,
  180. .i2c_reg_len = REGLEN_8bit,
  181. }, {
  182. .id = 0x1f,
  183. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  184. .name = "TDA10048-2",
  185. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  186. .i2c_bus_addr = 0x12 >> 1,
  187. .i2c_reg_len = REGLEN_8bit,
  188. } },
  189. },
  190. [SAA7164_BOARD_HAUPPAUGE_HVR2250] = {
  191. .name = "Hauppauge WinTV-HVR2250",
  192. .porta = SAA7164_MPEG_DVB,
  193. .portb = SAA7164_MPEG_DVB,
  194. .chiprev = SAA7164_CHIP_REV3,
  195. .unit = {{
  196. .id = 0x22,
  197. .type = SAA7164_UNIT_EEPROM,
  198. .name = "4K EEPROM",
  199. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  200. .i2c_bus_addr = 0xa0 >> 1,
  201. .i2c_reg_len = REGLEN_8bit,
  202. }, {
  203. .id = 0x04,
  204. .type = SAA7164_UNIT_TUNER,
  205. .name = "TDA18271-1",
  206. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  207. .i2c_bus_addr = 0xc0 >> 1,
  208. .i2c_reg_len = REGLEN_8bit,
  209. }, {
  210. .id = 0x07,
  211. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  212. .name = "CX24228/S5H1411-1 (TOP)",
  213. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  214. .i2c_bus_addr = 0x32 >> 1,
  215. .i2c_reg_len = REGLEN_8bit,
  216. }, {
  217. .id = 0x08,
  218. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  219. .name = "CX24228/S5H1411-1 (QAM)",
  220. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  221. .i2c_bus_addr = 0x34 >> 1,
  222. .i2c_reg_len = REGLEN_8bit,
  223. }, {
  224. .id = 0x1e,
  225. .type = SAA7164_UNIT_TUNER,
  226. .name = "TDA18271-2",
  227. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  228. .i2c_bus_addr = 0xc0 >> 1,
  229. .i2c_reg_len = REGLEN_8bit,
  230. }, {
  231. .id = 0x20,
  232. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  233. .name = "CX24228/S5H1411-2 (TOP)",
  234. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  235. .i2c_bus_addr = 0x32 >> 1,
  236. .i2c_reg_len = REGLEN_8bit,
  237. }, {
  238. .id = 0x23,
  239. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  240. .name = "CX24228/S5H1411-2 (QAM)",
  241. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  242. .i2c_bus_addr = 0x34 >> 1,
  243. .i2c_reg_len = REGLEN_8bit,
  244. } },
  245. },
  246. [SAA7164_BOARD_HAUPPAUGE_HVR2250_2] = {
  247. .name = "Hauppauge WinTV-HVR2250",
  248. .porta = SAA7164_MPEG_DVB,
  249. .portb = SAA7164_MPEG_DVB,
  250. .chiprev = SAA7164_CHIP_REV3,
  251. .unit = {{
  252. .id = 0x28,
  253. .type = SAA7164_UNIT_EEPROM,
  254. .name = "4K EEPROM",
  255. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  256. .i2c_bus_addr = 0xa0 >> 1,
  257. .i2c_reg_len = REGLEN_8bit,
  258. }, {
  259. .id = 0x04,
  260. .type = SAA7164_UNIT_TUNER,
  261. .name = "TDA18271-1",
  262. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  263. .i2c_bus_addr = 0xc0 >> 1,
  264. .i2c_reg_len = REGLEN_8bit,
  265. }, {
  266. .id = 0x07,
  267. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  268. .name = "CX24228/S5H1411-1 (TOP)",
  269. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  270. .i2c_bus_addr = 0x32 >> 1,
  271. .i2c_reg_len = REGLEN_8bit,
  272. }, {
  273. .id = 0x08,
  274. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  275. .name = "CX24228/S5H1411-1 (QAM)",
  276. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  277. .i2c_bus_addr = 0x34 >> 1,
  278. .i2c_reg_len = REGLEN_8bit,
  279. }, {
  280. .id = 0x24,
  281. .type = SAA7164_UNIT_TUNER,
  282. .name = "TDA18271-2",
  283. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  284. .i2c_bus_addr = 0xc0 >> 1,
  285. .i2c_reg_len = REGLEN_8bit,
  286. }, {
  287. .id = 0x26,
  288. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  289. .name = "CX24228/S5H1411-2 (TOP)",
  290. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  291. .i2c_bus_addr = 0x32 >> 1,
  292. .i2c_reg_len = REGLEN_8bit,
  293. }, {
  294. .id = 0x29,
  295. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  296. .name = "CX24228/S5H1411-2 (QAM)",
  297. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  298. .i2c_bus_addr = 0x34 >> 1,
  299. .i2c_reg_len = REGLEN_8bit,
  300. } },
  301. },
  302. [SAA7164_BOARD_HAUPPAUGE_HVR2250_3] = {
  303. .name = "Hauppauge WinTV-HVR2250",
  304. .porta = SAA7164_MPEG_DVB,
  305. .portb = SAA7164_MPEG_DVB,
  306. .chiprev = SAA7164_CHIP_REV3,
  307. .unit = {{
  308. .id = 0x26,
  309. .type = SAA7164_UNIT_EEPROM,
  310. .name = "4K EEPROM",
  311. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  312. .i2c_bus_addr = 0xa0 >> 1,
  313. .i2c_reg_len = REGLEN_8bit,
  314. }, {
  315. .id = 0x04,
  316. .type = SAA7164_UNIT_TUNER,
  317. .name = "TDA18271-1",
  318. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  319. .i2c_bus_addr = 0xc0 >> 1,
  320. .i2c_reg_len = REGLEN_8bit,
  321. }, {
  322. .id = 0x07,
  323. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  324. .name = "CX24228/S5H1411-1 (TOP)",
  325. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  326. .i2c_bus_addr = 0x32 >> 1,
  327. .i2c_reg_len = REGLEN_8bit,
  328. }, {
  329. .id = 0x08,
  330. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  331. .name = "CX24228/S5H1411-1 (QAM)",
  332. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  333. .i2c_bus_addr = 0x34 >> 1,
  334. .i2c_reg_len = REGLEN_8bit,
  335. }, {
  336. .id = 0x22,
  337. .type = SAA7164_UNIT_TUNER,
  338. .name = "TDA18271-2",
  339. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  340. .i2c_bus_addr = 0xc0 >> 1,
  341. .i2c_reg_len = REGLEN_8bit,
  342. }, {
  343. .id = 0x24,
  344. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  345. .name = "CX24228/S5H1411-2 (TOP)",
  346. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  347. .i2c_bus_addr = 0x32 >> 1,
  348. .i2c_reg_len = REGLEN_8bit,
  349. }, {
  350. .id = 0x27,
  351. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  352. .name = "CX24228/S5H1411-2 (QAM)",
  353. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  354. .i2c_bus_addr = 0x34 >> 1,
  355. .i2c_reg_len = REGLEN_8bit,
  356. } },
  357. },
  358. };
  359. const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
  360. /* ------------------------------------------------------------------ */
  361. /* PCI subsystem IDs */
  362. struct saa7164_subid saa7164_subids[] = {
  363. {
  364. .subvendor = 0x0070,
  365. .subdevice = 0x8880,
  366. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  367. }, {
  368. .subvendor = 0x0070,
  369. .subdevice = 0x8810,
  370. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  371. }, {
  372. .subvendor = 0x0070,
  373. .subdevice = 0x8980,
  374. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200,
  375. }, {
  376. .subvendor = 0x0070,
  377. .subdevice = 0x8900,
  378. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_2,
  379. }, {
  380. .subvendor = 0x0070,
  381. .subdevice = 0x8901,
  382. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_3,
  383. }, {
  384. .subvendor = 0x0070,
  385. .subdevice = 0x88A1,
  386. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_3,
  387. }, {
  388. .subvendor = 0x0070,
  389. .subdevice = 0x8891,
  390. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  391. }, {
  392. .subvendor = 0x0070,
  393. .subdevice = 0x8851,
  394. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  395. },
  396. };
  397. const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
  398. void saa7164_card_list(struct saa7164_dev *dev)
  399. {
  400. int i;
  401. if (0 == dev->pci->subsystem_vendor &&
  402. 0 == dev->pci->subsystem_device) {
  403. printk(KERN_ERR
  404. "%s: Board has no valid PCIe Subsystem ID and can't\n"
  405. "%s: be autodetected. Pass card=<n> insmod option to\n"
  406. "%s: workaround that. Send complaints to the vendor\n"
  407. "%s: of the TV card. Best regards,\n"
  408. "%s: -- tux\n",
  409. dev->name, dev->name, dev->name, dev->name, dev->name);
  410. } else {
  411. printk(KERN_ERR
  412. "%s: Your board isn't known (yet) to the driver.\n"
  413. "%s: Try to pick one of the existing card configs via\n"
  414. "%s: card=<n> insmod option. Updating to the latest\n"
  415. "%s: version might help as well.\n",
  416. dev->name, dev->name, dev->name, dev->name);
  417. }
  418. printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod "
  419. "option:\n", dev->name);
  420. for (i = 0; i < saa7164_bcount; i++)
  421. printk(KERN_ERR "%s: card=%d -> %s\n",
  422. dev->name, i, saa7164_boards[i].name);
  423. }
  424. /* TODO: clean this define up into the -cards.c structs */
  425. #define PCIEBRIDGE_UNITID 2
  426. void saa7164_gpio_setup(struct saa7164_dev *dev)
  427. {
  428. switch (dev->board) {
  429. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  430. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  431. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  432. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  433. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  434. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  435. /*
  436. GPIO 2: s5h1411 / tda10048-1 demod reset
  437. GPIO 3: s5h1411 / tda10048-2 demod reset
  438. GPIO 7: IRBlaster Zilog reset
  439. */
  440. /* Reset parts by going in and out of reset */
  441. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  442. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  443. msleep(10);
  444. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  445. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  446. break;
  447. }
  448. }
  449. static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
  450. {
  451. struct tveeprom tv;
  452. /* TODO: Assumption: eeprom on bus 0 */
  453. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
  454. eeprom_data);
  455. /* Make sure we support the board model */
  456. switch (tv.model) {
  457. case 88001:
  458. /* Development board - Limit circulation */
  459. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  460. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  461. case 88021:
  462. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  463. * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
  464. break;
  465. case 88041:
  466. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  467. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  468. break;
  469. case 88061:
  470. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  471. * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
  472. break;
  473. case 89519:
  474. case 89609:
  475. /* WinTV-HVR2200 (PCIe, Retail, full-height)
  476. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  477. break;
  478. case 89619:
  479. /* WinTV-HVR2200 (PCIe, Retail, half-height)
  480. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  481. break;
  482. default:
  483. printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
  484. dev->name, tv.model);
  485. break;
  486. }
  487. printk(KERN_INFO "%s: Hauppauge eeprom: model=%d\n", dev->name,
  488. tv.model);
  489. }
  490. void saa7164_card_setup(struct saa7164_dev *dev)
  491. {
  492. static u8 eeprom[256];
  493. if (dev->i2c_bus[0].i2c_rc == 0) {
  494. if (saa7164_api_read_eeprom(dev, &eeprom[0],
  495. sizeof(eeprom)) < 0)
  496. return;
  497. }
  498. switch (dev->board) {
  499. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  500. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  501. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  502. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  503. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  504. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  505. hauppauge_eeprom(dev, &eeprom[0]);
  506. break;
  507. }
  508. }
  509. /* With most other drivers, the kernel expects to communicate with subdrivers
  510. * through i2c. This bridge does not allow that, it does not expose any direct
  511. * access to I2C. Instead we have to communicate through the device f/w for
  512. * register access to 'processing units'. Each unit has a unique
  513. * id, regardless of how the physical implementation occurs across
  514. * the three physical i2c busses. The being said if we want leverge of
  515. * the existing kernel drivers for tuners and demods we have to 'speak i2c',
  516. * to this bridge implements 3 virtual i2c buses. This is a helper function
  517. * for those.
  518. *
  519. * Description: Translate the kernels notion of an i2c address and bus into
  520. * the appropriate unitid.
  521. */
  522. int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr)
  523. {
  524. /* For a given bus and i2c device address, return the saa7164 unique
  525. * unitid. < 0 on error */
  526. struct saa7164_dev *dev = bus->dev;
  527. struct saa7164_unit *unit;
  528. int i;
  529. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  530. unit = &saa7164_boards[dev->board].unit[i];
  531. if (unit->type == SAA7164_UNIT_UNDEFINED)
  532. continue;
  533. if ((bus->nr == unit->i2c_bus_nr) &&
  534. (addr == unit->i2c_bus_addr))
  535. return unit->id;
  536. }
  537. return -1;
  538. }
  539. /* The 7164 API needs to know the i2c register length in advance.
  540. * this is a helper function. Based on a specific chip addr and bus return the
  541. * reg length.
  542. */
  543. int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr)
  544. {
  545. /* For a given bus and i2c device address, return the
  546. * saa7164 registry address width. < 0 on error
  547. */
  548. struct saa7164_dev *dev = bus->dev;
  549. struct saa7164_unit *unit;
  550. int i;
  551. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  552. unit = &saa7164_boards[dev->board].unit[i];
  553. if (unit->type == SAA7164_UNIT_UNDEFINED)
  554. continue;
  555. if ((bus->nr == unit->i2c_bus_nr) &&
  556. (addr == unit->i2c_bus_addr))
  557. return unit->i2c_reg_len;
  558. }
  559. return -1;
  560. }
  561. /* TODO: implement a 'findeeprom' functio like the above and fix any other
  562. * eeprom related todo's in -api.c.
  563. */
  564. /* Translate a unitid into a x readable device name, for display purposes. */
  565. char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid)
  566. {
  567. char *undefed = "UNDEFINED";
  568. char *bridge = "BRIDGE";
  569. struct saa7164_unit *unit;
  570. int i;
  571. if (unitid == 0)
  572. return bridge;
  573. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  574. unit = &saa7164_boards[dev->board].unit[i];
  575. if (unit->type == SAA7164_UNIT_UNDEFINED)
  576. continue;
  577. if (unitid == unit->id)
  578. return unit->name;
  579. }
  580. return undefed;
  581. }