From d76a617903fa6dc466907531056cc33100560ea4 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Mon, 23 Jan 2006 17:11:06 -0200 Subject: V4L/DVB (3413): Kill nxt2002 in favor of the nxt200x module - Kill nxt2002 module in favor of nxt200x. - Repair broken nxt2002 support in the nxt200x module. - Make the flexcop driver use nxt200x instead of the nxt2002 module for the Air2PC 2nd generation PCI card. - Remove the nxt2002 module from cvs and kernel build. Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/Kconfig | 12 - drivers/media/dvb/frontends/Makefile | 1 - drivers/media/dvb/frontends/dvb-pll.c | 2 +- drivers/media/dvb/frontends/nxt2002.c | 706 ---------------------------------- drivers/media/dvb/frontends/nxt2002.h | 23 -- drivers/media/dvb/frontends/nxt200x.c | 58 ++- 6 files changed, 51 insertions(+), 751 deletions(-) delete mode 100644 drivers/media/dvb/frontends/nxt2002.c delete mode 100644 drivers/media/dvb/frontends/nxt2002.h (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index db3a8b40031..f09e3da669f 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -166,18 +166,6 @@ config DVB_STV0297 comment "ATSC (North American/Korean Terresterial DTV) frontends" depends on DVB_CORE -config DVB_NXT2002 - tristate "Nxt2002 based" - depends on DVB_CORE - select FW_LOADER - help - An ATSC 8VSB tuner module. Say Y when you want to support this frontend. - - This driver needs external firmware. Please use the command - "/Documentation/dvb/get_dvb_firmware nxt2002" to - download/extract it, and then copy it to /usr/lib/hotplug/firmware - or /lib/firmware (depending on configuration of firmware hotplug). - config DVB_NXT200X tristate "Nextwave NXT2002/NXT2004 based" depends on DVB_CORE diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 615ec830e1c..8f301468568 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -25,7 +25,6 @@ obj-$(CONFIG_DVB_CX22702) += cx22702.o obj-$(CONFIG_DVB_TDA80XX) += tda80xx.o obj-$(CONFIG_DVB_TDA10021) += tda10021.o obj-$(CONFIG_DVB_STV0297) += stv0297.o -obj-$(CONFIG_DVB_NXT2002) += nxt2002.o obj-$(CONFIG_DVB_NXT200X) += nxt200x.o obj-$(CONFIG_DVB_OR51211) += or51211.o obj-$(CONFIG_DVB_OR51132) += or51132.o diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index 1b9934ea5b0..9c9c12af579 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c @@ -326,7 +326,7 @@ struct dvb_pll_desc dvb_pll_tuv1236d = { }; EXPORT_SYMBOL(dvb_pll_tuv1236d); -/* Samsung TBMV30111IN +/* Samsung TBMV30111IN / TBMV30712IN1 * used in Air2PC ATSC - 2nd generation (nxt2002) */ struct dvb_pll_desc dvb_pll_tbmv30111in = { diff --git a/drivers/media/dvb/frontends/nxt2002.c b/drivers/media/dvb/frontends/nxt2002.c deleted file mode 100644 index 4f263e65ba1..00000000000 --- a/drivers/media/dvb/frontends/nxt2002.c +++ /dev/null @@ -1,706 +0,0 @@ -/* - Support for B2C2/BBTI Technisat Air2PC - ATSC - - Copyright (C) 2004 Taylor Jacob - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -/* - * This driver needs external firmware. Please use the command - * "/Documentation/dvb/get_dvb_firmware nxt2002" to - * download/extract it, and then copy it to /usr/lib/hotplug/firmware - * or /lib/firmware (depending on configuration of firmware hotplug). - */ -#define NXT2002_DEFAULT_FIRMWARE "dvb-fe-nxt2002.fw" -#define CRC_CCIT_MASK 0x1021 - -#include -#include -#include -#include -#include -#include -#include - -#include "dvb_frontend.h" -#include "nxt2002.h" - -struct nxt2002_state { - - struct i2c_adapter* i2c; - struct dvb_frontend_ops ops; - const struct nxt2002_config* config; - struct dvb_frontend frontend; - - /* demodulator private data */ - u8 initialised:1; -}; - -static int debug; -#define dprintk(args...) \ - do { \ - if (debug) printk(KERN_DEBUG "nxt2002: " args); \ - } while (0) - -static int i2c_writebytes (struct nxt2002_state* state, u8 reg, u8 *buf, u8 len) -{ - /* probbably a much better way or doing this */ - u8 buf2 [256],x; - int err; - struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf2, .len = len + 1 }; - - buf2[0] = reg; - for (x = 0 ; x < len ; x++) - buf2[x+1] = buf[x]; - - if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { - printk ("%s: i2c write error (addr %02x, err == %i)\n", - __FUNCTION__, state->config->demod_address, err); - return -EREMOTEIO; - } - - return 0; -} - -static u8 i2c_readbytes (struct nxt2002_state* state, u8 reg, u8* buf, u8 len) -{ - u8 reg2 [] = { reg }; - - struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = reg2, .len = 1 }, - { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len } }; - - int err; - - if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) { - printk ("%s: i2c read error (addr %02x, err == %i)\n", - __FUNCTION__, state->config->demod_address, err); - return -EREMOTEIO; - } - - return 0; -} - -static u16 nxt2002_crc(u16 crc, u8 c) -{ - - u8 i; - u16 input = (u16) c & 0xFF; - - input<<=8; - for(i=0 ;i<8 ;i++) { - if((crc ^ input) & 0x8000) - crc=(crc<<1)^CRC_CCIT_MASK; - else - crc<<=1; - input<<=1; - } - return crc; -} - -static int nxt2002_writereg_multibyte (struct nxt2002_state* state, u8 reg, u8* data, u8 len) -{ - u8 buf; - dprintk("%s\n", __FUNCTION__); - - /* set multi register length */ - i2c_writebytes(state,0x34,&len,1); - - /* set mutli register register */ - i2c_writebytes(state,0x35,®,1); - - /* send the actual data */ - i2c_writebytes(state,0x36,data,len); - - /* toggle the multireg write bit*/ - buf = 0x02; - i2c_writebytes(state,0x21,&buf,1); - - i2c_readbytes(state,0x21,&buf,1); - - if ((buf & 0x02) == 0) - return 0; - - dprintk("Error writing multireg register %02X\n",reg); - - return 0; -} - -static int nxt2002_readreg_multibyte (struct nxt2002_state* state, u8 reg, u8* data, u8 len) -{ - u8 len2; - dprintk("%s\n", __FUNCTION__); - - /* set multi register length */ - len2 = len & 0x80; - i2c_writebytes(state,0x34,&len2,1); - - /* set mutli register register */ - i2c_writebytes(state,0x35,®,1); - - /* send the actual data */ - i2c_readbytes(state,reg,data,len); - - return 0; -} - -static void nxt2002_microcontroller_stop (struct nxt2002_state* state) -{ - u8 buf[2],counter = 0; - dprintk("%s\n", __FUNCTION__); - - buf[0] = 0x80; - i2c_writebytes(state,0x22,buf,1); - - while (counter < 20) { - i2c_readbytes(state,0x31,buf,1); - if (buf[0] & 0x40) - return; - msleep(10); - counter++; - } - - dprintk("Timeout waiting for micro to stop.. This is ok after firmware upload\n"); - return; -} - -static void nxt2002_microcontroller_start (struct nxt2002_state* state) -{ - u8 buf; - dprintk("%s\n", __FUNCTION__); - - buf = 0x00; - i2c_writebytes(state,0x22,&buf,1); -} - -static int nxt2002_writetuner (struct nxt2002_state* state, u8* data) -{ - u8 buf,count = 0; - - dprintk("Tuner Bytes: %02X %02X %02X %02X\n",data[0],data[1],data[2],data[3]); - - dprintk("%s\n", __FUNCTION__); - /* stop the micro first */ - nxt2002_microcontroller_stop(state); - - /* set the i2c transfer speed to the tuner */ - buf = 0x03; - i2c_writebytes(state,0x20,&buf,1); - - /* setup to transfer 4 bytes via i2c */ - buf = 0x04; - i2c_writebytes(state,0x34,&buf,1); - - /* write actual tuner bytes */ - i2c_writebytes(state,0x36,data,4); - - /* set tuner i2c address */ - buf = 0xC2; - i2c_writebytes(state,0x35,&buf,1); - - /* write UC Opmode to begin transfer */ - buf = 0x80; - i2c_writebytes(state,0x21,&buf,1); - - while (count < 20) { - i2c_readbytes(state,0x21,&buf,1); - if ((buf & 0x80)== 0x00) - return 0; - msleep(100); - count++; - } - - printk("nxt2002: timeout error writing tuner\n"); - return 0; -} - -static void nxt2002_agc_reset(struct nxt2002_state* state) -{ - u8 buf; - dprintk("%s\n", __FUNCTION__); - - buf = 0x08; - i2c_writebytes(state,0x08,&buf,1); - - buf = 0x00; - i2c_writebytes(state,0x08,&buf,1); - - return; -} - -static int nxt2002_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) -{ - - struct nxt2002_state* state = fe->demodulator_priv; - u8 buf[256],written = 0,chunkpos = 0; - u16 rambase,position,crc = 0; - - dprintk("%s\n", __FUNCTION__); - dprintk("Firmware is %zu bytes\n",fw->size); - - /* Get the RAM base for this nxt2002 */ - i2c_readbytes(state,0x10,buf,1); - - if (buf[0] & 0x10) - rambase = 0x1000; - else - rambase = 0x0000; - - dprintk("rambase on this nxt2002 is %04X\n",rambase); - - /* Hold the micro in reset while loading firmware */ - buf[0] = 0x80; - i2c_writebytes(state,0x2B,buf,1); - - for (position = 0; position < fw->size ; position++) { - if (written == 0) { - crc = 0; - chunkpos = 0x28; - buf[0] = ((rambase + position) >> 8); - buf[1] = (rambase + position) & 0xFF; - buf[2] = 0x81; - /* write starting address */ - i2c_writebytes(state,0x29,buf,3); - } - written++; - chunkpos++; - - if ((written % 4) == 0) - i2c_writebytes(state,chunkpos,&fw->data[position-3],4); - - crc = nxt2002_crc(crc,fw->data[position]); - - if ((written == 255) || (position+1 == fw->size)) { - /* write remaining bytes of firmware */ - i2c_writebytes(state, chunkpos+4-(written %4), - &fw->data[position-(written %4) + 1], - written %4); - buf[0] = crc << 8; - buf[1] = crc & 0xFF; - - /* write crc */ - i2c_writebytes(state,0x2C,buf,2); - - /* do a read to stop things */ - i2c_readbytes(state,0x2A,buf,1); - - /* set transfer mode to complete */ - buf[0] = 0x80; - i2c_writebytes(state,0x2B,buf,1); - - written = 0; - } - } - - printk ("done.\n"); - return 0; -}; - -static int nxt2002_setup_frontend_parameters (struct dvb_frontend* fe, - struct dvb_frontend_parameters *p) -{ - struct nxt2002_state* state = fe->demodulator_priv; - u32 freq = 0; - u16 tunerfreq = 0; - u8 buf[4]; - - freq = 44000 + ( p->frequency / 1000 ); - - dprintk("freq = %d p->frequency = %d\n",freq,p->frequency); - - tunerfreq = freq * 24/4000; - - buf[0] = (tunerfreq >> 8) & 0x7F; - buf[1] = (tunerfreq & 0xFF); - - if (p->frequency <= 214000000) { - buf[2] = 0x84 + (0x06 << 3); - buf[3] = (p->frequency <= 172000000) ? 0x01 : 0x02; - } else if (p->frequency <= 721000000) { - buf[2] = 0x84 + (0x07 << 3); - buf[3] = (p->frequency <= 467000000) ? 0x02 : 0x08; - } else if (p->frequency <= 841000000) { - buf[2] = 0x84 + (0x0E << 3); - buf[3] = 0x08; - } else { - buf[2] = 0x84 + (0x0F << 3); - buf[3] = 0x02; - } - - /* write frequency information */ - nxt2002_writetuner(state,buf); - - /* reset the agc now that tuning has been completed */ - nxt2002_agc_reset(state); - - /* set target power level */ - switch (p->u.vsb.modulation) { - case QAM_64: - case QAM_256: - buf[0] = 0x74; - break; - case VSB_8: - buf[0] = 0x70; - break; - default: - return -EINVAL; - break; - } - i2c_writebytes(state,0x42,buf,1); - - /* configure sdm */ - buf[0] = 0x87; - i2c_writebytes(state,0x57,buf,1); - - /* write sdm1 input */ - buf[0] = 0x10; - buf[1] = 0x00; - nxt2002_writereg_multibyte(state,0x58,buf,2); - - /* write sdmx input */ - switch (p->u.vsb.modulation) { - case QAM_64: - buf[0] = 0x68; - break; - case QAM_256: - buf[0] = 0x64; - break; - case VSB_8: - buf[0] = 0x60; - break; - default: - return -EINVAL; - break; - } - buf[1] = 0x00; - nxt2002_writereg_multibyte(state,0x5C,buf,2); - - /* write adc power lpf fc */ - buf[0] = 0x05; - i2c_writebytes(state,0x43,buf,1); - - /* write adc power lpf fc */ - buf[0] = 0x05; - i2c_writebytes(state,0x43,buf,1); - - /* write accumulator2 input */ - buf[0] = 0x80; - buf[1] = 0x00; - nxt2002_writereg_multibyte(state,0x4B,buf,2); - - /* write kg1 */ - buf[0] = 0x00; - i2c_writebytes(state,0x4D,buf,1); - - /* write sdm12 lpf fc */ - buf[0] = 0x44; - i2c_writebytes(state,0x55,buf,1); - - /* write agc control reg */ - buf[0] = 0x04; - i2c_writebytes(state,0x41,buf,1); - - /* write agc ucgp0 */ - switch (p->u.vsb.modulation) { - case QAM_64: - buf[0] = 0x02; - break; - case QAM_256: - buf[0] = 0x03; - break; - case VSB_8: - buf[0] = 0x00; - break; - default: - return -EINVAL; - break; - } - i2c_writebytes(state,0x30,buf,1); - - /* write agc control reg */ - buf[0] = 0x00; - i2c_writebytes(state,0x41,buf,1); - - /* write accumulator2 input */ - buf[0] = 0x80; - buf[1] = 0x00; - nxt2002_writereg_multibyte(state,0x49,buf,2); - nxt2002_writereg_multibyte(state,0x4B,buf,2); - - /* write agc control reg */ - buf[0] = 0x04; - i2c_writebytes(state,0x41,buf,1); - - nxt2002_microcontroller_start(state); - - /* adjacent channel detection should be done here, but I don't - have any stations with this need so I cannot test it */ - - return 0; -} - -static int nxt2002_read_status(struct dvb_frontend* fe, fe_status_t* status) -{ - struct nxt2002_state* state = fe->demodulator_priv; - u8 lock; - i2c_readbytes(state,0x31,&lock,1); - - *status = 0; - if (lock & 0x20) { - *status |= FE_HAS_SIGNAL; - *status |= FE_HAS_CARRIER; - *status |= FE_HAS_VITERBI; - *status |= FE_HAS_SYNC; - *status |= FE_HAS_LOCK; - } - return 0; -} - -static int nxt2002_read_ber(struct dvb_frontend* fe, u32* ber) -{ - struct nxt2002_state* state = fe->demodulator_priv; - u8 b[3]; - - nxt2002_readreg_multibyte(state,0xE6,b,3); - - *ber = ((b[0] << 8) + b[1]) * 8; - - return 0; -} - -static int nxt2002_read_signal_strength(struct dvb_frontend* fe, u16* strength) -{ - struct nxt2002_state* state = fe->demodulator_priv; - u8 b[2]; - u16 temp = 0; - - /* setup to read cluster variance */ - b[0] = 0x00; - i2c_writebytes(state,0xA1,b,1); - - /* get multreg val */ - nxt2002_readreg_multibyte(state,0xA6,b,2); - - temp = (b[0] << 8) | b[1]; - *strength = ((0x7FFF - temp) & 0x0FFF) * 16; - - return 0; -} - -static int nxt2002_read_snr(struct dvb_frontend* fe, u16* snr) -{ - - struct nxt2002_state* state = fe->demodulator_priv; - u8 b[2]; - u16 temp = 0, temp2; - u32 snrdb = 0; - - /* setup to read cluster variance */ - b[0] = 0x00; - i2c_writebytes(state,0xA1,b,1); - - /* get multreg val from 0xA6 */ - nxt2002_readreg_multibyte(state,0xA6,b,2); - - temp = (b[0] << 8) | b[1]; - temp2 = 0x7FFF - temp; - - /* snr will be in db */ - if (temp2 > 0x7F00) - snrdb = 1000*24 + ( 1000*(30-24) * ( temp2 - 0x7F00 ) / ( 0x7FFF - 0x7F00 ) ); - else if (temp2 > 0x7EC0) - snrdb = 1000*18 + ( 1000*(24-18) * ( temp2 - 0x7EC0 ) / ( 0x7F00 - 0x7EC0 ) ); - else if (temp2 > 0x7C00) - snrdb = 1000*12 + ( 1000*(18-12) * ( temp2 - 0x7C00 ) / ( 0x7EC0 - 0x7C00 ) ); - else - snrdb = 1000*0 + ( 1000*(12-0) * ( temp2 - 0 ) / ( 0x7C00 - 0 ) ); - - /* the value reported back from the frontend will be FFFF=32db 0000=0db */ - - *snr = snrdb * (0xFFFF/32000); - - return 0; -} - -static int nxt2002_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) -{ - struct nxt2002_state* state = fe->demodulator_priv; - u8 b[3]; - - nxt2002_readreg_multibyte(state,0xE6,b,3); - *ucblocks = b[2]; - - return 0; -} - -static int nxt2002_sleep(struct dvb_frontend* fe) -{ - return 0; -} - -static int nxt2002_init(struct dvb_frontend* fe) -{ - struct nxt2002_state* state = fe->demodulator_priv; - const struct firmware *fw; - int ret; - u8 buf[2]; - - if (!state->initialised) { - /* request the firmware, this will block until someone uploads it */ - printk("nxt2002: Waiting for firmware upload (%s)...\n", NXT2002_DEFAULT_FIRMWARE); - ret = state->config->request_firmware(fe, &fw, NXT2002_DEFAULT_FIRMWARE); - printk("nxt2002: Waiting for firmware upload(2)...\n"); - if (ret) { - printk("nxt2002: no firmware upload (timeout or file not found?)\n"); - return ret; - } - - ret = nxt2002_load_firmware(fe, fw); - if (ret) { - printk("nxt2002: writing firmware to device failed\n"); - release_firmware(fw); - return ret; - } - printk("nxt2002: firmware upload complete\n"); - - /* Put the micro into reset */ - nxt2002_microcontroller_stop(state); - - /* ensure transfer is complete */ - buf[0]=0; - i2c_writebytes(state,0x2B,buf,1); - - /* Put the micro into reset for real this time */ - nxt2002_microcontroller_stop(state); - - /* soft reset everything (agc,frontend,eq,fec)*/ - buf[0] = 0x0F; - i2c_writebytes(state,0x08,buf,1); - buf[0] = 0x00; - i2c_writebytes(state,0x08,buf,1); - - /* write agc sdm configure */ - buf[0] = 0xF1; - i2c_writebytes(state,0x57,buf,1); - - /* write mod output format */ - buf[0] = 0x20; - i2c_writebytes(state,0x09,buf,1); - - /* write fec mpeg mode */ - buf[0] = 0x7E; - buf[1] = 0x00; - i2c_writebytes(state,0xE9,buf,2); - - /* write mux selection */ - buf[0] = 0x00; - i2c_writebytes(state,0xCC,buf,1); - - state->initialised = 1; - } - - return 0; -} - -static int nxt2002_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) -{ - fesettings->min_delay_ms = 500; - fesettings->step_size = 0; - fesettings->max_drift = 0; - return 0; -} - -static void nxt2002_release(struct dvb_frontend* fe) -{ - struct nxt2002_state* state = fe->demodulator_priv; - kfree(state); -} - -static struct dvb_frontend_ops nxt2002_ops; - -struct dvb_frontend* nxt2002_attach(const struct nxt2002_config* config, - struct i2c_adapter* i2c) -{ - struct nxt2002_state* state = NULL; - u8 buf [] = {0,0,0,0,0}; - - /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct nxt2002_state), GFP_KERNEL); - if (state == NULL) goto error; - - /* setup the state */ - state->config = config; - state->i2c = i2c; - memcpy(&state->ops, &nxt2002_ops, sizeof(struct dvb_frontend_ops)); - state->initialised = 0; - - /* Check the first 5 registers to ensure this a revision we can handle */ - - i2c_readbytes(state, 0x00, buf, 5); - if (buf[0] != 0x04) goto error; /* device id */ - if (buf[1] != 0x02) goto error; /* fab id */ - if (buf[2] != 0x11) goto error; /* month */ - if (buf[3] != 0x20) goto error; /* year msb */ - if (buf[4] != 0x00) goto error; /* year lsb */ - - /* create dvb_frontend */ - state->frontend.ops = &state->ops; - state->frontend.demodulator_priv = state; - return &state->frontend; - -error: - kfree(state); - return NULL; -} - -static struct dvb_frontend_ops nxt2002_ops = { - - .info = { - .name = "Nextwave nxt2002 VSB/QAM frontend", - .type = FE_ATSC, - .frequency_min = 54000000, - .frequency_max = 860000000, - /* stepsize is just a guess */ - .frequency_stepsize = 166666, - .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | - FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | - FE_CAN_8VSB | FE_CAN_QAM_64 | FE_CAN_QAM_256 - }, - - .release = nxt2002_release, - - .init = nxt2002_init, - .sleep = nxt2002_sleep, - - .set_frontend = nxt2002_setup_frontend_parameters, - .get_tune_settings = nxt2002_get_tune_settings, - - .read_status = nxt2002_read_status, - .read_ber = nxt2002_read_ber, - .read_signal_strength = nxt2002_read_signal_strength, - .read_snr = nxt2002_read_snr, - .read_ucblocks = nxt2002_read_ucblocks, - -}; - -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); - -MODULE_DESCRIPTION("NXT2002 ATSC (8VSB & ITU J83 AnnexB FEC QAM64/256) demodulator driver"); -MODULE_AUTHOR("Taylor Jacob"); -MODULE_LICENSE("GPL"); - -EXPORT_SYMBOL(nxt2002_attach); diff --git a/drivers/media/dvb/frontends/nxt2002.h b/drivers/media/dvb/frontends/nxt2002.h deleted file mode 100644 index 462301f577e..00000000000 --- a/drivers/media/dvb/frontends/nxt2002.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - Driver for the Nxt2002 demodulator -*/ - -#ifndef NXT2002_H -#define NXT2002_H - -#include -#include - -struct nxt2002_config -{ - /* the demodulator's i2c address */ - u8 demod_address; - - /* request firmware for device */ - int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); -}; - -extern struct dvb_frontend* nxt2002_attach(const struct nxt2002_config* config, - struct i2c_adapter* i2c); - -#endif // NXT2002_H diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c index 78d2b93d35b..9e353539450 100644 --- a/drivers/media/dvb/frontends/nxt200x.c +++ b/drivers/media/dvb/frontends/nxt200x.c @@ -1,9 +1,10 @@ /* * Support for NXT2002 and NXT2004 - VSB/QAM * - * Copyright (C) 2005 Kirk Lapray (kirk.lapray@gmail.com) + * Copyright (C) 2005 Kirk Lapray + * Copyright (C) 2006 Michael Krufky * based on nxt2002 by Taylor Jacob - * and nxt2004 by Jean-Francois Thibert (jeanfrancois@sagetv.com) + * and nxt2004 by Jean-Francois Thibert * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -614,7 +615,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe, /* write sdm1 input */ buf[0] = 0x10; buf[1] = 0x00; - nxt200x_writebytes(state, 0x58, buf, 2); + switch (state->demod_chip) { + case NXT2002: + nxt200x_writereg_multibyte(state, 0x58, buf, 2); + break; + case NXT2004: + nxt200x_writebytes(state, 0x58, buf, 2); + break; + default: + return -EINVAL; + break; + } /* write sdmx input */ switch (p->u.vsb.modulation) { @@ -632,7 +643,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe, break; } buf[1] = 0x00; - nxt200x_writebytes(state, 0x5C, buf, 2); + switch (state->demod_chip) { + case NXT2002: + nxt200x_writereg_multibyte(state, 0x5C, buf, 2); + break; + case NXT2004: + nxt200x_writebytes(state, 0x5C, buf, 2); + break; + default: + return -EINVAL; + break; + } /* write adc power lpf fc */ buf[0] = 0x05; @@ -648,7 +669,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe, /* write accumulator2 input */ buf[0] = 0x80; buf[1] = 0x00; - nxt200x_writebytes(state, 0x4B, buf, 2); + switch (state->demod_chip) { + case NXT2002: + nxt200x_writereg_multibyte(state, 0x4B, buf, 2); + break; + case NXT2004: + nxt200x_writebytes(state, 0x4B, buf, 2); + break; + default: + return -EINVAL; + break; + } /* write kg1 */ buf[0] = 0x00; @@ -714,8 +745,19 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe, /* write accumulator2 input */ buf[0] = 0x80; buf[1] = 0x00; - nxt200x_writebytes(state, 0x49, buf,2); - nxt200x_writebytes(state, 0x4B, buf,2); + switch (state->demod_chip) { + case NXT2002: + nxt200x_writereg_multibyte(state, 0x49, buf, 2); + nxt200x_writereg_multibyte(state, 0x4B, buf, 2); + break; + case NXT2004: + nxt200x_writebytes(state, 0x49, buf, 2); + nxt200x_writebytes(state, 0x4B, buf, 2); + break; + default: + return -EINVAL; + break; + } /* write agc control reg */ buf[0] = 0x04; @@ -1199,7 +1241,7 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); MODULE_DESCRIPTION("NXT200X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver"); -MODULE_AUTHOR("Kirk Lapray, Jean-Francois Thibert, and Taylor Jacob"); +MODULE_AUTHOR("Kirk Lapray, Michael Krufky, Jean-Francois Thibert, and Taylor Jacob"); MODULE_LICENSE("GPL"); EXPORT_SYMBOL(nxt200x_attach); -- cgit v1.2.3 From 28f3d4b37db26a30b8990e039b6881b43de815f9 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Mon, 23 Jan 2006 17:11:07 -0200 Subject: V4L/DVB (3414): rename dvb_pll_tbmv30111in to dvb_pll_samsung_tbmv - rename dvb_pll_tbmv30111in to dvb_pll_samsung_tbmv Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/dvb-pll.c | 6 +++--- drivers/media/dvb/frontends/dvb-pll.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index 9c9c12af579..4dcb6050d4f 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c @@ -329,8 +329,8 @@ EXPORT_SYMBOL(dvb_pll_tuv1236d); /* Samsung TBMV30111IN / TBMV30712IN1 * used in Air2PC ATSC - 2nd generation (nxt2002) */ -struct dvb_pll_desc dvb_pll_tbmv30111in = { - .name = "Samsung TBMV30111IN", +struct dvb_pll_desc dvb_pll_samsung_tbmv = { + .name = "Samsung TBMV30111IN / TBMV30712IN1", .min = 54000000, .max = 860000000, .count = 6, @@ -343,7 +343,7 @@ struct dvb_pll_desc dvb_pll_tbmv30111in = { { 999999999, 44000000, 166666, 0xfc, 0x02 }, } }; -EXPORT_SYMBOL(dvb_pll_tbmv30111in); +EXPORT_SYMBOL(dvb_pll_samsung_tbmv); /* * Philips SD1878 Tuner. diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h index f682c09189b..bb8d4b4eb18 100644 --- a/drivers/media/dvb/frontends/dvb-pll.h +++ b/drivers/media/dvb/frontends/dvb-pll.h @@ -38,7 +38,7 @@ extern struct dvb_pll_desc dvb_pll_tded4; extern struct dvb_pll_desc dvb_pll_tuv1236d; extern struct dvb_pll_desc dvb_pll_tdhu2; -extern struct dvb_pll_desc dvb_pll_tbmv30111in; +extern struct dvb_pll_desc dvb_pll_samsung_tbmv; extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261; int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, -- cgit v1.2.3 From ab66b22f0c4e5786d59fa23569ac37a4a21ab4fb Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Mon, 23 Jan 2006 17:11:11 -0200 Subject: V4L/DVB (3435): rename cb variable names in tuner structures for global consistency - rename cb variable names in tuner structures for global consistency Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/dvb-pll.c | 4 ++-- drivers/media/dvb/frontends/dvb-pll.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index 4dcb6050d4f..cd8f28275ed 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c @@ -391,8 +391,8 @@ int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize; buf[0] = div >> 8; buf[1] = div & 0xff; - buf[2] = desc->entries[i].cb1; - buf[3] = desc->entries[i].cb2; + buf[2] = desc->entries[i].config; + buf[3] = desc->entries[i].cb; if (desc->setbw) desc->setbw(buf, freq, bandwidth); diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h index bb8d4b4eb18..872e3b4c139 100644 --- a/drivers/media/dvb/frontends/dvb-pll.h +++ b/drivers/media/dvb/frontends/dvb-pll.h @@ -15,8 +15,8 @@ struct dvb_pll_desc { u32 limit; u32 offset; u32 stepsize; - u8 cb1; - u8 cb2; + u8 config; + u8 cb; } entries[12]; }; -- cgit v1.2.3 From a78d0bfabda67dd40a5a97ba4c24265e1820e7ea Mon Sep 17 00:00:00 2001 From: Jose Alberto Reguero Date: Tue, 7 Feb 2006 06:25:14 -0200 Subject: V4L/DVB (3267): Add support for the Avermedia 777 DVB-T card Signed-off-by: Jose Alberto Reguero Signed-off-by: Hartmut Hackmann Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/dvb-pll.c | 42 +++++++++++++++++++++++++++++++++++ drivers/media/dvb/frontends/dvb-pll.h | 1 + 2 files changed, 43 insertions(+) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index cd8f28275ed..4f682534df4 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c @@ -362,6 +362,48 @@ struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { }; EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261); +/* + * Philips TD1316 Tuner. + */ +static void td1316_bw(u8 *buf, u32 freq, int bandwidth) +{ + u8 band; + + /* determine band */ + if (freq < 161000000) + band = 1; + else if (freq < 444000000) + band = 2; + else + band = 4; + + buf[3] |= band; + + /* setup PLL filter */ + if (bandwidth == BANDWIDTH_8_MHZ) + buf[3] |= 1 << 3; +} + +struct dvb_pll_desc dvb_pll_philips_td1316 = { + .name = "Philips TD1316", + .min = 87000000, + .max = 895000000, + .setbw = td1316_bw, + .count = 9, + .entries = { + { 93834000, 36166000, 166666, 0xca, 0x60}, + { 123834000, 36166000, 166666, 0xca, 0xa0}, + { 163834000, 36166000, 166666, 0xca, 0xc0}, + { 253834000, 36166000, 166666, 0xca, 0x60}, + { 383834000, 36166000, 166666, 0xca, 0xa0}, + { 443834000, 36166000, 166666, 0xca, 0xc0}, + { 583834000, 36166000, 166666, 0xca, 0x60}, + { 793834000, 36166000, 166666, 0xca, 0xa0}, + { 858834000, 36166000, 166666, 0xca, 0xe0}, + }, +}; +EXPORT_SYMBOL(dvb_pll_philips_td1316); + /* ----------------------------------------------------------- */ /* code */ diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h index 872e3b4c139..56c3cd76a7f 100644 --- a/drivers/media/dvb/frontends/dvb-pll.h +++ b/drivers/media/dvb/frontends/dvb-pll.h @@ -40,6 +40,7 @@ extern struct dvb_pll_desc dvb_pll_tuv1236d; extern struct dvb_pll_desc dvb_pll_tdhu2; extern struct dvb_pll_desc dvb_pll_samsung_tbmv; extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261; +extern struct dvb_pll_desc dvb_pll_philips_td1316; int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, u32 freq, int bandwidth); -- cgit v1.2.3 From 0eb3de20a1cec67547951cebc4fcddc701e7428b Mon Sep 17 00:00:00 2001 From: Hartmut Hackmann Date: Tue, 7 Feb 2006 06:49:10 -0200 Subject: V4L/DVB (3304): TDA10046 Driver update - Set outputs to tristate in sleep mode - Reduce dangerously high firmware download speed with 16MHz xtal - added tda827x configuration with GPIOs low - added comments to stupid looking IIC reads that work around bugs in the tda10046. - some minor updates Signed-off-by: Hartmut Hackmann Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/tda1004x.c | 25 +++++++++++++++++++++---- drivers/media/dvb/frontends/tda1004x.h | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index c63e9a5084e..8e8df7b4ca0 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c @@ -229,7 +229,7 @@ static int tda1004x_enable_tuner_i2c(struct tda1004x_state *state) dprintk("%s\n", __FUNCTION__); result = tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 2); - msleep(1); + msleep(20); return result; } @@ -502,7 +502,12 @@ static int tda10046_fwupload(struct dvb_frontend* fe) const struct firmware *fw; /* reset + wake up chip */ - tda1004x_write_byteI(state, TDA1004X_CONFC4, 0); + if (state->config->xtal_freq == TDA10046_XTAL_4M) { + tda1004x_write_byteI(state, TDA1004X_CONFC4, 0); + } else { + dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __FUNCTION__); + tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80); + } tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); /* let the clocks recover from sleep */ msleep(5); @@ -651,7 +656,7 @@ static int tda10046_init(struct dvb_frontend* fe) // tda setup tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream - tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer + tda1004x_write_byteI(state, TDA1004X_CONFC1, 0x88); // enable pulse killer switch (state->config->agc_config) { case TDA10046_AGC_DEFAULT: @@ -672,6 +677,12 @@ static int tda10046_init(struct dvb_frontend* fe) tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x6a); // set AGC polarities break; + case TDA10046_AGC_TDA827X_GPL: + tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup + tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold + tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize + tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities + break; } tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38); tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on @@ -683,6 +694,7 @@ static int tda10046_init(struct dvb_frontend* fe) tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config + // tda1004x_write_mask(state, 0x50, 0x80, 0x80); // handle out of guard echoes tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7); state->initialised = 1; @@ -1027,6 +1039,7 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status if (status == -1) return -EIO; cber |= (status << 8); + // The address 0x20 should be read to cope with a TDA10046 bug tda1004x_read_byte(state, TDA1004X_CBER_RESET); if (cber != 65535) @@ -1047,7 +1060,8 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status status = tda1004x_read_byte(state, TDA1004X_VBER_MSB); if (status == -1) return -EIO; - vber |= ((status << 16) & 0x0f); + vber |= (status & 0x0f) << 16; + // The CVBER_LUT should be read to cope with TDA10046 hardware bug tda1004x_read_byte(state, TDA1004X_CVBER_LUT); // if RS has passed some valid TS packets, then we must be @@ -1161,6 +1175,7 @@ static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber) if (tmp < 0) return -EIO; *ber |= (tmp << 9); + // The address 0x20 should be read to cope with a TDA10046 bug tda1004x_read_byte(state, TDA1004X_CBER_RESET); dprintk("%s: ber=0x%x\n", __FUNCTION__, *ber); @@ -1187,6 +1202,8 @@ static int tda1004x_sleep(struct dvb_frontend* fe) tda1004x_disable_tuner_i2c(state); } } + /* set outputs to tristate */ + tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff); tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1); break; } diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h index 8659c52647a..cc0c4af6406 100644 --- a/drivers/media/dvb/frontends/tda1004x.h +++ b/drivers/media/dvb/frontends/tda1004x.h @@ -35,7 +35,8 @@ enum tda10046_agc { TDA10046_AGC_DEFAULT, /* original configuration */ TDA10046_AGC_IFO_AUTO_NEG, /* IF AGC only, automatic, negtive */ TDA10046_AGC_IFO_AUTO_POS, /* IF AGC only, automatic, positive */ - TDA10046_AGC_TDA827X, /* IF AGC only, special setup for tda827x */ + TDA10046_AGC_TDA827X, /* IF AGC only, special setup for tda827x */ + TDA10046_AGC_TDA827X_GPL, /* same as above, but GPIOs 0 */ }; enum tda10046_if { -- cgit v1.2.3 From 3593cab5d62c4c7abced1076710f9bc2d8847433 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Tue, 7 Feb 2006 06:49:14 -0200 Subject: V4L/DVB (3318b): sem2mutex: drivers/media/, #2 Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/bcm3510.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/bcm3510.c b/drivers/media/dvb/frontends/bcm3510.c index caaee893ca7..1708a1d4893 100644 --- a/drivers/media/dvb/frontends/bcm3510.c +++ b/drivers/media/dvb/frontends/bcm3510.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "dvb_frontend.h" #include "bcm3510.h" @@ -52,7 +53,7 @@ struct bcm3510_state { struct dvb_frontend frontend; /* demodulator private data */ - struct semaphore hab_sem; + struct mutex hab_mutex; u8 firmware_loaded:1; unsigned long next_status_check; @@ -213,7 +214,7 @@ static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *ob dbufout(ob,olen+2,deb_hab); deb_hab("\n"); - if (down_interruptible(&st->hab_sem) < 0) + if (mutex_lock_interruptible(&st->hab_mutex) < 0) return -EAGAIN; if ((ret = bcm3510_hab_send_request(st, ob, olen+2)) < 0 || @@ -226,7 +227,7 @@ static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *ob memcpy(ibuf,&ib[2],ilen); error: - up(&st->hab_sem); + mutex_unlock(&st->hab_mutex); return ret; } @@ -796,7 +797,7 @@ struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config, state->frontend.ops = &state->ops; state->frontend.demodulator_priv = state; - sema_init(&state->hab_sem, 1); + mutex_init(&state->hab_mutex); if ((ret = bcm3510_readB(state,0xe0,&v)) < 0) goto error; -- cgit v1.2.3 From 2d77645a0e8228d3473008ec736e89b7105eafff Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 7 Feb 2006 06:49:15 -0200 Subject: V4L/DVB (3318e): DVB: remove the at76c651/tda80xx frontends The at76c651 and tda80xx frontends are currently completely unused, IOW their only effect is making the kernel larger for people accitentially enabling them. The current in-kernel drivers differ from the drivers at cvs.tuxbox.org, and re-adding them when parts of the dbox2 project get merged should be trivial. Signed-off-by: Adrian Bunk Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/Kconfig | 12 - drivers/media/dvb/frontends/Makefile | 2 - drivers/media/dvb/frontends/at76c651.c | 450 -------------------- drivers/media/dvb/frontends/at76c651.h | 47 --- drivers/media/dvb/frontends/tda80xx.c | 734 --------------------------------- drivers/media/dvb/frontends/tda80xx.h | 51 --- 6 files changed, 1296 deletions(-) delete mode 100644 drivers/media/dvb/frontends/at76c651.c delete mode 100644 drivers/media/dvb/frontends/at76c651.h delete mode 100644 drivers/media/dvb/frontends/tda80xx.c delete mode 100644 drivers/media/dvb/frontends/tda80xx.h (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index f09e3da669f..76b6a2aef32 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -28,12 +28,6 @@ config DVB_TDA8083 help A DVB-S tuner module. Say Y when you want to support this frontend. -config DVB_TDA80XX - tristate "Philips TDA8044 or TDA8083 based" - depends on DVB_CORE - help - A DVB-S tuner module. Say Y when you want to support this frontend. - config DVB_MT312 tristate "Zarlink MT312 based" depends on DVB_CORE @@ -139,12 +133,6 @@ config DVB_DIB3000MC comment "DVB-C (cable) frontends" depends on DVB_CORE -config DVB_ATMEL_AT76C651 - tristate "Atmel AT76C651 based" - depends on DVB_CORE - help - A DVB-C tuner module. Say Y when you want to support this frontend. - config DVB_VES1820 tristate "VLSI VES1820 based" depends on DVB_CORE diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 8f301468568..1af769cd90c 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_DVB_CORE) += dvb-pll.o obj-$(CONFIG_DVB_STV0299) += stv0299.o obj-$(CONFIG_DVB_SP8870) += sp8870.o obj-$(CONFIG_DVB_CX22700) += cx22700.o -obj-$(CONFIG_DVB_ATMEL_AT76C651) += at76c651.o obj-$(CONFIG_DVB_CX24110) += cx24110.o obj-$(CONFIG_DVB_TDA8083) += tda8083.o obj-$(CONFIG_DVB_L64781) += l64781.o @@ -22,7 +21,6 @@ obj-$(CONFIG_DVB_SP887X) += sp887x.o obj-$(CONFIG_DVB_NXT6000) += nxt6000.o obj-$(CONFIG_DVB_MT352) += mt352.o obj-$(CONFIG_DVB_CX22702) += cx22702.o -obj-$(CONFIG_DVB_TDA80XX) += tda80xx.o obj-$(CONFIG_DVB_TDA10021) += tda10021.o obj-$(CONFIG_DVB_STV0297) += stv0297.o obj-$(CONFIG_DVB_NXT200X) += nxt200x.o diff --git a/drivers/media/dvb/frontends/at76c651.c b/drivers/media/dvb/frontends/at76c651.c deleted file mode 100644 index 8e0f4b3a141..00000000000 --- a/drivers/media/dvb/frontends/at76c651.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * at76c651.c - * - * Atmel DVB-C Frontend Driver (at76c651/tua6010xs) - * - * Copyright (C) 2001 fnbrd - * & 2002-2004 Andreas Oberritter - * & 2003 Wolfram Joost - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * AT76C651 - * http://www.nalanda.nitc.ac.in/industry/datasheets/atmel/acrobat/doc1293.pdf - * http://www.atmel.com/atmel/acrobat/doc1320.pdf - */ - -#include -#include -#include -#include -#include -#include -#include -#include "dvb_frontend.h" -#include "at76c651.h" - - -struct at76c651_state { - - struct i2c_adapter* i2c; - - struct dvb_frontend_ops ops; - - const struct at76c651_config* config; - - struct dvb_frontend frontend; - - /* revision of the chip */ - u8 revision; - - /* last QAM value set */ - u8 qam; -}; - -static int debug; -#define dprintk(args...) \ - do { \ - if (debug) printk(KERN_DEBUG "at76c651: " args); \ - } while (0) - - -#if ! defined(__powerpc__) -static __inline__ int __ilog2(unsigned long x) -{ - int i; - - if (x == 0) - return -1; - - for (i = 0; x != 0; i++) - x >>= 1; - - return i - 1; -} -#endif - -static int at76c651_writereg(struct at76c651_state* state, u8 reg, u8 data) -{ - int ret; - u8 buf[] = { reg, data }; - struct i2c_msg msg = - { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; - - ret = i2c_transfer(state->i2c, &msg, 1); - - if (ret != 1) - dprintk("%s: writereg error " - "(reg == 0x%02x, val == 0x%02x, ret == %i)\n", - __FUNCTION__, reg, data, ret); - - msleep(10); - - return (ret != 1) ? -EREMOTEIO : 0; -} - -static u8 at76c651_readreg(struct at76c651_state* state, u8 reg) -{ - int ret; - u8 val; - struct i2c_msg msg[] = { - { .addr = state->config->demod_address, .flags = 0, .buf = ®, .len = 1 }, - { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = &val, .len = 1 } - }; - - ret = i2c_transfer(state->i2c, msg, 2); - - if (ret != 2) - dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret); - - return val; -} - -static int at76c651_reset(struct at76c651_state* state) -{ - return at76c651_writereg(state, 0x07, 0x01); -} - -static void at76c651_disable_interrupts(struct at76c651_state* state) -{ - at76c651_writereg(state, 0x0b, 0x00); -} - -static int at76c651_set_auto_config(struct at76c651_state *state) -{ - /* - * Autoconfig - */ - - at76c651_writereg(state, 0x06, 0x01); - - /* - * Performance optimizations, should be done after autoconfig - */ - - at76c651_writereg(state, 0x10, 0x06); - at76c651_writereg(state, 0x11, ((state->qam == 5) || (state->qam == 7)) ? 0x12 : 0x10); - at76c651_writereg(state, 0x15, 0x28); - at76c651_writereg(state, 0x20, 0x09); - at76c651_writereg(state, 0x24, ((state->qam == 5) || (state->qam == 7)) ? 0xC0 : 0x90); - at76c651_writereg(state, 0x30, 0x90); - if (state->qam == 5) - at76c651_writereg(state, 0x35, 0x2A); - - /* - * Initialize A/D-converter - */ - - if (state->revision == 0x11) { - at76c651_writereg(state, 0x2E, 0x38); - at76c651_writereg(state, 0x2F, 0x13); - } - - at76c651_disable_interrupts(state); - - /* - * Restart operation - */ - - at76c651_reset(state); - - return 0; -} - -static void at76c651_set_bbfreq(struct at76c651_state* state) -{ - at76c651_writereg(state, 0x04, 0x3f); - at76c651_writereg(state, 0x05, 0xee); -} - -static int at76c651_set_symbol_rate(struct at76c651_state* state, u32 symbol_rate) -{ - u8 exponent; - u32 mantissa; - - if (symbol_rate > 9360000) - return -EINVAL; - - /* - * FREF = 57800 kHz - * exponent = 10 + floor (log2(symbol_rate / FREF)) - * mantissa = (symbol_rate / FREF) * (1 << (30 - exponent)) - */ - - exponent = __ilog2((symbol_rate << 4) / 903125); - mantissa = ((symbol_rate / 3125) * (1 << (24 - exponent))) / 289; - - at76c651_writereg(state, 0x00, mantissa >> 13); - at76c651_writereg(state, 0x01, mantissa >> 5); - at76c651_writereg(state, 0x02, (mantissa << 3) | exponent); - - return 0; -} - -static int at76c651_set_qam(struct at76c651_state *state, fe_modulation_t qam) -{ - switch (qam) { - case QPSK: - state->qam = 0x02; - break; - case QAM_16: - state->qam = 0x04; - break; - case QAM_32: - state->qam = 0x05; - break; - case QAM_64: - state->qam = 0x06; - break; - case QAM_128: - state->qam = 0x07; - break; - case QAM_256: - state->qam = 0x08; - break; -#if 0 - case QAM_512: - state->qam = 0x09; - break; - case QAM_1024: - state->qam = 0x0A; - break; -#endif - default: - return -EINVAL; - - } - - return at76c651_writereg(state, 0x03, state->qam); -} - -static int at76c651_set_inversion(struct at76c651_state* state, fe_spectral_inversion_t inversion) -{ - u8 feciqinv = at76c651_readreg(state, 0x60); - - switch (inversion) { - case INVERSION_OFF: - feciqinv |= 0x02; - feciqinv &= 0xFE; - break; - - case INVERSION_ON: - feciqinv |= 0x03; - break; - - case INVERSION_AUTO: - feciqinv &= 0xFC; - break; - - default: - return -EINVAL; - } - - return at76c651_writereg(state, 0x60, feciqinv); -} - -static int at76c651_set_parameters(struct dvb_frontend* fe, - struct dvb_frontend_parameters *p) -{ - int ret; - struct at76c651_state* state = fe->demodulator_priv; - - at76c651_writereg(state, 0x0c, 0xc3); - state->config->pll_set(fe, p); - at76c651_writereg(state, 0x0c, 0xc2); - - if ((ret = at76c651_set_symbol_rate(state, p->u.qam.symbol_rate))) - return ret; - - if ((ret = at76c651_set_inversion(state, p->inversion))) - return ret; - - return at76c651_set_auto_config(state); -} - -static int at76c651_set_defaults(struct dvb_frontend* fe) -{ - struct at76c651_state* state = fe->demodulator_priv; - - at76c651_set_symbol_rate(state, 6900000); - at76c651_set_qam(state, QAM_64); - at76c651_set_bbfreq(state); - at76c651_set_auto_config(state); - - if (state->config->pll_init) { - at76c651_writereg(state, 0x0c, 0xc3); - state->config->pll_init(fe); - at76c651_writereg(state, 0x0c, 0xc2); - } - - return 0; -} - -static int at76c651_read_status(struct dvb_frontend* fe, fe_status_t* status) -{ - struct at76c651_state* state = fe->demodulator_priv; - u8 sync; - - /* - * Bits: FEC, CAR, EQU, TIM, AGC2, AGC1, ADC, PLL (PLL=0) - */ - sync = at76c651_readreg(state, 0x80); - *status = 0; - - if (sync & (0x04 | 0x10)) /* AGC1 || TIM */ - *status |= FE_HAS_SIGNAL; - if (sync & 0x10) /* TIM */ - *status |= FE_HAS_CARRIER; - if (sync & 0x80) /* FEC */ - *status |= FE_HAS_VITERBI; - if (sync & 0x40) /* CAR */ - *status |= FE_HAS_SYNC; - if ((sync & 0xF0) == 0xF0) /* TIM && EQU && CAR && FEC */ - *status |= FE_HAS_LOCK; - - return 0; -} - -static int at76c651_read_ber(struct dvb_frontend* fe, u32* ber) -{ - struct at76c651_state* state = fe->demodulator_priv; - - *ber = (at76c651_readreg(state, 0x81) & 0x0F) << 16; - *ber |= at76c651_readreg(state, 0x82) << 8; - *ber |= at76c651_readreg(state, 0x83); - *ber *= 10; - - return 0; -} - -static int at76c651_read_signal_strength(struct dvb_frontend* fe, u16* strength) -{ - struct at76c651_state* state = fe->demodulator_priv; - - u8 gain = ~at76c651_readreg(state, 0x91); - *strength = (gain << 8) | gain; - - return 0; -} - -static int at76c651_read_snr(struct dvb_frontend* fe, u16* snr) -{ - struct at76c651_state* state = fe->demodulator_priv; - - *snr = 0xFFFF - - ((at76c651_readreg(state, 0x8F) << 8) | - at76c651_readreg(state, 0x90)); - - return 0; -} - -static int at76c651_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) -{ - struct at76c651_state* state = fe->demodulator_priv; - - *ucblocks = at76c651_readreg(state, 0x82); - - return 0; -} - -static int at76c651_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *fesettings) -{ - fesettings->min_delay_ms = 50; - fesettings->step_size = 0; - fesettings->max_drift = 0; - return 0; -} - -static void at76c651_release(struct dvb_frontend* fe) -{ - struct at76c651_state* state = fe->demodulator_priv; - kfree(state); -} - -static struct dvb_frontend_ops at76c651_ops; - -struct dvb_frontend* at76c651_attach(const struct at76c651_config* config, - struct i2c_adapter* i2c) -{ - struct at76c651_state* state = NULL; - - /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct at76c651_state), GFP_KERNEL); - if (state == NULL) goto error; - - /* setup the state */ - state->config = config; - state->qam = 0; - - /* check if the demod is there */ - if (at76c651_readreg(state, 0x0e) != 0x65) goto error; - - /* finalise state setup */ - state->i2c = i2c; - state->revision = at76c651_readreg(state, 0x0f) & 0xfe; - memcpy(&state->ops, &at76c651_ops, sizeof(struct dvb_frontend_ops)); - - /* create dvb_frontend */ - state->frontend.ops = &state->ops; - state->frontend.demodulator_priv = state; - return &state->frontend; - -error: - kfree(state); - return NULL; -} - -static struct dvb_frontend_ops at76c651_ops = { - - .info = { - .name = "Atmel AT76C651B DVB-C", - .type = FE_QAM, - .frequency_min = 48250000, - .frequency_max = 863250000, - .frequency_stepsize = 62500, - /*.frequency_tolerance = */ /* FIXME: 12% of SR */ - .symbol_rate_min = 0, /* FIXME */ - .symbol_rate_max = 9360000, /* FIXME */ - .symbol_rate_tolerance = 4000, - .caps = FE_CAN_INVERSION_AUTO | - FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | - FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | - FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | - FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 | FE_CAN_QAM_128 | - FE_CAN_MUTE_TS | FE_CAN_QAM_256 | FE_CAN_RECOVER - }, - - .release = at76c651_release, - - .init = at76c651_set_defaults, - - .set_frontend = at76c651_set_parameters, - .get_tune_settings = at76c651_get_tune_settings, - - .read_status = at76c651_read_status, - .read_ber = at76c651_read_ber, - .read_signal_strength = at76c651_read_signal_strength, - .read_snr = at76c651_read_snr, - .read_ucblocks = at76c651_read_ucblocks, -}; - -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); - -MODULE_DESCRIPTION("Atmel AT76C651 DVB-C Demodulator Driver"); -MODULE_AUTHOR("Andreas Oberritter "); -MODULE_LICENSE("GPL"); - -EXPORT_SYMBOL(at76c651_attach); diff --git a/drivers/media/dvb/frontends/at76c651.h b/drivers/media/dvb/frontends/at76c651.h deleted file mode 100644 index 34054df9360..00000000000 --- a/drivers/media/dvb/frontends/at76c651.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * at76c651.c - * - * Atmel DVB-C Frontend Driver (at76c651) - * - * Copyright (C) 2001 fnbrd - * & 2002-2004 Andreas Oberritter - * & 2003 Wolfram Joost - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * AT76C651 - * http://www.nalanda.nitc.ac.in/industry/datasheets/atmel/acrobat/doc1293.pdf - * http://www.atmel.com/atmel/acrobat/doc1320.pdf - */ - -#ifndef AT76C651_H -#define AT76C651_H - -#include - -struct at76c651_config -{ - /* the demodulator's i2c address */ - u8 demod_address; - - /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); -}; - -extern struct dvb_frontend* at76c651_attach(const struct at76c651_config* config, - struct i2c_adapter* i2c); - -#endif // AT76C651_H diff --git a/drivers/media/dvb/frontends/tda80xx.c b/drivers/media/dvb/frontends/tda80xx.c deleted file mode 100644 index d1cabb6a0a1..00000000000 --- a/drivers/media/dvb/frontends/tda80xx.c +++ /dev/null @@ -1,734 +0,0 @@ -/* - * tda80xx.c - * - * Philips TDA8044 / TDA8083 QPSK demodulator driver - * - * Copyright (C) 2001 Felix Domke - * Copyright (C) 2002-2004 Andreas Oberritter - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dvb_frontend.h" -#include "tda80xx.h" - -enum { - ID_TDA8044 = 0x04, - ID_TDA8083 = 0x05, -}; - - -struct tda80xx_state { - - struct i2c_adapter* i2c; - - struct dvb_frontend_ops ops; - - /* configuration settings */ - const struct tda80xx_config* config; - - struct dvb_frontend frontend; - - u32 clk; - int afc_loop; - struct work_struct worklet; - fe_code_rate_t code_rate; - fe_spectral_inversion_t spectral_inversion; - fe_status_t status; - u8 id; -}; - -static int debug = 1; -#define dprintk if (debug) printk - -static u8 tda8044_inittab_pre[] = { - 0x02, 0x00, 0x6f, 0xb5, 0x86, 0x22, 0x00, 0xea, - 0x30, 0x42, 0x98, 0x68, 0x70, 0x42, 0x99, 0x58, - 0x95, 0x10, 0xf5, 0xe7, 0x93, 0x0b, 0x15, 0x68, - 0x9a, 0x90, 0x61, 0x80, 0x00, 0xe0, 0x40, 0x00, - 0x0f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -static u8 tda8044_inittab_post[] = { - 0x04, 0x00, 0x6f, 0xb5, 0x86, 0x22, 0x00, 0xea, - 0x30, 0x42, 0x98, 0x68, 0x70, 0x42, 0x99, 0x50, - 0x95, 0x10, 0xf5, 0xe7, 0x93, 0x0b, 0x15, 0x68, - 0x9a, 0x90, 0x61, 0x80, 0x00, 0xe0, 0x40, 0x6c, - 0x0f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -static u8 tda8083_inittab[] = { - 0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea, - 0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10, - 0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8, - 0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00, - 0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 -}; - -static __inline__ u32 tda80xx_div(u32 a, u32 b) -{ - return (a + (b / 2)) / b; -} - -static __inline__ u32 tda80xx_gcd(u32 a, u32 b) -{ - u32 r; - - while ((r = a % b)) { - a = b; - b = r; - } - - return b; -} - -static int tda80xx_read(struct tda80xx_state* state, u8 reg, u8 *buf, u8 len) -{ - int ret; - struct i2c_msg msg[] = { { .addr = state->config->demod_address, .flags = 0, .buf = ®, .len = 1 }, - { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len } }; - - ret = i2c_transfer(state->i2c, msg, 2); - - if (ret != 2) - dprintk("%s: readreg error (reg %02x, ret == %i)\n", - __FUNCTION__, reg, ret); - - mdelay(10); - - return (ret == 2) ? 0 : -EREMOTEIO; -} - -static int tda80xx_write(struct tda80xx_state* state, u8 reg, const u8 *buf, u8 len) -{ - int ret; - u8 wbuf[len + 1]; - struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = wbuf, .len = len + 1 }; - - wbuf[0] = reg; - memcpy(&wbuf[1], buf, len); - - ret = i2c_transfer(state->i2c, &msg, 1); - - if (ret != 1) - dprintk("%s: i2c xfer error (ret == %i)\n", __FUNCTION__, ret); - - mdelay(10); - - return (ret == 1) ? 0 : -EREMOTEIO; -} - -static __inline__ u8 tda80xx_readreg(struct tda80xx_state* state, u8 reg) -{ - u8 val; - - tda80xx_read(state, reg, &val, 1); - - return val; -} - -static __inline__ int tda80xx_writereg(struct tda80xx_state* state, u8 reg, u8 data) -{ - return tda80xx_write(state, reg, &data, 1); -} - -static int tda80xx_set_parameters(struct tda80xx_state* state, - fe_spectral_inversion_t inversion, - u32 symbol_rate, - fe_code_rate_t fec_inner) -{ - u8 buf[15]; - u64 ratio; - u32 clk; - u32 k; - u32 sr = symbol_rate; - u32 gcd; - u8 scd; - - if (symbol_rate > (state->clk * 3) / 16) - scd = 0; - else if (symbol_rate > (state->clk * 3) / 32) - scd = 1; - else if (symbol_rate > (state->clk * 3) / 64) - scd = 2; - else - scd = 3; - - clk = scd ? (state->clk / (scd * 2)) : state->clk; - - /* - * Viterbi decoder: - * Differential decoding off - * Spectral inversion unknown - * QPSK modulation - */ - if (inversion == INVERSION_ON) - buf[0] = 0x60; - else if (inversion == INVERSION_OFF) - buf[0] = 0x20; - else - buf[0] = 0x00; - - /* - * CLK ratio: - * system clock frequency is up to 64 or 96 MHz - * - * formula: - * r = k * clk / symbol_rate - * - * k: 2^21 for caa 0..3, - * 2^20 for caa 4..5, - * 2^19 for caa 6..7 - */ - if (symbol_rate <= (clk * 3) / 32) - k = (1 << 19); - else if (symbol_rate <= (clk * 3) / 16) - k = (1 << 20); - else - k = (1 << 21); - - gcd = tda80xx_gcd(clk, sr); - clk /= gcd; - sr /= gcd; - - gcd = tda80xx_gcd(k, sr); - k /= gcd; - sr /= gcd; - - ratio = (u64)k * (u64)clk; - do_div(ratio, sr); - - buf[1] = ratio >> 16; - buf[2] = ratio >> 8; - buf[3] = ratio; - - /* nyquist filter roll-off factor 35% */ - buf[4] = 0x20; - - clk = scd ? (state->clk / (scd * 2)) : state->clk; - - /* Anti Alias Filter */ - if (symbol_rate < (clk * 3) / 64) - printk("tda80xx: unsupported symbol rate: %u\n", symbol_rate); - else if (symbol_rate <= clk / 16) - buf[4] |= 0x07; - else if (symbol_rate <= (clk * 3) / 32) - buf[4] |= 0x06; - else if (symbol_rate <= clk / 8) - buf[4] |= 0x05; - else if (symbol_rate <= (clk * 3) / 16) - buf[4] |= 0x04; - else if (symbol_rate <= clk / 4) - buf[4] |= 0x03; - else if (symbol_rate <= (clk * 3) / 8) - buf[4] |= 0x02; - else if (symbol_rate <= clk / 2) - buf[4] |= 0x01; - else - buf[4] |= 0x00; - - /* Sigma Delta converter */ - buf[5] = 0x00; - - /* FEC: Possible puncturing rates */ - if (fec_inner == FEC_NONE) - buf[6] = 0x00; - else if ((fec_inner >= FEC_1_2) && (fec_inner <= FEC_8_9)) - buf[6] = (1 << (8 - fec_inner)); - else if (fec_inner == FEC_AUTO) - buf[6] = 0xff; - else - return -EINVAL; - - /* carrier lock detector threshold value */ - buf[7] = 0x30; - /* AFC1: proportional part settings */ - buf[8] = 0x42; - /* AFC1: integral part settings */ - buf[9] = 0x98; - /* PD: Leaky integrator SCPC mode */ - buf[10] = 0x28; - /* AFC2, AFC1 controls */ - buf[11] = 0x30; - /* PD: proportional part settings */ - buf[12] = 0x42; - /* PD: integral part settings */ - buf[13] = 0x99; - /* AGC */ - buf[14] = 0x50 | scd; - - printk("symbol_rate=%u clk=%u\n", symbol_rate, clk); - - return tda80xx_write(state, 0x01, buf, sizeof(buf)); -} - -static int tda80xx_set_clk(struct tda80xx_state* state) -{ - u8 buf[2]; - - /* CLK proportional part */ - buf[0] = (0x06 << 5) | 0x08; /* CMP[2:0], CSP[4:0] */ - /* CLK integral part */ - buf[1] = (0x04 << 5) | 0x1a; /* CMI[2:0], CSI[4:0] */ - - return tda80xx_write(state, 0x17, buf, sizeof(buf)); -} - -#if 0 -static int tda80xx_set_scpc_freq_offset(struct tda80xx_state* state) -{ - /* a constant value is nonsense here imho */ - return tda80xx_writereg(state, 0x22, 0xf9); -} -#endif - -static int tda80xx_close_loop(struct tda80xx_state* state) -{ - u8 buf[2]; - - /* PD: Loop closed, LD: lock detect enable, SCPC: Sweep mode - AFC1 loop closed */ - buf[0] = 0x68; - /* AFC1: Loop closed, CAR Feedback: 8192 */ - buf[1] = 0x70; - - return tda80xx_write(state, 0x0b, buf, sizeof(buf)); -} - -static irqreturn_t tda80xx_irq(int irq, void *priv, struct pt_regs *pt) -{ - schedule_work(priv); - - return IRQ_HANDLED; -} - -static void tda80xx_read_status_int(struct tda80xx_state* state) -{ - u8 val; - - static const fe_spectral_inversion_t inv_tab[] = { - INVERSION_OFF, INVERSION_ON - }; - - static const fe_code_rate_t fec_tab[] = { - FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4, - FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8, - }; - - val = tda80xx_readreg(state, 0x02); - - state->status = 0; - - if (val & 0x01) /* demodulator lock */ - state->status |= FE_HAS_SIGNAL; - if (val & 0x02) /* clock recovery lock */ - state->status |= FE_HAS_CARRIER; - if (val & 0x04) /* viterbi lock */ - state->status |= FE_HAS_VITERBI; - if (val & 0x08) /* deinterleaver lock (packet sync) */ - state->status |= FE_HAS_SYNC; - if (val & 0x10) /* derandomizer lock (frame sync) */ - state->status |= FE_HAS_LOCK; - if (val & 0x20) /* frontend can not lock */ - state->status |= FE_TIMEDOUT; - - if ((state->status & (FE_HAS_CARRIER)) && (state->afc_loop)) { - printk("tda80xx: closing loop\n"); - tda80xx_close_loop(state); - state->afc_loop = 0; - } - - if (state->status & (FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK)) { - val = tda80xx_readreg(state, 0x0e); - state->code_rate = fec_tab[val & 0x07]; - if (state->status & (FE_HAS_SYNC | FE_HAS_LOCK)) - state->spectral_inversion = inv_tab[(val >> 7) & 0x01]; - else - state->spectral_inversion = INVERSION_AUTO; - } - else { - state->code_rate = FEC_AUTO; - } -} - -static void tda80xx_worklet(void *priv) -{ - struct tda80xx_state *state = priv; - - tda80xx_writereg(state, 0x00, 0x04); - enable_irq(state->config->irq); - - tda80xx_read_status_int(state); -} - -static void tda80xx_wait_diseqc_fifo(struct tda80xx_state* state) -{ - size_t i; - - for (i = 0; i < 100; i++) { - if (tda80xx_readreg(state, 0x02) & 0x80) - break; - msleep(10); - } -} - -static int tda8044_init(struct dvb_frontend* fe) -{ - struct tda80xx_state* state = fe->demodulator_priv; - int ret; - - /* - * this function is a mess... - */ - - if ((ret = tda80xx_write(state, 0x00, tda8044_inittab_pre, sizeof(tda8044_inittab_pre)))) - return ret; - - tda80xx_writereg(state, 0x0f, 0x50); -#if 1 - tda80xx_writereg(state, 0x20, 0x8F); /* FIXME */ - tda80xx_writereg(state, 0x20, state->config->volt18setting); /* FIXME */ - //tda80xx_writereg(state, 0x00, 0x04); - tda80xx_writereg(state, 0x00, 0x0C); -#endif - //tda80xx_writereg(state, 0x00, 0x08); /* Reset AFC1 loop filter */ - - tda80xx_write(state, 0x00, tda8044_inittab_post, sizeof(tda8044_inittab_post)); - - if (state->config->pll_init) { - tda80xx_writereg(state, 0x1c, 0x80); - state->config->pll_init(fe); - tda80xx_writereg(state, 0x1c, 0x00); - } - - return 0; -} - -static int tda8083_init(struct dvb_frontend* fe) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - tda80xx_write(state, 0x00, tda8083_inittab, sizeof(tda8083_inittab)); - - if (state->config->pll_init) { - tda80xx_writereg(state, 0x1c, 0x80); - state->config->pll_init(fe); - tda80xx_writereg(state, 0x1c, 0x00); - } - - return 0; -} - -static int tda80xx_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - switch (voltage) { - case SEC_VOLTAGE_13: - return tda80xx_writereg(state, 0x20, state->config->volt13setting); - case SEC_VOLTAGE_18: - return tda80xx_writereg(state, 0x20, state->config->volt18setting); - case SEC_VOLTAGE_OFF: - return tda80xx_writereg(state, 0x20, 0); - default: - return -EINVAL; - } -} - -static int tda80xx_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - switch (tone) { - case SEC_TONE_OFF: - return tda80xx_writereg(state, 0x29, 0x00); - case SEC_TONE_ON: - return tda80xx_writereg(state, 0x29, 0x80); - default: - return -EINVAL; - } -} - -static int tda80xx_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - if (cmd->msg_len > 6) - return -EINVAL; - - tda80xx_writereg(state, 0x29, 0x08 | (cmd->msg_len - 3)); - tda80xx_write(state, 0x23, cmd->msg, cmd->msg_len); - tda80xx_writereg(state, 0x29, 0x0c | (cmd->msg_len - 3)); - tda80xx_wait_diseqc_fifo(state); - - return 0; -} - -static int tda80xx_send_diseqc_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t cmd) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - switch (cmd) { - case SEC_MINI_A: - tda80xx_writereg(state, 0x29, 0x14); - break; - case SEC_MINI_B: - tda80xx_writereg(state, 0x29, 0x1c); - break; - default: - return -EINVAL; - } - - tda80xx_wait_diseqc_fifo(state); - - return 0; -} - -static int tda80xx_sleep(struct dvb_frontend* fe) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - tda80xx_writereg(state, 0x00, 0x02); /* enter standby */ - - return 0; -} - -static int tda80xx_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - tda80xx_writereg(state, 0x1c, 0x80); - state->config->pll_set(fe, p); - tda80xx_writereg(state, 0x1c, 0x00); - - tda80xx_set_parameters(state, p->inversion, p->u.qpsk.symbol_rate, p->u.qpsk.fec_inner); - tda80xx_set_clk(state); - //tda80xx_set_scpc_freq_offset(state); - state->afc_loop = 1; - - return 0; -} - -static int tda80xx_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - if (!state->config->irq) - tda80xx_read_status_int(state); - - p->inversion = state->spectral_inversion; - p->u.qpsk.fec_inner = state->code_rate; - - return 0; -} - -static int tda80xx_read_status(struct dvb_frontend* fe, fe_status_t* status) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - if (!state->config->irq) - tda80xx_read_status_int(state); - *status = state->status; - - return 0; -} - -static int tda80xx_read_ber(struct dvb_frontend* fe, u32* ber) -{ - struct tda80xx_state* state = fe->demodulator_priv; - int ret; - u8 buf[3]; - - if ((ret = tda80xx_read(state, 0x0b, buf, sizeof(buf)))) - return ret; - - *ber = ((buf[0] & 0x1f) << 16) | (buf[1] << 8) | buf[2]; - - return 0; -} - -static int tda80xx_read_signal_strength(struct dvb_frontend* fe, u16* strength) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - u8 gain = ~tda80xx_readreg(state, 0x01); - *strength = (gain << 8) | gain; - - return 0; -} - -static int tda80xx_read_snr(struct dvb_frontend* fe, u16* snr) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - u8 quality = tda80xx_readreg(state, 0x08); - *snr = (quality << 8) | quality; - - return 0; -} - -static int tda80xx_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - *ucblocks = tda80xx_readreg(state, 0x0f); - if (*ucblocks == 0xff) - *ucblocks = 0xffffffff; - - return 0; -} - -static int tda80xx_init(struct dvb_frontend* fe) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - switch(state->id) { - case ID_TDA8044: - return tda8044_init(fe); - - case ID_TDA8083: - return tda8083_init(fe); - } - return 0; -} - -static void tda80xx_release(struct dvb_frontend* fe) -{ - struct tda80xx_state* state = fe->demodulator_priv; - - if (state->config->irq) - free_irq(state->config->irq, &state->worklet); - - kfree(state); -} - -static struct dvb_frontend_ops tda80xx_ops; - -struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config, - struct i2c_adapter* i2c) -{ - struct tda80xx_state* state = NULL; - int ret; - - /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct tda80xx_state), GFP_KERNEL); - if (state == NULL) goto error; - - /* setup the state */ - state->config = config; - state->i2c = i2c; - memcpy(&state->ops, &tda80xx_ops, sizeof(struct dvb_frontend_ops)); - state->spectral_inversion = INVERSION_AUTO; - state->code_rate = FEC_AUTO; - state->status = 0; - state->afc_loop = 0; - - /* check if the demod is there */ - if (tda80xx_writereg(state, 0x89, 0x00) < 0) goto error; - state->id = tda80xx_readreg(state, 0x00); - - switch (state->id) { - case ID_TDA8044: - state->clk = 96000000; - printk("tda80xx: Detected tda8044\n"); - break; - - case ID_TDA8083: - state->clk = 64000000; - printk("tda80xx: Detected tda8083\n"); - break; - - default: - goto error; - } - - /* setup IRQ */ - if (state->config->irq) { - INIT_WORK(&state->worklet, tda80xx_worklet, state); - if ((ret = request_irq(state->config->irq, tda80xx_irq, SA_ONESHOT, "tda80xx", &state->worklet)) < 0) { - printk(KERN_ERR "tda80xx: request_irq failed (%d)\n", ret); - goto error; - } - } - - /* create dvb_frontend */ - state->frontend.ops = &state->ops; - state->frontend.demodulator_priv = state; - return &state->frontend; - -error: - kfree(state); - return NULL; -} - -static struct dvb_frontend_ops tda80xx_ops = { - - .info = { - .name = "Philips TDA80xx DVB-S", - .type = FE_QPSK, - .frequency_min = 500000, - .frequency_max = 2700000, - .frequency_stepsize = 125, - .symbol_rate_min = 4500000, - .symbol_rate_max = 45000000, - .caps = FE_CAN_INVERSION_AUTO | - FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | - FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | - FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | - FE_CAN_QPSK | - FE_CAN_MUTE_TS - }, - - .release = tda80xx_release, - - .init = tda80xx_init, - .sleep = tda80xx_sleep, - - .set_frontend = tda80xx_set_frontend, - .get_frontend = tda80xx_get_frontend, - - .read_status = tda80xx_read_status, - .read_ber = tda80xx_read_ber, - .read_signal_strength = tda80xx_read_signal_strength, - .read_snr = tda80xx_read_snr, - .read_ucblocks = tda80xx_read_ucblocks, - - .diseqc_send_master_cmd = tda80xx_send_diseqc_msg, - .diseqc_send_burst = tda80xx_send_diseqc_burst, - .set_tone = tda80xx_set_tone, - .set_voltage = tda80xx_set_voltage, -}; - -module_param(debug, int, 0644); - -MODULE_DESCRIPTION("Philips TDA8044 / TDA8083 DVB-S Demodulator driver"); -MODULE_AUTHOR("Felix Domke, Andreas Oberritter"); -MODULE_LICENSE("GPL"); - -EXPORT_SYMBOL(tda80xx_attach); diff --git a/drivers/media/dvb/frontends/tda80xx.h b/drivers/media/dvb/frontends/tda80xx.h deleted file mode 100644 index cd639a0aad5..00000000000 --- a/drivers/media/dvb/frontends/tda80xx.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * tda80xx.c - * - * Philips TDA8044 / TDA8083 QPSK demodulator driver - * - * Copyright (C) 2001 Felix Domke - * Copyright (C) 2002-2004 Andreas Oberritter - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef TDA80XX_H -#define TDA80XX_H - -#include - -struct tda80xx_config -{ - /* the demodulator's i2c address */ - u8 demod_address; - - /* IRQ to use (0=>no IRQ used) */ - u32 irq; - - /* Register setting to use for 13v */ - u8 volt13setting; - - /* Register setting to use for 18v */ - u8 volt18setting; - - /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); -}; - -extern struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config, - struct i2c_adapter* i2c); - -#endif // TDA80XX_H -- cgit v1.2.3 From 4592b3a08454bb018e482de230fd5f15757bba92 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 27 Feb 2006 00:07:49 -0300 Subject: V4L/DVB (3337): Drivers/media/dvb/frontends/mt312.c: cleanups This patch contains the following possible cleanups: - update the Kconfig help to mention the VP310 - merge vp310_attach and mt312_attach into a new vp310_mt312_attach to remove some code duplication Signed-off-by: Adrian Bunk Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/Kconfig | 2 +- drivers/media/dvb/frontends/mt312.c | 116 ++++++++++++++---------------------- drivers/media/dvb/frontends/mt312.h | 6 +- 3 files changed, 47 insertions(+), 77 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index 76b6a2aef32..c676b1e23ab 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -29,7 +29,7 @@ config DVB_TDA8083 A DVB-S tuner module. Say Y when you want to support this frontend. config DVB_MT312 - tristate "Zarlink MT312 based" + tristate "Zarlink VP310/MT312 based" depends on DVB_CORE help A DVB-S tuner module. Say Y when you want to support this frontend. diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c index ec4e641acc6..d3aea83cf21 100644 --- a/drivers/media/dvb/frontends/mt312.c +++ b/drivers/media/dvb/frontends/mt312.c @@ -612,76 +612,6 @@ static void mt312_release(struct dvb_frontend* fe) kfree(state); } -static struct dvb_frontend_ops vp310_mt312_ops; - -struct dvb_frontend* vp310_attach(const struct mt312_config* config, - struct i2c_adapter* i2c) -{ - struct mt312_state* state = NULL; - - /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL); - if (state == NULL) - goto error; - - /* setup the state */ - state->config = config; - state->i2c = i2c; - memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops)); - strcpy(state->ops.info.name, "Zarlink VP310 DVB-S"); - - /* check if the demod is there */ - if (mt312_readreg(state, ID, &state->id) < 0) - goto error; - if (state->id != ID_VP310) { - goto error; - } - - /* create dvb_frontend */ - state->frequency = 90; - state->frontend.ops = &state->ops; - state->frontend.demodulator_priv = state; - return &state->frontend; - -error: - kfree(state); - return NULL; -} - -struct dvb_frontend* mt312_attach(const struct mt312_config* config, - struct i2c_adapter* i2c) -{ - struct mt312_state* state = NULL; - - /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL); - if (state == NULL) - goto error; - - /* setup the state */ - state->config = config; - state->i2c = i2c; - memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops)); - strcpy(state->ops.info.name, "Zarlink MT312 DVB-S"); - - /* check if the demod is there */ - if (mt312_readreg(state, ID, &state->id) < 0) - goto error; - if (state->id != ID_MT312) { - goto error; - } - - /* create dvb_frontend */ - state->frequency = 60; - state->frontend.ops = &state->ops; - state->frontend.demodulator_priv = state; - return &state->frontend; - -error: - kfree(state); - return NULL; -} - static struct dvb_frontend_ops vp310_mt312_ops = { .info = { @@ -720,6 +650,49 @@ static struct dvb_frontend_ops vp310_mt312_ops = { .set_voltage = mt312_set_voltage, }; +struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, + struct i2c_adapter* i2c) +{ + struct mt312_state* state = NULL; + + /* allocate memory for the internal state */ + state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL); + if (state == NULL) + goto error; + + /* setup the state */ + state->config = config; + state->i2c = i2c; + memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops)); + + /* check if the demod is there */ + if (mt312_readreg(state, ID, &state->id) < 0) + goto error; + + switch (state->id) { + case ID_VP310: + strcpy(state->ops.info.name, "Zarlink VP310 DVB-S"); + state->frequency = 90; + break; + case ID_MT312: + strcpy(state->ops.info.name, "Zarlink MT312 DVB-S"); + state->frequency = 60; + break; + default: + printk (KERN_WARNING "Only Zarlink VP310/MT312 are supported chips.\n"); + goto error; + } + + /* create dvb_frontend */ + state->frontend.ops = &state->ops; + state->frontend.demodulator_priv = state; + return &state->frontend; + +error: + kfree(state); + return NULL; +} + module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); @@ -727,5 +700,4 @@ MODULE_DESCRIPTION("Zarlink VP310/MT312 DVB-S Demodulator driver"); MODULE_AUTHOR("Andreas Oberritter "); MODULE_LICENSE("GPL"); -EXPORT_SYMBOL(mt312_attach); -EXPORT_SYMBOL(vp310_attach); +EXPORT_SYMBOL(vp310_mt312_attach); diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h index b3a53a73a11..074d844f013 100644 --- a/drivers/media/dvb/frontends/mt312.h +++ b/drivers/media/dvb/frontends/mt312.h @@ -38,10 +38,8 @@ struct mt312_config int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); }; -extern struct dvb_frontend* mt312_attach(const struct mt312_config* config, - struct i2c_adapter* i2c); +struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, + struct i2c_adapter* i2c); -extern struct dvb_frontend* vp310_attach(const struct mt312_config* config, - struct i2c_adapter* i2c); #endif // MT312_H -- cgit v1.2.3 From 981a16f185bdf105f0d411d87f5c276d3da60e64 Mon Sep 17 00:00:00 2001 From: Mattias Nordstrom Date: Mon, 27 Feb 2006 00:09:17 -0300 Subject: V4L/DVB (3382): Fix stv0297 for qam128 on tt c1500 (saa7146) I have a TT C1500 card (saa7146, STV0297) which had problems tuning channels at QAM128 (like the ones in the Finnish HTV / Welho network). A fix which seems to work perfectly so far is to change the delay for QAM128 to the same values as for QAM256 in stv0297_set_frontend(), Signed-off-by: Mattias Nordstrom Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stv0297.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 6122ba754bc..eb15676d374 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c @@ -393,10 +393,6 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par break; case QAM_128: - delay = 150; - sweeprate = 1000; - break; - case QAM_256: delay = 200; sweeprate = 500; -- cgit v1.2.3 From 1e7eb89ba936fc1db54e247a336f3f55bdbc644d Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Mon, 27 Feb 2006 00:09:25 -0300 Subject: V4L/DVB (3388): Ignore DiSEqC messages > 6 and < 3 Ignore invalid messages on cx24110 frontend. Thanks to Edgar Toernig Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/cx24110.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index d15d32c51dc..cc68b7e83b5 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -418,6 +418,9 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, struct cx24110_state *state = fe->demodulator_priv; unsigned long timeout; + if (cmd->msg_len < 3 || cmd->msg_len > 6) + return -EINVAL; /* not implemented */ + for (i = 0; i < cmd->msg_len; i++) cx24110_writereg(state, 0x79 + i, cmd->msg[i]); -- cgit v1.2.3 From e7ac46469c247a931f760354deaed9cf10b75fde Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Mon, 27 Feb 2006 00:09:29 -0300 Subject: V4L/DVB (3389): Fix broken IF-OUT Relay handling Fixed broken IF-OUT on pinnacle sat board. Thanks to Edgar Toernig Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/cx24110.c | 10 ++++++++++ drivers/media/dvb/frontends/cx24110.h | 1 + 2 files changed, 11 insertions(+) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index cc68b7e83b5..f3edf8b517d 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -371,6 +371,15 @@ static int cx24110_initfe(struct dvb_frontend* fe) return 0; } +static int cx24110_sleep(struct dvb_frontend *fe) +{ + struct cx24110_state *state = fe->demodulator_priv; + + if (state->config->pll_sleep) + return state->config->pll_sleep(fe); + return 0; +} + static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) { struct cx24110_state *state = fe->demodulator_priv; @@ -642,6 +651,7 @@ static struct dvb_frontend_ops cx24110_ops = { .release = cx24110_release, .init = cx24110_initfe, + .sleep = cx24110_sleep, .set_frontend = cx24110_set_frontend, .get_frontend = cx24110_get_frontend, .read_status = cx24110_read_status, diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h index b63ecf26421..609ac642b40 100644 --- a/drivers/media/dvb/frontends/cx24110.h +++ b/drivers/media/dvb/frontends/cx24110.h @@ -35,6 +35,7 @@ struct cx24110_config /* PLL maintenance */ int (*pll_init)(struct dvb_frontend* fe); int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_sleep)(struct dvb_frontend* fe); }; extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, -- cgit v1.2.3 From 2f27bdce972ceb97a2fd109a77546c37aa499fc9 Mon Sep 17 00:00:00 2001 From: Oliver Endriss Date: Tue, 28 Feb 2006 09:31:16 -0300 Subject: V4L/DVB (3404): Refactored LNBP21 and BSBE1 support Moved duplicated code to separate files. LNBP21 stuff rewritten from scratch, BSBE1 copied from av7110.c. Modified budget driver to use the new routines. Signed-off-by: Oliver Endriss Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/bsbe1.h | 123 +++++++++++++++++++++++++++++++ drivers/media/dvb/frontends/lnbp21.h | 139 +++++++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 drivers/media/dvb/frontends/bsbe1.h create mode 100644 drivers/media/dvb/frontends/lnbp21.h (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/bsbe1.h b/drivers/media/dvb/frontends/bsbe1.h new file mode 100644 index 00000000000..78573b22ada --- /dev/null +++ b/drivers/media/dvb/frontends/bsbe1.h @@ -0,0 +1,123 @@ +/* + * bsbe1.h - ALPS BSBE1 tuner support (moved from av7110.c) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html + * + * + * the project's page is at http://www.linuxtv.org + */ + +#ifndef BSBE1_H +#define BSBE1_H + +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, 0xb9, + 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 = 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_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, + .skip_reinit = 0, + .min_delay_ms = 100, + .set_symbol_rate = alps_bsbe1_set_symbol_rate, + .pll_set = alps_bsbe1_pll_set, +}; + +#endif diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h new file mode 100644 index 00000000000..0dcbe61b61b --- /dev/null +++ b/drivers/media/dvb/frontends/lnbp21.h @@ -0,0 +1,139 @@ +/* + * lnbp21.h - driver for lnb supply and control ic lnbp21 + * + * Copyright (C) 2006 Oliver Endriss + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html + * + * + * the project's page is at http://www.linuxtv.org + */ + +#ifndef _LNBP21_H +#define _LNBP21_H + +/* system register */ +#define LNBP21_OLF 0x01 +#define LNBP21_OTF 0x02 +#define LNBP21_EN 0x04 +#define LNBP21_VSEL 0x08 +#define LNBP21_LLC 0x10 +#define LNBP21_TEN 0x20 +#define LNBP21_ISEL 0x40 +#define LNBP21_PCL 0x80 + +struct lnbp21 { + u8 config; + u8 override_or; + u8 override_and; + struct i2c_adapter *i2c; + void (*release_chain)(struct dvb_frontend* fe); +}; + +static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) +{ + struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv; + struct i2c_msg msg = { .addr = 0x08, .flags = 0, + .buf = &lnbp21->config, + .len = sizeof(lnbp21->config) }; + + lnbp21->config &= ~(LNBP21_VSEL | LNBP21_EN); + + switch(voltage) { + case SEC_VOLTAGE_OFF: + break; + case SEC_VOLTAGE_13: + lnbp21->config |= LNBP21_EN; + break; + case SEC_VOLTAGE_18: + lnbp21->config |= (LNBP21_EN | LNBP21_VSEL); + break; + default: + return -EINVAL; + }; + + lnbp21->config |= lnbp21->override_or; + lnbp21->config &= lnbp21->override_and; + + return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO; +} + +static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) +{ + struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv; + struct i2c_msg msg = { .addr = 0x08, .flags = 0, + .buf = &lnbp21->config, + .len = sizeof(lnbp21->config) }; + + if (arg) + lnbp21->config |= LNBP21_LLC; + else + lnbp21->config &= ~LNBP21_LLC; + + lnbp21->config |= lnbp21->override_or; + lnbp21->config &= lnbp21->override_and; + + return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO; +} + +static void lnbp21_exit(struct dvb_frontend *fe) +{ + struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv; + + /* LNBP power off */ + lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF); + + /* free data & call next release routine */ + fe->ops->release = lnbp21->release_chain; + kfree(fe->misc_priv); + fe->misc_priv = NULL; + if (fe->ops->release) + fe->ops->release(fe); +} + +static int lnbp21_init(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear) +{ + struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL); + + if (!lnbp21) + return -ENOMEM; + + /* default configuration */ + lnbp21->config = LNBP21_ISEL; + + /* bits which should be forced to '1' */ + lnbp21->override_or = override_set; + + /* bits which should be forced to '0' */ + lnbp21->override_and = ~override_clear; + + /* install release callback */ + lnbp21->release_chain = fe->ops->release; + fe->ops->release = lnbp21_exit; + + /* override frontend ops */ + fe->ops->set_voltage = lnbp21_set_voltage; + fe->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage; + + lnbp21->i2c = i2c; + fe->misc_priv = lnbp21; + + return lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF); +} + +#endif -- cgit v1.2.3 From 780dfef37e2c941985b708f67aa0074edc922bea Mon Sep 17 00:00:00 2001 From: Chris Pascoe Date: Tue, 28 Feb 2006 08:34:59 -0300 Subject: V4L/DVB (3408): DViCO FusionHDTV DVB-T Hybrid and ZL10353-based FusionHDTV DVB-T Plus support Add support for the FE6600 tuner used on the DVB-T Hybrid board. Add support for the Zarlink ZL10353 DVB-T demodulator, which supersedes the MT352, used on the DViCO FusionHDTV DVB-T Hybrid and later model Plus boards. Signed-off-by: Chris Pascoe Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/Kconfig | 6 + drivers/media/dvb/frontends/Makefile | 1 + drivers/media/dvb/frontends/dvb-pll.c | 15 ++ drivers/media/dvb/frontends/dvb-pll.h | 2 + drivers/media/dvb/frontends/zl10353.c | 311 +++++++++++++++++++++++++++++ drivers/media/dvb/frontends/zl10353.h | 43 ++++ drivers/media/dvb/frontends/zl10353_priv.h | 42 ++++ 7 files changed, 420 insertions(+) create mode 100644 drivers/media/dvb/frontends/zl10353.c create mode 100644 drivers/media/dvb/frontends/zl10353.h create mode 100644 drivers/media/dvb/frontends/zl10353_priv.h (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index c676b1e23ab..a1a894d8104 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -116,6 +116,12 @@ config DVB_MT352 help A DVB-T tuner module. Say Y when you want to support this frontend. +config DVB_ZL10353 + tristate "Zarlink ZL10353 based" + depends on DVB_CORE + help + A DVB-T tuner module. Say Y when you want to support this frontend. + config DVB_DIB3000MB tristate "DiBcom 3000M-B" depends on DVB_CORE diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 1af769cd90c..d09b6071fba 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_DVB_TDA1004X) += tda1004x.o obj-$(CONFIG_DVB_SP887X) += sp887x.o obj-$(CONFIG_DVB_NXT6000) += nxt6000.o obj-$(CONFIG_DVB_MT352) += mt352.o +obj-$(CONFIG_DVB_ZL10353) += zl10353.o obj-$(CONFIG_DVB_CX22702) += cx22702.o obj-$(CONFIG_DVB_TDA10021) += tda10021.o obj-$(CONFIG_DVB_STV0297) += stv0297.o diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index 4f682534df4..8a4c904d3a2 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c @@ -404,6 +404,21 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = { }; EXPORT_SYMBOL(dvb_pll_philips_td1316); +/* FE6600 used on DViCO Hybrid */ +struct dvb_pll_desc dvb_pll_unknown_fe6600 = { + .name = "FE6600", + .min = 44250000, + .max = 858000000, + .count = 4, + .entries = { + { 250000000, 36213333, 166667, 0xb4, 0x12 }, + { 455000000, 36213333, 166667, 0xfe, 0x11 }, + { 775500000, 36213333, 166667, 0xbc, 0x18 }, + { 999999999, 36213333, 166667, 0xf4, 0x18 }, + } +}; +EXPORT_SYMBOL(dvb_pll_unknown_fe6600); + /* ----------------------------------------------------------- */ /* code */ diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h index 56c3cd76a7f..8a7f0b941c3 100644 --- a/drivers/media/dvb/frontends/dvb-pll.h +++ b/drivers/media/dvb/frontends/dvb-pll.h @@ -42,6 +42,8 @@ extern struct dvb_pll_desc dvb_pll_samsung_tbmv; extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261; extern struct dvb_pll_desc dvb_pll_philips_td1316; +extern struct dvb_pll_desc dvb_pll_unknown_fe6600; + int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, u32 freq, int bandwidth); diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c new file mode 100644 index 00000000000..23846c4452a --- /dev/null +++ b/drivers/media/dvb/frontends/zl10353.c @@ -0,0 +1,311 @@ +/* + * Driver for Zarlink DVB-T ZL10353 demodulator + * + * Copyright (C) 2006 Christopher Pascoe + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "dvb_frontend.h" +#include "zl10353_priv.h" +#include "zl10353.h" + +struct zl10353_state { + struct i2c_adapter *i2c; + struct dvb_frontend frontend; + struct dvb_frontend_ops ops; + + struct zl10353_config config; +}; + +static int debug_regs = 0; + +static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val) +{ + struct zl10353_state *state = fe->demodulator_priv; + u8 buf[2] = { reg, val }; + struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0, + .buf = buf, .len = 2 }; + int err = i2c_transfer(state->i2c, &msg, 1); + if (err != 1) { + printk("zl10353: write to reg %x failed (err = %d)!\n", reg, err); + return err; + } + return 0; +} + +int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen) +{ + int err, i; + for (i = 0; i < ilen - 1; i++) + if ((err = zl10353_single_write(fe, ibuf[0] + i, ibuf[i + 1]))) + return err; + + return 0; +} + +static int zl10353_read_register(struct zl10353_state *state, u8 reg) +{ + int ret; + u8 b0[1] = { reg }; + u8 b1[1] = { 0 }; + struct i2c_msg msg[2] = { { .addr = state->config.demod_address, + .flags = 0, + .buf = b0, .len = 1 }, + { .addr = state->config.demod_address, + .flags = I2C_M_RD, + .buf = b1, .len = 1 } }; + + ret = i2c_transfer(state->i2c, msg, 2); + + if (ret != 2) { + printk("%s: readreg error (reg=%d, ret==%i)\n", + __FUNCTION__, reg, ret); + return ret; + } + + return b1[0]; +} + +void zl10353_dump_regs(struct dvb_frontend *fe) +{ + struct zl10353_state *state = fe->demodulator_priv; + char buf[52], buf2[4]; + int ret; + u8 reg; + + /* Dump all registers. */ + for (reg = 0; ; reg++) { + if (reg % 16 == 0) { + if (reg) + printk(KERN_DEBUG "%s\n", buf); + sprintf(buf, "%02x: ", reg); + } + ret = zl10353_read_register(state, reg); + if (ret >= 0) + sprintf(buf2, "%02x ", (u8)ret); + else + strcpy(buf2, "-- "); + strcat(buf, buf2); + if (reg == 0xff) + break; + } + printk(KERN_DEBUG "%s\n", buf); +} + +static int zl10353_sleep(struct dvb_frontend *fe) +{ + static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 }; + + zl10353_write(fe, zl10353_softdown, sizeof(zl10353_softdown)); + return 0; +} + +static int zl10353_set_parameters(struct dvb_frontend *fe, + struct dvb_frontend_parameters *param) +{ + struct zl10353_state *state = fe->demodulator_priv; + u8 pllbuf[6] = { 0x67 }; + + /* These settings set "auto-everything" and start the FSM. */ + zl10353_single_write(fe, 0x55, 0x80); + udelay(200); + zl10353_single_write(fe, 0xEA, 0x01); + udelay(200); + zl10353_single_write(fe, 0xEA, 0x00); + + zl10353_single_write(fe, 0x56, 0x28); + zl10353_single_write(fe, 0x89, 0x20); + zl10353_single_write(fe, 0x5E, 0x00); + zl10353_single_write(fe, 0x65, 0x5A); + zl10353_single_write(fe, 0x66, 0xE9); + zl10353_single_write(fe, 0x62, 0x0A); + + state->config.pll_set(fe, param, pllbuf + 1); + zl10353_write(fe, pllbuf, sizeof(pllbuf)); + + zl10353_single_write(fe, 0x70, 0x01); + udelay(250); + zl10353_single_write(fe, 0xE4, 0x00); + zl10353_single_write(fe, 0xE5, 0x2A); + zl10353_single_write(fe, 0xE9, 0x02); + zl10353_single_write(fe, 0xE7, 0x40); + zl10353_single_write(fe, 0xE8, 0x10); + + return 0; +} + +static int zl10353_read_status(struct dvb_frontend *fe, fe_status_t *status) +{ + struct zl10353_state *state = fe->demodulator_priv; + int s6, s7, s8; + + if ((s6 = zl10353_read_register(state, STATUS_6)) < 0) + return -EREMOTEIO; + if ((s7 = zl10353_read_register(state, STATUS_7)) < 0) + return -EREMOTEIO; + if ((s8 = zl10353_read_register(state, STATUS_8)) < 0) + return -EREMOTEIO; + + *status = 0; + if (s6 & (1 << 2)) + *status |= FE_HAS_CARRIER; + if (s6 & (1 << 1)) + *status |= FE_HAS_VITERBI; + if (s6 & (1 << 5)) + *status |= FE_HAS_LOCK; + if (s7 & (1 << 4)) + *status |= FE_HAS_SYNC; + if (s8 & (1 << 6)) + *status |= FE_HAS_SIGNAL; + + if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) != + (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) + *status &= ~FE_HAS_LOCK; + + return 0; +} + +static int zl10353_read_snr(struct dvb_frontend *fe, u16 *snr) +{ + struct zl10353_state *state = fe->demodulator_priv; + u8 _snr; + + if (debug_regs) + zl10353_dump_regs(fe); + + _snr = zl10353_read_register(state, SNR); + *snr = (_snr << 8) | _snr; + + return 0; +} + +static int zl10353_get_tune_settings(struct dvb_frontend *fe, + struct dvb_frontend_tune_settings + *fe_tune_settings) +{ + fe_tune_settings->min_delay_ms = 1000; + fe_tune_settings->step_size = 0; + fe_tune_settings->max_drift = 0; + + return 0; +} + +static int zl10353_init(struct dvb_frontend *fe) +{ + struct zl10353_state *state = fe->demodulator_priv; + u8 zl10353_reset_attach[6] = { 0x50, 0x03, 0x64, 0x46, 0x15, 0x0F }; + int rc = 0; + + if (debug_regs) + zl10353_dump_regs(fe); + + /* Do a "hard" reset if not already done */ + if (zl10353_read_register(state, 0x50) != 0x03) { + rc = zl10353_write(fe, zl10353_reset_attach, + sizeof(zl10353_reset_attach)); + if (debug_regs) + zl10353_dump_regs(fe); + } + + return 0; +} + +static void zl10353_release(struct dvb_frontend *fe) +{ + struct zl10353_state *state = fe->demodulator_priv; + + kfree(state); +} + +static struct dvb_frontend_ops zl10353_ops; + +struct dvb_frontend *zl10353_attach(const struct zl10353_config *config, + struct i2c_adapter *i2c) +{ + struct zl10353_state *state = NULL; + + /* allocate memory for the internal state */ + state = kzalloc(sizeof(struct zl10353_state), GFP_KERNEL); + if (state == NULL) + goto error; + + /* setup the state */ + state->i2c = i2c; + memcpy(&state->config, config, sizeof(struct zl10353_config)); + memcpy(&state->ops, &zl10353_ops, sizeof(struct dvb_frontend_ops)); + + /* check if the demod is there */ + if (zl10353_read_register(state, CHIP_ID) != ID_ZL10353) + goto error; + + /* create dvb_frontend */ + state->frontend.ops = &state->ops; + state->frontend.demodulator_priv = state; + + return &state->frontend; +error: + kfree(state); + return NULL; +} + +static struct dvb_frontend_ops zl10353_ops = { + + .info = { + .name = "Zarlink ZL10353 DVB-T", + .type = FE_OFDM, + .frequency_min = 174000000, + .frequency_max = 862000000, + .frequency_stepsize = 166667, + .frequency_tolerance = 0, + .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | + FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | + FE_CAN_FEC_AUTO | + FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | + FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | + FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER | + FE_CAN_MUTE_TS + }, + + .release = zl10353_release, + + .init = zl10353_init, + .sleep = zl10353_sleep, + + .set_frontend = zl10353_set_parameters, + .get_tune_settings = zl10353_get_tune_settings, + + .read_status = zl10353_read_status, + .read_snr = zl10353_read_snr, +}; + +module_param(debug_regs, int, 0644); +MODULE_PARM_DESC(debug_regs, "Turn on/off frontend register dumps (default:off)."); + +MODULE_DESCRIPTION("Zarlink ZL10353 DVB-T demodulator driver"); +MODULE_AUTHOR("Chris Pascoe"); +MODULE_LICENSE("GPL"); + +EXPORT_SYMBOL(zl10353_attach); +EXPORT_SYMBOL(zl10353_write); diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h new file mode 100644 index 00000000000..5cc4ae718d8 --- /dev/null +++ b/drivers/media/dvb/frontends/zl10353.h @@ -0,0 +1,43 @@ +/* + * Driver for Zarlink DVB-T ZL10353 demodulator + * + * Copyright (C) 2006 Christopher Pascoe + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= + */ + +#ifndef ZL10353_H +#define ZL10353_H + +#include + +struct zl10353_config +{ + /* demodulator's I2C address */ + u8 demod_address; + + /* function which configures the PLL buffer (for secondary I2C + * connected tuner) or tunes the PLL (for direct connected tuner) */ + int (*pll_set)(struct dvb_frontend *fe, + struct dvb_frontend_parameters *params, u8 *pllbuf); +}; + +extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, + struct i2c_adapter *i2c); + +extern int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen); + +#endif /* ZL10353_H */ diff --git a/drivers/media/dvb/frontends/zl10353_priv.h b/drivers/media/dvb/frontends/zl10353_priv.h new file mode 100644 index 00000000000..b72224bd7dd --- /dev/null +++ b/drivers/media/dvb/frontends/zl10353_priv.h @@ -0,0 +1,42 @@ +/* + * Driver for Zarlink DVB-T ZL10353 demodulator + * + * Copyright (C) 2006 Christopher Pascoe + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= + */ + +#ifndef _ZL10353_PRIV_ +#define _ZL10353_PRIV_ + +#define ID_ZL10353 0x14 + +enum zl10353_reg_addr { + INTERRUPT_0 = 0x00, + INTERRUPT_1 = 0x01, + INTERRUPT_2 = 0x02, + INTERRUPT_3 = 0x03, + INTERRUPT_4 = 0x04, + INTERRUPT_5 = 0x05, + STATUS_6 = 0x06, + STATUS_7 = 0x07, + STATUS_8 = 0x08, + STATUS_9 = 0x09, + SNR = 0x10, + CHIP_ID = 0x7F, +}; + +#endif /* _ZL10353_PRIV_ */ -- cgit v1.2.3 From 91ae3299d7d3493a25e5f26cbaceeb18e7760ef3 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Wed, 1 Mar 2006 00:04:42 -0300 Subject: V4L/DVB (3411): FE6600 is a Thomson tuner - The tuner used in DViCO FusionHDTV DVB-T hybrid is made by Thomson - renamed tuner and dvb_pll structs accordingly Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/dvb-pll.c | 6 +++--- drivers/media/dvb/frontends/dvb-pll.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index 8a4c904d3a2..b6e2c387a04 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c @@ -405,8 +405,8 @@ struct dvb_pll_desc dvb_pll_philips_td1316 = { EXPORT_SYMBOL(dvb_pll_philips_td1316); /* FE6600 used on DViCO Hybrid */ -struct dvb_pll_desc dvb_pll_unknown_fe6600 = { - .name = "FE6600", +struct dvb_pll_desc dvb_pll_thomson_fe6600 = { + .name = "Thomson FE6600", .min = 44250000, .max = 858000000, .count = 4, @@ -417,7 +417,7 @@ struct dvb_pll_desc dvb_pll_unknown_fe6600 = { { 999999999, 36213333, 166667, 0xf4, 0x18 }, } }; -EXPORT_SYMBOL(dvb_pll_unknown_fe6600); +EXPORT_SYMBOL(dvb_pll_thomson_fe6600); /* ----------------------------------------------------------- */ /* code */ diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h index 8a7f0b941c3..2b846178498 100644 --- a/drivers/media/dvb/frontends/dvb-pll.h +++ b/drivers/media/dvb/frontends/dvb-pll.h @@ -42,7 +42,7 @@ extern struct dvb_pll_desc dvb_pll_samsung_tbmv; extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261; extern struct dvb_pll_desc dvb_pll_philips_td1316; -extern struct dvb_pll_desc dvb_pll_unknown_fe6600; +extern struct dvb_pll_desc dvb_pll_thomson_fe6600; int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, u32 freq, int bandwidth); -- cgit v1.2.3 From c04e89b1f2c624fbb1e57874062491c2b987c7e2 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 15 Mar 2006 16:17:11 -0300 Subject: V4L/DVB (3509): Make a needlessly global function static. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/zl10353.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c index 23846c4452a..d7d9f59d76d 100644 --- a/drivers/media/dvb/frontends/zl10353.c +++ b/drivers/media/dvb/frontends/zl10353.c @@ -88,7 +88,7 @@ static int zl10353_read_register(struct zl10353_state *state, u8 reg) return b1[0]; } -void zl10353_dump_regs(struct dvb_frontend *fe) +static void zl10353_dump_regs(struct dvb_frontend *fe) { struct zl10353_state *state = fe->demodulator_priv; char buf[52], buf2[4]; -- cgit v1.2.3 From f5c08a2ee906381d85a6f0a3ca309fd56cf3b90f Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Thu, 16 Mar 2006 13:18:25 -0300 Subject: V4L/DVB (3528): Kconfig: fix ATSC frontend menu item names by manufacturer - Corrected typo for NxtWave NXT200X - Added "Oren" manufacturer name to menu items for OR51132 and OR51211 - Removed "(pcHDTV HDx000 card)" from Oren frontends menu item names, This isn't necessary, as these frontends are selected by the card drivers, build configuration (DVB_BT8XX and VIDEO_CX88_DVB). Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index a1a894d8104..94233168d24 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig @@ -161,7 +161,7 @@ comment "ATSC (North American/Korean Terresterial DTV) frontends" depends on DVB_CORE config DVB_NXT200X - tristate "Nextwave NXT2002/NXT2004 based" + tristate "NxtWave Communications NXT2002/NXT2004 based" depends on DVB_CORE select FW_LOADER help @@ -175,14 +175,14 @@ config DVB_NXT200X or /lib/firmware (depending on configuration of firmware hotplug). config DVB_OR51211 - tristate "or51211 based (pcHDTV HD2000 card)" + tristate "Oren OR51211 based" depends on DVB_CORE select FW_LOADER help An ATSC 8VSB tuner module. Say Y when you want to support this frontend. config DVB_OR51132 - tristate "OR51132 based (pcHDTV HD3000 card)" + tristate "Oren OR51132 based" depends on DVB_CORE select FW_LOADER help -- cgit v1.2.3 From 265366e8fb8c31706711aea5f79d763816a968db Mon Sep 17 00:00:00 2001 From: Perceval Anichini Date: Thu, 16 Mar 2006 11:22:47 -0300 Subject: V4L/DVB (3532): Moved duplicated code of ALPS BSRU6 tuner to a standalone file. Moved duplicated code of ALPS BSRU6 tuner to a standalone file. Modified av7110 and budget drivers to include the new file. Signed-off-by: Perceval Anichini Signed-off-by: Oliver Endriss Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/bsru6.h | 140 ++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 drivers/media/dvb/frontends/bsru6.h (limited to 'drivers/media/dvb/frontends') diff --git a/drivers/media/dvb/frontends/bsru6.h b/drivers/media/dvb/frontends/bsru6.h new file mode 100644 index 00000000000..2a5366ce79c --- /dev/null +++ b/drivers/media/dvb/frontends/bsru6.h @@ -0,0 +1,140 @@ +/* + * bsru6.h - ALPS BSRU6 tuner support (moved from budget-ci.c) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html + * + * + * the project's page is at http://www.linuxtv.org + */ + +#ifndef BSRU6_H +#define BSRU6_H + +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, 0xb9, + 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, + .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, +}; + +#endif -- cgit v1.2.3