Lines Matching refs:dev

20 static int fc2580_wr_reg_ff(struct fc2580_dev *dev, u8 reg, u8 val)  in fc2580_wr_reg_ff()  argument
25 return regmap_write(dev->regmap, reg, val); in fc2580_wr_reg_ff()
28 static int fc2580_set_params(struct fc2580_dev *dev) in fc2580_set_params() argument
30 struct i2c_client *client = dev->client; in fc2580_set_params()
37 if (!dev->active) { in fc2580_set_params()
38 dev_dbg(&client->dev, "tuner is sleeping\n"); in fc2580_set_params()
58 if (dev->f_frequency <= fc2580_pll_lut[i].freq) in fc2580_set_params()
67 #define F_REF dev->clk in fc2580_set_params()
69 f_vco = (u64) dev->f_frequency * div_out; in fc2580_set_params()
94 dev_dbg(&client->dev, in fc2580_set_params()
96 dev->f_frequency, dev->f_bandwidth, f_vco, F_REF, div_ref, in fc2580_set_params()
99 ret = regmap_write(dev->regmap, 0x02, synth_config); in fc2580_set_params()
103 ret = regmap_write(dev->regmap, 0x18, div_ref_val << 0 | k_cw >> 16); in fc2580_set_params()
107 ret = regmap_write(dev->regmap, 0x1a, (k_cw >> 8) & 0xff); in fc2580_set_params()
111 ret = regmap_write(dev->regmap, 0x1b, (k_cw >> 0) & 0xff); in fc2580_set_params()
115 ret = regmap_write(dev->regmap, 0x1c, div_n); in fc2580_set_params()
121 if (dev->f_frequency <= fc2580_freq_regs_lut[i].freq) in fc2580_set_params()
129 ret = fc2580_wr_reg_ff(dev, 0x25, fc2580_freq_regs_lut[i].r25_val); in fc2580_set_params()
133 ret = fc2580_wr_reg_ff(dev, 0x27, fc2580_freq_regs_lut[i].r27_val); in fc2580_set_params()
137 ret = fc2580_wr_reg_ff(dev, 0x28, fc2580_freq_regs_lut[i].r28_val); in fc2580_set_params()
141 ret = fc2580_wr_reg_ff(dev, 0x29, fc2580_freq_regs_lut[i].r29_val); in fc2580_set_params()
145 ret = fc2580_wr_reg_ff(dev, 0x2b, fc2580_freq_regs_lut[i].r2b_val); in fc2580_set_params()
149 ret = fc2580_wr_reg_ff(dev, 0x2c, fc2580_freq_regs_lut[i].r2c_val); in fc2580_set_params()
153 ret = fc2580_wr_reg_ff(dev, 0x2d, fc2580_freq_regs_lut[i].r2d_val); in fc2580_set_params()
157 ret = fc2580_wr_reg_ff(dev, 0x30, fc2580_freq_regs_lut[i].r30_val); in fc2580_set_params()
161 ret = fc2580_wr_reg_ff(dev, 0x44, fc2580_freq_regs_lut[i].r44_val); in fc2580_set_params()
165 ret = fc2580_wr_reg_ff(dev, 0x50, fc2580_freq_regs_lut[i].r50_val); in fc2580_set_params()
169 ret = fc2580_wr_reg_ff(dev, 0x53, fc2580_freq_regs_lut[i].r53_val); in fc2580_set_params()
173 ret = fc2580_wr_reg_ff(dev, 0x5f, fc2580_freq_regs_lut[i].r5f_val); in fc2580_set_params()
177 ret = fc2580_wr_reg_ff(dev, 0x61, fc2580_freq_regs_lut[i].r61_val); in fc2580_set_params()
181 ret = fc2580_wr_reg_ff(dev, 0x62, fc2580_freq_regs_lut[i].r62_val); in fc2580_set_params()
185 ret = fc2580_wr_reg_ff(dev, 0x63, fc2580_freq_regs_lut[i].r63_val); in fc2580_set_params()
189 ret = fc2580_wr_reg_ff(dev, 0x67, fc2580_freq_regs_lut[i].r67_val); in fc2580_set_params()
193 ret = fc2580_wr_reg_ff(dev, 0x68, fc2580_freq_regs_lut[i].r68_val); in fc2580_set_params()
197 ret = fc2580_wr_reg_ff(dev, 0x69, fc2580_freq_regs_lut[i].r69_val); in fc2580_set_params()
201 ret = fc2580_wr_reg_ff(dev, 0x6a, fc2580_freq_regs_lut[i].r6a_val); in fc2580_set_params()
205 ret = fc2580_wr_reg_ff(dev, 0x6b, fc2580_freq_regs_lut[i].r6b_val); in fc2580_set_params()
209 ret = fc2580_wr_reg_ff(dev, 0x6c, fc2580_freq_regs_lut[i].r6c_val); in fc2580_set_params()
213 ret = fc2580_wr_reg_ff(dev, 0x6d, fc2580_freq_regs_lut[i].r6d_val); in fc2580_set_params()
217 ret = fc2580_wr_reg_ff(dev, 0x6e, fc2580_freq_regs_lut[i].r6e_val); in fc2580_set_params()
221 ret = fc2580_wr_reg_ff(dev, 0x6f, fc2580_freq_regs_lut[i].r6f_val); in fc2580_set_params()
227 if (dev->f_bandwidth <= fc2580_if_filter_lut[i].freq) in fc2580_set_params()
235 ret = regmap_write(dev->regmap, 0x36, fc2580_if_filter_lut[i].r36_val); in fc2580_set_params()
239 uitmp = (unsigned int) 8058000 - (dev->f_bandwidth * 122 / 100 / 2); in fc2580_set_params()
240 uitmp = div64_u64((u64) dev->clk * uitmp, 1000000000000ULL); in fc2580_set_params()
241 ret = regmap_write(dev->regmap, 0x37, uitmp); in fc2580_set_params()
245 ret = regmap_write(dev->regmap, 0x39, fc2580_if_filter_lut[i].r39_val); in fc2580_set_params()
252 ret = regmap_write(dev->regmap, 0x2e, 0x09); in fc2580_set_params()
257 ret = regmap_read(dev->regmap, 0x2f, &uitmp); in fc2580_set_params()
262 ret = regmap_write(dev->regmap, 0x2e, 0x01); in fc2580_set_params()
267 dev_dbg(&client->dev, "filter did not lock %02x\n", uitmp); in fc2580_set_params()
271 dev_dbg(&client->dev, "failed=%d\n", ret); in fc2580_set_params()
275 static int fc2580_init(struct fc2580_dev *dev) in fc2580_init() argument
277 struct i2c_client *client = dev->client; in fc2580_init()
280 dev_dbg(&client->dev, "\n"); in fc2580_init()
283 ret = regmap_write(dev->regmap, fc2580_init_reg_vals[i].reg, in fc2580_init()
289 dev->active = true; in fc2580_init()
292 dev_dbg(&client->dev, "failed=%d\n", ret); in fc2580_init()
296 static int fc2580_sleep(struct fc2580_dev *dev) in fc2580_sleep() argument
298 struct i2c_client *client = dev->client; in fc2580_sleep()
301 dev_dbg(&client->dev, "\n"); in fc2580_sleep()
303 dev->active = false; in fc2580_sleep()
305 ret = regmap_write(dev->regmap, 0x02, 0x0a); in fc2580_sleep()
310 dev_dbg(&client->dev, "failed=%d\n", ret); in fc2580_sleep()
319 struct fc2580_dev *dev = fe->tuner_priv; in fc2580_dvb_set_params() local
322 dev->f_frequency = c->frequency; in fc2580_dvb_set_params()
323 dev->f_bandwidth = c->bandwidth_hz; in fc2580_dvb_set_params()
324 return fc2580_set_params(dev); in fc2580_dvb_set_params()
378 struct fc2580_dev *dev = fc2580_subdev_to_dev(sd); in fc2580_standby() local
381 ret = fc2580_sleep(dev); in fc2580_standby()
385 return fc2580_set_params(dev); in fc2580_standby()
390 struct fc2580_dev *dev = fc2580_subdev_to_dev(sd); in fc2580_g_tuner() local
391 struct i2c_client *client = dev->client; in fc2580_g_tuner()
393 dev_dbg(&client->dev, "index=%d\n", v->index); in fc2580_g_tuner()
405 struct fc2580_dev *dev = fc2580_subdev_to_dev(sd); in fc2580_s_tuner() local
406 struct i2c_client *client = dev->client; in fc2580_s_tuner()
408 dev_dbg(&client->dev, "index=%d\n", v->index); in fc2580_s_tuner()
414 struct fc2580_dev *dev = fc2580_subdev_to_dev(sd); in fc2580_g_frequency() local
415 struct i2c_client *client = dev->client; in fc2580_g_frequency()
417 dev_dbg(&client->dev, "tuner=%d\n", f->tuner); in fc2580_g_frequency()
418 f->frequency = dev->f_frequency; in fc2580_g_frequency()
425 struct fc2580_dev *dev = fc2580_subdev_to_dev(sd); in fc2580_s_frequency() local
426 struct i2c_client *client = dev->client; in fc2580_s_frequency()
428 dev_dbg(&client->dev, "tuner=%d type=%d frequency=%u\n", in fc2580_s_frequency()
431 dev->f_frequency = clamp_t(unsigned int, f->frequency, in fc2580_s_frequency()
433 return fc2580_set_params(dev); in fc2580_s_frequency()
439 struct fc2580_dev *dev = fc2580_subdev_to_dev(sd); in fc2580_enum_freq_bands() local
440 struct i2c_client *client = dev->client; in fc2580_enum_freq_bands()
442 dev_dbg(&client->dev, "tuner=%d type=%d index=%d\n", in fc2580_enum_freq_bands()
469 struct fc2580_dev *dev = container_of(ctrl->handler, struct fc2580_dev, hdl); in fc2580_s_ctrl() local
470 struct i2c_client *client = dev->client; in fc2580_s_ctrl()
473 dev_dbg(&client->dev, "ctrl: id=%d name=%s cur.val=%d val=%d\n", in fc2580_s_ctrl()
484 dev->f_bandwidth = dev->bandwidth->val; in fc2580_s_ctrl()
485 ret = fc2580_set_params(dev); in fc2580_s_ctrl()
488 dev_dbg(&client->dev, "unknown ctrl"); in fc2580_s_ctrl()
501 struct fc2580_dev *dev = i2c_get_clientdata(client); in fc2580_get_v4l2_subdev() local
503 if (dev->subdev.ops) in fc2580_get_v4l2_subdev()
504 return &dev->subdev; in fc2580_get_v4l2_subdev()
511 struct fc2580_dev *dev; in fc2580_probe() local
512 struct fc2580_platform_data *pdata = client->dev.platform_data; in fc2580_probe()
521 dev = kzalloc(sizeof(*dev), GFP_KERNEL); in fc2580_probe()
522 if (!dev) { in fc2580_probe()
528 dev->clk = pdata->clk; in fc2580_probe()
530 dev->clk = 16384000; /* internal clock */ in fc2580_probe()
531 dev->client = client; in fc2580_probe()
532 dev->regmap = devm_regmap_init_i2c(client, &regmap_config); in fc2580_probe()
533 if (IS_ERR(dev->regmap)) { in fc2580_probe()
534 ret = PTR_ERR(dev->regmap); in fc2580_probe()
539 ret = regmap_read(dev->regmap, 0x01, &uitmp); in fc2580_probe()
543 dev_dbg(&client->dev, "chip_id=%02x\n", uitmp); in fc2580_probe()
556 v4l2_ctrl_handler_init(&dev->hdl, 2); in fc2580_probe()
557 dev->bandwidth_auto = v4l2_ctrl_new_std(&dev->hdl, &fc2580_ctrl_ops, in fc2580_probe()
560 dev->bandwidth = v4l2_ctrl_new_std(&dev->hdl, &fc2580_ctrl_ops, in fc2580_probe()
563 v4l2_ctrl_auto_cluster(2, &dev->bandwidth_auto, 0, false); in fc2580_probe()
564 if (dev->hdl.error) { in fc2580_probe()
565 ret = dev->hdl.error; in fc2580_probe()
566 dev_err(&client->dev, "Could not initialize controls\n"); in fc2580_probe()
567 v4l2_ctrl_handler_free(&dev->hdl); in fc2580_probe()
570 dev->subdev.ctrl_handler = &dev->hdl; in fc2580_probe()
571 dev->f_frequency = bands[0].rangelow; in fc2580_probe()
572 dev->f_bandwidth = dev->bandwidth->val; in fc2580_probe()
573 v4l2_i2c_subdev_init(&dev->subdev, client, &fc2580_subdev_ops); in fc2580_probe()
575 fe->tuner_priv = dev; in fc2580_probe()
579 i2c_set_clientdata(client, dev); in fc2580_probe()
581 dev_info(&client->dev, "FCI FC2580 successfully identified\n"); in fc2580_probe()
584 kfree(dev); in fc2580_probe()
586 dev_dbg(&client->dev, "failed=%d\n", ret); in fc2580_probe()
592 struct fc2580_dev *dev = i2c_get_clientdata(client); in fc2580_remove() local
594 dev_dbg(&client->dev, "\n"); in fc2580_remove()
597 v4l2_ctrl_handler_free(&dev->hdl); in fc2580_remove()
599 kfree(dev); in fc2580_remove()