cx88-dvb.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. /*
  2. *
  3. * device driver for Conexant 2388x based TV cards
  4. * MPEG Transport Stream (DVB) routines
  5. *
  6. * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
  7. * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23. #include <linux/module.h>
  24. #include <linux/init.h>
  25. #include <linux/device.h>
  26. #include <linux/fs.h>
  27. #include <linux/kthread.h>
  28. #include <linux/file.h>
  29. #include <linux/suspend.h>
  30. #include "cx88.h"
  31. #include "dvb-pll.h"
  32. #include <media/v4l2-common.h>
  33. #include "mt352.h"
  34. #include "mt352_priv.h"
  35. #ifdef HAVE_VP3054_I2C
  36. # include "cx88-vp3054-i2c.h"
  37. #endif
  38. #include "zl10353.h"
  39. #include "cx22702.h"
  40. #include "or51132.h"
  41. #include "lgdt330x.h"
  42. #include "lg_h06xf.h"
  43. #include "nxt200x.h"
  44. #include "cx24123.h"
  45. #include "isl6421.h"
  46. MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
  47. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  48. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  49. MODULE_LICENSE("GPL");
  50. static unsigned int debug = 0;
  51. module_param(debug, int, 0644);
  52. MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
  53. #define dprintk(level,fmt, arg...) if (debug >= level) \
  54. printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
  55. /* ------------------------------------------------------------------ */
  56. static int dvb_buf_setup(struct videobuf_queue *q,
  57. unsigned int *count, unsigned int *size)
  58. {
  59. struct cx8802_dev *dev = q->priv_data;
  60. dev->ts_packet_size = 188 * 4;
  61. dev->ts_packet_count = 32;
  62. *size = dev->ts_packet_size * dev->ts_packet_count;
  63. *count = 32;
  64. return 0;
  65. }
  66. static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
  67. enum v4l2_field field)
  68. {
  69. struct cx8802_dev *dev = q->priv_data;
  70. return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
  71. }
  72. static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
  73. {
  74. struct cx8802_dev *dev = q->priv_data;
  75. cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
  76. }
  77. static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
  78. {
  79. cx88_free_buffer(q, (struct cx88_buffer*)vb);
  80. }
  81. static struct videobuf_queue_ops dvb_qops = {
  82. .buf_setup = dvb_buf_setup,
  83. .buf_prepare = dvb_buf_prepare,
  84. .buf_queue = dvb_buf_queue,
  85. .buf_release = dvb_buf_release,
  86. };
  87. /* ------------------------------------------------------------------ */
  88. static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
  89. {
  90. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
  91. static u8 reset [] = { RESET, 0x80 };
  92. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  93. static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
  94. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  95. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  96. mt352_write(fe, clock_config, sizeof(clock_config));
  97. udelay(200);
  98. mt352_write(fe, reset, sizeof(reset));
  99. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  100. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  101. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  102. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  103. return 0;
  104. }
  105. static int dvico_dual_demod_init(struct dvb_frontend *fe)
  106. {
  107. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
  108. static u8 reset [] = { RESET, 0x80 };
  109. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  110. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
  111. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  112. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  113. mt352_write(fe, clock_config, sizeof(clock_config));
  114. udelay(200);
  115. mt352_write(fe, reset, sizeof(reset));
  116. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  117. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  118. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  119. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  120. return 0;
  121. }
  122. static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
  123. {
  124. static u8 clock_config [] = { 0x89, 0x38, 0x39 };
  125. static u8 reset [] = { 0x50, 0x80 };
  126. static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
  127. static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
  128. 0x00, 0xFF, 0x00, 0x40, 0x40 };
  129. static u8 dntv_extra[] = { 0xB5, 0x7A };
  130. static u8 capt_range_cfg[] = { 0x75, 0x32 };
  131. mt352_write(fe, clock_config, sizeof(clock_config));
  132. udelay(2000);
  133. mt352_write(fe, reset, sizeof(reset));
  134. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  135. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  136. udelay(2000);
  137. mt352_write(fe, dntv_extra, sizeof(dntv_extra));
  138. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  139. return 0;
  140. }
  141. static struct mt352_config dvico_fusionhdtv = {
  142. .demod_address = 0x0f,
  143. .demod_init = dvico_fusionhdtv_demod_init,
  144. };
  145. static struct mt352_config dntv_live_dvbt_config = {
  146. .demod_address = 0x0f,
  147. .demod_init = dntv_live_dvbt_demod_init,
  148. };
  149. static struct mt352_config dvico_fusionhdtv_dual = {
  150. .demod_address = 0x0f,
  151. .demod_init = dvico_dual_demod_init,
  152. };
  153. #ifdef HAVE_VP3054_I2C
  154. static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
  155. {
  156. static u8 clock_config [] = { 0x89, 0x38, 0x38 };
  157. static u8 reset [] = { 0x50, 0x80 };
  158. static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
  159. static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
  160. 0x00, 0xFF, 0x00, 0x40, 0x40 };
  161. static u8 dntv_extra[] = { 0xB5, 0x7A };
  162. static u8 capt_range_cfg[] = { 0x75, 0x32 };
  163. mt352_write(fe, clock_config, sizeof(clock_config));
  164. udelay(2000);
  165. mt352_write(fe, reset, sizeof(reset));
  166. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  167. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  168. udelay(2000);
  169. mt352_write(fe, dntv_extra, sizeof(dntv_extra));
  170. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  171. return 0;
  172. }
  173. static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
  174. {
  175. struct cx8802_dev *dev= fe->dvb->priv;
  176. /* this message is to set up ATC and ALC */
  177. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
  178. struct i2c_msg msg =
  179. { .addr = dev->core->pll_addr, .flags = 0,
  180. .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
  181. int err;
  182. if (fe->ops.i2c_gate_ctrl)
  183. fe->ops.i2c_gate_ctrl(fe, 1);
  184. if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
  185. if (err < 0)
  186. return err;
  187. else
  188. return -EREMOTEIO;
  189. }
  190. return 0;
  191. }
  192. static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
  193. struct dvb_frontend_parameters* params)
  194. {
  195. struct cx8802_dev *dev= fe->dvb->priv;
  196. u8 buf[4];
  197. struct i2c_msg msg =
  198. { .addr = dev->core->pll_addr, .flags = 0,
  199. .buf = buf, .len = 4 };
  200. int err;
  201. /* Switch PLL to DVB mode */
  202. err = philips_fmd1216_pll_init(fe);
  203. if (err)
  204. return err;
  205. /* Tune PLL */
  206. dvb_pll_configure(dev->core->pll_desc, buf,
  207. params->frequency,
  208. params->u.ofdm.bandwidth);
  209. if (fe->ops.i2c_gate_ctrl)
  210. fe->ops.i2c_gate_ctrl(fe, 1);
  211. if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
  212. printk(KERN_WARNING "cx88-dvb: %s error "
  213. "(addr %02x <- %02x, err = %i)\n",
  214. __FUNCTION__, dev->core->pll_addr, buf[0], err);
  215. if (err < 0)
  216. return err;
  217. else
  218. return -EREMOTEIO;
  219. }
  220. return 0;
  221. }
  222. static struct mt352_config dntv_live_dvbt_pro_config = {
  223. .demod_address = 0x0f,
  224. .no_tuner = 1,
  225. .demod_init = dntv_live_dvbt_pro_demod_init,
  226. };
  227. #endif
  228. static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe,
  229. struct dvb_frontend_parameters *params)
  230. {
  231. u8 pllbuf[4];
  232. struct cx8802_dev *dev= fe->dvb->priv;
  233. struct i2c_msg msg =
  234. { .addr = dev->core->pll_addr, .flags = 0,
  235. .buf = pllbuf, .len = 4 };
  236. int err;
  237. dvb_pll_configure(dev->core->pll_desc, pllbuf,
  238. params->frequency,
  239. params->u.ofdm.bandwidth);
  240. if (fe->ops.i2c_gate_ctrl)
  241. fe->ops.i2c_gate_ctrl(fe, 1);
  242. if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
  243. printk(KERN_WARNING "cx88-dvb: %s error "
  244. "(addr %02x <- %02x, err = %i)\n",
  245. __FUNCTION__, pllbuf[0], pllbuf[1], err);
  246. if (err < 0)
  247. return err;
  248. else
  249. return -EREMOTEIO;
  250. }
  251. return 0;
  252. }
  253. static struct zl10353_config dvico_fusionhdtv_hybrid = {
  254. .demod_address = 0x0f,
  255. .no_tuner = 1,
  256. };
  257. static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
  258. .demod_address = 0x0f,
  259. };
  260. static struct cx22702_config connexant_refboard_config = {
  261. .demod_address = 0x43,
  262. .output_mode = CX22702_SERIAL_OUTPUT,
  263. };
  264. static struct cx22702_config hauppauge_novat_config = {
  265. .demod_address = 0x43,
  266. .output_mode = CX22702_SERIAL_OUTPUT,
  267. };
  268. static struct cx22702_config hauppauge_hvr1100_config = {
  269. .demod_address = 0x63,
  270. .output_mode = CX22702_SERIAL_OUTPUT,
  271. };
  272. static struct cx22702_config hauppauge_hvr3000_config = {
  273. .demod_address = 0x63,
  274. .output_mode = CX22702_SERIAL_OUTPUT,
  275. };
  276. static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe,
  277. int acquire)
  278. {
  279. struct cx8802_dev *dev= fe->dvb->priv;
  280. struct cx8802_driver *drv = NULL;
  281. int ret = 0;
  282. drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
  283. if (drv) {
  284. if(acquire)
  285. ret = drv->request_acquire(drv);
  286. else
  287. ret = drv->request_release(drv);
  288. }
  289. return ret;
  290. }
  291. static struct cx22702_config hauppauge_hvr1300_config = {
  292. .demod_address = 0x63,
  293. .output_mode = CX22702_SERIAL_OUTPUT,
  294. };
  295. static int or51132_set_ts_param(struct dvb_frontend* fe,
  296. int is_punctured)
  297. {
  298. struct cx8802_dev *dev= fe->dvb->priv;
  299. dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
  300. return 0;
  301. }
  302. static struct or51132_config pchdtv_hd3000 = {
  303. .demod_address = 0x15,
  304. .set_ts_params = or51132_set_ts_param,
  305. };
  306. static int lgdt3302_tuner_set_params(struct dvb_frontend* fe,
  307. struct dvb_frontend_parameters* params)
  308. {
  309. /* FIXME make this routine use the tuner-simple code.
  310. * It could probably be shared with a number of ATSC
  311. * frontends. Many share the same tuner with analog TV. */
  312. struct cx8802_dev *dev= fe->dvb->priv;
  313. struct cx88_core *core = dev->core;
  314. u8 buf[4];
  315. struct i2c_msg msg =
  316. { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 };
  317. int err;
  318. dvb_pll_configure(core->pll_desc, buf, params->frequency, 0);
  319. dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
  320. __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]);
  321. if (fe->ops.i2c_gate_ctrl)
  322. fe->ops.i2c_gate_ctrl(fe, 1);
  323. if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) {
  324. printk(KERN_WARNING "cx88-dvb: %s error "
  325. "(addr %02x <- %02x, err = %i)\n",
  326. __FUNCTION__, buf[0], buf[1], err);
  327. if (err < 0)
  328. return err;
  329. else
  330. return -EREMOTEIO;
  331. }
  332. return 0;
  333. }
  334. static int lgdt3303_tuner_set_params(struct dvb_frontend* fe,
  335. struct dvb_frontend_parameters* params)
  336. {
  337. struct cx8802_dev *dev= fe->dvb->priv;
  338. struct cx88_core *core = dev->core;
  339. /* Put the analog decoder in standby to keep it quiet */
  340. cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
  341. return lg_h06xf_pll_set(fe, &core->i2c_adap, params);
  342. }
  343. static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
  344. {
  345. struct cx8802_dev *dev= fe->dvb->priv;
  346. struct cx88_core *core = dev->core;
  347. dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
  348. if (index == 0)
  349. cx_clear(MO_GP0_IO, 8);
  350. else
  351. cx_set(MO_GP0_IO, 8);
  352. return 0;
  353. }
  354. static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
  355. {
  356. struct cx8802_dev *dev= fe->dvb->priv;
  357. if (is_punctured)
  358. dev->ts_gen_cntrl |= 0x04;
  359. else
  360. dev->ts_gen_cntrl &= ~0x04;
  361. return 0;
  362. }
  363. static struct lgdt330x_config fusionhdtv_3_gold = {
  364. .demod_address = 0x0e,
  365. .demod_chip = LGDT3302,
  366. .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
  367. .set_ts_params = lgdt330x_set_ts_param,
  368. };
  369. static struct lgdt330x_config fusionhdtv_5_gold = {
  370. .demod_address = 0x0e,
  371. .demod_chip = LGDT3303,
  372. .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
  373. .set_ts_params = lgdt330x_set_ts_param,
  374. };
  375. static struct lgdt330x_config pchdtv_hd5500 = {
  376. .demod_address = 0x59,
  377. .demod_chip = LGDT3303,
  378. .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
  379. .set_ts_params = lgdt330x_set_ts_param,
  380. };
  381. static int nxt200x_set_ts_param(struct dvb_frontend* fe,
  382. int is_punctured)
  383. {
  384. struct cx8802_dev *dev= fe->dvb->priv;
  385. dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
  386. return 0;
  387. }
  388. static int nxt200x_set_pll_input(u8* buf, int input)
  389. {
  390. if (input)
  391. buf[3] |= 0x08;
  392. else
  393. buf[3] &= ~0x08;
  394. return 0;
  395. }
  396. static struct nxt200x_config ati_hdtvwonder = {
  397. .demod_address = 0x0a,
  398. .set_pll_input = nxt200x_set_pll_input,
  399. .set_ts_params = nxt200x_set_ts_param,
  400. };
  401. static int cx24123_set_ts_param(struct dvb_frontend* fe,
  402. int is_punctured)
  403. {
  404. struct cx8802_dev *dev= fe->dvb->priv;
  405. dev->ts_gen_cntrl = 0x02;
  406. return 0;
  407. }
  408. static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
  409. fe_sec_voltage_t voltage)
  410. {
  411. struct cx8802_dev *dev= fe->dvb->priv;
  412. struct cx88_core *core = dev->core;
  413. if (voltage == SEC_VOLTAGE_OFF) {
  414. cx_write(MO_GP0_IO, 0x000006fb);
  415. } else {
  416. cx_write(MO_GP0_IO, 0x000006f9);
  417. }
  418. if (core->prev_set_voltage)
  419. return core->prev_set_voltage(fe, voltage);
  420. return 0;
  421. }
  422. static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
  423. fe_sec_voltage_t voltage)
  424. {
  425. struct cx8802_dev *dev= fe->dvb->priv;
  426. struct cx88_core *core = dev->core;
  427. if (voltage == SEC_VOLTAGE_OFF) {
  428. dprintk(1,"LNB Voltage OFF\n");
  429. cx_write(MO_GP0_IO, 0x0000efff);
  430. }
  431. if (core->prev_set_voltage)
  432. return core->prev_set_voltage(fe, voltage);
  433. return 0;
  434. }
  435. static struct cx24123_config geniatech_dvbs_config = {
  436. .demod_address = 0x55,
  437. .set_ts_params = cx24123_set_ts_param,
  438. };
  439. static struct cx24123_config hauppauge_novas_config = {
  440. .demod_address = 0x55,
  441. .set_ts_params = cx24123_set_ts_param,
  442. };
  443. static struct cx24123_config kworld_dvbs_100_config = {
  444. .demod_address = 0x15,
  445. .set_ts_params = cx24123_set_ts_param,
  446. .lnb_polarity = 1,
  447. };
  448. static int dvb_register(struct cx8802_dev *dev)
  449. {
  450. /* init struct videobuf_dvb */
  451. dev->dvb.name = dev->core->name;
  452. dev->ts_gen_cntrl = 0x0c;
  453. /* init frontend */
  454. switch (dev->core->board) {
  455. case CX88_BOARD_HAUPPAUGE_DVB_T1:
  456. dev->dvb.frontend = dvb_attach(cx22702_attach,
  457. &hauppauge_novat_config,
  458. &dev->core->i2c_adap);
  459. if (dev->dvb.frontend != NULL) {
  460. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  461. &dev->core->i2c_adap,
  462. &dvb_pll_thomson_dtt759x);
  463. }
  464. break;
  465. case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
  466. case CX88_BOARD_CONEXANT_DVB_T1:
  467. case CX88_BOARD_KWORLD_DVB_T_CX22702:
  468. case CX88_BOARD_WINFAST_DTV1000:
  469. dev->dvb.frontend = dvb_attach(cx22702_attach,
  470. &connexant_refboard_config,
  471. &dev->core->i2c_adap);
  472. if (dev->dvb.frontend != NULL) {
  473. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
  474. &dev->core->i2c_adap,
  475. &dvb_pll_thomson_dtt7579);
  476. }
  477. break;
  478. case CX88_BOARD_WINFAST_DTV2000H:
  479. case CX88_BOARD_HAUPPAUGE_HVR1100:
  480. case CX88_BOARD_HAUPPAUGE_HVR1100LP:
  481. dev->dvb.frontend = dvb_attach(cx22702_attach,
  482. &hauppauge_hvr1100_config,
  483. &dev->core->i2c_adap);
  484. if (dev->dvb.frontend != NULL) {
  485. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  486. &dev->core->i2c_adap,
  487. &dvb_pll_fmd1216me);
  488. }
  489. break;
  490. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
  491. dev->dvb.frontend = dvb_attach(mt352_attach,
  492. &dvico_fusionhdtv,
  493. &dev->core->i2c_adap);
  494. if (dev->dvb.frontend != NULL) {
  495. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
  496. NULL, &dvb_pll_thomson_dtt7579);
  497. break;
  498. }
  499. /* ZL10353 replaces MT352 on later cards */
  500. dev->dvb.frontend = dvb_attach(zl10353_attach,
  501. &dvico_fusionhdtv_plus_v1_1,
  502. &dev->core->i2c_adap);
  503. if (dev->dvb.frontend != NULL) {
  504. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
  505. NULL, &dvb_pll_thomson_dtt7579);
  506. }
  507. break;
  508. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
  509. /* The tin box says DEE1601, but it seems to be DTT7579
  510. * compatible, with a slightly different MT352 AGC gain. */
  511. dev->dvb.frontend = dvb_attach(mt352_attach,
  512. &dvico_fusionhdtv_dual,
  513. &dev->core->i2c_adap);
  514. if (dev->dvb.frontend != NULL) {
  515. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  516. NULL, &dvb_pll_thomson_dtt7579);
  517. break;
  518. }
  519. /* ZL10353 replaces MT352 on later cards */
  520. dev->dvb.frontend = dvb_attach(zl10353_attach,
  521. &dvico_fusionhdtv_plus_v1_1,
  522. &dev->core->i2c_adap);
  523. if (dev->dvb.frontend != NULL) {
  524. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  525. NULL, &dvb_pll_thomson_dtt7579);
  526. }
  527. break;
  528. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
  529. dev->dvb.frontend = dvb_attach(mt352_attach,
  530. &dvico_fusionhdtv,
  531. &dev->core->i2c_adap);
  532. if (dev->dvb.frontend != NULL) {
  533. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  534. NULL, &dvb_pll_lg_z201);
  535. }
  536. break;
  537. case CX88_BOARD_KWORLD_DVB_T:
  538. case CX88_BOARD_DNTV_LIVE_DVB_T:
  539. case CX88_BOARD_ADSTECH_DVB_T_PCI:
  540. dev->dvb.frontend = dvb_attach(mt352_attach,
  541. &dntv_live_dvbt_config,
  542. &dev->core->i2c_adap);
  543. if (dev->dvb.frontend != NULL) {
  544. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  545. NULL, &dvb_pll_unknown_1);
  546. }
  547. break;
  548. case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
  549. #ifdef HAVE_VP3054_I2C
  550. dev->core->pll_addr = 0x61;
  551. dev->core->pll_desc = &dvb_pll_fmd1216me;
  552. dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
  553. &((struct vp3054_i2c_state *)dev->card_priv)->adap);
  554. if (dev->dvb.frontend != NULL) {
  555. dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
  556. }
  557. #else
  558. printk("%s: built without vp3054 support\n", dev->core->name);
  559. #endif
  560. break;
  561. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
  562. dev->core->pll_addr = 0x61;
  563. dev->core->pll_desc = &dvb_pll_thomson_fe6600;
  564. dev->dvb.frontend = dvb_attach(zl10353_attach,
  565. &dvico_fusionhdtv_hybrid,
  566. &dev->core->i2c_adap);
  567. if (dev->dvb.frontend != NULL) {
  568. dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params;
  569. }
  570. break;
  571. case CX88_BOARD_PCHDTV_HD3000:
  572. dev->dvb.frontend = dvb_attach(or51132_attach,
  573. &pchdtv_hd3000,
  574. &dev->core->i2c_adap);
  575. if (dev->dvb.frontend != NULL) {
  576. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  577. &dev->core->i2c_adap,
  578. &dvb_pll_thomson_dtt761x);
  579. }
  580. break;
  581. case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
  582. dev->ts_gen_cntrl = 0x08;
  583. {
  584. /* Do a hardware reset of chip before using it. */
  585. struct cx88_core *core = dev->core;
  586. cx_clear(MO_GP0_IO, 1);
  587. mdelay(100);
  588. cx_set(MO_GP0_IO, 1);
  589. mdelay(200);
  590. /* Select RF connector callback */
  591. fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
  592. dev->core->pll_addr = 0x61;
  593. dev->core->pll_desc = &dvb_pll_microtune_4042;
  594. dev->dvb.frontend = dvb_attach(lgdt330x_attach,
  595. &fusionhdtv_3_gold,
  596. &dev->core->i2c_adap);
  597. if (dev->dvb.frontend != NULL) {
  598. dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
  599. }
  600. }
  601. break;
  602. case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
  603. dev->ts_gen_cntrl = 0x08;
  604. {
  605. /* Do a hardware reset of chip before using it. */
  606. struct cx88_core *core = dev->core;
  607. cx_clear(MO_GP0_IO, 1);
  608. mdelay(100);
  609. cx_set(MO_GP0_IO, 9);
  610. mdelay(200);
  611. dev->core->pll_addr = 0x61;
  612. dev->core->pll_desc = &dvb_pll_thomson_dtt761x;
  613. dev->dvb.frontend = dvb_attach(lgdt330x_attach,
  614. &fusionhdtv_3_gold,
  615. &dev->core->i2c_adap);
  616. if (dev->dvb.frontend != NULL) {
  617. dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
  618. }
  619. }
  620. break;
  621. case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
  622. dev->ts_gen_cntrl = 0x08;
  623. {
  624. /* Do a hardware reset of chip before using it. */
  625. struct cx88_core *core = dev->core;
  626. cx_clear(MO_GP0_IO, 1);
  627. mdelay(100);
  628. cx_set(MO_GP0_IO, 1);
  629. mdelay(200);
  630. dev->dvb.frontend = dvb_attach(lgdt330x_attach,
  631. &fusionhdtv_5_gold,
  632. &dev->core->i2c_adap);
  633. if (dev->dvb.frontend != NULL) {
  634. dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
  635. }
  636. }
  637. break;
  638. case CX88_BOARD_PCHDTV_HD5500:
  639. dev->ts_gen_cntrl = 0x08;
  640. {
  641. /* Do a hardware reset of chip before using it. */
  642. struct cx88_core *core = dev->core;
  643. cx_clear(MO_GP0_IO, 1);
  644. mdelay(100);
  645. cx_set(MO_GP0_IO, 1);
  646. mdelay(200);
  647. dev->dvb.frontend = dvb_attach(lgdt330x_attach,
  648. &pchdtv_hd5500,
  649. &dev->core->i2c_adap);
  650. if (dev->dvb.frontend != NULL) {
  651. dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
  652. }
  653. }
  654. break;
  655. case CX88_BOARD_ATI_HDTVWONDER:
  656. dev->dvb.frontend = dvb_attach(nxt200x_attach,
  657. &ati_hdtvwonder,
  658. &dev->core->i2c_adap);
  659. if (dev->dvb.frontend != NULL) {
  660. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  661. NULL, &dvb_pll_tuv1236d);
  662. }
  663. break;
  664. case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
  665. case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
  666. dev->dvb.frontend = dvb_attach(cx24123_attach,
  667. &hauppauge_novas_config,
  668. &dev->core->i2c_adap);
  669. if (dev->dvb.frontend) {
  670. dvb_attach(isl6421_attach, dev->dvb.frontend,
  671. &dev->core->i2c_adap, 0x08, 0x00, 0x00);
  672. }
  673. break;
  674. case CX88_BOARD_KWORLD_DVBS_100:
  675. dev->dvb.frontend = dvb_attach(cx24123_attach,
  676. &kworld_dvbs_100_config,
  677. &dev->core->i2c_adap);
  678. if (dev->dvb.frontend) {
  679. dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
  680. dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
  681. }
  682. break;
  683. case CX88_BOARD_GENIATECH_DVBS:
  684. dev->dvb.frontend = dvb_attach(cx24123_attach,
  685. &geniatech_dvbs_config,
  686. &dev->core->i2c_adap);
  687. if (dev->dvb.frontend) {
  688. dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
  689. dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
  690. }
  691. break;
  692. case CX88_BOARD_HAUPPAUGE_HVR1300:
  693. dev->dvb.frontend = dvb_attach(cx22702_attach,
  694. &hauppauge_hvr1300_config,
  695. &dev->core->i2c_adap);
  696. if (dev->dvb.frontend != NULL) {
  697. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  698. &dev->core->i2c_adap,
  699. &dvb_pll_fmd1216me);
  700. }
  701. break;
  702. case CX88_BOARD_HAUPPAUGE_HVR3000:
  703. dev->dvb.frontend = dvb_attach(cx22702_attach,
  704. &hauppauge_hvr3000_config,
  705. &dev->core->i2c_adap);
  706. if (dev->dvb.frontend != NULL) {
  707. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  708. &dev->core->i2c_adap,
  709. &dvb_pll_fmd1216me);
  710. }
  711. break;
  712. default:
  713. printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
  714. dev->core->name);
  715. break;
  716. }
  717. if (NULL == dev->dvb.frontend) {
  718. printk("%s: frontend initialization failed\n",dev->core->name);
  719. return -1;
  720. }
  721. if (dev->core->pll_desc) {
  722. dev->dvb.frontend->ops.info.frequency_min = dev->core->pll_desc->min;
  723. dev->dvb.frontend->ops.info.frequency_max = dev->core->pll_desc->max;
  724. }
  725. /* Ensure all frontends negotiate bus access */
  726. dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
  727. /* Put the analog decoder in standby to keep it quiet */
  728. cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
  729. /* register everything */
  730. return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  731. }
  732. /* ----------------------------------------------------------- */
  733. /* CX8802 MPEG -> mini driver - We have been given the hardware */
  734. static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
  735. {
  736. struct cx88_core *core = drv->core;
  737. int err = 0;
  738. dprintk( 1, "%s\n", __FUNCTION__);
  739. switch (core->board) {
  740. case CX88_BOARD_HAUPPAUGE_HVR1300:
  741. /* We arrive here with either the cx23416 or the cx22702
  742. * on the bus. Take the bus from the cx23416 and enable the
  743. * cx22702 demod
  744. */
  745. cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
  746. cx_clear(MO_GP0_IO, 0x00000004);
  747. udelay(1000);
  748. break;
  749. default:
  750. err = -ENODEV;
  751. }
  752. return err;
  753. }
  754. /* CX8802 MPEG -> mini driver - We no longer have the hardware */
  755. static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
  756. {
  757. struct cx88_core *core = drv->core;
  758. int err = 0;
  759. dprintk( 1, "%s\n", __FUNCTION__);
  760. switch (core->board) {
  761. case CX88_BOARD_HAUPPAUGE_HVR1300:
  762. /* Do Nothing, leave the cx22702 on the bus. */
  763. break;
  764. default:
  765. err = -ENODEV;
  766. }
  767. return err;
  768. }
  769. static int cx8802_dvb_probe(struct cx8802_driver *drv)
  770. {
  771. struct cx88_core *core = drv->core;
  772. struct cx8802_dev *dev = drv->core->dvbdev;
  773. int err;
  774. dprintk( 1, "%s\n", __FUNCTION__);
  775. dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
  776. core->board,
  777. core->name,
  778. core->pci_bus,
  779. core->pci_slot);
  780. err = -ENODEV;
  781. if (!(cx88_boards[core->board].mpeg & CX88_MPEG_DVB))
  782. goto fail_core;
  783. #ifdef HAVE_VP3054_I2C
  784. err = vp3054_i2c_probe(dev);
  785. if (0 != err)
  786. goto fail_core;
  787. #endif
  788. /* dvb stuff */
  789. printk("%s/2: cx2388x based dvb card\n", core->name);
  790. videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
  791. dev->pci, &dev->slock,
  792. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  793. V4L2_FIELD_TOP,
  794. sizeof(struct cx88_buffer),
  795. dev);
  796. err = dvb_register(dev);
  797. if (err != 0)
  798. printk("%s dvb_register failed err = %d\n", __FUNCTION__, err);
  799. fail_core:
  800. return err;
  801. }
  802. static int cx8802_dvb_remove(struct cx8802_driver *drv)
  803. {
  804. struct cx8802_dev *dev = drv->core->dvbdev;
  805. /* dvb */
  806. videobuf_dvb_unregister(&dev->dvb);
  807. #ifdef HAVE_VP3054_I2C
  808. vp3054_i2c_remove(dev);
  809. #endif
  810. return 0;
  811. }
  812. static struct cx8802_driver cx8802_dvb_driver = {
  813. .type_id = CX88_MPEG_DVB,
  814. .hw_access = CX8802_DRVCTL_SHARED,
  815. .probe = cx8802_dvb_probe,
  816. .remove = cx8802_dvb_remove,
  817. .advise_acquire = cx8802_dvb_advise_acquire,
  818. .advise_release = cx8802_dvb_advise_release,
  819. };
  820. static int dvb_init(void)
  821. {
  822. printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
  823. (CX88_VERSION_CODE >> 16) & 0xff,
  824. (CX88_VERSION_CODE >> 8) & 0xff,
  825. CX88_VERSION_CODE & 0xff);
  826. #ifdef SNAPSHOT
  827. printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
  828. SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
  829. #endif
  830. return cx8802_register_driver(&cx8802_dvb_driver);
  831. }
  832. static void dvb_fini(void)
  833. {
  834. cx8802_unregister_driver(&cx8802_dvb_driver);
  835. }
  836. module_init(dvb_init);
  837. module_exit(dvb_fini);
  838. /*
  839. * Local variables:
  840. * c-basic-offset: 8
  841. * compile-command: "make DVB=1"
  842. * End:
  843. */