Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3944823ybi; Mon, 10 Jun 2019 21:06:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLbkd4dg3Tikz6iZlvImRPuHDeKnWHeCrcMHtqbLllVELXERfadCuN6oVvO9du5Ezs/m1r X-Received: by 2002:a17:90a:a407:: with SMTP id y7mr24763945pjp.97.1560226006694; Mon, 10 Jun 2019 21:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560226006; cv=none; d=google.com; s=arc-20160816; b=Uf2Ye6bgZbe3E9mHu6sqk+xFxUw+Di1iHocba11jVnqMyEZ9TX3422/rHZfDQHqJQP szqIAG88DqqjKt/BvnJJsNH0ToRtNkGbA3+R7YfVG/zj9JKWe4tLOCezEjwF5Cuz9f7D pv41nmIJCR0d7IB4oZmTI+HPK1sqP7dfMBStaS/rCXxz75O0g1/3KKoYlH4AZNN81PcR 818k1Om65iJmqhzHYIYQ1S+wQBx4pD53A08DPmE7tO4sdGLKO5txMbFZQewWE4grq5G0 iw+1lyDaY+7UCcphskNje7apTm8eCOa92xdoGcPEi73BMM8zM+JrZfbqXECYYkzceTHe jIRw== 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=dK5nepKO/Lu9qcWjch0d2Z8IhG0b83DDW/+1Tc5GcLg=; b=zMZD4BsB+39pLm16UKsUX4lPetkMwv692fJY46dKUYQ5NbPDmJgNN2F6ib6kPt5DXe La++s+gwzXFV/EeAvx9ZX9LE8lbn2ynE0QLk6BLCOlfCdwVDs3aqmuaW7QWjRWB8/dai LF4cV1oJJOvLNMO+HWioR/YyNW6w5ktRMSLW7fmcre/AfNGGar+XuuKI9Nag6DHYkUjA uarURLU75z8D1JM5xbJiiJLNRwaZLG+WkoV4QmKeX/4mrZ2uBjJFo3ldZ9HSCglVWDHZ W6SSlURUt+k/y3DKtcSp9OA6wCijocbtOjGgcmXcv8YsrElfnhnekvc2ez1hGtnOeK1l jhpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KXrCMiQg; 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 s15si11548016pgj.350.2019.06.10.21.06.31; Mon, 10 Jun 2019 21:06:46 -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=KXrCMiQg; 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 S2387997AbfFKED7 (ORCPT + 99 others); Tue, 11 Jun 2019 00:03:59 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41865 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbfFKED5 (ORCPT ); Tue, 11 Jun 2019 00:03:57 -0400 Received: by mail-pf1-f194.google.com with SMTP id m30so6017521pff.8 for ; Mon, 10 Jun 2019 21:03:57 -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=dK5nepKO/Lu9qcWjch0d2Z8IhG0b83DDW/+1Tc5GcLg=; b=KXrCMiQg7a3OfPUXlEJ0jxFjUzyZmNjg7jLQ3vlyHvu+/ZoYFywdDn0CYhVxJ6210H Be7ENhzB8haIWSJaAFOqD/im/zV70ZC09Z+ulYwJ0v3pb2/30T9ccgBbFuxxbqyb4Sb3 F8SC9XyvrE2wKX+6pwO4Kc/M8q4p4YESBKAMI= 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=dK5nepKO/Lu9qcWjch0d2Z8IhG0b83DDW/+1Tc5GcLg=; b=h8GJtED14sH2lLlt0/xv+PlUX0yjJYyVw8STTpyR0RY7OyVaeZSZfysnXAVENo1BsN WH8uifnCt5mXj2qh2t/mzWtZkOze77SHArj6xjxBnWKSPBrtuC1YXNrea47iVNAFOOkP mk82NBfdI/gCdndtVXR733KjGzYDzuwoHJ5CC7NeIb1XK0qLhfowE91I0oojLt/zc0sc vUi4LWRcUuYgrhAurwQ0FYjqe7VYRx5SrQBsQuRiOR0BdZx1eIObB6gFA/XiIuEQ9oDS 0Q1r3fPZBYBxklIIjNyH7YIIfU3SemNLpJGvplwQmS24xpQIxgOHPdpBZ6kALqVNGKAg Lp5g== X-Gm-Message-State: APjAAAXev/zUv+F9gbzur7syvmNx19VJwcVFxYwsxkd4vgXHiExsJUH7 GhcRTJ2HHGmjchWY4x/d35hBouPCRyg= X-Received: by 2002:a62:ce07:: with SMTP id y7mr49658309pfg.12.1560225836465; Mon, 10 Jun 2019 21:03:56 -0700 (PDT) Received: from exogeni.mtv.corp.google.com ([2620:15c:202:1:5be8:f2a6:fd7b:7459]) by smtp.gmail.com with ESMTPSA id y133sm13301185pfb.28.2019.06.10.21.03.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 10 Jun 2019 21:03:55 -0700 (PDT) From: Derek Basehore To: linux-kernel@vger.kernel.org Cc: Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , Rob Herring , Mark Rutland , Maarten Lankhorst , Maxime Ripard , Sean Paul , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , CK Hu , Philipp Zabel , Matthias Brugger , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Derek Basehore Subject: [PATCH 1/5] drm/panel: Add helper for reading DT rotation Date: Mon, 10 Jun 2019 21:03:46 -0700 Message-Id: <20190611040350.90064-2-dbasehore@chromium.org> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog In-Reply-To: <20190611040350.90064-1-dbasehore@chromium.org> References: <20190611040350.90064-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 | 41 +++++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 7 +++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index dbd5b873e8f2..3b689ce4a51a 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -172,6 +172,47 @@ 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, int *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..13631b2efbaa 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, + int *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, + int *orientation) +{ + return -ENODEV; +} #endif #endif -- 2.22.0.rc2.383.gf4fbbf30c2-goog