Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2091765iof; Tue, 7 Jun 2022 19:25:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvbv6JskYc1dFDcGNxnUY3rVf5kCoCuYWIHyr6tHytBsSAaVBT2yMNQ4iTTe/HzvnXQHaZ X-Received: by 2002:a65:6a16:0:b0:39d:4f3:67e6 with SMTP id m22-20020a656a16000000b0039d04f367e6mr28279079pgu.84.1654655152868; Tue, 07 Jun 2022 19:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654655152; cv=none; d=google.com; s=arc-20160816; b=USwzxqEeEHuDX7JurEbmmMPYSbC0G0v3uNEHBxxUUIAzOxcX7ib2qQECVoN7D5SojF gdFfLCODUJBzJ/btkUooE8EvMSCbxDgPqfBjtAE4SRB76VGSvLkCeAON28Jo4vc0lJgL 5kwdOXPeYoqWIK9sw/WIDu0428F6RQCBlLsYDnh3k6jqoom1F6WyTtHlYIKfp5/CnMZO yYiJNmwutmw3Ahc4GRFb/xQ2yKepKB18DlzTlsLYpGKj7UCXn7Sxcj8V81JOVBjlHhsO iEY+1OkbAjPdqYQCfgzATMa2hS8TFM2wyijEW53MkIfSAuE5fL3eYlQmG/kYyBxmv6nu GWEQ== 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=JYiFnAz00MQeZi91E0UGkYUB+X1a+/Lsax/pqn3rMlA=; b=hoEwUx+nmkn+7dI7+ZMvvpdkxP3Nhy9YiIMd+4ax1oxnavNUmR38jAfa49Pecs2t4W saH0E/VBdqTR696pGXlKTNhPGAg+GHv7BEO6+W2oziBvHX359AZAXTNIpZ1eIQaerNQB ZJksaZDoPdXnEA6x5esR6OaDswedqjO2Wkhfl4IyuzGchueeaRtAI869RZJMdk/yuV/0 a9oqlqPvGyMya7ZI330a11AdAkdzDy6H8eWDAVhhTSeTTpDcVIB+hpvsNBzc+ThC1+eT rqfciv2GzhfAwFCCWULS+mAVPGVIFQLFdaHTZ+/q05H8LZ5JAyWjZ3dfSAdRLkqHIL7E P0ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KH3+lr+u; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id x22-20020aa793b6000000b0050e0530cfe4si24533282pff.279.2022.06.07.19.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 19:25:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KH3+lr+u; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 962783AC1CF; Tue, 7 Jun 2022 19:08:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237768AbiFGJGM (ORCPT + 99 others); Tue, 7 Jun 2022 05:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238886AbiFGJGA (ORCPT ); Tue, 7 Jun 2022 05:06:00 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F4A5CA3FC for ; Tue, 7 Jun 2022 02:05:59 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id w3so14278080plp.13 for ; Tue, 07 Jun 2022 02:05:59 -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=JYiFnAz00MQeZi91E0UGkYUB+X1a+/Lsax/pqn3rMlA=; b=KH3+lr+udpk9BxBvp8pMA2hNB+th+s1iQrrtA3y5IMRralVN952OscgP2INjWAZFd8 k4mjICqnU4+kEi0V4d+uTKrHr7Rh/7LZgNlFafUHVj0Q1/jNY9mXrUrB2PtUobzOOhqC rFSPen3RMgxDU4KLhSxdhq54eJ0q9X09oVhzQ= 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=JYiFnAz00MQeZi91E0UGkYUB+X1a+/Lsax/pqn3rMlA=; b=1PPDy3aHEZq8BYUTGjzzyKbVgaRV2atM8F8S/M0SPueyDyulpKh9mG0anVuIozr3Op I4ypF7wO7BeLwST240x+oZgwMG/XjeZ9oD581xYY/aKcOEPaPoVixAl/XAhfp4lBg0Ul Kj+D7Od2bodIjBodxEgc9KLbMzzu0QILB3FKDWft2NT/6fwwIKS2ia6m+3eZZl/UNCUZ DN18paFNFGZXpRRgBI8aqqvpurNNEG+J2AZEtzaa83DeFsBaS2xD/hjim6WJPqcG5DfF XHhAFEAaOL4FghHXpKsWsn3sWW4+jdpLFZOzFhQPYaeJ78LSPj0UD7ReU8xQd6EwBtK3 0fnw== X-Gm-Message-State: AOAM533xblRqcbHwyhiQyJWdM7lktPLJ/sWbI8rnnqBcaZCooWWbX/rR XVold9duL0TpUTzah9vCAJvhNg== X-Received: by 2002:a17:902:a413:b0:156:15b:524a with SMTP id p19-20020a170902a41300b00156015b524amr28148208plq.106.1654592758652; Tue, 07 Jun 2022 02:05:58 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:40b7:55ce:10ee:c7a0]) by smtp.gmail.com with ESMTPSA id t27-20020aa7947b000000b0051c0fe8fb8csm4507010pfq.95.2022.06.07.02.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:05:58 -0700 (PDT) From: Hsin-Yi Wang To: Chun-Kuang Hu Cc: Hans de Goede , Thierry Reding , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Rob Clark , Stephen Boyd , Douglas Anderson , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/8] drm/panel: Add an API to allow drm to set orientation from panel Date: Tue, 7 Jun 2022 17:05:42 +0800 Message-Id: <20220607090549.2345795-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607090549.2345795-1-hsinyi@chromium.org> References: <20220607090549.2345795-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 --- v4 -> v5: - Simplify the caller from drm_connector_set_panel_orientation(connector, drm_panel_get_orientation(panel)) to drm_connector_set_orientation_from_panel(connector, panel). The main function is also moved from drm_panel to drm_connector. - Add some notice for the original drm_connector_set_panel_orientation() usage. - sort callbacks. --- 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