Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3215037imu; Sat, 24 Nov 2018 00:17:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/UAcpFBjRk1MJ0fmvGEwitiDEWIPCIxK0v0qyq0y89H98A+xPoaLd8FzXBgFe5xbCbpDAJx X-Received: by 2002:a63:2643:: with SMTP id m64mr16788623pgm.35.1543047435288; Sat, 24 Nov 2018 00:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047435; cv=none; d=google.com; s=arc-20160816; b=Z55xd4br7GgLMa/wxGQfQOMn5y/p06iv3yAreYTkCVaQImfBHxouHy3LF+aPImgJ/M YGJC6h+uO9eDznONLDKfpcb8BTiTRA1lwDogq1j0kR4r0oaz50o3oMgDDbDeMqTgdtFR 29SN00/qY9DI23QU7b2RTs0hp7XXF43e3yM4wcbYzw7dE2Jepi2wGlhnFKy/Dp3FWxdz henIbQBTfBIVCgAZc8i+ulIOsx9jnAx8pAtTMnzeCVhue5lz15XWEhCySDo1xo6FP7g4 4aSEIZtoL7ePFwiy1h7BXjKzuzQk8vqcFjOkU995P/LtQX8ZzTha+PzzyQzez5yd1oa4 MhWg== 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=2NFNWHFnv1iLyM/ZdioL/8SaP8Scx9/2W76OYt/xtlw=; b=lHGXPSmDa8p010xMcVKWxQELxAPgtonVKCj7AJwbkBJthsQjeN7A5/nDkh+5twHcfW 5c1jD2kO2aOGc4jlhBUbNrJJ3zIT9GLYvKnJ22khbleFSL/6/qErhai30XPbDSo/79vn 6lbxWvEZig1rm4/h4/8UiIDPyLxhjHG3mu1XEqFikZXxehcDqG6r2gd+0Qt5LB77/sDJ UQBAogv0Av2MUpPLJ+vMgy3ahK9YAA3P2S0iE4ShvZwtcGoXJtMBk0Xi2nvU9fOraIww bTw9pMtsjvUvufLW7E1AL9ozEY+E5PGwJQUQXXjCh1Hiad4XioH3+dqBpO/vJR3tYxAU sROw== 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 e11si51277122pgf.450.2018.11.24.00.17.01; Sat, 24 Nov 2018 00:17:15 -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 S2502759AbeKWUK0 (ORCPT + 99 others); Fri, 23 Nov 2018 15:10:26 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49313 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390556AbeKWUKZ (ORCPT ); Fri, 23 Nov 2018 15:10:25 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id F288320DE1; 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 DA7D820DE4; Fri, 23 Nov 2018 10:26:31 +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 17/43] drm/sun4i: frontend: Add helpers for input data mode and pixel sequence Date: Fri, 23 Nov 2018 10:24:49 +0100 Message-Id: <20181123092515.2511-18-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 new helpers for retrieving the input data mode and pixel sequence register field values based on the DRM format instead of hardcoding these. This makes it easier to add support for more formats. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 46 +++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index f54b1c4a9264..bb5977a466f3 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -116,6 +116,30 @@ static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val) } } +static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val) +{ + switch (fmt) { + case DRM_FORMAT_XRGB8888: + *val = 1; + return 0; + + default: + return -EINVAL; + } +} + +static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val) +{ + switch (fmt) { + case DRM_FORMAT_XRGB8888: + *val = 1; + return 0; + + default: + return -EINVAL; + } +} + static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val) { switch (fmt) { @@ -149,17 +173,29 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend, { struct drm_plane_state *state = plane->state; struct drm_framebuffer *fb = state->fb; + uint32_t format = fb->format->format; u32 out_fmt_val; - u32 in_fmt_val; + u32 in_fmt_val, in_mod_val, in_ps_val; int ret; - ret = sun4i_frontend_drm_format_to_input_fmt(fb->format->format, - &in_fmt_val); + ret = sun4i_frontend_drm_format_to_input_fmt(format, &in_fmt_val); if (ret) { DRM_DEBUG_DRIVER("Invalid input format\n"); return ret; } + ret = sun4i_frontend_drm_format_to_input_mode(format, &in_mod_val); + if (ret) { + DRM_DEBUG_DRIVER("Invalid input mode\n"); + return ret; + } + + ret = sun4i_frontend_drm_format_to_input_sequence(format, &in_ps_val); + if (ret) { + DRM_DEBUG_DRIVER("Invalid pixel sequence\n"); + return ret; + } + ret = sun4i_frontend_drm_format_to_output_fmt(out_fmt, &out_fmt_val); if (ret) { DRM_DEBUG_DRIVER("Invalid output format\n"); @@ -182,9 +218,9 @@ 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(1) | + SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(in_mod_val) | SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(in_fmt_val) | - SUN4I_FRONTEND_INPUT_FMT_PS(1)); + SUN4I_FRONTEND_INPUT_FMT_PS(in_ps_val)); /* * TODO: It look like the A31 and A80 at least will need the -- 2.19.1