From 4f6aa2cac3fdd2487ae54417472216869759314a Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Thu, 1 Oct 2009 22:48:22 +0200 Subject: Changes due to information from Media-Pointer. Added initialisation of register TSTTNR1=0x26 & TSTTNR3=0x26. Change from comment unnecessary sourcode out to preprocessor directive "#ifdef 0". Set repeter level from STV090x_RPTLEVEL_64 to STV090x_RPTLEVEL_16. --- linux/drivers/media/dvb/frontends/stv090x.c | 2 + linux/drivers/media/video/ngene/ngene-core.c | 2012 +++++++++++++------------- 2 files changed, 1023 insertions(+), 991 deletions(-) diff --git a/linux/drivers/media/dvb/frontends/stv090x.c b/linux/drivers/media/dvb/frontends/stv090x.c index 8b152bea3..7283a8d69 100644 --- a/linux/drivers/media/dvb/frontends/stv090x.c +++ b/linux/drivers/media/dvb/frontends/stv090x.c @@ -888,7 +888,9 @@ static struct stv090x_reg stv0900_initval[] = { { STV090x_AGCRF1CFG, 0x11 }, { STV090x_AGCRF2CFG, 0x13 }, { STV090x_TSGENERAL1X, 0x14 }, + { STV090x_TSTTNR1, 0x26 }, { STV090x_TSTTNR2, 0x21 }, + { STV090x_TSTTNR3, 0x26 }, { STV090x_TSTTNR4, 0x21 }, { STV090x_P2_DISTXCTL, 0x22 }, { STV090x_P2_F22TX, 0xc0 }, diff --git a/linux/drivers/media/video/ngene/ngene-core.c b/linux/drivers/media/video/ngene/ngene-core.c index 2a73c6c86..0fad67e17 100644 --- a/linux/drivers/media/video/ngene/ngene-core.c +++ b/linux/drivers/media/video/ngene/ngene-core.c @@ -714,15 +714,17 @@ static void FillTSBuffer(void *Buffer, int Length, u32 Flags) } } -//static void clear_tsin(struct ngene_channel *chan) -//{ -// struct SBufferHeader *Cur = chan->nextBuffer; -// -// do { -// memset(&Cur->ngeneBuffer.SR, 0, sizeof(Cur->ngeneBuffer.SR)); -// Cur = Cur->Next; -// } while (Cur != chan->nextBuffer); -//} +#if 0 +static void clear_tsin(struct ngene_channel *chan) +{ + struct SBufferHeader *Cur = chan->nextBuffer; + + do { + memset(&Cur->ngeneBuffer.SR, 0, sizeof(Cur->ngeneBuffer.SR)); + Cur = Cur->Next; + } while (Cur != chan->nextBuffer); +} +#endif static void flush_buffers(struct ngene_channel *chan) @@ -1076,15 +1078,17 @@ struct i2c_algorithm ngene_i2c_algo = { .functionality = ngene_i2c_functionality, }; -//static int ngene_i2c_attach(struct i2c_client *client) -//{ -// return 0; -//} -// -//static int ngene_i2c_detach(struct i2c_client *client) -//{ -// return 0; -//} +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) +static int ngene_i2c_attach(struct i2c_client *client) +{ + return 0; +} + +static int ngene_i2c_detach(struct i2c_client *client) +{ + return 0; +} +#endif static int ngene_i2c_init(struct ngene *dev, int dev_nr) { @@ -1104,8 +1108,10 @@ static int ngene_i2c_init(struct ngene *dev, int dev_nr) #else adap->id=I2C_HW_SAA7146; #endif -// adap->client_register=ngene_i2c_attach; -// adap->client_unregister=ngene_i2c_detach; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + adap->client_register=ngene_i2c_attach; + adap->client_unregister=ngene_i2c_detach; +#endif adap->algo=&ngene_i2c_algo; adap->algo_data=(void *)&(dev->channel[dev_nr]); @@ -1129,19 +1135,21 @@ int i2c_write(struct i2c_adapter *adapter, u8 adr, u8 data) return 0; } -//static int i2c_write_register(struct i2c_adapter *adapter, -// u8 adr, u8 reg, u8 data) -//{ -// u8 m[2]={reg, data}; -// struct i2c_msg msg={.addr=adr, .flags=0, .buf=m, .len=2}; -// -// if (i2c_transfer(adapter, &msg, 1)!=1) { -// printk("Failed to write to I2C register %02x@%02x!\n", -// reg, adr); -// return -1; -// } -// return 0; -//} +#if 0 +static int i2c_write_register(struct i2c_adapter *adapter, + u8 adr, u8 reg, u8 data) +{ + u8 m[2]={reg, data}; + struct i2c_msg msg={.addr=adr, .flags=0, .buf=m, .len=2}; + + if (i2c_transfer(adapter, &msg, 1)!=1) { + printk("Failed to write to I2C register %02x@%02x!\n", + reg, adr); + return -1; + } + return 0; +} +#endif static int i2c_write_read(struct i2c_adapter *adapter, u8 adr, u8 *w, u8 wlen, u8 *r, u8 rlen) @@ -1246,144 +1254,146 @@ static int i2c_read_eeprom(struct i2c_adapter *adapter, return 0; } -//static int ReadEEProm(struct i2c_adapter *adapter, -// u16 Tag, u32 MaxLen, u8 *data, u32 *pLength) -//{ -// int status=0; -// u16 Addr=MICNG_EE_START, Length, tag=0; -// u8 EETag[3]; -// -// while (Addr+sizeof(u16)+1MICNG_EE_END) { -// printk(DEVICE_NAME -// ": Reached EOEE @ Tag = %04x Length = %3d\n", -// tag, EETag[2]); -// return -1; -// } -// Length=EETag[2]; -// if (Length>MaxLen) -// Length=(u16)MaxLen; -// if (Length>0) { -// Addr+=sizeof(u16)+1; -// if (!(status=i2c_read_eeprom(adapter, 0x50, -// Addr, data, Length))) { -// *pLength=EETag[2]; -// if (LengthMICNG_EE_END) { -// printk(DEVICE_NAME -// ": Reached EOEE @ Tag = %04x Length = %3d\n", -// tag, EETag[2]); -// return -1; -// } -// -// if (Length>EETag[2]) -// return -EINVAL; -// /* Note: We write the data one byte at a time to avoid -// issues with page sizes. (which are different for -// each manufacture and eeprom size) -// */ -// Addr+=sizeof(u16)+1; -// for (i=0; i>8; -// buf[1]=data&0xff; -// if ((stat=WriteEEProm(adapter, tag, 2, buf))) -// return stat; -// return 0; -//} +#if 0 +static int ReadEEProm(struct i2c_adapter *adapter, + u16 Tag, u32 MaxLen, u8 *data, u32 *pLength) +{ + int status=0; + u16 Addr=MICNG_EE_START, Length, tag=0; + u8 EETag[3]; + + while (Addr+sizeof(u16)+1MICNG_EE_END) { + printk(DEVICE_NAME + ": Reached EOEE @ Tag = %04x Length = %3d\n", + tag, EETag[2]); + return -1; + } + Length=EETag[2]; + if (Length>MaxLen) + Length=(u16)MaxLen; + if (Length>0) { + Addr+=sizeof(u16)+1; + if (!(status=i2c_read_eeprom(adapter, 0x50, + Addr, data, Length))) { + *pLength=EETag[2]; + if (LengthMICNG_EE_END) { + printk(DEVICE_NAME + ": Reached EOEE @ Tag = %04x Length = %3d\n", + tag, EETag[2]); + return -1; + } + + if (Length>EETag[2]) + return -EINVAL; + /* Note: We write the data one byte at a time to avoid + issues with page sizes. (which are different for + each manufacture and eeprom size) + */ + Addr+=sizeof(u16)+1; + for (i=0; i>8; + buf[1]=data&0xff; + if ((stat=WriteEEProm(adapter, tag, 2, buf))) + return stat; + return 0; +} +#endif static int i2c_dump_eeprom(struct i2c_adapter *adapter, u8 adr) { @@ -1641,48 +1651,50 @@ static int send_cli_val(struct ngene *dev, char *cmd, u32 val) return write_uart(dev, s, strlen(s)); } -//static int ngene_command_write_uart_user(struct ngene *dev, -// const u8 *data, int len) -//{ -// struct ngene_command com; -// -// dev->tx_busy=1; -// com.cmd.hdr.Opcode=CMD_WRITE_UART; -// com.cmd.hdr.Length=len; -// -// if (copy_from_user(com.cmd.WriteUart.Data, data, len)) -// return -EFAULT; -// com.in_len=len; -// com.out_len=0; -// -// if (ngene_command(dev, &com)<0) -// return -EIO; -// -// return 0; -//} -// -//static ssize_t uart_write(struct file *file, const char *buf, -// size_t count, loff_t *ppos) -//{ -// struct dvb_device *dvbdev=file->private_data; -// struct ngene_channel *chan=dvbdev->priv; -// struct ngene *dev=chan->dev; -// int len, ret=0; -// size_t left=count; -// -// while (left) { -// len=left; -// if (len>250) -// len=250; -// ret=wait_event_interruptible(dev->tx_wq, dev->tx_busy==0); -// if (ret<0) -// return ret; -// ngene_command_write_uart_user(dev, buf, len); -// left-=len; -// buf+=len; -// } -// return count; -//} +#if 0 +static int ngene_command_write_uart_user(struct ngene *dev, + const u8 *data, int len) +{ + struct ngene_command com; + + dev->tx_busy=1; + com.cmd.hdr.Opcode=CMD_WRITE_UART; + com.cmd.hdr.Length=len; + + if (copy_from_user(com.cmd.WriteUart.Data, data, len)) + return -EFAULT; + com.in_len=len; + com.out_len=0; + + if (ngene_command(dev, &com)<0) + return -EIO; + + return 0; +} + +static ssize_t uart_write(struct file *file, const char *buf, + size_t count, loff_t *ppos) +{ + struct dvb_device *dvbdev=file->private_data; + struct ngene_channel *chan=dvbdev->priv; + struct ngene *dev=chan->dev; + int len, ret=0; + size_t left=count; + + while (left) { + len=left; + if (len>250) + len=250; + ret=wait_event_interruptible(dev->tx_wq, dev->tx_busy==0); + if (ret<0) + return ret; + ngene_command_write_uart_user(dev, buf, len); + left-=len; + buf+=len; + } + return count; +} +#endif static ssize_t ts_write(struct file *file, const char *buf, size_t count, loff_t *ppos) @@ -1853,15 +1865,17 @@ static void *tsout_exchange(void *priv, void *buf, u32 len, return buf; } -//static void set_dto(struct ngene_channel *chan, u32 rate) -//{ -// u64 val=rate*0x89705f41ULL; /* times val for 2^26 Hz */ -// -// val=((val>>25)+1)>>1; -// chan->AudioDTOValue=(u32)val; -// //chan->AudioDTOUpdated=1; -// //printk("Setting DTO to %08x\n", val); -//} +#if 0 +static void set_dto(struct ngene_channel *chan, u32 rate) +{ + u64 val=rate*0x89705f41ULL; /* times val for 2^26 Hz */ + + val=((val>>25)+1)>>1; + chan->AudioDTOValue=(u32)val; + //chan->AudioDTOUpdated=1; + //printk("Setting DTO to %08x\n", val); +} +#endif static void set_transfer(struct ngene_channel *chan, int state) { @@ -2007,196 +2021,198 @@ static int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed) return 0; } -//static int write_demod(struct i2c_adapter *adapter, -// u8 adr, u16 reg, u16 data) -//{ -// u8 mm[5]={0x10, (reg>>8)&0xff, reg&0xff, -// (data>>8)&0xff, data&0xff}; -// struct i2c_msg msg={.addr=adr, .flags=0, .buf=mm, .len=5}; -// -// if (i2c_transfer(adapter, &msg, 1)!=1) { -// printk("error in write_demod\n"); -// return -1; -// } -// return 0; -//} -// -//#if 0 -//static int read_demod(struct i2c_adapter *adapter, -// u8 adr, u16 reg, u16 *data) -//{ -// u8 msg[3] = {0x11, (reg>>8)&0xff, reg&0xff}; -// u8 val[2]; -// struct i2c_msg msgs[2]={{.addr=adr, .flags=0, -// .buf=msg, .len=3 }, -// {.addr=adr, .flags=I2C_M_RD, -// .buf=val, .len=2 }}; -// -// if (i2c_transfer(adapter, msgs, 2)!=2) { -// printk("error in read_demod\n"); -// return -1; -// } -// *data=(val[0]<<8)|val[1]; -// return 0; -//} -//#endif -// -//static int ngene_drxd_pll_set(struct ngene_channel *chan, -// u8 *pll, u8 *aux, u8 plladr) -//{ -// struct i2c_adapter *adap=&chan->i2c_adapter; -// struct i2c_msg msg_pll={.addr=plladr, .flags=0, .buf=pll, .len=4}; -// struct i2c_msg msg_aux={.addr=plladr, .flags=0, .buf=aux, .len=2}; -// int err=0; -// -// if (chan->dev->card_info->i2c_access&1) -// down(&chan->dev->pll_mutex); -// -//#if 1 -// chan->fe->ops.i2c_gate_ctrl(chan->fe, 1); -//#else -// drxd_config_i2c(chan->fe, 1); -//#endif -// if ((err=i2c_transfer(adap, &msg_pll, 1))!=1) -// goto error; -// if (aux) -// err=i2c_transfer(adap, &msg_aux, 1); -//error: -//#if 1 -// chan->fe->ops.i2c_gate_ctrl(chan->fe, 0); -//#else -// drxd_config_i2c(chan->fe, 0); -//#endif -// if (chan->dev->card_info->i2c_access&1) -// up(&chan->dev->pll_mutex); -// return err; -//} -// -//static int ngene_pll_set_th_dtt7520x(void *priv, void *priv_params, -// u8 plladr, u8 dadr, s32 *off) -//{ -// struct dvb_frontend_parameters *params=priv_params; -// struct ngene_channel *chan=priv; -// -// u32 freq=params->frequency; -// u8 pll[4], aux[2]; -// u8 c1, c2; -// u32 div; -// -// if (freq<185000000 || freq>900000000) -// return -EINVAL; -// -// if (freq<465000000) -// c2=0x12; -// else -// c2=0x18; -// -// if (freq<305000000) c1=0xb4; -// else if (freq<405000000) c1=0xbc; -// else if (freq<445000000) c1=0xf4; -// else if (freq<465000000) c1=0xfc; -// else if (freq<735000000) c1=0xbc; -// else if (freq<835000000) c1=0xf4; -// else c1=0xfc; -// -// if (params->u.ofdm.bandwidth==BANDWIDTH_8_MHZ) -// c2^=0x10; -// -// div=(freq+36000000+166667/2)/166667; -// *off=((s32) div)*166667-(s32)freq-36000000; -// -// pll[0]=(div>>8)&0x7f; -// pll[1]=div&0xff; -// pll[2]=c1; -// pll[3]=c2; -// -// aux[0]=(c1&0xc7)|0x98; -// aux[1]=0x30; -// -// return ngene_drxd_pll_set(chan, pll, aux, plladr); -//} -// -//static int ngene_pll_set_mt_3x0823(void *priv, -// void *priv_params, -// u8 plladr, u8 dadr, s32 *off) -//{ -// struct dvb_frontend_parameters *params=priv_params; -// struct ngene_channel *chan=priv; -// struct i2c_adapter *adap=&chan->i2c_adapter; -// u32 freq=params->frequency; -// u8 pll[4]; -// u8 aux[2]; -// u8 c1, c2; -// u32 div; -// -// if (freq<47125000 || freq>855250000) -// return -EINVAL; -// else if (freq<120000000) { c1=0xcc; c2=0x01; } -// else if (freq<155500000) { c1=0xfc; c2=0x01; } -// else if (freq<300000000) { c1=0xbc; c2=0x02; } -// else if (freq<467000000) { c1=0xcc; c2=0x02; } -// else { c1=0xcc; c2=0x04; } -// -// if (params->u.ofdm.bandwidth==BANDWIDTH_8_MHZ) -// c2|=0x08; -// -//#define INTERFREQ (36000000) -// -// div=(freq+INTERFREQ+166667/2)/166667; -// -// *off=((s32) div)*166667-(s32)freq-INTERFREQ; -// -// pll[0]=(div>>8)&0x7f; -// pll[1]=div&0xff; -// pll[2]=c1; -// pll[3]=c2; -// -// aux[0]=(c1&0xc7)|0x98; -// aux[1]=0x20; -// -//#if 0 -// write_demod(adap, dadr, 0x1007, 0x000); -// write_demod(adap, dadr, 0x1094, 0x500); /*280-7ff*/ -//#else -// write_demod(adap, dadr, 0x1007, 0xc27); -// -// switch (params->u.ofdm.bandwidth) { -// case BANDWIDTH_7_MHZ: -// write_demod(adap, dadr, 0x0020, 0x103); -// break; -// case BANDWIDTH_AUTO: -// case BANDWIDTH_8_MHZ: -// write_demod(adap, dadr, 0x0020, 0x003); -// break; -// case BANDWIDTH_6_MHZ: -// write_demod(adap, dadr, 0x0020, 0x002); -// /*write_demod(adap, dadr, 0x1022, 397);*/ -// break; -// } -//#endif -// -// return ngene_drxd_pll_set(chan, pll, aux, plladr); -// -//} -// -//static s16 osc_deviation(void *priv, s16 deviation, int flag) -//{ -// struct ngene_channel *chan=priv; -// struct i2c_adapter *adap=&chan->i2c_adapter; -// u16 data=0; -// -// if (flag) { -// data=(u16) deviation; -// printk("write deviation %d\n", deviation); -// eeprom_write_ushort(adap, 0x1000+chan->number, data); -// } else { -// if (eeprom_read_ushort(adap, 0x1000+chan->number, &data)) -// data=0; -// printk("read deviation %d\n", (s16)data); -// } -// -// return (s16) data; -//} +#if 0 +static int write_demod(struct i2c_adapter *adapter, + u8 adr, u16 reg, u16 data) +{ + u8 mm[5]={0x10, (reg>>8)&0xff, reg&0xff, + (data>>8)&0xff, data&0xff}; + struct i2c_msg msg={.addr=adr, .flags=0, .buf=mm, .len=5}; + + if (i2c_transfer(adapter, &msg, 1)!=1) { + printk("error in write_demod\n"); + return -1; + } + return 0; +} + +#if 0 +static int read_demod(struct i2c_adapter *adapter, + u8 adr, u16 reg, u16 *data) +{ + u8 msg[3] = {0x11, (reg>>8)&0xff, reg&0xff}; + u8 val[2]; + struct i2c_msg msgs[2]={{.addr=adr, .flags=0, + .buf=msg, .len=3 }, + {.addr=adr, .flags=I2C_M_RD, + .buf=val, .len=2 }}; + + if (i2c_transfer(adapter, msgs, 2)!=2) { + printk("error in read_demod\n"); + return -1; + } + *data=(val[0]<<8)|val[1]; + return 0; +} +#endif + +static int ngene_drxd_pll_set(struct ngene_channel *chan, + u8 *pll, u8 *aux, u8 plladr) +{ + struct i2c_adapter *adap=&chan->i2c_adapter; + struct i2c_msg msg_pll={.addr=plladr, .flags=0, .buf=pll, .len=4}; + struct i2c_msg msg_aux={.addr=plladr, .flags=0, .buf=aux, .len=2}; + int err=0; + + if (chan->dev->card_info->i2c_access&1) + down(&chan->dev->pll_mutex); + +#if 1 + chan->fe->ops.i2c_gate_ctrl(chan->fe, 1); +#else + drxd_config_i2c(chan->fe, 1); +#endif + if ((err=i2c_transfer(adap, &msg_pll, 1))!=1) + goto error; + if (aux) + err=i2c_transfer(adap, &msg_aux, 1); +error: +#if 1 + chan->fe->ops.i2c_gate_ctrl(chan->fe, 0); +#else + drxd_config_i2c(chan->fe, 0); +#endif + if (chan->dev->card_info->i2c_access&1) + up(&chan->dev->pll_mutex); + return err; +} + +static int ngene_pll_set_th_dtt7520x(void *priv, void *priv_params, + u8 plladr, u8 dadr, s32 *off) +{ + struct dvb_frontend_parameters *params=priv_params; + struct ngene_channel *chan=priv; + + u32 freq=params->frequency; + u8 pll[4], aux[2]; + u8 c1, c2; + u32 div; + + if (freq<185000000 || freq>900000000) + return -EINVAL; + + if (freq<465000000) + c2=0x12; + else + c2=0x18; + + if (freq<305000000) c1=0xb4; + else if (freq<405000000) c1=0xbc; + else if (freq<445000000) c1=0xf4; + else if (freq<465000000) c1=0xfc; + else if (freq<735000000) c1=0xbc; + else if (freq<835000000) c1=0xf4; + else c1=0xfc; + + if (params->u.ofdm.bandwidth==BANDWIDTH_8_MHZ) + c2^=0x10; + + div=(freq+36000000+166667/2)/166667; + *off=((s32) div)*166667-(s32)freq-36000000; + + pll[0]=(div>>8)&0x7f; + pll[1]=div&0xff; + pll[2]=c1; + pll[3]=c2; + + aux[0]=(c1&0xc7)|0x98; + aux[1]=0x30; + + return ngene_drxd_pll_set(chan, pll, aux, plladr); +} + +static int ngene_pll_set_mt_3x0823(void *priv, + void *priv_params, + u8 plladr, u8 dadr, s32 *off) +{ + struct dvb_frontend_parameters *params=priv_params; + struct ngene_channel *chan=priv; + struct i2c_adapter *adap=&chan->i2c_adapter; + u32 freq=params->frequency; + u8 pll[4]; + u8 aux[2]; + u8 c1, c2; + u32 div; + + if (freq<47125000 || freq>855250000) + return -EINVAL; + else if (freq<120000000) { c1=0xcc; c2=0x01; } + else if (freq<155500000) { c1=0xfc; c2=0x01; } + else if (freq<300000000) { c1=0xbc; c2=0x02; } + else if (freq<467000000) { c1=0xcc; c2=0x02; } + else { c1=0xcc; c2=0x04; } + + if (params->u.ofdm.bandwidth==BANDWIDTH_8_MHZ) + c2|=0x08; + +#define INTERFREQ (36000000) + + div=(freq+INTERFREQ+166667/2)/166667; + + *off=((s32) div)*166667-(s32)freq-INTERFREQ; + + pll[0]=(div>>8)&0x7f; + pll[1]=div&0xff; + pll[2]=c1; + pll[3]=c2; + + aux[0]=(c1&0xc7)|0x98; + aux[1]=0x20; + +#if 0 + write_demod(adap, dadr, 0x1007, 0x000); + write_demod(adap, dadr, 0x1094, 0x500); /*280-7ff*/ +#else + write_demod(adap, dadr, 0x1007, 0xc27); + + switch (params->u.ofdm.bandwidth) { + case BANDWIDTH_7_MHZ: + write_demod(adap, dadr, 0x0020, 0x103); + break; + case BANDWIDTH_AUTO: + case BANDWIDTH_8_MHZ: + write_demod(adap, dadr, 0x0020, 0x003); + break; + case BANDWIDTH_6_MHZ: + write_demod(adap, dadr, 0x0020, 0x002); + /*write_demod(adap, dadr, 0x1022, 397);*/ + break; + } +#endif + + return ngene_drxd_pll_set(chan, pll, aux, plladr); + +} + +static s16 osc_deviation(void *priv, s16 deviation, int flag) +{ + struct ngene_channel *chan=priv; + struct i2c_adapter *adap=&chan->i2c_adapter; + u16 data=0; + + if (flag) { + data=(u16) deviation; + printk("write deviation %d\n", deviation); + eeprom_write_ushort(adap, 0x1000+chan->number, data); + } else { + if (eeprom_read_ushort(adap, 0x1000+chan->number, &data)) + data=0; + printk("read deviation %d\n", (s16)data); + } + + return (s16) data; +} +#endif static int write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len) @@ -2639,97 +2655,99 @@ static u32 Buffer1Sizes[MAX_STREAM] = MAX_AUDIO_BUFFER_SIZE }; -static u32 Buffer2Sizes[MAX_STREAM] = -{ - MAX_VBI_BUFFER_SIZE, - MAX_VBI_BUFFER_SIZE, - 0, - 0, - 0 -}; +static u32 Buffer2Sizes[MAX_STREAM] = +{ + MAX_VBI_BUFFER_SIZE, + MAX_VBI_BUFFER_SIZE, + 0, + 0, + 0 +}; + +#if 0 +static int allocate_buffer(struct pci_dev *pci_dev, + dma_addr_t of, + struct SRingBufferDescriptor *rbuf, + u32 entries, + u32 size1, u32 size2) +{ + if (create_ring_buffer(pci_dev, rbuf, entries)<0) + return -ENOMEM; + + if (AllocateRingBuffers(pci_dev, of, + rbuf, size1, size2)<0) + return -ENOMEM; + + return 0; +} + +static int channel_allocate_buffers(struct ngene_channel *chan) +{ + struct ngene *dev=chan->dev; + int type=dev->card_info->io_type[chan->number]; + int status; + + chan->State = KSSTATE_STOP; + + if (type&(NGENE_IO_TV|NGENE_IO_HDTV|NGENE_IO_AIN)) { + status=create_ring_buffer(dev->pci_dev, + &chan->RingBuffer, + RingBufferSizes[chan->number]); + if (status<0) + return -ENOMEM; + + if (type&(NGENE_IO_TV|NGENE_IO_AIN)) { + status=AllocateRingBuffers(dev->pci_dev, + dev->PAOverflowBuffer, + &chan->RingBuffer, + Buffer1Sizes[chan->number], + Buffer2Sizes[chan->number]); + if (status<0) + return -ENOMEM; + } else if (type&NGENE_IO_HDTV) { + status=AllocateRingBuffers(dev->pci_dev, + dev->PAOverflowBuffer, + &chan->RingBuffer, + MAX_HDTV_BUFFER_SIZE, 0); + if (status<0) + return -ENOMEM; + } + } + + if (type&(NGENE_IO_TSIN|NGENE_IO_TSOUT)) { -//static int allocate_buffer(struct pci_dev *pci_dev, -// dma_addr_t of, -// struct SRingBufferDescriptor *rbuf, -// u32 entries, -// u32 size1, u32 size2) -//{ -// if (create_ring_buffer(pci_dev, rbuf, entries)<0) -// return -ENOMEM; -// -// if (AllocateRingBuffers(pci_dev, of, -// rbuf, size1, size2)<0) -// return -ENOMEM; -// -// return 0; -//} -// -//static int channel_allocate_buffers(struct ngene_channel *chan) -//{ -// struct ngene *dev=chan->dev; -// int type=dev->card_info->io_type[chan->number]; -// int status; -// -// chan->State = KSSTATE_STOP; -// -// if (type&(NGENE_IO_TV|NGENE_IO_HDTV|NGENE_IO_AIN)) { -// status=create_ring_buffer(dev->pci_dev, -// &chan->RingBuffer, -// RingBufferSizes[chan->number]); -// if (status<0) -// return -ENOMEM; -// -// if (type&(NGENE_IO_TV|NGENE_IO_AIN)) { -// status=AllocateRingBuffers(dev->pci_dev, -// dev->PAOverflowBuffer, -// &chan->RingBuffer, -// Buffer1Sizes[chan->number], -// Buffer2Sizes[chan->number]); -// if (status<0) -// return -ENOMEM; -// } else if (type&NGENE_IO_HDTV) { -// status=AllocateRingBuffers(dev->pci_dev, -// dev->PAOverflowBuffer, -// &chan->RingBuffer, -// MAX_HDTV_BUFFER_SIZE, 0); -// if (status<0) -// return -ENOMEM; -// } -// } -// -// if (type&(NGENE_IO_TSIN|NGENE_IO_TSOUT)) { -// -// status=create_ring_buffer(dev->pci_dev, -// &chan->TSRingBuffer, -// RING_SIZE_TS); -// if (status<0) -// return -ENOMEM; -// -// status=AllocateRingBuffers(dev->pci_dev, -// dev->PAOverflowBuffer, -// &chan->TSRingBuffer, -// MAX_TS_BUFFER_SIZE,0); -// if (status) -// return -ENOMEM; -// } -// -// if (type&NGENE_IO_TSOUT) { -// status=create_ring_buffer(dev->pci_dev, -// &chan->TSIdleBuffer, -// 1); -// if (status<0) -// return -ENOMEM; -// status=AllocateRingBuffers(dev->pci_dev, -// dev->PAOverflowBuffer, -// &chan->TSIdleBuffer, -// MAX_TS_BUFFER_SIZE,0); -// if (status) -// return -ENOMEM; -// FillTSIdleBuffer(&chan->TSIdleBuffer, -// &chan->TSRingBuffer); -// } -// return 0; -//} + status=create_ring_buffer(dev->pci_dev, + &chan->TSRingBuffer, + RING_SIZE_TS); + if (status<0) + return -ENOMEM; + + status=AllocateRingBuffers(dev->pci_dev, + dev->PAOverflowBuffer, + &chan->TSRingBuffer, + MAX_TS_BUFFER_SIZE,0); + if (status) + return -ENOMEM; + } + + if (type&NGENE_IO_TSOUT) { + status=create_ring_buffer(dev->pci_dev, + &chan->TSIdleBuffer, + 1); + if (status<0) + return -ENOMEM; + status=AllocateRingBuffers(dev->pci_dev, + dev->PAOverflowBuffer, + &chan->TSIdleBuffer, + MAX_TS_BUFFER_SIZE,0); + if (status) + return -ENOMEM; + FillTSIdleBuffer(&chan->TSIdleBuffer, + &chan->TSRingBuffer); + } + return 0; +} +#endif static int AllocCommonBuffers(struct ngene *dev) { @@ -3000,7 +3018,7 @@ static int ngene_start(struct ngene *dev) if (dev->card_info->fw_version==17) { u8 hdtv_config[6]={6144/64,0,0,2048/64,2048/64,2048/64}; u8 tsin4_config[6]={3072/64,3072/64,0,3072/64,3072/64,0}; -// u8 ts5_config[6]={2048/64,2048/64,0,2048/64,2048/64,2048/64}; + //u8 ts5_config[6]={2048/64,2048/64,0,2048/64,2048/64,2048/64}; u8 default_config[6]={4096/64,4096/64,0,2048/64,2048/64,0}; u8 *bconf=default_config; @@ -3363,19 +3381,22 @@ static int lnbh21_set_tone(struct dvb_frontend *fe, } #endif + /****************************************************************************/ /* Switch control (I2C gates, etc.) *****************************************/ /****************************************************************************/ -//static int avf_output(struct ngene_channel *chan, int state) -//{ -// if (chan->dev->card_info->avf[chan->number]) -// i2c_write_register(&chan->i2c_adapter, -// chan->dev-> -// card_info->avf[chan->number], -// 0xf2, state ? 0x89 : 0x80); -// return 0; -//} +#if 0 +static int avf_output(struct ngene_channel *chan, int state) +{ + if (chan->dev->card_info->avf[chan->number]) + i2c_write_register(&chan->i2c_adapter, + chan->dev-> + card_info->avf[chan->number], + 0xf2, state ? 0x89 : 0x80); + return 0; +} +#endif /* Viper expander: sw11,sw12,sw21,sw22,i2csw1,i2csw2,tsen1,tsen2 */ @@ -3395,162 +3416,167 @@ static int exp_init(struct ngene *dev) return exp_set(dev); } -//static int exp_set_bit(struct ngene *dev, int bit, int val) -//{ -// if (val) -// set_bit(bit, &dev->exp_val); -// else -// clear_bit(bit, &dev->exp_val); -// return exp_set(dev); -//} -// -//static int viper_switch_ctrl(struct ngene_channel *chan, int type, int val) -//{ -// switch (type) { -// case 0: /* I2C tuner gate on/off */ -// return exp_set_bit(chan->dev, 4+chan->number, val); -// case 1: /* Stream: 0=TS 1=ITU */ -// avf_output(chan, val); -// return exp_set_bit(chan->dev, 6+chan->number, val); -// case 2: /* Input: 0=digital 1=analog antenna input */ -// exp_set_bit(chan->dev, 0+chan->number*2, val ? 0 : 1); -// exp_set_bit(chan->dev, 1+chan->number*2, val ? 1 : 0); -// break; -// } -// return 0; -//} -// -//static int viper_switch_ctrl2(struct ngene_channel *chan, int type, int val) -//{ -// switch (type) { -// case 0: /* I2C tuner gate on/off */ -// return exp_set_bit(chan->dev, 4+chan->number, val); -// case 1: /* Stream: 0=TS 1=ITU */ -// avf_output(chan, val); -// return exp_set_bit(chan->dev, 6+chan->number, val); -// case 2: /* Input: 0=digital 1=analog antenna input */ -// exp_set_bit(chan->dev, 0+chan->number*2, val ? 0 : 1); -// exp_set_bit(chan->dev, 1+chan->number*2, 0); -// break; -// } -// return 0; -//} -// -//static int viper_gate_ctrl(struct dvb_frontend *fe, int enable) -//{ -//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -// struct ngene_channel *chan=fe->misc_priv; -//#else /* Why is there no misc_priv available anymore !?!?! */ -// /* Well, just abuse sec :-) */ -// struct ngene_channel *chan=fe->sec_priv; -//#endif -// struct ngene *dev=chan->dev; -// -// return dev->card_info->switch_ctrl(chan, 0, enable); -//} -// -//static int python_switch_ctrl(struct ngene_channel *chan, int type, int val) -//{ -// switch (type) { -// case 0: /* I2C tuner gate on/off */ -// if (chan->number>1) -// return -EINVAL; -// return ngene_command_gpio_set(chan->dev, 3+chan->number, val); -// case 1: /* Stream: 0=TS 1=ITU */ -// avf_output(chan, val); -// return 0; -// } -// return 0; -//} -// -//static int viper_reset_xc(struct dvb_frontend *fe) -//{ -//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -// struct ngene_channel *chan=fe->misc_priv; -//#else -// struct ngene_channel *chan=fe->sec_priv; -//#endif -// struct ngene *dev=chan->dev; -// -// printk("Reset XC3028\n"); -// -// if (chan->number>1) -// return -EINVAL; -// -// ngene_command_gpio_set(dev, 3+chan->number, 0); -// msleep(150); -// ngene_command_gpio_set(dev, 3+chan->number, 1); -// return 0; -//} -// -//static int python_gate_ctrl(struct dvb_frontend *fe, int enable) -//{ -//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -// struct ngene_channel *chan=fe->misc_priv; -//#else /* Why is there no misc_priv available anymore !?!?! */ -// struct ngene_channel *chan=fe->sec_priv; -//#endif -// struct ngene *dev=chan->dev; -// -// if (chan->number==0) -// return ngene_command_gpio_set(dev, 3, enable); -// if (chan->number==1) -// return ngene_command_gpio_set(dev, 4, enable); -// return -EINVAL; -//} +#if 0 +static int exp_set_bit(struct ngene *dev, int bit, int val) +{ + if (val) + set_bit(bit, &dev->exp_val); + else + clear_bit(bit, &dev->exp_val); + return exp_set(dev); +} + +static int viper_switch_ctrl(struct ngene_channel *chan, int type, int val) +{ + switch (type) { + case 0: /* I2C tuner gate on/off */ + return exp_set_bit(chan->dev, 4+chan->number, val); + case 1: /* Stream: 0=TS 1=ITU */ + avf_output(chan, val); + return exp_set_bit(chan->dev, 6+chan->number, val); + case 2: /* Input: 0=digital 1=analog antenna input */ + exp_set_bit(chan->dev, 0+chan->number*2, val ? 0 : 1); + exp_set_bit(chan->dev, 1+chan->number*2, val ? 1 : 0); + break; + } + return 0; +} + +static int viper_switch_ctrl2(struct ngene_channel *chan, int type, int val) +{ + switch (type) { + case 0: /* I2C tuner gate on/off */ + return exp_set_bit(chan->dev, 4+chan->number, val); + case 1: /* Stream: 0=TS 1=ITU */ + avf_output(chan, val); + return exp_set_bit(chan->dev, 6+chan->number, val); + case 2: /* Input: 0=digital 1=analog antenna input */ + exp_set_bit(chan->dev, 0+chan->number*2, val ? 0 : 1); + exp_set_bit(chan->dev, 1+chan->number*2, 0); + break; + } + return 0; +} + +static int viper_gate_ctrl(struct dvb_frontend *fe, int enable) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + struct ngene_channel *chan=fe->misc_priv; +#else /* Why is there no misc_priv available anymore !?!?! */ + /* Well, just abuse sec :-) */ + struct ngene_channel *chan=fe->sec_priv; +#endif + struct ngene *dev=chan->dev; + + return dev->card_info->switch_ctrl(chan, 0, enable); +} + +static int python_switch_ctrl(struct ngene_channel *chan, int type, int val) +{ + switch (type) { + case 0: /* I2C tuner gate on/off */ + if (chan->number>1) + return -EINVAL; + return ngene_command_gpio_set(chan->dev, 3+chan->number, val); + case 1: /* Stream: 0=TS 1=ITU */ + avf_output(chan, val); + return 0; + } + return 0; +} + +static int viper_reset_xc(struct dvb_frontend *fe) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + struct ngene_channel *chan=fe->misc_priv; +#else + struct ngene_channel *chan=fe->sec_priv; +#endif + struct ngene *dev=chan->dev; + + printk("Reset XC3028\n"); + + if (chan->number>1) + return -EINVAL; + + ngene_command_gpio_set(dev, 3+chan->number, 0); + msleep(150); + ngene_command_gpio_set(dev, 3+chan->number, 1); + return 0; +} + +static int python_gate_ctrl(struct dvb_frontend *fe, int enable) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + struct ngene_channel *chan=fe->misc_priv; +#else /* Why is there no misc_priv available anymore !?!?! */ + struct ngene_channel *chan=fe->sec_priv; +#endif + struct ngene *dev=chan->dev; + + if (chan->number==0) + return ngene_command_gpio_set(dev, 3, enable); + if (chan->number==1) + return ngene_command_gpio_set(dev, 4, enable); + return -EINVAL; +} +#endif /****************************************************************************/ /* Demod/tuner attachment ***************************************************/ /****************************************************************************/ -//static int tuner_attach_mt2060(struct ngene_channel *chan) -//{ -// struct ngene *dev=chan->dev; -// void *tconf=dev->card_info->tuner_config[chan->number]; -// u8 drxa=dev->card_info->demoda[chan->number]; -// struct dvb_frontend *fe=chan->fe, *fe2; -// -//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -// fe->misc_priv=chan; -//#else -// fe->sec_priv=chan; -//#endif -// fe->ops.i2c_gate_ctrl=dev->card_info->gate_ctrl; -// -// dev->card_info->gate_ctrl(fe, 1); -// fe2=mt2060_attach(fe, &chan->i2c_adapter, tconf, 1220); -// dev->card_info->gate_ctrl(fe, 0); -// -// i2c_write_register(&chan->i2c_adapter, drxa, 3, 4); -// write_demod(&chan->i2c_adapter, drxa, 0x1012, 15); -// write_demod(&chan->i2c_adapter, drxa, 0x1007, 0xc27); -// write_demod(&chan->i2c_adapter, drxa, 0x0020, 0x003); -// -// return fe2 ? 0 : -ENODEV; -//} -// -//static int tuner_attach_xc3028(struct ngene_channel *chan) -//{ -// struct ngene *dev=chan->dev; -// void *tconf=dev->card_info->tuner_config[chan->number]; -// struct dvb_frontend *fe=chan->fe, *fe2; -// -//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -// fe->misc_priv=chan; -//#else -// fe->sec_priv=chan; -//#endif -// fe->ops.i2c_gate_ctrl=dev->card_info->gate_ctrl; -// -// dev->card_info->gate_ctrl(fe, 1); -// fe2=xc3028_attach(fe, &chan->i2c_adapter, tconf); -// dev->card_info->gate_ctrl(fe, 0); -// -// /*chan->fe->ops.tuner_ops.set_frequency(chan->fe,231250000);*/ -// -// return fe2 ? 0 : -ENODEV; -//} +#if 0 +static int tuner_attach_mt2060(struct ngene_channel *chan) +{ + struct ngene *dev=chan->dev; + void *tconf=dev->card_info->tuner_config[chan->number]; + u8 drxa=dev->card_info->demoda[chan->number]; + struct dvb_frontend *fe=chan->fe, *fe2; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + fe->misc_priv=chan; +#else + fe->sec_priv=chan; +#endif + fe->ops.i2c_gate_ctrl=dev->card_info->gate_ctrl; + + dev->card_info->gate_ctrl(fe, 1); + fe2=mt2060_attach(fe, &chan->i2c_adapter, tconf, 1220); + dev->card_info->gate_ctrl(fe, 0); + + i2c_write_register(&chan->i2c_adapter, drxa, 3, 4); + write_demod(&chan->i2c_adapter, drxa, 0x1012, 15); + write_demod(&chan->i2c_adapter, drxa, 0x1007, 0xc27); + write_demod(&chan->i2c_adapter, drxa, 0x0020, 0x003); + + return fe2 ? 0 : -ENODEV; +} + +static int tuner_attach_xc3028(struct ngene_channel *chan) +{ + struct ngene *dev=chan->dev; + void *tconf=dev->card_info->tuner_config[chan->number]; + struct dvb_frontend *fe=chan->fe, *fe2; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + fe->misc_priv=chan; +#else + fe->sec_priv=chan; +#endif + fe->ops.i2c_gate_ctrl=dev->card_info->gate_ctrl; + + dev->card_info->gate_ctrl(fe, 1); + fe2=xc3028_attach(fe, &chan->i2c_adapter, tconf); + dev->card_info->gate_ctrl(fe, 0); + + /*chan->fe->ops.tuner_ops.set_frequency(chan->fe,231250000);*/ + + return fe2 ? 0 : -ENODEV; +} + +#endif static int tuner_attach_stv6110(struct ngene_channel *chan) { @@ -3581,6 +3607,7 @@ static int tuner_attach_stv6110(struct ngene_channel *chan) feconf->tuner_get_bbgain = ctl->tuner_get_bbgain; feconf->tuner_set_refclk = ctl->tuner_set_refclk; feconf->tuner_get_status = ctl->tuner_get_status; + #else struct stv6110_config *tunerconf = (struct stv6110_config*)chan->dev->card_info->tuner_config[chan->number]; @@ -3603,9 +3630,7 @@ static int tuner_attach_stv6110(struct ngene_channel *chan) chan->fe->ops.set_voltage=lnbh21_set_voltage; #else printk(DEVICE_NAME ": lnbh24_attach: nr = %d, lnb = %x\n", chan->number, chan->dev->card_info->lnb[chan->number]); - if (!dvb_attach(lnbh24_attach, chan->fe, &chan->i2c_adapter, - 0, /* LNBH24_PCL */ - 0, /* LNBH24_TTX */ + if (!dvb_attach(lnbh24_attach, chan->fe, &chan->i2c_adapter, 0, 0, chan->dev->card_info->lnb[chan->number])) { printk(KERN_ERR "No LNBH24 found!\n"); return -ENODEV; @@ -3615,47 +3640,49 @@ static int tuner_attach_stv6110(struct ngene_channel *chan) return 0; } -//static int demod_attach_drxd(struct ngene_channel *chan) -//{ -// void *feconf=chan->dev->card_info->fe_config[chan->number]; -// -// chan->fe=drxd_attach(feconf, -// chan, &chan->i2c_adapter, -// &chan->dev->pci_dev->dev); -// return (chan->fe) ? 0 : -ENODEV; -//} -// -//static int demod_attach_drxh(struct ngene_channel *chan) -//{ -// void *feconf=chan->dev->card_info->fe_config[chan->number]; -// -// chan->fe=drxh_attach(feconf, chan, -// &chan->i2c_adapter, -// &chan->dev->pci_dev->dev); -// return (chan->fe) ? 0 : -ENODEV; -//} -// -//static int demod_attach_stb0899(struct ngene_channel *chan) -//{ -// void *feconf=chan->dev->card_info->fe_config[chan->number]; -// -// chan->fe=stb0899_attach(feconf, -// chan, &chan->i2c_adapter, -// &chan->dev->pci_dev->dev); -// if (chan->fe) { -//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) -// chan->set_tone=chan->fe->ops->set_tone; -// chan->fe->ops->set_tone=lnbh21_set_tone; -// chan->fe->ops->set_voltage=lnbh21_set_voltage; -//#else -// chan->set_tone=chan->fe->ops.set_tone; -// chan->fe->ops.set_tone=lnbh21_set_tone; -// chan->fe->ops.set_voltage=lnbh21_set_voltage; -//#endif -// } -// -// return (chan->fe) ? 0 : -ENODEV; -//} +#if 0 +static int demod_attach_drxd(struct ngene_channel *chan) +{ + void *feconf=chan->dev->card_info->fe_config[chan->number]; + + chan->fe=drxd_attach(feconf, + chan, &chan->i2c_adapter, + &chan->dev->pci_dev->dev); + return (chan->fe) ? 0 : -ENODEV; +} + +static int demod_attach_drxh(struct ngene_channel *chan) +{ + void *feconf=chan->dev->card_info->fe_config[chan->number]; + + chan->fe=drxh_attach(feconf, chan, + &chan->i2c_adapter, + &chan->dev->pci_dev->dev); + return (chan->fe) ? 0 : -ENODEV; +} + +static int demod_attach_stb0899(struct ngene_channel *chan) +{ + void *feconf=chan->dev->card_info->fe_config[chan->number]; + + chan->fe=stb0899_attach(feconf, + chan, &chan->i2c_adapter, + &chan->dev->pci_dev->dev); + if (chan->fe) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) + chan->set_tone=chan->fe->ops->set_tone; + chan->fe->ops->set_tone=lnbh21_set_tone; + chan->fe->ops->set_voltage=lnbh21_set_voltage; +#else + chan->set_tone=chan->fe->ops.set_tone; + chan->fe->ops.set_tone=lnbh21_set_tone; + chan->fe->ops.set_voltage=lnbh21_set_voltage; +#endif + } + + return (chan->fe) ? 0 : -ENODEV; +} +#endif static int demod_attach_stv0900(struct ngene_channel *chan) { @@ -3985,141 +4012,143 @@ fail1: /* Card configs *************************************************************/ /****************************************************************************/ -//static struct drxd_config fe_terratec_dvbt_0 = { -// .index=0, .demod_address=0x70, .demod_revision=0xa2, -// .demoda_address=0x00, .pll_address=0x60, -// .pll_type=DRXD_PLL_DTT7520X, .clock=20000, -// .pll_set=ngene_pll_set_th_dtt7520x, -// .osc_deviation=osc_deviation, -//}; -// -//static struct drxd_config fe_terratec_dvbt_1 = { -// .index=1, .demod_address=0x71, .demod_revision=0xa2, -// .demoda_address=0x00, .pll_address=0x60, -// .pll_type=DRXD_PLL_DTT7520X, .clock=20000, -// .pll_set=ngene_pll_set_th_dtt7520x, -// .osc_deviation=osc_deviation, -//}; -// -//static struct ngene_info ngene_info_terratec = { -// .type=NGENE_TERRATEC, -// .name="Terratec Integra/Cinergy2400i Dual DVB-T", -// .io_type={NGENE_IO_TSIN, NGENE_IO_TSIN}, -// .demod_attach={demod_attach_drxd, demod_attach_drxd}, -// .fe_config={&fe_terratec_dvbt_0, &fe_terratec_dvbt_1 }, -// .i2c_access=1, -//}; +#if 0 +static struct drxd_config fe_terratec_dvbt_0 = { + .index=0, .demod_address=0x70, .demod_revision=0xa2, + .demoda_address=0x00, .pll_address=0x60, + .pll_type=DRXD_PLL_DTT7520X, .clock=20000, + .pll_set=ngene_pll_set_th_dtt7520x, + .osc_deviation=osc_deviation, +}; + +static struct drxd_config fe_terratec_dvbt_1 = { + .index=1, .demod_address=0x71, .demod_revision=0xa2, + .demoda_address=0x00, .pll_address=0x60, + .pll_type=DRXD_PLL_DTT7520X, .clock=20000, + .pll_set=ngene_pll_set_th_dtt7520x, + .osc_deviation=osc_deviation, +}; + +static struct ngene_info ngene_info_terratec = { + .type=NGENE_TERRATEC, + .name="Terratec Integra/Cinergy2400i Dual DVB-T", + .io_type={NGENE_IO_TSIN, NGENE_IO_TSIN}, + .demod_attach={demod_attach_drxd, demod_attach_drxd}, + .fe_config={&fe_terratec_dvbt_0, &fe_terratec_dvbt_1 }, + .i2c_access=1, +}; /****************************************************************************/ -//static struct mt2060_config tuner_python_0 = { -// .i2c_address = 0x60, -// .clock_out = 3, -// .input = 0 -//}; -// -//static struct mt2060_config tuner_python_1 = { -// .i2c_address = 0x61, -// .clock_out = 3, -// .input = 1 -//}; -// -//static struct drxd_config fe_python_0 = { -// .index = 0, -// .demod_address = 0x71, -// .demod_revision = 0xb1, -// .demoda_address = 0x41, -// .clock = 16000, -// .osc_deviation = osc_deviation, -//}; -// -//static struct drxd_config fe_python_1 = { -// .index = 1, -// .demod_address = 0x70, -// .demod_revision = 0xb1, -// .demoda_address = 0x45, -// .clock = 16000, -// .osc_deviation = osc_deviation, -//}; -// -//static struct ngene_info ngene_info_python = { -// .type = NGENE_PYTHON, -// .name = "Micronas MicPython/Hedgehog Dual DVB-T", -// .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_AIN, NGENE_IO_AIN }, -// .demod_attach = { demod_attach_drxd, demod_attach_drxd }, -// .tuner_attach = { tuner_attach_mt2060, tuner_attach_mt2060 }, -// .fe_config = { &fe_python_0, &fe_python_1 }, -// .tuner_config = { &tuner_python_0, &tuner_python_1 }, -// .avf = { 0x43, 0x47 }, -// .msp = { 0x40, 0x42 }, -// .demoda = { 0x41, 0x45 }, -// .gate_ctrl = python_gate_ctrl, -// .switch_ctrl = python_switch_ctrl, -//}; +static struct mt2060_config tuner_python_0 = { + .i2c_address = 0x60, + .clock_out = 3, + .input = 0 +}; + +static struct mt2060_config tuner_python_1 = { + .i2c_address = 0x61, + .clock_out = 3, + .input = 1 +}; + +static struct drxd_config fe_python_0 = { + .index = 0, + .demod_address = 0x71, + .demod_revision = 0xb1, + .demoda_address = 0x41, + .clock = 16000, + .osc_deviation = osc_deviation, +}; + +static struct drxd_config fe_python_1 = { + .index = 1, + .demod_address = 0x70, + .demod_revision = 0xb1, + .demoda_address = 0x45, + .clock = 16000, + .osc_deviation = osc_deviation, +}; + +static struct ngene_info ngene_info_python = { + .type = NGENE_PYTHON, + .name = "Micronas MicPython/Hedgehog Dual DVB-T", + .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_AIN, NGENE_IO_AIN }, + .demod_attach = { demod_attach_drxd, demod_attach_drxd }, + .tuner_attach = { tuner_attach_mt2060, tuner_attach_mt2060 }, + .fe_config = { &fe_python_0, &fe_python_1 }, + .tuner_config = { &tuner_python_0, &tuner_python_1 }, + .avf = { 0x43, 0x47 }, + .msp = { 0x40, 0x42 }, + .demoda = { 0x41, 0x45 }, + .gate_ctrl = python_gate_ctrl, + .switch_ctrl = python_switch_ctrl, +}; /****************************************************************************/ -//static struct drxd_config fe_appb_dvbt_0 = { -// .index = 0, -// .demod_address = 0x71, -// .demod_revision = 0xa2, -// .demoda_address = 0x41, -// .pll_address = 0x63, -// .pll_type = DRXD_PLL_MT3X0823, .clock=20000, -// .pll_set = ngene_pll_set_mt_3x0823, -// .osc_deviation = osc_deviation, -//}; -// -//static struct drxd_config fe_appb_dvbt_1 = { -// .index = 1, -// .demod_address = 0x70, -// .demod_revision = 0xa2, -// .demoda_address = 0x45, -// .pll_address = 0x60, -// .pll_type = DRXD_PLL_MT3X0823, .clock=20000, -// .pll_set = ngene_pll_set_mt_3x0823, -// .osc_deviation = osc_deviation, -//}; -// -//static struct ngene_info ngene_info_appboard = { -// .type = NGENE_APP, -// .name = "Micronas Application Board Dual DVB-T", -// .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, -// .demod_attach = {demod_attach_drxd, demod_attach_drxd}, -// .fe_config = {&fe_appb_dvbt_0, &fe_appb_dvbt_1 }, -// .avf = {0x43, 0x47}, -//}; -// -//static struct ngene_info ngene_info_appboard_ntsc = { -// .type = NGENE_APP, -// .name = "Micronas Application Board Dual DVB-T", -// .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, -// .demod_attach = {demod_attach_drxd, demod_attach_drxd}, -// .fe_config = {&fe_appb_dvbt_0, &fe_appb_dvbt_1 }, -// .avf = {0x43, 0x47}, -// .ntsc=1, -//}; +static struct drxd_config fe_appb_dvbt_0 = { + .index = 0, + .demod_address = 0x71, + .demod_revision = 0xa2, + .demoda_address = 0x41, + .pll_address = 0x63, + .pll_type = DRXD_PLL_MT3X0823, .clock=20000, + .pll_set = ngene_pll_set_mt_3x0823, + .osc_deviation = osc_deviation, +}; + +static struct drxd_config fe_appb_dvbt_1 = { + .index = 1, + .demod_address = 0x70, + .demod_revision = 0xa2, + .demoda_address = 0x45, + .pll_address = 0x60, + .pll_type = DRXD_PLL_MT3X0823, .clock=20000, + .pll_set = ngene_pll_set_mt_3x0823, + .osc_deviation = osc_deviation, +}; + +static struct ngene_info ngene_info_appboard = { + .type = NGENE_APP, + .name = "Micronas Application Board Dual DVB-T", + .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, + .demod_attach = {demod_attach_drxd, demod_attach_drxd}, + .fe_config = {&fe_appb_dvbt_0, &fe_appb_dvbt_1 }, + .avf = {0x43, 0x47}, +}; + +static struct ngene_info ngene_info_appboard_ntsc = { + .type = NGENE_APP, + .name = "Micronas Application Board Dual DVB-T", + .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, + .demod_attach = {demod_attach_drxd, demod_attach_drxd}, + .fe_config = {&fe_appb_dvbt_0, &fe_appb_dvbt_1 }, + .avf = {0x43, 0x47}, + .ntsc=1, +}; /****************************************************************************/ -//static struct stb0899_config fe_sidewinder_0 = { -// .demod_address=0x68, .pll_address=0x63, -//}; -// -//static struct stb0899_config fe_sidewinder_1 = { -// .demod_address=0x6b, .pll_address=0x60, -//}; -// -//static struct ngene_info ngene_info_sidewinder = { -// .type = NGENE_SIDEWINDER, -// .name = "Micronas MicSquirrel/Sidewinder Dual DVB-S2", -// .io_type = { NGENE_IO_TSIN, NGENE_IO_TSIN }, -// .demod_attach = { demod_attach_stb0899, demod_attach_stb0899 }, -// .fe_config = { &fe_sidewinder_0, &fe_sidewinder_1 }, -// .lnb = { 0x0b, 0x08 }, -//}; +static struct stb0899_config fe_sidewinder_0 = { + .demod_address=0x68, .pll_address=0x63, +}; + +static struct stb0899_config fe_sidewinder_1 = { + .demod_address=0x6b, .pll_address=0x60, +}; + +static struct ngene_info ngene_info_sidewinder = { + .type = NGENE_SIDEWINDER, + .name = "Micronas MicSquirrel/Sidewinder Dual DVB-S2", + .io_type = { NGENE_IO_TSIN, NGENE_IO_TSIN }, + .demod_attach = { demod_attach_stb0899, demod_attach_stb0899 }, + .fe_config = { &fe_sidewinder_0, &fe_sidewinder_1 }, + .lnb = { 0x0b, 0x08 }, +}; +#endif /****************************************************************************/ @@ -4133,10 +4162,10 @@ static struct stv090x_config fe_mps2 = { .address = 0x68, .ref_clk = 27000000, - .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, - .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, + .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, /* => TSCFGH.SERIAL & TSCFGH.TSFIFO_DVBCI */ + .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, /* => TSCFGH.SERIAL & TSCFGH.TSFIFO_DVBCI */ - .repeater_level = STV090x_RPTLEVEL_64, /* STV090x_RPTLEVEL_16 */ + .repeater_level = STV090x_RPTLEVEL_16, /* => I2CRPT.ENARPT_LEVEL */ .tuner_init = NULL, .tuner_set_mode = NULL, @@ -4186,12 +4215,12 @@ static struct stv0900_reg stv0900_regs[] = { // { R0900_P1_TNRCFG2, 0x80 }, /* v4l: 0x82 */ // { R0900_P2_TNRCFG2, 0x80 }, /* v4l: 0x02 */ //TSCFG -// { R0900_P1_TSCFGH, 0x60 }, /* v4l: 0xe0 */ -// { R0900_P2_TSCFGH, 0x60 }, /* v4l: 0xe0 */ + { R0900_P1_TSCFGH, 0x60 }, /* v4l: 0xe0 */ + { R0900_P2_TSCFGH, 0x60 }, /* v4l: 0xe0 */ { R0900_P1_TSCFGM, 0x00 }, /* v4l: 0xc0 */ { R0900_P2_TSCFGM, 0x00 }, /* v4l: 0xc0 */ -// { R0900_P1_TSCFGL, 0x20 }, /* v4l: 0x20 */ -// { R0900_P2_TSCFGL, 0x20 }, /* v4l: 0x20 */ + { R0900_P1_TSCFGL, 0x20 }, /* v4l: 0x20 */ + { R0900_P2_TSCFGL, 0x20 }, /* v4l: 0x20 */ // { R0900_P1_BCLC2S2Q, 0x86 }, /* v4l: 0x86 */ // { R0900_P2_BCLC2S2Q, 0xa5 }, /* v4l: 0x86 */ @@ -4203,36 +4232,35 @@ static struct stv0900_reg stv0900_regs[] = { { 0xffff, 0xff }, /* terminate */ }; -//TODO F0900_INV_CLKADCI1 = 1 static struct stv0900_config fe_mps2 = { .demod_address = 0x68, .xtal = 27000000, - .clkmode = 2,/* 0-CLKI, 2-XTALI, else AUTO */ - .diseqc_mode = 2,/* 2/3 PWM */ + .clkmode = 2, /* 0-CLKI, 2-XTALI, else AUTO => SYNTCTRL.SELOSCI */ + .diseqc_mode = 2, /* ??? => DISTXCTL.DISTX_MODE */ /* STV0900_USE_REGISTERS_DEFAULT = 0, * STV0900_SERIAL_PUNCT_CLOCK = 1, * STV0900_SERIAL_CONT_CLOCK = 2, * STV0900_PARALLEL_PUNCT_CLOCK = 3, * STV0900_DVBCI_CLOCK = 4 */ -// .path1_mode = 1, -// .path2_mode = 1, +// .path1_mode = 1, /* => TSCFGH.TSFIFO_SERIAL & TSCFGH.TSFIFO_DVBCI */ +// .path2_mode = 1, /* => TSCFGH.TSFIFO_SERIAL & TSCFGH.TSFIFO_DVBCI */ .ts_config_regs = stv0900_regs, - .tun1_maddress = 0,/* 0x60 */ - .tun2_maddress = 3,/* 0x63 */ - .tun1_adc = 0, - .tun2_adc = 0, + .tun1_maddress = 0, /* 0x60 */ + .tun2_maddress = 3, /* 0x63 */ + .tun1_adc = 1, /* => if 1 TSTTNR1=0x26 */ + .tun2_adc = 1, /* => if 1 TSTTNR3=0x26 */ }; static struct stv6110_config tuner_mps2_0 = { .i2c_address = 0x60, - .mclk = 27000000, - .clk_div = 1, + .mclk = 27000000, /* => CTRL1.K */ + .clk_div = 1, /* => CTRL2.CO_DIV */ }; static struct stv6110_config tuner_mps2_1 = { .i2c_address = 0x63, - .mclk = 27000000, - .clk_div = 1, + .mclk = 27000000, /* => CTRL1.K */ + .clk_div = 1, /* => CTRL2.CO_DIV */ }; #endif /* NGENE_STV090X */ @@ -4254,153 +4282,155 @@ static struct ngene_info ngene_info_mps2 = { /* Yet unnamed S2 card with dual DVB-S2 demod */ /****************************************************************************/ -//static struct stv0900_config fe_s2_0 = { -// .addr=0x68, .pll=0x63, .pll_type=0, .nr=0, -//}; -// -//static struct stv0900_config fe_s2_1 = { -// .addr=0x68, .pll=0x60, .pll_type=0, .nr=1, -//}; -// -//static struct ngene_info ngene_info_s2 = { -// .type = NGENE_SIDEWINDER, -// .name = "S2", -// .io_type = { NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN }, -// .demod_attach = { demod_attach_stv0900, demod_attach_stv0900 }, -// .fe_config = { &fe_s2_0, &fe_s2_1 }, -// .lnb = { 0x0b, 0x08 }, -// .tsf = { 3, 3 }, -// .fw_version = 15, -//}; - -//static struct stv0900_config fe_s2b_0 = { -// .addr=0x68, .pll=0x60, .pll_type=0x10, .nr=0, -//}; -// -//static struct stv0900_config fe_s2b_1 = { -// .addr=0x68, .pll=0x63, .pll_type=0x10, .nr=1, -//}; -// -//static struct ngene_info ngene_info_s2_b = { -// .type = NGENE_SIDEWINDER, -// .name = "S2 V2", -// .io_type = { NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN }, -// .demod_attach = { demod_attach_stv0900, demod_attach_stv0900 }, -// .fe_config = { &fe_s2b_0, &fe_s2b_1 }, -// .lnb = { 0x0b, 0x08 }, -// .tsf = { 3, 3 }, -// .fw_version = 17, -//}; -// -///****************************************************************************/ -// -//static struct xc3028_config tuner_viper_0 = { -// .adr = 0x61, .reset=viper_reset_xc -//}; -// -//static struct xc3028_config tuner_viper_1 = { -// .adr = 0x64, .reset=viper_reset_xc -//}; -// -//static struct drxh_config fe_viper_h_0 = { .adr=0x2b }; -// -//static struct drxh_config fe_viper_h_1 = { .adr=0x29 }; -// -//static struct drxh_config fe_viper_l_0 = { .adr=0x2b, .type=3931 }; -// -//static struct drxh_config fe_viper_l_1 = { .adr=0x29, .type=3931 }; -// -//static struct ngene_info ngene_info_viper_v1 = { -// .type = NGENE_VIPER, -// .name = "Micronas MicViper Dual ATSC DRXH", -// .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_AIN, NGENE_IO_AIN }, -// .demod_attach = { demod_attach_drxh, demod_attach_drxh }, -// .fe_config = { &fe_viper_h_0, &fe_viper_h_1 }, -// .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, -// .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, -// .avf = { 0x43, 0x47 }, -// .msp = { 0x40, 0x42 }, -// .exp = 0x20, -// .exp_init = 0xf5, -// .gate_ctrl = viper_gate_ctrl, -// .switch_ctrl = viper_switch_ctrl, -// .tsf = { 2, 2 }, -//}; -// -//static struct ngene_info ngene_info_viper_v2 = { -// .type = NGENE_VIPER, -// .name = "Micronas MicViper Dual ATSC DRXL", -// .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_AIN, NGENE_IO_AIN }, -// .demod_attach = { demod_attach_drxh, demod_attach_drxh }, -// .fe_config = { &fe_viper_l_0, &fe_viper_l_1 }, -// .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, -// .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, -// .avf = { 0x43, 0x47 }, -// .msp = { 0x40, 0x42 }, -// .exp = 0x38, -// .exp_init = 0xf5, -// .gate_ctrl = viper_gate_ctrl, -// .switch_ctrl = viper_switch_ctrl, -// .tsf = { 2, 2 }, -//}; +#if 0 +static struct stv0900_config fe_s2_0 = { + .addr=0x68, .pll=0x63, .pll_type=0, .nr=0, +}; + +static struct stv0900_config fe_s2_1 = { + .addr=0x68, .pll=0x60, .pll_type=0, .nr=1, +}; + +static struct ngene_info ngene_info_s2 = { + .type = NGENE_SIDEWINDER, + .name = "S2", + .io_type = { NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN }, + .demod_attach = { demod_attach_stv0900, demod_attach_stv0900 }, + .fe_config = { &fe_s2_0, &fe_s2_1 }, + .lnb = { 0x0b, 0x08 }, + .tsf = { 3, 3 }, + .fw_version = 15, +}; + +static struct stv0900_config fe_s2b_0 = { + .addr=0x68, .pll=0x60, .pll_type=0x10, .nr=0, +}; + +static struct stv0900_config fe_s2b_1 = { + .addr=0x68, .pll=0x63, .pll_type=0x10, .nr=1, +}; + +static struct ngene_info ngene_info_s2_b = { + .type = NGENE_SIDEWINDER, + .name = "S2 V2", + .io_type = { NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN }, + .demod_attach = { demod_attach_stv0900, demod_attach_stv0900 }, + .fe_config = { &fe_s2b_0, &fe_s2b_1 }, + .lnb = { 0x0b, 0x08 }, + .tsf = { 3, 3 }, + .fw_version = 17, +}; + +/****************************************************************************/ + +static struct xc3028_config tuner_viper_0 = { + .adr = 0x61, .reset=viper_reset_xc +}; + +static struct xc3028_config tuner_viper_1 = { + .adr = 0x64, .reset=viper_reset_xc +}; + +static struct drxh_config fe_viper_h_0 = { .adr=0x2b }; + +static struct drxh_config fe_viper_h_1 = { .adr=0x29 }; + +static struct drxh_config fe_viper_l_0 = { .adr=0x2b, .type=3931 }; + +static struct drxh_config fe_viper_l_1 = { .adr=0x29, .type=3931 }; + +static struct ngene_info ngene_info_viper_v1 = { + .type = NGENE_VIPER, + .name = "Micronas MicViper Dual ATSC DRXH", + .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_AIN, NGENE_IO_AIN }, + .demod_attach = { demod_attach_drxh, demod_attach_drxh }, + .fe_config = { &fe_viper_h_0, &fe_viper_h_1 }, + .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, + .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, + .avf = { 0x43, 0x47 }, + .msp = { 0x40, 0x42 }, + .exp = 0x20, + .exp_init = 0xf5, + .gate_ctrl = viper_gate_ctrl, + .switch_ctrl = viper_switch_ctrl, + .tsf = { 2, 2 }, +}; + +static struct ngene_info ngene_info_viper_v2 = { + .type = NGENE_VIPER, + .name = "Micronas MicViper Dual ATSC DRXL", + .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_AIN, NGENE_IO_AIN }, + .demod_attach = { demod_attach_drxh, demod_attach_drxh }, + .fe_config = { &fe_viper_l_0, &fe_viper_l_1 }, + .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, + .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, + .avf = { 0x43, 0x47 }, + .msp = { 0x40, 0x42 }, + .exp = 0x38, + .exp_init = 0xf5, + .gate_ctrl = viper_gate_ctrl, + .switch_ctrl = viper_switch_ctrl, + .tsf = { 2, 2 }, +}; /****************************************************************************/ -//static struct ngene_info ngene_info_vbox_v1 = { -// .type = NGENE_VBOX_V1, -// .name = "VBox Cat's Eye 164E", -// .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_AIN, NGENE_IO_AIN }, -// .demod_attach = { demod_attach_drxh, demod_attach_drxh }, -// .fe_config = { &fe_viper_h_0, &fe_viper_h_1 }, -// .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, -// .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, -// .avf = { 0x43, 0x47 }, -// .msp = { 0x40, 0x42 }, -// .exp = 0x20, -// .exp_init = 0xf5, -// .gate_ctrl = viper_gate_ctrl, -// .switch_ctrl = viper_switch_ctrl, -// .tsf = { 2, 2 }, -//}; +static struct ngene_info ngene_info_vbox_v1 = { + .type = NGENE_VBOX_V1, + .name = "VBox Cat's Eye 164E", + .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_AIN, NGENE_IO_AIN }, + .demod_attach = { demod_attach_drxh, demod_attach_drxh }, + .fe_config = { &fe_viper_h_0, &fe_viper_h_1 }, + .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, + .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, + .avf = { 0x43, 0x47 }, + .msp = { 0x40, 0x42 }, + .exp = 0x20, + .exp_init = 0xf5, + .gate_ctrl = viper_gate_ctrl, + .switch_ctrl = viper_switch_ctrl, + .tsf = { 2, 2 }, +}; /****************************************************************************/ -//static struct ngene_info ngene_info_vbox_v2 = { -// .type = NGENE_VBOX_V2, -// .name = "VBox Cat's Eye 164E", -// .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_TSIN | NGENE_IO_TV, -// NGENE_IO_AIN, NGENE_IO_AIN }, -// .demod_attach = { demod_attach_drxh, demod_attach_drxh }, -// .fe_config = { &fe_viper_h_0, &fe_viper_h_1 }, -// .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, -// .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, -// .avf = { 0x43, 0x47 }, -// .msp = { 0x40, 0x42 }, -// .exp = 0x20, -// .exp_init = 0xf5, -// .gate_ctrl = viper_gate_ctrl, -// .switch_ctrl = viper_switch_ctrl2, -// .tsf = { 2, 2 }, -//}; +static struct ngene_info ngene_info_vbox_v2 = { + .type = NGENE_VBOX_V2, + .name = "VBox Cat's Eye 164E", + .io_type = { NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_TSIN | NGENE_IO_TV, + NGENE_IO_AIN, NGENE_IO_AIN }, + .demod_attach = { demod_attach_drxh, demod_attach_drxh }, + .fe_config = { &fe_viper_h_0, &fe_viper_h_1 }, + .tuner_config = { &tuner_viper_0, &tuner_viper_1 }, + .tuner_attach = { tuner_attach_xc3028, tuner_attach_xc3028 }, + .avf = { 0x43, 0x47 }, + .msp = { 0x40, 0x42 }, + .exp = 0x20, + .exp_init = 0xf5, + .gate_ctrl = viper_gate_ctrl, + .switch_ctrl = viper_switch_ctrl2, + .tsf = { 2, 2 }, +}; /****************************************************************************/ -//static struct ngene_info ngene_info_racer = { -// .type = NGENE_RACER, -// .name = "Micronas MicRacer HDTV Decoder Card", -// .io_type = { NGENE_IO_HDTV, NGENE_IO_NONE, -// NGENE_IO_AIN, NGENE_IO_NONE, -// NGENE_IO_TSOUT }, -// .i2s = { 0, 0, 1, 0 }, -// .fw_version = 17, -//}; +static struct ngene_info ngene_info_racer = { + .type = NGENE_RACER, + .name = "Micronas MicRacer HDTV Decoder Card", + .io_type = { NGENE_IO_HDTV, NGENE_IO_NONE, + NGENE_IO_AIN, NGENE_IO_NONE, + NGENE_IO_TSOUT }, + .i2s = { 0, 0, 1, 0 }, + .fw_version = 17, +}; +#endif /****************************************************************************/ @@ -4415,13 +4445,13 @@ static struct ngene_info ngene_info_mps2 = { /****************************************************************************/ static const struct pci_device_id ngene_id_tbl[] __devinitdata = { -//TODO NGENE_ID( 0x153b, 0x1167, ngene_info_terratec ), NGENE_ID( 0x18c3, 0xabc3, ngene_info_mps2 ), #if 0 /* not (yet?) supported */ NGENE_ID( 0x18c3, 0x0000, ngene_info_appboard ), NGENE_ID( 0x18c3, 0x0004, ngene_info_appboard ), NGENE_ID( 0x18c3, 0x8011, ngene_info_appboard ), NGENE_ID( 0x18c3, 0x8015, ngene_info_appboard_ntsc ), + NGENE_ID( 0x153b, 0x1167, ngene_info_terratec ), NGENE_ID( 0x18c3, 0x0030, ngene_info_python ), NGENE_ID( 0x18c3, 0x0052, ngene_info_sidewinder ), NGENE_ID( 0x18c3, 0x8f00, ngene_info_racer ), -- cgit v1.2.3 From 858c76725dd04c8b802e1d72d5f70eefe04484aa Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Sun, 4 Oct 2009 15:00:42 +0200 Subject: Small bugfixing. Replaced integer "ret" by integer "err". --- linux/drivers/media/video/ngene/ngene-snd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/drivers/media/video/ngene/ngene-snd.c b/linux/drivers/media/video/ngene/ngene-snd.c index 28348b4c9..36e796ed4 100644 --- a/linux/drivers/media/video/ngene/ngene-snd.c +++ b/linux/drivers/media/video/ngene/ngene-snd.c @@ -389,10 +389,10 @@ int ngene_snd_init(struct ngene_channel *chan) if (card == NULL) return -ENOMEM; #else - int ret = snd_card_create(index[sound_dev], id[sound_dev], THIS_MODULE, + err = snd_card_create(index[sound_dev], id[sound_dev], THIS_MODULE, sizeof(struct mychip), &card); - if (ret < 0) - return ret; + if (err < 0) + return err; #endif chip= card->private_data; -- cgit v1.2.3 From f3c1d3f451080e0e216b8a9cd409dbd27c3009e7 Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Sun, 4 Oct 2009 20:24:28 +0200 Subject: Use NGENE_LNB. Activated NGENE_LNB to set tone via I2C bus with additional register initialisation using TTX. --- linux/drivers/media/video/ngene/ngene-core.c | 1 + linux/drivers/media/video/ngene/ngene.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/linux/drivers/media/video/ngene/ngene-core.c b/linux/drivers/media/video/ngene/ngene-core.c index 0fad67e17..6b01127ef 100644 --- a/linux/drivers/media/video/ngene/ngene-core.c +++ b/linux/drivers/media/video/ngene/ngene-core.c @@ -3624,6 +3624,7 @@ static int tuner_attach_stv6110(struct ngene_channel *chan) #endif /* NGENE_STV090X */ #ifdef NGENE_LNB + chan->lnbh=0x40; /* use TTX */ chan->fe->sec_priv=chan; chan->set_tone=chan->fe->ops.set_tone; chan->fe->ops.set_tone=lnbh21_set_tone; diff --git a/linux/drivers/media/video/ngene/ngene.h b/linux/drivers/media/video/ngene/ngene.h index 86ba676c7..5a7582e32 100644 --- a/linux/drivers/media/video/ngene/ngene.h +++ b/linux/drivers/media/video/ngene/ngene.h @@ -27,7 +27,7 @@ //#define ONE_ADAPTER #define NGENE_COMMAND_API #define NGENE_STV090X -//#define NGENE_LNB +#define NGENE_LNB //#define NGENE_V4L #include -- cgit v1.2.3 From f54aa101e722c6ffade627cb5cf43b50d894cd9c Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Sun, 11 Oct 2009 14:53:23 +0200 Subject: Changed stv0900_config. Removed stv0900_regs and set stv0900_config.ts_config_regs=NULL. Set path1_mode and path2_mode to STV0900_SRIAL_PUNCT_CLOCK. --- linux/drivers/media/dvb/frontends/stv090x.c | 2 -- linux/drivers/media/video/ngene/ngene-core.c | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/linux/drivers/media/dvb/frontends/stv090x.c b/linux/drivers/media/dvb/frontends/stv090x.c index 7283a8d69..8b152bea3 100644 --- a/linux/drivers/media/dvb/frontends/stv090x.c +++ b/linux/drivers/media/dvb/frontends/stv090x.c @@ -888,9 +888,7 @@ static struct stv090x_reg stv0900_initval[] = { { STV090x_AGCRF1CFG, 0x11 }, { STV090x_AGCRF2CFG, 0x13 }, { STV090x_TSGENERAL1X, 0x14 }, - { STV090x_TSTTNR1, 0x26 }, { STV090x_TSTTNR2, 0x21 }, - { STV090x_TSTTNR3, 0x26 }, { STV090x_TSTTNR4, 0x21 }, { STV090x_P2_DISTXCTL, 0x22 }, { STV090x_P2_F22TX, 0xc0 }, diff --git a/linux/drivers/media/video/ngene/ngene-core.c b/linux/drivers/media/video/ngene/ngene-core.c index 6b01127ef..3d37ec8b4 100644 --- a/linux/drivers/media/video/ngene/ngene-core.c +++ b/linux/drivers/media/video/ngene/ngene-core.c @@ -4191,6 +4191,7 @@ static struct stv6110x_config tuner_mps2_1 = { }; #else +#if 0 static struct stv0900_reg stv0900_regs[] = { // { R0900_TSGENERAL, 0x00 }, //GPIO: @@ -4232,6 +4233,7 @@ static struct stv0900_reg stv0900_regs[] = { { 0xffff, 0xff }, /* terminate */ }; +#endif static struct stv0900_config fe_mps2 = { .demod_address = 0x68, @@ -4243,9 +4245,9 @@ static struct stv0900_config fe_mps2 = { * STV0900_SERIAL_CONT_CLOCK = 2, * STV0900_PARALLEL_PUNCT_CLOCK = 3, * STV0900_DVBCI_CLOCK = 4 */ -// .path1_mode = 1, /* => TSCFGH.TSFIFO_SERIAL & TSCFGH.TSFIFO_DVBCI */ -// .path2_mode = 1, /* => TSCFGH.TSFIFO_SERIAL & TSCFGH.TSFIFO_DVBCI */ - .ts_config_regs = stv0900_regs, + .path1_mode = 1, /* => TSCFGH.TSFIFO_SERIAL & TSCFGH.TSFIFO_DVBCI */ + .path2_mode = 1, /* => TSCFGH.TSFIFO_SERIAL & TSCFGH.TSFIFO_DVBCI */ + .ts_config_regs = NULL, .tun1_maddress = 0, /* 0x60 */ .tun2_maddress = 3, /* 0x63 */ .tun1_adc = 1, /* => if 1 TSTTNR1=0x26 */ @@ -4255,13 +4257,13 @@ static struct stv0900_config fe_mps2 = { static struct stv6110_config tuner_mps2_0 = { .i2c_address = 0x60, .mclk = 27000000, /* => CTRL1.K */ - .clk_div = 1, /* => CTRL2.CO_DIV */ + .clk_div = 0, /* => CTRL2.CO_DIV */ }; static struct stv6110_config tuner_mps2_1 = { .i2c_address = 0x63, .mclk = 27000000, /* => CTRL1.K */ - .clk_div = 1, /* => CTRL2.CO_DIV */ + .clk_div = 0, /* => CTRL2.CO_DIV */ }; #endif /* NGENE_STV090X */ -- cgit v1.2.3 From a7d9fa9242773c926b1259cbbdcc09cac9a7f30b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 12 Oct 2009 20:33:42 +0200 Subject: Committer: helau On branch mediapointer-dvb-s2 modified: linux/include/linux/dvb/video.h changed for compiling non kernel modules --- linux/include/linux/dvb/video.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux/include/linux/dvb/video.h b/linux/include/linux/dvb/video.h index 1d750c0fd..0ae3fd8fa 100644 --- a/linux/include/linux/dvb/video.h +++ b/linux/include/linux/dvb/video.h @@ -25,9 +25,8 @@ #define _DVBVIDEO_H_ #include -#ifdef __KERNEL__ #include -#else +#ifndef __KERNEL__ #include #include #endif -- cgit v1.2.3 From 768ce27cedcf408552a624d037d910167421b7e7 Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Wed, 28 Oct 2009 20:53:27 +0100 Subject: Added subvendor id "0xabc4" --- linux/drivers/media/video/ngene/ngene-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux/drivers/media/video/ngene/ngene-core.c b/linux/drivers/media/video/ngene/ngene-core.c index 3d37ec8b4..881d14abb 100644 --- a/linux/drivers/media/video/ngene/ngene-core.c +++ b/linux/drivers/media/video/ngene/ngene-core.c @@ -4270,7 +4270,7 @@ static struct stv6110_config tuner_mps2_1 = { static struct ngene_info ngene_info_mps2 = { .type = NGENE_SIDEWINDER, - .name = "Media-Pointer MP-S2² DVB-S2 Twin Tuner", + .name = "Media-Pointer MP-S2� DVB-S2 Twin Tuner", .io_type = { NGENE_IO_TSIN, NGENE_IO_TSIN }, .demod_attach = { demod_attach_stv0900, demod_attach_stv0900 }, .tuner_attach = { tuner_attach_stv6110, tuner_attach_stv6110 }, @@ -4449,6 +4449,7 @@ static struct ngene_info ngene_info_racer = { static const struct pci_device_id ngene_id_tbl[] __devinitdata = { NGENE_ID( 0x18c3, 0xabc3, ngene_info_mps2 ), + NGENE_ID( 0x18c3, 0xabc4, ngene_info_mps2 ), #if 0 /* not (yet?) supported */ NGENE_ID( 0x18c3, 0x0000, ngene_info_appboard ), NGENE_ID( 0x18c3, 0x0004, ngene_info_appboard ), -- cgit v1.2.3 From b47e35a25d357fca19c553b93b07e1820f389e0f Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Wed, 28 Oct 2009 21:00:32 +0100 Subject: Removed "#define NGENE_LNB" and also use of lnbh24 module. Removed stv0900_regs. --- linux/drivers/media/video/ngene/ngene-core.c | 55 ---------------------------- linux/drivers/media/video/ngene/ngene.h | 1 - 2 files changed, 56 deletions(-) diff --git a/linux/drivers/media/video/ngene/ngene-core.c b/linux/drivers/media/video/ngene/ngene-core.c index 881d14abb..c9955f3ee 100644 --- a/linux/drivers/media/video/ngene/ngene-core.c +++ b/linux/drivers/media/video/ngene/ngene-core.c @@ -52,7 +52,6 @@ #include "stv0900_reg.h" #include "stv6110.h" #endif /* NGENE_STV090X */ -#include "lnbh24.h" #ifdef NGENE_COMMAND_API #include "ngene-ioctls.h" @@ -3331,7 +3330,6 @@ static struct dvb_device dvbdev_video = { /* LNBH21 *******************************************************************/ /****************************************************************************/ -#ifdef NGENE_LNB static int lnbh21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) { @@ -3379,7 +3377,6 @@ static int lnbh21_set_tone(struct dvb_frontend *fe, return i2c_write(&chan->i2c_adapter, chan->dev->card_info->lnb[chan->number], chan->lnbh); } -#endif /****************************************************************************/ @@ -3623,20 +3620,11 @@ static int tuner_attach_stv6110(struct ngene_channel *chan) } #endif /* NGENE_STV090X */ -#ifdef NGENE_LNB chan->lnbh=0x40; /* use TTX */ chan->fe->sec_priv=chan; chan->set_tone=chan->fe->ops.set_tone; chan->fe->ops.set_tone=lnbh21_set_tone; chan->fe->ops.set_voltage=lnbh21_set_voltage; -#else - printk(DEVICE_NAME ": lnbh24_attach: nr = %d, lnb = %x\n", chan->number, chan->dev->card_info->lnb[chan->number]); - if (!dvb_attach(lnbh24_attach, chan->fe, &chan->i2c_adapter, 0, 0, - chan->dev->card_info->lnb[chan->number])) { - printk(KERN_ERR "No LNBH24 found!\n"); - return -ENODEV; - } -#endif /* NGENE_LNB */ return 0; } @@ -4191,49 +4179,6 @@ static struct stv6110x_config tuner_mps2_1 = { }; #else -#if 0 -static struct stv0900_reg stv0900_regs[] = { -// { R0900_TSGENERAL, 0x00 }, -//GPIO: -// { R0900_CLKI2CFG, 0x5a }, /* v4l: n.d. */ // GPIO: open-drain=0, xor=0, value=45 (CLKOUT3) -// { R0900_ERROR1CFG, 0xc4 }, /* v4l: n.d. */ // GPIO: open-drain=1, xor=0, value=22 (ERROR1) -// { R0900_CLKOUT27CFG, 0x7e }, /* v4l: n.d. */ // GPIO: open-drain=0, xor=0, value=63 (XTAL_IN) -// { R0900_CLKOUT1CFG, 0xc6 }, /* v4l: 0x50 */ // GPIO: open-drain=1, xor=0, value=35 (CLKOUT1) -// { R0900_CLKOUT2CFG, 0xd0 }, /* v4l: 0x50 */ // GPIO: open-drain=1, xor=0, value=40 (CLKOUT2) -// { R0900_DATA71CFG, 0xc8 }, /* v4l: 0x52 */ // GPIO: open-drain=1, xor=0, value=36 (D71) -// { R0900_DISEQCO1CFG, 0x14 }, /* v4l: n.d. */ // GPIO: open-drain=0, xor=0, value=10 (DISEQCOUT1) -// { R0900_DISEQCO2CFG, 0x16 }, /* v4l: n.d. */ // GPIO: open-drain=0, xor=0, value=11 (DISEQCOUT2) -// { R0900_GPIO9CFG, 0x00 }, /* v4l: n.d. */ // GPIO: open-drain=0, xor=0, value= 0 (logical 0) -// { R0900_GPIO10CFG, 0x02 }, /* v4l: n.d. */ // GPIO: open-drain=0, xor=0, value= 1 (logical 1) -// { R0900_DPN1CFG, 0xc0 }, /* v4l: 0x4a */ // GPIO: open-drain=1, xor=0, value=32 (DPN1) -// { R0900_STROUT1CFG, 0xc2 }, /* v4l: 0x4c */ // GPIO: open-drain=1, xor=0, value=33 (STROUT1) -// { R0900_STROUT2CFG, 0xcc }, /* v4l: 0x4c */ // GPIO: open-drain=1, xor=0, value=38 (STROUT2) -// -// { R0900_P1_LDT2, 0xb0 }, /* v4l: 0xb8 */ // Negative edge of carrier lock detector (n=2:1) -// { R0900_P2_LDT2, 0xb0 }, /* v4l: 0xb8 */ // Negative edge of carrier lock detector (n=2:1) -// { R0900_P1_TMGCFG, 0xd3 }, /* v4l: 0xd2 */ // Timing lock detector -// { R0900_P2_TMGCFG, 0xd3 }, /* v4l: 0xd2 */ // Timing lock detector -//TNRCFG -// { R0900_P1_TNRCFG2, 0x80 }, /* v4l: 0x82 */ -// { R0900_P2_TNRCFG2, 0x80 }, /* v4l: 0x02 */ -//TSCFG - { R0900_P1_TSCFGH, 0x60 }, /* v4l: 0xe0 */ - { R0900_P2_TSCFGH, 0x60 }, /* v4l: 0xe0 */ - { R0900_P1_TSCFGM, 0x00 }, /* v4l: 0xc0 */ - { R0900_P2_TSCFGM, 0x00 }, /* v4l: 0xc0 */ - { R0900_P1_TSCFGL, 0x20 }, /* v4l: 0x20 */ - { R0900_P2_TSCFGL, 0x20 }, /* v4l: 0x20 */ - -// { R0900_P1_BCLC2S2Q, 0x86 }, /* v4l: 0x86 */ -// { R0900_P2_BCLC2S2Q, 0xa5 }, /* v4l: 0x86 */ -// { R0900_P1_BCLC2S28, 0x86 }, /* v4l: 0x86 */ -// { R0900_P2_BCLC2S28, 0xa5 }, /* v4l: 0x86 */ -// { R0900_P1_SFRUPRATIO, 0x40 }, /* v4l: 0xf0 */ -// { R0900_P2_SFRUPRATIO, 0x40 }, /* v4l: 0xf0 */ - - { 0xffff, 0xff }, /* terminate */ -}; -#endif static struct stv0900_config fe_mps2 = { .demod_address = 0x68, diff --git a/linux/drivers/media/video/ngene/ngene.h b/linux/drivers/media/video/ngene/ngene.h index 5a7582e32..7f0637fdf 100644 --- a/linux/drivers/media/video/ngene/ngene.h +++ b/linux/drivers/media/video/ngene/ngene.h @@ -27,7 +27,6 @@ //#define ONE_ADAPTER #define NGENE_COMMAND_API #define NGENE_STV090X -#define NGENE_LNB //#define NGENE_V4L #include -- cgit v1.2.3 From f2ad5ccac9fe27a8d3105ed66896197aab66d368 Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Sat, 14 Nov 2009 18:35:53 +0100 Subject: Added changes from http://powarman.dyndns.org/hgwebdir.cgi/v4l-dvb/. --- linux/drivers/media/dvb/frontends/stv090x.c | 344 +++++++++++++---------- linux/drivers/media/dvb/frontends/stv090x_priv.h | 3 +- linux/drivers/media/dvb/frontends/stv090x_reg.h | 70 +++-- linux/drivers/media/dvb/frontends/stv6110x.c | 6 +- 4 files changed, 232 insertions(+), 191 deletions(-) diff --git a/linux/drivers/media/dvb/frontends/stv090x.c b/linux/drivers/media/dvb/frontends/stv090x.c index 8b152bea3..2cddbd5f6 100644 --- a/linux/drivers/media/dvb/frontends/stv090x.c +++ b/linux/drivers/media/dvb/frontends/stv090x.c @@ -1556,7 +1556,7 @@ static int stv090x_set_min_srate(struct stv090x_state *state, u32 clk, u32 srate sym /= (state->mclk >> 7); } - if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0xff)) < 0) /* MSB */ + if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0x7f)) < 0) /* MSB */ goto err; if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym & 0xff)) < 0) /* LSB */ goto err; @@ -1630,9 +1630,9 @@ static int stv090x_set_viterbi(struct stv090x_state *state) { switch (state->search_mode) { case STV090x_SEARCH_AUTO: - if (STV090x_WRITE_DEMOD(state, FECM, 0x10) < 0) /* DVB-S and DVB-S2 */ + if (STV090x_WRITE_DEMOD(state, FECM, 0x00) < 0) /* DVB-S and DVB-S2, disable DSS in auto mode */ goto err; - if (STV090x_WRITE_DEMOD(state, PRVIT, 0x3f) < 0) /* all puncture rate */ + if (STV090x_WRITE_DEMOD(state, PRVIT, 0x2f) < 0) /* all puncture rate except 6/7 */ goto err; break; case STV090x_SEARCH_DVBS1: @@ -1665,7 +1665,7 @@ static int stv090x_set_viterbi(struct stv090x_state *state) break; default: - if (STV090x_WRITE_DEMOD(state, PRVIT, 0x2f) < 0) /* all */ + if (STV090x_WRITE_DEMOD(state, PRVIT, 0x2f) < 0) /* all except 6/7 */ goto err; break; } @@ -1969,12 +1969,18 @@ static int stv090x_delivery_search(struct stv090x_state *state) goto err; } + if (stv090x_set_vit_thtracq(state) < 0) + goto err; break; case STV090x_SEARCH_AUTO: default: /* enable DVB-S2 and DVB-S2 in Auto MODE */ reg = STV090x_READ_DEMOD(state, DMDCFGMD); + STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 0); + STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0); + if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) + goto err; STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1); STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1); if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) @@ -2009,17 +2015,8 @@ static int stv090x_delivery_search(struct stv090x_state *state) goto err; } - if (state->srate >= 2000000) { - /* Srate >= 2MSPS, Viterbi threshold to acquire */ - if (stv090x_set_vit_thacq(state) < 0) - goto err; - } else { - /* Srate < 2MSPS, Reset Viterbi thresholdto track - * and then re-acquire - */ - if (stv090x_set_vit_thtracq(state) < 0) - goto err; - } + if (stv090x_set_vit_thacq(state) < 0) + goto err; if (stv090x_set_viterbi(state) < 0) goto err; @@ -2048,7 +2045,7 @@ static int stv090x_start_search(struct stv090x_state *state) goto err; if (STV090x_WRITE_DEMOD(state, CFRUP1, 0x0f) < 0) goto err; - if (STV090x_WRITE_DEMOD(state, CFRUP1, 0xff) < 0) + if (STV090x_WRITE_DEMOD(state, CFRUP0, 0xff) < 0) goto err; if (STV090x_WRITE_DEMOD(state, CFRLOW1, 0xf0) < 0) goto err; @@ -2102,7 +2099,7 @@ static int stv090x_start_search(struct stv090x_state *state) if (STV090x_WRITE_DEMOD(state, CFRUP1, MSB(freq)) < 0) goto err; - if (STV090x_WRITE_DEMOD(state, CFRUP1, LSB(freq)) < 0) + if (STV090x_WRITE_DEMOD(state, CFRUP0, LSB(freq)) < 0) goto err; freq *= -1; @@ -2153,6 +2150,9 @@ static int stv090x_start_search(struct stv090x_state *state) if (STV090x_WRITE_DEMOD(state, DMDCFG2, reg) < 0) goto err; + if (STV090x_WRITE_DEMOD(state, RTC, 0x88) < 0) + goto err; + if (state->dev_ver >= 0x20) { /*Frequency offset detector setting*/ if (state->srate < 2000000) { @@ -2161,20 +2161,23 @@ static int stv090x_start_search(struct stv090x_state *state) if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x39) < 0) goto err; } else { - /* Cut 2 */ + /* Cut 3 */ if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x89) < 0) goto err; } if (STV090x_WRITE_DEMOD(state, CARHDR, 0x40) < 0) goto err; } - - if (state->srate < 10000000) { + else if (state->srate < 10000000) { if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4c) < 0) goto err; + if (STV090x_WRITE_DEMOD(state, CARHDR, 0x20) < 0) + goto err; } else { if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4b) < 0) goto err; + if (STV090x_WRITE_DEMOD(state, CARHDR, 0x20) < 0) + goto err; } } else { if (state->srate < 10000000) { @@ -2216,14 +2219,14 @@ err: static int stv090x_get_agc2_min_level(struct stv090x_state *state) { - u32 agc2_min = 0, agc2 = 0, freq_init, freq_step, reg; + u32 agc2_min = 0xffff, agc2 = 0, freq_init, freq_step, reg; s32 i, j, steps, dir; if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) goto err; reg = STV090x_READ_DEMOD(state, DMDCFGMD); - STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1); - STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1); + STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 0); + STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0); if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) goto err; @@ -2240,10 +2243,8 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state) if (stv090x_set_srate(state, 1000000) < 0) goto err; - steps = -1 + state->search_range / 1000000; - steps /= 2; - steps = (2 * steps) + 1; - if (steps < 0) + steps = state->search_range / 1000000; + if (steps <= 0) steps = 1; dir = 1; @@ -2256,7 +2257,7 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state) else freq_init = freq_init - (freq_step * i); - dir = -1; + dir *= -1; if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5c) < 0) /* Demod RESET */ goto err; @@ -2267,13 +2268,13 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state) if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */ goto err; msleep(10); + + agc2 = 0; for (j = 0; j < 10; j++) { - agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8; - agc2 |= STV090x_READ_DEMOD(state, AGC2I0); + agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | STV090x_READ_DEMOD(state, AGC2I0); } agc2 /= 10; - agc2_min = 0xffff; - if (agc2 < 0xffff) + if (agc2 < agc2_min) agc2_min = agc2; } @@ -2315,6 +2316,13 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) int tmg_lock = 0, i; s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq; u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg; + u32 agc2th; + + if (state->dev_ver >= 0x30) { + agc2th = 0x2e00; + } else { + agc2th = 0x1f00; + } reg = STV090x_READ_DEMOD(state, DMDISTATE); STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */ @@ -2322,13 +2330,15 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) goto err; if (STV090x_WRITE_DEMOD(state, TMGCFG, 0x12) < 0) goto err; + if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc0) < 0) + goto err; if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0xf0) < 0) goto err; if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0xe0) < 0) goto err; reg = STV090x_READ_DEMOD(state, DMDCFGMD); STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1); - STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1); + STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0); if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) goto err; @@ -2342,13 +2352,13 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) goto err; if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0) goto err; - if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x60) < 0) + if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x50) < 0) goto err; if (state->dev_ver >= 0x30) { if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x99) < 0) goto err; - if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x95) < 0) + if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x98) < 0) goto err; } else if (state->dev_ver >= 0x20) { @@ -2383,23 +2393,28 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) while ((!tmg_lock) && (cur_step < steps)) { if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5f) < 0) /* Demod RESET */ goto err; - reg = STV090x_READ_DEMOD(state, DMDISTATE); - STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x00); /* trigger acquisition */ - if (STV090x_WRITE_DEMOD(state, DMDISTATE, reg) < 0) + if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) + goto err; + if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0) + goto err; + if (STV090x_WRITE_DEMOD(state, SFRINIT1, 0x00) < 0) + goto err; + if (STV090x_WRITE_DEMOD(state, SFRINIT0, 0x00) < 0) + goto err; + if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x40) < 0) /* trigger acquisition */ goto err; msleep(50); for (i = 0; i < 10; i++) { reg = STV090x_READ_DEMOD(state, DSTATUS); if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2) tmg_cpt++; - agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8; - agc2 |= STV090x_READ_DEMOD(state, AGC2I0); + agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | STV090x_READ_DEMOD(state, AGC2I0); } agc2 /= 10; srate_coarse = stv090x_get_srate(state, state->mclk); cur_step++; dir *= -1; - if ((tmg_cpt >= 5) && (agc2 < 0x1f00) && (srate_coarse < 55000000) && (srate_coarse > 850000)) + if ((tmg_cpt >= 5) && (agc2 < agc2th) && (srate_coarse < 50000000) && (srate_coarse > 850000)) tmg_lock = 1; else if (cur_step < steps) { if (dir > 0) @@ -2412,7 +2427,7 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) goto err; if (state->config->tuner_set_frequency) { - if (state->config->tuner_set_frequency(fe, state->frequency) < 0) + if (state->config->tuner_set_frequency(fe, freq) < 0) goto err; } @@ -2469,7 +2484,7 @@ static u32 stv090x_srate_srch_fine(struct stv090x_state *state) else { if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) /* Demod RESET */ goto err; - if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0x01) < 0) + if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc1) < 0) goto err; if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0x20) < 0) goto err; @@ -2482,6 +2497,9 @@ static u32 stv090x_srate_srch_fine(struct stv090x_state *state) if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) goto err; + if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) + goto err; + if (state->dev_ver >= 0x30) { if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0) goto err; @@ -2587,12 +2605,12 @@ static int stv090x_get_dmdlock(struct stv090x_state *state, s32 timeout) static int stv090x_blind_search(struct stv090x_state *state) { u32 agc2, reg, srate_coarse; - s32 timeout_dmd = 500, cpt_fail, agc2_ovflw, i; + s32 cpt_fail, agc2_ovflw, i; u8 k_ref, k_max, k_min; int coarse_fail, lock; - k_max = 120; - k_min = 30; + k_max = 110; + k_min = 10; agc2 = stv090x_get_agc2_min_level(state); @@ -2631,7 +2649,7 @@ static int stv090x_blind_search(struct stv090x_state *state) srate_coarse = stv090x_srate_srch_fine(state); if (srate_coarse != 0) { stv090x_get_lock_tmg(state); - lock = stv090x_get_dmdlock(state, timeout_dmd); + lock = stv090x_get_dmdlock(state, state->DemodTimeout); } else { lock = 0; } @@ -2639,8 +2657,7 @@ static int stv090x_blind_search(struct stv090x_state *state) cpt_fail = 0; agc2_ovflw = 0; for (i = 0; i < 10; i++) { - agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8; - agc2 |= STV090x_READ_DEMOD(state, AGC2I0); + agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | STV090x_READ_DEMOD(state, AGC2I0); if (agc2 >= 0xff00) agc2_ovflw++; reg = STV090x_READ_DEMOD(state, DSTATUS2); @@ -2654,7 +2671,7 @@ static int stv090x_blind_search(struct stv090x_state *state) lock = 0; } - k_ref -= 30; + k_ref -= 20; } while ((k_ref >= k_min) && (!lock) && (!coarse_fail)); } @@ -2793,7 +2810,7 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd) goto err; if (state->config->tuner_set_frequency) { - if (state->config->tuner_set_frequency(fe, state->frequency) < 0) + if (state->config->tuner_set_frequency(fe, freq) < 0) goto err; } @@ -2824,17 +2841,6 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd) goto err; STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c); - if (state->delsys == STV090x_DVBS2) { - reg = STV090x_READ_DEMOD(state, DMDCFGMD); - STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 0); - STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0); - if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) - goto err; - STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1); - STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1); - if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) - goto err; - } if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) goto err; if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0) @@ -3156,7 +3162,7 @@ static s32 stv090x_get_car_freq(struct stv090x_state *state, u32 mclk) derot = (int_1 * int_2) + ((int_1 * tmp_2) >> 12) + - ((int_1 * tmp_1) >> 12); + ((int_2 * tmp_1) >> 12); return derot; } @@ -3463,7 +3469,7 @@ static int stv090x_optimize_track(struct stv090x_state *state) switch (state->delsys) { case STV090x_DVBS1: case STV090x_DSS: - if (state->algo == STV090x_SEARCH_AUTO) { + if (state->search_mode == STV090x_SEARCH_AUTO) { reg = STV090x_READ_DEMOD(state, DMDCFGMD); STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1); STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0); @@ -3594,6 +3600,9 @@ static int stv090x_optimize_track(struct stv090x_state *state) goto err; #endif blind_tune = 1; + + if (stv090x_dvbs_track_crl(state) < 0) + goto err; } if (state->dev_ver >= 0x20) { @@ -3854,7 +3863,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) struct dvb_frontend *fe = &state->frontend; enum stv090x_signal_state signal_state = STV090x_NOCARRIER; u32 reg; - s32 timeout_dmd = 500, timeout_fec = 50, agc1_power, power_iq = 0, i; + s32 agc1_power, power_iq = 0, i; int lock = 0, low_sr = 0, no_signal = 0; reg = STV090x_READ_DEMOD(state, TSCFGH); @@ -3866,8 +3875,13 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) goto err; if (state->dev_ver >= 0x20) { - if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x9e) < 0) /* cut 2.0 */ - goto err; + if (state->srate > 5000000) { + if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x9e) < 0) /* cut 2.0 */ + goto err; + } else { + if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x82) < 0) /* cut 2.0 */ + goto err; + } } stv090x_get_lock_tmg(state); @@ -3987,7 +4001,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) if ((agc1_power == 0) && (power_iq < STV090x_IQPOWER_THRESHOLD)) { dprintk(FE_ERROR, 1, "No Signal: POWER_IQ=0x%02x", power_iq); lock = 0; - + signal_state = STV090x_NOAGC1; } else { reg = STV090x_READ_DEMOD(state, DEMOD); STV090x_SETFIELD_Px(reg, SPECINV_CONTROL_FIELD, state->inversion); @@ -4011,83 +4025,82 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) } } - /* need to check for AGC1 state */ - + if (signal_state != STV090x_NOAGC1) { + if (state->algo == STV090x_BLIND_SEARCH) + lock = stv090x_blind_search(state); - if (state->algo == STV090x_BLIND_SEARCH) - lock = stv090x_blind_search(state); + else if (state->algo == STV090x_COLD_SEARCH) + lock = stv090x_get_coldlock(state, state->DemodTimeout); - else if (state->algo == STV090x_COLD_SEARCH) - lock = stv090x_get_coldlock(state, timeout_dmd); + else if (state->algo == STV090x_WARM_SEARCH) + lock = stv090x_get_dmdlock(state, state->DemodTimeout); - else if (state->algo == STV090x_WARM_SEARCH) - lock = stv090x_get_dmdlock(state, timeout_dmd); - - if ((!lock) && (state->algo == STV090x_COLD_SEARCH)) { - if (!low_sr) { - if (stv090x_chk_tmg(state)) - lock = stv090x_sw_algo(state); + if ((!lock) && (state->algo == STV090x_COLD_SEARCH)) { + if (!low_sr) { + if (stv090x_chk_tmg(state)) + lock = stv090x_sw_algo(state); + } } - } - if (lock) - signal_state = stv090x_get_sig_params(state); + if (lock) + signal_state = stv090x_get_sig_params(state); - if ((lock) && (signal_state == STV090x_RANGEOK)) { /* signal within Range */ - stv090x_optimize_track(state); + if ((lock) && (signal_state == STV090x_RANGEOK)) { /* signal within Range */ + stv090x_optimize_track(state); - if (state->dev_ver >= 0x20) { - /* >= Cut 2.0 :release TS reset after - * demod lock and optimized Tracking - */ - reg = STV090x_READ_DEMOD(state, TSCFGH); - STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0); /* release merger reset */ - if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) - goto err; + if (state->dev_ver >= 0x20) { + /* >= Cut 2.0 :release TS reset after + * demod lock and optimized Tracking + */ + reg = STV090x_READ_DEMOD(state, TSCFGH); + STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0); /* release merger reset */ + if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) + goto err; - msleep(3); + msleep(3); - STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* merger reset */ - if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) - goto err; + STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* merger reset */ + if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) + goto err; - STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0); /* release merger reset */ - if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) - goto err; - } + STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0); /* release merger reset */ + if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) + goto err; + } - if (stv090x_get_lock(state, timeout_fec, timeout_fec)) { - lock = 1; - if (state->delsys == STV090x_DVBS2) { - stv090x_set_s2rolloff(state); + if (stv090x_get_lock(state, state->FecTimeout, state->FecTimeout)) { + lock = 1; + if (state->delsys == STV090x_DVBS2) { + stv090x_set_s2rolloff(state); - reg = STV090x_READ_DEMOD(state, PDELCTRL2); - STV090x_SETFIELD_Px(reg, RESET_UPKO_COUNT, 1); - if (STV090x_WRITE_DEMOD(state, PDELCTRL2, reg) < 0) - goto err; - /* Reset DVBS2 packet delinator error counter */ - reg = STV090x_READ_DEMOD(state, PDELCTRL2); - STV090x_SETFIELD_Px(reg, RESET_UPKO_COUNT, 0); - if (STV090x_WRITE_DEMOD(state, PDELCTRL2, reg) < 0) - goto err; + reg = STV090x_READ_DEMOD(state, PDELCTRL2); + STV090x_SETFIELD_Px(reg, RESET_UPKO_COUNT, 1); + if (STV090x_WRITE_DEMOD(state, PDELCTRL2, reg) < 0) + goto err; + /* Reset DVBS2 packet delinator error counter */ + reg = STV090x_READ_DEMOD(state, PDELCTRL2); + STV090x_SETFIELD_Px(reg, RESET_UPKO_COUNT, 0); + if (STV090x_WRITE_DEMOD(state, PDELCTRL2, reg) < 0) + goto err; - if (STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x67) < 0) /* PER */ + if (STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x67) < 0) /* PER */ + goto err; + } else { + if (STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x75) < 0) + goto err; + } + /* Reset the Total packet counter */ + if (STV090x_WRITE_DEMOD(state, FBERCPT4, 0x00) < 0) goto err; - } else { - if (STV090x_WRITE_DEMOD(state, ERRCTRL1, 0x75) < 0) + /* Reset the packet Error counter2 */ + if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1) < 0) goto err; + } else { + lock = 0; + signal_state = STV090x_NODATA; + no_signal = stv090x_chk_signal(state); } - /* Reset the Total packet counter */ - if (STV090x_WRITE_DEMOD(state, FBERCPT4, 0x00) < 0) - goto err; - /* Reset the packet Error counter2 */ - if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1) < 0) - goto err; - } else { - lock = 0; - signal_state = STV090x_NODATA; - no_signal = stv090x_chk_signal(state); } } return signal_state; @@ -4108,7 +4121,13 @@ static enum dvbfe_search stv090x_search(struct dvb_frontend *fe, struct dvb_fron state->search_mode = STV090x_SEARCH_AUTO; state->algo = STV090x_COLD_SEARCH; state->fec = STV090x_PRERR; - state->search_range = 2000000; + if (state->srate > 10000000) { + dprintk(FE_DEBUG, 1, "Search range: 10 MHz"); + state->search_range = 10000000; + } else { + dprintk(FE_DEBUG, 1, "Search range: 5 MHz"); + state->search_range = 5000000; + } if (stv090x_algo(state) == STV090x_RANGEOK) { dprintk(FE_DEBUG, 1, "Search success!"); @@ -4121,7 +4140,6 @@ static enum dvbfe_search stv090x_search(struct dvb_frontend *fe, struct dvb_fron return DVBFE_ALGO_SEARCH_ERROR; } -/* FIXME! */ static int stv090x_read_status(struct dvb_frontend *fe, enum fe_status *status) { struct stv090x_state *state = fe->demodulator_priv; @@ -4143,9 +4161,12 @@ static int stv090x_read_status(struct dvb_frontend *fe, enum fe_status *status) dprintk(FE_DEBUG, 1, "Delivery system: DVB-S2"); reg = STV090x_READ_DEMOD(state, DSTATUS); if (STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD)) { - reg = STV090x_READ_DEMOD(state, TSSTATUS); - if (STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD)) { - *status = FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; + reg = STV090x_READ_DEMOD(state, PDELSTATUS1); + if (STV090x_GETFIELD_Px(reg, PKTDELIN_LOCK_FIELD)) { + reg = STV090x_READ_DEMOD(state, TSSTATUS); + if (STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD)) { + *status = FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; + } } } break; @@ -4224,14 +4245,10 @@ static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int val) int res = 0; int min = 0, med; - if (val < tab[min].read) - res = tab[min].real; - else if (val >= tab[max].read) - res = tab[max].real; - else { + if ((val >= tab[min].read && val < tab[max].read) || (val >= tab[max].read && val < tab[min].read)) { while ((max - min) > 1) { med = (max + min) / 2; - if (val >= tab[min].read && val < tab[med].read) + if ((val >= tab[min].read && val < tab[med].read) || (val >= tab[med].read && val < tab[min].read)) max = med; else min = med; @@ -4240,6 +4257,18 @@ static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int val) (tab[max].real - tab[min].real) / (tab[max].read - tab[min].read)) + tab[min].real; + } else { + if (tab[min].read < tab[max].read) { + if (val < tab[min].read) + res = tab[min].real; + else if (val >= tab[max].read) + res = tab[max].real; + } else { + if (val >= tab[min].read) + res = tab[min].real; + else if (val < tab[max].read) + res = tab[max].real; + } } return res; @@ -4249,16 +4278,21 @@ static int stv090x_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { struct stv090x_state *state = fe->demodulator_priv; u32 reg; - s32 agc; + s32 agc_0, agc_1, agc; + s32 str; reg = STV090x_READ_DEMOD(state, AGCIQIN1); - agc = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); + agc_1 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); + reg = STV090x_READ_DEMOD(state, AGCIQIN0); + agc_0 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); + agc = MAKEWORD16(agc_1, agc_0); - *strength = stv090x_table_lookup(stv090x_rf_tab, ARRAY_SIZE(stv090x_rf_tab) - 1, agc); + str = stv090x_table_lookup(stv090x_rf_tab, ARRAY_SIZE(stv090x_rf_tab) - 1, agc); if (agc > stv090x_rf_tab[0].read) - *strength = 5; + str = 0; else if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read) - *strength = -100; + str = -100; + *strength = (str + 100) * 0xFFFF / 100; return 0; } @@ -4269,6 +4303,8 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) u32 reg_0, reg_1, reg, i; s32 val_0, val_1, val = 0; u8 lock_f; + s32 snr; + s32 div; switch (state->delsys) { case STV090x_DVBS2: @@ -4280,14 +4316,15 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) reg_1 = STV090x_READ_DEMOD(state, NNOSPLHT1); val_1 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); reg_0 = STV090x_READ_DEMOD(state, NNOSPLHT0); - val_0 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); + val_0 = STV090x_GETFIELD_Px(reg_0, NOSPLHT_NORMED_FIELD); val += MAKEWORD16(val_1, val_0); msleep(1); } val /= 16; - *cnr = stv090x_table_lookup(stv090x_s2cn_tab, ARRAY_SIZE(stv090x_s2cn_tab) - 1, val); - if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s2cn_tab) - 1].read) - *cnr = 1000; + snr = stv090x_table_lookup(stv090x_s2cn_tab, ARRAY_SIZE(stv090x_s2cn_tab) - 1, val); + div = stv090x_s2cn_tab[0].read - stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s2cn_tab) - 1].read; + *cnr = 0xFFFF - ((val * 0xFFFF) / div); + /* *cnr = snr * 0xFFFF / stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s2cn_tab) - 1].real; */ } break; @@ -4301,14 +4338,15 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) reg_1 = STV090x_READ_DEMOD(state, NOSDATAT1); val_1 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); reg_0 = STV090x_READ_DEMOD(state, NOSDATAT0); - val_0 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); + val_0 = STV090x_GETFIELD_Px(reg_0, NOSDATAT_UNNORMED_FIELD); val += MAKEWORD16(val_1, val_0); msleep(1); } val /= 16; - *cnr = stv090x_table_lookup(stv090x_s1cn_tab, ARRAY_SIZE(stv090x_s1cn_tab) - 1, val); - if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s1cn_tab) - 1].read) - *cnr = 1000; + snr = stv090x_table_lookup(stv090x_s1cn_tab, ARRAY_SIZE(stv090x_s1cn_tab) - 1, val); + div = stv090x_s1cn_tab[0].read - stv090x_s1cn_tab[ARRAY_SIZE(stv090x_s1cn_tab) - 1].read; + *cnr = 0xFFFF - ((val * 0xFFFF) / div); + /* *cnr = snr * 0xFFFF / stv090x_s1cn_tab[ARRAY_SIZE(stv090x_s1cn_tab) - 1].real; */ } break; default: @@ -4544,6 +4582,8 @@ static int stv090x_ldpc_mode(struct stv090x_state *state, enum stv090x_mode ldpc { u32 reg = 0; + reg = stv090x_read_reg(state, STV090x_GENCFG); + switch (ldpc_mode) { case STV090x_DUAL: default: diff --git a/linux/drivers/media/dvb/frontends/stv090x_priv.h b/linux/drivers/media/dvb/frontends/stv090x_priv.h index 5a4a01740..5921a8d6c 100644 --- a/linux/drivers/media/dvb/frontends/stv090x_priv.h +++ b/linux/drivers/media/dvb/frontends/stv090x_priv.h @@ -83,7 +83,7 @@ #define STV090x_IQPOWER_THRESHOLD 30 #define STV090x_SEARCH_AGC2_TH_CUT20 700 -#define STV090x_SEARCH_AGC2_TH_CUT30 1200 +#define STV090x_SEARCH_AGC2_TH_CUT30 1400 #define STV090x_SEARCH_AGC2_TH(__ver) \ ((__ver <= 0x20) ? \ @@ -91,6 +91,7 @@ STV090x_SEARCH_AGC2_TH_CUT30) enum stv090x_signal_state { + STV090x_NOAGC1, STV090x_NOCARRIER, STV090x_NODATA, STV090x_DATAOK, diff --git a/linux/drivers/media/dvb/frontends/stv090x_reg.h b/linux/drivers/media/dvb/frontends/stv090x_reg.h index 57b6abbbd..2f76ec0cf 100644 --- a/linux/drivers/media/dvb/frontends/stv090x_reg.h +++ b/linux/drivers/media/dvb/frontends/stv090x_reg.h @@ -44,7 +44,7 @@ #define STV090x_OFFST_OUTSERRS2_HZ_FIELD 5 #define STV090x_WIDTH_OUTSERRS2_HZ_FIELD 1 #define STV090x_OFFST_OUTSERRS3_HZ_FIELD 4 -#define STV090x_WIDTH_OUTPARRS3_HZ_FIELD 1 +#define STV090x_WIDTH_OUTSERRS3_HZ_FIELD 1 #define STV090x_OFFST_OUTPARRS3_HZ_FIELD 3 #define STV090x_WIDTH_OUTPARRS3_HZ_FIELD 1 @@ -113,24 +113,24 @@ #define STV090x_IRQMASK3 0xf124 #define STV090x_OFFST_MPLL_LOCK_FIELD 5 #define STV090x_WIDTH_MPLL_LOCK_FIELD 1 -#define STV090x_OFFST_MSTREAM_LCK_3_FIELD 2 -#define STV090x_WIDTH_MSTREAM_LCK_3_FIELD 3 -#define STV090x_OFFST_MSTREAM_LCK_2_FIELD 2 -#define STV090x_WIDTH_MSTREAM_LCK_2_FIELD 3 +#define STV090x_OFFST_MSTREAM_LCK_3_FIELD 4 +#define STV090x_WIDTH_MSTREAM_LCK_3_FIELD 1 +#define STV090x_OFFST_MSTREAM_LCK_2_FIELD 3 +#define STV090x_WIDTH_MSTREAM_LCK_2_FIELD 1 #define STV090x_OFFST_MSTREAM_LCK_1_FIELD 2 -#define STV090x_WIDTH_MSTREAM_LCK_1_FIELD 3 +#define STV090x_WIDTH_MSTREAM_LCK_1_FIELD 1 #define STV090x_OFFST_MDVBS1_PRF_2_FIELD 1 #define STV090x_WIDTH_MDVBS1_PRF_2_FIELD 1 #define STV090x_OFFST_MDVBS1_PRF_1_FIELD 0 #define STV090x_WIDTH_MDVBS1_PRF_1_FIELD 1 #define STV090x_IRQMASK2 0xf125 -#define STV090x_OFFST_MSPY_ENDSIM_3_FIELD 5 -#define STV090x_WIDTH_MSPY_ENDSIM_3_FIELD 3 -#define STV090x_OFFST_MSPY_ENDSIM_2_FIELD 5 -#define STV090x_WIDTH_MSPY_ENDSIM_2_FIELD 3 +#define STV090x_OFFST_MSPY_ENDSIM_3_FIELD 7 +#define STV090x_WIDTH_MSPY_ENDSIM_3_FIELD 1 +#define STV090x_OFFST_MSPY_ENDSIM_2_FIELD 6 +#define STV090x_WIDTH_MSPY_ENDSIM_2_FIELD 1 #define STV090x_OFFST_MSPY_ENDSIM_1_FIELD 5 -#define STV090x_WIDTH_MSPY_ENDSIM_1_FIELD 3 +#define STV090x_WIDTH_MSPY_ENDSIM_1_FIELD 1 #define STV090x_OFFST_MPKTDEL_ERROR_2_FIELD 4 #define STV090x_WIDTH_MPKTDEL_ERROR_2_FIELD 1 #define STV090x_OFFST_MPKTDEL_LOCKB_2_FIELD 3 @@ -370,7 +370,7 @@ #define STV090x_OFFST_SELX1RATIO_FIELD 5 #define STV090x_WIDTH_SELX1RATIO_FIELD 1 #define STV090x_OFFST_STOP_PLL_FIELD 3 -#define STV090x_WIDTH_SELX1RATIO_FIELD 1 +#define STV090x_WIDTH_STOP_PLL_FIELD 1 #define STV090x_OFFST_BYPASSPLLFSK_FIELD 2 #define STV090x_WIDTH_BYPASSPLLFSK_FIELD 1 #define STV090x_OFFST_SELOSCI_FIELD 1 @@ -616,7 +616,7 @@ #define STV090x_OFFST_Px_CONT_TONE_FIELD 4 #define STV090x_WIDTH_Px_CONT_TONE_FIELD 1 #define STV090x_OFFST_Px_FIFO_4BREADY_FIELD 3 -#define STV090x_WIDTH_Px_FIFO_4BREADY_FIELD 2 +#define STV090x_WIDTH_Px_FIFO_4BREADY_FIELD 1 #define STV090x_OFFST_Px_FIFO_EMPTY_FIELD 2 #define STV090x_WIDTH_Px_FIFO_EMPTY_FIELD 1 #define STV090x_OFFST_Px_ABORT_DISRX_FIELD 0 @@ -847,12 +847,10 @@ #define STV090x_WIDTH_Px_DVBS2_ENABLE_FIELD 1 #define STV090x_OFFST_Px_DVBS1_ENABLE_FIELD 6 #define STV090x_WIDTH_Px_DVBS1_ENABLE_FIELD 1 -#define STV090x_OFFST_Px_CFR_AUTOSCAN_FIELD 5 /* check */ -#define STV090x_WIDTH_Px_CFR_AUTOSCAN_FIELD 1 -#define STV090x_OFFST_Px_SCAN_ENABLE_FIELD 4 /* check */ +#define STV090x_OFFST_Px_SCAN_ENABLE_FIELD 4 #define STV090x_WIDTH_Px_SCAN_ENABLE_FIELD 1 -#define STV090x_OFFST_Px_TUN_AUTOSCAN_FIELD 3 -#define STV090x_WIDTH_Px_TUN_AUTOSCAN_FIELD 1 +#define STV090x_OFFST_Px_CFR_AUTOSCAN_FIELD 3 +#define STV090x_WIDTH_Px_CFR_AUTOSCAN_FIELD 1 #define STV090x_OFFST_Px_NOFORCE_RELOCK_FIELD 2 #define STV090x_WIDTH_Px_NOFORCE_RELOCK_FIELD 1 #define STV090x_OFFST_Px_TUN_RNG_FIELD 0 @@ -885,7 +883,7 @@ #define STV090x_P2_DMDFLYW STV090x_Px_DMDFLYW(2) #define STV090x_OFFST_Px_I2C_IRQVAL_FIELD 4 #define STV090x_WIDTH_Px_I2C_IRQVAL_FIELD 4 -#define STV090x_OFFST_Px_FLYWHEEL_CPT_FIELD 0 /* check */ +#define STV090x_OFFST_Px_FLYWHEEL_CPT_FIELD 0 #define STV090x_WIDTH_Px_FLYWHEEL_CPT_FIELD 4 #define STV090x_Px_DSTATUS3(__x) (0xF41D - (__x - 1) * 0x200) @@ -1048,12 +1046,12 @@ #define STV090x_P1_CFRINC1 STV090x_Px_CFRINC1(1) #define STV090x_P2_CFRINC1 STV090x_Px_CFRINC1(2) #define STV090x_OFFST_Px_CFR_INC1_FIELD 0 -#define STV090x_WIDTH_Px_CFR_INC1_FIELD 7 +#define STV090x_WIDTH_Px_CFR_INC1_FIELD 7 /* check */ #define STV090x_Px_CFRINC0(__x) (0xF44B - (__x - 1) * 0x200) #define STV090x_P1_CFRINC0 STV090x_Px_CFRINC0(1) #define STV090x_P2_CFRINC0 STV090x_Px_CFRINC0(2) -#define STV090x_OFFST_Px_CFR_INC0_FIELD 4 +#define STV090x_OFFST_Px_CFR_INC0_FIELD 4 /* check */ #define STV090x_WIDTH_Px_CFR_INC0_FIELD 4 #define STV090x_Pn_CFRy(__x, __y) (0xF44E - (__x - 1) * 0x200 - __y * 0x1) @@ -1145,14 +1143,14 @@ #define STV090x_Px_SFRINIT1(__x) (0xF45E - (__x - 1) * 0x200) #define STV090x_P1_SFRINIT1 STV090x_Px_SFRINIT1(1) #define STV090x_P2_SFRINIT1 STV090x_Px_SFRINIT1(2) -#define STV090x_OFFST_Px_SFR_INIT_FIELD 0 -#define STV090x_WIDTH_Px_SFR_INIT_FIELD 8 +#define STV090x_OFFST_Px_SFR_INIT1_FIELD 0 +#define STV090x_WIDTH_Px_SFR_INIT1_FIELD 7 #define STV090x_Px_SFRINIT0(__x) (0xF45F - (__x - 1) * 0x200) #define STV090x_P1_SFRINIT0 STV090x_Px_SFRINIT0(1) #define STV090x_P2_SFRINIT0 STV090x_Px_SFRINIT0(2) -#define STV090x_OFFST_Px_SFR_INIT_FIELD 0 -#define STV090x_WIDTH_Px_SFR_INIT_FIELD 8 +#define STV090x_OFFST_Px_SFR_INIT0_FIELD 0 +#define STV090x_WIDTH_Px_SFR_INIT0_FIELD 8 #define STV090x_Px_SFRUP1(__x) (0xF460 - (__x - 1) * 0x200) #define STV090x_P1_SFRUP1 STV090x_Px_SFRUP1(1) @@ -1178,7 +1176,7 @@ #define STV090x_OFFST_Px_SYMB_FREQ_LOW0_FIELD 0 #define STV090x_WIDTH_Px_SYMB_FREQ_LOW0_FIELD 8 -#define STV090x_Px_SFRy(__x, __y) (0xF464 - (__x-1) * 0x200 + (3 - __y)) +#define STV090x_Px_SFRy(__x, __y) (0xF467 - (__x - 1) * 0x200 - __y * 0x1) #define STV090x_P1_SFR0 STV090x_Px_SFRy(1, 0) #define STV090x_P1_SFR1 STV090x_Px_SFRy(1, 1) #define STV090x_P1_SFR2 STV090x_Px_SFRy(1, 2) @@ -1188,7 +1186,7 @@ #define STV090x_P2_SFR2 STV090x_Px_SFRy(2, 2) #define STV090x_P2_SFR3 STV090x_Px_SFRy(2, 3) #define STV090x_OFFST_Px_SYMB_FREQ_FIELD 0 -#define STV090x_WIDTH_Px_SYMB_FREQ_FIELD 32 +#define STV090x_WIDTH_Px_SYMB_FREQ_FIELD 8 #define STV090x_Px_TMGREG2(__x) (0xF468 - (__x - 1) * 0x200) #define STV090x_P1_TMGREG2 STV090x_Px_TMGREG2(1) @@ -1198,7 +1196,7 @@ #define STV090x_Px_TMGREG1(__x) (0xF469 - (__x - 1) * 0x200) #define STV090x_P1_TMGREG1 STV090x_Px_TMGREG1(1) -#define STV090x_P2_TMGREG1 STV090x_Px_TMGREG1(2) +#define STV090x_P2_TMGREG1 STV090x_Px_TMGREG1(2) #define STV090x_OFFST_Px_TMGREG_FIELD 0 #define STV090x_WIDTH_Px_TMGREG_FIELD 8 @@ -1230,7 +1228,7 @@ #define STV090x_OFFST_Px_MU_EQUALDFE_FIELD 0 #define STV090x_WIDTH_Px_MU_EQUALDFE_FIELD 3 -#define STV090x_Px_EQUAIy(__x, __y) (0xf470 - (__x - 1) * 0x200 + (__y - 1)) +#define STV090x_Px_EQUAIy(__x, __y) (0xf470 - (__x - 1) * 0x200 + 2*(__y - 1)) #define STV090x_P1_EQUAI1 STV090x_Px_EQUAIy(1, 1) #define STV090x_P1_EQUAI2 STV090x_Px_EQUAIy(1, 2) #define STV090x_P1_EQUAI3 STV090x_Px_EQUAIy(1, 3) @@ -1251,7 +1249,7 @@ #define STV090x_OFFST_Px_EQUA_ACCIy_FIELD 0 #define STV090x_WIDTH_Px_EQUA_ACCIy_FIELD 8 -#define STV090x_Px_EQUAQy(__x, __y) (0xf471 - (__x - 1) * 0x200 + (__y - 1)) +#define STV090x_Px_EQUAQy(__x, __y) (0xf471 - (__x - 1) * 0x200 + 2*(__y - 1)) #define STV090x_P1_EQUAQ1 STV090x_Px_EQUAQy(1, 1) #define STV090x_P1_EQUAQ2 STV090x_Px_EQUAQy(1, 2) #define STV090x_P1_EQUAQ3 STV090x_Px_EQUAQy(1, 3) @@ -1390,7 +1388,7 @@ #define STV090x_OFFST_Px_CAR2S2_16A_ALPH_E_FIELD 0 #define STV090x_WIDTH_Px_CAR2S2_16A_ALPH_E_FIELD 4 -#define STV090x_Px_ACLC2S232A(__x) (0xf499 - (__x - 1) * 0x200) +#define STV090x_Px_ACLC2S232A(__x) (0xf49A - (__x - 1) * 0x200) #define STV090x_P1_ACLC2S232A STV090x_Px_ACLC2S232A(1) #define STV090x_P2_ACLC2S232A STV090x_Px_ACLC2S232A(2) #define STV090x_OFFST_Px_CAR2S2_32A_ALPH_M_FIELD 4 @@ -1414,7 +1412,7 @@ #define STV090x_OFFST_Px_CAR2S2_8_BETA_E_FIELD 0 #define STV090x_WIDTH_Px_CAR2S2_8_BETA_E_FIELD 4 -#define STV090x_Px_BCLC2S216A(__x) (0xf49d - (__x - 1) * 0x200) +#define STV090x_Px_BCLC2S216A(__x) (0xf49e - (__x - 1) * 0x200) #define STV090x_P1_BCLC2S216A STV090x_Px_BCLC2S216A(1) #define STV090x_P2_BCLC2S216A STV090x_Px_BCLC2S216A(1) #define STV090x_OFFST_Px_CAR2S2_16A_BETA_M_FIELD 4 @@ -1422,7 +1420,7 @@ #define STV090x_OFFST_Px_CAR2S2_16A_BETA_E_FIELD 0 #define STV090x_WIDTH_Px_CAR2S2_16A_BETA_E_FIELD 4 -#define STV090x_Px_BCLC2S232A(__x) (0xf49d - (__x - 1) * 0x200) +#define STV090x_Px_BCLC2S232A(__x) (0xf49f - (__x - 1) * 0x200) #define STV090x_P1_BCLC2S232A STV090x_Px_BCLC2S232A(1) #define STV090x_P2_BCLC2S232A STV090x_Px_BCLC2S232A(1) #define STV090x_OFFST_Px_CAR2S2_32A_BETA_M_FIELD 4 @@ -1458,7 +1456,7 @@ #define STV090x_P1_MODCODLST1 STV090x_Px_MODCODLST1(1) #define STV090x_P2_MODCODLST1 STV090x_Px_MODCODLST1(2) #define STV090x_OFFST_Px_DIS_MODCOD29_FIELD 4 -#define STV090x_WIDTH_Px_DIS_MODCOD29T_FIELD 4 +#define STV090x_WIDTH_Px_DIS_MODCOD29_FIELD 4 #define STV090x_OFFST_Px_DIS_32PSK_9_10_FIELD 0 #define STV090x_WIDTH_Px_DIS_32PSK_9_10_FIELD 4 @@ -2180,7 +2178,7 @@ #define STV090x_WIDTH_Px_TSFIFOSPEED_STORE_FIELD 1 #define STV090x_OFFST_Px_DILXX_RESET_FIELD 5 #define STV090x_WIDTH_Px_DILXX_RESET_FIELD 1 -#define STV090x_OFFST_Px_TSSERIAL_IMPOS_FIELD 5 +#define STV090x_OFFST_Px_TSSERIAL_IMPOS_FIELD 4 #define STV090x_WIDTH_Px_TSSERIAL_IMPOS_FIELD 1 #define STV090x_OFFST_Px_SCRAMBDETECT_FIELD 1 #define STV090x_WIDTH_Px_SCRAMBDETECT_FIELD 1 @@ -2190,7 +2188,7 @@ #define STV090x_P1_TSBITRATE1 STV090x_Px_TSBITRATEy(1, 1) #define STV090x_P2_TSBITRATE0 STV090x_Px_TSBITRATEy(2, 0) #define STV090x_P2_TSBITRATE1 STV090x_Px_TSBITRATEy(2, 1) -#define STV090x_OFFST_Px_TSFIFO_BITRATE_FIELD 7 +#define STV090x_OFFST_Px_TSFIFO_BITRATE_FIELD 0 #define STV090x_WIDTH_Px_TSFIFO_BITRATE_FIELD 8 #define STV090x_Px_ERRCTRL1(__x) (0xF598 - (__x - 1) * 0x200) diff --git a/linux/drivers/media/dvb/frontends/stv6110x.c b/linux/drivers/media/dvb/frontends/stv6110x.c index cca32f3d6..f02ca89a0 100644 --- a/linux/drivers/media/dvb/frontends/stv6110x.c +++ b/linux/drivers/media/dvb/frontends/stv6110x.c @@ -95,7 +95,7 @@ static int stv6110x_set_frequency(struct dvb_frontend *fe, u32 frequency) { struct stv6110x_state *stv6110x = fe->tuner_priv; u32 rDiv, divider; - s32 pVal, pCalc, rDivOpt = 0; + s32 pVal, pCalc, rDivOpt = 0, pCalcOpt = 1000; u8 i; STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_K, (REFCLOCK_MHz - 16)); @@ -121,8 +121,10 @@ static int stv6110x_set_frequency(struct dvb_frontend *fe, u32 frequency) for (rDiv = 0; rDiv <= 3; rDiv++) { pCalc = (REFCLOCK_kHz / 100) / R_DIV(rDiv); - if ((abs((s32)(pCalc - pVal))) < (abs((s32)(1000 - pVal)))) + if ((abs((s32)(pCalc - pVal))) < (abs((s32)(pCalcOpt - pVal)))) rDivOpt = rDiv; + + pCalcOpt = (REFCLOCK_kHz / 100) / R_DIV(rDivOpt); } divider = (frequency * R_DIV(rDivOpt) * pVal) / REFCLOCK_kHz; -- cgit v1.2.3 From 0dd1bbae72fb6955238716ea6ab2cf4f7f16b1a6 Mon Sep 17 00:00:00 2001 From: Matthias Benesch Date: Sat, 28 Nov 2009 15:06:30 +0100 Subject: Added changes from @pram to enable unloading of modules stv090x and stv6110x. --- linux/drivers/media/video/ngene/ngene-core.c | 20 ++++++++++++++++---- linux/drivers/media/video/ngene/ngene.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/linux/drivers/media/video/ngene/ngene-core.c b/linux/drivers/media/video/ngene/ngene-core.c index c9955f3ee..ad02fa16c 100644 --- a/linux/drivers/media/video/ngene/ngene-core.c +++ b/linux/drivers/media/video/ngene/ngene-core.c @@ -1955,6 +1955,7 @@ static int ngene_start_feed(struct dvb_demux_feed *dvbdmxfeed) { struct dvb_demux *dvbdmx=dvbdmxfeed->demux; struct ngene_channel *chan=dvbdmx->priv; +#ifdef NGENE_COMMAND_API struct ngene *dev=chan->dev; if (dev->card_info->io_type[chan->number]&NGENE_IO_TSOUT) { @@ -1979,6 +1980,7 @@ static int ngene_start_feed(struct dvb_demux_feed *dvbdmxfeed) } } +#endif if (chan->users==0) { set_transfer(chan, 1); @@ -1992,6 +1994,7 @@ static int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { struct dvb_demux *dvbdmx=dvbdmxfeed->demux; struct ngene_channel *chan=dvbdmx->priv; +#ifdef NGENE_COMMAND_API struct ngene *dev=chan->dev; if (dev->card_info->io_type[chan->number]&NGENE_IO_TSOUT) { @@ -2011,6 +2014,7 @@ static int ngene_stop_feed(struct dvb_demux_feed *dvbdmxfeed) } } +#endif if (--chan->users) return chan->users; @@ -3206,6 +3210,7 @@ ssize_t video_read(struct file *file, char *buf, size_t count, loff_t *ppos) /* Why is this not exported from dvb_core ?!?! */ +#ifdef NGENE_COMMAND_API static int dvb_usercopy2(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg, int (*func)(struct inode *inode, struct file *file, @@ -3307,6 +3312,7 @@ static int video_ioctl(struct inode *inode, struct file *file, { return dvb_usercopy2(inode, file, cmd, arg, video_do_ioctl); } +#endif static struct file_operations video_fops = { .owner= THIS_MODULE, @@ -3314,7 +3320,9 @@ static struct file_operations video_fops = { .write= video_write, .open= video_open, .release= video_release, +#ifdef NGENE_COMMAND_API .ioctl= video_ioctl, +#endif }; static struct dvb_device dvbdev_video = { @@ -3740,7 +3748,7 @@ static void release_channel(struct ngene_channel *chan) dvb_unregister_device(chan->video_dev); if (chan->fe) { dvb_unregister_frontend(chan->fe); - /*dvb_frontend_detach(chan->fe);*/ + dvb_frontend_detach(chan->fe); chan->fe=0; } dvbdemux->dmx.close(&dvbdemux->dmx); @@ -3919,8 +3927,10 @@ static int __devinit ngene_probe(struct pci_dev *pci_dev, return -ENODEV; dev=vmalloc(sizeof(struct ngene)); - if (dev==NULL) - return -ENOMEM; + if (dev==NULL) { + stat = -ENOMEM; + goto fail0; + } memset(dev, 0, sizeof(struct ngene)); dev->pci_dev=pci_dev; @@ -3991,6 +4001,8 @@ fail2: ngene_stop(dev); fail1: ngene_release_buffers(dev); +fail0: + pci_disable_device(pci_dev); pci_set_drvdata(pci_dev, 0); return stat; } @@ -4471,7 +4483,7 @@ static struct pci_driver ngene_pci_driver = { .name = "ngene", .id_table = ngene_id_tbl, .probe = ngene_probe, - .remove = ngene_remove, + .remove = __devexit_p(ngene_remove), #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) .err_handler = &ngene_errors, #endif diff --git a/linux/drivers/media/video/ngene/ngene.h b/linux/drivers/media/video/ngene/ngene.h index 7f0637fdf..4c59646f3 100644 --- a/linux/drivers/media/video/ngene/ngene.h +++ b/linux/drivers/media/video/ngene/ngene.h @@ -25,7 +25,7 @@ #define _NGENE_H_ //#define ONE_ADAPTER -#define NGENE_COMMAND_API +//#define NGENE_COMMAND_API #define NGENE_STV090X //#define NGENE_V4L -- cgit v1.2.3