em28xx-cards.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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. static int tuner = -1;
  34. module_param(tuner, int, 0444);
  35. MODULE_PARM_DESC(tuner, "tuner type");
  36. static unsigned int disable_ir;
  37. module_param(disable_ir, int, 0444);
  38. MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
  39. struct em28xx_hash_table {
  40. unsigned long hash;
  41. unsigned int model;
  42. unsigned int tuner;
  43. };
  44. struct em28xx_board em28xx_boards[] = {
  45. [EM2800_BOARD_UNKNOWN] = {
  46. .name = "Unknown EM2800 video grabber",
  47. .is_em2800 = 1,
  48. .vchannels = 2,
  49. .tda9887_conf = TDA9887_PRESENT,
  50. .decoder = EM28XX_SAA7113,
  51. .input = { {
  52. .type = EM28XX_VMUX_COMPOSITE1,
  53. .vmux = SAA7115_COMPOSITE0,
  54. .amux = 1,
  55. }, {
  56. .type = EM28XX_VMUX_SVIDEO,
  57. .vmux = SAA7115_SVIDEO3,
  58. .amux = 1,
  59. } },
  60. },
  61. [EM2820_BOARD_UNKNOWN] = {
  62. .name = "Unknown EM2750/28xx video grabber",
  63. .is_em2800 = 0,
  64. .tuner_type = TUNER_ABSENT,
  65. },
  66. [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
  67. .name = "Kworld PVR TV 2800 RF",
  68. .is_em2800 = 0,
  69. .vchannels = 2,
  70. .tuner_type = TUNER_TEMIC_PAL,
  71. .tda9887_conf = TDA9887_PRESENT,
  72. .decoder = EM28XX_SAA7113,
  73. .input = { {
  74. .type = EM28XX_VMUX_COMPOSITE1,
  75. .vmux = SAA7115_COMPOSITE0,
  76. .amux = 1,
  77. }, {
  78. .type = EM28XX_VMUX_SVIDEO,
  79. .vmux = SAA7115_SVIDEO3,
  80. .amux = 1,
  81. } },
  82. },
  83. [EM2820_BOARD_TERRATEC_CINERGY_250] = {
  84. .name = "Terratec Cinergy 250 USB",
  85. .vchannels = 3,
  86. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  87. .tda9887_conf = TDA9887_PRESENT,
  88. .decoder = EM28XX_SAA7113,
  89. .input = { {
  90. .type = EM28XX_VMUX_TELEVISION,
  91. .vmux = SAA7115_COMPOSITE2,
  92. .amux = 1,
  93. }, {
  94. .type = EM28XX_VMUX_COMPOSITE1,
  95. .vmux = SAA7115_COMPOSITE0,
  96. .amux = 1,
  97. }, {
  98. .type = EM28XX_VMUX_SVIDEO,
  99. .vmux = SAA7115_SVIDEO3,
  100. .amux = 1,
  101. } },
  102. },
  103. [EM2820_BOARD_PINNACLE_USB_2] = {
  104. .name = "Pinnacle PCTV USB 2",
  105. .vchannels = 3,
  106. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  107. .tda9887_conf = TDA9887_PRESENT,
  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. .decoder = EM28XX_TVP5150,
  131. .has_msp34xx = 1,
  132. /*FIXME: S-Video not tested */
  133. .input = { {
  134. .type = EM28XX_VMUX_TELEVISION,
  135. .vmux = TVP5150_COMPOSITE0,
  136. .amux = MSP_INPUT_DEFAULT,
  137. }, {
  138. .type = EM28XX_VMUX_SVIDEO,
  139. .vmux = TVP5150_SVIDEO,
  140. .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
  141. MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
  142. } },
  143. },
  144. [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
  145. .name = "Hauppauge WinTV HVR 900",
  146. .vchannels = 3,
  147. .tda9887_conf = TDA9887_PRESENT,
  148. .tuner_type = TUNER_XC2028,
  149. .mts_firmware = 1,
  150. .decoder = EM28XX_TVP5150,
  151. .input = { {
  152. .type = EM28XX_VMUX_TELEVISION,
  153. .vmux = TVP5150_COMPOSITE0,
  154. .amux = 0,
  155. }, {
  156. .type = EM28XX_VMUX_COMPOSITE1,
  157. .vmux = TVP5150_COMPOSITE1,
  158. .amux = 1,
  159. }, {
  160. .type = EM28XX_VMUX_SVIDEO,
  161. .vmux = TVP5150_SVIDEO,
  162. .amux = 1,
  163. } },
  164. },
  165. [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
  166. .name = "Hauppauge WinTV HVR 950",
  167. .vchannels = 3,
  168. .tda9887_conf = TDA9887_PRESENT,
  169. .tuner_type = TUNER_XC2028,
  170. .mts_firmware = 1,
  171. .has_12mhz_i2s = 1,
  172. .has_dvb = 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. .tuner_type = TUNER_XC2028,
  193. .decoder = EM28XX_TVP5150,
  194. .input = { {
  195. .type = EM28XX_VMUX_TELEVISION,
  196. .vmux = TVP5150_COMPOSITE0,
  197. .amux = 0,
  198. }, {
  199. .type = EM28XX_VMUX_COMPOSITE1,
  200. .vmux = TVP5150_COMPOSITE1,
  201. .amux = 1,
  202. }, {
  203. .type = EM28XX_VMUX_SVIDEO,
  204. .vmux = TVP5150_SVIDEO,
  205. .amux = 1,
  206. } },
  207. },
  208. /* maybe there's a reason behind it why Terratec sells the Hybrid XS
  209. as Prodigy XS with a different PID, let's keep it separated for now
  210. maybe we'll need it lateron */
  211. [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
  212. .name = "Terratec Prodigy XS",
  213. .vchannels = 3,
  214. .tda9887_conf = TDA9887_PRESENT,
  215. .tuner_type = TUNER_XC2028,
  216. .decoder = EM28XX_TVP5150,
  217. .input = { {
  218. .type = EM28XX_VMUX_TELEVISION,
  219. .vmux = TVP5150_COMPOSITE0,
  220. .amux = 0,
  221. }, {
  222. .type = EM28XX_VMUX_COMPOSITE1,
  223. .vmux = TVP5150_COMPOSITE1,
  224. .amux = 1,
  225. }, {
  226. .type = EM28XX_VMUX_SVIDEO,
  227. .vmux = TVP5150_SVIDEO,
  228. .amux = 1,
  229. } },
  230. },
  231. [EM2820_BOARD_MSI_VOX_USB_2] = {
  232. .name = "MSI VOX USB 2.0",
  233. .vchannels = 3,
  234. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  235. .tda9887_conf = TDA9887_PRESENT |
  236. TDA9887_PORT1_ACTIVE |
  237. TDA9887_PORT2_ACTIVE,
  238. .max_range_640_480 = 1,
  239. .decoder = EM28XX_SAA7114,
  240. .input = { {
  241. .type = EM28XX_VMUX_TELEVISION,
  242. .vmux = SAA7115_COMPOSITE4,
  243. .amux = 0,
  244. }, {
  245. .type = EM28XX_VMUX_COMPOSITE1,
  246. .vmux = SAA7115_COMPOSITE0,
  247. .amux = 1,
  248. }, {
  249. .type = EM28XX_VMUX_SVIDEO,
  250. .vmux = SAA7115_SVIDEO3,
  251. .amux = 1,
  252. } },
  253. },
  254. [EM2800_BOARD_TERRATEC_CINERGY_200] = {
  255. .name = "Terratec Cinergy 200 USB",
  256. .is_em2800 = 1,
  257. .vchannels = 3,
  258. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  259. .tda9887_conf = TDA9887_PRESENT,
  260. .decoder = EM28XX_SAA7113,
  261. .input = { {
  262. .type = EM28XX_VMUX_TELEVISION,
  263. .vmux = SAA7115_COMPOSITE2,
  264. .amux = 0,
  265. }, {
  266. .type = EM28XX_VMUX_COMPOSITE1,
  267. .vmux = SAA7115_COMPOSITE0,
  268. .amux = 1,
  269. }, {
  270. .type = EM28XX_VMUX_SVIDEO,
  271. .vmux = SAA7115_SVIDEO3,
  272. .amux = 1,
  273. } },
  274. },
  275. [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
  276. .name = "Leadtek Winfast USB II",
  277. .is_em2800 = 1,
  278. .vchannels = 3,
  279. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  280. .tda9887_conf = TDA9887_PRESENT,
  281. .decoder = EM28XX_SAA7113,
  282. .input = { {
  283. .type = EM28XX_VMUX_TELEVISION,
  284. .vmux = SAA7115_COMPOSITE2,
  285. .amux = 0,
  286. }, {
  287. .type = EM28XX_VMUX_COMPOSITE1,
  288. .vmux = SAA7115_COMPOSITE0,
  289. .amux = 1,
  290. }, {
  291. .type = EM28XX_VMUX_SVIDEO,
  292. .vmux = SAA7115_SVIDEO3,
  293. .amux = 1,
  294. } },
  295. },
  296. [EM2800_BOARD_KWORLD_USB2800] = {
  297. .name = "Kworld USB2800",
  298. .is_em2800 = 1,
  299. .vchannels = 3,
  300. .tuner_type = TUNER_PHILIPS_FCV1236D,
  301. .tda9887_conf = TDA9887_PRESENT,
  302. .decoder = EM28XX_SAA7113,
  303. .input = { {
  304. .type = EM28XX_VMUX_TELEVISION,
  305. .vmux = SAA7115_COMPOSITE2,
  306. .amux = 0,
  307. }, {
  308. .type = EM28XX_VMUX_COMPOSITE1,
  309. .vmux = SAA7115_COMPOSITE0,
  310. .amux = 1,
  311. }, {
  312. .type = EM28XX_VMUX_SVIDEO,
  313. .vmux = SAA7115_SVIDEO3,
  314. .amux = 1,
  315. } },
  316. },
  317. [EM2820_BOARD_PINNACLE_DVC_90] = {
  318. .name = "Pinnacle Dazzle DVC 90/DVC 100",
  319. .vchannels = 3,
  320. .tuner_type = TUNER_ABSENT,
  321. .decoder = EM28XX_SAA7113,
  322. .input = { {
  323. .type = EM28XX_VMUX_COMPOSITE1,
  324. .vmux = SAA7115_COMPOSITE0,
  325. .amux = 1,
  326. }, {
  327. .type = EM28XX_VMUX_SVIDEO,
  328. .vmux = SAA7115_SVIDEO3,
  329. .amux = 1,
  330. } },
  331. },
  332. [EM2800_BOARD_VGEAR_POCKETTV] = {
  333. .name = "V-Gear PocketTV",
  334. .is_em2800 = 1,
  335. .vchannels = 3,
  336. .tuner_type = TUNER_LG_PAL_NEW_TAPC,
  337. .tda9887_conf = TDA9887_PRESENT,
  338. .decoder = EM28XX_SAA7113,
  339. .input = { {
  340. .type = EM28XX_VMUX_TELEVISION,
  341. .vmux = SAA7115_COMPOSITE2,
  342. .amux = 0,
  343. }, {
  344. .type = EM28XX_VMUX_COMPOSITE1,
  345. .vmux = SAA7115_COMPOSITE0,
  346. .amux = 1,
  347. }, {
  348. .type = EM28XX_VMUX_SVIDEO,
  349. .vmux = SAA7115_SVIDEO3,
  350. .amux = 1,
  351. } },
  352. },
  353. [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
  354. .name = "Pixelview Prolink PlayTV USB 2.0",
  355. .vchannels = 3,
  356. .tda9887_conf = TDA9887_PRESENT,
  357. .tuner_type = TUNER_YMEC_TVF_5533MF,
  358. .decoder = EM28XX_SAA7113,
  359. .input = { {
  360. .type = EM28XX_VMUX_TELEVISION,
  361. .vmux = SAA7115_COMPOSITE2,
  362. .amux = EM28XX_AMUX_LINE_IN,
  363. }, {
  364. .type = EM28XX_VMUX_COMPOSITE1,
  365. .vmux = SAA7115_COMPOSITE0,
  366. .amux = EM28XX_AMUX_LINE_IN,
  367. }, {
  368. .type = EM28XX_VMUX_SVIDEO,
  369. .vmux = SAA7115_SVIDEO3,
  370. .amux = EM28XX_AMUX_LINE_IN,
  371. } },
  372. },
  373. };
  374. const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
  375. /* table of devices that work with this driver */
  376. struct usb_device_id em28xx_id_table [] = {
  377. { USB_DEVICE(0xeb1a, 0x2750),
  378. .driver_info = EM2820_BOARD_UNKNOWN },
  379. { USB_DEVICE(0xeb1a, 0x2800),
  380. .driver_info = EM2800_BOARD_UNKNOWN },
  381. { USB_DEVICE(0xeb1a, 0x2820),
  382. .driver_info = EM2820_BOARD_UNKNOWN },
  383. { USB_DEVICE(0xeb1a, 0x2821),
  384. .driver_info = EM2820_BOARD_UNKNOWN },
  385. { USB_DEVICE(0xeb1a, 0x2860),
  386. .driver_info = EM2820_BOARD_UNKNOWN },
  387. { USB_DEVICE(0xeb1a, 0x2861),
  388. .driver_info = EM2820_BOARD_UNKNOWN },
  389. { USB_DEVICE(0xeb1a, 0x2870),
  390. .driver_info = EM2820_BOARD_UNKNOWN },
  391. { USB_DEVICE(0xeb1a, 0x2881),
  392. .driver_info = EM2820_BOARD_UNKNOWN },
  393. { USB_DEVICE(0xeb1a, 0x2883),
  394. .driver_info = EM2820_BOARD_UNKNOWN },
  395. { USB_DEVICE(0x0ccd, 0x0036),
  396. .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
  397. { USB_DEVICE(0x2304, 0x0208),
  398. .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
  399. { USB_DEVICE(0x2040, 0x4200),
  400. .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
  401. { USB_DEVICE(0x2040, 0x4201),
  402. .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
  403. { USB_DEVICE(0x2304, 0x0207),
  404. .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
  405. { USB_DEVICE(0x2304, 0x021a),
  406. .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
  407. { USB_DEVICE(0x2040, 0x6500),
  408. .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
  409. { USB_DEVICE(0x2040, 0x6502),
  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. /*
  421. * Reset sequences for analog/digital modes
  422. */
  423. /* Board Hauppauge WinTV HVR 900 analog */
  424. struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
  425. { -1, -1, 6},
  426. {0x08, 0x2d, 10},
  427. {0x08, 0x3d, 5},
  428. { -1, -1, -1},
  429. };
  430. /* Board Hauppauge WinTV HVR 900 digital */
  431. struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
  432. { -1, -1, 6},
  433. {0x08, 0x2e, 6},
  434. {0x08, 0x3e, 6},
  435. { -1, -1, -1},
  436. };
  437. /*
  438. * EEPROM hash table for devices with generic USB IDs
  439. */
  440. static struct em28xx_hash_table em28xx_eeprom_hash [] = {
  441. /* P/N: SA 60002070465 Tuner: TVF7533-MF */
  442. {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
  443. };
  444. /* I2C devicelist hash table for devices with generic USB IDs */
  445. static struct em28xx_hash_table em28xx_i2c_hash[] = {
  446. {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
  447. {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
  448. };
  449. int em28xx_tuner_callback(void *ptr, int command, int arg)
  450. {
  451. int rc = 0;
  452. struct em28xx *dev = ptr;
  453. struct em28xx_reg_seq *gpio;
  454. if (dev->tuner_type != TUNER_XC2028)
  455. return 0;
  456. if (command != XC2028_TUNER_RESET)
  457. return 0;
  458. if (dev->mode == EM28XX_ANALOG_MODE)
  459. gpio = dev->analog_gpio;
  460. else
  461. gpio = dev->digital_gpio;
  462. /* djh - Not sure if these are still required */
  463. dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
  464. if (dev->mode == EM28XX_ANALOG_MODE)
  465. dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
  466. else
  467. dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x37", 1);
  468. msleep(6);
  469. if (!gpio)
  470. return rc;
  471. /* Send GPIO reset sequences specified at board entry */
  472. while (gpio->sleep >= 0) {
  473. if (gpio->reg >= 0)
  474. rc = dev->em28xx_write_regs(dev,
  475. gpio->reg,
  476. &gpio->val, 1);
  477. if (gpio->sleep > 0)
  478. msleep(gpio->sleep);
  479. gpio++;
  480. }
  481. return rc;
  482. }
  483. EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
  484. static void em28xx_set_model(struct em28xx *dev)
  485. {
  486. dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
  487. dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
  488. dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
  489. dev->decoder = em28xx_boards[dev->model].decoder;
  490. dev->video_inputs = em28xx_boards[dev->model].vchannels;
  491. dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
  492. dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
  493. dev->has_dvb = em28xx_boards[dev->model].has_dvb;
  494. }
  495. /* Since em28xx_pre_card_setup() requires a proper dev->model,
  496. * this won't work for boards with generic PCI IDs
  497. */
  498. void em28xx_pre_card_setup(struct em28xx *dev)
  499. {
  500. em28xx_set_model(dev);
  501. /* request some modules */
  502. switch (dev->model) {
  503. case EM2880_BOARD_TERRATEC_PRODIGY_XS:
  504. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
  505. case EM2880_BOARD_TERRATEC_HYBRID_XS:
  506. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
  507. em28xx_write_regs(dev, XCLK_REG, "\x27", 1);
  508. em28xx_write_regs(dev, I2C_CLK_REG, "\x40", 1);
  509. em28xx_write_regs(dev, 0x08, "\xff", 1);
  510. em28xx_write_regs(dev, 0x04, "\x00", 1);
  511. msleep(100);
  512. em28xx_write_regs(dev, 0x04, "\x08", 1);
  513. msleep(100);
  514. em28xx_write_regs(dev, 0x08, "\xff", 1);
  515. msleep(50);
  516. em28xx_write_regs(dev, 0x08, "\x2d", 1);
  517. msleep(50);
  518. em28xx_write_regs(dev, 0x08, "\x3d", 1);
  519. dev->analog_gpio = hauppauge_wintv_hvr_900_analog;
  520. dev->digital_gpio = hauppauge_wintv_hvr_900_digital;
  521. break;
  522. }
  523. }
  524. void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
  525. {
  526. memset(ctl, 0, sizeof(*ctl));
  527. ctl->fname = XC2028_DEFAULT_FIRMWARE;
  528. ctl->max_len = 64;
  529. ctl->mts = em28xx_boards[dev->model].mts_firmware;
  530. switch (dev->model) {
  531. /* Add card-specific parameters for xc3028 here */
  532. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
  533. ctl->demod = XC3028_FE_DEFAULT;
  534. break;
  535. default:
  536. ctl->demod = XC3028_FE_OREN538;
  537. }
  538. }
  539. EXPORT_SYMBOL_GPL(em28xx_setup_xc3028);
  540. static void em28xx_config_tuner(struct em28xx *dev)
  541. {
  542. struct v4l2_priv_tun_config xc2028_cfg;
  543. struct tuner_setup tun_setup;
  544. struct v4l2_frequency f;
  545. if (dev->tuner_type == TUNER_ABSENT)
  546. return;
  547. tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
  548. tun_setup.type = dev->tuner_type;
  549. tun_setup.addr = dev->tuner_addr;
  550. tun_setup.tuner_callback = em28xx_tuner_callback;
  551. em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
  552. if (dev->tuner_type == TUNER_XC2028) {
  553. struct xc2028_ctrl ctl;
  554. em28xx_setup_xc3028(dev, &ctl);
  555. xc2028_cfg.tuner = TUNER_XC2028;
  556. xc2028_cfg.priv = &ctl;
  557. em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
  558. }
  559. /* configure tuner */
  560. f.tuner = 0;
  561. f.type = V4L2_TUNER_ANALOG_TV;
  562. f.frequency = 9076; /* just a magic number */
  563. dev->ctl_freq = f.frequency;
  564. em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
  565. }
  566. static int em28xx_hint_board(struct em28xx *dev)
  567. {
  568. int i;
  569. /* HINT method: EEPROM
  570. *
  571. * This method works only for boards with eeprom.
  572. * Uses a hash of all eeprom bytes. The hash should be
  573. * unique for a vendor/tuner pair.
  574. * There are a high chance that tuners for different
  575. * video standards produce different hashes.
  576. */
  577. for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
  578. if (dev->hash == em28xx_eeprom_hash[i].hash) {
  579. dev->model = em28xx_eeprom_hash[i].model;
  580. dev->tuner_type = em28xx_eeprom_hash[i].tuner;
  581. em28xx_errdev("Your board has no unique USB ID.\n");
  582. em28xx_errdev("A hint were successfully done, "
  583. "based on eeprom hash.\n");
  584. em28xx_errdev("This method is not 100%% failproof.\n");
  585. em28xx_errdev("If the board were missdetected, "
  586. "please email this log to:\n");
  587. em28xx_errdev("\tV4L Mailing List "
  588. " <video4linux-list@redhat.com>\n");
  589. em28xx_errdev("Board detected as %s\n",
  590. em28xx_boards[dev->model].name);
  591. return 0;
  592. }
  593. }
  594. /* HINT method: I2C attached devices
  595. *
  596. * This method works for all boards.
  597. * Uses a hash of i2c scanned devices.
  598. * Devices with the same i2c attached chips will
  599. * be considered equal.
  600. * This method is less precise than the eeprom one.
  601. */
  602. /* user did not request i2c scanning => do it now */
  603. if (!dev->i2c_hash)
  604. em28xx_do_i2c_scan(dev);
  605. for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
  606. if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
  607. dev->model = em28xx_i2c_hash[i].model;
  608. dev->tuner_type = em28xx_i2c_hash[i].tuner;
  609. em28xx_errdev("Your board has no unique USB ID.\n");
  610. em28xx_errdev("A hint were successfully done, "
  611. "based on i2c devicelist hash.\n");
  612. em28xx_errdev("This method is not 100%% failproof.\n");
  613. em28xx_errdev("If the board were missdetected, "
  614. "please email this log to:\n");
  615. em28xx_errdev("\tV4L Mailing List "
  616. " <video4linux-list@redhat.com>\n");
  617. em28xx_errdev("Board detected as %s\n",
  618. em28xx_boards[dev->model].name);
  619. return 0;
  620. }
  621. }
  622. em28xx_errdev("Your board has no unique USB ID and thus need a "
  623. "hint to be detected.\n");
  624. em28xx_errdev("You may try to use card=<n> insmod option to "
  625. "workaround that.\n");
  626. em28xx_errdev("Please send an email with this log to:\n");
  627. em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
  628. em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
  629. em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
  630. em28xx_errdev("Here is a list of valid choices for the card=<n>"
  631. " insmod option:\n");
  632. for (i = 0; i < em28xx_bcount; i++) {
  633. em28xx_errdev(" card=%d -> %s\n",
  634. i, em28xx_boards[i].name);
  635. }
  636. return -1;
  637. }
  638. /* ----------------------------------------------------------------------- */
  639. void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
  640. {
  641. if (disable_ir) {
  642. ir->get_key = NULL;
  643. return ;
  644. }
  645. /* detect & configure */
  646. switch (dev->model) {
  647. case (EM2800_BOARD_UNKNOWN):
  648. break;
  649. case (EM2820_BOARD_UNKNOWN):
  650. break;
  651. case (EM2800_BOARD_TERRATEC_CINERGY_200):
  652. case (EM2820_BOARD_TERRATEC_CINERGY_250):
  653. ir->ir_codes = ir_codes_em_terratec;
  654. ir->get_key = em28xx_get_key_terratec;
  655. snprintf(ir->c.name, sizeof(ir->c.name),
  656. "i2c IR (EM28XX Terratec)");
  657. break;
  658. case (EM2820_BOARD_PINNACLE_USB_2):
  659. ir->ir_codes = ir_codes_pinnacle_grey;
  660. ir->get_key = em28xx_get_key_pinnacle_usb_grey;
  661. snprintf(ir->c.name, sizeof(ir->c.name),
  662. "i2c IR (EM28XX Pinnacle PCTV)");
  663. break;
  664. case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
  665. ir->ir_codes = ir_codes_hauppauge_new;
  666. ir->get_key = em28xx_get_key_em_haup;
  667. snprintf(ir->c.name, sizeof(ir->c.name),
  668. "i2c IR (EM2840 Hauppauge)");
  669. break;
  670. case (EM2820_BOARD_MSI_VOX_USB_2):
  671. break;
  672. case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
  673. break;
  674. case (EM2800_BOARD_KWORLD_USB2800):
  675. break;
  676. }
  677. }
  678. void em28xx_card_setup(struct em28xx *dev)
  679. {
  680. em28xx_set_model(dev);
  681. dev->tuner_type = em28xx_boards[dev->model].tuner_type;
  682. /* request some modules */
  683. switch (dev->model) {
  684. case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
  685. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
  686. case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
  687. {
  688. struct tveeprom tv;
  689. #ifdef CONFIG_MODULES
  690. request_module("tveeprom");
  691. #endif
  692. /* Call first TVeeprom */
  693. dev->i2c_client.addr = 0xa0 >> 1;
  694. tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
  695. dev->tuner_type = tv.tuner_type;
  696. if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
  697. dev->i2s_speed = 2048000;
  698. dev->has_msp34xx = 1;
  699. }
  700. #ifdef CONFIG_MODULES
  701. if (tv.has_ir)
  702. request_module("ir-kbd-i2c");
  703. #endif
  704. break;
  705. }
  706. case EM2820_BOARD_KWORLD_PVRTV2800RF:
  707. /* GPIO enables sound on KWORLD PVR TV 2800RF */
  708. em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
  709. break;
  710. case EM2820_BOARD_UNKNOWN:
  711. case EM2800_BOARD_UNKNOWN:
  712. if (!em28xx_hint_board(dev))
  713. em28xx_set_model(dev);
  714. }
  715. /* Allow override tuner type by a module parameter */
  716. if (tuner >= 0)
  717. dev->tuner_type = tuner;
  718. #ifdef CONFIG_MODULES
  719. /* request some modules */
  720. if (dev->has_msp34xx)
  721. request_module("msp3400");
  722. if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
  723. request_module("saa7115");
  724. if (dev->decoder == EM28XX_TVP5150)
  725. request_module("tvp5150");
  726. if (dev->tuner_type != TUNER_ABSENT)
  727. request_module("tuner");
  728. #endif
  729. em28xx_config_tuner(dev);
  730. }