summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2003-06-27 21:32:56 +0000
committerAndrew de Quincy <devnull@localhost>2003-06-27 21:32:56 +0000
commit301b61e16b1c6b2e83db1de3ca23d1d6a2d7f856 (patch)
tree043831b9d379177bf5ea0917179a4957e0d15f94
parent792560bd9e52ded6a26e80ccc93baab135f1bae6 (diff)
downloadmediapointer-dvb-s2-301b61e16b1c6b2e83db1de3ca23d1d6a2d7f856.tar.gz
mediapointer-dvb-s2-301b61e16b1c6b2e83db1de3ca23d1d6a2d7f856.tar.bz2
Final cleanup of tda10045h support
-rw-r--r--linux/drivers/media/dvb/frontends/tda1004x.c195
1 files changed, 63 insertions, 132 deletions
diff --git a/linux/drivers/media/dvb/frontends/tda1004x.c b/linux/drivers/media/dvb/frontends/tda1004x.c
index c60335abf..bbabb37f2 100644
--- a/linux/drivers/media/dvb/frontends/tda1004x.c
+++ b/linux/drivers/media/dvb/frontends/tda1004x.c
@@ -65,7 +65,7 @@ static char *tda1004x_firmware = CONFIG_TDA1004X_MC_LOCATION;
#define TDA1004X_OUT_CONF2 0x05
#define TDA1004X_STATUS_CD 0x06
#define TDA1004X_CONFC4 0x07
-#define TDA1004X_REG0C 0x0C
+#define TDA1004X_DSSPARE2 0x0C
#define TDA1004X_CODE_IN 0x0D
#define TDA1004X_FWPAGE 0x0E
#define TDA1004X_SCAN_CPT 0x10
@@ -100,7 +100,6 @@ static char *tda1004x_firmware = CONFIG_TDA1004X_MC_LOCATION;
#define TDA1004X_CONFADC2 0x37
#define TDA1004X_IOFFSET 0x38
-
#define dprintk if (tda1004x_debug) printk
static struct dvb_frontend_info tda10045h_info = {
@@ -120,7 +119,7 @@ static struct dvb_frontend_info tda10045h_info = {
struct tda1004x_state {
u8 tda1004x_address;
u8 tuner_address;
- u8 initialised;
+ u8 initialised:1;
};
#pragma pack()
@@ -132,10 +131,6 @@ struct fwinfo {
static struct fwinfo tda10045h_fwinfo[] = { {.file_size = 286720,.fw_offset = 0x34cc5,.fw_size = 30555} };
static int tda10045h_fwinfo_count = sizeof(tda10045h_fwinfo) / sizeof(struct fwinfo);
-
-static u8 tda10045h_bandwidth_8mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x48, 0x17, 0x89, 0xc7, 0x14 };
-static u8 tda10045h_bandwidth_7mhz[] = { 0x02, 0x00, 0x37, 0x00, 0x4a, 0x2f, 0x6d, 0x76, 0xdb };
-static u8 tda10045h_bandwidth_6mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x60, 0x1e, 0xa7, 0x45, 0x4f };
static int errno;
@@ -238,67 +233,55 @@ static int tda1004x_disable_tuner_i2c(struct dvb_i2c_bus *i2c, struct tda1004x_s
return tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 2, 0);
}
-static int tda1004x_dsp_command(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state, int cmd, int arg)
+
+static int tda10045h_set_bandwidth(struct dvb_i2c_bus *i2c,
+ struct tda1004x_state *tda_state,
+ fe_bandwidth_t bandwidth)
{
- int counter;
- int data1;
- int data2;
+ static u8 bandwidth_6mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x60, 0x1e, 0xa7, 0x45, 0x4f };
+ static u8 bandwidth_7mhz[] = { 0x02, 0x00, 0x37, 0x00, 0x4a, 0x2f, 0x6d, 0x76, 0xdb };
+ static u8 bandwidth_8mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x48, 0x17, 0x89, 0xc7, 0x14 };
- dprintk("%s: cmd=0x%x, arg=0x%x\n", __FUNCTION__, cmd, arg);
+ switch (bandwidth) {
+ case BANDWIDTH_6_MHZ:
+ tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0x14);
+ tda1004x_write_buf(i2c, tda_state, TDA1004X_CONFPLL_P, bandwidth_6mhz, sizeof(bandwidth_6mhz));
+ break;
- // send command and argument
- if (tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_ARG, arg) < 0)
- return -1;
- if (tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_CMD, cmd) < 0)
- return -1;
+ case BANDWIDTH_7_MHZ:
+ tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0x80);
+ tda1004x_write_buf(i2c, tda_state, TDA1004X_CONFPLL_P, bandwidth_7mhz, sizeof(bandwidth_7mhz));
+ break;
- // command retry loop
- counter = 0;
- while (counter++ < 5) {
+ case BANDWIDTH_8_MHZ:
+ tda1004x_write_byte(i2c, tda_state, TDA1004X_DSSPARE2, 0x14);
+ tda1004x_write_buf(i2c, tda_state, TDA1004X_CONFPLL_P, bandwidth_8mhz, sizeof(bandwidth_8mhz));
+ break;
- // read in the two data bytes
- data1 = tda1004x_read_byte(i2c, tda_state, TDA1004X_DSP_DATA1);
- data2 = tda1004x_read_byte(i2c, tda_state, TDA1004X_DSP_DATA2);
- if ((data1 < 0) || (data2 < 0))
- return -1;
-
- // finshed yet?
- if (data1 == cmd)
- continue;
- if (data2 == arg)
- continue;
-
- // OK, resend command
- if (tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_CMD, cmd) < 0)
- return -1;
+ default:
+ return -EINVAL;
}
- // OK, did it work?
- if (data1 != cmd)
- return -1;
- if (data2 != arg)
- return -1;
+ tda1004x_write_byte(i2c, tda_state, TDA1004X_IOFFSET, 0);
- // success
- return 0;
+ // done
+ return 0;
}
-static int tda10045h_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state)
+static int tda1004x_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_state)
{
- int fw_pos;
- int tx_size;
- int counter;
u8 fw_buf[65];
struct i2c_msg fw_msg = {.addr = 0,.flags = 0,.buf = fw_buf,.len = 0 };
struct i2c_msg tuner_msg = {.addr = 0,.flags = 0,.buf = 0,.len = 0 };
- u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
unsigned char *firmware = NULL;
int filesize;
- int fw_size = 0;
int fd;
- int data1;
int fwinfo_idx;
+ int fw_size = 0;
+ int fw_pos;
+ int tx_size;
+ static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
mm_segment_t fs = get_fs();
dprintk("%s\n", __FUNCTION__);
@@ -361,9 +344,12 @@ static int tda10045h_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_st
}
tda1004x_disable_tuner_i2c(i2c, tda_state);
- // setup some valid bandwidth parameters
- tda1004x_write_buf(i2c, tda_state, TDA1004X_CONFPLL_P, tda10045h_bandwidth_8mhz, sizeof(tda10045h_bandwidth_8mhz));
- tda1004x_write_byte(i2c, tda_state, TDA1004X_IOFFSET, 0);
+ // set some valid bandwith parameters
+ switch(tda_state->tda1004x_address) {
+ case TDA10045H_ADDRESS:
+ tda10045h_set_bandwidth(i2c, tda_state, BANDWIDTH_8_MHZ);
+ break;
+ }
dvb_delay(500);
// do the firmware upload
@@ -400,47 +386,18 @@ static int tda10045h_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_st
return -EIO;
}
- // DSP init
- tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x10, 0);
- if (tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_CMD, 0x61) < 0)
- return -1;
- counter = 0;
- while (counter++ < 5) {
- // read in the data byte
- data1 = tda1004x_read_byte(i2c, tda_state, TDA1004X_DSP_DATA1);
- if (data1 < 0)
- return data1;
-
- // finshed yet?
- if (data1 & 1)
- continue;
-
- // OK, resend command
- if (tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_CMD, 0x61) < 0)
- return -1;
- }
- tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_DATA1, 0x01);
- tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_DATA2, 0x0e);
- tda1004x_dsp_command(i2c, tda_state, 0x69, 0);
- tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_DATA2, 0x01);
- tda1004x_dsp_command(i2c, tda_state, 0x69, 1);
- tda1004x_write_byte(i2c, tda_state, TDA1004X_DSP_DATA2, 0x03);
- tda1004x_dsp_command(i2c, tda_state, 0x69, 2);
-
// tda setup
- tda1004x_write_byte(i2c, tda_state, TDA1004X_CONFADC1, 0x2e);
- tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFADC1, 0x80, 0);
- tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFADC2, 0x20, 0x20);
+ tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 8, 0);
+ tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 0x10, 0x10);
+ tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF2, 0xC0, 0x0);
+ tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x20, 0);
+ tda1004x_write_byte(i2c, tda_state, TDA1004X_CONFADC1, 0x2e);
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x80, 0x80);
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x40, 0);
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC1, 0x10, 0);
- tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x20, 0);
- tda1004x_write_mask(i2c, tda_state, TDA1004X_IN_CONF2, 0xC0, 0x0);
- tda1004x_write_mask(i2c, tda_state, TDA1004X_VBER_MSB, 0xe0, 0xa0);
tda1004x_write_byte(i2c, tda_state, TDA1004X_REG1E, 0);
tda1004x_write_byte(i2c, tda_state, TDA1004X_REG1F, 0);
- tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 0x10, 0x10);
- tda1004x_write_mask(i2c, tda_state, TDA1004X_AUTO, 8, 0);
+ tda1004x_write_mask(i2c, tda_state, TDA1004X_VBER_MSB, 0xe0, 0xa0);
// done
return 0;
@@ -490,13 +447,11 @@ static int tda1004x_set_frequency(struct dvb_i2c_bus *i2c,
struct tda1004x_state *tda_state,
struct dvb_frontend_parameters *fe_params)
{
- int counter, counter2;
u8 tuner_buf[4];
- u8 band;
- u8 cp;
- u8 filter;
struct i2c_msg tuner_msg = {.addr=0, .flags=0, .buf=tuner_buf, .len=sizeof(tuner_buf) };
int tuner_frequency;
+ u8 band, cp, filter;
+ int counter, counter2;
dprintk("%s\n", __FUNCTION__);
@@ -640,6 +595,7 @@ static int tda1004x_set_fe(struct dvb_i2c_bus *i2c,
dprintk("%s\n", __FUNCTION__);
+
// set frequency
tmp = tda1004x_set_frequency(i2c, tda_state, fe_params);
if (tmp < 0)
@@ -715,26 +671,12 @@ static int tda1004x_set_fe(struct dvb_i2c_bus *i2c,
}
}
- // set bandwidth
- switch (fe_params->u.ofdm.bandwidth) {
- case BANDWIDTH_6_MHZ:
- tda1004x_write_byte(i2c, tda_state, TDA1004X_REG0C, 0x14);
- tda1004x_write_buf(i2c, tda_state, TDA1004X_CONFPLL_P, tda10045h_bandwidth_6mhz, sizeof(tda10045h_bandwidth_6mhz));
- break;
-
- case BANDWIDTH_7_MHZ:
- tda1004x_write_byte(i2c, tda_state, TDA1004X_REG0C, 0x80);
- tda1004x_write_buf(i2c, tda_state, TDA1004X_CONFPLL_P, tda10045h_bandwidth_7mhz, sizeof(tda10045h_bandwidth_7mhz));
- break;
-
- case BANDWIDTH_8_MHZ:
- tda1004x_write_byte(i2c, tda_state, TDA1004X_REG0C, 0x14);
- tda1004x_write_buf(i2c, tda_state, TDA1004X_CONFPLL_P, tda10045h_bandwidth_8mhz, sizeof(tda10045h_bandwidth_8mhz));
- break;
-
- default:
- return -EINVAL;
- }
+ // set bandwidth
+ switch(tda_state->tda1004x_address) {
+ case TDA10045H_ADDRESS:
+ tda10045h_set_bandwidth(i2c, tda_state, fe_params->u.ofdm.bandwidth);
+ break;
+ }
// set inversion
switch (fe_params->inversion) {
@@ -1055,6 +997,7 @@ static int tda1004x_read_ber(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda
return 0;
}
+
static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
int status = 0;
@@ -1093,20 +1036,13 @@ static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_GET_FRONTEND:
return tda1004x_get_fe(i2c, tda_state, (struct dvb_frontend_parameters*) arg);
- case FE_SLEEP:
- break;
-
case FE_INIT:
// don't bother reinitialising
if (tda_state->initialised)
return 0;
// OK, perform initialisation
- switch(tda_state->tda1004x_address) {
- case TDA10045H_ADDRESS:
- status = tda10045h_init(i2c, tda_state);
- break;
- }
+ status = tda1004x_init(i2c, tda_state);
if (status == 0)
tda_state->initialised = 1;
return status;
@@ -1123,9 +1059,10 @@ static int tda1004x_attach(struct dvb_i2c_bus *i2c)
{
int tda1004x_address = -1;
int tuner_address = -1;
- u8 tuner_buf[4];
- struct i2c_msg tuner_msg = {.addr=0, .flags=0, .buf=0, .len=0 };
struct tda1004x_state tda_state;
+ struct i2c_msg tuner_msg = {.addr=0, .flags=0, .buf=0, .len=0 };
+ static u8 td1344_init[] = { 0x0b, 0xf5, 0x88, 0xab };
+ static u8 tdm1316l_init[] = { 0x0b, 0xf5, 0x85, 0xab };
dprintk("%s\n", __FUNCTION__);
@@ -1144,22 +1081,16 @@ static int tda1004x_attach(struct dvb_i2c_bus *i2c)
// supported tuner?
tda1004x_enable_tuner_i2c(i2c, &tda_state);
tuner_msg.addr = TD1344_ADDRESS;
- tuner_msg.buf = tuner_buf;
- tuner_msg.len = 4;
- tuner_buf[0] = 0x0b;
- tuner_buf[1] = 0xf5;
- tuner_buf[2] = 0x88;
- tuner_buf[3] = 0xab;
+ tuner_msg.buf = td1344_init;
+ tuner_msg.len = sizeof(td1344_init);
if (i2c->xfer(i2c, &tuner_msg, 1) == 1) {
- tuner_address = TD1344_ADDRESS;
dvb_delay(1);
+ tuner_address = TD1344_ADDRESS;
printk("tda1004x: Detected Philips TD1344 tuner. PLEASE CHECK THIS AND REPORT BACK!.\n");
} else {
tuner_msg.addr = TDM1316L_ADDRESS;
- tuner_buf[0] = 0x0b;
- tuner_buf[1] = 0xf5;
- tuner_buf[2] = 0x85;
- tuner_buf[3] = 0xab;
+ tuner_msg.buf = tdm1316l_init;
+ tuner_msg.len = sizeof(tdm1316l_init);
if (i2c->xfer(i2c, &tuner_msg, 1) == 1) {
dvb_delay(1);
tuner_address = TDM1316L_ADDRESS;