From patchwork Fri May 16 13:33:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 4192101 Return-Path: X-Original-To: patchwork-davinci@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 8BBB5BFF02 for ; Fri, 16 May 2014 13:42:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D87F20379 for ; Fri, 16 May 2014 13:42:17 +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 D4E6020251 for ; Fri, 16 May 2014 13:42:15 +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 s4GDfEA6020572; Fri, 16 May 2014 08:41:14 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDf95B011565; Fri, 16 May 2014 08:41:14 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Fri, 16 May 2014 08:41:10 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDfBVj001950; Fri, 16 May 2014 08:41:11 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 0C5698062C; Fri, 16 May 2014 08:41:11 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlelxv84.itg.ti.com (dlelxv84.itg.ti.com [172.17.0.246]) by linux.omap.com (Postfix) with ESMTP id 1CDCC8062E for ; Fri, 16 May 2014 08:38:46 -0500 (CDT) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dlelxv84.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDck6u009585 for ; Fri, 16 May 2014 08:38:46 -0500 Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by white.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4GDcjvR021417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 May 2014 08:38:45 -0500 Received: from [216.82.250.51:10449] by server-14.bemta-12.messagelabs.com id A5/BD-04933-5E416735; Fri, 16 May 2014 13:38:45 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-5.tower-108.messagelabs.com!1400247523!3460929!1 X-Originating-IP: [209.85.220.54] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, ML_RADAR_SPEW_LINKS_14,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13587 invoked from network); 16 May 2014 13:38:44 -0000 Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by server-5.tower-108.messagelabs.com with RC4-SHA encrypted SMTP; 16 May 2014 13:38:44 -0000 Received: by mail-pa0-f54.google.com with SMTP id bj1so2582405pad.13 for ; Fri, 16 May 2014 06:38:43 -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=lCppS3puIN7PKLxdrhA/IPHgsrA6E408wWgVtK9gPhk=; b=qkKymICPTmLUD175Pax+vz2EdHkx5KIXfSOUm06cFZzRNSrIV4D20y2Wd6zJZHHrZw bNkC14bQPs4/YdQ61g7vQHZK/D8FP0PF9Vh+Dtp+fMpAQjTlr3zx7rDmEbKl885Y7QPT uEWVa335YLO0Wc9neiQML1ZNh3BnMFC9fy3BmumYRCBYnZTQGz+i/YF8ueS9xewLVh7j LwriGYZTztcNIuaVWqt14b6VODEewjOaZ9TbkTY1VH/2Qn5ZQoWisRvnfQBCMKKDNbGu IbdZagukJOxypgqk7l/P+MhSQCX8qSai2Rjil3AKHftZOSnJmxYX9Sa4w28R3vHKjFHW nRoQ== X-Received: by 10.66.162.74 with SMTP id xy10mr21288438pab.4.1400247523467; Fri, 16 May 2014 06:38:43 -0700 (PDT) Received: from localhost.localdomain ([27.107.45.22]) by mx.google.com with ESMTPSA id cj1sm34699547pac.40.2014.05.16.06.38.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 06:38:41 -0700 (PDT) From: "Lad, Prabhakar" To: LMML , Hans Verkuil Subject: [PATCH v5 11/49] media: davinci: vpif_display: use vb2_ioctl_* helpers Date: Fri, 16 May 2014 19:03:16 +0530 Message-ID: <1400247235-31434-13-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400247235-31434-1-git-send-email-prabhakar.csengg@gmail.com> References: <1400247235-31434-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@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 From: "Lad, Prabhakar" Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpif_display.c | 180 ++----------------------- 1 file changed, 10 insertions(+), 170 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 5fc1256..8bd3794 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -745,75 +745,6 @@ static int vpif_try_fmt_vid_out(struct file *file, void *priv, return ret; } -static int vpif_reqbufs(struct file *file, void *priv, - struct v4l2_requestbuffers *reqbuf) -{ - struct video_device *vdev = video_devdata(file); - struct channel_obj *ch = video_get_drvdata(vdev); - struct common_obj *common; - enum v4l2_field field; - u8 index = 0; - - if (V4L2_BUF_TYPE_VIDEO_OUTPUT != reqbuf->type) - return -EINVAL; - - index = VPIF_VIDEO_INDEX; - - common = &ch->common[index]; - - if (common->fmt.type != reqbuf->type || !vpif_dev) - return -EINVAL; - if (0 != common->io_usrs) - return -EBUSY; - - if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { - if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY) - field = V4L2_FIELD_INTERLACED; - else - field = common->fmt.fmt.pix.field; - } else { - field = V4L2_VBI_INTERLACED; - } - /* Increment io usrs member of channel object to 1 */ - common->io_usrs = 1; - /* Store type of memory requested in channel object */ - common->memory = reqbuf->memory; - /* Allocate buffers */ - return vb2_reqbufs(&common->buffer_queue, reqbuf); -} - -static int vpif_querybuf(struct file *file, void *priv, - struct v4l2_buffer *tbuf) -{ - struct video_device *vdev = video_devdata(file); - struct channel_obj *ch = video_get_drvdata(vdev); - struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; - - if (common->fmt.type != tbuf->type) - return -EINVAL; - - return vb2_querybuf(&common->buffer_queue, tbuf); -} - -static int vpif_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) -{ - struct video_device *vdev = video_devdata(file); - struct channel_obj *ch = video_get_drvdata(vdev); - struct common_obj *common = NULL; - - if (!buf || !priv) - return -EINVAL; - - if (!ch) - return -EINVAL; - - common = &(ch->common[VPIF_VIDEO_INDEX]); - if (common->fmt.type != buf->type) - return -EINVAL; - - return vb2_qbuf(&common->buffer_queue, buf); -} - static int vpif_s_std(struct file *file, void *priv, v4l2_std_id std_id) { struct video_device *vdev = video_devdata(file); @@ -870,101 +801,6 @@ static int vpif_g_std(struct file *file, void *priv, v4l2_std_id *std) return 0; } -static int vpif_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) -{ - struct video_device *vdev = video_devdata(file); - struct channel_obj *ch = video_get_drvdata(vdev); - struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; - - return vb2_dqbuf(&common->buffer_queue, p, - (file->f_flags & O_NONBLOCK)); -} - -static int vpif_streamon(struct file *file, void *priv, - enum v4l2_buf_type buftype) -{ - struct video_device *vdev = video_devdata(file); - struct channel_obj *ch = video_get_drvdata(vdev); - struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; - struct channel_obj *oth_ch = vpif_obj.dev[!ch->channel_id]; - int ret = 0; - - if (buftype != V4L2_BUF_TYPE_VIDEO_OUTPUT) { - vpif_err("buffer type not supported\n"); - return -EINVAL; - } - - /* If Streaming is already started, return error */ - if (common->started) { - vpif_err("channel->started\n"); - return -EBUSY; - } - - if ((ch->channel_id == VPIF_CHANNEL2_VIDEO - && oth_ch->common[VPIF_VIDEO_INDEX].started && - ch->vpifparams.std_info.ycmux_mode == 0) - || ((ch->channel_id == VPIF_CHANNEL3_VIDEO) - && (2 == oth_ch->common[VPIF_VIDEO_INDEX].started))) { - vpif_err("other channel is using\n"); - return -EBUSY; - } - - ret = vpif_check_format(ch, &common->fmt.fmt.pix); - if (ret < 0) - return ret; - - /* Call vb2_streamon to start streaming in videobuf2 */ - ret = vb2_streamon(&common->buffer_queue, buftype); - if (ret < 0) { - vpif_err("vb2_streamon\n"); - return ret; - } - - return ret; -} - -static int vpif_streamoff(struct file *file, void *priv, - enum v4l2_buf_type buftype) -{ - struct video_device *vdev = video_devdata(file); - struct channel_obj *ch = video_get_drvdata(vdev); - struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; - struct vpif_display_config *vpif_config_data = - vpif_dev->platform_data; - - if (buftype != V4L2_BUF_TYPE_VIDEO_OUTPUT) { - vpif_err("buffer type not supported\n"); - return -EINVAL; - } - - if (!common->started) { - vpif_err("channel->started\n"); - return -EINVAL; - } - - if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) { - /* disable channel */ - if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { - if (vpif_config_data-> - chan_config[VPIF_CHANNEL2_VIDEO].clip_en) - channel2_clipping_enable(0); - enable_channel2(0); - channel2_intr_enable(0); - } - if ((VPIF_CHANNEL3_VIDEO == ch->channel_id) || - (2 == common->started)) { - if (vpif_config_data-> - chan_config[VPIF_CHANNEL3_VIDEO].clip_en) - channel3_clipping_enable(0); - enable_channel3(0); - channel3_intr_enable(0); - } - } - - common->started = 0; - return vb2_streamoff(&common->buffer_queue, buftype); -} - static int vpif_cropcap(struct file *file, void *priv, struct v4l2_cropcap *crop) { @@ -1261,12 +1097,16 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = { .vidioc_g_fmt_vid_out = vpif_g_fmt_vid_out, .vidioc_s_fmt_vid_out = vpif_s_fmt_vid_out, .vidioc_try_fmt_vid_out = vpif_try_fmt_vid_out, - .vidioc_reqbufs = vpif_reqbufs, - .vidioc_querybuf = vpif_querybuf, - .vidioc_qbuf = vpif_qbuf, - .vidioc_dqbuf = vpif_dqbuf, - .vidioc_streamon = vpif_streamon, - .vidioc_streamoff = vpif_streamoff, + + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, + .vidioc_s_std = vpif_s_std, .vidioc_g_std = vpif_g_std, .vidioc_enum_output = vpif_enum_output,