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

[media] gspca_pac7311: Remove vflip control

Enabling vflip leads to a much better image, with vflip disabled the
image looks washed out as if there is a too high brightness setting.

Since we don't know how to lower the brightness setting when not
vflipping, simply always vflip and tell userspace to flip the image back,
resulting in a much better (less washed out) image.

Since the image is now no longer too bright, also modify the luminance
level the auto-gain algorithm aims for.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 42f85d0a
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
* 0x0f Master gain 1-245, low value = high gain * 0x0f Master gain 1-245, low value = high gain
* 0x10 Another gain 0-15, limited influence (1-2x gain I guess) * 0x10 Another gain 0-15, limited influence (1-2x gain I guess)
* 0x21 Bitfield: 0-1 unused, 2-3 vflip/hflip, 4-5 unknown, 6-7 unused * 0x21 Bitfield: 0-1 unused, 2-3 vflip/hflip, 4-5 unknown, 6-7 unused
* Note setting vflip disabled leads to a much lower image quality,
* so we always vflip, and tell userspace to flip it back
* 0x27 Seems to toggle various gains on / off, Setting bit 7 seems to * 0x27 Seems to toggle various gains on / off, Setting bit 7 seems to
* completely disable the analog amplification block. Set to 0x68 * completely disable the analog amplification block. Set to 0x68
* for max gain, 0x14 for minimal gain. * for max gain, 0x14 for minimal gain.
...@@ -75,10 +77,7 @@ struct sd { ...@@ -75,10 +77,7 @@ 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 *contrast; struct v4l2_ctrl *contrast;
struct { /* flip cluster */
struct v4l2_ctrl *hflip; struct v4l2_ctrl *hflip;
struct v4l2_ctrl *vflip;
};
u8 sof_read; u8 sof_read;
u8 autogain_ignore_frames; u8 autogain_ignore_frames;
...@@ -292,6 +291,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -292,6 +291,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->cam_mode = vga_mode; cam->cam_mode = vga_mode;
cam->nmodes = ARRAY_SIZE(vga_mode); cam->nmodes = ARRAY_SIZE(vga_mode);
cam->input_flags = V4L2_IN_ST_VFLIP;
return 0; return 0;
} }
...@@ -399,7 +399,7 @@ static int sd_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -399,7 +399,7 @@ static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
setgain(gspca_dev, gspca_dev->gain->val); setgain(gspca_dev, gspca_dev->gain->val);
break; break;
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
sethvflip(gspca_dev, sd->hflip->val, sd->vflip->val); sethvflip(gspca_dev, sd->hflip->val, 1);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -432,8 +432,6 @@ static int sd_init_controls(struct gspca_dev *gspca_dev) ...@@ -432,8 +432,6 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
PAC7311_GAIN_DEFAULT); PAC7311_GAIN_DEFAULT);
sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0); V4L2_CID_HFLIP, 0, 1, 1, 0);
sd->vflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
V4L2_CID_VFLIP, 0, 1, 1, 0);
if (hdl->error) { if (hdl->error) {
pr_err("Could not initialize controls\n"); pr_err("Could not initialize controls\n");
...@@ -441,7 +439,6 @@ static int sd_init_controls(struct gspca_dev *gspca_dev) ...@@ -441,7 +439,6 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
} }
v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false);
v4l2_ctrl_cluster(2, &sd->hflip);
return 0; return 0;
} }
...@@ -457,8 +454,7 @@ static int sd_start(struct gspca_dev *gspca_dev) ...@@ -457,8 +454,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
setcontrast(gspca_dev, v4l2_ctrl_g_ctrl(sd->contrast)); setcontrast(gspca_dev, v4l2_ctrl_g_ctrl(sd->contrast));
setgain(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->gain)); setgain(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->gain));
setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure)); setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure));
sethvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip), sethvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip), 1);
v4l2_ctrl_g_ctrl(sd->vflip));
/* set correct resolution */ /* set correct resolution */
switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {
...@@ -513,7 +509,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) ...@@ -513,7 +509,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
if (avg_lum == -1) if (avg_lum == -1)
return; return;
desired_lum = 200; desired_lum = 170;
deadzone = 20; deadzone = 20;
if (sd->autogain_ignore_frames > 0) if (sd->autogain_ignore_frames > 0)
......
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