Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp20631ybd; Fri, 21 Jun 2019 20:41:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuZNByPMwUSoX7dzbDB6f4Ip+gUrqbs2GO6/a1gH0RZLwU87sVm8BSLkJ6hrSwwzH0jk4Y X-Received: by 2002:a17:90a:d595:: with SMTP id v21mr10659666pju.34.1561174916812; Fri, 21 Jun 2019 20:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561174916; cv=none; d=google.com; s=arc-20160816; b=jy5ARU0iVqlW8XTpq70YXf5FmOKtjmtFCfGDPJqzn/xhWXROd/MpeFGUVJ9l8cdDwz 06aVG8CFDp/jauvrZ2FMx8pLjtI1tHiBR6g8c/ClG71bf/ivVMSR9rWwbJ6riI+fTINs 5To5MOo99BHtNUfk/Oe6N4fnSx5PQ6tGZ/r3CfUnlj/MZg64veoMEOihbYP5JSJkBmTb VI04+Wccw5dr7eYk6Y+eAWedmid5AaUGQZBsh6NO5eZVeTLtraInsnbYT0Pkv5w8HxfT BR0WMxmWLOtb83L5ZNZS82XtIlgvIEvnajbVm5DvrtJunOyctb7iveUZyNAO6WjDFjpL kwsA== 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 :dkim-signature; bh=VR+1gVBeNp5zLQOTjis3BU5nyFYrQmMm0AGMlO4tl+8=; b=WeTrO73FMtIvVzZmLm3I+xd5a+TqP7K22H8hhoIehCWJj43Ptvte0p78WQ3yNrSa/C kY8zEgUfKZW1cQ7QsWpOALucL6nXzDZVw5BOSLgDGS4Uj0V+M4hPIzMPxk7siGg+hbRN GAbM4ADwM7//CJxY2crTDkTEqKA7qIYuYIzFfJvMORkIrO8GLMJl78xdlpzKOY0/p6q3 pW4XulgforkopNbvRH33jwbVi1gpXeSmH1PoiEjPHM23fTFEGC89AqORG4JambErDJwL YcKwev/FdXtHc4jCfw1KycrkbGhER6uzxlmZOHsIuWqExE3s1jyQTW9h4koHGv/AyMv6 3b5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Hz1UANN1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si4044798pgv.233.2019.06.21.20.41.20; Fri, 21 Jun 2019 20:41:56 -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; dkim=pass header.i=@chromium.org header.s=google header.b=Hz1UANN1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfFVDlN (ORCPT + 99 others); Fri, 21 Jun 2019 23:41:13 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34018 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfFVDlN (ORCPT ); Fri, 21 Jun 2019 23:41:13 -0400 Received: by mail-pl1-f193.google.com with SMTP id i2so3902508plt.1 for ; Fri, 21 Jun 2019 20:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VR+1gVBeNp5zLQOTjis3BU5nyFYrQmMm0AGMlO4tl+8=; b=Hz1UANN1roomVyU9jl8Q45f5XfmMGxREC6DBubcmkHxA8N1aR36jWxl686CM4zFQL/ 7MiFPw3h+X4133oN0+Q3yDg/27rL+fCVzFuuMjiJdEJ0QbnbArUJNJK5+nHiqylNnq3C XXbpjYWXPs4o9kfi5BLzH73e3K1SmGKI8+SCU= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VR+1gVBeNp5zLQOTjis3BU5nyFYrQmMm0AGMlO4tl+8=; b=GHQ5wT7IDVevzlBrelHrDDvhhJctxP2sn7n2Aq5xgVgoYtTBhHEwKarbirTO/sdz0g P4b108TvbfIkTNCoMTxHLryY2tLo2TgnK0qbnV2kbvEUkbgma91ql+QercjGI6wLYDJj S+CC4t6d6uaVf0MBQc1iLS6Dr+/OpQUZjhM5E3a86Ym1S2sdWBS+J2iJcULnyvRxvi3d 6FRWTozc8bhvyn6gB2tC9cwIZu0ubgsUbZZARxlbOCEA3wL6RhTWgjVpMlnGeD5SOcPm BimY03PQvabzASXCp2nT3ViQVKCLttP3Qq9VWM/ZOiRsfT54LRMBWDX2Q7PfYv06btcs ma1Q== X-Gm-Message-State: APjAAAUdClOT9bxiYjbUKpGhv9SnC/0wLeeur6Gh9+j6HRJjtW6qM8+J CNcqRfyiLmUlwWxqRi0yqErYLvCHLwQ= X-Received: by 2002:a17:902:e58b:: with SMTP id cl11mr113259716plb.24.1561174872149; Fri, 21 Jun 2019 20:41:12 -0700 (PDT) Received: from exogeni.mtv.corp.google.com ([2620:15c:202:1:5be8:f2a6:fd7b:7459]) by smtp.gmail.com with ESMTPSA id u128sm4756688pfu.26.2019.06.21.20.41.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 20:41:11 -0700 (PDT) From: Derek Basehore To: linux-kernel@vger.kernel.org Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Thierry Reding , Sam Ravnborg , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , CK Hu , Philipp Zabel , Matthias Brugger , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Derek Basehore Subject: [PATCH v3 1/4] drm/panel: Add helper for reading DT rotation Date: Fri, 21 Jun 2019 20:41:02 -0700 Message-Id: <20190622034105.188454-2-dbasehore@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190622034105.188454-1-dbasehore@chromium.org> References: <20190622034105.188454-1-dbasehore@chromium.org> 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 adds a helper function for reading the rotation (panel orientation) from the device tree. Signed-off-by: Derek Basehore --- drivers/gpu/drm/drm_panel.c | 42 +++++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 7 +++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index dbd5b873e8f2..507099af4b57 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -172,6 +172,48 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np) return ERR_PTR(-EPROBE_DEFER); } EXPORT_SYMBOL(of_drm_find_panel); + +/** + * of_drm_get_panel_orientation - look up the rotation of the panel using a + * device tree node + * @np: device tree node of the panel + * @orientation: orientation enum to be filled in + * + * Looks up the rotation of a panel in the device tree. The rotation in the + * device tree is counter clockwise. + * + * Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the + * rotation property doesn't exist. -EERROR otherwise. + */ +int of_drm_get_panel_orientation(const struct device_node *np, + enum drm_panel_orientation *orientation) +{ + int rotation, ret; + + ret = of_property_read_u32(np, "rotation", &rotation); + if (ret == -EINVAL) { + /* Don't return an error if there's no rotation property. */ + *orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + return 0; + } + + if (ret < 0) + return ret; + + if (rotation == 0) + *orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; + else if (rotation == 90) + *orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP; + else if (rotation == 180) + *orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; + else if (rotation == 270) + *orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP; + else + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL(of_drm_get_panel_orientation); #endif MODULE_AUTHOR("Thierry Reding "); diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 8c738c0e6e9f..3564952f1a4f 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -197,11 +197,18 @@ int drm_panel_detach(struct drm_panel *panel); #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL) struct drm_panel *of_drm_find_panel(const struct device_node *np); +int of_drm_get_panel_orientation(const struct device_node *np, + enum drm_panel_orientation *orientation); #else static inline struct drm_panel *of_drm_find_panel(const struct device_node *np) { return ERR_PTR(-ENODEV); } +int of_drm_get_panel_orientation(const struct device_node *np, + enum drm_panel_orientation *orientation) +{ + return -ENODEV; +} #endif #endif -- 2.22.0.410.gd8fdbe21b5-goog