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

[media] gscpa: Move ctrl_handler to gspca_dev

We intend to eventually port all sub-drivers to the control-framework. At
which point it will make more sense to have the ctrl_handler in gspca_dev
then to have it in the subdrivers. Lets move it there now, to avoid a lot
of work to move it later.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 98684298
...@@ -174,6 +174,7 @@ struct gspca_dev { ...@@ -174,6 +174,7 @@ struct gspca_dev {
const struct sd_desc *sd_desc; /* subdriver description */ const struct sd_desc *sd_desc; /* subdriver description */
unsigned ctrl_dis; /* disabled controls (bit map) */ unsigned ctrl_dis; /* disabled controls (bit map) */
unsigned ctrl_inac; /* inactive controls (bit map) */ unsigned ctrl_inac; /* inactive controls (bit map) */
struct v4l2_ctrl_handler ctrl_handler;
/* autogain and exposure or gain control cluster, these are global as /* autogain and exposure or gain control cluster, these are global as
the autogain/exposure functions in autogain_functions.c use them */ the autogain/exposure functions in autogain_functions.c use them */
......
...@@ -34,7 +34,6 @@ MODULE_LICENSE("GPL"); ...@@ -34,7 +34,6 @@ MODULE_LICENSE("GPL");
struct sd { struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */ struct gspca_dev gspca_dev; /* !! must be the first item */
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_ctrl *brightness; struct v4l2_ctrl *brightness;
struct v4l2_ctrl *saturation; struct v4l2_ctrl *saturation;
struct v4l2_ctrl *sharpness; struct v4l2_ctrl *sharpness;
...@@ -161,8 +160,9 @@ static void setilluminators(struct gspca_dev *gspca_dev, bool top, bool bottom) ...@@ -161,8 +160,9 @@ static void setilluminators(struct gspca_dev *gspca_dev, bool top, bool bottom)
static int mars_s_ctrl(struct v4l2_ctrl *ctrl) static int mars_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
struct gspca_dev *gspca_dev = &sd->gspca_dev; container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
struct sd *sd = (struct sd *)gspca_dev;
gspca_dev->usb_err = 0; gspca_dev->usb_err = 0;
...@@ -179,20 +179,20 @@ static int mars_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -179,20 +179,20 @@ static int mars_s_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS: case V4L2_CID_BRIGHTNESS:
setbrightness(&sd->gspca_dev, ctrl->val); setbrightness(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_SATURATION: case V4L2_CID_SATURATION:
setcolors(&sd->gspca_dev, ctrl->val); setcolors(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_GAMMA: case V4L2_CID_GAMMA:
setgamma(&sd->gspca_dev, ctrl->val); setgamma(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_ILLUMINATORS_1: case V4L2_CID_ILLUMINATORS_1:
setilluminators(&sd->gspca_dev, sd->illum_top->val, setilluminators(gspca_dev, sd->illum_top->val,
sd->illum_bottom->val); sd->illum_bottom->val);
break; break;
case V4L2_CID_SHARPNESS: case V4L2_CID_SHARPNESS:
setsharpness(&sd->gspca_dev, ctrl->val); setsharpness(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_JPEG_COMPRESSION_QUALITY: case V4L2_CID_JPEG_COMPRESSION_QUALITY:
jpeg_set_qual(sd->jpeg_hdr, ctrl->val); jpeg_set_qual(sd->jpeg_hdr, ctrl->val);
...@@ -211,7 +211,7 @@ static const struct v4l2_ctrl_ops mars_ctrl_ops = { ...@@ -211,7 +211,7 @@ static const struct v4l2_ctrl_ops mars_ctrl_ops = {
static int sd_init_controls(struct gspca_dev *gspca_dev) static int sd_init_controls(struct gspca_dev *gspca_dev)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
gspca_dev->vdev.ctrl_handler = hdl; gspca_dev->vdev.ctrl_handler = hdl;
v4l2_ctrl_handler_init(hdl, 7); v4l2_ctrl_handler_init(hdl, 7);
......
...@@ -70,7 +70,6 @@ MODULE_LICENSE("GPL"); ...@@ -70,7 +70,6 @@ MODULE_LICENSE("GPL");
struct sd { struct sd {
struct gspca_dev gspca_dev; struct gspca_dev gspca_dev;
struct v4l2_ctrl_handler ctrl_handler;
struct { /* color control cluster */ struct { /* color control cluster */
struct v4l2_ctrl *brightness; struct v4l2_ctrl *brightness;
struct v4l2_ctrl *contrast; struct v4l2_ctrl *contrast;
...@@ -1694,8 +1693,9 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -1694,8 +1693,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
static int sd_s_ctrl(struct v4l2_ctrl *ctrl) static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
struct gspca_dev *gspca_dev = &sd->gspca_dev; container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
struct sd *sd = (struct sd *)gspca_dev;
gspca_dev->usb_err = 0; gspca_dev->usb_err = 0;
...@@ -1705,37 +1705,37 @@ static int sd_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -1705,37 +1705,37 @@ static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) { switch (ctrl->id) {
/* color control cluster */ /* color control cluster */
case V4L2_CID_BRIGHTNESS: case V4L2_CID_BRIGHTNESS:
set_cmatrix(&sd->gspca_dev, sd->brightness->val, set_cmatrix(gspca_dev, sd->brightness->val,
sd->contrast->val, sd->saturation->val, sd->hue->val); sd->contrast->val, sd->saturation->val, sd->hue->val);
break; break;
case V4L2_CID_GAMMA: case V4L2_CID_GAMMA:
set_gamma(&sd->gspca_dev, ctrl->val); set_gamma(gspca_dev, ctrl->val);
break; break;
/* blue/red balance cluster */ /* blue/red balance cluster */
case V4L2_CID_BLUE_BALANCE: case V4L2_CID_BLUE_BALANCE:
set_redblue(&sd->gspca_dev, sd->blue->val, sd->red->val); set_redblue(gspca_dev, sd->blue->val, sd->red->val);
break; break;
/* h/vflip cluster */ /* h/vflip cluster */
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
set_hvflip(&sd->gspca_dev, sd->hflip->val, sd->vflip->val); set_hvflip(gspca_dev, sd->hflip->val, sd->vflip->val);
break; break;
/* standalone exposure control */ /* standalone exposure control */
case V4L2_CID_EXPOSURE: case V4L2_CID_EXPOSURE:
set_exposure(&sd->gspca_dev, ctrl->val); set_exposure(gspca_dev, ctrl->val);
break; break;
/* standalone gain control */ /* standalone gain control */
case V4L2_CID_GAIN: case V4L2_CID_GAIN:
set_gain(&sd->gspca_dev, ctrl->val); set_gain(gspca_dev, ctrl->val);
break; break;
/* autogain + exposure or gain control cluster */ /* autogain + exposure or gain control cluster */
case V4L2_CID_AUTOGAIN: case V4L2_CID_AUTOGAIN:
if (sd->sensor == SENSOR_SOI968) if (sd->sensor == SENSOR_SOI968)
set_gain(&sd->gspca_dev, sd->gain->val); set_gain(gspca_dev, sd->gain->val);
else else
set_exposure(&sd->gspca_dev, sd->exposure->val); set_exposure(gspca_dev, sd->exposure->val);
break; break;
case V4L2_CID_JPEG_COMPRESSION_QUALITY: case V4L2_CID_JPEG_COMPRESSION_QUALITY:
set_quality(&sd->gspca_dev, ctrl->val); set_quality(gspca_dev, ctrl->val);
break; break;
} }
return gspca_dev->usb_err; return gspca_dev->usb_err;
...@@ -1748,7 +1748,7 @@ static const struct v4l2_ctrl_ops sd_ctrl_ops = { ...@@ -1748,7 +1748,7 @@ static const struct v4l2_ctrl_ops sd_ctrl_ops = {
static int sd_init_controls(struct gspca_dev *gspca_dev) static int sd_init_controls(struct gspca_dev *gspca_dev)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
gspca_dev->vdev.ctrl_handler = hdl; gspca_dev->vdev.ctrl_handler = hdl;
v4l2_ctrl_handler_init(hdl, 13); v4l2_ctrl_handler_init(hdl, 13);
......
...@@ -268,7 +268,7 @@ static int stv06xx_init_controls(struct gspca_dev *gspca_dev) ...@@ -268,7 +268,7 @@ static int stv06xx_init_controls(struct gspca_dev *gspca_dev)
PDEBUG(D_PROBE, "Initializing controls"); PDEBUG(D_PROBE, "Initializing controls");
gspca_dev->vdev.ctrl_handler = &sd->ctrl_handler; gspca_dev->vdev.ctrl_handler = &gspca_dev->ctrl_handler;
return sd->sensor->init_controls(sd); return sd->sensor->init_controls(sd);
} }
......
...@@ -89,9 +89,6 @@ struct sd { ...@@ -89,9 +89,6 @@ struct sd {
/* A pointer to the currently connected sensor */ /* A pointer to the currently connected sensor */
const struct stv06xx_sensor *sensor; const struct stv06xx_sensor *sensor;
/* Control handler */
struct v4l2_ctrl_handler ctrl_handler;
/* Sensor private data */ /* Sensor private data */
void *sensor_priv; void *sensor_priv;
......
...@@ -335,15 +335,16 @@ static int hdcs_set_size(struct sd *sd, ...@@ -335,15 +335,16 @@ static int hdcs_set_size(struct sd *sd,
static int hdcs_s_ctrl(struct v4l2_ctrl *ctrl) static int hdcs_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
int err = -EINVAL; int err = -EINVAL;
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_GAIN: case V4L2_CID_GAIN:
err = hdcs_set_gain(&sd->gspca_dev, ctrl->val); err = hdcs_set_gain(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_EXPOSURE: case V4L2_CID_EXPOSURE:
err = hdcs_set_exposure(&sd->gspca_dev, ctrl->val); err = hdcs_set_exposure(gspca_dev, ctrl->val);
break; break;
} }
return err; return err;
...@@ -355,7 +356,7 @@ static const struct v4l2_ctrl_ops hdcs_ctrl_ops = { ...@@ -355,7 +356,7 @@ static const struct v4l2_ctrl_ops hdcs_ctrl_ops = {
static int hdcs_init_controls(struct sd *sd) static int hdcs_init_controls(struct sd *sd)
{ {
struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler;
v4l2_ctrl_handler_init(hdl, 2); v4l2_ctrl_handler_init(hdl, 2);
v4l2_ctrl_new_std(hdl, &hdcs_ctrl_ops, v4l2_ctrl_new_std(hdl, &hdcs_ctrl_ops,
......
...@@ -87,24 +87,26 @@ static struct v4l2_pix_format pb0100_mode[] = { ...@@ -87,24 +87,26 @@ static struct v4l2_pix_format pb0100_mode[] = {
static int pb0100_s_ctrl(struct v4l2_ctrl *ctrl) static int pb0100_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
struct sd *sd = (struct sd *)gspca_dev;
struct pb0100_ctrls *ctrls = sd->sensor_priv; struct pb0100_ctrls *ctrls = sd->sensor_priv;
int err = -EINVAL; int err = -EINVAL;
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_AUTOGAIN: case V4L2_CID_AUTOGAIN:
err = pb0100_set_autogain(&sd->gspca_dev, ctrl->val); err = pb0100_set_autogain(gspca_dev, ctrl->val);
if (err) if (err)
break; break;
if (ctrl->val) if (ctrl->val)
break; break;
err = pb0100_set_gain(&sd->gspca_dev, ctrls->gain->val); err = pb0100_set_gain(gspca_dev, ctrls->gain->val);
if (err) if (err)
break; break;
err = pb0100_set_exposure(&sd->gspca_dev, ctrls->exposure->val); err = pb0100_set_exposure(gspca_dev, ctrls->exposure->val);
break; break;
case V4L2_CTRL_CLASS_USER + 0x1001: case V4L2_CTRL_CLASS_USER + 0x1001:
err = pb0100_set_autogain_target(&sd->gspca_dev, ctrl->val); err = pb0100_set_autogain_target(gspca_dev, ctrl->val);
break; break;
} }
return err; return err;
...@@ -116,7 +118,7 @@ static const struct v4l2_ctrl_ops pb0100_ctrl_ops = { ...@@ -116,7 +118,7 @@ static const struct v4l2_ctrl_ops pb0100_ctrl_ops = {
static int pb0100_init_controls(struct sd *sd) static int pb0100_init_controls(struct sd *sd)
{ {
struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler;
struct pb0100_ctrls *ctrls; struct pb0100_ctrls *ctrls;
static const struct v4l2_ctrl_config autogain_target = { static const struct v4l2_ctrl_config autogain_target = {
.ops = &pb0100_ctrl_ops, .ops = &pb0100_ctrl_ops,
......
...@@ -67,7 +67,9 @@ static int setexposure(struct sd *sd, s16 expo); ...@@ -67,7 +67,9 @@ static int setexposure(struct sd *sd, s16 expo);
static int st6422_s_ctrl(struct v4l2_ctrl *ctrl) static int st6422_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
struct sd *sd = (struct sd *)gspca_dev;
int err = -EINVAL; int err = -EINVAL;
switch (ctrl->id) { switch (ctrl->id) {
...@@ -98,7 +100,7 @@ static const struct v4l2_ctrl_ops st6422_ctrl_ops = { ...@@ -98,7 +100,7 @@ static const struct v4l2_ctrl_ops st6422_ctrl_ops = {
static int st6422_init_controls(struct sd *sd) static int st6422_init_controls(struct sd *sd)
{ {
struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler;
v4l2_ctrl_handler_init(hdl, 4); v4l2_ctrl_handler_init(hdl, 4);
v4l2_ctrl_new_std(hdl, &st6422_ctrl_ops, v4l2_ctrl_new_std(hdl, &st6422_ctrl_ops,
......
...@@ -46,21 +46,22 @@ static struct v4l2_pix_format vv6410_mode[] = { ...@@ -46,21 +46,22 @@ static struct v4l2_pix_format vv6410_mode[] = {
static int vv6410_s_ctrl(struct v4l2_ctrl *ctrl) static int vv6410_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
int err = -EINVAL; int err = -EINVAL;
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
err = vv6410_set_hflip(&sd->gspca_dev, ctrl->val); err = vv6410_set_hflip(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_VFLIP: case V4L2_CID_VFLIP:
err = vv6410_set_vflip(&sd->gspca_dev, ctrl->val); err = vv6410_set_vflip(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_GAIN: case V4L2_CID_GAIN:
err = vv6410_set_analog_gain(&sd->gspca_dev, ctrl->val); err = vv6410_set_analog_gain(gspca_dev, ctrl->val);
break; break;
case V4L2_CID_EXPOSURE: case V4L2_CID_EXPOSURE:
err = vv6410_set_exposure(&sd->gspca_dev, ctrl->val); err = vv6410_set_exposure(gspca_dev, ctrl->val);
break; break;
} }
return err; return err;
...@@ -91,7 +92,7 @@ static int vv6410_probe(struct sd *sd) ...@@ -91,7 +92,7 @@ static int vv6410_probe(struct sd *sd)
static int vv6410_init_controls(struct sd *sd) static int vv6410_init_controls(struct sd *sd)
{ {
struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler;
v4l2_ctrl_handler_init(hdl, 4); v4l2_ctrl_handler_init(hdl, 4);
v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops,
......
...@@ -39,7 +39,6 @@ static int force_sensor = -1; ...@@ -39,7 +39,6 @@ static int force_sensor = -1;
struct sd { struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */ struct gspca_dev gspca_dev; /* !! must be the first item */
struct v4l2_ctrl_handler ctrl_handler;
struct { /* gamma/brightness/contrast control cluster */ struct { /* gamma/brightness/contrast control cluster */
struct v4l2_ctrl *gamma; struct v4l2_ctrl *gamma;
struct v4l2_ctrl *brightness; struct v4l2_ctrl *brightness;
...@@ -6328,8 +6327,9 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -6328,8 +6327,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
static int zcxx_g_volatile_ctrl(struct v4l2_ctrl *ctrl) static int zcxx_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
struct gspca_dev *gspca_dev = &sd->gspca_dev; container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
struct sd *sd = (struct sd *)gspca_dev;
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_AUTOGAIN: case V4L2_CID_AUTOGAIN:
...@@ -6343,8 +6343,9 @@ static int zcxx_g_volatile_ctrl(struct v4l2_ctrl *ctrl) ...@@ -6343,8 +6343,9 @@ static int zcxx_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
static int zcxx_s_ctrl(struct v4l2_ctrl *ctrl) static int zcxx_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); struct gspca_dev *gspca_dev =
struct gspca_dev *gspca_dev = &sd->gspca_dev; container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
struct sd *sd = (struct sd *)gspca_dev;
int i, qual; int i, qual;
gspca_dev->usb_err = 0; gspca_dev->usb_err = 0;
...@@ -6404,7 +6405,7 @@ static const struct v4l2_ctrl_ops zcxx_ctrl_ops = { ...@@ -6404,7 +6405,7 @@ static const struct v4l2_ctrl_ops zcxx_ctrl_ops = {
static int sd_init_controls(struct gspca_dev *gspca_dev) static int sd_init_controls(struct gspca_dev *gspca_dev)
{ {
struct sd *sd = (struct sd *)gspca_dev; struct sd *sd = (struct sd *)gspca_dev;
struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
static const u8 gamma[SENSOR_MAX] = { static const u8 gamma[SENSOR_MAX] = {
[SENSOR_ADCM2700] = 4, [SENSOR_ADCM2700] = 4,
[SENSOR_CS2102] = 4, [SENSOR_CS2102] = 4,
......
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