summaryrefslogtreecommitdiff
path: root/v4l
diff options
context:
space:
mode:
authorGerd Knorr <devnull@localhost>2005-02-10 11:43:41 +0000
committerGerd Knorr <devnull@localhost>2005-02-10 11:43:41 +0000
commit1e0a5f7ce4f1fa6d96df603e3a47f5ef4ec40f75 (patch)
treeb3b9f16e420cd471a6f357257683e5874b4d2012 /v4l
parent390439a668a9a5ec08ea0d8768a88afe92188477 (diff)
downloadmediapointer-dvb-s2-1e0a5f7ce4f1fa6d96df603e3a47f5ef4ec40f75.tar.gz
mediapointer-dvb-s2-1e0a5f7ce4f1fa6d96df603e3a47f5ef4ec40f75.tar.bz2
- a number of pcHDTV cleanups.
Diffstat (limited to 'v4l')
-rw-r--r--v4l/or51132.c420
-rw-r--r--v4l/or51132.h9
2 files changed, 214 insertions, 215 deletions
diff --git a/v4l/or51132.c b/v4l/or51132.c
index 13adc620a..fc0de1050 100644
--- a/v4l/or51132.c
+++ b/v4l/or51132.c
@@ -29,6 +29,7 @@
#include <linux/delay.h>
#include "dvb_frontend.h"
+#include "dvb-pll.h"
#include "or51132.h"
static int debug;
@@ -1200,205 +1201,215 @@ static int or51132_init(struct dvb_frontend* fe)
unsigned char rec_buf[14];
unsigned char cmd_buf[14];
- char tudata[sizeof(tud1)+sizeof(tud2)+128+64];
int tudata_size = sizeof(tud1) + sizeof(tud2) + 128 + 64;
+ char *tudata;
int i;
- if (!state->initialized) {
- /* Get eprom data */
- tudata[0] = 8;
- if(i2c_writebytes(state,0x50,tudata,1)) {
- printk(KERN_WARNING "or51132: init error eprom addr\n");
- return -1;
- }
- if(i2c_readbytes(state,0x50,&tudata[16*8+1],128+64)) {
- printk(KERN_WARNING "or51132: init error eprom\n");
- return -1;
- }
-
- for(i=0;i<tud1_size;i++) {
- tudata[i] = tud1[i];
- }
- for(i=0;i<tud2_size;i++) {
- tudata[i+tud1_size+128+64] = tud2[i];
- }
-
- if(i2c_writebytes(state,state->config->demod_address,tudata,tudata_size)) {
- printk(KERN_WARNING "or51132: init error 1\n");
- return -1;
- }
- udelay(1000); /* 1ms */
- if(i2c_writebytes(state,state->config->demod_address,tuc,tuc_size)) {
- printk(KERN_WARNING "or51132: init error 2\n");
- return -1;
- }
- udelay(1000); /* 1ms */
- if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51132: init error 3\n");
- return -1;
- }
- /* wait at least 5 msec */
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51132: init error 4\n");
- return -1;
- }
-
- msleep(500); /* 500ms for operation to begin */
-
- if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51132: init error 5\n");
- return -1;
- }
-
- /* wait at least 5 msec */
- msleep(20); /* 20ms */
-
- if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51132: init error 6\n");
- return -1;
- }
-
- msleep(20); /* 20ms */
-
- /* set operation mode in Receiver 1 register;
- * type 1:
- * data 0x50h Automatic sets receiver channel conditions
- * Automatic NTSC rejection filter
- * Enable MPEG serial data output
- * MPEG2tr
- * High tuner phase noise
- * normal +/-150kHz Carrier acquisition range
- */
-
- /* Read back ucode version to besure we loaded correctly and are really up and running */
- cmd_buf[0]=0x1c; /* CTL REG 6 */
- cmd_buf[1]=0x03; /* REC MODE inv IF spectrum, Normal */
- cmd_buf[2]=0x06; /* Channel MODE ATSC/VSB8 */
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
- printk(KERN_WARNING "or51132: init error a\n");
- return -1;
- }
-
- /* Get uCode version */
- cmd_buf[0]=0x10;
- cmd_buf[1]=0x10;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
- printk(KERN_WARNING "or51132: init error b\n");
- return -1;
- }
-
- cmd_buf[0]=0x04;
- cmd_buf[1]=0x17;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
- printk(KERN_WARNING "or51132: init error c\n");
- return -1;
- }
-
- cmd_buf[0]=0x00;
- cmd_buf[1]=0x00;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
- printk(KERN_WARNING "or51132: init error d\n");
- return -1;
- }
-
- for(i=0;i<4;i++) {
- msleep(20); /* 20ms */
- udelay(1000); /* 1ms */
- get_ver_buf[4] = i+1;
- if(i2c_readbytes(state,state->config->demod_address,&rec_buf[i*2],2)) {
- printk(KERN_WARNING "or51132: init error 7 - %d\n",i);
- return -1;
- }
- }
-
- printk(KERN_WARNING
- "or51132: 0 Version Data: %02X%02X%02X%02X-%02X%02X%02X%02X\n",
- rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
- rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6]);
-
- cmd_buf[0]=0x10;
- cmd_buf[1]=0x00;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
- printk(KERN_WARNING "or51132: init error e\n");
- return -1;
- }
-
- cmd_buf[0]=0x10;
- cmd_buf[1]=0x10;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
- printk(KERN_WARNING "or51132: init error f\n");
- return -1;
- }
-
- cmd_buf[0]=0x04;
- cmd_buf[1]=0x17;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
- printk(KERN_WARNING "or51132: init error g\n");
- return -1;
- }
+ if (state->initialized)
+ return 0;
- cmd_buf[0]=0x00;
- cmd_buf[1]=0x00;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
+ tudata = kmalloc(tudata_size, GFP_KERNEL);
+ if (NULL == tudata)
+ return -ENOMEM;
+
+ /* Get eprom data */
+ tudata[0] = 8;
+ if(i2c_writebytes(state,0x50,tudata,1)) {
+ printk(KERN_WARNING "or51132: init error eprom addr\n");
+ goto eio;
+ }
+ if(i2c_readbytes(state,0x50,&tudata[16*8+1],128+64)) {
+ printk(KERN_WARNING "or51132: init error eprom\n");
+ goto eio;
+ }
+
+ for(i=0;i<tud1_size;i++) {
+ tudata[i] = tud1[i];
+ }
+ for(i=0;i<tud2_size;i++) {
+ tudata[i+tud1_size+128+64] = tud2[i];
+ }
+
+ if(i2c_writebytes(state,state->config->demod_address,tudata,tudata_size)) {
+ printk(KERN_WARNING "or51132: init error 1\n");
+ goto eio;
+ }
+ udelay(1000); /* 1ms */
+ if(i2c_writebytes(state,state->config->demod_address,tuc,tuc_size)) {
+ printk(KERN_WARNING "or51132: init error 2\n");
+ goto eio;
+ }
+ udelay(1000); /* 1ms */
+ if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
+ printk(KERN_WARNING "or51132: init error 3\n");
+ goto eio;
+ }
+ /* wait at least 5 msec */
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
+ printk(KERN_WARNING "or51132: init error 4\n");
+ goto eio;
+ }
+
+ msleep(500); /* 500ms for operation to begin */
+
+ if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
+ printk(KERN_WARNING "or51132: init error 5\n");
+ goto eio;
+ }
+
+ /* wait at least 5 msec */
+ msleep(20); /* 20ms */
+
+ if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
+ printk(KERN_WARNING "or51132: init error 6\n");
+ goto eio;
+ }
+
+ msleep(20); /* 20ms */
+
+ /* set operation mode in Receiver 1 register;
+ * type 1:
+ * data 0x50h Automatic sets receiver channel conditions
+ * Automatic NTSC rejection filter
+ * Enable MPEG serial data output
+ * MPEG2tr
+ * High tuner phase noise
+ * normal +/-150kHz Carrier acquisition range
+ */
+
+ /* Read back ucode version to besure we loaded correctly and are really up and running */
+ cmd_buf[0]=0x1c; /* CTL REG 6 */
+ cmd_buf[1]=0x03; /* REC MODE inv IF spectrum, Normal */
+ cmd_buf[2]=0x06; /* Channel MODE ATSC/VSB8 */
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
+ printk(KERN_WARNING "or51132: init error a\n");
+ goto eio;
+ }
+
+ /* Get uCode version */
+ cmd_buf[0]=0x10;
+ cmd_buf[1]=0x10;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
+ printk(KERN_WARNING "or51132: init error b\n");
+ goto eio;
+ }
+
+ cmd_buf[0]=0x04;
+ cmd_buf[1]=0x17;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
+ printk(KERN_WARNING "or51132: init error c\n");
+ goto eio;
+ }
+
+ cmd_buf[0]=0x00;
+ cmd_buf[1]=0x00;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
+ printk(KERN_WARNING "or51132: init error d\n");
+ goto eio;
+ }
+
+ for(i=0;i<4;i++) {
msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
- printk(KERN_WARNING "or51132: init error h\n");
- return -1;
- }
-
- for(i=0;i<4;i++) {
- msleep(20); /* 20ms */
- udelay(1000); /* 1ms */
- get_ver_buf[4] = i+1;
- if(i2c_readbytes(state,state->config->demod_address,&rec_buf[i*2],2)) {
- printk(KERN_WARNING "or51132: init error 8 - %d\n",i);
- return -1;
- }
+ udelay(1000); /* 1ms */
+ get_ver_buf[4] = i+1;
+ if(i2c_readbytes(state,state->config->demod_address,&rec_buf[i*2],2)) {
+ printk(KERN_WARNING "or51132: init error 7 - %d\n",i);
+ goto eio;
}
-
- printk(KERN_WARNING
- "or51132: 1 Version Data: %02X%02X%02X%02X-%02X%02X%02X%02X\n",
- rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
- rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6]);
- printk(KERN_WARNING
- "or51132: Version: %02X%01X-%01X-%02X%01X-%01X\n",
- rec_buf[3],rec_buf[2]>>4,rec_buf[2]&0x0f,
- rec_buf[5],rec_buf[4]>>4,rec_buf[4]&0x0f);
-
- cmd_buf[0]=0x10;
- cmd_buf[1]=0x00;
- cmd_buf[2]=0x00;
- cmd_buf[3]=0x00;
+ }
+
+ printk(KERN_WARNING
+ "or51132: 0 Version Data: %02X%02X%02X%02X-%02X%02X%02X%02X\n",
+ rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
+ rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6]);
+
+ cmd_buf[0]=0x10;
+ cmd_buf[1]=0x00;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
+ printk(KERN_WARNING "or51132: init error e\n");
+ goto eio;
+ }
+
+ cmd_buf[0]=0x10;
+ cmd_buf[1]=0x10;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
+ printk(KERN_WARNING "or51132: init error f\n");
+ goto eio;
+ }
+
+ cmd_buf[0]=0x04;
+ cmd_buf[1]=0x17;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
+ printk(KERN_WARNING "or51132: init error g\n");
+ goto eio;
+ }
+
+ cmd_buf[0]=0x00;
+ cmd_buf[1]=0x00;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,2)) {
+ printk(KERN_WARNING "or51132: init error h\n");
+ goto eio;
+ }
+
+ for(i=0;i<4;i++) {
msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
- printk(KERN_WARNING "or51132: init error i\n");
- return -1;
+ udelay(1000); /* 1ms */
+ get_ver_buf[4] = i+1;
+ if(i2c_readbytes(state,state->config->demod_address,&rec_buf[i*2],2)) {
+ printk(KERN_WARNING "or51132: init error 8 - %d\n",i);
+ goto eio;
}
- state->initialized = 1;
}
+
+ printk(KERN_WARNING
+ "or51132: 1 Version Data: %02X%02X%02X%02X-%02X%02X%02X%02X\n",
+ rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
+ rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6]);
+ printk(KERN_WARNING
+ "or51132: Version: %02X%01X-%01X-%02X%01X-%01X\n",
+ rec_buf[3],rec_buf[2]>>4,rec_buf[2]&0x0f,
+ rec_buf[5],rec_buf[4]>>4,rec_buf[4]&0x0f);
+
+ cmd_buf[0]=0x10;
+ cmd_buf[1]=0x00;
+ cmd_buf[2]=0x00;
+ cmd_buf[3]=0x00;
+ msleep(20); /* 20ms */
+ if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
+ printk(KERN_WARNING "or51132: init error i\n");
+ goto eio;
+ }
+ state->initialized = 1;
+ kfree(tudata);
return 0;
+
+eio:
+ kfree(tudata);
+ return -EIO;
}
static int or51132_read_ber(struct dvb_frontend* fe, u32* ber)
@@ -1484,36 +1495,17 @@ static int or51132_set_parameters(struct dvb_frontend* fe,
struct dvb_frontend_parameters *param)
{
struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
- u32 freq = 0;
- u16 tunerfreq = 0;
u8 buf[4];
/* Change only if we are actually changing the channel */
if (state->current_frequency == param->frequency)
return 0;
- freq = 44000 + (param->frequency/1000);
- tunerfreq = freq * 16/1000;
-
- dprintk("set_parameters frequency = %d (freq = %d, tunerfreq = %d)\n",param->frequency,freq,tunerfreq);
-
- buf[0] = (tunerfreq >> 8) & 0x7f;
- buf[1] = (tunerfreq & 0xff);
- buf[2] = 0x8e;
-
- if (param->frequency < 157250000) {
- buf[3] = 0x39;
- dprintk(KERN_WARNING "set_parameters VHF low range\n");
- } else if (param->frequency < 454000000) {
- buf[3] = 0x3a;
- dprintk(KERN_WARNING "set_parameters VHF high range\n");
- } else {
- buf[3] = 0x3c;
- dprintk(KERN_WARNING "set_parameters UHF range\n");
- }
- dprintk("set_parameters tuner bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
-
- if (i2c_writebytes(state,0xc2>>1,buf,4))
+ dvb_pll_configure(state->config->pll_desc, buf,
+ param->frequency, 0);
+ dprintk("set_parameters tuner bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ buf[0],buf[1],buf[2],buf[3]);
+ if (i2c_writebytes(state, state->config->pll_address ,buf, 4))
printk(KERN_WARNING "or51132: set_parameters error writing to tuner\n");
/* Set to ATSC mode */
@@ -1696,7 +1688,7 @@ struct dvb_frontend* or51132_attach(const struct or51132_config* config,
struct or51132_state* state = NULL;
/* Allocate memory for the internal state */
- state = (struct or51132_state*) kmalloc(sizeof(struct or51132_state), GFP_KERNEL);
+ state = kmalloc(sizeof(struct or51132_state), GFP_KERNEL);
if (state == NULL)
goto error;
diff --git a/v4l/or51132.h b/v4l/or51132.h
index 14a64add4..cb6540c6b 100644
--- a/v4l/or51132.h
+++ b/v4l/or51132.h
@@ -28,10 +28,17 @@ struct or51132_config
{
/* The demodulator's i2c address */
u8 demod_address;
+ u8 pll_address;
+ struct dvb_pll_desc *pll_desc;
};
extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,
- struct i2c_adapter* i2c);
+ struct i2c_adapter* i2c);
#endif // OR51132_H
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */