Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp141775ybi; Tue, 2 Jul 2019 17:53:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjrVTE2q0JHjy/AFVoOka4IKPymxRxXGrScebugRLcmano7Kxay7UgWsyVHI1Asa9RlXwG X-Received: by 2002:a17:90a:cb81:: with SMTP id a1mr8590363pju.81.1562115184290; Tue, 02 Jul 2019 17:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562115184; cv=none; d=google.com; s=arc-20160816; b=DNdB1VsdoG+kPXorM0o032qZ6xOsnDwp26vOSVu6yYAd9sAsJr+YY1T+36nHD83VqO M8ECTyzCIYXDfCexvLXylgD0JqVj/tlRhnwjSuzVnISxsDYDT2oqhx3UZb3xp/I+DV6X 43NpQy2v4zsEELON1HSyvwlO2bG8hGRWDyhjvmEXJ7lee/JSufDUHCMYdS83313sg5CG tb3aWVLNPmYrP4JkQ1UMbShXTMYmgnbK+hSUkd2wRKAoH5Nu10iT1GOAEWEJGTLxjH9z I3Isxftt2JQORvaT9y5QNpnGlJ0SbJQVrXSadeq1rtJ8Cz1TYdENUH7S/O2pZPwaHspN RoRg== 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=Vk6BXomPunDdx0W/BxDNv5anqPGmrYNDxfTQs6Xy/Tno8kEh3nALcrGfDZSruITEqK rz0EbhqUztKoYsBklZf2pQrQbdFBkBkZqlO01rk+YDjbR4aK7zXkBAwizPdH2T5z0I3d 7GHkCA+B946A3ds3PfmNbQLwMBXhT308igEh+9dKBS4ZPItDa8DYChBTFzECWIgxNsZR 6CYA3C+04Szmprz0u1am7VO3MMOTmg2TsfDZ8qrEgq3nkB055VI79ZMnONzNg7sU1E76 IA+R7QJ3uZMxvZCLsZPAOriNCyDwPOCAynWpeD0V7W5iYMcpE9Ddvm3eVmdY4NgtrBfg dT5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=e9dnHhed; 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 m9si346210pgq.373.2019.07.02.17.52.48; Tue, 02 Jul 2019 17:53:04 -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=e9dnHhed; 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 S1727338AbfGCAvS (ORCPT + 99 others); Tue, 2 Jul 2019 20:51:18 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34416 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbfGCAvR (ORCPT ); Tue, 2 Jul 2019 20:51:17 -0400 Received: by mail-pg1-f196.google.com with SMTP id p10so260672pgn.1 for ; Tue, 02 Jul 2019 17:51: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=e9dnHhedfc+lNBCeuQXfqoxiBpz0VmlnQH3dYfHeptLuCxi0FSdQwptmK/hVygjteY 67O617zIP6ppcNt6CT00h0I3dMCDvoFYdMLtG6ehC8KqJqijJU800ko63y3+dH3MlKdQ 7IbBaEAUNGtXwQWMBgoAlAOSE/HJHBGWeepqU= 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=GXwgMGMIZoQvofw7CVpz4LByojEM8KuM63xcVJyYEfxy8ZvDDEcPIYHBgHkXQfazWz roG0kcdZGDHEw1CAiF0EYF3cbWdkcKmHIKHSeg7v+0B+HPjzC0iKM9Isp3x4TwcEVgzZ OKUQnSklmV43lX+SKSdtddjYQWkgI7q0jHPYX0q58FRbWSOixKYQqu49fHVpIvwciXn9 Z4mXTm8tkA7GJ7JVheqIi9xXrF45rDaH4j6c+vAVfysmWMpoPB6OBcFD2bnIQgf7JMM3 bcRWSE8DNAi1J8y0jd7FRJeGq0oeZ2/LQQgcnGq63+ItB7zQYC6q5bZcSD45/Q+lp9fQ r7ew== X-Gm-Message-State: APjAAAUZx/twBR0yELv+lMagK7WFBg0+NJ8Eb2/0SOtguPoLw/0TuZIM sHfMRNPwCFrMiyj7LmD4bJjJ1cgvnx4= X-Received: by 2002:a17:90a:2305:: with SMTP id f5mr8983837pje.128.1562110984080; Tue, 02 Jul 2019 16:43:04 -0700 (PDT) Received: from exogeni.mtv.corp.google.com ([2620:15c:202:1:5be8:f2a6:fd7b:7459]) by smtp.gmail.com with ESMTPSA id c26sm167611pfr.172.2019.07.02.16.43.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 16:43:03 -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 v4 1/4] drm/panel: Add helper for reading DT rotation Date: Tue, 2 Jul 2019 16:42:55 -0700 Message-Id: <20190702234258.136349-2-dbasehore@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190702234258.136349-1-dbasehore@chromium.org> References: <20190702234258.136349-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