cx88-dvb.c 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  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. #include "cx88-vp3054-i2c.h"
  36. #include "zl10353.h"
  37. #include "cx22702.h"
  38. #include "or51132.h"
  39. #include "lgdt330x.h"
  40. #include "s5h1409.h"
  41. #include "xc5000.h"
  42. #include "nxt200x.h"
  43. #include "cx24123.h"
  44. #include "isl6421.h"
  45. #include "tuner-simple.h"
  46. #include "tda9887.h"
  47. #include "s5h1411.h"
  48. #include "stv0299.h"
  49. #include "z0194a.h"
  50. #include "stv0288.h"
  51. #include "stb6000.h"
  52. #include "cx24116.h"
  53. MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
  54. MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
  55. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  56. MODULE_LICENSE("GPL");
  57. static unsigned int debug;
  58. module_param(debug, int, 0644);
  59. MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
  60. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  61. #define dprintk(level,fmt, arg...) if (debug >= level) \
  62. printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
  63. /* ------------------------------------------------------------------ */
  64. static int dvb_buf_setup(struct videobuf_queue *q,
  65. unsigned int *count, unsigned int *size)
  66. {
  67. struct cx8802_dev *dev = q->priv_data;
  68. dev->ts_packet_size = 188 * 4;
  69. dev->ts_packet_count = 32;
  70. *size = dev->ts_packet_size * dev->ts_packet_count;
  71. *count = 32;
  72. return 0;
  73. }
  74. static int dvb_buf_prepare(struct videobuf_queue *q,
  75. struct videobuf_buffer *vb, enum v4l2_field field)
  76. {
  77. struct cx8802_dev *dev = q->priv_data;
  78. return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
  79. }
  80. static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
  81. {
  82. struct cx8802_dev *dev = q->priv_data;
  83. cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
  84. }
  85. static void dvb_buf_release(struct videobuf_queue *q,
  86. struct videobuf_buffer *vb)
  87. {
  88. cx88_free_buffer(q, (struct cx88_buffer*)vb);
  89. }
  90. static struct videobuf_queue_ops dvb_qops = {
  91. .buf_setup = dvb_buf_setup,
  92. .buf_prepare = dvb_buf_prepare,
  93. .buf_queue = dvb_buf_queue,
  94. .buf_release = dvb_buf_release,
  95. };
  96. /* ------------------------------------------------------------------ */
  97. static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
  98. {
  99. struct cx8802_dev *dev= fe->dvb->priv;
  100. struct cx8802_driver *drv = NULL;
  101. int ret = 0;
  102. int fe_id;
  103. fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
  104. if (!fe_id) {
  105. printk(KERN_ERR "%s() No frontend found\n", __func__);
  106. return -EINVAL;
  107. }
  108. drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
  109. if (drv) {
  110. if (acquire){
  111. dev->frontends.active_fe_id = fe_id;
  112. ret = drv->request_acquire(drv);
  113. } else {
  114. ret = drv->request_release(drv);
  115. dev->frontends.active_fe_id = 0;
  116. }
  117. }
  118. return ret;
  119. }
  120. static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
  121. {
  122. struct videobuf_dvb_frontends *f;
  123. struct videobuf_dvb_frontend *fe;
  124. if (!core->dvbdev)
  125. return;
  126. f = &core->dvbdev->frontends;
  127. if (!f)
  128. return;
  129. if (f->gate <= 1) /* undefined or fe0 */
  130. fe = videobuf_dvb_get_frontend(f, 1);
  131. else
  132. fe = videobuf_dvb_get_frontend(f, f->gate);
  133. if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
  134. fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
  135. }
  136. /* ------------------------------------------------------------------ */
  137. static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
  138. {
  139. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
  140. static u8 reset [] = { RESET, 0x80 };
  141. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  142. static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
  143. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  144. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  145. mt352_write(fe, clock_config, sizeof(clock_config));
  146. udelay(200);
  147. mt352_write(fe, reset, sizeof(reset));
  148. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  149. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  150. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  151. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  152. return 0;
  153. }
  154. static int dvico_dual_demod_init(struct dvb_frontend *fe)
  155. {
  156. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
  157. static u8 reset [] = { RESET, 0x80 };
  158. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  159. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
  160. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
  161. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
  162. mt352_write(fe, clock_config, sizeof(clock_config));
  163. udelay(200);
  164. mt352_write(fe, reset, sizeof(reset));
  165. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  166. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  167. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  168. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  169. return 0;
  170. }
  171. static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
  172. {
  173. static u8 clock_config [] = { 0x89, 0x38, 0x39 };
  174. static u8 reset [] = { 0x50, 0x80 };
  175. static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
  176. static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
  177. 0x00, 0xFF, 0x00, 0x40, 0x40 };
  178. static u8 dntv_extra[] = { 0xB5, 0x7A };
  179. static u8 capt_range_cfg[] = { 0x75, 0x32 };
  180. mt352_write(fe, clock_config, sizeof(clock_config));
  181. udelay(2000);
  182. mt352_write(fe, reset, sizeof(reset));
  183. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  184. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  185. udelay(2000);
  186. mt352_write(fe, dntv_extra, sizeof(dntv_extra));
  187. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  188. return 0;
  189. }
  190. static struct mt352_config dvico_fusionhdtv = {
  191. .demod_address = 0x0f,
  192. .demod_init = dvico_fusionhdtv_demod_init,
  193. };
  194. static struct mt352_config dntv_live_dvbt_config = {
  195. .demod_address = 0x0f,
  196. .demod_init = dntv_live_dvbt_demod_init,
  197. };
  198. static struct mt352_config dvico_fusionhdtv_dual = {
  199. .demod_address = 0x0f,
  200. .demod_init = dvico_dual_demod_init,
  201. };
  202. #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
  203. static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
  204. {
  205. static u8 clock_config [] = { 0x89, 0x38, 0x38 };
  206. static u8 reset [] = { 0x50, 0x80 };
  207. static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
  208. static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
  209. 0x00, 0xFF, 0x00, 0x40, 0x40 };
  210. static u8 dntv_extra[] = { 0xB5, 0x7A };
  211. static u8 capt_range_cfg[] = { 0x75, 0x32 };
  212. mt352_write(fe, clock_config, sizeof(clock_config));
  213. udelay(2000);
  214. mt352_write(fe, reset, sizeof(reset));
  215. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  216. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  217. udelay(2000);
  218. mt352_write(fe, dntv_extra, sizeof(dntv_extra));
  219. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  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 struct zl10353_config dvico_fusionhdtv_hybrid = {
  229. .demod_address = 0x0f,
  230. .no_tuner = 1,
  231. };
  232. static struct zl10353_config dvico_fusionhdtv_xc3028 = {
  233. .demod_address = 0x0f,
  234. .if2 = 45600,
  235. .no_tuner = 1,
  236. };
  237. static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
  238. .demod_address = 0x0f,
  239. .if2 = 4560,
  240. .no_tuner = 1,
  241. .demod_init = dvico_fusionhdtv_demod_init,
  242. };
  243. static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
  244. .demod_address = 0x0f,
  245. };
  246. static struct cx22702_config connexant_refboard_config = {
  247. .demod_address = 0x43,
  248. .output_mode = CX22702_SERIAL_OUTPUT,
  249. };
  250. static struct cx22702_config hauppauge_hvr_config = {
  251. .demod_address = 0x63,
  252. .output_mode = CX22702_SERIAL_OUTPUT,
  253. };
  254. static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
  255. {
  256. struct cx8802_dev *dev= fe->dvb->priv;
  257. dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
  258. return 0;
  259. }
  260. static struct or51132_config pchdtv_hd3000 = {
  261. .demod_address = 0x15,
  262. .set_ts_params = or51132_set_ts_param,
  263. };
  264. static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
  265. {
  266. struct cx8802_dev *dev= fe->dvb->priv;
  267. struct cx88_core *core = dev->core;
  268. dprintk(1, "%s: index = %d\n", __func__, index);
  269. if (index == 0)
  270. cx_clear(MO_GP0_IO, 8);
  271. else
  272. cx_set(MO_GP0_IO, 8);
  273. return 0;
  274. }
  275. static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
  276. {
  277. struct cx8802_dev *dev= fe->dvb->priv;
  278. if (is_punctured)
  279. dev->ts_gen_cntrl |= 0x04;
  280. else
  281. dev->ts_gen_cntrl &= ~0x04;
  282. return 0;
  283. }
  284. static struct lgdt330x_config fusionhdtv_3_gold = {
  285. .demod_address = 0x0e,
  286. .demod_chip = LGDT3302,
  287. .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
  288. .set_ts_params = lgdt330x_set_ts_param,
  289. };
  290. static struct lgdt330x_config fusionhdtv_5_gold = {
  291. .demod_address = 0x0e,
  292. .demod_chip = LGDT3303,
  293. .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
  294. .set_ts_params = lgdt330x_set_ts_param,
  295. };
  296. static struct lgdt330x_config pchdtv_hd5500 = {
  297. .demod_address = 0x59,
  298. .demod_chip = LGDT3303,
  299. .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
  300. .set_ts_params = lgdt330x_set_ts_param,
  301. };
  302. static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
  303. {
  304. struct cx8802_dev *dev= fe->dvb->priv;
  305. dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
  306. return 0;
  307. }
  308. static struct nxt200x_config ati_hdtvwonder = {
  309. .demod_address = 0x0a,
  310. .set_ts_params = nxt200x_set_ts_param,
  311. };
  312. static int cx24123_set_ts_param(struct dvb_frontend* fe,
  313. int is_punctured)
  314. {
  315. struct cx8802_dev *dev= fe->dvb->priv;
  316. dev->ts_gen_cntrl = 0x02;
  317. return 0;
  318. }
  319. static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
  320. fe_sec_voltage_t voltage)
  321. {
  322. struct cx8802_dev *dev= fe->dvb->priv;
  323. struct cx88_core *core = dev->core;
  324. if (voltage == SEC_VOLTAGE_OFF)
  325. cx_write(MO_GP0_IO, 0x000006fb);
  326. else
  327. cx_write(MO_GP0_IO, 0x000006f9);
  328. if (core->prev_set_voltage)
  329. return core->prev_set_voltage(fe, voltage);
  330. return 0;
  331. }
  332. static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
  333. fe_sec_voltage_t voltage)
  334. {
  335. struct cx8802_dev *dev= fe->dvb->priv;
  336. struct cx88_core *core = dev->core;
  337. if (voltage == SEC_VOLTAGE_OFF) {
  338. dprintk(1,"LNB Voltage OFF\n");
  339. cx_write(MO_GP0_IO, 0x0000efff);
  340. }
  341. if (core->prev_set_voltage)
  342. return core->prev_set_voltage(fe, voltage);
  343. return 0;
  344. }
  345. static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
  346. fe_sec_voltage_t voltage)
  347. {
  348. struct cx8802_dev *dev= fe->dvb->priv;
  349. struct cx88_core *core = dev->core;
  350. switch (voltage) {
  351. case SEC_VOLTAGE_13:
  352. printk("LNB Voltage SEC_VOLTAGE_13\n");
  353. cx_write(MO_GP0_IO, 0x00006040);
  354. break;
  355. case SEC_VOLTAGE_18:
  356. printk("LNB Voltage SEC_VOLTAGE_18\n");
  357. cx_write(MO_GP0_IO, 0x00006060);
  358. break;
  359. case SEC_VOLTAGE_OFF:
  360. printk("LNB Voltage SEC_VOLTAGE_off\n");
  361. break;
  362. }
  363. if (core->prev_set_voltage)
  364. return core->prev_set_voltage(fe, voltage);
  365. return 0;
  366. }
  367. static struct cx24123_config geniatech_dvbs_config = {
  368. .demod_address = 0x55,
  369. .set_ts_params = cx24123_set_ts_param,
  370. };
  371. static struct cx24123_config hauppauge_novas_config = {
  372. .demod_address = 0x55,
  373. .set_ts_params = cx24123_set_ts_param,
  374. };
  375. static struct cx24123_config kworld_dvbs_100_config = {
  376. .demod_address = 0x15,
  377. .set_ts_params = cx24123_set_ts_param,
  378. .lnb_polarity = 1,
  379. };
  380. static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
  381. .demod_address = 0x32 >> 1,
  382. .output_mode = S5H1409_PARALLEL_OUTPUT,
  383. .gpio = S5H1409_GPIO_ON,
  384. .qam_if = 44000,
  385. .inversion = S5H1409_INVERSION_OFF,
  386. .status_mode = S5H1409_DEMODLOCKING,
  387. .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
  388. };
  389. static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
  390. .demod_address = 0x32 >> 1,
  391. .output_mode = S5H1409_SERIAL_OUTPUT,
  392. .gpio = S5H1409_GPIO_OFF,
  393. .inversion = S5H1409_INVERSION_OFF,
  394. .status_mode = S5H1409_DEMODLOCKING,
  395. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  396. };
  397. static struct s5h1409_config kworld_atsc_120_config = {
  398. .demod_address = 0x32 >> 1,
  399. .output_mode = S5H1409_SERIAL_OUTPUT,
  400. .gpio = S5H1409_GPIO_OFF,
  401. .inversion = S5H1409_INVERSION_OFF,
  402. .status_mode = S5H1409_DEMODLOCKING,
  403. .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  404. };
  405. static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
  406. .i2c_address = 0x64,
  407. .if_khz = 5380,
  408. };
  409. static struct zl10353_config cx88_pinnacle_hybrid_pctv = {
  410. .demod_address = (0x1e >> 1),
  411. .no_tuner = 1,
  412. .if2 = 45600,
  413. };
  414. static struct zl10353_config cx88_geniatech_x8000_mt = {
  415. .demod_address = (0x1e >> 1),
  416. .no_tuner = 1,
  417. };
  418. static struct s5h1411_config dvico_fusionhdtv7_config = {
  419. .output_mode = S5H1411_SERIAL_OUTPUT,
  420. .gpio = S5H1411_GPIO_ON,
  421. .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  422. .qam_if = S5H1411_IF_44000,
  423. .vsb_if = S5H1411_IF_44000,
  424. .inversion = S5H1411_INVERSION_OFF,
  425. .status_mode = S5H1411_DEMODLOCKING
  426. };
  427. static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
  428. .i2c_address = 0xc2 >> 1,
  429. .if_khz = 5380,
  430. };
  431. static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
  432. {
  433. struct dvb_frontend *fe;
  434. struct videobuf_dvb_frontend *fe0 = NULL;
  435. struct xc2028_ctrl ctl;
  436. struct xc2028_config cfg = {
  437. .i2c_adap = &dev->core->i2c_adap,
  438. .i2c_addr = addr,
  439. .ctrl = &ctl,
  440. };
  441. /* Get the first frontend */
  442. fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
  443. if (!fe0)
  444. return -EINVAL;
  445. if (!fe0->dvb.frontend) {
  446. printk(KERN_ERR "%s/2: dvb frontend not attached. "
  447. "Can't attach xc3028\n",
  448. dev->core->name);
  449. return -EINVAL;
  450. }
  451. /*
  452. * Some xc3028 devices may be hidden by an I2C gate. This is known
  453. * to happen with some s5h1409-based devices.
  454. * Now that I2C gate is open, sets up xc3028 configuration
  455. */
  456. cx88_setup_xc3028(dev->core, &ctl);
  457. fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
  458. if (!fe) {
  459. printk(KERN_ERR "%s/2: xc3028 attach failed\n",
  460. dev->core->name);
  461. dvb_frontend_detach(fe0->dvb.frontend);
  462. dvb_unregister_frontend(fe0->dvb.frontend);
  463. fe0->dvb.frontend = NULL;
  464. return -EINVAL;
  465. }
  466. printk(KERN_INFO "%s/2: xc3028 attached\n",
  467. dev->core->name);
  468. return 0;
  469. }
  470. static int cx24116_set_ts_param(struct dvb_frontend *fe,
  471. int is_punctured)
  472. {
  473. struct cx8802_dev *dev = fe->dvb->priv;
  474. dev->ts_gen_cntrl = 0x2;
  475. return 0;
  476. }
  477. static int cx24116_reset_device(struct dvb_frontend *fe)
  478. {
  479. struct cx8802_dev *dev = fe->dvb->priv;
  480. struct cx88_core *core = dev->core;
  481. /* Reset the part */
  482. /* Put the cx24116 into reset */
  483. cx_write(MO_SRST_IO, 0);
  484. msleep(10);
  485. /* Take the cx24116 out of reset */
  486. cx_write(MO_SRST_IO, 1);
  487. msleep(10);
  488. return 0;
  489. }
  490. static struct cx24116_config hauppauge_hvr4000_config = {
  491. .demod_address = 0x05,
  492. .set_ts_params = cx24116_set_ts_param,
  493. .reset_device = cx24116_reset_device,
  494. };
  495. static struct cx24116_config tevii_s460_config = {
  496. .demod_address = 0x55,
  497. .set_ts_params = cx24116_set_ts_param,
  498. .reset_device = cx24116_reset_device,
  499. };
  500. static struct stv0299_config tevii_tuner_sharp_config = {
  501. .demod_address = 0x68,
  502. .inittab = sharp_z0194a_inittab,
  503. .mclk = 88000000UL,
  504. .invert = 1,
  505. .skip_reinit = 0,
  506. .lock_output = 1,
  507. .volt13_op0_op1 = STV0299_VOLT13_OP1,
  508. .min_delay_ms = 100,
  509. .set_symbol_rate = sharp_z0194a_set_symbol_rate,
  510. .set_ts_params = cx24116_set_ts_param,
  511. };
  512. static struct stv0288_config tevii_tuner_earda_config = {
  513. .demod_address = 0x68,
  514. .min_delay_ms = 100,
  515. .set_ts_params = cx24116_set_ts_param,
  516. };
  517. static int dvb_register(struct cx8802_dev *dev)
  518. {
  519. struct cx88_core *core = dev->core;
  520. struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
  521. int mfe_shared = 0; /* bus not shared by default */
  522. int i;
  523. if (0 != core->i2c_rc) {
  524. printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
  525. goto frontend_detach;
  526. }
  527. if (!core->board.num_frontends)
  528. return -EINVAL;
  529. mutex_init(&dev->frontends.lock);
  530. INIT_LIST_HEAD(&dev->frontends.felist);
  531. printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
  532. core->board.num_frontends);
  533. for (i = 1; i <= core->board.num_frontends; i++) {
  534. fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, i);
  535. if (!fe0) {
  536. printk(KERN_ERR "%s() failed to alloc\n", __func__);
  537. videobuf_dvb_dealloc_frontends(&dev->frontends);
  538. goto frontend_detach;
  539. }
  540. }
  541. /* Get the first frontend */
  542. fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
  543. if (!fe0)
  544. goto frontend_detach;
  545. /* multi-frontend gate control is undefined or defaults to fe0 */
  546. dev->frontends.gate = 0;
  547. /* Sets the gate control callback to be used by i2c command calls */
  548. core->gate_ctrl = cx88_dvb_gate_ctrl;
  549. /* init frontend(s) */
  550. switch (core->boardnr) {
  551. case CX88_BOARD_HAUPPAUGE_DVB_T1:
  552. fe0->dvb.frontend = dvb_attach(cx22702_attach,
  553. &connexant_refboard_config,
  554. &core->i2c_adap);
  555. if (fe0->dvb.frontend != NULL) {
  556. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  557. 0x61, &core->i2c_adap,
  558. DVB_PLL_THOMSON_DTT759X))
  559. goto frontend_detach;
  560. }
  561. break;
  562. case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
  563. case CX88_BOARD_CONEXANT_DVB_T1:
  564. case CX88_BOARD_KWORLD_DVB_T_CX22702:
  565. case CX88_BOARD_WINFAST_DTV1000:
  566. fe0->dvb.frontend = dvb_attach(cx22702_attach,
  567. &connexant_refboard_config,
  568. &core->i2c_adap);
  569. if (fe0->dvb.frontend != NULL) {
  570. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  571. 0x60, &core->i2c_adap,
  572. DVB_PLL_THOMSON_DTT7579))
  573. goto frontend_detach;
  574. }
  575. break;
  576. case CX88_BOARD_WINFAST_DTV2000H:
  577. case CX88_BOARD_HAUPPAUGE_HVR1100:
  578. case CX88_BOARD_HAUPPAUGE_HVR1100LP:
  579. case CX88_BOARD_HAUPPAUGE_HVR1300:
  580. fe0->dvb.frontend = dvb_attach(cx22702_attach,
  581. &hauppauge_hvr_config,
  582. &core->i2c_adap);
  583. if (fe0->dvb.frontend != NULL) {
  584. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  585. &core->i2c_adap, 0x61,
  586. TUNER_PHILIPS_FMD1216ME_MK3))
  587. goto frontend_detach;
  588. }
  589. break;
  590. case CX88_BOARD_HAUPPAUGE_HVR3000:
  591. /* MFE frontend 1 */
  592. mfe_shared = 1;
  593. dev->frontends.gate = 2;
  594. /* DVB-S init */
  595. fe0->dvb.frontend = dvb_attach(cx24123_attach,
  596. &hauppauge_novas_config,
  597. &dev->core->i2c_adap);
  598. if (fe0->dvb.frontend) {
  599. if (!dvb_attach(isl6421_attach,
  600. fe0->dvb.frontend,
  601. &dev->core->i2c_adap,
  602. 0x08, ISL6421_DCL, 0x00))
  603. goto frontend_detach;
  604. }
  605. /* MFE frontend 2 */
  606. fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
  607. if (!fe1)
  608. goto frontend_detach;
  609. /* DVB-T init */
  610. fe1->dvb.frontend = dvb_attach(cx22702_attach,
  611. &hauppauge_hvr_config,
  612. &dev->core->i2c_adap);
  613. if (fe1->dvb.frontend) {
  614. fe1->dvb.frontend->id = 1;
  615. if (!dvb_attach(simple_tuner_attach,
  616. fe1->dvb.frontend,
  617. &dev->core->i2c_adap,
  618. 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
  619. goto frontend_detach;
  620. }
  621. break;
  622. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
  623. fe0->dvb.frontend = dvb_attach(mt352_attach,
  624. &dvico_fusionhdtv,
  625. &core->i2c_adap);
  626. if (fe0->dvb.frontend != NULL) {
  627. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  628. 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
  629. goto frontend_detach;
  630. break;
  631. }
  632. /* ZL10353 replaces MT352 on later cards */
  633. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  634. &dvico_fusionhdtv_plus_v1_1,
  635. &core->i2c_adap);
  636. if (fe0->dvb.frontend != NULL) {
  637. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  638. 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
  639. goto frontend_detach;
  640. }
  641. break;
  642. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
  643. /* The tin box says DEE1601, but it seems to be DTT7579
  644. * compatible, with a slightly different MT352 AGC gain. */
  645. fe0->dvb.frontend = dvb_attach(mt352_attach,
  646. &dvico_fusionhdtv_dual,
  647. &core->i2c_adap);
  648. if (fe0->dvb.frontend != NULL) {
  649. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  650. 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
  651. goto frontend_detach;
  652. break;
  653. }
  654. /* ZL10353 replaces MT352 on later cards */
  655. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  656. &dvico_fusionhdtv_plus_v1_1,
  657. &core->i2c_adap);
  658. if (fe0->dvb.frontend != NULL) {
  659. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  660. 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
  661. goto frontend_detach;
  662. }
  663. break;
  664. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
  665. fe0->dvb.frontend = dvb_attach(mt352_attach,
  666. &dvico_fusionhdtv,
  667. &core->i2c_adap);
  668. if (fe0->dvb.frontend != NULL) {
  669. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  670. 0x61, NULL, DVB_PLL_LG_Z201))
  671. goto frontend_detach;
  672. }
  673. break;
  674. case CX88_BOARD_KWORLD_DVB_T:
  675. case CX88_BOARD_DNTV_LIVE_DVB_T:
  676. case CX88_BOARD_ADSTECH_DVB_T_PCI:
  677. fe0->dvb.frontend = dvb_attach(mt352_attach,
  678. &dntv_live_dvbt_config,
  679. &core->i2c_adap);
  680. if (fe0->dvb.frontend != NULL) {
  681. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
  682. 0x61, NULL, DVB_PLL_UNKNOWN_1))
  683. goto frontend_detach;
  684. }
  685. break;
  686. case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
  687. #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
  688. /* MT352 is on a secondary I2C bus made from some GPIO lines */
  689. fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
  690. &dev->vp3054->adap);
  691. if (fe0->dvb.frontend != NULL) {
  692. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  693. &core->i2c_adap, 0x61,
  694. TUNER_PHILIPS_FMD1216ME_MK3))
  695. goto frontend_detach;
  696. }
  697. #else
  698. printk(KERN_ERR "%s/2: built without vp3054 support\n",
  699. core->name);
  700. #endif
  701. break;
  702. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
  703. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  704. &dvico_fusionhdtv_hybrid,
  705. &core->i2c_adap);
  706. if (fe0->dvb.frontend != NULL) {
  707. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  708. &core->i2c_adap, 0x61,
  709. TUNER_THOMSON_FE6600))
  710. goto frontend_detach;
  711. }
  712. break;
  713. case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
  714. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  715. &dvico_fusionhdtv_xc3028,
  716. &core->i2c_adap);
  717. if (fe0->dvb.frontend == NULL)
  718. fe0->dvb.frontend = dvb_attach(mt352_attach,
  719. &dvico_fusionhdtv_mt352_xc3028,
  720. &core->i2c_adap);
  721. /*
  722. * On this board, the demod provides the I2C bus pullup.
  723. * We must not permit gate_ctrl to be performed, or
  724. * the xc3028 cannot communicate on the bus.
  725. */
  726. if (fe0->dvb.frontend)
  727. fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
  728. if (attach_xc3028(0x61, dev) < 0)
  729. goto frontend_detach;
  730. break;
  731. case CX88_BOARD_PCHDTV_HD3000:
  732. fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
  733. &core->i2c_adap);
  734. if (fe0->dvb.frontend != NULL) {
  735. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  736. &core->i2c_adap, 0x61,
  737. TUNER_THOMSON_DTT761X))
  738. goto frontend_detach;
  739. }
  740. break;
  741. case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
  742. dev->ts_gen_cntrl = 0x08;
  743. /* Do a hardware reset of chip before using it. */
  744. cx_clear(MO_GP0_IO, 1);
  745. mdelay(100);
  746. cx_set(MO_GP0_IO, 1);
  747. mdelay(200);
  748. /* Select RF connector callback */
  749. fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
  750. fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
  751. &fusionhdtv_3_gold,
  752. &core->i2c_adap);
  753. if (fe0->dvb.frontend != NULL) {
  754. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  755. &core->i2c_adap, 0x61,
  756. TUNER_MICROTUNE_4042FI5))
  757. goto frontend_detach;
  758. }
  759. break;
  760. case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
  761. dev->ts_gen_cntrl = 0x08;
  762. /* Do a hardware reset of chip before using it. */
  763. cx_clear(MO_GP0_IO, 1);
  764. mdelay(100);
  765. cx_set(MO_GP0_IO, 9);
  766. mdelay(200);
  767. fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
  768. &fusionhdtv_3_gold,
  769. &core->i2c_adap);
  770. if (fe0->dvb.frontend != NULL) {
  771. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  772. &core->i2c_adap, 0x61,
  773. TUNER_THOMSON_DTT761X))
  774. goto frontend_detach;
  775. }
  776. break;
  777. case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
  778. dev->ts_gen_cntrl = 0x08;
  779. /* Do a hardware reset of chip before using it. */
  780. cx_clear(MO_GP0_IO, 1);
  781. mdelay(100);
  782. cx_set(MO_GP0_IO, 1);
  783. mdelay(200);
  784. fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
  785. &fusionhdtv_5_gold,
  786. &core->i2c_adap);
  787. if (fe0->dvb.frontend != NULL) {
  788. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  789. &core->i2c_adap, 0x61,
  790. TUNER_LG_TDVS_H06XF))
  791. goto frontend_detach;
  792. if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
  793. &core->i2c_adap, 0x43))
  794. goto frontend_detach;
  795. }
  796. break;
  797. case CX88_BOARD_PCHDTV_HD5500:
  798. dev->ts_gen_cntrl = 0x08;
  799. /* Do a hardware reset of chip before using it. */
  800. cx_clear(MO_GP0_IO, 1);
  801. mdelay(100);
  802. cx_set(MO_GP0_IO, 1);
  803. mdelay(200);
  804. fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
  805. &pchdtv_hd5500,
  806. &core->i2c_adap);
  807. if (fe0->dvb.frontend != NULL) {
  808. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  809. &core->i2c_adap, 0x61,
  810. TUNER_LG_TDVS_H06XF))
  811. goto frontend_detach;
  812. if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
  813. &core->i2c_adap, 0x43))
  814. goto frontend_detach;
  815. }
  816. break;
  817. case CX88_BOARD_ATI_HDTVWONDER:
  818. fe0->dvb.frontend = dvb_attach(nxt200x_attach,
  819. &ati_hdtvwonder,
  820. &core->i2c_adap);
  821. if (fe0->dvb.frontend != NULL) {
  822. if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  823. &core->i2c_adap, 0x61,
  824. TUNER_PHILIPS_TUV1236D))
  825. goto frontend_detach;
  826. }
  827. break;
  828. case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
  829. case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
  830. fe0->dvb.frontend = dvb_attach(cx24123_attach,
  831. &hauppauge_novas_config,
  832. &core->i2c_adap);
  833. if (fe0->dvb.frontend) {
  834. if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
  835. &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
  836. goto frontend_detach;
  837. }
  838. break;
  839. case CX88_BOARD_KWORLD_DVBS_100:
  840. fe0->dvb.frontend = dvb_attach(cx24123_attach,
  841. &kworld_dvbs_100_config,
  842. &core->i2c_adap);
  843. if (fe0->dvb.frontend) {
  844. core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
  845. fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
  846. }
  847. break;
  848. case CX88_BOARD_GENIATECH_DVBS:
  849. fe0->dvb.frontend = dvb_attach(cx24123_attach,
  850. &geniatech_dvbs_config,
  851. &core->i2c_adap);
  852. if (fe0->dvb.frontend) {
  853. core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
  854. fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
  855. }
  856. break;
  857. case CX88_BOARD_PINNACLE_PCTV_HD_800i:
  858. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  859. &pinnacle_pctv_hd_800i_config,
  860. &core->i2c_adap);
  861. if (fe0->dvb.frontend != NULL) {
  862. if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
  863. &core->i2c_adap,
  864. &pinnacle_pctv_hd_800i_tuner_config))
  865. goto frontend_detach;
  866. }
  867. break;
  868. case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
  869. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  870. &dvico_hdtv5_pci_nano_config,
  871. &core->i2c_adap);
  872. if (fe0->dvb.frontend != NULL) {
  873. struct dvb_frontend *fe;
  874. struct xc2028_config cfg = {
  875. .i2c_adap = &core->i2c_adap,
  876. .i2c_addr = 0x61,
  877. };
  878. static struct xc2028_ctrl ctl = {
  879. .fname = XC2028_DEFAULT_FIRMWARE,
  880. .max_len = 64,
  881. .scode_table = XC3028_FE_OREN538,
  882. };
  883. fe = dvb_attach(xc2028_attach,
  884. fe0->dvb.frontend, &cfg);
  885. if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
  886. fe->ops.tuner_ops.set_config(fe, &ctl);
  887. }
  888. break;
  889. case CX88_BOARD_PINNACLE_HYBRID_PCTV:
  890. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  891. &cx88_pinnacle_hybrid_pctv,
  892. &core->i2c_adap);
  893. if (fe0->dvb.frontend) {
  894. fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
  895. if (attach_xc3028(0x61, dev) < 0)
  896. goto frontend_detach;
  897. }
  898. break;
  899. case CX88_BOARD_GENIATECH_X8000_MT:
  900. dev->ts_gen_cntrl = 0x00;
  901. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  902. &cx88_geniatech_x8000_mt,
  903. &core->i2c_adap);
  904. if (attach_xc3028(0x61, dev) < 0)
  905. goto frontend_detach;
  906. break;
  907. case CX88_BOARD_KWORLD_ATSC_120:
  908. fe0->dvb.frontend = dvb_attach(s5h1409_attach,
  909. &kworld_atsc_120_config,
  910. &core->i2c_adap);
  911. if (attach_xc3028(0x61, dev) < 0)
  912. goto frontend_detach;
  913. break;
  914. case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
  915. fe0->dvb.frontend = dvb_attach(s5h1411_attach,
  916. &dvico_fusionhdtv7_config,
  917. &core->i2c_adap);
  918. if (fe0->dvb.frontend != NULL) {
  919. if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
  920. &core->i2c_adap,
  921. &dvico_fusionhdtv7_tuner_config))
  922. goto frontend_detach;
  923. }
  924. break;
  925. case CX88_BOARD_HAUPPAUGE_HVR4000:
  926. /* MFE frontend 1 */
  927. mfe_shared = 1;
  928. dev->frontends.gate = 2;
  929. /* DVB-S/S2 Init */
  930. fe0->dvb.frontend = dvb_attach(cx24116_attach,
  931. &hauppauge_hvr4000_config,
  932. &dev->core->i2c_adap);
  933. if (fe0->dvb.frontend) {
  934. if (!dvb_attach(isl6421_attach,
  935. fe0->dvb.frontend,
  936. &dev->core->i2c_adap,
  937. 0x08, ISL6421_DCL, 0x00))
  938. goto frontend_detach;
  939. }
  940. /* MFE frontend 2 */
  941. fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
  942. if (!fe1)
  943. goto frontend_detach;
  944. /* DVB-T Init */
  945. fe1->dvb.frontend = dvb_attach(cx22702_attach,
  946. &hauppauge_hvr_config,
  947. &dev->core->i2c_adap);
  948. if (fe1->dvb.frontend) {
  949. fe1->dvb.frontend->id = 1;
  950. if (!dvb_attach(simple_tuner_attach,
  951. fe1->dvb.frontend,
  952. &dev->core->i2c_adap,
  953. 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
  954. goto frontend_detach;
  955. }
  956. break;
  957. case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
  958. fe0->dvb.frontend = dvb_attach(cx24116_attach,
  959. &hauppauge_hvr4000_config,
  960. &dev->core->i2c_adap);
  961. if (fe0->dvb.frontend) {
  962. if (!dvb_attach(isl6421_attach,
  963. fe0->dvb.frontend,
  964. &dev->core->i2c_adap,
  965. 0x08, ISL6421_DCL, 0x00))
  966. goto frontend_detach;
  967. }
  968. break;
  969. case CX88_BOARD_PROF_6200:
  970. case CX88_BOARD_TBS_8910:
  971. case CX88_BOARD_TEVII_S420:
  972. fe0->dvb.frontend = dvb_attach(stv0299_attach,
  973. &tevii_tuner_sharp_config,
  974. &core->i2c_adap);
  975. if (fe0->dvb.frontend != NULL) {
  976. if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
  977. &core->i2c_adap, DVB_PLL_OPERA1))
  978. goto frontend_detach;
  979. core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
  980. fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
  981. } else {
  982. fe0->dvb.frontend = dvb_attach(stv0288_attach,
  983. &tevii_tuner_earda_config,
  984. &core->i2c_adap);
  985. if (fe0->dvb.frontend != NULL) {
  986. if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
  987. &core->i2c_adap))
  988. goto frontend_detach;
  989. core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
  990. fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
  991. }
  992. }
  993. break;
  994. case CX88_BOARD_TEVII_S460:
  995. fe0->dvb.frontend = dvb_attach(cx24116_attach,
  996. &tevii_s460_config,
  997. &core->i2c_adap);
  998. if (fe0->dvb.frontend != NULL)
  999. fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
  1000. break;
  1001. case CX88_BOARD_OMICOM_SS4_PCI:
  1002. case CX88_BOARD_TBS_8920:
  1003. case CX88_BOARD_PROF_7300:
  1004. case CX88_BOARD_SATTRADE_ST4200:
  1005. fe0->dvb.frontend = dvb_attach(cx24116_attach,
  1006. &hauppauge_hvr4000_config,
  1007. &core->i2c_adap);
  1008. if (fe0->dvb.frontend != NULL)
  1009. fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
  1010. break;
  1011. default:
  1012. printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
  1013. core->name);
  1014. break;
  1015. }
  1016. if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
  1017. printk(KERN_ERR
  1018. "%s/2: frontend initialization failed\n",
  1019. core->name);
  1020. goto frontend_detach;
  1021. }
  1022. /* define general-purpose callback pointer */
  1023. fe0->dvb.frontend->callback = cx88_tuner_callback;
  1024. /* Ensure all frontends negotiate bus access */
  1025. fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
  1026. if (fe1)
  1027. fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
  1028. /* Put the analog decoder in standby to keep it quiet */
  1029. cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
  1030. /* register everything */
  1031. return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
  1032. &dev->pci->dev, adapter_nr, mfe_shared);
  1033. frontend_detach:
  1034. core->gate_ctrl = NULL;
  1035. videobuf_dvb_dealloc_frontends(&dev->frontends);
  1036. return -EINVAL;
  1037. }
  1038. /* ----------------------------------------------------------- */
  1039. /* CX8802 MPEG -> mini driver - We have been given the hardware */
  1040. static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
  1041. {
  1042. struct cx88_core *core = drv->core;
  1043. int err = 0;
  1044. dprintk( 1, "%s\n", __func__);
  1045. switch (core->boardnr) {
  1046. case CX88_BOARD_HAUPPAUGE_HVR1300:
  1047. /* We arrive here with either the cx23416 or the cx22702
  1048. * on the bus. Take the bus from the cx23416 and enable the
  1049. * cx22702 demod
  1050. */
  1051. /* Toggle reset on cx22702 leaving i2c active */
  1052. cx_set(MO_GP0_IO, 0x00000080);
  1053. udelay(1000);
  1054. cx_clear(MO_GP0_IO, 0x00000080);
  1055. udelay(50);
  1056. cx_set(MO_GP0_IO, 0x00000080);
  1057. udelay(1000);
  1058. /* enable the cx22702 pins */
  1059. cx_clear(MO_GP0_IO, 0x00000004);
  1060. udelay(1000);
  1061. break;
  1062. case CX88_BOARD_HAUPPAUGE_HVR3000:
  1063. case CX88_BOARD_HAUPPAUGE_HVR4000:
  1064. /* Toggle reset on cx22702 leaving i2c active */
  1065. cx_set(MO_GP0_IO, 0x00000080);
  1066. udelay(1000);
  1067. cx_clear(MO_GP0_IO, 0x00000080);
  1068. udelay(50);
  1069. cx_set(MO_GP0_IO, 0x00000080);
  1070. udelay(1000);
  1071. switch (core->dvbdev->frontends.active_fe_id) {
  1072. case 1: /* DVB-S/S2 Enabled */
  1073. /* tri-state the cx22702 pins */
  1074. cx_set(MO_GP0_IO, 0x00000004);
  1075. /* Take the cx24116/cx24123 out of reset */
  1076. cx_write(MO_SRST_IO, 1);
  1077. core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
  1078. break;
  1079. case 2: /* DVB-T Enabled */
  1080. /* Put the cx24116/cx24123 into reset */
  1081. cx_write(MO_SRST_IO, 0);
  1082. /* enable the cx22702 pins */
  1083. cx_clear(MO_GP0_IO, 0x00000004);
  1084. core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
  1085. break;
  1086. }
  1087. udelay(1000);
  1088. break;
  1089. default:
  1090. err = -ENODEV;
  1091. }
  1092. return err;
  1093. }
  1094. /* CX8802 MPEG -> mini driver - We no longer have the hardware */
  1095. static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
  1096. {
  1097. struct cx88_core *core = drv->core;
  1098. int err = 0;
  1099. dprintk( 1, "%s\n", __func__);
  1100. switch (core->boardnr) {
  1101. case CX88_BOARD_HAUPPAUGE_HVR1300:
  1102. /* Do Nothing, leave the cx22702 on the bus. */
  1103. break;
  1104. case CX88_BOARD_HAUPPAUGE_HVR3000:
  1105. case CX88_BOARD_HAUPPAUGE_HVR4000:
  1106. break;
  1107. default:
  1108. err = -ENODEV;
  1109. }
  1110. return err;
  1111. }
  1112. static int cx8802_dvb_probe(struct cx8802_driver *drv)
  1113. {
  1114. struct cx88_core *core = drv->core;
  1115. struct cx8802_dev *dev = drv->core->dvbdev;
  1116. int err;
  1117. dprintk( 1, "%s\n", __func__);
  1118. dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
  1119. core->boardnr,
  1120. core->name,
  1121. core->pci_bus,
  1122. core->pci_slot);
  1123. err = -ENODEV;
  1124. if (!(core->board.mpeg & CX88_MPEG_DVB))
  1125. goto fail_core;
  1126. /* If vp3054 isn't enabled, a stub will just return 0 */
  1127. err = vp3054_i2c_probe(dev);
  1128. if (0 != err)
  1129. goto fail_probe;
  1130. /* dvb stuff */
  1131. printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
  1132. dev->ts_gen_cntrl = 0x0c;
  1133. err = -ENODEV;
  1134. if (core->board.num_frontends) {
  1135. struct videobuf_dvb_frontend *fe;
  1136. int i;
  1137. for (i = 1; i <= core->board.num_frontends; i++) {
  1138. fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
  1139. if (fe == NULL) {
  1140. printk(KERN_ERR "%s() failed to get frontend(%d)\n",
  1141. __func__, i);
  1142. goto fail_probe;
  1143. }
  1144. videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
  1145. &dev->pci->dev, &dev->slock,
  1146. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  1147. V4L2_FIELD_TOP,
  1148. sizeof(struct cx88_buffer),
  1149. dev);
  1150. /* init struct videobuf_dvb */
  1151. fe->dvb.name = dev->core->name;
  1152. }
  1153. } else {
  1154. /* no frontends allocated */
  1155. printk(KERN_ERR "%s/2 .num_frontends should be non-zero\n",
  1156. core->name);
  1157. goto fail_core;
  1158. }
  1159. err = dvb_register(dev);
  1160. if (err)
  1161. /* frontends/adapter de-allocated in dvb_register */
  1162. printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
  1163. core->name, err);
  1164. return err;
  1165. fail_probe:
  1166. videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
  1167. fail_core:
  1168. return err;
  1169. }
  1170. static int cx8802_dvb_remove(struct cx8802_driver *drv)
  1171. {
  1172. struct cx88_core *core = drv->core;
  1173. struct cx8802_dev *dev = drv->core->dvbdev;
  1174. dprintk( 1, "%s\n", __func__);
  1175. videobuf_dvb_unregister_bus(&dev->frontends);
  1176. vp3054_i2c_remove(dev);
  1177. core->gate_ctrl = NULL;
  1178. return 0;
  1179. }
  1180. static struct cx8802_driver cx8802_dvb_driver = {
  1181. .type_id = CX88_MPEG_DVB,
  1182. .hw_access = CX8802_DRVCTL_SHARED,
  1183. .probe = cx8802_dvb_probe,
  1184. .remove = cx8802_dvb_remove,
  1185. .advise_acquire = cx8802_dvb_advise_acquire,
  1186. .advise_release = cx8802_dvb_advise_release,
  1187. };
  1188. static int dvb_init(void)
  1189. {
  1190. printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
  1191. (CX88_VERSION_CODE >> 16) & 0xff,
  1192. (CX88_VERSION_CODE >> 8) & 0xff,
  1193. CX88_VERSION_CODE & 0xff);
  1194. #ifdef SNAPSHOT
  1195. printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
  1196. SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
  1197. #endif
  1198. return cx8802_register_driver(&cx8802_dvb_driver);
  1199. }
  1200. static void dvb_fini(void)
  1201. {
  1202. cx8802_unregister_driver(&cx8802_dvb_driver);
  1203. }
  1204. module_init(dvb_init);
  1205. module_exit(dvb_fini);
  1206. /*
  1207. * Local variables:
  1208. * c-basic-offset: 8
  1209. * compile-command: "make DVB=1"
  1210. * End:
  1211. */