pwc
[Top] [All Lists]

[pwc] [PATCH] Add missing cases to the VIDIOC_G_CTRL ioctl

To:
Subject: [pwc] [PATCH] Add missing cases to the VIDIOC_G_CTRL ioctl
From: Peter Osterlund <>
Date: 13 Nov 2005 22:15:40 +0100
Hi!

Here is a patch that implements reading V4L2_CID_AUTOGAIN and
V4L2_CID_EXPOSURE using the VIDIOC_G_CTRL ioctl.

I have tested it with a Logitech QC 4000 Pro camera, which is detected
as a 740 model.

Signed-off-by: Peter Osterlund <>
---

 drivers/usb/media/pwc/pwc-ctrl.c |   27 +++++++++++++++++++++++++++
 drivers/usb/media/pwc/pwc-v4l.c  |   10 ++++++++++
 drivers/usb/media/pwc/pwc.h      |    1 +
 3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/usb/media/pwc/pwc-ctrl.c
index 2716b7b..4f1d8e5 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/usb/media/pwc/pwc-ctrl.c
@@ -722,6 +722,33 @@ int pwc_set_shutter_speed(struct pwc_dev
        return ret;
 }      
 
+int pwc_get_shutter_speed(struct pwc_device *pdev, int *value)
+{
+       unsigned char buf[2];
+       int ret;
+       
+       ret = RecvControlMsg(GET_STATUS_CTL, READ_SHUTTER_FORMATTER, 2);
+       if (ret < 0)
+               return ret;
+       *value = buf[0] + (buf[1] << 8);
+       switch(pdev->type) {
+       case 675:
+       case 680:
+       case 690:
+               /* speed ranges from 0x0 to 0x290 (656) */
+               *value *= 100;
+               break;
+       case 720:
+       case 730:
+       case 740:
+       case 750:
+               /* speed seems to range from 0x0 to 0xff */
+               *value <<= 8;
+               break;
+       }
+       return 0;
+}
+
 
 /* POWER */
 
diff --git a/drivers/usb/media/pwc/pwc-v4l.c b/drivers/usb/media/pwc/pwc-v4l.c
index fc61e32..e554a10 100644
--- a/drivers/usb/media/pwc/pwc-v4l.c
+++ b/drivers/usb/media/pwc/pwc-v4l.c
@@ -646,7 +646,17 @@ int pwc_video_do_ioctl(struct inode *ino
                                        c->value >>= 8;
                                        return 0;
                                case V4L2_CID_AUTOGAIN:
+                                       ret = pwc_get_agc(pdev, &c->value);
+                                       if (ret<0)
+                                               return -EINVAL;
+                                       c->value = (c->value < 0)?1:0;
+                                       return 0;
                                case V4L2_CID_EXPOSURE:
+                                       ret = pwc_get_shutter_speed(pdev, 
&c->value);
+                                       if (ret<0)
+                                               return -EINVAL;
+                                       c->value >>= 8;
+                                       return 0;
                                case V4L2_CID_PRIVATE_SAVE_USER:
                                case V4L2_CID_PRIVATE_RESTORE_USER:
                                case V4L2_CID_PRIVATE_RESTORE_FACTORY:
diff --git a/drivers/usb/media/pwc/pwc.h b/drivers/usb/media/pwc/pwc.h
index e1c18d0..918e581 100644
--- a/drivers/usb/media/pwc/pwc.h
+++ b/drivers/usb/media/pwc/pwc.h
@@ -286,6 +286,7 @@ extern int pwc_set_awb(struct pwc_device
 extern int pwc_set_agc(struct pwc_device *pdev, int mode, int value);
 extern int pwc_get_agc(struct pwc_device *pdev, int *value);
 extern int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int value);
+extern int pwc_get_shutter_speed(struct pwc_device *pdev, int *value);
 
 /* Power down or up the camera; not supported by all models */
 extern int pwc_camera_power(struct pwc_device *pdev, int power);

-- 
Peter Osterlund - 
http://web.telia.com/~u89404340
_______________________________________________
pwc mailing list

http://lists.saillard.org/mailman/listinfo/pwc

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU