diff options
author | Malcolm Priestley <tvboxspy@gmail.com> | 2013-12-24 11:18:46 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-01-07 06:37:29 -0500 |
commit | dd4491dfb9eb4fa3bfa7dc73ba989e69fbce2e10 (patch) | |
tree | bfa950fea42eb3bcb53dfe9536ef02fbb6588abf /drivers/media | |
parent | 06af15d1b6f45c60358feab88004472e5428f01c (diff) |
[media] m88rs2000: set symbol rate accurately
Current setting of symbol rate is not very actuate causing
loss of lock.
Covert temp to u64 and use mclk to calculate from big number.
Calculate symbol rate by dividing symbol rate by 1000 times
1 << 24 and dividing sum by mclk.
Add other symbol rate settings to function registers 0xa0-0xa3.
In set_frontend add changes to register 0xf1 this must be done
prior call to fe_reset. Register 0x00 doesn't need a second
write of 0x1
Applied after patch
m88rs2000: add m88rs2000_set_carrieroffset
Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Cc: stable@vger.kernel.org # v3.9+
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb-frontends/m88rs2000.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c index 8091653e8864..02699c111019 100644 --- a/drivers/media/dvb-frontends/m88rs2000.c +++ b/drivers/media/dvb-frontends/m88rs2000.c | |||
@@ -160,24 +160,44 @@ static int m88rs2000_set_symbolrate(struct dvb_frontend *fe, u32 srate) | |||
160 | { | 160 | { |
161 | struct m88rs2000_state *state = fe->demodulator_priv; | 161 | struct m88rs2000_state *state = fe->demodulator_priv; |
162 | int ret; | 162 | int ret; |
163 | u32 temp; | 163 | u64 temp; |
164 | u32 mclk; | ||
164 | u8 b[3]; | 165 | u8 b[3]; |
165 | 166 | ||
166 | if ((srate < 1000000) || (srate > 45000000)) | 167 | if ((srate < 1000000) || (srate > 45000000)) |
167 | return -EINVAL; | 168 | return -EINVAL; |
168 | 169 | ||
170 | mclk = m88rs2000_get_mclk(fe); | ||
171 | if (!mclk) | ||
172 | return -EINVAL; | ||
173 | |||
169 | temp = srate / 1000; | 174 | temp = srate / 1000; |
170 | temp *= 11831; | 175 | temp *= 1 << 24; |
171 | temp /= 68; | 176 | |
172 | temp -= 3; | 177 | do_div(temp, mclk); |
173 | 178 | ||
174 | b[0] = (u8) (temp >> 16) & 0xff; | 179 | b[0] = (u8) (temp >> 16) & 0xff; |
175 | b[1] = (u8) (temp >> 8) & 0xff; | 180 | b[1] = (u8) (temp >> 8) & 0xff; |
176 | b[2] = (u8) temp & 0xff; | 181 | b[2] = (u8) temp & 0xff; |
182 | |||
177 | ret = m88rs2000_writereg(state, 0x93, b[2]); | 183 | ret = m88rs2000_writereg(state, 0x93, b[2]); |
178 | ret |= m88rs2000_writereg(state, 0x94, b[1]); | 184 | ret |= m88rs2000_writereg(state, 0x94, b[1]); |
179 | ret |= m88rs2000_writereg(state, 0x95, b[0]); | 185 | ret |= m88rs2000_writereg(state, 0x95, b[0]); |
180 | 186 | ||
187 | if (srate > 10000000) | ||
188 | ret |= m88rs2000_writereg(state, 0xa0, 0x20); | ||
189 | else | ||
190 | ret |= m88rs2000_writereg(state, 0xa0, 0x60); | ||
191 | |||
192 | ret |= m88rs2000_writereg(state, 0xa1, 0xe0); | ||
193 | |||
194 | if (srate > 12000000) | ||
195 | ret |= m88rs2000_writereg(state, 0xa3, 0x20); | ||
196 | else if (srate > 2800000) | ||
197 | ret |= m88rs2000_writereg(state, 0xa3, 0x98); | ||
198 | else | ||
199 | ret |= m88rs2000_writereg(state, 0xa3, 0x90); | ||
200 | |||
181 | deb_info("m88rs2000: m88rs2000_set_symbolrate\n"); | 201 | deb_info("m88rs2000: m88rs2000_set_symbolrate\n"); |
182 | return ret; | 202 | return ret; |
183 | } | 203 | } |
@@ -307,8 +327,6 @@ struct inittab m88rs2000_shutdown[] = { | |||
307 | 327 | ||
308 | struct inittab fe_reset[] = { | 328 | struct inittab fe_reset[] = { |
309 | {DEMOD_WRITE, 0x00, 0x01}, | 329 | {DEMOD_WRITE, 0x00, 0x01}, |
310 | {DEMOD_WRITE, 0xf1, 0xbf}, | ||
311 | {DEMOD_WRITE, 0x00, 0x01}, | ||
312 | {DEMOD_WRITE, 0x20, 0x81}, | 330 | {DEMOD_WRITE, 0x20, 0x81}, |
313 | {DEMOD_WRITE, 0x21, 0x80}, | 331 | {DEMOD_WRITE, 0x21, 0x80}, |
314 | {DEMOD_WRITE, 0x10, 0x33}, | 332 | {DEMOD_WRITE, 0x10, 0x33}, |
@@ -351,9 +369,6 @@ struct inittab fe_trigger[] = { | |||
351 | {DEMOD_WRITE, 0x9b, 0x64}, | 369 | {DEMOD_WRITE, 0x9b, 0x64}, |
352 | {DEMOD_WRITE, 0x9e, 0x00}, | 370 | {DEMOD_WRITE, 0x9e, 0x00}, |
353 | {DEMOD_WRITE, 0x9f, 0xf8}, | 371 | {DEMOD_WRITE, 0x9f, 0xf8}, |
354 | {DEMOD_WRITE, 0xa0, 0x20}, | ||
355 | {DEMOD_WRITE, 0xa1, 0xe0}, | ||
356 | {DEMOD_WRITE, 0xa3, 0x38}, | ||
357 | {DEMOD_WRITE, 0x98, 0xff}, | 372 | {DEMOD_WRITE, 0x98, 0xff}, |
358 | {DEMOD_WRITE, 0xc0, 0x0f}, | 373 | {DEMOD_WRITE, 0xc0, 0x0f}, |
359 | {DEMOD_WRITE, 0x89, 0x01}, | 374 | {DEMOD_WRITE, 0x89, 0x01}, |
@@ -625,8 +640,13 @@ static int m88rs2000_set_frontend(struct dvb_frontend *fe) | |||
625 | if (ret < 0) | 640 | if (ret < 0) |
626 | return -ENODEV; | 641 | return -ENODEV; |
627 | 642 | ||
628 | /* Reset Demod */ | 643 | /* Reset demod by symbol rate */ |
629 | ret = m88rs2000_tab_set(state, fe_reset); | 644 | if (c->symbol_rate > 27500000) |
645 | ret = m88rs2000_writereg(state, 0xf1, 0xa4); | ||
646 | else | ||
647 | ret = m88rs2000_writereg(state, 0xf1, 0xbf); | ||
648 | |||
649 | ret |= m88rs2000_tab_set(state, fe_reset); | ||
630 | if (ret < 0) | 650 | if (ret < 0) |
631 | return -ENODEV; | 651 | return -ENODEV; |
632 | 652 | ||