V4L/DVB (11411): gspca - m5602: Rework v4l ctrl handling in all sensors
Previously, all sensors allocated a part of a large ctrl vector. Define this vector separately for each sensor instead. Signed-off-by: Erik Andrén <erik.andren@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
e335f224e3
commit
e4cc4fcc7b
13 changed files with 75 additions and 85 deletions
|
@ -7,5 +7,4 @@ gspca_m5602-objs := m5602_core.o \
|
|||
m5602_s5k83a.o \
|
||||
m5602_s5k4aa.o
|
||||
|
||||
EXTRA_CFLAGS += -Idrivers/media/video/gspca
|
||||
|
||||
EXTRA_CFLAGS += -Idrivers/media/video/gspca
|
|
@ -116,7 +116,7 @@ struct sd {
|
|||
char *name;
|
||||
|
||||
/* A pointer to the currently connected sensor */
|
||||
struct m5602_sensor *sensor;
|
||||
const struct m5602_sensor *sensor;
|
||||
|
||||
struct sd_desc *desc;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ int mt9m111_probe(struct sd *sd)
|
|||
sd->gspca_dev.cam.cam_mode = mt9m111.modes;
|
||||
sd->gspca_dev.cam.nmodes = mt9m111.nmodes;
|
||||
sd->desc->ctrls = mt9m111.ctrls;
|
||||
sd->desc->nctrls = mt9m111.nctrls;
|
||||
sd->desc->nctrls = ARRAY_SIZE(mt9m111_ctrls);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,18 +94,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
|
|||
int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
|
||||
int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val);
|
||||
|
||||
static struct m5602_sensor mt9m111 = {
|
||||
.name = "MT9M111",
|
||||
|
||||
.i2c_slave_id = 0xba,
|
||||
.i2c_regW = 2,
|
||||
|
||||
.probe = mt9m111_probe,
|
||||
.init = mt9m111_init,
|
||||
.power_down = mt9m111_power_down,
|
||||
|
||||
.nctrls = 3,
|
||||
.ctrls = {
|
||||
const static struct ctrl mt9m111_ctrls[] = {
|
||||
{
|
||||
{
|
||||
.id = V4L2_CID_VFLIP,
|
||||
|
@ -144,7 +133,17 @@ static struct m5602_sensor mt9m111 = {
|
|||
.set = mt9m111_set_gain,
|
||||
.get = mt9m111_get_gain
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
static struct m5602_sensor mt9m111 = {
|
||||
.name = "MT9M111",
|
||||
|
||||
.i2c_slave_id = 0xba,
|
||||
.i2c_regW = 2,
|
||||
|
||||
.probe = mt9m111_probe,
|
||||
.init = mt9m111_init,
|
||||
.power_down = mt9m111_power_down,
|
||||
|
||||
.nmodes = 1,
|
||||
.modes = {
|
||||
|
|
|
@ -113,7 +113,7 @@ int ov9650_probe(struct sd *sd)
|
|||
sd->gspca_dev.cam.cam_mode = ov9650.modes;
|
||||
sd->gspca_dev.cam.nmodes = ov9650.nmodes;
|
||||
sd->desc->ctrls = ov9650.ctrls;
|
||||
sd->desc->nctrls = ov9650.nctrls;
|
||||
sd->desc->nctrls = ARRAY_SIZE(ov9650_ctrls);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,18 +156,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val);
|
|||
int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val);
|
||||
int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val);
|
||||
|
||||
static struct m5602_sensor ov9650 = {
|
||||
.name = "OV9650",
|
||||
.i2c_slave_id = 0x60,
|
||||
.i2c_regW = 1,
|
||||
.probe = ov9650_probe,
|
||||
.init = ov9650_init,
|
||||
.start = ov9650_start,
|
||||
.stop = ov9650_stop,
|
||||
.power_down = ov9650_power_down,
|
||||
|
||||
.nctrls = 8,
|
||||
.ctrls = {
|
||||
static struct ctrl ov9650_ctrls[] = {
|
||||
{
|
||||
{
|
||||
.id = V4L2_CID_EXPOSURE,
|
||||
|
@ -267,7 +256,18 @@ static struct m5602_sensor ov9650 = {
|
|||
.set = ov9650_set_auto_gain,
|
||||
.get = ov9650_get_auto_gain
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
static struct m5602_sensor ov9650 = {
|
||||
.name = "OV9650",
|
||||
.i2c_slave_id = 0x60,
|
||||
.i2c_regW = 1,
|
||||
.probe = ov9650_probe,
|
||||
.init = ov9650_init,
|
||||
.start = ov9650_start,
|
||||
.stop = ov9650_stop,
|
||||
.power_down = ov9650_power_down,
|
||||
.ctrls = ov9650_ctrls,
|
||||
|
||||
.nmodes = 4,
|
||||
.modes = {
|
||||
|
@ -444,19 +444,10 @@ static const unsigned char init_ov9650[][3] =
|
|||
/* Enable denoise, and white-pixel erase */
|
||||
{SENSOR, OV9650_COM22, 0x23},
|
||||
|
||||
/* Set the high bits of the exposure value */
|
||||
{SENSOR, OV9650_AECH, ((EXPOSURE_DEFAULT & 0xff00) >> 8)},
|
||||
|
||||
/* Enable VARIOPIXEL */
|
||||
{SENSOR, OV9650_COM3, OV9650_VARIOPIXEL},
|
||||
{SENSOR, OV9650_COM4, OV9650_QVGA_VARIOPIXEL},
|
||||
|
||||
/* Set the low bits of the exposure value */
|
||||
{SENSOR, OV9650_COM1, (EXPOSURE_DEFAULT & 0xff)},
|
||||
{SENSOR, OV9650_GAIN, GAIN_DEFAULT},
|
||||
{SENSOR, OV9650_BLUE, BLUE_GAIN_DEFAULT},
|
||||
{SENSOR, OV9650_RED, RED_GAIN_DEFAULT},
|
||||
|
||||
/* Put the sensor in soft sleep mode */
|
||||
{SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X},
|
||||
};
|
||||
|
|
|
@ -62,7 +62,7 @@ int po1030_probe(struct sd *sd)
|
|||
sd->gspca_dev.cam.cam_mode = po1030.modes;
|
||||
sd->gspca_dev.cam.nmodes = po1030.nmodes;
|
||||
sd->desc->ctrls = po1030.ctrls;
|
||||
sd->desc->nctrls = po1030.nctrls;
|
||||
sd->desc->nctrls = ARRAY_SIZE(po1030_ctrls);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,18 +141,7 @@ int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
|
|||
int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
|
||||
int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
|
||||
|
||||
static struct m5602_sensor po1030 = {
|
||||
.name = "PO1030",
|
||||
|
||||
.i2c_slave_id = 0xdc,
|
||||
.i2c_regW = 1,
|
||||
|
||||
.probe = po1030_probe,
|
||||
.init = po1030_init,
|
||||
.power_down = po1030_power_down,
|
||||
|
||||
.nctrls = 6,
|
||||
.ctrls = {
|
||||
static struct ctrl po1030_ctrls[] = {
|
||||
{
|
||||
{
|
||||
.id = V4L2_CID_GAIN,
|
||||
|
@ -230,7 +219,19 @@ static struct m5602_sensor po1030 = {
|
|||
.set = po1030_set_vflip,
|
||||
.get = po1030_get_vflip
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
static struct m5602_sensor po1030 = {
|
||||
.name = "PO1030",
|
||||
|
||||
.i2c_slave_id = 0xdc,
|
||||
.i2c_regW = 1,
|
||||
|
||||
.probe = po1030_probe,
|
||||
.init = po1030_init,
|
||||
.power_down = po1030_power_down,
|
||||
|
||||
.ctrls = po1030_ctrls,
|
||||
|
||||
.nmodes = 1,
|
||||
.modes = {
|
||||
|
|
|
@ -118,8 +118,7 @@ int s5k4aa_probe(struct sd *sd)
|
|||
sd->gspca_dev.cam.cam_mode = s5k4aa.modes;
|
||||
sd->gspca_dev.cam.nmodes = s5k4aa.nmodes;
|
||||
sd->desc->ctrls = s5k4aa.ctrls;
|
||||
sd->desc->nctrls = s5k4aa.nctrls;
|
||||
|
||||
sd->desc->nctrls = ARRAY_SIZE(s5k4aa_ctrls);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,16 +77,7 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
|
|||
int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val);
|
||||
int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val);
|
||||
|
||||
static struct m5602_sensor s5k4aa = {
|
||||
.name = "S5K4AA",
|
||||
.probe = s5k4aa_probe,
|
||||
.init = s5k4aa_init,
|
||||
.start = s5k4aa_start,
|
||||
.power_down = s5k4aa_power_down,
|
||||
.i2c_slave_id = 0x5a,
|
||||
.i2c_regW = 2,
|
||||
.nctrls = 4,
|
||||
.ctrls = {
|
||||
static struct ctrl s5k4aa_ctrls[] = {
|
||||
{
|
||||
{
|
||||
.id = V4L2_CID_VFLIP,
|
||||
|
@ -140,7 +131,17 @@ static struct m5602_sensor s5k4aa = {
|
|||
.set = s5k4aa_set_exposure,
|
||||
.get = s5k4aa_get_exposure
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
static struct m5602_sensor s5k4aa = {
|
||||
.name = "S5K4AA",
|
||||
.probe = s5k4aa_probe,
|
||||
.init = s5k4aa_init,
|
||||
.start = s5k4aa_start,
|
||||
.power_down = s5k4aa_power_down,
|
||||
.i2c_slave_id = 0x5a,
|
||||
.i2c_regW = 2,
|
||||
.ctrls = s5k4aa_ctrls,
|
||||
|
||||
.nmodes = 1,
|
||||
.modes = {
|
||||
|
|
|
@ -66,7 +66,7 @@ int s5k83a_probe(struct sd *sd)
|
|||
sd->gspca_dev.cam.cam_mode = s5k83a.modes;
|
||||
sd->gspca_dev.cam.nmodes = s5k83a.nmodes;
|
||||
sd->desc->ctrls = s5k83a.ctrls;
|
||||
sd->desc->nctrls = s5k83a.nctrls;
|
||||
sd->desc->nctrls = ARRAY_SIZE(s5k83a_ctrls);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,17 +61,7 @@ int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
|
|||
int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
|
||||
int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
|
||||
|
||||
static struct m5602_sensor s5k83a = {
|
||||
.name = "S5K83A",
|
||||
.probe = s5k83a_probe,
|
||||
.init = s5k83a_init,
|
||||
.start = s5k83a_start,
|
||||
.stop = s5k83a_stop,
|
||||
.power_down = s5k83a_power_down,
|
||||
.i2c_slave_id = 0x5a,
|
||||
.i2c_regW = 2,
|
||||
.nctrls = 5,
|
||||
.ctrls = {
|
||||
static struct ctrl s5k83a_ctrls[] = {
|
||||
{
|
||||
{
|
||||
.id = V4L2_CID_BRIGHTNESS,
|
||||
|
@ -136,8 +126,21 @@ static struct m5602_sensor s5k83a = {
|
|||
},
|
||||
.set = s5k83a_set_vflip,
|
||||
.get = s5k83a_get_vflip
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static struct m5602_sensor s5k83a = {
|
||||
.name = "S5K83A",
|
||||
.probe = s5k83a_probe,
|
||||
.init = s5k83a_init,
|
||||
.start = s5k83a_start,
|
||||
.stop = s5k83a_stop,
|
||||
.power_down = s5k83a_power_down,
|
||||
.i2c_slave_id = 0x5a,
|
||||
.i2c_regW = 2,
|
||||
.ctrls = s5k83a_ctrls,
|
||||
|
||||
.nmodes = 1,
|
||||
.modes = {
|
||||
{
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#define M5602_DEFAULT_FRAME_WIDTH 640
|
||||
#define M5602_DEFAULT_FRAME_HEIGHT 480
|
||||
|
||||
#define M5602_MAX_CTRLS (V4L2_CID_LASTP1 - V4L2_CID_BASE + 10)
|
||||
|
||||
/* Enumerates all supported sensors */
|
||||
enum sensors {
|
||||
OV9650_SENSOR = 1,
|
||||
|
@ -67,8 +65,7 @@ struct m5602_sensor {
|
|||
/* Performs a power down sequence */
|
||||
int (*power_down)(struct sd *sd);
|
||||
|
||||
int nctrls;
|
||||
struct ctrl ctrls[M5602_MAX_CTRLS];
|
||||
const struct ctrl *ctrls;
|
||||
|
||||
char nmodes;
|
||||
struct v4l2_pix_format modes[];
|
||||
|
|
Loading…
Reference in a new issue