summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorHolger Waechtler <devnull@localhost>2003-01-15 14:07:18 +0000
committerHolger Waechtler <devnull@localhost>2003-01-15 14:07:18 +0000
commitddfc150a995f065fffb03791eebd341adfdb0a1f (patch)
treeeb51dd65df45afd0b176e6f1780ab651f982be8c /linux
parenta0679558590ef5305b58c4f19727bdf5f0754486 (diff)
downloadmediapointer-dvb-s2-ddfc150a995f065fffb03791eebd341adfdb0a1f.tar.gz
mediapointer-dvb-s2-ddfc150a995f065fffb03791eebd341adfdb0a1f.tar.bz2
update
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/dvb/frontends/alps_tdlb7.c130
1 files changed, 86 insertions, 44 deletions
diff --git a/linux/drivers/media/dvb/frontends/alps_tdlb7.c b/linux/drivers/media/dvb/frontends/alps_tdlb7.c
index e66af832b..47b480a9c 100644
--- a/linux/drivers/media/dvb/frontends/alps_tdlb7.c
+++ b/linux/drivers/media/dvb/frontends/alps_tdlb7.c
@@ -51,6 +51,7 @@
#include <linux/fs.h>
#include <linux/unistd.h>
+#include "compat.h"
#include "dvb_frontend.h"
static int debug = 0;
@@ -62,7 +63,7 @@ static char * mcfile = "/usr/lib/DVB/driver/frontends/Sc_main.mc";
#define dprintk if (debug) printk
/* microcode size for sp8870 */
-#define SP8870_CODE_SIZE 16384
+#define SP8870_CODE_SIZE 16382
/* starting point for microcode in file 'Sc_main.mc' */
#define SP8870_CODE_OFFSET 0x0A
@@ -143,7 +144,7 @@ static
int sp5659_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, u8 pwr)
{
u32 div = (freq + 36200000) / 166666;
- u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x85, (pwr << 5) | 0x30 };
+ u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x85, (pwr << 6)};
return sp5659_write (i2c, buf);
}
@@ -198,8 +199,14 @@ int sp8870_load_code(struct dvb_i2c_bus *i2c)
int c;
mm_segment_t fs = get_fs();
- sp8870_writereg(i2c,0x8F08,0x1FFF);
- sp8870_writereg(i2c,0x8F0A,0x0000);
+ // system controller stop
+ sp8870_writereg(i2c,0x0F00,0x0000);
+
+ // instruction RAM register hiword
+ sp8870_writereg(i2c,0x8F08,((SP8870_CODE_SIZE/2) & 0xFFFF));
+
+ // instruction RAM MWR
+ sp8870_writereg(i2c,0x8F0A,((SP8870_CODE_SIZE/2) >> 16));
set_fs(get_ds());
if (sp8870_read_code(mcfile,(char**) &lcode)<0) return -1;
@@ -215,7 +222,8 @@ int sp8870_load_code(struct dvb_i2c_bus *i2c)
msg.buf=buf;
msg.len=c;
if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
- dprintk ("%s: i2c error (err == %i)\n", __FUNCTION__, err);
+ dprintk ("%s: i2c error (err == %i)\n",
+ __FUNCTION__, err);
vfree(lcode);
return -EREMOTEIO;
}
@@ -233,39 +241,37 @@ int sp8870_init (struct dvb_i2c_bus *i2c)
dprintk ("%s\n", __FUNCTION__);
- sp8870_readreg(i2c,0x200);
- sp8870_readreg(i2c,0x200);
- sp8870_readreg(i2c,0x0F00); /* system controller stop */
- sp8870_readreg(i2c,0x0301); /* ???????? */
- sp8870_readreg(i2c,0x0309); /* integer carrier offset */
- sp8870_readreg(i2c,0x030A); /* fractional carrier offset */
- sp8870_readreg(i2c,0x0311); /* filter for 8 Mhz channel */
- sp8870_readreg(i2c,0x0319); /* sample rate correction bit [23..17] */
- sp8870_readreg(i2c,0x031A); /* sample rate correction bit [16..0] */
- sp8870_readreg(i2c,0x0338); /* ???????? */
- sp8870_readreg(i2c,0x0F00);
- sp8870_readreg(i2c,0x0200);
+ // system controller stop
+ sp8870_writereg(i2c,0x0F00,0x0000);
- return 0;
-}
+ // ADC mode: 2 for MT8872, 3 for MT8870/8871
+ sp8870_writereg(i2c,0x0301,0x0003);
+ // Reed Solomon parity bytes passed to output
+ sp8870_writereg(i2c,0x0C13,0x0001);
-static
-int sp8870_reset (struct dvb_i2c_bus *i2c)
-{
- dprintk("%s\n", __FUNCTION__);
- sp8870_writereg(i2c,0x0F00,0x0000); /* system controller stop */
- sp8870_writereg(i2c,0x0301,0x0003); /* ???????? */
- sp8870_writereg(i2c,0x0309,0x0400); /* integer carrier offset */
- sp8870_writereg(i2c,0x030A,0x0000); /* fractional carrier offset */
- sp8870_writereg(i2c,0x0311,0x0000); /* filter for 8 Mhz channel */
- sp8870_writereg(i2c,0x0319,0x000A); /* sample rate correction bit [23..17] */
- sp8870_writereg(i2c,0x031A,0x0AAB); /* sample rate correction bit [16..0] */
- sp8870_writereg(i2c,0x0338,0x0000); /* ???????? */
- sp8870_writereg(i2c,0x0201,0x0000); /* interrupts for change of lock or tuner adjustment disabled */
- sp8870_writereg(i2c,0x0F00,0x0001); /* system controller start */
+ // MPEG clock is suppressed if no valid data
+ sp8870_writereg(i2c,0x0C14,0x0001);
- return 0;
+ // sample rate correction bit [23..17]
+ sp8870_writereg(i2c,0x0319,0x000A);
+
+ // sample rate correction bit [16..0]
+ sp8870_writereg(i2c,0x031A,0x0AAB);
+
+ // integer carrier offset
+ sp8870_writereg(i2c,0x0309,0x0400);
+
+ // fractional carrier offset
+ sp8870_writereg(i2c,0x030A,0x0000);
+
+ // filter for 8 Mhz channel
+ sp8870_writereg(i2c,0x0311,0x0000);
+
+ // scan order: 2k first = 0x0000, 8k first = 0x0001
+ sp8870_writereg(i2c,0x0338,0x0000);
+
+ return 0;
}
@@ -307,7 +313,8 @@ int tdlb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_READ_BER:
{
u32 *ber=(u32 *) arg;
- *ber=sp8870_readreg(i2c,0x0C07); // bit error rate before Viterbi
+ // bit error rate before Viterbi
+ *ber=sp8870_readreg(i2c,0x0C07);
break;
}
@@ -322,26 +329,64 @@ int tdlb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
s32 *snr=(s32 *) arg;
*snr=0;
- break;
+ return -EOPNOTSUPP;
}
case FE_READ_UNCORRECTED_BLOCKS: // not supported by hardware?
{
u32 *ublocks=(u32 *) arg;
*ublocks=0;
- break;
+ return -EOPNOTSUPP;
}
case FE_SET_FRONTEND:
{
struct dvb_frontend_parameters *p = arg;
+
+ // system controller stop
+ sp8870_writereg(i2c,0x0F00,0x0000);
+
sp5659_set_tv_freq (i2c, p->frequency, 0);
- sp8870_reset (i2c); // reset default values and restart system controller
- // parameters are calculated by system controller
- break;
+
+ // sample rate correction bit [23..17]
+ sp8870_writereg(i2c,0x0319,0x000A);
+
+ // sample rate correction bit [16..0]
+ sp8870_writereg(i2c,0x031A,0x0AAB);
+
+ // integer carrier offset
+ sp8870_writereg(i2c,0x0309,0x0400);
+
+ // fractional carrier offset
+ sp8870_writereg(i2c,0x030A,0x0000);
+
+ // filter for 6/7/8 Mhz channel
+ if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
+ sp8870_writereg(i2c,0x0311,0x0002);
+ else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
+ sp8870_writereg(i2c,0x0311,0x0001);
+ else
+ sp8870_writereg(i2c,0x0311,0x0000);
+
+ // scan order: 2k first = 0x0000, 8k first = 0x0001
+ if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K)
+ sp8870_writereg(i2c,0x0338,0x0000);
+ else
+ sp8870_writereg(i2c,0x0338,0x0001);
+
+ // instruction RAM register loword
+ sp8870_writereg(i2c,0x0F09,0x0000);
+
+ // instruction RAM register hiword
+ sp8870_writereg(i2c,0x0F08,0x0000);
+
+ // system controller start
+ sp8870_writereg(i2c,0x0F00,0x0001);
+
+ break;
}
- case FE_GET_FRONTEND: // how to do this?
+ case FE_GET_FRONTEND: // FIXME: read known values back from Hardware...
{
break;
}
@@ -352,9 +397,6 @@ int tdlb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_INIT:
return sp8870_init (i2c);
- case FE_RESET:
- return sp8870_reset (i2c);
-
default:
return -EOPNOTSUPP;
};