From patchwork Fri May 16 13:33:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 4191641 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 23B9CBFF02 for ; Fri, 16 May 2014 13:37:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D85FB20200 for ; Fri, 16 May 2014 13:37:01 +0000 (UTC) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD1ED2026F for ; Fri, 16 May 2014 13:36:59 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4GDa0mD003526; Fri, 16 May 2014 08:36:00 -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 s4GDZxf7031720; Fri, 16 May 2014 08:35:59 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 16 May 2014 08:35:59 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDZw4E022552; Fri, 16 May 2014 08:35:58 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 654F680628; Fri, 16 May 2014 08:35:58 -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 6130080626 for ; Fri, 16 May 2014 08:35:57 -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 s4GDZvCa007902 for ; Fri, 16 May 2014 08:35:57 -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 s4GDZu0O000470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 May 2014 08:35:56 -0500 Received: from [216.82.250.83:42741] by server-5.bemta-12.messagelabs.com id 3F/6F-18132-C3416735; Fri, 16 May 2014 13:35:56 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-16.tower-120.messagelabs.com!1400247354!4609804!1 X-Originating-IP: [209.85.220.51] X-SpamReason: No, hits=0.0 required=7.0 tests=ML_RADAR_SPEW_LINKS_14, spamassassin: X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17358 invoked from network); 16 May 2014 13:35:55 -0000 Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by server-16.tower-120.messagelabs.com with RC4-SHA encrypted SMTP; 16 May 2014 13:35:55 -0000 Received: by mail-pa0-f51.google.com with SMTP id kq14so2537531pab.24 for ; Fri, 16 May 2014 06:35:54 -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=nOAjWLGdFUBnuIJG/c9/saPiLNsHgAQdL3TIi8fN5uM=; b=cEEhsg85mtQ4cCHFV+7+0NB2TPzAr5SS5dBjgFmU95dPcFWlfgnWGgQ0+6rBZOJmrO FTSbI0iYq++B7NdZ+wO6n7LLzzgm6bO+qeSY4TMze6yjdtEtKm74P9zDegrH1vKeGCYs rMeCt9mBvQwj/zWXyOFWIpUPHzr+jk87TAvgKYizKPLsHOPmmitfVQmHBGwNa+3/GeSM RA1nNPCEOtkyce5zJMZXUFCByCd8igFwTTj01iUa4mDA8Xq47kZ8OUE3KZ5ol95OIz76 93E5QfevnKfcbEnU4m6H2iYO6350HcoGBL5p4ZG3FEIcmSN1RgoujOQiBpP/znrVURMM mjRg== X-Received: by 10.68.249.2 with SMTP id yq2mr21082045pbc.70.1400247350568; Fri, 16 May 2014 06:35:50 -0700 (PDT) Received: from localhost.localdomain ([27.107.45.22]) by mx.google.com with ESMTPSA id cj1sm34699547pac.40.2014.05.16.06.35.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 06:35:48 -0700 (PDT) From: "Lad, Prabhakar" To: LMML , Hans Verkuil Subject: [PATCH v5 01/49] media: davinci: vpif_display: initalize vb2 queue and DMA context during probe Date: Fri, 16 May 2014 19:03:05 +0530 Message-ID: <1400247235-31434-2-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" this patch moves the initalization of vb2 queue and the DMA context to probe() and clean up in remove() callback respectively. Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpif_display.c | 86 ++++++++++++------------- 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index d03487f..dbd4f0f 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -74,12 +74,12 @@ static void vpif_config_addr(struct channel_obj *ch, int muxmode); */ static int vpif_buffer_prepare(struct vb2_buffer *vb) { - struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue); struct vb2_queue *q = vb->vb2_queue; + struct channel_obj *ch = vb2_get_drv_priv(q); struct common_obj *common; unsigned long addr; - common = &fh->channel->common[VPIF_VIDEO_INDEX]; + common = &ch->common[VPIF_VIDEO_INDEX]; if (vb->state != VB2_BUF_STATE_ACTIVE && vb->state != VB2_BUF_STATE_PREPARED) { vb2_set_plane_payload(vb, 0, common->fmt.fmt.pix.sizeimage); @@ -112,8 +112,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) { - struct vpif_fh *fh = vb2_get_drv_priv(vq); - struct channel_obj *ch = fh->channel; + struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; unsigned long size; @@ -154,10 +153,9 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, */ static void vpif_buffer_queue(struct vb2_buffer *vb) { - struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue); struct vpif_disp_buffer *buf = container_of(vb, struct vpif_disp_buffer, vb); - struct channel_obj *ch = fh->channel; + struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue); struct common_obj *common; unsigned long flags; @@ -175,10 +173,9 @@ static void vpif_buffer_queue(struct vb2_buffer *vb) */ static void vpif_buf_cleanup(struct vb2_buffer *vb) { - struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue); struct vpif_disp_buffer *buf = container_of(vb, struct vpif_disp_buffer, vb); - struct channel_obj *ch = fh->channel; + struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue); struct common_obj *common; unsigned long flags; @@ -192,8 +189,7 @@ static void vpif_buf_cleanup(struct vb2_buffer *vb) static void vpif_wait_prepare(struct vb2_queue *vq) { - struct vpif_fh *fh = vb2_get_drv_priv(vq); - struct channel_obj *ch = fh->channel; + struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common; common = &ch->common[VPIF_VIDEO_INDEX]; @@ -202,8 +198,7 @@ static void vpif_wait_prepare(struct vb2_queue *vq) static void vpif_wait_finish(struct vb2_queue *vq) { - struct vpif_fh *fh = vb2_get_drv_priv(vq); - struct channel_obj *ch = fh->channel; + struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common; common = &ch->common[VPIF_VIDEO_INDEX]; @@ -226,8 +221,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) { struct vpif_display_config *vpif_config_data = vpif_dev->platform_data; - struct vpif_fh *fh = vb2_get_drv_priv(vq); - struct channel_obj *ch = fh->channel; + struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; struct vpif_params *vpif = &ch->vpifparams; unsigned long addr = 0; @@ -310,8 +304,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) /* abort streaming and wait for last buffer */ static void vpif_stop_streaming(struct vb2_queue *vq) { - struct vpif_fh *fh = vb2_get_drv_priv(vq); - struct channel_obj *ch = fh->channel; + struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common; unsigned long flags; @@ -794,10 +787,6 @@ static int vpif_release(struct file *filep) if (fh->io_allowed[VPIF_VIDEO_INDEX]) { /* Reset io_usrs member of channel object */ common->io_usrs = 0; - /* Free buffers allocated */ - vb2_queue_release(&common->buffer_queue); - vb2_dma_contig_cleanup_ctx(common->alloc_ctx); - common->numbuffers = config_params.numbuffers[ch->channel_id]; } @@ -939,9 +928,7 @@ static int vpif_reqbufs(struct file *file, void *priv, struct channel_obj *ch = fh->channel; struct common_obj *common; enum v4l2_field field; - struct vb2_queue *q; u8 index = 0; - int ret; /* This file handle has not initialized the channel, It is not allowed to do settings */ @@ -973,35 +960,12 @@ static int vpif_reqbufs(struct file *file, void *priv, } else { field = V4L2_VBI_INTERLACED; } - /* Initialize videobuf2 queue as per the buffer type */ - common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev); - if (IS_ERR(common->alloc_ctx)) { - vpif_err("Failed to get the context\n"); - return PTR_ERR(common->alloc_ctx); - } - q = &common->buffer_queue; - q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - q->io_modes = VB2_MMAP | VB2_USERPTR; - q->drv_priv = fh; - q->ops = &video_qops; - q->mem_ops = &vb2_dma_contig_memops; - q->buf_struct_size = sizeof(struct vpif_disp_buffer); - q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed = 1; - - ret = vb2_queue_init(q); - if (ret) { - vpif_err("vpif_display: vb2_queue_init() failed\n"); - vb2_dma_contig_cleanup_ctx(common->alloc_ctx); - return ret; - } /* Set io allowed member of file handle to TRUE */ fh->io_allowed[index] = 1; /* 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; - INIT_LIST_HEAD(&common->dma_queue); /* Allocate buffers */ return vb2_reqbufs(&common->buffer_queue, reqbuf); } @@ -1637,6 +1601,7 @@ static int vpif_probe_complete(void) { struct common_obj *common; struct channel_obj *ch; + struct vb2_queue *q; int j, err, k; for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) { @@ -1685,6 +1650,32 @@ static int vpif_probe_complete(void) if (err) goto probe_out; + /* Initialize vb2 queue */ + q = &common->buffer_queue; + q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; + q->drv_priv = ch; + q->ops = &video_qops; + q->mem_ops = &vb2_dma_contig_memops; + q->buf_struct_size = sizeof(struct vpif_disp_buffer); + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + q->min_buffers_needed = 1; + + err = vb2_queue_init(q); + if (err) { + vpif_err("vpif_display: vb2_queue_init() failed\n"); + goto probe_out; + } + + common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev); + if (IS_ERR(common->alloc_ctx)) { + vpif_err("Failed to get the context\n"); + err = PTR_ERR(common->alloc_ctx); + goto probe_out; + } + + INIT_LIST_HEAD(&common->dma_queue); + /* register video device */ vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", (int)ch, (int)&ch->video_dev); @@ -1700,6 +1691,8 @@ static int vpif_probe_complete(void) probe_out: for (k = 0; k < j; k++) { ch = vpif_obj.dev[k]; + common = &ch->common[k]; + vb2_dma_contig_cleanup_ctx(common->alloc_ctx); video_unregister_device(ch->video_dev); video_device_release(ch->video_dev); ch->video_dev = NULL; @@ -1865,6 +1858,7 @@ vpif_unregister: */ static int vpif_remove(struct platform_device *device) { + struct common_obj *common; struct channel_obj *ch; int i; @@ -1875,6 +1869,8 @@ static int vpif_remove(struct platform_device *device) for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) { /* Get the pointer to the channel object */ ch = vpif_obj.dev[i]; + common = &ch->common[i]; + vb2_dma_contig_cleanup_ctx(common->alloc_ctx); /* Unregister video device */ video_unregister_device(ch->video_dev);