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: Prabhakar X-Patchwork-Id: 5071841 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EC1839F1EE for ; Sun, 12 Oct 2014 20:43:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D43A320176 for ; Sun, 12 Oct 2014 20:43:46 +0000 (UTC) Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A35122018E for ; Sun, 12 Oct 2014 20:43:45 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9CKhiva010260 for ; Sun, 12 Oct 2014 15:43:44 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9CKhifv031594 for ; Sun, 12 Oct 2014 15:43:44 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Sun, 12 Oct 2014 15:43:44 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9CKhi8D020074 for ; Sun, 12 Oct 2014 15:43:44 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id A48188062A for ; Sun, 12 Oct 2014 15:43:44 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflxv17.itg.ti.com (dflxv17.itg.ti.com [128.247.5.93]) by linux.omap.com (Postfix) with ESMTP id 66D9480628 for ; Sun, 12 Oct 2014 15:41:05 -0500 (CDT) Received: from neches.ext.ti.com (neches.ext.ti.com [192.91.81.29]) by dflxv17.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9CKf5Bd029828 for ; Sun, 12 Oct 2014 15:41:05 -0500 Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9CKf444002753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 12 Oct 2014 15:41:05 -0500 Received: from [216.82.253.163:46518] by server-9.bemta-7.messagelabs.com id 1C/0C-03013-067EA345; Sun, 12 Oct 2014 20:41:04 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-6.tower-166.messagelabs.com!1413146462!20407281!1 X-Originating-IP: [209.85.212.169] X-SpamReason: No, hits=0.7 required=7.0 tests=BODY_RANDOM_LONG, RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13464 invoked from network); 12 Oct 2014 20:41:03 -0000 Received: from mail-wi0-f169.google.com (HELO mail-wi0-f169.google.com) (209.85.212.169) by server-6.tower-166.messagelabs.com with RC4-SHA encrypted SMTP; 12 Oct 2014 20:41:03 -0000 Received: by mail-wi0-f169.google.com with SMTP id h11so1892053wiw.0 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 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> CC: DLOS , LKML X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com 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, 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,