cx88-dvb.c 37 KB

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