Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 465433fa authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab
Browse files

[media] tua9001: various minor changes



Fix logging. Style issues. Rename things.

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 96676239
Loading
Loading
Loading
Loading
+75 −78
Original line number Diff line number Diff line
@@ -12,35 +12,30 @@
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "tua9001.h"
#include "tua9001_priv.h"

/* write register */
static int tua9001_wr_reg(struct tua9001_priv *priv, u8 reg, u16 val)
static int tua9001_wr_reg(struct tua9001_dev *dev, u8 reg, u16 val)
{
	struct i2c_client *client = dev->client;
	int ret;
	u8 buf[3] = { reg, (val >> 8) & 0xff, (val >> 0) & 0xff };
	struct i2c_msg msg[1] = {
		{
			.addr = priv->i2c_addr,
			.addr = client->addr,
			.flags = 0,
			.len = sizeof(buf),
			.buf = buf,
		}
	};

	ret = i2c_transfer(priv->i2c, msg, 1);
	ret = i2c_transfer(client->adapter, msg, 1);
	if (ret == 1) {
		ret = 0;
	} else {
		dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x\n",
				KBUILD_MODNAME, ret, reg);
		dev_warn(&client->dev, "i2c wr failed=%d reg=%02x\n", ret, reg);
		ret = -EREMOTEIO;
	}

@@ -49,10 +44,10 @@ static int tua9001_wr_reg(struct tua9001_priv *priv, u8 reg, u16 val)

static int tua9001_init(struct dvb_frontend *fe)
{
	struct tua9001_priv *priv = fe->tuner_priv;
	int ret = 0;
	u8 i;
	struct reg_val data[] = {
	struct tua9001_dev *dev = fe->tuner_priv;
	struct i2c_client *client = dev->client;
	int ret, i;
	static const struct tua9001_reg_val data[] = {
		{0x1e, 0x6512},
		{0x25, 0xb888},
		{0x39, 0x5460},
@@ -70,55 +65,60 @@ static int tua9001_init(struct dvb_frontend *fe)
		{0x34, 0x0a40},
	};

	dev_dbg(&priv->i2c->dev, "%s:\n", __func__);
	dev_dbg(&client->dev, "\n");

	if (fe->callback) {
		ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
		ret = fe->callback(client->adapter,
				   DVB_FRONTEND_COMPONENT_TUNER,
				   TUA9001_CMD_RESETN, 0);
		if (ret < 0)
		if (ret)
			goto err;
	}

	for (i = 0; i < ARRAY_SIZE(data); i++) {
		ret = tua9001_wr_reg(priv, data[i].reg, data[i].val);
		if (ret < 0)
		ret = tua9001_wr_reg(dev, data[i].reg, data[i].val);
		if (ret)
			goto err;
	}
	return 0;
err:
	if (ret < 0)
		dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);

	dev_dbg(&client->dev, "failed=%d\n", ret);
	return ret;
}

static int tua9001_sleep(struct dvb_frontend *fe)
{
	struct tua9001_priv *priv = fe->tuner_priv;
	int ret = 0;
	struct tua9001_dev *dev = fe->tuner_priv;
	struct i2c_client *client = dev->client;
	int ret;

	dev_dbg(&priv->i2c->dev, "%s:\n", __func__);
	dev_dbg(&client->dev, "\n");

	if (fe->callback)
		ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
	if (fe->callback) {
		ret = fe->callback(client->adapter,
				   DVB_FRONTEND_COMPONENT_TUNER,
				   TUA9001_CMD_RESETN, 1);

	if (ret < 0)
		dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);

		if (ret)
			goto err;
	}
	return 0;
err:
	dev_dbg(&client->dev, "failed=%d\n", ret);
	return ret;
}

static int tua9001_set_params(struct dvb_frontend *fe)
{
	struct tua9001_priv *priv = fe->tuner_priv;
	struct tua9001_dev *dev = fe->tuner_priv;
	struct i2c_client *client = dev->client;
	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
	int ret = 0, i;
	int ret, i;
	u16 val;
	u32 frequency;
	struct reg_val data[2];
	struct tua9001_reg_val data[2];

	dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d frequency=%d " \
			"bandwidth_hz=%d\n", __func__,
	dev_dbg(&client->dev,
		"delivery_system=%u frequency=%u bandwidth_hz=%u\n",
		c->delivery_system, c->frequency, c->bandwidth_hz);

	switch (c->delivery_system) {
@@ -158,49 +158,48 @@ static int tua9001_set_params(struct dvb_frontend *fe)
	data[1].val = frequency;

	if (fe->callback) {
		ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
		ret = fe->callback(client->adapter,
				   DVB_FRONTEND_COMPONENT_TUNER,
				   TUA9001_CMD_RXEN, 0);
		if (ret < 0)
		if (ret)
			goto err;
	}

	for (i = 0; i < ARRAY_SIZE(data); i++) {
		ret = tua9001_wr_reg(priv, data[i].reg, data[i].val);
		if (ret < 0)
		ret = tua9001_wr_reg(dev, data[i].reg, data[i].val);
		if (ret)
			goto err;
	}

	if (fe->callback) {
		ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
		ret = fe->callback(client->adapter,
				   DVB_FRONTEND_COMPONENT_TUNER,
				   TUA9001_CMD_RXEN, 1);
		if (ret < 0)
		if (ret)
			goto err;
	}
	return 0;
err:
	if (ret < 0)
		dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);

	dev_dbg(&client->dev, "failed=%d\n", ret);
	return ret;
}

static int tua9001_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
{
	struct tua9001_priv *priv = fe->tuner_priv;
	struct tua9001_dev *dev = fe->tuner_priv;
	struct i2c_client *client = dev->client;

	dev_dbg(&priv->i2c->dev, "%s:\n", __func__);
	dev_dbg(&client->dev, "\n");

	*frequency = 0; /* Zero-IF */

	return 0;
}

static const struct dvb_tuner_ops tua9001_tuner_ops = {
	.info = {
		.name           = "Infineon TUA9001",

		.frequency_min  = 170000000,
		.frequency_max  = 862000000,
		.frequency_step = 0,
	},

	.init = tua9001_init,
@@ -213,7 +212,7 @@ static const struct dvb_tuner_ops tua9001_tuner_ops = {
static int tua9001_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct tua9001_priv *dev;
	struct tua9001_dev *dev;
	struct tua9001_platform_data *pdata = client->dev.platform_data;
	struct dvb_frontend *fe = pdata->dvb_frontend;
	int ret;
@@ -225,8 +224,6 @@ static int tua9001_probe(struct i2c_client *client,
	}

	dev->client = client;
	dev->i2c_addr = client->addr;
	dev->i2c = client->adapter;
	dev->fe = pdata->dvb_frontend;

	if (fe->callback) {
@@ -265,7 +262,7 @@ static int tua9001_probe(struct i2c_client *client,

static int tua9001_remove(struct i2c_client *client)
{
	struct tua9001_priv *dev = i2c_get_clientdata(client);
	struct tua9001_dev *dev = i2c_get_clientdata(client);
	struct dvb_frontend *fe = dev->fe;
	int ret;

+1 −5
Original line number Diff line number Diff line
@@ -12,10 +12,6 @@
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef TUA9001_H
+6 −10
Original line number Diff line number Diff line
@@ -12,25 +12,21 @@
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef TUA9001_PRIV_H
#define TUA9001_PRIV_H

struct reg_val {
#include "tua9001.h"

struct tua9001_reg_val {
	u8 reg;
	u16 val;
};

struct tua9001_priv {
	struct i2c_client *client;
	struct i2c_adapter *i2c;
	u8 i2c_addr;
struct tua9001_dev {
	struct dvb_frontend *fe;
	struct i2c_client *client;
};

#endif
+1 −1

File changed.

Contains only whitespace changes.