Received: by 10.192.165.156 with SMTP id m28csp493782imm; Thu, 19 Apr 2018 02:36:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+OT/gxFfldqLNLHoDT0mISUNVunm+fmhke3YgYSnaEotde6DRp24ZdQea4Dekr8u17Hfva X-Received: by 10.98.68.86 with SMTP id r83mr5178902pfa.145.1524130597410; Thu, 19 Apr 2018 02:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524130597; cv=none; d=google.com; s=arc-20160816; b=h5FaUBBGicO0+quxk+qZmRgCXPX6JPWvVrE6tairH/mZKwGnjXgukCqj32JKvc7Aqj IYm5WPQZM5KZP75e6Bthkpdi+gmbZ3r/NfMfTOrtrJa4D+Zs/Ryukm/vE4H+n3Wn52Ux ep6kGMACLujyNvR5I8G9vXvJZ+vj3bITJeDuPNn11zEOY/RqInQWCORO4PhBjZ8R5pR5 pi9ZdvTOXmJYyOnLOV15r8qeW9/rpHhsBCqgmzp6IbLEESSl2TgpgAjv+vYix90i1dF4 RwJo2sz7fqPLxIEC4knuLDu0RthhhdJfkVqGF62VdrKDNbariicxFXfRg3XRT277OXf4 qJmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7VKZGD3OPK0d/ZmTJRiy5fXWf4npHh9cr/WIp33dQBM=; b=WD/gPbr5BU6I+gdlbtT2v94nCvYB9yy5zinUklzibnp0wT6k5rtC3542tYFAWWllRE Naq4yJh5Ud5n9xa/2cXO2x0Ju6zoF7TRxlaBNVj4GeBGc6Fsrm4zhMn+3u1EoLcNVvvl DNUn+U0sTDfUpVvYSLTNUVLXE52edDg5U3Vetib/wMcNq0tcvaQoOLXnq2qQYwq9MK5+ pM0NRp0SEt/7QlmvlSXTphrgC7XodBNEVjh2GdRMQVJd70GzSNl7USwv1FDrUlF4+TUa vhZxEmM5JMz0ouYEc43AaBrYKX0ox21AmKevycGycNS40ZUZDP3xZCvkplpFJDn2mfjc W9tA== 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 r12si2137929pgf.217.2018.04.19.02.36.23; Thu, 19 Apr 2018 02:36:37 -0700 (PDT) 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 S1752981AbeDSJes (ORCPT + 99 others); Thu, 19 Apr 2018 05:34:48 -0400 Received: from mirror2.csie.ntu.edu.tw ([140.112.30.76]:35662 "EHLO wens.csie.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752777AbeDSJce (ORCPT ); Thu, 19 Apr 2018 05:32:34 -0400 Received: by wens.csie.org (Postfix, from userid 1000) id 881F15F987; Thu, 19 Apr 2018 17:32:29 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , David Airlie , Thierry Reding , Rob Herring , Mark Rutland Cc: Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Jonathan Liu Subject: [PATCH 1/6] drm/sun4i: tcon: Pass drm_encoder * into sun4i_tcon0_mode_set_cpu Date: Thu, 19 Apr 2018 17:32:20 +0800 Message-Id: <20180419093225.614-2-wens@csie.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419093225.614-1-wens@csie.org> References: <20180419093225.614-1-wens@csie.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sun4i_tcon0_mode_set_cpu() currently accepts struct mipi_dsi_device * as its second parameter. This is derived from drm_encoder. The DSI encoder is tied to the CPU interface mode of the TCON as a special case. In theory, if hardware were available, we could also support normal CPU interface modes. It is better to pass the generic encoder instead of the specialized mipi_dsi_device, and handle the differences inside the function. Passing the encoder would also enable the function to pass it, or any other data structures related to it, to other functions expecting it. One such example would be dithering support that will be added in a later patch, which looks at properties tied to the connector to determine whether dithering should be enabled or not. Signed-off-by: Chen-Yu Tsai --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 08747fc3ee71..2bd53ef7d4b8 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -277,9 +277,12 @@ static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon, } static void sun4i_tcon0_mode_set_cpu(struct sun4i_tcon *tcon, - struct mipi_dsi_device *device, + struct drm_encoder *encoder, const struct drm_display_mode *mode) { + /* TODO support normal CPU interface modes */ + struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); + struct mipi_dsi_device *device = dsi->device; u8 bpp = mipi_dsi_pixel_format_to_bpp(device->format); u8 lanes = device->lanes; u32 block_space, start_delay; @@ -606,16 +609,10 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon, const struct drm_encoder *encoder, const struct drm_display_mode *mode) { - struct sun6i_dsi *dsi; - switch (encoder->encoder_type) { case DRM_MODE_ENCODER_DSI: - /* - * This is not really elegant, but it's the "cleaner" - * way I could think of... - */ - dsi = encoder_to_sun6i_dsi(encoder); - sun4i_tcon0_mode_set_cpu(tcon, dsi->device, mode); + /* DSI is tied to special case of CPU interface */ + sun4i_tcon0_mode_set_cpu(tcon, encoder, mode); break; case DRM_MODE_ENCODER_LVDS: sun4i_tcon0_mode_set_lvds(tcon, encoder, mode); -- 2.17.0