Lines Matching refs:stv6110x

30 static int stv6110x_read_reg(struct stv6110x_state *stv6110x, u8 reg, u8 *data)  in stv6110x_read_reg()  argument
33 const struct stv6110x_config *config = stv6110x->config; in stv6110x_read_reg()
41 ret = i2c_transfer(stv6110x->i2c, msg, 2); in stv6110x_read_reg()
51 static int stv6110x_write_regs(struct stv6110x_state *stv6110x, int start, u8 data[], int len) in stv6110x_write_regs() argument
54 const struct stv6110x_config *config = stv6110x->config; in stv6110x_write_regs()
77 ret = i2c_transfer(stv6110x->i2c, &msg, 1); in stv6110x_write_regs()
86 static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data) in stv6110x_write_reg() argument
90 return stv6110x_write_regs(stv6110x, reg, &tmp, 1); in stv6110x_write_reg()
95 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_init() local
98 ret = stv6110x_write_regs(stv6110x, 0, stv6110x->regs, in stv6110x_init()
99 ARRAY_SIZE(stv6110x->regs)); in stv6110x_init()
110 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_set_frequency() local
115 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL1], CTRL1_K, (REFCLOCK_MHz - 16)); in stv6110x_set_frequency()
118 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_DIV4SEL, 1); in stv6110x_set_frequency()
119 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_PRESC32_ON, 0); in stv6110x_set_frequency()
122 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_DIV4SEL, 1); in stv6110x_set_frequency()
123 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_PRESC32_ON, 1); in stv6110x_set_frequency()
126 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_DIV4SEL, 0); in stv6110x_set_frequency()
127 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_PRESC32_ON, 0); in stv6110x_set_frequency()
130 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_DIV4SEL, 0); in stv6110x_set_frequency()
131 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_PRESC32_ON, 1); in stv6110x_set_frequency()
147 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_R_DIV, rDivOpt); in stv6110x_set_frequency()
148 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG1], TNG1_N_DIV_11_8, MSB(divider)); in stv6110x_set_frequency()
149 STV6110x_SETFIELD(stv6110x->regs[STV6110x_TNG0], TNG0_N_DIV_7_0, LSB(divider)); in stv6110x_set_frequency()
152 STV6110x_SETFIELD(stv6110x->regs[STV6110x_STAT1], STAT1_CALVCO_STRT, 1); in stv6110x_set_frequency()
154 stv6110x_write_reg(stv6110x, STV6110x_CTRL1, stv6110x->regs[STV6110x_CTRL1]); in stv6110x_set_frequency()
155 stv6110x_write_reg(stv6110x, STV6110x_TNG1, stv6110x->regs[STV6110x_TNG1]); in stv6110x_set_frequency()
156 stv6110x_write_reg(stv6110x, STV6110x_TNG0, stv6110x->regs[STV6110x_TNG0]); in stv6110x_set_frequency()
157 stv6110x_write_reg(stv6110x, STV6110x_STAT1, stv6110x->regs[STV6110x_STAT1]); in stv6110x_set_frequency()
160 stv6110x_read_reg(stv6110x, STV6110x_STAT1, &stv6110x->regs[STV6110x_STAT1]); in stv6110x_set_frequency()
161 if (!STV6110x_GETFIELD(STAT1_CALVCO_STRT, stv6110x->regs[STV6110x_STAT1])) in stv6110x_set_frequency()
171 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_get_frequency() local
173 stv6110x_read_reg(stv6110x, STV6110x_TNG1, &stv6110x->regs[STV6110x_TNG1]); in stv6110x_get_frequency()
174 stv6110x_read_reg(stv6110x, STV6110x_TNG0, &stv6110x->regs[STV6110x_TNG0]); in stv6110x_get_frequency()
176 *frequency = (MAKEWORD16(STV6110x_GETFIELD(TNG1_N_DIV_11_8, stv6110x->regs[STV6110x_TNG1]), in stv6110x_get_frequency()
177 STV6110x_GETFIELD(TNG0_N_DIV_7_0, stv6110x->regs[STV6110x_TNG0]))) * REFCLOCK_kHz; in stv6110x_get_frequency()
179 *frequency /= (1 << (STV6110x_GETFIELD(TNG1_R_DIV, stv6110x->regs[STV6110x_TNG1]) + in stv6110x_get_frequency()
180 STV6110x_GETFIELD(TNG1_DIV4SEL, stv6110x->regs[STV6110x_TNG1]))); in stv6110x_get_frequency()
189 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_set_bandwidth() local
196 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL3], CTRL3_CF, 31); /* LPF */ in stv6110x_set_bandwidth()
198 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL3], CTRL3_CF, 0); /* LPF */ in stv6110x_set_bandwidth()
200 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL3], CTRL3_CF, ((halfbw / 1000000) - 5)); /* LPF */ in stv6110x_set_bandwidth()
203 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL3], CTRL3_RCCLK_OFF, 0x0); /* cal. clk activated */ in stv6110x_set_bandwidth()
204 STV6110x_SETFIELD(stv6110x->regs[STV6110x_STAT1], STAT1_CALRC_STRT, 0x1); /* LPF auto cal */ in stv6110x_set_bandwidth()
206 stv6110x_write_reg(stv6110x, STV6110x_CTRL3, stv6110x->regs[STV6110x_CTRL3]); in stv6110x_set_bandwidth()
207 stv6110x_write_reg(stv6110x, STV6110x_STAT1, stv6110x->regs[STV6110x_STAT1]); in stv6110x_set_bandwidth()
210 stv6110x_read_reg(stv6110x, STV6110x_STAT1, &stv6110x->regs[STV6110x_STAT1]); in stv6110x_set_bandwidth()
211 if (!STV6110x_GETFIELD(STAT1_CALRC_STRT, stv6110x->regs[STV6110x_STAT1])) in stv6110x_set_bandwidth()
215 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL3], CTRL3_RCCLK_OFF, 0x1); /* cal. done */ in stv6110x_set_bandwidth()
216 stv6110x_write_reg(stv6110x, STV6110x_CTRL3, stv6110x->regs[STV6110x_CTRL3]); in stv6110x_set_bandwidth()
223 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_get_bandwidth() local
225 stv6110x_read_reg(stv6110x, STV6110x_CTRL3, &stv6110x->regs[STV6110x_CTRL3]); in stv6110x_get_bandwidth()
226 *bandwidth = (STV6110x_GETFIELD(CTRL3_CF, stv6110x->regs[STV6110x_CTRL3]) + 5) * 2000000; in stv6110x_get_bandwidth()
233 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_set_refclock() local
239 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], CTRL2_CO_DIV, 0); in stv6110x_set_refclock()
242 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], CTRL2_CO_DIV, 1); in stv6110x_set_refclock()
245 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], CTRL2_CO_DIV, 2); in stv6110x_set_refclock()
249 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], CTRL2_CO_DIV, 3); in stv6110x_set_refclock()
252 stv6110x_write_reg(stv6110x, STV6110x_CTRL2, stv6110x->regs[STV6110x_CTRL2]); in stv6110x_set_refclock()
259 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_get_bbgain() local
261 stv6110x_read_reg(stv6110x, STV6110x_CTRL2, &stv6110x->regs[STV6110x_CTRL2]); in stv6110x_get_bbgain()
262 *gain = 2 * STV6110x_GETFIELD(CTRL2_BBGAIN, stv6110x->regs[STV6110x_CTRL2]); in stv6110x_get_bbgain()
269 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_set_bbgain() local
271 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], CTRL2_BBGAIN, gain / 2); in stv6110x_set_bbgain()
272 stv6110x_write_reg(stv6110x, STV6110x_CTRL2, stv6110x->regs[STV6110x_CTRL2]); in stv6110x_set_bbgain()
279 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_set_mode() local
284 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL1], CTRL1_SYN, 0); in stv6110x_set_mode()
285 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL1], CTRL1_RX, 0); in stv6110x_set_mode()
286 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL1], CTRL1_LPT, 0); in stv6110x_set_mode()
290 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL1], CTRL1_SYN, 1); in stv6110x_set_mode()
291 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL1], CTRL1_RX, 1); in stv6110x_set_mode()
292 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL1], CTRL1_LPT, 1); in stv6110x_set_mode()
296 ret = stv6110x_write_reg(stv6110x, STV6110x_CTRL1, stv6110x->regs[STV6110x_CTRL1]); in stv6110x_set_mode()
315 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_get_status() local
317 stv6110x_read_reg(stv6110x, STV6110x_STAT1, &stv6110x->regs[STV6110x_STAT1]); in stv6110x_get_status()
319 if (STV6110x_GETFIELD(STAT1_LOCK, stv6110x->regs[STV6110x_STAT1])) in stv6110x_get_status()
330 struct stv6110x_state *stv6110x = fe->tuner_priv; in stv6110x_release() local
333 kfree(stv6110x); in stv6110x_release()
336 static void st6110x_init_regs(struct stv6110x_state *stv6110x) in st6110x_init_regs() argument
340 memcpy(stv6110x->regs, default_regs, 8); in st6110x_init_regs()
343 static void stv6110x_setup_divider(struct stv6110x_state *stv6110x) in stv6110x_setup_divider() argument
345 switch (stv6110x->config->clk_div) { in stv6110x_setup_divider()
348 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], in stv6110x_setup_divider()
353 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], in stv6110x_setup_divider()
358 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], in stv6110x_setup_divider()
364 STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], in stv6110x_setup_divider()
394 static void stv6110x_set_frontend_opts(struct stv6110x_state *stv6110x) in stv6110x_set_frontend_opts() argument
396 stv6110x->frontend->tuner_priv = stv6110x; in stv6110x_set_frontend_opts()
397 stv6110x->frontend->ops.tuner_ops = stv6110x_ops; in stv6110x_set_frontend_opts()
402 struct stv6110x_state *stv6110x = i2c_get_clientdata(client); in stv6110x_get_devctl() local
406 return stv6110x->devctl; in stv6110x_get_devctl()
413 struct stv6110x_state *stv6110x; in stv6110x_probe() local
415 stv6110x = kzalloc(sizeof(*stv6110x), GFP_KERNEL); in stv6110x_probe()
416 if (!stv6110x) in stv6110x_probe()
419 stv6110x->frontend = config->frontend; in stv6110x_probe()
420 stv6110x->i2c = client->adapter; in stv6110x_probe()
421 stv6110x->config = config; in stv6110x_probe()
422 stv6110x->devctl = &stv6110x_ctl; in stv6110x_probe()
424 st6110x_init_regs(stv6110x); in stv6110x_probe()
425 stv6110x_setup_divider(stv6110x); in stv6110x_probe()
426 stv6110x_set_frontend_opts(stv6110x); in stv6110x_probe()
428 dev_info(&stv6110x->i2c->dev, "Probed STV6110x\n"); in stv6110x_probe()
430 i2c_set_clientdata(client, stv6110x); in stv6110x_probe()
440 struct stv6110x_state *stv6110x = i2c_get_clientdata(client); in stv6110x_remove() local
442 stv6110x_release(stv6110x->frontend); in stv6110x_remove()
449 struct stv6110x_state *stv6110x; in stv6110x_attach() local
451 stv6110x = kzalloc(sizeof(*stv6110x), GFP_KERNEL); in stv6110x_attach()
452 if (!stv6110x) in stv6110x_attach()
455 stv6110x->frontend = fe; in stv6110x_attach()
456 stv6110x->i2c = i2c; in stv6110x_attach()
457 stv6110x->config = config; in stv6110x_attach()
458 stv6110x->devctl = &stv6110x_ctl; in stv6110x_attach()
460 st6110x_init_regs(stv6110x); in stv6110x_attach()
461 stv6110x_setup_divider(stv6110x); in stv6110x_attach()
462 stv6110x_set_frontend_opts(stv6110x); in stv6110x_attach()
464 fe->tuner_priv = stv6110x; in stv6110x_attach()
467 dev_info(&stv6110x->i2c->dev, "Attaching STV6110x\n"); in stv6110x_attach()
468 return stv6110x->devctl; in stv6110x_attach()