Lines Matching refs:dev
143 static int rtl2832_rd_demod_reg(struct rtl2832_dev *dev, int reg, u32 *val) in rtl2832_rd_demod_reg() argument
145 struct i2c_client *client = dev->client; in rtl2832_rd_demod_reg()
157 ret = regmap_bulk_read(dev->regmap, reg_start_addr, reading, len); in rtl2832_rd_demod_reg()
169 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_rd_demod_reg()
173 static int rtl2832_wr_demod_reg(struct rtl2832_dev *dev, int reg, u32 val) in rtl2832_wr_demod_reg() argument
175 struct i2c_client *client = dev->client; in rtl2832_wr_demod_reg()
187 ret = regmap_bulk_read(dev->regmap, reg_start_addr, reading, len); in rtl2832_wr_demod_reg()
201 ret = regmap_bulk_write(dev->regmap, reg_start_addr, writing, len); in rtl2832_wr_demod_reg()
207 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_wr_demod_reg()
213 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_set_if() local
214 struct i2c_client *client = dev->client; in rtl2832_set_if()
223 pset_iffreq = if_freq % dev->pdata->clk; in rtl2832_set_if()
225 pset_iffreq = div_u64(pset_iffreq, dev->pdata->clk); in rtl2832_set_if()
228 dev_dbg(&client->dev, "if_frequency=%d pset_iffreq=%08x\n", in rtl2832_set_if()
231 ret = rtl2832_wr_demod_reg(dev, DVBT_EN_BBIN, en_bbin); in rtl2832_set_if()
235 ret = rtl2832_wr_demod_reg(dev, DVBT_PSET_IFFREQ, pset_iffreq); in rtl2832_set_if()
241 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_set_if()
247 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_init() local
248 struct i2c_client *client = dev->client; in rtl2832_init()
249 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; in rtl2832_init()
298 dev_dbg(&client->dev, "\n"); in rtl2832_init()
300 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x0); in rtl2832_init()
305 ret = rtl2832_wr_demod_reg(dev, rtl2832_initial_regs[i].reg, in rtl2832_init()
312 dev_dbg(&client->dev, "load settings for tuner=%02x\n", in rtl2832_init()
313 dev->pdata->tuner); in rtl2832_init()
314 switch (dev->pdata->tuner) { in rtl2832_init()
347 ret = rtl2832_wr_demod_reg(dev, init[i].reg, init[i].value); in rtl2832_init()
361 dev->sleeping = false; in rtl2832_init()
365 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_init()
371 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_sleep() local
372 struct i2c_client *client = dev->client; in rtl2832_sleep()
375 dev_dbg(&client->dev, "\n"); in rtl2832_sleep()
377 dev->sleeping = true; in rtl2832_sleep()
378 dev->fe_status = 0; in rtl2832_sleep()
380 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1); in rtl2832_sleep()
386 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_sleep()
393 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_get_tune_settings() local
394 struct i2c_client *client = dev->client; in rtl2832_get_tune_settings()
396 dev_dbg(&client->dev, "\n"); in rtl2832_get_tune_settings()
405 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_set_frontend() local
406 struct i2c_client *client = dev->client; in rtl2832_set_frontend()
437 dev_dbg(&client->dev, "frequency=%u bandwidth_hz=%u inversion=%u\n", in rtl2832_set_frontend()
471 dev_err(&client->dev, "invalid bandwidth_hz %u\n", in rtl2832_set_frontend()
478 ret = regmap_bulk_write(dev->regmap, in rtl2832_set_frontend()
488 num = dev->pdata->clk * 7ULL; in rtl2832_set_frontend()
492 ret = rtl2832_wr_demod_reg(dev, DVBT_RSAMP_RATIO, resamp_ratio); in rtl2832_set_frontend()
501 num2 = dev->pdata->clk * 7ULL; in rtl2832_set_frontend()
505 ret = rtl2832_wr_demod_reg(dev, DVBT_CFREQ_OFF_RATIO, cfreq_off_ratio); in rtl2832_set_frontend()
510 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1); in rtl2832_set_frontend()
514 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x0); in rtl2832_set_frontend()
520 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_set_frontend()
527 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_get_frontend() local
528 struct i2c_client *client = dev->client; in rtl2832_get_frontend()
532 if (dev->sleeping) in rtl2832_get_frontend()
535 ret = regmap_bulk_read(dev->regmap, 0x33c, buf, 2); in rtl2832_get_frontend()
539 ret = regmap_bulk_read(dev->regmap, 0x351, &buf[2], 1); in rtl2832_get_frontend()
543 dev_dbg(&client->dev, "TPS=%*ph\n", 3, buf); in rtl2832_get_frontend()
633 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_get_frontend()
639 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_read_status() local
640 struct i2c_client *client = dev->client; in rtl2832_read_status()
647 dev_dbg(&client->dev, "\n"); in rtl2832_read_status()
650 if (dev->sleeping) in rtl2832_read_status()
653 ret = rtl2832_rd_demod_reg(dev, DVBT_FSM_STAGE, &tmp); in rtl2832_read_status()
665 dev->fe_status = *status; in rtl2832_read_status()
668 if (dev->fe_status & FE_HAS_SIGNAL) { in rtl2832_read_status()
670 ret = regmap_bulk_read(dev->regmap, 0x305, &u8tmp, 1); in rtl2832_read_status()
674 dev_dbg(&client->dev, "digital agc=%02x", u8tmp); in rtl2832_read_status()
686 if (dev->fe_status & FE_HAS_VITERBI) { in rtl2832_read_status()
696 ret = regmap_bulk_read(dev->regmap, 0x33c, &u8tmp, 1); in rtl2832_read_status()
709 ret = regmap_bulk_read(dev->regmap, 0x40c, buf, 2); in rtl2832_read_status()
720 dev_dbg(&client->dev, "cnr raw=%u\n", u16tmp); in rtl2832_read_status()
729 if (dev->fe_status & FE_HAS_LOCK) { in rtl2832_read_status()
730 ret = regmap_bulk_read(dev->regmap, 0x34e, buf, 2); in rtl2832_read_status()
735 dev->post_bit_error += u16tmp; in rtl2832_read_status()
736 dev->post_bit_count += 1000000; in rtl2832_read_status()
738 dev_dbg(&client->dev, "ber errors=%u total=1000000\n", u16tmp); in rtl2832_read_status()
741 c->post_bit_error.stat[0].uvalue = dev->post_bit_error; in rtl2832_read_status()
743 c->post_bit_count.stat[0].uvalue = dev->post_bit_count; in rtl2832_read_status()
751 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_read_status()
770 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_read_ber() local
772 *ber = (dev->post_bit_error - dev->post_bit_error_prev); in rtl2832_read_ber()
773 dev->post_bit_error_prev = dev->post_bit_error; in rtl2832_read_ber()
786 struct rtl2832_dev *dev = container_of(work, struct rtl2832_dev, i2c_gate_work.work); in rtl2832_i2c_gate_work() local
787 struct i2c_client *client = dev->client; in rtl2832_i2c_gate_work()
791 ret = regmap_update_bits(dev->regmap, 0x101, 0x08, 0x00); in rtl2832_i2c_gate_work()
797 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_i2c_gate_work()
802 struct rtl2832_dev *dev = i2c_mux_priv(muxc); in rtl2832_select() local
803 struct i2c_client *client = dev->client; in rtl2832_select()
807 cancel_delayed_work(&dev->i2c_gate_work); in rtl2832_select()
810 ret = regmap_update_bits(dev->regmap, 0x101, 0x08, 0x08); in rtl2832_select()
816 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_select()
822 struct rtl2832_dev *dev = i2c_mux_priv(muxc); in rtl2832_deselect() local
824 schedule_delayed_work(&dev->i2c_gate_work, usecs_to_jiffies(100)); in rtl2832_deselect()
865 static bool rtl2832_volatile_reg(struct device *dev, unsigned int reg) in rtl2832_volatile_reg() argument
883 struct rtl2832_dev *dev = i2c_get_clientdata(client); in rtl2832_get_dvb_frontend() local
885 dev_dbg(&client->dev, "\n"); in rtl2832_get_dvb_frontend()
886 return &dev->fe; in rtl2832_get_dvb_frontend()
891 struct rtl2832_dev *dev = i2c_get_clientdata(client); in rtl2832_get_i2c_adapter() local
893 dev_dbg(&client->dev, "\n"); in rtl2832_get_i2c_adapter()
894 return dev->muxc->adapter[0]; in rtl2832_get_i2c_adapter()
899 struct rtl2832_dev *dev = i2c_get_clientdata(client); in rtl2832_slave_ts_ctrl() local
902 dev_dbg(&client->dev, "enable=%d\n", enable); in rtl2832_slave_ts_ctrl()
905 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x0); in rtl2832_slave_ts_ctrl()
908 ret = regmap_bulk_write(dev->regmap, 0x10c, "\x5f\xff", 2); in rtl2832_slave_ts_ctrl()
911 ret = rtl2832_wr_demod_reg(dev, DVBT_PIP_ON, 0x1); in rtl2832_slave_ts_ctrl()
914 ret = regmap_bulk_write(dev->regmap, 0x0bc, "\x18", 1); in rtl2832_slave_ts_ctrl()
917 ret = regmap_bulk_write(dev->regmap, 0x192, "\x7f\xf7\xff", 3); in rtl2832_slave_ts_ctrl()
921 ret = regmap_bulk_write(dev->regmap, 0x192, "\x00\x0f\xff", 3); in rtl2832_slave_ts_ctrl()
924 ret = regmap_bulk_write(dev->regmap, 0x0bc, "\x08", 1); in rtl2832_slave_ts_ctrl()
927 ret = rtl2832_wr_demod_reg(dev, DVBT_PIP_ON, 0x0); in rtl2832_slave_ts_ctrl()
930 ret = regmap_bulk_write(dev->regmap, 0x10c, "\x00\x00", 2); in rtl2832_slave_ts_ctrl()
933 ret = rtl2832_wr_demod_reg(dev, DVBT_SOFT_RST, 0x1); in rtl2832_slave_ts_ctrl()
938 dev->slave_ts = enable; in rtl2832_slave_ts_ctrl()
942 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_slave_ts_ctrl()
948 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_pid_filter_ctrl() local
949 struct i2c_client *client = dev->client; in rtl2832_pid_filter_ctrl()
953 dev_dbg(&client->dev, "onoff=%d, slave_ts=%d\n", onoff, dev->slave_ts); in rtl2832_pid_filter_ctrl()
961 if (dev->slave_ts) in rtl2832_pid_filter_ctrl()
962 ret = regmap_update_bits(dev->regmap, 0x021, 0xc0, u8tmp); in rtl2832_pid_filter_ctrl()
964 ret = regmap_update_bits(dev->regmap, 0x061, 0xc0, u8tmp); in rtl2832_pid_filter_ctrl()
970 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_pid_filter_ctrl()
977 struct rtl2832_dev *dev = fe->demodulator_priv; in rtl2832_pid_filter() local
978 struct i2c_client *client = dev->client; in rtl2832_pid_filter()
982 dev_dbg(&client->dev, "index=%d pid=%04x onoff=%d slave_ts=%d\n", in rtl2832_pid_filter()
983 index, pid, onoff, dev->slave_ts); in rtl2832_pid_filter()
990 set_bit(index, &dev->filters); in rtl2832_pid_filter()
992 clear_bit(index, &dev->filters); in rtl2832_pid_filter()
995 buf[0] = (dev->filters >> 0) & 0xff; in rtl2832_pid_filter()
996 buf[1] = (dev->filters >> 8) & 0xff; in rtl2832_pid_filter()
997 buf[2] = (dev->filters >> 16) & 0xff; in rtl2832_pid_filter()
998 buf[3] = (dev->filters >> 24) & 0xff; in rtl2832_pid_filter()
1000 if (dev->slave_ts) in rtl2832_pid_filter()
1001 ret = regmap_bulk_write(dev->regmap, 0x022, buf, 4); in rtl2832_pid_filter()
1003 ret = regmap_bulk_write(dev->regmap, 0x062, buf, 4); in rtl2832_pid_filter()
1011 if (dev->slave_ts) in rtl2832_pid_filter()
1012 ret = regmap_bulk_write(dev->regmap, 0x026 + 2 * index, buf, 2); in rtl2832_pid_filter()
1014 ret = regmap_bulk_write(dev->regmap, 0x066 + 2 * index, buf, 2); in rtl2832_pid_filter()
1020 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_pid_filter()
1026 struct rtl2832_platform_data *pdata = client->dev.platform_data; in rtl2832_probe()
1028 struct rtl2832_dev *dev; in rtl2832_probe() local
1043 dev_dbg(&client->dev, "\n"); in rtl2832_probe()
1046 dev = kzalloc(sizeof(struct rtl2832_dev), GFP_KERNEL); in rtl2832_probe()
1047 if (dev == NULL) { in rtl2832_probe()
1053 i2c_set_clientdata(client, dev); in rtl2832_probe()
1054 dev->client = client; in rtl2832_probe()
1055 dev->pdata = client->dev.platform_data; in rtl2832_probe()
1056 dev->sleeping = true; in rtl2832_probe()
1057 INIT_DELAYED_WORK(&dev->i2c_gate_work, rtl2832_i2c_gate_work); in rtl2832_probe()
1059 dev->regmap_config.reg_bits = 8; in rtl2832_probe()
1060 dev->regmap_config.val_bits = 8; in rtl2832_probe()
1061 dev->regmap_config.volatile_reg = rtl2832_volatile_reg; in rtl2832_probe()
1062 dev->regmap_config.max_register = 5 * 0x100; in rtl2832_probe()
1063 dev->regmap_config.ranges = regmap_range_cfg; in rtl2832_probe()
1064 dev->regmap_config.num_ranges = ARRAY_SIZE(regmap_range_cfg); in rtl2832_probe()
1065 dev->regmap_config.cache_type = REGCACHE_NONE; in rtl2832_probe()
1066 dev->regmap = regmap_init_i2c(client, &dev->regmap_config); in rtl2832_probe()
1067 if (IS_ERR(dev->regmap)) { in rtl2832_probe()
1068 ret = PTR_ERR(dev->regmap); in rtl2832_probe()
1073 ret = regmap_bulk_read(dev->regmap, 0x000, &tmp, 1); in rtl2832_probe()
1078 dev->muxc = i2c_mux_alloc(i2c, &i2c->dev, 1, 0, I2C_MUX_LOCKED, in rtl2832_probe()
1080 if (!dev->muxc) { in rtl2832_probe()
1084 dev->muxc->priv = dev; in rtl2832_probe()
1085 ret = i2c_mux_add_adapter(dev->muxc, 0, 0, 0); in rtl2832_probe()
1090 memcpy(&dev->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops)); in rtl2832_probe()
1091 dev->fe.demodulator_priv = dev; in rtl2832_probe()
1099 pdata->regmap = dev->regmap; in rtl2832_probe()
1101 dev_info(&client->dev, "Realtek RTL2832 successfully attached\n"); in rtl2832_probe()
1104 regmap_exit(dev->regmap); in rtl2832_probe()
1106 kfree(dev); in rtl2832_probe()
1108 dev_dbg(&client->dev, "failed=%d\n", ret); in rtl2832_probe()
1114 struct rtl2832_dev *dev = i2c_get_clientdata(client); in rtl2832_remove() local
1116 dev_dbg(&client->dev, "\n"); in rtl2832_remove()
1118 cancel_delayed_work_sync(&dev->i2c_gate_work); in rtl2832_remove()
1120 i2c_mux_del_adapters(dev->muxc); in rtl2832_remove()
1122 regmap_exit(dev->regmap); in rtl2832_remove()
1124 kfree(dev); in rtl2832_remove()