Index: build-2.6/Makefile =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/build-2.6/Makefile,v retrieving revision 1.72 diff -u -r1.72 Makefile --- build-2.6/Makefile 2 Jul 2005 12:50:02 -0000 1.72 +++ build-2.6/Makefile 23 Jul 2005 07:50:41 -0000 @@ -207,4 +207,6 @@ obj-m += pluto2.o +obj-m += bsbe1.o bsru6.o bsrv2.o cd1516.o tbdu18132.o tbmu24112.o tdbe2.o tdtc9251dh0.o cu1216.o g29504-451.o tdmb7.o g29504-401.o tded4.o + endif Index: linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c,v retrieving revision 1.8 diff -u -r1.8 flexcop-fe-tuner.c --- linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c 16 Jul 2005 22:42:53 -0000 1.8 +++ linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c 23 Jul 2005 07:50:41 -0000 @@ -7,12 +7,12 @@ */ #include "flexcop.h" -#include "stv0299.h" -#include "mt352.h" +#include "tbmu24112.h" +#include "tdtc9251dh0.h" #include "nxt2002.h" #include "bcm3510.h" #include "stv0297.h" -#include "mt312.h" +#include "tbdu18132.h" /* lnb control */ @@ -142,154 +142,6 @@ return flexcop_send_diseqc_msg(fe, 0, NULL, minicmd); } -/* dvb-s stv0299 */ -static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio) -{ - u8 aclk = 0; - u8 bclk = 0; - - if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; } - else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; } - else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; } - else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; } - else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; } - else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; } - - stv0299_writereg (fe, 0x13, aclk); - stv0299_writereg (fe, 0x14, bclk); - stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff); - stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff); - stv0299_writereg (fe, 0x21, (ratio ) & 0xf0); - - return 0; -} - -static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) -{ - u8 buf[4]; - u32 div; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; - - div = params->frequency / 125; - - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = 0x84; /* 0xC4 */ - buf[3] = 0x08; - - if (params->frequency < 1500000) buf[3] |= 0x10; - - if (i2c_transfer(i2c, &msg, 1) != 1) - return -EIO; - return 0; -} - -static u8 samsung_tbmu24112_inittab[] = { - 0x01, 0x15, - 0x02, 0x30, - 0x03, 0x00, - 0x04, 0x7D, - 0x05, 0x35, - 0x06, 0x02, - 0x07, 0x00, - 0x08, 0xC3, - 0x0C, 0x00, - 0x0D, 0x81, - 0x0E, 0x23, - 0x0F, 0x12, - 0x10, 0x7E, - 0x11, 0x84, - 0x12, 0xB9, - 0x13, 0x88, - 0x14, 0x89, - 0x15, 0xC9, - 0x16, 0x00, - 0x17, 0x5C, - 0x18, 0x00, - 0x19, 0x00, - 0x1A, 0x00, - 0x1C, 0x00, - 0x1D, 0x00, - 0x1E, 0x00, - 0x1F, 0x3A, - 0x20, 0x2E, - 0x21, 0x80, - 0x22, 0xFF, - 0x23, 0xC1, - 0x28, 0x00, - 0x29, 0x1E, - 0x2A, 0x14, - 0x2B, 0x0F, - 0x2C, 0x09, - 0x2D, 0x05, - 0x31, 0x1F, - 0x32, 0x19, - 0x33, 0xFE, - 0x34, 0x93, - 0xff, 0xff, -}; - -static struct stv0299_config samsung_tbmu24112_config = { - .demod_address = 0x68, - .inittab = samsung_tbmu24112_inittab, - .mclk = 88000000UL, - .invert = 0, - .enhanced_tuning = 0, - .skip_reinit = 0, - .lock_output = STV0229_LOCKOUTPUT_LK, - .volt13_op0_op1 = STV0299_VOLT13_OP1, - .min_delay_ms = 100, - .set_symbol_rate = samsung_tbmu24112_set_symbol_rate, - .pll_set = samsung_tbmu24112_pll_set, -}; - -/* dvb-t mt352 */ -static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) -{ - static u8 mt352_clock_config [] = { 0x89, 0x18, 0x2d }; - static u8 mt352_reset [] = { 0x50, 0x80 }; - static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 }; - static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 }; - static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; - - mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); - udelay(2000); - mt352_write(fe, mt352_reset, sizeof(mt352_reset)); - mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); - - mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg)); - mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg)); - - return 0; -} - -static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) -{ - u32 div; - unsigned char bs = 0; - - #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ - div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - - if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09; - if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a; - if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08; - - pllbuf[0] = 0xc2; /* Note: non-linux standard PLL i2c address */ - pllbuf[1] = div >> 8; - pllbuf[2] = div & 0xff; - pllbuf[3] = 0xcc; - pllbuf[4] = bs; - - return 0; -} - -static struct mt352_config samsung_tdtc9251dh0_config = { - .demod_address = 0x0f, - .demod_init = samsung_tdtc9251dh0_demod_init, - .pll_set = samsung_tdtc9251dh0_pll_set, -}; - static int flexcop_fe_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) { struct flexcop_device *fc = fe->dvb->priv; @@ -306,34 +158,6 @@ .request_firmware = flexcop_fe_request_firmware, }; -static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - u8 buf[4]; - u32 div; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; - struct flexcop_device *fc = fe->dvb->priv; - - div = (params->frequency + (125/2)) / 125; - - buf[0] = (div >> 8) & 0x7f; - buf[1] = (div >> 0) & 0xff; - buf[2] = 0x84 | ((div >> 10) & 0x60); - buf[3] = 0x80; - - if (params->frequency < 1550000) - buf[3] |= 0x02; - - if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) - return -EIO; - return 0; -} - -static struct mt312_config skystar23_samsung_tbdu18132_config = { - - .demod_address = 0x0e, - .pll_set = skystar23_samsung_tbdu18132_pll_set, -}; - static struct stv0297_config alps_tdee4_stv0297_config = { .demod_address = 0x1c, // .invert = 1, @@ -344,19 +168,19 @@ int flexcop_frontend_init(struct flexcop_device *fc) { /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ - if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { + if ((fc->fe = samsung_tbmu24112_attach(&fc->i2c_adap)) != NULL) { fc->fe->ops->set_voltage = flexcop_set_voltage; fc->fe_sleep = fc->fe->ops->sleep; fc->fe->ops->sleep = flexcop_sleep; fc->dev_type = FC_SKY; - info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address); + info("found the stv0299"); } else /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ - if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) { + if ((fc->fe = samsung_tdtc9251dh0_attach(&fc->i2c_adap)) != NULL) { fc->dev_type = FC_AIR_DVB; - info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); + info("found the mt352"); } else /* try the air atsc 2nd generation (nxt2002) */ if ((fc->fe = nxt2002_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) { @@ -374,7 +198,7 @@ info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); } else /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ - if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { + if ((fc->fe = samsung_tbdu18132_attach(&fc->i2c_adap)) != NULL) { fc->fe->ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; fc->fe->ops->diseqc_send_burst = flexcop_diseqc_send_burst; fc->fe->ops->set_tone = flexcop_set_tone; @@ -384,7 +208,7 @@ fc->fe->ops->sleep = flexcop_sleep; fc->dev_type = FC_SKY_OLD; - info("found the vp310 (aka mt312) at i2c address: 0x%02x",skystar23_samsung_tbdu18132_config.demod_address); + info("found the vp310"); } if (fc->fe == NULL) { Index: linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c,v retrieving revision 1.44 diff -u -r1.44 dvb-bt8xx.c --- linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c 23 Apr 2005 19:16:15 -0000 1.44 +++ linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c 23 Jul 2005 07:50:41 -0000 @@ -425,42 +425,6 @@ .sleep = or51211_sleep, }; - -static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; - u8 buf[4]; - u32 div; - struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf) }; - - div = (params->frequency + 36166667) / 166667; - - buf[0] = (div >> 8) & 0x7F; - buf[1] = div & 0xFF; - buf[2] = 0x85; - if ((params->frequency >= 47000000) && (params->frequency < 153000000)) - buf[3] = 0x01; - else if ((params->frequency >= 153000000) && (params->frequency < 430000000)) - buf[3] = 0x02; - else if ((params->frequency >= 430000000) && (params->frequency < 824000000)) - buf[3] = 0x0C; - else if ((params->frequency >= 824000000) && (params->frequency < 863000000)) - buf[3] = 0x8C; - else - return -EINVAL; - - i2c_transfer(card->i2c_adapter, &msg, 1); - return 0; -} - -static struct nxt6000_config vp3021_alps_tded4_config = { - - .demod_address = 0x0a, - .clock_inversion = 1, - .pll_set = vp3021_alps_tded4_pll_set, -}; - - static void frontend_init(struct dvb_bt8xx_card *card, u32 type) { int ret; @@ -483,7 +447,7 @@ #else case BTTV_NEBULA_DIGITV: #endif - card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); + card->fe = alps_tded4_attach(card->i2c_adapter); if (card->fe != NULL) { break; } Index: linux/drivers/media/dvb/bt8xx/dvb-bt8xx.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.h,v retrieving revision 1.18 diff -u -r1.18 dvb-bt8xx.h --- linux/drivers/media/dvb/bt8xx/dvb-bt8xx.h 17 Jul 2005 20:56:25 -0000 1.18 +++ linux/drivers/media/dvb/bt8xx/dvb-bt8xx.h 23 Jul 2005 07:50:41 -0000 @@ -32,7 +32,7 @@ #include "mt352.h" #include "sp887x.h" #include "dst_common.h" -#include "nxt6000.h" +#include "tded4.h" #include "cx24110.h" #include "or51211.h" Index: linux/drivers/media/dvb/frontends/Makefile =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/Makefile,v retrieving revision 1.27 diff -u -r1.27 Makefile --- linux/drivers/media/dvb/frontends/Makefile 28 Jun 2005 16:37:18 -0000 1.27 +++ linux/drivers/media/dvb/frontends/Makefile 23 Jul 2005 07:50:41 -0000 @@ -31,3 +31,5 @@ obj-$(CONFIG_DVB_BCM3510) += bcm3510.o obj-$(CONFIG_DVB_S5H1420) += s5h1420.o obj-$(CONFIG_DVB_LGDT3302) += lgdt3302.o + +obj-$(CONFIG_DVB_TBMU24112) += tbmu24112.o Index: linux/drivers/media/dvb/frontends/at76c651.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/at76c651.c,v retrieving revision 1.29 diff -u -r1.29 at76c651.c --- linux/drivers/media/dvb/frontends/at76c651.c 5 Apr 2005 00:30:38 -0000 1.29 +++ linux/drivers/media/dvb/frontends/at76c651.c 23 Jul 2005 07:50:41 -0000 @@ -262,7 +262,7 @@ struct at76c651_state* state = fe->demodulator_priv; at76c651_writereg(state, 0x0c, 0xc3); - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); at76c651_writereg(state, 0x0c, 0xc2); if ((ret = at76c651_set_symbol_rate(state, p->u.qam.symbol_rate))) @@ -285,7 +285,7 @@ if (state->config->pll_init) { at76c651_writereg(state, 0x0c, 0xc3); - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); at76c651_writereg(state, 0x0c, 0xc2); } Index: linux/drivers/media/dvb/frontends/at76c651.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/at76c651.h,v retrieving revision 1.3 diff -u -r1.3 at76c651.h --- linux/drivers/media/dvb/frontends/at76c651.h 2 Mar 2005 21:42:00 -0000 1.3 +++ linux/drivers/media/dvb/frontends/at76c651.h 23 Jul 2005 07:50:41 -0000 @@ -37,8 +37,9 @@ u8 demod_address; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend* fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* at76c651_attach(const struct at76c651_config* config, Index: linux/drivers/media/dvb/frontends/bsbe1.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/bsbe1.c diff -N linux/drivers/media/dvb/frontends/bsbe1.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/bsbe1.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,137 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * Philips SAA7146 and Texas Instruments AV7110 + * + * See drivers/media/dvb/ttpci/av7110.c for copyright information. + */ +#include "bsbe1.h" +#include "stv0299.h" + +static const u8 alps_bsbe1_inittab[] = { + 0x01, 0x15, + 0x02, 0x30, + 0x03, 0x00, + 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ + 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ + 0x06, 0x40, /* DAC not used, set to high impendance mode */ + 0x07, 0x00, /* DAC LSB */ + 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ + 0x09, 0x00, /* FIFO */ + 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ + 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ + 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ + 0x10, 0x3f, /* AGC2 0x3d */ + 0x11, 0x84, + 0x12, 0xb5, /* Lock detect: -64 Carrier freq detect:on */ + 0x15, 0xc9, /* lock detector threshold */ + 0x16, 0x00, + 0x17, 0x00, + 0x18, 0x00, + 0x19, 0x00, + 0x1a, 0x00, + 0x1f, 0x50, + 0x20, 0x00, + 0x21, 0x00, + 0x22, 0x00, + 0x23, 0x00, + 0x28, 0x00, /* out imp: normal out type: parallel FEC mode:0 */ + 0x29, 0x1e, /* 1/2 threshold */ + 0x2a, 0x14, /* 2/3 threshold */ + 0x2b, 0x0f, /* 3/4 threshold */ + 0x2c, 0x09, /* 5/6 threshold */ + 0x2d, 0x05, /* 7/8 threshold */ + 0x2e, 0x01, + 0x31, 0x1f, /* test all FECs */ + 0x32, 0x19, /* viterbi and synchro search */ + 0x33, 0xfc, /* rs control */ + 0x34, 0x93, /* error control */ + 0x0f, 0x92, + 0xff, 0xff +}; + +static int alps_bsbe1_set_symbol_rate(struct dvb_frontend *fe, u32 srate, + u32 ratio) +{ + u8 aclk; + u8 bclk; + + if (srate < 1500000) { + aclk = 0xb7; + bclk = 0x47; + } else if (srate < 3000000) { + aclk = 0xb7; + bclk = 0x4b; + } else if (srate < 7000000) { + aclk = 0xb7; + bclk = 0x4f; + } else if (srate < 14000000) { + aclk = 0xb7; + bclk = 0x53; + } else if (srate < 30000000) { + aclk = 0xb6; + bclk = 0x53; + } else { + aclk = 0xb4; + bclk = 0x51; + } + + stv0299_writereg(fe, 0x13, aclk); + stv0299_writereg(fe, 0x14, bclk); + stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); + stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); + stv0299_writereg(fe, 0x21, (ratio) & 0xf0); + + return 0; +} + +static int alps_bsbe1_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 data[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = data, + .len = sizeof(data), + }; + + if ((p->frequency < 950000) || (p->frequency > 2150000)) + return -EINVAL; + + div = (p->frequency + (125 - 1)) / 125; // round correctly + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; + data[3] = (p->frequency > 1530000) ? 0xE0 : 0xE4; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct stv0299_config alps_bsbe1_config = { + .demod_address = 0x68, + .inittab = alps_bsbe1_inittab, + .mclk = 88000000UL, + .invert = 1, + .enhanced_tuning = 0, + .skip_reinit = 0, + .min_delay_ms = 100, + .set_symbol_rate = alps_bsbe1_set_symbol_rate, + .pll_set = alps_bsbe1_pll_set, +}; + +struct dvb_frontend *alps_bsbe1_attach(struct i2c_adapter *i2c) +{ + return stv0299_attach(&alps_bsbe1_config, i2c); +} + +EXPORT_SYMBOL(alps_bsbe1_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/bsbe1.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/bsbe1.h diff -N linux/drivers/media/dvb/frontends/bsbe1.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/bsbe1.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef BSBE1_H +#define BSBE1_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *alps_bsbe1_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/bsru6.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/bsru6.c diff -N linux/drivers/media/dvb/frontends/bsru6.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/bsru6.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,139 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * Philips SAA7146 and Texas Instruments AV7110 + * + * See drivers/media/dvb/ttpci/av7110.c for copyright information. + */ +#include "bsru6.h" +#include "stv0299.h" + +static const u8 alps_bsru6_inittab[] = { + 0x01, 0x15, + 0x02, 0x30, + 0x03, 0x00, + 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ + 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ + 0x06, 0x40, /* DAC not used, set to high impendance mode */ + 0x07, 0x00, /* DAC LSB */ + 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ + 0x09, 0x00, /* FIFO */ + 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ + 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ + 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ + 0x10, 0x3f, /* AGC2 0x3d */ + 0x11, 0x84, + 0x12, 0xb5, /* Lock detect: -64 Carrier freq detect:on */ + 0x15, 0xc9, /* lock detector threshold */ + 0x16, 0x00, + 0x17, 0x00, + 0x18, 0x00, + 0x19, 0x00, + 0x1a, 0x00, + 0x1f, 0x50, + 0x20, 0x00, + 0x21, 0x00, + 0x22, 0x00, + 0x23, 0x00, + 0x28, 0x00, /* out imp: normal out type: parallel FEC mode:0 */ + 0x29, 0x1e, /* 1/2 threshold */ + 0x2a, 0x14, /* 2/3 threshold */ + 0x2b, 0x0f, /* 3/4 threshold */ + 0x2c, 0x09, /* 5/6 threshold */ + 0x2d, 0x05, /* 7/8 threshold */ + 0x2e, 0x01, + 0x31, 0x1f, /* test all FECs */ + 0x32, 0x19, /* viterbi and synchro search */ + 0x33, 0xfc, /* rs control */ + 0x34, 0x93, /* error control */ + 0x0f, 0x52, + 0xff, 0xff +}; + +static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, + u32 ratio) +{ + u8 aclk; + u8 bclk; + + if (srate < 1500000) { + aclk = 0xb7; + bclk = 0x47; + } else if (srate < 3000000) { + aclk = 0xb7; + bclk = 0x4b; + } else if (srate < 7000000) { + aclk = 0xb7; + bclk = 0x4f; + } else if (srate < 14000000) { + aclk = 0xb7; + bclk = 0x53; + } else if (srate < 30000000) { + aclk = 0xb6; + bclk = 0x53; + } else { + aclk = 0xb4; + bclk = 0x51; + } + + stv0299_writereg(fe, 0x13, aclk); + stv0299_writereg(fe, 0x14, bclk); + stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); + stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); + stv0299_writereg(fe, 0x21, (ratio) & 0xf0); + + return 0; +} + +static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 data[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = data, + .len = sizeof(data), + }; + + if ((p->frequency < 950000) || (p->frequency > 2150000)) + return -EINVAL; + + div = (p->frequency + (125 - 1)) / 125; // round correctly + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; + data[3] = (p->frequency > 1530000) ? 0xc0 : 0xc4; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct stv0299_config alps_bsru6_config = { + .demod_address = 0x68, + .inittab = alps_bsru6_inittab, + .mclk = 88000000UL, + .invert = 1, + .enhanced_tuning = 0, + .skip_reinit = 0, + .lock_output = STV0229_LOCKOUTPUT_1, + .volt13_op0_op1 = STV0299_VOLT13_OP1, + .min_delay_ms = 100, + .set_symbol_rate = alps_bsru6_set_symbol_rate, + .pll_set = alps_bsru6_pll_set, +}; + +struct dvb_frontend *alps_bsru6_attach(struct i2c_adapter *i2c) +{ + return stv0299_attach(&alps_bsru6_config, i2c); +} + +EXPORT_SYMBOL(alps_bsru6_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/bsru6.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/bsru6.h diff -N linux/drivers/media/dvb/frontends/bsru6.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/bsru6.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef BSRU6_H +#define BSRU6_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *alps_bsru6_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/bsrv2.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/bsrv2.c diff -N linux/drivers/media/dvb/frontends/bsrv2.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/bsrv2.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,70 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * Philips SAA7146 and Texas Instruments AV7110 + * + * See drivers/media/dvb/ttpci/av7110.c for copyright information. + */ +#include "bsrv2.h" +#include "ves1x93.h" + +static int alps_bsrv2_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 pwr; + u8 buf[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = buf, + .len = sizeof(buf), + }; + + // NOTE: since we're using a prescaler of 2, we set the + // divisor frequency to 62.5kHz and divide by 125 + div = (p->frequency + 479500) / 125; + + if (p->frequency > 2000000) + pwr = 3; + else if (p->frequency > 1800000) + pwr = 2; + else if (p->frequency > 1600000) + pwr = 1; + else if (p->frequency > 1200000) + pwr = 0; + else if (p->frequency >= 1100000) + pwr = 1; + else + pwr = 2; + + buf[0] = (div >> 8) & 0x7f; + buf[1] = div & 0xff; + buf[2] = ((div & 0x18000) >> 10) | 0x95; + buf[3] = (pwr << 6) | 0x30; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct ves1x93_config alps_bsrv2_config = { + .demod_address = 0x08, + .xin = 90100000UL, + .invert_pwm = 0, + .pll_set = alps_bsrv2_pll_set, +}; + +struct dvb_frontend *alps_bsrv2_attach(struct i2c_adapter *i2c) +{ + return ves1x93_attach(&alps_bsrv2_config, i2c); +} + +EXPORT_SYMBOL(alps_bsrv2_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/bsrv2.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/bsrv2.h diff -N linux/drivers/media/dvb/frontends/bsrv2.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/bsrv2.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef BSRV2_H +#define BSRV2_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *alps_bsrv2_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/cd1516.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/cd1516.c diff -N linux/drivers/media/dvb/frontends/cd1516.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/cd1516.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,61 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * Philips SAA7146 and Texas Instruments AV7110 + * + * See drivers/media/dvb/ttpci/av7110.c for copyright information. + */ +#include "cd1516.h" +#include "ves1820.h" + +static int philips_cd1516_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u32 div; + u8 data[4]; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = data, + .len = sizeof(data), + }; + + div = (p->frequency + 36125000 + 31250) / 62500; + + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = 0x8e; + + if (p->frequency < 174000000) + data[3] = 0xa1; + else if (p->frequency < 470000000) + data[3] = 0x92; + else + data[3] = 0x34; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct ves1820_config philips_cd1516_config = { + .demod_address = 0x09, + .xin = 57840000UL, + .invert = 1, + .selagc = VES1820_SELAGC_SIGNAMPERR, + .pll_set = philips_cd1516_pll_set, +}; + +struct dvb_frontend *philips_cd1516_attach(struct i2c_adapter *i2c, u8 pwm) +{ + return ves1820_attach(&philips_cd1516_config, i2c, pwm); +} + +EXPORT_SYMBOL(philips_cd1516_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/cd1516.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/cd1516.h diff -N linux/drivers/media/dvb/frontends/cd1516.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/cd1516.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef CD1516_H +#define CD1516_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *philips_cd1516_attach(struct i2c_adapter *i2c, u8 pwm); + +#endif Index: linux/drivers/media/dvb/frontends/cu1216.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/cu1216.c diff -N linux/drivers/media/dvb/frontends/cu1216.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/cu1216.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,54 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * Philips SAA7146 + * + * See drivers/media/dvb/ttpci/budget-av.c for copyright information. + */ +#include "cu1216.h" +#include "tda10021.h" + +static int philips_cu1216_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 buf[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x60, + .flags = 0, + .buf = buf, + .len = sizeof(buf), + }; + +#define TUNER_MUL 62500 + div = (p->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL; + + buf[0] = (div >> 8) & 0x7f; + buf[1] = div & 0xff; + buf[2] = 0x86; + buf[3] = (p->frequency < 150000000 ? 0x01 : + p->frequency < 445000000 ? 0x02 : 0x04); + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static struct tda10021_config philips_cu1216_config = { + .demod_address = 0x0c, + .pll_set = philips_cu1216_pll_set, +}; + +struct dvb_frontend *philips_cu1216_attach(struct i2c_adapter *i2c, u8 pwm) +{ + return tda10021_attach(&philips_cu1216_config, i2c, pwm); +} + +EXPORT_SYMBOL(philips_cu1216_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/cu1216.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/cu1216.h diff -N linux/drivers/media/dvb/frontends/cu1216.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/cu1216.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef CU1216_H +#define CU1216_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *philips_cu1216_attach(struct i2c_adapter *i2c, u8 pwm); + +#endif Index: linux/drivers/media/dvb/frontends/cx22700.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/cx22700.c,v retrieving revision 1.6 diff -u -r1.6 cx22700.c --- linux/drivers/media/dvb/frontends/cx22700.c 5 Apr 2005 00:30:38 -0000 1.6 +++ linux/drivers/media/dvb/frontends/cx22700.c 23 Jul 2005 07:50:41 -0000 @@ -249,7 +249,7 @@ if (state->config->pll_init) { cx22700_writereg (state, 0x0a, 0x00); /* open i2c bus switch */ - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); cx22700_writereg (state, 0x0a, 0x01); /* close i2c bus switch */ } @@ -334,7 +334,7 @@ cx22700_writereg (state, 0x00, 0x00); cx22700_writereg (state, 0x0a, 0x00); /* open i2c bus switch */ - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); cx22700_writereg (state, 0x0a, 0x01); /* close i2c bus switch */ cx22700_set_inversion (state, p->inversion); cx22700_set_tps (state, &p->u.ofdm); Index: linux/drivers/media/dvb/frontends/cx22700.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/cx22700.h,v retrieving revision 1.2 diff -u -r1.2 cx22700.h --- linux/drivers/media/dvb/frontends/cx22700.h 28 Oct 2004 17:37:07 -0000 1.2 +++ linux/drivers/media/dvb/frontends/cx22700.h 23 Jul 2005 07:50:41 -0000 @@ -31,8 +31,9 @@ u8 demod_address; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters* p); }; extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, Index: linux/drivers/media/dvb/frontends/g29504-401.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/g29504-401.c diff -N linux/drivers/media/dvb/frontends/g29504-401.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/g29504-401.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,68 @@ +/* + * av7110 + */ +#include "g29504-401.h" +#include "l64781.h" + +static int grundig_29504_401_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 data[4]; + u32 div; + int ret; + u8 cpump, band_select; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = data, + .len = sizeof(data), + }; + + div = (p->frequency + 36125000) / 166666; + + if (p->frequency < 175000000) + cpump = 2; + else if (p->frequency < 390000000) + cpump = 1; + else if (p->frequency < 470000000) + cpump = 2; + else if (p->frequency < 750000000) + cpump = 1; + else + cpump = 3; + + if (p->frequency < 175000000) + band_select = 0x0e; + else if (p->frequency < 470000000) + band_select = 0x05; + else + band_select = 0x03; + + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = ((div >> 10) & 0x60) | 0x88; + data[3] = (cpump << 6) | band_select; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct l64781_config grundig_29504_401_config = { + .demod_address = 0x55, + .pll_set = grundig_29504_401_pll_set, +}; + +struct dvb_frontend *grundig_29504_401_attach(struct i2c_adapter *i2c) +{ + return l64781_attach(&grundig_29504_401_config, i2c); +} + +EXPORT_SYMBOL(grundig_29504_401_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/g29504-401.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/g29504-401.h diff -N linux/drivers/media/dvb/frontends/g29504-401.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/g29504-401.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef G29504_401_H +#define G29504_401_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *grundig_29504_401_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/g29504-451.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/g29504-451.c diff -N linux/drivers/media/dvb/frontends/g29504-451.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/g29504-451.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,51 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * Philips SAA7146 and Texas Instruments AV7110 + * + * See drivers/media/dvb/ttpci/av7110.c for copyright information. + */ +#include "g29504-451.h" +#include "tda8083.h" + +static int grundig_29504_451_pll_set(struct dvb_frontend* fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters* p) +{ + u32 div; + u8 data[4]; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = data, + .len = sizeof(data), + }; + + div = p->frequency / 125; + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = 0x8e; + data[3] = 0x00; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct tda8083_config grundig_29504_451_config = { + .demod_address = 0x68, + .pll_set = grundig_29504_451_pll_set, +}; + +struct dvb_frontend *grundig_29504_451_attach(struct i2c_adapter *i2c) +{ + return tda8083_attach(&grundig_29504_451_config, i2c); +} + +EXPORT_SYMBOL(grundig_29504_451_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/g29504-451.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/g29504-451.h diff -N linux/drivers/media/dvb/frontends/g29504-451.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/g29504-451.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef G29504_451_H +#define G29504_451_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *grundig_29504_451_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/l64781.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/l64781.c,v retrieving revision 1.8 diff -u -r1.8 l64781.c --- linux/drivers/media/dvb/frontends/l64781.c 6 Jun 2005 14:06:16 -0000 1.8 +++ linux/drivers/media/dvb/frontends/l64781.c 23 Jul 2005 07:50:41 -0000 @@ -141,7 +141,7 @@ u8 val0x06; int bw = p->bandwidth - BANDWIDTH_8_MHZ; - state->config->pll_set(fe, param); + state->config->pll_set(fe, state->i2c, param); if (param->inversion != INVERSION_ON && param->inversion != INVERSION_OFF) @@ -463,7 +463,8 @@ /* Everything is two's complement, soft bit and CSI_OUT too */ l64781_writereg (state, 0x1e, 0x09); - if (state->config->pll_init) state->config->pll_init(fe); + if (state->config->pll_init) + state->config->pll_init(fe, state->i2c); /* delay a bit after first init attempt */ if (state->first) { Index: linux/drivers/media/dvb/frontends/l64781.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/l64781.h,v retrieving revision 1.3 diff -u -r1.3 l64781.h --- linux/drivers/media/dvb/frontends/l64781.h 10 Feb 2005 07:50:42 -0000 1.3 +++ linux/drivers/media/dvb/frontends/l64781.h 23 Jul 2005 07:50:41 -0000 @@ -31,8 +31,9 @@ u8 demod_address; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; Index: linux/drivers/media/dvb/frontends/mt312.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/mt312.c,v retrieving revision 1.23 diff -u -r1.23 mt312.c --- linux/drivers/media/dvb/frontends/mt312.c 5 Apr 2005 00:30:38 -0000 1.23 +++ linux/drivers/media/dvb/frontends/mt312.c 23 Jul 2005 07:50:41 -0000 @@ -277,7 +277,7 @@ if (state->config->pll_init) { mt312_writereg(state, GPP_CTRL, 0x40); - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); mt312_writereg(state, GPP_CTRL, 0x00); } @@ -527,7 +527,7 @@ } mt312_writereg(state, GPP_CTRL, 0x40); - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); mt312_writereg(state, GPP_CTRL, 0x00); /* sr = (u16)(sr * 256.0 / 1000000.0) */ Index: linux/drivers/media/dvb/frontends/mt312.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/mt312.h,v retrieving revision 1.7 diff -u -r1.7 mt312.h --- linux/drivers/media/dvb/frontends/mt312.h 19 Nov 2004 00:00:40 -0000 1.7 +++ linux/drivers/media/dvb/frontends/mt312.h 23 Jul 2005 07:50:41 -0000 @@ -34,8 +34,9 @@ u8 demod_address; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* mt312_attach(const struct mt312_config* config, Index: linux/drivers/media/dvb/frontends/nxt6000.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/nxt6000.c,v retrieving revision 1.27 diff -u -r1.27 nxt6000.c --- linux/drivers/media/dvb/frontends/nxt6000.c 5 Apr 2005 00:30:39 -0000 1.27 +++ linux/drivers/media/dvb/frontends/nxt6000.c 23 Jul 2005 07:50:41 -0000 @@ -210,7 +210,7 @@ if (state->config->pll_init) { nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01); /* open i2c bus switch */ - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x00); /* close i2c bus switch */ } } @@ -470,7 +470,7 @@ int result; nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01); /* open i2c bus switch */ - state->config->pll_set(fe, param); + state->config->pll_set(fe, state->i2c, param); nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x00); /* close i2c bus switch */ if ((result = nxt6000_set_bandwidth(state, param->u.ofdm.bandwidth)) < 0) Index: linux/drivers/media/dvb/frontends/nxt6000.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/nxt6000.h,v retrieving revision 1.4 diff -u -r1.4 nxt6000.h --- linux/drivers/media/dvb/frontends/nxt6000.h 28 Oct 2004 17:37:08 -0000 1.4 +++ linux/drivers/media/dvb/frontends/nxt6000.h 23 Jul 2005 07:50:41 -0000 @@ -33,8 +33,9 @@ u8 clock_inversion:1; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, Index: linux/drivers/media/dvb/frontends/stv0299.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/stv0299.h,v retrieving revision 1.3 diff -u -r1.3 stv0299.h --- linux/drivers/media/dvb/frontends/stv0299.h 16 Jul 2005 22:42:53 -0000 1.3 +++ linux/drivers/media/dvb/frontends/stv0299.h 23 Jul 2005 07:50:41 -0000 @@ -65,7 +65,7 @@ * First of each pair is the register, second is the value. * List should be terminated with an 0xff, 0xff pair. */ - u8* inittab; + const u8* inittab; /* master clock to use */ u32 mclk; Index: linux/drivers/media/dvb/frontends/tbdu18132.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/tbdu18132.c diff -N linux/drivers/media/dvb/frontends/tbdu18132.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tbdu18132.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,55 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * B2C2 FlexcopII(b)/III + * + * See drivers/media/dvb/b2c2/flexcop.c for copyright information. + */ +#include "tbdu18132.h" +#include "mt312.h" + +static int samsung_tbdu18132_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 buf[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = buf, + .len = sizeof(buf), + }; + + div = (p->frequency + (125 / 2)) / 125; + + buf[0] = (div >> 8) & 0x7f; + buf[1] = (div >> 0) & 0xff; + buf[2] = 0x84 | ((div >> 10) & 0x60); + buf[3] = 0x80; + + if (p->frequency < 1550000) + buf[3] |= 0x02; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct mt312_config samsung_tbdu18132_config = { + .demod_address = 0x0e, + .pll_set = samsung_tbdu18132_pll_set, +}; + +struct dvb_frontend *samsung_tbdu18132_attach(struct i2c_adapter *i2c) +{ + return vp310_attach(&samsung_tbdu18132_config, i2c); +} + +EXPORT_SYMBOL(samsung_tbdu18132_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/tbdu18132.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/tbdu18132.h diff -N linux/drivers/media/dvb/frontends/tbdu18132.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tbdu18132.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef TBDU18132_H +#define TBDU18132_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *samsung_tbdu18132_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/tbmu24112.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/tbmu24112.c diff -N linux/drivers/media/dvb/frontends/tbmu24112.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tbmu24112.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,144 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * B2C2 FlexcopII(b)/III + * + * See drivers/media/dvb/b2c2/flexcop.c for copyright information. + */ +#include "tbmu24112.h" +#include "stv0299.h" + +static const u8 samsung_tbmu24112_inittab[] = { + 0x01, 0x15, + 0x02, 0x30, + 0x03, 0x00, + 0x04, 0x7D, + 0x05, 0x35, + 0x06, 0x02, + 0x07, 0x00, + 0x08, 0xC3, + 0x0C, 0x00, + 0x0D, 0x81, + 0x0E, 0x23, + 0x0F, 0x12, + 0x10, 0x7E, + 0x11, 0x84, + 0x12, 0xB9, + 0x13, 0x88, + 0x14, 0x89, + 0x15, 0xC9, + 0x16, 0x00, + 0x17, 0x5C, + 0x18, 0x00, + 0x19, 0x00, + 0x1A, 0x00, + 0x1C, 0x00, + 0x1D, 0x00, + 0x1E, 0x00, + 0x1F, 0x3A, + 0x20, 0x2E, + 0x21, 0x80, + 0x22, 0xFF, + 0x23, 0xC1, + 0x28, 0x00, + 0x29, 0x1E, + 0x2A, 0x14, + 0x2B, 0x0F, + 0x2C, 0x09, + 0x2D, 0x05, + 0x31, 0x1F, + 0x32, 0x19, + 0x33, 0xFE, + 0x34, 0x93, + 0xff, 0xff, +}; + +static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend *fe, + u32 srate, u32 ratio) +{ + u8 aclk; + u8 bclk; + + if (srate < 1500000) { + aclk = 0xb7; + bclk = 0x47; + } else if (srate < 3000000) { + aclk = 0xb7; + bclk = 0x4b; + } else if (srate < 7000000) { + aclk = 0xb7; + bclk = 0x4f; + } else if (srate < 14000000) { + aclk = 0xb7; + bclk = 0x53; + } else if (srate < 30000000) { + aclk = 0xb6; + bclk = 0x53; + } else { + aclk = 0xb4; + bclk = 0x51; + } + + stv0299_writereg(fe, 0x13, aclk); + stv0299_writereg(fe, 0x14, bclk); + stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); + stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); + stv0299_writereg(fe, 0x21, (ratio) & 0xf0); + + return 0; +} + +static int samsung_tbmu24112_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 buf[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = buf, + .len = sizeof(buf), + }; + + div = p->frequency / 125; + + buf[0] = (div >> 8) & 0x7f; + buf[1] = (div) & 0xff; + buf[2] = 0x84; /* 0xC4 */ + buf[3] = 0x08; + + if (p->frequency < 1500000) + buf[3] |= 0x10; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct stv0299_config samsung_tbmu24112_config = { + .demod_address = 0x68, + .inittab = samsung_tbmu24112_inittab, + .mclk = 88000000UL, + .invert = 0, + .enhanced_tuning = 0, + .skip_reinit = 0, + .lock_output = STV0229_LOCKOUTPUT_LK, + .volt13_op0_op1 = STV0299_VOLT13_OP1, + .min_delay_ms = 100, + .set_symbol_rate = samsung_tbmu24112_set_symbol_rate, + .pll_set = samsung_tbmu24112_pll_set, +}; + +struct dvb_frontend *samsung_tbmu24112_attach(struct i2c_adapter *i2c) +{ + return stv0299_attach(&samsung_tbmu24112_config, i2c); +} + +EXPORT_SYMBOL(samsung_tbmu24112_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/tbmu24112.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/tbmu24112.h diff -N linux/drivers/media/dvb/frontends/tbmu24112.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tbmu24112.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef TBMU24112_H +#define TBMU24112_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *samsung_tbmu24112_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/tda10021.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/tda10021.c,v retrieving revision 1.9 diff -u -r1.9 tda10021.c --- linux/drivers/media/dvb/frontends/tda10021.c 5 Apr 2005 00:30:39 -0000 1.9 +++ linux/drivers/media/dvb/frontends/tda10021.c 23 Jul 2005 07:50:41 -0000 @@ -228,7 +228,7 @@ if (state->config->pll_init) { lock_tuner(state); - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); unlock_tuner(state); } @@ -260,7 +260,7 @@ //printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate); lock_tuner(state); - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); unlock_tuner(state); tda10021_set_symbolrate (state, p->u.qam.symbol_rate); Index: linux/drivers/media/dvb/frontends/tda10021.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/tda10021.h,v retrieving revision 1.4 diff -u -r1.4 tda10021.h --- linux/drivers/media/dvb/frontends/tda10021.h 2 Mar 2005 21:42:01 -0000 1.4 +++ linux/drivers/media/dvb/frontends/tda10021.h 23 Jul 2005 07:50:41 -0000 @@ -32,8 +32,9 @@ u8 demod_address; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config, Index: linux/drivers/media/dvb/frontends/tda8083.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/tda8083.c,v retrieving revision 1.5 diff -u -r1.5 tda8083.c --- linux/drivers/media/dvb/frontends/tda8083.c 5 Apr 2005 00:30:39 -0000 1.5 +++ linux/drivers/media/dvb/frontends/tda8083.c 23 Jul 2005 07:50:41 -0000 @@ -292,7 +292,7 @@ { struct tda8083_state* state = fe->demodulator_priv; - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); tda8083_set_inversion (state, p->inversion); tda8083_set_fec (state, p->u.qpsk.fec_inner); tda8083_set_symbolrate (state, p->u.qpsk.symbol_rate); @@ -333,7 +333,8 @@ for (i=0; i<44; i++) tda8083_writereg (state, i, tda8083_init_tab[i]); - if (state->config->pll_init) state->config->pll_init(fe); + if (state->config->pll_init) + state->config->pll_init(fe, state->i2c); tda8083_writereg (state, 0x00, 0x3c); tda8083_writereg (state, 0x00, 0x04); Index: linux/drivers/media/dvb/frontends/tda8083.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/tda8083.h,v retrieving revision 1.2 diff -u -r1.2 tda8083.h --- linux/drivers/media/dvb/frontends/tda8083.h 28 Oct 2004 17:37:08 -0000 1.2 +++ linux/drivers/media/dvb/frontends/tda8083.h 23 Jul 2005 07:50:41 -0000 @@ -35,8 +35,9 @@ u8 demod_address; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, Index: linux/drivers/media/dvb/frontends/tda80xx.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/tda80xx.c,v retrieving revision 1.6 diff -u -r1.6 tda80xx.c --- linux/drivers/media/dvb/frontends/tda80xx.c 5 Apr 2005 00:30:39 -0000 1.6 +++ linux/drivers/media/dvb/frontends/tda80xx.c 23 Jul 2005 07:50:41 -0000 @@ -423,7 +423,7 @@ if (state->config->pll_init) { tda80xx_writereg(state, 0x1c, 0x80); - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); tda80xx_writereg(state, 0x1c, 0x00); } @@ -438,7 +438,7 @@ if (state->config->pll_init) { tda80xx_writereg(state, 0x1c, 0x80); - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); tda80xx_writereg(state, 0x1c, 0x00); } @@ -524,7 +524,7 @@ struct tda80xx_state* state = fe->demodulator_priv; tda80xx_writereg(state, 0x1c, 0x80); - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); tda80xx_writereg(state, 0x1c, 0x00); tda80xx_set_parameters(state, p->inversion, p->u.qpsk.symbol_rate, p->u.qpsk.fec_inner); Index: linux/drivers/media/dvb/frontends/tda80xx.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/tda80xx.h,v retrieving revision 1.2 diff -u -r1.2 tda80xx.h --- linux/drivers/media/dvb/frontends/tda80xx.h 28 Oct 2004 17:37:08 -0000 1.2 +++ linux/drivers/media/dvb/frontends/tda80xx.h 23 Jul 2005 07:50:41 -0000 @@ -41,8 +41,9 @@ u8 volt18setting; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config, Index: linux/drivers/media/dvb/frontends/tdbe2.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/tdbe2.c diff -N linux/drivers/media/dvb/frontends/tdbe2.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tdbe2.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,61 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * Philips SAA7146 and Texas Instruments AV7110 + * + * See drivers/media/dvb/ttpci/av7110.c for copyright information. + */ +#include "tdbe2.h" +#include "ves1820.h" + +static int alps_tdbe2_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u32 div; + u8 data[4]; + int ret; + struct i2c_msg msg = { + .addr = 0x62, + .flags = 0, + .buf = data, + .len = sizeof(data), + }; + + div = (p->frequency + 35937500 + 31250) / 62500; + + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = 0x85 | ((div >> 10) & 0x60); + + if (p->frequency < 174000000) + data[3] = 0x88; + else if (p->frequency < 470000000) + data[3] = 0x84; + else + data[3] = 0x81; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct ves1820_config alps_tdbe2_config = { + .demod_address = 0x09, + .xin = 57840000UL, + .invert = 1, + .selagc = VES1820_SELAGC_SIGNAMPERR, + .pll_set = alps_tdbe2_pll_set, +}; + +struct dvb_frontend *alps_tdbe2_attach(struct i2c_adapter *i2c, u8 pwm) +{ + return ves1820_attach(&alps_tdbe2_config, i2c, pwm); +} + +EXPORT_SYMBOL(alps_tdbe2_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/tdbe2.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/tdbe2.h diff -N linux/drivers/media/dvb/frontends/tdbe2.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tdbe2.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef TDBE2_H +#define TDBE2_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *alps_tdbe2_attach(struct i2c_adapter *i2c, u8 pwm); + +#endif Index: linux/drivers/media/dvb/frontends/tded4.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/tded4.c diff -N linux/drivers/media/dvb/frontends/tded4.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tded4.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,60 @@ +/* + * dvb-bt8xx.c + */ +#include "tded4.h" +#include "nxt6000.h" + +static int alps_tded4_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 buf[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x60, + .flags = 0, + .buf = buf, + .len = sizeof(buf), + }; + + if ((p->frequency < 47000000) || (p->frequency > 863000000)) + return -EINVAL; + + div = (p->frequency + 36166667) / 166667; + + buf[0] = (div >> 8) & 0x7F; + buf[1] = div & 0xFF; + buf[2] = 0x85; + + if (p->frequency < 153000000) + buf[3] = 0x01; + else if (p->frequency < 430000000) + buf[3] = 0x02; + else if (p->frequency < 824000000) + buf[3] = 0x0C; + else + buf[3] = 0x8C; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct nxt6000_config alps_tded4_config = { + .demod_address = 0x0a, + .clock_inversion = 1, + .pll_set = alps_tded4_pll_set, +}; + +struct dvb_frontend *alps_tded4_attach(struct i2c_adapter *i2c) +{ + return nxt6000_attach(&alps_tded4_config, i2c); +} + +EXPORT_SYMBOL(alps_tded4_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/tded4.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/tded4.h diff -N linux/drivers/media/dvb/frontends/tded4.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tded4.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef TDED4_H +#define TDED4_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *alps_tded4_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/tdmb7.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/tdmb7.c diff -N linux/drivers/media/dvb/frontends/tdmb7.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tdmb7.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,49 @@ +/* + * dvb-ttusb-budget.c + */ +#include "tdmb7.h" +#include "cx22700.h" + +static int alps_tdmb7_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p) +{ + u8 data[4]; + u32 div; + int ret; + struct i2c_msg msg = { + .addr = 0x61, + .flags = 0, + .buf = data, + .len = sizeof(data), + }; + + div = (p->frequency + 36166667) / 166667; + + data[0] = (div >> 8) & 0x7f; + data[1] = div & 0xff; + data[2] = ((div >> 10) & 0x60) | 0x85; + data[3] = p->frequency < 592000000 ? 0x40 : 0x80; + + ret = i2c_transfer(i2c, &msg, 1); + if (ret < 0) + return ret; + else if (ret != 1) + return -EREMOTEIO; + + return 0; +} + +static const struct cx22700_config alps_tdmb7_config = { + .demod_address = 0x43, + .pll_set = alps_tdmb7_pll_set, +}; + +struct dvb_frontend *alps_tdmb7_attach(struct i2c_adapter *i2c) +{ + return cx22700_attach(&alps_tdmb7_config, i2c); +} + +EXPORT_SYMBOL(alps_tdmb7_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/tdmb7.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/tdmb7.h diff -N linux/drivers/media/dvb/frontends/tdmb7.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tdmb7.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef TDMB7_H +#define TDMB7_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *alps_tdmb7_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/tdtc9251dh0.c =================================================================== RCS file: linux/drivers/media/dvb/frontends/tdtc9251dh0.c diff -N linux/drivers/media/dvb/frontends/tdtc9251dh0.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tdtc9251dh0.c 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,68 @@ +/* + * This file is part of the linux driver for digital TV devices based on + * B2C2 FlexcopII(b)/III + * + * See drivers/media/dvb/b2c2/flexcop.c for copyright information. + */ +#include "tdtc9251dh0.h" +#include "mt352.h" + +static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend *fe) +{ + static u8 mt352_clock_config[] = { 0x89, 0x18, 0x2d }; + static u8 mt352_reset[] = { 0x50, 0x80 }; + static u8 mt352_adc_ctl_1_cfg[] = { 0x8E, 0x40 }; + static u8 mt352_agc_cfg[] = { 0x67, 0x28, 0xa1 }; + static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; + + mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); + mdelay(2); + mt352_write(fe, mt352_reset, sizeof(mt352_reset)); + mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); + + mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg)); + mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg)); + + return 0; +} + +static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend *fe, + struct dvb_frontend_parameters *p, + u8 *pllbuf) +{ + u32 div; + unsigned char bs = 0; + +#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ + div = (((p->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; + + if (p->frequency >= 48000000 && p->frequency <= 154000000) + bs = 0x09; + if (p->frequency >= 161000000 && p->frequency <= 439000000) + bs = 0x0a; + if (p->frequency >= 447000000 && p->frequency <= 863000000) + bs = 0x08; + + pllbuf[0] = 0xc2; /* Note: non-linux standard PLL i2c address */ + pllbuf[1] = div >> 8; + pllbuf[2] = div & 0xff; + pllbuf[3] = 0xcc; + pllbuf[4] = bs; + + return 0; +} + +static const struct mt352_config samsung_tdtc9251dh0_config = { + .demod_address = 0x0f, + .demod_init = samsung_tdtc9251dh0_demod_init, + .pll_set = samsung_tdtc9251dh0_pll_set, +}; + +struct dvb_frontend *samsung_tdtc9251dh0_attach(struct i2c_adapter *i2c) +{ + return mt352_attach(&samsung_tdtc9251dh0_config, i2c); +} + +EXPORT_SYMBOL(samsung_tdtc9251dh0_attach); + +MODULE_LICENSE("GPL"); Index: linux/drivers/media/dvb/frontends/tdtc9251dh0.h =================================================================== RCS file: linux/drivers/media/dvb/frontends/tdtc9251dh0.h diff -N linux/drivers/media/dvb/frontends/tdtc9251dh0.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drivers/media/dvb/frontends/tdtc9251dh0.h 23 Jul 2005 07:50:41 -0000 @@ -0,0 +1,9 @@ +#ifndef TDTC9251DH0_H +#define TDTC9251DH0_H + +#include +#include "dvb_frontend.h" + +struct dvb_frontend *samsung_tdtc9251dh0_attach(struct i2c_adapter *i2c); + +#endif Index: linux/drivers/media/dvb/frontends/ves1820.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/ves1820.c,v retrieving revision 1.56 diff -u -r1.56 ves1820.c --- linux/drivers/media/dvb/frontends/ves1820.c 7 Apr 2005 20:16:46 -0000 1.56 +++ linux/drivers/media/dvb/frontends/ves1820.c 23 Jul 2005 07:50:41 -0000 @@ -206,7 +206,8 @@ ves1820_writereg(state, 0x34, state->pwm); - if (state->config->pll_init) state->config->pll_init(fe); + if (state->config->pll_init) + state->config->pll_init(fe, state->i2c); return 0; } @@ -224,7 +225,7 @@ if (real_qam < 0 || real_qam > 4) return -EINVAL; - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); ves1820_set_symbolrate(state, p->u.qam.symbol_rate); ves1820_writereg(state, 0x34, state->pwm); Index: linux/drivers/media/dvb/frontends/ves1820.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/ves1820.h,v retrieving revision 1.3 diff -u -r1.3 ves1820.h --- linux/drivers/media/dvb/frontends/ves1820.h 2 Mar 2005 21:42:01 -0000 1.3 +++ linux/drivers/media/dvb/frontends/ves1820.h 23 Jul 2005 07:50:41 -0000 @@ -41,8 +41,9 @@ u8 selagc:1; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, Index: linux/drivers/media/dvb/frontends/ves1x93.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/ves1x93.c,v retrieving revision 1.26 diff -u -r1.26 ves1x93.c --- linux/drivers/media/dvb/frontends/ves1x93.c 5 Apr 2005 00:30:39 -0000 1.26 +++ linux/drivers/media/dvb/frontends/ves1x93.c 23 Jul 2005 07:50:41 -0000 @@ -280,7 +280,7 @@ if (state->config->pll_init) { ves1x93_writereg(state, 0x00, 0x11); - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); ves1x93_writereg(state, 0x00, 0x01); } @@ -396,7 +396,7 @@ struct ves1x93_state* state = fe->demodulator_priv; ves1x93_writereg(state, 0x00, 0x11); - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); ves1x93_writereg(state, 0x00, 0x01); ves1x93_set_inversion (state, p->inversion); ves1x93_set_fec (state, p->u.qpsk.fec_inner); Index: linux/drivers/media/dvb/frontends/ves1x93.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/ves1x93.h,v retrieving revision 1.2 diff -u -r1.2 ves1x93.h --- linux/drivers/media/dvb/frontends/ves1x93.h 28 Oct 2004 17:37:08 -0000 1.2 +++ linux/drivers/media/dvb/frontends/ves1x93.h 23 Jul 2005 07:50:41 -0000 @@ -40,8 +40,9 @@ u8 invert_pwm:1; /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, + struct dvb_frontend_parameters *p); }; extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, Index: linux/drivers/media/dvb/ttpci/av7110.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/av7110.c,v retrieving revision 1.185 diff -u -r1.185 av7110.c --- linux/drivers/media/dvb/ttpci/av7110.c 16 Jul 2005 22:42:53 -0000 1.185 +++ linux/drivers/media/dvb/ttpci/av7110.c 23 Jul 2005 07:50:41 -0000 @@ -1568,220 +1568,6 @@ } #endif - -static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; - u8 pwr = 0; - u8 buf[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; - u32 div = (params->frequency + 479500) / 125; - - if (params->frequency > 2000000) pwr = 3; - else if (params->frequency > 1800000) pwr = 2; - else if (params->frequency > 1600000) pwr = 1; - else if (params->frequency > 1200000) pwr = 0; - else if (params->frequency >= 1100000) pwr = 1; - else pwr = 2; - - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = ((div & 0x18000) >> 10) | 0x95; - buf[3] = (pwr << 6) | 0x30; - - // NOTE: since we're using a prescaler of 2, we set the - // divisor frequency to 62.5kHz and divide by 125 above - - if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) - return -EIO; - return 0; -} - -static struct ves1x93_config alps_bsrv2_config = { - .demod_address = 0x08, - .xin = 90100000UL, - .invert_pwm = 0, - .pll_set = alps_bsrv2_pll_set, -}; - - -static u8 alps_bsru6_inittab[] = { - 0x01, 0x15, - 0x02, 0x30, - 0x03, 0x00, - 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ - 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ - 0x06, 0x40, /* DAC not used, set to high impendance mode */ - 0x07, 0x00, /* DAC LSB */ - 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ - 0x09, 0x00, /* FIFO */ - 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ - 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ - 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ - 0x10, 0x3f, // AGC2 0x3d - 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on - 0x15, 0xc9, // lock detector threshold - 0x16, 0x00, - 0x17, 0x00, - 0x18, 0x00, - 0x19, 0x00, - 0x1a, 0x00, - 0x1f, 0x50, - 0x20, 0x00, - 0x21, 0x00, - 0x22, 0x00, - 0x23, 0x00, - 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 - 0x29, 0x1e, // 1/2 threshold - 0x2a, 0x14, // 2/3 threshold - 0x2b, 0x0f, // 3/4 threshold - 0x2c, 0x09, // 5/6 threshold - 0x2d, 0x05, // 7/8 threshold - 0x2e, 0x01, - 0x31, 0x1f, // test all FECs - 0x32, 0x19, // viterbi and synchro search - 0x33, 0xfc, // rs control - 0x34, 0x93, // error control - 0x0f, 0x52, - 0xff, 0xff -}; - -static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio) -{ - u8 aclk = 0; - u8 bclk = 0; - - if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; } - else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; } - else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; } - else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; } - else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; } - else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; } - - stv0299_writereg(fe, 0x13, aclk); - stv0299_writereg(fe, 0x14, bclk); - stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); - stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); - stv0299_writereg(fe, 0x21, (ratio ) & 0xf0); - - return 0; -} - -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) -{ - int ret; - u8 data[4]; - u32 div; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - if ((params->frequency < 950000) || (params->frequency > 2150000)) - return -EINVAL; - - div = (params->frequency + (125 - 1)) / 125; // round correctly - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; - data[3] = 0xC4; - - if (params->frequency > 1530000) data[3] = 0xc0; - - ret = i2c_transfer(i2c, &msg, 1); - if (ret != 1) - return -EIO; - return 0; -} - -static struct stv0299_config alps_bsru6_config = { - - .demod_address = 0x68, - .inittab = alps_bsru6_inittab, - .mclk = 88000000UL, - .invert = 1, - .enhanced_tuning = 0, - .skip_reinit = 0, - .lock_output = STV0229_LOCKOUTPUT_1, - .volt13_op0_op1 = STV0299_VOLT13_OP1, - .min_delay_ms = 100, - .set_symbol_rate = alps_bsru6_set_symbol_rate, - .pll_set = alps_bsru6_pll_set, -}; - - -static u8 alps_bsbe1_inittab[] = { - 0x01, 0x15, - 0x02, 0x30, - 0x03, 0x00, - 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ - 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ - 0x06, 0x40, /* DAC not used, set to high impendance mode */ - 0x07, 0x00, /* DAC LSB */ - 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ - 0x09, 0x00, /* FIFO */ - 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ - 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ - 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ - 0x10, 0x3f, // AGC2 0x3d - 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on - 0x15, 0xc9, // lock detector threshold - 0x16, 0x00, - 0x17, 0x00, - 0x18, 0x00, - 0x19, 0x00, - 0x1a, 0x00, - 0x1f, 0x50, - 0x20, 0x00, - 0x21, 0x00, - 0x22, 0x00, - 0x23, 0x00, - 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 - 0x29, 0x1e, // 1/2 threshold - 0x2a, 0x14, // 2/3 threshold - 0x2b, 0x0f, // 3/4 threshold - 0x2c, 0x09, // 5/6 threshold - 0x2d, 0x05, // 7/8 threshold - 0x2e, 0x01, - 0x31, 0x1f, // test all FECs - 0x32, 0x19, // viterbi and synchro search - 0x33, 0xfc, // rs control - 0x34, 0x93, // error control - 0x0f, 0x92, - 0xff, 0xff -}; - -static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) -{ - int ret; - u8 data[4]; - u32 div; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - if ((params->frequency < 950000) || (params->frequency > 2150000)) - return -EINVAL; - - div = (params->frequency + (125 - 1)) / 125; // round correctly - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; - data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; - - ret = i2c_transfer(i2c, &msg, 1); - return (ret != 1) ? -EIO : 0; -} - -static struct stv0299_config alps_bsbe1_config = { - .demod_address = 0x68, - .inittab = alps_bsbe1_inittab, - .mclk = 88000000UL, - .invert = 1, - .enhanced_tuning = 0, - .skip_reinit = 0, - .min_delay_ms = 100, - .set_symbol_rate = alps_bsru6_set_symbol_rate, - .pll_set = alps_bsbe1_pll_set, -}; - static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) { struct av7110* av7110 = (struct av7110*) fe->dvb->priv; @@ -1807,94 +1593,6 @@ return (ret != 1) ? -EIO : 0; } - -static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct av7110* av7110 = fe->dvb->priv; - u32 div; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = (params->frequency + 35937500 + 31250) / 62500; - - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x85 | ((div >> 10) & 0x60); - data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81); - - if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1) - return -EIO; - return 0; -} - -static struct ves1820_config alps_tdbe2_config = { - .demod_address = 0x09, - .xin = 57840000UL, - .invert = 1, - .selagc = VES1820_SELAGC_SIGNAMPERR, - .pll_set = alps_tdbe2_pll_set, -}; - - - - -static int grundig_29504_451_pll_set(struct dvb_frontend* fe, - struct dvb_frontend_parameters* params) -{ - struct av7110* av7110 = fe->dvb->priv; - u32 div; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = params->frequency / 125; - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x8e; - data[3] = 0x00; - - if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1) - return -EIO; - return 0; -} - -static struct tda8083_config grundig_29504_451_config = { - .demod_address = 0x68, - .pll_set = grundig_29504_451_pll_set, -}; - - - -static int philips_cd1516_pll_set(struct dvb_frontend* fe, - struct dvb_frontend_parameters* params) -{ - struct av7110* av7110 = fe->dvb->priv; - u32 div; - u32 f = params->frequency; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = (f + 36125000 + 31250) / 62500; - - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x8e; - data[3] = (f < 174000000 ? 0xa1 : f < 470000000 ? 0x92 : 0x34); - - if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1) - return -EIO; - return 0; -} - -static struct ves1820_config philips_cd1516_config = { - .demod_address = 0x09, - .xin = 57840000UL, - .invert = 1, - .selagc = VES1820_SELAGC_SIGNAMPERR, - .pll_set = philips_cd1516_pll_set, -}; - - - static int alps_tdlb7_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { struct av7110* av7110 = fe->dvb->priv; @@ -1986,46 +1684,6 @@ .pll_set = nexusca_stv0297_pll_set, }; - - -static int grundig_29504_401_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; - u32 div; - u8 cfg, cpump, band_select; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = (36125000 + params->frequency) / 166666; - - cfg = 0x88; - - if (params->frequency < 175000000) cpump = 2; - else if (params->frequency < 390000000) cpump = 1; - else if (params->frequency < 470000000) cpump = 2; - else if (params->frequency < 750000000) cpump = 1; - else cpump = 3; - - if (params->frequency < 175000000) band_select = 0x0e; - else if (params->frequency < 470000000) band_select = 0x05; - else band_select = 0x03; - - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = ((div >> 10) & 0x60) | cfg; - data[3] = (cpump << 6) | band_select; - - if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct l64781_config grundig_29504_401_config = { - .demod_address = 0x55, - .pll_set = grundig_29504_401_pll_set, -}; - - - static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status) { int ret = 0; @@ -2178,8 +1836,7 @@ if (av7110->dev->pci->subsystem_vendor == 0x110a) { switch(av7110->dev->pci->subsystem_device) { case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??)) - av7110->fe = ves1820_attach(&philips_cd1516_config, - &av7110->i2c_adap, read_pwm(av7110)); + av7110->fe = philips_cd1516_attach(&av7110->i2c_adap, read_pwm(av7110)); break; } @@ -2190,7 +1847,7 @@ case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE // try the ALPS BSRV2 first of all - av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap); + av7110->fe = alps_bsrv2_attach(&av7110->i2c_adap); if (av7110->fe) { av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; @@ -2199,7 +1856,7 @@ } // try the ALPS BSRU6 now - av7110->fe = stv0299_attach(&alps_bsru6_config, &av7110->i2c_adap); + av7110->fe = alps_bsru6_attach(&av7110->i2c_adap); if (av7110->fe) { av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; @@ -2208,7 +1865,7 @@ } // Try the grundig 29504-451 - av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); + av7110->fe = grundig_29504_451_attach(&av7110->i2c_adap); if (av7110->fe) { av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; @@ -2220,13 +1877,11 @@ switch(av7110->dev->pci->subsystem_device) { case 0x0000: /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */ - av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap, - read_pwm(av7110)); + av7110->fe = philips_cd1516_attach(&av7110->i2c_adap, read_pwm(av7110)); break; case 0x0003: /* Haupauge DVB-C 2.1 VES1820/ALPS TDBE2 */ - av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, - read_pwm(av7110)); + av7110->fe = alps_tdbe2_attach(&av7110->i2c_adap, read_pwm(av7110)); break; } break; @@ -2238,13 +1893,12 @@ break; case 0x0002: // Hauppauge/TT DVB-C premium rev2.X - - av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); + av7110->fe = alps_tdbe2_attach(&av7110->i2c_adap, read_pwm(av7110)); break; case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */ /* Grundig 29504-451 */ - av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); + av7110->fe = grundig_29504_451_attach(&av7110->i2c_adap); if (av7110->fe) { av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; @@ -2254,7 +1908,7 @@ case 0x0008: // Hauppauge/TT DVB-T - av7110->fe = l64781_attach(&grundig_29504_401_config, &av7110->i2c_adap); + av7110->fe = grundig_29504_401_attach(&av7110->i2c_adap); break; case 0x000A: // Hauppauge/TT Nexus-CA rev1.X @@ -2273,7 +1927,7 @@ case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */ /* ALPS BSBE1 */ - av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap); + av7110->fe = alps_bsbe1_attach(&av7110->i2c_adap); if (av7110->fe) av7110->fe->ops->set_voltage = lnbp21_set_voltage; break; Index: linux/drivers/media/dvb/ttpci/av7110.h =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/av7110.h,v retrieving revision 1.43 diff -u -r1.43 av7110.h --- linux/drivers/media/dvb/ttpci/av7110.h 19 Jun 2005 12:49:47 -0000 1.43 +++ linux/drivers/media/dvb/ttpci/av7110.h 23 Jul 2005 07:50:41 -0000 @@ -25,13 +25,17 @@ #include "dvb_net.h" #include "dvb_ringbuffer.h" #include "dvb_frontend.h" -#include "ves1820.h" -#include "ves1x93.h" -#include "stv0299.h" -#include "tda8083.h" + +#include "bsbe1.h" +#include "bsru6.h" +#include "bsrv2.h" +#include "cd1516.h" +#include "g29504-401.h" +#include "g29504-451.h" +#include "tdbe2.h" + #include "sp8870.h" #include "stv0297.h" -#include "l64781.h" #include Index: linux/drivers/media/dvb/ttpci/budget-av.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/budget-av.c,v retrieving revision 1.44 diff -u -r1.44 budget-av.c --- linux/drivers/media/dvb/ttpci/budget-av.c 8 Jul 2005 22:44:51 -0000 1.44 +++ linux/drivers/media/dvb/ttpci/budget-av.c 23 Jul 2005 07:50:41 -0000 @@ -35,7 +35,7 @@ #include "budget.h" #include "stv0299.h" -#include "tda10021.h" +#include "cu1216.h" #include "tda1004x.h" #include #include @@ -453,9 +453,9 @@ } static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv; u32 div; u8 buf[4]; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -481,12 +481,12 @@ else if (params->frequency < 2150000) buf[3] |= 0xC0; - if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } -static u8 typhoon_cinergy1200s_inittab[] = { +static const u8 typhoon_cinergy1200s_inittab[] = { 0x01, 0x15, 0x02, 0x30, 0x03, 0x00, @@ -557,36 +557,6 @@ .pll_set = philips_su1278_ty_ci_pll_set, }; - -static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) -{ - struct budget *budget = (struct budget *) fe->dvb->priv; - u8 buf[4]; - struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; - -#define TUNER_MUL 62500 - - u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL; - - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = 0x86; - buf[3] = (params->frequency < 150000000 ? 0x01 : - params->frequency < 445000000 ? 0x02 : 0x04); - - if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) - return -EIO; - return 0; -} - -static struct tda10021_config philips_cu1216_config = { - .demod_address = 0x0c, - .pll_set = philips_cu1216_pll_set, -}; - - - - static int philips_tu1216_pll_init(struct dvb_frontend *fe) { struct budget *budget = (struct budget *) fe->dvb->priv; @@ -765,8 +735,7 @@ case SUBID_DVBC_KNC1: case SUBID_DVBC_KNC1_PLUS: - fe = tda10021_attach(&philips_cu1216_config, - &budget_av->budget.i2c_adap, + fe = philips_cu1216_attach(&budget_av->budget.i2c_adap, read_pwm(budget_av)); break; @@ -777,8 +746,7 @@ break; case SUBID_DVBC_CINERGY1200: - fe = tda10021_attach(&philips_cu1216_config, - &budget_av->budget.i2c_adap, + fe = philips_cu1216_attach(&budget_av->budget.i2c_adap, read_pwm(budget_av)); break; Index: linux/drivers/media/dvb/ttpci/budget-ci.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/budget-ci.c,v retrieving revision 1.37 diff -u -r1.37 budget-ci.c --- linux/drivers/media/dvb/ttpci/budget-ci.c 16 Jul 2005 22:42:53 -0000 1.37 +++ linux/drivers/media/dvb/ttpci/budget-ci.c 23 Jul 2005 07:50:41 -0000 @@ -39,6 +39,7 @@ #include #include "dvb_ca_en50221.h" +#include "bsru6.h" #include "stv0299.h" #include "tda1004x.h" @@ -471,125 +472,7 @@ tasklet_schedule(&budget_ci->ciintf_irq_tasklet); } - -static u8 alps_bsru6_inittab[] = { - 0x01, 0x15, - 0x02, 0x00, - 0x03, 0x00, - 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ - 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ - 0x06, 0x40, /* DAC not used, set to high impendance mode */ - 0x07, 0x00, /* DAC LSB */ - 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ - 0x09, 0x00, /* FIFO */ - 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ - 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ - 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ - 0x10, 0x3f, // AGC2 0x3d - 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on - 0x15, 0xc9, // lock detector threshold - 0x16, 0x00, - 0x17, 0x00, - 0x18, 0x00, - 0x19, 0x00, - 0x1a, 0x00, - 0x1f, 0x50, - 0x20, 0x00, - 0x21, 0x00, - 0x22, 0x00, - 0x23, 0x00, - 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 - 0x29, 0x1e, // 1/2 threshold - 0x2a, 0x14, // 2/3 threshold - 0x2b, 0x0f, // 3/4 threshold - 0x2c, 0x09, // 5/6 threshold - 0x2d, 0x05, // 7/8 threshold - 0x2e, 0x01, - 0x31, 0x1f, // test all FECs - 0x32, 0x19, // viterbi and synchro search - 0x33, 0xfc, // rs control - 0x34, 0x93, // error control - 0x0f, 0x52, - 0xff, 0xff -}; - -static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio) -{ - u8 aclk = 0; - u8 bclk = 0; - - if (srate < 1500000) { - aclk = 0xb7; - bclk = 0x47; - } else if (srate < 3000000) { - aclk = 0xb7; - bclk = 0x4b; - } else if (srate < 7000000) { - aclk = 0xb7; - bclk = 0x4f; - } else if (srate < 14000000) { - aclk = 0xb7; - bclk = 0x53; - } else if (srate < 30000000) { - aclk = 0xb6; - bclk = 0x53; - } else if (srate < 45000000) { - aclk = 0xb4; - bclk = 0x51; - } - - stv0299_writereg(fe, 0x13, aclk); - stv0299_writereg(fe, 0x14, bclk); - stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); - stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); - stv0299_writereg(fe, 0x21, (ratio) & 0xf0); - - return 0; -} - -static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) -{ - u8 buf[4]; - u32 div; - struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; - - if ((params->frequency < 950000) || (params->frequency > 2150000)) - return -EINVAL; - - div = (params->frequency + (125 - 1)) / 125; // round correctly - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4; - buf[3] = 0xC4; - - if (params->frequency > 1530000) - buf[3] = 0xc0; - - if (i2c_transfer(i2c, &msg, 1) != 1) - return -EIO; - return 0; -} - -static struct stv0299_config alps_bsru6_config = { - - .demod_address = 0x68, - .inittab = alps_bsru6_inittab, - .mclk = 88000000UL, - .invert = 1, - .enhanced_tuning = 0, - .skip_reinit = 0, - .lock_output = STV0229_LOCKOUTPUT_1, - .volt13_op0_op1 = STV0299_VOLT13_OP1, - .min_delay_ms = 100, - .set_symbol_rate = alps_bsru6_set_symbol_rate, - .pll_set = alps_bsru6_pll_set, -}; - - - - -static u8 philips_su1278_tt_inittab[] = { +static const u8 philips_su1278_tt_inittab[] = { 0x01, 0x0f, 0x02, 0x30, 0x03, 0x00, @@ -854,7 +737,7 @@ switch (budget_ci->budget.dev->pci->subsystem_device) { case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059)) budget_ci->budget.dvb_frontend = - stv0299_attach(&alps_bsru6_config, &budget_ci->budget.i2c_adap); + alps_bsru6_attach(&budget_ci->budget.i2c_adap); if (budget_ci->budget.dvb_frontend) { break; } Index: linux/drivers/media/dvb/ttpci/budget-patch.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/budget-patch.c,v retrieving revision 1.21 diff -u -r1.21 budget-patch.c --- linux/drivers/media/dvb/ttpci/budget-patch.c 16 Jul 2005 22:42:53 -0000 1.21 +++ linux/drivers/media/dvb/ttpci/budget-patch.c 23 Jul 2005 07:50:41 -0000 @@ -33,9 +33,7 @@ #include "av7110.h" #include "av7110_hw.h" #include "budget.h" -#include "stv0299.h" -#include "ves1x93.h" -#include "tda8083.h" +#include "g29504-451.h" #define budget_patch budget @@ -256,160 +254,6 @@ return 0; } -static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv; - u8 pwr = 0; - u8 buf[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; - u32 div = (params->frequency + 479500) / 125; - - if (params->frequency > 2000000) pwr = 3; - else if (params->frequency > 1800000) pwr = 2; - else if (params->frequency > 1600000) pwr = 1; - else if (params->frequency > 1200000) pwr = 0; - else if (params->frequency >= 1100000) pwr = 1; - else pwr = 2; - - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = ((div & 0x18000) >> 10) | 0x95; - buf[3] = (pwr << 6) | 0x30; - - // NOTE: since we're using a prescaler of 2, we set the - // divisor frequency to 62.5kHz and divide by 125 above - - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct ves1x93_config alps_bsrv2_config = { - .demod_address = 0x08, - .xin = 90100000UL, - .invert_pwm = 0, - .pll_set = alps_bsrv2_pll_set, -}; - -static u8 alps_bsru6_inittab[] = { - 0x01, 0x15, - 0x02, 0x00, - 0x03, 0x00, - 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ - 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ - 0x06, 0x40, /* DAC not used, set to high impendance mode */ - 0x07, 0x00, /* DAC LSB */ - 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ - 0x09, 0x00, /* FIFO */ - 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ - 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ - 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ - 0x10, 0x3f, // AGC2 0x3d - 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on - 0x15, 0xc9, // lock detector threshold - 0x16, 0x00, - 0x17, 0x00, - 0x18, 0x00, - 0x19, 0x00, - 0x1a, 0x00, - 0x1f, 0x50, - 0x20, 0x00, - 0x21, 0x00, - 0x22, 0x00, - 0x23, 0x00, - 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 - 0x29, 0x1e, // 1/2 threshold - 0x2a, 0x14, // 2/3 threshold - 0x2b, 0x0f, // 3/4 threshold - 0x2c, 0x09, // 5/6 threshold - 0x2d, 0x05, // 7/8 threshold - 0x2e, 0x01, - 0x31, 0x1f, // test all FECs - 0x32, 0x19, // viterbi and synchro search - 0x33, 0xfc, // rs control - 0x34, 0x93, // error control - 0x0f, 0x52, - 0xff, 0xff -}; - -static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio) -{ - u8 aclk = 0; - u8 bclk = 0; - - if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; } - else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; } - else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; } - else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; } - else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; } - else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; } - - stv0299_writereg (fe, 0x13, aclk); - stv0299_writereg (fe, 0x14, bclk); - stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff); - stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff); - stv0299_writereg (fe, 0x21, (ratio ) & 0xf0); - - return 0; -} - -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) -{ - u8 data[4]; - u32 div; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - if ((params->frequency < 950000) || (params->frequency > 2150000)) return -EINVAL; - - div = (params->frequency + (125 - 1)) / 125; // round correctly - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; - data[3] = 0xC4; - - if (params->frequency > 1530000) data[3] = 0xc0; - - if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct stv0299_config alps_bsru6_config = { - - .demod_address = 0x68, - .inittab = alps_bsru6_inittab, - .mclk = 88000000UL, - .invert = 1, - .enhanced_tuning = 0, - .skip_reinit = 0, - .lock_output = STV0229_LOCKOUTPUT_1, - .volt13_op0_op1 = STV0299_VOLT13_OP1, - .min_delay_ms = 100, - .set_symbol_rate = alps_bsru6_set_symbol_rate, - .pll_set = alps_bsru6_pll_set, -}; - -static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv; - u32 div; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = params->frequency / 125; - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x8e; - data[3] = 0x00; - - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct tda8083_config grundig_29504_451_config = { - .demod_address = 0x68, - .pll_set = grundig_29504_451_pll_set, -}; - static void frontend_init(struct budget_patch* budget) { switch(budget->dev->pci->subsystem_device) { @@ -417,7 +261,7 @@ case 0x1013: // SATELCO Multimedia PCI // try the ALPS BSRV2 first of all - budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); + budget->dvb_frontend = alps_bsrv2_attach(&budget->i2c_adap); if (budget->dvb_frontend) { budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd; budget->dvb_frontend->ops->diseqc_send_burst = budget_patch_diseqc_send_burst; @@ -426,7 +270,7 @@ } // try the ALPS BSRU6 now - budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); + budget->dvb_frontend = alps_bsru6_attach(&budget->i2c_adap); if (budget->dvb_frontend) { budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd; budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst; @@ -435,7 +279,7 @@ } // Try the grundig 29504-451 - budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); + budget->dvb_frontend = grundig_29504_451_attach(&budget->i2c_adap); if (budget->dvb_frontend) { budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd; budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst; Index: linux/drivers/media/dvb/ttpci/budget.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/budget.c,v retrieving revision 1.36 diff -u -r1.36 budget.c --- linux/drivers/media/dvb/ttpci/budget.c 21 Jul 2005 19:07:29 -0000 1.36 +++ linux/drivers/media/dvb/ttpci/budget.c 23 Jul 2005 07:50:41 -0000 @@ -35,11 +35,11 @@ */ #include "budget.h" -#include "stv0299.h" -#include "ves1x93.h" -#include "ves1820.h" -#include "l64781.h" -#include "tda8083.h" +#include "bsru6.h" +#include "bsrv2.h" +#include "g29504-401.h" +#include "g29504-451.h" +#include "tdbe2.h" #include "s5h1420.h" static void Set22K (struct budget *budget, int state) @@ -234,223 +234,6 @@ i2c_transfer (&budget->i2c_adap, &msg, 1); } -static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct budget* budget = (struct budget*) fe->dvb->priv; - u8 pwr = 0; - u8 buf[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; - u32 div = (params->frequency + 479500) / 125; - - if (params->frequency > 2000000) pwr = 3; - else if (params->frequency > 1800000) pwr = 2; - else if (params->frequency > 1600000) pwr = 1; - else if (params->frequency > 1200000) pwr = 0; - else if (params->frequency >= 1100000) pwr = 1; - else pwr = 2; - - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = ((div & 0x18000) >> 10) | 0x95; - buf[3] = (pwr << 6) | 0x30; - - // NOTE: since we're using a prescaler of 2, we set the - // divisor frequency to 62.5kHz and divide by 125 above - - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct ves1x93_config alps_bsrv2_config = -{ - .demod_address = 0x08, - .xin = 90100000UL, - .invert_pwm = 0, - .pll_set = alps_bsrv2_pll_set, -}; - -static u8 alps_bsru6_inittab[] = { - 0x01, 0x15, - 0x02, 0x00, - 0x03, 0x00, - 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ - 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ - 0x06, 0x40, /* DAC not used, set to high impendance mode */ - 0x07, 0x00, /* DAC LSB */ - 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ - 0x09, 0x00, /* FIFO */ - 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ - 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ - 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ - 0x10, 0x3f, // AGC2 0x3d - 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on - 0x15, 0xc9, // lock detector threshold - 0x16, 0x00, - 0x17, 0x00, - 0x18, 0x00, - 0x19, 0x00, - 0x1a, 0x00, - 0x1f, 0x50, - 0x20, 0x00, - 0x21, 0x00, - 0x22, 0x00, - 0x23, 0x00, - 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 - 0x29, 0x1e, // 1/2 threshold - 0x2a, 0x14, // 2/3 threshold - 0x2b, 0x0f, // 3/4 threshold - 0x2c, 0x09, // 5/6 threshold - 0x2d, 0x05, // 7/8 threshold - 0x2e, 0x01, - 0x31, 0x1f, // test all FECs - 0x32, 0x19, // viterbi and synchro search - 0x33, 0xfc, // rs control - 0x34, 0x93, // error control - 0x0f, 0x52, - 0xff, 0xff -}; - -static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio) -{ - u8 aclk = 0; - u8 bclk = 0; - - if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; } - else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; } - else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; } - else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; } - else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; } - else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; } - - stv0299_writereg (fe, 0x13, aclk); - stv0299_writereg (fe, 0x14, bclk); - stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff); - stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff); - stv0299_writereg (fe, 0x21, (ratio ) & 0xf0); - - return 0; -} - -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) -{ - u8 data[4]; - u32 div; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - if ((params->frequency < 950000) || (params->frequency > 2150000)) return -EINVAL; - - div = (params->frequency + (125 - 1)) / 125; // round correctly - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; - data[3] = 0xC4; - - if (params->frequency > 1530000) data[3] = 0xc0; - - if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct stv0299_config alps_bsru6_config = { - - .demod_address = 0x68, - .inittab = alps_bsru6_inittab, - .mclk = 88000000UL, - .invert = 1, - .enhanced_tuning = 0, - .skip_reinit = 0, - .lock_output = STV0229_LOCKOUTPUT_1, - .volt13_op0_op1 = STV0299_VOLT13_OP1, - .min_delay_ms = 100, - .set_symbol_rate = alps_bsru6_set_symbol_rate, - .pll_set = alps_bsru6_pll_set, -}; - -static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct budget* budget = (struct budget*) fe->dvb->priv; - u32 div; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = (params->frequency + 35937500 + 31250) / 62500; - - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x85 | ((div >> 10) & 0x60); - data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81); - - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct ves1820_config alps_tdbe2_config = { - .demod_address = 0x09, - .xin = 57840000UL, - .invert = 1, - .selagc = VES1820_SELAGC_SIGNAMPERR, - .pll_set = alps_tdbe2_pll_set, -}; - -static int grundig_29504_401_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct budget* budget = (struct budget*) fe->dvb->priv; - u32 div; - u8 cfg, cpump, band_select; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = (36125000 + params->frequency) / 166666; - - cfg = 0x88; - - if (params->frequency < 175000000) cpump = 2; - else if (params->frequency < 390000000) cpump = 1; - else if (params->frequency < 470000000) cpump = 2; - else if (params->frequency < 750000000) cpump = 1; - else cpump = 3; - - if (params->frequency < 175000000) band_select = 0x0e; - else if (params->frequency < 470000000) band_select = 0x05; - else band_select = 0x03; - - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = ((div >> 10) & 0x60) | cfg; - data[3] = (cpump << 6) | band_select; - - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct l64781_config grundig_29504_401_config = { - .demod_address = 0x55, - .pll_set = grundig_29504_401_pll_set, -}; - -static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct budget* budget = (struct budget*) fe->dvb->priv; - u32 div; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = params->frequency / 125; - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x8e; - data[3] = 0x00; - - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct tda8083_config grundig_29504_451_config = { - .demod_address = 0x68, - .pll_set = grundig_29504_451_pll_set, -}; - static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout) { struct budget* budget = (struct budget*) fe->dvb->priv; @@ -503,7 +286,7 @@ case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659)) case 0x1013: // try the ALPS BSRV2 first of all - budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); + budget->dvb_frontend = alps_bsrv2_attach(&budget->i2c_adap); if (budget->dvb_frontend) { budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd; budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst; @@ -512,7 +295,7 @@ } // try the ALPS BSRU6 now - budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); + budget->dvb_frontend = alps_bsru6_attach(&budget->i2c_adap); if (budget->dvb_frontend) { budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd; budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst; @@ -522,19 +305,15 @@ break; case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) - - budget->dvb_frontend = ves1820_attach(&alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget)); - if (budget->dvb_frontend) break; + budget->dvb_frontend = alps_tdbe2_attach(&budget->i2c_adap, read_pwm(budget)); break; case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060)) - - budget->dvb_frontend = l64781_attach(&grundig_29504_401_config, &budget->i2c_adap); - if (budget->dvb_frontend) break; + budget->dvb_frontend = grundig_29504_401_attach(&budget->i2c_adap); break; case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059)) - budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); + budget->dvb_frontend = alps_bsru6_attach(&budget->i2c_adap); if (budget->dvb_frontend) { budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage; break; @@ -542,7 +321,7 @@ break; case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522)) - budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); + budget->dvb_frontend = grundig_29504_451_attach(&budget->i2c_adap); if (budget->dvb_frontend) { budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage; break; Index: linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c =================================================================== RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c,v retrieving revision 1.55 diff -u -r1.55 dvb-ttusb-budget.c --- linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 16 Jul 2005 22:42:53 -0000 1.55 +++ linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 23 Jul 2005 07:50:41 -0000 @@ -24,11 +24,12 @@ #include "dmxdev.h" #include "dvb_demux.h" #include "dvb_net.h" -#include "ves1820.h" -#include "cx22700.h" +#include "bsbe1.h" +#include "bsru6.h" +#include "g29504-451.h" +#include "tdbe2.h" +#include "tdmb7.h" #include "tda1004x.h" -#include "stv0299.h" -#include "tda8083.h" #include #include @@ -1046,35 +1047,6 @@ return I2C_FUNC_I2C; } - - -static int alps_tdmb7_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; - u8 data[4]; - struct i2c_msg msg = {.addr=0x61, .flags=0, .buf=data, .len=sizeof(data) }; - u32 div; - - div = (params->frequency + 36166667) / 166667; - - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = ((div >> 10) & 0x60) | 0x85; - data[3] = params->frequency < 592000000 ? 0x40 : 0x80; - - if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) return -EIO; - return 0; -} - -static struct cx22700_config alps_tdmb7_config = { - .demod_address = 0x43, - .pll_set = alps_tdmb7_pll_set, -}; - - - - - static int philips_tdm1316l_pll_init(struct dvb_frontend* fe) { struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; @@ -1181,222 +1153,6 @@ .request_firmware = philips_tdm1316l_request_firmware, }; -static u8 alps_bsbe1_inittab[] = { - 0x01, 0x15, - 0x02, 0x30, - 0x03, 0x00, - 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ - 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ - 0x06, 0x40, /* DAC not used, set to high impendance mode */ - 0x07, 0x00, /* DAC LSB */ - 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ - 0x09, 0x00, /* FIFO */ - 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ - 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ - 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ - 0x10, 0x3f, // AGC2 0x3d - 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on - 0x15, 0xc9, // lock detector threshold - 0x16, 0x00, - 0x17, 0x00, - 0x18, 0x00, - 0x19, 0x00, - 0x1a, 0x00, - 0x1f, 0x50, - 0x20, 0x00, - 0x21, 0x00, - 0x22, 0x00, - 0x23, 0x00, - 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 - 0x29, 0x1e, // 1/2 threshold - 0x2a, 0x14, // 2/3 threshold - 0x2b, 0x0f, // 3/4 threshold - 0x2c, 0x09, // 5/6 threshold - 0x2d, 0x05, // 7/8 threshold - 0x2e, 0x01, - 0x31, 0x1f, // test all FECs - 0x32, 0x19, // viterbi and synchro search - 0x33, 0xfc, // rs control - 0x34, 0x93, // error control - 0x0f, 0x92, - 0xff, 0xff -}; - -static u8 alps_bsru6_inittab[] = { - 0x01, 0x15, - 0x02, 0x30, - 0x03, 0x00, - 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ - 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ - 0x06, 0x40, /* DAC not used, set to high impendance mode */ - 0x07, 0x00, /* DAC LSB */ - 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ - 0x09, 0x00, /* FIFO */ - 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ - 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ - 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ - 0x10, 0x3f, // AGC2 0x3d - 0x11, 0x84, - 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on - 0x15, 0xc9, // lock detector threshold - 0x16, 0x00, - 0x17, 0x00, - 0x18, 0x00, - 0x19, 0x00, - 0x1a, 0x00, - 0x1f, 0x50, - 0x20, 0x00, - 0x21, 0x00, - 0x22, 0x00, - 0x23, 0x00, - 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 - 0x29, 0x1e, // 1/2 threshold - 0x2a, 0x14, // 2/3 threshold - 0x2b, 0x0f, // 3/4 threshold - 0x2c, 0x09, // 5/6 threshold - 0x2d, 0x05, // 7/8 threshold - 0x2e, 0x01, - 0x31, 0x1f, // test all FECs - 0x32, 0x19, // viterbi and synchro search - 0x33, 0xfc, // rs control - 0x34, 0x93, // error control - 0x0f, 0x52, - 0xff, 0xff -}; - -static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio) -{ - u8 aclk = 0; - u8 bclk = 0; - - if (srate < 1500000) { - aclk = 0xb7; - bclk = 0x47; - } else if (srate < 3000000) { - aclk = 0xb7; - bclk = 0x4b; - } else if (srate < 7000000) { - aclk = 0xb7; - bclk = 0x4f; - } else if (srate < 14000000) { - aclk = 0xb7; - bclk = 0x53; - } else if (srate < 30000000) { - aclk = 0xb6; - bclk = 0x53; - } else if (srate < 45000000) { - aclk = 0xb4; - bclk = 0x51; - } - - stv0299_writereg(fe, 0x13, aclk); - stv0299_writereg(fe, 0x14, bclk); - stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); - stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); - stv0299_writereg(fe, 0x21, (ratio) & 0xf0); - - return 0; -} - -static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) -{ - struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; - u8 buf[4]; - u32 div; - struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; - - if ((params->frequency < 950000) || (params->frequency > 2150000)) - return -EINVAL; - - div = (params->frequency + (125 - 1)) / 125; // round correctly - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4; - buf[3] = 0xC4; - - if (params->frequency > 1530000) - buf[3] = 0xC0; - - /* BSBE1 wants XCE bit set */ - if (ttusb->revision == TTUSB_REV_2_2) - buf[3] |= 0x20; - - if (i2c_transfer(i2c, &msg, 1) != 1) - return -EIO; - - return 0; -} - -static struct stv0299_config alps_stv0299_config = { - .demod_address = 0x68, - .inittab = alps_bsru6_inittab, - .mclk = 88000000UL, - .invert = 1, - .enhanced_tuning = 0, - .skip_reinit = 0, - .lock_output = STV0229_LOCKOUTPUT_1, - .volt13_op0_op1 = STV0299_VOLT13_OP1, - .min_delay_ms = 100, - .set_symbol_rate = alps_stv0299_set_symbol_rate, - .pll_set = philips_tsa5059_pll_set, -}; - -static int ttusb_novas_grundig_29504_491_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) -{ - struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; - u8 buf[4]; - u32 div; - struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; - - div = params->frequency / 125; - - buf[0] = (div >> 8) & 0x7f; - buf[1] = div & 0xff; - buf[2] = 0x8e; - buf[3] = 0x00; - - if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) - return -EIO; - - return 0; -} - -static struct tda8083_config ttusb_novas_grundig_29504_491_config = { - - .demod_address = 0x68, - .pll_set = ttusb_novas_grundig_29504_491_pll_set, -}; - -static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) -{ - struct ttusb* ttusb = fe->dvb->priv; - u32 div; - u8 data[4]; - struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) }; - - div = (params->frequency + 35937500 + 31250) / 62500; - - data[0] = (div >> 8) & 0x7f; - data[1] = div & 0xff; - data[2] = 0x85 | ((div >> 10) & 0x60); - data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81); - - if (i2c_transfer (&ttusb->i2c_adap, &msg, 1) != 1) - return -EIO; - - return 0; -} - - -static struct ves1820_config alps_tdbe2_config = { - .demod_address = 0x09, - .xin = 57840000UL, - .invert = 1, - .selagc = VES1820_SELAGC_SIGNAMPERR, - .pll_set = alps_tdbe2_pll_set, -}; - static u8 read_pwm(struct ttusb* ttusb) { u8 b = 0xff; @@ -1416,19 +1172,22 @@ switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) { case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6|BSBE1(tsa5059)) // try the stv0299 based first - ttusb->fe = stv0299_attach(&alps_stv0299_config, &ttusb->i2c_adap); - if (ttusb->fe != NULL) { - if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1 - alps_stv0299_config.inittab = alps_bsbe1_inittab; + if (ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1 + ttusb->fe = alps_bsbe1_attach(&ttusb->i2c_adap); + if (ttusb->fe != NULL) { ttusb->fe->ops->set_voltage = lnbp21_set_voltage; - } else { // ALPS BSRU6 + break; + } + } else { // ALPS BSRU6 + ttusb->fe = alps_bsru6_attach(&ttusb->i2c_adap); + if (ttusb->fe != NULL) { ttusb->fe->ops->set_voltage = ttusb_set_voltage; + break; } - break; } - // Grundig 29504-491 - ttusb->fe = tda8083_attach(&ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap); + // Grundig 29504-451 + ttusb->fe = grundig_29504_451_attach(&ttusb->i2c_adap); if (ttusb->fe != NULL) { ttusb->fe->ops->set_voltage = ttusb_set_voltage; break; @@ -1437,14 +1196,14 @@ break; case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) - ttusb->fe = ves1820_attach(&alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb)); + ttusb->fe = alps_tdbe2_attach(&ttusb->i2c_adap, read_pwm(ttusb)); if (ttusb->fe != NULL) break; break; case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??)) // try the ALPS TDMB7 first - ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap); + ttusb->fe = alps_tdmb7_attach(&ttusb->i2c_adap); if (ttusb->fe != NULL) break;