From patchwork Mon Nov 5 23:31:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10669469 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7DBB1751 for ; Mon, 5 Nov 2018 23:31:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE75A29FFF for ; Mon, 5 Nov 2018 23:31:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBA302A013; Mon, 5 Nov 2018 23:31:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0791429FFF for ; Mon, 5 Nov 2018 23:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726156AbeKFIyD (ORCPT ); Tue, 6 Nov 2018 03:54:03 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:59178 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbeKFIyD (ORCPT ); Tue, 6 Nov 2018 03:54:03 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1E28B6189D; Mon, 5 Nov 2018 23:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541460712; bh=5wCFHDx2YycsxZaPP5QeGbEoksvek7dQHxUk7/DU97w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=noVKh9qXCRhmCN/xPnY8mUM9VFlX0exNfgqxomlkiVWIJgvrpTMB3yrddPQ6DQBZf 6Pb1zGQH2CcTZTpHVZuTdAGY9p/9hf8ukxp/zn8j1fiLQ8Ot+QCAY7sojDdw3Pnl0U fo6GrIMqxgnm6CJFDTiDMDb7zacgsPb9b3Kpz+bM= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A0CFA61688; Mon, 5 Nov 2018 23:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541460680; bh=5wCFHDx2YycsxZaPP5QeGbEoksvek7dQHxUk7/DU97w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Co19rQffr2WYNypr9m/HITRpl+F3QyygCvJ5OxidvswBrUvxVIXbf01aqbOEHkMV1 xwRKQG3zkSv6092DXRkB98asHX8GkzLn94XCdd8spUsNgwYmxQenO7Vxp3RNasvtWI cHwF8qvGHFMtzJWZVv60yq9e/tEAvIxZsRbE2osg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A0CFA61688 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, seanpaul@chromium.org, abhinavk@codeaurora.org, dri-devel@lists.freedesktop.org, bzwang@chromium.org, sam@ravnborg.org Subject: [PATCH 11/11] drm/msm/dpu: Clean up dpu_media_info.h static inline functions Date: Mon, 5 Nov 2018 16:31:03 -0700 Message-Id: <20181105233103.7657-12-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181105233103.7657-1-jcrouse@codeaurora.org> References: <20181105233103.7657-1-jcrouse@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do some cleanup in the static inline functions defined in dpu_media_info.h by cleaning up gotos and unneeded local variables. Signed-off-by: Jordan Crouse Reviewed-by: Sean Paul Acked-by: Sam Ravnborg --- .../gpu/drm/msm/disp/dpu1/msm_media_info.h | 164 ++++++------------ 1 file changed, 57 insertions(+), 107 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h b/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h index 75470ee5b18f..8b8309f25c1a 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h +++ b/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h @@ -822,36 +822,30 @@ enum color_fmts { */ static unsigned int VENUS_Y_STRIDE(int color_fmt, int width) { - unsigned int alignment, stride = 0; + unsigned int stride = 0; if (!width) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV21: case COLOR_FMT_NV12: case COLOR_FMT_NV12_MVTB: case COLOR_FMT_NV12_UBWC: - alignment = 128; - stride = MSM_MEDIA_ALIGN(width, alignment); + stride = MSM_MEDIA_ALIGN(width, 128); break; case COLOR_FMT_NV12_BPP10_UBWC: - alignment = 256; stride = MSM_MEDIA_ALIGN(width, 192); - stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment); + stride = MSM_MEDIA_ALIGN(stride * 4/3, 256); break; case COLOR_FMT_P010_UBWC: - alignment = 256; - stride = MSM_MEDIA_ALIGN(width * 2, alignment); + stride = MSM_MEDIA_ALIGN(width * 2, 256); break; case COLOR_FMT_P010: - alignment = 128; - stride = MSM_MEDIA_ALIGN(width*2, alignment); - break; - default: + stride = MSM_MEDIA_ALIGN(width * 2, 128); break; } -invalid_input: + return stride; } @@ -864,36 +858,30 @@ static unsigned int VENUS_Y_STRIDE(int color_fmt, int width) */ static unsigned int VENUS_UV_STRIDE(int color_fmt, int width) { - unsigned int alignment, stride = 0; + unsigned int stride = 0; if (!width) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV21: case COLOR_FMT_NV12: case COLOR_FMT_NV12_MVTB: case COLOR_FMT_NV12_UBWC: - alignment = 128; - stride = MSM_MEDIA_ALIGN(width, alignment); + stride = MSM_MEDIA_ALIGN(width, 128); break; case COLOR_FMT_NV12_BPP10_UBWC: - alignment = 256; stride = MSM_MEDIA_ALIGN(width, 192); - stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment); + stride = MSM_MEDIA_ALIGN(stride * 4/3, 256); break; case COLOR_FMT_P010_UBWC: - alignment = 256; - stride = MSM_MEDIA_ALIGN(width * 2, alignment); + stride = MSM_MEDIA_ALIGN(width * 2, 256); break; case COLOR_FMT_P010: - alignment = 128; - stride = MSM_MEDIA_ALIGN(width*2, alignment); - break; - default: + stride = MSM_MEDIA_ALIGN(width*2, 128); break; } -invalid_input: + return stride; } @@ -906,10 +894,10 @@ static unsigned int VENUS_UV_STRIDE(int color_fmt, int width) */ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) { - unsigned int alignment, sclines = 0; + unsigned int sclines = 0; if (!height) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV21: @@ -917,17 +905,14 @@ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) case COLOR_FMT_NV12_MVTB: case COLOR_FMT_NV12_UBWC: case COLOR_FMT_P010: - alignment = 32; + sclines = MSM_MEDIA_ALIGN(height, 32); break; case COLOR_FMT_NV12_BPP10_UBWC: case COLOR_FMT_P010_UBWC: - alignment = 16; + sclines = MSM_MEDIA_ALIGN(height, 16); break; - default: - return 0; } - sclines = MSM_MEDIA_ALIGN(height, alignment); -invalid_input: + return sclines; } @@ -940,10 +925,10 @@ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) */ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) { - unsigned int alignment, sclines = 0; + unsigned int sclines = 0; if (!height) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV21: @@ -952,18 +937,13 @@ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) case COLOR_FMT_NV12_BPP10_UBWC: case COLOR_FMT_P010_UBWC: case COLOR_FMT_P010: - alignment = 16; + sclines = MSM_MEDIA_ALIGN((height+1)>>1, 16); break; case COLOR_FMT_NV12_UBWC: - alignment = 32; + sclines = MSM_MEDIA_ALIGN((height+1)>>1, 32); break; - default: - goto invalid_input; } - sclines = MSM_MEDIA_ALIGN((height+1)>>1, alignment); - -invalid_input: return sclines; } @@ -976,10 +956,10 @@ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) */ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) { - int y_tile_width = 0, y_meta_stride = 0; + int y_tile_width = 0, y_meta_stride; if (!width) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV12_UBWC: @@ -990,14 +970,11 @@ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) y_tile_width = 48; break; default: - goto invalid_input; + return 0; } y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width); - y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64); - -invalid_input: - return y_meta_stride; + return MSM_MEDIA_ALIGN(y_meta_stride, 64); } /* @@ -1009,10 +986,10 @@ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) */ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) { - int y_tile_height = 0, y_meta_scanlines = 0; + int y_tile_height = 0, y_meta_scanlines; if (!height) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV12_UBWC: @@ -1023,14 +1000,11 @@ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) y_tile_height = 4; break; default: - goto invalid_input; + return 0; } y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height); - y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16); - -invalid_input: - return y_meta_scanlines; + return MSM_MEDIA_ALIGN(y_meta_scanlines, 16); } /* @@ -1042,10 +1016,10 @@ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) */ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) { - int uv_tile_width = 0, uv_meta_stride = 0; + int uv_tile_width = 0, uv_meta_stride; if (!width) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV12_UBWC: @@ -1056,14 +1030,11 @@ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) uv_tile_width = 24; break; default: - goto invalid_input; + return 0; } uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width); - uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64); - -invalid_input: - return uv_meta_stride; + return MSM_MEDIA_ALIGN(uv_meta_stride, 64); } /* @@ -1075,10 +1046,10 @@ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) */ static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height) { - int uv_tile_height = 0, uv_meta_scanlines = 0; + int uv_tile_height = 0, uv_meta_scanlines; if (!height) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_NV12_UBWC: @@ -1089,22 +1060,19 @@ static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height) uv_tile_height = 4; break; default: - goto invalid_input; + return 0; } uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height); - uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16); - -invalid_input: - return uv_meta_scanlines; + return MSM_MEDIA_ALIGN(uv_meta_scanlines, 16); } static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width) { - unsigned int alignment = 0, stride = 0, bpp = 4; + unsigned int alignment = 0, bpp = 4; if (!width) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_RGBA8888: @@ -1119,21 +1087,18 @@ static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width) alignment = 256; break; default: - goto invalid_input; + return 0; } - stride = MSM_MEDIA_ALIGN(width * bpp, alignment); - -invalid_input: - return stride; + return MSM_MEDIA_ALIGN(width * bpp, alignment); } static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height) { - unsigned int alignment = 0, scanlines = 0; + unsigned int alignment = 0; if (!height) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_RGBA8888: @@ -1145,61 +1110,46 @@ static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height) alignment = 16; break; default: - goto invalid_input; + return 0; } - scanlines = MSM_MEDIA_ALIGN(height, alignment); - -invalid_input: - return scanlines; + return MSM_MEDIA_ALIGN(height, alignment); } static unsigned int VENUS_RGB_META_STRIDE(int color_fmt, int width) { - int rgb_tile_width = 0, rgb_meta_stride = 0; + int rgb_meta_stride; if (!width) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_RGBA8888_UBWC: case COLOR_FMT_RGBA1010102_UBWC: case COLOR_FMT_RGB565_UBWC: - rgb_tile_width = 16; - break; - default: - goto invalid_input; + rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, 16); + return MSM_MEDIA_ALIGN(rgb_meta_stride, 64); } - rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width); - rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64); - -invalid_input: - return rgb_meta_stride; + return 0; } static unsigned int VENUS_RGB_META_SCANLINES(int color_fmt, int height) { - int rgb_tile_height = 0, rgb_meta_scanlines = 0; + int rgb_meta_scanlines; if (!height) - goto invalid_input; + return 0; switch (color_fmt) { case COLOR_FMT_RGBA8888_UBWC: case COLOR_FMT_RGBA1010102_UBWC: case COLOR_FMT_RGB565_UBWC: - rgb_tile_height = 4; - break; - default: - goto invalid_input; + rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, 4); + return MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16); } - rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height); - rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16); - -invalid_input: - return rgb_meta_scanlines; + return 0; } #endif