📄 flexcop-fe-tuner.c
字号:
buf[1] = (div >> 0) & 0xff; buf[2] = 0x84 | ((div >> 10) & 0x60); buf[3] = 0x80; if (params->frequency < 1550000) buf[3] |= 0x02; if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1) return -EIO; return 0;}static struct mt312_config skystar23_samsung_tbdu18132_config = { .demod_address = 0x0e,};static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep){ struct flexcop_device *fc = fe->dvb->priv; u8 buf[4]; u16 div; int ret;/* 62.5 kHz * 10 */#define REF_FREQ 625#define FREQ_OFFSET 36125 div = ((fep->frequency/1000 + FREQ_OFFSET ) * 10) / REF_FREQ; // 4 MHz = 4000 KHz buf[0] = (u8)( div >> 8) & 0x7f; buf[1] = (u8) div & 0xff;/* F(osc) = N * Reference Freq. (62.5 kHz) * byte 2 : 0 N14 N13 N12 N11 N10 N9 N8 * byte 3 : N7 N6 N5 N4 N3 N2 N1 N0 * byte 4 : 1 * * AGD R3 R2 R1 R0 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95 */ buf[2] = 0x95;// Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5// 47 - 153 0 * 0 0 0 0 0 1 0x01// 153 - 430 0 * 0 0 0 0 1 0 0x02// 430 - 822 0 * 0 0 1 0 0 0 0x08// 822 - 862 1 * 0 0 1 0 0 0 0x88 if (fep->frequency <= 153000000) buf[3] = 0x01; else if (fep->frequency <= 430000000) buf[3] = 0x02; else if (fep->frequency <= 822000000) buf[3] = 0x08; else buf[3] = 0x88; if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]); ret = fc->i2c_request(&fc->fc_i2c_adap[2], FC_WRITE, 0x61, buf[0], &buf[1], 3); deb_tuner("tuner write returned: %d\n",ret); return ret;}static u8 alps_tdee4_stv0297_inittab[] = { 0x80, 0x01, 0x80, 0x00, 0x81, 0x01, 0x81, 0x00, 0x00, 0x48, 0x01, 0x58, 0x03, 0x00, 0x04, 0x00, 0x07, 0x00, 0x08, 0x00, 0x30, 0xff, 0x31, 0x9d, 0x32, 0xff, 0x33, 0x00, 0x34, 0x29, 0x35, 0x55, 0x36, 0x80, 0x37, 0x6e, 0x38, 0x9c, 0x40, 0x1a, 0x41, 0xfe, 0x42, 0x33, 0x43, 0x00, 0x44, 0xff, 0x45, 0x00, 0x46, 0x00, 0x49, 0x04, 0x4a, 0x51, 0x4b, 0xf8, 0x52, 0x30, 0x53, 0x06, 0x59, 0x06, 0x5a, 0x5e, 0x5b, 0x04, 0x61, 0x49, 0x62, 0x0a, 0x70, 0xff, 0x71, 0x04, 0x72, 0x00, 0x73, 0x00, 0x74, 0x0c, 0x80, 0x20, 0x81, 0x00, 0x82, 0x30, 0x83, 0x00, 0x84, 0x04, 0x85, 0x22, 0x86, 0x08, 0x87, 0x1b, 0x88, 0x00, 0x89, 0x00, 0x90, 0x00, 0x91, 0x04, 0xa0, 0x86, 0xa1, 0x00, 0xa2, 0x00, 0xb0, 0x91, 0xb1, 0x0b, 0xc0, 0x5b, 0xc1, 0x10, 0xc2, 0x12, 0xd0, 0x02, 0xd1, 0x00, 0xd2, 0x00, 0xd3, 0x00, 0xd4, 0x02, 0xd5, 0x00, 0xde, 0x00, 0xdf, 0x01, 0xff, 0xff,};static struct stv0297_config alps_tdee4_stv0297_config = { .demod_address = 0x1c, .inittab = alps_tdee4_stv0297_inittab,// .invert = 1,// .pll_set = alps_tdee4_stv0297_pll_set,};/* SkyStar2 rev2.7 (a/u) */static struct s5h1420_config skystar2_rev2_7_s5h1420_config = { .demod_address = 0x53, .invert = 1, .repeated_start_workaround = 1, .serial_mpeg = 1,};static struct itd1000_config skystar2_rev2_7_itd1000_config = { .i2c_address = 0x61,};/* SkyStar2 rev2.8 */static struct cx24123_config skystar2_rev2_8_cx24123_config = { .demod_address = 0x55, .dont_use_pll = 1, .agc_callback = cx24113_agc_callback,};static const struct cx24113_config skystar2_rev2_8_cx24113_config = { .i2c_addr = 0x54, .xtal_khz = 10111,};/* try to figure out the frontend, each card/box can have on of the following list */int flexcop_frontend_init(struct flexcop_device *fc){ struct dvb_frontend_ops *ops; struct i2c_adapter *i2c = &fc->fc_i2c_adap[0].i2c_adap; struct i2c_adapter *i2c_tuner; /* enable no_base_addr - no repeated start when reading */ fc->fc_i2c_adap[0].no_base_addr = 1; fc->fe = dvb_attach(s5h1420_attach, &skystar2_rev2_7_s5h1420_config, i2c); if (fc->fe != NULL) { flexcop_ibi_value r108; i2c_tuner = s5h1420_get_tuner_i2c_adapter(fc->fe); ops = &fc->fe->ops; fc->fe_sleep = ops->sleep; ops->sleep = flexcop_sleep; fc->dev_type = FC_SKY_REV27; /* enable no_base_addr - no repeated start when reading */ fc->fc_i2c_adap[2].no_base_addr = 1; if (dvb_attach(isl6421_attach, fc->fe, &fc->fc_i2c_adap[2].i2c_adap, 0x08, 1, 1) == NULL) err("ISL6421 could NOT be attached"); else info("ISL6421 successfully attached"); /* the ITD1000 requires a lower i2c clock - it slows down the stuff for everyone - but is it a problem ? */ r108.raw = 0x00000506; fc->write_ibi_reg(fc, tw_sm_c_108, r108); if (i2c_tuner) { if (dvb_attach(itd1000_attach, fc->fe, i2c_tuner, &skystar2_rev2_7_itd1000_config) == NULL) err("ITD1000 could NOT be attached"); else info("ITD1000 successfully attached"); } goto fe_found; } fc->fc_i2c_adap[0].no_base_addr = 0; /* for the next devices we need it again */ /* try the sky v2.8 (cx24123, isl6421) */ fc->fe = dvb_attach(cx24123_attach, &skystar2_rev2_8_cx24123_config, i2c); if (fc->fe != NULL) { i2c_tuner = cx24123_get_tuner_i2c_adapter(fc->fe); if (i2c_tuner != NULL) { if (dvb_attach(cx24113_attach, fc->fe, &skystar2_rev2_8_cx24113_config, i2c_tuner) == NULL) err("CX24113 could NOT be attached"); else info("CX24113 successfully attached"); } fc->dev_type = FC_SKY_REV28; fc->fc_i2c_adap[2].no_base_addr = 1; if (dvb_attach(isl6421_attach, fc->fe, &fc->fc_i2c_adap[2].i2c_adap, 0x08, 0, 0) == NULL) err("ISL6421 could NOT be attached"); else info("ISL6421 successfully attached"); /* TODO on i2c_adap[1] addr 0x11 (EEPROM) there seems to be an * IR-receiver (PIC16F818) - but the card has no input for * that ??? */ goto fe_found; } /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c); if (fc->fe != NULL) { ops = &fc->fe->ops; ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; ops->set_voltage = flexcop_set_voltage; fc->fe_sleep = ops->sleep; ops->sleep = flexcop_sleep; fc->dev_type = FC_SKY; goto fe_found; } /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c); if (fc->fe != NULL) { fc->dev_type = FC_AIR_DVB; fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; goto fe_found; } /* try the air atsc 2nd generation (nxt2002) */ fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, i2c); if (fc->fe != NULL) { fc->dev_type = FC_AIR_ATSC2; dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV); goto fe_found; } fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, i2c); if (fc->fe != NULL) { fc->dev_type = FC_AIR_ATSC3; dvb_attach(simple_tuner_attach, fc->fe, i2c, 0x61, TUNER_LG_TDVS_H06XF); goto fe_found; } /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, i2c); if (fc->fe != NULL) { fc->dev_type = FC_AIR_ATSC1; goto fe_found; } /* try the cable dvb (stv0297) */ fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c); if (fc->fe != NULL) { fc->dev_type = FC_CABLE; fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; goto fe_found; } /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ fc->fe = dvb_attach(mt312_attach, &skystar23_samsung_tbdu18132_config, i2c); if (fc->fe != NULL) { ops = &fc->fe->ops; ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; ops->diseqc_send_burst = flexcop_diseqc_send_burst; ops->set_tone = flexcop_set_tone; ops->set_voltage = flexcop_set_voltage; fc->fe_sleep = ops->sleep; ops->sleep = flexcop_sleep; fc->dev_type = FC_SKY_OLD; goto fe_found; } err("no frontend driver found for this B2C2/FlexCop adapter"); return -ENODEV;fe_found: info("found '%s' .", fc->fe->ops.info.name); if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { err("frontend registration failed!"); ops = &fc->fe->ops; if (ops->release != NULL) ops->release(fc->fe); fc->fe = NULL; return -EINVAL; } fc->init_state |= FC_STATE_FE_INIT; return 0;}void flexcop_frontend_exit(struct flexcop_device *fc){ if (fc->init_state & FC_STATE_FE_INIT) { dvb_unregister_frontend(fc->fe); dvb_frontend_detach(fc->fe); } fc->init_state &= ~FC_STATE_FE_INIT;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -