Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3215000imu; Sat, 24 Nov 2018 00:17:12 -0800 (PST) X-Google-Smtp-Source: AJdET5ftIS2fIMzKETl1wLT6DodZDeyTWlAp6OkEaUMt3+aB2etEhKQ9XSRlmLF2tP0/wl5aCDNu X-Received: by 2002:a62:380e:: with SMTP id f14-v6mr19180378pfa.203.1543047432261; Sat, 24 Nov 2018 00:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047432; cv=none; d=google.com; s=arc-20160816; b=pT+frcLVTzD9bawBUohWy3RybPXIjJUIWumo+Ln/WlBKz0XqhoxrSTEbhHCuOpk+B8 K1eq/v4C802kOZ909Y3N5UKgCgrIVXaGUwb4yrfcFpdUlnjCiWcyDltwFn6hmAXUvqbe 8d9OIovKsJsBFLO0Gp7DmjOX2+U2swsIQEv8OfDnq8PgND/Zq59vaPD65RjSwNRabZjY /rNR8xzK9sSZRhfvtKmvGS0VQ69leubcdz2sPH9YHJAt7h6ElSfBltijdVrr1NB4HSbW wZML/4pBhrvmluvkuTjWAsVsWwLnrcggvEAmdQD38cLvphg8St9wyOCcs5lNJvd96fJG 2xlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nTymt5CN/7REVUE9mMa4eFZhjCtK0FzkooWPXA64EJo=; b=CvYj1XRaud6yB/N3Xp07gKT3f9WrTOGruoM01JKpRXT60LnHE8rfooueXwScLGghS+ AskRFcRJYjHJhHLOCqiGIp/rhJ3/0Ltm6zqB1GIjTkJAYJFZDFanS8DDaWlruwL/iysd N1IkIxK3rsxKOcyp8t/53CVpmQ0jlzE7zp9uuVTmTPQbNCbyAu8zRDrVXdD2vit1BwSC +xFG+1TrRBEylAaS2jWNcT0BJI5uTCacXzyDiT295OBMg+/W2PjiKM9KsFT1oHVcace7 Ls2AL6KxGInT6odjACN/oL8x1sXb7TRNTdHz2qJ0k/6Jpm7Db/Z26d5/2dn+va/KftoV ARLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si53317424pgb.491.2018.11.24.00.16.57; Sat, 24 Nov 2018 00:17:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502717AbeKWUKZ (ORCPT + 99 others); Fri, 23 Nov 2018 15:10:25 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49324 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393935AbeKWUKZ (ORCPT ); Fri, 23 Nov 2018 15:10:25 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 00926207AB; Fri, 23 Nov 2018 10:26:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 272CE20DE5; Fri, 23 Nov 2018 10:26:32 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Daniel Vetter , Paul Kocialkowski Subject: [PATCH v2 18/43] drm/sun4i: frontend: Add proper definitions for format registers Date: Fri, 23 Nov 2018 10:24:50 +0100 Message-Id: <20181123092515.2511-19-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This introduces proper definitions for the input and output format configuration registers instead of a macro and raw values in the code, with the intent to increase code readability and reduce indirections. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 14 ++++++-------- drivers/gpu/drm/sun4i/sun4i_frontend.h | 8 ++++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index bb5977a466f3..a305b731b042 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -108,7 +108,7 @@ static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 5; + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB; return 0; default: @@ -120,7 +120,7 @@ static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 1; + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED; return 0; default: @@ -132,7 +132,7 @@ static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 1; + *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB; return 0; default: @@ -144,7 +144,7 @@ static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) { switch (fmt) { case DRM_FORMAT_XRGB8888: - *val = 2; + *val = SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888; return 0; default: @@ -218,9 +218,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, SUN4I_FRONTEND_BYPASS_CSC_EN); regmap_write(frontend->regs, SUN4I_FRONTEND_INPUT_FMT_REG, - SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(in_mod_val) | - SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(in_fmt_val) | - SUN4I_FRONTEND_INPUT_FMT_PS(in_ps_val)); + in_mod_val | in_fmt_val | in_ps_val); /* * TODO: It look like the A31 and A80 at least will need the @@ -228,7 +226,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, * ARGB8888). */ regmap_write(frontend->regs, SUN4I_FRONTEND_OUTPUT_FMT_REG, - SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(out_fmt_val)); + out_fmt_val); return 0; } diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index a9cb908ced16..56bd5a3f9723 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -26,12 +26,12 @@ #define SUN4I_FRONTEND_LINESTRD0_REG 0x040 #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c -#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(mod) ((mod) << 8) -#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(fmt) ((fmt) << 4) -#define SUN4I_FRONTEND_INPUT_FMT_PS(ps) (ps) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB (5 << 4) +#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1 #define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c -#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(fmt) (fmt) +#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2 #define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100 #define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1))) -- 2.19.1