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>
m5602_s5k83a.o \
m5602_s5k4aa.o
-EXTRA_CFLAGS += -Idrivers/media/video/gspca
-
+EXTRA_CFLAGS += -Idrivers/media/video/gspca
\ No newline at end of file
char *name;
/* A pointer to the currently connected sensor */
- struct m5602_sensor *sensor;
+ const struct m5602_sensor *sensor;
struct sd_desc *desc;
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;
}
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,
.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 = {
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;
}
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,
.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 = {
/* 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},
};
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;
}
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,
.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 = {
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;
}
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,
.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 = {
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;
}
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,
},
.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 = {
{
#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,
/* 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[];