From patchwork Sun Oct 12 20:40:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 5072021 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 E208F9F1EE for ; Sun, 12 Oct 2014 20:46:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50F4D20176 for ; Sun, 12 Oct 2014 20:46:26 +0000 (UTC) Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 748202018E for ; Sun, 12 Oct 2014 20:46:24 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9CKjIj3010196; Sun, 12 Oct 2014 15:45:18 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9CKjIF0017009; Sun, 12 Oct 2014 15:45:18 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Sun, 12 Oct 2014 15:45:17 -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 s9CKjIwX025146; Sun, 12 Oct 2014 15:45:18 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 1C82E80627; Sun, 12 Oct 2014 15:45:18 -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 758C28062B for ; Sun, 12 Oct 2014 15:41:05 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dlelxv84.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9CKf5FJ026925 for ; Sun, 12 Oct 2014 15:41:05 -0500 Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9CKf4ck009335 (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.250.51:42497] by server-7.bemta-12.messagelabs.com id 8E/E5-10811-067EA345; Sun, 12 Oct 2014 20:41:04 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-5.tower-108.messagelabs.com!1413146461!10572418!1 X-Originating-IP: [209.85.212.182] X-SpamReason: No, hits=0.2 required=7.0 tests=RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22289 invoked from network); 12 Oct 2014 20:41:02 -0000 Received: from mail-wi0-f182.google.com (HELO mail-wi0-f182.google.com) (209.85.212.182) by server-5.tower-108.messagelabs.com with RC4-SHA encrypted SMTP; 12 Oct 2014 20:41:02 -0000 Received: by mail-wi0-f182.google.com with SMTP id n3so5928187wiv.9 for ; Sun, 12 Oct 2014 13:41:01 -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=PBRTSSqM7E3ePwLSbzrq2aHYnegyGimpPwo4F9631So=; b=yQgDWWLjN4M1Ua1W3eTX4iPgUFO7fSe/bw929anqgS0cx9UCTCScV4jTHI8ZCG69fP Sxx9eB+FMn3NpQZbzlyzQ1UaY8m6Sd9Zg+2cr4453oiAtMwE5tc/SWCEq9Sks57+shIZ +Pa/tEEWELVMEogUqVKV5FZtWR263aJYHR7S5GOk+XhAu8CE7yHiWmRCqrOwkQ9znP6D lUJI5lno5zUkZUH1HL3A1OSB4YKteqLjvLj5SkoFhripdXy+i6y0Nolvkib10nwS+Edx 2Uis4NRkhhwqz3J8CUo3+Go27ozRgrYF48xxdrqELAxNlvKPBm0/SQUcztpCaGNalalA iQbQ== X-Received: by 10.180.73.143 with SMTP id l15mr16606778wiv.76.1413146461045; Sun, 12 Oct 2014 13:41:01 -0700 (PDT) Received: from tango-charlie.Home ([2.127.193.40]) by mx.google.com with ESMTPSA id y5sm9970930wix.10.2014.10.12.13.40.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Oct 2014 13:41:00 -0700 (PDT) From: "Lad, Prabhakar" To: LMML Subject: [PATCH 07/15] media: davinci: vpbe: use fh handling provided by v4l Date: Sun, 12 Oct 2014 21:40:37 +0100 Message-ID: <1413146445-7304-8-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@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=unavailable 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 converts the driver to use fh handling provided by the v4l core instead of driver doing it. Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpbe_display.c | 189 +++++++++----------------- include/media/davinci/vpbe_display.h | 11 -- 2 files changed, 65 insertions(+), 135 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index fc3bdb6..970242c 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c @@ -628,8 +628,8 @@ static int vpbe_try_format(struct vpbe_display *disp_dev, static int vpbe_display_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + struct vpbe_layer *layer = video_drvdata(file); + struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; cap->version = VPBE_DISPLAY_VERSION_CODE; cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; @@ -646,9 +646,8 @@ static int vpbe_display_querycap(struct file *file, void *priv, static int vpbe_display_s_crop(struct file *file, void *priv, const struct v4l2_crop *crop) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_display *disp_dev = fh->disp_dev; + struct vpbe_layer *layer = video_drvdata(file); + struct vpbe_display *disp_dev = layer->disp_dev; struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; struct osd_layer_config *cfg = &layer->layer_info.config; struct osd_state *osd_device = disp_dev->osd_device; @@ -715,11 +714,10 @@ static int vpbe_display_s_crop(struct file *file, void *priv, static int vpbe_display_g_crop(struct file *file, void *priv, struct v4l2_crop *crop) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; + struct vpbe_layer *layer = video_drvdata(file); struct osd_layer_config *cfg = &layer->layer_info.config; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; - struct osd_state *osd_device = fh->disp_dev->osd_device; + struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; + struct osd_state *osd_device = layer->disp_dev->osd_device; struct v4l2_rect *rect = &crop->c; v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, @@ -743,8 +741,8 @@ static int vpbe_display_g_crop(struct file *file, void *priv, static int vpbe_display_cropcap(struct file *file, void *priv, struct v4l2_cropcap *cropcap) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_CROPCAP ioctl\n"); @@ -761,9 +759,8 @@ static int vpbe_display_cropcap(struct file *file, void *priv, static int vpbe_display_g_fmt(struct file *file, void *priv, struct v4l2_format *fmt) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_G_FMT, layer id = %d\n", @@ -783,9 +780,8 @@ static int vpbe_display_g_fmt(struct file *file, void *priv, static int vpbe_display_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *fmt) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + struct vpbe_layer *layer = video_drvdata(file); + struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; unsigned int index = 0; v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, @@ -815,9 +811,8 @@ static int vpbe_display_enum_fmt(struct file *file, void *priv, static int vpbe_display_s_fmt(struct file *file, void *priv, struct v4l2_format *fmt) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_display *disp_dev = fh->disp_dev; + struct vpbe_layer *layer = video_drvdata(file); + struct vpbe_display *disp_dev = layer->disp_dev; struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; struct osd_layer_config *cfg = &layer->layer_info.config; struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; @@ -904,9 +899,9 @@ static int vpbe_display_s_fmt(struct file *file, void *priv, static int vpbe_display_try_fmt(struct file *file, void *priv, struct v4l2_format *fmt) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_display *disp_dev = fh->disp_dev; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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 v4l2_pix_format *pixfmt = &fmt->fmt.pix; v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_TRY_FMT\n"); @@ -930,9 +925,8 @@ static int vpbe_display_try_fmt(struct file *file, void *priv, static int vpbe_display_s_std(struct file *file, void *priv, v4l2_std_id std_id) { - struct vpbe_fh *fh = priv; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_S_STD\n"); @@ -965,8 +959,8 @@ static int vpbe_display_s_std(struct file *file, void *priv, static int vpbe_display_g_std(struct file *file, void *priv, v4l2_std_id *std_id) { - struct vpbe_fh *fh = priv; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_G_STD\n"); @@ -988,8 +982,8 @@ static int vpbe_display_g_std(struct file *file, void *priv, static int vpbe_display_enum_output(struct file *file, void *priv, struct v4l2_output *output) { - struct vpbe_fh *fh = priv; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_ENUM_OUTPUT\n"); @@ -1016,9 +1010,8 @@ static int vpbe_display_enum_output(struct file *file, void *priv, static int vpbe_display_s_output(struct file *file, void *priv, unsigned int i) { - struct vpbe_fh *fh = priv; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_S_OUTPUT\n"); @@ -1047,8 +1040,8 @@ static int vpbe_display_s_output(struct file *file, void *priv, static int vpbe_display_g_output(struct file *file, void *priv, unsigned int *i) { - struct vpbe_fh *fh = priv; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_G_OUTPUT\n"); /* Get the standard from the current encoder */ @@ -1067,8 +1060,8 @@ static int vpbe_display_enum_dv_timings(struct file *file, void *priv, struct v4l2_enum_dv_timings *timings) { - struct vpbe_fh *fh = priv; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_ENUM_DV_TIMINGS\n"); @@ -1097,9 +1090,8 @@ static int vpbe_display_s_dv_timings(struct file *file, void *priv, struct v4l2_dv_timings *timings) { - struct vpbe_fh *fh = priv; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_S_DV_TIMINGS\n"); @@ -1135,8 +1127,8 @@ static int vpbe_display_g_dv_timings(struct file *file, void *priv, struct v4l2_dv_timings *dv_timings) { - struct vpbe_fh *fh = priv; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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_G_DV_TIMINGS\n"); @@ -1155,10 +1147,9 @@ vpbe_display_g_dv_timings(struct file *file, void *priv, static int vpbe_display_streamoff(struct file *file, void *priv, enum v4l2_buf_type buf_type) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; - struct osd_state *osd_device = fh->disp_dev->osd_device; + 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, @@ -1170,12 +1161,6 @@ static int vpbe_display_streamoff(struct file *file, void *priv, return -EINVAL; } - /* If io is allowed for this file handle, return error */ - if (!fh->io_allowed) { - v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); - return -EACCES; - } - /* If streaming is not started, return error */ if (!layer->started) { v4l2_err(&vpbe_dev->v4l2_dev, "streaming not started in layer" @@ -1194,10 +1179,9 @@ static int vpbe_display_streamoff(struct file *file, void *priv, static int vpbe_display_streamon(struct file *file, void *priv, enum v4l2_buf_type buf_type) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_display *disp_dev = fh->disp_dev; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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; @@ -1212,11 +1196,6 @@ static int vpbe_display_streamon(struct file *file, void *priv, return -EINVAL; } - /* If file handle is not allowed IO, return error */ - if (!fh->io_allowed) { - v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); - return -EACCES; - } /* If Streaming is already started, return error */ if (layer->started) { v4l2_err(&vpbe_dev->v4l2_dev, "layer is already streaming\n"); @@ -1239,9 +1218,8 @@ static int vpbe_display_streamon(struct file *file, void *priv, static int vpbe_display_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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, @@ -1252,11 +1230,6 @@ static int vpbe_display_dqbuf(struct file *file, void *priv, v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); return -EINVAL; } - /* If this file handle is not allowed to do IO, return error */ - if (!fh->io_allowed) { - v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); - return -EACCES; - } if (file->f_flags & O_NONBLOCK) /* Call videobuf_dqbuf for non blocking mode */ ret = vb2_dqbuf(&layer->buffer_queue, buf, 1); @@ -1270,9 +1243,8 @@ static int vpbe_display_dqbuf(struct file *file, void *priv, static int vpbe_display_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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", @@ -1283,21 +1255,14 @@ static int vpbe_display_qbuf(struct file *file, void *priv, return -EINVAL; } - /* If this file handle is not allowed to do IO, return error */ - if (!fh->io_allowed) { - v4l2_err(&vpbe_dev->v4l2_dev, "No io_allowed\n"); - return -EACCES; - } - return vb2_qbuf(&layer->buffer_queue, p); } static int vpbe_display_querybuf(struct file *file, void *priv, struct v4l2_buffer *buf) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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", @@ -1314,9 +1279,8 @@ static int vpbe_display_querybuf(struct file *file, void *priv, static int vpbe_display_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *req_buf) { - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; + 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"); @@ -1330,8 +1294,6 @@ static int vpbe_display_reqbufs(struct file *file, void *priv, v4l2_err(&vpbe_dev->v4l2_dev, "not IO user\n"); return -EBUSY; } - /* Set io allowed member of file handle to TRUE */ - fh->io_allowed = 1; /* Increment io usrs member of layer object to 1 */ layer->io_usrs = 1; /* Store type of memory requested in layer object */ @@ -1347,30 +1309,22 @@ static int vpbe_display_reqbufs(struct file *file, void *priv, */ static int vpbe_display_open(struct file *file) { - struct vpbe_fh *fh = NULL; struct vpbe_layer *layer = video_drvdata(file); - struct video_device *vdev = video_devdata(file); struct vpbe_display *disp_dev = layer->disp_dev; struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; struct osd_state *osd_device = disp_dev->osd_device; int err; - /* Allocate memory for the file handle object */ - fh = kmalloc(sizeof(struct vpbe_fh), GFP_KERNEL); - if (fh == NULL) { - v4l2_err(&vpbe_dev->v4l2_dev, - "unable to allocate memory for file handle object\n"); - return -ENOMEM; + /* creating context for file descriptor */ + err = v4l2_fh_open(file); + if (err) { + v4l2_err(&vpbe_dev->v4l2_dev, "v4l2_fh_open failed\n"); + return err; } - v4l2_fh_init(&fh->fh, vdev); - v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, - "vpbe display open plane = %d\n", - layer->device_id); - /* store pointer to fh in private_data member of filep */ - file->private_data = fh; - fh->layer = layer; - fh->disp_dev = disp_dev; + /* leaving if layer is already initialized */ + if (!v4l2_fh_is_singular_file(file)) + return err; if (!layer->usrs) { if (mutex_lock_interruptible(&layer->opslock)) @@ -1383,15 +1337,12 @@ static int vpbe_display_open(struct file *file) /* Couldn't get layer */ v4l2_err(&vpbe_dev->v4l2_dev, "Display Manager failed to allocate layer\n"); - kfree(fh); + v4l2_fh_release(file); return -EINVAL; } } /* Increment layer usrs counter */ layer->usrs++; - /* Set io_allowed member to false */ - fh->io_allowed = 0; - v4l2_fh_add(&fh->fh); v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe display device opened successfully\n"); return 0; @@ -1404,26 +1355,21 @@ static int vpbe_display_open(struct file *file) */ static int vpbe_display_release(struct file *file) { - /* Get the layer object and file handle object */ - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; + struct vpbe_layer *layer = video_drvdata(file); struct osd_layer_config *cfg = &layer->layer_info.config; - struct vpbe_display *disp_dev = fh->disp_dev; + struct vpbe_display *disp_dev = layer->disp_dev; struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; struct osd_state *osd_device = disp_dev->osd_device; v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_release\n"); mutex_lock(&layer->opslock); - /* if this instance is doing IO */ - if (fh->io_allowed) { - /* Reset io_usrs member of layer object */ - layer->io_usrs = 0; + /* Reset io_usrs member of layer object */ + layer->io_usrs = 0; - osd_device->ops.disable_layer(osd_device, - layer->layer_info.id); - layer->started = 0; - } + osd_device->ops.disable_layer(osd_device, + layer->layer_info.id); + layer->started = 0; /* Decrement layer usrs counter */ layer->usrs--; @@ -1444,14 +1390,9 @@ static int vpbe_display_release(struct file *file) layer->layer_info.id); } - v4l2_fh_del(&fh->fh); - v4l2_fh_exit(&fh->fh); - file->private_data = NULL; + _vb2_fop_release(file, NULL); mutex_unlock(&layer->opslock); - /* Free memory allocated to file handle object */ - kfree(fh); - disp_dev->cbcr_ofst = 0; return 0; diff --git a/include/media/davinci/vpbe_display.h b/include/media/davinci/vpbe_display.h index 637749a..06ea815 100644 --- a/include/media/davinci/vpbe_display.h +++ b/include/media/davinci/vpbe_display.h @@ -131,17 +131,6 @@ struct vpbe_display { struct osd_state *osd_device; }; -/* File handle structure */ -struct vpbe_fh { - struct v4l2_fh fh; - /* vpbe device structure */ - struct vpbe_display *disp_dev; - /* pointer to layer object for opened device */ - struct vpbe_layer *layer; - /* Indicates whether this file handle is doing IO */ - unsigned char io_allowed; -}; - struct buf_config_params { unsigned char min_numbuffers; unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];