On Sunday 17 July 2005 10:54 pm, Mac Michaels wrote: > Here are the next changes I plan to make to the driver I > maintain. Many of these changes are in preparation of > merging the lgdt3302 and lgdt3303 drivers. > > 1) Remove the dvb_pll_desc fromthe frontend and replace > with a pll_set-callback to isolate the tuner programming > from the frontend. > > 2) Select the RF input connector based upon the type of > demodulation selected. ANT RF connector is selected for > 8-VSB and CABLE RF connector is selected for > QAM64/QAM256. Implement this along the lines posted to > this list earlier by Patrick. This only affects the cards > that use the Microtune 4042 tuner. This is not ideal, but > there is no current specification for selecting RF > inputs. It makes the card work the same way as the > Windows driver thus it may reduce user confusion. > > 3) Modify the driver make initialization table driven. > This is done in preparation of merging with the lgdt3303. > > 4) Merge with existing lgdt3303 driver. > > *5) Add support for the FusionHDTV 5 Gold. > > *6) Add support for the FusionHDTV 5 Lite. > > *Note. The order of 5 and 6 could be reversed if by some > miracle I receive a Lite card for testing. > > -- Mac A patch to implement item 1 above follows. I think this is what Patrick suggested. It makes sense to me as it puts more of the tuner code into the dvb-pll files. I will post patches for items 2 - 6 as I complete them. This patch is against an old version of the video4linux CVS. It still has the lgdt3302.* files and the makefile to build them. Note also that the last fix I made for the QAM intermittent problem is also in this patch. I know it is wrong to do this, but I am interested in feedback. It is very convenient for me to work this way. When I finish merging the lgdt3302 and lgdt3303 I will produce a proper patch. -- Mac Index: cx88-dvb.c =================================================================== RCS file: /cvs/video4linux/video4linux/cx88-dvb.c,v retrieving revision 1.42 diff -u -r1.42 cx88-dvb.c --- cx88-dvb.c 12 Jul 2005 15:44:55 -0000 1.42 +++ cx88-dvb.c 19 Jul 2005 17:13:05 -0000 @@ -209,6 +209,18 @@ #endif #if CONFIG_DVB_LGDT3302 +static int lgdt3302_pll_set(struct dvb_frontend* fe, + struct dvb_frontend_parameters* params, + u8* pllbuf) +{ + struct cx8802_dev *dev= fe->dvb->priv; + + pllbuf[0] = dev->core->pll_addr; + dvb_pll_configure(dev->core->pll_desc, &pllbuf[1], + params->frequency, 0); + return 0; +} + static int lgdt3302_set_ts_param(struct dvb_frontend* fe, int is_punctured) { struct cx8802_dev *dev= fe->dvb->priv; @@ -219,17 +231,9 @@ return 0; } -static struct lgdt3302_config fusionhdtv_3_gold_q = { +static struct lgdt3302_config fusionhdtv_3_gold = { .demod_address = 0x0e, - .pll_address = 0x61, - .pll_desc = &dvb_pll_microtune_4042, - .set_ts_params = lgdt3302_set_ts_param, -}; - -static struct lgdt3302_config fusionhdtv_3_gold_t = { - .demod_address = 0x0e, - .pll_address = 0x61, - .pll_desc = &dvb_pll_thomson_dtt7611, + .pll_set = lgdt3302_pll_set, .set_ts_params = lgdt3302_set_ts_param, }; #endif @@ -292,10 +296,13 @@ mdelay(100); cx_set(MO_GP0_IO, 9); // ANT connector too FIXME mdelay(200); - dev->dvb.frontend = lgdt3302_attach(&fusionhdtv_3_gold_q, + dev->core->pll_addr = 0x61; + dev->core->pll_desc = &dvb_pll_microtune_4042; + dev->dvb.frontend = lgdt3302_attach(&fusionhdtv_3_gold, &dev->core->i2c_adap); } break; + case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: dev->ts_gen_cntrl = 0x08; { @@ -306,7 +313,9 @@ mdelay(100); cx_set(MO_GP0_IO, 9); /* ANT connector too FIXME */ mdelay(200); - dev->dvb.frontend = lgdt3302_attach(&fusionhdtv_3_gold_t, + dev->core->pll_addr = 0x61; + dev->core->pll_desc = &dvb_pll_thomson_dtt7611; + dev->dvb.frontend = lgdt3302_attach(&fusionhdtv_3_gold, &dev->core->i2c_adap); } break; Index: lgdt3302.c =================================================================== RCS file: /cvs/video4linux/video4linux/Attic/lgdt3302.c,v retrieving revision 1.17 diff -u -r1.17 lgdt3302.c --- lgdt3302.c 12 Jul 2005 04:09:24 -0000 1.17 +++ lgdt3302.c 19 Jul 2005 17:13:06 -0000 @@ -76,20 +76,7 @@ u8 *buf, /* data bytes to send */ int len /* number of bytes to send */ ) { - if (addr == state->config->pll_address) { - struct i2c_msg msg = - { .addr = addr, .flags = 0, .buf = buf, .len = len }; - int err; - - if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { - printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err); - if (err < 0) - return err; - else - return -EREMOTEIO; - } - } else { - u8 tmp[] = { buf[0], buf[1] }; + u8 tmp[] = { buf[0], buf[1] }; struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = tmp, .len = 2 }; int err; @@ -106,9 +93,9 @@ } tmp[0]++; } - } return 0; } + static int i2c_readbytes (struct lgdt3302_state* state, u8 addr, /* demod_address or pll_address */ u8 *buf, /* holds data bytes read */ @@ -209,7 +196,6 @@ static int lgdt3302_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_parameters *param) { - u8 buf[4]; struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv; @@ -219,13 +205,11 @@ static u8 demux_ctrl_cfg[] = { DEMUX_CONTROL, 0xfb }; static u8 agc_rf_cfg[] = { AGC_RF_BANDWIDTH0, 0x40, 0x93, 0x00 }; static u8 agc_ctrl_cfg[] = { AGC_FUNC_CTRL2, 0xc6, 0x40 }; - static u8 agc_delay_cfg[] = { AGC_DELAY0, 0x00, 0x00, 0x00 }; + static u8 agc_delay_cfg[] = { AGC_DELAY0, 0x07, 0x00, 0xfe }; static u8 agc_loop_cfg[] = { AGC_LOOP_BANDWIDTH0, 0x08, 0x9a }; /* Change only if we are actually changing the modulation */ if (state->current_modulation != param->u.vsb.modulation) { - int value; - switch(param->u.vsb.modulation) { case VSB_8: dprintk("%s: VSB_8 MODE\n", __FUNCTION__); @@ -278,16 +262,9 @@ recovery center frequency register */ i2c_writebytes(state, state->config->demod_address, vsb_freq_cfg, sizeof(vsb_freq_cfg)); + /* Set the value of 'INLVTHD' register 0x2a/0x2c - to value from 'IFACC' register 0x39/0x3b -1 */ - i2c_selectreadbytes(state, AGC_RFIF_ACC0, - &agc_delay_cfg[1], 3); - value = ((agc_delay_cfg[1] & 0x0f) << 8) | agc_delay_cfg[3]; - value = value -1; - dprintk("%s IFACC -1 = 0x%03x\n", __FUNCTION__, value); - agc_delay_cfg[1] = (value >> 8) & 0x0f; - agc_delay_cfg[2] = 0x00; - agc_delay_cfg[3] = value & 0xff; + to 0x7fe */ i2c_writebytes(state, state->config->demod_address, agc_delay_cfg, sizeof(agc_delay_cfg)); @@ -302,16 +279,30 @@ /* Change only if we are actually changing the channel */ if (state->current_frequency != param->frequency) { - dvb_pll_configure(state->config->pll_desc, buf, - param->frequency, 0); - dprintk("%s: tuner bytes: 0x%02x 0x%02x " - "0x%02x 0x%02x\n", __FUNCTION__, buf[0],buf[1],buf[2],buf[3]); - i2c_writebytes(state, state->config->pll_address ,buf, 4); + u8 buf[5]; - /* Check the status of the tuner pll */ - i2c_readbytes(state, state->config->pll_address, buf, 1); - dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]); + /* This must be done before the initialized msg is declared */ + state->config->pll_set(fe, param, buf); + struct i2c_msg msg = + { .addr = buf[0], .flags = 0, .buf = &buf[1], .len = 4 }; + int err; + + dprintk("%s: tuner at 0x%02x bytes: 0x%02x 0x%02x " + "0x%02x 0x%02x\n", __FUNCTION__, + buf[0],buf[1],buf[2],buf[3],buf[4]); + if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { + printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err = %i)\n", __FUNCTION__, buf[0], buf[1], err); + if (err < 0) + return err; + else + return -EREMOTEIO; + } +#if 0 + /* Check the status of the tuner pll */ + i2c_readbytes(state, buf[0], &buf[1], 1); + dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[1]); +#endif /* Update current frequency */ state->current_frequency = param->frequency; } @@ -333,13 +324,6 @@ u8 buf[3]; *status = 0; /* Reset status result */ - - /* Check the status of the tuner pll */ - i2c_readbytes(state, state->config->pll_address, buf, 1); - dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]); - if ((buf[0] & 0xc0) != 0x40) - return 0; /* Tuner PLL not locked or not powered on */ - /* * You must set the Mask bits to 1 in the IRQ_MASK in order * to see that status bit in the IRQ_STATUS register. Index: lgdt3302.h =================================================================== RCS file: /cvs/video4linux/video4linux/Attic/lgdt3302.h,v retrieving revision 1.4 diff -u -r1.4 lgdt3302.h --- lgdt3302.h 28 Jun 2005 12:34:14 -0000 1.4 +++ lgdt3302.h 19 Jul 2005 17:13:06 -0000 @@ -30,8 +30,9 @@ { /* The demodulator's i2c address */ u8 demod_address; - u8 pll_address; - struct dvb_pll_desc *pll_desc; + + /* PLL interface */ + int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pll_address); /* Need to set device param for start_dma */ int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);