/drivers/media/video/saa7164/saa7164-cards.c

https://bitbucket.org/wisechild/galaxy-nexus · C · 715 lines · 595 code · 40 blank · 80 comment · 30 complexity · 64a420c949ca41ffe07c691dda4390c8 MD5 · raw file

  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. };
  447. const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
  448. /* ------------------------------------------------------------------ */
  449. /* PCI subsystem IDs */
  450. struct saa7164_subid saa7164_subids[] = {
  451. {
  452. .subvendor = 0x0070,
  453. .subdevice = 0x8880,
  454. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  455. }, {
  456. .subvendor = 0x0070,
  457. .subdevice = 0x8810,
  458. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  459. }, {
  460. .subvendor = 0x0070,
  461. .subdevice = 0x8980,
  462. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200,
  463. }, {
  464. .subvendor = 0x0070,
  465. .subdevice = 0x8900,
  466. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_2,
  467. }, {
  468. .subvendor = 0x0070,
  469. .subdevice = 0x8901,
  470. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_3,
  471. }, {
  472. .subvendor = 0x0070,
  473. .subdevice = 0x88A1,
  474. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_3,
  475. }, {
  476. .subvendor = 0x0070,
  477. .subdevice = 0x8891,
  478. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  479. }, {
  480. .subvendor = 0x0070,
  481. .subdevice = 0x8851,
  482. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  483. }, {
  484. .subvendor = 0x0070,
  485. .subdevice = 0x8940,
  486. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_4,
  487. },
  488. };
  489. const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
  490. void saa7164_card_list(struct saa7164_dev *dev)
  491. {
  492. int i;
  493. if (0 == dev->pci->subsystem_vendor &&
  494. 0 == dev->pci->subsystem_device) {
  495. printk(KERN_ERR
  496. "%s: Board has no valid PCIe Subsystem ID and can't\n"
  497. "%s: be autodetected. Pass card=<n> insmod option to\n"
  498. "%s: workaround that. Send complaints to the vendor\n"
  499. "%s: of the TV card. Best regards,\n"
  500. "%s: -- tux\n",
  501. dev->name, dev->name, dev->name, dev->name, dev->name);
  502. } else {
  503. printk(KERN_ERR
  504. "%s: Your board isn't known (yet) to the driver.\n"
  505. "%s: Try to pick one of the existing card configs via\n"
  506. "%s: card=<n> insmod option. Updating to the latest\n"
  507. "%s: version might help as well.\n",
  508. dev->name, dev->name, dev->name, dev->name);
  509. }
  510. printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod "
  511. "option:\n", dev->name);
  512. for (i = 0; i < saa7164_bcount; i++)
  513. printk(KERN_ERR "%s: card=%d -> %s\n",
  514. dev->name, i, saa7164_boards[i].name);
  515. }
  516. /* TODO: clean this define up into the -cards.c structs */
  517. #define PCIEBRIDGE_UNITID 2
  518. void saa7164_gpio_setup(struct saa7164_dev *dev)
  519. {
  520. switch (dev->board) {
  521. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  522. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  523. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  524. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  525. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  526. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  527. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  528. /*
  529. GPIO 2: s5h1411 / tda10048-1 demod reset
  530. GPIO 3: s5h1411 / tda10048-2 demod reset
  531. GPIO 7: IRBlaster Zilog reset
  532. */
  533. /* Reset parts by going in and out of reset */
  534. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  535. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  536. msleep(20);
  537. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  538. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  539. break;
  540. }
  541. }
  542. static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
  543. {
  544. struct tveeprom tv;
  545. /* TODO: Assumption: eeprom on bus 0 */
  546. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
  547. eeprom_data);
  548. /* Make sure we support the board model */
  549. switch (tv.model) {
  550. case 88001:
  551. /* Development board - Limit circulation */
  552. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  553. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  554. case 88021:
  555. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  556. * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
  557. break;
  558. case 88041:
  559. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  560. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  561. break;
  562. case 88061:
  563. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  564. * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
  565. break;
  566. case 89519:
  567. case 89609:
  568. /* WinTV-HVR2200 (PCIe, Retail, full-height)
  569. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  570. break;
  571. case 89619:
  572. /* WinTV-HVR2200 (PCIe, Retail, half-height)
  573. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  574. break;
  575. default:
  576. printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
  577. dev->name, tv.model);
  578. break;
  579. }
  580. printk(KERN_INFO "%s: Hauppauge eeprom: model=%d\n", dev->name,
  581. tv.model);
  582. }
  583. void saa7164_card_setup(struct saa7164_dev *dev)
  584. {
  585. static u8 eeprom[256];
  586. if (dev->i2c_bus[0].i2c_rc == 0) {
  587. if (saa7164_api_read_eeprom(dev, &eeprom[0],
  588. sizeof(eeprom)) < 0)
  589. return;
  590. }
  591. switch (dev->board) {
  592. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  593. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  594. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  595. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  596. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  597. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  598. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  599. hauppauge_eeprom(dev, &eeprom[0]);
  600. break;
  601. }
  602. }
  603. /* With most other drivers, the kernel expects to communicate with subdrivers
  604. * through i2c. This bridge does not allow that, it does not expose any direct
  605. * access to I2C. Instead we have to communicate through the device f/w for
  606. * register access to 'processing units'. Each unit has a unique
  607. * id, regardless of how the physical implementation occurs across
  608. * the three physical i2c busses. The being said if we want leverge of
  609. * the existing kernel drivers for tuners and demods we have to 'speak i2c',
  610. * to this bridge implements 3 virtual i2c buses. This is a helper function
  611. * for those.
  612. *
  613. * Description: Translate the kernels notion of an i2c address and bus into
  614. * the appropriate unitid.
  615. */
  616. int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr)
  617. {
  618. /* For a given bus and i2c device address, return the saa7164 unique
  619. * unitid. < 0 on error */
  620. struct saa7164_dev *dev = bus->dev;
  621. struct saa7164_unit *unit;
  622. int i;
  623. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  624. unit = &saa7164_boards[dev->board].unit[i];
  625. if (unit->type == SAA7164_UNIT_UNDEFINED)
  626. continue;
  627. if ((bus->nr == unit->i2c_bus_nr) &&
  628. (addr == unit->i2c_bus_addr))
  629. return unit->id;
  630. }
  631. return -1;
  632. }
  633. /* The 7164 API needs to know the i2c register length in advance.
  634. * this is a helper function. Based on a specific chip addr and bus return the
  635. * reg length.
  636. */
  637. int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr)
  638. {
  639. /* For a given bus and i2c device address, return the
  640. * saa7164 registry address width. < 0 on error
  641. */
  642. struct saa7164_dev *dev = bus->dev;
  643. struct saa7164_unit *unit;
  644. int i;
  645. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  646. unit = &saa7164_boards[dev->board].unit[i];
  647. if (unit->type == SAA7164_UNIT_UNDEFINED)
  648. continue;
  649. if ((bus->nr == unit->i2c_bus_nr) &&
  650. (addr == unit->i2c_bus_addr))
  651. return unit->i2c_reg_len;
  652. }
  653. return -1;
  654. }
  655. /* TODO: implement a 'findeeprom' functio like the above and fix any other
  656. * eeprom related todo's in -api.c.
  657. */
  658. /* Translate a unitid into a x readable device name, for display purposes. */
  659. char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid)
  660. {
  661. char *undefed = "UNDEFINED";
  662. char *bridge = "BRIDGE";
  663. struct saa7164_unit *unit;
  664. int i;
  665. if (unitid == 0)
  666. return bridge;
  667. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  668. unit = &saa7164_boards[dev->board].unit[i];
  669. if (unit->type == SAA7164_UNIT_UNDEFINED)
  670. continue;
  671. if (unitid == unit->id)
  672. return unit->name;
  673. }
  674. return undefed;
  675. }