em28xx-cards.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  2. em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
  3. video capture devices
  4. Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
  5. Markus Rechberger <mrechberger@gmail.com>
  6. Mauro Carvalho Chehab <mchehab@infradead.org>
  7. Sascha Sommer <saschasommer@freenet.de>
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <linux/init.h>
  21. #include <linux/module.h>
  22. #include <linux/delay.h>
  23. #include <linux/i2c.h>
  24. #include <linux/usb.h>
  25. #include <media/tuner.h>
  26. #include <media/msp3400.h>
  27. #include <media/saa7115.h>
  28. #include <media/tvp5150.h>
  29. #include <media/tveeprom.h>
  30. #include <media/audiochip.h>
  31. #include <media/v4l2-common.h>
  32. #include "em28xx.h"
  33. #include "tuner-xc2028.h"
  34. static int tuner = -1;
  35. module_param(tuner, int, 0444);
  36. MODULE_PARM_DESC(tuner, "tuner type");
  37. struct em28xx_hash_table {
  38. unsigned long hash;
  39. unsigned int model;
  40. unsigned int tuner;
  41. };
  42. struct em28xx_board em28xx_boards[] = {
  43. [EM2800_BOARD_UNKNOWN] = {
  44. .name = "Unknown EM2800 video grabber",
  45. .is_em2800 = 1,
  46. .vchannels = 2,
  47. .tda9887_conf = TDA9887_PRESENT,
  48. .has_tuner = 1,
  49. .decoder = EM28XX_SAA7113,
  50. .input = { {
  51. .type = EM28XX_VMUX_COMPOSITE1,
  52. .vmux = SAA7115_COMPOSITE0,
  53. .amux = 1,
  54. }, {
  55. .type = EM28XX_VMUX_SVIDEO,
  56. .vmux = SAA7115_SVIDEO3,
  57. .amux = 1,
  58. } },
  59. },
  60. [EM2820_BOARD_UNKNOWN] = {
  61. .name = "Unknown EM2750/28xx video grabber",
  62. .is_em2800 = 0,
  63. },
  64. [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
  65. .name = "Kworld PVR TV 2800 RF",
  66. .is_em2800 = 0,
  67. .vchannels = 2,
  68. .tda9887_conf = TDA9887_PRESENT,
  69. .has_tuner = 1,
  70. .decoder = EM28XX_SAA7113,
  71. .input = { {
  72. .type = EM28XX_VMUX_COMPOSITE1,
  73. .vmux = SAA7115_COMPOSITE0,
  74. .amux = 1,
  75. }, {
  76. .type = EM28XX_VMUX_SVIDEO,
  77. .vmux = SAA7115_SVIDEO3,
  78. .amux = 1,
  79. } },
  80. },
  81. [EM2820_BOARD_TERRATEC_CINERGY_250] = {
  82. .name = "Terratec Cinergy 250 USB",
  83. .vchannels = 3,
  84. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  85. .tda9887_conf = TDA9887_PRESENT,
  86. .has_tuner = 1,
  87. .decoder = EM28XX_SAA7113,
  88. .input = { {
  89. .type = EM28XX_VMUX_TELEVISION,
  90. .vmux = SAA7115_COMPOSITE2,
  91. .amux = 1,
  92. }, {
  93. .type = EM28XX_VMUX_COMPOSITE1,
  94. .vmux = SAA7115_COMPOSITE0,
  95. .amux = 1,
  96. }, {
  97. .type = EM28XX_VMUX_SVIDEO,
  98. .vmux = SAA7115_SVIDEO3,
  99. .amux = 1,
  100. } },
  101. },
  102. [EM2820_BOARD_PINNACLE_USB_2] = {
  103. .name = "Pinnacle PCTV USB 2",
  104. .vchannels = 3,
  105. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  106. .tda9887_conf = TDA9887_PRESENT,
  107. .has_tuner = 1,
  108. .decoder = EM28XX_SAA7113,
  109. .input = { {
  110. .type = EM28XX_VMUX_TELEVISION,
  111. .vmux = SAA7115_COMPOSITE2,
  112. .amux = 0,
  113. }, {
  114. .type = EM28XX_VMUX_COMPOSITE1,
  115. .vmux = SAA7115_COMPOSITE0,
  116. .amux = 1,
  117. }, {
  118. .type = EM28XX_VMUX_SVIDEO,
  119. .vmux = SAA7115_SVIDEO3,
  120. .amux = 1,
  121. } },
  122. },
  123. [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
  124. .name = "Hauppauge WinTV USB 2",
  125. .vchannels = 3,
  126. .tuner_type = TUNER_PHILIPS_FM1236_MK3,
  127. .tda9887_conf = TDA9887_PRESENT |
  128. TDA9887_PORT1_ACTIVE|
  129. TDA9887_PORT2_ACTIVE,
  130. .has_tuner = 1,
  131. .decoder = EM28XX_TVP5150,
  132. .has_msp34xx = 1,
  133. /*FIXME: S-Video not tested */
  134. .input = { {
  135. .type = EM28XX_VMUX_TELEVISION,
  136. .vmux = TVP5150_COMPOSITE0,
  137. .amux = MSP_INPUT_DEFAULT,
  138. }, {
  139. .type = EM28XX_VMUX_SVIDEO,
  140. .vmux = TVP5150_SVIDEO,
  141. .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
  142. MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
  143. } },
  144. },
  145. [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
  146. .name = "Hauppauge WinTV HVR 900",
  147. .vchannels = 3,
  148. .tda9887_conf = TDA9887_PRESENT,
  149. .tuner_type = TUNER_XC2028,
  150. .has_tuner = 1,
  151. .mts_firmware = 1,
  152. .decoder = EM28XX_TVP5150,
  153. .input = { {
  154. .type = EM28XX_VMUX_TELEVISION,
  155. .vmux = TVP5150_COMPOSITE0,
  156. .amux = 0,
  157. }, {
  158. .type = EM28XX_VMUX_COMPOSITE1,
  159. .vmux = TVP5150_COMPOSITE1,
  160. .amux = 1,
  161. }, {
  162. .type = EM28XX_VMUX_SVIDEO,
  163. .vmux = TVP5150_SVIDEO,
  164. .amux = 1,
  165. } },
  166. },
  167. [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
  168. .name = "Hauppauge WinTV HVR 950",
  169. .vchannels = 3,
  170. .tda9887_conf = TDA9887_PRESENT,
  171. .tuner_type = TUNER_XC2028,
  172. .has_tuner = 1,
  173. .decoder = EM28XX_TVP5150,
  174. .input = { {
  175. .type = EM28XX_VMUX_TELEVISION,
  176. .vmux = TVP5150_COMPOSITE0,
  177. .amux = 0,
  178. }, {
  179. .type = EM28XX_VMUX_COMPOSITE1,
  180. .vmux = TVP5150_COMPOSITE1,
  181. .amux = 1,
  182. }, {
  183. .type = EM28XX_VMUX_SVIDEO,
  184. .vmux = TVP5150_SVIDEO,
  185. .amux = 1,
  186. } },
  187. },
  188. [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
  189. .name = "Terratec Hybrid XS",
  190. .vchannels = 3,
  191. .tda9887_conf = TDA9887_PRESENT,
  192. .has_tuner = 1,
  193. .tuner_type = TUNER_XC2028,
  194. .decoder = EM28XX_TVP5150,
  195. .input = { {
  196. .type = EM28XX_VMUX_TELEVISION,
  197. .vmux = TVP5150_COMPOSITE0,
  198. .amux = 0,
  199. }, {
  200. .type = EM28XX_VMUX_COMPOSITE1,
  201. .vmux = TVP5150_COMPOSITE1,
  202. .amux = 1,
  203. }, {
  204. .type = EM28XX_VMUX_SVIDEO,
  205. .vmux = TVP5150_SVIDEO,
  206. .amux = 1,
  207. } },
  208. },
  209. /* maybe there's a reason behind it why Terratec sells the Hybrid XS
  210. as Prodigy XS with a different PID, let's keep it separated for now
  211. maybe we'll need it lateron */
  212. [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
  213. .name = "Terratec Prodigy XS",
  214. .vchannels = 3,
  215. .tda9887_conf = TDA9887_PRESENT,
  216. .has_tuner = 1,
  217. .tuner_type = TUNER_XC2028,
  218. .decoder = EM28XX_TVP5150,
  219. .input = { {
  220. .type = EM28XX_VMUX_TELEVISION,
  221. .vmux = TVP5150_COMPOSITE0,
  222. .amux = 0,
  223. }, {
  224. .type = EM28XX_VMUX_COMPOSITE1,
  225. .vmux = TVP5150_COMPOSITE1,
  226. .amux = 1,
  227. }, {
  228. .type = EM28XX_VMUX_SVIDEO,
  229. .vmux = TVP5150_SVIDEO,
  230. .amux = 1,
  231. } },
  232. },
  233. [EM2820_BOARD_MSI_VOX_USB_2] = {
  234. .name = "MSI VOX USB 2.0",
  235. .vchannels = 3,
  236. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  237. .tda9887_conf = TDA9887_PRESENT |
  238. TDA9887_PORT1_ACTIVE |
  239. TDA9887_PORT2_ACTIVE,
  240. .has_tuner = 1,
  241. .decoder = EM28XX_SAA7114,
  242. .input = { {
  243. .type = EM28XX_VMUX_TELEVISION,
  244. .vmux = SAA7115_COMPOSITE4,
  245. .amux = 0,
  246. }, {
  247. .type = EM28XX_VMUX_COMPOSITE1,
  248. .vmux = SAA7115_COMPOSITE0,
  249. .amux = 1,
  250. }, {
  251. .type = EM28XX_VMUX_SVIDEO,
  252. .vmux = SAA7115_SVIDEO3,
  253. .amux = 1,
  254. } },
  255. },
  256. [EM2800_BOARD_TERRATEC_CINERGY_200] = {
  257. .name = "Terratec Cinergy 200 USB",
  258. .is_em2800 = 1,
  259. .vchannels = 3,
  260. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  261. .tda9887_conf = TDA9887_PRESENT,
  262. .has_tuner = 1,
  263. .decoder = EM28XX_SAA7113,
  264. .input = { {
  265. .type = EM28XX_VMUX_TELEVISION,
  266. .vmux = SAA7115_COMPOSITE2,
  267. .amux = 0,
  268. }, {
  269. .type = EM28XX_VMUX_COMPOSITE1,
  270. .vmux = SAA7115_COMPOSITE0,
  271. .amux = 1,
  272. }, {
  273. .type = EM28XX_VMUX_SVIDEO,
  274. .vmux = SAA7115_SVIDEO3,
  275. .amux = 1,
  276. } },
  277. },
  278. [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
  279. .name = "Leadtek Winfast USB II",
  280. .is_em2800 = 1,
  281. .vchannels = 3,
  282. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  283. .tda9887_conf = TDA9887_PRESENT,
  284. .has_tuner = 1,
  285. .decoder = EM28XX_SAA7113,
  286. .input = { {
  287. .type = EM28XX_VMUX_TELEVISION,
  288. .vmux = SAA7115_COMPOSITE2,
  289. .amux = 0,
  290. }, {
  291. .type = EM28XX_VMUX_COMPOSITE1,
  292. .vmux = SAA7115_COMPOSITE0,
  293. .amux = 1,
  294. }, {
  295. .type = EM28XX_VMUX_SVIDEO,
  296. .vmux = SAA7115_SVIDEO3,
  297. .amux = 1,
  298. } },
  299. },
  300. [EM2800_BOARD_KWORLD_USB2800] = {
  301. .name = "Kworld USB2800",
  302. .is_em2800 = 1,
  303. .vchannels = 3,
  304. .tuner_type = TUNER_PHILIPS_ATSC,
  305. .tda9887_conf = TDA9887_PRESENT,
  306. .has_tuner = 1,
  307. .decoder = EM28XX_SAA7113,
  308. .input = { {
  309. .type = EM28XX_VMUX_TELEVISION,
  310. .vmux = SAA7115_COMPOSITE2,
  311. .amux = 0,
  312. }, {
  313. .type = EM28XX_VMUX_COMPOSITE1,
  314. .vmux = SAA7115_COMPOSITE0,
  315. .amux = 1,
  316. }, {
  317. .type = EM28XX_VMUX_SVIDEO,
  318. .vmux = SAA7115_SVIDEO3,
  319. .amux = 1,
  320. } },
  321. },
  322. [EM2820_BOARD_PINNACLE_DVC_90] = {
  323. .name = "Pinnacle Dazzle DVC 90",
  324. .vchannels = 3,
  325. .has_tuner = 0,
  326. .decoder = EM28XX_SAA7113,
  327. .input = { {
  328. .type = EM28XX_VMUX_COMPOSITE1,
  329. .vmux = SAA7115_COMPOSITE0,
  330. .amux = 1,
  331. }, {
  332. .type = EM28XX_VMUX_SVIDEO,
  333. .vmux = SAA7115_SVIDEO3,
  334. .amux = 1,
  335. } },
  336. },
  337. [EM2800_BOARD_VGEAR_POCKETTV] = {
  338. .name = "V-Gear PocketTV",
  339. .is_em2800 = 1,
  340. .vchannels = 3,
  341. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  342. .tda9887_conf = TDA9887_PRESENT,
  343. .has_tuner = 1,
  344. .decoder = EM28XX_SAA7113,
  345. .input = { {
  346. .type = EM28XX_VMUX_TELEVISION,
  347. .vmux = SAA7115_COMPOSITE2,
  348. .amux = 0,
  349. }, {
  350. .type = EM28XX_VMUX_COMPOSITE1,
  351. .vmux = SAA7115_COMPOSITE0,
  352. .amux = 1,
  353. }, {
  354. .type = EM28XX_VMUX_SVIDEO,
  355. .vmux = SAA7115_SVIDEO3,
  356. .amux = 1,
  357. } },
  358. },
  359. [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
  360. .name = "Pixelview Prolink PlayTV USB 2.0",
  361. .vchannels = 3,
  362. .tda9887_conf = TDA9887_PRESENT,
  363. .has_tuner = 1,
  364. .decoder = EM28XX_SAA7113,
  365. .input = { {
  366. .type = EM28XX_VMUX_TELEVISION,
  367. .vmux = SAA7115_COMPOSITE2,
  368. .amux = 1,
  369. }, {
  370. .type = EM28XX_VMUX_COMPOSITE1,
  371. .vmux = SAA7115_COMPOSITE0,
  372. .amux = 1,
  373. }, {
  374. .type = EM28XX_VMUX_SVIDEO,
  375. .vmux = SAA7115_SVIDEO3,
  376. .amux = 1,
  377. } },
  378. },
  379. };
  380. const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
  381. /* table of devices that work with this driver */
  382. struct usb_device_id em28xx_id_table [] = {
  383. { USB_DEVICE(0xeb1a, 0x2750),
  384. .driver_info = EM2820_BOARD_UNKNOWN },
  385. { USB_DEVICE(0xeb1a, 0x2800),
  386. .driver_info = EM2800_BOARD_UNKNOWN },
  387. { USB_DEVICE(0xeb1a, 0x2820),
  388. .driver_info = EM2820_BOARD_UNKNOWN },
  389. { USB_DEVICE(0xeb1a, 0x2821),
  390. .driver_info = EM2820_BOARD_UNKNOWN },
  391. { USB_DEVICE(0xeb1a, 0x2860),
  392. .driver_info = EM2820_BOARD_UNKNOWN },
  393. { USB_DEVICE(0xeb1a, 0x2861),
  394. .driver_info = EM2820_BOARD_UNKNOWN },
  395. { USB_DEVICE(0xeb1a, 0x2870),
  396. .driver_info = EM2820_BOARD_UNKNOWN },
  397. { USB_DEVICE(0xeb1a, 0x2881),
  398. .driver_info = EM2820_BOARD_UNKNOWN },
  399. { USB_DEVICE(0xeb1a, 0x2883),
  400. .driver_info = EM2820_BOARD_UNKNOWN },
  401. { USB_DEVICE(0x0ccd, 0x0036),
  402. .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
  403. { USB_DEVICE(0x2304, 0x0208),
  404. .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
  405. { USB_DEVICE(0x2040, 0x4200),
  406. .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
  407. { USB_DEVICE(0x2304, 0x0207),
  408. .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
  409. { USB_DEVICE(0x2040, 0x6500),
  410. .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
  411. { USB_DEVICE(0x2040, 0x6513),
  412. .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
  413. { USB_DEVICE(0x0ccd, 0x0042),
  414. .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
  415. { USB_DEVICE(0x0ccd, 0x0047),
  416. .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
  417. { },
  418. };
  419. MODULE_DEVICE_TABLE(usb, em28xx_id_table);
  420. /* EEPROM hash table for devices with generic USB IDs */
  421. static struct em28xx_hash_table em28xx_eeprom_hash [] = {
  422. /* P/N: SA 60002070465 Tuner: TVF7533-MF */
  423. {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
  424. };
  425. /* I2C devicelist hash table for devices with generic USB IDs */
  426. static struct em28xx_hash_table em28xx_i2c_hash[] = {
  427. {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
  428. {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
  429. };
  430. /* Since em28xx_pre_card_setup() requires a proper dev->model,
  431. * this won't work for boards with generic PCI IDs
  432. */
  433. void em28xx_pre_card_setup(struct em28xx *dev)
  434. {
  435. /* request some modules */
  436. switch (dev->model) {
  437. case EM2880_BOARD_TERRATEC_PRODIGY_XS:
  438. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
  439. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
  440. case EM2880_BOARD_TERRATEC_HYBRID_XS:
  441. /* reset through GPIO? */
  442. em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1);
  443. break;
  444. }
  445. }
  446. static int em28xx_tuner_callback(void *ptr, int command, int arg)
  447. {
  448. int rc = 0;
  449. struct em28xx *dev = ptr;
  450. if (dev->tuner_type != TUNER_XC2028)
  451. return 0;
  452. switch (command) {
  453. case XC2028_TUNER_RESET:
  454. /* FIXME: This is device-dependent */
  455. dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
  456. dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
  457. msleep(140);
  458. break;
  459. }
  460. return rc;
  461. }
  462. static void em28xx_config_tuner(struct em28xx *dev)
  463. {
  464. struct v4l2_priv_tun_config xc2028_cfg;
  465. struct xc2028_ctrl ctl;
  466. struct tuner_setup tun_setup;
  467. struct v4l2_frequency f;
  468. if (!dev->has_tuner)
  469. return;
  470. tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
  471. tun_setup.type = dev->tuner_type;
  472. tun_setup.addr = dev->tuner_addr;
  473. tun_setup.tuner_callback = em28xx_tuner_callback;
  474. em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
  475. if (dev->tuner_type == TUNER_XC2028) {
  476. memset(&ctl, 0, sizeof(ctl));
  477. ctl.fname = XC2028_DEFAULT_FIRMWARE;
  478. ctl.max_len = 64;
  479. ctl.mts = em28xx_boards[dev->model].mts_firmware;
  480. xc2028_cfg.tuner = TUNER_XC2028;
  481. xc2028_cfg.priv = &ctl;
  482. em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
  483. }
  484. /* configure tuner */
  485. f.tuner = 0;
  486. f.type = V4L2_TUNER_ANALOG_TV;
  487. f.frequency = 9076; /* just a magic number */
  488. dev->ctl_freq = f.frequency;
  489. em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
  490. }
  491. static int em28xx_hint_board(struct em28xx *dev)
  492. {
  493. int i;
  494. /* HINT method: EEPROM
  495. *
  496. * This method works only for boards with eeprom.
  497. * Uses a hash of all eeprom bytes. The hash should be
  498. * unique for a vendor/tuner pair.
  499. * There are a high chance that tuners for different
  500. * video standards produce different hashes.
  501. */
  502. for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
  503. if (dev->hash == em28xx_eeprom_hash[i].hash) {
  504. dev->model = em28xx_eeprom_hash[i].model;
  505. dev->tuner_type = em28xx_eeprom_hash[i].tuner;
  506. em28xx_errdev("Your board has no unique USB ID.\n");
  507. em28xx_errdev("A hint were successfully done, "
  508. "based on eeprom hash.\n");
  509. em28xx_errdev("This method is not 100%% failproof.\n");
  510. em28xx_errdev("If the board were missdetected, "
  511. "please email this log to:\n");
  512. em28xx_errdev("\tV4L Mailing List "
  513. " <video4linux-list@redhat.com>\n");
  514. em28xx_errdev("Board detected as %s\n",
  515. em28xx_boards[dev->model].name);
  516. return 0;
  517. }
  518. }
  519. /* HINT method: I2C attached devices
  520. *
  521. * This method works for all boards.
  522. * Uses a hash of i2c scanned devices.
  523. * Devices with the same i2c attached chips will
  524. * be considered equal.
  525. * This method is less precise than the eeprom one.
  526. */
  527. /* user did not request i2c scanning => do it now */
  528. if (!dev->i2c_hash)
  529. em28xx_do_i2c_scan(dev);
  530. for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
  531. if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
  532. dev->model = em28xx_i2c_hash[i].model;
  533. dev->tuner_type = em28xx_i2c_hash[i].tuner;
  534. em28xx_errdev("Your board has no unique USB ID.\n");
  535. em28xx_errdev("A hint were successfully done, "
  536. "based on i2c devicelist hash.\n");
  537. em28xx_errdev("This method is not 100%% failproof.\n");
  538. em28xx_errdev("If the board were missdetected, "
  539. "please email this log to:\n");
  540. em28xx_errdev("\tV4L Mailing List "
  541. " <video4linux-list@redhat.com>\n");
  542. em28xx_errdev("Board detected as %s\n",
  543. em28xx_boards[dev->model].name);
  544. return 0;
  545. }
  546. }
  547. em28xx_errdev("Your board has no unique USB ID and thus need a "
  548. "hint to be detected.\n");
  549. em28xx_errdev("You may try to use card=<n> insmod option to "
  550. "workaround that.\n");
  551. em28xx_errdev("Please send an email with this log to:\n");
  552. em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
  553. em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
  554. em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
  555. em28xx_errdev("Here is a list of valid choices for the card=<n>"
  556. " insmod option:\n");
  557. for (i = 0; i < em28xx_bcount; i++) {
  558. em28xx_errdev(" card=%d -> %s\n",
  559. i, em28xx_boards[i].name);
  560. }
  561. return -1;
  562. }
  563. static void em28xx_set_model(struct em28xx *dev)
  564. {
  565. dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
  566. dev->has_tuner = em28xx_boards[dev->model].has_tuner;
  567. dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
  568. dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
  569. dev->decoder = em28xx_boards[dev->model].decoder;
  570. dev->video_inputs = em28xx_boards[dev->model].vchannels;
  571. if (!em28xx_boards[dev->model].has_tuner)
  572. dev->tuner_type = UNSET;
  573. }
  574. void em28xx_card_setup(struct em28xx *dev)
  575. {
  576. em28xx_set_model(dev);
  577. dev->tuner_type = em28xx_boards[dev->model].tuner_type;
  578. /* request some modules */
  579. switch (dev->model) {
  580. case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
  581. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
  582. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
  583. {
  584. struct tveeprom tv;
  585. #ifdef CONFIG_MODULES
  586. request_module("tveeprom");
  587. #endif
  588. /* Call first TVeeprom */
  589. dev->i2c_client.addr = 0xa0 >> 1;
  590. tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
  591. dev->tuner_type = tv.tuner_type;
  592. if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
  593. dev->i2s_speed = 2048000;
  594. dev->has_msp34xx = 1;
  595. }
  596. #ifdef CONFIG_MODULES
  597. if (tv.has_ir)
  598. request_module("ir-kbd-i2c");
  599. #endif
  600. /* FIXME: Should also retrieve decoder processor type */
  601. break;
  602. }
  603. case EM2820_BOARD_KWORLD_PVRTV2800RF:
  604. /* GPIO enables sound on KWORLD PVR TV 2800RF */
  605. em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
  606. break;
  607. case EM2820_BOARD_UNKNOWN:
  608. case EM2800_BOARD_UNKNOWN:
  609. if (!em28xx_hint_board(dev))
  610. em28xx_set_model(dev);
  611. }
  612. /* Allow override tuner type by a module parameter */
  613. if (tuner >= 0)
  614. dev->tuner_type = tuner;
  615. #ifdef CONFIG_MODULES
  616. /* request some modules */
  617. if (dev->has_msp34xx)
  618. request_module("msp3400");
  619. if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
  620. request_module("saa7115");
  621. if (dev->decoder == EM28XX_TVP5150)
  622. request_module("tvp5150");
  623. if (dev->has_tuner)
  624. request_module("tuner");
  625. #endif
  626. em28xx_config_tuner(dev);
  627. }