V4L: soc_camera: allow reading from video device if supported
PATCH 1/1 V4L: soc_camera: allow reading from video device if supported
Try reading on video device. If the camera bus driver supports reading we can try it and return the result. Also add a debug line.
--- drivers/media/platform/soc_camera.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/media/platform/soc_camera.c +8 -1
@@ -645,9 +645,16 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct soc_camera_device *icd = file->private_data; +struct soc_camera_host *ici =to_soc_camera_host (icd->parent);int err = -EINVAL ; -dev_err (icd->pdev,"camera device read not implemented\n" ); +dev_dbg (icd->pdev,"read called, buf %p\n" , buf); + +if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes &VB2_READ ) + err =vb2_read (&icd->vb2_vidq, buf, count, ppos, + file->f_flags &O_NONBLOCK ); +else +dev_err (icd->pdev,"camera device read not implemented\n" );return err; }
Signature · 1 line
1.7.1
PATCH v2 1/1 V4L: soc_camera: allow reading from video device if supported
Try reading on video device. If the camera bus driver supports reading we can try it and return the result. Also add a debug line.
---
v2: - rebased on current staging/for_v3.7 branch
drivers/media/platform/soc_camera/soc_camera.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/media/platform/soc_camera/soc_camera.c +8 -1
@@ -645,9 +645,16 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct soc_camera_device *icd = file->private_data; +struct soc_camera_host *ici =to_soc_camera_host (icd->parent);int err = -EINVAL ; -dev_err (icd->pdev,"camera device read not implemented\n" ); +dev_dbg (icd->pdev,"read called, buf %p\n" , buf); + +if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes &VB2_READ ) + err =vb2_read (&icd->vb2_vidq, buf, count, ppos, + file->f_flags &O_NONBLOCK ); +else +dev_err (icd->pdev,"camera device read not implemented\n" );return err; }
Signature · 1 line
1.7.1
Quoted 21 lines · Anatolij Gustschin
Try reading on video device. If the camera bus driver supports reading we can try it and return the result. Also add a debug line.
Signed-off-by Anatolij Gustschin <[email protected]>---
v2: - rebased on current staging/for_v3.7 branchdrivers/media/platform/soc_camera/soc_camera.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)drivers/media/platform/soc_camera/soc_camera.c +1
-0@@ -645,9 +645,16 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct soc_camera_device *icd = file->private_data; +struct soc_camera_host *ici =to_soc_camera_host (icd->parent);int err = -EINVAL ;
drivers/media/platform/soc_camera/soc_camera.c static ssize_t soc_camera_read(struct file *file, char __user *buf, · line 659
Quoted 10 lines
drivers/media/platform/soc_camera/soc_camera.c +7
-1-dev_err (icd->pdev,"camera device read not implemented\n" ); +dev_dbg (icd->pdev,"read called, buf %p\n" , buf); + +if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes &VB2_READ ) + err =vb2_read (&icd->vb2_vidq, buf, count, ppos, + file->f_flags &O_NONBLOCK ); +else +dev_err (icd->pdev,"camera device read not implemented\n" );return err;
How about a slightly simpler
drivers/media/platform/soc_camera/soc_camera.c static ssize_t soc_camera_read(struct file *file, char __user *buf,
Quoted 13 lines
drivers/media/platform/soc_camera/soc_camera.c +8
-3+struct soc_camera_host *ici =to_soc_camera_host (icd->parent); -int err = -EINVAL ; -dev_err (icd->pdev,"camera device read not implemented\n" ); +dev_dbg (icd->pdev,"read called, buf %p\n" , buf); -return err; +if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes &VB2_READ ) +return vb2_read (&icd->vb2_vidq, buf, count, ppos, + file->f_flags &O_NONBLOCK ); + +dev_err (icd->pdev,"camera device read not implemented\n" ); +return -EINVAL ;
Thanks
Guennadi
Quoted 4 lines
}
Signature · 1 line
1.7.1
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
Hi Guennadi,
On Fri, 24 Aug 2012 13:37:20 +0200 (CEST) Guennadi Liakhovetski <[email protected]> wrote:
...
Quoted 8 lines
How about a slightly simpler
Quoted 6 lines
drivers/media/platform/soc_camera/soc_camera.c +2
-2+struct soc_camera_host *ici =to_soc_camera_host (icd->parent); -int err = -EINVAL ; -dev_err (icd->pdev,"camera device read not implemented\n" ); +dev_dbg (icd->pdev,"read called, buf %p\n" , buf);
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +6
-1- return err; + if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes & VB2_READ) + return vb2_read(&icd->vb2_vidq, buf, count, ppos, + file->f_flags & O_NONBLOCK); + + dev_err(icd->pdev, "camera device read not implemented\n"); + return -EINVAL;
Ok, I'll simplify as suggested and resubmit.
Thanks,
Anatolij
PATCH v3 1/1 V4L: soc_camera: allow reading from video device if supported
In reply to Anatolij GustschinTry reading on video device. If the camera bus driver supports reading we can try it and return the result. Also add a debug line.
---
v3: - simplified as suggested by Guennadi
v2: - rebased on current staging/for_v3.7 branch
drivers/media/platform/soc_camera/soc_camera.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/soc_camera/soc_camera.c +8 -2
@@ -645,11 +645,17 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct soc_camera_device *icd = file->private_data; -int err = -EINVAL ; +struct soc_camera_host *ici =to_soc_camera_host (icd->parent); + +dev_dbg (icd->pdev,"read called, buf %p\n" , buf); + +if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes &VB2_READ ) +return vb2_read (&icd->vb2_vidq, buf, count, ppos, + file->f_flags &O_NONBLOCK );dev_err (icd->pdev,"camera device read not implemented\n" ); -return err; +return -EINVAL ; }static int soc_camera_mmap (struct file *file,struct vm_area_struct *vma)
Signature · 1 line
1.7.1