media: af9013: add pid filter support

af9013 demod has pid filter. Add support for it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Antti Palosaari 2017-06-26 04:57:09 -04:00 committed by Mauro Carvalho Chehab
parent 12c6b22fbf
commit 83d6b7c327
2 changed files with 57 additions and 0 deletions

View file

@ -1171,6 +1171,56 @@ static const struct dvb_frontend_ops af9013_ops = {
.read_ucblocks = af9013_read_ucblocks, .read_ucblocks = af9013_read_ucblocks,
}; };
static int af9013_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
{
struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret;
dev_dbg(&client->dev, "onoff %d\n", onoff);
ret = regmap_update_bits(state->regmap, 0xd503, 0x01, onoff);
if (ret)
goto err;
return 0;
err:
dev_dbg(&client->dev, "failed %d\n", ret);
return ret;
}
static int af9013_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid,
int onoff)
{
struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client;
int ret;
u8 buf[2];
dev_dbg(&client->dev, "index %d, pid %04x, onoff %d\n",
index, pid, onoff);
if (pid > 0x1fff) {
/* 0x2000 is kernel virtual pid for whole ts (all pids) */
ret = 0;
goto err;
}
buf[0] = (pid >> 0) & 0xff;
buf[1] = (pid >> 8) & 0xff;
ret = regmap_bulk_write(state->regmap, 0xd505, buf, 2);
if (ret)
goto err;
ret = regmap_write(state->regmap, 0xd504, onoff << 5 | index << 0);
if (ret)
goto err;
return 0;
err:
dev_dbg(&client->dev, "failed %d\n", ret);
return ret;
}
static struct dvb_frontend *af9013_get_dvb_frontend(struct i2c_client *client) static struct dvb_frontend *af9013_get_dvb_frontend(struct i2c_client *client)
{ {
struct af9013_state *state = i2c_get_clientdata(client); struct af9013_state *state = i2c_get_clientdata(client);
@ -1473,6 +1523,8 @@ static int af9013_probe(struct i2c_client *client,
/* Setup callbacks */ /* Setup callbacks */
pdata->get_dvb_frontend = af9013_get_dvb_frontend; pdata->get_dvb_frontend = af9013_get_dvb_frontend;
pdata->get_i2c_adapter = af9013_get_i2c_adapter; pdata->get_i2c_adapter = af9013_get_i2c_adapter;
pdata->pid_filter = af9013_pid_filter;
pdata->pid_filter_ctrl = af9013_pid_filter_ctrl;
/* Init stats to indicate which stats are supported */ /* Init stats to indicate which stats are supported */
c = &state->fe.dtv_property_cache; c = &state->fe.dtv_property_cache;

View file

@ -38,6 +38,9 @@
* @api_version: Firmware API version. * @api_version: Firmware API version.
* @gpio: GPIOs. * @gpio: GPIOs.
* @get_dvb_frontend: Get DVB frontend callback. * @get_dvb_frontend: Get DVB frontend callback.
* @get_i2c_adapter: Get I2C adapter.
* @pid_filter_ctrl: Control PID filter.
* @pid_filter: Set PID to PID filter.
*/ */
struct af9013_platform_data { struct af9013_platform_data {
/* /*
@ -78,6 +81,8 @@ struct af9013_platform_data {
struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *); struct i2c_adapter* (*get_i2c_adapter)(struct i2c_client *);
int (*pid_filter_ctrl)(struct dvb_frontend *, int);
int (*pid_filter)(struct dvb_frontend *, u8, u16, int);
}; };
/* /*