Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1438475ybi; Wed, 3 Jul 2019 16:03:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK0N22bSl9Cv+WKonZ7ULMc+evGsxlX0Vd2MQ12R19heZLs7mWe8tOfhIOIDSgWQpcJtBZ X-Received: by 2002:a65:6089:: with SMTP id t9mr38822420pgu.170.1562194987206; Wed, 03 Jul 2019 16:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562194987; cv=none; d=google.com; s=arc-20160816; b=LcfFDqoj4/yQ4EO/xnOVq5aQO+v1tyEW2wWN5Gcpx37v72+Q+J6r9cVKO/p2GHoGsf QCaHgfAwUCDja/0BiEHXvBruK2ib6k2BY+og4Bpk71wfbvVf8ofsD5rcMtXkWuo0srYB LjytA+bVyUM6yiY/S5q6N394tG/EDVDFBY3YuqplLfWQDN/e+JX+rYUCrxPuHp+x1CfT wl6syMqycTWvoycjMnryszNnBkuM3rsy9v8MG28833qr0NTA4Qg4vqElqI078SHwwAIW Y9vQjZn6LTzmLgEYvBQjLSg3iEQ2EgFnK0BWHONow3OUi2hv6gG0+FhUR0i597vTml3b pNoQ== 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=aN1fc/2k+rfSW/EC4oQs93BniUXT0kzrcpLPTc60YrA=; b=DHwP8k2x/PFqnMmCirJPE2fq0TzLJx2AjgYHYeVQYPGEZ6Y7xG+uixjui1GGv0q8Wm JzvD++2hApoCRUMC5LRGLP2fa3gXD38qf/W9+lmd+/xiw7OU68rL0j+fHD9zUTIxHYgp WtThE8BGkubnMYkPo1ho9+D0QLmp9X2Eyr73g0/QuUtlXzUivPZz156JuVK6uIr0NXpq Frbv1Gn2OV246gcgawf1+oazaFck33fAoQBn0hiz+lXmMMKJe5JHj1z9L7eQryVSpD8/ +97iU0HqJigCAdFYBI3l6LMJzLcMZYUb/FbORcr94k0uEUih5GRHKh0jbl//Ct+kdcO/ 9/Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AvAPogXe; 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 v99si3072751pjb.82.2019.07.03.16.02.50; Wed, 03 Jul 2019 16:03:07 -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=AvAPogXe; 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 S1727444AbfGCXCU (ORCPT + 99 others); Wed, 3 Jul 2019 19:02:20 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34037 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbfGCXCR (ORCPT ); Wed, 3 Jul 2019 19:02:17 -0400 Received: by mail-pf1-f194.google.com with SMTP id c85so1987214pfc.1 for ; Wed, 03 Jul 2019 16:02:17 -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=aN1fc/2k+rfSW/EC4oQs93BniUXT0kzrcpLPTc60YrA=; b=AvAPogXeMhAMyX6Qn73Z4Mb7gUtQ6GdM3hW2lA0fqx3qKFbiNPs0oqDDEcOvWLEgX4 aStyjhVWEcNNkVbiS4n/Ij8W4hS+WWcIhDQKoq/CfAIywTOhiYopNzj8Mcfy6hwnvEd0 tbxJjj4OUCR1uSSEZ8ews+4V3aSvZvUuGIHOQ= 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=aN1fc/2k+rfSW/EC4oQs93BniUXT0kzrcpLPTc60YrA=; b=iac9q6CB7TAEHPDXL5vz5c02dF+OEIAwmWgEJeFYBMZxqe/R9fHCaJZYVaQImqb0+w dQHSPLcxu0o2gEnJ/Qk2T2bKk+Sl1ZZ4cxFJgpW3ML5HJ5uYuUgONZVGl0iw9Ub67sXC w7rRayYQbGCvNVu71GWLSlhyWZcdP2iaue+ijfdue8ewwYei7aixaoX2UK/o6T0nOZaE R1RxFseK/WaWCvA+f2XQWambyNe8vp+PAid50ywMsvlBxn8zyqEL1GAC+TiUMAuPBaOr BbTcM0rlabU/7vt3A9GcR89V0/D7pp8715+c25IgcFO3A4kF0umSsS6wLjVQz+ki9Q8s XOdg== X-Gm-Message-State: APjAAAXcVeh9r+gUTS8lZNtuF8rr0DVrl1lqgKnTK4O12NWizV3AQESX EGvEtO+tqGUQ+tOWUWfRYw1uZv89UD4= X-Received: by 2002:a63:34c3:: with SMTP id b186mr39455164pga.294.1562194936143; Wed, 03 Jul 2019 16:02:16 -0700 (PDT) Received: from exogeni.mtv.corp.google.com ([2620:15c:202:1:5be8:f2a6:fd7b:7459]) by smtp.gmail.com with ESMTPSA id t8sm4245171pfq.31.2019.07.03.16.02.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 16:02:15 -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 v5 1/4] drm/panel: Add helper for reading DT rotation Date: Wed, 3 Jul 2019 16:02:07 -0700 Message-Id: <20190703230210.85342-2-dbasehore@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190703230210.85342-1-dbasehore@chromium.org> References: <20190703230210.85342-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 | 43 +++++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 7 ++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index dbd5b873e8f2..169bab54d52d 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -172,6 +172,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 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