From patchwork Tue Jun 11 04:03:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Basehore X-Patchwork-Id: 10985855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBD6113AF for ; Tue, 11 Jun 2019 04:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE34827F54 for ; Tue, 11 Jun 2019 04:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1292286C1; Tue, 11 Jun 2019 04:04:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7D57027F54 for ; Tue, 11 Jun 2019 04:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JoFqSgb2ESMTX89VKdo6XGJ77FlI818WAO06RQaUAdE=; b=ZEptRpFm6w7dSK qNQZIT3PcQLRpFeBJOC9xesHi2fcrCxrSU1gNY6dMHM16PsVui27OOIiwKzsYAlkYfnjlggreWydh 764nohf3yaLp1EgNvuwZX6f6BbAf+0kRegWWVlQICEQh/R2dVvKJaSfv1M2Ux9n3d58HDLA3shHt2 zS7lSEbb2xgOHSQkAMcHGzWNwiLZlkDAxijf9BE2ruxKKHVW6LRPxdt36+VZU2CH3FSUeJtb5QHb8 sWFj/utjrVjvcYV9Qc5mbT9DDSzP83tDPIWYsfuYwm014WOA2Ehl18NaXizg6RC0tlHnDu1AM2E7O KA1nRhXxUZ3PVMDjaObw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1haY1Q-0006Dd-5c; Tue, 11 Jun 2019 04:04:32 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1haY0q-0005gS-Vs for linux-mediatek@lists.infradead.org; Tue, 11 Jun 2019 04:03:58 +0000 Received: by mail-pg1-x543.google.com with SMTP id 196so6161134pgc.6 for ; Mon, 10 Jun 2019 21:03:56 -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=RY3QARCb0rbSCty26SMCinifqUhJ8PCzWX42ib4tMuYhtFxpTOwF4VtItToVnq6Cye FBy7aEUKXnle1ORpsljrIypu0XO6l3aV9Gq/vKRW7IvPWvqg2bm2kG+evvnGzq50LpS/ Hj1kw+ya55DGLXzie9Cqsgs1WAUhWTmc9EYVgCyN7bjXNGbLhJ7vTp9B8b+mMKIWa00q WdhLmNG4zP/ifVF4sMuJ8K2C+bYpibaLgHuzVBAJn8kcywl6D9FVb3SilSwuvaM5WzA8 z5lK+GHkEEj5dQM2o+gzlZL/N4wke7OgBeTQ1/yOsbmIA4Kk4/C2w+o7d+wKvQ6qNuX3 bQRg== X-Gm-Message-State: APjAAAXu4KmvhY9RE4eLJcyR6IHKdCkYjxyiBsu+WVhr1OdpnUDye+Bb 6yFob3BgP8d30I0Sv3YVQ6oBtg== X-Google-Smtp-Source: APXvYqwobTrT91p21YyGnsEse1+RxzZxvnHAKh/XjPiTdvWC3iFSRE8s82N6n3Ie7F+FBFdVUvCVAQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190610_210357_024648_D59857E2 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Derek Basehore , Philipp Zabel , David Airlie , Sean Paul , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , Jani Nikula , Maxime Ripard , Rob Herring , Thierry Reding , dri-devel@lists.freedesktop.org, Daniel Vetter , Rodrigo Vivi , CK Hu , linux-mediatek@lists.infradead.org, Sam Ravnborg , linux-arm-kernel@lists.infradead.org, Matthias Brugger Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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