Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1893432ybn; Thu, 26 Sep 2019 03:56:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpecoClL8x40KPmiI63gRVrnXdv5O1SyYeBzs8OUalXViycIZBcm2xxtKY9R3qfi+zTQHl X-Received: by 2002:a17:906:18e2:: with SMTP id e2mr2414963ejf.129.1569495360258; Thu, 26 Sep 2019 03:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569495360; cv=none; d=google.com; s=arc-20160816; b=rXR4cmfwOrn73JJnra6yUmN79X2ccfXeTsovu8J+u/fDcHShg7qT4929ahShp9vQ45 tyDfgpwDFAEB/dLhGM15v7o8bV3jZfUZuLXQihe9lkDQ+JTFwYUDhkOTuv9L9cW4QgCf 6PMFgEzaqnBceLXV+AHMk00TcHsd+IqzL+QDLUqbg1j8DGpTUuUd8FnYnhiOfiHK0C2p 2EL4p8TWj2UabA0UGkgguqxXXNSQjiuutuFy94p5OQU3qLk/O5dxJcxofZJZMT9n4QQv feCYB0IQczQIVcaZ204eT066uRKzwB1zY4GXOBohLpZ8bWylNZl7i6pGPhIQAxkJZbBb zkgg== 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=8RLpwKs4I/KTJ32MS45zoaSBUWPxrYYP2TJ+BhJ7dIo=; b=dln5zdttsuUffKj7sslk+w2Ocuus3CzDhnbEHbr0LJJpoA7K/mBEZLklUVd8vVGI/I uhppgT+PZW6YTf5v4pQJd29D9B6DGC6rnUm2ksZM78C+1SziIo5CUNRzKtEsK6O/4p1p nLa5KdOyIhqHY608LR0kNoZH9A/3VOQj/dh309SnNpYg29e5aWvjyAXVU1S13kfGxsL+ A+TDd7FBRm6ex9pdrT6GcppmGUZkhneLMAlD5M/0XnuCBR9Sd25xl+/9OS0XRJyfZeNj pnFP86VHxSdQbGsYQm+Gr9T6XlNWO+k2qxwvqkJkLXBZUm5rDtYwQjsRo0IZdzJDLJ6X Bs9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lX625GkS; 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 5si1142320edy.95.2019.09.26.03.55.33; Thu, 26 Sep 2019 03:56:00 -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=lX625GkS; 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 S1730184AbfIYW6n (ORCPT + 99 others); Wed, 25 Sep 2019 18:58:43 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43729 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729638AbfIYW6m (ORCPT ); Wed, 25 Sep 2019 18:58:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id v27so182396pgk.10 for ; Wed, 25 Sep 2019 15:58:41 -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=8RLpwKs4I/KTJ32MS45zoaSBUWPxrYYP2TJ+BhJ7dIo=; b=lX625GkSWQhcn3jHGAe6xWSr0MrR/xtQ2yTUKlx5cgk/atVv5K7Kc50LuoUY675HjQ Y8b+UWDk8muJoMytA0w5+vX8OLmFKLu/+beCXViUfxS6zK4zo/TzqMNEAAa/VdGnvPYT Jq1YeEDWdMlDsRJCeFLex/1KV68Gz4c6ISl1Q= 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=8RLpwKs4I/KTJ32MS45zoaSBUWPxrYYP2TJ+BhJ7dIo=; b=YSw2G8DnaeQspmtsLdmyIMm6fiJ7erek3jGW2er41pjMYSB/25VKSDlr+WBDIAIDxS b7CSCmEW1tvptVk6M1oNm1xj+INqelbv4h8Ir6nJiZgknSoFN9RhBiOg9Wz6vlA+h//K MXA0QJWqIRuGerYQFEYL2gTU7dQFd2lqX9Y2ldGHnS+Rnon8wAfXspCy4THJDkdMJ2aZ 2OFHfpsYK0Y7V9fdgEOnvi7on3QB8YRxHsJ0LfXD7jzxCQmJUaIn+VMCyyytXHMn8UUD C5t4kkoF4CM2aSFuXPg0mcKcAWhIw/dG5dG9LKtReprO0CJE/b0qTh2SMV7EXHwoUZsj zDWA== X-Gm-Message-State: APjAAAVermHy+L7wCZRMYCRpZfuLK/Qm60sBJs0qa09QGmcM3NzQLHm2 nVBocBTDzQv2FYI58zQs/E3e0t//trU= X-Received: by 2002:a63:67c2:: with SMTP id b185mr278299pgc.436.1569452320464; Wed, 25 Sep 2019 15:58:40 -0700 (PDT) Received: from exogeni.mtv.corp.google.com ([2620:15c:202:1:5be8:f2a6:fd7b:7459]) by smtp.gmail.com with ESMTPSA id j24sm76185pff.71.2019.09.25.15.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 15:58:39 -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 v8 1/4] drm/panel: Add helper for reading DT rotation Date: Wed, 25 Sep 2019 15:58:30 -0700 Message-Id: <20190925225833.7310-2-dbasehore@chromium.org> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog In-Reply-To: <20190925225833.7310-1-dbasehore@chromium.org> References: <20190925225833.7310-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 Reviewed-by: Sam Ravnborg --- drivers/gpu/drm/drm_panel.c | 43 +++++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 9 ++++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 6b0bf42039cf..0909b53b74e6 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -264,6 +264,49 @@ 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 orientation of the panel through + * the "rotation" binding from 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 orientation of the + * panel is expressed as a property name "rotation" 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 624bd15ecfab..d16158deacdc 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -34,6 +34,8 @@ struct drm_device; struct drm_panel; struct display_timing; +enum drm_panel_orientation; + /** * struct drm_panel_funcs - perform operations on a given panel * @@ -165,11 +167,18 @@ int drm_panel_get_modes(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); } +static inline int of_drm_get_panel_orientation(const struct device_node *np, + enum drm_panel_orientation *orientation) +{ + return -ENODEV; +} #endif #endif -- 2.23.0.351.gc4317032e6-goog