From patchwork Thu Aug 18 18:42:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12947597 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C46EEC32789 for ; Thu, 18 Aug 2022 18:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345175AbiHRSoh (ORCPT ); Thu, 18 Aug 2022 14:44:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345504AbiHRSoJ (ORCPT ); Thu, 18 Aug 2022 14:44:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3271772692 for ; Thu, 18 Aug 2022 11:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660848243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qrq3jpVRYU69sa7YRSW2l75eCA/KK5r1b/nr5Dq5Cwo=; b=U7czZS1eViBYOkSsMw2K8+pp/fbOY/61bLpRBuIVDwe4vERIiOVD4G8K4/YT79LkjwKuDC JEEMUHR7WW02V0HlxHtSPKpCUoZYKh32yX42+r9KIUlOP+4QQ0j6CaP5UOb4HJ9icAyqSx YoAEKMRgfGZilAr48OvqrryVdxDOZas= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-482-gBnhk6qINlyM6CRcR2f6GA-1; Thu, 18 Aug 2022 14:44:00 -0400 X-MC-Unique: gBnhk6qINlyM6CRcR2f6GA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B856080418F; Thu, 18 Aug 2022 18:43:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D104492C3B; Thu, 18 Aug 2022 18:43:55 +0000 (UTC) From: Hans de Goede To: Ben Skeggs , Karol Herbst , Lyude , Daniel Dadap , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Pan@vger.kernel.org, Xinhui , "Rafael J . Wysocki" , Mika Westerberg , Lukas Wunner , Mark Gross , Andy Shevchenko Cc: Hans de Goede , nouveau@lists.freedesktop.org, Daniel Vetter , David Airlie , intel-gfx , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Len Brown , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v3 11/31] drm/i915: Call acpi_video_register_backlight() (v2) Date: Thu, 18 Aug 2022 20:42:42 +0200 Message-Id: <20220818184302.10051-12-hdegoede@redhat.com> In-Reply-To: <20220818184302.10051-1-hdegoede@redhat.com> References: <20220818184302.10051-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org On machins without an i915 opregion the acpi_video driver immediately probes the ACPI video bus and used to also immediately register acpi_video# backlight devices when supported. Once the drm/kms driver then loaded later and possibly registered a native backlight device then the drivers/acpi/video_detect.c code unregistered the acpi_video0 device to avoid there being 2 backlight devices (when acpi_video_get_backlight_type()==native). This means that userspace used to briefly see 2 devices and the disappearing of acpi_video0 after a brief time confuses the systemd backlight level save/restore code, see e.g.: https://bbs.archlinux.org/viewtopic.php?id=269920 To fix this the ACPI video code has been modified to make backlight class device registration a separate step, relying on the drm/kms driver to ask for the acpi_video backlight registration after it is done setting up its native backlight device. Add a call to the new acpi_video_register_backlight() after the i915 calls acpi_video_register() (after setting up the i915 opregion) so that the acpi_video backlight devices get registered on systems where the i915 native backlight device is not registered. Changes in v2: -Only call acpi_video_register_backlight() when a panel is detected Signed-off-by: Hans de Goede --- drivers/gpu/drm/i915/display/intel_display.c | 8 ++++++++ drivers/gpu/drm/i915/display/intel_panel.c | 3 +++ drivers/gpu/drm/i915/i915_drv.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 533fff79aeda..e7a4584e3189 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -9082,6 +9082,14 @@ void intel_display_driver_register(struct drm_i915_private *i915) /* Must be done after probing outputs */ intel_opregion_register(i915); acpi_video_register(); + /* + * Only call this if i915 is driving the internal panel. If the internal + * panel is not driven by i915 then another GPU driver may still register + * a native backlight driver later and this should only be called after + * any native backlights have been registered. + */ + if (i915->have_panel) + acpi_video_register_backlight(); intel_audio_init(i915); diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c index 237a40623dd7..4536c527f50c 100644 --- a/drivers/gpu/drm/i915/display/intel_panel.c +++ b/drivers/gpu/drm/i915/display/intel_panel.c @@ -646,8 +646,11 @@ intel_panel_mode_valid(struct intel_connector *connector, int intel_panel_init(struct intel_connector *connector) { + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct intel_panel *panel = &connector->panel; + dev_priv->have_panel = true; + intel_backlight_init_funcs(panel); drm_dbg_kms(connector->base.dev, diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 086bbe8945d6..a632d9b87bc8 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -756,6 +756,8 @@ struct drm_i915_private { bool ipc_enabled; + bool have_panel; + struct intel_audio_private audio; struct i915_pmu pmu;