Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4858031ybp; Mon, 7 Oct 2019 15:15:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxu7gha5K8Wr9HU8sZH+0QNYb58I8xdnFmB23yksEZ69lltna7okMHJ73Q8obC70HmzHGCD X-Received: by 2002:a17:906:4ad2:: with SMTP id u18mr26431963ejt.117.1570486539138; Mon, 07 Oct 2019 15:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570486539; cv=none; d=google.com; s=arc-20160816; b=F9bZCfj2cu/Yagkkq8EGRkpgZPZOoHPjD/OulWs8q0AvvE7p4kvwOiryA6md25n+bz KZvDEnRV8eVnS8LA9Cztd6veaeZLyKIaFenIWYM9sNLuZl2XGdH0Oq/IPCGuydqbQM5P j2RxIRB3FoxiK/1pI6ddZcvoADgzFU5dA9e+3/hqnMxbMam9xSqV+vjxYLsv90RXJneZ 9I4S2UESapmgWXP/Iw0JH9hEcGdXlcVOVOSqiL2zCqjeEJlrZLoG7AVyUpnEfq3Oo5G2 nC7gFPSS8pcvU+a8Nx9QvLgvQ+8wAAfs4QWgL/e55imcabREkipT2RsKP19hDthqwAx/ n0JA== 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=+x3+NIU7NmFQGG7aY+XAxLXvLzEYeAhpOrsYIv4oDkM=; b=gj4wANsC3rW33oGB9WjNLpQnGqGrMWbe8N9LkTu7B1xRwzQLXXWDwerMlLfm714+nx tx2RIeSlacBbgFLu37mlbrjIEeKJH1oi9Hg6X3B/vO//C3rqCbvqBu9mSe2/kMrNoB4h IPEhsfPkTpb1IqggJCqlNx8fLaX54eXjewxTIcB8S+FDpuzzrg0nDzJexa/VlSUFFnMw /ejMGUbYHXy+3QIiP5tKpA3pkxTEp2CiyMHy8cdKEgaZSDl3TR+zlAesAFHGzf10rIJo CkU2zvzP9jVkQIlGDXFmjgsnVvqYAr7v0GukivKbBjckNyaaPOvHWlSntFTW2z+SQaMZ IHcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MRy0AppF; 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 dv21si7581330ejb.241.2019.10.07.15.15.15; Mon, 07 Oct 2019 15:15:39 -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=MRy0AppF; 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 S1729448AbfJGWMP (ORCPT + 99 others); Mon, 7 Oct 2019 18:12:15 -0400 Received: from mail-ua1-f66.google.com ([209.85.222.66]:40920 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728654AbfJGWMO (ORCPT ); Mon, 7 Oct 2019 18:12:14 -0400 Received: by mail-ua1-f66.google.com with SMTP id i13so4587088uaq.7 for ; Mon, 07 Oct 2019 15:12:13 -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=+x3+NIU7NmFQGG7aY+XAxLXvLzEYeAhpOrsYIv4oDkM=; b=MRy0AppFIQGOlY6L6gMMEunAMXL17PrnNxCObaQGdWiDqCIMWNkg6d5h2eu2WrGsUo isbpiMoDVCMNQvERIIm5fZzgOV9cvY+1+AfjY/rODIpIhEefkrJ5GDUVMpt12++LLjRp 9Vn/Kcj1lKTBr5qjg8tHk7Co5qMshcdfb/qIg= 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=+x3+NIU7NmFQGG7aY+XAxLXvLzEYeAhpOrsYIv4oDkM=; b=FxtppPufnrxpo3ThjXsoKxc/vNmei8yVnY58rr9Ohu/yeYpMhRuPH83dg2Yk1kk7UP blO34Prn82elzEQ84kmpredLjkhXsIg+HupN1nKjmwnZft6UMCGB+bQ+shubZJd4kzeX ChwAd2imbPuZWmbxcznik0/i6IOTIOlQ5VpDTq1/3DitqGii0tAiPTyagpZ8/rHwQL+p WbyMahIeNsp9tntECkqn5sJbN5xSSxLMOmefuGH2RWxdD4D+t1dmcmlbIiS0UlJHpJLT G8e26Cc1xScCHDf0EOYIFAG5jIlviFaCnXiLlPFgWz+CzIDDfa2OcGJh6J6qIke5WNIK WDsw== X-Gm-Message-State: APjAAAWPqdphJsalYysV05LyLEp7AA1qKTIojtREpz/E8znyRxMdp1K7 fzwH4AGBelJyU4qeRB3b7LBHlfuLPd0mReoft6EuQQ== X-Received: by 2002:a9f:2746:: with SMTP id a64mr3186185uaa.66.1570486332696; Mon, 07 Oct 2019 15:12:12 -0700 (PDT) MIME-Version: 1.0 References: <20190925225833.7310-1-dbasehore@chromium.org> <20190925225833.7310-2-dbasehore@chromium.org> <20191007163822.GA126146@art_vandelay> In-Reply-To: <20191007163822.GA126146@art_vandelay> From: "dbasehore ." Date: Mon, 7 Oct 2019 15:12:00 -0700 Message-ID: Subject: Re: [PATCH v8 1/4] drm/panel: Add helper for reading DT rotation To: Sean Paul Cc: linux-kernel , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , Thierry Reding , Sam Ravnborg , 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, Oct 7, 2019 at 9:38 AM Sean Paul wrote: > > On Wed, Sep 25, 2019 at 03:58:30PM -0700, Derek Basehore wrote: > > This adds a helper function for reading the rotation (panel > > orientation) from the device tree. > > > > Signed-off-by: Derek Basehore > > Reviewed-by: Sam Ravnborg > > The patch LGTM, but I don't see it used anywhere later in the patch? Is there a > panel driver incoming? Yeah, the boe-tv101wum-nl6 panel will use it. It's not in the patch currently sent upstream since I don't want to step on their toes, but I plan on sending a patch to add it as soon as that is merged. I could hold back on this patch until that panel driver is merged too. Another alternative is to throw this into the generic drm_panel code, but there's no obvious place to put it since DRM seems to leave reading the DTS up to the panel drivers themselves. > > Sean > > > --- > > drivers/gpu/drm/drm_panel.c | 43 +++++++++++++++++++++++++++++++++++++ > > include/drm/drm_panel.h | 9 ++++++++ > > 2 files changed, 52 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c > > index 6b0bf42039cf..0909b53b74e6 100644 > > --- a/drivers/gpu/drm/drm_panel.c > > +++ b/drivers/gpu/drm/drm_panel.c > > @@ -264,6 +264,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 624bd15ecfab..d16158deacdc 100644 > > --- a/include/drm/drm_panel.h > > +++ b/include/drm/drm_panel.h > > @@ -34,6 +34,8 @@ struct drm_device; > > struct drm_panel; > > struct display_timing; > > > > +enum drm_panel_orientation; > > + > > /** > > * struct drm_panel_funcs - perform operations on a given panel > > * > > @@ -165,11 +167,18 @@ int drm_panel_get_modes(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); > > } > > +static inline int of_drm_get_panel_orientation(const struct device_node *np, > > + enum drm_panel_orientation *orientation) > > +{ > > + return -ENODEV; > > +} > > #endif > > > > #endif > > -- > > 2.23.0.351.gc4317032e6-goog > > > > -- > Sean Paul, Software Engineer, Google / Chromium OS