[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 
---
 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(&dev->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(&dev->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(&dev->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] s2255drv: fix payload size for JPG, MJPEG

2014-11-17 Thread Dean Anderson
Signed-off-by: Dean Anderson 
---
 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


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 
---
 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] [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 
---
 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 

---
 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
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 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 
---
 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 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 

-#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 *

[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 
---
 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 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
-#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:
-

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_

[PATCH] s2255drv: upgrade to videobuf2

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

Signed-off-by: Dean Anderson 

---
 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 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
-#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

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 

---
 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 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 

-#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   

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


[PATCH] s2255drv: cleanup of s2255_fh

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

Signed-off-by: Dean Anderson 
---
 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

[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 
---
 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: 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 
---
 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_

[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 
---
 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: 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 
---
 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: remove redundant parameter

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

Signed-off-by: Dean Anderson 
---
 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


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

--
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: 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 
---
 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");
+   dprin

[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 
---
 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 = vi

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 
---
 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,
   

[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 
---
 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 = vi

[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 
---
 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 
 #include 
 
-#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 

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 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 
---
 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 s

[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 
---
 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 
 #include 
 
-#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 

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 Carpenter
---

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)

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 

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 Carpenter

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


Re: Fw: [PATCH] v4l/dvb: remove err macro from few usb devices

2009-01-12 Thread Dean Anderson

Alexey Klimov wrote:

Hello, all
  
Dean, so you think that we don't need s2255 name in the beginning of

message and we doesn't need s2255_dev_err macros, right ?

As i remember pr_err is just printk with KERN_ERR..

  
Not at all.  We must have s2255 in the beginning of the message.  I 
wasn't sure only about pr_err, but it looks ok now. 


The s2255_dev_err macros are a good idea.

Thanks,

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