summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l/libv4lconvert/control
diff options
context:
space:
mode:
authorhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-05-25 15:25:15 +0200
committerhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-05-25 15:25:15 +0200
commit51949cfaadebd8e341fed1e85eca683dd40195d2 (patch)
treea073bed97a4704eb6f73c2c0e54399f30f35e93d /v4l2-apps/libv4l/libv4lconvert/control
parentb152107391374bfc61ea21d1731fd349352bedf2 (diff)
downloadmediapointer-dvb-s2-51949cfaadebd8e341fed1e85eca683dd40195d2.tar.gz
mediapointer-dvb-s2-51949cfaadebd8e341fed1e85eca683dd40195d2.tar.bz2
libv4l: add software autogain / exposure
From: Hans de Goede <hdegoede@redhat.com> Add software autogain / exposure, for camera's which have gain and exposure controls but do not contain the ability to calculate the average lumination in hardware (which is needed to do this in the kernel). This patch enables this for the spca561 rev12a, but it should be usefull for other cameras too. Priority: normal Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l/libv4lconvert/control')
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c36
-rw-r--r--v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.h13
2 files changed, 45 insertions, 4 deletions
diff --git a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c
index 4d227c366..edf86483d 100644
--- a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c
+++ b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c
@@ -67,7 +67,7 @@ static const struct v4lcontrol_flags_info v4lcontrol_flags[] = {
/* Asus N50Vn laptop */
{ 0x04f2, 0xb106, 0, "ASUSTeK Computer Inc. ", "N50Vn ",
V4LCONTROL_HFLIPPED|V4LCONTROL_VFLIPPED },
-/* Second: devices which should use sw whitebalance by default */
+/* Second: devices which should use some software processing by default */
/* Pac207 based devices */
{ 0x041e, 0x4028, 0, NULL, NULL, V4LCONTROL_WANTS_WB },
{ 0x093a, 0x2460, 0x1f, NULL, NULL, V4LCONTROL_WANTS_WB },
@@ -78,6 +78,9 @@ static const struct v4lcontrol_flags_info v4lcontrol_flags[] = {
V4LCONTROL_ROTATED_90_JPEG|V4LCONTROL_WANTS_WB },
/* sq905 devices */
{ 0x2770, 0x9120, 0, NULL, NULL, V4LCONTROL_WANTS_WB },
+ /* spca561 revison 12a devices */
+ { 0x041e, 0x403b, 0, NULL, NULL, V4LCONTROL_WANTS_WB_AUTOGAIN },
+ { 0x046d, 0x0928, 7, NULL, NULL, V4LCONTROL_WANTS_WB_AUTOGAIN },
};
static const struct v4l2_queryctrl fake_controls[];
@@ -223,13 +226,17 @@ struct v4lcontrol_data *v4lcontrol_create(int fd, int always_needs_conversion)
/* If the device always needs conversion, we can add fake controls at no cost
(no cost when not activated by the user that is) */
if (always_needs_conversion || v4lcontrol_needs_conversion(data)) {
- for (i = 0; i < V4LCONTROL_COUNT; i++) {
+ for (i = 0; i < V4LCONTROL_AUTO_ENABLE_COUNT; i++) {
ctrl.id = fake_controls[i].id;
if (syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, &ctrl) == -1)
data->controls |= 1 << i;
}
}
+ if (data->flags & V4LCONTROL_WANTS_AUTOGAIN)
+ data->controls |= 1 << V4LCONTROL_AUTOGAIN |
+ 1 << V4LCONTROL_AUTOGAIN_TARGET;
+
/* Allow overriding through environment */
if ((s = getenv("LIBV4LCONTROL_CONTROLS")))
data->controls = strtol(s, NULL, 0);
@@ -266,6 +273,10 @@ struct v4lcontrol_data *v4lcontrol_create(int fd, int always_needs_conversion)
if (init) {
/* Initialize the new shm object we created */
memset(data->shm_values, 0, sizeof(V4LCONTROL_SHM_SIZE));
+
+ for (i = 0; i < V4LCONTROL_COUNT; i++)
+ data->shm_values[i] = fake_controls[i].default_value;
+
if (data->flags & V4LCONTROL_WANTS_WB)
data->shm_values[V4LCONTROL_WHITEBALANCE] = 1;
}
@@ -316,6 +327,27 @@ static const struct v4l2_queryctrl fake_controls[V4LCONTROL_COUNT] = {
.default_value = 0,
.flags = 0
},
+{}, /* Dummy place holder for V4LCONTROL_AUTO_ENABLE_COUNT */
+{
+ .id = V4L2_CID_AUTOGAIN,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "Auto Gain (software)",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 1,
+ .flags = 0
+},
+{
+ .id = V4L2_CTRL_CLASS_USER + 0x2000, /* FIXME */
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Auto Gain target",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 1,
+ .default_value = 100,
+ .flags = 0
+},
};
int v4lcontrol_vidioc_queryctrl(struct v4lcontrol_data *data, void *arg)
diff --git a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.h b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.h
index 85129ee4c..a3640038b 100644
--- a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.h
+++ b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.h
@@ -12,7 +12,7 @@
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
@@ -27,13 +27,22 @@
#define V4LCONTROL_VFLIPPED 0x02
#define V4LCONTROL_ROTATED_90_JPEG 0x04
#define V4LCONTROL_WANTS_WB 0x08
+#define V4LCONTROL_WANTS_AUTOGAIN 0x10
+
+/* Masks */
+#define V4LCONTROL_WANTS_WB_AUTOGAIN (V4LCONTROL_WANTS_WB | V4LCONTROL_WANTS_AUTOGAIN)
/* Controls */
enum {
V4LCONTROL_WHITEBALANCE,
V4LCONTROL_HFLIP,
V4LCONTROL_VFLIP,
- V4LCONTROL_COUNT };
+ /* All fake controls above here are auto enabled when not present in hw */
+ V4LCONTROL_AUTO_ENABLE_COUNT,
+ V4LCONTROL_AUTOGAIN,
+ V4LCONTROL_AUTOGAIN_TARGET,
+ V4LCONTROL_COUNT
+ };
struct v4lcontrol_data;