Commit c84e412f authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

[media] gscpa_m5602: Convert to the control framework

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 676fdd85
......@@ -136,16 +136,33 @@ struct sd {
/* A pointer to the currently connected sensor */
const struct m5602_sensor *sensor;
struct sd_desc *desc;
/* Sensor private data */
void *sensor_priv;
/* The current frame's id, used to detect frame boundaries */
u8 frame_id;
/* The current frame count */
u32 frame_count;
/* Camera rotation polling thread for "flipable" cams */
struct task_struct *rotation_thread;
struct { /* auto-white-bal + green/red/blue balance control cluster */
struct v4l2_ctrl *auto_white_bal;
struct v4l2_ctrl *red_bal;
struct v4l2_ctrl *blue_bal;
struct v4l2_ctrl *green_bal;
};
struct { /* autoexpo / expo cluster */
struct v4l2_ctrl *autoexpo;
struct v4l2_ctrl *expo;
};
struct { /* autogain / gain cluster */
struct v4l2_ctrl *autogain;
struct v4l2_ctrl *gain;
};
struct { /* hflip/vflip cluster */
struct v4l2_ctrl *hflip;
struct v4l2_ctrl *vflip;
};
};
int m5602_read_bridge(
......
......@@ -252,6 +252,16 @@ static int m5602_init(struct gspca_dev *gspca_dev)
return err;
}
static int m5602_init_controls(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
if (!sd->sensor->init_controls)
return 0;
return sd->sensor->init_controls(sd);
}
static int m5602_start_transfer(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
......@@ -336,11 +346,12 @@ static void m5602_stop_transfer(struct gspca_dev *gspca_dev)
sd->sensor->stop(sd);
}
/* sub-driver description, the ctrl and nctrl is filled at probe time */
static struct sd_desc sd_desc = {
/* sub-driver description */
static const struct sd_desc sd_desc = {
.name = MODULE_NAME,
.config = m5602_configure,
.init = m5602_init,
.init_controls = m5602_init_controls,
.start = m5602_start_transfer,
.stopN = m5602_stop_transfer,
.pkt_scan = m5602_urb_complete
......@@ -355,7 +366,6 @@ static int m5602_configure(struct gspca_dev *gspca_dev,
int err;
cam = &gspca_dev->cam;
sd->desc = &sd_desc;
if (dump_bridge)
m5602_dump_bridge(sd);
......
......@@ -110,6 +110,7 @@ extern bool dump_sensor;
int mt9m111_probe(struct sd *sd);
int mt9m111_init(struct sd *sd);
int mt9m111_init_controls(struct sd *sd);
int mt9m111_start(struct sd *sd);
void mt9m111_disconnect(struct sd *sd);
......@@ -121,6 +122,7 @@ static const struct m5602_sensor mt9m111 = {
.probe = mt9m111_probe,
.init = mt9m111_init,
.init_controls = mt9m111_init_controls,
.disconnect = mt9m111_disconnect,
.start = mt9m111_start,
};
......
......@@ -90,6 +90,8 @@ extern bool dump_sensor;
int ov7660_probe(struct sd *sd);
int ov7660_init(struct sd *sd);
int ov7660_init(struct sd *sd);
int ov7660_init_controls(struct sd *sd);
int ov7660_start(struct sd *sd);
int ov7660_stop(struct sd *sd);
void ov7660_disconnect(struct sd *sd);
......@@ -100,6 +102,7 @@ static const struct m5602_sensor ov7660 = {
.i2c_regW = 1,
.probe = ov7660_probe,
.init = ov7660_init,
.init_controls = ov7660_init_controls,
.start = ov7660_start,
.stop = ov7660_stop,
.disconnect = ov7660_disconnect,
......
......@@ -139,6 +139,7 @@ extern bool dump_sensor;
int ov9650_probe(struct sd *sd);
int ov9650_init(struct sd *sd);
int ov9650_init_controls(struct sd *sd);
int ov9650_start(struct sd *sd);
int ov9650_stop(struct sd *sd);
void ov9650_disconnect(struct sd *sd);
......@@ -149,6 +150,7 @@ static const struct m5602_sensor ov9650 = {
.i2c_regW = 1,
.probe = ov9650_probe,
.init = ov9650_init,
.init_controls = ov9650_init_controls,
.start = ov9650_start,
.stop = ov9650_stop,
.disconnect = ov9650_disconnect,
......
......@@ -151,6 +151,7 @@ extern bool dump_sensor;
int po1030_probe(struct sd *sd);
int po1030_init(struct sd *sd);
int po1030_init_controls(struct sd *sd);
int po1030_start(struct sd *sd);
void po1030_disconnect(struct sd *sd);
......@@ -162,6 +163,7 @@ static const struct m5602_sensor po1030 = {
.probe = po1030_probe,
.init = po1030_init,
.init_controls = po1030_init_controls,
.start = po1030_start,
.disconnect = po1030_disconnect,
};
......
......@@ -69,6 +69,7 @@ extern bool dump_sensor;
int s5k4aa_probe(struct sd *sd);
int s5k4aa_init(struct sd *sd);
int s5k4aa_init_controls(struct sd *sd);
int s5k4aa_start(struct sd *sd);
void s5k4aa_disconnect(struct sd *sd);
......@@ -79,6 +80,7 @@ static const struct m5602_sensor s5k4aa = {
.probe = s5k4aa_probe,
.init = s5k4aa_init,
.init_controls = s5k4aa_init_controls,
.start = s5k4aa_start,
.disconnect = s5k4aa_disconnect,
};
......
......@@ -45,6 +45,7 @@ extern bool dump_sensor;
int s5k83a_probe(struct sd *sd);
int s5k83a_init(struct sd *sd);
int s5k83a_init_controls(struct sd *sd);
int s5k83a_start(struct sd *sd);
int s5k83a_stop(struct sd *sd);
void s5k83a_disconnect(struct sd *sd);
......@@ -53,6 +54,7 @@ static const struct m5602_sensor s5k83a = {
.name = "S5K83A",
.probe = s5k83a_probe,
.init = s5k83a_init,
.init_controls = s5k83a_init_controls,
.start = s5k83a_start,
.stop = s5k83a_stop,
.disconnect = s5k83a_disconnect,
......@@ -60,13 +62,6 @@ static const struct m5602_sensor s5k83a = {
.i2c_regW = 2,
};
struct s5k83a_priv {
/* We use another thread periodically
probing the orientation of the camera */
struct task_struct *rotation_thread;
s32 *settings;
};
static const unsigned char preinit_s5k83a[][4] = {
{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
{BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
......
......@@ -57,6 +57,9 @@ struct m5602_sensor {
/* Performs a initialization sequence */
int (*init)(struct sd *sd);
/* Controls initialization, maybe NULL */
int (*init_controls)(struct sd *sd);
/* Executed when the camera starts to send data */
int (*start)(struct sd *sd);
......
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