flexcop-fe-tuner.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /*
  2. * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
  3. *
  4. * flexcop-fe-tuner.c - methods for attaching a frontend and controlling DiSEqC.
  5. *
  6. * see flexcop.c for copyright information.
  7. */
  8. #include <media/tuner.h>
  9. #include "flexcop.h"
  10. #include "stv0299.h"
  11. #include "mt352.h"
  12. #include "nxt200x.h"
  13. #include "bcm3510.h"
  14. #include "stv0297.h"
  15. #include "mt312.h"
  16. #include "lgdt330x.h"
  17. #include "dvb-pll.h"
  18. #include "tuner-simple.h"
  19. #include "s5h1420.h"
  20. #include "itd1000.h"
  21. #include "cx24123.h"
  22. #include "cx24113.h"
  23. #include "isl6421.h"
  24. /* lnb control */
  25. static int flexcop_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  26. {
  27. struct flexcop_device *fc = fe->dvb->priv;
  28. flexcop_ibi_value v;
  29. deb_tuner("polarity/voltage = %u\n", voltage);
  30. v = fc->read_ibi_reg(fc, misc_204);
  31. switch (voltage) {
  32. case SEC_VOLTAGE_OFF:
  33. v.misc_204.ACPI1_sig = 1;
  34. break;
  35. case SEC_VOLTAGE_13:
  36. v.misc_204.ACPI1_sig = 0;
  37. v.misc_204.LNB_L_H_sig = 0;
  38. break;
  39. case SEC_VOLTAGE_18:
  40. v.misc_204.ACPI1_sig = 0;
  41. v.misc_204.LNB_L_H_sig = 1;
  42. break;
  43. default:
  44. err("unknown SEC_VOLTAGE value");
  45. return -EINVAL;
  46. }
  47. return fc->write_ibi_reg(fc, misc_204, v);
  48. }
  49. static int flexcop_sleep(struct dvb_frontend* fe)
  50. {
  51. struct flexcop_device *fc = fe->dvb->priv;
  52. /* flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204); */
  53. if (fc->fe_sleep)
  54. return fc->fe_sleep(fe);
  55. /* v.misc_204.ACPI3_sig = 1;
  56. fc->write_ibi_reg(fc,misc_204,v);*/
  57. return 0;
  58. }
  59. static int flexcop_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
  60. {
  61. /* u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc }; */
  62. struct flexcop_device *fc = fe->dvb->priv;
  63. flexcop_ibi_value v;
  64. u16 ax;
  65. v.raw = 0;
  66. deb_tuner("tone = %u\n",tone);
  67. switch (tone) {
  68. case SEC_TONE_ON:
  69. ax = 0x01ff;
  70. break;
  71. case SEC_TONE_OFF:
  72. ax = 0;
  73. break;
  74. default:
  75. err("unknown SEC_TONE value");
  76. return -EINVAL;
  77. }
  78. v.lnb_switch_freq_200.LNB_CTLPrescaler_sig = 1; /* divide by 2 */
  79. v.lnb_switch_freq_200.LNB_CTLHighCount_sig = ax;
  80. v.lnb_switch_freq_200.LNB_CTLLowCount_sig = ax == 0 ? 0x1ff : ax;
  81. return fc->write_ibi_reg(fc,lnb_switch_freq_200,v);
  82. }
  83. static void flexcop_diseqc_send_bit(struct dvb_frontend* fe, int data)
  84. {
  85. flexcop_set_tone(fe, SEC_TONE_ON);
  86. udelay(data ? 500 : 1000);
  87. flexcop_set_tone(fe, SEC_TONE_OFF);
  88. udelay(data ? 1000 : 500);
  89. }
  90. static void flexcop_diseqc_send_byte(struct dvb_frontend* fe, int data)
  91. {
  92. int i, par = 1, d;
  93. for (i = 7; i >= 0; i--) {
  94. d = (data >> i) & 1;
  95. par ^= d;
  96. flexcop_diseqc_send_bit(fe, d);
  97. }
  98. flexcop_diseqc_send_bit(fe, par);
  99. }
  100. static int flexcop_send_diseqc_msg(struct dvb_frontend* fe, int len, u8 *msg, unsigned long burst)
  101. {
  102. int i;
  103. flexcop_set_tone(fe, SEC_TONE_OFF);
  104. mdelay(16);
  105. for (i = 0; i < len; i++)
  106. flexcop_diseqc_send_byte(fe,msg[i]);
  107. mdelay(16);
  108. if (burst != -1) {
  109. if (burst)
  110. flexcop_diseqc_send_byte(fe, 0xff);
  111. else {
  112. flexcop_set_tone(fe, SEC_TONE_ON);
  113. mdelay(12);
  114. udelay(500);
  115. flexcop_set_tone(fe, SEC_TONE_OFF);
  116. }
  117. msleep(20);
  118. }
  119. return 0;
  120. }
  121. static int flexcop_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
  122. {
  123. return flexcop_send_diseqc_msg(fe, cmd->msg_len, cmd->msg, 0);
  124. }
  125. static int flexcop_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
  126. {
  127. return flexcop_send_diseqc_msg(fe, 0, NULL, minicmd);
  128. }
  129. /* dvb-s stv0299 */
  130. static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
  131. {
  132. u8 aclk = 0;
  133. u8 bclk = 0;
  134. if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
  135. else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
  136. else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
  137. else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
  138. else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
  139. else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
  140. stv0299_writereg (fe, 0x13, aclk);
  141. stv0299_writereg (fe, 0x14, bclk);
  142. stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
  143. stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
  144. stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
  145. return 0;
  146. }
  147. static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
  148. {
  149. u8 buf[4];
  150. u32 div;
  151. struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
  152. struct flexcop_device *fc = fe->dvb->priv;
  153. div = params->frequency / 125;
  154. buf[0] = (div >> 8) & 0x7f;
  155. buf[1] = div & 0xff;
  156. buf[2] = 0x84; /* 0xC4 */
  157. buf[3] = 0x08;
  158. if (params->frequency < 1500000)
  159. buf[3] |= 0x10;
  160. if (fe->ops.i2c_gate_ctrl)
  161. fe->ops.i2c_gate_ctrl(fe, 1);
  162. if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1)
  163. return -EIO;
  164. return 0;
  165. }
  166. static u8 samsung_tbmu24112_inittab[] = {
  167. 0x01, 0x15,
  168. 0x02, 0x30,
  169. 0x03, 0x00,
  170. 0x04, 0x7D,
  171. 0x05, 0x35,
  172. 0x06, 0x02,
  173. 0x07, 0x00,
  174. 0x08, 0xC3,
  175. 0x0C, 0x00,
  176. 0x0D, 0x81,
  177. 0x0E, 0x23,
  178. 0x0F, 0x12,
  179. 0x10, 0x7E,
  180. 0x11, 0x84,
  181. 0x12, 0xB9,
  182. 0x13, 0x88,
  183. 0x14, 0x89,
  184. 0x15, 0xC9,
  185. 0x16, 0x00,
  186. 0x17, 0x5C,
  187. 0x18, 0x00,
  188. 0x19, 0x00,
  189. 0x1A, 0x00,
  190. 0x1C, 0x00,
  191. 0x1D, 0x00,
  192. 0x1E, 0x00,
  193. 0x1F, 0x3A,
  194. 0x20, 0x2E,
  195. 0x21, 0x80,
  196. 0x22, 0xFF,
  197. 0x23, 0xC1,
  198. 0x28, 0x00,
  199. 0x29, 0x1E,
  200. 0x2A, 0x14,
  201. 0x2B, 0x0F,
  202. 0x2C, 0x09,
  203. 0x2D, 0x05,
  204. 0x31, 0x1F,
  205. 0x32, 0x19,
  206. 0x33, 0xFE,
  207. 0x34, 0x93,
  208. 0xff, 0xff,
  209. };
  210. static struct stv0299_config samsung_tbmu24112_config = {
  211. .demod_address = 0x68,
  212. .inittab = samsung_tbmu24112_inittab,
  213. .mclk = 88000000UL,
  214. .invert = 0,
  215. .skip_reinit = 0,
  216. .lock_output = STV0299_LOCKOUTPUT_LK,
  217. .volt13_op0_op1 = STV0299_VOLT13_OP1,
  218. .min_delay_ms = 100,
  219. .set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
  220. };
  221. /* dvb-t mt352 */
  222. static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
  223. {
  224. static u8 mt352_clock_config [] = { 0x89, 0x18, 0x2d };
  225. static u8 mt352_reset [] = { 0x50, 0x80 };
  226. static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
  227. static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
  228. static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
  229. mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
  230. udelay(2000);
  231. mt352_write(fe, mt352_reset, sizeof(mt352_reset));
  232. mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
  233. mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
  234. mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
  235. return 0;
  236. }
  237. static int samsung_tdtc9251dh0_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
  238. {
  239. u32 div;
  240. unsigned char bs = 0;
  241. if (buf_len < 5)
  242. return -EINVAL;
  243. #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
  244. div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
  245. if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
  246. if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
  247. if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
  248. pllbuf[0] = 0x61;
  249. pllbuf[1] = div >> 8;
  250. pllbuf[2] = div & 0xff;
  251. pllbuf[3] = 0xcc;
  252. pllbuf[4] = bs;
  253. return 5;
  254. }
  255. static struct mt352_config samsung_tdtc9251dh0_config = {
  256. .demod_address = 0x0f,
  257. .demod_init = samsung_tdtc9251dh0_demod_init,
  258. };
  259. static int flexcop_fe_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
  260. {
  261. struct flexcop_device *fc = fe->dvb->priv;
  262. return request_firmware(fw, name, fc->dev);
  263. }
  264. static struct lgdt330x_config air2pc_atsc_hd5000_config = {
  265. .demod_address = 0x59,
  266. .demod_chip = LGDT3303,
  267. .serial_mpeg = 0x04,
  268. .clock_polarity_flip = 1,
  269. };
  270. static struct nxt200x_config samsung_tbmv_config = {
  271. .demod_address = 0x0a,
  272. };
  273. static struct bcm3510_config air2pc_atsc_first_gen_config = {
  274. .demod_address = 0x0f,
  275. .request_firmware = flexcop_fe_request_firmware,
  276. };
  277. static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
  278. {
  279. u8 buf[4];
  280. u32 div;
  281. struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
  282. struct flexcop_device *fc = fe->dvb->priv;
  283. div = (params->frequency + (125/2)) / 125;
  284. buf[0] = (div >> 8) & 0x7f;
  285. buf[1] = (div >> 0) & 0xff;
  286. buf[2] = 0x84 | ((div >> 10) & 0x60);
  287. buf[3] = 0x80;
  288. if (params->frequency < 1550000)
  289. buf[3] |= 0x02;
  290. if (fe->ops.i2c_gate_ctrl)
  291. fe->ops.i2c_gate_ctrl(fe, 1);
  292. if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1)
  293. return -EIO;
  294. return 0;
  295. }
  296. static struct mt312_config skystar23_samsung_tbdu18132_config = {
  297. .demod_address = 0x0e,
  298. };
  299. static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe,
  300. struct dvb_frontend_parameters *fep)
  301. {
  302. struct flexcop_device *fc = fe->dvb->priv;
  303. u8 buf[4];
  304. u16 div;
  305. int ret;
  306. /* 62.5 kHz * 10 */
  307. #define REF_FREQ 625
  308. #define FREQ_OFFSET 36125
  309. div = ((fep->frequency/1000 + FREQ_OFFSET ) * 10) / REF_FREQ; // 4 MHz = 4000 KHz
  310. buf[0] = (u8)( div >> 8) & 0x7f;
  311. buf[1] = (u8) div & 0xff;
  312. /* F(osc) = N * Reference Freq. (62.5 kHz)
  313. * byte 2 : 0 N14 N13 N12 N11 N10 N9 N8
  314. * byte 3 : N7 N6 N5 N4 N3 N2 N1 N0
  315. * byte 4 : 1 * * AGD R3 R2 R1 R0
  316. * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
  317. * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95 */
  318. buf[2] = 0x95;
  319. // Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
  320. // 47 - 153 0 * 0 0 0 0 0 1 0x01
  321. // 153 - 430 0 * 0 0 0 0 1 0 0x02
  322. // 430 - 822 0 * 0 0 1 0 0 0 0x08
  323. // 822 - 862 1 * 0 0 1 0 0 0 0x88
  324. if (fep->frequency <= 153000000) buf[3] = 0x01;
  325. else if (fep->frequency <= 430000000) buf[3] = 0x02;
  326. else if (fep->frequency <= 822000000) buf[3] = 0x08;
  327. else buf[3] = 0x88;
  328. if (fe->ops.i2c_gate_ctrl)
  329. fe->ops.i2c_gate_ctrl(fe, 0);
  330. deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]);
  331. ret = fc->i2c_request(&fc->fc_i2c_adap[2],
  332. FC_WRITE, 0x61, buf[0], &buf[1], 3);
  333. deb_tuner("tuner write returned: %d\n",ret);
  334. return ret;
  335. }
  336. static u8 alps_tdee4_stv0297_inittab[] = {
  337. 0x80, 0x01,
  338. 0x80, 0x00,
  339. 0x81, 0x01,
  340. 0x81, 0x00,
  341. 0x00, 0x48,
  342. 0x01, 0x58,
  343. 0x03, 0x00,
  344. 0x04, 0x00,
  345. 0x07, 0x00,
  346. 0x08, 0x00,
  347. 0x30, 0xff,
  348. 0x31, 0x9d,
  349. 0x32, 0xff,
  350. 0x33, 0x00,
  351. 0x34, 0x29,
  352. 0x35, 0x55,
  353. 0x36, 0x80,
  354. 0x37, 0x6e,
  355. 0x38, 0x9c,
  356. 0x40, 0x1a,
  357. 0x41, 0xfe,
  358. 0x42, 0x33,
  359. 0x43, 0x00,
  360. 0x44, 0xff,
  361. 0x45, 0x00,
  362. 0x46, 0x00,
  363. 0x49, 0x04,
  364. 0x4a, 0x51,
  365. 0x4b, 0xf8,
  366. 0x52, 0x30,
  367. 0x53, 0x06,
  368. 0x59, 0x06,
  369. 0x5a, 0x5e,
  370. 0x5b, 0x04,
  371. 0x61, 0x49,
  372. 0x62, 0x0a,
  373. 0x70, 0xff,
  374. 0x71, 0x04,
  375. 0x72, 0x00,
  376. 0x73, 0x00,
  377. 0x74, 0x0c,
  378. 0x80, 0x20,
  379. 0x81, 0x00,
  380. 0x82, 0x30,
  381. 0x83, 0x00,
  382. 0x84, 0x04,
  383. 0x85, 0x22,
  384. 0x86, 0x08,
  385. 0x87, 0x1b,
  386. 0x88, 0x00,
  387. 0x89, 0x00,
  388. 0x90, 0x00,
  389. 0x91, 0x04,
  390. 0xa0, 0x86,
  391. 0xa1, 0x00,
  392. 0xa2, 0x00,
  393. 0xb0, 0x91,
  394. 0xb1, 0x0b,
  395. 0xc0, 0x5b,
  396. 0xc1, 0x10,
  397. 0xc2, 0x12,
  398. 0xd0, 0x02,
  399. 0xd1, 0x00,
  400. 0xd2, 0x00,
  401. 0xd3, 0x00,
  402. 0xd4, 0x02,
  403. 0xd5, 0x00,
  404. 0xde, 0x00,
  405. 0xdf, 0x01,
  406. 0xff, 0xff,
  407. };
  408. static struct stv0297_config alps_tdee4_stv0297_config = {
  409. .demod_address = 0x1c,
  410. .inittab = alps_tdee4_stv0297_inittab,
  411. // .invert = 1,
  412. // .pll_set = alps_tdee4_stv0297_pll_set,
  413. };
  414. /* SkyStar2 rev2.7 (a/u) */
  415. static struct s5h1420_config skystar2_rev2_7_s5h1420_config = {
  416. .demod_address = 0x53,
  417. .invert = 1,
  418. .repeated_start_workaround = 1,
  419. .serial_mpeg = 1,
  420. };
  421. static struct itd1000_config skystar2_rev2_7_itd1000_config = {
  422. .i2c_address = 0x61,
  423. };
  424. /* SkyStar2 rev2.8 */
  425. static struct cx24123_config skystar2_rev2_8_cx24123_config = {
  426. .demod_address = 0x55,
  427. .dont_use_pll = 1,
  428. .agc_callback = cx24113_agc_callback,
  429. };
  430. static const struct cx24113_config skystar2_rev2_8_cx24113_config = {
  431. .i2c_addr = 0x54,
  432. .xtal_khz = 10111,
  433. };
  434. /* try to figure out the frontend, each card/box can have on of the following list */
  435. int flexcop_frontend_init(struct flexcop_device *fc)
  436. {
  437. struct dvb_frontend_ops *ops;
  438. struct i2c_adapter *i2c = &fc->fc_i2c_adap[0].i2c_adap;
  439. struct i2c_adapter *i2c_tuner;
  440. /* enable no_base_addr - no repeated start when reading */
  441. fc->fc_i2c_adap[0].no_base_addr = 1;
  442. fc->fe = dvb_attach(s5h1420_attach, &skystar2_rev2_7_s5h1420_config, i2c);
  443. if (fc->fe != NULL) {
  444. flexcop_ibi_value r108;
  445. i2c_tuner = s5h1420_get_tuner_i2c_adapter(fc->fe);
  446. ops = &fc->fe->ops;
  447. fc->fe_sleep = ops->sleep;
  448. ops->sleep = flexcop_sleep;
  449. fc->dev_type = FC_SKY_REV27;
  450. /* enable no_base_addr - no repeated start when reading */
  451. fc->fc_i2c_adap[2].no_base_addr = 1;
  452. if (dvb_attach(isl6421_attach, fc->fe, &fc->fc_i2c_adap[2].i2c_adap, 0x08, 1, 1) == NULL)
  453. err("ISL6421 could NOT be attached");
  454. else
  455. info("ISL6421 successfully attached");
  456. /* the ITD1000 requires a lower i2c clock - it slows down the stuff for everyone - but is it a problem ? */
  457. r108.raw = 0x00000506;
  458. fc->write_ibi_reg(fc, tw_sm_c_108, r108);
  459. if (i2c_tuner) {
  460. if (dvb_attach(itd1000_attach, fc->fe, i2c_tuner, &skystar2_rev2_7_itd1000_config) == NULL)
  461. err("ITD1000 could NOT be attached");
  462. else
  463. info("ITD1000 successfully attached");
  464. }
  465. goto fe_found;
  466. }
  467. fc->fc_i2c_adap[0].no_base_addr = 0; /* for the next devices we need it again */
  468. /* try the sky v2.8 (cx24123, isl6421) */
  469. fc->fe = dvb_attach(cx24123_attach,
  470. &skystar2_rev2_8_cx24123_config, i2c);
  471. if (fc->fe != NULL) {
  472. i2c_tuner = cx24123_get_tuner_i2c_adapter(fc->fe);
  473. if (i2c_tuner != NULL) {
  474. if (dvb_attach(cx24113_attach, fc->fe,
  475. &skystar2_rev2_8_cx24113_config,
  476. i2c_tuner) == NULL)
  477. err("CX24113 could NOT be attached");
  478. else
  479. info("CX24113 successfully attached");
  480. }
  481. fc->dev_type = FC_SKY_REV28;
  482. fc->fc_i2c_adap[2].no_base_addr = 1;
  483. if (dvb_attach(isl6421_attach, fc->fe,
  484. &fc->fc_i2c_adap[2].i2c_adap, 0x08, 0, 0) == NULL)
  485. err("ISL6421 could NOT be attached");
  486. else
  487. info("ISL6421 successfully attached");
  488. /* TODO on i2c_adap[1] addr 0x11 (EEPROM) there seems to be an
  489. * IR-receiver (PIC16F818) - but the card has no input for
  490. * that ??? */
  491. goto fe_found;
  492. }
  493. /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */
  494. fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c);
  495. if (fc->fe != NULL) {
  496. ops = &fc->fe->ops;
  497. ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params;
  498. ops->set_voltage = flexcop_set_voltage;
  499. fc->fe_sleep = ops->sleep;
  500. ops->sleep = flexcop_sleep;
  501. fc->dev_type = FC_SKY;
  502. goto fe_found;
  503. }
  504. /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
  505. fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c);
  506. if (fc->fe != NULL) {
  507. fc->dev_type = FC_AIR_DVB;
  508. fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
  509. goto fe_found;
  510. }
  511. /* try the air atsc 2nd generation (nxt2002) */
  512. fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, i2c);
  513. if (fc->fe != NULL) {
  514. fc->dev_type = FC_AIR_ATSC2;
  515. dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV);
  516. goto fe_found;
  517. }
  518. fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, i2c);
  519. if (fc->fe != NULL) {
  520. fc->dev_type = FC_AIR_ATSC3;
  521. dvb_attach(simple_tuner_attach, fc->fe, i2c, 0x61,
  522. TUNER_LG_TDVS_H06XF);
  523. goto fe_found;
  524. }
  525. /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */
  526. fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, i2c);
  527. if (fc->fe != NULL) {
  528. fc->dev_type = FC_AIR_ATSC1;
  529. goto fe_found;
  530. }
  531. /* try the cable dvb (stv0297) */
  532. fc->fc_i2c_adap[0].no_base_addr = 1;
  533. fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c);
  534. if (fc->fe != NULL) {
  535. fc->dev_type = FC_CABLE;
  536. fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
  537. goto fe_found;
  538. }
  539. fc->fc_i2c_adap[0].no_base_addr = 0;
  540. /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
  541. fc->fe = dvb_attach(mt312_attach,
  542. &skystar23_samsung_tbdu18132_config, i2c);
  543. if (fc->fe != NULL) {
  544. ops = &fc->fe->ops;
  545. ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params;
  546. ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
  547. ops->diseqc_send_burst = flexcop_diseqc_send_burst;
  548. ops->set_tone = flexcop_set_tone;
  549. ops->set_voltage = flexcop_set_voltage;
  550. fc->fe_sleep = ops->sleep;
  551. ops->sleep = flexcop_sleep;
  552. fc->dev_type = FC_SKY_OLD;
  553. goto fe_found;
  554. }
  555. err("no frontend driver found for this B2C2/FlexCop adapter");
  556. return -ENODEV;
  557. fe_found:
  558. info("found '%s' .", fc->fe->ops.info.name);
  559. if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) {
  560. err("frontend registration failed!");
  561. ops = &fc->fe->ops;
  562. if (ops->release != NULL)
  563. ops->release(fc->fe);
  564. fc->fe = NULL;
  565. return -EINVAL;
  566. }
  567. fc->init_state |= FC_STATE_FE_INIT;
  568. return 0;
  569. }
  570. void flexcop_frontend_exit(struct flexcop_device *fc)
  571. {
  572. if (fc->init_state & FC_STATE_FE_INIT) {
  573. dvb_unregister_frontend(fc->fe);
  574. dvb_frontend_detach(fc->fe);
  575. }
  576. fc->init_state &= ~FC_STATE_FE_INIT;
  577. }