From patchwork Wed Jun 8 09:48:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12873111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 88A6FC433EF for ; Wed, 8 Jun 2022 09:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hBwqBVt8KLeY7bn7JLiDxrZ2wyKESMUzLQtiB1dPUHw=; b=E9WAHSZnuGaTSR qye+xcqArx+GjLx8g/T8FzeDOD9iuaayuUKo65L279LiNPL9hlHwpuH/9QP9HQq5hVePAK4bWOzae 9mqDQ22FznZ6wxdv7lNdSyTer9VLoWppjIwPq/4sXBNvIc+WLao7o+EehBeLoZ89nixd1KcFQEy5y lpwSGV29WJtvs1viuZepHHAR+hA+tgLtFs1o6QO93E2acnA3pc543q3Q9iQNJ+t04j+Wsg/lslQHk Goag88VpPtJBILwqCTRZ/vP8FaVaZhKA0zWF8ZB7jLEiP3ks3t1zaTjf1FxCQigML/jx2QoIG8rQk SJAHO7nd7CCFyZAfylNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nysIn-00CT8C-Ax; Wed, 08 Jun 2022 09:48:37 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nysIc-00CT4q-E3 for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2022 09:48:27 +0000 Received: by mail-pj1-x102c.google.com with SMTP id o6-20020a17090a0a0600b001e2c6566046so23335230pjo.0 for ; Wed, 08 Jun 2022 02:48:26 -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=Dk2EVUG101rQm23r/ZlU8mzZDKwDG1KKDCi7n9ZjRd8=; b=j8QWqh3VeH6zE+x5CqSxyRP92nBBtths9qDeKi+gqFUHoz2TBsRRzOmCA/dl65TGwX /YWZzow5DUgSybhjFdXM6++3qtRpUf+Y3ZTUfD0/hucV8+31RhGlibfVOBG48yYoOvcN ChPCccBhnxS9PivqID9+qUOQp1utj7jEqX7+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dk2EVUG101rQm23r/ZlU8mzZDKwDG1KKDCi7n9ZjRd8=; b=jZ0GxbzwZLw5v4t6PXMSJYBIMu42jVFiTHz+dR5C7BWm7Xufuph8t65Ik9MQPOAgmd qyfcaQISxCUcS5XPoIIvNAFNADUBj7bN+b/eH2Q6O/mlT8AAxtabHvxRzNsKkja5Gap8 KhWeRVQYjmuPT0F6fiEnO+3iUTW3WZHRJ5li5sxK3sJ+suTsTulFqNb22qjtZp8m5yzu QspPrhfGN9mJGnO0aGYszQpB/UrhMlOsrQhQxQX5Bdtm/dvfdl3kYy/A907bik0pszz+ StfIkLTz1rtrAvbQkXCAFuOXyyH5wysnitaJZF9BPUdp1zOpbfo7pnNNdNSh2YO8L2x3 ipkA== X-Gm-Message-State: AOAM532YoOfpyIeD9rAArn7wfEkfxlSUCMONL4z1E7bkSHV0tut3rLk2 fTQ6IIdN0zomH3BmmKcE6Q55hw== X-Google-Smtp-Source: ABdhPJzyscN4nhpdxlEaz3bHujhJtkfRSWOh9x+gpg+krvUZqaEWRACfaESxbhHHo/6Uk0P45Tdfvg== X-Received: by 2002:a17:90b:c85:b0:1e2:e645:a8c9 with SMTP id o5-20020a17090b0c8500b001e2e645a8c9mr36464915pjz.185.1654681705655; Wed, 08 Jun 2022 02:48:25 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:c46b:e7b1:f6c8:5eb8]) by smtp.gmail.com with ESMTPSA id t10-20020a17090a950a00b001e28e80a8d6sm13584038pjo.38.2022.06.08.02.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 02:48:25 -0700 (PDT) From: Hsin-Yi Wang To: Hans de Goede , Sam Ravnborg , Stephen Boyd , Douglas Anderson Cc: Thierry Reding , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Philipp Zabel , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, Rob Clark , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/8] drm/panel: Add an API to allow drm to set orientation from panel Date: Wed, 8 Jun 2022 17:48:09 +0800 Message-Id: <20220608094816.2898692-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220608094816.2898692-1-hsinyi@chromium.org> References: <20220608094816.2898692-1-hsinyi@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220608_024826_514479_A8F8AF83 X-CRM114-Status: GOOD ( 18.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Panels usually call drm_connector_set_panel_orientation(), which is later than drm/kms driver calling drm_dev_register(). This leads to a WARN(). The orientation property is known earlier. For example, some panels parse the property through device tree during probe. Add an API to return the property from panel to drm/kms driver, so the drivers are able to call drm_connector_set_orientation_from_panel() before drm_dev_register(). Suggested-by: Hans de Goede Signed-off-by: Hsin-Yi Wang Reviewed-by: Hans de Goede Reviewed-by: Douglas Anderson Reviewed-by: Stephen Boyd --- drivers/gpu/drm/drm_connector.c | 32 ++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 4 ++++ include/drm/drm_panel.h | 9 +++++++++ 3 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e..859165a1c8f1 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -2320,6 +2321,9 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property); * It is allowed to call this function with a panel_orientation of * DRM_MODE_PANEL_ORIENTATION_UNKNOWN, in which case it is a no-op. * + * The function shouldn't be called in panel after drm is registered (i.e. + * drm_dev_register() is called in drm). + * * Returns: * Zero on success, negative errno on failure. */ @@ -2389,6 +2393,34 @@ int drm_connector_set_panel_orientation_with_quirk( } EXPORT_SYMBOL(drm_connector_set_panel_orientation_with_quirk); +/** + * drm_connector_set_orientation_from_panel - + * set the connector's panel_orientation from panel's callback. + * @connector: connector for which to init the panel-orientation property. + * @panel: panel that can provide orientation information. + * + * Drm drivers should call this function before drm_dev_register(). + * Orientation is obtained from panel's .get_orientation() callback. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_connector_set_orientation_from_panel( + struct drm_connector *connector, + struct drm_panel *panel) +{ + enum drm_panel_orientation panel_orientation; + + if (panel && panel->funcs && panel->funcs->get_orientation) + panel_orientation = panel->funcs->get_orientation(panel); + else + panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + + return drm_connector_set_panel_orientation(connector, + panel_orientation); +} +EXPORT_SYMBOL(drm_connector_set_orientation_from_panel); + static const struct drm_prop_enum_list privacy_screen_enum[] = { { PRIVACY_SCREEN_DISABLED, "Disabled" }, { PRIVACY_SCREEN_ENABLED, "Enabled" }, diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 3ac4bf87f257..94b422b55cc1 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -38,6 +38,7 @@ struct drm_modeset_acquire_ctx; struct drm_device; struct drm_crtc; struct drm_encoder; +struct drm_panel; struct drm_property; struct drm_property_blob; struct drm_printer; @@ -1802,6 +1803,9 @@ int drm_connector_set_panel_orientation_with_quirk( struct drm_connector *connector, enum drm_panel_orientation panel_orientation, int width, int height); +int drm_connector_set_orientation_from_panel( + struct drm_connector *connector, + struct drm_panel *panel); int drm_connector_attach_max_bpc_property(struct drm_connector *connector, int min, int max); void drm_connector_create_privacy_screen_properties(struct drm_connector *conn); diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index d279ee455f01..3a271128c078 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -116,6 +116,15 @@ struct drm_panel_funcs { int (*get_modes)(struct drm_panel *panel, struct drm_connector *connector); + /** + * @get_orientation: + * + * Return the panel orientation set by device tree or EDID. + * + * This function is optional. + */ + enum drm_panel_orientation (*get_orientation)(struct drm_panel *panel); + /** * @get_timings: *