Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1307ybd; Tue, 25 Jun 2019 15:13:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzvlMU/+fGbCgKBEvD4HagI8a+a3k8KpTHZfwPJxDnDAwaM7lhzNZwyY9TzkfpUow4mu/Z X-Received: by 2002:a17:902:7793:: with SMTP id o19mr1083271pll.110.1561500823186; Tue, 25 Jun 2019 15:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561500823; cv=none; d=google.com; s=arc-20160816; b=aYtMey6YU/kosDKsirGNIBuUviEkRlC7kaG7OA+g9ADC889Zz/sQiHTPmFxQQyrrAM wK8X4nXziptcjHdQfcF+rD3FWAp0tzWd3ggOf8QQgmSOG2GHrBskex8Gc5+H8Ibb49Wy E/gNYQv9Z3SnhxWmCXSKlOH8dn+wi+PnNeUCN0liihHoFz5UON6I6pavrtD4mycY/g9C CQ/QS6S7V0shbKmIx+IfUO4tW9PpQjcBchRTHMeWl2h8k8CMBS5LKcG5DxDPBOZcrf4c 9/wBz6pN74U0uK1c3+k/7gNdfs9BNTmkMe3Bjp9iViz2suGGnkEbTtL/kPrVvDf/ARcv /W9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3n+LcMejLmcA2HmAuYiDTQTe/hLh9m1gb0zWqdGsK68=; b=zBWdKSDQvs5pK306Bfiui7/U1jyR7z8xmA4YG+NM7pEjrZEfJ/UqTVUlcHECjOY9AT wRJvaVPYL56+IQGZc+xQcTiqTt+8TQnXHNn5qrf+cHImockzDsGVmG4e3b2qMTDo+XiQ Qb5N0BWpuqM+6Xd6O5yS5aZDeJeB3jBeZvDHle3qI2F94/xTt0Yk4Sil1+J/r0WinHT4 beDj/A2gGJhC6YEv5SOP+S73KLnu58NA7BSYHG3OLp6nrrM8k/wohGChxE+KOPT76Gd7 6sAN8bVkT/cIjQDGSb3c2fmSXfMeMpqfxWQEiUni6LCxcFwrecwxaOIO/NpjKu7wxtBU O6Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VZCpcSru; 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 t22si14140181pgh.582.2019.06.25.15.13.26; Tue, 25 Jun 2019 15:13:43 -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=VZCpcSru; 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 S1726523AbfFYWNE (ORCPT + 99 others); Tue, 25 Jun 2019 18:13:04 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:40932 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbfFYWND (ORCPT ); Tue, 25 Jun 2019 18:13:03 -0400 Received: by mail-vs1-f68.google.com with SMTP id a186so244732vsd.7 for ; Tue, 25 Jun 2019 15:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3n+LcMejLmcA2HmAuYiDTQTe/hLh9m1gb0zWqdGsK68=; b=VZCpcSruMkBN/fSuTzWYVVaGnaXStuxDTlxa6KFFowmHSW6v2Kp5xf+pb8sCdtaNmI xWDUgTBPVJTm3UOzht8hRhzYr5tvq5wbDau9K9ekcL7zkkOkPO6YsM415uZM6T3vh/XA fGfPjTr6Fy2AgIjssn8ZMUzqkRDozC0cHm7b8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3n+LcMejLmcA2HmAuYiDTQTe/hLh9m1gb0zWqdGsK68=; b=G9O9ffwgF+RkOF1032LehYSR/Idz8a/oNZ4IMCm93km6WShymKjG9X1hIvyDaKA5gm lxnOu3aAp38FI76hBouowJl7+QjQJVNXoWYZjdod71Hwpnwv2YWuDEr8QmchfSdPdh7r 0XDH8HjW6cn7K9/1lPbTuyJRhbeOKkX5yG0fopdbbKI58L0KsUe3jP4zoaQHpVTnkxiB GmGE8ysJmnEy8fe2wriMiGd4Z6ov2NYB04ONIE75+5LGL7dZZtuXhMOxLxrR2faGsFAK sCDL/3yfdiNYrSMbZOpMTauaFDdldZ35bbXDjW47yiS1/jVsmmwe8Oq5HCYurzIZhd1s kTGA== X-Gm-Message-State: APjAAAUeR4xKC4BZPRW9zNzPp3snJTjfKas3GtC9SHqY0ApiHSyQAt8f +EiGCMPFzZUzyiik9DnXV3juSDYh7F018nDx9aLfRA== X-Received: by 2002:a67:cd9a:: with SMTP id r26mr780862vsl.152.1561500782182; Tue, 25 Jun 2019 15:13:02 -0700 (PDT) MIME-Version: 1.0 References: <20190622034105.188454-1-dbasehore@chromium.org> <20190622034105.188454-2-dbasehore@chromium.org> <20190624203632.GA12316@ravnborg.org> In-Reply-To: <20190624203632.GA12316@ravnborg.org> From: "dbasehore ." Date: Tue, 25 Jun 2019 15:12:51 -0700 Message-ID: Subject: Re: [PATCH v3 1/4] drm/panel: Add helper for reading DT rotation To: Sam Ravnborg Cc: linux-kernel , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Thierry Reding , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , CK Hu , Philipp Zabel , Matthias Brugger , dri-devel , Intel Graphics , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 24, 2019 at 1:36 PM Sam Ravnborg wrote: > > Hi Derek. > > On Fri, Jun 21, 2019 at 08:41:02PM -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 | 42 +++++++++++++++++++++++++++++++++++++ > > include/drm/drm_panel.h | 7 +++++++ > > 2 files changed, 49 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c > > index dbd5b873e8f2..507099af4b57 100644 > > --- a/drivers/gpu/drm/drm_panel.c > > +++ b/drivers/gpu/drm/drm_panel.c > > @@ -172,6 +172,48 @@ 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. > > + */ > This function should better spell out why it talks about rotation versus > orientation. > > It happens that orientation, due to bad design choices is named rotation > in DT. > But then this function is all about orientation, that just happens to be > named rotation in DT. > And the comments associated to the function should reflect this. > > something like: > /** > * of_drm_get_panel_orientation - look up the orientation 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 property of a panel in the device tree. > * The orientation of the panel is expressed as a property named > * "rotation" in the device tree. > * The rotation in the device tree is counter clockwise. > * > * Return: 0 when a valid orientation value (0, 90, 180, or 270) is read or the > * rotation property doesn't exist. -EERROR otherwise. > */ I'll clear this up in the next patch set. > > This would at least remove some of my confusiuon. > And then maybe add a bit more explanation to the binding property > description too. Tried this, yet I got told off for adding kernel details to the DT documentation (which is frowned upon). > > Sam > > > > > > > > > > > > > > +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 Thanks for the review