[PATCH 1/1] s2255drv: update firmware load.

2017-11-03 Thread Dean Anderson
fixes intermittent soft reboot issue with firmware load
increases wait time of reset, as required by HW

Signed-off-by: Dean Anderson <d...@sensoray.com>
---
 drivers/media/usb/s2255/s2255drv.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index b2f239c..8a8e314 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -350,7 +350,7 @@ static void s2255_fillbuff(struct s2255_vc *vc, struct 
s2255_buffer *buf,
   int jpgsize);
 static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode);
 static int s2255_board_shutdown(struct s2255_dev *dev);
-static void s2255_fwload_start(struct s2255_dev *dev, int reset);
+static void s2255_fwload_start(struct s2255_dev *dev);
 static void s2255_destroy(struct s2255_dev *dev);
 static long s2255_vendor_req(struct s2255_dev *dev, unsigned char req,
 u16 index, u16 value, void *buf,
@@ -476,7 +476,7 @@ static void planar422p_to_yuv_packed(const unsigned char 
*in,
 static void s2255_reset_dsppower(struct s2255_dev *dev)
 {
s2255_vendor_req(dev, 0x40, 0x, 0x0001, NULL, 0, 1);
-   msleep(20);
+   msleep(50);
s2255_vendor_req(dev, 0x50, 0x, 0x, NULL, 0, 1);
msleep(600);
s2255_vendor_req(dev, 0x10, 0x, 0x, NULL, 0, 1);
@@ -1449,7 +1449,7 @@ static int s2255_open(struct file *file)
case S2255_FW_FAILED:
s2255_dev_err(>udev->dev,
"firmware load failed. retrying.\n");
-   s2255_fwload_start(dev, 1);
+   s2255_fwload_start(dev);
wait_event_timeout(dev->fw_data->wait_fw,
   ((atomic_read(>fw_data->fw_state)
 == S2255_FW_SUCCESS) ||
@@ -2208,10 +2208,9 @@ static void s2255_stop_readpipe(struct s2255_dev *dev)
return;
 }
 
-static void s2255_fwload_start(struct s2255_dev *dev, int reset)
+static void s2255_fwload_start(struct s2255_dev *dev)
 {
-   if (reset)
-   s2255_reset_dsppower(dev);
+   s2255_reset_dsppower(dev);
dev->fw_data->fw_size = dev->fw_data->fw->size;
atomic_set(>fw_data->fw_state, S2255_FW_NOTLOADED);
memcpy(dev->fw_data->pfw_data,
@@ -2336,7 +2335,7 @@ static int s2255_probe(struct usb_interface *interface,
retval = s2255_board_init(dev);
if (retval)
goto errorBOARDINIT;
-   s2255_fwload_start(dev, 0);
+   s2255_fwload_start(dev);
/* loads v4l specific */
retval = s2255_probe_v4l(dev);
if (retval)
-- 
2.7.4



[PATCH] media: usb: s2255drv: update to firmware loading

2017-09-29 Thread dean

fixes intermittent soft reboot issue with firmware load
increases wait time of reset, as required by HW

Signed-off-by: Dean Anderson <d...@sensoray.com>

---
 drivers/media/usb/s2255/s2255drv.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c

index b2f239c..8a8e314 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -350,7 +350,7 @@ static void s2255_fillbuff(struct s2255_vc *vc, 
struct s2255_buffer *buf,

   int jpgsize);
 static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode 
*mode);

 static int s2255_board_shutdown(struct s2255_dev *dev);
-static void s2255_fwload_start(struct s2255_dev *dev, int reset);
+static void s2255_fwload_start(struct s2255_dev *dev);
 static void s2255_destroy(struct s2255_dev *dev);
 static long s2255_vendor_req(struct s2255_dev *dev, unsigned char req,
 u16 index, u16 value, void *buf,
@@ -476,7 +476,7 @@ static void planar422p_to_yuv_packed(const unsigned 
char *in,

 static void s2255_reset_dsppower(struct s2255_dev *dev)
 {
s2255_vendor_req(dev, 0x40, 0x, 0x0001, NULL, 0, 1);
-   msleep(20);
+   msleep(50);
s2255_vendor_req(dev, 0x50, 0x, 0x, NULL, 0, 1);
msleep(600);
s2255_vendor_req(dev, 0x10, 0x, 0x, NULL, 0, 1);
@@ -1449,7 +1449,7 @@ static int s2255_open(struct file *file)
case S2255_FW_FAILED:
s2255_dev_err(>udev->dev,
"firmware load failed. retrying.\n");
-   s2255_fwload_start(dev, 1);
+   s2255_fwload_start(dev);
wait_event_timeout(dev->fw_data->wait_fw,
   ((atomic_read(>fw_data->fw_state)
 == S2255_FW_SUCCESS) ||
@@ -2208,10 +2208,9 @@ static void s2255_stop_readpipe(struct s2255_dev 
*dev)

return;
 }

-static void s2255_fwload_start(struct s2255_dev *dev, int reset)
+static void s2255_fwload_start(struct s2255_dev *dev)
 {
-   if (reset)
-   s2255_reset_dsppower(dev);
+   s2255_reset_dsppower(dev);
dev->fw_data->fw_size = dev->fw_data->fw->size;
atomic_set(>fw_data->fw_state, S2255_FW_NOTLOADED);
memcpy(dev->fw_data->pfw_data,
@@ -2336,7 +2335,7 @@ static int s2255_probe(struct usb_interface 
*interface,

retval = s2255_board_init(dev);
if (retval)
goto errorBOARDINIT;
-   s2255_fwload_start(dev, 0);
+   s2255_fwload_start(dev);
/* loads v4l specific */
retval = s2255_probe_v4l(dev);
if (retval)
--
2.9.5



[PATCH] [media] s2255drv: fix payload size for JPG, MJPEG

2014-11-17 Thread Dean Anderson
Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index a56a05b..82014bb 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -635,7 +635,7 @@ static void s2255_fillbuff(struct s2255_vc *vc,
break;
case V4L2_PIX_FMT_JPEG:
case V4L2_PIX_FMT_MJPEG:
-   buf-vb.v4l2_buf.length = jpgsize;
+   vb2_set_plane_payload(buf-vb, 0, jpgsize);
memcpy(vbuf, tmpbuf, jpgsize);
break;
case V4L2_PIX_FMT_YUV422P:
-- 
1.9.1

--
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] [media] s2255drv: fix spinlock issue

2014-11-04 Thread Dean Anderson
qlock spinlock controls access to buf_list and sequence.
qlock spinlock should not be locked during a copy to video buffers, an
operation that may sleep.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index ccc0009..24c4413 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -558,27 +558,31 @@ static void s2255_fwchunk_complete(struct urb *urb)
 
 }
 
-static int s2255_got_frame(struct s2255_vc *vc, int jpgsize)
+static void s2255_got_frame(struct s2255_vc *vc, int jpgsize)
 {
struct s2255_buffer *buf;
struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
unsigned long flags = 0;
-   int rc = 0;
+
spin_lock_irqsave(vc-qlock, flags);
if (list_empty(vc-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
-   rc = -1;
-   goto unlock;
+   spin_unlock_irqrestore(vc-qlock, flags);
+   return;
}
buf = list_entry(vc-buf_list.next,
 struct s2255_buffer, list);
list_del(buf-list);
v4l2_get_timestamp(buf-vb.v4l2_buf.timestamp);
+   buf-vb.v4l2_buf.field = vc-field;
+   buf-vb.v4l2_buf.sequence = vc-frame_count;
+   spin_unlock_irqrestore(vc-qlock, flags);
+
s2255_fillbuff(vc, buf, jpgsize);
+   /* tell v4l buffer was filled */
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_DONE);
dprintk(dev, 2, %s: [buf] [%p]\n, __func__, buf);
-unlock:
-   spin_unlock_irqrestore(vc-qlock, flags);
-   return rc;
+   return;
 }
 
 static const struct s2255_fmt *format_by_fourcc(int fourcc)
@@ -649,11 +653,6 @@ static void s2255_fillbuff(struct s2255_vc *vc,
}
dprintk(dev, 2, s2255fill at : Buffer 0x%08lx size= %d\n,
(unsigned long)vbuf, pos);
-   /* tell v4l buffer was filled */
-   buf-vb.v4l2_buf.field = vc-field;
-   buf-vb.v4l2_buf.sequence = vc-frame_count;
-   v4l2_get_timestamp(buf-vb.v4l2_buf.timestamp);
-   vb2_buffer_done(buf-vb, VB2_BUF_STATE_DONE);
 }
 
 
-- 
1.9.1

--
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: [PATCH] [media] s2255drv: fix spinlock issue

2014-11-04 Thread Dean Anderson
This patch is not so urgent, but should still be considered.  Please 
disregard the second comment below, which is not correct.


The original code, however, holds the spinlock for a long time.  From 
the structure of videobuf2, we could just hold qlock during buf_list and 
sequence accesses.



On 2014-11-04 14:34, Dean Anderson wrote:

qlock spinlock controls access to buf_list and sequence.
qlock spinlock should not be locked during a copy to video buffers, an
operation that may sleep.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c
b/drivers/media/usb/s2255/s2255drv.c
index ccc0009..24c4413 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -558,27 +558,31 @@ static void s2255_fwchunk_complete(struct urb 
*urb)


 }

-static int s2255_got_frame(struct s2255_vc *vc, int jpgsize)
+static void s2255_got_frame(struct s2255_vc *vc, int jpgsize)
 {
struct s2255_buffer *buf;
struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
unsigned long flags = 0;
-   int rc = 0;
+
spin_lock_irqsave(vc-qlock, flags);
if (list_empty(vc-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
-   rc = -1;
-   goto unlock;
+   spin_unlock_irqrestore(vc-qlock, flags);
+   return;
}
buf = list_entry(vc-buf_list.next,
 struct s2255_buffer, list);
list_del(buf-list);
v4l2_get_timestamp(buf-vb.v4l2_buf.timestamp);
+   buf-vb.v4l2_buf.field = vc-field;
+   buf-vb.v4l2_buf.sequence = vc-frame_count;
+   spin_unlock_irqrestore(vc-qlock, flags);
+
s2255_fillbuff(vc, buf, jpgsize);
+   /* tell v4l buffer was filled */
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_DONE);
dprintk(dev, 2, %s: [buf] [%p]\n, __func__, buf);
-unlock:
-   spin_unlock_irqrestore(vc-qlock, flags);
-   return rc;
+   return;
 }

 static const struct s2255_fmt *format_by_fourcc(int fourcc)
@@ -649,11 +653,6 @@ static void s2255_fillbuff(struct s2255_vc *vc,
}
dprintk(dev, 2, s2255fill at : Buffer 0x%08lx size= %d\n,
(unsigned long)vbuf, pos);
-   /* tell v4l buffer was filled */
-   buf-vb.v4l2_buf.field = vc-field;
-   buf-vb.v4l2_buf.sequence = vc-frame_count;
-   v4l2_get_timestamp(buf-vb.v4l2_buf.timestamp);
-   vb2_buffer_done(buf-vb, VB2_BUF_STATE_DONE);
 }


--
1.9.1

--
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] s2255drv: urgent memory leak fix.

2014-02-28 Thread Dean Anderson
Critical bug fix.  Fixes memory leak introduced by 
commit 47d8c881c304642a68d398b87d9e8846e643c81a.

Signed-off-by: Dean Anderson linux-...@sensoray.com

---
 drivers/media/usb/s2255/s2255drv.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index ef66b1b..4964194 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -2175,11 +2175,6 @@ static int s2255_stop_acquire(struct s2255_vc *vc)
 
mutex_lock(dev-cmdlock);
chn_rev = G_chnmap[vc-idx];
-   buffer = kzalloc(512, GFP_KERNEL);
-   if (buffer == NULL) {
-   dev_err(dev-udev-dev, out of mem\n);
-   return -ENOMEM;
-   }
/* send the stop command */
buffer[0] = IN_DATA_TOKEN;
buffer[1] = (__le32) cpu_to_le32(chn_rev);
-- 
1.7.9.5

--
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: [PATCH] s2255drv: upgrade to videobuf2

2014-02-12 Thread Dean Anderson

./utils/v4l2-compliance/v4l2-compliance -s

Driver Info:
Driver name   : s2255
Card type : s2255
Bus info  : usb-:00:1a.7-3.6
Driver version: 3.13.0
Capabilities  : 0x8401
Video Capture
Streaming
Device Capabilities
Device Caps   : 0x0401
Video Capture
Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
		warn: v4l2-test-controls.cpp(753): The VIDIOC_G_JPEGCOMP ioctl is 
deprecated!
		warn: v4l2-test-controls.cpp(770): The VIDIOC_S_JPEGCOMP ioctl is 
deprecated!

test VIDIOC_G/S_JPEGCOMP: OK
Standard Controls: 7 Private Controls: 1

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
		warn: v4l2-test-formats.cpp(599): TRY_FMT cannot handle an invalid 
pixelformat.
		warn: v4l2-test-formats.cpp(600): This may or may not be a problem. 
For more information see:
		warn: v4l2-test-formats.cpp(601): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_TRY_FMT: OK
		warn: v4l2-test-formats.cpp(786): S_FMT cannot handle an invalid 
pixelformat.
		warn: v4l2-test-formats.cpp(787): This may or may not be a problem. 
For more information see:
		warn: v4l2-test-formats.cpp(788): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
warn: v4l2-test-buffers.cpp(343): VIDIOC_CREATE_BUFS not 
supported
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
fail: v4l2-test-buffers.cpp(379): ret  0  errno != EINVAL
test read/write: FAIL
fail: v4l2-test-buffers.cpp(537): can_stream
test MMAP: FAIL
fail: v4l2-test-buffers.cpp(641): can_stream
test USERPTR: FAIL

Total: 39, Succeeded: 36, Failed: 3, Warnings: 9



On 2014-02-11 17:07, Hans Verkuil wrote:

Hi Dean,

On 02/12/2014 12:05 AM, Dean Anderson wrote:
The output of v4l2-compliance looks fine.  The warnings can be 
ignored

for this patch.


Can you update to the latest v4l2-compliance that I just pushed this 
morning?


I added support for the streaming I/O ioctls (use the -s option and 
make sure

that you have a valid video signal).

That will be very useful.

Regards,

Hans




./v4l2-compliance :

Driver Info:
Driver name   : s2255
Card type : s2255
Bus info  : usb-:00:1a.7-3.6
Driver version: 3.13.0
Capabilities  : 0x8401
Video Capture
Streaming
Device Capabilities
Device Caps   : 0x0401
Video Capture
Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test

[PATCH v2] s2255drv: upgrade to videobuf2

2014-02-12 Thread Dean Anderson
Upgrade to videobuf2 libraries.  
No errors reported with v4l2-compliance -s.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  512 +++-
 1 file changed, 152 insertions(+), 360 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index e0663ce..ef66b1b 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -45,14 +45,14 @@
 #include linux/mm.h
 #include linux/vmalloc.h
 #include linux/usb.h
-#include media/videobuf-vmalloc.h
+#include media/videobuf2-vmalloc.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-ctrls.h
 #include media/v4l2-event.h
 
-#define S2255_VERSION  1.24.1
+#define S2255_VERSION  1.25.1
 #define FIRMWARE_FILE_NAME f2255usb.bin
 
 /* default JPEG quality */
@@ -229,8 +229,6 @@ struct s2255_vc {
struct v4l2_captureparm cap_parm;
int cur_frame;
int last_frame;
-
-   int b_acquire;
/* allocated image size */
unsigned long   req_image_size;
/* received packet size */
@@ -249,8 +247,12 @@ struct s2255_vc {
int vidstatus_ready;
unsigned intwidth;
unsigned intheight;
+   enum v4l2_field field;
const struct s2255_fmt  *fmt;
int idx; /* channel number on device, 0-3 */
+   struct vb2_queue vb_vidq;
+   struct mutex vb_lock; /* streaming lock */
+   spinlock_t qlock;
 };
 
 
@@ -270,7 +272,6 @@ struct s2255_dev {
u32 cc; /* current channel */
int frame_ready;
int chn_ready;
-   spinlock_t  slock;
/* dsp firmware version (f2255usb.bin) */
int dsp_fw_ver;
u16 pid; /* product id */
@@ -292,16 +293,10 @@ struct s2255_fmt {
 /* buffer for one video frame */
 struct s2255_buffer {
/* common v4l buffer stuff -- must be first */
-   struct videobuf_buffer vb;
+   struct vb2_buffer vb;
+   struct list_head list;
 };
 
-struct s2255_fh {
-   /* this must be the first field in this struct */
-   struct v4l2_fh  fh;
-   struct videobuf_queue   vb_vidq;
-   struct s2255_vc *vc;
-   int resources;
-};
 
 /* current cypress EEPROM firmware version */
 #define S2255_CUR_USB_FWVER((3  8) | 12)
@@ -569,21 +564,20 @@ static int s2255_got_frame(struct s2255_vc *vc, int 
jpgsize)
struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
unsigned long flags = 0;
int rc = 0;
-   spin_lock_irqsave(dev-slock, flags);
+   spin_lock_irqsave(vc-qlock, flags);
if (list_empty(vc-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
buf = list_entry(vc-buf_list.next,
-struct s2255_buffer, vb.queue);
-   list_del(buf-vb.queue);
-   v4l2_get_timestamp(buf-vb.ts);
+struct s2255_buffer, list);
+   list_del(buf-list);
+   v4l2_get_timestamp(buf-vb.v4l2_buf.timestamp);
s2255_fillbuff(vc, buf, jpgsize);
-   wake_up(buf-vb.done);
-   dprintk(dev, 2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
+   dprintk(dev, 2, %s: [buf] [%p]\n, __func__, buf);
 unlock:
-   spin_unlock_irqrestore(dev-slock, flags);
+   spin_unlock_irqrestore(vc-qlock, flags);
return rc;
 }
 
@@ -615,7 +609,7 @@ static void s2255_fillbuff(struct s2255_vc *vc,
 {
int pos = 0;
const char *tmpbuf;
-   char *vbuf = videobuf_to_vmalloc(buf-vb);
+   char *vbuf = vb2_plane_vaddr(buf-vb, 0);
unsigned long last_frame;
struct s2255_dev *dev = vc-dev;
 
@@ -629,21 +623,21 @@ static void s2255_fillbuff(struct s2255_vc *vc,
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
planar422p_to_yuv_packed((const unsigned char *)tmpbuf,
-vbuf, buf-vb.width,
-buf-vb.height,
+vbuf, vc-width,
+vc-height,
 vc-fmt-fourcc);
break;
case V4L2_PIX_FMT_GREY:
-   memcpy(vbuf, tmpbuf, buf-vb.width * buf-vb.height);
+   memcpy(vbuf, tmpbuf, vc-width * vc-height);
break;
case V4L2_PIX_FMT_JPEG:
case V4L2_PIX_FMT_MJPEG:
-   buf-vb.size = jpgsize;
-   memcpy(vbuf, tmpbuf, buf

Re: [PATCH v2] s2255drv: upgrade to videobuf2

2014-02-12 Thread Dean Anderson

./v4l2-compliance -s

Driver Info:
Driver name   : s2255
Card type : s2255
Bus info  : usb-:00:1a.7-3.6
Driver version: 3.13.0
Capabilities  : 0x8501
Video Capture
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x0501
Video Capture
Read/Write
Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
		warn: v4l2-test-controls.cpp(753): The VIDIOC_G_JPEGCOMP ioctl is 
deprecated!
		warn: v4l2-test-controls.cpp(770): The VIDIOC_S_JPEGCOMP ioctl is 
deprecated!

test VIDIOC_G/S_JPEGCOMP: OK
Standard Controls: 7 Private Controls: 1

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
		warn: v4l2-test-formats.cpp(599): TRY_FMT cannot handle an invalid 
pixelformat.
		warn: v4l2-test-formats.cpp(600): This may or may not be a problem. 
For more information see:
		warn: v4l2-test-formats.cpp(601): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_TRY_FMT: OK
		warn: v4l2-test-formats.cpp(786): S_FMT cannot handle an invalid 
pixelformat.
		warn: v4l2-test-formats.cpp(787): This may or may not be a problem. 
For more information see:
		warn: v4l2-test-formats.cpp(788): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
warn: v4l2-test-buffers.cpp(343): VIDIOC_CREATE_BUFS not 
supported
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test read/write: OK
test MMAP: OK
test USERPTR: OK

Total: 39, Succeeded: 39, Failed: 0, Warnings: 9


On 2014-02-12 14:25, Dean Anderson wrote:

Upgrade to videobuf2 libraries.
No errors reported with v4l2-compliance -s.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  512 
+++-

 1 file changed, 152 insertions(+), 360 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c
b/drivers/media/usb/s2255/s2255drv.c
index e0663ce..ef66b1b 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -45,14 +45,14 @@
 #include linux/mm.h
 #include linux/vmalloc.h
 #include linux/usb.h
-#include media/videobuf-vmalloc.h
+#include media/videobuf2-vmalloc.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-ctrls.h
 #include media/v4l2-event.h

-#define S2255_VERSION  1.24.1
+#define S2255_VERSION  1.25.1
 #define FIRMWARE_FILE_NAME f2255usb.bin

 /* default JPEG quality */
@@ -229,8 +229,6 @@ struct s2255_vc {
struct v4l2_captureparm cap_parm;
int cur_frame;
int last_frame;
-
-   int b_acquire;
/* allocated image size */
unsigned long   req_image_size;
/* received packet size */
@@ -249,8 +247,12 @@ struct s2255_vc {
int vidstatus_ready;
unsigned intwidth;
unsigned intheight;
+   enum v4l2_field field;
const struct s2255_fmt  *fmt

Re: [PATCH] s2255drv: upgrade to videobuf2

2014-02-12 Thread Dean Anderson
Updated:  Only error is readbuffers now.  I'll fix it and submit a v2 
patch with 0 errors.


FYI, the fix for the readbuffers v4l2-compliance fail will be setting 
v4l2_streamparm.capture.readbuffers to the minimum buffer value.


Thanks,


On 2014-02-12 10:10, Hans Verkuil wrote:

On 02/12/14 17:01, Dean Anderson wrote:

./utils/v4l2-compliance/v4l2-compliance -s

Driver Info:
Driver name   : s2255
Card type : s2255
Bus info  : usb-:00:1a.7-3.6
Driver version: 3.13.0
Capabilities  : 0x8401
Video Capture
Streaming
Device Capabilities
Device Caps   : 0x0401
Video Capture
Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
warn: v4l2-test-controls.cpp(753): The VIDIOC_G_JPEGCOMP 
ioctl is deprecated!
warn: v4l2-test-controls.cpp(770): The VIDIOC_S_JPEGCOMP 
ioctl is deprecated!

test VIDIOC_G/S_JPEGCOMP: OK
Standard Controls: 7 Private Controls: 1

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
warn: v4l2-test-formats.cpp(599): TRY_FMT cannot handle an 
invalid pixelformat.
warn: v4l2-test-formats.cpp(600): This may or may not be a 
problem. For more information see:
warn: v4l2-test-formats.cpp(601): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_TRY_FMT: OK
warn: v4l2-test-formats.cpp(786): S_FMT cannot handle an 
invalid pixelformat.
warn: v4l2-test-formats.cpp(787): This may or may not be a 
problem. For more information see:
warn: v4l2-test-formats.cpp(788): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
warn: v4l2-test-buffers.cpp(343): VIDIOC_CREATE_BUFS not 
supported

test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
fail: v4l2-test-buffers.cpp(379): ret  0  errno != EINVAL


You added read() support, but did not add V4L2_CAP_READWRITE to 
querycap.


The following errors are a knock-on effect of that since the driver
is still in read() mode so attempts to call REQBUFS will fail.

I should see if I can improve that in v4l2-compliance.

Regards,

Hans


test read/write: FAIL
fail: v4l2-test-buffers.cpp(537): can_stream
test MMAP: FAIL
fail: v4l2-test-buffers.cpp(641): can_stream
test USERPTR: FAIL

Total: 39, Succeeded: 36, Failed: 3, Warnings: 9

--
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: [PATCH] s2255drv: upgrade to videobuf2

2014-02-11 Thread Dean Anderson
The output of v4l2-compliance looks fine.  The warnings can be ignored 
for this patch.



./v4l2-compliance :

Driver Info:
Driver name   : s2255
Card type : s2255
Bus info  : usb-:00:1a.7-3.6
Driver version: 3.13.0
Capabilities  : 0x8401
Video Capture
Streaming
Device Capabilities
Device Caps   : 0x0401
Video Capture
Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
		warn: v4l2-test-controls.cpp(753): The VIDIOC_G_JPEGCOMP ioctl is 
deprecated!
		warn: v4l2-test-controls.cpp(770): The VIDIOC_S_JPEGCOMP ioctl is 
deprecated!

test VIDIOC_G/S_JPEGCOMP: OK
Standard Controls: 7 Private Controls: 1

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
		warn: v4l2-test-formats.cpp(598): TRY_FMT cannot handle an invalid 
pixelformat.
		warn: v4l2-test-formats.cpp(599): This may or may not be a problem. 
For more information see:
		warn: v4l2-test-formats.cpp(600): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_TRY_FMT: OK
		warn: v4l2-test-formats.cpp(785): S_FMT cannot handle an invalid 
pixelformat.
		warn: v4l2-test-formats.cpp(786): This may or may not be a problem. 
For more information see:
		warn: v4l2-test-formats.cpp(787): 
http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html

test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
warn: v4l2-test-buffers.cpp(335): VIDIOC_CREATE_BUFS not 
supported
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK

Total: 36, Succeeded: 36, Failed: 0, Warnings: 9



On 2014-02-11 16:56, Dean Anderson wrote:

Upgrade to videobuf2 libraries.

Signed-off-by: Dean Anderson linux-...@sensoray.com

---
 drivers/media/usb/s2255/s2255drv.c |  507 
+++-

 1 file changed, 148 insertions(+), 359 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c
b/drivers/media/usb/s2255/s2255drv.c
index e0663ce..3f0d1a6 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -45,14 +45,14 @@
 #include linux/mm.h
 #include linux/vmalloc.h
 #include linux/usb.h
-#include media/videobuf-vmalloc.h
+#include media/videobuf2-vmalloc.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-ctrls.h
 #include media/v4l2-event.h

-#define S2255_VERSION  1.24.1
+#define S2255_VERSION  1.25.1
 #define FIRMWARE_FILE_NAME f2255usb.bin

 /* default JPEG quality */
@@ -229,8 +229,6 @@ struct s2255_vc {
struct v4l2_captureparm cap_parm;
int cur_frame;
int last_frame;
-
-   int b_acquire;
/* allocated image size */
unsigned long   req_image_size;
/* received packet size */
@@ -249,8 +247,12 @@ struct s2255_vc {
int vidstatus_ready;
unsigned intwidth;
unsigned intheight;
+   enum v4l2_field field;
const struct s2255_fmt  *fmt;
int idx; /* channel number on device, 0-3 */
+   struct vb2_queue vb_vidq

[PATCH] s2255drv: upgrade to videobuf2

2014-02-11 Thread Dean Anderson
Upgrade to videobuf2 libraries.

Signed-off-by: Dean Anderson linux-...@sensoray.com

---
 drivers/media/usb/s2255/s2255drv.c |  507 +++-
 1 file changed, 148 insertions(+), 359 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index e0663ce..3f0d1a6 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -45,14 +45,14 @@
 #include linux/mm.h
 #include linux/vmalloc.h
 #include linux/usb.h
-#include media/videobuf-vmalloc.h
+#include media/videobuf2-vmalloc.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-ctrls.h
 #include media/v4l2-event.h
 
-#define S2255_VERSION  1.24.1
+#define S2255_VERSION  1.25.1
 #define FIRMWARE_FILE_NAME f2255usb.bin
 
 /* default JPEG quality */
@@ -229,8 +229,6 @@ struct s2255_vc {
struct v4l2_captureparm cap_parm;
int cur_frame;
int last_frame;
-
-   int b_acquire;
/* allocated image size */
unsigned long   req_image_size;
/* received packet size */
@@ -249,8 +247,12 @@ struct s2255_vc {
int vidstatus_ready;
unsigned intwidth;
unsigned intheight;
+   enum v4l2_field field;
const struct s2255_fmt  *fmt;
int idx; /* channel number on device, 0-3 */
+   struct vb2_queue vb_vidq;
+   struct mutex vb_lock; /* streaming lock */
+   spinlock_t qlock;
 };
 
 
@@ -270,7 +272,6 @@ struct s2255_dev {
u32 cc; /* current channel */
int frame_ready;
int chn_ready;
-   spinlock_t  slock;
/* dsp firmware version (f2255usb.bin) */
int dsp_fw_ver;
u16 pid; /* product id */
@@ -292,16 +293,10 @@ struct s2255_fmt {
 /* buffer for one video frame */
 struct s2255_buffer {
/* common v4l buffer stuff -- must be first */
-   struct videobuf_buffer vb;
+   struct vb2_buffer vb;
+   struct list_head list;
 };
 
-struct s2255_fh {
-   /* this must be the first field in this struct */
-   struct v4l2_fh  fh;
-   struct videobuf_queue   vb_vidq;
-   struct s2255_vc *vc;
-   int resources;
-};
 
 /* current cypress EEPROM firmware version */
 #define S2255_CUR_USB_FWVER((3  8) | 12)
@@ -569,21 +564,20 @@ static int s2255_got_frame(struct s2255_vc *vc, int 
jpgsize)
struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
unsigned long flags = 0;
int rc = 0;
-   spin_lock_irqsave(dev-slock, flags);
+   spin_lock_irqsave(vc-qlock, flags);
if (list_empty(vc-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
buf = list_entry(vc-buf_list.next,
-struct s2255_buffer, vb.queue);
-   list_del(buf-vb.queue);
-   v4l2_get_timestamp(buf-vb.ts);
+struct s2255_buffer, list);
+   list_del(buf-list);
+   v4l2_get_timestamp(buf-vb.v4l2_buf.timestamp);
s2255_fillbuff(vc, buf, jpgsize);
-   wake_up(buf-vb.done);
-   dprintk(dev, 2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
+   dprintk(dev, 2, %s: [buf] [%p]\n, __func__, buf);
 unlock:
-   spin_unlock_irqrestore(dev-slock, flags);
+   spin_unlock_irqrestore(vc-qlock, flags);
return rc;
 }
 
@@ -615,7 +609,7 @@ static void s2255_fillbuff(struct s2255_vc *vc,
 {
int pos = 0;
const char *tmpbuf;
-   char *vbuf = videobuf_to_vmalloc(buf-vb);
+   char *vbuf = vb2_plane_vaddr(buf-vb, 0);
unsigned long last_frame;
struct s2255_dev *dev = vc-dev;
 
@@ -629,21 +623,21 @@ static void s2255_fillbuff(struct s2255_vc *vc,
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
planar422p_to_yuv_packed((const unsigned char *)tmpbuf,
-vbuf, buf-vb.width,
-buf-vb.height,
+vbuf, vc-width,
+vc-height,
 vc-fmt-fourcc);
break;
case V4L2_PIX_FMT_GREY:
-   memcpy(vbuf, tmpbuf, buf-vb.width * buf-vb.height);
+   memcpy(vbuf, tmpbuf, vc-width * vc-height);
break;
case V4L2_PIX_FMT_JPEG:
case V4L2_PIX_FMT_MJPEG:
-   buf-vb.size = jpgsize;
-   memcpy(vbuf, tmpbuf, buf-vb.size);
+   buf

[PATCH] s2255drv: remove redundant parameter

2014-02-05 Thread Dean Anderson
Removing duplicate fmt from buffer structure.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 1b267b1..517901b 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -290,7 +290,6 @@ struct s2255_fmt {
 struct s2255_buffer {
/* common v4l buffer stuff -- must be first */
struct videobuf_buffer vb;
-   const struct s2255_fmt *fmt;
 };
 
 struct s2255_fh {
@@ -625,13 +624,13 @@ static void s2255_fillbuff(struct s2255_vc *vc,
if (last_frame != -1) {
tmpbuf =
(const char *)vc-buffer.frame[last_frame].lpvbits;
-   switch (buf-fmt-fourcc) {
+   switch (vc-fmt-fourcc) {
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
planar422p_to_yuv_packed((const unsigned char *)tmpbuf,
 vbuf, buf-vb.width,
 buf-vb.height,
-buf-fmt-fourcc);
+vc-fmt-fourcc);
break;
case V4L2_PIX_FMT_GREY:
memcpy(vbuf, tmpbuf, buf-vb.width * buf-vb.height);
@@ -711,7 +710,6 @@ static int buffer_prepare(struct videobuf_queue *vq, struct 
videobuf_buffer *vb,
return -EINVAL;
}
 
-   buf-fmt = vc-fmt;
buf-vb.width = w;
buf-vb.height = h;
buf-vb.field = field;
-- 
1.7.9.5

--
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] s2255drv: buffer setup fix

2014-02-05 Thread Dean Anderson
Buffer setup should check if minimum number of buffers is used.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 2e24aee..1b267b1 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -69,7 +69,7 @@
 #define S2255_DSP_BOOTTIME  800
 /* maximum time to wait for firmware to load (ms) */
 #define S2255_LOAD_TIMEOUT  (5000 + S2255_DSP_BOOTTIME)
-#define S2255_DEF_BUFS  16
+#define S2255_MIN_BUFS  2
 #define S2255_SETMODE_TIMEOUT   500
 #define S2255_VIDSTATUS_TIMEOUT 350
 #define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL)
@@ -374,9 +374,6 @@ static long s2255_vendor_req(struct s2255_dev *dev, 
unsigned char req,
 
 static struct usb_driver s2255_driver;
 
-/* Declare static vars that will be used as parameters */
-static unsigned int vid_limit = 16;/* Video memory limit, in Mb */
-
 /* start video number */
 static int video_nr = -1;  /* /dev/videoN, -1 for autodetect */
 
@@ -385,8 +382,6 @@ static int jpeg_enable = 1;
 
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, Debug level(0-100) default 0);
-module_param(vid_limit, int, 0644);
-MODULE_PARM_DESC(vid_limit, video memory limit(Mb));
 module_param(video_nr, int, 0644);
 MODULE_PARM_DESC(video_nr, start video minor(-1 default autodetect));
 module_param(jpeg_enable, int, 0644);
@@ -671,18 +666,15 @@ static void s2255_fillbuff(struct s2255_vc *vc,
Videobuf operations
--*/
 
-static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
+static int buffer_setup(struct videobuf_queue *vq, unsigned int *nbuffers,
unsigned int *size)
 {
struct s2255_fh *fh = vq-priv_data;
struct s2255_vc *vc = fh-vc;
*size = vc-width * vc-height * (vc-fmt-depth  3);
 
-   if (0 == *count)
-   *count = S2255_DEF_BUFS;
-
-   if (*size * *count  vid_limit * 1024 * 1024)
-   *count = (vid_limit * 1024 * 1024) / *size;
+   if (*nbuffers  S2255_MIN_BUFS)
+   *nbuffers = S2255_MIN_BUFS;
 
return 0;
 }
-- 
1.7.9.5

--
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] s2255drv: fix for return code not checked

2014-02-05 Thread Dean Anderson
Start acquisition return code was not being checked.  Return error
if start acquisition fails.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 4c483ad..556e5e5 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1230,12 +1230,16 @@ static int vidioc_streamon(struct file *file, void 
*priv, enum v4l2_buf_type i)
vc-buffer.frame[j].cur_size = 0;
}
res = videobuf_streamon(fh-vb_vidq);
-   if (res == 0) {
-   s2255_start_acquire(vc);
-   vc-b_acquire = 1;
-   } else
+   if (res != 0) {
res_free(fh);
-
+   return res;
+   }
+   res = s2255_start_acquire(vc);
+   if (res != 0) {
+   res_free(fh);
+   return res;
+   }
+   vc-b_acquire = 1;
return res;
 }
 
-- 
1.7.9.5

--
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] s2255drv: dynamic memory allocation efficiency fix

2014-02-05 Thread Dean Anderson
Driver was allocating a kernel buffer each time it was sending a command.
It is better to allocate this buffer once at startup.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |   67 
 1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 517901b..4c483ad 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -260,6 +260,7 @@ struct s2255_dev {
atomic_tnum_channels;
int frames;
struct mutexlock;   /* channels[].vdev.lock */
+   struct mutexcmdlock; /* protects cmdbuf */
struct usb_device   *udev;
struct usb_interface*interface;
u8  read_endpoint;
@@ -273,6 +274,8 @@ struct s2255_dev {
/* dsp firmware version (f2255usb.bin) */
int dsp_fw_ver;
u16 pid; /* product id */
+#define S2255_CMDBUF_SIZE 512
+   __le32  *cmdbuf;
 };
 
 static inline struct s2255_dev *to_s2255_dev(struct v4l2_device *v4l2_dev)
@@ -1121,11 +1124,12 @@ static int s2255_set_mode(struct s2255_vc *vc,
  struct s2255_mode *mode)
 {
int res;
-   __le32 *buffer;
unsigned long chn_rev;
struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
int i;
+   __le32 *buffer = dev-cmdbuf;
 
+   mutex_lock(dev-cmdlock);
chn_rev = G_chnmap[vc-idx];
dprintk(dev, 3, %s channel: %d\n, __func__, vc-idx);
/* if JPEG, set the quality */
@@ -1139,11 +1143,6 @@ static int s2255_set_mode(struct s2255_vc *vc,
vc-mode = *mode;
vc-req_image_size = get_transfer_size(mode);
dprintk(dev, 1, %s: reqsize %ld\n, __func__, vc-req_image_size);
-   buffer = kzalloc(512, GFP_KERNEL);
-   if (buffer == NULL) {
-   dev_err(dev-udev-dev, out of mem\n);
-   return -ENOMEM;
-   }
/* set the mode */
buffer[0] = IN_DATA_TOKEN;
buffer[1] = (__le32) cpu_to_le32(chn_rev);
@@ -1154,7 +1153,6 @@ static int s2255_set_mode(struct s2255_vc *vc,
res = s2255_write_config(dev-udev, (unsigned char *)buffer, 512);
if (debug)
s2255_print_cfg(dev, mode);
-   kfree(buffer);
/* wait at least 3 frames before continuing */
if (mode-restart) {
wait_event_timeout(vc-wait_setmode,
@@ -1168,22 +1166,20 @@ static int s2255_set_mode(struct s2255_vc *vc,
/* clear the restart flag */
vc-mode.restart = 0;
dprintk(dev, 1, %s chn %d, result: %d\n, __func__, vc-idx, res);
+   mutex_unlock(dev-cmdlock);
return res;
 }
 
 static int s2255_cmd_status(struct s2255_vc *vc, u32 *pstatus)
 {
int res;
-   __le32 *buffer;
u32 chn_rev;
struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
+   __le32 *buffer = dev-cmdbuf;
+
+   mutex_lock(dev-cmdlock);
chn_rev = G_chnmap[vc-idx];
dprintk(dev, 4, %s chan %d\n, __func__, vc-idx);
-   buffer = kzalloc(512, GFP_KERNEL);
-   if (buffer == NULL) {
-   dev_err(dev-udev-dev, out of mem\n);
-   return -ENOMEM;
-   }
/* form the get vid status command */
buffer[0] = IN_DATA_TOKEN;
buffer[1] = (__le32) cpu_to_le32(chn_rev);
@@ -1191,7 +1187,6 @@ static int s2255_cmd_status(struct s2255_vc *vc, u32 
*pstatus)
*pstatus = 0;
vc-vidstatus_ready = 0;
res = s2255_write_config(dev-udev, (unsigned char *)buffer, 512);
-   kfree(buffer);
wait_event_timeout(vc-wait_vidstatus,
   (vc-vidstatus_ready != 0),
   msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT));
@@ -1201,6 +1196,7 @@ static int s2255_cmd_status(struct s2255_vc *vc, u32 
*pstatus)
}
*pstatus = vc-vidstatus;
dprintk(dev, 4, %s, vid status %d\n, __func__, *pstatus);
+   mutex_unlock(dev-cmdlock);
return res;
 }
 
@@ -1724,6 +1720,7 @@ static void s2255_destroy(struct s2255_dev *dev)
mutex_destroy(dev-lock);
usb_put_dev(dev-udev);
v4l2_device_unregister(dev-v4l2_dev);
+   kfree(dev-cmdbuf);
kfree(dev);
 }
 
@@ -2350,18 +2347,14 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
 /* starts acquisition process */
 static int s2255_start_acquire(struct s2255_vc *vc)
 {
-   unsigned char *buffer;
int res;
unsigned long chn_rev;
int j;
struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
-   chn_rev = G_chnmap[vc-idx];
-   buffer = kzalloc(512, GFP_KERNEL);
-   if (buffer == NULL) {
-   dev_err(dev-udev-dev, out of mem\n);
-   return -ENOMEM;
-   }
+   __le32 *buffer = dev-cmdbuf

[PATCH v2] s2255drv: fix for return code not checked

2014-02-05 Thread Dean Anderson
Start acquisition return code was not being checked.  Return error
if start acquisition fails.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 4c483ad..787b591 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1230,12 +1230,16 @@ static int vidioc_streamon(struct file *file, void 
*priv, enum v4l2_buf_type i)
vc-buffer.frame[j].cur_size = 0;
}
res = videobuf_streamon(fh-vb_vidq);
-   if (res == 0) {
-   s2255_start_acquire(vc);
-   vc-b_acquire = 1;
-   } else
+   if (res != 0) {
res_free(fh);
-
+   return res;
+   }
+   res = s2255_start_acquire(vc);
+   if (res != 0) {
+   res_free(fh);
+   return res;
+   }
+   vc-b_acquire = 1;
return res;
 }
 
@@ -2373,7 +2377,7 @@ static int s2255_start_acquire(struct s2255_vc *vc)
 
dprintk(dev, 2, start acquire exit[%d] %d\n, vc-idx, res);
mutex_unlock(dev-cmdlock);
-   return 0;
+   return res;
 }
 
 static int s2255_stop_acquire(struct s2255_vc *vc)
-- 
1.7.9.5

--
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] s2255drv: cleanup of s2255_fh

2014-02-05 Thread Dean Anderson
Removal of unnecessary parameters from s2255_fh.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |   94 +---
 1 file changed, 44 insertions(+), 50 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 787b591..e0663ce 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -298,9 +298,7 @@ struct s2255_buffer {
 struct s2255_fh {
/* this must be the first field in this struct */
struct v4l2_fh  fh;
-   struct s2255_dev*dev;
struct videobuf_queue   vb_vidq;
-   enum v4l2_buf_type  type;
struct s2255_vc *vc;
int resources;
 };
@@ -673,6 +671,7 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned 
int *nbuffers,
 {
struct s2255_fh *fh = vq-priv_data;
struct s2255_vc *vc = fh-vc;
+
*size = vc-width * vc-height * (vc-fmt-depth  3);
 
if (*nbuffers  S2255_MIN_BUFS)
@@ -696,7 +695,7 @@ static int buffer_prepare(struct videobuf_queue *vq, struct 
videobuf_buffer *vb,
int rc;
int w = vc-width;
int h = vc-height;
-   dprintk(fh-dev, 4, %s, field=%d\n, __func__, field);
+   dprintk(vc-dev, 4, %s, field=%d\n, __func__, field);
if (vc-fmt == NULL)
return -EINVAL;
 
@@ -704,12 +703,12 @@ static int buffer_prepare(struct videobuf_queue *vq, 
struct videobuf_buffer *vb,
(w  norm_maxw(vc)) ||
(h  norm_minh(vc)) ||
(h  norm_maxh(vc))) {
-   dprintk(fh-dev, 4, invalid buffer prepare\n);
+   dprintk(vc-dev, 4, invalid buffer prepare\n);
return -EINVAL;
}
buf-vb.size = w * h * (vc-fmt-depth  3);
if (0 != buf-vb.baddr  buf-vb.bsize  buf-vb.size) {
-   dprintk(fh-dev, 4, invalid buffer prepare\n);
+   dprintk(vc-dev, 4, invalid buffer prepare\n);
return -EINVAL;
}
 
@@ -735,7 +734,7 @@ static void buffer_queue(struct videobuf_queue *vq, struct 
videobuf_buffer *vb)
struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
struct s2255_fh *fh = vq-priv_data;
struct s2255_vc *vc = fh-vc;
-   dprintk(fh-dev, 1, %s\n, __func__);
+   dprintk(vc-dev, 1, %s\n, __func__);
buf-vb.state = VIDEOBUF_QUEUED;
list_add_tail(buf-vb.queue, vc-buf_list);
 }
@@ -745,7 +744,8 @@ static void buffer_release(struct videobuf_queue *vq,
 {
struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
struct s2255_fh *fh = vq-priv_data;
-   dprintk(fh-dev, 4, %s %d\n, __func__, fh-vc-idx);
+   struct s2255_vc *vc = fh-vc;
+   dprintk(vc-dev, 4, %s %d\n, __func__, vc-idx);
free_buffer(vq, buf);
 }
 
@@ -766,7 +766,7 @@ static int res_get(struct s2255_fh *fh)
/* it's free, grab it */
vc-resources = 1;
fh-resources = 1;
-   dprintk(fh-dev, 1, s2255: res: get\n);
+   dprintk(vc-dev, 1, s2255: res: get\n);
return 1;
 }
 
@@ -792,7 +792,7 @@ static int vidioc_querycap(struct file *file, void *priv,
   struct v4l2_capability *cap)
 {
struct s2255_fh *fh = file-private_data;
-   struct s2255_dev *dev = fh-dev;
+   struct s2255_dev *dev = fh-vc-dev;
 
strlcpy(cap-driver, s2255, sizeof(cap-driver));
strlcpy(cap-card, s2255, sizeof(cap-card));
@@ -855,7 +855,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void 
*priv,
 
field = f-fmt.pix.field;
 
-   dprintk(fh-dev, 50, %s NTSC: %d suggested width: %d, height: %d\n,
+   dprintk(vc-dev, 50, %s NTSC: %d suggested width: %d, height: %d\n,
__func__, is_ntsc, f-fmt.pix.width, f-fmt.pix.height);
if (is_ntsc) {
/* NTSC */
@@ -897,7 +897,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void 
*priv,
f-fmt.pix.sizeimage = f-fmt.pix.height * f-fmt.pix.bytesperline;
f-fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
f-fmt.pix.priv = 0;
-   dprintk(fh-dev, 50, %s: set width %d height %d field %d\n, __func__,
+   dprintk(vc-dev, 50, %s: set width %d height %d field %d\n, __func__,
f-fmt.pix.width, f-fmt.pix.height, f-fmt.pix.field);
return 0;
 }
@@ -925,13 +925,13 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
mutex_lock(q-vb_lock);
 
if (videobuf_queue_is_busy(fh-vb_vidq)) {
-   dprintk(fh-dev, 1, queue busy\n);
+   dprintk(vc-dev, 1, queue busy\n);
ret = -EBUSY;
goto out_s_fmt;
}
 
if (res_locked(fh)) {
-   dprintk(fh-dev, 1, %s: channel busy\n, __func__);
+   dprintk(vc-dev, 1, %s: channel busy\n, __func__);
ret = -EBUSY;
goto out_s_fmt

Re: [PATCH] s2255drv: port to videobuf2

2014-02-05 Thread Dean Anderson

On 2014-02-04 04:04, Hans Verkuil wrote:

Hi Dean,

On 02/03/14 18:06, Dean Anderson wrote:

On 2014-02-03 03:51, Hans Verkuil wrote:

Hi Dean,

Some specific comments below, but first two general comments:

It is easier to review if at least the removal of the old s2255_fh 
struct
was done as a separate patch. It's always good to try and keep the 
changes
in patches as small as possible. The actual vb2 conversion is always 
a
'big bang' patch, that's unavoidable, but it's easier if it isn't 
mixed in
with other changes that are not directly related to the vb2 
conversion.



I figured removal of s2255_fh was a natural part of the videobuf2 
conversion process, but I can break it up.


It's more like the first phase of a vb2 conversion. It really is wrong
for videobuf as well, so it makes sense to do that first.

I also did change some formatting and naming changes (s2255_channel 
to s2255_vc) that can be postponed.


Just put it in a separate patch either before or after the patch that 
does

the vb2 conversion.





And did you also run the v4l2-compliance utility for this driver? 
That's

useful to check that everything it still correct.


Thanks for the comments.  I'll do a v2 soon with v4l2-compliance 
fully tested too.


Rather than the standard v4l2-compliance from v4l-utils, can you use 
this

from my own tree:

http://git.linuxtv.org/hverkuil/v4l-utils.git/shortlog/refs/heads/streaming

I've started work to add tests for streaming to v4l2-compliance. While 
not
complete it should cover what the s2255 driver needs. I'm very 
interested

in what it finds (or, as the case might be, what it doesn't find).

In order to do the streaming tests you have to run it with option -s.



The current driver before the videobuf2 patch has 3 errors and 8 
warnings with option -s.  The warnings are msg5650 warnings that 
will break existing applications if fixed.


Here's what is causing at least two of the errors (the other is 
unsupported USERPTR, which will be fixed in VB2):


Vidioc_reqbufs calls videobuf_reqbufs, which returns a fail if 
req-count = 0.


IE:

if (req-count  1) {
dprintk(1, reqbufs: count invalid (%d)\n, req-count);
return -EINVAL;
}

Are drivers using videobuf required to check if 
v4l2_requestbuffers-count == 0 before calling videobuf_reqbufs? That 
seems unlikely and inefficient, so this could be an issue with 
videobuf-core.c..


Thanks,







Regards,

Hans

--
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: [PATCH] s2255drv: port to videobuf2

2014-02-04 Thread Dean Anderson

On 2014-02-04 04:04, Hans Verkuil wrote:

Hi Dean,

On 02/03/14 18:06, Dean Anderson wrote:

On 2014-02-03 03:51, Hans Verkuil wrote:

Hi Dean,

Some specific comments below, but first two general comments:

It is easier to review if at least the removal of the old s2255_fh 
struct
was done as a separate patch. It's always good to try and keep the 
changes
in patches as small as possible. The actual vb2 conversion is always 
a
'big bang' patch, that's unavoidable, but it's easier if it isn't 
mixed in
with other changes that are not directly related to the vb2 
conversion.



I figured removal of s2255_fh was a natural part of the videobuf2 
conversion process, but I can break it up.


It's more like the first phase of a vb2 conversion. It really is wrong
for videobuf as well, so it makes sense to do that first.


Hans, if it's ok with you, I'd prefer to do it after the vb2 
conversion.  Right now, it's using SAA7134-style locking with resources 
in fh.  I could use videobuf_queue_is_busy from videobuf-core.c, but 
it has this comment /* Locking: Only usage in bttv unsafe find way to 
remove */.


Thanks,

Dean






I also did change some formatting and naming changes (s2255_channel 
to s2255_vc) that can be postponed.


Just put it in a separate patch either before or after the patch that 
does

the vb2 conversion.





And did you also run the v4l2-compliance utility for this driver? 
That's

useful to check that everything it still correct.


Thanks for the comments.  I'll do a v2 soon with v4l2-compliance 
fully tested too.


Rather than the standard v4l2-compliance from v4l-utils, can you use 
this

from my own tree:

http://git.linuxtv.org/hverkuil/v4l-utils.git/shortlog/refs/heads/streaming

I've started work to add tests for streaming to v4l2-compliance. While 
not
complete it should cover what the s2255 driver needs. I'm very 
interested

in what it finds (or, as the case might be, what it doesn't find).

In order to do the streaming tests you have to run it with option -s.

Regards,

Hans

--
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] s2255drv: removal of s2255_dmaqueue structure

2014-02-04 Thread Dean Anderson
Removal of unused and unnecessary s2255dma_queue structure.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |   29 ++---
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index c6bdccc..5f09a56 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1,7 +1,7 @@
 /*
  *  s2255drv.c - a driver for the Sensoray 2255 USB video capture device
  *
- *   Copyright (C) 2007-2013 by Sensoray Company Inc.
+ *   Copyright (C) 2007-2014 by Sensoray Company Inc.
  *  Dean Anderson
  *
  * Some video buffer code based on vivi driver:
@@ -52,7 +52,7 @@
 #include media/v4l2-ctrls.h
 #include media/v4l2-event.h
 
-#define S2255_VERSION  1.23.1
+#define S2255_VERSION  1.24.1
 #define FIRMWARE_FILE_NAME f2255usb.bin
 
 /* default JPEG quality */
@@ -178,11 +178,6 @@ struct s2255_bufferi {
DEF_FDEC, DEF_BRIGHT, DEF_CONTRAST, DEF_SATURATION, \
DEF_HUE, 0, DEF_USB_BLOCK, 0}
 
-struct s2255_dmaqueue {
-   struct list_headactive;
-   struct s2255_dev*dev;
-};
-
 /* for firmware loading, fw_state */
 #define S2255_FW_NOTLOADED 0
 #define S2255_FW_LOADED_DSPWAIT1
@@ -223,7 +218,7 @@ struct s2255_channel {
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl*jpegqual_ctrl;
int resources;
-   struct s2255_dmaqueue   vidq;
+   struct list_headbuf_list;
struct s2255_bufferibuffer;
struct s2255_mode   mode;
v4l2_std_id std;
@@ -574,18 +569,17 @@ static void s2255_fwchunk_complete(struct urb *urb)
 
 static int s2255_got_frame(struct s2255_channel *channel, int jpgsize)
 {
-   struct s2255_dmaqueue *dma_q = channel-vidq;
struct s2255_buffer *buf;
struct s2255_dev *dev = to_s2255_dev(channel-vdev.v4l2_dev);
unsigned long flags = 0;
int rc = 0;
spin_lock_irqsave(dev-slock, flags);
-   if (list_empty(dma_q-active)) {
+   if (list_empty(channel-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
-   buf = list_entry(dma_q-active.next,
+   buf = list_entry(channel-buf_list.next,
 struct s2255_buffer, vb.queue);
list_del(buf-vb.queue);
v4l2_get_timestamp(buf-vb.ts);
@@ -747,10 +741,9 @@ static void buffer_queue(struct videobuf_queue *vq, struct 
videobuf_buffer *vb)
struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
struct s2255_fh *fh = vq-priv_data;
struct s2255_channel *channel = fh-channel;
-   struct s2255_dmaqueue *vidq = channel-vidq;
dprintk(fh-dev, 1, %s\n, __func__);
buf-vb.state = VIDEOBUF_QUEUED;
-   list_add_tail(buf-vb.queue, vidq-active);
+   list_add_tail(buf-vb.queue, channel-buf_list);
 }
 
 static void buffer_release(struct videobuf_queue *vq,
@@ -1679,11 +1672,10 @@ static int __s2255_open(struct file *file)
}
dprintk(dev, 1, %s: dev=%s type=%s\n, __func__,
video_device_node_name(vdev), v4l2_type_names[type]);
-   dprintk(dev, 2, %s: fh=0x%08lx, dev=0x%08lx, vidq=0x%08lx\n, __func__,
-   (unsigned long)fh, (unsigned long)dev,
-   (unsigned long)channel-vidq);
+   dprintk(dev, 2, %s: fh=0x%08lx, dev=0x%08lx\n, __func__,
+   (unsigned long)fh, (unsigned long)dev);
dprintk(dev, 4, %s: list_empty active=%d\n, __func__,
-   list_empty(channel-vidq.active));
+   list_empty(channel-buf_list));
videobuf_queue_vmalloc_init(fh-vb_vidq, s2255_video_qops,
NULL, dev-slock,
fh-type,
@@ -1876,7 +1868,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
/* register 4 video devices */
for (i = 0; i  MAX_CHANNELS; i++) {
channel = dev-channel[i];
-   INIT_LIST_HEAD(channel-vidq.active);
+   INIT_LIST_HEAD(channel-buf_list);
 
v4l2_ctrl_handler_init(channel-hdl, 6);
v4l2_ctrl_new_std(channel-hdl, s2255_ctrl_ops,
@@ -1901,7 +1893,6 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
dev_err(dev-udev-dev, couldn't register control\n);
break;
}
-   channel-vidq.dev = dev;
/* register 4 video devices */
channel-vdev = template;
channel-vdev.ctrl_handler = channel-hdl;
-- 
1.7.9.5

--
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] s2255drv: refactoring s2255_channel to s2255_vc

2014-02-04 Thread Dean Anderson
Renaming s2255_channel and all instances of channel to vc (video channel).

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  469 ++--
 1 file changed, 235 insertions(+), 234 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 5f09a56..e8b7096 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -212,7 +212,8 @@ struct s2255_pipeinfo {
 struct s2255_fmt; /*forward declaration */
 struct s2255_dev;
 
-struct s2255_channel {
+/* 2255 video channel */
+struct s2255_vc {
struct s2255_dev*dev;
struct video_device vdev;
struct v4l2_ctrl_handler hdl;
@@ -254,7 +255,7 @@ struct s2255_channel {
 
 
 struct s2255_dev {
-   struct s2255_channelchannel[MAX_CHANNELS];
+   struct s2255_vc vc[MAX_CHANNELS];
struct v4l2_device  v4l2_dev;
atomic_tnum_channels;
int frames;
@@ -298,7 +299,7 @@ struct s2255_fh {
struct s2255_dev*dev;
struct videobuf_queue   vb_vidq;
enum v4l2_buf_type  type;
-   struct s2255_channel*channel;
+   struct s2255_vc *vc;
int resources;
 };
 
@@ -351,11 +352,11 @@ static int debug;
 
 static int s2255_start_readpipe(struct s2255_dev *dev);
 static void s2255_stop_readpipe(struct s2255_dev *dev);
-static int s2255_start_acquire(struct s2255_channel *channel);
-static int s2255_stop_acquire(struct s2255_channel *channel);
-static void s2255_fillbuff(struct s2255_channel *chn, struct s2255_buffer *buf,
+static int s2255_start_acquire(struct s2255_vc *vc);
+static int s2255_stop_acquire(struct s2255_vc *vc);
+static void s2255_fillbuff(struct s2255_vc *chn, struct s2255_buffer *buf,
   int jpgsize);
-static int s2255_set_mode(struct s2255_channel *chan, struct s2255_mode *mode);
+static int s2255_set_mode(struct s2255_vc *chan, struct s2255_mode *mode);
 static int s2255_board_shutdown(struct s2255_dev *dev);
 static void s2255_fwload_start(struct s2255_dev *dev, int reset);
 static void s2255_destroy(struct s2255_dev *dev);
@@ -434,27 +435,27 @@ static const struct s2255_fmt formats[] = {
}
 };
 
-static int norm_maxw(struct s2255_channel *channel)
+static int norm_maxw(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL;
 }
 
-static int norm_maxh(struct s2255_channel *channel)
+static int norm_maxh(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
(NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2);
 }
 
-static int norm_minw(struct s2255_channel *channel)
+static int norm_minw(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL;
 }
 
-static int norm_minh(struct s2255_channel *channel)
+static int norm_minh(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
(NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL);
 }
 
@@ -567,23 +568,23 @@ static void s2255_fwchunk_complete(struct urb *urb)
 
 }
 
-static int s2255_got_frame(struct s2255_channel *channel, int jpgsize)
+static int s2255_got_frame(struct s2255_vc *vc, int jpgsize)
 {
struct s2255_buffer *buf;
-   struct s2255_dev *dev = to_s2255_dev(channel-vdev.v4l2_dev);
+   struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
unsigned long flags = 0;
int rc = 0;
spin_lock_irqsave(dev-slock, flags);
-   if (list_empty(channel-buf_list)) {
+   if (list_empty(vc-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
-   buf = list_entry(channel-buf_list.next,
+   buf = list_entry(vc-buf_list.next,
 struct s2255_buffer, vb.queue);
list_del(buf-vb.queue);
v4l2_get_timestamp(buf-vb.ts);
-   s2255_fillbuff(channel, buf, jpgsize);
+   s2255_fillbuff(vc, buf, jpgsize);
wake_up(buf-vb.done);
dprintk(dev, 2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
 unlock:
@@ -614,21 +615,21 @@ static const struct s2255_fmt *format_by_fourcc(int 
fourcc)
  *  http://v4l.videotechnology.com/
  *
  */
-static void s2255_fillbuff(struct s2255_channel *channel,
+static void s2255_fillbuff(struct s2255_vc *vc,
   struct s2255_buffer *buf, int jpgsize)
 {
int pos = 0;
const char *tmpbuf;
char *vbuf = videobuf_to_vmalloc(buf-vb);
unsigned long last_frame;
-   struct s2255_dev *dev = channel-dev;
+   struct s2255_dev *dev = vc-dev

Re: [PATCH] s2255drv: refactoring s2255_channel to s2255_vc

2014-02-04 Thread Dean Anderson
There are some missing changes.  It compiles, but please review v2 
instead.


On 2014-02-04 15:04, Dean Anderson wrote:
Renaming s2255_channel and all instances of channel to vc (video 
channel).


Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  469 
++--

 1 file changed, 235 insertions(+), 234 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c
b/drivers/media/usb/s2255/s2255drv.c
index 5f09a56..e8b7096 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -212,7 +212,8 @@ struct s2255_pipeinfo {
 struct s2255_fmt; /*forward declaration */
 struct s2255_dev;

-struct s2255_channel {
+/* 2255 video channel */
+struct s2255_vc {
struct s2255_dev*dev;
struct video_device vdev;
struct v4l2_ctrl_handler hdl;
@@ -254,7 +255,7 @@ struct s2255_channel {


 struct s2255_dev {
-   struct s2255_channelchannel[MAX_CHANNELS];
+   struct s2255_vc vc[MAX_CHANNELS];
struct v4l2_device  v4l2_dev;
atomic_tnum_channels;
int frames;
@@ -298,7 +299,7 @@ struct s2255_fh {
struct s2255_dev*dev;
struct videobuf_queue   vb_vidq;
enum v4l2_buf_type  type;
-   struct s2255_channel*channel;
+   struct s2255_vc *vc;
int resources;
 };

@@ -351,11 +352,11 @@ static int debug;

 static int s2255_start_readpipe(struct s2255_dev *dev);
 static void s2255_stop_readpipe(struct s2255_dev *dev);
-static int s2255_start_acquire(struct s2255_channel *channel);
-static int s2255_stop_acquire(struct s2255_channel *channel);
-static void s2255_fillbuff(struct s2255_channel *chn, struct 
s2255_buffer *buf,

+static int s2255_start_acquire(struct s2255_vc *vc);
+static int s2255_stop_acquire(struct s2255_vc *vc);
+static void s2255_fillbuff(struct s2255_vc *chn, struct s2255_buffer 
*buf,

   int jpgsize);
-static int s2255_set_mode(struct s2255_channel *chan, struct 
s2255_mode *mode);
+static int s2255_set_mode(struct s2255_vc *chan, struct s2255_mode 
*mode);

 static int s2255_board_shutdown(struct s2255_dev *dev);
 static void s2255_fwload_start(struct s2255_dev *dev, int reset);
 static void s2255_destroy(struct s2255_dev *dev);
@@ -434,27 +435,27 @@ static const struct s2255_fmt formats[] = {
}
 };

-static int norm_maxw(struct s2255_channel *channel)
+static int norm_maxw(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL;
 }

-static int norm_maxh(struct s2255_channel *channel)
+static int norm_maxh(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
(NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2);
 }

-static int norm_minw(struct s2255_channel *channel)
+static int norm_minw(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL;
 }

-static int norm_minh(struct s2255_channel *channel)
+static int norm_minh(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
(NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL);
 }

@@ -567,23 +568,23 @@ static void s2255_fwchunk_complete(struct urb 
*urb)


 }

-static int s2255_got_frame(struct s2255_channel *channel, int 
jpgsize)

+static int s2255_got_frame(struct s2255_vc *vc, int jpgsize)
 {
struct s2255_buffer *buf;
-   struct s2255_dev *dev = to_s2255_dev(channel-vdev.v4l2_dev);
+   struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
unsigned long flags = 0;
int rc = 0;
spin_lock_irqsave(dev-slock, flags);
-   if (list_empty(channel-buf_list)) {
+   if (list_empty(vc-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
-   buf = list_entry(channel-buf_list.next,
+   buf = list_entry(vc-buf_list.next,
 struct s2255_buffer, vb.queue);
list_del(buf-vb.queue);
v4l2_get_timestamp(buf-vb.ts);
-   s2255_fillbuff(channel, buf, jpgsize);
+   s2255_fillbuff(vc, buf, jpgsize);
wake_up(buf-vb.done);
dprintk(dev, 2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
 unlock:
@@ -614,21 +615,21 @@ static const struct s2255_fmt
*format_by_fourcc(int fourcc)
  *  http://v4l.videotechnology.com/
  *
  */
-static void s2255_fillbuff(struct s2255_channel *channel,
+static void s2255_fillbuff(struct s2255_vc *vc,
   struct s2255_buffer *buf, int jpgsize)
 {
int pos = 0;
const char *tmpbuf;
char *vbuf = videobuf_to_vmalloc(buf-vb

[PATCH v2] s2255drv: refactoring s2255_channel to s2255_vc

2014-02-04 Thread Dean Anderson
Renaming s2255_channel and all instances of channel to vc (video channel).

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  517 ++--
 1 file changed, 259 insertions(+), 258 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 5f09a56..2e24aee 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -212,7 +212,8 @@ struct s2255_pipeinfo {
 struct s2255_fmt; /*forward declaration */
 struct s2255_dev;
 
-struct s2255_channel {
+/* 2255 video channel */
+struct s2255_vc {
struct s2255_dev*dev;
struct video_device vdev;
struct v4l2_ctrl_handler hdl;
@@ -254,7 +255,7 @@ struct s2255_channel {
 
 
 struct s2255_dev {
-   struct s2255_channelchannel[MAX_CHANNELS];
+   struct s2255_vc vc[MAX_CHANNELS];
struct v4l2_device  v4l2_dev;
atomic_tnum_channels;
int frames;
@@ -298,7 +299,7 @@ struct s2255_fh {
struct s2255_dev*dev;
struct videobuf_queue   vb_vidq;
enum v4l2_buf_type  type;
-   struct s2255_channel*channel;
+   struct s2255_vc *vc;
int resources;
 };
 
@@ -351,11 +352,11 @@ static int debug;
 
 static int s2255_start_readpipe(struct s2255_dev *dev);
 static void s2255_stop_readpipe(struct s2255_dev *dev);
-static int s2255_start_acquire(struct s2255_channel *channel);
-static int s2255_stop_acquire(struct s2255_channel *channel);
-static void s2255_fillbuff(struct s2255_channel *chn, struct s2255_buffer *buf,
+static int s2255_start_acquire(struct s2255_vc *vc);
+static int s2255_stop_acquire(struct s2255_vc *vc);
+static void s2255_fillbuff(struct s2255_vc *vc, struct s2255_buffer *buf,
   int jpgsize);
-static int s2255_set_mode(struct s2255_channel *chan, struct s2255_mode *mode);
+static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode);
 static int s2255_board_shutdown(struct s2255_dev *dev);
 static void s2255_fwload_start(struct s2255_dev *dev, int reset);
 static void s2255_destroy(struct s2255_dev *dev);
@@ -434,27 +435,27 @@ static const struct s2255_fmt formats[] = {
}
 };
 
-static int norm_maxw(struct s2255_channel *channel)
+static int norm_maxw(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL;
 }
 
-static int norm_maxh(struct s2255_channel *channel)
+static int norm_maxh(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
(NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2);
 }
 
-static int norm_minw(struct s2255_channel *channel)
+static int norm_minw(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL;
 }
 
-static int norm_minh(struct s2255_channel *channel)
+static int norm_minh(struct s2255_vc *vc)
 {
-   return (channel-std  V4L2_STD_525_60) ?
+   return (vc-std  V4L2_STD_525_60) ?
(NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL);
 }
 
@@ -567,23 +568,23 @@ static void s2255_fwchunk_complete(struct urb *urb)
 
 }
 
-static int s2255_got_frame(struct s2255_channel *channel, int jpgsize)
+static int s2255_got_frame(struct s2255_vc *vc, int jpgsize)
 {
struct s2255_buffer *buf;
-   struct s2255_dev *dev = to_s2255_dev(channel-vdev.v4l2_dev);
+   struct s2255_dev *dev = to_s2255_dev(vc-vdev.v4l2_dev);
unsigned long flags = 0;
int rc = 0;
spin_lock_irqsave(dev-slock, flags);
-   if (list_empty(channel-buf_list)) {
+   if (list_empty(vc-buf_list)) {
dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
-   buf = list_entry(channel-buf_list.next,
+   buf = list_entry(vc-buf_list.next,
 struct s2255_buffer, vb.queue);
list_del(buf-vb.queue);
v4l2_get_timestamp(buf-vb.ts);
-   s2255_fillbuff(channel, buf, jpgsize);
+   s2255_fillbuff(vc, buf, jpgsize);
wake_up(buf-vb.done);
dprintk(dev, 2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
 unlock:
@@ -614,21 +615,21 @@ static const struct s2255_fmt *format_by_fourcc(int 
fourcc)
  *  http://v4l.videotechnology.com/
  *
  */
-static void s2255_fillbuff(struct s2255_channel *channel,
+static void s2255_fillbuff(struct s2255_vc *vc,
   struct s2255_buffer *buf, int jpgsize)
 {
int pos = 0;
const char *tmpbuf;
char *vbuf = videobuf_to_vmalloc(buf-vb);
unsigned long last_frame;
-   struct s2255_dev *dev = channel-dev;
+   struct s2255_dev *dev = vc-dev

[PATCH] s2255drv: file handle cleanup

2014-02-04 Thread Dean Anderson
Removes most parameters from s2255_fh.  These elements belong in s2255_ch.
In the future, s2255_fh will be removed when videobuf2 is used. videobuf2
has convenient and safe functions for locking streaming resources.

The removal of s2255_fh (and s2255_fh-resources) was not done now to
avoid using videobuf_queue_is_busy.

videobuf_queue_is busy may be unsafe as noted by the following comment 
in videobuf-core.c:
/* Locking: Only usage in bttv unsafe find way to remove */

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  224 +---
 1 file changed, 105 insertions(+), 119 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 2e24aee..3ea1bd5e 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -251,6 +251,8 @@ struct s2255_vc {
unsigned intheight;
const struct s2255_fmt  *fmt;
int idx; /* channel number on device, 0-3 */
+   struct videobuf_queue   vb_vidq;
+   enum v4l2_buf_type  type;
 };
 
 
@@ -296,10 +298,6 @@ struct s2255_buffer {
 struct s2255_fh {
/* this must be the first field in this struct */
struct v4l2_fh  fh;
-   struct s2255_dev*dev;
-   struct videobuf_queue   vb_vidq;
-   enum v4l2_buf_type  type;
-   struct s2255_vc *vc;
int resources;
 };
 
@@ -674,8 +672,7 @@ static void s2255_fillbuff(struct s2255_vc *vc,
 static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
unsigned int *size)
 {
-   struct s2255_fh *fh = vq-priv_data;
-   struct s2255_vc *vc = fh-vc;
+   struct s2255_vc *vc = vq-priv_data;
*size = vc-width * vc-height * (vc-fmt-depth  3);
 
if (0 == *count)
@@ -696,13 +693,12 @@ static void free_buffer(struct videobuf_queue *vq, struct 
s2255_buffer *buf)
 static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer 
*vb,
  enum v4l2_field field)
 {
-   struct s2255_fh *fh = vq-priv_data;
-   struct s2255_vc *vc = fh-vc;
+   struct s2255_vc *vc = vq-priv_data;
struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
int rc;
int w = vc-width;
int h = vc-height;
-   dprintk(fh-dev, 4, %s, field=%d\n, __func__, field);
+   dprintk(vc-dev, 4, %s, field=%d\n, __func__, field);
if (vc-fmt == NULL)
return -EINVAL;
 
@@ -710,12 +706,12 @@ static int buffer_prepare(struct videobuf_queue *vq, 
struct videobuf_buffer *vb,
(w  norm_maxw(vc)) ||
(h  norm_minh(vc)) ||
(h  norm_maxh(vc))) {
-   dprintk(fh-dev, 4, invalid buffer prepare\n);
+   dprintk(vc-dev, 4, invalid buffer prepare\n);
return -EINVAL;
}
buf-vb.size = w * h * (vc-fmt-depth  3);
if (0 != buf-vb.baddr  buf-vb.bsize  buf-vb.size) {
-   dprintk(fh-dev, 4, invalid buffer prepare\n);
+   dprintk(vc-dev, 4, invalid buffer prepare\n);
return -EINVAL;
}
 
@@ -740,9 +736,8 @@ fail:
 static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
 {
struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
-   struct s2255_fh *fh = vq-priv_data;
-   struct s2255_vc *vc = fh-vc;
-   dprintk(fh-dev, 1, %s\n, __func__);
+   struct s2255_vc *vc = vq-priv_data;
+   dprintk(vc-dev, 1, %s\n, __func__);
buf-vb.state = VIDEOBUF_QUEUED;
list_add_tail(buf-vb.queue, vc-buf_list);
 }
@@ -751,8 +746,8 @@ static void buffer_release(struct videobuf_queue *vq,
   struct videobuf_buffer *vb)
 {
struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
-   struct s2255_fh *fh = vq-priv_data;
-   dprintk(fh-dev, 4, %s %d\n, __func__, fh-vc-idx);
+   struct s2255_vc *vc = vq-priv_data;
+   dprintk(vc-dev, 4, %s %d\n, __func__, vc-idx);
free_buffer(vq, buf);
 }
 
@@ -764,22 +759,21 @@ static struct videobuf_queue_ops s2255_video_qops = {
 };
 
 
-static int res_get(struct s2255_fh *fh)
+static int res_get(struct s2255_fh *fh, struct s2255_vc *vc)
 {
-   struct s2255_vc *vc = fh-vc;
/* is it free? */
if (vc-resources)
return 0; /* no, someone else uses it */
/* it's free, grab it */
vc-resources = 1;
fh-resources = 1;
-   dprintk(fh-dev, 1, s2255: res: get\n);
+   dprintk(vc-dev, 1, s2255: res: get\n);
return 1;
 }
 
-static int res_locked(struct s2255_fh *fh)
+static int res_locked(struct s2255_vc *vc)
 {
-   return fh-vc-resources;
+   return vc-resources;
 }
 
 static int res_check(struct s2255_fh *fh)
@@ -788,9 +782,8 @@ static int res_check(struct s2255_fh *fh)
 }
 
 
-static void res_free(struct s2255_fh *fh

Re: [PATCH] s2255drv: file handle cleanup

2014-02-04 Thread Dean Anderson

Hi Hans,

Please ignore and reject this patch. videobuf_queue_vmalloc_init needs 
to be in probe, not in open.


Let me know your thoughts on doing videobuf2 before s2255_fh removal so 
we don't have to work around or fix videobuf version one's deficiencies.


Thanks,




On 2014-02-04 16:36, Dean Anderson wrote:
Removes most parameters from s2255_fh.  These elements belong in 
s2255_ch.
In the future, s2255_fh will be removed when videobuf2 is used. 
videobuf2

has convenient and safe functions for locking streaming resources.

The removal of s2255_fh (and s2255_fh-resources) was not done now to
avoid using videobuf_queue_is_busy.

videobuf_queue_is busy may be unsafe as noted by the following comment
in videobuf-core.c:
/* Locking: Only usage in bttv unsafe find way to remove */

Signed-off-by: Dean Anderson linux-...@sensoray.com
---

--
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: [PATCH]: s2255drv: checkpatch fix: coding style fix

2014-01-29 Thread dean

Hi Hans,


-   dprintk(2, s2255fill at : Buffer 0x%08lx size= %d\n,
-   (unsigned long)vbuf, pos);
+   if (debug = 2)
+   pr_debug(s2255fill at : Buffer 0x%08lx size= %d\n,
+  (unsigned long)vbuf, pos);


Why this change? What's wrong with dprintk?


dev wasn't available in this function without a back-reference from 
channel, which may be a good idea.  The other issue you mention below is 
also important.  I'll update this patch.


Thanks,


On 2014-01-29 01:19, Hans Verkuil wrote:

Hi Dean,

A few small nitpicks below...

On 01/29/2014 12:31 AM, d...@sensoray.com wrote:

Fixes all style warnings from scripts/checkpatch -f

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
  drivers/media/usb/s2255/s2255drv.c |  328

  1 file changed, 147 insertions(+), 181 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c
b/drivers/media/usb/s2255/s2255drv.c
index 6bc9b8e..c938b02 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -259,7 +259,7 @@ struct s2255_channel {

  struct s2255_dev {
struct s2255_channelchannel[MAX_CHANNELS];
-   struct v4l2_device  v4l2_dev;
+   struct v4l2_device  v4l2_dev;
atomic_tnum_channels;
int frames;
struct mutexlock;   /* channels[].vdev.lock */
@@ -352,7 +352,6 @@ struct s2255_fh {
  static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};

  static int debug;
-static int *s2255_debug = debug;

  static int s2255_start_readpipe(struct s2255_dev *dev);
  static void s2255_stop_readpipe(struct s2255_dev *dev);
@@ -373,13 +372,8 @@ static long s2255_vendor_req(struct s2255_dev
*dev, unsigned char req,
  #define s2255_dev_err(dev, fmt, arg...)   
\
dev_err(dev, S2255_DRIVER_NAME  -  fmt, ##arg)

-#define dprintk(level, fmt, arg...)\
-   do {\
-   if (*s2255_debug = (level)) {   \
-   printk(KERN_DEBUG S2255_DRIVER_NAME \
-   :  fmt, ##arg); \
-   }   \
-   } while (0)
+#define dprintk(dev, level, fmt, arg...) \
+   v4l2_dbg(level, debug, dev-v4l2_dev, fmt, ## arg)

  static struct usb_driver s2255_driver;

@@ -498,7 +492,7 @@ static void planar422p_to_yuv_packed(const 
unsigned

char *in,
  static void s2255_reset_dsppower(struct s2255_dev *dev)
  {
s2255_vendor_req(dev, 0x40, 0x, 0x0001, NULL, 0, 1);
-   msleep(10);
+   msleep(20);
s2255_vendor_req(dev, 0x50, 0x, 0x, NULL, 0, 1);
msleep(600);
s2255_vendor_req(dev, 0x10, 0x, 0x, NULL, 0, 1);
@@ -510,9 +504,8 @@ static void s2255_reset_dsppower(struct s2255_dev
*dev)
  static void s2255_timer(unsigned long user_data)
  {
struct s2255_fw *data = (struct s2255_fw *)user_data;
-   dprintk(100, %s\n, __func__);
if (usb_submit_urb(data-fw_urb, GFP_ATOMIC)  0) {
-   printk(KERN_ERR s2255: can't submit urb\n);
+   pr_err(s2255: can't submit urb\n);
atomic_set(data-fw_state, S2255_FW_FAILED);
/* wake up anything waiting for the firmware */
wake_up(data-wait_fw);
@@ -532,7 +525,6 @@ static void s2255_fwchunk_complete(struct urb 
*urb)

struct s2255_fw *data = urb-context;
struct usb_device *udev = urb-dev;
int len;
-   dprintk(100, %s: udev %p urb %p, __func__, udev, urb);
if (urb-status) {
dev_err(udev-dev, URB failed with status %d\n, urb-status);
atomic_set(data-fw_state, S2255_FW_FAILED);
@@ -559,9 +551,6 @@ static void s2255_fwchunk_complete(struct urb 
*urb)

if (len  CHUNK_SIZE)
memset(data-pfw_data, 0, CHUNK_SIZE);

-   dprintk(100, completed len %d, loaded %d \n, len,
-   data-fw_loaded);
-
memcpy(data-pfw_data,
   (char *) data-fw-data + data-fw_loaded, len);

@@ -576,10 +565,8 @@ static void s2255_fwchunk_complete(struct urb
*urb)
return;
}
data-fw_loaded += len;
-   } else {
+   } else
atomic_set(data-fw_state, S2255_FW_LOADED_DSPWAIT);
-   dprintk(100, %s: firmware upload complete\n, __func__);
-   }
return;

  }
@@ -593,7 +580,7 @@ static int s2255_got_frame(struct s2255_channel
*channel, int jpgsize)
int rc = 0;
spin_lock_irqsave(dev-slock, flags);
if (list_empty(dma_q-active)) {
-   dprintk(1, No active queue to serve\n);
+   dprintk(dev, 1, No active queue to serve\n

[PATCH v2]: s2255drv: checkpatch fix: coding style fix

2014-01-29 Thread Dean Anderson
Fixes all style warnings from scripts/checkpatch -f

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  333 
 1 file changed, 151 insertions(+), 182 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 6bc9b8e..c6bdccc 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -218,6 +218,7 @@ struct s2255_fmt; /*forward declaration */
 struct s2255_dev;
 
 struct s2255_channel {
+   struct s2255_dev*dev;
struct video_device vdev;
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl*jpegqual_ctrl;
@@ -259,7 +260,7 @@ struct s2255_channel {
 
 struct s2255_dev {
struct s2255_channelchannel[MAX_CHANNELS];
-   struct v4l2_device  v4l2_dev;
+   struct v4l2_device  v4l2_dev;
atomic_tnum_channels;
int frames;
struct mutexlock;   /* channels[].vdev.lock */
@@ -352,7 +353,6 @@ struct s2255_fh {
 static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};
 
 static int debug;
-static int *s2255_debug = debug;
 
 static int s2255_start_readpipe(struct s2255_dev *dev);
 static void s2255_stop_readpipe(struct s2255_dev *dev);
@@ -373,13 +373,8 @@ static long s2255_vendor_req(struct s2255_dev *dev, 
unsigned char req,
 #define s2255_dev_err(dev, fmt, arg...)
\
dev_err(dev, S2255_DRIVER_NAME  -  fmt, ##arg)
 
-#define dprintk(level, fmt, arg...)\
-   do {\
-   if (*s2255_debug = (level)) {  \
-   printk(KERN_DEBUG S2255_DRIVER_NAME \
-   :  fmt, ##arg);   \
-   }   \
-   } while (0)
+#define dprintk(dev, level, fmt, arg...) \
+   v4l2_dbg(level, debug, dev-v4l2_dev, fmt, ## arg)
 
 static struct usb_driver s2255_driver;
 
@@ -498,7 +493,7 @@ static void planar422p_to_yuv_packed(const unsigned char 
*in,
 static void s2255_reset_dsppower(struct s2255_dev *dev)
 {
s2255_vendor_req(dev, 0x40, 0x, 0x0001, NULL, 0, 1);
-   msleep(10);
+   msleep(20);
s2255_vendor_req(dev, 0x50, 0x, 0x, NULL, 0, 1);
msleep(600);
s2255_vendor_req(dev, 0x10, 0x, 0x, NULL, 0, 1);
@@ -510,9 +505,8 @@ static void s2255_reset_dsppower(struct s2255_dev *dev)
 static void s2255_timer(unsigned long user_data)
 {
struct s2255_fw *data = (struct s2255_fw *)user_data;
-   dprintk(100, %s\n, __func__);
if (usb_submit_urb(data-fw_urb, GFP_ATOMIC)  0) {
-   printk(KERN_ERR s2255: can't submit urb\n);
+   pr_err(s2255: can't submit urb\n);
atomic_set(data-fw_state, S2255_FW_FAILED);
/* wake up anything waiting for the firmware */
wake_up(data-wait_fw);
@@ -532,7 +526,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
struct s2255_fw *data = urb-context;
struct usb_device *udev = urb-dev;
int len;
-   dprintk(100, %s: udev %p urb %p, __func__, udev, urb);
if (urb-status) {
dev_err(udev-dev, URB failed with status %d\n, urb-status);
atomic_set(data-fw_state, S2255_FW_FAILED);
@@ -559,9 +552,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
if (len  CHUNK_SIZE)
memset(data-pfw_data, 0, CHUNK_SIZE);
 
-   dprintk(100, completed len %d, loaded %d \n, len,
-   data-fw_loaded);
-
memcpy(data-pfw_data,
   (char *) data-fw-data + data-fw_loaded, len);
 
@@ -576,10 +566,8 @@ static void s2255_fwchunk_complete(struct urb *urb)
return;
}
data-fw_loaded += len;
-   } else {
+   } else
atomic_set(data-fw_state, S2255_FW_LOADED_DSPWAIT);
-   dprintk(100, %s: firmware upload complete\n, __func__);
-   }
return;
 
 }
@@ -593,7 +581,7 @@ static int s2255_got_frame(struct s2255_channel *channel, 
int jpgsize)
int rc = 0;
spin_lock_irqsave(dev-slock, flags);
if (list_empty(dma_q-active)) {
-   dprintk(1, No active queue to serve\n);
+   dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
@@ -603,7 +591,7 @@ static int s2255_got_frame(struct s2255_channel *channel, 
int jpgsize)
v4l2_get_timestamp(buf-vb.ts);
s2255_fillbuff(channel, buf, jpgsize);
wake_up(buf-vb.done);
-   dprintk(2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
+   dprintk(dev, 2, %s: [buf/i] [%p

[PATCH]: s2255drv: checkpatch fix: coding style fix

2014-01-28 Thread dean

Fixes all style warnings from scripts/checkpatch -f

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |  328 


 1 file changed, 147 insertions(+), 181 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c

index 6bc9b8e..c938b02 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -259,7 +259,7 @@ struct s2255_channel {

 struct s2255_dev {
struct s2255_channelchannel[MAX_CHANNELS];
-   struct v4l2_device  v4l2_dev;
+   struct v4l2_device  v4l2_dev;
atomic_tnum_channels;
int frames;
struct mutexlock;   /* channels[].vdev.lock */
@@ -352,7 +352,6 @@ struct s2255_fh {
 static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};

 static int debug;
-static int *s2255_debug = debug;

 static int s2255_start_readpipe(struct s2255_dev *dev);
 static void s2255_stop_readpipe(struct s2255_dev *dev);
@@ -373,13 +372,8 @@ static long s2255_vendor_req(struct s2255_dev 
*dev, unsigned char req,

 #define s2255_dev_err(dev, fmt, arg...)
\
dev_err(dev, S2255_DRIVER_NAME  -  fmt, ##arg)

-#define dprintk(level, fmt, arg...)\
-   do {\
-   if (*s2255_debug = (level)) {   \
-   printk(KERN_DEBUG S2255_DRIVER_NAME \
-   :  fmt, ##arg); \
-   }   \
-   } while (0)
+#define dprintk(dev, level, fmt, arg...) \
+   v4l2_dbg(level, debug, dev-v4l2_dev, fmt, ## arg)

 static struct usb_driver s2255_driver;

@@ -498,7 +492,7 @@ static void planar422p_to_yuv_packed(const unsigned 
char *in,

 static void s2255_reset_dsppower(struct s2255_dev *dev)
 {
s2255_vendor_req(dev, 0x40, 0x, 0x0001, NULL, 0, 1);
-   msleep(10);
+   msleep(20);
s2255_vendor_req(dev, 0x50, 0x, 0x, NULL, 0, 1);
msleep(600);
s2255_vendor_req(dev, 0x10, 0x, 0x, NULL, 0, 1);
@@ -510,9 +504,8 @@ static void s2255_reset_dsppower(struct s2255_dev 
*dev)

 static void s2255_timer(unsigned long user_data)
 {
struct s2255_fw *data = (struct s2255_fw *)user_data;
-   dprintk(100, %s\n, __func__);
if (usb_submit_urb(data-fw_urb, GFP_ATOMIC)  0) {
-   printk(KERN_ERR s2255: can't submit urb\n);
+   pr_err(s2255: can't submit urb\n);
atomic_set(data-fw_state, S2255_FW_FAILED);
/* wake up anything waiting for the firmware */
wake_up(data-wait_fw);
@@ -532,7 +525,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
struct s2255_fw *data = urb-context;
struct usb_device *udev = urb-dev;
int len;
-   dprintk(100, %s: udev %p urb %p, __func__, udev, urb);
if (urb-status) {
dev_err(udev-dev, URB failed with status %d\n, urb-status);
atomic_set(data-fw_state, S2255_FW_FAILED);
@@ -559,9 +551,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
if (len  CHUNK_SIZE)
memset(data-pfw_data, 0, CHUNK_SIZE);

-   dprintk(100, completed len %d, loaded %d \n, len,
-   data-fw_loaded);
-
memcpy(data-pfw_data,
   (char *) data-fw-data + data-fw_loaded, len);

@@ -576,10 +565,8 @@ static void s2255_fwchunk_complete(struct urb 
*urb)

return;
}
data-fw_loaded += len;
-   } else {
+   } else
atomic_set(data-fw_state, S2255_FW_LOADED_DSPWAIT);
-   dprintk(100, %s: firmware upload complete\n, __func__);
-   }
return;

 }
@@ -593,7 +580,7 @@ static int s2255_got_frame(struct s2255_channel 
*channel, int jpgsize)

int rc = 0;
spin_lock_irqsave(dev-slock, flags);
if (list_empty(dma_q-active)) {
-   dprintk(1, No active queue to serve\n);
+   dprintk(dev, 1, No active queue to serve\n);
rc = -1;
goto unlock;
}
@@ -603,7 +590,7 @@ static int s2255_got_frame(struct s2255_channel 
*channel, int jpgsize)

v4l2_get_timestamp(buf-vb.ts);
s2255_fillbuff(channel, buf, jpgsize);
wake_up(buf-vb.done);
-   dprintk(2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
+   dprintk(dev, 2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
 unlock:
spin_unlock_irqrestore(dev-slock, flags);
return rc;
@@ -615,9 +602,9 @@ static const struct s2255_fmt *format_by_fourcc(int 
fourcc)

for (i = 0; i  ARRAY_SIZE(formats); i

[PATCH] S2255: Removal of unnecessary videobuf_queue_is_busy

2013-07-23 Thread Dean Anderson
Removes unnecessary query of buffer state.  The code already checks if stream 
is active or not.

Signed-off-by: Dean Anderson linux-...@sensoray.com
---
 drivers/media/usb/s2255/s2255drv.c |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index ab97e7d..6bc9b8e 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1,7 +1,7 @@
 /*
  *  s2255drv.c - a driver for the Sensoray 2255 USB video capture device
  *
- *   Copyright (C) 2007-2010 by Sensoray Company Inc.
+ *   Copyright (C) 2007-2013 by Sensoray Company Inc.
  *  Dean Anderson
  *
  * Some video buffer code based on vivi driver:
@@ -52,7 +52,7 @@
 #include media/v4l2-ctrls.h
 #include media/v4l2-event.h
 
-#define S2255_VERSION  1.22.1
+#define S2255_VERSION  1.23.1
 #define FIRMWARE_FILE_NAME f2255usb.bin
 
 /* default JPEG quality */
@@ -1303,11 +1303,6 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id i)
int ret = 0;
 
mutex_lock(q-vb_lock);
-   if (videobuf_queue_is_busy(q)) {
-   dprintk(1, queue busy\n);
-   ret = -EBUSY;
-   goto out_s_std;
-   }
if (res_locked(fh)) {
dprintk(1, can't change standard after started\n);
ret = -EBUSY;
-- 
1.7.9.5

--
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: [patch 2/2] [media] s2255drv: fix some endian bugs

2012-02-22 Thread dean anderson

Hi Dan,

The original code has an issue on big endian hardware.  The patch looks ok.

Signed-off-by: Dean Anderson linux-...@sensoray.com

On 2/16/2012 10:44 PM, Dan Carpenter wrote:

I don't have this hardware and I don't know the subsystem very well.  So
please review this patch carefully.  The original code definitely looks
buggy though.

Sparse complains about some endian bugs where little endian bugs are
treated as cpu endian.

Signed-off-by: Dan Carpenterdan.carpen...@oracle.com
---

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 3505242..4894cbb 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -134,7 +134,7 @@

  /* usb config commands */
  #define IN_DATA_TOKEN cpu_to_le32(0x2255c0de)
-#define CMD_2255   cpu_to_le32(0xc2255000)
+#define CMD_2255   0xc2255000
  #define CMD_SET_MODE  cpu_to_le32((CMD_2255 | 0x10))
  #define CMD_START cpu_to_le32((CMD_2255 | 0x20))
  #define CMD_STOP  cpu_to_le32((CMD_2255 | 0x30))
@@ -2025,7 +2025,7 @@ static int save_frame(struct s2255_dev *dev, struct 
s2255_pipeinfo *pipe_info)
pdata[1]);
offset = jj + PREFIX_SIZE;
bframe = 1;
-   cc = pdword[1];
+   cc = le32_to_cpu(pdword[1]);
if (cc= MAX_CHANNELS) {
printk(KERN_ERR
   bad channel\n);
@@ -2034,22 +2034,22 @@ static int save_frame(struct s2255_dev *dev, struct 
s2255_pipeinfo *pipe_info)
/* reverse it */
dev-cc = G_chnmap[cc];
channel =dev-channel[dev-cc];
-   payload =  pdword[3];
+   payload =  le32_to_cpu(pdword[3]);
if (payload  channel-req_image_size) {
channel-bad_payload++;
/* discard the bad frame */
return -EINVAL;
}
channel-pkt_size = payload;
-   channel-jpg_size = pdword[4];
+   channel-jpg_size = le32_to_cpu(pdword[4]);
break;
case S2255_MARKER_RESPONSE:

pdata += DEF_USB_BLOCK;
jj += DEF_USB_BLOCK;
-   if (pdword[1]= MAX_CHANNELS)
+   if (le32_to_cpu(pdword[1])= MAX_CHANNELS)
break;
-   cc = G_chnmap[pdword[1]];
+   cc = G_chnmap[le32_to_cpu(pdword[1])];
if (cc= MAX_CHANNELS)
break;
channel =dev-channel[cc];
@@ -2072,11 +2072,11 @@ static int save_frame(struct s2255_dev *dev, struct 
s2255_pipeinfo *pipe_info)
wake_up(dev-fw_data-wait_fw);
break;
case S2255_RESPONSE_STATUS:
-   channel-vidstatus = pdword[3];
+   channel-vidstatus = 
le32_to_cpu(pdword[3]);
channel-vidstatus_ready = 1;
wake_up(channel-wait_vidstatus);
dprintk(5, got vidstatus %x chan %d\n,
-   pdword[3], cc);
+   le32_to_cpu(pdword[3]), cc);
break;
default:
printk(KERN_INFO s2255 unknown 
resp\n);
@@ -2603,10 +2603,11 @@ static int s2255_probe(struct usb_interface *interface,
__le32 *pRel;
pRel = (__le32 *)dev-fw_data-fw-data[fw_size - 4];
printk(KERN_INFO s2255 dsp fw version %x\n, *pRel);
-   dev-dsp_fw_ver = *pRel;
-   if (*pRel  S2255_CUR_DSP_FWVER)
+   dev-dsp_fw_ver = le32_to_cpu(*pRel);
+   if (dev-dsp_fw_ver  S2255_CUR_DSP_FWVER)
printk(KERN_INFO s2255: f2255usb.bin out of date.\n);
-   if (dev-pid == 0x2257  *pRel  S2255_MIN_DSP_COLORFILTER)
+   if (dev-pid == 0x2257
+   dev-dsp_fw_ver  S2255_MIN_DSP_COLORFILTER)
printk(KERN_WARNING s2255: 2257 requires firmware %d
or above.\n, S2255_MIN_DSP_COLORFILTER);
}



--
To unsubscribe from this list: send the line

Re: [patch 1/2] [media] s2255drv: cleanup vidioc_enum_fmt_cap()

2012-02-17 Thread dean anderson

Thanks Dan,

I can sign off on this.  The check isn't required.

Signed-off-by: Dean Anderson linux-...@sensoray.com

On 2/16/2012 10:43 PM, Dan Carpenter wrote:

f wasn't checked consistently, so static checkers complain.  This
function is always called with a valid f pointer, so I have removed
the check.

Also the indenting was messed up.

Signed-off-by: Dan Carpenterdan.carpen...@oracle.com

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index c1bef61..3505242 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -852,15 +852,13 @@ static int vidioc_querycap(struct file *file, void *priv,
  static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
   struct v4l2_fmtdesc *f)
  {
-   int index = 0;
-   if (f)
-   index = f-index;
+   int index = f-index;

if (index= ARRAY_SIZE(formats))
return -EINVAL;
-if (!jpeg_enable  ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
-(formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
-   return -EINVAL;
+   if (!jpeg_enable  ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
+   (formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
+   return -EINVAL;
dprintk(4, name %s\n, formats[index].name);
strlcpy(f-description, formats[index].name, sizeof(f-description));
f-pixelformat = formats[index].fourcc;
--
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



--
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] s2255drv: video_device_alloc call not checked fix

2010-03-31 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1270045856 25200
# Node ID 2ab296deae938864b06b29cc224eb4b670ae3aa9
# Parent  18586e4ac3ed5972dac2015600f8c21e26c0fc16
s2255drv: video_device allocation fix

From: Dean Anderson d...@sensoray.com

call to video_device_alloc was not being checked in probe function.
code simplified and uses video_device inside device structure.

Priority: high

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r 18586e4ac3ed -r 2ab296deae93 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Mon Mar 29 15:11:18 2010 -0700
+++ b/linux/drivers/media/video/s2255drv.c  Wed Mar 31 07:30:56 2010 -0700
@@ -224,6 +224,7 @@
 struct s2255_fmt; /*forward declaration */
 
 struct s2255_dev {
+   struct video_device vdev[MAX_CHANNELS];
int frames;
struct mutexlock;
struct mutexopen_lock;
@@ -233,7 +234,6 @@
u8  read_endpoint;
 
struct s2255_dmaqueue   vidq[MAX_CHANNELS];
-   struct video_device *vdev[MAX_CHANNELS];
struct timer_list   timer;
struct s2255_fw *fw_data;
struct s2255_pipeinfo   pipe;
@@ -719,10 +719,10 @@
if (fh-fmt == NULL)
return -EINVAL;
 
-   if ((fh-width  norm_minw(fh-dev-vdev[fh-channel])) ||
-   (fh-width  norm_maxw(fh-dev-vdev[fh-channel])) ||
-   (fh-height  norm_minh(fh-dev-vdev[fh-channel])) ||
-   (fh-height  norm_maxh(fh-dev-vdev[fh-channel]))) {
+   if ((fh-width  norm_minw(fh-dev-vdev[fh-channel])) ||
+   (fh-width  norm_maxw(fh-dev-vdev[fh-channel])) ||
+   (fh-height  norm_minh(fh-dev-vdev[fh-channel])) ||
+   (fh-height  norm_maxh(fh-dev-vdev[fh-channel]))) {
dprintk(4, invalid buffer prepare\n);
return -EINVAL;
}
@@ -896,7 +896,7 @@
int is_ntsc;
 
is_ntsc =
-   (dev-vdev[fh-channel]-current_norm  V4L2_STD_NTSC) ? 1 : 0;
+   (dev-vdev[fh-channel].current_norm  V4L2_STD_NTSC) ? 1 : 0;
 
fmt = format_by_fourcc(f-fmt.pix.pixelformat);
 
@@ -1029,9 +1029,9 @@
fh-height = f-fmt.pix.height;
fh-vb_vidq.field = f-fmt.pix.field;
fh-type = f-type;
-   norm = norm_minw(fh-dev-vdev[fh-channel]);
-   if (fh-width  norm_minw(fh-dev-vdev[fh-channel])) {
-   if (fh-height  norm_minh(fh-dev-vdev[fh-channel])) {
+   norm = norm_minw(fh-dev-vdev[fh-channel]);
+   if (fh-width  norm_minw(fh-dev-vdev[fh-channel])) {
+   if (fh-height  norm_minh(fh-dev-vdev[fh-channel])) {
if (fh-dev-cap_parm[fh-channel].capturemode 
V4L2_MODE_HIGHQUALITY) {
fh-mode.scale = SCALE_4CIFSI;
@@ -1755,7 +1755,7 @@
video_device_node_name(vdev));
lock_kernel();
for (i = 0; i  MAX_CHANNELS; i++)
-   if (dev-vdev[i] == vdev) {
+   if (dev-vdev[i] == vdev) {
cur_channel = i;
break;
}
@@ -1985,7 +1985,6 @@
 static void s2255_video_device_release(struct video_device *vdev)
 {
struct s2255_dev *dev = video_get_drvdata(vdev);
-   video_device_release(vdev);
kref_put(dev-kref, s2255_destroy);
return;
 }
@@ -2012,19 +2011,18 @@
dev-vidq[i].dev = dev;
dev-vidq[i].channel = i;
/* register 4 video devices */
-   dev-vdev[i] = video_device_alloc();
-   memcpy(dev-vdev[i], template, sizeof(struct video_device));
-   dev-vdev[i]-parent = dev-interface-dev;
-   video_set_drvdata(dev-vdev[i], dev);
+   memcpy(dev-vdev[i], template, sizeof(struct video_device));
+   dev-vdev[i].parent = dev-interface-dev;
+   video_set_drvdata(dev-vdev[i], dev);
if (video_nr == -1)
-   ret = video_register_device(dev-vdev[i],
+   ret = video_register_device(dev-vdev[i],
VFL_TYPE_GRABBER,
video_nr);
else
-   ret = video_register_device(dev-vdev[i],
+   ret = video_register_device(dev-vdev[i],
VFL_TYPE_GRABBER,
cur_nr + i);
-   video_set_drvdata(dev-vdev[i], dev);
+   video_set_drvdata(dev-vdev[i], dev);
 
if (ret != 0) {
dev_err(dev-udev-dev,
@@ -2721,8 +2719,8 @@
return 0;
 errorV4L:
for (i = 0; i  MAX_CHANNELS; i++)
-   if (dev-vdev[i]  video_is_registered(dev-vdev[i]))
-   video_unregister_device(dev-vdev[i

[PATCH] s2255drv: removal of big kernel lock

2010-03-31 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1270046291 25200
# Node ID c72bdc8732abc0cf7bc376babfd06b2d999bdcf4
# Parent  2ab296deae938864b06b29cc224eb4b670ae3aa9
s2255drv: removal of BKL

From: Dean Anderson d...@sensoray.com

big kernel lock removed from open function.
v4l2 code does not require locking the open function except
to check asynchronous firmware load state, which is protected
by a mutex

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r 2ab296deae93 -r c72bdc8732ab linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Wed Mar 31 07:30:56 2010 -0700
+++ b/linux/drivers/media/video/s2255drv.c  Wed Mar 31 07:38:11 2010 -0700
@@ -1753,7 +1753,6 @@
int state;
dprintk(1, s2255: open called (dev=%s)\n,
video_device_node_name(vdev));
-   lock_kernel();
for (i = 0; i  MAX_CHANNELS; i++)
if (dev-vdev[i] == vdev) {
cur_channel = i;
@@ -1769,7 +1768,6 @@
switch (state) {
case S2255_FW_DISCONNECTING:
mutex_unlock(dev-open_lock);
-   unlock_kernel();
return -ENODEV;
case S2255_FW_FAILED:
s2255_dev_err(dev-udev-dev,
@@ -1809,30 +1807,24 @@
break;
case S2255_FW_FAILED:
printk(KERN_INFO 2255 firmware load failed.\n);
-   unlock_kernel();
return -ENODEV;
case S2255_FW_DISCONNECTING:
printk(KERN_INFO %s: disconnecting\n, __func__);
-   unlock_kernel();
return -ENODEV;
case S2255_FW_LOADED_DSPWAIT:
case S2255_FW_NOTLOADED:
printk(KERN_INFO %s: firmware not loaded yet
   please try again later\n,
   __func__);
-   unlock_kernel();
return -EAGAIN;
default:
printk(KERN_INFO %s: unknown state\n, __func__);
-   unlock_kernel();
return -EFAULT;
}
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-   if (NULL == fh) {
-   unlock_kernel();
+   if (NULL == fh)
return -ENOMEM;
-   }
file-private_data = fh;
fh-dev = dev;
fh-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1860,7 +1852,6 @@
fh-type,
V4L2_FIELD_INTERLACED,
sizeof(struct s2255_buffer), fh);
-   unlock_kernel();
return 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] s2255drv: cleanup of debug messages

2010-03-31 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1270056198 25200
# Node ID db81e2f83909ee79dcca8496ceeda2653775e60a
# Parent  0690e4e1d81e785af1a5f06a13573dcf2cc5cb0c
s2255drv: cleanup of debug messages

From: Dean Anderson d...@sensoray.com

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r 0690e4e1d81e -r db81e2f83909 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Wed Mar 31 09:30:44 2010 -0700
+++ b/linux/drivers/media/video/s2255drv.c  Wed Mar 31 10:23:18 2010 -0700
@@ -57,10 +57,14 @@
 #include linux/usb.h
 #include compat.h
 
+#define S2255_MAJOR_VERSION1
+#define S2255_MINOR_VERSION19
+#define S2255_RELEASE  0
+#define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
+  S2255_MINOR_VERSION, \
+  S2255_RELEASE)
 #define FIRMWARE_FILE_NAME f2255usb.bin
 
-
-
 /* default JPEG quality */
 #define S2255_DEF_JPEG_QUAL 50
 /* vendor request in */
@@ -310,13 +314,6 @@
 /* Need DSP version 5+ for video status feature */
 #define S2255_MIN_DSP_STATUS  5
 #define S2255_MIN_DSP_COLORFILTER 8
-#define S2255_MAJOR_VERSION1
-#define S2255_MINOR_VERSION18
-#define S2255_RELEASE  0
-#define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
-  S2255_MINOR_VERSION, \
-  S2255_RELEASE)
-
 #define S2255_NORMS(V4L2_STD_PAL | V4L2_STD_NTSC)
 
 /* private V4L2 controls */
@@ -503,7 +500,7 @@
 static void s2255_timer(unsigned long user_data)
 {
struct s2255_fw *data = (struct s2255_fw *)user_data;
-   dprintk(100, s2255 timer\n);
+   dprintk(100, %s\n, __func__);
if (usb_submit_urb(data-fw_urb, GFP_ATOMIC)  0) {
printk(KERN_ERR s2255: can't submit urb\n);
atomic_set(data-fw_state, S2255_FW_FAILED);
@@ -525,7 +522,7 @@
struct s2255_fw *data = urb-context;
struct usb_device *udev = urb-dev;
int len;
-   dprintk(100, udev %p urb %p, udev, urb);
+   dprintk(100, %s: udev %p urb %p, __func__, udev, urb);
if (urb-status) {
dev_err(udev-dev, URB failed with status %d\n, urb-status);
atomic_set(data-fw_state, S2255_FW_FAILED);
@@ -571,8 +568,8 @@
data-fw_loaded += len;
} else {
atomic_set(data-fw_state, S2255_FW_LOADED_DSPWAIT);
+   dprintk(100, %s: firmware upload complete\n, __func__);
}
-   dprintk(100, 2255 complete done\n);
return;
 
 }
@@ -583,9 +580,7 @@
struct s2255_buffer *buf;
unsigned long flags = 0;
int rc = 0;
-   dprintk(2, wakeup: %p channel: %d\n, dma_q, chn);
spin_lock_irqsave(dev-slock, flags);
-
if (list_empty(dma_q-active)) {
dprintk(1, No active queue to serve\n);
rc = -1;
@@ -593,13 +588,11 @@
}
buf = list_entry(dma_q-active.next,
 struct s2255_buffer, vb.queue);
-
list_del(buf-vb.queue);
do_gettimeofday(buf-vb.ts);
-   dprintk(100, [%p/%d] wakeup\n, buf, buf-vb.i);
s2255_fillbuff(dev, buf, dma_q-channel, jpgsize);
wake_up(buf-vb.done);
-   dprintk(2, wakeup [buf/i] [%p/%d]\n, buf, buf-vb.i);
+   dprintk(2, %s: [buf/i] [%p/%d]\n, __func__, buf, buf-vb.i);
 unlock:
spin_unlock_irqrestore(dev-slock, flags);
return 0;
@@ -608,7 +601,6 @@
 static const struct s2255_fmt *format_by_fourcc(int fourcc)
 {
unsigned int i;
-
for (i = 0; i  ARRAY_SIZE(formats); i++) {
if (-1 == formats[i].fourcc)
continue;
@@ -741,7 +733,6 @@
buf-vb.height = fh-height;
buf-vb.field = field;
 
-
if (VIDEOBUF_NEEDS_INIT == buf-vb.state) {
rc = videobuf_iolock(vq, buf-vb, NULL);
if (rc  0)
@@ -761,9 +752,7 @@
struct s2255_fh *fh = vq-priv_data;
struct s2255_dev *dev = fh-dev;
struct s2255_dmaqueue *vidq = dev-vidq[fh-channel];
-
dprintk(1, %s\n, __func__);
-
buf-vb.state = VIDEOBUF_QUEUED;
list_add_tail(buf-vb.queue, vidq-active);
 }
@@ -909,10 +898,8 @@
if (field == V4L2_FIELD_ANY)
b_any_field = 1;
 
-   dprintk(4, try format %d \n, is_ntsc);
-   /* supports 3 sizes. see s2255drv.h */
-   dprintk(50, width test %d, height %d\n,
-   f-fmt.pix.width, f-fmt.pix.height);
+   dprintk(50, %s NTSC: %d suggested width: %d, height: %d\n,
+   __func__, is_ntsc, f-fmt.pix.width, f-fmt.pix.height);
if (is_ntsc) {
/* NTSC */
if (f-fmt.pix.height = NUM_LINES_1CIFS_NTSC * 2) {
@@ -967,29 +954,24 @@
}
}
if (f-fmt.pix.width = LINE_SZ_4CIFS_PAL

Re: [PATCH] s2255drv: v4l2 device added

2010-03-31 Thread dean
You are correct.  Please withdraw this 
patch(https://patchwork.kernel.org/patch/89985/).


Regards,




Hans Verkuil wrote:

On Wednesday 31 March 2010 18:34:39 Dean A. wrote:
  

# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1270053044 25200
# Node ID 0690e4e1d81e785af1a5f06a13573dcf2cc5cb0c
# Parent  c72bdc8732abc0cf7bc376babfd06b2d999bdcf4
s2255drv: adding v4l2_device structure. video_register_device cleanup

From: Dean Anderson d...@sensoray.com

adding v4l2_device structure.
if one video_register_device call fails, allows use of other devices
or channels.



That's not correct. There is only one v4l2_device per USB device. And the
first argument should be dev-interface-dev, not dev-udev-dev.

When you register the video device node you shouldn't set vdev[i]-parent
anymore, instead point vdev[i]-v4l2_dev to the v4l2_device struct.

Regards,

Hans

  

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r c72bdc8732ab -r 0690e4e1d81e linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Wed Mar 31 07:38:11 2010 -0700
+++ b/linux/drivers/media/video/s2255drv.c  Wed Mar 31 09:30:44 2010 -0700
@@ -51,6 +51,7 @@
 #include linux/smp_lock.h
 #include media/videobuf-vmalloc.h
 #include media/v4l2-common.h
+#include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include linux/vmalloc.h
 #include linux/usb.h
@@ -77,7 +78,6 @@
 #define S2255_DEF_BUFS  16
 #define S2255_SETMODE_TIMEOUT   500
 #define S2255_VIDSTATUS_TIMEOUT 350
-#define MAX_CHANNELS   4
 #define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL)
 #define S2255_MARKER_RESPONSE  cpu_to_le32(0x2255ACACL)
 #define S2255_RESPONSE_SETMODE  cpu_to_le32(0x01)
@@ -225,6 +225,8 @@
 
 struct s2255_dev {

struct video_device vdev[MAX_CHANNELS];
+   struct v4l2_device  v4l2_dev[MAX_CHANNELS];
+   int channels; /* number of channels registered */
int frames;
struct mutexlock;
struct mutexopen_lock;
@@ -1753,7 +1755,8 @@
int state;
dprintk(1, s2255: open called (dev=%s)\n,
video_device_node_name(vdev));
-   for (i = 0; i  MAX_CHANNELS; i++)
+
+   for (i = 0; i  dev-channels; i++)
if (dev-vdev[i] == vdev) {
cur_channel = i;
break;
@@ -1994,7 +1997,11 @@
int ret;
int i;
int cur_nr = video_nr;
-
+   for (i = 0; i  MAX_CHANNELS; i++) {
+   ret = v4l2_device_register(dev-udev-dev, dev-v4l2_dev[i]);
+   if (ret)
+   goto unreg_v4l2;
+   }
/* initialize all video 4 linux */
/* register 4 video devices */
for (i = 0; i  MAX_CHANNELS; i++) {
@@ -2014,16 +2021,29 @@
VFL_TYPE_GRABBER,
cur_nr + i);
video_set_drvdata(dev-vdev[i], dev);
-
-   if (ret != 0) {
+   if (ret) {
dev_err(dev-udev-dev,
failed to register video device!\n);
-   return ret;
+   break;
}
+   dev-channels++;
+   v4l2_info(dev-v4l2_dev[i], V4L2 device registered as %s\n,
+ video_device_node_name(dev-vdev[i]));
+
}
+
printk(KERN_INFO Sensoray 2255 V4L driver Revision: %d.%d\n,
   S2255_MAJOR_VERSION,
   S2255_MINOR_VERSION);
+   /* if no channels registered, return error and probe will fail*/
+   if (dev-channels == 0)
+   return ret;
+   if (dev-channels != MAX_CHANNELS)
+   printk(KERN_WARNING s2255: Not all channels available.\n);
+   return 0;
+unreg_v4l2:
+   for (i-- ; i  0; i--)
+   v4l2_device_unregister(dev-v4l2_dev[i]);
return ret;
 }
 
@@ -2705,13 +2725,9 @@

/* loads v4l specific */
retval = s2255_probe_v4l(dev);
if (retval)
-   goto errorV4L;
+   goto errorBOARDINIT;
dev_info(interface-dev, Sensoray 2255 detected\n);
return 0;
-errorV4L:
-   for (i = 0; i  MAX_CHANNELS; i++)
-   if (video_is_registered(dev-vdev[i]))
-   video_unregister_device(dev-vdev[i]);
 errorBOARDINIT:
s2255_board_shutdown(dev);
 errorFWMARKER:





  




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.791 / Virus Database: 271.1.1/2781 - Release Date: 03/30/10 23:32:00


  


--
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: [PATCH] s2255drv: cleanup of driver disconnect code

2010-03-30 Thread dean

Thanks for this and the other feedback.

The concern, without knowing the full history, is if video_device_alloc 
changes to do more than just allocate the whole structure with a single 
call to kzalloc?  Otherwise, why have this extra indirection and 
overhead in most V4L drivers?


The majority of V4L drivers are using video_device_alloc.  Very few 
(bw-qcam.h, c-qcam.c, cpia.h, pvrusb2, usbvideo) are using struct 
video_device statically similar to solution 1.  Three drivers(zoran, 
radio-gemtek, saa5249) are allocating their own video_device structure 
directly with kzalloc similar to solution #2.


The call definitely needs checked, but I'd like some more feedback on this.

Thanks and best regards,

Dean




David Ellingsworth wrote:

This patch looks good, but there was one other thing that caught my eye.

In s2255_probe_v4l, video_device_alloc is called for each video
device, which is nothing more than a call to kzalloc, but the result
of the call is never verified.

Given that this driver has a fixed number of video device nodes, the
array of video_device structs could be allocated within the s2255_dev
struct. This would remove the extra calls to video_device_alloc,
video_device_release, and the additional error checks that should have
been there. If you'd prefer to keep the array of video_device structs
independent of the s2255_dev struct, an alternative would be to
dynamically allocate the entire array at once using kcalloc and store
only the pointer to the array in the s2255_dev struct. In my opinion,
either of these methods would be better than calling
video_device_alloc for each video device that needs to be registered.

Regards,

David Ellingsworth
--
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


--
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] s2255drv: cleanup of driver disconnect code

2010-03-29 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1269899865 25200
# Node ID c437bd6f3659885afbe20ad12857347f0850156b
# Parent  a539e5b689454b8feb6b5acf5a67516b142c2823
s2255drv: cleanup of driver disconnect code

From: Dean Anderson d...@sensoray.com

simplifies use of kref in driver

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r a539e5b68945 -r c437bd6f3659 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Sat Mar 27 23:09:47 2010 -0300
+++ b/linux/drivers/media/video/s2255drv.c  Mon Mar 29 14:57:45 2010 -0700
@@ -226,7 +226,6 @@
 
 struct s2255_dev {
int frames;
-   int users[MAX_CHANNELS];
struct mutexlock;
struct mutexopen_lock;
int resources[MAX_CHANNELS];
@@ -367,7 +366,6 @@
 static int s2255_set_mode(struct s2255_dev *dev, unsigned long chn,
  struct s2255_mode *mode);
 static int s2255_board_shutdown(struct s2255_dev *dev);
-static void s2255_exit_v4l(struct s2255_dev *dev);
 static void s2255_fwload_start(struct s2255_dev *dev, int reset);
 static void s2255_destroy(struct kref *kref);
 static long s2255_vendor_req(struct s2255_dev *dev, unsigned char req,
@@ -606,7 +604,6 @@
return 0;
 }
 
-
 static const struct s2255_fmt *format_by_fourcc(int fourcc)
 {
unsigned int i;
@@ -620,9 +617,6 @@
return NULL;
 }
 
-
-
-
 /* video buffer vmalloc implementation based partly on VIVI driver which is
  *  Copyright (c) 2006 by
  *  Mauro Carvalho Chehab mchehab--a.t--infradead.org
@@ -849,7 +843,6 @@
return v4l2_ctrl_query_menu(qmenu, NULL, NULL);
 }
 
-
 static int vidioc_querycap(struct file *file, void *priv,
   struct v4l2_capability *cap)
 {
@@ -1759,31 +1752,26 @@
int i = 0;
int cur_channel = -1;
int state;
-
dprintk(1, s2255: open called (dev=%s)\n,
video_device_node_name(vdev));
-
lock_kernel();
-
-   for (i = 0; i  MAX_CHANNELS; i++) {
+   for (i = 0; i  MAX_CHANNELS; i++)
if (dev-vdev[i] == vdev) {
cur_channel = i;
break;
}
-   }
-
-   if (atomic_read(dev-fw_data-fw_state) == S2255_FW_DISCONNECTING) {
+   /*
+* open lock necessary to prevent multiple instances
+* of v4l-conf (or other programs) from simultaneously
+* reloading firmware.
+*/
+   mutex_lock(dev-open_lock);
+   state = atomic_read(dev-fw_data-fw_state);
+   switch (state) {
+   case S2255_FW_DISCONNECTING:
+   mutex_unlock(dev-open_lock);
unlock_kernel();
-   printk(KERN_INFO disconnecting\n);
return -ENODEV;
-   }
-   kref_get(dev-kref);
-   mutex_lock(dev-open_lock);
-
-   dev-users[cur_channel]++;
-   dprintk(4, s2255: open_handles %d\n, dev-users[cur_channel]);
-
-   switch (atomic_read(dev-fw_data-fw_state)) {
case S2255_FW_FAILED:
s2255_dev_err(dev-udev-dev,
firmware load failed. retrying.\n);
@@ -1794,6 +1782,8 @@
(atomic_read(dev-fw_data-fw_state)
 == S2255_FW_DISCONNECTING)),
   msecs_to_jiffies(S2255_LOAD_TIMEOUT));
+   /* state may have changed, re-read */
+   state = atomic_read(dev-fw_data-fw_state);
break;
case S2255_FW_NOTLOADED:
case S2255_FW_LOADED_DSPWAIT:
@@ -1806,52 +1796,44 @@
(atomic_read(dev-fw_data-fw_state)
 == S2255_FW_DISCONNECTING)),
msecs_to_jiffies(S2255_LOAD_TIMEOUT));
+   /* state may have changed, re-read */
+   state = atomic_read(dev-fw_data-fw_state);
break;
case S2255_FW_SUCCESS:
default:
break;
}
-   state = atomic_read(dev-fw_data-fw_state);
-   if (state != S2255_FW_SUCCESS) {
-   int rc;
-   switch (state) {
-   case S2255_FW_FAILED:
-   printk(KERN_INFO 2255 FW load failed. %d\n, state);
-   rc = -ENODEV;
-   break;
-   case S2255_FW_DISCONNECTING:
-   printk(KERN_INFO %s: disconnecting\n, __func__);
-   rc = -ENODEV;
-   break;
-   case S2255_FW_LOADED_DSPWAIT:
-   case S2255_FW_NOTLOADED:
-   printk(KERN_INFO %s: firmware not loaded yet
-  please try again later\n,
-  __func__);
-   rc = -EAGAIN;
-   break

[PATCH] s2255drv: code cleanup

2010-03-29 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1269900678 25200
# Node ID 18586e4ac3ed5972dac2015600f8c21e26c0fc16
# Parent  c437bd6f3659885afbe20ad12857347f0850156b
s2255drv: code cleanup

From: Dean Anderson d...@sensoray.com

removal of unused pipe array (of size one).

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r c437bd6f3659 -r 18586e4ac3ed linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Mon Mar 29 14:57:45 2010 -0700
+++ b/linux/drivers/media/video/s2255drv.c  Mon Mar 29 15:11:18 2010 -0700
@@ -85,7 +85,6 @@
 #define S2255_RESPONSE_STATUS   cpu_to_le32(0x20)
 #define S2255_USB_XFER_SIZE(16 * 1024)
 #define MAX_CHANNELS   4
-#define MAX_PIPE_BUFFERS   1
 #define SYS_FRAMES 4
 /* maximum size is PAL full size plus room for the marker header(s) */
 #define SYS_FRAMES_MAXSIZE (720*288*2*2 + 4096)
@@ -237,8 +236,8 @@
struct video_device *vdev[MAX_CHANNELS];
struct timer_list   timer;
struct s2255_fw *fw_data;
-   struct s2255_pipeinfo   pipes[MAX_PIPE_BUFFERS];
-   struct s2255_bufferibuffer[MAX_CHANNELS];
+   struct s2255_pipeinfo   pipe;
+   struct s2255_bufferibuffer[MAX_CHANNELS];
struct s2255_mode   mode[MAX_CHANNELS];
/* jpeg compression */
struct v4l2_jpegcompression jc[MAX_CHANNELS];
@@ -2334,25 +2333,21 @@
 
 static int s2255_board_init(struct s2255_dev *dev)
 {
-   int j;
struct s2255_mode mode_def = DEF_MODEI_NTSC_CONT;
int fw_ver;
+   int j;
+   struct s2255_pipeinfo *pipe = dev-pipe;
dprintk(4, board init: %p, dev);
+   memset(pipe, 0, sizeof(*pipe));
+   pipe-dev = dev;
+   pipe-cur_transfer_size = S2255_USB_XFER_SIZE;
+   pipe-max_transfer_size = S2255_USB_XFER_SIZE;
 
-   for (j = 0; j  MAX_PIPE_BUFFERS; j++) {
-   struct s2255_pipeinfo *pipe = dev-pipes[j];
-
-   memset(pipe, 0, sizeof(*pipe));
-   pipe-dev = dev;
-   pipe-cur_transfer_size = S2255_USB_XFER_SIZE;
-   pipe-max_transfer_size = S2255_USB_XFER_SIZE;
-
-   pipe-transfer_buffer = kzalloc(pipe-max_transfer_size,
-   GFP_KERNEL);
-   if (pipe-transfer_buffer == NULL) {
-   dprintk(1, out of memory!\n);
-   return -ENOMEM;
-   }
+   pipe-transfer_buffer = kzalloc(pipe-max_transfer_size,
+   GFP_KERNEL);
+   if (pipe-transfer_buffer == NULL) {
+   dprintk(1, out of memory!\n);
+   return -ENOMEM;
}
/* query the firmware */
fw_ver = s2255_get_fx2fw(dev);
@@ -2401,12 +2396,8 @@
 
for (i = 0; i  MAX_CHANNELS; i++)
s2255_release_sys_buffers(dev, i);
-
-   /* release transfer buffers */
-   for (i = 0; i  MAX_PIPE_BUFFERS; i++) {
-   struct s2255_pipeinfo *pipe = dev-pipes[i];
-   kfree(pipe-transfer_buffer);
-   }
+   /* release transfer buffer */
+   kfree(dev-pipe.transfer_buffer);
return 0;
 }
 
@@ -2472,35 +2463,30 @@
 {
int pipe;
int retval;
-   int i;
-   struct s2255_pipeinfo *pipe_info = dev-pipes;
+   struct s2255_pipeinfo *pipe_info = dev-pipe;
pipe = usb_rcvbulkpipe(dev-udev, dev-read_endpoint);
dprintk(2, start pipe IN %d\n, dev-read_endpoint);
+   pipe_info-state = 1;
+   pipe_info-err_count = 0;
+   pipe_info-stream_urb = usb_alloc_urb(0, GFP_KERNEL);
+   if (!pipe_info-stream_urb) {
+   dev_err(dev-udev-dev,
+   ReadStream: Unable to alloc URB\n);
+   return -ENOMEM;
+   }
+   /* transfer buffer allocated in board_init */
+   usb_fill_bulk_urb(pipe_info-stream_urb, dev-udev,
+ pipe,
+ pipe_info-transfer_buffer,
+ pipe_info-cur_transfer_size,
+ read_pipe_completion, pipe_info);
 
-   for (i = 0; i  MAX_PIPE_BUFFERS; i++) {
-   pipe_info-state = 1;
-   pipe_info-err_count = 0;
-   pipe_info-stream_urb = usb_alloc_urb(0, GFP_KERNEL);
-   if (!pipe_info-stream_urb) {
-   dev_err(dev-udev-dev,
-   ReadStream: Unable to alloc URB\n);
-   return -ENOMEM;
-   }
-   /* transfer buffer allocated in board_init */
-   usb_fill_bulk_urb(pipe_info-stream_urb, dev-udev,
- pipe,
- pipe_info-transfer_buffer,
- pipe_info-cur_transfer_size,
- read_pipe_completion, pipe_info);
-
-   dprintk(4, submitting URB %p\n, pipe_info-stream_urb

[PATCH] s2255drv: support for frame skipping

2010-03-08 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1268089334 28800
# Node ID 3ac8a7637cf3db984665e5aa43e03c22ee0c16f2
# Parent  08932f075cb147c47e2acc4b1f464c736080bc96
s2255drv: frame decimation support

From: Dean Anderson d...@sensoray.com

adds hardware frame skipping using VIDIOC_S_PARM ioctl.
adds support for VIDIOC_ENUM_FRAMEINTERVALS.

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r 08932f075cb1 -r 3ac8a7637cf3 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Fri Mar 05 14:55:23 2010 -0800
+++ b/linux/drivers/media/video/s2255drv.c  Mon Mar 08 15:02:14 2010 -0800
@@ -1427,11 +1427,19 @@
}
mode = fh-mode;
if (*i  V4L2_STD_NTSC) {
-   dprintk(4, vidioc_s_std NTSC\n);
-   mode-format = FORMAT_NTSC;
+   dprintk(4, %s NTSC\n, __func__);
+   /* if changing format, reset frame decimation/intervals */
+   if (mode-format != FORMAT_NTSC) {
+   mode-format = FORMAT_NTSC;
+   mode-fdec = FDEC_1;
+   }
} else if (*i  V4L2_STD_PAL) {
-   dprintk(4, vidioc_s_std PAL\n);
+   dprintk(4, %s PAL\n, __func__);
mode-format = FORMAT_PAL;
+   if (mode-format != FORMAT_PAL) {
+   mode-format = FORMAT_PAL;
+   mode-fdec = FDEC_1;
+   }
} else {
ret = -EINVAL;
}
@@ -1633,10 +1641,34 @@
 {
struct s2255_fh *fh = priv;
struct s2255_dev *dev = fh-dev;
+   __u32 def_num, def_dem;
if (sp-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
+   memset(sp, 0, sizeof(struct v4l2_streamparm));
+   sp-parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
sp-parm.capture.capturemode = dev-cap_parm[fh-channel].capturemode;
-   dprintk(2, getting parm %d\n, sp-parm.capture.capturemode);
+   def_num = (fh-mode.format == FORMAT_NTSC) ? 1001 : 1000;
+   def_dem = (fh-mode.format == FORMAT_NTSC) ? 3 : 25000;
+   sp-parm.capture.timeperframe.denominator = def_dem;
+   switch (fh-mode.fdec) {
+   default:
+   case FDEC_1:
+   sp-parm.capture.timeperframe.numerator = def_num;
+   break;
+   case FDEC_2:
+   sp-parm.capture.timeperframe.numerator = def_num * 2;
+   break;
+   case FDEC_3:
+   sp-parm.capture.timeperframe.numerator = def_num * 3;
+   break;
+   case FDEC_5:
+   sp-parm.capture.timeperframe.numerator = def_num * 5;
+   break;
+   }
+   dprintk(4, %s capture mode, %d timeperframe %d/%d\n, __func__,
+   sp-parm.capture.capturemode,
+   sp-parm.capture.timeperframe.numerator,
+   sp-parm.capture.timeperframe.denominator);
return 0;
 }
 
@@ -1645,15 +1677,79 @@
 {
struct s2255_fh *fh = priv;
struct s2255_dev *dev = fh-dev;
-
+   int fdec = FDEC_1;
+   __u32 def_num, def_dem;
if (sp-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
-
-   dev-cap_parm[fh-channel].capturemode = sp-parm.capture.capturemode;
-   dprintk(2, setting param capture mode %d\n,
-   sp-parm.capture.capturemode);
+   /* high quality capture mode requires a stream restart */
+   if (dev-cap_parm[fh-channel].capturemode
+   != sp-parm.capture.capturemode  res_locked(fh-dev, fh))
+   return -EBUSY;
+   def_num = (fh-mode.format == FORMAT_NTSC) ? 1001 : 1000;
+   def_dem = (fh-mode.format == FORMAT_NTSC) ? 3 : 25000;
+   if (def_dem != sp-parm.capture.timeperframe.denominator)
+   sp-parm.capture.timeperframe.numerator = def_num;
+   else if (sp-parm.capture.timeperframe.numerator = def_num)
+   sp-parm.capture.timeperframe.numerator = def_num;
+   else if (sp-parm.capture.timeperframe.numerator = (def_num * 2)) {
+   sp-parm.capture.timeperframe.numerator = def_num * 2;
+   fdec = FDEC_2;
+   } else if (sp-parm.capture.timeperframe.numerator = (def_num * 3)) {
+   sp-parm.capture.timeperframe.numerator = def_num * 3;
+   fdec = FDEC_3;
+   } else {
+   sp-parm.capture.timeperframe.numerator = def_num * 5;
+   fdec = FDEC_5;
+   }
+   fh-mode.fdec = fdec;
+   sp-parm.capture.timeperframe.denominator = def_dem;
+   s2255_set_mode(dev, fh-channel, fh-mode);
+   dprintk(4, %s capture mode, %d timeperframe %d/%d, fdec %d\n,
+   __func__,
+   sp-parm.capture.capturemode,
+   sp-parm.capture.timeperframe.numerator,
+   sp-parm.capture.timeperframe.denominator, fdec);
return 0;
 }
+
+static int vidioc_enum_frameintervals(struct file *file, void *priv

[PATCH] s2255drv: cleanup of V4L2 controls

2010-03-05 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1267809968 28800
# Node ID bdfee5ee52c800a24e1231cd52eeeb91636c013c
# Parent  ff343fa70b4def92d35f9ef7ee56a953b012d169
s2255drv cleanup of V4L2 video controls

From: Dean Anderson d...@sensoray.com

s2255drv cleanup of V4L2 video controls

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r ff343fa70b4d -r bdfee5ee52c8 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Thu Mar 04 15:43:28 2010 -0800
+++ b/linux/drivers/media/video/s2255drv.c  Fri Mar 05 09:26:08 2010 -0800
@@ -310,7 +310,7 @@
 /* Need DSP version 5+ for video status feature */
 #define S2255_MIN_DSP_STATUS5
 #define S2255_MAJOR_VERSION1
-#define S2255_MINOR_VERSION16
+#define S2255_MINOR_VERSION17
 #define S2255_RELEASE  0
 #define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
   S2255_MINOR_VERSION, \
@@ -384,49 +384,6 @@
 
 #define BUFFER_TIMEOUT msecs_to_jiffies(400)
 
-/* supported controls */
-static struct v4l2_queryctrl s2255_qctrl[] = {
-   {
-   .id = V4L2_CID_BRIGHTNESS,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   .name = Brightness,
-   .minimum = -127,
-   .maximum = 128,
-   .step = 1,
-   .default_value = 0,
-   .flags = 0,
-   }, {
-   .id = V4L2_CID_CONTRAST,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   .name = Contrast,
-   .minimum = 0,
-   .maximum = 255,
-   .step = 0x1,
-   .default_value = DEF_CONTRAST,
-   .flags = 0,
-   }, {
-   .id = V4L2_CID_SATURATION,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   .name = Saturation,
-   .minimum = 0,
-   .maximum = 255,
-   .step = 0x1,
-   .default_value = DEF_SATURATION,
-   .flags = 0,
-   }, {
-   .id = V4L2_CID_HUE,
-   .type = V4L2_CTRL_TYPE_INTEGER,
-   .name = Hue,
-   .minimum = 0,
-   .maximum = 255,
-   .step = 0x1,
-   .default_value = DEF_HUE,
-   .flags = 0,
-   }
-};
-
-static int qctl_regs[ARRAY_SIZE(s2255_qctrl)];
-
 /* image formats.  */
 static const struct s2255_fmt formats[] = {
{
@@ -1472,74 +1429,82 @@
 static int vidioc_queryctrl(struct file *file, void *priv,
struct v4l2_queryctrl *qc)
 {
-   int i;
-
-   for (i = 0; i  ARRAY_SIZE(s2255_qctrl); i++)
-   if (qc-id  qc-id == s2255_qctrl[i].id) {
-   memcpy(qc, (s2255_qctrl[i]), sizeof(*qc));
-   return 0;
-   }
-
-   dprintk(4, query_ctrl -EINVAL %d\n, qc-id);
-   return -EINVAL;
+   switch (qc-id) {
+   case V4L2_CID_BRIGHTNESS:
+   v4l2_ctrl_query_fill(qc, -127, 127, 1, DEF_BRIGHT);
+   break;
+   case V4L2_CID_CONTRAST:
+   v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_CONTRAST);
+   break;
+   case V4L2_CID_SATURATION:
+   v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_SATURATION);
+   break;
+   case V4L2_CID_HUE:
+   v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_HUE);
+   break;
+   default:
+   return -EINVAL;
+   }
+   dprintk(4, %s, id %d\n, __func__, qc-id);
+   return 0;
 }
 
 static int vidioc_g_ctrl(struct file *file, void *priv,
 struct v4l2_control *ctrl)
 {
-   int i;
-
-   for (i = 0; i  ARRAY_SIZE(s2255_qctrl); i++)
-   if (ctrl-id == s2255_qctrl[i].id) {
-   ctrl-value = qctl_regs[i];
-   return 0;
-   }
-   dprintk(4, g_ctrl -EINVAL\n);
-
-   return -EINVAL;
+   struct s2255_fh *fh = priv;
+   switch (ctrl-id) {
+   case V4L2_CID_BRIGHTNESS:
+   ctrl-value = fh-mode.bright;
+   break;
+   case V4L2_CID_CONTRAST:
+   ctrl-value = fh-mode.contrast;
+   break;
+   case V4L2_CID_SATURATION:
+   ctrl-value = fh-mode.saturation;
+   break;
+   case V4L2_CID_HUE:
+   ctrl-value = fh-mode.hue;
+   break;
+   default:
+   return -EINVAL;
+   }
+   dprintk(4, %s, id %d val %d\n, __func__, ctrl-id, ctrl-value);
+   return 0;
 }
 
 static int vidioc_s_ctrl(struct file *file, void *priv,
 struct v4l2_control *ctrl)
 {
-   int i;
struct s2255_fh *fh = priv;
struct s2255_dev *dev = fh-dev;
struct s2255_mode *mode;
mode = fh-mode;
-   dprintk(4, vidioc_s_ctrl\n);
-   for (i = 0; i  ARRAY_SIZE(s2255_qctrl); i++) {
-   if (ctrl-id == s2255_qctrl[i].id) {
-   if (ctrl-value  s2255_qctrl[i].minimum ||
-   ctrl-value  s2255_qctrl[i].maximum)
-   return -ERANGE;
-
-   qctl_regs[i] = ctrl-value

[PATCH] s2255drv: support for 2257 device

2010-03-05 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1267829723 28800
# Node ID 54b44c52d908b363f69488fed84f1e8b9ccaf038
# Parent  bdfee5ee52c800a24e1231cd52eeeb91636c013c
s2255drv: support for 2257 device

From: Dean Anderson d...@sensoray.com

2257 is 2255 with 2 svideo inputs

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r bdfee5ee52c8 -r 54b44c52d908 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Fri Mar 05 09:26:08 2010 -0800
+++ b/linux/drivers/media/video/s2255drv.c  Fri Mar 05 14:55:23 2010 -0800
@@ -120,9 +120,10 @@
 #define COLOR_YUVPK2   /* YUV packed */
 #define COLOR_Y8   4   /* monochrome */
 #define COLOR_JPG   5   /* JPEG */
-#define MASK_COLOR  0xff
-#define MASK_JPG_QUALITY 0xff00
 
+#define MASK_COLOR   0x00ff
+#define MASK_JPG_QUALITY 0xff00
+#define MASK_INPUT_TYPE  0x000f
 /* frame decimation. Not implemented by V4L yet(experimental in V4L) */
 #define FDEC_1 1   /* capture every frame. default */
 #define FDEC_2 2   /* capture every 2nd frame */
@@ -196,7 +197,6 @@
 #define S2255_FW_SUCCESS   2
 #define S2255_FW_FAILED3
 #define S2255_FW_DISCONNECTING  4
-
 #define S2255_FW_MARKERcpu_to_le32(0x22552f2f)
 /* 2255 read states */
 #define S2255_READ_IDLE 0
@@ -267,12 +267,12 @@
int vidstatus[MAX_CHANNELS];
wait_queue_head_t   wait_vidstatus[MAX_CHANNELS];
int vidstatus_ready[MAX_CHANNELS];
-
int chn_ready;
-   struct kref kref;
spinlock_t  slock;
/* dsp firmware version (f2255usb.bin) */
int dsp_fw_ver;
+   u16 pid; /* product id */
+   struct kref kref;
 };
 #define to_s2255_dev(d) container_of(d, struct s2255_dev, kref)
 
@@ -306,20 +306,49 @@
 /* current cypress EEPROM firmware version */
 #define S2255_CUR_USB_FWVER((3  8) | 6)
 /* current DSP FW version */
-#define S2255_CUR_DSP_FWVER 5
+#define S2255_CUR_DSP_FWVER 8
 /* Need DSP version 5+ for video status feature */
-#define S2255_MIN_DSP_STATUS5
+#define S2255_MIN_DSP_STATUS  5
+#define S2255_MIN_DSP_COLORFILTER 8
 #define S2255_MAJOR_VERSION1
-#define S2255_MINOR_VERSION17
+#define S2255_MINOR_VERSION18
 #define S2255_RELEASE  0
 #define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
   S2255_MINOR_VERSION, \
   S2255_RELEASE)
 
-/* vendor ids */
-#define USB_S2255_VENDOR_ID0x1943
-#define USB_S2255_PRODUCT_ID   0x2255
 #define S2255_NORMS(V4L2_STD_PAL | V4L2_STD_NTSC)
+
+/* private V4L2 controls */
+
+/*
+ * The following chart displays how COLORFILTER should be set
+ *  =
+ *  = fourcc  = COLORFILTER =
+ *  = ===
+ *  = =   0 =1  =
+ *  =
+ *  =  V4L2_PIX_FMT_GREY(Y8)  = monochrome from = monochrome=
+ *  = = s-video or  = composite =
+ *  = = B/W camera  = input =
+ *  =
+ *  =other= color, svideo   = color,=
+ *  = = = composite =
+ *  =
+ *
+ * Notes:
+ *   channels 0-3 on 2255 are composite
+ *   channels 0-1 on 2257 are composite, 2-3 are s-video
+ * If COLORFILTER is 0 with a composite color camera connected,
+ * the output will appear monochrome but hatching
+ * will occur.
+ * COLORFILTER is different from color killer and color effects
+ * for reasons above.
+ */
+#define S2255_V4L2_YC_ON  1
+#define S2255_V4L2_YC_OFF 0
+#define V4L2_CID_PRIVATE_COLORFILTER (V4L2_CID_PRIVATE_BASE + 0)
+
 /* frame prefix size (sent once every frame) */
 #define PREFIX_SIZE512
 
@@ -360,7 +389,6 @@
 
 static struct usb_driver s2255_driver;
 
-
 /* Declare static vars that will be used as parameters */
 static unsigned int vid_limit = 16;/* Video memory limit, in Mb */
 
@@ -375,13 +403,14 @@
 MODULE_PARM_DESC(video_nr, start video minor(-1 default autodetect));
 
 /* USB device table */
+#define USB_SENSORAY_VID   0x1943
 static struct usb_device_id s2255_table[] = {
-   {USB_DEVICE(USB_S2255_VENDOR_ID, USB_S2255_PRODUCT_ID)},
+   {USB_DEVICE(USB_SENSORAY_VID, 0x2255)},
+   {USB_DEVICE(USB_SENSORAY_VID, 0x2257)}, /*same family as 2255*/
{ } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, s2255_table);
 
-
 #define BUFFER_TIMEOUT msecs_to_jiffies(400

[PATCH] s2255drv: fixes for big endian arch

2010-03-04 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1267746208 28800
# Node ID ff343fa70b4def92d35f9ef7ee56a953b012d169
# Parent  c9c1bcda21557cea425589f281b6b3100e2c15a0
s2255drv: fixes for big endian arch

From: Dean Anderson d...@sensoray.com

s2255drv fixes for big endian architecture

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r c9c1bcda2155 -r ff343fa70b4d linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Wed Mar 03 14:28:53 2010 -0800
+++ b/linux/drivers/media/video/s2255drv.c  Thu Mar 04 15:43:28 2010 -0800
@@ -78,11 +78,11 @@
 #define S2255_SETMODE_TIMEOUT   500
 #define S2255_VIDSTATUS_TIMEOUT 350
 #define MAX_CHANNELS   4
-#define S2255_MARKER_FRAME 0x2255DA4AL
-#define S2255_MARKER_RESPONSE  0x2255ACACL
-#define S2255_RESPONSE_SETMODE  0x01
-#define S2255_RESPONSE_FW   0x10
-#define S2255_RESPONSE_STATUS   0x20
+#define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL)
+#define S2255_MARKER_RESPONSE  cpu_to_le32(0x2255ACACL)
+#define S2255_RESPONSE_SETMODE  cpu_to_le32(0x01)
+#define S2255_RESPONSE_FW   cpu_to_le32(0x10)
+#define S2255_RESPONSE_STATUS   cpu_to_le32(0x20)
 #define S2255_USB_XFER_SIZE(16 * 1024)
 #define MAX_CHANNELS   4
 #define MAX_PIPE_BUFFERS   1
@@ -141,12 +141,12 @@
 #define DEF_HUE0
 
 /* usb config commands */
-#define IN_DATA_TOKEN  0x2255c0de
-#define CMD_2255   0xc2255000
-#define CMD_SET_MODE   (CMD_2255 | 0x10)
-#define CMD_START  (CMD_2255 | 0x20)
-#define CMD_STOP   (CMD_2255 | 0x30)
-#define CMD_STATUS (CMD_2255 | 0x40)
+#define IN_DATA_TOKEN  cpu_to_le32(0x2255c0de)
+#define CMD_2255   cpu_to_le32(0xc2255000)
+#define CMD_SET_MODE   cpu_to_le32((CMD_2255 | 0x10))
+#define CMD_START  cpu_to_le32((CMD_2255 | 0x20))
+#define CMD_STOP   cpu_to_le32((CMD_2255 | 0x30))
+#define CMD_STATUS cpu_to_le32((CMD_2255 | 0x40))
 
 struct s2255_mode {
u32 format; /* input video format (NTSC, PAL) */
@@ -310,7 +310,7 @@
 /* Need DSP version 5+ for video status feature */
 #define S2255_MIN_DSP_STATUS5
 #define S2255_MAJOR_VERSION1
-#define S2255_MINOR_VERSION15
+#define S2255_MINOR_VERSION16
 #define S2255_RELEASE  0
 #define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
   S2255_MINOR_VERSION, \
@@ -1219,9 +1219,8 @@
  struct s2255_mode *mode)
 {
int res;
-   u32 *buffer;
+   __le32 *buffer;
unsigned long chn_rev;
-
mutex_lock(dev-lock);
chn_rev = G_chnmap[chn];
dprintk(3, mode scale [%ld] %p %d\n, chn, mode, mode-scale);
@@ -1247,7 +1246,7 @@
 
/* set the mode */
buffer[0] = IN_DATA_TOKEN;
-   buffer[1] = (u32) chn_rev;
+   buffer[1] = (__le32) cpu_to_le32(chn_rev);
buffer[2] = CMD_SET_MODE;
memcpy(buffer[3], dev-mode[chn], sizeof(struct s2255_mode));
dev-setmode_ready[chn] = 0;
@@ -1278,7 +1277,7 @@
u32 *pstatus)
 {
int res;
-   u32 *buffer;
+   __le32 *buffer;
u32 chn_rev;
mutex_lock(dev-lock);
chn_rev = G_chnmap[chn];
@@ -1291,7 +1290,7 @@
}
/* form the get vid status command */
buffer[0] = IN_DATA_TOKEN;
-   buffer[1] = chn_rev;
+   buffer[1] = (__le32) cpu_to_le32(chn_rev);
buffer[2] = CMD_STATUS;
*pstatus = 0;
dev-vidstatus_ready[chn] = 0;
@@ -1971,14 +1970,14 @@
if (frm-ulState == S2255_READ_IDLE) {
int jj;
unsigned int cc;
-   s32 *pdword;
+   __le32 *pdword; /*data from dsp is little endian */
int payload;
/* search for marker codes */
pdata = (unsigned char *)pipe_info-transfer_buffer;
+   pdword = (__le32 *)pdata;
for (jj = 0; jj  (pipe_info-cur_transfer_size - 12); jj++) {
-   switch (*(s32 *) pdata) {
+   switch (*pdword) {
case S2255_MARKER_FRAME:
-   pdword = (s32 *)pdata;
dprintk(4, found frame marker at offset:
 %d [%x %x]\n, jj, pdata[0],
pdata[1]);
@@ -2002,7 +2001,6 @@
dev-jpg_size[dev-cc] = pdword[4];
break;
case S2255_MARKER_RESPONSE:
-   pdword = (s32 *)pdata;
pdata += DEF_USB_BLOCK;
jj += DEF_USB_BLOCK;
if (pdword[1] = MAX_CHANNELS)
@@ -2437,9 +2435,9 @@
}
 
/* send the start command */
-   *(u32 *) buffer = IN_DATA_TOKEN;
-   *((u32 *) buffer + 1) = (u32) chn_rev;
-   *((u32 *) buffer

[PATCH] s2255drv : adding video input status capability

2010-03-03 Thread Dean A.
# HG changeset patch
# User Dean Anderson d...@sensoray.com
# Date 1267655333 28800
# Node ID 3bf09a2ab1100269d6424c487ca98a1b1e4ead54
# Parent  5e0d6be7f020d6c0741795b0bd039ace7d54d310
Adds video status capability to 2255 driver

From: Dean Anderson d...@sensoray.com

Video status capability for inputs on Sensoray 2255 driver.

Priority: normal

Signed-off-by: Dean Anderson d...@sensoray.com

diff -r 5e0d6be7f020 -r 3bf09a2ab110 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Wed Mar 03 18:34:32 2010 -0300
+++ b/linux/drivers/media/video/s2255drv.c  Wed Mar 03 14:28:53 2010 -0800
@@ -1,7 +1,7 @@
 /*
  *  s2255drv.c - a driver for the Sensoray 2255 USB video capture device
  *
- *   Copyright (C) 2007-2008 by Sensoray Company Inc.
+ *   Copyright (C) 2007-2010 by Sensoray Company Inc.
  *  Dean Anderson
  *
  * Some video buffer code based on vivi driver:
@@ -76,11 +76,13 @@
 #define S2255_LOAD_TIMEOUT  (5000 + S2255_DSP_BOOTTIME)
 #define S2255_DEF_BUFS  16
 #define S2255_SETMODE_TIMEOUT   500
+#define S2255_VIDSTATUS_TIMEOUT 350
 #define MAX_CHANNELS   4
 #define S2255_MARKER_FRAME 0x2255DA4AL
 #define S2255_MARKER_RESPONSE  0x2255ACACL
 #define S2255_RESPONSE_SETMODE  0x01
 #define S2255_RESPONSE_FW   0x10
+#define S2255_RESPONSE_STATUS   0x20
 #define S2255_USB_XFER_SIZE(16 * 1024)
 #define MAX_CHANNELS   4
 #define MAX_PIPE_BUFFERS   1
@@ -261,9 +263,16 @@
int chn_configured[MAX_CHANNELS];
wait_queue_head_t   wait_setmode[MAX_CHANNELS];
int setmode_ready[MAX_CHANNELS];
+   /* video status items */
+   int vidstatus[MAX_CHANNELS];
+   wait_queue_head_t   wait_vidstatus[MAX_CHANNELS];
+   int vidstatus_ready[MAX_CHANNELS];
+
int chn_ready;
struct kref kref;
spinlock_t  slock;
+   /* dsp firmware version (f2255usb.bin) */
+   int dsp_fw_ver;
 };
 #define to_s2255_dev(d) container_of(d, struct s2255_dev, kref)
 
@@ -296,8 +305,12 @@
 
 /* current cypress EEPROM firmware version */
 #define S2255_CUR_USB_FWVER((3  8) | 6)
+/* current DSP FW version */
+#define S2255_CUR_DSP_FWVER 5
+/* Need DSP version 5+ for video status feature */
+#define S2255_MIN_DSP_STATUS5
 #define S2255_MAJOR_VERSION1
-#define S2255_MINOR_VERSION14
+#define S2255_MINOR_VERSION15
 #define S2255_RELEASE  0
 #define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
   S2255_MINOR_VERSION, \
@@ -1261,6 +1274,42 @@
return res;
 }
 
+static int s2255_cmd_status(struct s2255_dev *dev, unsigned long chn,
+   u32 *pstatus)
+{
+   int res;
+   u32 *buffer;
+   u32 chn_rev;
+   mutex_lock(dev-lock);
+   chn_rev = G_chnmap[chn];
+   dprintk(4, %s chan %d\n, __func__, chn_rev);
+   buffer = kzalloc(512, GFP_KERNEL);
+   if (buffer == NULL) {
+   dev_err(dev-udev-dev, out of mem\n);
+   mutex_unlock(dev-lock);
+   return -ENOMEM;
+   }
+   /* form the get vid status command */
+   buffer[0] = IN_DATA_TOKEN;
+   buffer[1] = chn_rev;
+   buffer[2] = CMD_STATUS;
+   *pstatus = 0;
+   dev-vidstatus_ready[chn] = 0;
+   res = s2255_write_config(dev-udev, (unsigned char *)buffer, 512);
+   kfree(buffer);
+   wait_event_timeout(dev-wait_vidstatus[chn],
+  (dev-vidstatus_ready[chn] != 0),
+  msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT));
+   if (dev-vidstatus_ready[chn] != 1) {
+   printk(KERN_DEBUG s2255: no vidstatus response\n);
+   res = -EFAULT;
+   }
+   *pstatus = dev-vidstatus[chn];
+   dprintk(4, %s, vid status %d\n, __func__, *pstatus);
+   mutex_unlock(dev-lock);
+   return res;
+}
+
 static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
 {
int res;
@@ -1386,11 +1435,24 @@
 static int vidioc_enum_input(struct file *file, void *priv,
 struct v4l2_input *inp)
 {
+   struct s2255_fh *fh = priv;
+   struct s2255_dev *dev = fh-dev;
+   u32 status = 0;
+
if (inp-index != 0)
return -EINVAL;
 
inp-type = V4L2_INPUT_TYPE_CAMERA;
inp-std = S2255_NORMS;
+   inp-status = 0;
+   if (dev-dsp_fw_ver = S2255_MIN_DSP_STATUS) {
+   int rc;
+   rc = s2255_cmd_status(dev, fh-channel, status);
+   dprintk(4, s2255_cmd_status rc: %d status %x\n, rc, status);
+   if (rc == 0)
+   inp-status =  (status  0x01) ? 0
+   : V4L2_IN_ST_NO_SIGNAL;
+   }
strlcpy(inp-name, Camera, sizeof(inp-name

OnAir USB HDTV Creator

2010-02-26 Thread Dean
I am trying to use an 'OnAir USB HDTV Creator' (from autumnwave.com).  
According to
http://www.linuxtv.org/wiki/index.php/OnAir_USB_HDTV_Creator
This device is supported, however it's not working for me.  Following the 
instructions at above link, I tried this:
modprobe pvrusb2 initusbreset=0

The result:
FATAL: Error inserting pvrusb2 
(/lib/modules/2.6.31.12-desktop586-1mnb/kernel/drivers/media/video/pvrusb2/pvrusb2.ko.gz):
 Unknown symbol in module, or unknown parameter (see dmesg)

When connecting the unit, dmesg shows only these six lines.

usb 1-3: new high speed USB device using ehci_hcd and address 10
usb 1-3: New USB device found, idVendor=11ba, idProduct=1101
usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-3: Product: USB HDTV-GT(1.1)
usb 1-3: Manufacturer: OnAirSolution
usb 1-3: configuration #1 chosen from 1 choice

Anyone know what to do?
--
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: eb1a:2860 eMPIA em28xx device to usb1 ??? usb hub problem?

2010-02-23 Thread Dean
Devin Heitmueller wrote:
 On Tue, Feb 23, 2010 at 1:37 AM, Dean r...@linuxstation.net wrote:
 Hi,

 I have the KWorld DVB-T 305U, an em28xx device.  Only the video works for me 
 under Linux, no audio.  In case anyone wants to see it, I have attached the 
 full dmesg text, solely from this device.

 Cheers,
 Dean
 
 Hi Dean,
 
 How are you testing the audio, and under what video standard are you
 trying to use the device (NTSC/PAL/SECAM)?
 
 Devin


Devin

I am receiving NTSC TV signals.  I test with mplayer.  Example;

mplayer tv://9 -tv 
driver=v4l2:alsa:immediatemode=0:adevice=hw.Em28xxAudio,0:norm=ntsc:chanlist=us-cable
 -vf pp=ci

The above command works fine (both audio and video) with my Hauppauge HVR-850, 
but for the Kworld 305U I must change 'immediatemode=0' to 'immediatemode=1' 
otherwise the video frame rate is about 1/2 normal speed and about 1 minute 
later mplayer starts printing 'video buffer full - dropping frame'.

According to dmesg the Kworld 305U loads the same firmware as my Hauppauge 
HVR-850, and (during separate test sessions) installs the same ALSA device;

card 1: Em28xxAudio [Em28xx Audio], device 0: Em28xx Audio [Empia 28xx Capture]
  Subdevices: 0/1
  Subdevice #0: subdevice #0


Dean
--
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: eb1a:2860 eMPIA em28xx device to usb1 ??? usb hub problem?

2010-02-22 Thread Dean
Hi,

I have the KWorld DVB-T 305U, an em28xx device.  Only the video works for me 
under Linux, no audio.  In case anyone wants to see it, I have attached the 
full dmesg text, solely from this device.

Cheers,
Dean


Devin Heitmueller wrote:
 
 Also, please provide the *full* dmesg output, so we have more context
 information about the system (things such as the kernel version, etc).
 
 Cheers,
 
 Devin
 


em28xx_KWorld_DVB-T_305U_dmesg.txt.gz
Description: GNU Zip compressed data


KWorld DVB-T 305U now working

2010-02-14 Thread Dean
My dmesg gave the following (excerpt) when I connected my KWorld 305U.

em28xx #0: Identified as KWorld DVB-T 305U (card=47)
em28xx #0: 

em28xx #0: The support for this board weren't valid yet.
em28xx #0: Please send a report of having this working
em28xx #0: not to V4L mailing list (and/or to other addresses)

So here I am, making this announcement.  Do I even have the correct mailing 
list?  What is the next step towards re-classifying the KWorld 305U as a 
supported device?

Regards.
--
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: [PATCH] s2255drv: Don't conditionalize video buffer completion on waiting processes

2009-09-23 Thread dean
This seems ok.  This portion of code was based on vivi.c, so that might 
be checked also.




Mike Isely wrote:

# HG changeset patch
# User Mike Isely is...@pobox.com
# Date 1253739604 18000
# Node ID 522a74147753ba59c7f45e368439928090a286f2
# Parent  e349075171ddf939381fad432c23c1269abc4899
s2255drv: Don't conditionalize video buffer completion on waiting processes

From: Mike Isely is...@pobox.com

The s2255 driver had logic which aborted processing of a video frame
if there was no process waiting on the video buffer in question.  That
simply doesn't work when the application is doing things in an
asynchronous manner.  If the application went to the trouble to queue
the buffer in the first place, then the driver should always attempt
to complete it - even if the application at that moment has its
attention turned elsewhere.  Applications which always blocked waiting
for I/O on the capture device would not have been affected by this.
Applications which *mostly* blocked waiting for I/O on the capture
device probably only would have been somewhat affected (frame lossage,
at a rate which goes up as the application blocks less).  Applications
which never blocked on the capture device (e.g. polling only) however
would never have been able to receive any video frames, since in that
case this is anyone waiting on this? check on the buffer never would
have evalutated true.  This patch just deletes that harmful check
against the buffer's wait queue.

Priority: high

Signed-off-by: Mike Isely is...@pobox.com

diff -r e349075171dd -r 522a74147753 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Mon Sep 21 10:42:22 2009 -0500
+++ b/linux/drivers/media/video/s2255drv.c  Wed Sep 23 16:00:04 2009 -0500
@@ -599,11 +599,6 @@
buf = list_entry(dma_q-active.next,
 struct s2255_buffer, vb.queue);
 
-	if (!waitqueue_active(buf-vb.done)) {

-   /* no one active */
-   rc = -1;
-   goto unlock;
-   }
list_del(buf-vb.queue);
do_gettimeofday(buf-vb.ts);
dprintk(100, [%p/%d] wakeup\n, buf, buf-vb.i);


  


--
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: s2255drv: adding V4L2_MODE_HIGHQUALITY

2009-05-15 Thread Dean A.
From: Dean Anderson d...@sensoray.com

Adding V4L2_MODE_HIGHQUALITY feature.

Signed-off-by: Dean Anderson d...@sensoray.com

--- v4l-dvb-0018ed9bbca3/linux/drivers/media/video/s2255drv.c.orig  
2009-05-15 10:15:36.0 -0700
+++ v4l-dvb-0018ed9bbca3/linux/drivers/media/video/s2255drv.c   2009-05-15 
10:20:43.0 -0700
@@ -110,6 +110,8 @@
 #define SCALE_4CIFS1   /* 640x480(NTSC) or 704x576(PAL) */
 #define SCALE_2CIFS2   /* 640x240(NTSC) or 704x288(PAL) */
 #define SCALE_1CIFS3   /* 320x240(NTSC) or 352x288(PAL) */
+/* SCALE_4CIFSI is the 2 fields interpolated into one */
+#define SCALE_4CIFSI   4   /* 640x480(NTSC) or 704x576(PAL) high quality */
 
 #define COLOR_YUVPL1   /* YUV planar */
 #define COLOR_YUVPK2   /* YUV packed */
@@ -239,6 +241,8 @@
struct s2255_mode   mode[MAX_CHANNELS];
/* jpeg compression */
struct v4l2_jpegcompression jc[MAX_CHANNELS];
+   /* capture parameters (for high quality mode full size) */
+   struct v4l2_captureparm cap_parm[MAX_CHANNELS];
const struct s2255_fmt  *cur_fmt[MAX_CHANNELS];
int cur_frame[MAX_CHANNELS];
int last_frame[MAX_CHANNELS];
@@ -1021,9 +1025,16 @@
fh-type = f-type;
norm = norm_minw(fh-dev-vdev[fh-channel]);
if (fh-width  norm_minw(fh-dev-vdev[fh-channel])) {
-   if (fh-height  norm_minh(fh-dev-vdev[fh-channel]))
-   fh-mode.scale = SCALE_4CIFS;
-   else
+   if (fh-height  norm_minh(fh-dev-vdev[fh-channel])) {
+   if (fh-dev-cap_parm[fh-channel].capturemode 
+   V4L2_MODE_HIGHQUALITY) {
+   fh-mode.scale = SCALE_4CIFSI;
+   dprintk(2, scale 4CIFSI\n);
+   } else {
+   fh-mode.scale = SCALE_4CIFS;
+   dprintk(2, scale 4CIFS\n);
+   }
+   } else
fh-mode.scale = SCALE_2CIFS;
 
} else {
@@ -1124,6 +1135,7 @@
if (mode-format == FORMAT_NTSC) {
switch (mode-scale) {
case SCALE_4CIFS:
+   case SCALE_4CIFSI:
linesPerFrame = NUM_LINES_4CIFS_NTSC * 2;
pixelsPerLine = LINE_SZ_4CIFS_NTSC;
break;
@@ -1141,6 +1153,7 @@
} else if (mode-format == FORMAT_PAL) {
switch (mode-scale) {
case SCALE_4CIFS:
+   case SCALE_4CIFSI:
linesPerFrame = NUM_LINES_4CIFS_PAL * 2;
pixelsPerLine = LINE_SZ_4CIFS_PAL;
break;
@@ -1496,6 +1509,33 @@
dprintk(2, setting jpeg quality %d\n, jc-quality);
return 0;
 }
+
+static int vidioc_g_parm(struct file *file, void *priv,
+struct v4l2_streamparm *sp)
+{
+   struct s2255_fh *fh = priv;
+   struct s2255_dev *dev = fh-dev;
+   if (sp-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+   sp-parm.capture.capturemode = dev-cap_parm[fh-channel].capturemode;
+   dprintk(2, getting parm %d\n, sp-parm.capture.capturemode);
+   return 0;
+}
+
+static int vidioc_s_parm(struct file *file, void *priv,
+struct v4l2_streamparm *sp)
+{
+   struct s2255_fh *fh = priv;
+   struct s2255_dev *dev = fh-dev;
+
+   if (sp-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   return -EINVAL;
+
+   dev-cap_parm[fh-channel].capturemode = sp-parm.capture.capturemode;
+   dprintk(2, setting param capture mode %d\n,
+   sp-parm.capture.capturemode);
+   return 0;
+}
 static int s2255_open(struct file *file)
 {
int minor = video_devdata(file)-minor;
@@ -1787,6 +1827,8 @@
 #endif
.vidioc_s_jpegcomp = vidioc_s_jpegcomp,
.vidioc_g_jpegcomp = vidioc_g_jpegcomp,
+   .vidioc_s_parm = vidioc_s_parm,
+   .vidioc_g_parm = vidioc_g_parm,
 };
 
 static struct video_device template = {

--
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: s2255drv: urb completion routine fixes

2009-04-30 Thread Dean A.
From: Dean Anderson d...@sensoray.com

Error count in read pipe completion corrected.
URB not resubmitted if shutting down.
URB not freed in completion routine if new urb_submit_fails.
(URB is freed on shutdown).

Signed-off-by: Dean Anderson d...@sensoray.com

--- v4l-dvb-83712d149893/linux/drivers/media/video/s2255drv.c.orig  
2009-04-30 07:34:34.0 -0700
+++ v4l-dvb-83712d149893/linux/drivers/media/video/s2255drv.c   2009-04-30 
07:27:10.0 -0700
@@ -2240,8 +2240,10 @@ static void read_pipe_completion(struct 
return;
}
status = purb-status;
-   if (status != 0) {
-   dprintk(2, read_pipe_completion: err\n);
+   /* if shutting down, do not resubmit, exit immediately */
+   if (status == -ESHUTDOWN) {
+   dprintk(2, read_pipe_completion: err shutdown\n);
+   pipe_info-err_count++;
return;
}
 
@@ -2250,9 +2252,13 @@ static void read_pipe_completion(struct 
return;
}
 
-   s2255_read_video_callback(dev, pipe_info);
+   if (status == 0)
+   s2255_read_video_callback(dev, pipe_info);
+   else {
+   pipe_info-err_count++;
+   dprintk(1, s2255drv: failed URB %d\n, status);
+   }
 
-   pipe_info-err_count = 0;
pipe = usb_rcvbulkpipe(dev-udev, dev-read_endpoint);
/* reuse urb */
usb_fill_bulk_urb(pipe_info-stream_urb, dev-udev,
@@ -2264,7 +2270,6 @@ static void read_pipe_completion(struct 
if (pipe_info-state != 0) {
if (usb_submit_urb(pipe_info-stream_urb, GFP_KERNEL)) {
dev_err(dev-udev-dev, error submitting urb\n);
-   usb_free_urb(pipe_info-stream_urb);
}
} else {
dprintk(2, read pipe complete state 0\n);

--
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: s2255drv: code cleanup

2009-04-23 Thread Dean A.
From: Dean Anderson d...@sensoray.com

Removal of unused structure items. Response values defined. Driver revision 
printk.

Signed-off-by: Dean Anderson d...@sensoray.com

--- v4l-dvb-ebb7b82f2b48/linux/drivers/media/video/s2255drv.c.orig  
2009-04-23 11:37:28.0 -0700
+++ v4l-dvb-ebb7b82f2b48/linux/drivers/media/video/s2255drv.c   2009-04-23 
11:54:24.0 -0700
@@ -78,6 +78,8 @@
 #define MAX_CHANNELS   4
 #define S2255_MARKER_FRAME 0x2255DA4AL
 #define S2255_MARKER_RESPONSE  0x2255ACACL
+#define S2255_RESPONSE_SETMODE  0x01
+#define S2255_RESPONSE_FW   0x10
 #define S2255_USB_XFER_SIZE(16 * 1024)
 #define MAX_CHANNELS   4
 #define MAX_PIPE_BUFFERS   1
@@ -179,9 +181,6 @@ struct s2255_bufferi {
 
 struct s2255_dmaqueue {
struct list_headactive;
-   /* thread for acquisition */
-   struct task_struct  *kthread;
-   int frame;
struct s2255_dev*dev;
int channel;
 };
@@ -211,16 +210,11 @@ struct s2255_pipeinfo {
u32 max_transfer_size;
u32 cur_transfer_size;
u8 *transfer_buffer;
-   u32 transfer_flags;;
u32 state;
-   u32 prev_state;
-   u32 urb_size;
void *stream_urb;
void *dev;  /* back pointer to s2255_dev struct*/
u32 err_count;
-   u32 buf_index;
u32 idx;
-   u32 priority_set;
 };
 
 struct s2255_fmt; /*forward declaration */
@@ -240,8 +234,6 @@ struct s2255_dev {
struct list_heads2255_devlist;
struct timer_list   timer;
struct s2255_fw *fw_data;
-   int board_num;
-   int is_open;
struct s2255_pipeinfo   pipes[MAX_PIPE_BUFFERS];
struct s2255_bufferibuffer[MAX_CHANNELS];
struct s2255_mode   mode[MAX_CHANNELS];
@@ -298,9 +290,10 @@ struct s2255_fh {
int resources[MAX_CHANNELS];
 };
 
-#define CUR_USB_FWVER  774 /* current cypress EEPROM firmware version */
+/* current cypress EEPROM firmware version */
+#define S2255_CUR_USB_FWVER((3  8) | 6)
 #define S2255_MAJOR_VERSION1
-#define S2255_MINOR_VERSION13
+#define S2255_MINOR_VERSION14
 #define S2255_RELEASE  0
 #define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
   S2255_MINOR_VERSION, \
@@ -1819,7 +1812,6 @@ static int s2255_probe_v4l(struct s2255_
INIT_LIST_HEAD(dev-vidq[i].active);
dev-vidq[i].dev = dev;
dev-vidq[i].channel = i;
-   dev-vidq[i].kthread = NULL;
/* register 4 video devices */
dev-vdev[i] = video_device_alloc();
memcpy(dev-vdev[i], template, sizeof(struct video_device));
@@ -1840,7 +1832,9 @@ static int s2255_probe_v4l(struct s2255_
return ret;
}
}
-   printk(KERN_INFO Sensoray 2255 V4L driver\n);
+   printk(KERN_INFO Sensoray 2255 V4L driver Revision: %d.%d\n,
+  S2255_MAJOR_VERSION,
+  S2255_MINOR_VERSION);
return ret;
 }
 
@@ -1930,14 +1924,14 @@ static int save_frame(struct s2255_dev *
if (!(cc = 0  cc  MAX_CHANNELS))
break;
switch (pdword[2]) {
-   case 0x01:
+   case S2255_RESPONSE_SETMODE:
/* check if channel valid */
/* set mode ready */
dev-setmode_ready[cc] = 1;
wake_up(dev-wait_setmode[cc]);
dprintk(5, setmode ready %d\n, cc);
break;
-   case 0x10:
+   case S2255_RESPONSE_FW:
 
dev-chn_ready |= (1  cc);
if ((dev-chn_ready  0x0f) != 0x0f)
@@ -2173,10 +2167,15 @@ static int s2255_board_init(struct s2255
/* query the firmware */
fw_ver = s2255_get_fx2fw(dev);
 
-   printk(KERN_INFO 2255 usb firmware version %d \n, fw_ver);
-   if (fw_ver  CUR_USB_FWVER)
+   printk(KERN_INFO 2255 usb firmware version %d.%d\n,
+  (fw_ver  8)  0xff,
+  fw_ver  0xff);
+
+   if (fw_ver  S2255_CUR_USB_FWVER)
dev_err(dev-udev-dev,
-   usb firmware not up to date %d\n, fw_ver);
+   usb firmware not up to date %d.%d\n,
+   (fw_ver  8)  0xff,
+   fw_ver  0xff);
 
for (j = 0; j  MAX_CHANNELS; j++) {
dev-b_acquire[j] = 0;
@@ -2284,8 +2283,7 @@ static int s2255_start_readpipe(struct s
 
for (i = 0

patch: s2255drv high quality mode and video status querying

2009-04-07 Thread Dean A.
From: Dean Anderson d...@sensoray.com

This patch adds V4L2 video status capability and V4L2_MODE_HIGHQUALITY
operation.

Signed-off-by: Dean Anderson d...@sensoray.com

--- v4l-dvb-1e670024659d/linux/drivers/media/video/s2255drv.c.orig  
2009-04-07 10:38:42.0 -0700
+++ v4l-dvb-1e670024659d/linux/drivers/media/video/s2255drv.c   2009-04-07 
10:42:51.0 -0700
@@ -57,7 +57,8 @@
 
 #define FIRMWARE_FILE_NAME f2255usb.bin
 
-
+#define S2255_REV_MAJOR 1
+#define S2255_REV_MINOR 20
 
 /* default JPEG quality */
 #define S2255_DEF_JPEG_QUAL 50
@@ -75,9 +76,13 @@
 #define S2255_LOAD_TIMEOUT  (5000 + S2255_DSP_BOOTTIME)
 #define S2255_DEF_BUFS  16
 #define S2255_SETMODE_TIMEOUT   500
+#define S2255_VIDSTATUS_TIMEOUT 350
 #define MAX_CHANNELS   4
-#define S2255_MARKER_FRAME 0x2255DA4AL
-#define S2255_MARKER_RESPONSE  0x2255ACACL
+#define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL)
+#define S2255_MARKER_RESPONSE  cpu_to_le32(0x2255ACACL)
+#define S2255_RESPONSE_SETMODE  cpu_to_le32(0x01)
+#define S2255_RESPONSE_FW   cpu_to_le32(0x10)
+#define S2255_RESPONSE_STATUS   cpu_to_le32(0x20)
 #define S2255_USB_XFER_SIZE(16 * 1024)
 #define MAX_CHANNELS   4
 #define MAX_PIPE_BUFFERS   1
@@ -100,14 +105,16 @@
 #define LINE_SZ_DEF640
 #define NUM_LINES_DEF  240
 
-
 /* predefined settings */
 #define FORMAT_NTSC1
 #define FORMAT_PAL 2
 
+/* SCALE_4CIFS is the 2 fields merge into one */
 #define SCALE_4CIFS1   /* 640x480(NTSC) or 704x576(PAL) */
 #define SCALE_2CIFS2   /* 640x240(NTSC) or 704x288(PAL) */
 #define SCALE_1CIFS3   /* 320x240(NTSC) or 352x288(PAL) */
+/* SCALE_4CIFSI is the 2 fields interpolated into one */
+#define SCALE_4CIFSI   4   /* 640x480(NTSC) or 704x576(PAL) high quality */
 
 #define COLOR_YUVPL1   /* YUV planar */
 #define COLOR_YUVPK2   /* YUV packed */
@@ -134,12 +141,12 @@
 #define DEF_HUE0
 
 /* usb config commands */
-#define IN_DATA_TOKEN  0x2255c0de
-#define CMD_2255   0xc2255000
-#define CMD_SET_MODE   (CMD_2255 | 0x10)
-#define CMD_START  (CMD_2255 | 0x20)
-#define CMD_STOP   (CMD_2255 | 0x30)
-#define CMD_STATUS (CMD_2255 | 0x40)
+#define IN_DATA_TOKEN  cpu_to_le32(0x2255c0de)
+#define CMD_2255   cpu_to_le32(0xc2255000)
+#define CMD_SET_MODE   cpu_to_le32((CMD_2255 | 0x10))
+#define CMD_START  cpu_to_le32((CMD_2255 | 0x20))
+#define CMD_STOP   cpu_to_le32((CMD_2255 | 0x30))
+#define CMD_STATUS cpu_to_le32((CMD_2255 | 0x40))
 
 struct s2255_mode {
u32 format; /* input video format (NTSC, PAL) */
@@ -181,7 +188,6 @@ struct s2255_dmaqueue {
struct list_headactive;
/* thread for acquisition */
struct task_struct  *kthread;
-   int frame;
struct s2255_dev*dev;
int channel;
 };
@@ -211,16 +217,12 @@ struct s2255_pipeinfo {
u32 max_transfer_size;
u32 cur_transfer_size;
u8 *transfer_buffer;
-   u32 transfer_flags;;
u32 state;
-   u32 prev_state;
u32 urb_size;
void *stream_urb;
void *dev;  /* back pointer to s2255_dev struct*/
u32 err_count;
-   u32 buf_index;
u32 idx;
-   u32 priority_set;
 };
 
 struct s2255_fmt; /*forward declaration */
@@ -239,14 +241,15 @@ struct s2255_dev {
struct video_device *vdev[MAX_CHANNELS];
struct list_heads2255_devlist;
struct timer_list   timer;
-   struct s2255_fw *fw_data;
-   int board_num;
-   int is_open;
+   struct s2255_fw *fw_data;
struct s2255_pipeinfo   pipes[MAX_PIPE_BUFFERS];
struct s2255_bufferibuffer[MAX_CHANNELS];
struct s2255_mode   mode[MAX_CHANNELS];
/* jpeg compression */
struct v4l2_jpegcompression jc[MAX_CHANNELS];
+   /* capture parameters (for high quality mode full size) */
+   struct v4l2_captureparm cap_parm[MAX_CHANNELS];
+
const struct s2255_fmt  *cur_fmt[MAX_CHANNELS];
int cur_frame[MAX_CHANNELS];
int last_frame[MAX_CHANNELS];
@@ -265,9 +268,16 @@ struct s2255_dev {
int chn_configured[MAX_CHANNELS];
wait_queue_head_t   wait_setmode[MAX_CHANNELS];
int setmode_ready[MAX_CHANNELS];
+   /* video status items */
+   int vidstatus[MAX_CHANNELS];
+   wait_queue_head_t   wait_vidstatus[MAX_CHANNELS];
+   int vidstatus_ready[MAX_CHANNELS];
+
int chn_ready;
struct kref kref;
spinlock_t  slock;
+   /* dsp firmware version (f2255usb.bin) */
+   int dsp_fw_ver;
 };
 #define to_s2255_dev(d) container_of(d, struct