Commit 107063c6 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (10714): zoran et al: convert zoran i2c modules to V4L2.



The zoran i2c modules were still using V4L1 internally. Replace this
with V4L2. Also deleted saa7111.c and saa7114.c, we use saa7115.c instead.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
[mchehab@redhat.com: fix v4l2_ctrl_query_fill_std merge conflict]
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 84c1b094
Loading
Loading
Loading
Loading
+4 −24
Original line number Diff line number Diff line
@@ -307,38 +307,18 @@ config VIDEO_TCM825X

config VIDEO_SAA7110
	tristate "Philips SAA7110 video decoder"
	depends on VIDEO_V4L1 && I2C
	depends on VIDEO_V4L2 && I2C
	---help---
	  Support for the Philips SAA7110 video decoders.

	  To compile this driver as a module, choose M here: the
	  module will be called saa7110.

config VIDEO_SAA7111
	tristate "Philips SAA7111 video decoder"
	depends on VIDEO_V4L1 && I2C
	---help---
	  Support for the Philips SAA711 video decoder.

	  To compile this driver as a module, choose M here: the
	  module will be called saa7111.

config VIDEO_SAA7114
	tristate "Philips SAA7114 video decoder"
	depends on VIDEO_V4L1 && I2C
	---help---
	  Support for the Philips SAA7114 video decoder. This driver
	  is used only on Zoran driver and should be moved soon to
	  SAA711x module.

	  To compile this driver as a module, choose M here: the
	  module will be called saa7114.

config VIDEO_SAA711X
	tristate "Philips SAA7113/4/5 video decoders"
	tristate "Philips SAA7111/3/4/5 video decoders"
	depends on VIDEO_V4L2 && I2C
	---help---
	  Support for the Philips SAA7113/4/5 video decoders.
	  Support for the Philips SAA7111/3/4/5 video decoders.

	  To compile this driver as a module, choose M here: the
	  module will be called saa7115.
@@ -639,7 +619,7 @@ config VIDEO_MXB
	depends on PCI && VIDEO_V4L1 && I2C
	select VIDEO_SAA7146_VV
	select VIDEO_TUNER
	select VIDEO_SAA7115 if VIDEO_HELPER_CHIPS_AUTO
	select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
	select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO
	select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO
	select VIDEO_TEA6420 if VIDEO_HELPER_CHIPS_AUTO
+0 −2
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o
obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o
obj-$(CONFIG_VIDEO_SAA7111) += saa7111.o
obj-$(CONFIG_VIDEO_SAA7114) += saa7114.o
obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o
obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
+18 −56
Original line number Diff line number Diff line
@@ -52,9 +52,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct adv7170 {
	unsigned char reg[128];

	int norm;
	v4l2_std_id norm;
	int input;
	int enable;
	int bright;
	int contrast;
	int hue;
@@ -62,7 +61,6 @@ struct adv7170 {
};

static char *inputs[] = { "pass_through", "play_back" };
static char *norms[] = { "PAL", "NTSC" };

/* ----------------------------------------------------------------------- */

@@ -191,7 +189,7 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg)
	struct adv7170 *encoder = i2c_get_clientdata(client);

	switch (cmd) {
	case 0:
	case VIDIOC_INT_INIT:
#if 0
		/* This is just for testing!!! */
		adv7170_write_block(client, init_common,
@@ -201,63 +199,47 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg)
#endif
		break;

	case ENCODER_GET_CAPABILITIES:
	{
		struct video_encoder_capability *cap = arg;

		cap->flags = VIDEO_ENCODER_PAL |
			     VIDEO_ENCODER_NTSC;
		cap->inputs = 2;
		cap->outputs = 1;
		break;
	}

	case ENCODER_SET_NORM:
	case VIDIOC_INT_S_STD_OUTPUT:
	{
		int iarg = *(int *) arg;
		v4l2_std_id iarg = *(v4l2_std_id *) arg;

		v4l_dbg(1, debug, client, "set norm %d\n", iarg);
		v4l_dbg(1, debug, client, "set norm %llx\n", iarg);

		switch (iarg) {
		case VIDEO_MODE_NTSC:
		if (iarg & V4L2_STD_NTSC) {
			adv7170_write_block(client, init_NTSC,
					    sizeof(init_NTSC));
			if (encoder->input == 0)
				adv7170_write(client, 0x02, 0x0e);	// Enable genlock
			adv7170_write(client, 0x07, TR0MODE | TR0RST);
			adv7170_write(client, 0x07, TR0MODE);
			break;

		case VIDEO_MODE_PAL:
		} else if (iarg & V4L2_STD_PAL) {
			adv7170_write_block(client, init_PAL,
					    sizeof(init_PAL));
			if (encoder->input == 0)
				adv7170_write(client, 0x02, 0x0e);	// Enable genlock
			adv7170_write(client, 0x07, TR0MODE | TR0RST);
			adv7170_write(client, 0x07, TR0MODE);
			break;

		default:
			v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg);
		} else {
			v4l_dbg(1, debug, client, "illegal norm: %llx\n", iarg);
			return -EINVAL;
		}
		v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]);
		v4l_dbg(1, debug, client, "switched to %llx\n", iarg);
		encoder->norm = iarg;
		break;
	}

	case ENCODER_SET_INPUT:
	case VIDIOC_INT_S_VIDEO_ROUTING:
	{
		int iarg = *(int *) arg;
		struct v4l2_routing *route = arg;

		/* RJ: *iarg = 0: input is from decoder
		 *iarg = 1: input is from ZR36060
		 *iarg = 2: color bar */

		v4l_dbg(1, debug, client, "set input from %s\n",
			iarg == 0 ? "decoder" : "ZR36060");
			route->input == 0 ? "decoder" : "ZR36060");

		switch (iarg) {
		switch (route->input) {
		case 0:
			adv7170_write(client, 0x01, 0x20);
			adv7170_write(client, 0x08, TR1CAPT);	/* TR1 */
@@ -277,30 +259,11 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg)
			break;

		default:
			v4l_dbg(1, debug, client, "illegal input: %d\n", iarg);
			v4l_dbg(1, debug, client, "illegal input: %d\n", route->input);
			return -EINVAL;
		}
		v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]);
		encoder->input = iarg;
		break;
	}

	case ENCODER_SET_OUTPUT:
	{
		int *iarg = arg;

		/* not much choice of outputs */
		if (*iarg != 0) {
			return -EINVAL;
		}
		break;
	}

	case ENCODER_ENABLE_OUTPUT:
	{
		int *iarg = arg;

		encoder->enable = !!*iarg;
		v4l_dbg(1, debug, client, "switched to %s\n", inputs[route->input]);
		encoder->input = route->input;
		break;
	}

@@ -337,9 +300,8 @@ static int adv7170_probe(struct i2c_client *client,
	encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL);
	if (encoder == NULL)
		return -ENOMEM;
	encoder->norm = VIDEO_MODE_NTSC;
	encoder->norm = V4L2_STD_NTSC;
	encoder->input = 0;
	encoder->enable = 1;
	i2c_set_clientdata(client, encoder);

	i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC));
+21 −60
Original line number Diff line number Diff line
@@ -46,9 +46,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */

struct adv7175 {
	int norm;
	v4l2_std_id norm;
	int input;
	int enable;
	int bright;
	int contrast;
	int hue;
@@ -59,7 +58,6 @@ struct adv7175 {
#define   I2C_ADV7176        0x54

static char *inputs[] = { "pass_through", "play_back", "color_bar" };
static char *norms[] = { "PAL", "NTSC", "SECAM->PAL (may not work!)" };

/* ----------------------------------------------------------------------- */

@@ -189,7 +187,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
	struct adv7175 *encoder = i2c_get_clientdata(client);

	switch (cmd) {
	case 0:
	case VIDIOC_INT_INIT:
		/* This is just for testing!!! */
		adv7175_write_block(client, init_common,
				    sizeof(init_common));
@@ -197,42 +195,25 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
		adv7175_write(client, 0x07, TR0MODE);
		break;

	case ENCODER_GET_CAPABILITIES:
	{
		struct video_encoder_capability *cap = arg;

		cap->flags = VIDEO_ENCODER_PAL |
			     VIDEO_ENCODER_NTSC |
			     VIDEO_ENCODER_SECAM; /* well, hacky */
		cap->inputs = 2;
		cap->outputs = 1;
		break;
	}

	case ENCODER_SET_NORM:
	case VIDIOC_INT_S_STD_OUTPUT:
	{
		int iarg = *(int *) arg;
		v4l2_std_id iarg = *(v4l2_std_id *) arg;

		switch (iarg) {
		case VIDEO_MODE_NTSC:
		if (iarg & V4L2_STD_NTSC) {
			adv7175_write_block(client, init_ntsc,
					    sizeof(init_ntsc));
			if (encoder->input == 0)
				adv7175_write(client, 0x0d, 0x4f);	// Enable genlock
			adv7175_write(client, 0x07, TR0MODE | TR0RST);
			adv7175_write(client, 0x07, TR0MODE);
			break;

		case VIDEO_MODE_PAL:
		} else if (iarg & V4L2_STD_PAL) {
			adv7175_write_block(client, init_pal,
					    sizeof(init_pal));
			if (encoder->input == 0)
				adv7175_write(client, 0x0d, 0x4f);	// Enable genlock
			adv7175_write(client, 0x07, TR0MODE | TR0RST);
			adv7175_write(client, 0x07, TR0MODE);
			break;

		case VIDEO_MODE_SECAM:	// WARNING! ADV7176 does not support SECAM.
		} else if (iarg & V4L2_STD_SECAM) {
			/* This is an attempt to convert
			 * SECAM->PAL (typically it does not work
			 * due to genlock: when decoder is in SECAM
@@ -245,33 +226,32 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
				adv7175_write(client, 0x0d, 0x49);	// Disable genlock
			adv7175_write(client, 0x07, TR0MODE | TR0RST);
			adv7175_write(client, 0x07, TR0MODE);
			break;
		default:
			v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg);
		} else {
			v4l_dbg(1, debug, client, "illegal norm: %llx\n", iarg);
			return -EINVAL;
		}
		v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]);
		v4l_dbg(1, debug, client, "switched to %llx\n", iarg);
		encoder->norm = iarg;
		break;
	}

	case ENCODER_SET_INPUT:
	case VIDIOC_INT_S_VIDEO_ROUTING:
	{
		int iarg = *(int *) arg;
		struct v4l2_routing *route = arg;

		/* RJ: *iarg = 0: input is from SAA7110
		 *iarg = 1: input is from ZR36060
		 *iarg = 2: color bar */

		switch (iarg) {
		switch (route->input) {
		case 0:
			adv7175_write(client, 0x01, 0x00);

			if (encoder->norm == VIDEO_MODE_NTSC)
			if (encoder->norm & V4L2_STD_NTSC)
				set_subcarrier_freq(client, 1);

			adv7175_write(client, 0x0c, TR1CAPT);	/* TR1 */
			if (encoder->norm == VIDEO_MODE_SECAM)
			if (encoder->norm & V4L2_STD_SECAM)
				adv7175_write(client, 0x0d, 0x49);	// Disable genlock
			else
				adv7175_write(client, 0x0d, 0x4f);	// Enable genlock
@@ -283,7 +263,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
		case 1:
			adv7175_write(client, 0x01, 0x00);

			if (encoder->norm == VIDEO_MODE_NTSC)
			if (encoder->norm & V4L2_STD_NTSC)
				set_subcarrier_freq(client, 0);

			adv7175_write(client, 0x0c, TR1PLAY);	/* TR1 */
@@ -296,7 +276,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
		case 2:
			adv7175_write(client, 0x01, 0x80);

			if (encoder->norm == VIDEO_MODE_NTSC)
			if (encoder->norm & V4L2_STD_NTSC)
				set_subcarrier_freq(client, 0);

			adv7175_write(client, 0x0d, 0x49);
@@ -306,29 +286,11 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
			break;

		default:
			v4l_dbg(1, debug, client, "illegal input: %d\n", iarg);
			return -EINVAL;
		}
		v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]);
		encoder->input = iarg;
		break;
	}

	case ENCODER_SET_OUTPUT:
	{
		int *iarg = arg;

		/* not much choice of outputs */
		if (*iarg != 0)
			v4l_dbg(1, debug, client, "illegal input: %d\n", route->input);
			return -EINVAL;
		break;
		}

	case ENCODER_ENABLE_OUTPUT:
	{
		int *iarg = arg;

		encoder->enable = !!*iarg;
		v4l_dbg(1, debug, client, "switched to %s\n", inputs[route->input]);
		encoder->input = route->input;
		break;
	}

@@ -369,9 +331,8 @@ static int adv7175_probe(struct i2c_client *client,
	encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL);
	if (encoder == NULL)
		return -ENOMEM;
	encoder->norm = VIDEO_MODE_PAL;
	encoder->norm = V4L2_STD_NTSC;
	encoder->input = 0;
	encoder->enable = 1;
	i2c_set_clientdata(client, encoder);

	i = adv7175_write_block(client, init_common, sizeof(init_common));
+142 −129
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ struct bt819 {
	unsigned char reg[32];

	int initialized;
	int norm;
	v4l2_std_id norm;
	int input;
	int enable;
	int bright;
@@ -178,7 +178,7 @@ static int bt819_init(struct i2c_client *client)
		0x1a, 0x80,	/* 0x1a ADC Interface */
	};

	struct timing *timing = &timing_data[decoder->norm];
	struct timing *timing = &timing_data[(decoder->norm & V4L2_STD_525_60) ? 1 : 0];

	init[0x03 * 2 - 1] =
	    (((timing->vdelay >> 8) & 0x03) << 6) |
@@ -192,7 +192,7 @@ static int bt819_init(struct i2c_client *client)
	init[0x08 * 2 - 1] = timing->hscale >> 8;
	init[0x09 * 2 - 1] = timing->hscale & 0xff;
	/* 0x15 in array is address 0x19 */
	init[0x15 * 2 - 1] = (decoder->norm == 0) ? 115 : 93;	/* Chroma burst delay */
	init[0x15 * 2 - 1] = (decoder->norm & V4L2_STD_625_50) ? 115 : 93;	/* Chroma burst delay */
	/* reset */
	bt819_write(client, 0x1f, 0x00);
	mdelay(1);
@@ -215,93 +215,67 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg)
	}

	switch (cmd) {
	case 0:
	case VIDIOC_INT_INIT:
		/* This is just for testing!!! */
		bt819_init(client);
		break;

	case DECODER_GET_CAPABILITIES:
	{
		struct video_decoder_capability *cap = arg;

		cap->flags = VIDEO_DECODER_PAL |
			     VIDEO_DECODER_NTSC |
			     VIDEO_DECODER_AUTO |
			     VIDEO_DECODER_CCIR;
		cap->inputs = 8;
		cap->outputs = 1;
		break;
	}

	case DECODER_GET_STATUS:
	{
	case VIDIOC_QUERYSTD:
	case VIDIOC_INT_G_INPUT_STATUS: {
		int *iarg = arg;
		v4l2_std_id *istd = arg;
		int status;
		int res;
		int res = V4L2_IN_ST_NO_SIGNAL;
		v4l2_std_id std;

		status = bt819_read(client, 0x00);
		res = 0;
		if ((status & 0x80))
			res |= DECODER_STATUS_GOOD;
			res = 0;

		switch (decoder->norm) {
		case VIDEO_MODE_NTSC:
			res |= DECODER_STATUS_NTSC;
			break;
		case VIDEO_MODE_PAL:
			res |= DECODER_STATUS_PAL;
			break;
		default:
		case VIDEO_MODE_AUTO:
		if ((status & 0x10))
				res |= DECODER_STATUS_PAL;
			std = V4L2_STD_PAL;
		else
			std = V4L2_STD_NTSC;
		if (cmd == VIDIOC_QUERYSTD)
			*istd = std;
		else
				res |= DECODER_STATUS_NTSC;
			break;
		}
		res |= DECODER_STATUS_COLOR;
			*iarg = res;

		v4l_dbg(1, debug, client, "get status %x\n", *iarg);
		break;
	}

	case DECODER_SET_NORM:
	case VIDIOC_S_STD:
	{
		int *iarg = arg;
		v4l2_std_id *iarg = arg;
		struct timing *timing = NULL;

		v4l_dbg(1, debug, client, "set norm %x\n", *iarg);
		v4l_dbg(1, debug, client, "set norm %llx\n", *iarg);

		switch (*iarg) {
		case VIDEO_MODE_NTSC:
		if (*iarg & V4L2_STD_NTSC) {
			bt819_setbit(client, 0x01, 0, 1);
			bt819_setbit(client, 0x01, 1, 0);
			bt819_setbit(client, 0x01, 5, 0);
			bt819_write(client, 0x18, 0x68);
			bt819_write(client, 0x19, 0x5d);
			/* bt819_setbit(client, 0x1a,  5, 1); */
			timing = &timing_data[VIDEO_MODE_NTSC];
			break;
		case VIDEO_MODE_PAL:
			timing = &timing_data[1];
		} else if (*iarg & V4L2_STD_PAL) {
			bt819_setbit(client, 0x01, 0, 1);
			bt819_setbit(client, 0x01, 1, 1);
			bt819_setbit(client, 0x01, 5, 1);
			bt819_write(client, 0x18, 0x7f);
			bt819_write(client, 0x19, 0x72);
			/* bt819_setbit(client, 0x1a,  5, 0); */
			timing = &timing_data[VIDEO_MODE_PAL];
			break;
		case VIDEO_MODE_AUTO:
			bt819_setbit(client, 0x01, 0, 0);
			bt819_setbit(client, 0x01, 1, 0);
			break;
		default:
			v4l_dbg(1, debug, client, "unsupported norm %x\n", *iarg);
			timing = &timing_data[0];
		} else {
			v4l_dbg(1, debug, client, "unsupported norm %llx\n", *iarg);
			return -EINVAL;
		}
/*		case VIDEO_MODE_AUTO:
			bt819_setbit(client, 0x01, 0, 0);
			bt819_setbit(client, 0x01, 1, 0);*/

		if (timing) {
		bt819_write(client, 0x03,
			    (((timing->vdelay >> 8) & 0x03) << 6) |
			    (((timing->vactive >> 8) & 0x03) << 4) |
@@ -313,23 +287,21 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg)
		bt819_write(client, 0x07, timing->hactive & 0xff);
		bt819_write(client, 0x08, (timing->hscale >> 8) & 0xff);
		bt819_write(client, 0x09, timing->hscale & 0xff);
		}

		decoder->norm = *iarg;
		break;
	}

	case DECODER_SET_INPUT:
	case VIDIOC_INT_S_VIDEO_ROUTING:
	{
		int *iarg = arg;
		struct v4l2_routing *route = arg;

		v4l_dbg(1, debug, client, "set input %x\n", *iarg);
		v4l_dbg(1, debug, client, "set input %x\n", route->input);

		if (*iarg < 0 || *iarg > 7)
		if (route->input < 0 || route->input > 7)
			return -EINVAL;

		if (decoder->input != *iarg) {
			decoder->input = *iarg;
		if (decoder->input != route->input) {
			decoder->input = route->input;
			/* select mode */
			if (decoder->input == 0) {
				bt819_setbit(client, 0x0b, 6, 0);
@@ -342,75 +314,116 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg)
		break;
	}

	case DECODER_SET_OUTPUT:
	case VIDIOC_STREAMON:
	case VIDIOC_STREAMOFF:
	{
		int *iarg = arg;
		int enable = cmd == VIDIOC_STREAMON;

		v4l_dbg(1, debug, client, "set output %x\n", *iarg);
		v4l_dbg(1, debug, client, "enable output %x\n", enable);

		/* not much choice of outputs */
		if (*iarg != 0)
			return -EINVAL;
		if (decoder->enable != enable) {
			decoder->enable = enable;
			bt819_setbit(client, 0x16, 7, !enable);
		}
		break;
	}

	case DECODER_ENABLE_OUTPUT:
	case VIDIOC_QUERYCTRL:
	{
		int *iarg = arg;
		int enable = (*iarg != 0);
		struct v4l2_queryctrl *qc = arg;

		switch (qc->id) {
		case V4L2_CID_BRIGHTNESS:
			v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
			break;

		v4l_dbg(1, debug, client, "enable output %x\n", *iarg);
		case V4L2_CID_CONTRAST:
			v4l2_ctrl_query_fill(qc, 0, 511, 1, 256);
			break;

		if (decoder->enable != enable) {
			decoder->enable = enable;
			bt819_setbit(client, 0x16, 7, !enable);
		case V4L2_CID_SATURATION:
			v4l2_ctrl_query_fill(qc, 0, 511, 1, 256);
			break;

		case V4L2_CID_HUE:
			v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
			break;

		default:
			return -EINVAL;
		}
		break;
	}

	case DECODER_SET_PICTURE:
	case VIDIOC_S_CTRL:
	{
		struct video_picture *pic = arg;

		v4l_dbg(1, debug, client,
			"set picture brightness %d contrast %d colour %d\n",
			pic->brightness, pic->contrast, pic->colour);
		struct v4l2_control *ctrl = arg;


		if (decoder->bright != pic->brightness) {
			/* We want -128 to 127 we get 0-65535 */
			decoder->bright = pic->brightness;
			bt819_write(client, 0x0a,
				    (decoder->bright >> 8) - 128);
		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			if (decoder->bright != ctrl->value) {
				decoder->bright = ctrl->value;
				bt819_write(client, 0x0a, decoder->bright);
			}
			break;

		if (decoder->contrast != pic->contrast) {
			/* We want 0 to 511 we get 0-65535 */
			decoder->contrast = pic->contrast;
		case V4L2_CID_CONTRAST:
			if (decoder->contrast != ctrl->value) {
				decoder->contrast = ctrl->value;
				bt819_write(client, 0x0c,
				    (decoder->contrast >> 7) & 0xff);
						decoder->contrast & 0xff);
				bt819_setbit(client, 0x0b, 2,
				     ((decoder->contrast >> 15) & 0x01));
						((decoder->contrast >> 8) & 0x01));
			}
			break;

		if (decoder->sat != pic->colour) {
			/* We want 0 to 511 we get 0-65535 */
			decoder->sat = pic->colour;
		case V4L2_CID_SATURATION:
			if (decoder->sat != ctrl->value) {
				decoder->sat = ctrl->value;
				bt819_write(client, 0x0d,
						(decoder->sat >> 7) & 0xff);
				bt819_setbit(client, 0x0b, 1,
						((decoder->sat >> 15) & 0x01));

			temp = (decoder->sat * 201) / 237;
				/* Ratio between U gain and V gain must stay the same as
				   the ratio between the default U and V gain values. */
				temp = (decoder->sat * 180) / 254;
				bt819_write(client, 0x0e, (temp >> 7) & 0xff);
				bt819_setbit(client, 0x0b, 0, (temp >> 15) & 0x01);
			}
			break;

		if (decoder->hue != pic->hue) {
			/* We want -128 to 127 we get 0-65535 */
			decoder->hue = pic->hue;
			bt819_write(client, 0x0f,
				    128 - (decoder->hue >> 8));
		case V4L2_CID_HUE:
			if (decoder->hue != ctrl->value) {
				decoder->hue = ctrl->value;
				bt819_write(client, 0x0f, decoder->hue);
			}
			break;
		default:
			return -EINVAL;
		}
		break;
	}

	case VIDIOC_G_CTRL:
	{
		struct v4l2_control *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			ctrl->value = decoder->bright;
			break;
		case V4L2_CID_CONTRAST:
			ctrl->value = decoder->contrast;
			break;
		case V4L2_CID_SATURATION:
			ctrl->value = decoder->sat;
			break;
		case V4L2_CID_HUE:
			ctrl->value = decoder->hue;
			break;
		default:
			return -EINVAL;
		}
		break;
	}
@@ -462,13 +475,13 @@ static int bt819_probe(struct i2c_client *client,
	decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL);
	if (decoder == NULL)
		return -ENOMEM;
	decoder->norm = VIDEO_MODE_NTSC;
	decoder->norm = V4L2_STD_NTSC;
	decoder->input = 0;
	decoder->enable = 1;
	decoder->bright = 32768;
	decoder->contrast = 32768;
	decoder->hue = 32768;
	decoder->sat = 32768;
	decoder->bright = 0;
	decoder->contrast = 0xd8;	/* 100% of original signal */
	decoder->hue = 0;
	decoder->sat = 0xfe;	/* 100% of original signal */
	decoder->initialized = 0;
	i2c_set_clientdata(client, decoder);

Loading