From patchwork Fri May 16 13:33:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 4192071 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 A94419F1C0 for ; Fri, 16 May 2014 13:41:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1266201BC for ; Fri, 16 May 2014 13:41:55 +0000 (UTC) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B4E420200 for ; Fri, 16 May 2014 13:41:54 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4GDf35f024208; Fri, 16 May 2014 08:41:03 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4GDf2Ua006926; Fri, 16 May 2014 08:41:02 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Fri, 16 May 2014 08:41:02 -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 s4GDf2TJ025886; Fri, 16 May 2014 08:41:02 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 6697F80626; Fri, 16 May 2014 08:41:02 -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 6F1A88062A for ; Fri, 16 May 2014 08:37:59 -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 s4GDbxHl008997 for ; Fri, 16 May 2014 08:37:59 -0500 Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by red.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4GDbwUb006902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 May 2014 08:37:59 -0500 Received: from [216.82.250.51:24171] by server-12.bemta-12.messagelabs.com id D8/B4-29721-6B416735; Fri, 16 May 2014 13:37:58 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-8.tower-108.messagelabs.com!1400247476!13706730!1 X-Originating-IP: [209.85.160.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 29047 invoked from network); 16 May 2014 13:37:57 -0000 Received: from mail-pb0-f51.google.com (HELO mail-pb0-f51.google.com) (209.85.160.51) by server-8.tower-108.messagelabs.com with RC4-SHA encrypted SMTP; 16 May 2014 13:37:57 -0000 Received: by mail-pb0-f51.google.com with SMTP id ma3so2622357pbc.38 for ; Fri, 16 May 2014 06:37:56 -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=AWhwpCaC6+sjCbkpafsilmdwyVn179DMFMn+yOSga90=; b=HlXMvWa+TxuUchfIkTwfNYcuASw4bzekbZyPFPHYEFkbl4lcQ8RC1OzY8HeP5AzfH2 kglYAnRdvftXuokHiz6yd12k7TXH9RhxghhcqdyxFl52ysy/Ox3EEagd3C2bOzh2tZK/ /PSx4XOErNgvCXpHyrUVMazdqZ6Bz1VSN75sjrvGymQxxPX7HVEmHwPxLa/aFz9R1XtF O0fvgNy3fVgsE3yhPIGrGhZDJeu1uX/bpVMz2nFKQwsRYANG85XJ12yE3J7U0Za/9M9f w9x+w/GVu5QbeoAHtdHvFQvtxuHlGtrk4iBIUtb3fRbjmU/kn7a0WuPY8/5aC1QAdmFJ FgLg== X-Received: by 10.67.24.1 with SMTP id ie1mr20909074pad.133.1400247476700; Fri, 16 May 2014 06:37:56 -0700 (PDT) Received: from localhost.localdomain ([27.107.45.22]) by mx.google.com with ESMTPSA id cj1sm34699547pac.40.2014.05.16.06.37.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 06:37:55 -0700 (PDT) From: "Lad, Prabhakar" To: LMML , Hans Verkuil Subject: [PATCH v5 08/49] media: davinci: vpif_display: improve start/stop_streaming callbacks Date: Fri, 16 May 2014 19:03:13 +0530 Message-ID: <1400247235-31434-10-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 drops unnecessary check from start_streaming() callback as this is already done in try/s_fmt and some minor code cleanups, drops check for vb2_is_streaming() as this check is done by vb2 itself before calling this callback. Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpif_display.c | 59 ++++++++++++++----------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 1b6cbe8..933d28f 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -62,11 +62,18 @@ static struct vpif_config_params config_params = { .channel_bufsize[1] = 720 * 576 * 2, }; +static u8 channel_first_int[VPIF_NUMOBJECTS][2] = { {1, 1} }; + static struct vpif_device vpif_obj = { {NULL} }; static struct device *vpif_dev; static void vpif_calculate_offsets(struct channel_obj *ch); static void vpif_config_addr(struct channel_obj *ch, int muxmode); +static inline struct vpif_disp_buffer *to_vpif_buffer(struct vb2_buffer *vb) +{ + return container_of(vb, struct vpif_disp_buffer, vb); +} + /** * vpif_buffer_prepare : callback function for buffer prepare * @vb: ptr to vb2_buffer @@ -139,13 +146,15 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, return 0; } -/* - * vpif_buffer_queue: This function adds the buffer to DMA queue +/** + * vpif_buffer_queue : Callback function to add buffer to DMA queue + * @vb: ptr to vb2_buffer + * + * This callback fucntion queues the buffer to DMA engine */ static void vpif_buffer_queue(struct vb2_buffer *vb) { - struct vpif_disp_buffer *buf = container_of(vb, - struct vpif_disp_buffer, vb); + struct vpif_disp_buffer *buf = to_vpif_buffer(vb); struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue); struct common_obj *common; unsigned long flags; @@ -158,8 +167,11 @@ static void vpif_buffer_queue(struct vb2_buffer *vb) spin_unlock_irqrestore(&common->irqlock, flags); } -static u8 channel_first_int[VPIF_NUMOBJECTS][2] = { {1, 1} }; - +/** + * vpif_start_streaming : Starts the DMA engine for streaming + * @vb: ptr to vb2_buffer + * @count: number of buffers + */ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) { struct vpif_display_config *vpif_config_data = @@ -177,16 +189,6 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) ch->field_id = 0; common->started = 1; - if ((ch->vpifparams.std_info.frm_fmt && - ((common->fmt.fmt.pix.field != V4L2_FIELD_NONE) - && (common->fmt.fmt.pix.field != V4L2_FIELD_ANY))) - || (!ch->vpifparams.std_info.frm_fmt - && (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) { - vpif_err("conflict in field format and std format\n"); - ret = -EINVAL; - goto err; - } - /* clock settings */ if (vpif_config_data->set_clock) { ret = vpif_config_data->set_clock(ch->vpifparams.std_info. @@ -220,8 +222,10 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) (addr + common->ctop_off), (addr + common->cbtm_off)); - /* Set interrupt for both the fields in VPIF - Register enable channel in VPIF register */ + /* + * Set interrupt for both the fields in VPIF + * Register enable channel in VPIF register + */ channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { channel2_intr_assert(); @@ -231,8 +235,8 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) channel2_clipping_enable(1); } - if ((VPIF_CHANNEL3_VIDEO == ch->channel_id) - || (common->started == 2)) { + if (VPIF_CHANNEL3_VIDEO == ch->channel_id || + common->started == 2) { channel3_intr_assert(); channel3_intr_enable(1); enable_channel3(1); @@ -251,16 +255,19 @@ err: return ret; } -/* abort streaming and wait for last buffer */ +/** + * vpif_stop_streaming : Stop the DMA engine + * @vq: ptr to vb2_queue + * + * This callback stops the DMA engine and any remaining buffers + * in the DMA queue are released. + */ static void vpif_stop_streaming(struct vb2_queue *vq) { struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common; unsigned long flags; - if (!vb2_is_streaming(vq)) - return; - common = &ch->common[VPIF_VIDEO_INDEX]; /* Disable channel */ @@ -268,8 +275,8 @@ static void vpif_stop_streaming(struct vb2_queue *vq) enable_channel2(0); channel2_intr_enable(0); } - if ((VPIF_CHANNEL3_VIDEO == ch->channel_id) || - (2 == common->started)) { + if (VPIF_CHANNEL3_VIDEO == ch->channel_id || + 2 == common->started) { enable_channel3(0); channel3_intr_enable(0); }