Skip to content

Commit

Permalink
[media] stk-webcam: Add an upside down dmi table, and add the Asus G1…
Browse files Browse the repository at this point in the history
… to it

The stk-webcam module is inserted upside-down in some webcams, so we
need to de hflip and vflip by default on some models.
Note that this patch inverts the value of the controls as reported by
the control API in this case so that for the user they still make sense
(iow not doing any flipping from the ctrl API pov results in an upright
image).

Reported-by: Jose Gómez <adler@dreamcoder.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Dec 21, 2012
1 parent 143dd34 commit 7a29ee2
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions drivers/media/usb/stkwebcam/stk-webcam.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/errno.h>
#include <linux/slab.h>

#include <linux/dmi.h>
#include <linux/usb.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
Expand All @@ -38,12 +39,12 @@
#include "stk-webcam.h"


static bool hflip;
module_param(hflip, bool, 0444);
static int hflip = -1;
module_param(hflip, int, 0444);
MODULE_PARM_DESC(hflip, "Horizontal image flip (mirror). Defaults to 0");

static bool vflip;
module_param(vflip, bool, 0444);
static int vflip = -1;
module_param(vflip, int, 0444);
MODULE_PARM_DESC(vflip, "Vertical image flip. Defaults to 0");

static int debug;
Expand All @@ -62,6 +63,19 @@ static struct usb_device_id stkwebcam_table[] = {
};
MODULE_DEVICE_TABLE(usb, stkwebcam_table);

/* The stk webcam laptop module is mounted upside down in some laptops :( */
static const struct dmi_system_id stk_upside_down_dmi_table[] = {
{
.ident = "ASUS G1",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "G1")
}
},
{}
};


/*
* Basic stuff
*/
Expand Down Expand Up @@ -817,10 +831,16 @@ static int stk_vidioc_g_ctrl(struct file *filp,
c->value = dev->vsettings.brightness;
break;
case V4L2_CID_HFLIP:
c->value = dev->vsettings.hflip;
if (dmi_check_system(stk_upside_down_dmi_table))
c->value = !dev->vsettings.hflip;
else
c->value = dev->vsettings.hflip;
break;
case V4L2_CID_VFLIP:
c->value = dev->vsettings.vflip;
if (dmi_check_system(stk_upside_down_dmi_table))
c->value = !dev->vsettings.vflip;
else
c->value = dev->vsettings.vflip;
break;
default:
return -EINVAL;
Expand All @@ -837,10 +857,16 @@ static int stk_vidioc_s_ctrl(struct file *filp,
dev->vsettings.brightness = c->value;
return stk_sensor_set_brightness(dev, c->value >> 8);
case V4L2_CID_HFLIP:
dev->vsettings.hflip = c->value;
if (dmi_check_system(stk_upside_down_dmi_table))
dev->vsettings.hflip = !c->value;
else
dev->vsettings.hflip = c->value;
return 0;
case V4L2_CID_VFLIP:
dev->vsettings.vflip = c->value;
if (dmi_check_system(stk_upside_down_dmi_table))
dev->vsettings.vflip = !c->value;
else
dev->vsettings.vflip = c->value;
return 0;
default:
return -EINVAL;
Expand Down Expand Up @@ -1276,8 +1302,18 @@ static int stk_camera_probe(struct usb_interface *interface,
dev->interface = interface;
usb_get_intf(interface);

dev->vsettings.vflip = vflip;
dev->vsettings.hflip = hflip;
if (hflip != -1)
dev->vsettings.hflip = hflip;
else if (dmi_check_system(stk_upside_down_dmi_table))
dev->vsettings.hflip = 1;
else
dev->vsettings.hflip = 0;
if (vflip != -1)
dev->vsettings.vflip = vflip;
else if (dmi_check_system(stk_upside_down_dmi_table))
dev->vsettings.vflip = 1;
else
dev->vsettings.vflip = 0;
dev->n_sbufs = 0;
set_present(dev);

Expand Down

0 comments on commit 7a29ee2

Please sign in to comment.