Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp25695ybi; Fri, 14 Jun 2019 17:45:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcFWMCKJLtNg+l44N8OFXks6nHAlJXxGoAngDLdB6vJmfYMRgXvSgyl9myLJMzlLF/unRI X-Received: by 2002:a63:eb0d:: with SMTP id t13mr39198696pgh.37.1560559551918; Fri, 14 Jun 2019 17:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560559551; cv=none; d=google.com; s=arc-20160816; b=xvek1cGq7onwjYklb0cP1BUJA7WRTG1XYrsi7S+Kp1DMG8sYF+fREwm2Ec8v4n/O+o DttTjNjZYEs/EQG7IFPmpRLMrV8tEuBl2Zt3U/Cin1M9iEZogVNRMWloJhGK6lmbXZGk ckNOTcLFhGojd/mz4aCWQC0sgi1njihkXwwJo9b65TmjGAwbeAtB5KhR4NjAGmJ9ru3y 2wYGW3uSivFMY4fc6OwomyjQqkBs7yE/Cmo6aQkU4Kchtn1A5lLQ0ANeTrwa9QdAy4Sx C5NDdYuWR6vrZI4Q6p5TsaK4VzLXlOplKZQJNpJTFF/YDDDutgfQ4bNehMmSXUQocTKI G0Zg== 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=Hqhu3iKjp8F7B0PNppJXXZGMbjFkFcAKAjlOSHZGpCw=; b=UwmjIqw+L7n4R6hbW+Lev7NLhggjuMpVvcde0ZqqHmNezxkvTKAyr8Lf8mVBfKybDg JXxuV3TWC2L9JlC4c0FeoGUO9QCHhMgoKyqk3abDxbvWVqT8HjruhrIrkgoqP5zokmdD o3vE7kxsUWgtnRfZg3BDEDQ9su5TZQoeJwAD/DlcrU7tDg2ML+t9hdGMMRZ5UDsznFDv zkfkZ61q/jPPrzWkmaWaYQdq9DgryzJG5bQX55v0WdQW2QtJD0u63AxtMePwUf657Tem d5Pjg5f/6PEC9XLErmutU7dOlH9KyTCyMebgo4+kIB7fpvsAH7/Uvv/0VEBtgqiV/Dzt lFqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BtucgTmj; 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 m12si1014479plt.413.2019.06.14.17.45.36; Fri, 14 Jun 2019 17:45:51 -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=BtucgTmj; 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 S1726185AbfFOAoh (ORCPT + 99 others); Fri, 14 Jun 2019 20:44:37 -0400 Received: from mail-ua1-f68.google.com ([209.85.222.68]:43013 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbfFOAog (ORCPT ); Fri, 14 Jun 2019 20:44:36 -0400 Received: by mail-ua1-f68.google.com with SMTP id o2so1524288uae.10 for ; Fri, 14 Jun 2019 17:44:35 -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=Hqhu3iKjp8F7B0PNppJXXZGMbjFkFcAKAjlOSHZGpCw=; b=BtucgTmjUbw04kv6gLtiH5nn5+UMipRd1oqlFsMTR2xCAp7dX7SUmOFAn+CiWX1/b0 hhfIE8TVXUaoZx+P37dcbybW/6oDUCNAojfJQ3XVpYGMNP//S4/I38oQKNIvywS47Ah3 eIKb/hDcaVeqiHgUKu6Oac7LI+kqGw2jXUavc= 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=Hqhu3iKjp8F7B0PNppJXXZGMbjFkFcAKAjlOSHZGpCw=; b=esNFrhAdxew+/ugpThR2S2o+H2ScLSEQPOWs0aOPzknCezwgdXk5Af2VWCGRZcZ23L YuBhK60s9Bq4syfxthWeK0cgATAQFa+7JCLBDoCfYxPLqK3f2jr/xLge3QM3fmobfrJa d+0ExsPFNllhd3UAdDMq1aGOOCEflolrJ+FAk6BYI+2iE65kEOQwbLUvdy2xBfCfu0Mq kiF5b55QSOtpZfHcDIwpCuWlVt9YEmo4I8y0XYgTSh0IKrCymQNMJpI4LGYJXTpM8jsQ KJxQ6Xa26SWR71elymfFwYbQ52Gfb+YaSomV+w65XOa3X/lY4wApSpRH0bWopS1MtDM8 HiLQ== X-Gm-Message-State: APjAAAU4idPObvSB2rKJXhmSOQ5gdMu++hLgvb6iGIrlwiEA8MKKzLhn z06025dj2rsr0pp94ED9ldCc0msUUAgWPuwqKLiUMg== X-Received: by 2002:a9f:31a2:: with SMTP id v31mr1811971uad.15.1560559475175; Fri, 14 Jun 2019 17:44:35 -0700 (PDT) MIME-Version: 1.0 References: <20190611040350.90064-1-dbasehore@chromium.org> <20190611040350.90064-2-dbasehore@chromium.org> <20190612211807.GA13155@ravnborg.org> In-Reply-To: From: "dbasehore ." Date: Fri, 14 Jun 2019 17:44:24 -0700 Message-ID: Subject: Re: [PATCH 1/5] drm/panel: Add helper for reading DT rotation To: Sam Ravnborg Cc: linux-kernel , 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 , devicetree@vger.kernel.org, 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 Fri, Jun 14, 2019 at 5:43 PM dbasehore . wrote: > > On Wed, Jun 12, 2019 at 2:18 PM Sam Ravnborg wrote: > > > > 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? > > > > The binding is just an int value, but I can change it to the enum. Oops, I see what happened here. The way I wrote it should actually use the enum > > > > + * > > > + * 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