On Fri, 24 Aug 2012, Anatolij Gustschin wrote:

> 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 branch
>  
>  drivers/media/platform/soc_camera/soc_camera.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
> b/drivers/media/platform/soc_camera/soc_camera.c
> index 10b57f8..d591a42 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -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;

How about a slightly simpler

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

>  }
> -- 
> 1.7.1
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to