heis!
Same patch as earlier, but now with fixed nominal rate calculation.
Still I don't have any idea why real xtal freq differs from freq used in
code. Interesting enough, the difference between real and software
frequency is just 2048 (kHz) :)
It could be interesting to see what are used values in case of different
xtal. Does someone have a stick with zl10353 demod and different xtal?
Tested successfully with au6610 & gl861 against fi-Oulu frequencies.
Signed-off-by: Antti Palosaari <crope@xxxxxx>
Regards Antti Palosaari
Antti Palosaari wrote:
heippa!
Implement trl nominal rate calculation to Zarlink ZL10353 demod. Patch
is based on calculation used in Zarlink MT352 which seems to be very
similar.
There seems to be a little difference in calculation that I haven't
found yet. Using bandwidth 7 it gives rate 0x5ae8 instead of 0x5ae9
which have seen in logs sniffed from windows driver. I assume that this
small difference does not have any effect.
The other thing I don't understand is xtal used in hardware is 20.480
MHz, but in code it needs to be set 22528. Does anyone know why the
difference?
With those two "findings" I assume that there is still a slight
calculation error. I did simple openoffice spreadsheet to calculate
nominal rate, try it and find correct formula :)
http://otit.fi/~crope/v4l-dvb/zl10353/zl10535_trl_nominal_rate_calculator.ods
Signed-off-by: Antti Palosaari <crope@xxxxxx>
Regards Antti Palosaari
--
|||
(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 836a1942a2e4 linux/drivers/media/dvb/frontends/zl10353.c
--- a/linux/drivers/media/dvb/frontends/zl10353.c Tue Jan 23 20:58:30 2007 -0500
+++ b/linux/drivers/media/dvb/frontends/zl10353.c Fri Jan 26 00:48:04 2007 +0200
@@ -37,6 +37,12 @@ struct zl10353_state {
struct zl10353_config config;
};
+
+static int debug;
+#define dprintk(args...) \
+ do { \
+ if (debug) printk(KERN_DEBUG "zl10353: " args); \
+ } while (0)
#if 1
static int debug_regs = 0;
@@ -117,6 +123,36 @@ static void zl10353_dump_regs(struct dvb
}
#endif
+static void zl10353_calc_nominal_rate(struct dvb_frontend *fe,
+ enum fe_bandwidth bandwidth,
+ u16 *nominal_rate)
+{
+ u32 adc_clock = 22528; /* 20.480 MHz on the board(!?) */
+ u8 bw;
+ struct zl10353_state *state = fe->demodulator_priv;
+
+ if (state->config.adc_clock)
+ adc_clock = state->config.adc_clock;
+
+ switch (bandwidth) {
+ case BANDWIDTH_6_MHZ:
+ bw = 6;
+ break;
+ case BANDWIDTH_7_MHZ:
+ bw = 7;
+ break;
+ case BANDWIDTH_8_MHZ:
+ default:
+ bw = 8;
+ break;
+ }
+
+ *nominal_rate = (64 * bw * (1<<16) / (7 * 8) * 4000 / adc_clock + 2) / 4;
+
+ dprintk("%s: bw %d, adc_clock %d => 0x%x\n",
+ __FUNCTION__, bw, adc_clock, *nominal_rate);
+}
+
static int zl10353_sleep(struct dvb_frontend *fe)
{
static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 };
@@ -129,7 +165,7 @@ static int zl10353_set_parameters(struct
struct dvb_frontend_parameters *param)
{
struct zl10353_state *state = fe->demodulator_priv;
-
+ u16 nominal_rate;
u8 pllbuf[6] = { 0x67 };
/* These settings set "auto-everything" and start the FSM. */
@@ -144,6 +180,11 @@ static int zl10353_set_parameters(struct
zl10353_single_write(fe, 0x5E, 0x00);
zl10353_single_write(fe, 0x6C, 0xCD);
zl10353_single_write(fe, 0x6D, 0x7E);
+
+ zl10353_calc_nominal_rate(fe, param->u.ofdm.bandwidth, &nominal_rate);
+ zl10353_single_write(fe, TRL_NOMINAL_RATE_1, msb(nominal_rate));
+ zl10353_single_write(fe, TRL_NOMINAL_RATE_0, lsb(nominal_rate));
+
fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
// if there is no attached secondary tuner, we call set_params to program
diff -r 836a1942a2e4 linux/drivers/media/dvb/frontends/zl10353.h
--- a/linux/drivers/media/dvb/frontends/zl10353.h Tue Jan 23 20:58:30 2007 -0500
+++ b/linux/drivers/media/dvb/frontends/zl10353.h Thu Jan 25 21:58:05 2007 +0200
@@ -29,6 +29,9 @@ struct zl10353_config
/* demodulator's I2C address */
u8 demod_address;
+ /* frequencies in kHz */
+ int adc_clock; // default: 22528
+
/* set if no pll is connected to the secondary i2c bus */
int no_tuner;
diff -r 836a1942a2e4 linux/drivers/media/dvb/frontends/zl10353_priv.h
--- a/linux/drivers/media/dvb/frontends/zl10353_priv.h Tue Jan 23 20:58:30 2007 -0500
+++ b/linux/drivers/media/dvb/frontends/zl10353_priv.h Thu Jan 25 21:52:19 2007 +0200
@@ -24,19 +24,24 @@
#define ID_ZL10353 0x14
+#define msb(x) (((x) >> 8) & 0xff)
+#define lsb(x) ((x) & 0xff)
+
enum zl10353_reg_addr {
- INTERRUPT_0 = 0x00,
- INTERRUPT_1 = 0x01,
- INTERRUPT_2 = 0x02,
- INTERRUPT_3 = 0x03,
- INTERRUPT_4 = 0x04,
- INTERRUPT_5 = 0x05,
- STATUS_6 = 0x06,
- STATUS_7 = 0x07,
- STATUS_8 = 0x08,
- STATUS_9 = 0x09,
- SNR = 0x10,
- CHIP_ID = 0x7F,
+ INTERRUPT_0 = 0x00,
+ INTERRUPT_1 = 0x01,
+ INTERRUPT_2 = 0x02,
+ INTERRUPT_3 = 0x03,
+ INTERRUPT_4 = 0x04,
+ INTERRUPT_5 = 0x05,
+ STATUS_6 = 0x06,
+ STATUS_7 = 0x07,
+ STATUS_8 = 0x08,
+ STATUS_9 = 0x09,
+ SNR = 0x10,
+ TRL_NOMINAL_RATE_1 = 0x65,
+ TRL_NOMINAL_RATE_0 = 0x66,
+ CHIP_ID = 0x7F,
};
#endif /* _ZL10353_PRIV_ */
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb