mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-16 01:24:08 +08:00
[media] spca505: convert to the control framework
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
9b6b35dcb0
commit
2aed6c1b77
@ -33,34 +33,11 @@ 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 */
|
||||||
|
|
||||||
u8 brightness;
|
|
||||||
|
|
||||||
u8 subtype;
|
u8 subtype;
|
||||||
#define IntelPCCameraPro 0
|
#define IntelPCCameraPro 0
|
||||||
#define Nxultra 1
|
#define Nxultra 1
|
||||||
};
|
};
|
||||||
|
|
||||||
/* V4L2 controls supported by the driver */
|
|
||||||
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
|
|
||||||
static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
|
|
||||||
|
|
||||||
static const struct ctrl sd_ctrls[] = {
|
|
||||||
{
|
|
||||||
{
|
|
||||||
.id = V4L2_CID_BRIGHTNESS,
|
|
||||||
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
||||||
.name = "Brightness",
|
|
||||||
.minimum = 0,
|
|
||||||
.maximum = 255,
|
|
||||||
.step = 1,
|
|
||||||
#define BRIGHTNESS_DEF 127
|
|
||||||
.default_value = BRIGHTNESS_DEF,
|
|
||||||
},
|
|
||||||
.set = sd_setbrightness,
|
|
||||||
.get = sd_getbrightness,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct v4l2_pix_format vga_mode[] = {
|
static const struct v4l2_pix_format vga_mode[] = {
|
||||||
{160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
|
{160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
|
||||||
.bytesperline = 160,
|
.bytesperline = 160,
|
||||||
@ -633,7 +610,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||||||
cam->nmodes = ARRAY_SIZE(vga_mode);
|
cam->nmodes = ARRAY_SIZE(vga_mode);
|
||||||
else /* no 640x480 for IntelPCCameraPro */
|
else /* no 640x480 for IntelPCCameraPro */
|
||||||
cam->nmodes = ARRAY_SIZE(vga_mode) - 1;
|
cam->nmodes = ARRAY_SIZE(vga_mode) - 1;
|
||||||
sd->brightness = BRIGHTNESS_DEF;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -651,11 +627,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setbrightness(struct gspca_dev *gspca_dev)
|
static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness)
|
||||||
{
|
{
|
||||||
struct sd *sd = (struct sd *) gspca_dev;
|
|
||||||
u8 brightness = sd->brightness;
|
|
||||||
|
|
||||||
reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6);
|
reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6);
|
||||||
reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2);
|
reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2);
|
||||||
}
|
}
|
||||||
@ -710,7 +683,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
|
|||||||
SPCA50X_USB_CTRL,
|
SPCA50X_USB_CTRL,
|
||||||
SPCA50X_CUSB_ENABLE);
|
SPCA50X_CUSB_ENABLE);
|
||||||
|
|
||||||
setbrightness(gspca_dev);
|
v4l2_ctrl_handler_setup(&gspca_dev->ctrl_handler);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -756,30 +729,49 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
|
static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
{
|
{
|
||||||
struct sd *sd = (struct sd *) gspca_dev;
|
struct gspca_dev *gspca_dev =
|
||||||
|
container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
|
||||||
|
|
||||||
sd->brightness = val;
|
gspca_dev->usb_err = 0;
|
||||||
if (gspca_dev->streaming)
|
|
||||||
setbrightness(gspca_dev);
|
if (!gspca_dev->streaming)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
switch (ctrl->id) {
|
||||||
|
case V4L2_CID_BRIGHTNESS:
|
||||||
|
setbrightness(gspca_dev, ctrl->val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return gspca_dev->usb_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
|
static const struct v4l2_ctrl_ops sd_ctrl_ops = {
|
||||||
{
|
.s_ctrl = sd_s_ctrl,
|
||||||
struct sd *sd = (struct sd *) gspca_dev;
|
};
|
||||||
|
|
||||||
*val = sd->brightness;
|
static int sd_init_controls(struct gspca_dev *gspca_dev)
|
||||||
|
{
|
||||||
|
struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
|
||||||
|
|
||||||
|
gspca_dev->vdev.ctrl_handler = hdl;
|
||||||
|
v4l2_ctrl_handler_init(hdl, 5);
|
||||||
|
v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
|
||||||
|
V4L2_CID_BRIGHTNESS, 0, 255, 1, 127);
|
||||||
|
|
||||||
|
if (hdl->error) {
|
||||||
|
pr_err("Could not initialize controls\n");
|
||||||
|
return hdl->error;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sub-driver description */
|
/* sub-driver description */
|
||||||
static const struct sd_desc sd_desc = {
|
static const struct sd_desc sd_desc = {
|
||||||
.name = MODULE_NAME,
|
.name = MODULE_NAME,
|
||||||
.ctrls = sd_ctrls,
|
|
||||||
.nctrls = ARRAY_SIZE(sd_ctrls),
|
|
||||||
.config = sd_config,
|
.config = sd_config,
|
||||||
|
.init_controls = sd_init_controls,
|
||||||
.init = sd_init,
|
.init = sd_init,
|
||||||
.start = sd_start,
|
.start = sd_start,
|
||||||
.stopN = sd_stopN,
|
.stopN = sd_stopN,
|
||||||
|
Loading…
Reference in New Issue
Block a user