Great.
Unfortunatly I have problems to understand it.

Anyway - I think you wanted a choice about auto-gain.
he attached patch should provide the framewrok for an "ov9650_set_autogain()" function.

BTW: checkpatch keeps complaing that I initiazed a static to 0. Is 0 the default value for statics?

GWater


Vasily Khoruzhick schrieb:
On 23 November 2008 23:06:39 GWater wrote:
I'm working on Autogain control and I notice that we are defining our
own autoexposure CID. Why are we not using the existing ones?

(from <linux/videodev2.h>:)

#define V4L2_CID_EXPOSURE_AUTO
(V4L2_CID_CAMERA_CLASS_BASE+1)
enum v4l2_exposure_auto_type {
         V4L2_EXPOSURE_AUTO = 0,
         V4L2_EXPOSURE_MANUAL = 1,
         V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
         V4L2_EXPOSURE_APERTURE_PRIORITY = 3
};

I think we should use that. (microdia-v4l.c already includes videodev2.h
via v4l2-common.h and v4l2-dev.h)

Agreed

From 6de2a56404ec042903499891f7859d2f528cd454 Mon Sep 17 00:00:00 2001
From: GWater <[EMAIL PROTECTED]>
Date: Sun, 23 Nov 2008 22:12:55 +0100
Subject: [PATCH] make an adjustable auto-gain setting.

Signed-off-by: GWater <[EMAIL PROTECTED]>
---
 microdia-dev.c |   18 ++++++++++++++++++
 microdia-usb.c |   18 +++++++++++++++++-
 microdia-v4l.c |   18 ++++++++++++++++++
 microdia.h     |    3 +++
 4 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/microdia-dev.c b/microdia-dev.c
index b276cf2..632d35c 100644
--- a/microdia-dev.c
+++ b/microdia-dev.c
@@ -282,6 +282,7 @@ int dev_microdia_camera_settings(struct usb_microdia *dev)
        dev_microdia_camera_set_sharpness(dev);
        dev_microdia_camera_set_rgb_gain(dev);
        dev_microdia_camera_set_auto_exposure(dev);
+       dev_microdia_camera_set_auto_gain(dev);
        dev_microdia_camera_set_auto_whitebalance(dev);
        return 0;
 }
@@ -419,6 +420,23 @@ int dev_microdia_camera_set_auto_exposure(struct 
usb_microdia *dev)
 }
 
 /**
+ * @brief Wrapper function for device-specific auto-gain functions
+ *
+ * @param dev Pointer to device structure
+ *
+ * @returns 0 or negative error value
+ *
+ */
+int dev_microdia_camera_set_auto_gain(struct usb_microdia *dev)
+{
+       int ret = -ENODEV;
+       if (dev && dev->camera.sensor->set_auto_gain)
+               ret = dev->camera.sensor->set_auto_gain(dev);
+
+       return ret;
+}
+
+/**
  * @brief Wrapper function for device-specific auto-whitebalance functions
  *
  * @param dev Pointer to device structure
diff --git a/microdia-usb.c b/microdia-usb.c
index a51a39e..3d99cd7 100644
--- a/microdia-usb.c
+++ b/microdia-usb.c
@@ -128,8 +128,15 @@ static int max_buffers = 5;
 static int auto_exposure = 1;
 
 /**
+ * @var auto_gain
+ *   Module parameter to set the gain
+ */
+static int auto_gain = 0;
+
+
+/**
  * @var auto_whitebalance
- *   Module parameter to set the exposure
+ *   Module parameter to set the auto-whitebalance
  */
 static int auto_whitebalance = 1;
 
@@ -704,6 +711,7 @@ static int usb_microdia_default_settings(struct 
usb_microdia *dev)
        dev->vsettings.rgb_gain[2] = (rgb_gain >> 8) & 0x7f;
        dev->vsettings.rgb_gain[3] = rgb_gain & 0x7f;
        dev->vsettings.auto_exposure = auto_exposure & 1;
+       dev->vsettings.auto_gain = auto_gain & 1;
        dev->vsettings.auto_whitebalance = auto_whitebalance & 1;
        dev->vsettings.hue = 0xffff;
 
@@ -870,6 +878,7 @@ module_param(hflip, int, 0444);                     /**< 
@brief Module parameter horizontal flip p
 module_param(vflip, int, 0444);                        /**< @brief Module 
parameter vertical flip process */
 module_param(flip_detect, int, 0444);          /**< @brief Module parameter 
flip detect */
 module_param(auto_exposure, int, 0444);                /**< @brief Module 
parameter automatic exposure control */
+module_param(auto_gain, int, 0444);            /**< @brief Module parameter 
automatic gain control */
 module_param(auto_whitebalance, int, 0444);    /**< @brief Module parameter 
automatic whitebalance control */
 module_param(brightness, int, 0444);           /**< @brief Module parameter 
brightness */
 module_param(whiteness, int, 0444);            /**< @brief Module parameter 
whiteness */
@@ -945,6 +954,12 @@ static int __init usb_microdia_init(void)
                auto_exposure = 1;
        }
 
+       if (auto_gain != 0 && auto_gain != 1) {
+               UDIA_WARNING("Automatic gain should be 0 or 1! "
+                            "Defaulting to 0\n");
+               auto_gain = 0;
+       }
+
        if (auto_whitebalance != 0 && auto_whitebalance != 1) {
                UDIA_WARNING("Automatic whitebalance should be 0 or 1! "
                             "Defaulting to 1\n");
@@ -1003,6 +1018,7 @@ MODULE_PARM_DESC(hflip, "Horizontal image flip"); /**< 
@brief Description of 'hf
 MODULE_PARM_DESC(vflip, "Vertical image flip");                /**< @brief 
Description of 'vflip' parameter */
 MODULE_PARM_DESC(flip_detect, "Image flip detection");         /**< @brief 
Description of 'vflip_detect' parameter */
 MODULE_PARM_DESC(auto_exposure, "Automatic exposure control"); /**< @brief 
Description of 'auto_exposure' parameter */
+MODULE_PARM_DESC(auto_gain, "Automatic gain control");         /**< @brief 
Description of 'auto_gain' parameter */
 MODULE_PARM_DESC(auto_whitebalance, "Automatic whitebalance"); /**< @brief 
Description of 'auto_whitebalance' parameter */
 MODULE_PARM_DESC(brightness, "Brightness setting");    /**< @brief Description 
of 'brightness' parameter */
 MODULE_PARM_DESC(whiteness, "Whiteness setting");      /**< @brief Description 
of 'whiteness' parameter */
diff --git a/microdia-v4l.c b/microdia-v4l.c
index b8d965a..5a4fe24 100644
--- a/microdia-v4l.c
+++ b/microdia-v4l.c
@@ -161,6 +161,15 @@ static struct v4l2_queryctrl microdia_controls[] = {
                .default_value = 0,
        },
        {
+               .id      = V4L2_CID_AUTOGAIN,
+               .type    = V4L2_CTRL_TYPE_BOOLEAN,
+               .name    = "Automatic gain control",
+               .minimum = 0,
+               .maximum = 1,
+               .step    = 1,
+               .default_value = 0,
+       },
+       {
                .id      = V4L2_CID_AUTO_WHITE_BALANCE,
                .type    = V4L2_CTRL_TYPE_BOOLEAN,
                .name    = "Automatic whitbalance control",
@@ -813,6 +822,10 @@ int microdia_vidioc_g_ctrl(struct file *file, void *priv,
                ctrl->value = dev->vsettings.auto_exposure;
                break;
 
+       case V4L2_CID_AUTOGAIN:
+               ctrl->value = dev->vsettings.auto_gain;
+               break;
+
        case V4L2_CID_AUTO_WHITE_BALANCE:
                ctrl->value = dev->vsettings.auto_whitebalance;
                break;
@@ -897,6 +910,11 @@ int microdia_vidioc_s_ctrl(struct file *file, void *priv,
                dev_microdia_camera_set_auto_exposure(dev);
                break;
 
+       case V4L2_CID_AUTOGAIN:
+               dev->vsettings.auto_gain = ctrl->value;
+               dev_microdia_camera_set_auto_gain(dev);
+               break;
+
        case V4L2_CID_AUTO_WHITE_BALANCE:
                dev->vsettings.auto_whitebalance = ctrl->value;
                dev_microdia_camera_set_auto_whitebalance(dev);
diff --git a/microdia.h b/microdia.h
index 86eb11f..d02962e 100644
--- a/microdia.h
+++ b/microdia.h
@@ -273,6 +273,7 @@ struct microdia_video {
        int sharpness;                          /**< Sharpness */
        __u8 rgb_gain[4];                       /**< RGB Gain (RGGB) */
        int auto_exposure;                      /**< Automatic exposure */
+       int auto_gain;                          /**< Automatic gain */
        int auto_whitebalance;                  /**< Automatic whitebalance */
 };
 
@@ -347,6 +348,7 @@ struct sensor_info {
        int (*initialize) (struct usb_microdia *dev);
        int (*set_exposure) (struct usb_microdia *dev);
        int (*set_auto_exposure) (struct usb_microdia *dev);
+       int (*set_auto_gain) (struct usb_microdia *dev);
        int (*set_auto_whitebalance) (struct usb_microdia *dev);
        int (*flip_detect) (struct usb_microdia *dev);
        int (*set_hvflip) (struct usb_microdia *dev);
@@ -449,6 +451,7 @@ int dev_microdia_camera_set_hvflip(struct usb_microdia *);
 int dev_microdia_camera_set_sharpness(struct usb_microdia *dev);
 int dev_microdia_camera_set_rgb_gain(struct usb_microdia *dev);
 int dev_microdia_camera_set_auto_exposure(struct usb_microdia *dev);
+int dev_microdia_camera_set_auto_gain(struct usb_microdia *dev);
 int dev_microdia_camera_set_auto_whitebalance(struct usb_microdia *dev);
 /* int dev_microdia_set_camera_quality(struct usb_microdia *);*/
 
-- 
1.5.6.5

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to