Re: DiB3000MC : autosearch doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



IIRC Patrick has the datasheet.

Is it held under some kind of non disclosure agreement?

Why don't we create a repository for all datasheets available. I think
the more people check the code, the better it is.

Also the old driver
http://castet.matthieu.free.fr/tmp/v4l-dvb-stk3000p-e5798f307b00.tar.gz
autosearch works  for me.

I need an older kernel to try it. I'll do it tomorrow maybe.

I was trying to compare the 2 versions but it is very hard. The old
driver had a lot of #define s, while in the new one the are plenty of
"magic" numbers which are not easy to understand.

The following could be completely wrong, but this is as far as I got
to understand.

The only big "difference" I can see is about the channel which is used
before auto search starts. It is like an initial guess.

In the new code the initial guess is (regardless of the settings of
the channel required):

fchan.nfft = 1; fchan.guard = 0; fchan.nqam = 2;
fchan.vit_alpha = 1; fchan.vit_code_rate_hp = 2; fchan.vit_code_rate_lp = 2;
fchan.vit_hrch = 0; fchan.vit_select_hp = 1;

which means ( 8K, 1_32, QAM_64, 2_3 .....).

I've changed the code to behave more similar to the old version, where
only the parameters XX_AUTO where given an initial guess (leaving the
others unchanged), which was

( 2K, 1_32, QPSK, 0 for FEC )

That way I can autosearch one parameter at a time and not all together.

In my tests the TRANSMISSION_MODE and the GUARD_INTERVAL cannot be autosearched.

This exaplains why I can auto search BBC ONE (2K, 1_32) and not the
HDTV (8K, 1_32), and when I give the guess the wrong value for the
GUARD INTERVAL it fails.

I still have to investigate something called (in the old driver)
DIB3000MC_REG_SEQ_TPS which seems to have something to do with
TRANSMISSION, GUARD and INVERSION.

Time to eat now.
diff -r 5e9d301ef13b linux/drivers/media/dvb/frontends/dib3000mc.c
--- a/linux/drivers/media/dvb/frontends/dib3000mc.c	Thu Oct 26 10:10:56 2006 -0300
+++ b/linux/drivers/media/dvb/frontends/dib3000mc.c	Sat Oct 28 13:34:33 2006 +0100
@@ -26,7 +26,7 @@ module_param(debug, int, 0644);
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
 
-#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB3000MC/P:"); printk(args); } } while (0)
+#define dprintk(args...) do { if (debug) { printk("DiB3000MC/P: "); printk(args); } } while (0)
 
 struct dib3000mc_state {
 	struct dvb_frontend demod;
@@ -496,16 +496,16 @@ static void dib3000mc_set_channel_cfg(st
 
 	dib3000mc_set_impulse_noise(state, 0, chan->nfft);
 
-	tmp = ((chan->nfft & 0x1) << 7) | (chan->guard << 5) | (chan->nqam << 3) | chan->vit_alpha;
+	tmp = ((chan->nfft & 0x1) << 7) | ((chan->guard & 0x3) << 5) | ((chan->nqam & 0x3) << 3) | (chan->vit_alpha & 0x7);
 	dib3000mc_write_word(state, 0, tmp);
 
 	dib3000mc_write_word(state, 5, seq);
 
-	tmp = (chan->vit_hrch << 4) | (chan->vit_select_hp);
+	tmp = ((chan->vit_hrch & 0x1)<< 4) | (chan->vit_select_hp & 0x1);
 	if (!chan->vit_hrch || (chan->vit_hrch && chan->vit_select_hp))
-		tmp |= chan->vit_code_rate_hp << 1;
+	  tmp |= (chan->vit_code_rate_hp & 0x7) << 1;
 	else
-		tmp |= chan->vit_code_rate_lp << 1;
+	  tmp |= (chan->vit_code_rate_lp & 0x7) << 1;
 	dib3000mc_write_word(state, 181, tmp);
 
 	// diversity synchro delay
@@ -523,8 +523,9 @@ static void dib3000mc_set_channel_cfg(st
 	dib3000mc_set_impulse_noise(state, state->cfg->impulse_noise_mode, chan->nfft);
 }
 
-static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dibx000_ofdm_channel *chan)
-{
+static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dvb_frontend_parameters *fep, struct dibx000_ofdm_channel *chan)
+{
+	struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
 	struct dib3000mc_state *state = demod->demodulator_priv;
 	u16 reg;
 //	u32 val;
@@ -544,9 +545,66 @@ static int dib3000mc_autosearch_start(st
 #endif
 
 	/* a channel for autosearch */
-	fchan.nfft = 1; fchan.guard = 0; fchan.nqam = 2;
+	/*	fchan.nfft = 1; fchan.guard = 0; fchan.nqam = 2;
 	fchan.vit_alpha = 1; fchan.vit_code_rate_hp = 2; fchan.vit_code_rate_lp = 2;
-	fchan.vit_hrch = 0; fchan.vit_select_hp = 1;
+	fchan.vit_hrch = 0; fchan.vit_select_hp = 1;*/
+
+	// ===========================================================================================
+
+	// initial guess
+
+	// those apparently are not autosearched
+	fchan.nfft = 0; fchan.guard = 0; 
+
+	// those are succefully autosearched
+	fchan.nqam = 0; fchan.vit_code_rate_hp = 0; fchan.vit_code_rate_lp = 0; 
+
+	// those apparently are fixed (see FEP2DIB)
+	fchan.vit_select_hp = 1; fchan.vit_alpha = 1; fchan.vit_hrch = 0;
+
+	switch (ofdm->transmission_mode) {
+		case TRANSMISSION_MODE_2K: fchan.nfft = 0; break;
+		case TRANSMISSION_MODE_8K: fchan.nfft = 1; break;
+		case TRANSMISSION_MODE_AUTO: break;
+		default: return -EINVAL;
+	}
+	switch (ofdm->guard_interval) {
+		case GUARD_INTERVAL_1_32: fchan.guard = 0; break;
+		case GUARD_INTERVAL_1_16: fchan.guard = 1; break;
+		case GUARD_INTERVAL_1_8:  fchan.guard = 2; break;
+		case GUARD_INTERVAL_1_4:  fchan.guard = 3; break;
+		case GUARD_INTERVAL_AUTO: break;
+		default: return -EINVAL;
+	}
+	switch (ofdm->constellation) {
+		case QPSK:   fchan.nqam = 0; break;
+		case QAM_16: fchan.nqam = 1; break;
+		case QAM_64: fchan.nqam = 2; break;
+		case QAM_AUTO: break;
+		default: return -EINVAL;
+	}
+	switch (ofdm->code_rate_HP) {
+		case FEC_1_2: fchan.vit_code_rate_hp = 1; break;
+		case FEC_2_3: fchan.vit_code_rate_hp = 2; break;
+		case FEC_3_4: fchan.vit_code_rate_hp = 3; break;
+		case FEC_5_6: fchan.vit_code_rate_hp = 5; break;
+		case FEC_7_8: fchan.vit_code_rate_hp = 7; break;
+		case FEC_NONE: break;
+		case FEC_AUTO: break;
+		default: return -EINVAL;
+	}
+	switch (ofdm->code_rate_LP) {
+		case FEC_1_2: fchan.vit_code_rate_lp = 1; break;
+		case FEC_2_3: fchan.vit_code_rate_lp = 2; break;
+		case FEC_3_4: fchan.vit_code_rate_lp = 3; break;
+		case FEC_5_6: fchan.vit_code_rate_lp = 5; break;
+		case FEC_7_8: fchan.vit_code_rate_lp = 7; break;
+		case FEC_NONE: break;
+		case FEC_AUTO: break;
+		default: return -EINVAL;
+	}
+	
+	// ===========================================================================================
 
 	dib3000mc_set_channel_cfg(state, &fchan, 7);
 
@@ -684,7 +742,7 @@ static int dib3000mc_set_frontend(struct
 		fep->u.ofdm.code_rate_HP      == FEC_AUTO) {
 		int i = 100, found;
 
-		dib3000mc_autosearch_start(fe, &ch);
+		dib3000mc_autosearch_start(fe, fep, &ch);
 		do {
 			msleep(1);
 			found = dib3000mc_autosearch_is_irq(fe);
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux