Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp155535iol; Thu, 9 Jun 2022 00:40:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9nrqe9DpfbAiBgv1wZbfxW2RmjE0qYguNXKbbR8NHj0abOtRJ5oZB2ArJprN6IbChUz5x X-Received: by 2002:a17:907:3d8a:b0:710:c2e8:79f2 with SMTP id he10-20020a1709073d8a00b00710c2e879f2mr23773955ejc.577.1654760447397; Thu, 09 Jun 2022 00:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654760447; cv=none; d=google.com; s=arc-20160816; b=xyK008sLTGxY1gsOzpq+h29SAG2tWH5syyV/aLVWaL9LjqTvLaP/lKJKtq8Z5GvIpL Kl0z7FCJURCPB5XsCNYElG/Lswc2MNCZ7k4qj5An5Gmh/pDYR+0BariWdncsgi2SDIm1 LYm0e/SqyGOfSFOlvufJwlQkT9cEcx/N2gapTfR2Vnw//sESls7fkHH8sflEE7P8quob YoBqM5DSsL7n2+gxiZ+JEaijndKYMBxNPS6iD79EyiXLxZqfTkxGn26lAjGyDSWXl6Pg mU9+9vTAigjMLeblJkS3A/jbkUFDqfTWZhi8vir/IrOV9aLCZ7Rg8ljF48TJice4Fbb6 nkpQ== 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=bSY8PN7v8lUTRFzxoXQ+q0czheJOMexRG2Ekt+dl1cw=; b=VuHDLY0tklNgPskfd/5kjTbPcKfUvJ0IOLRGrZecabJvGQhPWoRtKdrHNYekZwzUYX 52ZeQXNQT2ZUzEvXDoF446o60CvrhECM+u2NqzhG+XLiGRRzpBd1lzcy1+gXuF8Arz4z F65VcI2pQ+/Sh26D9Z8JhAlhcC8isTWD77z/A2JhXSPTadqPw/YoXUJlNQTunxSQA1U8 l/L+RNuFjBuyRL/+nEfp1S8zqR4ApUJLp4tGuaaQ9z9B301uNGU7kQXa50rowDjMKuyj awjJ657xNtzwiQ3eqPJmlckFgNHtn9yZphNME6C7W/Ke02WyQe1FXiVpmy9VE1XM0av2 eYDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=STJ78LHW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a056402330400b0043173ab6724si1638266eda.455.2022.06.09.00.40.22; Thu, 09 Jun 2022 00:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=STJ78LHW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239995AbiFIH1o (ORCPT + 99 others); Thu, 9 Jun 2022 03:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239990AbiFIH1l (ORCPT ); Thu, 9 Jun 2022 03:27:41 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7695F166D5F for ; Thu, 9 Jun 2022 00:27:40 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id t2so19603321pld.4 for ; Thu, 09 Jun 2022 00:27:40 -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=bSY8PN7v8lUTRFzxoXQ+q0czheJOMexRG2Ekt+dl1cw=; b=STJ78LHWIq3C6SkgzJ/vmNYE8VNnAJLKUqWHPZRVIUmZBSKT92GoA4MlA2UUn+zELj Hecy+rWHtXRTwVJWiNpg4XrX00FawpR2IH3ajUFEBTJ39rvjrxyMYGCLADFePJ90Fxl+ vrYyOqQ1njaCv4FURyE3Kxlnv7lisKIFrKmC0= 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=bSY8PN7v8lUTRFzxoXQ+q0czheJOMexRG2Ekt+dl1cw=; b=FWfe7IrszCjTpBqtYDhkntWBsutUM7vOgQVzPYTac0z6S1KOPfxL7VY/4zsXanm3cq 5pOCBDNI9xcP70rEBznVIVW7jNZkxvGbLTeoVsOU/k7HaTsFwzk1b7qQkvJky5dsoUZV 5B20tytRDSW6FRrRoVj+S0lrGhnQUdzs/cWyuPM5dHXSWM7Koyq8YvtzLoZlqMAmU7q6 lFmR3+NDkkjwphm9Rqa4CLQDxX1HLsHtqgaKc2W2jFh2lFPAEM8C04cqTcqsW3AuKXn/ wrvHRc7jxKl8FMUuyZ9Sq8DQS0igu+50XV6t8ul0Nf5zR3q8+gQwdG2KdobN5UjJQjmC Tg/Q== X-Gm-Message-State: AOAM533mOTWggJIP0EqKZaqygC/XsrVrbgZvTeDoDuvEWnrKD+7qx+k9 H5QcmiD7qXa3ULXz2pJrejGvvg== X-Received: by 2002:a17:902:8b89:b0:168:ab37:3283 with SMTP id ay9-20020a1709028b8900b00168ab373283mr1151222plb.101.1654759659616; Thu, 09 Jun 2022 00:27:39 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:5119:d95b:c6cd:77fb]) by smtp.gmail.com with ESMTPSA id p16-20020a1709027ed000b0016403cae7desm15312221plb.276.2022.06.09.00.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 00:27:39 -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 v7 1/8] drm/panel: Add an API to allow drm to set orientation from panel Date: Thu, 9 Jun 2022 15:27:15 +0800 Message-Id: <20220609072722.3488207-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220609072722.3488207-1-hsinyi@chromium.org> References: <20220609072722.3488207-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Reviewed-by: Stephen Boyd --- v6->v7: remane variable. --- drivers/gpu/drm/drm_connector.c | 31 +++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 4 ++++ include/drm/drm_panel.h | 9 +++++++++ 3 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e3..ab066a063f3ba 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,33 @@ 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 orientation; + + if (panel && panel->funcs && panel->funcs->get_orientation) + orientation = panel->funcs->get_orientation(panel); + else + orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + + return drm_connector_set_panel_orientation(connector, 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 3ac4bf87f2571..94b422b55cc1f 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 d279ee455f014..3a271128c0784 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