24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
27 #include <linux/i2c.h>
59 addr = state->
config->demod_address;
62 for (i = 0; i < 3; i++) {
63 write_buf[0] = 0x8b +
i;
72 msgs[1].
len =
sizeof(read_buf);
73 msgs[1].
buf = read_buf;
85 x = 10 * (
intlog10(0x540000 * 100 / word) - (2 << 24));
86 y = (24ll << 46) / 1000000;
87 y = ((
s64)y * x >> 30) - (16ll << 40) / 10000;
88 y = ((
s64)y * x >> 29) + (398ll << 35) / 10000;
89 y = ((
s64)y * x >> 30) + (5491ll << 29) / 10000;
90 y = ((
s64)y * x >> 30) + (30965ll << 23) / 10000;
95 static int va1j5jf8007t_get_frontend_algo(
struct dvb_frontend *fe)
152 for (i = 0; i <
ARRAY_SIZE(va1j5jf8007t_cb_maps); i++) {
153 map = &va1j5jf8007t_cb_maps[
i];
154 if (frequency < map->frequency)
167 frequency = state->
fe.dtv_property_cache.frequency;
169 word = (frequency + 71428) / 142857 + 399;
175 buf[5] = va1j5jf8007t_lookup_cb(frequency);
192 u8 write_buf[2], read_buf[1];
195 addr = state->
config->demod_address;
207 msgs[1].
len =
sizeof(read_buf);
208 msgs[1].
buf = read_buf;
213 *lock = read_buf[0] & 0x40;
237 int *lock,
int *
retry)
240 u8 write_buf[1], read_buf[1];
243 addr = state->
config->demod_address;
254 msgs[1].
len =
sizeof(read_buf);
255 msgs[1].
buf = read_buf;
260 *lock = !(read_buf[0] & 0x10);
261 *retry = read_buf[0] & 0x80;
268 unsigned int mode_flags,
unsigned int *
delay,
273 int lock = 0, retry = 0;
287 ret = va1j5jf8007t_set_frequency(state);
297 ret = va1j5jf8007t_check_frequency(state, &lock);
302 *delay = (
HZ + 999) / 1000;
313 ret = va1j5jf8007t_set_modulation(state);
323 ret = va1j5jf8007t_check_modulation(state, &lock, &retry);
334 *delay = (
HZ + 999) / 1000;
386 buf[1] = sleep ? 0x90 : 0x80;
406 ret = va1j5jf8007t_init_frequency(state);
410 return va1j5jf8007t_set_sleep(state, 1);
420 return va1j5jf8007t_set_sleep(state, 0);
423 static void va1j5jf8007t_release(
struct dvb_frontend *fe)
433 .name =
"VA1J5JF8007/VA1J5JF8011 ISDB-T",
434 .frequency_min = 90000000,
435 .frequency_max = 770000000,
436 .frequency_stepsize = 142857,
442 .read_snr = va1j5jf8007t_read_snr,
443 .get_frontend_algo = va1j5jf8007t_get_frontend_algo,
444 .read_status = va1j5jf8007t_read_status,
445 .tune = va1j5jf8007t_tune,
446 .sleep = va1j5jf8007t_sleep,
447 .init = va1j5jf8007t_init,
448 .release = va1j5jf8007t_release,
451 static const u8 va1j5jf8007t_20mhz_prepare_bufs[][2] = {
452 {0x03, 0x90}, {0x14, 0x8f}, {0x1c, 0x2a}, {0x1d, 0xa8}, {0x1e, 0xa2},
453 {0x22, 0x83}, {0x31, 0x0d}, {0x32, 0xe0}, {0x39, 0xd3}, {0x3a, 0x00},
454 {0x5c, 0x40}, {0x5f, 0x80}, {0x75, 0x02}, {0x76, 0x4e}, {0x77, 0x03},
458 static const u8 va1j5jf8007t_25mhz_prepare_bufs[][2] = {
459 {0x03, 0x90}, {0x1c, 0x2a}, {0x1d, 0xa8}, {0x1e, 0xa2}, {0x22, 0x83},
460 {0x3a, 0x00}, {0x5c, 0x40}, {0x5f, 0x80}, {0x75, 0x0a}, {0x76, 0x4c},
461 {0x77, 0x03}, {0xef, 0x01}
475 switch (state->
config->frequency) {
477 bufs = va1j5jf8007t_20mhz_prepare_bufs;
478 size =
ARRAY_SIZE(va1j5jf8007t_20mhz_prepare_bufs);
481 bufs = va1j5jf8007t_25mhz_prepare_bufs;
482 size =
ARRAY_SIZE(va1j5jf8007t_25mhz_prepare_bufs);
493 for (i = 0; i <
size; i++) {
499 return va1j5jf8007t_init_frequency(state);
525 msg.
addr = state->config->demod_address;