From patchwork Sun Jul 28 10:52:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 11062931 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 ADCB313A4 for ; Sun, 28 Jul 2019 10:52:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96CA22887B for ; Sun, 28 Jul 2019 10:52:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72BE528970; Sun, 28 Jul 2019 10:52:35 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 934772887B for ; Sun, 28 Jul 2019 10:52:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1659B88735; Sun, 28 Jul 2019 10:52:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4520F88735 for ; Sun, 28 Jul 2019 10:52:29 +0000 (UTC) Received: by mail-lf1-x141.google.com with SMTP id h28so39967588lfj.5 for ; Sun, 28 Jul 2019 03:52:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UeXytxinaTVdoUbaK5tSXVCVlMrTupBhZAX9BXOt6wg=; b=c/P1VaLQDCedubUA9OKRMuWMjEhM/05C79EqGTobGR09EhDYxmsEtgBN/mDhm/ONZ5 Ek1orntdIbaFqx9ykhhf7d7D9z7iv6TnpI/+gLE094dI3wz8MeW0d0BjF/tbu9I/BHEG gz92+04aMFSXGSBx1eBeYbo/ztzeHBt1qUYAZhCumJ5529mqTbqLUwpdwuFCOhT9G+y8 +BrwFHc6iYKLZ7a9p9g75RFZewP97bluwAHCvmiZcdw8V3XriMgByBvpQpLw3G79iL8W WP025Uj0l3vOl+PK7ewLVEzDP4JOvzqjbyKJJWkcvWbiOb94c+RPsLhHoSZ/0/ic9QoC SYGQ== X-Gm-Message-State: APjAAAUcMCWzhJLFzOwajXE2ZCwipuSqfAYEpBOHOOVnZ5y30+qu1N+c y1fspCjzx5nIXEnNnrgEzIYVjg== X-Google-Smtp-Source: APXvYqydibPwae38ZwyFB1DF7jqDyz+vRRoAFCB8mYDGnfhT8vgbHhhMxMKAbZ3rqmRTxR46Ys1iOg== X-Received: by 2002:ac2:47fa:: with SMTP id b26mr33743290lfp.82.1564311147512; Sun, 28 Jul 2019 03:52:27 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u27sm10016534lfn.87.2019.07.28.03.52.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 28 Jul 2019 03:52:26 -0700 (PDT) From: Linus Walleij To: Thierry Reding , Sam Ravnborg , dri-devel@lists.freedesktop.org Subject: [PATCH] drm/panel: s6d16d0: Support rotation Date: Sun, 28 Jul 2019 12:52:23 +0200 Message-Id: <20190728105223.4966-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UeXytxinaTVdoUbaK5tSXVCVlMrTupBhZAX9BXOt6wg=; b=mQ2g6j66cErscfM9Awe4uzCguKYTsCsN4Ebj8Int+04xEGYMxbmjJsWXMV0qdqRKRP bXLvGMLcA2U6udnaNeD0qhYrutXhXZFADJlnhvPKc9RnSqveX4iiNTbaJ3tvWfnScGN4 9FueYCsm5NkudxtIWSVwJ40kMRj1iAo1UaA+j89U7W5KVe1zYwghYpQoD/Kj42Kz3LFQ IGPyOLdkxTSkyau6dpZ4LgPfn98eH9Fm7cUxuQJQDVZ/XBLOal3WQZlFyn4MdDtU6Gea cao4vrvuz+40oRkbNgDz9X6gBdbqXdIpAjKfxpYY5GZhMqkS2AcpklPvAHj12xY1x6f7 SzNw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use the standard DT "rotation" attribute from Documentation/devicetree/bindings/display/panel/panel.txt to handle designs where the panel is mounted rotated 90 (or 270) degrees as in the ST-Ericsson HREF520 reference design. Signed-off-by: Linus Walleij --- drivers/gpu/drm/panel/panel-samsung-s6d16d0.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c index f75bef24e050..d4c33781ade8 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c @@ -13,6 +13,7 @@ #include #include #include +#include #include struct s6d16d0 { @@ -20,6 +21,7 @@ struct s6d16d0 { struct drm_panel panel; struct regulator *supply; struct gpio_desc *reset_gpio; + bool flipped; }; /* @@ -47,6 +49,28 @@ static const struct drm_display_mode samsung_s6d16d0_mode = { .height_mm = 48, }; +/* In the standing mode, things are just flipped around X/Y */ +static const struct drm_display_mode samsung_s6d16d0_standing_mode = { + /* HS clock, (htotal*vtotal*vrefresh)/1000 */ + .clock = 420160, + .hdisplay = 480, + .hsync_start = 480 + 154, + .hsync_end = 480 + 154 + 16, + .htotal = 480 + 154 + 16 + 32, + .vdisplay = 864, + .vsync_start = 864 + 1, + .vsync_end = 864 + 1 + 1, + .vtotal = 864 + 1 + 1 + 1, + /* + * This depends on the clocking HS vs LP rate, this value + * is calculated as: + * vrefresh = (clock * 1000) / (htotal*vtotal) + */ + .vrefresh = 816, + .width_mm = 48, + .height_mm = 84, +}; + static inline struct s6d16d0 *panel_to_s6d16d0(struct drm_panel *panel) { return container_of(panel, struct s6d16d0, panel); @@ -145,10 +169,16 @@ static int s6d16d0_disable(struct drm_panel *panel) static int s6d16d0_get_modes(struct drm_panel *panel) { + struct s6d16d0 *s6 = panel_to_s6d16d0(panel); struct drm_connector *connector = panel->connector; struct drm_display_mode *mode; - mode = drm_mode_duplicate(panel->drm, &samsung_s6d16d0_mode); + if (s6->flipped) + mode = drm_mode_duplicate(panel->drm, + &samsung_s6d16d0_standing_mode); + else + mode = drm_mode_duplicate(panel->drm, + &samsung_s6d16d0_mode); if (!mode) { DRM_ERROR("bad mode or failed to add mode\n"); return -EINVAL; @@ -176,6 +206,7 @@ static int s6d16d0_probe(struct mipi_dsi_device *dsi) { struct device *dev = &dsi->dev; struct s6d16d0 *s6; + u32 rot_angle; int ret; s6 = devm_kzalloc(dev, sizeof(struct s6d16d0), GFP_KERNEL); @@ -215,6 +246,11 @@ static int s6d16d0_probe(struct mipi_dsi_device *dsi) return ret; } + /* Support rotation of the display panel */ + ret = of_property_read_u32(dev->of_node, "rotation", &rot_angle); + if (!ret && (rot_angle == 90 || rot_angle == 270)) + s6->flipped = true; + drm_panel_init(&s6->panel); s6->panel.dev = dev; s6->panel.funcs = &s6d16d0_drm_funcs;