return ret;
}
-static struct dvb_frontend_ops rtl2832_ops;
-
-static void rtl2832_release(struct dvb_frontend *fe)
-{
- struct rtl2832_priv *priv = fe->demodulator_priv;
-
- dev_dbg(&priv->i2c->dev, "%s:\n", __func__);
- cancel_delayed_work_sync(&priv->i2c_gate_work);
- i2c_del_mux_adapter(priv->i2c_adapter_tuner);
- i2c_del_mux_adapter(priv->i2c_adapter);
- kfree(priv);
-}
-
/*
* Delay mechanism to avoid unneeded I2C gate open / close. Gate close is
* delayed here a little bit in order to see if there is sequence of I2C
return 0;
}
-int rtl2832_enable_external_ts_if(struct dvb_frontend *fe)
-{
- struct rtl2832_priv *priv = fe->demodulator_priv;
- int ret;
-
- dev_dbg(&priv->i2c->dev, "%s: setting PIP mode\n", __func__);
-
- ret = rtl2832_wr_regs(priv, 0x0c, 1, "\x5f\xff", 2);
- if (ret)
- goto err;
-
- ret = rtl2832_wr_demod_reg(priv, DVBT_PIP_ON, 0x1);
- if (ret)
- goto err;
-
- ret = rtl2832_wr_reg(priv, 0xbc, 0, 0x18);
- if (ret)
- goto err;
-
- ret = rtl2832_wr_reg(priv, 0x22, 0, 0x01);
- if (ret)
- goto err;
-
- ret = rtl2832_wr_reg(priv, 0x26, 0, 0x1f);
- if (ret)
- goto err;
-
- ret = rtl2832_wr_reg(priv, 0x27, 0, 0xff);
- if (ret)
- goto err;
-
- ret = rtl2832_wr_regs(priv, 0x92, 1, "\x7f\xf7\xff", 3);
- if (ret)
- goto err;
-
- /* soft reset */
- ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x1);
- if (ret)
- goto err;
-
- ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x0);
- if (ret)
- goto err;
-
- return 0;
-err:
- dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
- return ret;
-
-}
-EXPORT_SYMBOL(rtl2832_enable_external_ts_if);
-
-struct i2c_adapter *rtl2832_get_i2c_adapter(struct dvb_frontend *fe)
-{
- struct rtl2832_priv *priv = fe->demodulator_priv;
- return priv->i2c_adapter_tuner;
-}
-EXPORT_SYMBOL(rtl2832_get_i2c_adapter);
-
-struct i2c_adapter *rtl2832_get_private_i2c_adapter(struct dvb_frontend *fe)
-{
- struct rtl2832_priv *priv = fe->demodulator_priv;
- return priv->i2c_adapter;
-}
-EXPORT_SYMBOL(rtl2832_get_private_i2c_adapter);
-
-struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg,
- struct i2c_adapter *i2c)
-{
- struct rtl2832_priv *priv = NULL;
- int ret = 0;
- u8 tmp;
-
- dev_dbg(&i2c->dev, "%s:\n", __func__);
-
- /* allocate memory for the internal state */
- priv = kzalloc(sizeof(struct rtl2832_priv), GFP_KERNEL);
- if (priv == NULL)
- goto err;
-
- /* setup the priv */
- priv->i2c = i2c;
- priv->tuner = cfg->tuner;
- memcpy(&priv->cfg, cfg, sizeof(struct rtl2832_config));
- INIT_DELAYED_WORK(&priv->i2c_gate_work, rtl2832_i2c_gate_work);
-
- /* create muxed i2c adapter for demod itself */
- priv->i2c_adapter = i2c_add_mux_adapter(i2c, &i2c->dev, priv, 0, 0, 0,
- rtl2832_select, NULL);
- if (priv->i2c_adapter == NULL)
- goto err;
-
- /* check if the demod is there */
- ret = rtl2832_rd_reg(priv, 0x00, 0x0, &tmp);
- if (ret)
- goto err;
-
- /* create muxed i2c adapter for demod tuner bus */
- priv->i2c_adapter_tuner = i2c_add_mux_adapter(i2c, &i2c->dev, priv,
- 0, 1, 0, rtl2832_select, rtl2832_deselect);
- if (priv->i2c_adapter_tuner == NULL)
- goto err;
-
- /* create dvb_frontend */
- memcpy(&priv->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops));
- priv->fe.demodulator_priv = priv;
-
- /* TODO implement sleep mode */
- priv->sleeping = true;
-
- return &priv->fe;
-err:
- dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret);
- if (priv && priv->i2c_adapter)
- i2c_del_mux_adapter(priv->i2c_adapter);
- kfree(priv);
- return NULL;
-}
-EXPORT_SYMBOL(rtl2832_attach);
-
static struct dvb_frontend_ops rtl2832_ops = {
.delsys = { SYS_DVBT },
.info = {
FE_CAN_MUTE_TS
},
- .release = rtl2832_release,
-
.init = rtl2832_init,
.sleep = rtl2832_sleep,
/* create dvb_frontend */
memcpy(&priv->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops));
- priv->fe.ops.release = NULL;
priv->fe.demodulator_priv = priv;
i2c_set_clientdata(client, priv);
- if (pdata->dvb_frontend)
- *pdata->dvb_frontend = &priv->fe;
/* setup callbacks */
pdata->get_dvb_frontend = rtl2832_get_dvb_frontend;
#ifndef RTL2832_H
#define RTL2832_H
-#include <linux/kconfig.h>
#include <linux/dvb/frontend.h>
struct rtl2832_config {
const struct rtl2832_config *config;
/*
- * frontend
- * returned by driver
- */
- struct dvb_frontend **dvb_frontend;
-
- /*
*/
struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
int (*enable_slave_ts)(struct i2c_client *);
};
-#if IS_ENABLED(CONFIG_DVB_RTL2832)
-struct dvb_frontend *rtl2832_attach(
- const struct rtl2832_config *cfg,
- struct i2c_adapter *i2c
-);
-
-extern struct i2c_adapter *rtl2832_get_i2c_adapter(
- struct dvb_frontend *fe
-);
-
-extern struct i2c_adapter *rtl2832_get_private_i2c_adapter(
- struct dvb_frontend *fe
-);
-
-extern int rtl2832_enable_external_ts_if(
- struct dvb_frontend *fe
-);
-
-#else
-
-static inline struct dvb_frontend *rtl2832_attach(
- const struct rtl2832_config *config,
- struct i2c_adapter *i2c
-)
-{
- pr_warn("%s: driver disabled by Kconfig\n", __func__);
- return NULL;
-}
-
-static inline struct i2c_adapter *rtl2832_get_i2c_adapter(
- struct dvb_frontend *fe
-)
-{
- return NULL;
-}
-
-static inline struct i2c_adapter *rtl2832_get_private_i2c_adapter(
- struct dvb_frontend *fe
-)
-{
- return NULL;
-}
-
-static inline int rtl2832_enable_external_ts_if(
- struct dvb_frontend *fe
-)
-{
- return -ENODEV;
-}
-
-#endif
-
-
#endif /* RTL2832_H */