From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sam Ravnborg Subject: Re: [PATCH 1/5] drm/panel: Add helper for reading DT rotation Date: Wed, 12 Jun 2019 23:18:07 +0200 Message-ID: <20190612211807.GA13155@ravnborg.org> References: <20190611040350.90064-1-dbasehore@chromium.org> <20190611040350.90064-2-dbasehore@chromium.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Return-path: Content-Disposition: inline In-Reply-To: <20190611040350.90064-2-dbasehore@chromium.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Derek Basehore Cc: Mark Rutland , devicetree@vger.kernel.org, Philipp Zabel , David Airlie , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Maxime Ripard , Rob Herring , dri-devel@lists.freedesktop.org, CK Hu , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Matthias Brugger List-Id: linux-mediatek@lists.infradead.org SGkgRGVyZWsuCgpPbiBNb24sIEp1biAxMCwgMjAxOSBhdCAwOTowMzo0NlBNIC0wNzAwLCBEZXJl ayBCYXNlaG9yZSB3cm90ZToKPiBUaGlzIGFkZHMgYSBoZWxwZXIgZnVuY3Rpb24gZm9yIHJlYWRp bmcgdGhlIHJvdGF0aW9uIChwYW5lbAo+IG9yaWVudGF0aW9uKSBmcm9tIHRoZSBkZXZpY2UgdHJl ZS4KPiAKPiBTaWduZWQtb2ZmLWJ5OiBEZXJlayBCYXNlaG9yZSA8ZGJhc2Vob3JlQGNocm9taXVt Lm9yZz4KPiAtLS0KPiAgZHJpdmVycy9ncHUvZHJtL2RybV9wYW5lbC5jIHwgNDEgKysrKysrKysr KysrKysrKysrKysrKysrKysrKysrKysrKysrKwo+ICBpbmNsdWRlL2RybS9kcm1fcGFuZWwuaCAg ICAgfCAgNyArKysrKysrCj4gIDIgZmlsZXMgY2hhbmdlZCwgNDggaW5zZXJ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yYzIu MzgzLmdmNGZiYmYzMGMyLWdvb2cKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX18KSW50ZWwtZ2Z4IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRl c2t0b3Aub3JnCmh0dHBzOi8vbGlzdHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8v aW50ZWwtZ2Z4 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0B2CC31E46 for ; Wed, 12 Jun 2019 21:18:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9B9D20B7C for ; Wed, 12 Jun 2019 21:18:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="up2F4Hv5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9B9D20B7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ur9NXLFDXX0yA2n9herocqUoUz/YerSh/5EtKILnB8k=; b=up2F4Hv5GV6piV PvNwDGPUPInGmEAZAmsMYNnQlJMQlwNPwhCA7zxSl0IFPtC+QoFecLikXb4KO7OjBZ2LQU8VFZrvq 6AjrumFZQ+wOwTUYvMgK//T9/5jzaYE3j/iTMMPiLyyL5/8ajiw2u3DbUNJ0HjHFioSRyHoypI2Ms 0jDEvHaMeQ4I/d73Enva/xyLQpHi/aZVbNAnU2MminD5ZOPIAdqPwMnkDwtWRs2BLacI7CstdBu5u YbzxlEiZD7FbUVJGHs58YvzitiJWtc/0fuocH/rtcufmRZfxvofsIS3giN/qOT+p9CDASDJyJx7yg v6KuhsNFLU+R2J4K3v8Q==; 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 1hbAdS-0006AB-AP; Wed, 12 Jun 2019 21:18:22 +0000 Received: from asavdk3.altibox.net ([109.247.116.14]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hbAdO-00069Z-Km; Wed, 12 Jun 2019 21:18:20 +0000 Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk3.altibox.net (Postfix) with ESMTPS id 187362001E; Wed, 12 Jun 2019 23:18:09 +0200 (CEST) Date: Wed, 12 Jun 2019 23:18:07 +0200 From: Sam Ravnborg To: Derek Basehore Subject: Re: [PATCH 1/5] drm/panel: Add helper for reading DT rotation Message-ID: <20190612211807.GA13155@ravnborg.org> References: <20190611040350.90064-1-dbasehore@chromium.org> <20190611040350.90064-2-dbasehore@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190611040350.90064-2-dbasehore@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=dqr19Wo4 c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=cm27Pg_UAAAA:8 a=Ikd4Dj_1AAAA:8 a=t_KA93f0VNsUmkpjo_oA:9 a=CjuIK1q_8ugA:10 a=xmb-EsYY8bH0VWELuYED:22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190612_141819_042178_8C2769E5 X-CRM114-Status: GOOD ( 23.98 ) 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: Mark Rutland , devicetree@vger.kernel.org, Philipp Zabel , David Airlie , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , linux-kernel@vger.kernel.org, Jani Nikula , Maxime Ripard , Rob Herring , Thierry Reding , dri-devel@lists.freedesktop.org, Daniel Vetter , Rodrigo Vivi , CK Hu , linux-mediatek@lists.infradead.org, Sean Paul , linux-arm-kernel@lists.infradead.org, Matthias Brugger Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Derek. On Mon, Jun 10, 2019 at 09:03:46PM -0700, Derek Basehore wrote: > 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 The comment says "enum" but the type used is an int. Why not use enum drm_panel_orientation? > + * > + * 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. > + */ Initially I read -EEROOR as a specific error code. But I gues the semantic is to say that a negative error code is returned if something was wrong. As we do not use the "-EERROR" syntax anywhere else in drm, please reword like we do in other places. Also - it is worth to mention that the rotation returned is DRM_MODE_PANEL_ORIENTATION_UNKNOWN if the property is not specified. I wonder if this is correct, as no property could also been interpretated as DRM_MODE_PANEL_ORIENTATION_NORMAL. And in most cases the roation property is optional, so one could assume that no property equals 0 degree. Sam > +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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4473AC31E45 for ; Thu, 13 Jun 2019 17:17:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23D8A21721 for ; Thu, 13 Jun 2019 17:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393684AbfFMRRk (ORCPT ); Thu, 13 Jun 2019 13:17:40 -0400 Received: from asavdk3.altibox.net ([109.247.116.14]:38705 "EHLO asavdk3.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727836AbfFLVSQ (ORCPT ); Wed, 12 Jun 2019 17:18:16 -0400 Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk3.altibox.net (Postfix) with ESMTPS id 187362001E; Wed, 12 Jun 2019 23:18:09 +0200 (CEST) Date: Wed, 12 Jun 2019 23:18:07 +0200 From: Sam Ravnborg To: Derek Basehore Cc: linux-kernel@vger.kernel.org, Thierry Reding , 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 Subject: Re: [PATCH 1/5] drm/panel: Add helper for reading DT rotation Message-ID: <20190612211807.GA13155@ravnborg.org> References: <20190611040350.90064-1-dbasehore@chromium.org> <20190611040350.90064-2-dbasehore@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611040350.90064-2-dbasehore@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=dqr19Wo4 c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=cm27Pg_UAAAA:8 a=Ikd4Dj_1AAAA:8 a=t_KA93f0VNsUmkpjo_oA:9 a=CjuIK1q_8ugA:10 a=xmb-EsYY8bH0VWELuYED:22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Derek. On Mon, Jun 10, 2019 at 09:03:46PM -0700, Derek Basehore wrote: > 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 The comment says "enum" but the type used is an int. Why not use enum drm_panel_orientation? > + * > + * 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. > + */ Initially I read -EEROOR as a specific error code. But I gues the semantic is to say that a negative error code is returned if something was wrong. As we do not use the "-EERROR" syntax anywhere else in drm, please reword like we do in other places. Also - it is worth to mention that the rotation returned is DRM_MODE_PANEL_ORIENTATION_UNKNOWN if the property is not specified. I wonder if this is correct, as no property could also been interpretated as DRM_MODE_PANEL_ORIENTATION_NORMAL. And in most cases the roation property is optional, so one could assume that no property equals 0 degree. Sam > +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