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: 169951 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2278305ilk; Sun, 28 Jul 2019 03:52:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLKvIaI/d/AgrIZgGEt8oCVYWvkuSKa6shn2TeGRklO/Noy2sWLsngycLi+ojFd6RGJZ75 X-Received: by 2002:a17:902:fa2:: with SMTP id 31mr106584729plz.38.1564311153941; Sun, 28 Jul 2019 03:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564311153; cv=none; d=google.com; s=arc-20160816; b=aDe+oEca1m5kD3A6CFtr1Zf/wjtj+RNi3POmMRaLchjHQqEgtGqRXzn019MwyR/379 pgszyQXPiIlVfNCYfEDmLyMPlpqnxgtFwntlQ9sqGzwOLdvvki9f7SuDcELtyjLVc63J MDx+D52pjV7JqMXjKfxVhO3hP0+G1PHY6In/Wmb0AAYPta5U8WNRa/rhxchCSYTsypVl CQrLtYah4tDSec0pGi4A4MBp4Roy50FeqEBloZoookfCVdBtr0FGDuaymJYhqajn9so/ hX5/QtepqEzTQ0Ajv1ATV6HQKs47hc8uk3zvKDnsXhcrBbs4bw9Ldm/ylEZzK5v6KToC shtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:to:from:delivered-to; bh=rg7ntdJ8cxD2Sy1G6ZAYVnzUYZkpgdsql104KZ6UQpc=; b=LR2+tHhYKy8aFJrZ/nmuR38n28E6hpvGdzhZSBMsBDxO4cmFd2bP21ROpFhhz4Im1L wH/M4H3t2kbne/6gzG37XuNDerAsiUbv5fr9cHAW5d/pu2B3+/C+vz6D/cqqkDVL6P1i B+8/kqiO37uRIbbpn6yd3Q9RMGyzpdxGbiPHZ+KG/nw6oIcWYiARfkSfrAwJ2pUIml+6 1pqOb3SMU/Eozv0m60tdGkFsCpGGOzscTw43ZW0J5hmoFe/MRn1qRn4inDtsrRdGCxQF sq0Kmrmp8vLcxvD5CzH5P3vZDcqEl1u66at6rqzhZgKJZJZNcVE7jZBPf4+1RhZQvRel HHBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id a26si30053828pgb.276.2019.07.28.03.52.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jul 2019 03:52:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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" 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;