aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-12-14 12:07:35 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-02-03 13:09:56 -0500
commit4b01e01a81b6629878344430531ced347cc2ed5b (patch)
treec9ae0f7a1efc926e841d9e7eb640942ed0de373f /drivers/media
parent1c7da405c6f7def830258349bccdfb96eebcdc61 (diff)
[media] rtl2832: implement PID filter
Implement PID filter. This demod has PID filter size of 32 PIDs. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c69
-rw-r--r--drivers/media/dvb-frontends/rtl2832.h2
-rw-r--r--drivers/media/dvb-frontends/rtl2832_priv.h1
3 files changed, 72 insertions, 0 deletions
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 6bcec7506064..e59765fa8e7c 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -1145,6 +1145,73 @@ err:
1145 return ret; 1145 return ret;
1146} 1146}
1147 1147
1148static int rtl2832_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
1149{
1150 struct rtl2832_dev *dev = fe->demodulator_priv;
1151 struct i2c_client *client = dev->client;
1152 int ret;
1153 u8 u8tmp;
1154
1155 dev_dbg(&client->dev, "onoff=%d\n", onoff);
1156
1157 /* enable / disable PID filter */
1158 if (onoff)
1159 u8tmp = 0x80;
1160 else
1161 u8tmp = 0x00;
1162
1163 ret = rtl2832_update_bits(client, 0x061, 0xc0, u8tmp);
1164 if (ret)
1165 goto err;
1166
1167 return 0;
1168err:
1169 dev_dbg(&client->dev, "failed=%d\n", ret);
1170 return ret;
1171}
1172
1173static int rtl2832_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid,
1174 int onoff)
1175{
1176 struct rtl2832_dev *dev = fe->demodulator_priv;
1177 struct i2c_client *client = dev->client;
1178 int ret;
1179 u8 buf[4];
1180
1181 dev_dbg(&client->dev, "index=%d pid=%04x onoff=%d\n",
1182 index, pid, onoff);
1183
1184 /* skip invalid PIDs (0x2000) */
1185 if (pid > 0x1fff || index > 32)
1186 return 0;
1187
1188 if (onoff)
1189 set_bit(index, &dev->filters);
1190 else
1191 clear_bit(index, &dev->filters);
1192
1193 /* enable / disable PIDs */
1194 buf[0] = (dev->filters >> 0) & 0xff;
1195 buf[1] = (dev->filters >> 8) & 0xff;
1196 buf[2] = (dev->filters >> 16) & 0xff;
1197 buf[3] = (dev->filters >> 24) & 0xff;
1198 ret = rtl2832_bulk_write(client, 0x062, buf, 4);
1199 if (ret)
1200 goto err;
1201
1202 /* add PID */
1203 buf[0] = (pid >> 8) & 0xff;
1204 buf[1] = (pid >> 0) & 0xff;
1205 ret = rtl2832_bulk_write(client, 0x066 + 2 * index, buf, 2);
1206 if (ret)
1207 goto err;
1208
1209 return 0;
1210err:
1211 dev_dbg(&client->dev, "failed=%d\n", ret);
1212 return ret;
1213}
1214
1148static int rtl2832_probe(struct i2c_client *client, 1215static int rtl2832_probe(struct i2c_client *client,
1149 const struct i2c_device_id *id) 1216 const struct i2c_device_id *id)
1150{ 1217{
@@ -1235,6 +1302,8 @@ static int rtl2832_probe(struct i2c_client *client,
1235 pdata->get_i2c_adapter = rtl2832_get_i2c_adapter_; 1302 pdata->get_i2c_adapter = rtl2832_get_i2c_adapter_;
1236 pdata->get_private_i2c_adapter = rtl2832_get_private_i2c_adapter_; 1303 pdata->get_private_i2c_adapter = rtl2832_get_private_i2c_adapter_;
1237 pdata->enable_slave_ts = rtl2832_enable_slave_ts; 1304 pdata->enable_slave_ts = rtl2832_enable_slave_ts;
1305 pdata->pid_filter = rtl2832_pid_filter;
1306 pdata->pid_filter_ctrl = rtl2832_pid_filter_ctrl;
1238 1307
1239 dev_info(&client->dev, "Realtek RTL2832 successfully attached\n"); 1308 dev_info(&client->dev, "Realtek RTL2832 successfully attached\n");
1240 return 0; 1309 return 0;
diff --git a/drivers/media/dvb-frontends/rtl2832.h b/drivers/media/dvb-frontends/rtl2832.h
index 35e86e6bc751..e79c479d6127 100644
--- a/drivers/media/dvb-frontends/rtl2832.h
+++ b/drivers/media/dvb-frontends/rtl2832.h
@@ -78,6 +78,8 @@ struct rtl2832_platform_data {
78 struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *); 78 struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
79 struct i2c_adapter* (*get_private_i2c_adapter)(struct i2c_client *); 79 struct i2c_adapter* (*get_private_i2c_adapter)(struct i2c_client *);
80 int (*enable_slave_ts)(struct i2c_client *); 80 int (*enable_slave_ts)(struct i2c_client *);
81 int (*pid_filter)(struct dvb_frontend *, u8, u16, int);
82 int (*pid_filter_ctrl)(struct dvb_frontend *, int);
81}; 83};
82 84
83#endif /* RTL2832_H */ 85#endif /* RTL2832_H */
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h
index 6f3fe77e8ec5..216e905763d4 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -41,6 +41,7 @@ struct rtl2832_dev {
41 u64 post_bit_count; 41 u64 post_bit_count;
42 bool sleeping; 42 bool sleeping;
43 struct delayed_work i2c_gate_work; 43 struct delayed_work i2c_gate_work;
44 unsigned long filters; /* PID filter */
44}; 45};
45 46
46struct rtl2832_reg_entry { 47struct rtl2832_reg_entry {