cx23885-dvb.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*
  2. * Driver for the Conexant CX23885 PCIe bridge
  3. *
  4. * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
  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/module.h>
  22. #include <linux/init.h>
  23. #include <linux/device.h>
  24. #include <linux/fs.h>
  25. #include <linux/kthread.h>
  26. #include <linux/file.h>
  27. #include <linux/suspend.h>
  28. #include "cx23885.h"
  29. #include <media/v4l2-common.h>
  30. #include "s5h1409.h"
  31. #include "s5h1411.h"
  32. #include "mt2131.h"
  33. #include "tda8290.h"
  34. #include "tda18271.h"
  35. #include "lgdt330x.h"
  36. #include "xc5000.h"
  37. #include "tda10048.h"
  38. #include "tuner-xc2028.h"
  39. #include "tuner-simple.h"
  40. #include "dib7000p.h"
  41. #include "dibx000_common.h"
  42. #include "zl10353.h"
  43. static unsigned int debug;
  44. #define dprintk(level, fmt, arg...)\
  45. do { if (debug >= level)\
  46. printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
  47. } while (0)
  48. /* ------------------------------------------------------------------ */
  49. static unsigned int alt_tuner;
  50. module_param(alt_tuner, int, 0644);
  51. MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
  52. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  53. /* ------------------------------------------------------------------ */
  54. static int dvb_buf_setup(struct videobuf_queue *q,
  55. unsigned int *count, unsigned int *size)
  56. {
  57. struct cx23885_tsport *port = q->priv_data;
  58. port->ts_packet_size = 188 * 4;
  59. port->ts_packet_count = 32;
  60. *size = port->ts_packet_size * port->ts_packet_count;
  61. *count = 32;
  62. return 0;
  63. }
  64. static int dvb_buf_prepare(struct videobuf_queue *q,
  65. struct videobuf_buffer *vb, enum v4l2_field field)
  66. {
  67. struct cx23885_tsport *port = q->priv_data;
  68. return cx23885_buf_prepare(q, port, (struct cx23885_buffer*)vb, field);
  69. }
  70. static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
  71. {
  72. struct cx23885_tsport *port = q->priv_data;
  73. cx23885_buf_queue(port, (struct cx23885_buffer*)vb);
  74. }
  75. static void dvb_buf_release(struct videobuf_queue *q,
  76. struct videobuf_buffer *vb)
  77. {
  78. cx23885_free_buffer(q, (struct cx23885_buffer*)vb);
  79. }
  80. static struct videobuf_queue_ops dvb_qops = {
  81. .buf_setup = dvb_buf_setup,
  82. .buf_prepare = dvb_buf_prepare,
  83. .buf_queue = dvb_buf_queue,
  84. .buf_release = dvb_buf_release,
  85. };
  86. static struct s5h1409_config hauppauge_generic_config = {
  87. .demod_address = 0x32 >> 1,
  88. .output_mode = S5H1409_SERIAL_OUTPUT,
  89. .gpio = S5H1409_GPIO_ON,
  90. .qam_if = 44000,
  91. .inversion = S5H1409_INVERSION_OFF,
  92. .status_mode = S5H1409_DEMODLOCKING,
  93. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  94. };
  95. static struct tda10048_config hauppauge_hvr1200_config = {
  96. .demod_address = 0x10 >> 1,
  97. .output_mode = TDA10048_SERIAL_OUTPUT,
  98. .fwbulkwritelen = TDA10048_BULKWRITE_200,
  99. .inversion = TDA10048_INVERSION_ON
  100. };
  101. static struct s5h1409_config hauppauge_ezqam_config = {
  102. .demod_address = 0x32 >> 1,
  103. .output_mode = S5H1409_SERIAL_OUTPUT,
  104. .gpio = S5H1409_GPIO_OFF,
  105. .qam_if = 4000,
  106. .inversion = S5H1409_INVERSION_ON,
  107. .status_mode = S5H1409_DEMODLOCKING,
  108. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  109. };
  110. static struct s5h1409_config hauppauge_hvr1800lp_config = {
  111. .demod_address = 0x32 >> 1,
  112. .output_mode = S5H1409_SERIAL_OUTPUT,
  113. .gpio = S5H1409_GPIO_OFF,
  114. .qam_if = 44000,
  115. .inversion = S5H1409_INVERSION_OFF,
  116. .status_mode = S5H1409_DEMODLOCKING,
  117. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  118. };
  119. static struct s5h1409_config hauppauge_hvr1500_config = {
  120. .demod_address = 0x32 >> 1,
  121. .output_mode = S5H1409_SERIAL_OUTPUT,
  122. .gpio = S5H1409_GPIO_OFF,
  123. .inversion = S5H1409_INVERSION_OFF,
  124. .status_mode = S5H1409_DEMODLOCKING,
  125. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  126. };
  127. static struct mt2131_config hauppauge_generic_tunerconfig = {
  128. 0x61
  129. };
  130. static struct lgdt330x_config fusionhdtv_5_express = {
  131. .demod_address = 0x0e,
  132. .demod_chip = LGDT3303,
  133. .serial_mpeg = 0x40,
  134. };
  135. static struct s5h1409_config hauppauge_hvr1500q_config = {
  136. .demod_address = 0x32 >> 1,
  137. .output_mode = S5H1409_SERIAL_OUTPUT,
  138. .gpio = S5H1409_GPIO_ON,
  139. .qam_if = 44000,
  140. .inversion = S5H1409_INVERSION_OFF,
  141. .status_mode = S5H1409_DEMODLOCKING,
  142. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  143. };
  144. static struct s5h1409_config dvico_s5h1409_config = {
  145. .demod_address = 0x32 >> 1,
  146. .output_mode = S5H1409_SERIAL_OUTPUT,
  147. .gpio = S5H1409_GPIO_ON,
  148. .qam_if = 44000,
  149. .inversion = S5H1409_INVERSION_OFF,
  150. .status_mode = S5H1409_DEMODLOCKING,
  151. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  152. };
  153. static struct s5h1411_config dvico_s5h1411_config = {
  154. .output_mode = S5H1411_SERIAL_OUTPUT,
  155. .gpio = S5H1411_GPIO_ON,
  156. .qam_if = S5H1411_IF_44000,
  157. .vsb_if = S5H1411_IF_44000,
  158. .inversion = S5H1411_INVERSION_OFF,
  159. .status_mode = S5H1411_DEMODLOCKING,
  160. .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  161. };
  162. static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
  163. .i2c_address = 0x61,
  164. .if_khz = 5380,
  165. };
  166. static struct xc5000_config dvico_xc5000_tunerconfig = {
  167. .i2c_address = 0x64,
  168. .if_khz = 5380,
  169. };
  170. static struct tda829x_config tda829x_no_probe = {
  171. .probe_tuner = TDA829X_DONT_PROBE,
  172. };
  173. static struct tda18271_std_map hauppauge_tda18271_std_map = {
  174. .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
  175. .if_lvl = 6, .rfagc_top = 0x37 },
  176. .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
  177. .if_lvl = 6, .rfagc_top = 0x37 },
  178. };
  179. static struct tda18271_config hauppauge_tda18271_config = {
  180. .std_map = &hauppauge_tda18271_std_map,
  181. .gate = TDA18271_GATE_ANALOG,
  182. };
  183. static struct tda18271_config hauppauge_hvr1200_tuner_config = {
  184. .gate = TDA18271_GATE_ANALOG,
  185. };
  186. static struct dibx000_agc_config xc3028_agc_config = {
  187. BAND_VHF | BAND_UHF, /* band_caps */
  188. /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
  189. * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
  190. * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
  191. * P_agc_nb_est=2, P_agc_write=0
  192. */
  193. (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
  194. (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
  195. 712, /* inv_gain */
  196. 21, /* time_stabiliz */
  197. 0, /* alpha_level */
  198. 118, /* thlock */
  199. 0, /* wbd_inv */
  200. 2867, /* wbd_ref */
  201. 0, /* wbd_sel */
  202. 2, /* wbd_alpha */
  203. 0, /* agc1_max */
  204. 0, /* agc1_min */
  205. 39718, /* agc2_max */
  206. 9930, /* agc2_min */
  207. 0, /* agc1_pt1 */
  208. 0, /* agc1_pt2 */
  209. 0, /* agc1_pt3 */
  210. 0, /* agc1_slope1 */
  211. 0, /* agc1_slope2 */
  212. 0, /* agc2_pt1 */
  213. 128, /* agc2_pt2 */
  214. 29, /* agc2_slope1 */
  215. 29, /* agc2_slope2 */
  216. 17, /* alpha_mant */
  217. 27, /* alpha_exp */
  218. 23, /* beta_mant */
  219. 51, /* beta_exp */
  220. 1, /* perform_agc_softsplit */
  221. };
  222. /* PLL Configuration for COFDM BW_MHz = 8.000000
  223. * With external clock = 30.000000 */
  224. static struct dibx000_bandwidth_config xc3028_bw_config = {
  225. 60000, /* internal */
  226. 30000, /* sampling */
  227. 1, /* pll_cfg: prediv */
  228. 8, /* pll_cfg: ratio */
  229. 3, /* pll_cfg: range */
  230. 1, /* pll_cfg: reset */
  231. 0, /* pll_cfg: bypass */
  232. 0, /* misc: refdiv */
  233. 0, /* misc: bypclk_div */
  234. 1, /* misc: IO_CLK_en_core */
  235. 1, /* misc: ADClkSrc */
  236. 0, /* misc: modulo */
  237. (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
  238. (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
  239. 20452225, /* timf */
  240. 30000000 /* xtal_hz */
  241. };
  242. static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
  243. .output_mpeg2_in_188_bytes = 1,
  244. .hostbus_diversity = 1,
  245. .tuner_is_baseband = 0,
  246. .update_lna = NULL,
  247. .agc_config_count = 1,
  248. .agc = &xc3028_agc_config,
  249. .bw = &xc3028_bw_config,
  250. .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
  251. .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
  252. .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
  253. .pwm_freq_div = 0,
  254. .agc_control = NULL,
  255. .spur_protect = 0,
  256. .output_mode = OUTMODE_MPEG2_SERIAL,
  257. };
  258. static struct zl10353_config dvico_fusionhdtv_xc3028 = {
  259. .demod_address = 0x0f,
  260. .if2 = 45600,
  261. .no_tuner = 1,
  262. };
  263. static int dvb_register(struct cx23885_tsport *port)
  264. {
  265. struct cx23885_dev *dev = port->dev;
  266. struct cx23885_i2c *i2c_bus = NULL;
  267. struct videobuf_dvb_frontend *fe0;
  268. /* FIXME: add support for multi-frontend */
  269. mutex_init(&port->frontends.lock);
  270. INIT_LIST_HEAD(&port->frontends.frontend.felist);
  271. port->frontends.active_fe_id = 0;
  272. printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
  273. if (videobuf_dvb_alloc_frontend(dev, &port->frontends, 1) == NULL) {
  274. printk(KERN_ERR "%s() failed to alloc\n", __func__);
  275. return -ENOMEM;
  276. }
  277. /* Get the first frontend */
  278. fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
  279. if (!fe0)
  280. return -EINVAL;
  281. /* init struct videobuf_dvb */
  282. fe0->dvb.name = dev->name;
  283. /* init frontend */
  284. switch (dev->board) {
  285. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  286. i2c_bus = &dev->i2c_bus[0];
  287. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  288. &hauppauge_generic_config,
  289. &i2c_bus->i2c_adap);
  290. if (fe0->dvb.frontend != NULL) {
  291. dvb_attach(mt2131_attach, fe0->dvb.frontend,
  292. &i2c_bus->i2c_adap,
  293. &hauppauge_generic_tunerconfig, 0);
  294. }
  295. break;
  296. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  297. i2c_bus = &dev->i2c_bus[0];
  298. switch (alt_tuner) {
  299. case 1:
  300. fe0->dvb.frontend =
  301. dvb_attach(s5h1409_attach,
  302. &hauppauge_ezqam_config,
  303. &i2c_bus->i2c_adap);
  304. if (fe0->dvb.frontend != NULL) {
  305. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  306. &dev->i2c_bus[1].i2c_adap, 0x42,
  307. &tda829x_no_probe);
  308. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  309. 0x60, &dev->i2c_bus[1].i2c_adap,
  310. &hauppauge_tda18271_config);
  311. }
  312. break;
  313. case 0:
  314. default:
  315. fe0->dvb.frontend =
  316. dvb_attach(s5h1409_attach,
  317. &hauppauge_generic_config,
  318. &i2c_bus->i2c_adap);
  319. if (fe0->dvb.frontend != NULL)
  320. dvb_attach(mt2131_attach, fe0->dvb.frontend,
  321. &i2c_bus->i2c_adap,
  322. &hauppauge_generic_tunerconfig, 0);
  323. break;
  324. }
  325. break;
  326. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  327. i2c_bus = &dev->i2c_bus[0];
  328. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  329. &hauppauge_hvr1800lp_config,
  330. &i2c_bus->i2c_adap);
  331. if (fe0->dvb.frontend != NULL) {
  332. dvb_attach(mt2131_attach, fe0->dvb.frontend,
  333. &i2c_bus->i2c_adap,
  334. &hauppauge_generic_tunerconfig, 0);
  335. }
  336. break;
  337. case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
  338. i2c_bus = &dev->i2c_bus[0];
  339. fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
  340. &fusionhdtv_5_express,
  341. &i2c_bus->i2c_adap);
  342. if (fe0->dvb.frontend != NULL) {
  343. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  344. &i2c_bus->i2c_adap, 0x61,
  345. TUNER_LG_TDVS_H06XF);
  346. }
  347. break;
  348. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  349. i2c_bus = &dev->i2c_bus[1];
  350. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  351. &hauppauge_hvr1500q_config,
  352. &dev->i2c_bus[0].i2c_adap);
  353. if (fe0->dvb.frontend != NULL)
  354. dvb_attach(xc5000_attach, fe0->dvb.frontend,
  355. &i2c_bus->i2c_adap,
  356. &hauppauge_hvr1500q_tunerconfig);
  357. break;
  358. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  359. i2c_bus = &dev->i2c_bus[1];
  360. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  361. &hauppauge_hvr1500_config,
  362. &dev->i2c_bus[0].i2c_adap);
  363. if (fe0->dvb.frontend != NULL) {
  364. struct dvb_frontend *fe;
  365. struct xc2028_config cfg = {
  366. .i2c_adap = &i2c_bus->i2c_adap,
  367. .i2c_addr = 0x61,
  368. };
  369. static struct xc2028_ctrl ctl = {
  370. .fname = XC2028_DEFAULT_FIRMWARE,
  371. .max_len = 64,
  372. .scode_table = XC3028_FE_OREN538,
  373. };
  374. fe = dvb_attach(xc2028_attach,
  375. fe0->dvb.frontend, &cfg);
  376. if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
  377. fe->ops.tuner_ops.set_config(fe, &ctl);
  378. }
  379. break;
  380. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  381. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  382. i2c_bus = &dev->i2c_bus[0];
  383. fe0->dvb.frontend = dvb_attach(tda10048_attach,
  384. &hauppauge_hvr1200_config,
  385. &i2c_bus->i2c_adap);
  386. if (fe0->dvb.frontend != NULL) {
  387. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  388. &dev->i2c_bus[1].i2c_adap, 0x42,
  389. &tda829x_no_probe);
  390. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  391. 0x60, &dev->i2c_bus[1].i2c_adap,
  392. &hauppauge_hvr1200_tuner_config);
  393. }
  394. break;
  395. case CX23885_BOARD_HAUPPAUGE_HVR1400:
  396. i2c_bus = &dev->i2c_bus[0];
  397. fe0->dvb.frontend = dvb_attach(dib7000p_attach,
  398. &i2c_bus->i2c_adap,
  399. 0x12, &hauppauge_hvr1400_dib7000_config);
  400. if (fe0->dvb.frontend != NULL) {
  401. struct dvb_frontend *fe;
  402. struct xc2028_config cfg = {
  403. .i2c_adap = &dev->i2c_bus[1].i2c_adap,
  404. .i2c_addr = 0x64,
  405. };
  406. static struct xc2028_ctrl ctl = {
  407. .fname = XC3028L_DEFAULT_FIRMWARE,
  408. .max_len = 64,
  409. .demod = 5000,
  410. /* This is true for all demods with v36 firmware? */
  411. .type = XC2028_D2633,
  412. };
  413. fe = dvb_attach(xc2028_attach,
  414. fe0->dvb.frontend, &cfg);
  415. if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
  416. fe->ops.tuner_ops.set_config(fe, &ctl);
  417. }
  418. break;
  419. case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
  420. i2c_bus = &dev->i2c_bus[port->nr - 1];
  421. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  422. &dvico_s5h1409_config,
  423. &i2c_bus->i2c_adap);
  424. if (fe0->dvb.frontend == NULL)
  425. fe0->dvb.frontend = dvb_attach(s5h1411_attach,
  426. &dvico_s5h1411_config,
  427. &i2c_bus->i2c_adap);
  428. if (fe0->dvb.frontend != NULL)
  429. dvb_attach(xc5000_attach, fe0->dvb.frontend,
  430. &i2c_bus->i2c_adap,
  431. &dvico_xc5000_tunerconfig);
  432. break;
  433. case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
  434. i2c_bus = &dev->i2c_bus[port->nr - 1];
  435. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  436. &dvico_fusionhdtv_xc3028,
  437. &i2c_bus->i2c_adap);
  438. if (fe0->dvb.frontend != NULL) {
  439. struct dvb_frontend *fe;
  440. struct xc2028_config cfg = {
  441. .i2c_adap = &i2c_bus->i2c_adap,
  442. .i2c_addr = 0x61,
  443. };
  444. static struct xc2028_ctrl ctl = {
  445. .fname = XC2028_DEFAULT_FIRMWARE,
  446. .max_len = 64,
  447. .demod = XC3028_FE_ZARLINK456,
  448. };
  449. fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
  450. &cfg);
  451. if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
  452. fe->ops.tuner_ops.set_config(fe, &ctl);
  453. }
  454. break;
  455. }
  456. case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
  457. i2c_bus = &dev->i2c_bus[0];
  458. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  459. &dvico_fusionhdtv_xc3028,
  460. &i2c_bus->i2c_adap);
  461. if (fe0->dvb.frontend != NULL) {
  462. struct dvb_frontend *fe;
  463. struct xc2028_config cfg = {
  464. .i2c_adap = &dev->i2c_bus[1].i2c_adap,
  465. .i2c_addr = 0x61,
  466. };
  467. static struct xc2028_ctrl ctl = {
  468. .fname = XC2028_DEFAULT_FIRMWARE,
  469. .max_len = 64,
  470. .demod = XC3028_FE_ZARLINK456,
  471. };
  472. fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
  473. &cfg);
  474. if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
  475. fe->ops.tuner_ops.set_config(fe, &ctl);
  476. }
  477. break;
  478. default:
  479. printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
  480. dev->name);
  481. break;
  482. }
  483. if (NULL == fe0->dvb.frontend) {
  484. printk("%s: frontend initialization failed\n", dev->name);
  485. return -1;
  486. }
  487. /* define general-purpose callback pointer */
  488. fe0->dvb.frontend->callback = cx23885_tuner_callback;
  489. /* Put the analog decoder in standby to keep it quiet */
  490. cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL);
  491. if (fe0->dvb.frontend->ops.analog_ops.standby)
  492. fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
  493. /* register everything */
  494. return videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
  495. &dev->pci->dev, adapter_nr);
  496. }
  497. int cx23885_dvb_register(struct cx23885_tsport *port)
  498. {
  499. struct videobuf_dvb_frontend *fe0;
  500. struct cx23885_dev *dev = port->dev;
  501. int err;
  502. fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
  503. if (!fe0)
  504. err = -EINVAL;
  505. dprintk(1, "%s\n", __func__);
  506. dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
  507. dev->board,
  508. dev->name,
  509. dev->pci_bus,
  510. dev->pci_slot);
  511. err = -ENODEV;
  512. /* dvb stuff */
  513. printk("%s: cx23885 based dvb card\n", dev->name);
  514. videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock,
  515. V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
  516. sizeof(struct cx23885_buffer), port);
  517. err = dvb_register(port);
  518. if (err != 0)
  519. printk("%s() dvb_register failed err = %d\n", __func__, err);
  520. return err;
  521. }
  522. int cx23885_dvb_unregister(struct cx23885_tsport *port)
  523. {
  524. struct videobuf_dvb_frontend *fe0;
  525. fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
  526. /* dvb */
  527. if(fe0->dvb.frontend)
  528. videobuf_dvb_unregister_bus(&port->frontends);
  529. return 0;
  530. }
  531. /*
  532. * Local variables:
  533. * c-basic-offset: 8
  534. * End:
  535. * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off
  536. */