aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-12-09 14:08:44 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-02-02 14:56:50 -0500
commitdf70ddad81b47c57bcccffc805fbd75f2f1b2dc6 (patch)
tree676d534f4b3d7bdffe3a16e7c1c4d0d0224ebae1
parent6dcfe3cc2e33ecd04987828ccbf56d6eda9a833f (diff)
[media] rtl2830: implement PID filter
Implement PID filter. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/dvb-frontends/rtl2830.c67
-rw-r--r--drivers/media/dvb-frontends/rtl2830.h2
-rw-r--r--drivers/media/dvb-frontends/rtl2830_priv.h1
3 files changed, 70 insertions, 0 deletions
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index f1f1cfb6cb16..8abaca66e132 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -723,6 +723,71 @@ err:
723 dev_dbg(&client->dev, "failed=%d\n", ret); 723 dev_dbg(&client->dev, "failed=%d\n", ret);
724} 724}
725 725
726static int rtl2830_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
727{
728 struct i2c_client *client = fe->demodulator_priv;
729 int ret;
730 u8 u8tmp;
731
732 dev_dbg(&client->dev, "onoff=%d\n", onoff);
733
734 /* enable / disable PID filter */
735 if (onoff)
736 u8tmp = 0x80;
737 else
738 u8tmp = 0x00;
739
740 ret = rtl2830_wr_reg_mask(client, 0x061, u8tmp, 0x80);
741 if (ret)
742 goto err;
743
744 return 0;
745err:
746 dev_dbg(&client->dev, "failed=%d\n", ret);
747 return ret;
748}
749
750static int rtl2830_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid, int onoff)
751{
752 struct i2c_client *client = fe->demodulator_priv;
753 struct rtl2830_dev *dev = i2c_get_clientdata(client);
754 int ret;
755 u8 buf[4];
756
757 dev_dbg(&client->dev, "index=%d pid=%04x onoff=%d\n",
758 index, pid, onoff);
759
760 /* skip invalid PIDs (0x2000) */
761 if (pid > 0x1fff || index > 32)
762 return 0;
763
764 if (onoff)
765 set_bit(index, &dev->filters);
766 else
767 clear_bit(index, &dev->filters);
768
769 /* enable / disable PIDs */
770 buf[0] = (dev->filters >> 0) & 0xff;
771 buf[1] = (dev->filters >> 8) & 0xff;
772 buf[2] = (dev->filters >> 16) & 0xff;
773 buf[3] = (dev->filters >> 24) & 0xff;
774 ret = rtl2830_wr_regs(client, 0x062, buf, 4);
775 if (ret)
776 goto err;
777
778 /* add PID */
779 buf[0] = (pid >> 8) & 0xff;
780 buf[1] = (pid >> 0) & 0xff;
781 ret = rtl2830_wr_regs(client, 0x066 + 2 * index, buf, 2);
782 if (ret)
783 goto err;
784
785 return 0;
786err:
787 dev_dbg(&client->dev, "failed=%d\n", ret);
788 return ret;
789}
790
726/* 791/*
727 * I2C gate/repeater logic 792 * I2C gate/repeater logic
728 * We must use unlocked i2c_transfer() here because I2C lock is already taken 793 * We must use unlocked i2c_transfer() here because I2C lock is already taken
@@ -843,6 +908,8 @@ static int rtl2830_probe(struct i2c_client *client,
843 /* setup callbacks */ 908 /* setup callbacks */
844 pdata->get_dvb_frontend = rtl2830_get_dvb_frontend; 909 pdata->get_dvb_frontend = rtl2830_get_dvb_frontend;
845 pdata->get_i2c_adapter = rtl2830_get_i2c_adapter; 910 pdata->get_i2c_adapter = rtl2830_get_i2c_adapter;
911 pdata->pid_filter = rtl2830_pid_filter;
912 pdata->pid_filter_ctrl = rtl2830_pid_filter_ctrl;
846 913
847 dev_info(&client->dev, "Realtek RTL2830 successfully attached\n"); 914 dev_info(&client->dev, "Realtek RTL2830 successfully attached\n");
848 915
diff --git a/drivers/media/dvb-frontends/rtl2830.h b/drivers/media/dvb-frontends/rtl2830.h
index 61f784c935be..156edf714f9f 100644
--- a/drivers/media/dvb-frontends/rtl2830.h
+++ b/drivers/media/dvb-frontends/rtl2830.h
@@ -49,6 +49,8 @@ struct rtl2830_platform_data {
49 */ 49 */
50 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); 50 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
51 struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *); 51 struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
52 int (*pid_filter)(struct dvb_frontend *, u8, u16, int);
53 int (*pid_filter_ctrl)(struct dvb_frontend *, int);
52}; 54};
53 55
54#endif /* RTL2830_H */ 56#endif /* RTL2830_H */
diff --git a/drivers/media/dvb-frontends/rtl2830_priv.h b/drivers/media/dvb-frontends/rtl2830_priv.h
index 6a0e982584f3..293188924f51 100644
--- a/drivers/media/dvb-frontends/rtl2830_priv.h
+++ b/drivers/media/dvb-frontends/rtl2830_priv.h
@@ -31,6 +31,7 @@ struct rtl2830_dev {
31 struct dvb_frontend fe; 31 struct dvb_frontend fe;
32 bool sleeping; 32 bool sleeping;
33 u8 page; /* active register page */ 33 u8 page; /* active register page */
34 unsigned long filters;
34 struct delayed_work stat_work; 35 struct delayed_work stat_work;
35 fe_status_t fe_status; 36 fe_status_t fe_status;
36 u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */ 37 u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */