From 021cd2d21b5d68d6e7c1edb468e990e1c0caf6fb Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Fri, 5 Dec 2014 21:25:33 -0300 Subject: [PATCH] [media] mn88472: add ts mode and ts clock to driver Signed-off-by: Benjamin Larsson Reviewed-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/mn88472.h | 12 +++++++++++ drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 ++ drivers/staging/media/mn88472/mn88472.c | 30 ++++++++++++++++++++++++++-- drivers/staging/media/mn88472/mn88472_priv.h | 2 ++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/mn88472.h b/drivers/media/dvb-frontends/mn88472.h index e4e0b80..095294d 100644 --- a/drivers/media/dvb-frontends/mn88472.h +++ b/drivers/media/dvb-frontends/mn88472.h @@ -19,6 +19,16 @@ #include +enum ts_clock { + VARIABLE_TS_CLOCK, + FIXED_TS_CLOCK, +}; + +enum ts_mode { + SERIAL_TS_MODE, + PARALLEL_TS_MODE, +}; + struct mn88472_config { /* * Max num of bytes given I2C adapter could write at once. @@ -39,6 +49,8 @@ struct mn88472_config { * Hz */ u32 xtal; + int ts_mode; + int ts_clock; }; #endif diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index ea75b3a..1091ea6 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -868,6 +868,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) mn88472_config.i2c_wr_max = 22, strlcpy(info.type, "mn88472", I2C_NAME_SIZE); mn88472_config.xtal = 20500000; + mn88472_config.ts_mode = SERIAL_TS_MODE; + mn88472_config.ts_clock = VARIABLE_TS_CLOCK; info.addr = 0x18; info.platform_data = &mn88472_config; request_module(info.type); diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index 44edcf6..ed379ab 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -178,8 +178,32 @@ static int mn88472_set_frontend(struct dvb_frontend *fe) ret = regmap_write(dev->regmap[0], 0x46, 0x00); ret = regmap_write(dev->regmap[0], 0xae, 0x00); - ret = regmap_write(dev->regmap[2], 0x08, 0x1d); - ret = regmap_write(dev->regmap[0], 0xd9, 0xe3); + + switch (dev->ts_mode) { + case SERIAL_TS_MODE: + ret = regmap_write(dev->regmap[2], 0x08, 0x1d); + break; + case PARALLEL_TS_MODE: + ret = regmap_write(dev->regmap[2], 0x08, 0x00); + break; + default: + dev_dbg(&client->dev, "ts_mode error: %d\n", dev->ts_mode); + ret = -EINVAL; + goto err; + } + + switch (dev->ts_clock) { + case VARIABLE_TS_CLOCK: + ret = regmap_write(dev->regmap[0], 0xd9, 0xe3); + break; + case FIXED_TS_CLOCK: + ret = regmap_write(dev->regmap[0], 0xd9, 0xe1); + break; + default: + dev_dbg(&client->dev, "ts_clock error: %d\n", dev->ts_clock); + ret = -EINVAL; + goto err; + } /* Reset demod */ ret = regmap_write(dev->regmap[2], 0xf8, 0x9f); @@ -439,6 +463,8 @@ static int mn88472_probe(struct i2c_client *client, dev->i2c_wr_max = config->i2c_wr_max; dev->xtal = config->xtal; + dev->ts_mode = config->ts_mode; + dev->ts_clock = config->ts_clock; dev->client[0] = client; dev->regmap[0] = regmap_init_i2c(dev->client[0], ®map_config); if (IS_ERR(dev->regmap[0])) { diff --git a/drivers/staging/media/mn88472/mn88472_priv.h b/drivers/staging/media/mn88472/mn88472_priv.h index b12b731..9ba8c8b 100644 --- a/drivers/staging/media/mn88472/mn88472_priv.h +++ b/drivers/staging/media/mn88472/mn88472_priv.h @@ -32,6 +32,8 @@ struct mn88472_dev { fe_delivery_system_t delivery_system; bool warm; /* FW running */ u32 xtal; + int ts_mode; + int ts_clock; }; #endif -- 2.7.4