From patchwork Fri May 16 13:33:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 4193031 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 183349F1C0 for ; Fri, 16 May 2014 13:55:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 273C720379 for ; Fri, 16 May 2014 13:55:44 +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 277C120295 for ; Fri, 16 May 2014 13:55:43 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4GDskc8019719; Fri, 16 May 2014 08:54:46 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDskan027456; Fri, 16 May 2014 08:54:46 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Fri, 16 May 2014 08:54:46 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDsk2m009235; Fri, 16 May 2014 08:54:46 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 63FE180628; Fri, 16 May 2014 08:54:46 -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 6D0DE8065D for ; Fri, 16 May 2014 08:41:47 -0500 (CDT) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dlelxv84.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDflZL011665 for ; Fri, 16 May 2014 08:41:47 -0500 Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by red.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4GDfkGo007929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 May 2014 08:41:47 -0500 Received: from [216.82.242.131:1073] by server-17.bemta-8.messagelabs.com id 36/AF-09669-A9516735; Fri, 16 May 2014 13:41:46 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-8.tower-76.messagelabs.com!1400247704!30976629!1 X-Originating-IP: [209.85.160.45] 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 11836 invoked from network); 16 May 2014 13:41:45 -0000 Received: from mail-pb0-f45.google.com (HELO mail-pb0-f45.google.com) (209.85.160.45) by server-8.tower-76.messagelabs.com with RC4-SHA encrypted SMTP; 16 May 2014 13:41:45 -0000 Received: by mail-pb0-f45.google.com with SMTP id um1so2627952pbc.4 for ; Fri, 16 May 2014 06:41:44 -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=k61N2C5uM/6tPO242oCtvHAl0n/UPYjNM5sdw6q7SG4=; b=LrvoBkiA6MIG9TWJemfByOoAfym76l6ZfijVGpWQ9EV/AsZwsgVwke5eKWTFPvsOiK q2/ZNvlEp9S1gyo3+7cgqZrSJgfr/lu4Xm0/omgPVvoSShJdH1nccaGXpDMtj72U8MDV 85ITDgHrcXQc3DcTTunw9r1KpuIMSleNfpSPIB11u6Yq9/bxUTuWVxPKfbw+UCHZ5C1J ZHpDHN94ZDLnf1WxrnH94kr/g7dr1FiOn2/BMldZ5MOlFM7lexzwDVROXrX33d15EheO IF75X7Oc15yJv0YjbkNjMSCalYW/O87SeboM2I5/5FIRCRgW/3pFWuvTKb0h3wUqTWr1 5vlw== X-Received: by 10.66.155.102 with SMTP id vv6mr21069557pab.89.1400247704728; Fri, 16 May 2014 06:41:44 -0700 (PDT) Received: from localhost.localdomain ([27.107.45.22]) by mx.google.com with ESMTPSA id cj1sm34699547pac.40.2014.05.16.06.41.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 06:41:43 -0700 (PDT) From: "Lad, Prabhakar" To: LMML , Hans Verkuil Subject: [PATCH v5 32/49] media: davinci: vpif_capture: improve vpif_buffer_queue_setup() function Date: Fri, 16 May 2014 19:03:38 +0530 Message-ID: <1400247235-31434-35-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 sets the sizes[0] of plane according to the fmt passed or which is being set in the channel, in both MMAP and USERPTR buffer type. This patch also move the calculation of offests(vpif_calculate_offsets()) to queue_setup() callback as after queue_setup() callback the application is no longer allowed to change format, and prepares to removal of config_params. Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpif_capture.c | 40 +++++-------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 025eb24..c77c176 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -134,45 +134,24 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, { struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common; - unsigned long size; common = &ch->common[VPIF_VIDEO_INDEX]; vpif_dbg(2, debug, "vpif_buffer_setup\n"); - /* If memory type is not mmap, return */ - if (V4L2_MEMORY_MMAP == common->memory) { - /* Calculate the size of the buffer */ - size = config_params.channel_bufsize[ch->channel_id]; - /* - * Checking if the buffer size exceeds the available buffer - * ycmux_mode = 0 means 1 channel mode HD and - * ycmux_mode = 1 means 2 channels mode SD - */ - if (ch->vpifparams.std_info.ycmux_mode == 0) { - if (config_params.video_limit[ch->channel_id]) - while (size * *nbuffers > - (config_params.video_limit[0] - + config_params.video_limit[1])) - (*nbuffers)--; - } else { - if (config_params.video_limit[ch->channel_id]) - while (size * *nbuffers > - config_params.video_limit[ch->channel_id]) - (*nbuffers)--; - } - - } else { - size = common->fmt.fmt.pix.sizeimage; - } + if (fmt && fmt->fmt.pix.sizeimage < common->fmt.fmt.pix.sizeimage) + return -EINVAL; - if (*nbuffers < config_params.min_numbuffers) - *nbuffers = config_params.min_numbuffers; + if (vq->num_buffers + *nbuffers < 3) + *nbuffers = 3 - vq->num_buffers; *nplanes = 1; - sizes[0] = size; + sizes[0] = fmt ? fmt->fmt.pix.sizeimage : common->fmt.fmt.pix.sizeimage; alloc_ctxs[0] = common->alloc_ctx; + /* Calculate the offset for Y and C data in the buffer */ + vpif_calculate_offsets(ch); + return 0; } @@ -214,9 +193,6 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) ch->field_id = 0; common->started = 1; - /* Calculate the offset for Y and C data in the buffer */ - vpif_calculate_offsets(ch); - if ((vpif->std_info.frm_fmt && ((common->fmt.fmt.pix.field != V4L2_FIELD_NONE) && (common->fmt.fmt.pix.field != V4L2_FIELD_ANY))) ||