Hi,
changes:
- 125kHz step, register 0x1a
- tuner offset and fix register 0x07 calculation
- added some alternative values to registers 0x11, 0x1f and 0x20. Values
are hidden behind preprocessor macros, old values are used by default.
I don't know what is the real stepping supported by HW, probably it is
less than 125kHz. 125kHz were used in both of the Sigmatek DVB-110 and
MSI Megasky GL681 Windows drivers. Though, I guess, 125kHz is enough for
tuning all frequencies in DVB-T bands supported by hw (48-860MHz). In my
understanding it should be possible now to tune all DVB-T channels used
worldwide, in theory at least. Locking is harder to get, because most of
the register values are still only magic numbers, for example setting
bandwidth is unknown. Frequency is set by: 0x07 (n*32MHz) + 0x0a
(n*4MHz) + 0x1a (n*125kHz).
Patch should not change functionality of the other than frequency
registers, eg. if your Megasky works before this patch, it should work
also after. If not, there is a bug.
Patch tested with Megasky GL681 and Sigmatek DVB-110 against fi-Oulu
frequencies. Megasky works always and Sigmatek as poor as without patch
:) If I change defines to SIGMATEK, Sigmatek works better and also
Megasky seems to work as expected. I still left old functionality to
default, because Sigmatek stick is not so popular as Megasky. Please
test different configurations and report.
If someone owns devices with QT1010 tuner, other than mentioned this
mail, and can do USB-sniffing in windows, please help. I will give
detailed information by email.
Aapo, could you test this patch with your hardware.
Regards,
Antti Palosaari
Signed-off-by: Antti Palosaari <crope@xxxxxx>
--
|||
(0-0)
---------oOO--(_)--OOo--------------------------------------------
tel. +358 40 535 7322 | MSN Messenger crope@xxxxxx | www.palosaari.fi
-Kahta asiaa en ymmärrä.. C-kielen syntaksi ja naisten logiikka.."
diff -r 11fa5f80d049 linux/drivers/media/dvb/frontends/qt1010.h
--- a/linux/drivers/media/dvb/frontends/qt1010.h Sun Nov 05 14:05:38 2006 -0500
+++ b/linux/drivers/media/dvb/frontends/qt1010.h Wed Nov 29 03:07:24 2006 +0200
@@ -21,14 +21,22 @@
#define QT1010_W 0
#define QT1010_R 1
-/* Not actual hw limits. */
-#define QT1010_MIN_STEP 2000000
-#define QT1010_MIN_FREQ 48000000
+#define QT1010_STEP 125000 /* 125 kHz used by Windows drivers,
+ hw could be more precise but we don't know how to use */
+#define QT1010_MIN_FREQ 48000000 /* 48 MHz */
+#define QT1010_MAX_FREQ 860000000 /* 860 MHz */
+#define QT1010_OFFSET 1246000000 /* 1246 MHz */
+
+#undef MEGASKY_GL861
+#define MEGASKY_M9206
+#undef SIGMATEK
static int qt1010_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
{
int i;
- int div, mod;
+ int div, mod1, mod2;
+ unsigned long freq;
+
struct {
u8 read, reg, value;
} rd[46] = { { QT1010_W, 0x01, 0x80 },
@@ -80,122 +88,243 @@ static int qt1010_set_params(struct dvb_
};
struct i2c_msg msg;
struct dvb_usb_adapter *adap = fe->dvb->priv;
- unsigned long freq = params->frequency;
-
- if (freq % QT1010_MIN_STEP)
- printk("frequency not supported.\n");
-
- div = (freq - QT1010_MIN_FREQ) / QT1010_MIN_STEP;
- mod = (div + 16 - 9) % 16;
+
+#define FREQ1 32000000 /* 32 MHz */
+#define FREQ2 4000000 /* 4 MHz Quartz oscillator in the stick? */
+
+ div = (params->frequency + QT1010_OFFSET) / QT1010_STEP;
+ freq = (div * QT1010_STEP) - QT1010_OFFSET;
+ mod1 = (freq + QT1010_OFFSET) % FREQ1;
+ mod2 = (freq + QT1010_OFFSET) % FREQ2;
/* 0x5 */
- if (div >= 377)
+ if (freq >= 802000000) /* 802 MHz */
rd[2].value = 0x74;
- else if (div >= 265)
+ else if (freq >= 578000000) /* 578 MHz */
rd[2].value = 0x54;
- else if (div >= 121)
+ else if (freq >= 290000000) /* 290 MHz */
rd[2].value = 0x34;
else
rd[2].value = 0x14;
- /* 0x7 */
- rd[4].value = (((freq - QT1010_MIN_FREQ) / 1000000) * 9975 + 12960000) / 320000;
+ /* 07 - set frequency: 32MHz scale */
+ rd[4].value = (freq + QT1010_OFFSET) / FREQ1;
/* 09 */
- if (mod < 4)
+ if (mod1 < 8000000) /* 8/24 MHz */
rd[6].value = 0x1d;
else
rd[6].value = 0x1c;
- /* 0a */
- if (mod < 2)
+ /* 0a - set frequency: 4MHz scale */
+ if (mod1 < 1*FREQ2) /* +0 MHz */
rd[7].value = 0x09;
- else if (mod < 4)
+ else if (mod1 < 2*FREQ2) /* +4 MHz */
rd[7].value = 0x08;
- else if (mod < 6)
+ else if (mod1 < 3*FREQ2) /* +8 MHz */
rd[7].value = 0x0f;
- else if (mod < 8)
+ else if (mod1 < 4*FREQ2) /* +12 MHz */
rd[7].value = 0x0e;
- else if (mod < 10)
+ else if (mod1 < 5*FREQ2) /* +16 MHz */
rd[7].value = 0x0d;
- else if (mod < 12)
+ else if (mod1 < 6*FREQ2) /* +20 MHz */
rd[7].value = 0x0c;
- else if (mod < 14)
+ else if (mod1 < 7*FREQ2) /* +24 MHz */
rd[7].value = 0x0b;
else
- rd[7].value = 0x0a;
+ rd[7].value = 0x0a; /* +28 MHz */
/* 0b */
- if (div & 1)
+ if (mod2 < 2000000) /* 2/2 MHz */
rd[8].value = 0x45;
else
rd[8].value = 0x44;
- /* 1a */
- if (div & 1)
+ /* 1a - set frequency: 125kHz scale */
+ if (mod2 < 1*QT1010_STEP) /* +0.000 MHz */
rd[10].value = 0x78;
- else
+ else if (mod2 < 2*QT1010_STEP) /* +0.125 MHz */
+ rd[10].value = 0x70;
+ else if (mod2 < 3*QT1010_STEP) /* +0.250 MHz */
+ rd[10].value = 0x68;
+ else if (mod2 < 4*QT1010_STEP) /* +0.375 MHz */
+ rd[10].value = 0x60;
+ else if (mod2 < 5*QT1010_STEP) /* +0.500 MHz */
+ rd[10].value = 0x58;
+ else if (mod2 < 6*QT1010_STEP) /* +0.625 MHz */
+ rd[10].value = 0x50;
+ else if (mod2 < 7*QT1010_STEP) /* +0.850 MHz */
+ rd[10].value = 0x48;
+ else if (mod2 < 8*QT1010_STEP) /* +0.975 MHz */
+ rd[10].value = 0x40;
+ else if (mod2 < 9*QT1010_STEP) /* +1.000 MHz */
+ rd[10].value = 0x38;
+ else if (mod2 < 10*QT1010_STEP) /* +1.125 MHz */
+ rd[10].value = 0x30;
+ else if (mod2 < 11*QT1010_STEP) /* +1.250 MHz */
+ rd[10].value = 0x28;
+ else if (mod2 < 12*QT1010_STEP) /* +1.375 MHz */
+ rd[10].value = 0x20;
+ else if (mod2 < 13*QT1010_STEP) /* +1.500 MHz */
+ rd[10].value = 0x18;
+ else if (mod2 < 14*QT1010_STEP) /* +1.625 MHz */
+ rd[10].value = 0x10;
+ else if (mod2 < 15*QT1010_STEP) /* +1.850 MHz */
+ rd[10].value = 0x08;
+ else if (mod2 < 16*QT1010_STEP) /* +1.975 MHz */
+ rd[10].value = 0x00;
+ else if (mod2 < 17*QT1010_STEP) /* +2.000 MHz */
rd[10].value = 0xf8;
+ else if (mod2 < 18*QT1010_STEP) /* +2.125 MHz */
+ rd[10].value = 0xf0;
+ else if (mod2 < 19*QT1010_STEP) /* +2.250 MHz */
+ rd[10].value = 0xe8;
+ else if (mod2 < 20*QT1010_STEP) /* +2.375 MHz */
+ rd[10].value = 0xe0;
+ else if (mod2 < 21*QT1010_STEP) /* +2.500 MHz */
+ rd[10].value = 0xd8;
+ else if (mod2 < 22*QT1010_STEP) /* +2.625 MHz */
+ rd[10].value = 0xd0;
+ else if (mod2 < 23*QT1010_STEP) /* +2.850 MHz */
+ rd[10].value = 0xc8;
+ else if (mod2 < 24*QT1010_STEP) /* +2.975 MHz */
+ rd[10].value = 0xc0;
+ else if (mod2 < 25*QT1010_STEP) /* +3.000 MHz */
+ rd[10].value = 0xb8;
+ else if (mod2 < 26*QT1010_STEP) /* +3.125 MHz */
+ rd[10].value = 0xb0;
+ else if (mod2 < 27*QT1010_STEP) /* +3.250 MHz */
+ rd[10].value = 0xa8;
+ else if (mod2 < 28*QT1010_STEP) /* +3.375 MHz */
+ rd[10].value = 0xa0;
+ else if (mod2 < 29*QT1010_STEP) /* +3.500 MHz */
+ rd[10].value = 0x98;
+ else if (mod2 < 30*QT1010_STEP) /* +3.625 MHz */
+ rd[10].value = 0x90;
+ else if (mod2 < 31*QT1010_STEP) /* +3.850 MHz */
+ rd[10].value = 0x88;
+ else /* +3.975 MHz */
+ rd[10].value = 0x80;
/* 11 */
- if (div >= 265)
+#if defined (MEGASKY_GL861) || defined (MEGASKY_M9206)
+ if (freq >= 578000000) /* 578 MHz */
rd[13].value = 0xf9;
- else if (div >= 121)
+ else if (freq >= 290000000) /* 290 MHz */
rd[13].value = 0xfd;
else
rd[13].value = 0xf9;
+#elif defined (SIGMATEK)
+ rd[13].value = 0xfd;
+#endif
/* 22 */
- if (div < 201)
+ if (freq < 450000000) /* 450 MHz */
rd[15].value = 0xd0;
- else if (div < 217)
+ else if (freq < 482000000) /* 482 MHz */
rd[15].value = 0xd3;
- else if (div < 233)
+ else if (freq < 514000000) /* 514 MHz */
rd[15].value = 0xd6;
- else if (div < 249)
+ else if (freq < 546000000) /* 546 MHz */
rd[15].value = 0xd9;
- else if (div < 265)
+ else if (freq < 578000000) /* 578 MHz */
rd[15].value = 0xda;
else
rd[15].value = 0xd0;
- /* 05 */
- if (div >= 377)
+ /* 0x5 */
+ if (freq >= 802000000) /* 802 MHz */
rd[34].value = 0x70;
- else if (div >= 265)
+ else if (freq >= 578000000) /* 578 MHz */
rd[34].value = 0x50;
- else if (div >= 121)
+ else if (freq >= 290000000) /* 290 MHz */
rd[34].value = 0x30;
else
rd[34].value = 0x10;
/* 1f */
- if (mod < 4)
+#if defined (MEGASKY_GL861)
+ if (mod1 < 8000000)
+ rd[39].value = 0x63;
+ else if (mod1 < 12000000)
+ rd[39].value = 0x65;
+ else if (mod1 < 16000000)
+ rd[39].value = 0x66;
+ else if (mod1 < 24000000)
+ rd[39].value = 0x67;
+ else if (mod1 < 28000000)
+ rd[39].value = 0x68;
+ else
+ rd[39].value = 0x69;
+#elif defined (MEGASKY_M9206)
+ if (mod1 < 8000000)
rd[39].value = 0x64;
- else if (mod < 6)
+ else if (mod1 < 12000000)
rd[39].value = 0x66;
- else if (mod < 8)
+ else if (mod1 < 16000000)
rd[39].value = 0x67;
- else if (mod < 12)
+ else if (mod1 < 24000000)
rd[39].value = 0x68;
- else if (mod < 14)
+ else if (mod1 < 28000000)
rd[39].value = 0x69;
else
rd[39].value = 0x6a;
+#elif defined (SIGMATEK)
+ if (mod1 < 8000000)
+ rd[39].value = 0x4b;
+ else if (mod1 < 12000000)
+ rd[39].value = 0x4d;
+ else if (mod1 < 16000000)
+ rd[39].value = 0x4e;
+ else if (mod1 < 24000000)
+ rd[39].value = 0x4f;
+ else if (mod1 < 28000000)
+ rd[39].value = 0x50;
+ else
+ rd[39].value = 0x51;
+#endif
/* 20 */
- if (mod < 4)
+#if defined (MEGASKY_GL861)
+ if (mod1 < 8000000)
+ rd[40].value = 0x0f;
+ else if (mod1 < 12000000)
rd[40].value = 0x10;
- else if (mod < 6)
+ else if (mod1 < 20000000)
rd[40].value = 0x11;
- else if (mod < 10)
+ else if (mod1 < 24000000)
rd[40].value = 0x12;
- else if (mod < 12)
+ else if (mod1 < 28000000)
rd[40].value = 0x13;
- else if (mod < 14)
+ else
rd[40].value = 0x14;
+#elif defined (MEGASKY_M9206)
+ if (mod1 < 8000000)
+ rd[40].value = 0x10;
+ else if (mod1 < 12000000)
+ rd[40].value = 0x11;
+ else if (mod1 < 20000000)
+ rd[40].value = 0x12;
+ else if (mod1 < 24000000)
+ rd[40].value = 0x13;
+ else if (mod1 < 28000000)
+ rd[40].value = 0x14;
else
rd[40].value = 0x15;
+#elif defined (SIGMATEK)
+ if (mod1 < 8000000)
+ rd[40].value = 0x16;
+ else if (mod1 < 12000000)
+ rd[40].value = 0x17;
+ else if (mod1 < 20000000)
+ rd[40].value = 0x18;
+ else if (mod1 < 24000000)
+ rd[40].value = 0x19;
+ else if (mod1 < 28000000)
+ rd[40].value = 0x1a;
+ else
+ rd[40].value = 0x1b;
+#endif
for (i = 0; i < sizeof(rd) / sizeof(*rd); i++) {
if (rd[i].read)
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb