summaryrefslogtreecommitdiff
path: root/v4l
diff options
context:
space:
mode:
authorGerd Knorr <devnull@localhost>2005-02-18 13:26:20 +0000
committerGerd Knorr <devnull@localhost>2005-02-18 13:26:20 +0000
commit5b61adadcb3d9c7bf4d368c21f0ff7857c60f455 (patch)
treec12c8f8027b6010c6799237dfa1101cfdd4ad069 /v4l
parente6d7b8f1e4a898fcb632e33c15ba44be8059b65c (diff)
downloadmediapointer-dvb-s2-5b61adadcb3d9c7bf4d368c21f0ff7857c60f455.tar.gz
mediapointer-dvb-s2-5b61adadcb3d9c7bf4d368c21f0ff7857c60f455.tar.bz2
- more HD3000 stuff from Rusty Scott.
Diffstat (limited to 'v4l')
-rw-r--r--v4l/or51132.c285
-rw-r--r--v4l/or51132.h3
2 files changed, 158 insertions, 130 deletions
diff --git a/v4l/or51132.c b/v4l/or51132.c
index 716611ce0..4ebf1321b 100644
--- a/v4l/or51132.c
+++ b/v4l/or51132.c
@@ -21,6 +21,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
+
/*
* This driver needs two external firmware files. Please copy
* "dvb-fe-or51132-vsb.fw" and "dvb-fe-or51132-qam.fw" to
@@ -59,7 +60,7 @@ struct or51132_state
struct dvb_frontend frontend;
/* Demodulator private data */
- u8 initialized:1;
+ fe_modulation_t current_modulation;
/* Tuner private data */
u32 current_frequency;
@@ -118,20 +119,20 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
dprintk("FirmwareB is %i bytes\n",firmwareBsize);
/* Upload firmware */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
&fw->data[8],firmwareAsize))) {
printk(KERN_WARNING "or51132: load_firmware error 1\n");
return ret;
}
msleep(1); /* 1ms */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
&fw->data[8+firmwareAsize],firmwareBsize))) {
printk(KERN_WARNING "or51132: load_firmware error 2\n");
return ret;
}
msleep(1); /* 1ms */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
run_buf,2))) {
printk(KERN_WARNING "or51132: load_firmware error 3\n");
return ret;
@@ -140,7 +141,7 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
/* Wait at least 5 msec */
msleep(20); /* 10ms */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
run_buf,2))) {
printk(KERN_WARNING "or51132: load_firmware error 4\n");
return ret;
@@ -149,26 +150,6 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
/* 50ms for operation to begin */
msleep(50);
- /* 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
- */
-
- cmd_buf[0] = 0x04;
- cmd_buf[1] = 0x01;
- cmd_buf[2] = 0x50;
- cmd_buf[3] = 0x00;
- if((ret = i2c_writebytes(state,state->config->demod_address,
- cmd_buf,3))) {
- printk(KERN_WARNING "or51132: load_firmware error 7\n");
- return ret;
- }
-
/* Read back ucode version to besure we loaded correctly and are really up and running */
/* Get uCode version */
cmd_buf[0] = 0x10;
@@ -176,7 +157,7 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
cmd_buf[2] = 0x00;
cmd_buf[3] = 0x00;
msleep(20); /* 20ms */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
cmd_buf,3))) {
printk(KERN_WARNING "or51132: load_firmware error a\n");
return ret;
@@ -187,7 +168,7 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
cmd_buf[2] = 0x00;
cmd_buf[3] = 0x00;
msleep(20); /* 20ms */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
cmd_buf,2))) {
printk(KERN_WARNING "or51132: load_firmware error b\n");
return ret;
@@ -198,7 +179,7 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
cmd_buf[2] = 0x00;
cmd_buf[3] = 0x00;
msleep(20); /* 20ms */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
cmd_buf,2))) {
printk(KERN_WARNING "or51132: load_firmware error c\n");
return ret;
@@ -207,7 +188,7 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
for(i=0;i<4;i++) {
msleep(20); /* 20ms */
get_ver_buf[4] = i+1;
- if((ret = i2c_readbytes(state,state->config->demod_address,
+ if ((ret = i2c_readbytes(state,state->config->demod_address,
&rec_buf[i*2],2))) {
printk(KERN_WARNING
"or51132: load_firmware error d - %d\n",i);
@@ -227,7 +208,7 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
cmd_buf[2] = 0x00;
cmd_buf[3] = 0x00;
msleep(20); /* 20ms */
- if((ret = i2c_writebytes(state,state->config->demod_address,
+ if ((ret = i2c_writebytes(state,state->config->demod_address,
cmd_buf,3))) {
printk(KERN_WARNING "or51132: load_firmware error e\n");
return ret;
@@ -237,42 +218,18 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
static int or51132_init(struct dvb_frontend* fe)
{
- int ret;
- struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
- const struct firmware *fw;
-
- printk("or51132: Waiting for firmware upload (%s)...\n",
- OR51132_VSB_FIRMWARE);
- ret = request_firmware(&fw, OR51132_VSB_FIRMWARE, &state->i2c->dev);
- if(ret){
- printk(KERN_WARNING "or51132: No firmware uploaded (timeout or file not found?)\n");
- return ret;
- }
-
- ret = or51132_load_firmware(fe, fw);
- if(ret) {
- printk(KERN_WARNING "or51132: Writing firmware to device failed!\n");
- goto fw_exit;
- }
- printk("or51132: Firmware upload complete.\n");
-
-
- state->initialized = 1;
- ret = 0;
- fw_exit:
- release_firmware(fw);
- return ret;
+ return 0;
}
static int or51132_read_ber(struct dvb_frontend* fe, u32* ber)
{
- *ber = ENOSYS;
+ *ber = 0;
return 0;
}
static int or51132_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
{
- *ucblocks = ENOSYS;
+ *ucblocks = 0;
return 0;
}
@@ -281,86 +238,154 @@ static int or51132_sleep(struct dvb_frontend* fe)
return 0;
}
-static int or51132_setmode(struct dvb_frontend* fe, int mode)
+static int or51132_setmode(struct dvb_frontend* fe)
{
struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
- static u8 run_buf[] = {0x7f,0x01};
- unsigned char rec_buf[8];
- unsigned char cmd_buf[8];
-
- dprintk("setmode %d\n",mode);
-
- if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51132: setmode error 1\n");
- return 1;
- }
+ unsigned char cmd_buf[4];
- /* Wait at least 5 msec */
- msleep(5);
-
- if(i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51132: setmode error 2\n");
- }
-
- /* Set operation mode */
- 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 */
+ dprintk("setmode %d\n",(int)state->current_modulation);
+ /* set operation mode in Receiver 1 register; */
+ cmd_buf[0] = 0x04;
+ cmd_buf[1] = 0x01;
+ switch (state->current_modulation) {
+ case QAM_256:
+ case QAM_64:
+ case QAM_AUTO:
+ /* Auto-deinterleave; MPEG ser, MPEG2tr, phase noise-high*/
+ cmd_buf[2] = 0x5F;
+ break;
+ case VSB_8:
+ /* Auto CH, Auto NTSC rej, MPEGser, MPEG2tr, phase noise-high*/
+ cmd_buf[2] = 0x50;
+ break;
+ default:
+ printk("setmode:Modulation set to unsupported value\n");
+ };
cmd_buf[3] = 0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,
- cmd_buf,3)) {
- printk(KERN_WARNING "or51132: load_firmware error 7\n");
+ if (i2c_writebytes(state,state->config->demod_address,
+ cmd_buf,3)) {
+ printk(KERN_WARNING "or51132: set_mode error 1\n");
return -1;
}
+ dprintk("or51132: set #1 to %02x\n", cmd_buf[2]);
+
+ /* Set operation mode in Receiver 6 register */
+ cmd_buf[0] = 0x1C;
+ switch (state->current_modulation) {
+ case QAM_AUTO:
+ /* REC MODE Normal Carrier Lock */
+ cmd_buf[1] = 0x00;
+ /* Channel MODE Auto QAM64/256 */
+ cmd_buf[2] = 0x4f;
+ break;
+ case QAM_256:
+ /* REC MODE Normal Carrier Lock */
+ cmd_buf[1] = 0x00;
+ /* Channel MODE QAM256 */
+ cmd_buf[2] = 0x45;
+ break;
+ case QAM_64:
+ /* REC MODE Normal Carrier Lock */
+ cmd_buf[1] = 0x00;
+ /* Channel MODE QAM64 */
+ cmd_buf[2] = 0x43;
+ break;
+ case VSB_8:
+ /* REC MODE inv IF spectrum, Normal */
+ cmd_buf[1] = 0x03;
+ /* Channel MODE ATSC/VSB8 */
+ cmd_buf[2] = 0x06;
+ break;
+ default:
+ printk("setmode: Modulation set to unsupported value\n");
+ };
+ cmd_buf[3] = 0x00;
msleep(20); /* 20ms */
-
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,5)) {
- printk(KERN_WARNING "or51132: setmode error 4\n");
- return 1;
+ if (i2c_writebytes(state,state->config->demod_address,
+ cmd_buf,3)) {
+ printk(KERN_WARNING "or51132: set_mode error 2\n");
+ return -1;
}
+ dprintk("or51132: set #6 to 0x%02x%02x\n", cmd_buf[1], cmd_buf[2]);
- cmd_buf[0]=0x04;
- cmd_buf[1]=0x00;
- cmd_buf[2]=0x03;
- cmd_buf[3]=0x00;
- msleep(20); /* 20ms */
- if(i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
- printk(KERN_WARNING "or51132: setmode error 5\n");
- return 1;
- }
- msleep(3);
- if(i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51132: setmode error 6\n");
- return 1;
- }
- dprintk("or51132: setmode rec status %02x %02x\n",rec_buf[0],rec_buf[1]);
-
return 0;
}
static int or51132_set_parameters(struct dvb_frontend* fe,
struct dvb_frontend_parameters *param)
{
- struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
+ int ret;
u8 buf[4];
+ struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
+ const struct firmware *fw;
+
+ /* Change only if we are actually changing the modulation */
+ if (state->current_modulation != param->u.vsb.modulation) {
+ switch(param->u.vsb.modulation) {
+ case VSB_8:
+ dprintk("set_parameters VSB MODE\n");
+ printk("or51132: Waiting for firmware upload(%s)...\n",
+ OR51132_VSB_FIRMWARE);
+ ret = request_firmware(&fw, OR51132_VSB_FIRMWARE,
+ &state->i2c->dev);
+ if (ret){
+ printk(KERN_WARNING "or51132: No firmware up"
+ "loaded(timeout or file not found?)\n");
+ return ret;
+ }
+ /* Set non-punctured clock for VSB */
+ state->config->set_ts_params(fe, 0);
+ break;
+ case QAM_AUTO:
+ case QAM_64:
+ case QAM_256:
+ dprintk("set_parameters QAM MODE\n");
+ printk("or51132: Waiting for firmware upload(%s)...\n",
+ OR51132_QAM_FIRMWARE);
+ ret = request_firmware(&fw, OR51132_QAM_FIRMWARE,
+ &state->i2c->dev);
+ if (ret){
+ printk(KERN_WARNING "or51132: No firmware up"
+ "loaded(timeout or file not found?)\n");
+ return ret;
+ }
+ /* Set punctured clock for QAM */
+ state->config->set_ts_params(fe, 1);
+ break;
+ default:
+ printk("or51132:Modulation type(%d) UNSUPPORTED\n",
+ param->u.vsb.modulation);
+ return -1;
+ };
+ ret = or51132_load_firmware(fe, fw);
+ release_firmware(fw);
+ if (ret) {
+ printk(KERN_WARNING "or51132: Writing firmware to "
+ "device failed!\n");
+ return ret;
+ }
+ printk("or51132: Firmware upload complete.\n");
+
+ state->current_modulation = param->u.vsb.modulation;
+ or51132_setmode(fe);
+ }
/* Change only if we are actually changing the channel */
- if (state->current_frequency == param->frequency)
- return 0;
-
- 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");
+ if (state->current_frequency != param->frequency) {
+ 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 */
- or51132_setmode(fe, 0);
+ /* Set to current mode */
+ or51132_setmode(fe);
- /* Update current frequency */
- state->current_frequency = param->frequency;
+ /* Update current frequency */
+ state->current_frequency = param->frequency;
+ }
return 0;
}
@@ -375,18 +400,18 @@ static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status)
snd_buf[0]=0x04;
snd_buf[1]=0x00;
msleep(30); /* 30ms */
- if(i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
+ if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
printk(KERN_WARNING "or51132: read_status write error\n");
return -1;
}
msleep(30); /* 30ms */
- if(i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
+ if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
printk(KERN_WARNING "or51132: read_status read error\n");
return -1;
}
dprintk("read_status %x %x\n",rec_buf[0],rec_buf[1]);
- if(rec_buf[1] & 0x01) { /* Receiver Lock */
+ if (rec_buf[1] & 0x01) { /* Receiver Lock */
*status |= FE_HAS_SIGNAL;
*status |= FE_HAS_CARRIER;
*status |= FE_HAS_VITERBI;
@@ -431,7 +456,7 @@ unsigned int i20Log10(unsigned short val)
while(tmp > 100) {tmp /= 100; exp++;}
val = (2 * val)/denom[exp];
- if(exp > 1) rntval = 2000*exp;
+ if (exp > 1) rntval = 2000*exp;
rntval += i100x20log10[val];
return rntval;
@@ -449,12 +474,12 @@ static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
snd_buf[0]=0x04;
snd_buf[1]=0x02; /* SNR after Equalizer */
msleep(30); /* 30ms */
- if(i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
+ if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
printk(KERN_WARNING "or51132: read_status write error\n");
return -1;
}
msleep(30); /* 30ms */
- if(i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
+ if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
printk(KERN_WARNING "or51132: read_status read error\n");
return -1;
}
@@ -465,12 +490,12 @@ static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
snd_buf[0]=0x04;
snd_buf[1]=0x00;
msleep(30); /* 30ms */
- if(i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
+ if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
printk(KERN_WARNING "or51132: read_signal_strength read_status write error\n");
return -1;
}
msleep(30); /* 30ms */
- if(i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
+ if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
printk(KERN_WARNING "or51132: read_signal_strength read_status read error\n");
return -1;
}
@@ -495,12 +520,12 @@ static int or51132_read_snr(struct dvb_frontend* fe, u16* snr)
snd_buf[0]=0x04;
snd_buf[1]=0x02; /* SNR after Equalizer */
msleep(30); /* 30ms */
- if(i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
+ if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
printk(KERN_WARNING "or51132: read_snr write error\n");
return -1;
}
msleep(30); /* 30ms */
- if(i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
+ if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
printk(KERN_WARNING "or51132: read_snr dvr read error\n");
return -1;
}
@@ -544,8 +569,8 @@ struct dvb_frontend* or51132_attach(const struct or51132_config* config,
state->config = config;
state->i2c = i2c;
memcpy(&state->ops, &or51132_ops, sizeof(struct dvb_frontend_ops));
- state->initialized = 0;
- state->current_frequency = 0;
+ state->current_frequency = -1;
+ state->current_modulation = -1;
/* Create dvb_frontend */
state->frontend.ops = &state->ops;
@@ -590,7 +615,7 @@ static struct dvb_frontend_ops or51132_ops = {
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-MODULE_DESCRIPTION("Oren OR51132 VSB/QAM [pcHDTV HD-3000] Demodulator Driver");
+MODULE_DESCRIPTION("OR51132 ATSC [pcHDTV HD-3000] (8VSB & ITU J83 AnnexB FEC QAM64/256) Demodulator Driver");
MODULE_AUTHOR("Kirk Lapray");
MODULE_LICENSE("GPL");
diff --git a/v4l/or51132.h b/v4l/or51132.h
index 9b0d1e05d..622cdd183 100644
--- a/v4l/or51132.h
+++ b/v4l/or51132.h
@@ -31,6 +31,9 @@ struct or51132_config
u8 demod_address;
u8 pll_address;
struct dvb_pll_desc *pll_desc;
+
+ /* Need to set device param for start_dma */
+ int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
};
extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,