Commit 9ba0a3c0 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (7087): tuner-simple: whitespace / comments / codingstyle cleanups

parent 3dc50637
Loading
Loading
Loading
Loading
+78 −60
Original line number Diff line number Diff line
@@ -13,13 +13,13 @@
#include "tuner-i2c.h"
#include "tuner-simple.h"

static int debug = 0;
static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "enable verbose debug messages");

#define PREFIX "tuner-simple"

static int offset = 0;
static int offset;
module_param(offset, int, 0664);
MODULE_PARM_DESC(offset, "Allows to specify an offset for tuner");

@@ -36,8 +36,8 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
 */
#define TEMIC_SET_PAL_I         0x05
#define TEMIC_SET_PAL_DK        0x09
#define TEMIC_SET_PAL_L         0x0a // SECAM ?
#define TEMIC_SET_PAL_L2        0x0b // change IF !
#define TEMIC_SET_PAL_L         0x0a /* SECAM ? */
#define TEMIC_SET_PAL_L2        0x0b /* change IF ! */
#define TEMIC_SET_PAL_BG        0x0c

/* tv tuner system standard selection for Philips FQ1216ME
@@ -219,9 +219,9 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
			continue;
		break;
	}
	/* use default tuner_t_params if desired_type not available */
	/* use default tuner params if desired_type not available */
	if (desired_type != tun->params[j].type) {
		tuner_dbg("IFPCoff = %d: tuner_t_params undefined for tuner %d\n",
		tuner_dbg("IFPCoff = %d: params undefined for tuner %d\n",
			  IFPCoff, priv->type);
		j = 0;
	}
@@ -246,20 +246,21 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,

	div = params->frequency + IFPCoff + offset;

	tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n",
	tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, "
		  "Offset=%d.%02d MHz, div=%0d\n",
		  params->frequency / 16, params->frequency % 16 * 100 / 16,
		  IFPCoff / 16, IFPCoff % 16 * 100 / 16,
					offset / 16, offset % 16 * 100 / 16,
					div);
		  offset / 16, offset % 16 * 100 / 16, div);

	/* tv norm specific stuff for multi-norm tuners */
	switch (priv->type) {
	case TUNER_PHILIPS_SECAM: // FI1216MF
	case TUNER_PHILIPS_SECAM: /* FI1216MF */
		/* 0x01 -> ??? no change ??? */
		/* 0x02 -> PAL BDGHI / SECAM L */
		/* 0x04 -> ??? PAL others / SECAM others ??? */
		cb &= ~0x03;
		if (params->std & V4L2_STD_SECAM_L) //also valid for V4L2_STD_SECAM
		if (params->std & V4L2_STD_SECAM_L)
			/* also valid for V4L2_STD_SECAM */
			cb |= PHILIPS_MF_SET_STD_L;
		else if (params->std & V4L2_STD_SECAM_LC)
			cb |= PHILIPS_MF_SET_STD_LC;
@@ -333,10 +334,14 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
		/* set to the correct mode (analog or digital) */
		tuneraddr = priv->i2c_props.addr;
		priv->i2c_props.addr = 0x0a;
		if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[0],2)))
			tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
		if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[2],2)))
			tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
		rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[0], 2);
		if (2 != rc)
			tuner_warn("i2c i/o error: rc == %d "
				   "(should be 2)\n", rc);
		rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[2], 2);
		if (2 != rc)
			tuner_warn("i2c i/o error: rc == %d "
				   "(should be 2)\n", rc);
		priv->i2c_props.addr = tuneraddr;
		/* FIXME: input */
		break;
@@ -357,8 +362,10 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
	if (t_params->has_tda9887) {
		struct v4l2_priv_tun_config tda9887_cfg;
		int config = 0;
		int is_secam_l = (params->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) &&
			!(params->std & ~(V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC));
		int is_secam_l = (params->std & (V4L2_STD_SECAM_L |
						 V4L2_STD_SECAM_LC)) &&
			!(params->std & ~(V4L2_STD_SECAM_L |
					  V4L2_STD_SECAM_LC));

		tda9887_cfg.tuner = TUNER_TDA9887;
		tda9887_cfg.priv  = &config;
@@ -368,8 +375,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
				config |= TDA9887_PORT1_ACTIVE;
			if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc)
				config |= TDA9887_PORT2_ACTIVE;
		}
		else {
		} else {
			if (t_params->port1_active)
				config |= TDA9887_PORT1_ACTIVE;
			if (t_params->port2_active)
@@ -384,8 +390,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
				config |= TDA9887_TOP(t_params->default_top_secam_mid);
			else if (t_params->default_top_secam_high)
				config |= TDA9887_TOP(t_params->default_top_secam_high);
		}
		else {
		} else {
			if (i == 0 && t_params->default_top_low)
				config |= TDA9887_TOP(t_params->default_top_low);
			else if (i == 1 && t_params->default_top_mid)
@@ -401,7 +406,8 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
	tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
		  buffer[0], buffer[1], buffer[2], buffer[3]);

	if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
	rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
	if (4 != rc)
		tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc);

	switch (priv->type) {
@@ -413,12 +419,14 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
		buffer[1] = 0x20;
		tuner_dbg("tv 0x%02x 0x%02x\n", buffer[0], buffer[1]);

		if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,2)))
			tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
		rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 2);
		if (2 != rc)
			tuner_warn("i2c i/o error: rc == %d "
				   "(should be 2)\n", rc);
		break;
	case TUNER_MICROTUNE_4042FI5:
	{
		// FIXME - this may also work for other tuners
		/* FIXME - this may also work for other tuners */
		unsigned long timeout = jiffies + msecs_to_jiffies(1);
		u8 status_byte = 0;

@@ -426,8 +434,11 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
		for (;;) {
			if (time_after(jiffies, timeout))
				return 0;
			if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,&status_byte,1))) {
				tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
			rc = tuner_i2c_xfer_recv(&priv->i2c_props,
						 &status_byte, 1);
			if (1 != rc) {
				tuner_warn("i2c i/o read error: rc == %d "
					   "(should be 1)\n", rc);
				break;
			}
			if (status_byte & TUNER_PLL_LOCKED)
@@ -444,8 +455,10 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
		tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
			  buffer[0], buffer[1], buffer[2], buffer[3]);

		if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
			tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
		rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
		if (4 != rc)
			tuner_warn("i2c i/o error: rc == %d "
				   "(should be 4)\n", rc);
		break;
	}
	}
@@ -483,7 +496,8 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
		freq += (unsigned int)(41.3*16000);
		break;
	default:
		tuner_warn("Unsupported radio_if value %d\n", t_params->radio_if);
		tuner_warn("Unsupported radio_if value %d\n",
			   t_params->radio_if);
		return 0;
	}

@@ -491,7 +505,8 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
	switch (priv->type) {
	case TUNER_TENA_9533_DI:
	case TUNER_YMEC_TVF_5533MF:
		tuner_dbg("This tuner doesn't have FM. Most cards have a TEA5767 for FM\n");
		tuner_dbg("This tuner doesn't have FM. "
			  "Most cards have a TEA5767 for FM\n");
		return 0;
	case TUNER_PHILIPS_FM1216ME_MK3:
	case TUNER_PHILIPS_FM1236_MK3:
@@ -544,9 +559,11 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
		tda9887_cfg.tuner = TUNER_TDA9887;
		tda9887_cfg.priv = &config;

		if (t_params->port1_active && !t_params->port1_fm_high_sensitivity)
		if (t_params->port1_active &&
		    !t_params->port1_fm_high_sensitivity)
			config |= TDA9887_PORT1_ACTIVE;
		if (t_params->port2_active && !t_params->port2_fm_high_sensitivity)
		if (t_params->port2_active &&
		    !t_params->port2_fm_high_sensitivity)
			config |= TDA9887_PORT2_ACTIVE;
		if (t_params->intercarrier_mode)
			config |= TDA9887_INTERCARRIER;
@@ -559,7 +576,8 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
		i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG,
				    &tda9887_cfg);
	}
	if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
	rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
	if (4 != rc)
		tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc);

	return 0;
@@ -627,16 +645,16 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
	priv->type = cfg->type;
	priv->tun  = cfg->tun;

	memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, sizeof(struct dvb_tuner_ops));
	memcpy(&fe->ops.tuner_ops, &simple_tuner_ops,
	       sizeof(struct dvb_tuner_ops));

	tuner_info("type set to %d (%s)\n", cfg->type, cfg->tun->name);

	strlcpy(fe->ops.tuner_ops.info.name, cfg->tun->name, sizeof(fe->ops.tuner_ops.info.name));
	strlcpy(fe->ops.tuner_ops.info.name, cfg->tun->name,
		sizeof(fe->ops.tuner_ops.info.name));

	return fe;
}


EXPORT_SYMBOL_GPL(simple_tuner_attach);

MODULE_DESCRIPTION("Simple 4-control-bytes style tuner driver");