saa7164-cards.c 17 KB

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