From patchwork Sun Oct 12 20:40:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 5071651 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D3DBBC11AD for ; Sun, 12 Oct 2014 20:41:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3105201B4 for ; Sun, 12 Oct 2014 20:41:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9846E2018E for ; Sun, 12 Oct 2014 20:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753014AbaJLUlJ (ORCPT ); Sun, 12 Oct 2014 16:41:09 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:42636 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752920AbaJLUlE (ORCPT ); Sun, 12 Oct 2014 16:41:04 -0400 Received: by mail-wg0-f45.google.com with SMTP id m15so7477424wgh.16 for ; Sun, 12 Oct 2014 13:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jZ0/CqrwnQNh48dO4ZFbhSUOhA1GHV+Y7UPPzgnqKus=; b=gjtn0lYUARMpqjshf1MulqZ5+fiflsIAQSv7p2sZ1N3J5iCXBaK0SZQPHh8t6i4bAS IqZVHfLGwG6TqK870yM4rm2raEWAZH41kaWUvFvMRS574EnYGqQUYG5qWrzVgcsKq0G4 6fqiVRz5DBlWo9c4rl7ccof2/JOo6bHLicbg26emJcdIOae+JyjfcBvCrw9U/SMoDton e5Lsba90s5v4WWQM04HRAAx+/d9es5Kk5M4pKPV/oKki15qc8vfXNdqMmMo2LCk6UCFj 4lmpPwJb0fSfRWcvZESopVLc93vHP2iXc63JkqpGbEvG2VO57DaHAMztWD6mm8bhUqIW 1dyQ== X-Received: by 10.180.189.68 with SMTP id gg4mr14274600wic.34.1413146462012; Sun, 12 Oct 2014 13:41:02 -0700 (PDT) Received: from tango-charlie.Home ([2.127.193.40]) by mx.google.com with ESMTPSA id y5sm9970930wix.10.2014.10.12.13.41.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Oct 2014 13:41:01 -0700 (PDT) From: "Lad, Prabhakar" To: LMML Cc: LKML , DLOS , "Lad, Prabhakar" Subject: [PATCH 08/15] media: davinci: vpbe: use vb2_ioctl_* helpers Date: Sun, 12 Oct 2014 21:40:38 +0100 Message-Id: <1413146445-7304-9-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413146445-7304-1-git-send-email-prabhakar.csengg@gmail.com> References: <1413146445-7304-1-git-send-email-prabhakar.csengg@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP this patch adds support for using vb2_ioctl_* helpers. Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpbe_display.c | 178 ++------------------------ 1 file changed, 14 insertions(+), 164 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 970242c..76450aa 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c @@ -281,8 +281,11 @@ static void vpbe_buffer_queue(struct vb2_buffer *vb) static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) { struct vpbe_layer *layer = vb2_get_drv_priv(vq); + struct osd_state *osd_device = layer->disp_dev->osd_device; int ret; + osd_device->ops.disable_layer(osd_device, layer->layer_info.id); + /* Get the next frame from the buffer queue */ layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next, struct vpbe_disp_buffer, list); @@ -320,12 +323,15 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) static void vpbe_stop_streaming(struct vb2_queue *vq) { struct vpbe_layer *layer = vb2_get_drv_priv(vq); + struct osd_state *osd_device = layer->disp_dev->osd_device; struct vpbe_display *disp = layer->disp_dev; unsigned long flags; if (!vb2_is_streaming(vq)) return; + osd_device->ops.disable_layer(osd_device, layer->layer_info.id); + /* release all active buffers */ spin_lock_irqsave(&disp->dma_queue_lock, flags); if (layer->cur_frm == layer->next_frm) { @@ -1144,164 +1150,6 @@ vpbe_display_g_dv_timings(struct file *file, void *priv, return 0; } -static int vpbe_display_streamoff(struct file *file, void *priv, - enum v4l2_buf_type buf_type) -{ - struct vpbe_layer *layer = video_drvdata(file); - struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; - struct osd_state *osd_device = layer->disp_dev->osd_device; - int ret; - - v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, - "VIDIOC_STREAMOFF,layer id = %d\n", - layer->device_id); - - if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf_type) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); - return -EINVAL; - } - - /* If streaming is not started, return error */ - if (!layer->started) { - v4l2_err(&vpbe_dev->v4l2_dev, "streaming not started in layer" - " id = %d\n", layer->device_id); - return -EINVAL; - } - - osd_device->ops.disable_layer(osd_device, - layer->layer_info.id); - layer->started = 0; - ret = vb2_streamoff(&layer->buffer_queue, buf_type); - - return ret; -} - -static int vpbe_display_streamon(struct file *file, void *priv, - enum v4l2_buf_type buf_type) -{ - struct vpbe_layer *layer = video_drvdata(file); - struct vpbe_display *disp_dev = layer->disp_dev; - struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; - struct osd_state *osd_device = disp_dev->osd_device; - int ret; - - osd_device->ops.disable_layer(osd_device, - layer->layer_info.id); - - v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_STREAMON, layerid=%d\n", - layer->device_id); - - if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf_type) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); - return -EINVAL; - } - - /* If Streaming is already started, return error */ - if (layer->started) { - v4l2_err(&vpbe_dev->v4l2_dev, "layer is already streaming\n"); - return -EBUSY; - } - - /* - * Call vb2_streamon to start streaming - * in videobuf - */ - ret = vb2_streamon(&layer->buffer_queue, buf_type); - if (ret) { - v4l2_err(&vpbe_dev->v4l2_dev, - "error in vb2_streamon\n"); - return ret; - } - return ret; -} - -static int vpbe_display_dqbuf(struct file *file, void *priv, - struct v4l2_buffer *buf) -{ - struct vpbe_layer *layer = video_drvdata(file); - struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; - int ret; - - v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, - "VIDIOC_DQBUF, layer id = %d\n", - layer->device_id); - - if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); - return -EINVAL; - } - if (file->f_flags & O_NONBLOCK) - /* Call videobuf_dqbuf for non blocking mode */ - ret = vb2_dqbuf(&layer->buffer_queue, buf, 1); - else - /* Call videobuf_dqbuf for blocking mode */ - ret = vb2_dqbuf(&layer->buffer_queue, buf, 0); - - return ret; -} - -static int vpbe_display_qbuf(struct file *file, void *priv, - struct v4l2_buffer *p) -{ - struct vpbe_layer *layer = video_drvdata(file); - struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; - - v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, - "VIDIOC_QBUF, layer id = %d\n", - layer->device_id); - - if (V4L2_BUF_TYPE_VIDEO_OUTPUT != p->type) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); - return -EINVAL; - } - - return vb2_qbuf(&layer->buffer_queue, p); -} - -static int vpbe_display_querybuf(struct file *file, void *priv, - struct v4l2_buffer *buf) -{ - struct vpbe_layer *layer = video_drvdata(file); - struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; - - v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, - "VIDIOC_QUERYBUF, layer id = %d\n", - layer->device_id); - - if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); - return -EINVAL; - } - /* Call vb2_querybuf to get information */ - return vb2_querybuf(&layer->buffer_queue, buf); -} - -static int vpbe_display_reqbufs(struct file *file, void *priv, - struct v4l2_requestbuffers *req_buf) -{ - struct vpbe_layer *layer = video_drvdata(file); - struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; - - v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_reqbufs\n"); - - if (V4L2_BUF_TYPE_VIDEO_OUTPUT != req_buf->type) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); - return -EINVAL; - } - - /* If io users of the layer is not zero, return error */ - if (0 != layer->io_usrs) { - v4l2_err(&vpbe_dev->v4l2_dev, "not IO user\n"); - return -EBUSY; - } - /* Increment io usrs member of layer object to 1 */ - layer->io_usrs = 1; - /* Store type of memory requested in layer object */ - layer->memory = req_buf->memory; - /* Allocate buffers */ - return vb2_reqbufs(&layer->buffer_queue, req_buf); -} - /* * vpbe_display_open() * It creates object of file handle structure and stores it in private_data @@ -1405,12 +1253,14 @@ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = { .vidioc_enum_fmt_vid_out = vpbe_display_enum_fmt, .vidioc_s_fmt_vid_out = vpbe_display_s_fmt, .vidioc_try_fmt_vid_out = vpbe_display_try_fmt, - .vidioc_reqbufs = vpbe_display_reqbufs, - .vidioc_querybuf = vpbe_display_querybuf, - .vidioc_qbuf = vpbe_display_qbuf, - .vidioc_dqbuf = vpbe_display_dqbuf, - .vidioc_streamon = vpbe_display_streamon, - .vidioc_streamoff = vpbe_display_streamoff, + + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, + .vidioc_cropcap = vpbe_display_cropcap, .vidioc_g_crop = vpbe_display_g_crop, .vidioc_s_crop = vpbe_display_s_crop,