From patchwork Fri Aug 5 07:47:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 1037642 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p757ls2Y027381 for ; Fri, 5 Aug 2011 07:47:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756061Ab1HEHrx (ORCPT ); Fri, 5 Aug 2011 03:47:53 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:64212 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756059Ab1HEHrw (ORCPT ); Fri, 5 Aug 2011 03:47:52 -0400 Received: from axis700.grange (dslb-178-006-240-175.pools.arcor-ip.net [178.6.240.175]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0MgI6w-1R35Jf0Wik-00NGQX; Fri, 05 Aug 2011 09:47:37 +0200 Received: by axis700.grange (Postfix, from userid 1000) id BAFBC189B6E; Fri, 5 Aug 2011 09:47:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id B85FB189B6D; Fri, 5 Aug 2011 09:47:36 +0200 (CEST) Date: Fri, 5 Aug 2011 09:47:36 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List cc: Sakari Ailus , Hans Verkuil , Pawel Osciak , Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab Subject: [PATCH 6/6 v4] V4L: soc-camera: add 2 new ioctl() handlers In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:Ii3T3uldbV864wvqyGJ+FHg3cO3DWHQvIeD9qXeyzDs IAl+6eR7yW8SJcGC3mAzuTnSr0cxFOO4b9L6I94PzrRUOB9iqh c2uCtvwkqqV500T61Uur62AKkldid6hBciCY4qKntImfE4K0NM q5eFLChq1rKkSHNOkqkD97g+1qkox1ps53ACL+D+TC6y+52Tod jCTLwG00e8nc4+KOPy/MzWGaDiBQZmmwJGe11G3TOo= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 05 Aug 2011 07:47:55 +0000 (UTC) This patch adds two new ioctl() handlers: .vidioc_create_bufs() and .vidioc_prepare_buf() for compliant vb2 soc-camera hosts. Signed-off-by: Guennadi Liakhovetski --- Actually, there should be one more patch before this one - to convert mx3-camera to the new API, otherwise it will break, if anyone decides to use CREATE_BUFS / PREPARE_BUF with it. I'll work on that while these patches are being reviewed. drivers/media/video/soc_camera.c | 33 +++++++++++++++++++++++++++++++-- 1 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index ac23916..088972d 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -318,6 +318,32 @@ static int soc_camera_dqbuf(struct file *file, void *priv, return vb2_dqbuf(&icd->vb2_vidq, p, file->f_flags & O_NONBLOCK); } +static int soc_camera_create_bufs(struct file *file, void *priv, + struct v4l2_create_buffers *create) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + + /* videobuf2 only */ + if (ici->ops->init_videobuf) + return -EINVAL; + else + return vb2_create_bufs(&icd->vb2_vidq, create); +} + +static int soc_camera_prepare_buf(struct file *file, void *priv, + struct v4l2_buffer *b) +{ + struct soc_camera_device *icd = file->private_data; + struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + + /* videobuf2 only */ + if (ici->ops->init_videobuf) + return -EINVAL; + else + return vb2_prepare_buf(&icd->vb2_vidq, b); +} + /* Always entered with .video_lock held */ static int soc_camera_init_user_formats(struct soc_camera_device *icd) { @@ -1101,6 +1127,7 @@ static int soc_camera_probe(struct soc_camera_device *icd) if (!control || !control->driver || !dev_get_drvdata(control) || !try_module_get(control->driver->owner)) { icl->del_device(icd); + ret = -ENODEV; goto enodrv; } } @@ -1366,19 +1393,21 @@ static int soc_camera_device_register(struct soc_camera_device *icd) static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_querycap = soc_camera_querycap, + .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_g_fmt_vid_cap = soc_camera_g_fmt_vid_cap, - .vidioc_enum_fmt_vid_cap = soc_camera_enum_fmt_vid_cap, .vidioc_s_fmt_vid_cap = soc_camera_s_fmt_vid_cap, + .vidioc_enum_fmt_vid_cap = soc_camera_enum_fmt_vid_cap, .vidioc_enum_input = soc_camera_enum_input, .vidioc_g_input = soc_camera_g_input, .vidioc_s_input = soc_camera_s_input, .vidioc_s_std = soc_camera_s_std, .vidioc_enum_framesizes = soc_camera_enum_fsizes, .vidioc_reqbufs = soc_camera_reqbufs, - .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap, .vidioc_querybuf = soc_camera_querybuf, .vidioc_qbuf = soc_camera_qbuf, .vidioc_dqbuf = soc_camera_dqbuf, + .vidioc_create_bufs = soc_camera_create_bufs, + .vidioc_prepare_buf = soc_camera_prepare_buf, .vidioc_streamon = soc_camera_streamon, .vidioc_streamoff = soc_camera_streamoff, .vidioc_queryctrl = soc_camera_queryctrl,