From patchwork Tue Jul 2 23:42:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Basehore X-Patchwork-Id: 11028741 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 C865114F6 for ; Tue, 2 Jul 2019 23:43:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFCAB26E49 for ; Tue, 2 Jul 2019 23:43:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A322B28991; Tue, 2 Jul 2019 23:43:29 +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 3B31C26E49 for ; Tue, 2 Jul 2019 23:43:28 +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=OeSBo+80qaslU9VlO5aUK24V0gPS7L/U9OnkecNScqU=; b=HcnSXQuto9mMZm EVqXdkGM6i7a9G7k5we+KGB2COT5FyG6qRJ13tQsSRmZT8ZCt6M1RSnfViOemsEdXKSK8ACeoJNNq rEHdpVyYipS6ZNwe3m700US3yMmB7UQ7RcXlP95vSufSjHQDHBtweT+rrNElSya+78kWG/T4w/9Rg oezmLDWZXvY1F4gJdlmpn3Ht1EPfiBYk9nuDMuPNp1kqe0Kko1wVjSBZPTy47G1hQkvmwoBbAFhcV U8egxsDBhy25paM0TXK6iGf8eKBp4nGTOXraCbsegbM1esRl922q81Rx7VqwYpN/hld70c8G5LLPn /3bOSMi1viCLNQc882jg==; 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 1hiSQk-0001gc-90; Tue, 02 Jul 2019 23:43:22 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiSQS-0001RY-Ju for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2019 23:43:06 +0000 Received: by mail-pf1-x442.google.com with SMTP id j2so222654pfe.6 for ; Tue, 02 Jul 2019 16:43:04 -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=mNYlFbyZOL5hJhi+/rz6fXp7oYm9ToNyASuPAbIaWO/UsYr8YffQHWGvtbuhimPZYZ OHqnLYWpSHCIq2Nf48LX5pobAUoA0zLIzD6C1r9qb2CVj4+Jpzs1VF0anKIUFiPguZxx RX4a2mFEl6l9jqqpV4GaRwVCaOUbpachSthpLwN2hIpmW4sbAZsjiwDR0YbJMNomGzvN deh8qm/zb500tnEcGyUrg7zpCsK4zuPv4wCOf0nr17/b9B+yb8nxM5KB7zZNDY6Bx+GM jj066VYc/5nXC/korRxF7GQoF9TYWBanDe0lmfu+wj9JHXLj24xdMWTN9HpUCURdIFMo 5qzA== X-Gm-Message-State: APjAAAVmZZbY60siRxNDoO+jfZe1rqqMcX/abf1p9sAJBNFgAQwKdLOX NiBxgytW4aNk/e62I3mljVAALw== X-Google-Smtp-Source: APXvYqxntetr46hd4VdYt//b/thMhWSNbwb9vCbsmQW+Uc08wwpf2Ox1a6CJOdMbbCECegJUMT/tqA== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_164304_652181_B4321625 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Derek Basehore , Philipp Zabel , Maxime Ripard , Sam Ravnborg , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , Jani Nikula , David Airlie , Thierry Reding , Matthias Brugger , dri-devel@lists.freedesktop.org, Daniel Vetter , Rodrigo Vivi , CK Hu , linux-mediatek@lists.infradead.org, Sean Paul , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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 | 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