[PATCH] Video : pwc : Fix regression in pwc_set_shutter_speed caused by bad constant = sizeof conversion.

2010-02-11 Thread Martin Fuzzey
Regression was caused by my commit 6b35ca0d3d586b8ecb8396821af21186e20afaf0
which determined message size using sizeof rather than hardcoded constants.

Unfortunately pwc_set_shutter_speed reuses a 2 byte buffer for a one byte
message too so the sizeof was bogus in this case.

All other uses of sizeof checked and are ok.

Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
CC: sta...@kernel.org

Signed-off-by: Martin Fuzzey mfuz...@gmail.com

---

 drivers/media/video/pwc/pwc-ctrl.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/pwc/pwc-ctrl.c 
b/drivers/media/video/pwc/pwc-ctrl.c
index 50b415e..f7f7e04 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -753,7 +753,7 @@ int pwc_set_shutter_speed(struct pwc_device *pdev, int 
mode, int value)
buf[0] = 0xff; /* fixed */
 
ret = send_control_msg(pdev,
-   SET_LUM_CTL, SHUTTER_MODE_FORMATTER, buf, sizeof(buf));
+   SET_LUM_CTL, SHUTTER_MODE_FORMATTER, buf, 1);
 
if (!mode  ret = 0) {
if (value  0)

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: fix regression in pwc_set_shutter_speed???

2010-01-30 Thread Martin Fuzzey
Greg KH wrote:
 Video developers, any comments?

 Jef, were you able to narrow it down to the actual patch that caused the
 problem.

   
Indeed it was my commit 6b35ca0d3d586b8ecb8396821af21186e20afaf0

I somehow missed the email from Laurent back in August about this.

Am checking the rest of that commit now and will send a fix patch soon.

Sorry about that.

Martin

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Video : pwc : Fix regression in pwc_set_shutter_speed caused by bad constant = sizeof conversion.

2010-01-30 Thread Martin Fuzzey
Regression was caused by my commit 6b35ca0d3d586b8ecb8396821af21186e20afaf0
which determined message size using sizeof rather than hardcoded constants.

Unfortunately pwc_set_shutter_speed reuses a 2 byte buffer for a one byte
message too so the sizeof was bogus in this case.

All other uses of sizeof checked and are ok.

Signed-off-by: Martin Fuzzey mfuz...@gmail.com

---

 drivers/media/video/pwc/pwc-ctrl.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/pwc/pwc-ctrl.c 
b/drivers/media/video/pwc/pwc-ctrl.c
index 50b415e..f7f7e04 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -753,7 +753,7 @@ int pwc_set_shutter_speed(struct pwc_device *pdev, int 
mode, int value)
buf[0] = 0xff; /* fixed */
 
ret = send_control_msg(pdev,
-   SET_LUM_CTL, SHUTTER_MODE_FORMATTER, buf, sizeof(buf));
+   SET_LUM_CTL, SHUTTER_MODE_FORMATTER, buf, 1);
 
if (!mode  ret = 0) {
if (value  0)

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] pwc : do not pass stack allocated buffers to USB core.

2009-04-21 Thread Martin Fuzzey
This is causes problems on platforms that have alignment requirements for DMA 
transfers.

Signed-off-by: Martin Fuzzey mfuz...@gmail.com

---

 drivers/media/video/pwc/pwc-ctrl.c |  238 +---
 1 files changed, 164 insertions(+), 74 deletions(-)

diff --git a/drivers/media/video/pwc/pwc-ctrl.c 
b/drivers/media/video/pwc/pwc-ctrl.c
index f9fbe02..50b415e 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -159,35 +159,67 @@ static void pwc_set_image_buffer_size(struct pwc_device 
*pdev);
 
 //
 
+static int _send_control_msg(struct pwc_device *pdev,
+   u8 request, u16 value, int index, void *buf, int buflen, int timeout)
+{
+   int rc;
+   void *kbuf = NULL;
+
+   if (buflen) {
+   kbuf = kmalloc(buflen, GFP_KERNEL); /* not allowed on stack */
+   if (kbuf == NULL)
+   return -ENOMEM;
+   memcpy(kbuf, buf, buflen);
+   }
 
-#define SendControlMsg(request, value, buflen) \
-   usb_control_msg(pdev-udev, usb_sndctrlpipe(pdev-udev, 0), \
-   request, \
-   USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, \
-   value, \
-   pdev-vcinterface, \
-   buf, buflen, 500)
+   rc = usb_control_msg(pdev-udev, usb_sndctrlpipe(pdev-udev, 0),
+   request,
+   USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+   value,
+   index,
+   kbuf, buflen, timeout);
 
-#define RecvControlMsg(request, value, buflen) \
-   usb_control_msg(pdev-udev, usb_rcvctrlpipe(pdev-udev, 0), \
-   request, \
-   USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, \
-   value, \
-   pdev-vcinterface, \
-   buf, buflen, 500)
+   kfree(kbuf);
+   return rc;
+}
 
+static int recv_control_msg(struct pwc_device *pdev,
+   u8 request, u16 value, void *buf, int buflen)
+{
+   int rc;
+   void *kbuf = kmalloc(buflen, GFP_KERNEL); /* not allowed on stack */
+
+   if (kbuf == NULL)
+   return -ENOMEM;
+
+   rc = usb_control_msg(pdev-udev, usb_rcvctrlpipe(pdev-udev, 0),
+   request,
+   USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+   value,
+   pdev-vcinterface,
+   kbuf, buflen, 500);
+   memcpy(buf, kbuf, buflen);
+   kfree(kbuf);
+   return rc;
+}
 
-static int send_video_command(struct usb_device *udev, int index, void *buf, 
int buflen)
+static inline int send_video_command(struct pwc_device *pdev,
+   int index, void *buf, int buflen)
 {
-   return usb_control_msg(udev,
-   usb_sndctrlpipe(udev, 0),
+   return _send_control_msg(pdev,
SET_EP_STREAM_CTL,
-   USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
VIDEO_OUTPUT_CONTROL_FORMATTER,
index,
buf, buflen, 1000);
 }
 
+static inline int send_control_msg(struct pwc_device *pdev,
+   u8 request, u16 value, void *buf, int buflen)
+{
+   return _send_control_msg(pdev,
+   request, value, pdev-vcinterface, buf, buflen, 500);
+}
+
 
 
 static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames)
@@ -224,7 +256,7 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int 
size, int frames)
return -EINVAL;
 
memcpy(buf, pEntry-mode, 3);
-   ret = send_video_command(pdev-udev, pdev-vendpoint, buf, 3);
+   ret = send_video_command(pdev, pdev-vendpoint, buf, 3);
if (ret  0) {
PWC_DEBUG_MODULE(Failed to send video command... %d\n, ret);
return ret;
@@ -285,7 +317,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, 
int size, int frames, i
memcpy(buf, pChoose-mode, 13);
if (snapshot)
buf[0] |= 0x80;
-   ret = send_video_command(pdev-udev, pdev-vendpoint, buf, 13);
+   ret = send_video_command(pdev, pdev-vendpoint, buf, 13);
if (ret  0)
return ret;
 
@@ -358,7 +390,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, 
int size, int frames, i
buf[0] |= 0x80;
 
/* Firmware bug: video endpoint is 5, but commands are sent to endpoint 
4 */
-   ret = send_video_command(pdev-udev, 4 /* pdev-vendpoint */, buf, 12);
+   ret = send_video_command(pdev, 4 /* pdev-vendpoint */, buf, 12);
if (ret  0)
return ret;
 
@@ -530,7 +562,8 @@ int pwc_get_brightness(struct pwc_device *pdev)
char buf;
int ret;
 
-   ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1);
+   ret = recv_control_msg(pdev,
+   GET_LUM_CTL, BRIGHTNESS_FORMATTER, buf, sizeof(buf));
if (ret  0)
return ret;
return buf

[PATCH] pwc : fix LED and power setup for first open

2009-03-09 Thread Martin Fuzzey
From: Martin Fuzzey mfuz...@gmail.com

Call pwc_construct before trying to talk to device to obtain vc interface so
that LED and power setup works the first time the video device is opened.

Signed-off-by: Martin Fuzzey mfuz...@gmail.com

---

diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 0d81018..e11f422 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1115,6 +1115,7 @@ static int pwc_video_open(struct file *file)
}

mutex_lock(pdev-modlock);
+   pwc_construct(pdev); /* set min/max sizes correct */
if (!pdev-usb_init) {
PWC_DEBUG_OPEN(Doing first time initialization.\n);
pdev-usb_init = 1;
@@ -1139,7 +1140,6 @@ static int pwc_video_open(struct file *file)
if (pwc_set_leds(pdev, led_on, led_off)  0)
PWC_DEBUG_OPEN(Failed to set LED on/off time.\n);

-   pwc_construct(pdev); /* set min/max sizes correct */

/* So far, so good. Allocate memory. */
i = pwc_allocate_buffers(pdev);


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html