14 #include <linux/string.h>
15 #include <linux/slab.h>
38 msg[0].addr = state->
config.demod_address;
41 msg[0].len =
sizeof(wbuf);
50 deb_fe(
" reg read failed.\n");
69 msg.len =
sizeof(wbuf);
72 deb_fe(
" reg write failed.");
82 for (i = 0; i < len - 1; i++) {
83 err = jdvbt90502_single_reg_write(state,
84 buf[0] + i, buf[i + 1]);
99 u8 pll_addr_byte = (state->
config.pll_address << 1) + 1;
108 ret = jdvbt90502_reg_read(state, 0x0100, result, 1);
112 deb_fe(
"PLL read val:%02x\n", *result);
116 deb_fe(
"%s:ret == %d\n", __func__, ret);
134 deb_fe(
"%s: freq=%d, step=%d\n", __func__, freq,
135 state->
frontend.ops.info.frequency_stepsize);
138 f = freq / state->
frontend.ops.info.frequency_stepsize;
151 msg[0].addr = state->
config.demod_address;
153 msg[0].buf = pll_freq_cmd;
154 msg[0].len =
sizeof(pll_freq_cmd);
170 msg[1].addr =
msg[0].addr;
172 msg[1].buf = pll_agc_cmd;
173 msg[1].len =
sizeof(pll_agc_cmd);
181 ret = jdvbt90502_single_reg_write(state, 0x01, 0x40);
182 ret |= jdvbt90502_single_reg_write(state, 0x01, 0x00);
188 #define RETRY_COUNT 5
190 ret = jdvbt90502_reg_read(state, 0x0096, &res1, 1);
194 ret = jdvbt90502_reg_read(state, 0x00B0, res2,
sizeof(res2));
201 if (retry >= RETRY_COUNT) {
202 deb_fe(
"%s: FE does not get ready after freq setting.\n",
209 deb_fe(
"%s:ret == %d\n", __func__, ret);
222 deb_fe(
"%s:ret == %d\n", __func__, ret);
237 static int jdvbt90502_read_signal_strength(
struct dvb_frontend *fe,
251 deb_fe(
"%s:ret == %d\n", __func__, ret);
256 *strength = (rbuf[3] << 8) + rbuf[4];
265 static int jdvbt90502_set_property(
struct dvb_frontend *fe,
285 static int jdvbt90502_get_frontend(
struct dvb_frontend *fe)
299 static int jdvbt90502_set_frontend(
struct dvb_frontend *fe)
317 ret = jdvbt90502_pll_set_freq(state, p->
frequency);
319 deb_fe(
"%s:ret == %d\n", __func__, ret);
331 static u8 init_code[][2] = {
370 static const int init_code_len =
sizeof(init_code) /
sizeof(
u8[2]);
380 deb_fe(
"%s called.\n", __func__);
385 for (i = 0; i < init_code_len; i++) {
386 msg.buf = init_code[
i];
397 deb_fe(
"%s: init_code[%d] failed. ret==%d\n", __func__, i, ret);
428 sizeof(jdvbt90502_ops));
431 if (jdvbt90502_init(&state->
frontend) < 0)
444 .name =
"Comtech JDVBT90502 ISDB-T",
445 .frequency_min = 473000000,
446 .frequency_max = 767142857,
448 .frequency_tolerance = 0,
461 .release = jdvbt90502_release,
463 .init = jdvbt90502_init,
464 .write = _jdvbt90502_write,
466 .set_property = jdvbt90502_set_property,
468 .set_frontend = jdvbt90502_set_frontend,
469 .get_frontend = jdvbt90502_get_frontend,
471 .read_status = jdvbt90502_read_status,
472 .read_signal_strength = jdvbt90502_read_signal_strength,