Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8458783ybi; Tue, 9 Jul 2019 16:22:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQpbc+cxyJm8EwAfeKvl0VZBhYrRTGoNbolBHMYx0xw7j2c71z7OybIfwWzocaoKHP1hhQ X-Received: by 2002:a17:90a:2488:: with SMTP id i8mr2794712pje.123.1562714570957; Tue, 09 Jul 2019 16:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562714570; cv=none; d=google.com; s=arc-20160816; b=Riuunc2UBkvXVna6gF4BcCCzYCvX3couw+UqfH206DphYxIFbLzwoZMc4Kmt7vhX4z KNhmSwou0IdSC2n0UqDsC5I7DrfO/9lJHlObQezzOhTD/2PmjHjVMYr/L+7ZaYXP6JQL 39i3RmHjh0q5z/R7/AYfAOqyxnBuUvPdWI/oXLBY8/8pYlD76bllTesNj7tYAJPUqzGD F7Xq9tIBmS5YeB7emC8k1SxYU9m/efCef22RBz1KgarfJYsu2xuQuqNH5HBgxdZPzErJ 4areSTFrhxg1bPDWa26QUqolSu29wdHsiwLbNX9wh7ciN3WZNFCRCzvDryo4+hs0CO3N tjaA== 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=+ybENbdq7sWCRKSx2uGRD4wfA317CnX0hX0yVvH3yjc=; b=bovuHFuq+SjjoaOs78iOx+rxwX092g/Cm0YrXz0dwlDvCVUgMIsSfKOq5hG9BXoCLn Gzzwb4B/h8TiFibOCskeiJBfmc3LIAPd3FEwqClnYY/b+Mv8kDywVFkuOBcodBG7S1WM c4pCPuctlA+GCPegfZxAZVgtA8qgFjLeQsrMtbgdA0a1JMCVo6dM7x4va6rNOrqwu+74 uZQqXKR/V3UvE4BByOvRlnxWt4wgA33IcrndBjG6mDAwFt/nfBAndGbT4TyGBWjZMhcJ EdCjLs0gxz5BkvM9mwe3ugOcv2J2DuzowBbtZbFS9rvBsorbjqptrRaZRpU3cZmcgYQn XkkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KvY5gN0S; 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 l7si253779pgp.318.2019.07.09.16.22.35; Tue, 09 Jul 2019 16:22:50 -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=KvY5gN0S; 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 S1727044AbfGIW6v (ORCPT + 99 others); Tue, 9 Jul 2019 18:58:51 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34065 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbfGIW6r (ORCPT ); Tue, 9 Jul 2019 18:58:47 -0400 Received: by mail-pl1-f193.google.com with SMTP id i2so155167plt.1 for ; Tue, 09 Jul 2019 15:58:47 -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=+ybENbdq7sWCRKSx2uGRD4wfA317CnX0hX0yVvH3yjc=; b=KvY5gN0SAZEGmUhF/z94ihkRRx7Eb5rUIo1+xQkeKLjy4t3pnTe+dluuROYHZWqy23 5X3FfLnvJNOPNn/6LWdiTwmeDxnemdCvhVFCuVHv6vW4/n+Qr14M5g12QK09ELKAuTMt jUqZgUW5b0wxPd77Rck45TBJOLUHR6V0PTo0M= 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=+ybENbdq7sWCRKSx2uGRD4wfA317CnX0hX0yVvH3yjc=; b=DzZeOK35U+eMKx5/ACwEVyguFtLwIldkm7qomyVpp9NoWv8F03Cn9l6MNuCE2vl03z fJfEBP/bIZDX0HpOC2H3MJQQ0/uQzJv4XEUFdAVqpm3bAkEd+ilWrFmBZUzHAwE7CUei I7cSmvC1cOTD0TN3CVXf1NfA/vgCawonvBT1bwvgR/uqEsF17ZR3M13KvW61Ts45J98a 426llxMTd8juKHcfkr99D1QUnSTfGkA5EgLilKFHRmrYDkuROz/rJiCRHyKCYdK9Qc61 gvm2MBf2A4bhmQjgkUEBvX7yVnQSpTav6+ZjV/zCtNqxRi4nhJ3ec7VhCi/gW9IDiAFQ afVw== X-Gm-Message-State: APjAAAV3JOTFClVDNd7j3tClumLaB82Aev5uSxr0Z1+KQBXZ25mLo3fj 3kN1MRdcDheNb2w0DS8EJRMxWtYorkg= X-Received: by 2002:a17:902:1081:: with SMTP id c1mr35359964pla.200.1562713126654; Tue, 09 Jul 2019 15:58:46 -0700 (PDT) Received: from exogeni.mtv.corp.google.com ([2620:15c:202:1:5be8:f2a6:fd7b:7459]) by smtp.gmail.com with ESMTPSA id 201sm152939pfz.24.2019.07.09.15.58.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 15:58:46 -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 v6 1/4] drm/panel: Add helper for reading DT rotation Date: Tue, 9 Jul 2019 15:58:37 -0700 Message-Id: <20190709225840.144038-2-dbasehore@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190709225840.144038-1-dbasehore@chromium.org> References: <20190709225840.144038-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 | 9 ++++++++ 2 files changed, 52 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..a18c59f136ab 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -33,6 +33,8 @@ struct drm_device; struct drm_panel; struct display_timing; +enum drm_panel_orientation; + /** * struct drm_panel_funcs - perform operations on a given panel * @disable: disable panel (turn off back light, etc.) @@ -197,11 +199,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