aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-18 17:26:06 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 12:42:57 -0300
commit107063c6156a0cbf055e771baafc28a3e3c0fb9b (patch)
tree813a2dc2c1426521167f2f289d7a106aaf2f24ec /drivers/media/video
parent84c1b09495ea366276726b0df2dcd7898cda9d0f (diff)
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: Hans Verkuil <hverkuil@xs4all.nl> [mchehab@redhat.com: fix v4l2_ctrl_query_fill_std merge conflict] Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/Kconfig28
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/adv7170.c74
-rw-r--r--drivers/media/video/adv7175.c81
-rw-r--r--drivers/media/video/bt819.c271
-rw-r--r--drivers/media/video/bt856.c92
-rw-r--r--drivers/media/video/bt866.c67
-rw-r--r--drivers/media/video/ks0127.c152
-rw-r--r--drivers/media/video/saa7110.c210
-rw-r--r--drivers/media/video/saa7111.c492
-rw-r--r--drivers/media/video/saa7114.c1068
-rw-r--r--drivers/media/video/saa7185.c78
-rw-r--r--drivers/media/video/vpx3220.c232
-rw-r--r--drivers/media/video/zoran/Kconfig4
-rw-r--r--drivers/media/video/zoran/zoran.h6
-rw-r--r--drivers/media/video/zoran/zoran_card.c60
-rw-r--r--drivers/media/video/zoran/zoran_device.c61
-rw-r--r--drivers/media/video/zoran/zoran_driver.c220
18 files changed, 636 insertions, 2562 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 3e4ce4aade3..bb7df8c18b0 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -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
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 6e2c69569f9..307490ebc23 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -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
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index e0eb4f32144..ebafe78cb4c 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -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:
+ case VIDIOC_INT_S_STD_OUTPUT:
{
- struct video_encoder_capability *cap = arg;
+ v4l2_std_id iarg = *(v4l2_std_id *) arg;
- cap->flags = VIDEO_ENCODER_PAL |
- VIDEO_ENCODER_NTSC;
- cap->inputs = 2;
- cap->outputs = 1;
- break;
- }
-
- case ENCODER_SET_NORM:
- {
- int iarg = *(int *) 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);
- 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;
}
@@ -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));
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 6008e84653f..154dff03a7d 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -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:
+ case VIDIOC_INT_S_STD_OUTPUT:
{
- struct video_encoder_capability *cap = arg;
+ v4l2_std_id iarg = *(v4l2_std_id *) 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:
- {
- int iarg = *(int *) 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);
+ 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;
}
@@ -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));
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index a07b7b88e5b..b8109a1b50c 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -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,121 +215,93 @@ 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;
- else
- res |= DECODER_STATUS_NTSC;
- break;
- }
- res |= DECODER_STATUS_COLOR;
- *iarg = res;
+ if ((status & 0x10))
+ std = V4L2_STD_PAL;
+ else
+ std = V4L2_STD_NTSC;
+ if (cmd == VIDIOC_QUERYSTD)
+ *istd = std;
+ else
+ *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;
}
-
- if (timing) {
- bt819_write(client, 0x03,
- (((timing->vdelay >> 8) & 0x03) << 6) |
- (((timing->vactive >> 8) & 0x03) << 4) |
- (((timing->hdelay >> 8) & 0x03) << 2) |
- ((timing->hactive >> 8) & 0x03) );
- bt819_write(client, 0x04, timing->vdelay & 0xff);
- bt819_write(client, 0x05, timing->vactive & 0xff);
- bt819_write(client, 0x06, timing->hdelay & 0xff);
- bt819_write(client, 0x07, timing->hactive & 0xff);
- bt819_write(client, 0x08, (timing->hscale >> 8) & 0xff);
- bt819_write(client, 0x09, timing->hscale & 0xff);
- }
-
+/* case VIDEO_MODE_AUTO:
+ bt819_setbit(client, 0x01, 0, 0);
+ bt819_setbit(client, 0x01, 1, 0);*/
+
+ bt819_write(client, 0x03,
+ (((timing->vdelay >> 8) & 0x03) << 6) |
+ (((timing->vactive >> 8) & 0x03) << 4) |
+ (((timing->hdelay >> 8) & 0x03) << 2) |
+ ((timing->hactive >> 8) & 0x03));
+ bt819_write(client, 0x04, timing->vdelay & 0xff);
+ bt819_write(client, 0x05, timing->vactive & 0xff);
+ bt819_write(client, 0x06, timing->hdelay & 0xff);
+ 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;
- v4l_dbg(1, debug, client, "enable output %x\n", *iarg);
+ switch (qc->id) {
+ case V4L2_CID_BRIGHTNESS:
+ v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
+ break;
- if (decoder->enable != enable) {
- decoder->enable = enable;
- bt819_setbit(client, 0x16, 7, !enable);
+ case V4L2_CID_CONTRAST:
+ v4l2_ctrl_query_fill(qc, 0, 511, 1, 256);
+ break;
+
+ 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;
+ struct v4l2_control *ctrl = arg;
- v4l_dbg(1, debug, client,
- "set picture brightness %d contrast %d colour %d\n",
- pic->brightness, pic->contrast, pic->colour);
+ switch (ctrl->id) {
+ case V4L2_CID_BRIGHTNESS:
+ if (decoder->bright != ctrl->value) {
+ decoder->bright = ctrl->value;
+ bt819_write(client, 0x0a, decoder->bright);
+ }
+ break;
+ case V4L2_CID_CONTRAST:
+ if (decoder->contrast != ctrl->value) {
+ decoder->contrast = ctrl->value;
+ bt819_write(client, 0x0c,
+ decoder->contrast & 0xff);
+ bt819_setbit(client, 0x0b, 2,
+ ((decoder->contrast >> 8) & 0x01));
+ }
+ break;
- 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);
- }
+ 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));
+
+ /* 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->contrast != pic->contrast) {
- /* We want 0 to 511 we get 0-65535 */
- decoder->contrast = pic->contrast;
- bt819_write(client, 0x0c,
- (decoder->contrast >> 7) & 0xff);
- bt819_setbit(client, 0x0b, 2,
- ((decoder->contrast >> 15) & 0x01));
+ case V4L2_CID_HUE:
+ if (decoder->hue != ctrl->value) {
+ decoder->hue = ctrl->value;
+ bt819_write(client, 0x0f, decoder->hue);
+ }
+ break;
+ default:
+ return -EINVAL;
}
+ break;
+ }
- if (decoder->sat != pic->colour) {
- /* We want 0 to 511 we get 0-65535 */
- decoder->sat = pic->colour;
- bt819_write(client, 0x0d,
- (decoder->sat >> 7) & 0xff);
- bt819_setbit(client, 0x0b, 1,
- ((decoder->sat >> 15) & 0x01));
-
- temp = (decoder->sat * 201) / 237;
- bt819_write(client, 0x0e, (temp >> 7) & 0xff);
- bt819_setbit(client, 0x0b, 0, (temp >> 15) & 0x01);
- }
+ case VIDIOC_G_CTRL:
+ {
+ struct v4l2_control *ctrl = arg;
- 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));
+ 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);
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 4213867507f..3e042c5ddaa 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -55,8 +55,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct bt856 {
unsigned char reg[BT856_NR_REG];
- int norm;
- int enable;
+ v4l2_std_id norm;
};
/* ----------------------------------------------------------------------- */
@@ -96,7 +95,7 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
struct bt856 *encoder = i2c_get_clientdata(client);
switch (cmd) {
- case 0:
+ case VIDIOC_INT_INIT:
/* This is just for testing!!! */
v4l_dbg(1, debug, client, "init\n");
bt856_write(client, 0xdc, 0x18);
@@ -107,15 +106,10 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
//bt856_setbit(client, 0xdc, 6, 0);
bt856_setbit(client, 0xdc, 4, 1);
- switch (encoder->norm) {
- case VIDEO_MODE_NTSC:
+ if (encoder->norm & V4L2_STD_NTSC)
bt856_setbit(client, 0xdc, 2, 0);
- break;
-
- case VIDEO_MODE_PAL:
+ else
bt856_setbit(client, 0xdc, 2, 1);
- break;
- }
bt856_setbit(client, 0xdc, 1, 1);
bt856_setbit(client, 0xde, 4, 0);
@@ -124,38 +118,19 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
bt856_dump(client);
break;
- case ENCODER_GET_CAPABILITIES:
+ case VIDIOC_INT_S_STD_OUTPUT:
{
- struct video_encoder_capability *cap = arg;
-
- v4l_dbg(1, debug, client, "get capabilities\n");
+ v4l2_std_id *iarg = arg;
- cap->flags = VIDEO_ENCODER_PAL |
- VIDEO_ENCODER_NTSC |
- VIDEO_ENCODER_CCIR;
- cap->inputs = 2;
- cap->outputs = 1;
- break;
- }
-
- case ENCODER_SET_NORM:
- {
- int *iarg = arg;
+ v4l_dbg(1, debug, client, "set norm %llx\n", *iarg);
- v4l_dbg(1, debug, client, "set norm %d\n", *iarg);
-
- switch (*iarg) {
- case VIDEO_MODE_NTSC:
+ if (*iarg & V4L2_STD_NTSC) {
bt856_setbit(client, 0xdc, 2, 0);
- break;
-
- case VIDEO_MODE_PAL:
+ } else if (*iarg & V4L2_STD_PAL) {
bt856_setbit(client, 0xdc, 2, 1);
bt856_setbit(client, 0xda, 0, 0);
//bt856_setbit(client, 0xda, 0, 1);
- break;
-
- default:
+ } else {
return -EINVAL;
}
encoder->norm = *iarg;
@@ -164,16 +139,16 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
break;
}
- case ENCODER_SET_INPUT:
+ case VIDIOC_INT_S_VIDEO_ROUTING:
{
- int *iarg = arg;
+ struct v4l2_routing *route = arg;
- v4l_dbg(1, debug, client, "set input %d\n", *iarg);
+ v4l_dbg(1, debug, client, "set input %d\n", route->input);
/* We only have video bus.
- * iarg = 0: input is from bt819
- * iarg = 1: input is from ZR36060 */
- switch (*iarg) {
+ * route->input= 0: input is from bt819
+ * route->input= 1: input is from ZR36060 */
+ switch (route->input) {
case 0:
bt856_setbit(client, 0xde, 4, 0);
bt856_setbit(client, 0xde, 3, 1);
@@ -199,28 +174,6 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
break;
}
- case ENCODER_SET_OUTPUT:
- {
- int *iarg = arg;
-
- v4l_dbg(1, debug, client, "set output %d\n", *iarg);
-
- /* 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, "enable output %d\n", encoder->enable);
- break;
- }
-
default:
return -EINVAL;
}
@@ -249,8 +202,7 @@ static int bt856_probe(struct i2c_client *client,
encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL);
if (encoder == NULL)
return -ENOMEM;
- encoder->norm = VIDEO_MODE_NTSC;
- encoder->enable = 1;
+ encoder->norm = V4L2_STD_NTSC;
i2c_set_clientdata(client, encoder);
bt856_write(client, 0xdc, 0x18);
@@ -261,16 +213,10 @@ static int bt856_probe(struct i2c_client *client,
//bt856_setbit(client, 0xdc, 6, 0);
bt856_setbit(client, 0xdc, 4, 1);
- switch (encoder->norm) {
-
- case VIDEO_MODE_NTSC:
+ if (encoder->norm & V4L2_STD_NTSC)
bt856_setbit(client, 0xdc, 2, 0);
- break;
-
- case VIDEO_MODE_PAL:
+ else
bt856_setbit(client, 0xdc, 2, 1);
- break;
- }
bt856_setbit(client, 0xdc, 1, 1);
bt856_setbit(client, 0xde, 4, 0);
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c
index 596f9e2376b..1df24c8776f 100644
--- a/drivers/media/video/bt866.c
+++ b/drivers/media/video/bt866.c
@@ -52,8 +52,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct bt866 {
u8 reg[256];
- int norm;
- int enable;
+ v4l2_std_id norm;
int bright;
int contrast;
int hue;
@@ -94,44 +93,21 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg)
struct bt866 *encoder