diff options
Diffstat (limited to 'drivers/media/dvb-frontends/rtl2832.c')
-rw-r--r-- | drivers/media/dvb-frontends/rtl2832.c | 69 |
1 files changed, 69 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 | ||
1148 | static 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; | ||
1168 | err: | ||
1169 | dev_dbg(&client->dev, "failed=%d\n", ret); | ||
1170 | return ret; | ||
1171 | } | ||
1172 | |||
1173 | static 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; | ||
1210 | err: | ||
1211 | dev_dbg(&client->dev, "failed=%d\n", ret); | ||
1212 | return ret; | ||
1213 | } | ||
1214 | |||
1148 | static int rtl2832_probe(struct i2c_client *client, | 1215 | static 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; |