/* write multiple hardware registers */
static int rtl2832_wr(struct rtl2832_dev *dev, u8 reg, u8 *val, int len)
{
+ struct i2c_client *client = dev->client;
int ret;
u8 buf[MAX_XFER_SIZE];
struct i2c_msg msg[1] = {
};
if (1 + len > sizeof(buf)) {
- dev_warn(&dev->i2c->dev,
- "%s: i2c wr reg=%04x: len=%d is too big!\n",
- KBUILD_MODNAME, reg, len);
+ dev_warn(&client->dev, "i2c wr reg=%04x: len=%d is too big!\n",
+ reg, len);
return -EINVAL;
}
if (ret == 1) {
ret = 0;
} else {
- dev_warn(&dev->i2c->dev,
- "%s: i2c wr failed=%d reg=%02x len=%d\n",
- KBUILD_MODNAME, ret, reg, len);
+ dev_warn(&client->dev, "i2c wr failed=%d reg=%02x len=%d\n",
+ ret, reg, len);
ret = -EREMOTEIO;
}
return ret;
/* read multiple hardware registers */
static int rtl2832_rd(struct rtl2832_dev *dev, u8 reg, u8 *val, int len)
{
+ struct i2c_client *client = dev->client;
int ret;
struct i2c_msg msg[2] = {
{
if (ret == 2) {
ret = 0;
} else {
- dev_warn(&dev->i2c->dev,
- "%s: i2c rd failed=%d reg=%02x len=%d\n",
- KBUILD_MODNAME, ret, reg, len);
+ dev_warn(&client->dev, "i2c rd failed=%d reg=%02x len=%d\n",
+ ret, reg, len);
ret = -EREMOTEIO;
}
return ret;
return ret;
dev->page = page;
-}
-
-return rtl2832_wr(dev, reg, val, len);
+ }
+ return rtl2832_wr(dev, reg, val, len);
}
/* read multiple registers */
dev->page = page;
}
-
return rtl2832_rd(dev, reg, val, len);
}
static int rtl2832_rd_demod_reg(struct rtl2832_dev *dev, int reg, u32 *val)
{
+ struct i2c_client *client = dev->client;
int ret;
u8 reg_start_addr;
return ret;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_wr_demod_reg(struct rtl2832_dev *dev, int reg, u32 val)
{
+ struct i2c_client *client = dev->client;
int ret, i;
u8 len;
u8 reg_start_addr;
return ret;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{
- int ret;
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
+ int ret;
- dev_dbg(&dev->i2c->dev, "%s: enable=%d\n", __func__, enable);
+ dev_dbg(&client->dev, "enable=%d\n", enable);
/* gate already open or close */
if (dev->i2c_gate_state == enable)
return ret;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_set_if(struct dvb_frontend *fe, u32 if_freq)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
int ret;
u64 pset_iffreq;
u8 en_bbin = (if_freq == 0 ? 0x1 : 0x0);
pset_iffreq = div_u64(pset_iffreq, dev->cfg.xtal);
pset_iffreq = -pset_iffreq;
pset_iffreq = pset_iffreq & 0x3fffff;
- dev_dbg(&dev->i2c->dev, "%s: if_frequency=%d pset_iffreq=%08x\n",
- __func__, if_freq, (unsigned)pset_iffreq);
+ dev_dbg(&client->dev, "if_frequency=%d pset_iffreq=%08x\n",
+ if_freq, (unsigned)pset_iffreq);
ret = rtl2832_wr_demod_reg(dev, DVBT_EN_BBIN, en_bbin);
if (ret)
static int rtl2832_init(struct dvb_frontend *fe)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
const struct rtl2832_reg_value *init;
int i, ret, len;
-
/* initialization values for the demodulator registers */
struct rtl2832_reg_value rtl2832_initial_regs[] = {
{DVBT_AD_EN_REG, 0x1},
{DVBT_CR_THD_SET2, 0x1},
};
- dev_dbg(&dev->i2c->dev, "%s:\n", __func__);
+ dev_dbg(&client->dev, "\n");
for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) {
ret = rtl2832_wr_demod_reg(dev, rtl2832_initial_regs[i].reg,
}
/* load tuner specific settings */
- dev_dbg(&dev->i2c->dev, "%s: load settings for tuner=%02x\n",
- __func__, dev->cfg.tuner);
+ dev_dbg(&client->dev, "load settings for tuner=%02x\n", dev->cfg.tuner);
switch (dev->cfg.tuner) {
case RTL2832_TUNER_FC0012:
case RTL2832_TUNER_FC0013:
return ret;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_sleep(struct dvb_frontend *fe)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
- dev_dbg(&dev->i2c->dev, "%s:\n", __func__);
+ dev_dbg(&client->dev, "\n");
dev->sleeping = true;
return 0;
}
struct dvb_frontend_tune_settings *s)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
- dev_dbg(&dev->i2c->dev, "%s:\n", __func__);
+ dev_dbg(&client->dev, "\n");
s->min_delay_ms = 1000;
s->step_size = fe->ops.info.frequency_stepsize * 2;
s->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1;
static int rtl2832_set_frontend(struct dvb_frontend *fe)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret, i, j;
u64 bw_mode, num, num2;
};
- dev_dbg(&dev->i2c->dev,
- "%s: frequency=%d bandwidth_hz=%d inversion=%d\n",
- __func__, c->frequency, c->bandwidth_hz, c->inversion);
+ dev_dbg(&client->dev, "frequency=%u bandwidth_hz=%u inversion=%u\n",
+ c->frequency, c->bandwidth_hz, c->inversion);
/* program tuner */
if (fe->ops.tuner_ops.set_params)
bw_mode = 64000000;
break;
default:
- dev_dbg(&dev->i2c->dev, "%s: invalid bandwidth\n", __func__);
- return -EINVAL;
+ dev_err(&client->dev, "invalid bandwidth_hz %u\n",
+ c->bandwidth_hz);
+ ret = -EINVAL;
+ goto err;
}
for (j = 0; j < sizeof(bw_params[0]); j++) {
return ret;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_get_frontend(struct dvb_frontend *fe)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret;
u8 buf[3];
if (ret)
goto err;
- dev_dbg(&dev->i2c->dev, "%s: TPS=%*ph\n", __func__, 3, buf);
+ dev_dbg(&client->dev, "TPS=%*ph\n", 3, buf);
switch ((buf[0] >> 2) & 3) {
case 0:
return 0;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_read_status(struct dvb_frontend *fe, fe_status_t *status)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
int ret;
u32 tmp;
- *status = 0;
- dev_dbg(&dev->i2c->dev, "%s:\n", __func__);
+ dev_dbg(&client->dev, "\n");
+
+ *status = 0;
if (dev->sleeping)
return 0;
return ret;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
int ret, hierarchy, constellation;
u8 buf[2], tmp;
u16 tmp16;
return 0;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber)
{
struct rtl2832_dev *dev = fe->demodulator_priv;
+ struct i2c_client *client = dev->client;
int ret;
u8 buf[2];
return 0;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
{
struct rtl2832_dev *dev = container_of(work,
struct rtl2832_dev, i2c_gate_work.work);
+ struct i2c_client *client = dev->client;
struct i2c_adapter *adap = dev->i2c;
int ret;
u8 buf[2];
}
};
+ dev_dbg(&client->dev, "\n");
+
/* select reg bank 1 */
buf[0] = 0x00;
buf[1] = 0x01;
return;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
-
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return;
}
static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
{
struct rtl2832_dev *dev = mux_priv;
+ struct i2c_client *client = dev->client;
int ret;
u8 buf[2], val;
struct i2c_msg msg[1] = {
return 0;
err:
- dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
-
+ dev_dbg(&client->dev, "failed=%d\n", ret);
return -EREMOTEIO;
}
u32 chan_id)
{
struct rtl2832_dev *dev = mux_priv;
+
schedule_delayed_work(&dev->i2c_gate_work, usecs_to_jiffies(100));
return 0;
}
struct rtl2832_dev *dev = i2c_get_clientdata(client);
int ret;
- dev_dbg(&client->dev, "setting PIP mode\n");
+ dev_dbg(&client->dev, "\n");
ret = rtl2832_wr_regs(dev, 0x0c, 1, "\x5f\xff", 2);
if (ret)