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

V4L/DVB (10861): vino/indycam/saa7191: convert to i2c modules to V4L2.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent babb7dc7
...@@ -19,10 +19,11 @@ ...@@ -19,10 +19,11 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/videodev.h>
/* IndyCam decodes stream of photons into digital image representation ;-) */ /* IndyCam decodes stream of photons into digital image representation ;-) */
#include <linux/video_decoder.h> #include <linux/videodev2.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <media/v4l2-common.h>
#include <media/v4l2-i2c-drv-legacy.h>
#include "indycam.h" #include "indycam.h"
...@@ -33,6 +34,10 @@ MODULE_VERSION(INDYCAM_MODULE_VERSION); ...@@ -33,6 +34,10 @@ MODULE_VERSION(INDYCAM_MODULE_VERSION);
MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static unsigned short normal_i2c[] = { 0x56 >> 1, I2C_CLIENT_END };
I2C_CLIENT_INSMOD;
// #define INDYCAM_DEBUG // #define INDYCAM_DEBUG
#ifdef INDYCAM_DEBUG #ifdef INDYCAM_DEBUG
...@@ -48,8 +53,6 @@ struct indycam { ...@@ -48,8 +53,6 @@ struct indycam {
u8 version; u8 version;
}; };
static struct i2c_driver i2c_driver_indycam;
static const u8 initseq[] = { static const u8 initseq[] = {
INDYCAM_CONTROL_AGCENA, /* INDYCAM_CONTROL */ INDYCAM_CONTROL_AGCENA, /* INDYCAM_CONTROL */
INDYCAM_SHUTTER_60, /* INDYCAM_SHUTTER */ INDYCAM_SHUTTER_60, /* INDYCAM_SHUTTER */
...@@ -138,44 +141,44 @@ static void indycam_regdump_debug(struct i2c_client *client) ...@@ -138,44 +141,44 @@ static void indycam_regdump_debug(struct i2c_client *client)
#endif #endif
static int indycam_get_control(struct i2c_client *client, static int indycam_get_control(struct i2c_client *client,
struct indycam_control *ctrl) struct v4l2_control *ctrl)
{ {
struct indycam *camera = i2c_get_clientdata(client); struct indycam *camera = i2c_get_clientdata(client);
u8 reg; u8 reg;
int ret = 0; int ret = 0;
switch (ctrl->type) { switch (ctrl->id) {
case INDYCAM_CONTROL_AGC: case V4L2_CID_AUTOGAIN:
case INDYCAM_CONTROL_AWB: case V4L2_CID_AUTO_WHITE_BALANCE:
ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg); ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg);
if (ret) if (ret)
return -EIO; return -EIO;
if (ctrl->type == INDYCAM_CONTROL_AGC) if (ctrl->id == V4L2_CID_AUTOGAIN)
ctrl->value = (reg & INDYCAM_CONTROL_AGCENA) ctrl->value = (reg & INDYCAM_CONTROL_AGCENA)
? 1 : 0; ? 1 : 0;
else else
ctrl->value = (reg & INDYCAM_CONTROL_AWBCTL) ctrl->value = (reg & INDYCAM_CONTROL_AWBCTL)
? 1 : 0; ? 1 : 0;
break; break;
case INDYCAM_CONTROL_SHUTTER: case V4L2_CID_EXPOSURE:
ret = indycam_read_reg(client, INDYCAM_REG_SHUTTER, &reg); ret = indycam_read_reg(client, INDYCAM_REG_SHUTTER, &reg);
if (ret) if (ret)
return -EIO; return -EIO;
ctrl->value = ((s32)reg == 0x00) ? 0xff : ((s32)reg - 1); ctrl->value = ((s32)reg == 0x00) ? 0xff : ((s32)reg - 1);
break; break;
case INDYCAM_CONTROL_GAIN: case V4L2_CID_GAIN:
ret = indycam_read_reg(client, INDYCAM_REG_GAIN, &reg); ret = indycam_read_reg(client, INDYCAM_REG_GAIN, &reg);
if (ret) if (ret)
return -EIO; return -EIO;
ctrl->value = (s32)reg; ctrl->value = (s32)reg;
break; break;
case INDYCAM_CONTROL_RED_BALANCE: case V4L2_CID_RED_BALANCE:
ret = indycam_read_reg(client, INDYCAM_REG_RED_BALANCE, &reg); ret = indycam_read_reg(client, INDYCAM_REG_RED_BALANCE, &reg);
if (ret) if (ret)
return -EIO; return -EIO;
ctrl->value = (s32)reg; ctrl->value = (s32)reg;
break; break;
case INDYCAM_CONTROL_BLUE_BALANCE: case V4L2_CID_BLUE_BALANCE:
ret = indycam_read_reg(client, INDYCAM_REG_BLUE_BALANCE, &reg); ret = indycam_read_reg(client, INDYCAM_REG_BLUE_BALANCE, &reg);
if (ret) if (ret)
return -EIO; return -EIO;
...@@ -195,7 +198,7 @@ static int indycam_get_control(struct i2c_client *client, ...@@ -195,7 +198,7 @@ static int indycam_get_control(struct i2c_client *client,
return -EIO; return -EIO;
ctrl->value = (s32)reg; ctrl->value = (s32)reg;
break; break;
case INDYCAM_CONTROL_GAMMA: case V4L2_CID_GAMMA:
if (camera->version == CAMERA_VERSION_MOOSE) { if (camera->version == CAMERA_VERSION_MOOSE) {
ret = indycam_read_reg(client, ret = indycam_read_reg(client,
INDYCAM_REG_GAMMA, &reg); INDYCAM_REG_GAMMA, &reg);
...@@ -214,20 +217,20 @@ static int indycam_get_control(struct i2c_client *client, ...@@ -214,20 +217,20 @@ static int indycam_get_control(struct i2c_client *client,
} }
static int indycam_set_control(struct i2c_client *client, static int indycam_set_control(struct i2c_client *client,
struct indycam_control *ctrl) struct v4l2_control *ctrl)
{ {
struct indycam *camera = i2c_get_clientdata(client); struct indycam *camera = i2c_get_clientdata(client);
u8 reg; u8 reg;
int ret = 0; int ret = 0;
switch (ctrl->type) { switch (ctrl->id) {
case INDYCAM_CONTROL_AGC: case V4L2_CID_AUTOGAIN:
case INDYCAM_CONTROL_AWB: case V4L2_CID_AUTO_WHITE_BALANCE:
ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg); ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg);
if (ret) if (ret)
break; break;
if (ctrl->type == INDYCAM_CONTROL_AGC) { if (ctrl->id == V4L2_CID_AUTOGAIN) {
if (ctrl->value) if (ctrl->value)
reg |= INDYCAM_CONTROL_AGCENA; reg |= INDYCAM_CONTROL_AGCENA;
else else
...@@ -241,18 +244,18 @@ static int indycam_set_control(struct i2c_client *client, ...@@ -241,18 +244,18 @@ static int indycam_set_control(struct i2c_client *client,
ret = indycam_write_reg(client, INDYCAM_REG_CONTROL, reg); ret = indycam_write_reg(client, INDYCAM_REG_CONTROL, reg);
break; break;
case INDYCAM_CONTROL_SHUTTER: case V4L2_CID_EXPOSURE:
reg = (ctrl->value == 0xff) ? 0x00 : (ctrl->value + 1); reg = (ctrl->value == 0xff) ? 0x00 : (ctrl->value + 1);
ret = indycam_write_reg(client, INDYCAM_REG_SHUTTER, reg); ret = indycam_write_reg(client, INDYCAM_REG_SHUTTER, reg);
break; break;
case INDYCAM_CONTROL_GAIN: case V4L2_CID_GAIN:
ret = indycam_write_reg(client, INDYCAM_REG_GAIN, ctrl->value); ret = indycam_write_reg(client, INDYCAM_REG_GAIN, ctrl->value);
break; break;
case INDYCAM_CONTROL_RED_BALANCE: case V4L2_CID_RED_BALANCE:
ret = indycam_write_reg(client, INDYCAM_REG_RED_BALANCE, ret = indycam_write_reg(client, INDYCAM_REG_RED_BALANCE,
ctrl->value); ctrl->value);
break; break;
case INDYCAM_CONTROL_BLUE_BALANCE: case V4L2_CID_BLUE_BALANCE:
ret = indycam_write_reg(client, INDYCAM_REG_BLUE_BALANCE, ret = indycam_write_reg(client, INDYCAM_REG_BLUE_BALANCE,
ctrl->value); ctrl->value);
break; break;
...@@ -264,7 +267,7 @@ static int indycam_set_control(struct i2c_client *client, ...@@ -264,7 +267,7 @@ static int indycam_set_control(struct i2c_client *client,
ret = indycam_write_reg(client, INDYCAM_REG_BLUE_SATURATION, ret = indycam_write_reg(client, INDYCAM_REG_BLUE_SATURATION,
ctrl->value); ctrl->value);
break; break;
case INDYCAM_CONTROL_GAMMA: case V4L2_CID_GAMMA:
if (camera->version == CAMERA_VERSION_MOOSE) { if (camera->version == CAMERA_VERSION_MOOSE) {
ret = indycam_write_reg(client, INDYCAM_REG_GAMMA, ret = indycam_write_reg(client, INDYCAM_REG_GAMMA,
ctrl->value); ctrl->value);
...@@ -279,44 +282,50 @@ static int indycam_set_control(struct i2c_client *client, ...@@ -279,44 +282,50 @@ static int indycam_set_control(struct i2c_client *client,
/* I2C-interface */ /* I2C-interface */
static int indycam_attach(struct i2c_adapter *adap, int addr, int kind) static int indycam_command(struct i2c_client *client, unsigned int cmd,
void *arg)
{
/* The old video_decoder interface just isn't enough,
* so we'll use some custom commands. */
switch (cmd) {
case VIDIOC_G_CTRL:
return indycam_get_control(client, arg);
case VIDIOC_S_CTRL:
return indycam_set_control(client, arg);
default:
return -EINVAL;
}
return 0;
}
static int indycam_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
int err = 0; int err = 0;
struct indycam *camera; struct indycam *camera;
struct i2c_client *client;
printk(KERN_INFO "SGI IndyCam driver version %s\n", v4l_info(client, "chip found @ 0x%x (%s)\n",
INDYCAM_MODULE_VERSION); client->addr << 1, client->adapter->name);
client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (!client)
return -ENOMEM;
camera = kzalloc(sizeof(struct indycam), GFP_KERNEL); camera = kzalloc(sizeof(struct indycam), GFP_KERNEL);
if (!camera) { if (!camera)
err = -ENOMEM; return -ENOMEM;
goto out_free_client;
}
client->addr = addr;
client->adapter = adap;
client->driver = &i2c_driver_indycam;
client->flags = 0;
strcpy(client->name, "IndyCam client");
i2c_set_clientdata(client, camera); i2c_set_clientdata(client, camera);
camera->client = client; camera->client = client;
err = i2c_attach_client(client);
if (err)
goto out_free_camera;
camera->version = i2c_smbus_read_byte_data(client, camera->version = i2c_smbus_read_byte_data(client,
INDYCAM_REG_VERSION); INDYCAM_REG_VERSION);
if (camera->version != CAMERA_VERSION_INDY && if (camera->version != CAMERA_VERSION_INDY &&
camera->version != CAMERA_VERSION_MOOSE) { camera->version != CAMERA_VERSION_MOOSE) {
err = -ENODEV; kfree(camera);
goto out_detach_client; return -ENODEV;
} }
printk(KERN_INFO "IndyCam v%d.%d detected\n", printk(KERN_INFO "IndyCam v%d.%d detected\n",
INDYCAM_VERSION_MAJOR(camera->version), INDYCAM_VERSION_MAJOR(camera->version),
INDYCAM_VERSION_MINOR(camera->version)); INDYCAM_VERSION_MINOR(camera->version));
...@@ -327,8 +336,8 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -327,8 +336,8 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind)
err = indycam_write_block(client, 0, sizeof(initseq), (u8 *)&initseq); err = indycam_write_block(client, 0, sizeof(initseq), (u8 *)&initseq);
if (err) { if (err) {
printk(KERN_ERR "IndyCam initialization failed\n"); printk(KERN_ERR "IndyCam initialization failed\n");
err = -EIO; kfree(camera);
goto out_detach_client; return -EIO;
} }
indycam_regdump(client); indycam_regdump(client);
...@@ -338,8 +347,8 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -338,8 +347,8 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind)
INDYCAM_CONTROL_AGCENA | INDYCAM_CONTROL_AWBCTL); INDYCAM_CONTROL_AGCENA | INDYCAM_CONTROL_AWBCTL);
if (err) { if (err) {
printk(KERN_ERR "IndyCam: White balancing camera failed\n"); printk(KERN_ERR "IndyCam: White balancing camera failed\n");
err = -EIO; kfree(camera);
goto out_detach_client; return -EIO;
} }
indycam_regdump(client); indycam_regdump(client);
...@@ -347,124 +356,33 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -347,124 +356,33 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind)
printk(KERN_INFO "IndyCam initialized\n"); printk(KERN_INFO "IndyCam initialized\n");
return 0; return 0;
out_detach_client:
i2c_detach_client(client);
out_free_camera:
kfree(camera);
out_free_client:
kfree(client);
return err;
}
static int indycam_probe(struct i2c_adapter *adap)
{
/* Indy specific crap */
if (adap->id == I2C_HW_SGI_VINO)
return indycam_attach(adap, INDYCAM_ADDR, 0);
/* Feel free to add probe here :-) */
return -ENODEV;
} }
static int indycam_detach(struct i2c_client *client) static int indycam_remove(struct i2c_client *client)
{ {
struct indycam *camera = i2c_get_clientdata(client); struct indycam *camera = i2c_get_clientdata(client);
i2c_detach_client(client);
kfree(camera); kfree(camera);
kfree(client);
return 0; return 0;
} }
static int indycam_command(struct i2c_client *client, unsigned int cmd, static int indycam_legacy_probe(struct i2c_adapter *adapter)
void *arg)
{ {
// struct indycam *camera = i2c_get_clientdata(client); return adapter->id == I2C_HW_SGI_VINO;
/* The old video_decoder interface just isn't enough,
* so we'll use some custom commands. */
switch (cmd) {
case DECODER_GET_CAPABILITIES: {
struct video_decoder_capability *cap = arg;
cap->flags = VIDEO_DECODER_NTSC;
cap->inputs = 1;
cap->outputs = 1;
break;
}
case DECODER_GET_STATUS: {
int *iarg = arg;
*iarg = DECODER_STATUS_GOOD | DECODER_STATUS_NTSC |
DECODER_STATUS_COLOR;
break;
}
case DECODER_SET_NORM: {
int *iarg = arg;
switch (*iarg) {
case VIDEO_MODE_NTSC:
break;
default:
return -EINVAL;
}
break;
}
case DECODER_SET_INPUT: {
int *iarg = arg;
if (*iarg != 0)
return -EINVAL;
break;
}
case DECODER_SET_OUTPUT: {
int *iarg = arg;
if (*iarg != 0)
return -EINVAL;
break;
}
case DECODER_ENABLE_OUTPUT: {
/* Always enabled */
break;
}
case DECODER_SET_PICTURE: {
// struct video_picture *pic = arg;
/* TODO: convert values for indycam_set_controls() */
break;
}
case DECODER_INDYCAM_GET_CONTROL: {
return indycam_get_control(client, arg);
}
case DECODER_INDYCAM_SET_CONTROL: {
return indycam_set_control(client, arg);
}
default:
return -EINVAL;
}
return 0;
} }
static struct i2c_driver i2c_driver_indycam = { static const struct i2c_device_id indycam_id[] = {
.driver = { { "indycam", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, indycam_id);
static struct v4l2_i2c_driver_data v4l2_i2c_data = {
.name = "indycam", .name = "indycam",
}, .driverid = I2C_DRIVERID_INDYCAM,
.id = I2C_DRIVERID_INDYCAM,
.attach_adapter = indycam_probe,
.detach_client = indycam_detach,
.command = indycam_command, .command = indycam_command,
.probe = indycam_probe,
.remove = indycam_remove,
.legacy_probe = indycam_legacy_probe,
.id_table = indycam_id,
}; };
static int __init indycam_init(void)
{
return i2c_add_driver(&i2c_driver_indycam);
}
static void __exit indycam_exit(void)
{
i2c_del_driver(&i2c_driver_indycam);
}
module_init(indycam_init);
module_exit(indycam_exit);
...@@ -87,22 +87,7 @@ ...@@ -87,22 +87,7 @@
/* Driver interface definitions */ /* Driver interface definitions */
#define INDYCAM_CONTROL_AGC 0 /* boolean */ #define INDYCAM_CONTROL_RED_SATURATION (V4L2_CID_PRIVATE_BASE + 0)
#define INDYCAM_CONTROL_AWB 1 /* boolean */ #define INDYCAM_CONTROL_BLUE_SATURATION (V4L2_CID_PRIVATE_BASE + 1)
#define INDYCAM_CONTROL_SHUTTER 2
#define INDYCAM_CONTROL_GAIN 3
#define INDYCAM_CONTROL_RED_BALANCE 4
#define INDYCAM_CONTROL_BLUE_BALANCE 5
#define INDYCAM_CONTROL_RED_SATURATION 6
#define INDYCAM_CONTROL_BLUE_SATURATION 7
#define INDYCAM_CONTROL_GAMMA 8
struct indycam_control {
u8 type;
s32 value;
};
#define DECODER_INDYCAM_GET_CONTROL _IOR('d', 193, struct indycam_control)
#define DECODER_INDYCAM_SET_CONTROL _IOW('d', 194, struct indycam_control)
#endif #endif
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/videodev.h> #include <linux/videodev2.h>
#include <linux/video_decoder.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-i2c-drv-legacy.h> #include <media/v4l2-i2c-drv-legacy.h>
...@@ -57,7 +56,7 @@ struct saa7191 { ...@@ -57,7 +56,7 @@ struct saa7191 {
u8 reg[25]; u8 reg[25];
int input; int input;
int norm; v4l2_std_id norm;
}; };
static const u8 initseq[] = { static const u8 initseq[] = {
...@@ -191,7 +190,7 @@ static int saa7191_set_input(struct i2c_client *client, int input) ...@@ -191,7 +190,7 @@ static int saa7191_set_input(struct i2c_client *client, int input)
return 0; return 0;
} }
static int saa7191_set_norm(struct i2c_client *client, int norm) static int saa7191_set_norm(struct i2c_client *client, v4l2_std_id norm)
{ {
struct saa7191 *decoder = i2c_get_clientdata(client); struct saa7191 *decoder = i2c_get_clientdata(client);
u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC); u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC);
...@@ -199,24 +198,20 @@ static int saa7191_set_norm(struct i2c_client *client, int norm) ...@@ -199,24 +198,20 @@ static int saa7191_set_norm(struct i2c_client *client, int norm)
u8 chcv = saa7191_read_reg(client, SAA7191_REG_CHCV); u8 chcv = saa7191_read_reg(client, SAA7191_REG_CHCV);
int err; int err;
switch(norm) { if (norm & V4L2_STD_PAL) {
case SAA7191_NORM_PAL:
stdc &= ~SAA7191_STDC_SECS; stdc &= ~SAA7191_STDC_SECS;
ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL); ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL);
chcv = SAA7191_CHCV_PAL; chcv = SAA7191_CHCV_PAL;
break; } else if (norm & V4L2_STD_NTSC) {
case SAA7191_NORM_NTSC:
stdc &= ~SAA7191_STDC_SECS; stdc &= ~SAA7191_STDC_SECS;
ctl3 &= ~SAA7191_CTL3_AUFD; ctl3 &= ~SAA7191_CTL3_AUFD;
ctl3 |= SAA7191_CTL3_FSEL; ctl3 |= SAA7191_CTL3_FSEL;
chcv = SAA7191_CHCV_NTSC; chcv = SAA7191_CHCV_NTSC;
break; } else if (norm & V4L2_STD_SECAM) {
case SAA7191_NORM_SECAM:
stdc |= SAA7191_STDC_SECS; stdc |= SAA7191_STDC_SECS;
ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL); ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL);
chcv = SAA7191_CHCV_PAL; chcv = SAA7191_CHCV_PAL;
break; } else {
default:
return -EINVAL; return -EINVAL;
} }
...@@ -234,7 +229,7 @@ static int saa7191_set_norm(struct i2c_client *client, int norm) ...@@ -234,7 +229,7 @@ static int saa7191_set_norm(struct i2c_client *client, int norm)
dprintk("ctl3: %02x stdc: %02x chcv: %02x\n", ctl3, dprintk("ctl3: %02x stdc: %02x chcv: %02x\n", ctl3,
stdc, chcv); stdc, chcv);
dprintk("norm: %d\n", norm); dprintk("norm: %llx\n", norm);
return 0; return 0;
} }
...@@ -262,15 +257,19 @@ static int saa7191_wait_for_signal(struct i2c_client *client, u8 *status) ...@@ -262,15 +257,19 @@ static int saa7191_wait_for_signal(struct i2c_client *client, u8 *status)
return -EBUSY; return -EBUSY;
} }
static int saa7191_autodetect_norm_extended(struct i2c_client *client) static int saa7191_autodetect_norm_extended(struct i2c_client *client,
v4l2_std_id *norm)
{ {
struct saa7191 *decoder = i2c_get_clientdata(client);
u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC); u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC);
u8 ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3); u8 ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3);
u8 status; u8 status;
v4l2_std_id old_norm = decoder->norm;
int err = 0; int err = 0;
dprintk("SAA7191 extended signal auto-detection...\n"); dprintk("SAA7191 extended signal auto-detection...\n");
*norm = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM;
stdc &= ~SAA7191_STDC_SECS; stdc &= ~SAA7191_STDC_SECS;
ctl3 &= ~(SAA7191_CTL3_FSEL); ctl3 &= ~(SAA7191_CTL3_FSEL);
...@@ -301,14 +300,15 @@ static int saa7191_autodetect_norm_extended(struct i2c_client *client) ...@@ -301,14 +300,15 @@ static int saa7191_autodetect_norm_extended(struct i2c_client *client)
if (status & SAA7191_STATUS_FIDT) { if (status & SAA7191_STATUS_FIDT) {
/* 60Hz signal -> NTSC */ /* 60Hz signal -> NTSC */
dprintk("60Hz signal: NTSC\n"); dprintk("60Hz signal: NTSC\n");
return saa7191_set_norm(client, SAA7191_NORM_NTSC); *norm = V4L2_STD_NTSC;
return 0;
} }
/* 50Hz signal */ /* 50Hz signal */
dprintk("50Hz signal: Trying PAL...\n"); dprintk("50Hz signal: Trying PAL...\n");
/* try PAL first */ /* try PAL first */
err = saa7191_set_norm(client, SAA7191_NORM_PAL); err = saa7191_set_norm(client, V4L2_STD_PAL);
if (err) if (err)
goto out; goto out;
...@@ -321,20 +321,20 @@ static int saa7191_autodetect_norm_extended(struct i2c_client *client) ...@@ -321,20 +321,20 @@ static int saa7191_autodetect_norm_extended(struct i2c_client *client)
/* not 50Hz ? */ /* not 50Hz ? */
if (status & SAA7191_STATUS_FIDT) { if (status & SAA7191_STATUS_FIDT) {
dprintk("No 50Hz signal\n"); dprintk("No 50Hz signal\n");
err = -EAGAIN; saa7191_set_norm(client, old_norm);
goto out; return -EAGAIN;
} }
if (status & SAA7191_STATUS_CODE) { if (status & SAA7191_STATUS_CODE) {
dprintk("PAL\n"); dprintk("PAL\n");
return 0; *norm = V4L2_STD_PAL;
return saa7191_set_norm(client, old_norm);
} }
dprintk("No color detected with PAL - Trying SECAM...\n"); dprintk("No color detected with PAL - Trying SECAM...\n");
/* no color detected ? -> try SECAM */ /* no color detected ? -> try SECAM */
err = saa7191_set_norm(client, err = saa7191_set_norm(client, V4L2_STD_SECAM);
SAA7191_NORM_SECAM);
if (err) if (err)
goto out; goto out;
...@@ -354,29 +354,14 @@ static int saa7191_autodetect_norm_extended(struct i2c_client *client) ...@@ -354,29 +354,14 @@ static int saa7191_autodetect_norm_extended(struct i2c_client *client)
if (status & SAA7191_STATUS_CODE) { if (status & SAA7191_STATUS_CODE) {
/* Color detected -> SECAM */ /* Color detected -> SECAM */
dprintk("SECAM\n"); dprintk("SECAM\n");
return 0; *norm = V4L2_STD_SECAM;
return saa7191_set_norm(client, old_norm);
} }
dprintk("No color detected with SECAM - Going back to PAL.\n"); dprintk("No color detected with SECAM - Going back to PAL.\n");
/* still no color detected ?
* -> set norm back to PAL */
err = saa7191_set_norm(client,
SAA7191_NORM_PAL);
if (err)
goto out;
out: out:
ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3); return saa7191_set_norm(client, old_norm);
if (ctl3 & SAA7191_CTL3_AUFD) {
ctl3 &= ~(SAA7191_CTL3_AUFD);
err = saa7191_write_reg(client, SAA7191_REG_CTL3, ctl3);
if (err) {
err = -EIO;
}
}
return err;
} }
static int saa7191_autodetect_norm(struct i2c_client *client) static int saa7191_autodetect_norm(struct i2c_client *client)
...@@ -403,26 +388,26 @@ static int saa7191_autodetect_norm(struct i2c_client *client) ...@@ -403,26 +388,26 @@ static int saa7191_autodetect_norm(struct i2c_client *client)
if (status & SAA7191_STATUS_FIDT) { if (status & SAA7191_STATUS_FIDT) {
/* 60hz signal -> NTSC */ /* 60hz signal -> NTSC */
dprintk("NTSC\n"); dprintk("NTSC\n");
return saa7191_set_norm(client, SAA7191_NORM_NTSC); return saa7191_set_norm(client, V4L2_STD_NTSC);
} else { } else {
/* 50hz signal -> PAL */ /* 50hz signal -> PAL */
dprintk("PAL\n"); dprintk("PAL\n");
return saa7191_set_norm(client, SAA7191_NORM_PAL); return saa7191_set_norm(client, V4L2_STD_PAL);
} }
} }
static int saa7191_get_control(struct i2c_client *client, static int saa7191_get_control(struct i2c_client *client,
struct saa7191_control *ctrl) struct v4l2_control *ctrl)
{ {
u8 reg; u8 reg;
int ret = 0; int ret = 0;
switch (ctrl->type) { switch (ctrl->id) {
case SAA7191_CONTROL_BANDPASS: case SAA7191_CONTROL_BANDPASS:
case SAA7191_CONTROL_BANDPASS_WEIGHT: case SAA7191_CONTROL_BANDPASS_WEIGHT:
case SAA7191_CONTROL_CORING: case SAA7191_CONTROL_CORING:
reg = saa7191_read_reg(client, SAA7191_REG_LUMA); reg = saa7191_read_reg(client, SAA7191_REG_LUMA);
switch (ctrl->type) { switch (ctrl->id) {
case SAA7191_CONTROL_BANDPASS: case SAA7191_CONTROL_BANDPASS:
ctrl->value = ((s32)reg & SAA7191_LUMA_BPSS_MASK) ctrl->value = ((s32)reg & SAA7191_LUMA_BPSS_MASK)
>> SAA7191_LUMA_BPSS_SHIFT; >> SAA7191_LUMA_BPSS_SHIFT;
...@@ -440,13 +425,13 @@ static int saa7191_get_control(struct i2c_client *client, ...@@ -440,13 +425,13 @@ static int saa7191_get_control(struct i2c_client *client,
case SAA7191_CONTROL_FORCE_COLOUR: case SAA7191_CONTROL_FORCE_COLOUR:
case SAA7191_CONTROL_CHROMA_GAIN: case SAA7191_CONTROL_CHROMA_GAIN:
reg = saa7191_read_reg(client, SAA7191_REG_GAIN); reg = saa7191_read_reg(client, SAA7191_REG_GAIN);
if (ctrl->type == SAA7191_CONTROL_FORCE_COLOUR) if (ctrl->id == SAA7191_CONTROL_FORCE_COLOUR)
ctrl->value = ((s32)reg & SAA7191_GAIN_COLO) ? 1 : 0; ctrl->value = ((s32)reg & SAA7191_GAIN_COLO) ? 1 : 0;
else else
ctrl->value = ((s32)reg & SAA7191_GAIN_LFIS_MASK) ctrl->value = ((s32)reg & SAA7191_GAIN_LFIS_MASK)
>> SAA7191_GAIN_LFIS_SHIFT; >> SAA7191_GAIN_LFIS_SHIFT;
break; break;
case SAA7191_CONTROL_HUE: case V4L2_CID_HUE:
reg = saa7191_read_reg(client, SAA7191_REG_HUEC); reg = saa7191_read_reg(client, SAA7191_REG_HUEC);
if (reg < 0x80) if (reg < 0x80)
reg += 0x80; reg += 0x80;
...@@ -478,17 +463,17 @@ static int saa7191_get_control(struct i2c_client *client, ...@@ -478,17 +463,17 @@ static int saa7191_get_control(struct i2c_client *client,
} }
static int saa7191_set_control(struct i2c_client *client, static int saa7191_set_control(struct i2c_client *client,
struct saa7191_control *ctrl) struct v4l2_control *ctrl)
{ {
u8 reg; u8 reg;
int ret = 0; int ret = 0;
switch (ctrl->type) { switch (ctrl->id) {
case SAA7191_CONTROL_BANDPASS: case SAA7191_CONTROL_BANDPASS:
case SAA7191_CONTROL_BANDPASS_WEIGHT: case SAA7191_CONTROL_BANDPASS_WEIGHT:
case SAA7191_CONTROL_CORING: case SAA7191_CONTROL_CORING:
reg = saa7191_read_reg(client, SAA7191_REG_LUMA); reg = saa7191_read_reg(client, SAA7191_REG_LUMA);
switch (ctrl->type) { switch (ctrl->id) {
case SAA7191_CONTROL_BANDPASS: case SAA7191_CONTROL_BANDPASS:
reg &= ~SAA7191_LUMA_BPSS_MASK; reg &= ~SAA7191_LUMA_BPSS_MASK;
reg |= (ctrl->value << SAA7191_LUMA_BPSS_SHIFT) reg |= (ctrl->value << SAA7191_LUMA_BPSS_SHIFT)
...@@ -510,7 +495,7 @@ static int saa7191_set_control(struct i2c_client *client, ...@@ -510,7 +495,7 @@ static int saa7191_set_control(struct i2c_client *client,
case SAA7191_CONTROL_FORCE_COLOUR: case SAA7191_CONTROL_FORCE_COLOUR:
case SAA7191_CONTROL_CHROMA_GAIN: case SAA7191_CONTROL_CHROMA_GAIN:
reg = saa7191_read_reg(client, SAA7191_REG_GAIN); reg = saa7191_read_reg(client, SAA7191_REG_GAIN);
if (ctrl->type == SAA7191_CONTROL_FORCE_COLOUR) { if (ctrl->id == SAA7191_CONTROL_FORCE_COLOUR) {
if (ctrl->value) if (ctrl->value)
reg |= SAA7191_GAIN_COLO; reg |= SAA7191_GAIN_COLO;
else else
...@@ -522,7 +507,7 @@ static int saa7191_set_control(struct i2c_client *client, ...@@ -522,7 +507,7 @@ static int saa7191_set_control(struct i2c_client *client,
} }
ret = saa7191_write_reg(client, SAA7191_REG_GAIN, reg); ret = saa7191_write_reg(client, SAA7191_REG_GAIN, reg);
break; break;
case SAA7191_CONTROL_HUE: case V4L2_CID_HUE:
reg = ctrl->value & 0xff; reg = ctrl->value & 0xff;
if (reg < 0x80) if (reg < 0x80)
reg += 0x80; reg += 0x80;
...@@ -568,141 +553,42 @@ static int saa7191_set_control(struct i2c_client *client, ...@@ -568,141 +553,42 @@ static int saa7191_set_control(struct i2c_client *client,
static int saa7191_command(struct i2c_client *client, unsigned int cmd, static int saa7191_command(struct i2c_client *client, unsigned int cmd,
void *arg) void *arg)
{ {
struct saa7191 *decoder = i2c_get_clientdata(client);
switch (cmd) { switch (cmd) {
case DECODER_GET_CAPABILITIES: { case VIDIOC_INT_G_INPUT_STATUS: {
struct video_decoder_capability *cap = arg; u32 *iarg = arg;
cap->flags = VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC |
VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO;
cap->inputs = (client->adapter->id == I2C_HW_SGI_VINO) ? 2 : 1;
cap->outputs = 1;
break;
}
case DECODER_GET_STATUS: {
int *iarg = arg;
u8 status; u8 status;
int res = 0; int res = V4L2_IN_ST_NO_SIGNAL;
if (saa7191_read_status(client, &status)) { if (saa7191_read_status(client, &status))
return -EIO; return -EIO;
}
if ((status & SAA7191_STATUS_HLCK) == 0) if ((status & SAA7191_STATUS_HLCK) == 0)
res |= DECODER_STATUS_GOOD; res = 0;
if (status & SAA7191_STATUS_CODE) if (!(status & SAA7191_STATUS_CODE))
res |= DECODER_STATUS_COLOR; res |= V4L2_IN_ST_NO_COLOR;
switch (decoder->norm) {
case SAA7191_NORM_NTSC:
res |= DECODER_STATUS_NTSC;
break;
case SAA7191_NORM_PAL:
res |= DECODER_STATUS_PAL;
break;
case SAA7191_NORM_SECAM:
res |= DECODER_STATUS_SECAM;
break;
case SAA7191_NORM_AUTO:
default:
if (status & SAA7191_STATUS_FIDT)
res |= DECODER_STATUS_NTSC;
else
res |= DECODER_STATUS_PAL;
break;
}
*iarg = res; *iarg = res;
break; break;
} }
case DECODER_SET_NORM: {
int *iarg = arg;
switch (*iarg) {
case VIDEO_MODE_AUTO:
return saa7191_autodetect_norm(client);
case VIDEO_MODE_PAL:
return saa7191_set_norm(client, SAA7191_NORM_PAL);
case VIDEO_MODE_NTSC:
return saa7191_set_norm(client, SAA7191_NORM_NTSC);
case VIDEO_MODE_SECAM:
return saa7191_set_norm(client, SAA7191_NORM_SECAM);
default:
return -EINVAL;
}
break;
}
case DECODER_SET_INPUT: {
int *iarg = arg;
switch (client->adapter->id) {
case I2C_HW_SGI_VINO:
return saa7191_set_input(client, *iarg);
default:
if (*iarg != 0)
return -EINVAL;
}
break;
}
case DECODER_SET_OUTPUT: {
int *iarg = arg;
/* not much choice of outputs */
if (*iarg != 0)
return -EINVAL;
break;
}
case DECODER_ENABLE_OUTPUT: {
/* Always enabled */
break;
}
case DECODER_SET_PICTURE: {
struct video_picture *pic = arg;
unsigned val;
int err;
val = (pic->hue >> 8) - 0x80; case VIDIOC_QUERYSTD:
return saa7191_autodetect_norm_extended(client, arg);
err = saa7191_write_reg(client, SAA7191_REG_HUEC, val); case VIDIOC_S_STD: {
if (err) v4l2_std_id *istd = arg;
return -EIO;
break; return saa7191_set_norm(client, *istd);
} }
case DECODER_SAA7191_GET_STATUS: { case VIDIOC_INT_S_VIDEO_ROUTING: {
struct saa7191_status *status = arg; struct v4l2_routing *route = arg;
u8 status_reg;
if (saa7191_read_status(client, &status_reg)) return saa7191_set_input(client, route->input);
return -EIO;
status->signal = ((status_reg & SAA7191_STATUS_HLCK) == 0)
? 1 : 0;
status->signal_60hz = (status_reg & SAA7191_STATUS_FIDT)
? 1 : 0;
status->color = (status_reg & SAA7191_STATUS_CODE) ? 1 : 0;
status->input = decoder->input;
status->norm = decoder->norm;
break;
} }
case DECODER_SAA7191_SET_NORM: {
int *norm = arg; case VIDIOC_G_CTRL:
switch (*norm) {
case SAA7191_NORM_AUTO:
return saa7191_autodetect_norm(client);
case SAA7191_NORM_AUTO_EXT:
return saa7191_autodetect_norm_extended(client);
default:
return saa7191_set_norm(client, *norm);
}
}
case DECODER_SAA7191_GET_CONTROL: {
return saa7191_get_control(client, arg); return saa7191_get_control(client, arg);
}
case DECODER_SAA7191_SET_CONTROL: { case VIDIOC_S_CTRL:
return saa7191_set_control(client, arg); return saa7191_set_control(client, arg);
}
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -737,7 +623,7 @@ static int saa7191_probe(struct i2c_client *client, ...@@ -737,7 +623,7 @@ static int saa7191_probe(struct i2c_client *client,
printk(KERN_INFO "SAA7191 initialized\n"); printk(KERN_INFO "SAA7191 initialized\n");
decoder->input = SAA7191_INPUT_COMPOSITE; decoder->input = SAA7191_INPUT_COMPOSITE;
decoder->norm = SAA7191_NORM_PAL; decoder->norm = V4L2_STD_PAL;
err = saa7191_autodetect_norm(client); err = saa7191_autodetect_norm(client);
if (err && (err != -EBUSY)) if (err && (err != -EBUSY))
......
...@@ -176,11 +176,9 @@ ...@@ -176,11 +176,9 @@
#define SAA7191_INPUT_COMPOSITE 0 #define SAA7191_INPUT_COMPOSITE 0
#define SAA7191_INPUT_SVIDEO 1 #define SAA7191_INPUT_SVIDEO 1
#define SAA7191_NORM_AUTO 0
#define SAA7191_NORM_PAL 1 #define SAA7191_NORM_PAL 1
#define SAA7191_NORM_NTSC 2 #define SAA7191_NORM_NTSC 2
#define SAA7191_NORM_SECAM 3 #define SAA7191_NORM_SECAM 3
#define SAA7191_NORM_AUTO_EXT 4 /* extended auto-detection */
struct saa7191_status { struct saa7191_status {
/* 0=no signal, 1=signal detected */ /* 0=no signal, 1=signal detected */
...@@ -232,24 +230,16 @@ struct saa7191_status { ...@@ -232,24 +230,16 @@ struct saa7191_status {
#define SAA7191_VNR_MAX 0x03 #define SAA7191_VNR_MAX 0x03
#define SAA7191_VNR_DEFAULT 0x00 #define SAA7191_VNR_DEFAULT 0x00
#define SAA7191_CONTROL_BANDPASS 0 #define SAA7191_CONTROL_BANDPASS (V4L2_CID_PRIVATE_BASE + 0)
#define SAA7191_CONTROL_BANDPASS_WEIGHT 1 #define SAA7191_CONTROL_BANDPASS_WEIGHT (V4L2_CID_PRIVATE_BASE + 1)
#define SAA7191_CONTROL_CORING 2 #define SAA7191_CONTROL_CORING (V4L2_CID_PRIVATE_BASE + 2)
#define SAA7191_CONTROL_FORCE_COLOUR 3 /* boolean */ #define SAA7191_CONTROL_FORCE_COLOUR (V4L2_CID_PRIVATE_BASE + 3)
#define SAA7191_CONTROL_CHROMA_GAIN 4 #define SAA7191_CONTROL_CHROMA_GAIN (V4L2_CID_PRIVATE_BASE + 4)
#define SAA7191_CONTROL_HUE 5 #define SAA7191_CONTROL_VTRC (V4L2_CID_PRIVATE_BASE + 5)
#define SAA7191_CONTROL_VTRC 6 /* boolean */ #define SAA7191_CONTROL_LUMA_DELAY (V4L2_CID_PRIVATE_BASE + 6)
#define SAA7191_CONTROL_LUMA_DELAY 7 #define SAA7191_CONTROL_VNR (V4L2_CID_PRIVATE_BASE + 7)
#define SAA7191_CONTROL_VNR 8
struct saa7191_control {
u8 type;
s32 value;
};
#define DECODER_SAA7191_GET_STATUS _IOR('d', 195, struct saa7191_status) #define DECODER_SAA7191_GET_STATUS _IOR('d', 195, struct saa7191_status)
#define DECODER_SAA7191_SET_NORM _IOW('d', 196, int) #define DECODER_SAA7191_SET_NORM _IOW('d', 196, int)
#define DECODER_SAA7191_GET_CONTROL _IOR('d', 197, struct saa7191_control)
#define DECODER_SAA7191_SET_CONTROL _IOW('d', 198, struct saa7191_control)
#endif #endif
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#include <linux/video_decoder.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <asm/paccess.h> #include <asm/paccess.h>
...@@ -139,10 +138,6 @@ MODULE_LICENSE("GPL"); ...@@ -139,10 +138,6 @@ MODULE_LICENSE("GPL");
#define VINO_DATA_NORM_PAL 1 #define VINO_DATA_NORM_PAL 1
#define VINO_DATA_NORM_SECAM 2 #define VINO_DATA_NORM_SECAM 2
#define VINO_DATA_NORM_D1 3 #define VINO_DATA_NORM_D1 3
/* The following are special entries that can be used to
* autodetect the norm. */
#define VINO_DATA_NORM_AUTO 0xfe
#define VINO_DATA_NORM_AUTO_EXT 0xff
#define VINO_DATA_NORM_COUNT 4 #define VINO_DATA_NORM_COUNT 4
...@@ -360,11 +355,11 @@ static const struct vino_input vino_inputs[] = { ...@@ -360,11 +355,11 @@ static const struct vino_input vino_inputs[] = {
.name = "Composite", .name = "Composite",
.std = V4L2_STD_NTSC | V4L2_STD_PAL .std = V4L2_STD_NTSC | V4L2_STD_PAL
| V4L2_STD_SECAM, | V4L2_STD_SECAM,
},{ }, {
.name = "S-Video", .name = "S-Video",
.std = V4L2_STD_NTSC | V4L2_STD_PAL .std = V4L2_STD_NTSC | V4L2_STD_PAL
| V4L2_STD_SECAM, | V4L2_STD_SECAM,
},{ }, {
.name = "D1/IndyCam", .name = "D1/IndyCam",
.std = V4L2_STD_NTSC, .std = V4L2_STD_NTSC,
} }
...@@ -376,17 +371,17 @@ static const struct vino_data_format vino_data_formats[] = { ...@@ -376,17 +371,17 @@ static const struct vino_data_format vino_data_formats[] = {
.bpp = 1, .bpp = 1,
.pixelformat = V4L2_PIX_FMT_GREY, .pixelformat = V4L2_PIX_FMT_GREY,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .colorspace = V4L2_COLORSPACE_SMPTE170M,
},{ }, {
.description = "8-bit dithered RGB 3-3-2", .description = "8-bit dithered RGB 3-3-2",
.bpp = 1, .bpp = 1,
.pixelformat = V4L2_PIX_FMT_RGB332, .pixelformat = V4L2_PIX_FMT_RGB332,
.colorspace = V4L2_COLORSPACE_SRGB, .colorspace = V4L2_COLORSPACE_SRGB,
},{ }, {
.description = "32-bit RGB", .description = "32-bit RGB",
.bpp = 4, .bpp = 4,
.pixelformat = V4L2_PIX_FMT_RGB32, .pixelformat = V4L2_PIX_FMT_RGB32,
.colorspace = V4L2_COLORSPACE_SRGB, .colorspace = V4L2_COLORSPACE_SRGB,
},{ }, {
.description = "YUV 4:2:2", .description = "YUV 4:2:2",
.bpp = 2, .bpp = 2,
.pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped? .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped?
...@@ -417,7 +412,7 @@ static const struct vino_data_norm vino_data_norms[] = { ...@@ -417,7 +412,7 @@ static const struct vino_data_norm vino_data_norms[] = {
+ VINO_NTSC_HEIGHT / 2 - 1, + VINO_NTSC_HEIGHT / 2 - 1,
.right = VINO_NTSC_WIDTH, .right = VINO_NTSC_WIDTH,
}, },
},{ }, {
.description = "PAL", .description = "PAL",
.std = V4L2_STD_PAL, .std = V4L2_STD_PAL,
.fps_min = 5, .fps_min = 5,
...@@ -439,7 +434,7 @@ static const struct vino_data_norm vino_data_norms[] = { ...@@ -439,7 +434,7 @@ static const struct vino_data_norm vino_data_norms[] = {
+ VINO_PAL_HEIGHT / 2 - 1, + VINO_PAL_HEIGHT / 2 - 1,
.right = VINO_PAL_WIDTH, .right = VINO_PAL_WIDTH,
}, },
},{ }, {
.description = "SECAM", .description = "SECAM",
.std = V4L2_STD_SECAM, .std = V4L2_STD_SECAM,
.fps_min = 5, .fps_min = 5,
...@@ -461,7 +456,7 @@ static const struct vino_data_norm vino_data_norms[] = { ...@@ -461,7 +456,7 @@ static const struct vino_data_norm vino_data_norms[] = {
+ VINO_PAL_HEIGHT / 2 - 1, + VINO_PAL_HEIGHT / 2 - 1,
.right = VINO_PAL_WIDTH, .right = VINO_PAL_WIDTH,
}, },
},{ }, {
.description = "NTSC/D1", .description = "NTSC/D1",
.std = V4L2_STD_NTSC, .std = V4L2_STD_NTSC,
.fps_min = 6, .fps_min = 6,
...@@ -497,9 +492,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { ...@@ -497,9 +492,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
.maximum = 1, .maximum = 1,
.step = 1, .step = 1,
.default_value = INDYCAM_AGC_DEFAULT, .default_value = INDYCAM_AGC_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_AGC, 0 },
},{
.id = V4L2_CID_AUTO_WHITE_BALANCE, .id = V4L2_CID_AUTO_WHITE_BALANCE,
.type = V4L2_CTRL_TYPE_BOOLEAN, .type = V4L2_CTRL_TYPE_BOOLEAN,
.name = "Automatic White Balance", .name = "Automatic White Balance",
...@@ -507,9 +500,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { ...@@ -507,9 +500,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
.maximum = 1, .maximum = 1,
.step = 1, .step = 1,
.default_value = INDYCAM_AWB_DEFAULT, .default_value = INDYCAM_AWB_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_AWB, 0 },
},{
.id = V4L2_CID_GAIN, .id = V4L2_CID_GAIN,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Gain", .name = "Gain",
...@@ -517,29 +508,23 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { ...@@ -517,29 +508,23 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
.maximum = INDYCAM_GAIN_MAX, .maximum = INDYCAM_GAIN_MAX,
.step = 1, .step = 1,
.default_value = INDYCAM_GAIN_DEFAULT, .default_value = INDYCAM_GAIN_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_GAIN, 0 }, .id = INDYCAM_CONTROL_RED_SATURATION,
},{
.id = V4L2_CID_PRIVATE_BASE,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Red Saturation", .name = "Red Saturation",
.minimum = INDYCAM_RED_SATURATION_MIN, .minimum = INDYCAM_RED_SATURATION_MIN,
.maximum = INDYCAM_RED_SATURATION_MAX, .maximum = INDYCAM_RED_SATURATION_MAX,
.step = 1, .step = 1,
.default_value = INDYCAM_RED_SATURATION_DEFAULT, .default_value = INDYCAM_RED_SATURATION_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_RED_SATURATION, 0 }, .id = INDYCAM_CONTROL_BLUE_SATURATION,
},{
.id = V4L2_CID_PRIVATE_BASE + 1,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Blue Saturation", .name = "Blue Saturation",
.minimum = INDYCAM_BLUE_SATURATION_MIN, .minimum = INDYCAM_BLUE_SATURATION_MIN,
.maximum = INDYCAM_BLUE_SATURATION_MAX, .maximum = INDYCAM_BLUE_SATURATION_MAX,
.step = 1, .step = 1,
.default_value = INDYCAM_BLUE_SATURATION_DEFAULT, .default_value = INDYCAM_BLUE_SATURATION_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_BLUE_SATURATION, 0 },
},{
.id = V4L2_CID_RED_BALANCE, .id = V4L2_CID_RED_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Red Balance", .name = "Red Balance",
...@@ -547,9 +532,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { ...@@ -547,9 +532,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
.maximum = INDYCAM_RED_BALANCE_MAX, .maximum = INDYCAM_RED_BALANCE_MAX,
.step = 1, .step = 1,
.default_value = INDYCAM_RED_BALANCE_DEFAULT, .default_value = INDYCAM_RED_BALANCE_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_RED_BALANCE, 0 },
},{
.id = V4L2_CID_BLUE_BALANCE, .id = V4L2_CID_BLUE_BALANCE,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Blue Balance", .name = "Blue Balance",
...@@ -557,9 +540,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { ...@@ -557,9 +540,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
.maximum = INDYCAM_BLUE_BALANCE_MAX, .maximum = INDYCAM_BLUE_BALANCE_MAX,
.step = 1, .step = 1,
.default_value = INDYCAM_BLUE_BALANCE_DEFAULT, .default_value = INDYCAM_BLUE_BALANCE_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_BLUE_BALANCE, 0 },
},{
.id = V4L2_CID_EXPOSURE, .id = V4L2_CID_EXPOSURE,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Shutter Control", .name = "Shutter Control",
...@@ -567,9 +548,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { ...@@ -567,9 +548,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
.maximum = INDYCAM_SHUTTER_MAX, .maximum = INDYCAM_SHUTTER_MAX,
.step = 1, .step = 1,
.default_value = INDYCAM_SHUTTER_DEFAULT, .default_value = INDYCAM_SHUTTER_DEFAULT,
.flags = 0, }, {
.reserved = { INDYCAM_CONTROL_SHUTTER, 0 },
},{
.id = V4L2_CID_GAMMA, .id = V4L2_CID_GAMMA,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Gamma", .name = "Gamma",
...@@ -577,8 +556,6 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { ...@@ -577,8 +556,6 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
.maximum = INDYCAM_GAMMA_MAX, .maximum = INDYCAM_GAMMA_MAX,
.step = 1, .step = 1,
.default_value = INDYCAM_GAMMA_DEFAULT, .default_value = INDYCAM_GAMMA_DEFAULT,
.flags = 0,
.reserved = { INDYCAM_CONTROL_GAMMA, 0 },
} }
}; };
...@@ -593,88 +570,70 @@ struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = { ...@@ -593,88 +570,70 @@ struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = {
.maximum = SAA7191_HUE_MAX, .maximum = SAA7191_HUE_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_HUE_DEFAULT, .default_value = SAA7191_HUE_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_HUE, 0 }, .id = SAA7191_CONTROL_BANDPASS,
},{
.id = V4L2_CID_PRIVATE_BASE,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Luminance Bandpass", .name = "Luminance Bandpass",
.minimum = SAA7191_BANDPASS_MIN, .minimum = SAA7191_BANDPASS_MIN,
.maximum = SAA7191_BANDPASS_MAX, .maximum = SAA7191_BANDPASS_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_BANDPASS_DEFAULT, .default_value = SAA7191_BANDPASS_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_BANDPASS, 0 }, .id = SAA7191_CONTROL_BANDPASS_WEIGHT,
},{
.id = V4L2_CID_PRIVATE_BASE + 1,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Luminance Bandpass Weight", .name = "Luminance Bandpass Weight",
.minimum = SAA7191_BANDPASS_WEIGHT_MIN, .minimum = SAA7191_BANDPASS_WEIGHT_MIN,
.maximum = SAA7191_BANDPASS_WEIGHT_MAX, .maximum = SAA7191_BANDPASS_WEIGHT_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_BANDPASS_WEIGHT_DEFAULT, .default_value = SAA7191_BANDPASS_WEIGHT_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_BANDPASS_WEIGHT, 0 }, .id = SAA7191_CONTROL_CORING,
},{
.id = V4L2_CID_PRIVATE_BASE + 2,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "HF Luminance Coring", .name = "HF Luminance Coring",
.minimum = SAA7191_CORING_MIN, .minimum = SAA7191_CORING_MIN,
.maximum = SAA7191_CORING_MAX, .maximum = SAA7191_CORING_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_CORING_DEFAULT, .default_value = SAA7191_CORING_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_CORING, 0 }, .id = SAA7191_CONTROL_FORCE_COLOUR,
},{
.id = V4L2_CID_PRIVATE_BASE + 3,
.type = V4L2_CTRL_TYPE_BOOLEAN, .type = V4L2_CTRL_TYPE_BOOLEAN,
.name = "Force Colour", .name = "Force Colour",
.minimum = SAA7191_FORCE_COLOUR_MIN, .minimum = SAA7191_FORCE_COLOUR_MIN,
.maximum = SAA7191_FORCE_COLOUR_MAX, .maximum = SAA7191_FORCE_COLOUR_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_FORCE_COLOUR_DEFAULT, .default_value = SAA7191_FORCE_COLOUR_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_FORCE_COLOUR, 0 }, .id = SAA7191_CONTROL_CHROMA_GAIN,
},{
.id = V4L2_CID_PRIVATE_BASE + 4,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Chrominance Gain Control", .name = "Chrominance Gain Control",
.minimum = SAA7191_CHROMA_GAIN_MIN, .minimum = SAA7191_CHROMA_GAIN_MIN,
.maximum = SAA7191_CHROMA_GAIN_MAX, .maximum = SAA7191_CHROMA_GAIN_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_CHROMA_GAIN_DEFAULT, .default_value = SAA7191_CHROMA_GAIN_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_CHROMA_GAIN, 0 }, .id = SAA7191_CONTROL_VTRC,
},{
.id = V4L2_CID_PRIVATE_BASE + 5,
.type = V4L2_CTRL_TYPE_BOOLEAN, .type = V4L2_CTRL_TYPE_BOOLEAN,
.name = "VTR Time Constant", .name = "VTR Time Constant",
.minimum = SAA7191_VTRC_MIN, .minimum = SAA7191_VTRC_MIN,
.maximum = SAA7191_VTRC_MAX, .maximum = SAA7191_VTRC_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_VTRC_DEFAULT, .default_value = SAA7191_VTRC_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_VTRC, 0 }, .id = SAA7191_CONTROL_LUMA_DELAY,
},{
.id = V4L2_CID_PRIVATE_BASE + 6,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Luminance Delay Compensation", .name = "Luminance Delay Compensation",
.minimum = SAA7191_LUMA_DELAY_MIN, .minimum = SAA7191_LUMA_DELAY_MIN,
.maximum = SAA7191_LUMA_DELAY_MAX, .maximum = SAA7191_LUMA_DELAY_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_LUMA_DELAY_DEFAULT, .default_value = SAA7191_LUMA_DELAY_DEFAULT,
.flags = 0, }, {
.reserved = { SAA7191_CONTROL_LUMA_DELAY, 0 }, .id = SAA7191_CONTROL_VNR,
},{
.id = V4L2_CID_PRIVATE_BASE + 7,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Vertical Noise Reduction", .name = "Vertical Noise Reduction",
.minimum = SAA7191_VNR_MIN, .minimum = SAA7191_VNR_MIN,
.maximum = SAA7191_VNR_MAX, .maximum = SAA7191_VNR_MAX,
.step = 1, .step = 1,
.default_value = SAA7191_VNR_DEFAULT, .default_value = SAA7191_VNR_DEFAULT,
.flags = 0,
.reserved = { SAA7191_CONTROL_VNR, 0 },
} }
}; };
...@@ -2490,77 +2449,6 @@ static int vino_get_saa7191_input(int input) ...@@ -2490,77 +2449,6 @@ static int vino_get_saa7191_input(int input)
} }
} }
static int vino_get_saa7191_norm(unsigned int data_norm)
{
switch (data_norm) {
case VINO_DATA_NORM_AUTO:
return SAA7191_NORM_AUTO;
case VINO_DATA_NORM_AUTO_EXT:
return SAA7191_NORM_AUTO_EXT;
case VINO_DATA_NORM_PAL:
return SAA7191_NORM_PAL;
case VINO_DATA_NORM_NTSC:
return SAA7191_NORM_NTSC;
case VINO_DATA_NORM_SECAM:
return SAA7191_NORM_SECAM;
default:
printk(KERN_ERR "VINO: vino_get_saa7191_norm(): "
"invalid norm!\n");
return -1;
}
}
static int vino_get_from_saa7191_norm(int saa7191_norm)
{
switch (saa7191_norm) {
case SAA7191_NORM_PAL:
return VINO_DATA_NORM_PAL;
case SAA7191_NORM_NTSC:
return VINO_DATA_NORM_NTSC;
case SAA7191_NORM_SECAM:
return VINO_DATA_NORM_SECAM;
default:
printk(KERN_ERR "VINO: vino_get_from_saa7191_norm(): "
"invalid norm!\n");
return VINO_DATA_NORM_NONE;
}
}
static int vino_saa7191_set_norm(unsigned int *data_norm)
{
int saa7191_norm, new_data_norm;
int err = 0;
saa7191_norm = vino_get_saa7191_norm(*data_norm);
err = i2c_decoder_command(DECODER_SAA7191_SET_NORM,
&saa7191_norm);
if (err)
goto out;
if ((*data_norm == VINO_DATA_NORM_AUTO)
|| (*data_norm == VINO_DATA_NORM_AUTO_EXT)) {
struct saa7191_status status;
err = i2c_decoder_command(DECODER_SAA7191_GET_STATUS,
&status);
if (err)
goto out;
new_data_norm =
vino_get_from_saa7191_norm(status.norm);
if (new_data_norm == VINO_DATA_NORM_NONE) {
err = -EINVAL;
goto out;
}
*data_norm = (unsigned int)new_data_norm;
}
out:
return err;
}
/* execute with input_lock locked */ /* execute with input_lock locked */
static int vino_is_input_owner(struct vino_channel_settings *vcs) static int vino_is_input_owner(struct vino_channel_settings *vcs)
{ {
...@@ -2593,15 +2481,16 @@ static int vino_acquire_input(struct vino_channel_settings *vcs) ...@@ -2593,15 +2481,16 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
vcs->data_norm = VINO_DATA_NORM_D1; vcs->data_norm = VINO_DATA_NORM_D1;
} else if (vino_drvdata->decoder.driver } else if (vino_drvdata->decoder.driver
&& (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) { && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) {
int input, data_norm; int input;
int saa7191_input; int data_norm;
v4l2_std_id norm;
struct v4l2_routing route = { 0, 0 };
i2c_use_client(vino_drvdata->decoder.driver); i2c_use_client(vino_drvdata->decoder.driver);
input = VINO_INPUT_COMPOSITE; input = VINO_INPUT_COMPOSITE;
saa7191_input = vino_get_saa7191_input(input); route.input = vino_get_saa7191_input(input);
ret = i2c_decoder_command(DECODER_SET_INPUT, ret = i2c_decoder_command(VIDIOC_INT_S_VIDEO_ROUTING, &route);
&saa7191_input);
if (ret) { if (ret) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -2612,12 +2501,15 @@ static int vino_acquire_input(struct vino_channel_settings *vcs) ...@@ -2612,12 +2501,15 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
/* Don't hold spinlocks while auto-detecting norm /* Don't hold spinlocks while auto-detecting norm
* as it may take a while... */ * as it may take a while... */
data_norm = VINO_DATA_NORM_AUTO_EXT; ret = i2c_decoder_command(VIDIOC_QUERYSTD, &norm);
if (!ret) {
ret = vino_saa7191_set_norm(&data_norm); for (data_norm = 0; data_norm < 3; data_norm++) {
if ((ret == -EBUSY) || (ret == -EAGAIN)) { if (vino_data_norms[data_norm].std & norm)
break;
}
if (data_norm == 3)
data_norm = VINO_DATA_NORM_PAL; data_norm = VINO_DATA_NORM_PAL;
ret = vino_saa7191_set_norm(&data_norm); ret = i2c_decoder_command(VIDIOC_S_STD, &norm);
} }
spin_lock_irqsave(&vino_drvdata->input_lock, flags); spin_lock_irqsave(&vino_drvdata->input_lock, flags);
...@@ -2684,11 +2576,11 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) ...@@ -2684,11 +2576,11 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
if (vino_drvdata->decoder.owner == vcs->channel) { if (vino_drvdata->decoder.owner == vcs->channel) {
int data_norm; int data_norm;
int saa7191_input; v4l2_std_id norm;
struct v4l2_routing route = { 0, 0 };
saa7191_input = vino_get_saa7191_input(input); route.input = vino_get_saa7191_input(input);
ret = i2c_decoder_command(DECODER_SET_INPUT, ret = i2c_decoder_command(VIDIOC_INT_S_VIDEO_ROUTING, &route);
&saa7191_input);
if (ret) { if (ret) {
vino_drvdata->decoder.owner = VINO_NO_CHANNEL; vino_drvdata->decoder.owner = VINO_NO_CHANNEL;
ret = -EINVAL; ret = -EINVAL;
...@@ -2700,12 +2592,15 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) ...@@ -2700,12 +2592,15 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
/* Don't hold spinlocks while auto-detecting norm /* Don't hold spinlocks while auto-detecting norm
* as it may take a while... */ * as it may take a while... */
data_norm = VINO_DATA_NORM_AUTO_EXT; ret = i2c_decoder_command(VIDIOC_QUERYSTD, &norm);
if (!ret) {
ret = vino_saa7191_set_norm(&data_norm); for (data_norm = 0; data_norm < 3; data_norm++) {
if ((ret == -EBUSY) || (ret == -EAGAIN)) { if (vino_data_norms[data_norm].std & norm)
break;
}
if (data_norm == 3)
data_norm = VINO_DATA_NORM_PAL; data_norm = VINO_DATA_NORM_PAL;
ret = vino_saa7191_set_norm(&data_norm); ret = i2c_decoder_command(VIDIOC_S_STD, &norm);
} }
spin_lock_irqsave(&vino_drvdata->input_lock, flags); spin_lock_irqsave(&vino_drvdata->input_lock, flags);
...@@ -2733,8 +2628,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) ...@@ -2733,8 +2628,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
if (vcs2->input == VINO_INPUT_D1) { if (vcs2->input == VINO_INPUT_D1) {
vino_drvdata->camera.owner = vcs2->channel; vino_drvdata->camera.owner = vcs2->channel;
} else { } else {
i2c_release_client(vino_drvdata-> i2c_release_client(vino_drvdata->camera.driver);
camera.driver);
vino_drvdata->camera.owner = VINO_NO_CHANNEL; vino_drvdata->camera.owner = VINO_NO_CHANNEL;
} }
} }
...@@ -2829,18 +2723,16 @@ static int vino_set_data_norm(struct vino_channel_settings *vcs, ...@@ -2829,18 +2723,16 @@ static int vino_set_data_norm(struct vino_channel_settings *vcs,
switch (vcs->input) { switch (vcs->input) {
case VINO_INPUT_D1: case VINO_INPUT_D1:
/* only one "norm" supported */ /* only one "norm" supported */
if ((data_norm != VINO_DATA_NORM_D1) if (data_norm != VINO_DATA_NORM_D1)
&& (data_norm != VINO_DATA_NORM_AUTO)
&& (data_norm != VINO_DATA_NORM_AUTO_EXT))
return -EINVAL; return -EINVAL;
break; break;
case VINO_INPUT_COMPOSITE: case VINO_INPUT_COMPOSITE:
case VINO_INPUT_SVIDEO: { case VINO_INPUT_SVIDEO: {
v4l2_std_id norm;
if ((data_norm != VINO_DATA_NORM_PAL) if ((data_norm != VINO_DATA_NORM_PAL)
&& (data_norm != VINO_DATA_NORM_NTSC) && (data_norm != VINO_DATA_NORM_NTSC)
&& (data_norm != VINO_DATA_NORM_SECAM) && (data_norm != VINO_DATA_NORM_SECAM))
&& (data_norm != VINO_DATA_NORM_AUTO)
&& (data_norm != VINO_DATA_NORM_AUTO_EXT))
return -EINVAL; return -EINVAL;
spin_unlock_irqrestore(&vino_drvdata->input_lock, *flags); spin_unlock_irqrestore(&vino_drvdata->input_lock, *flags);
...@@ -2848,7 +2740,8 @@ static int vino_set_data_norm(struct vino_channel_settings *vcs, ...@@ -2848,7 +2740,8 @@ static int vino_set_data_norm(struct vino_channel_settings *vcs,
/* Don't hold spinlocks while setting norm /* Don't hold spinlocks while setting norm
* as it may take a while... */ * as it may take a while... */
err = vino_saa7191_set_norm(&data_norm); norm = vino_data_norms[data_norm].std;
err = i2c_decoder_command(VIDIOC_S_STD, &norm);
spin_lock_irqsave(&vino_drvdata->input_lock, *flags); spin_lock_irqsave(&vino_drvdata->input_lock, *flags);
...@@ -2998,14 +2891,8 @@ static int vino_enum_input(struct file *file, void *__fh, ...@@ -2998,14 +2891,8 @@ static int vino_enum_input(struct file *file, void *__fh,
i->std = vino_inputs[input].std; i->std = vino_inputs[input].std;
strcpy(i->name, vino_inputs[input].name); strcpy(i->name, vino_inputs[input].name);
if ((input == VINO_INPUT_COMPOSITE) if (input == VINO_INPUT_COMPOSITE || input == VINO_INPUT_SVIDEO)
|| (input == VINO_INPUT_SVIDEO)) { i2c_decoder_command(VIDIOC_INT_G_INPUT_STATUS, &i->status);
struct saa7191_status status;
i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status);
i->status |= status.signal ? 0 : V4L2_IN_ST_NO_SIGNAL;
i->status |= status.color ? 0 : V4L2_IN_ST_NO_COLOR;
}
return 0; return 0;
} }
...@@ -3062,19 +2949,7 @@ static int vino_querystd(struct file *file, void *__fh, ...@@ -3062,19 +2949,7 @@ static int vino_querystd(struct file *file, void *__fh,
break; break;
case VINO_INPUT_COMPOSITE: case VINO_INPUT_COMPOSITE:
case VINO_INPUT_SVIDEO: { case VINO_INPUT_SVIDEO: {
struct saa7191_status status; i2c_decoder_command(VIDIOC_QUERYSTD, std);
i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status);
if (status.signal) {
if (status.signal_60hz) {
*std = V4L2_STD_NTSC;
} else {
*std = V4L2_STD_PAL | V4L2_STD_SECAM;
}
} else {
*std = vino_inputs[vcs->input].std;
}
break; break;
} }
default: default:
...@@ -3126,12 +3001,7 @@ static int vino_s_std(struct file *file, void *__fh, ...@@ -3126,12 +3001,7 @@ static int vino_s_std(struct file *file, void *__fh,
if (vcs->input == VINO_INPUT_D1) if (vcs->input == VINO_INPUT_D1)
goto out; goto out;
if (((*std) & V4L2_STD_PAL) if ((*std) & V4L2_STD_PAL) {
&& ((*std) & V4L2_STD_NTSC)
&& ((*std) & V4L2_STD_SECAM)) {
ret = vino_set_data_norm(vcs, VINO_DATA_NORM_AUTO_EXT,
&flags);
} else if ((*std) & V4L2_STD_PAL) {
ret = vino_set_data_norm(vcs, VINO_DATA_NORM_PAL, ret = vino_set_data_norm(vcs, VINO_DATA_NORM_PAL,
&flags); &flags);
} else if ((*std) & V4L2_STD_NTSC) { } else if ((*std) & V4L2_STD_NTSC) {
...@@ -3797,56 +3667,38 @@ static int vino_g_ctrl(struct file *file, void *__fh, ...@@ -3797,56 +3667,38 @@ static int vino_g_ctrl(struct file *file, void *__fh,
switch (vcs->input) { switch (vcs->input) {
case VINO_INPUT_D1: { case VINO_INPUT_D1: {
struct indycam_control indycam_ctrl; err = -EINVAL;
for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) {
if (vino_indycam_v4l2_controls[i].id == if (vino_indycam_v4l2_controls[i].id == control->id) {
control->id) { err = 0;
goto found1; break;
} }
} }
err = -EINVAL; if (err)
goto out; goto out;
found1: err = i2c_camera_command(VIDIOC_G_CTRL, &control);
indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0]; if (err)
err = i2c_camera_command(DECODER_INDYCAM_GET_CONTROL,
&indycam_ctrl);
if (err) {
err = -EINVAL; err = -EINVAL;
goto out;
}
control->value = indycam_ctrl.value;
break; break;
} }
case VINO_INPUT_COMPOSITE: case VINO_INPUT_COMPOSITE:
case VINO_INPUT_SVIDEO: { case VINO_INPUT_SVIDEO: {
struct saa7191_control saa7191_ctrl; err = -EINVAL;
for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) {
if (vino_saa7191_v4l2_controls[i].id == if (vino_saa7191_v4l2_controls[i].id == control->id) {
control->id) { err = 0;
goto found2; break;
} }
} }
err = -EINVAL; if (err)
goto out; goto out;
found2: err = i2c_decoder_command(VIDIOC_G_CTRL, &control);
saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0]; if (err)
err = i2c_decoder_command(DECODER_SAA7191_GET_CONTROL,
&saa7191_ctrl);
if (err) {
err = -EINVAL; err = -EINVAL;
goto out;
}
control->value = saa7191_ctrl.value;
break; break;
} }
default: default:
...@@ -3876,65 +3728,43 @@ static int vino_s_ctrl(struct file *file, void *__fh, ...@@ -3876,65 +3728,43 @@ static int vino_s_ctrl(struct file *file, void *__fh,
switch (vcs->input) { switch (vcs->input) {
case VINO_INPUT_D1: { case VINO_INPUT_D1: {
struct indycam_control indycam_ctrl; err = -EINVAL;
for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) {
if (vino_indycam_v4l2_controls[i].id == if (vino_indycam_v4l2_controls[i].id == control->id) {
control->id) { err = 0;
if ((control->value >= break;
vino_indycam_v4l2_controls[i].minimum)
&& (control->value <=
vino_indycam_v4l2_controls[i].
maximum)) {
goto found1;
} else {
err = -ERANGE;
goto out;
}
} }
} }
if (err)
err = -EINVAL;
goto out; goto out;
if (control->value < vino_indycam_v4l2_controls[i].minimum ||
found1: control->value > vino_indycam_v4l2_controls[i].maximum) {
indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0]; err = -ERANGE;
indycam_ctrl.value = control->value; goto out;
}
err = i2c_camera_command(DECODER_INDYCAM_SET_CONTROL, err = i2c_camera_command(VIDIOC_S_CTRL, &control);
&indycam_ctrl);
if (err) if (err)
err = -EINVAL; err = -EINVAL;
break; break;
} }
case VINO_INPUT_COMPOSITE: case VINO_INPUT_COMPOSITE:
case VINO_INPUT_SVIDEO: { case VINO_INPUT_SVIDEO: {
struct saa7191_control saa7191_ctrl; err = -EINVAL;
for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) {
if (vino_saa7191_v4l2_controls[i].id == if (vino_saa7191_v4l2_controls[i].id == control->id) {
control->id) { err = 0;
if ((control->value >= break;
vino_saa7191_v4l2_controls[i].minimum)
&& (control->value <=
vino_saa7191_v4l2_controls[i].
maximum)) {
goto found2;
} else {
err = -ERANGE;
goto out;
}
} }
} }
err = -EINVAL; if (err)
goto out; goto out;
if (control->value < vino_saa7191_v4l2_controls[i].minimum ||
control->value > vino_saa7191_v4l2_controls[i].maximum) {
err = -ERANGE;
goto out;
}
found2: err = i2c_decoder_command(VIDIOC_S_CTRL, &control);
saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0];
saa7191_ctrl.value = control->value;
err = i2c_decoder_command(DECODER_SAA7191_SET_CONTROL,
&saa7191_ctrl);
if (err) if (err)
err = -EINVAL; err = -EINVAL;
break; break;
......
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