Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2372806iof; Wed, 8 Jun 2022 03:40:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp9eWQPvdY6Ea02ByKDRQKQZ/TBoxSnT11jpAhcRC77X9ezQpjr+Cx1JwsWMD5XUW7OAUF X-Received: by 2002:a17:902:e752:b0:165:1282:8d56 with SMTP id p18-20020a170902e75200b0016512828d56mr33976212plf.48.1654684824384; Wed, 08 Jun 2022 03:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654684824; cv=none; d=google.com; s=arc-20160816; b=jb1svIbzU5DIGSR61LjjK4e3ZWoBkt5lh+ubOQvleaQJ77CSAdh0jhYes0Hj1a7/N5 O9NeKIKTL7+7fWjeXHMqF75k3AAaMLJhGQTjrWGTzXjNrAOLqlxA+c80E/ddrMt3v2s/ ee2you5B8lP6wFwEuqCd3pG2M5mh4A7SsTuLD1SBn1ZVoaRhK0MF6Bb4um/DaAlW2wYN 14/Hnh1Zb8B8m8DRl4wKGCn65sZnP9ps0382TVNn6DUHfuqWvdUNiiNXE/VhCZnDJWCc sigAwVJnZC9fdBPRm6CpXPa1meIunSl+W8nh7z8pnU6vDcVe0Dom0KgKTdLXuxJelr8F fXwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Dk2EVUG101rQm23r/ZlU8mzZDKwDG1KKDCi7n9ZjRd8=; b=Xf8N4TNxDVQqGBYD/Zqk/g4XQPsbAS6XU/2WqnyFpeThtrWaOuqWVdvpL6NQBLcg60 gofJnuZgm8j+hPEQrU5fEjRTTBCjSWVj7riyX5anIRj00EdjTz2cyiNxXX81MkMeavqt +mEaKqzdWUIcQE6gobcDIm8pKabqAkYlWvzE+yL2mN5D54qEQwCvcOZTfZ4y8kdykJyp oyN2fJVJORxY0IP5SBp1PTkxT7kiBVP3Q1MAQIIZydJ+auPV5RdMqb5sEeZLIAMiYnnT LHCMXxE6DHP6/OAE/4qAm0qx2v7vjc8+LSpwbvSM7tT3B26QrZZBYlFMxRYMVIytLqKo 62GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j8QWqh3V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 9-20020a630309000000b003fd12b8050esi22032067pgd.665.2022.06.08.03.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 03:40:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j8QWqh3V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 739F9B6421; Wed, 8 Jun 2022 03:07:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236085AbiFHKGQ (ORCPT + 99 others); Wed, 8 Jun 2022 06:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236020AbiFHKFn (ORCPT ); Wed, 8 Jun 2022 06:05:43 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31FDA14015 for ; Wed, 8 Jun 2022 02:48:26 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id 3-20020a17090a174300b001e426a02ac5so20131957pjm.2 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=Y4+VLBTpz88qC/HNW/8nF3QH8dnTqXrUF25ZYDiQkZCYmVmKofz9GvkYLsTNwSrsOR 4zm3Hi87NV/3LaJp/r1E/annd9DZDXTp20rEUG8GvOqIG0t0af6xpwuAWejpn3m9cXlk tgH+sHdwo8Lz2wBXwolJHp5LkXHSpmQlBIlNbe1r2T4YTVLQapk6Ozh4WyVdSy1n1QS3 0zpg8ozRrdYtZc4jCH8gzRgL3Zt2R/HcttkdbDqEB8EcsdI7NM3CWUNKWZfj3BNtbBF7 Gyv8HPgSrPPbq5/lMtb7v6LZKLp/HhYtx+mC2Flv//ivwsoWhmufEelgw0Pt1bFV0mOn cIYA== X-Gm-Message-State: AOAM533YE/RbKLfFeaByKH5jFf5tOgku6/LYRAtXeq/N+lboxWbXtssa z6CbStV+oyZzVxpbjTTnLUIs5w== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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: * -- 2.36.1.255.ge46751e96f-goog