[media] af9033: implement PID filter
authorAntti Palosaari <crope@iki.fi>
Thu, 13 Feb 2014 18:40:59 +0000 (15:40 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 14 Mar 2014 23:26:25 +0000 (20:26 -0300)
Implement PID filter and export it via symbol.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/dvb-frontends/af9033.c
drivers/media/dvb-frontends/af9033.h

index 65728c25ea05adcd50bd658c96a6c54dd6fb569b..5a1c508c7417b31ad996cd9b247766a71f19dc1a 100644 (file)
@@ -989,6 +989,59 @@ err:
        return ret;
 }
 
+int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
+{
+       struct af9033_state *state = fe->demodulator_priv;
+       int ret;
+
+       dev_dbg(&state->i2c->dev, "%s: onoff=%d\n", __func__, onoff);
+
+       ret = af9033_wr_reg_mask(state, 0x80f993, onoff, 0x01);
+       if (ret < 0)
+               goto err;
+
+       return 0;
+
+err:
+       dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
+
+       return ret;
+}
+EXPORT_SYMBOL(af9033_pid_filter_ctrl);
+
+int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int onoff)
+{
+       struct af9033_state *state = fe->demodulator_priv;
+       int ret;
+       u8 wbuf[2] = {(pid >> 0) & 0xff, (pid >> 8) & 0xff};
+
+       dev_dbg(&state->i2c->dev, "%s: index=%d pid=%04x onoff=%d\n",
+                       __func__, index, pid, onoff);
+
+       if (pid > 0x1fff)
+               return 0;
+
+       ret = af9033_wr_regs(state, 0x80f996, wbuf, 2);
+       if (ret < 0)
+               goto err;
+
+       ret = af9033_wr_reg(state, 0x80f994, onoff);
+       if (ret < 0)
+               goto err;
+
+       ret = af9033_wr_reg(state, 0x80f995, index);
+       if (ret < 0)
+               goto err;
+
+       return 0;
+
+err:
+       dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
+
+       return ret;
+}
+EXPORT_SYMBOL(af9033_pid_filter);
+
 static struct dvb_frontend_ops af9033_ops;
 
 struct dvb_frontend *af9033_attach(const struct af9033_config *config,
index c286e8f1ec02aab4a3da92f03780bcdd559ff7b1..de245f9adb652e539952466cfa6a17f8ad962b6f 100644 (file)
@@ -81,6 +81,11 @@ struct af9033_config {
 #if IS_ENABLED(CONFIG_DVB_AF9033)
 extern struct dvb_frontend *af9033_attach(const struct af9033_config *config,
        struct i2c_adapter *i2c);
+
+extern int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff);
+
+extern int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid,
+       int onoff);
 #else
 static inline struct dvb_frontend *af9033_attach(
        const struct af9033_config *config, struct i2c_adapter *i2c)
@@ -88,6 +93,20 @@ static inline struct dvb_frontend *af9033_attach(
        pr_warn("%s: driver disabled by Kconfig\n", __func__);
        return NULL;
 }
+
+static inline int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
+{
+       pr_warn("%s: driver disabled by Kconfig\n", __func__);
+       return -ENODEV;
+}
+
+static inline int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid,
+       int onoff)
+{
+       pr_warn("%s: driver disabled by Kconfig\n", __func__);
+       return -ENODEV;
+}
+
 #endif
 
 #endif /* AF9033_H */