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

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
...@@ -307,38 +307,18 @@ config VIDEO_TCM825X ...@@ -307,38 +307,18 @@ config VIDEO_TCM825X
config VIDEO_SAA7110 config VIDEO_SAA7110
tristate "Philips SAA7110 video decoder" tristate "Philips SAA7110 video decoder"
depends on VIDEO_V4L1 && I2C depends on VIDEO_V4L2 && I2C
---help--- ---help---
Support for the Philips SAA7110 video decoders. Support for the Philips SAA7110 video decoders.
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called saa7110. 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 config VIDEO_SAA711X
tristate "Philips SAA7113/4/5 video decoders" tristate "Philips SAA7111/3/4/5 video decoders"
depends on VIDEO_V4L2 && I2C depends on VIDEO_V4L2 && I2C
---help--- ---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 To compile this driver as a module, choose M here: the
module will be called saa7115. module will be called saa7115.
...@@ -639,7 +619,7 @@ config VIDEO_MXB ...@@ -639,7 +619,7 @@ config VIDEO_MXB
depends on PCI && VIDEO_V4L1 && I2C depends on PCI && VIDEO_V4L1 && I2C
select VIDEO_SAA7146_VV select VIDEO_SAA7146_VV
select VIDEO_TUNER 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_TDA9840 if VIDEO_HELPER_CHIPS_AUTO
select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO
select VIDEO_TEA6420 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_TEA6420 if VIDEO_HELPER_CHIPS_AUTO
......
...@@ -43,8 +43,6 @@ obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o ...@@ -43,8 +43,6 @@ obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o
obj-$(CONFIG_VIDEO_SAA7110) += saa7110.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_SAA711X) += saa7115.o
obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o
obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
......
...@@ -52,9 +52,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -52,9 +52,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct adv7170 { struct adv7170 {
unsigned char reg[128]; unsigned char reg[128];
int norm; v4l2_std_id norm;
int input; int input;
int enable;
int bright; int bright;
int contrast; int contrast;
int hue; int hue;
...@@ -62,7 +61,6 @@ struct adv7170 { ...@@ -62,7 +61,6 @@ struct adv7170 {
}; };
static char *inputs[] = { "pass_through", "play_back" }; 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) ...@@ -191,7 +189,7 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg)
struct adv7170 *encoder = i2c_get_clientdata(client); struct adv7170 *encoder = i2c_get_clientdata(client);
switch (cmd) { switch (cmd) {
case 0: case VIDIOC_INT_INIT:
#if 0 #if 0
/* This is just for testing!!! */ /* This is just for testing!!! */
adv7170_write_block(client, init_common, adv7170_write_block(client, init_common,
...@@ -201,63 +199,47 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -201,63 +199,47 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg)
#endif #endif
break; break;
case ENCODER_GET_CAPABILITIES: case VIDIOC_INT_S_STD_OUTPUT:
{
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:
{ {
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) { if (iarg & V4L2_STD_NTSC) {
case VIDEO_MODE_NTSC:
adv7170_write_block(client, init_NTSC, adv7170_write_block(client, init_NTSC,
sizeof(init_NTSC)); sizeof(init_NTSC));
if (encoder->input == 0) if (encoder->input == 0)
adv7170_write(client, 0x02, 0x0e); // Enable genlock adv7170_write(client, 0x02, 0x0e); // Enable genlock
adv7170_write(client, 0x07, TR0MODE | TR0RST); adv7170_write(client, 0x07, TR0MODE | TR0RST);
adv7170_write(client, 0x07, TR0MODE); adv7170_write(client, 0x07, TR0MODE);
break; } else if (iarg & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
adv7170_write_block(client, init_PAL, adv7170_write_block(client, init_PAL,
sizeof(init_PAL)); sizeof(init_PAL));
if (encoder->input == 0) if (encoder->input == 0)
adv7170_write(client, 0x02, 0x0e); // Enable genlock adv7170_write(client, 0x02, 0x0e); // Enable genlock
adv7170_write(client, 0x07, TR0MODE | TR0RST); adv7170_write(client, 0x07, TR0MODE | TR0RST);
adv7170_write(client, 0x07, TR0MODE); adv7170_write(client, 0x07, TR0MODE);
break; } else {
v4l_dbg(1, debug, client, "illegal norm: %llx\n", iarg);
default:
v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg);
return -EINVAL; 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; encoder->norm = iarg;
break; 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 /* RJ: *iarg = 0: input is from decoder
*iarg = 1: input is from ZR36060 *iarg = 1: input is from ZR36060
*iarg = 2: color bar */ *iarg = 2: color bar */
v4l_dbg(1, debug, client, "set input from %s\n", 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: case 0:
adv7170_write(client, 0x01, 0x20); adv7170_write(client, 0x01, 0x20);
adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ adv7170_write(client, 0x08, TR1CAPT); /* TR1 */
...@@ -277,30 +259,11 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -277,30 +259,11 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg)
break; break;
default: default:
v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); v4l_dbg(1, debug, client, "illegal input: %d\n", route->input);
return -EINVAL; return -EINVAL;
} }
v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); v4l_dbg(1, debug, client, "switched to %s\n", inputs[route->input]);
encoder->input = iarg; encoder->input = route->input;
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;
break; break;
} }
...@@ -337,9 +300,8 @@ static int adv7170_probe(struct i2c_client *client, ...@@ -337,9 +300,8 @@ static int adv7170_probe(struct i2c_client *client,
encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL);
if (encoder == NULL) if (encoder == NULL)
return -ENOMEM; return -ENOMEM;
encoder->norm = VIDEO_MODE_NTSC; encoder->norm = V4L2_STD_NTSC;
encoder->input = 0; encoder->input = 0;
encoder->enable = 1;
i2c_set_clientdata(client, encoder); i2c_set_clientdata(client, encoder);
i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC));
......
...@@ -46,9 +46,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -46,9 +46,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
struct adv7175 { struct adv7175 {
int norm; v4l2_std_id norm;
int input; int input;
int enable;
int bright; int bright;
int contrast; int contrast;
int hue; int hue;
...@@ -59,7 +58,6 @@ struct adv7175 { ...@@ -59,7 +58,6 @@ struct adv7175 {
#define I2C_ADV7176 0x54 #define I2C_ADV7176 0x54
static char *inputs[] = { "pass_through", "play_back", "color_bar" }; 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) ...@@ -189,7 +187,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
struct adv7175 *encoder = i2c_get_clientdata(client); struct adv7175 *encoder = i2c_get_clientdata(client);
switch (cmd) { switch (cmd) {
case 0: case VIDIOC_INT_INIT:
/* This is just for testing!!! */ /* This is just for testing!!! */
adv7175_write_block(client, init_common, adv7175_write_block(client, init_common,
sizeof(init_common)); sizeof(init_common));
...@@ -197,42 +195,25 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -197,42 +195,25 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
adv7175_write(client, 0x07, TR0MODE); adv7175_write(client, 0x07, TR0MODE);
break; break;
case ENCODER_GET_CAPABILITIES: case VIDIOC_INT_S_STD_OUTPUT:
{
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:
{ {
int iarg = *(int *) arg; v4l2_std_id iarg = *(v4l2_std_id *) arg;
switch (iarg) { if (iarg & V4L2_STD_NTSC) {
case VIDEO_MODE_NTSC:
adv7175_write_block(client, init_ntsc, adv7175_write_block(client, init_ntsc,
sizeof(init_ntsc)); sizeof(init_ntsc));
if (encoder->input == 0) if (encoder->input == 0)
adv7175_write(client, 0x0d, 0x4f); // Enable genlock adv7175_write(client, 0x0d, 0x4f); // Enable genlock
adv7175_write(client, 0x07, TR0MODE | TR0RST); adv7175_write(client, 0x07, TR0MODE | TR0RST);
adv7175_write(client, 0x07, TR0MODE); adv7175_write(client, 0x07, TR0MODE);
break; } else if (iarg & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
adv7175_write_block(client, init_pal, adv7175_write_block(client, init_pal,
sizeof(init_pal)); sizeof(init_pal));
if (encoder->input == 0) if (encoder->input == 0)
adv7175_write(client, 0x0d, 0x4f); // Enable genlock adv7175_write(client, 0x0d, 0x4f); // Enable genlock
adv7175_write(client, 0x07, TR0MODE | TR0RST); adv7175_write(client, 0x07, TR0MODE | TR0RST);
adv7175_write(client, 0x07, TR0MODE); adv7175_write(client, 0x07, TR0MODE);
break; } else if (iarg & V4L2_STD_SECAM) {
case VIDEO_MODE_SECAM: // WARNING! ADV7176 does not support SECAM.
/* This is an attempt to convert /* This is an attempt to convert
* SECAM->PAL (typically it does not work * SECAM->PAL (typically it does not work
* due to genlock: when decoder is in SECAM * due to genlock: when decoder is in SECAM
...@@ -245,33 +226,32 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -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, 0x0d, 0x49); // Disable genlock
adv7175_write(client, 0x07, TR0MODE | TR0RST); adv7175_write(client, 0x07, TR0MODE | TR0RST);
adv7175_write(client, 0x07, TR0MODE); adv7175_write(client, 0x07, TR0MODE);
break; } else {
default: v4l_dbg(1, debug, client, "illegal norm: %llx\n", iarg);
v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg);
return -EINVAL; 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; encoder->norm = iarg;
break; 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 /* RJ: *iarg = 0: input is from SAA7110
*iarg = 1: input is from ZR36060 *iarg = 1: input is from ZR36060
*iarg = 2: color bar */ *iarg = 2: color bar */
switch (iarg) { switch (route->input) {
case 0: case 0:
adv7175_write(client, 0x01, 0x00); adv7175_write(client, 0x01, 0x00);
if (encoder->norm == VIDEO_MODE_NTSC) if (encoder->norm & V4L2_STD_NTSC)
set_subcarrier_freq(client, 1); set_subcarrier_freq(client, 1);
adv7175_write(client, 0x0c, TR1CAPT); /* TR1 */ 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 adv7175_write(client, 0x0d, 0x49); // Disable genlock
else else
adv7175_write(client, 0x0d, 0x4f); // Enable genlock adv7175_write(client, 0x0d, 0x4f); // Enable genlock
...@@ -283,7 +263,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -283,7 +263,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
case 1: case 1:
adv7175_write(client, 0x01, 0x00); adv7175_write(client, 0x01, 0x00);
if (encoder->norm == VIDEO_MODE_NTSC) if (encoder->norm & V4L2_STD_NTSC)
set_subcarrier_freq(client, 0); set_subcarrier_freq(client, 0);
adv7175_write(client, 0x0c, TR1PLAY); /* TR1 */ adv7175_write(client, 0x0c, TR1PLAY); /* TR1 */
...@@ -296,7 +276,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -296,7 +276,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
case 2: case 2:
adv7175_write(client, 0x01, 0x80); adv7175_write(client, 0x01, 0x80);
if (encoder->norm == VIDEO_MODE_NTSC) if (encoder->norm & V4L2_STD_NTSC)
set_subcarrier_freq(client, 0); set_subcarrier_freq(client, 0);
adv7175_write(client, 0x0d, 0x49); adv7175_write(client, 0x0d, 0x49);
...@@ -306,29 +286,11 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -306,29 +286,11 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg)
break; break;
default: 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; return -EINVAL;
break;
} }
v4l_dbg(1, debug, client, "switched to %s\n", inputs[route->input]);
case ENCODER_ENABLE_OUTPUT: encoder->input = route->input;
{
int *iarg = arg;
encoder->enable = !!*iarg;
break; break;
} }
...@@ -369,9 +331,8 @@ static int adv7175_probe(struct i2c_client *client, ...@@ -369,9 +331,8 @@ static int adv7175_probe(struct i2c_client *client,
encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL);
if (encoder == NULL) if (encoder == NULL)
return -ENOMEM; return -ENOMEM;
encoder->norm = VIDEO_MODE_PAL; encoder->norm = V4L2_STD_NTSC;
encoder->input = 0; encoder->input = 0;
encoder->enable = 1;
i2c_set_clientdata(client, encoder); i2c_set_clientdata(client, encoder);
i = adv7175_write_block(client, init_common, sizeof(init_common)); i = adv7175_write_block(client, init_common, sizeof(init_common));
......
...@@ -54,7 +54,7 @@ struct bt819 { ...@@ -54,7 +54,7 @@ struct bt819 {
unsigned char reg[32]; unsigned char reg[32];
int initialized; int initialized;
int norm; v4l2_std_id norm;
int input; int input;
int enable; int enable;
int bright; int bright;
...@@ -178,7 +178,7 @@ static int bt819_init(struct i2c_client *client) ...@@ -178,7 +178,7 @@ static int bt819_init(struct i2c_client *client)
0x1a, 0x80, /* 0x1a ADC Interface */ 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] = init[0x03 * 2 - 1] =
(((timing->vdelay >> 8) & 0x03) << 6) | (((timing->vdelay >> 8) & 0x03) << 6) |
...@@ -192,7 +192,7 @@ static int bt819_init(struct i2c_client *client) ...@@ -192,7 +192,7 @@ static int bt819_init(struct i2c_client *client)
init[0x08 * 2 - 1] = timing->hscale >> 8; init[0x08 * 2 - 1] = timing->hscale >> 8;
init[0x09 * 2 - 1] = timing->hscale & 0xff; init[0x09 * 2 - 1] = timing->hscale & 0xff;
/* 0x15 in array is address 0x19 */ /* 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 */ /* reset */
bt819_write(client, 0x1f, 0x00); bt819_write(client, 0x1f, 0x00);
mdelay(1); mdelay(1);
...@@ -215,121 +215,93 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -215,121 +215,93 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg)
} }
switch (cmd) { switch (cmd) {
case 0: case VIDIOC_INT_INIT:
/* This is just for testing!!! */ /* This is just for testing!!! */
bt819_init(client); bt819_init(client);
break; break;
case DECODER_GET_CAPABILITIES: case VIDIOC_QUERYSTD:
{ case VIDIOC_INT_G_INPUT_STATUS: {
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:
{
int *iarg = arg; int *iarg = arg;
v4l2_std_id *istd = arg;
int status; int status;
int res; int res = V4L2_IN_ST_NO_SIGNAL;
v4l2_std_id std;
status = bt819_read(client, 0x00); status = bt819_read(client, 0x00);
res = 0;
if ((status & 0x80)) 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)) if ((status & 0x10))
res |= DECODER_STATUS_PAL; std = V4L2_STD_PAL;
else
std = V4L2_STD_NTSC;
if (cmd == VIDIOC_QUERYSTD)
*istd = std;
else else
res |= DECODER_STATUS_NTSC;
break;
}
res |= DECODER_STATUS_COLOR;
*iarg = res; *iarg = res;
v4l_dbg(1, debug, client, "get status %x\n", *iarg); v4l_dbg(1, debug, client, "get status %x\n", *iarg);
break; break;
} }
case DECODER_SET_NORM: case VIDIOC_S_STD:
{ {
int *iarg = arg; v4l2_std_id *iarg = arg;
struct timing *timing = NULL; 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) { if (*iarg & V4L2_STD_NTSC) {
case VIDEO_MODE_NTSC:
bt819_setbit(client, 0x01, 0, 1); bt819_setbit(client, 0x01, 0, 1);
bt819_setbit(client, 0x01, 1, 0); bt819_setbit(client, 0x01, 1, 0);
bt819_setbit(client, 0x01, 5, 0); bt819_setbit(client, 0x01, 5, 0);
bt819_write(client, 0x18, 0x68); bt819_write(client, 0x18, 0x68);
bt819_write(client, 0x19, 0x5d); bt819_write(client, 0x19, 0x5d);
/* bt819_setbit(client, 0x1a, 5, 1); */ /* bt819_setbit(client, 0x1a, 5, 1); */
timing = &timing_data[VIDEO_MODE_NTSC]; timing = &timing_data[1];
break; } else if (*iarg & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
bt819_setbit(client, 0x01, 0, 1); bt819_setbit(client, 0x01, 0, 1);
bt819_setbit(client, 0x01, 1, 1); bt819_setbit(client, 0x01, 1, 1);
bt819_setbit(client, 0x01, 5, 1); bt819_setbit(client, 0x01, 5, 1);
bt819_write(client, 0x18, 0x7f); bt819_write(client, 0x18, 0x7f);
bt819_write(client, 0x19, 0x72); bt819_write(client, 0x19, 0x72);
/* bt819_setbit(client, 0x1a, 5, 0); */ /* bt819_setbit(client, 0x1a, 5, 0); */
timing = &timing_data[VIDEO_MODE_PAL]; timing = &timing_data[0];
break; } else {
case VIDEO_MODE_AUTO: v4l_dbg(1, debug, client, "unsupported norm %llx\n", *iarg);
bt819_setbit(client, 0x01, 0, 0);
bt819_setbit(client, 0x01, 1, 0);
break;
default:
v4l_dbg(1, debug, client, "unsupported norm %x\n", *iarg);
return -EINVAL; return -EINVAL;
} }
/* case VIDEO_MODE_AUTO:
bt819_setbit(client, 0x01, 0, 0);
bt819_setbit(client, 0x01, 1, 0);*/
if (timing) {
bt819_write(client, 0x03, bt819_write(client, 0x03,
(((timing->vdelay >> 8) & 0x03) << 6) | (((timing->vdelay >> 8) & 0x03) << 6) |
(((timing->vactive >> 8) & 0x03) << 4) | (((timing->vactive >> 8) & 0x03) << 4) |
(((timing->hdelay >> 8) & 0x03) << 2) | (((timing->hdelay >> 8) & 0x03) << 2) |
((timing->hactive >> 8) & 0x03) ); ((timing->hactive >> 8) & 0x03));
bt819_write(client, 0x04, timing->vdelay & 0xff); bt819_write(client, 0x04, timing->vdelay & 0xff);
bt819_write(client, 0x05, timing->vactive & 0xff); bt819_write(client, 0x05, timing->vactive & 0xff);
bt819_write(client, 0x06, timing->hdelay & 0xff); bt819_write(client, 0x06, timing->hdelay & 0xff);
bt819_write(client, 0x07, timing->hactive & 0xff); bt819_write(client, 0x07, timing->hactive & 0xff);
bt819_write(client, 0x08, (timing->hscale >> 8) & 0xff); bt819_write(client, 0x08, (timing->hscale >> 8) & 0xff);
bt819_write(client, 0x09, timing->hscale & 0xff); bt819_write(client, 0x09, timing->hscale & 0xff);
}
decoder->norm = *iarg; decoder->norm = *iarg;
break; 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; return -EINVAL;
if (decoder->input != *iarg) { if (decoder->input != route->input) {
decoder->input = *iarg; decoder->input = route->input;
/* select mode */ /* select mode */
if (decoder->input == 0) { if (decoder->input == 0) {
bt819_setbit(client, 0x0b, 6, 0); bt819_setbit(client, 0x0b, 6, 0);
...@@ -342,75 +314,116 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -342,75 +314,116 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg)
break; 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 (decoder->enable != enable) {
if (*iarg != 0) decoder->enable = enable;
return -EINVAL; bt819_setbit(client, 0x16, 7, !enable);
}
break; break;
} }
case DECODER_ENABLE_OUTPUT: case VIDIOC_QUERYCTRL:
{ {
int *iarg = arg; struct v4l2_queryctrl *qc = arg;
int enable = (*iarg != 0);
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) { case V4L2_CID_SATURATION:
decoder->enable = enable; v4l2_ctrl_query_fill(qc, 0, 511, 1, 256);
bt819_setbit(client, 0x16, 7, !enable); break;
case V4L2_CID_HUE:
v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
break;
default:
return -EINVAL;
} }
break; 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) {
if (decoder->bright != pic->brightness) { case V4L2_CID_BRIGHTNESS:
/* We want -128 to 127 we get 0-65535 */ if (decoder->bright != ctrl->value) {
decoder->bright = pic->brightness; decoder->bright = ctrl->value;
bt819_write(client, 0x0a, bt819_write(client, 0x0a, decoder->bright);
(decoder->bright >> 8) - 128);
} }
break;
if (decoder->contrast != pic->contrast) { case V4L2_CID_CONTRAST:
/* We want 0 to 511 we get 0-65535 */ if (decoder->contrast != ctrl->value) {
decoder->contrast = pic->contrast; decoder->contrast = ctrl->value;
bt819_write(client, 0x0c, bt819_write(client, 0x0c,
(decoder->contrast >> 7) & 0xff); decoder->contrast & 0xff);
bt819_setbit(client, 0x0b, 2, bt819_setbit(client, 0x0b, 2,
((decoder->contrast >> 15) & 0x01)); ((decoder->contrast >> 8) & 0x01));
} }
break;
if (decoder->sat != pic->colour) { case V4L2_CID_SATURATION:
/* We want 0 to 511 we get 0-65535 */ if (decoder->sat != ctrl->value) {
decoder->sat = pic->colour; decoder->sat = ctrl->value;
bt819_write(client, 0x0d, bt819_write(client, 0x0d,
(decoder->sat >> 7) & 0xff); (decoder->sat >> 7) & 0xff);
bt819_setbit(client, 0x0b, 1, bt819_setbit(client, 0x0b, 1,
((decoder->sat >> 15) & 0x01)); ((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_write(client, 0x0e, (temp >> 7) & 0xff);
bt819_setbit(client, 0x0b, 0, (temp >> 15) & 0x01); bt819_setbit(client, 0x0b, 0, (temp >> 15) & 0x01);
} }
break;
if (decoder->hue != pic->hue) { case V4L2_CID_HUE:
/* We want -128 to 127 we get 0-65535 */ if (decoder->hue != ctrl->value) {
decoder->hue = pic->hue; decoder->hue = ctrl->value;
bt819_write(client, 0x0f, bt819_write(client, 0x0f, decoder->hue);
128 - (decoder->hue >> 8)); }
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; break;
} }
...@@ -462,13 +475,13 @@ static int bt819_probe(struct i2c_client *client, ...@@ -462,13 +475,13 @@ static int bt819_probe(struct i2c_client *client,
decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL);
if (decoder == NULL) if (decoder == NULL)
return -ENOMEM; return -ENOMEM;
decoder->norm = VIDEO_MODE_NTSC; decoder->norm = V4L2_STD_NTSC;
decoder->input = 0; decoder->input = 0;
decoder->enable = 1; decoder->enable = 1;
decoder->bright = 32768; decoder->bright = 0;
decoder->contrast = 32768; decoder->contrast = 0xd8; /* 100% of original signal */
decoder->hue = 32768; decoder->hue = 0;
decoder->sat = 32768; decoder->sat = 0xfe; /* 100% of original signal */
decoder->initialized = 0; decoder->initialized = 0;
i2c_set_clientdata(client, decoder); i2c_set_clientdata(client, decoder);
......
...@@ -55,8 +55,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -55,8 +55,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct bt856 { struct bt856 {
unsigned char reg[BT856_NR_REG]; unsigned char reg[BT856_NR_REG];
int norm; v4l2_std_id norm;
int enable;
}; };
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
...@@ -96,7 +95,7 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -96,7 +95,7 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
struct bt856 *encoder = i2c_get_clientdata(client); struct bt856 *encoder = i2c_get_clientdata(client);
switch (cmd) { switch (cmd) {
case 0: case VIDIOC_INT_INIT:
/* This is just for testing!!! */ /* This is just for testing!!! */
v4l_dbg(1, debug, client, "init\n"); v4l_dbg(1, debug, client, "init\n");
bt856_write(client, 0xdc, 0x18); bt856_write(client, 0xdc, 0x18);
...@@ -107,15 +106,10 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -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, 6, 0);
bt856_setbit(client, 0xdc, 4, 1); bt856_setbit(client, 0xdc, 4, 1);
switch (encoder->norm) { if (encoder->norm & V4L2_STD_NTSC)
case VIDEO_MODE_NTSC:
bt856_setbit(client, 0xdc, 2, 0); bt856_setbit(client, 0xdc, 2, 0);
break; else
case VIDEO_MODE_PAL:
bt856_setbit(client, 0xdc, 2, 1); bt856_setbit(client, 0xdc, 2, 1);
break;
}
bt856_setbit(client, 0xdc, 1, 1); bt856_setbit(client, 0xdc, 1, 1);
bt856_setbit(client, 0xde, 4, 0); bt856_setbit(client, 0xde, 4, 0);
...@@ -124,38 +118,19 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -124,38 +118,19 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
bt856_dump(client); bt856_dump(client);
break; break;
case ENCODER_GET_CAPABILITIES: case VIDIOC_INT_S_STD_OUTPUT:
{ {
struct video_encoder_capability *cap = arg; v4l2_std_id *iarg = arg;
v4l_dbg(1, debug, client, "get capabilities\n"); v4l_dbg(1, debug, client, "set norm %llx\n", *iarg);
cap->flags = VIDEO_ENCODER_PAL | if (*iarg & V4L2_STD_NTSC) {
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 %d\n", *iarg);
switch (*iarg) {
case VIDEO_MODE_NTSC:
bt856_setbit(client, 0xdc, 2, 0); bt856_setbit(client, 0xdc, 2, 0);
break; } else if (*iarg & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
bt856_setbit(client, 0xdc, 2, 1); bt856_setbit(client, 0xdc, 2, 1);
bt856_setbit(client, 0xda, 0, 0); bt856_setbit(client, 0xda, 0, 0);
//bt856_setbit(client, 0xda, 0, 1); //bt856_setbit(client, 0xda, 0, 1);
break; } else {
default:
return -EINVAL; return -EINVAL;
} }
encoder->norm = *iarg; encoder->norm = *iarg;
...@@ -164,16 +139,16 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -164,16 +139,16 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
break; 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. /* We only have video bus.
* iarg = 0: input is from bt819 * route->input= 0: input is from bt819
* iarg = 1: input is from ZR36060 */ * route->input= 1: input is from ZR36060 */
switch (*iarg) { switch (route->input) {
case 0: case 0:
bt856_setbit(client, 0xde, 4, 0); bt856_setbit(client, 0xde, 4, 0);
bt856_setbit(client, 0xde, 3, 1); bt856_setbit(client, 0xde, 3, 1);
...@@ -199,28 +174,6 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -199,28 +174,6 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg)
break; 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: default:
return -EINVAL; return -EINVAL;
} }
...@@ -249,8 +202,7 @@ static int bt856_probe(struct i2c_client *client, ...@@ -249,8 +202,7 @@ static int bt856_probe(struct i2c_client *client,
encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL);
if (encoder == NULL) if (encoder == NULL)
return -ENOMEM; return -ENOMEM;
encoder->norm = VIDEO_MODE_NTSC; encoder->norm = V4L2_STD_NTSC;
encoder->enable = 1;
i2c_set_clientdata(client, encoder); i2c_set_clientdata(client, encoder);
bt856_write(client, 0xdc, 0x18); bt856_write(client, 0xdc, 0x18);
...@@ -261,16 +213,10 @@ static int bt856_probe(struct i2c_client *client, ...@@ -261,16 +213,10 @@ static int bt856_probe(struct i2c_client *client,
//bt856_setbit(client, 0xdc, 6, 0); //bt856_setbit(client, 0xdc, 6, 0);
bt856_setbit(client, 0xdc, 4, 1); bt856_setbit(client, 0xdc, 4, 1);
switch (encoder->norm) { if (encoder->norm & V4L2_STD_NTSC)
case VIDEO_MODE_NTSC:
bt856_setbit(client, 0xdc, 2, 0); bt856_setbit(client, 0xdc, 2, 0);
break; else
case VIDEO_MODE_PAL:
bt856_setbit(client, 0xdc, 2, 1); bt856_setbit(client, 0xdc, 2, 1);
break;
}
bt856_setbit(client, 0xdc, 1, 1); bt856_setbit(client, 0xdc, 1, 1);
bt856_setbit(client, 0xde, 4, 0); bt856_setbit(client, 0xde, 4, 0);
......
...@@ -52,8 +52,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -52,8 +52,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct bt866 { struct bt866 {
u8 reg[256]; u8 reg[256];
int norm; v4l2_std_id norm;
int enable;
int bright; int bright;
int contrast; int contrast;
int hue; int hue;
...@@ -94,44 +93,21 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -94,44 +93,21 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg)
struct bt866 *encoder = i2c_get_clientdata(client); struct bt866 *encoder = i2c_get_clientdata(client);
switch (cmd) { switch (cmd) {
case ENCODER_GET_CAPABILITIES: case VIDIOC_INT_S_STD_OUTPUT:
{ {
struct video_encoder_capability *cap = arg; v4l2_std_id *iarg = arg;
v4l_dbg(1, debug, client, "get capabilities\n"); v4l_dbg(1, debug, client, "set norm %llx\n", *iarg);
cap->flags if (!(*iarg & (V4L2_STD_NTSC | V4L2_STD_PAL)))
= 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 %d\n", *iarg);
switch (*iarg) {
case VIDEO_MODE_NTSC:
break;
case VIDEO_MODE_PAL:
break;
default:
return -EINVAL; return -EINVAL;
}
encoder->norm = *iarg; encoder->norm = *iarg;
break; break;
} }
case ENCODER_SET_INPUT: case VIDIOC_INT_S_VIDEO_ROUTING:
{ {
int *iarg = arg; struct v4l2_routing *route = arg;
static const __u8 init[] = { static const __u8 init[] = {
0xc8, 0xcc, /* CRSCALE */ 0xc8, 0xcc, /* CRSCALE */
0xca, 0x91, /* CBSCALE */ 0xca, 0x91, /* CBSCALE */
...@@ -167,7 +143,7 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -167,7 +143,7 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg)
val = encoder->reg[0xdc]; val = encoder->reg[0xdc];
if (*iarg == 0) if (route->input == 0)
val |= 0x40; /* CBSWAP */ val |= 0x40; /* CBSWAP */
else else
val &= ~0x40; /* !CBSWAP */ val &= ~0x40; /* !CBSWAP */
...@@ -175,15 +151,15 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -175,15 +151,15 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg)
bt866_write(client, 0xdc, val); bt866_write(client, 0xdc, val);
val = encoder->reg[0xcc]; val = encoder->reg[0xcc];
if (*iarg == 2) if (route->input == 2)
val |= 0x01; /* OSDBAR */ val |= 0x01; /* OSDBAR */
else else
val &= ~0x01; /* !OSDBAR */ val &= ~0x01; /* !OSDBAR */
bt866_write(client, 0xcc, val); bt866_write(client, 0xcc, val);
v4l_dbg(1, debug, client, "set input %d\n", *iarg); v4l_dbg(1, debug, client, "set input %d\n", route->input);
switch (*iarg) { switch (route->input) {
case 0: case 0:
break; break;
case 1: case 1:
...@@ -194,27 +170,6 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -194,27 +170,6 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg)
break; 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;
}
case 4711: case 4711:
{ {
int *iarg = arg; int *iarg = arg;
......
...@@ -201,7 +201,7 @@ struct ks0127 { ...@@ -201,7 +201,7 @@ struct ks0127 {
int format_height; int format_height;
int cap_width; int cap_width;
int cap_height; int cap_height;
int norm; v4l2_std_id norm;
int ks_type; int ks_type;
u8 regs[256]; u8 regs[256];
}; };
...@@ -408,20 +408,22 @@ static void ks0127_reset(struct i2c_client *c) ...@@ -408,20 +408,22 @@ static void ks0127_reset(struct i2c_client *c)
static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
{ {
struct ks0127 *ks = i2c_get_clientdata(c); struct ks0127 *ks = i2c_get_clientdata(c);
struct v4l2_routing *route = arg;
int *iarg = (int *)arg; int *iarg = (int *)arg;
v4l2_std_id *istd = arg;
int status; int status;
if (!ks) if (!ks)
return -ENODEV; return -ENODEV;
switch (cmd) { switch (cmd) {
case DECODER_INIT: case VIDIOC_INT_INIT:
v4l_dbg(1, debug, c, "DECODER_INIT\n"); v4l_dbg(1, debug, c, "VIDIOC_INT_INIT\n");
ks0127_reset(c); ks0127_reset(c);
break; break;
case DECODER_SET_INPUT: case VIDIOC_INT_S_VIDEO_ROUTING:
switch(*iarg) { switch (route->input) {
case KS_INPUT_COMPOSITE_1: case KS_INPUT_COMPOSITE_1:
case KS_INPUT_COMPOSITE_2: case KS_INPUT_COMPOSITE_2:
case KS_INPUT_COMPOSITE_3: case KS_INPUT_COMPOSITE_3:
...@@ -429,7 +431,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -429,7 +431,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
case KS_INPUT_COMPOSITE_5: case KS_INPUT_COMPOSITE_5:
case KS_INPUT_COMPOSITE_6: case KS_INPUT_COMPOSITE_6:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_INPUT %d: Composite\n", *iarg); "VIDIOC_S_INPUT %d: Composite\n", *iarg);
/* autodetect 50/60 Hz */ /* autodetect 50/60 Hz */
ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); ks0127_and_or(c, KS_CMDA, 0xfc, 0x00);
/* VSE=0 */ /* VSE=0 */
...@@ -463,7 +465,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -463,7 +465,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
case KS_INPUT_SVIDEO_2: case KS_INPUT_SVIDEO_2:
case KS_INPUT_SVIDEO_3: case KS_INPUT_SVIDEO_3:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_INPUT %d: S-Video\n", *iarg); "VIDIOC_S_INPUT %d: S-Video\n", *iarg);
/* autodetect 50/60 Hz */ /* autodetect 50/60 Hz */
ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); ks0127_and_or(c, KS_CMDA, 0xfc, 0x00);
/* VSE=0 */ /* VSE=0 */
...@@ -495,9 +497,8 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -495,9 +497,8 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
case KS_INPUT_YUV656: case KS_INPUT_YUV656:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_INPUT 15: YUV656\n"); "VIDIOC_S_INPUT 15: YUV656\n");
if (ks->norm == VIDEO_MODE_NTSC || if (ks->norm & V4L2_STD_525_60)
ks->norm == KS_STD_PAL_M)
/* force 60 Hz */ /* force 60 Hz */
ks0127_and_or(c, KS_CMDA, 0xfc, 0x03); ks0127_and_or(c, KS_CMDA, 0xfc, 0x03);
else else
...@@ -541,7 +542,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -541,7 +542,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
default: default:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_INPUT: Unknown input %d\n", *iarg); "VIDIOC_INT_S_VIDEO_ROUTING: Unknown input %d\n", route->input);
break; break;
} }
...@@ -550,77 +551,37 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -550,77 +551,37 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
ks0127_write(c, KS_DEMOD, reg_defaults[KS_DEMOD]); ks0127_write(c, KS_DEMOD, reg_defaults[KS_DEMOD]);
break; break;
case DECODER_SET_OUTPUT: case VIDIOC_S_STD: /* sam This block mixes old and new norm names... */
switch(*iarg) {
case KS_OUTPUT_YUV656E:
v4l_dbg(1, debug, c,
"DECODER_SET_OUTPUT: OUTPUT_YUV656E (Missing)\n");
return -EINVAL;
case KS_OUTPUT_EXV:
v4l_dbg(1, debug, c,
"DECODER_SET_OUTPUT: OUTPUT_EXV\n");
ks0127_and_or(c, KS_OFMTA, 0xf0, 0x09);
break;
}
break;
case DECODER_SET_NORM: /* sam This block mixes old and new norm names... */
/* Set to automatic SECAM/Fsc mode */ /* Set to automatic SECAM/Fsc mode */
ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00);
ks->norm = *iarg; ks->norm = *istd;
switch (*iarg) {
/* this is untested !! */
/* It just detects PAL_N/NTSC_M (no special frequencies) */
/* And you have to set the standard a second time afterwards */
case VIDEO_MODE_AUTO:
v4l_dbg(1, debug, c,
"DECODER_SET_NORM: AUTO\n");
/* The chip determines the format */
/* based on the current field rate */
ks0127_and_or(c, KS_CMDA, 0xfc, 0x00);
ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20);
/* This is wrong for PAL ! As I said, */
/* you need to set the standard once again !! */
ks->format_height = 240;
ks->format_width = 704;
break;
case VIDEO_MODE_NTSC: if (*istd & V4L2_STD_NTSC) {
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_NORM: NTSC_M\n"); "VIDIOC_S_STD: NTSC_M\n");
ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20);
ks->format_height = 240; ks->format_height = 240;
ks->format_width = 704; ks->format_width = 704;
break; } else if (*istd & V4L2_STD_PAL_N) {
case KS_STD_NTSC_N:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"KS0127_SET_NORM: NTSC_N (fixme)\n"); "KS0127_SET_NORM: NTSC_N (fixme)\n");
ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40);
ks->format_height = 240; ks->format_height = 240;
ks->format_width = 704; ks->format_width = 704;
break; } else if (*istd & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_NORM: PAL_N\n"); "VIDIOC_S_STD: PAL_N\n");
ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20);
ks->format_height = 290; ks->format_height = 290;
ks->format_width = 704; ks->format_width = 704;
break; } else if (*istd & V4L2_STD_PAL_M) {
case KS_STD_PAL_M:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"KS0127_SET_NORM: PAL_M (fixme)\n"); "KS0127_SET_NORM: PAL_M (fixme)\n");
ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40);
ks->format_height = 290; ks->format_height = 290;
ks->format_width = 704; ks->format_width = 704;
break; } else if (*istd & V4L2_STD_SECAM) {
case VIDEO_MODE_SECAM:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"KS0127_SET_NORM: SECAM\n"); "KS0127_SET_NORM: SECAM\n");
ks->format_height = 290; ks->format_height = 290;
...@@ -632,29 +593,34 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -632,29 +593,34 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
schedule_timeout_interruptible(HZ/10+1); schedule_timeout_interruptible(HZ/10+1);
/* did it autodetect? */ /* did it autodetect? */
if (ks0127_read(c, KS_DEMOD) & 0x40) if (!(ks0127_read(c, KS_DEMOD) & 0x40))
break;
/* force to secam mode */ /* force to secam mode */
ks0127_and_or(c, KS_DEMOD, 0xf0, 0x0f); ks0127_and_or(c, KS_DEMOD, 0xf0, 0x0f);
break; } else {
default:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_NORM: Unknown norm %d\n", *iarg); "VIDIOC_S_STD: Unknown norm %llx\n", *istd);
break;
} }
break; break;
case DECODER_SET_PICTURE: case VIDIOC_QUERYCTRL:
{
return -EINVAL;
}
case VIDIOC_S_CTRL:
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_SET_PICTURE: not yet supported\n"); "VIDIOC_S_CTRL: not yet supported\n");
return -EINVAL; return -EINVAL;
/* sam todo: KS0127_SET_BRIGHTNESS: Merge into DECODER_SET_PICTURE */ case VIDIOC_G_CTRL:
/* sam todo: KS0127_SET_CONTRAST: Merge into DECODER_SET_PICTURE */ v4l_dbg(1, debug, c,
/* sam todo: KS0127_SET_HUE: Merge into DECODER_SET_PICTURE? */ "VIDIOC_G_CTRL: not yet supported\n");
/* sam todo: KS0127_SET_SATURATION: Merge into DECODER_SET_PICTURE */ return -EINVAL;
/* sam todo: KS0127_SET_BRIGHTNESS: Merge into VIDIOC_S_CTRL */
/* sam todo: KS0127_SET_CONTRAST: Merge into VIDIOC_S_CTRL */
/* sam todo: KS0127_SET_HUE: Merge into VIDIOC_S_CTRL? */
/* sam todo: KS0127_SET_SATURATION: Merge into VIDIOC_S_CTRL */
/* sam todo: KS0127_SET_AGC_MODE: */ /* sam todo: KS0127_SET_AGC_MODE: */
/* sam todo: KS0127_SET_AGC: */ /* sam todo: KS0127_SET_AGC: */
/* sam todo: KS0127_SET_CHROMA_MODE: */ /* sam todo: KS0127_SET_CHROMA_MODE: */
...@@ -670,22 +636,21 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -670,22 +636,21 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
/* sam todo: KS0127_SET_UNUSEV: */ /* sam todo: KS0127_SET_UNUSEV: */
/* sam todo: KS0127_SET_VSALIGN_MODE: */ /* sam todo: KS0127_SET_VSALIGN_MODE: */
case DECODER_ENABLE_OUTPUT: case VIDIOC_STREAMON:
case VIDIOC_STREAMOFF:
{ {
int enable; int enable = cmd == VIDIOC_STREAMON;
iarg = arg;
enable = (*iarg != 0);
if (enable) { if (enable) {
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_ENABLE_OUTPUT on\n"); "VIDIOC_STREAMON\n");
/* All output pins on */ /* All output pins on */
ks0127_and_or(c, KS_OFMTA, 0xcf, 0x30); ks0127_and_or(c, KS_OFMTA, 0xcf, 0x30);
/* Obey the OEN pin */ /* Obey the OEN pin */
ks0127_and_or(c, KS_CDEM, 0x7f, 0x00); ks0127_and_or(c, KS_CDEM, 0x7f, 0x00);
} else { } else {
v4l_dbg(1, debug, c, v4l_dbg(1, debug, c,
"DECODER_ENABLE_OUTPUT off\n"); "VIDIOC_STREAMOFF\n");
/* Video output pins off */ /* Video output pins off */
ks0127_and_or(c, KS_OFMTA, 0xcf, 0x00); ks0127_and_or(c, KS_OFMTA, 0xcf, 0x00);
/* Ignore the OEN pin */ /* Ignore the OEN pin */
...@@ -699,19 +664,26 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) ...@@ -699,19 +664,26 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg)
/* sam todo: KS0127_SET_HEIGHT: */ /* sam todo: KS0127_SET_HEIGHT: */
/* sam todo: KS0127_SET_HSCALE: */ /* sam todo: KS0127_SET_HSCALE: */
case DECODER_GET_STATUS: case VIDIOC_QUERYSTD:
v4l_dbg(1, debug, c, "DECODER_GET_STATUS\n"); case VIDIOC_INT_G_INPUT_STATUS: {
*iarg = 0; int stat = V4L2_IN_ST_NO_SIGNAL;
v4l2_std_id std = V4L2_STD_ALL;
v4l_dbg(1, debug, c, "VIDIOC_QUERYSTD/VIDIOC_INT_G_INPUT_STATUS\n");
status = ks0127_read(c, KS_STAT); status = ks0127_read(c, KS_STAT);
if (!(status & 0x20)) /* NOVID not set */ if (!(status & 0x20)) /* NOVID not set */
*iarg = (*iarg | DECODER_STATUS_GOOD); stat = 0;
if ((status & 0x01)) /* CLOCK set */ if (!(status & 0x01)) /* CLOCK set */
*iarg = (*iarg | DECODER_STATUS_COLOR); stat |= V4L2_IN_ST_NO_COLOR;
if ((status & 0x08)) /* PALDET set */ if ((status & 0x08)) /* PALDET set */
*iarg = (*iarg | DECODER_STATUS_PAL); std = V4L2_STD_PAL;
else else
*iarg = (*iarg | DECODER_STATUS_NTSC); std = V4L2_STD_NTSC;
if (cmd == VIDIOC_QUERYSTD)
*istd = std;
else
*iarg = stat;
break; break;
}
/* Catch any unknown command */ /* Catch any unknown command */
default: default:
......
...@@ -54,7 +54,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -54,7 +54,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct saa7110 { struct saa7110 {
u8 reg[SAA7110_NR_REG]; u8 reg[SAA7110_NR_REG];
int norm; v4l2_std_id norm;
int input; int input;
int enable; int enable;
int bright; int bright;
...@@ -176,7 +176,7 @@ static const unsigned char initseq[1 + SAA7110_NR_REG] = { ...@@ -176,7 +176,7 @@ static const unsigned char initseq[1 + SAA7110_NR_REG] = {
/* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02
}; };
static int determine_norm(struct i2c_client *client) static v4l2_std_id determine_norm(struct i2c_client *client)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
struct saa7110 *decoder = i2c_get_clientdata(client); struct saa7110 *decoder = i2c_get_clientdata(client);
...@@ -198,11 +198,11 @@ static int determine_norm(struct i2c_client *client) ...@@ -198,11 +198,11 @@ static int determine_norm(struct i2c_client *client)
if (status & 0x20) { if (status & 0x20) {
v4l_dbg(1, debug, client, "status=0x%02x (NTSC/no color)\n", status); v4l_dbg(1, debug, client, "status=0x%02x (NTSC/no color)\n", status);
//saa7110_write(client,0x2E,0x81); //saa7110_write(client,0x2E,0x81);
return VIDEO_MODE_NTSC; return V4L2_STD_NTSC;
} }
v4l_dbg(1, debug, client, "status=0x%02x (PAL/no color)\n", status); v4l_dbg(1, debug, client, "status=0x%02x (PAL/no color)\n", status);
//saa7110_write(client,0x2E,0x9A); //saa7110_write(client,0x2E,0x9A);
return VIDEO_MODE_PAL; return V4L2_STD_PAL;
} }
//saa7110_write(client,0x06,0x03); //saa7110_write(client,0x06,0x03);
if (status & 0x20) { /* 60Hz */ if (status & 0x20) { /* 60Hz */
...@@ -211,7 +211,7 @@ static int determine_norm(struct i2c_client *client) ...@@ -211,7 +211,7 @@ static int determine_norm(struct i2c_client *client)
saa7110_write(client, 0x0F, 0x50); saa7110_write(client, 0x0F, 0x50);
saa7110_write(client, 0x11, 0x2C); saa7110_write(client, 0x11, 0x2C);
//saa7110_write(client,0x2E,0x81); //saa7110_write(client,0x2E,0x81);
return VIDEO_MODE_NTSC; return V4L2_STD_NTSC;
} }
/* 50Hz -> PAL/SECAM */ /* 50Hz -> PAL/SECAM */
...@@ -228,10 +228,10 @@ static int determine_norm(struct i2c_client *client) ...@@ -228,10 +228,10 @@ static int determine_norm(struct i2c_client *client)
if ((status & 0x03) == 0x01) { if ((status & 0x03) == 0x01) {
v4l_dbg(1, debug, client, "status=0x%02x (SECAM)\n", status); v4l_dbg(1, debug, client, "status=0x%02x (SECAM)\n", status);
saa7110_write(client, 0x0D, 0x87); saa7110_write(client, 0x0D, 0x87);
return VIDEO_MODE_SECAM; return V4L2_STD_SECAM;
} }
v4l_dbg(1, debug, client, "status=0x%02x (PAL)\n", status); v4l_dbg(1, debug, client, "status=0x%02x (PAL)\n", status);
return VIDEO_MODE_PAL; return V4L2_STD_PAL;
} }
static int static int
...@@ -240,112 +240,81 @@ saa7110_command (struct i2c_client *client, ...@@ -240,112 +240,81 @@ saa7110_command (struct i2c_client *client,
void *arg) void *arg)
{ {
struct saa7110 *decoder = i2c_get_clientdata(client); struct saa7110 *decoder = i2c_get_clientdata(client);
struct v4l2_routing *route = arg;
v4l2_std_id std;
int v; int v;
switch (cmd) { switch (cmd) {
case 0: case VIDIOC_INT_INIT:
//saa7110_write_block(client, initseq, sizeof(initseq)); //saa7110_write_block(client, initseq, sizeof(initseq));
break; break;
case DECODER_GET_CAPABILITIES: case VIDIOC_INT_G_INPUT_STATUS:
{
struct video_decoder_capability *dc = arg;
dc->flags =
VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC |
VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO;
dc->inputs = SAA7110_MAX_INPUT;
dc->outputs = SAA7110_MAX_OUTPUT;
break;
}
case DECODER_GET_STATUS:
{ {
int res = V4L2_IN_ST_NO_SIGNAL;
int status; int status;
int res = 0;
status = saa7110_read(client); status = saa7110_read(client);
v4l_dbg(1, debug, client, "status=0x%02x norm=%d\n", v4l_dbg(1, debug, client, "status=0x%02x norm=%llx\n",
status, decoder->norm); status, decoder->norm);
if (!(status & 0x40)) if (!(status & 0x40))
res |= DECODER_STATUS_GOOD; res = 0;
if (status & 0x03) if (!(status & 0x03))
res |= DECODER_STATUS_COLOR; res |= V4L2_IN_ST_NO_COLOR;
switch (decoder->norm) { *(int *) arg = res;
case VIDEO_MODE_NTSC:
res |= DECODER_STATUS_NTSC;
break;
case VIDEO_MODE_PAL:
res |= DECODER_STATUS_PAL;
break;
case VIDEO_MODE_SECAM:
res |= DECODER_STATUS_SECAM;
break; break;
} }
*(int *) arg = res;
case VIDIOC_QUERYSTD:
{
*(v4l2_std_id *)arg = determine_norm(client);
break; break;
} }
case DECODER_SET_NORM: case VIDIOC_S_STD:
v = *(int *) arg; std = *(v4l2_std_id *) arg;
if (decoder->norm != v) { if (decoder->norm != std) {
decoder->norm = v; decoder->norm = std;
//saa7110_write(client, 0x06, 0x03); //saa7110_write(client, 0x06, 0x03);
switch (v) { if (std & V4L2_STD_NTSC) {
case VIDEO_MODE_NTSC:
saa7110_write(client, 0x0D, 0x86); saa7110_write(client, 0x0D, 0x86);
saa7110_write(client, 0x0F, 0x50); saa7110_write(client, 0x0F, 0x50);
saa7110_write(client, 0x11, 0x2C); saa7110_write(client, 0x11, 0x2C);
//saa7110_write(client, 0x2E, 0x81); //saa7110_write(client, 0x2E, 0x81);
v4l_dbg(1, debug, client, "switched to NTSC\n"); v4l_dbg(1, debug, client, "switched to NTSC\n");
break; } else if (std & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
saa7110_write(client, 0x0D, 0x86); saa7110_write(client, 0x0D, 0x86);
saa7110_write(client, 0x0F, 0x10); saa7110_write(client, 0x0F, 0x10);
saa7110_write(client, 0x11, 0x59); saa7110_write(client, 0x11, 0x59);
//saa7110_write(client, 0x2E, 0x9A); //saa7110_write(client, 0x2E, 0x9A);
v4l_dbg(1, debug, client, "switched to PAL\n"); v4l_dbg(1, debug, client, "switched to PAL\n");
break; } else if (std & V4L2_STD_SECAM) {
case VIDEO_MODE_SECAM:
saa7110_write(client, 0x0D, 0x87); saa7110_write(client, 0x0D, 0x87);
saa7110_write(client, 0x0F, 0x10); saa7110_write(client, 0x0F, 0x10);
saa7110_write(client, 0x11, 0x59); saa7110_write(client, 0x11, 0x59);
//saa7110_write(client, 0x2E, 0x9A); //saa7110_write(client, 0x2E, 0x9A);
v4l_dbg(1, debug, client, "switched to SECAM\n"); v4l_dbg(1, debug, client, "switched to SECAM\n");
break; } else {
case VIDEO_MODE_AUTO: return -EINVAL;
v4l_dbg(1, debug, client, "switched to AUTO\n");
decoder->norm = determine_norm(client);
*(int *) arg = decoder->norm;
break;
default:
return -EPERM;
} }
} }
break; break;
case DECODER_SET_INPUT: case VIDIOC_INT_S_VIDEO_ROUTING:
v = *(int *) arg; if (route->input < 0 || route->input >= SAA7110_MAX_INPUT) {
if (v < 0 || v >= SAA7110_MAX_INPUT) { v4l_dbg(1, debug, client, "input=%d not available\n", route->input);
v4l_dbg(1, debug, client, "input=%d not available\n", v);
return -EINVAL; return -EINVAL;
} }
if (decoder->input != v) { if (decoder->input != route->input) {
saa7110_selmux(client, v); saa7110_selmux(client, route->input);
v4l_dbg(1, debug, client, "switched to input=%d\n", v); v4l_dbg(1, debug, client, "switched to input=%d\n", route->input);
} }
break; break;
case DECODER_SET_OUTPUT: case VIDIOC_STREAMON:
v = *(int *) arg; case VIDIOC_STREAMOFF:
/* not much choice of outputs */ v = cmd == VIDIOC_STREAMON;
if (v != 0)
return -EINVAL;
break;
case DECODER_ENABLE_OUTPUT:
v = *(int *) arg;
if (decoder->enable != v) { if (decoder->enable != v) {
decoder->enable = v; decoder->enable = v;
saa7110_write(client, 0x0E, v ? 0x18 : 0x80); saa7110_write(client, 0x0E, v ? 0x18 : 0x80);
...@@ -353,46 +322,81 @@ saa7110_command (struct i2c_client *client, ...@@ -353,46 +322,81 @@ saa7110_command (struct i2c_client *client,
} }
break; break;
case DECODER_SET_PICTURE: case VIDIOC_QUERYCTRL:
{ {
struct video_picture *pic = arg; struct v4l2_queryctrl *qc = arg;
switch (qc->id) {
case V4L2_CID_BRIGHTNESS:
return v4l2_ctrl_query_fill(qc, 0, 255, 1, 128);
case V4L2_CID_CONTRAST:
case V4L2_CID_SATURATION:
return v4l2_ctrl_query_fill(qc, 0, 127, 1, 64);
case V4L2_CID_HUE:
return v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
default:
return -EINVAL;
}
break;
}
if (decoder->bright != pic->brightness) { case VIDIOC_G_CTRL:
/* We want 0 to 255 we get 0-65535 */ {
decoder->bright = pic->brightness; struct v4l2_control *ctrl = arg;
saa7110_write(client, 0x19, decoder->bright >> 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;
} }
if (decoder->contrast != pic->contrast) { break;
/* We want 0 to 127 we get 0-65535 */
decoder->contrast = pic->contrast;
saa7110_write(client, 0x13,
decoder->contrast >> 9);
} }
if (decoder->sat != pic->colour) {
/* We want 0 to 127 we get 0-65535 */ case VIDIOC_S_CTRL:
decoder->sat = pic->colour; {
saa7110_write(client, 0x12, decoder->sat >> 9); struct v4l2_control *ctrl = arg;
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
if (decoder->bright != ctrl->value) {
decoder->bright = ctrl->value;
saa7110_write(client, 0x19, decoder->bright);
} }
if (decoder->hue != pic->hue) { break;
/* We want -128 to 127 we get 0-65535 */ case V4L2_CID_CONTRAST:
decoder->hue = pic->hue; if (decoder->contrast != ctrl->value) {
saa7110_write(client, 0x07, decoder->contrast = ctrl->value;
(decoder->hue >> 8) - 128); saa7110_write(client, 0x13, decoder->contrast);
} }
break; break;
case V4L2_CID_SATURATION:
if (decoder->sat != ctrl->value) {
decoder->sat = ctrl->value;
saa7110_write(client, 0x12, decoder->sat);
} }
case DECODER_DUMP:
if (!debug)
break; break;
for (v = 0; v < SAA7110_NR_REG; v += 16) { case V4L2_CID_HUE:
int j; if (decoder->hue != ctrl->value) {
v4l_dbg(1, debug, client, "%02x:", v); decoder->hue = ctrl->value;
for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) saa7110_write(client, 0x07, decoder->hue);
printk(KERN_CONT " %02x", decoder->reg[v + j]);
printk(KERN_CONT "\n");
} }
break; break;
default:
return -EINVAL;
}
break;
}
default: default:
v4l_dbg(1, debug, client, "unknown command %08x\n", cmd); v4l_dbg(1, debug, client, "unknown command %08x\n", cmd);
...@@ -429,7 +433,7 @@ static int saa7110_probe(struct i2c_client *client, ...@@ -429,7 +433,7 @@ static int saa7110_probe(struct i2c_client *client,
decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL);
if (!decoder) if (!decoder)
return -ENOMEM; return -ENOMEM;
decoder->norm = VIDEO_MODE_PAL; decoder->norm = V4L2_STD_PAL;
decoder->input = 0; decoder->input = 0;
decoder->enable = 1; decoder->enable = 1;
decoder->bright = 32768; decoder->bright = 32768;
......
This diff is collapsed.
This diff is collapsed.
...@@ -49,8 +49,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -49,8 +49,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct saa7185 { struct saa7185 {
unsigned char reg[128]; unsigned char reg[128];
int norm; v4l2_std_id norm;
int enable;
int bright; int bright;
int contrast; int contrast;
int hue; int hue;
...@@ -218,68 +217,43 @@ static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -218,68 +217,43 @@ static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg)
struct saa7185 *encoder = i2c_get_clientdata(client); struct saa7185 *encoder = i2c_get_clientdata(client);
switch (cmd) { switch (cmd) {
case 0: case VIDIOC_INT_INIT:
saa7185_write_block(client, init_common, saa7185_write_block(client, init_common,
sizeof(init_common)); sizeof(init_common));
switch (encoder->norm) { if (encoder->norm & V4L2_STD_NTSC)
case VIDEO_MODE_NTSC:
saa7185_write_block(client, init_ntsc, saa7185_write_block(client, init_ntsc,
sizeof(init_ntsc)); sizeof(init_ntsc));
break; else
case VIDEO_MODE_PAL:
saa7185_write_block(client, init_pal, saa7185_write_block(client, init_pal,
sizeof(init_pal)); sizeof(init_pal));
break; break;
}
break;
case ENCODER_GET_CAPABILITIES:
{
struct video_encoder_capability *cap = arg;
cap->flags =
VIDEO_ENCODER_PAL | VIDEO_ENCODER_NTSC |
VIDEO_ENCODER_SECAM | VIDEO_ENCODER_CCIR;
cap->inputs = 1;
cap->outputs = 1;
break;
}
case ENCODER_SET_NORM: case VIDIOC_INT_S_STD_OUTPUT:
{ {
int *iarg = arg; v4l2_std_id *iarg = arg;
//saa7185_write_block(client, init_common, sizeof(init_common)); //saa7185_write_block(client, init_common, sizeof(init_common));
switch (*iarg) { if (*iarg & V4L2_STD_NTSC)
case VIDEO_MODE_NTSC:
saa7185_write_block(client, init_ntsc, saa7185_write_block(client, init_ntsc,
sizeof(init_ntsc)); sizeof(init_ntsc));
break; else if (*iarg & V4L2_STD_PAL)
case VIDEO_MODE_PAL:
saa7185_write_block(client, init_pal, saa7185_write_block(client, init_pal,
sizeof(init_pal)); sizeof(init_pal));
break; else
case VIDEO_MODE_SECAM:
default:
return -EINVAL; return -EINVAL;
}
encoder->norm = *iarg; encoder->norm = *iarg;
break; break;
} }
case ENCODER_SET_INPUT: case VIDIOC_INT_S_VIDEO_ROUTING:
{ {
int *iarg = arg; struct v4l2_routing *route = arg;
/* RJ: *iarg = 0: input is from SA7111 /* RJ: route->input = 0: input is from SA7111
*iarg = 1: input is from ZR36060 */ route->input = 1: input is from ZR36060 */
switch (*iarg) { switch (route->input) {
case 0: case 0:
/* turn off colorbar */ /* turn off colorbar */
saa7185_write(client, 0x3a, 0x0f); saa7185_write(client, 0x3a, 0x0f);
...@@ -315,27 +289,6 @@ static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -315,27 +289,6 @@ static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg)
break; 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;
saa7185_write(client, 0x61,
(encoder->reg[0x61] & 0xbf) |
(encoder->enable ? 0x00 : 0x40));
break;
}
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -365,8 +318,7 @@ static int saa7185_probe(struct i2c_client *client, ...@@ -365,8 +318,7 @@ static int saa7185_probe(struct i2c_client *client,
encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL);
if (encoder == NULL) if (encoder == NULL)
return -ENOMEM; return -ENOMEM;
encoder->norm = VIDEO_MODE_NTSC; encoder->norm = V4L2_STD_NTSC;
encoder->enable = 1;
i2c_set_clientdata(client, encoder); i2c_set_clientdata(client, encoder);
i = saa7185_write_block(client, init_common, sizeof(init_common)); i = saa7185_write_block(client, init_common, sizeof(init_common));
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-i2c-drv-legacy.h> #include <media/v4l2-i2c-drv-legacy.h>
#include <linux/videodev.h> #include <linux/videodev.h>
#include <linux/videodev2.h>
#include <linux/video_decoder.h> #include <linux/video_decoder.h>
MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver");
...@@ -44,7 +45,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -44,7 +45,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
struct vpx3220 { struct vpx3220 {
unsigned char reg[255]; unsigned char reg[255];
int norm; v4l2_std_id norm;
int input; int input;
int enable; int enable;
int bright; int bright;
...@@ -259,79 +260,41 @@ static const unsigned short init_fp[] = { ...@@ -259,79 +260,41 @@ static const unsigned short init_fp[] = {
0x4b, 0x298, /* PLL gain */ 0x4b, 0x298, /* PLL gain */
}; };
static void vpx3220_dump_i2c(struct i2c_client *client)
{
int len = sizeof(init_common);
const unsigned char *data = init_common;
while (len > 1) {
v4l_dbg(1, debug, client, "i2c reg 0x%02x data 0x%02x\n",
*data, vpx3220_read(client, *data));
data += 2;
len -= 2;
}
}
static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg)
{ {
struct vpx3220 *decoder = i2c_get_clientdata(client); struct vpx3220 *decoder = i2c_get_clientdata(client);
switch (cmd) { switch (cmd) {
case 0: case VIDIOC_INT_INIT:
{ {
vpx3220_write_block(client, init_common, vpx3220_write_block(client, init_common,
sizeof(init_common)); sizeof(init_common));
vpx3220_write_fp_block(client, init_fp, vpx3220_write_fp_block(client, init_fp,
sizeof(init_fp) >> 1); sizeof(init_fp) >> 1);
switch (decoder->norm) { if (decoder->norm & V4L2_STD_NTSC) {
case VIDEO_MODE_NTSC:
vpx3220_write_fp_block(client, init_ntsc, vpx3220_write_fp_block(client, init_ntsc,
sizeof(init_ntsc) >> 1); sizeof(init_ntsc) >> 1);
break; } else if (decoder->norm & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
vpx3220_write_fp_block(client, init_pal, vpx3220_write_fp_block(client, init_pal,
sizeof(init_pal) >> 1); sizeof(init_pal) >> 1);
break; } else if (decoder->norm & V4L2_STD_SECAM) {
case VIDEO_MODE_SECAM:
vpx3220_write_fp_block(client, init_secam, vpx3220_write_fp_block(client, init_secam,
sizeof(init_secam) >> 1); sizeof(init_secam) >> 1);
break; } else {
default:
vpx3220_write_fp_block(client, init_pal, vpx3220_write_fp_block(client, init_pal,
sizeof(init_pal) >> 1); sizeof(init_pal) >> 1);
break;
} }
break; break;
} }
case DECODER_DUMP: case VIDIOC_QUERYSTD:
{ case VIDIOC_INT_G_INPUT_STATUS:
vpx3220_dump_i2c(client);
break;
}
case DECODER_GET_CAPABILITIES:
{ {
struct video_decoder_capability *cap = arg; int res = V4L2_IN_ST_NO_SIGNAL, status;
v4l2_std_id std = 0;
v4l_dbg(1, debug, client, "DECODER_GET_CAPABILITIES\n"); v4l_dbg(1, debug, client, "VIDIOC_QUERYSTD/VIDIOC_INT_G_INPUT_STATUS\n");
cap->flags = VIDEO_DECODER_PAL |
VIDEO_DECODER_NTSC |
VIDEO_DECODER_SECAM |
VIDEO_DECODER_AUTO |
VIDEO_DECODER_CCIR;
cap->inputs = 3;
cap->outputs = 1;
break;
}
case DECODER_GET_STATUS:
{
int res = 0, status;
v4l_dbg(1, debug, client, "DECODER_GET_STATUS\n");
status = vpx3220_fp_read(client, 0x0f3); status = vpx3220_fp_read(client, 0x0f3);
...@@ -341,35 +304,38 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -341,35 +304,38 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg)
return status; return status;
if ((status & 0x20) == 0) { if ((status & 0x20) == 0) {
res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR; res = 0;
switch (status & 0x18) { switch (status & 0x18) {
case 0x00: case 0x00:
case 0x10: case 0x10:
case 0x14: case 0x14:
case 0x18: case 0x18:
res |= DECODER_STATUS_PAL; std = V4L2_STD_PAL;
break; break;
case 0x08: case 0x08:
res |= DECODER_STATUS_SECAM; std = V4L2_STD_SECAM;
break; break;
case 0x04: case 0x04:
case 0x0c: case 0x0c:
case 0x1c: case 0x1c:
res |= DECODER_STATUS_NTSC; std = V4L2_STD_NTSC;
break; break;
} }
} }
*(int *) arg = res; if (cmd == VIDIOC_QUERYSTD)
*(v4l2_std_id *)arg = std;
else
*(int *)arg = res;
break; break;
} }
case DECODER_SET_NORM: case VIDIOC_S_STD:
{ {
int *iarg = arg, data; v4l2_std_id *iarg = arg;
int temp_input; int temp_input;
/* Here we back up the input selection because it gets /* Here we back up the input selection because it gets
...@@ -377,36 +343,23 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -377,36 +343,23 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg)
choosen video norm */ choosen video norm */
temp_input = vpx3220_fp_read(client, 0xf2); temp_input = vpx3220_fp_read(client, 0xf2);
v4l_dbg(1, debug, client, "DECODER_SET_NORM %d\n", *iarg); v4l_dbg(1, debug, client, "VIDIOC_S_STD %llx\n", *iarg);
switch (*iarg) { if (*iarg & V4L2_STD_NTSC) {
case VIDEO_MODE_NTSC:
vpx3220_write_fp_block(client, init_ntsc, vpx3220_write_fp_block(client, init_ntsc,
sizeof(init_ntsc) >> 1); sizeof(init_ntsc) >> 1);
v4l_dbg(1, debug, client, "norm switched to NTSC\n"); v4l_dbg(1, debug, client, "norm switched to NTSC\n");
break; } else if (*iarg & V4L2_STD_PAL) {
case VIDEO_MODE_PAL:
vpx3220_write_fp_block(client, init_pal, vpx3220_write_fp_block(client, init_pal,
sizeof(init_pal) >> 1); sizeof(init_pal) >> 1);
v4l_dbg(1, debug, client, "norm switched to PAL\n"); v4l_dbg(1, debug, client, "norm switched to PAL\n");
break; } else if (*iarg & V4L2_STD_SECAM) {
case VIDEO_MODE_SECAM:
vpx3220_write_fp_block(client, init_secam, vpx3220_write_fp_block(client, init_secam,
sizeof(init_secam) >> 1); sizeof(init_secam) >> 1);
v4l_dbg(1, debug, client, "norm switched to SECAM\n"); v4l_dbg(1, debug, client, "norm switched to SECAM\n");
break; } else {
case VIDEO_MODE_AUTO:
/* FIXME This is only preliminary support */
data = vpx3220_fp_read(client, 0xf2) & 0x20;
vpx3220_fp_write(client, 0xf2, 0x00c0 | data);
v4l_dbg(1, debug, client, "norm switched to AUTO\n");
break;
default:
return -EINVAL; return -EINVAL;
} }
decoder->norm = *iarg; decoder->norm = *iarg;
/* And here we set the backed up video input again */ /* And here we set the backed up video input again */
...@@ -415,9 +368,10 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -415,9 +368,10 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg)
break; break;
} }
case DECODER_SET_INPUT: case VIDIOC_INT_S_VIDEO_ROUTING:
{ {
int *iarg = arg, data; struct v4l2_routing *route = arg;
int data;
/* RJ: *iarg = 0: ST8 (PCTV) input /* RJ: *iarg = 0: ST8 (PCTV) input
*iarg = 1: COMPOSITE input *iarg = 1: COMPOSITE input
...@@ -429,73 +383,117 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -429,73 +383,117 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg)
{0x0e, 1} {0x0e, 1}
}; };
if (*iarg < 0 || *iarg > 2) if (route->input < 0 || route->input > 2)
return -EINVAL; return -EINVAL;
v4l_dbg(1, debug, client, "input switched to %s\n", inputs[*iarg]); v4l_dbg(1, debug, client, "input switched to %s\n", inputs[route->input]);
vpx3220_write(client, 0x33, input[*iarg][0]); vpx3220_write(client, 0x33, input[route->input][0]);
data = vpx3220_fp_read(client, 0xf2) & ~(0x0020); data = vpx3220_fp_read(client, 0xf2) & ~(0x0020);
if (data < 0) if (data < 0)
return data; return data;
/* 0x0010 is required to latch the setting */ /* 0x0010 is required to latch the setting */
vpx3220_fp_write(client, 0xf2, vpx3220_fp_write(client, 0xf2,
data | (input[*iarg][1] << 5) | 0x0010); data | (input[route->input][1] << 5) | 0x0010);
udelay(10); udelay(10);
break; break;
} }
case DECODER_SET_OUTPUT: case VIDIOC_STREAMON:
case VIDIOC_STREAMOFF:
{
int on = cmd == VIDIOC_STREAMON;
v4l_dbg(1, debug, client, "VIDIOC_STREAM%s\n", on ? "ON" : "OFF");
vpx3220_write(client, 0xf2, (on ? 0x1b : 0x00));
break;
}
case VIDIOC_QUERYCTRL:
{ {
int *iarg = arg; struct v4l2_queryctrl *qc = arg;
switch (qc->id) {
case V4L2_CID_BRIGHTNESS:
v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
break;
case V4L2_CID_CONTRAST:
v4l2_ctrl_query_fill(qc, 0, 63, 1, 32);
break;
case V4L2_CID_SATURATION:
v4l2_ctrl_query_fill(qc, 0, 4095, 1, 2048);
break;
case V4L2_CID_HUE:
v4l2_ctrl_query_fill(qc, -512, 511, 1, 0);
break;
/* not much choice of outputs */ default:
if (*iarg != 0) {
return -EINVAL; return -EINVAL;
} }
break; break;
} }
case DECODER_ENABLE_OUTPUT: case VIDIOC_G_CTRL:
{ {
int *iarg = arg; struct v4l2_control *ctrl = arg;
v4l_dbg(1, debug, client, "DECODER_ENABLE_OUTPUT %d\n", *iarg); switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00)); 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; break;
} }
case DECODER_SET_PICTURE: case VIDIOC_S_CTRL:
{ {
struct video_picture *pic = arg; struct v4l2_control *ctrl = arg;
if (decoder->bright != pic->brightness) { switch (ctrl->id) {
/* We want -128 to 128 we get 0-65535 */ case V4L2_CID_BRIGHTNESS:
decoder->bright = pic->brightness; if (decoder->bright != ctrl->value) {
vpx3220_write(client, 0xe6, decoder->bright = ctrl->value;
(decoder->bright - 32768) >> 8); vpx3220_write(client, 0xe6, decoder->bright);
} }
if (decoder->contrast != pic->contrast) { break;
/* We want 0 to 64 we get 0-65535 */ case V4L2_CID_CONTRAST:
if (decoder->contrast != ctrl->value) {
/* Bit 7 and 8 is for noise shaping */ /* Bit 7 and 8 is for noise shaping */
decoder->contrast = pic->contrast; decoder->contrast = ctrl->value;
vpx3220_write(client, 0xe7, vpx3220_write(client, 0xe7,
(decoder->contrast >> 10) + 192); decoder->contrast + 192);
}
break;
case V4L2_CID_SATURATION:
if (decoder->sat != ctrl->value) {
decoder->sat = ctrl->value;
vpx3220_fp_write(client, 0xa0, decoder->sat);
} }
if (decoder->sat != pic->colour) { break;
/* We want 0 to 4096 we get 0-65535 */ case V4L2_CID_HUE:
decoder->sat = pic->colour; if (decoder->hue != ctrl->value) {
vpx3220_fp_write(client, 0xa0, decoder->hue = ctrl->value;
decoder->sat >> 4); vpx3220_fp_write(client, 0x1c, decoder->hue);
} }
if (decoder->hue != pic->hue) { break;
/* We want -512 to 512 we get 0-65535 */ default:
decoder->hue = pic->hue; return -EINVAL;
vpx3220_fp_write(client, 0x1c,
((decoder->hue - 32768) >> 6) & 0xFFF);
} }
break; break;
} }
...@@ -541,7 +539,7 @@ static int vpx3220_probe(struct i2c_client *client, ...@@ -541,7 +539,7 @@ static int vpx3220_probe(struct i2c_client *client,
decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL);
if (decoder == NULL) if (decoder == NULL)
return -ENOMEM; return -ENOMEM;
decoder->norm = VIDEO_MODE_PAL; decoder->norm = V4L2_STD_PAL;
decoder->input = 0; decoder->input = 0;
decoder->enable = 1; decoder->enable = 1;
decoder->bright = 32768; decoder->bright = 32768;
......
...@@ -32,7 +32,7 @@ config VIDEO_ZORAN_ZR36060 ...@@ -32,7 +32,7 @@ config VIDEO_ZORAN_ZR36060
config VIDEO_ZORAN_BUZ config VIDEO_ZORAN_BUZ
tristate "Iomega Buz support" tristate "Iomega Buz support"
depends on VIDEO_ZORAN_ZR36060 depends on VIDEO_ZORAN_ZR36060
select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
select VIDEO_SAA7185 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_SAA7185 if VIDEO_HELPER_CHIPS_AUTO
help help
Support for the Iomega Buz MJPEG capture/playback card. Support for the Iomega Buz MJPEG capture/playback card.
...@@ -58,7 +58,7 @@ config VIDEO_ZORAN_LML33 ...@@ -58,7 +58,7 @@ config VIDEO_ZORAN_LML33
config VIDEO_ZORAN_LML33R10 config VIDEO_ZORAN_LML33R10
tristate "Linux Media Labs LML33R10 support" tristate "Linux Media Labs LML33R10 support"
depends on VIDEO_ZORAN_ZR36060 depends on VIDEO_ZORAN_ZR36060
select VIDEO_SAA7114 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
select VIDEO_ADV7170 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_ADV7170 if VIDEO_HELPER_CHIPS_AUTO
help help
support for the Linux Media Labs LML33R10 MJPEG capture/playback support for the Linux Media Labs LML33R10 MJPEG capture/playback
......
...@@ -352,7 +352,7 @@ struct card_info { ...@@ -352,7 +352,7 @@ struct card_info {
char name[32]; char name[32];
} input[BUZ_MAX_INPUT]; } input[BUZ_MAX_INPUT];
int norms; v4l2_std_id norms;
struct tvnorm *tvn[3]; /* supported TV norms */ struct tvnorm *tvn[3]; /* supported TV norms */
u32 jpeg_int; /* JPEG interrupt */ u32 jpeg_int; /* JPEG interrupt */
...@@ -401,8 +401,8 @@ struct zoran { ...@@ -401,8 +401,8 @@ struct zoran {
spinlock_t spinlock; /* Spinlock */ spinlock_t spinlock; /* Spinlock */
/* Video for Linux parameters */ /* Video for Linux parameters */
int input, norm; /* card's norm and input - norm=VIDEO_MODE_* */ int input; /* card's norm and input - norm=VIDEO_MODE_* */
int hue, saturation, contrast, brightness; /* Current picture params */ v4l2_std_id norm;
struct video_buffer buffer; /* Current buffer params */ struct video_buffer buffer; /* Current buffer params */
struct zoran_overlay_settings overlay_settings; struct zoran_overlay_settings overlay_settings;
u32 *overlay_mask; /* overlay mask */ u32 *overlay_mask; /* overlay mask */
......
...@@ -340,11 +340,8 @@ i2cid_to_modulename (u16 i2c_id) ...@@ -340,11 +340,8 @@ i2cid_to_modulename (u16 i2c_id)
case I2C_DRIVERID_SAA7110: case I2C_DRIVERID_SAA7110:
name = "saa7110"; name = "saa7110";
break; break;
case I2C_DRIVERID_SAA7111A: case I2C_DRIVERID_SAA711X:
name = "saa7111"; name = "saa7115";
break;
case I2C_DRIVERID_SAA7114:
name = "saa7114";
break; break;
case I2C_DRIVERID_SAA7185B: case I2C_DRIVERID_SAA7185B:
name = "saa7185"; name = "saa7185";
...@@ -439,7 +436,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -439,7 +436,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 2, "S-Video" }, { 2, "S-Video" },
{ 0, "Internal/comp" } { 0, "Internal/comp" }
}, },
.norms = 3, .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
.tvn = { .tvn = {
&f50sqpixel_dc10, &f50sqpixel_dc10,
&f60sqpixel_dc10, &f60sqpixel_dc10,
...@@ -467,7 +464,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -467,7 +464,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 7, "S-Video" }, { 7, "S-Video" },
{ 5, "Internal/comp" } { 5, "Internal/comp" }
}, },
.norms = 3, .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
.tvn = { .tvn = {
&f50sqpixel, &f50sqpixel,
&f60sqpixel, &f60sqpixel,
...@@ -494,7 +491,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -494,7 +491,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 7, "S-Video" }, { 7, "S-Video" },
{ 5, "Internal/comp" } { 5, "Internal/comp" }
}, },
.norms = 3, .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
.tvn = { .tvn = {
&f50sqpixel, &f50sqpixel,
&f60sqpixel, &f60sqpixel,
...@@ -523,7 +520,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -523,7 +520,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 2, "S-Video" }, { 2, "S-Video" },
{ 0, "Internal/comp" } { 0, "Internal/comp" }
}, },
.norms = 3, .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
.tvn = { .tvn = {
&f50sqpixel_dc10, &f50sqpixel_dc10,
&f60sqpixel_dc10, &f60sqpixel_dc10,
...@@ -552,7 +549,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -552,7 +549,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 2, "S-Video" }, { 2, "S-Video" },
{ 0, "Internal/comp" } { 0, "Internal/comp" }
}, },
.norms = 3, .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
.tvn = { .tvn = {
&f50sqpixel_dc10, &f50sqpixel_dc10,
&f60sqpixel_dc10, &f60sqpixel_dc10,
...@@ -579,7 +576,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -579,7 +576,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 0, "Composite" }, { 0, "Composite" },
{ 7, "S-Video" } { 7, "S-Video" }
}, },
.norms = 2, .norms = V4L2_STD_NTSC|V4L2_STD_PAL,
.tvn = { .tvn = {
&f50ccir601_lml33, &f50ccir601_lml33,
&f60ccir601_lml33, &f60ccir601_lml33,
...@@ -597,7 +594,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -597,7 +594,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
}, { }, {
.type = LML33R10, .type = LML33R10,
.name = "LML33R10", .name = "LML33R10",
.i2c_decoder = I2C_DRIVERID_SAA7114, .i2c_decoder = I2C_DRIVERID_SAA711X,
.i2c_encoder = I2C_DRIVERID_ADV7170, .i2c_encoder = I2C_DRIVERID_ADV7170,
.video_codec = CODEC_TYPE_ZR36060, .video_codec = CODEC_TYPE_ZR36060,
...@@ -606,7 +603,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -606,7 +603,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 0, "Composite" }, { 0, "Composite" },
{ 7, "S-Video" } { 7, "S-Video" }
}, },
.norms = 2, .norms = V4L2_STD_NTSC|V4L2_STD_PAL,
.tvn = { .tvn = {
&f50ccir601_lm33r10, &f50ccir601_lm33r10,
&f60ccir601_lm33r10, &f60ccir601_lm33r10,
...@@ -624,7 +621,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -624,7 +621,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
}, { }, {
.type = BUZ, .type = BUZ,
.name = "Buz", .name = "Buz",
.i2c_decoder = I2C_DRIVERID_SAA7111A, .i2c_decoder = I2C_DRIVERID_SAA711X,
.i2c_encoder = I2C_DRIVERID_SAA7185B, .i2c_encoder = I2C_DRIVERID_SAA7185B,
.video_codec = CODEC_TYPE_ZR36060, .video_codec = CODEC_TYPE_ZR36060,
...@@ -633,7 +630,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -633,7 +630,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{ 3, "Composite" }, { 3, "Composite" },
{ 7, "S-Video" } { 7, "S-Video" }
}, },
.norms = 3, .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM,
.tvn = { .tvn = {
&f50ccir601, &f50ccir601,
&f60ccir601, &f60ccir601,
...@@ -670,7 +667,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { ...@@ -670,7 +667,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
{10, "S-Video 3" }, {10, "S-Video 3" },
{15, "YCbCr" } {15, "YCbCr" }
}, },
.norms = 2, .norms = V4L2_STD_NTSC|V4L2_STD_PAL,
.tvn = { .tvn = {
&f50ccir601_avs6eyes, &f50ccir601_avs6eyes,
&f60ccir601_avs6eyes, &f60ccir601_avs6eyes,
...@@ -1086,8 +1083,6 @@ static int __devinit ...@@ -1086,8 +1083,6 @@ static int __devinit
zr36057_init (struct zoran *zr) zr36057_init (struct zoran *zr)
{ {
int j, err; int j, err;
int two = 2;
int zero = 0;
dprintk(1, dprintk(1,
KERN_INFO KERN_INFO
...@@ -1113,14 +1108,23 @@ zr36057_init (struct zoran *zr) ...@@ -1113,14 +1108,23 @@ zr36057_init (struct zoran *zr)
if (default_norm < VIDEO_MODE_PAL && if (default_norm < VIDEO_MODE_PAL &&
default_norm > VIDEO_MODE_SECAM) default_norm > VIDEO_MODE_SECAM)
default_norm = VIDEO_MODE_PAL; default_norm = VIDEO_MODE_PAL;
zr->norm = default_norm; if (default_norm == VIDEO_MODE_PAL) {
if (!(zr->timing = zr->card.tvn[zr->norm])) { zr->norm = V4L2_STD_PAL;
zr->timing = zr->card.tvn[0];
} else if (default_norm == VIDEO_MODE_NTSC) {
zr->norm = V4L2_STD_NTSC;
zr->timing = zr->card.tvn[1];
} else {
zr->norm = V4L2_STD_SECAM;
zr->timing = zr->card.tvn[2];
}
if (zr->timing == NULL) {
dprintk(1, dprintk(1,
KERN_WARNING KERN_WARNING
"%s: zr36057_init() - default TV standard not supported by hardware. PAL will be used.\n", "%s: zr36057_init() - default TV standard not supported by hardware. PAL will be used.\n",
ZR_DEVNAME(zr)); ZR_DEVNAME(zr));
zr->norm = VIDEO_MODE_PAL; zr->norm = V4L2_STD_PAL;
zr->timing = zr->card.tvn[zr->norm]; zr->timing = zr->card.tvn[0];
} }
if (default_input > zr->card.inputs-1) { if (default_input > zr->card.inputs-1) {
...@@ -1132,12 +1136,6 @@ zr36057_init (struct zoran *zr) ...@@ -1132,12 +1136,6 @@ zr36057_init (struct zoran *zr)
} }
zr->input = default_input; zr->input = default_input;
/* Should the following be reset at every open ? */
zr->hue = 32768;
zr->contrast = 32768;
zr->saturation = 32768;
zr->brightness = 32768;
/* default setup (will be repeated at every open) */ /* default setup (will be repeated at every open) */
zoran_open_init_params(zr); zoran_open_init_params(zr);
...@@ -1173,8 +1171,10 @@ zr36057_init (struct zoran *zr) ...@@ -1173,8 +1171,10 @@ zr36057_init (struct zoran *zr)
detect_guest_activity(zr); detect_guest_activity(zr);
test_interrupts(zr); test_interrupts(zr);
if (!pass_through) { if (!pass_through) {
decoder_command(zr, DECODER_ENABLE_OUTPUT, &zero); struct v4l2_routing route = { 2, 0 };
encoder_command(zr, ENCODER_SET_INPUT, &two);
decoder_command(zr, VIDIOC_STREAMOFF, 0);
encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
} }
zr->zoran_proc = NULL; zr->zoran_proc = NULL;
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
#include <linux/videodev.h> #include <linux/videodev.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/sem.h> #include <linux/sem.h>
...@@ -312,9 +314,9 @@ zr36057_adjust_vfe (struct zoran *zr, ...@@ -312,9 +314,9 @@ zr36057_adjust_vfe (struct zoran *zr,
case BUZ_MODE_MOTION_COMPRESS: case BUZ_MODE_MOTION_COMPRESS:
case BUZ_MODE_IDLE: case BUZ_MODE_IDLE:
default: default:
if (zr->norm == VIDEO_MODE_NTSC || if ((zr->norm & V4L2_STD_NTSC) ||
(zr->card.type == LML33R10 && (zr->card.type == LML33R10 &&
zr->norm == VIDEO_MODE_PAL)) (zr->norm & V4L2_STD_PAL)))
btand(~ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR); btand(~ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR);
else else
btor(ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR); btor(ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR);
...@@ -355,14 +357,6 @@ zr36057_set_vfe (struct zoran *zr, ...@@ -355,14 +357,6 @@ zr36057_set_vfe (struct zoran *zr,
dprintk(2, KERN_INFO "%s: set_vfe() - width = %d, height = %d\n", dprintk(2, KERN_INFO "%s: set_vfe() - width = %d, height = %d\n",
ZR_DEVNAME(zr), video_width, video_height); ZR_DEVNAME(zr), video_width, video_height);
if (zr->norm != VIDEO_MODE_PAL &&
zr->norm != VIDEO_MODE_NTSC &&
zr->norm != VIDEO_MODE_SECAM) {
dprintk(1,
KERN_ERR "%s: set_vfe() - norm = %d not valid\n",
ZR_DEVNAME(zr), zr->norm);
return;
}
if (video_width < BUZ_MIN_WIDTH || if (video_width < BUZ_MIN_WIDTH ||
video_height < BUZ_MIN_HEIGHT || video_height < BUZ_MIN_HEIGHT ||
video_width > Wa || video_height > Ha) { video_width > Wa || video_height > Ha) {
...@@ -426,7 +420,7 @@ zr36057_set_vfe (struct zoran *zr, ...@@ -426,7 +420,7 @@ zr36057_set_vfe (struct zoran *zr,
* we get the correct colors when uncompressing to the screen */ * we get the correct colors when uncompressing to the screen */
//reg |= ZR36057_VFESPFR_VCLKPol; /**/ //reg |= ZR36057_VFESPFR_VCLKPol; /**/
/* RJ: Don't know if that is needed for NTSC also */ /* RJ: Don't know if that is needed for NTSC also */
if (zr->norm != VIDEO_MODE_NTSC) if (!(zr->norm & V4L2_STD_NTSC))
reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang
reg |= ZR36057_VFESPFR_TopField; reg |= ZR36057_VFESPFR_TopField;
if (HorDcm >= 48) { if (HorDcm >= 48) {
...@@ -981,11 +975,10 @@ void ...@@ -981,11 +975,10 @@ void
zr36057_enable_jpg (struct zoran *zr, zr36057_enable_jpg (struct zoran *zr,
enum zoran_codec_mode mode) enum zoran_codec_mode mode)
{ {
static int zero;
static int one = 1;
struct vfe_settings cap; struct vfe_settings cap;
int field_size = int field_size =
zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff; zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff;
struct v4l2_routing route = { 0, 0 };
zr->codec_mode = mode; zr->codec_mode = mode;
...@@ -1007,8 +1000,9 @@ zr36057_enable_jpg (struct zoran *zr, ...@@ -1007,8 +1000,9 @@ zr36057_enable_jpg (struct zoran *zr,
* the video bus direction set to input. * the video bus direction set to input.
*/ */
set_videobus_dir(zr, 0); set_videobus_dir(zr, 0);
decoder_command(zr, DECODER_ENABLE_OUTPUT, &one); decoder_command(zr, VIDIOC_STREAMON, 0);
encoder_command(zr, ENCODER_SET_INPUT, &zero); route.input = 0;
encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
/* Take the JPEG codec and the VFE out of sleep */ /* Take the JPEG codec and the VFE out of sleep */
jpeg_codec_sleep(zr, 0); jpeg_codec_sleep(zr, 0);
...@@ -1054,9 +1048,10 @@ zr36057_enable_jpg (struct zoran *zr, ...@@ -1054,9 +1048,10 @@ zr36057_enable_jpg (struct zoran *zr,
/* In motion decompression mode, the decoder output must be disabled, and /* In motion decompression mode, the decoder output must be disabled, and
* the video bus direction set to output. * the video bus direction set to output.
*/ */
decoder_command(zr, DECODER_ENABLE_OUTPUT, &zero); decoder_command(zr, VIDIOC_STREAMOFF, 0);
set_videobus_dir(zr, 1); set_videobus_dir(zr, 1);
encoder_command(zr, ENCODER_SET_INPUT, &one); route.input = 1;
encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
/* Take the JPEG codec and the VFE out of sleep */ /* Take the JPEG codec and the VFE out of sleep */
jpeg_codec_sleep(zr, 0); jpeg_codec_sleep(zr, 0);
...@@ -1100,8 +1095,9 @@ zr36057_enable_jpg (struct zoran *zr, ...@@ -1100,8 +1095,9 @@ zr36057_enable_jpg (struct zoran *zr,
jpeg_codec_sleep(zr, 1); jpeg_codec_sleep(zr, 1);
zr36057_adjust_vfe(zr, mode); zr36057_adjust_vfe(zr, mode);
decoder_command(zr, DECODER_ENABLE_OUTPUT, &one); decoder_command(zr, VIDIOC_STREAMON, 0);
encoder_command(zr, ENCODER_SET_INPUT, &zero); route.input = 0;
encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr));
break; break;
...@@ -1211,17 +1207,17 @@ zoran_reap_stat_com (struct zoran *zr) ...@@ -1211,17 +1207,17 @@ zoran_reap_stat_com (struct zoran *zr)
static void zoran_restart(struct zoran *zr) static void zoran_restart(struct zoran *zr)
{ {
/* Now the stat_comm buffer is ready for restart */ /* Now the stat_comm buffer is ready for restart */
int status, mode; int status = 0, mode;
if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
decoder_command(zr, DECODER_GET_STATUS, &status); decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status);
mode = CODEC_DO_COMPRESSION; mode = CODEC_DO_COMPRESSION;
} else { } else {
status = 0; status = V4L2_IN_ST_NO_SIGNAL;
mode = CODEC_DO_EXPANSION; mode = CODEC_DO_EXPANSION;
} }
if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
(status & DECODER_STATUS_GOOD)) { !(status & V4L2_IN_ST_NO_SIGNAL)) {
/********** RESTART code *************/ /********** RESTART code *************/
jpeg_codec_reset(zr); jpeg_codec_reset(zr);
zr->codec->set_mode(zr->codec, mode); zr->codec->set_mode(zr->codec, mode);
...@@ -1582,7 +1578,7 @@ zoran_set_pci_master (struct zoran *zr, ...@@ -1582,7 +1578,7 @@ zoran_set_pci_master (struct zoran *zr,
void void
zoran_init_hardware (struct zoran *zr) zoran_init_hardware (struct zoran *zr)
{ {
int j, zero = 0; struct v4l2_routing route = { 0, 0 };
/* Enable bus-mastering */ /* Enable bus-mastering */
zoran_set_pci_master(zr, 1); zoran_set_pci_master(zr, 1);
...@@ -1592,15 +1588,16 @@ zoran_init_hardware (struct zoran *zr) ...@@ -1592,15 +1588,16 @@ zoran_init_hardware (struct zoran *zr)
zr->card.init(zr); zr->card.init(zr);
} }
j = zr->card.input[zr->input].muxsel; route.input = zr->card.input[zr->input].muxsel;
decoder_command(zr, 0, NULL); decoder_command(zr, VIDIOC_INT_INIT, NULL);
decoder_command(zr, DECODER_SET_NORM, &zr->norm); decoder_command(zr, VIDIOC_S_STD, &zr->norm);
decoder_command(zr, DECODER_SET_INPUT, &j); decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
encoder_command(zr, 0, NULL); encoder_command(zr, VIDIOC_INT_INIT, NULL);
encoder_command(zr, ENCODER_SET_NORM, &zr->norm); encoder_command(zr, VIDIOC_INT_S_STD_OUTPUT, &zr->norm);
encoder_command(zr, ENCODER_SET_INPUT, &zero); route.input = 0;
encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route);
/* toggle JPEG codec sleep to sync PLL */ /* toggle JPEG codec sleep to sync PLL */
jpeg_codec_sleep(zr, 1); jpeg_codec_sleep(zr, 1);
...@@ -1674,7 +1671,7 @@ decoder_command (struct zoran *zr, ...@@ -1674,7 +1671,7 @@ decoder_command (struct zoran *zr,
return -EIO; return -EIO;
if (zr->card.type == LML33 && if (zr->card.type == LML33 &&
(cmd == DECODER_SET_NORM || cmd == DECODER_SET_INPUT)) { (cmd == VIDIOC_S_STD || cmd == VIDIOC_INT_S_VIDEO_ROUTING)) {
int res; int res;
// Bt819 needs to reset its FIFO buffer using #FRST pin and // Bt819 needs to reset its FIFO buffer using #FRST pin and
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment