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

Commit 44af747f authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab
Browse files

[media] it913x: get rid of it913x config struct



We don't need it. Tuner ID and device address are enough.

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d19812eb
Loading
Loading
Loading
Loading
+23 −15
Original line number Original line Diff line number Diff line
@@ -25,7 +25,8 @@
struct it913x_state {
struct it913x_state {
	struct dvb_frontend frontend;
	struct dvb_frontend frontend;
	struct i2c_adapter *i2c_adap;
	struct i2c_adapter *i2c_adap;
	struct ite_config *config;
	u8 chip_ver;
	u8 firmware_ver;
	u8 i2c_addr;
	u8 i2c_addr;
	u32 frequency;
	u32 frequency;
	fe_modulation_t constellation;
	fe_modulation_t constellation;
@@ -156,7 +157,7 @@ static int it913x_init(struct dvb_frontend *fe)
	u8 b[2];
	u8 b[2];


	/* v1 or v2 tuner script */
	/* v1 or v2 tuner script */
	if (state->config->chip_ver > 1)
	if (state->chip_ver > 1)
		ret = it913x_script_loader(state, it9135_v2);
		ret = it913x_script_loader(state, it9135_v2);
	else
	else
		ret = it913x_script_loader(state, it9135_v1);
		ret = it913x_script_loader(state, it9135_v1);
@@ -190,7 +191,7 @@ static int it913x_init(struct dvb_frontend *fe)
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;


	if (state->config->chip_ver == 2) {
	if (state->chip_ver == 2) {
		ret = it913x_wr_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x1);
		ret = it913x_wr_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x1);
		if (ret < 0)
		if (ret < 0)
			return -ENODEV;
			return -ENODEV;
@@ -237,7 +238,7 @@ static int it913x_init(struct dvb_frontend *fe)
	state->tun_fn_min /= (state->tun_fdiv * nv_val);
	state->tun_fn_min /= (state->tun_fdiv * nv_val);
	pr_debug("Tuner fn_min %d\n", state->tun_fn_min);
	pr_debug("Tuner fn_min %d\n", state->tun_fn_min);


	if (state->config->chip_ver > 1)
	if (state->chip_ver > 1)
		msleep(50);
		msleep(50);
	else {
	else {
		for (i = 0; i < 50; i++) {
		for (i = 0; i < 50; i++) {
@@ -276,7 +277,7 @@ static int it9137_set_params(struct dvb_frontend *fe)
	u8 lna_band;
	u8 lna_band;
	u8 bw;
	u8 bw;


	if (state->config->firmware_ver == 1)
	if (state->firmware_ver == 1)
		set_tuner = set_it9135_template;
		set_tuner = set_it9135_template;
	else
	else
		set_tuner = set_it9137_template;
		set_tuner = set_it9137_template;
@@ -440,40 +441,47 @@ static const struct dvb_tuner_ops it913x_tuner_ops = {
};
};


struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
	struct i2c_adapter *i2c_adap, u8 i2c_addr, struct ite_config *config)
		struct i2c_adapter *i2c_adap, u8 i2c_addr, u8 config)
{
{
	struct it913x_state *state = NULL;
	struct it913x_state *state = NULL;
	int ret;


	/* allocate memory for the internal state */
	/* allocate memory for the internal state */
	state = kzalloc(sizeof(struct it913x_state), GFP_KERNEL);
	state = kzalloc(sizeof(struct it913x_state), GFP_KERNEL);
	if (state == NULL)
	if (state == NULL)
		return NULL;
		return NULL;
	if (config == NULL)
		goto error;


	state->i2c_adap = i2c_adap;
	state->i2c_adap = i2c_adap;
	state->i2c_addr = i2c_addr;
	state->i2c_addr = i2c_addr;
	state->config = config;


	switch (state->config->tuner_id_0) {
	switch (config) {
	case IT9135_38:
	case IT9135_51:
	case IT9135_51:
	case IT9135_52:
	case IT9135_52:
		state->chip_ver = 0x01;
		break;
	case IT9135_60:
	case IT9135_60:
	case IT9135_61:
	case IT9135_61:
	case IT9135_62:
	case IT9135_62:
		state->tuner_type = state->config->tuner_id_0;
		state->chip_ver = 0x02;
		break;
		break;
	default:
	default:
	case IT9135_38:
		dev_dbg(&i2c_adap->dev,
		state->tuner_type = IT9135_38;
				"%s: invalid config=%02x\n", __func__, config);
		goto error;
	}
	}


	state->tuner_type = config;
	state->firmware_ver = 1;

	fe->tuner_priv = state;
	fe->tuner_priv = state;
	memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops,
	memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops,
			sizeof(struct dvb_tuner_ops));
			sizeof(struct dvb_tuner_ops));


	pr_info("%s: ITE Tech IT913X attached\n", KBUILD_MODNAME);
	dev_info(&i2c_adap->dev,
			"%s: ITE Tech IT913X successfully attached\n",
			KBUILD_MODNAME);
	dev_dbg(&i2c_adap->dev, "%s: config=%02x chip_ver=%02x\n",
			__func__, config, state->chip_ver);


	return fe;
	return fe;
error:
error:
+6 −16
Original line number Original line Diff line number Diff line
@@ -25,27 +25,17 @@


#include "dvb_frontend.h"
#include "dvb_frontend.h"


struct ite_config {
	u8 chip_ver;
	u16 chip_type;
	u32 firmware;
	u8 firmware_ver;
	u8 adc_x2;
	u8 tuner_id_0;
	u8 tuner_id_1;
	u8 dual_mode;
	u8 adf;
	/* option to read SIGNAL_LEVEL */
	u8 read_slevel;
};

#if defined(CONFIG_MEDIA_TUNER_IT913X) || \
#if defined(CONFIG_MEDIA_TUNER_IT913X) || \
	(defined(CONFIG_MEDIA_TUNER_IT913X_MODULE) && defined(MODULE))
	(defined(CONFIG_MEDIA_TUNER_IT913X_MODULE) && defined(MODULE))
extern struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
extern struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
	struct i2c_adapter *i2c_adap, u8 i2c_addr, struct ite_config *config);
	struct i2c_adapter *i2c_adap,
	u8 i2c_addr,
	u8 config);
#else
#else
static inline struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
static inline struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
	struct i2c_adapter *i2c_adap, u8 i2c_addr, struct ite_config *config)
	struct i2c_adapter *i2c_adap,
	u8 i2c_addr,
	u8 config)
{
{
	pr_warn("%s: driver disabled by Kconfig\n", __func__);
	pr_warn("%s: driver disabled by Kconfig\n", __func__);
	return NULL;
	return NULL;
+1 −17
Original line number Original line Diff line number Diff line
@@ -978,20 +978,6 @@ static const struct fc0012_config af9035_fc0012_config[] = {
	}
	}
};
};


static struct ite_config af9035_it913x_config = {
	.chip_ver = 0x02,
	.chip_type = 0x9135,
	.firmware = 0x00000000,
	.firmware_ver = 1,
	.adc_x2 = 1,
	.tuner_id_0 = 0x00,
	.tuner_id_1 = 0x00,
	.dual_mode = 0x00,
	.adf = 0x00,
	/* option to read SIGNAL_LEVEL */
	.read_slevel = 0,
};

static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
{
{
	struct state *state = adap_to_priv(adap);
	struct state *state = adap_to_priv(adap);
@@ -1159,15 +1145,13 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
	case AF9033_TUNER_IT9135_38:
	case AF9033_TUNER_IT9135_38:
	case AF9033_TUNER_IT9135_51:
	case AF9033_TUNER_IT9135_51:
	case AF9033_TUNER_IT9135_52:
	case AF9033_TUNER_IT9135_52:
		af9035_it913x_config.chip_ver = 0x01;
	case AF9033_TUNER_IT9135_60:
	case AF9033_TUNER_IT9135_60:
	case AF9033_TUNER_IT9135_61:
	case AF9033_TUNER_IT9135_61:
	case AF9033_TUNER_IT9135_62:
	case AF9033_TUNER_IT9135_62:
		af9035_it913x_config.tuner_id_0 = state->af9033_config[0].tuner;
		/* attach tuner */
		/* attach tuner */
		fe = dvb_attach(it913x_attach, adap->fe[0], &d->i2c_adap,
		fe = dvb_attach(it913x_attach, adap->fe[0], &d->i2c_adap,
				state->af9033_config[adap->id].i2c_addr,
				state->af9033_config[adap->id].i2c_addr,
				&af9035_it913x_config);
				state->af9033_config[0].tuner);
		break;
		break;
	default:
	default:
		fe = NULL;
		fe = NULL;