24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
27 #include <linux/i2c.h>
61 addr = state->
config->demod_address;
64 for (i = 0; i < 2; i++) {
65 write_buf[0] = 0xbc +
i;
74 msgs[1].
len =
sizeof(read_buf);
75 msgs[1].
buf = read_buf;
88 x1 =
int_sqrt(word << 16) * ((15625ll << 21) / 1000000);
89 x2 = (
s64)x1 * x1 >> 31;
90 x3 = (
s64)x2 * x1 >> 31;
91 x4 = (
s64)x2 * x2 >> 31;
92 x5 = (
s64)x4 * x1 >> 31;
94 y = (58857ll << 23) / 1000;
95 y -= (
s64)x1 * ((89565ll << 24) / 1000) >> 30;
96 y += (
s64)x2 * ((88977ll << 24) / 1000) >> 28;
97 y -= (
s64)x3 * ((50259ll << 25) / 1000) >> 27;
98 y += (
s64)x4 * ((14341ll << 27) / 1000) >> 27;
99 y -= (
s64)x5 * ((16346ll << 30) / 10000) >> 28;
101 *snr = y < 0 ? 0 : y >> 15;
105 static int va1j5jf8007s_get_frontend_algo(
struct dvb_frontend *fe)
166 for (i = 0; i <
ARRAY_SIZE(va1j5jf8007s_cb_maps); i++) {
167 map = &va1j5jf8007s_cb_maps[
i];
168 if (frequency < map->frequency)
181 frequency = state->
fe.dtv_property_cache.frequency;
183 word = (frequency + 500) / 1000;
184 if (frequency < 1072000)
185 word = (word << 1 & ~0x1f) | (word & 0x0f);
189 buf[2] = 0x40 | word >> 8;
192 buf[5] = va1j5jf8007s_lookup_cb(frequency);
231 frequency = state->
fe.dtv_property_cache.frequency;
236 buf[3] = va1j5jf8007s_lookup_cb(frequency) | 0x4;
253 u8 write_buf[2], read_buf[1];
256 addr = state->
config->demod_address;
268 msgs[1].
len =
sizeof(read_buf);
269 msgs[1].
buf = read_buf;
274 *lock = read_buf[0] & 0x40;
301 u8 write_buf[1], read_buf[1];
304 addr = state->
config->demod_address;
315 msgs[1].
len =
sizeof(read_buf);
316 msgs[1].
buf = read_buf;
321 *lock = !(read_buf[0] & 0x10);
332 ts_id = state->
fe.dtv_property_cache.stream_id;
355 u8 write_buf[1], read_buf[2];
359 ts_id = state->
fe.dtv_property_cache.stream_id;
365 addr = state->
config->demod_address;
376 msgs[1].
len =
sizeof(read_buf);
377 msgs[1].
buf = read_buf;
382 *lock = (read_buf[0] << 8 | read_buf[1]) == ts_id;
389 unsigned int mode_flags,
unsigned int *
delay,
408 ret = va1j5jf8007s_set_frequency_1(state);
418 ret = va1j5jf8007s_set_frequency_2(state);
423 *delay = (
HZ + 99) / 100;
428 ret = va1j5jf8007s_set_frequency_3(state);
438 ret = va1j5jf8007s_check_frequency(state, &lock);
443 *delay = (
HZ + 999) / 1000;
454 ret = va1j5jf8007s_set_modulation(state);
464 ret = va1j5jf8007s_check_modulation(state, &lock);
469 *delay = (
HZ + 49) / 50;
480 ret = va1j5jf8007s_set_ts_id(state);
488 ret = va1j5jf8007s_check_ts_id(state, &lock);
493 *delay = (
HZ + 99) / 100;
537 buf[1] = sleep ? 0x01 : 0x00;
557 ret = va1j5jf8007s_init_frequency(state);
561 return va1j5jf8007s_set_sleep(state, 1);
571 return va1j5jf8007s_set_sleep(state, 0);
574 static void va1j5jf8007s_release(
struct dvb_frontend *fe)
584 .name =
"VA1J5JF8007/VA1J5JF8011 ISDB-S",
585 .frequency_min = 950000,
586 .frequency_max = 2150000,
587 .frequency_stepsize = 1000,
594 .read_snr = va1j5jf8007s_read_snr,
595 .get_frontend_algo = va1j5jf8007s_get_frontend_algo,
596 .read_status = va1j5jf8007s_read_status,
597 .tune = va1j5jf8007s_tune,
598 .sleep = va1j5jf8007s_sleep,
599 .init = va1j5jf8007s_init,
600 .release = va1j5jf8007s_release,
606 u8 write_buf[1], read_buf[1];
609 addr = state->
config->demod_address;
620 msgs[1].
len =
sizeof(read_buf);
621 msgs[1].
buf = read_buf;
626 if (read_buf[0] != 0x41)
632 static const u8 va1j5jf8007s_20mhz_prepare_bufs[][2] = {
633 {0x04, 0x02}, {0x0d, 0x55}, {0x11, 0x40}, {0x13, 0x80}, {0x17, 0x01},
634 {0x1c, 0x0a}, {0x1d, 0xaa}, {0x1e, 0x20}, {0x1f, 0x88}, {0x51, 0xb0},
635 {0x52, 0x89}, {0x53, 0xb3}, {0x5a, 0x2d}, {0x5b, 0xd3}, {0x85, 0x69},
636 {0x87, 0x04}, {0x8e, 0x02}, {0xa3, 0xf7}, {0xa5, 0xc0},
639 static const u8 va1j5jf8007s_25mhz_prepare_bufs[][2] = {
640 {0x04, 0x02}, {0x11, 0x40}, {0x13, 0x80}, {0x17, 0x01}, {0x1c, 0x0a},
641 {0x1d, 0xaa}, {0x1e, 0x20}, {0x1f, 0x88}, {0x51, 0xb0}, {0x52, 0x89},
642 {0x53, 0xb3}, {0x5a, 0x2d}, {0x5b, 0xd3}, {0x85, 0x69}, {0x87, 0x04},
643 {0x8e, 0x26}, {0xa3, 0xf7}, {0xa5, 0xc0},
655 switch (state->
config->frequency) {
657 bufs = va1j5jf8007s_20mhz_prepare_bufs;
658 size =
ARRAY_SIZE(va1j5jf8007s_20mhz_prepare_bufs);
661 bufs = va1j5jf8007s_25mhz_prepare_bufs;
662 size =
ARRAY_SIZE(va1j5jf8007s_25mhz_prepare_bufs);
668 addr = state->
config->demod_address;
674 for (i = 0; i <
size; i++) {
691 ret = va1j5jf8007s_prepare_1(state);
695 ret = va1j5jf8007s_prepare_2(state);
699 return va1j5jf8007s_init_frequency(state);
725 msg.
addr = state->config->demod_address;