From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 34248C433FE for ; Wed, 18 May 2022 10:06:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BAEBA10E1BF; Wed, 18 May 2022 10:06:41 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 840A010E1BF for ; Wed, 18 May 2022 10:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652868399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=h/8VbWj8GQ51056RjyL73PtFFfJfK6K49+ftweCWop2hdFAYol19TeioeczScsJymLaJ7C tfXK45oLf4zcHk+i4AgOzrotVvLbn5GL9xe6rIaDEUpJwP7MEpUUbI5kyBbEaboowJPWn2 oPtPvqF1AtOhIDedJVUNUSx7DrAQcoI= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-DSnln11uPtCcvQUTxA8PEw-1; Wed, 18 May 2022 06:06:38 -0400 X-MC-Unique: DSnln11uPtCcvQUTxA8PEw-1 Received: by mail-ej1-f71.google.com with SMTP id nb10-20020a1709071c8a00b006e8f89863ceso703123ejc.18 for ; Wed, 18 May 2022 03:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=xO+B0oBNb+XUQn9LQ+8ED6TpfHD6q2ZfIXohVeVXzJeelPAcjDja/nKPXlr/l78uNL Y/nqcAw2mc2pT8ZatYtaREbms1YmGEJX0BzZ6+fHfqk9SWoYM3Hsbb5lpS8AVnkQn5tz ZCoL5mUr20wfaf+yvz3TvEaWjMJUM+ubjwaqEYplRDlnqmpeOXLGJ0OremUm11wCFpqw 4bvq9GjcItFUG04uK1m8sR7qNbNiieIbj5/VcwcvIic83zbFAK4RQhv7COUhq9ZyRG/o 8eYIlmmAZ74OBd8plZIdBBWzEZp+6zGBiR31q1/uhJDLSoJTZBhCHzSPUfcZu1wWg7Y9 hlZQ== X-Gm-Message-State: AOAM531W8zuHUVFHfYrzacIRUc4U21u65dNjHSpWCX6v4MaWfrW+lBET Wv0nK37Gk70eHLtSXYtm9vt68Qqifz32SeebwjdTyfvXvm9qgCufDNQg2/LueRfQ4HkoA1V4sfg 6ZaU8/d9UwDihwj3n/JMrDXM+pg== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645136edr.405.1652868397496; Wed, 18 May 2022 03:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW5N5eEgYNDxxR01FDnen1+ArS6hUX6UjT6X85gxiN1WIP+fe7U2YYHCi6kVoLRTzUEVBJfw== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645102edr.405.1652868397330; Wed, 18 May 2022 03:06:37 -0700 (PDT) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id gx3-20020a1709068a4300b006f3ef214e0csm774697ejc.114.2022.05.18.03.06.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 03:06:36 -0700 (PDT) Message-ID: Date: Wed, 18 May 2022 12:06:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 To: Jani Nikula , Ben Skeggs , Karol Herbst , Lyude , Daniel Dadap , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "Pan, Xinhui" , "Rafael J . Wysocki" , Mika Westerberg , Mark Gross , Andy Shevchenko References: <20220517152331.16217-1-hdegoede@redhat.com> <20220517152331.16217-2-hdegoede@redhat.com> <87y1yzdxtk.fsf@intel.com> From: Hans de Goede In-Reply-To: <87y1yzdxtk.fsf@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hdegoede@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Nouveau] [PATCH 01/14] ACPI: video: Add a native function parameter to acpi_video_get_backlight_type() X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , nouveau@lists.freedesktop.org, intel-gfx , amd-gfx@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Daniel Vetter , Len Brown Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" Hi, On 5/18/22 10:55, Jani Nikula wrote: > On Tue, 17 May 2022, Hans de Goede wrote: >> ATM on x86 laptops where we want userspace to use the acpi_video backlight >> device we often register both the GPU's native backlight device and >> acpi_video's firmware acpi_video# backlight device. This relies on >> userspace preferring firmware type backlight devices over native ones, but >> registering 2 backlight devices for a single display really is undesirable. >> >> On x86 laptops where the native GPU backlight device should be used, >> the registering of other backlight devices is avoided by their drivers >> using acpi_video_get_backlight_type() and only registering their backlight >> if the return value matches their type. >> >> acpi_video_get_backlight_type() uses >> backlight_device_get_by_type(BACKLIGHT_RAW) to determine if a native >> driver is available and will never return native if this returns >> false. This means that the GPU's native backlight registering code >> cannot just call acpi_video_get_backlight_type() to determine if it >> should register its backlight, since acpi_video_get_backlight_type() will >> never return native until the native backlight has already registered. >> >> To fix this add a native function parameter to >> acpi_video_get_backlight_type(), which when set to true will make >> acpi_video_get_backlight_type() behave as if a native backlight has >> already been registered. >> >> Note that all current callers are updated to pass false for the new >> parameter, so this change in itself causes no functional changes. > > >> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c >> index becc198e4c22..0a06f0edd298 100644 >> --- a/drivers/acpi/video_detect.c >> +++ b/drivers/acpi/video_detect.c >> @@ -17,12 +17,14 @@ >> * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop, >> * sony_acpi,... can take care about backlight brightness. >> * >> - * Backlight drivers can use acpi_video_get_backlight_type() to determine >> - * which driver should handle the backlight. >> + * Backlight drivers can use acpi_video_get_backlight_type() to determine which >> + * driver should handle the backlight. RAW/GPU-driver backlight drivers must >> + * pass true for the native function argument, other drivers must pass false. >> * >> * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) >> * this file will not be compiled and acpi_video_get_backlight_type() will >> - * always return acpi_backlight_vendor. >> + * return acpi_backlight_native when its native argument is true and >> + * acpi_backlight_vendor when it is false. >> */ > > Frankly, I think the boolean native parameter here, and at the call > sites, is confusing, and the slightly different explanations in the > commit message and comment here aren't helping. Can you elaborate the "slightly different explanations in the commit message and comment" part a bit (so that I can fix this) ? > I suggest adding a separate function that the native backlight drivers > should use. I think it's more obvious all around, and easier to document > too. Code wise I think this would mean renaming the original and then adding 2 wrappers, but that is fine with me. I've no real preference either way and I'm happy with adding a new variant of acpi_video_get_backlight_type() for the native backlight drivers any suggestion for a name ? Regards, Hans From mboxrd@z Thu Jan 1 00:00:00 1970 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 9A107C433EF for ; Wed, 18 May 2022 10:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234931AbiERKGo (ORCPT ); Wed, 18 May 2022 06:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234941AbiERKGm (ORCPT ); Wed, 18 May 2022 06:06:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ADD45134E3C for ; Wed, 18 May 2022 03:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652868399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=h/8VbWj8GQ51056RjyL73PtFFfJfK6K49+ftweCWop2hdFAYol19TeioeczScsJymLaJ7C tfXK45oLf4zcHk+i4AgOzrotVvLbn5GL9xe6rIaDEUpJwP7MEpUUbI5kyBbEaboowJPWn2 oPtPvqF1AtOhIDedJVUNUSx7DrAQcoI= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-643oZZlNPcSPYLL3Ymqt_Q-1; Wed, 18 May 2022 06:06:38 -0400 X-MC-Unique: 643oZZlNPcSPYLL3Ymqt_Q-1 Received: by mail-ej1-f70.google.com with SMTP id gs6-20020a170906f18600b006fe7a9ffacbso713323ejb.3 for ; Wed, 18 May 2022 03:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=Bj67TVGFuX4XhyG+tsmO92MjceNCBb2lQS0+hCkvYAzmbnfI8GjKIJMzNrdRJ9haCt leKbzBJZ/O4o7rvyyyGjnGfH/auozIVJjEETI1tL7siPURNEH4ApMuS4NSJHcqZfByW3 LJdXyH9K27y1++C4LM4bZ1V6EQNP4Um96sz3TA/ffEb1uI4x4fxdnzNtiQM7SeEeGuCu N70KqmIpKX7dZ32GT/Ujs6KBD2h81iv1Ym3wnO1uiXZfaAEIwYQKut8eTr+svPu+TiA3 rscvVDMk4EQOVvKYtvAEeCBvnvKmNxxIoIrEFZlHor0i4HfvNN9Nt3m341bkKoXbqEyK alyA== X-Gm-Message-State: AOAM530HKfff1yM8dlqRSOot8nwK/C9c2XPfac+1VS/9/ZcRDepJCYhg PGNCrVSC5csicUlfKazTY+38Xqe95q1dmEWeiKufGjhvcuS6Zz2oI2nJziPkiKLAuS7CYuF7zub C3J02TvvvrcsJY2c9Rj6FQg== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645132edr.405.1652868397496; Wed, 18 May 2022 03:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW5N5eEgYNDxxR01FDnen1+ArS6hUX6UjT6X85gxiN1WIP+fe7U2YYHCi6kVoLRTzUEVBJfw== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645102edr.405.1652868397330; Wed, 18 May 2022 03:06:37 -0700 (PDT) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id gx3-20020a1709068a4300b006f3ef214e0csm774697ejc.114.2022.05.18.03.06.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 03:06:36 -0700 (PDT) Message-ID: Date: Wed, 18 May 2022 12:06:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 01/14] ACPI: video: Add a native function parameter to acpi_video_get_backlight_type() Content-Language: en-US To: Jani Nikula , Ben Skeggs , Karol Herbst , Lyude , Daniel Dadap , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "Pan, Xinhui" , "Rafael J . Wysocki" , Mika Westerberg , Mark Gross , Andy Shevchenko Cc: 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 References: <20220517152331.16217-1-hdegoede@redhat.com> <20220517152331.16217-2-hdegoede@redhat.com> <87y1yzdxtk.fsf@intel.com> From: Hans de Goede In-Reply-To: <87y1yzdxtk.fsf@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Hi, On 5/18/22 10:55, Jani Nikula wrote: > On Tue, 17 May 2022, Hans de Goede wrote: >> ATM on x86 laptops where we want userspace to use the acpi_video backlight >> device we often register both the GPU's native backlight device and >> acpi_video's firmware acpi_video# backlight device. This relies on >> userspace preferring firmware type backlight devices over native ones, but >> registering 2 backlight devices for a single display really is undesirable. >> >> On x86 laptops where the native GPU backlight device should be used, >> the registering of other backlight devices is avoided by their drivers >> using acpi_video_get_backlight_type() and only registering their backlight >> if the return value matches their type. >> >> acpi_video_get_backlight_type() uses >> backlight_device_get_by_type(BACKLIGHT_RAW) to determine if a native >> driver is available and will never return native if this returns >> false. This means that the GPU's native backlight registering code >> cannot just call acpi_video_get_backlight_type() to determine if it >> should register its backlight, since acpi_video_get_backlight_type() will >> never return native until the native backlight has already registered. >> >> To fix this add a native function parameter to >> acpi_video_get_backlight_type(), which when set to true will make >> acpi_video_get_backlight_type() behave as if a native backlight has >> already been registered. >> >> Note that all current callers are updated to pass false for the new >> parameter, so this change in itself causes no functional changes. > > >> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c >> index becc198e4c22..0a06f0edd298 100644 >> --- a/drivers/acpi/video_detect.c >> +++ b/drivers/acpi/video_detect.c >> @@ -17,12 +17,14 @@ >> * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop, >> * sony_acpi,... can take care about backlight brightness. >> * >> - * Backlight drivers can use acpi_video_get_backlight_type() to determine >> - * which driver should handle the backlight. >> + * Backlight drivers can use acpi_video_get_backlight_type() to determine which >> + * driver should handle the backlight. RAW/GPU-driver backlight drivers must >> + * pass true for the native function argument, other drivers must pass false. >> * >> * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) >> * this file will not be compiled and acpi_video_get_backlight_type() will >> - * always return acpi_backlight_vendor. >> + * return acpi_backlight_native when its native argument is true and >> + * acpi_backlight_vendor when it is false. >> */ > > Frankly, I think the boolean native parameter here, and at the call > sites, is confusing, and the slightly different explanations in the > commit message and comment here aren't helping. Can you elaborate the "slightly different explanations in the commit message and comment" part a bit (so that I can fix this) ? > I suggest adding a separate function that the native backlight drivers > should use. I think it's more obvious all around, and easier to document > too. Code wise I think this would mean renaming the original and then adding 2 wrappers, but that is fine with me. I've no real preference either way and I'm happy with adding a new variant of acpi_video_get_backlight_type() for the native backlight drivers any suggestion for a name ? Regards, Hans From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D010DC433FE for ; Wed, 18 May 2022 10:06:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 87D5C10E259; Wed, 18 May 2022 10:06:42 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F5D110E1BF for ; Wed, 18 May 2022 10:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652868400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=W6tt3m2u4VVn74mYMI9lZQJhqcwc4ATF/HagYjvC9v47LLHbdnM6g/LDlH65OHU642PTmQ dQBkzES/obqa95//xFFSJFejA6UvLZJI7uqnrlh4fOsSHfgfnegWVvW4lxnfz7SG9uKPtB 702ohGPrw7loBXD3ffmt67ptEhXOzwM= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-512-TwA0hOnpPiiJQv1i3Z-B-g-1; Wed, 18 May 2022 06:06:38 -0400 X-MC-Unique: TwA0hOnpPiiJQv1i3Z-B-g-1 Received: by mail-ed1-f71.google.com with SMTP id ay24-20020a056402203800b0042a96a76ba5so1276672edb.20 for ; Wed, 18 May 2022 03:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=6rAmW4C8LhYYflLFdVAhuH+dFl9h1GsB3128vwCUPMzyuoNhoqllfrSUdWY3LiE/hn DI9tialJAvwFlLfktJ8ZmUPgU0QO8B0h/Sen2Wu7Nso7Codh3tf6m/CKQOHPNFnLTXXi r3SQoc4eCUbZw9kTb2nuOYRoNsJFIfbJEWLQX+RMMvTKi5zzaqOO4zdDlEN6cOo6XToE 1ax/NwCvbZm7vfTNpycH1qRQv6UVPVsTLJ7VvUPFfT581VeDiwrobS4oxDIRVSvHrwwQ r9Yi/Sotm9keF+R/hEeoRqYfL/6/X6+NQSFHe9kXdDePQAFm78ILQ7GGJlU4rmRlFPsa uQng== X-Gm-Message-State: AOAM5336vWukp0DWL3zaOsUfYltp4yNZjT2VAcxMCs08k+XAwnBroAGJ T1qqZFsSFm1h91O2wDJeG/Q5R5uwh82sUrQ2LNdUUyYUvb5YhTuZKc6B1etKkuW1QhXQmlxW6TE gTwxs7vUiyTqtwja0X77oeOlubCL6 X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645149edr.405.1652868397575; Wed, 18 May 2022 03:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW5N5eEgYNDxxR01FDnen1+ArS6hUX6UjT6X85gxiN1WIP+fe7U2YYHCi6kVoLRTzUEVBJfw== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645102edr.405.1652868397330; Wed, 18 May 2022 03:06:37 -0700 (PDT) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id gx3-20020a1709068a4300b006f3ef214e0csm774697ejc.114.2022.05.18.03.06.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 03:06:36 -0700 (PDT) Message-ID: Date: Wed, 18 May 2022 12:06:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 01/14] ACPI: video: Add a native function parameter to acpi_video_get_backlight_type() To: Jani Nikula , Ben Skeggs , Karol Herbst , Lyude , Daniel Dadap , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "Pan, Xinhui" , "Rafael J . Wysocki" , Mika Westerberg , Mark Gross , Andy Shevchenko References: <20220517152331.16217-1-hdegoede@redhat.com> <20220517152331.16217-2-hdegoede@redhat.com> <87y1yzdxtk.fsf@intel.com> From: Hans de Goede In-Reply-To: <87y1yzdxtk.fsf@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hdegoede@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , nouveau@lists.freedesktop.org, intel-gfx , amd-gfx@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Len Brown Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi, On 5/18/22 10:55, Jani Nikula wrote: > On Tue, 17 May 2022, Hans de Goede wrote: >> ATM on x86 laptops where we want userspace to use the acpi_video backlight >> device we often register both the GPU's native backlight device and >> acpi_video's firmware acpi_video# backlight device. This relies on >> userspace preferring firmware type backlight devices over native ones, but >> registering 2 backlight devices for a single display really is undesirable. >> >> On x86 laptops where the native GPU backlight device should be used, >> the registering of other backlight devices is avoided by their drivers >> using acpi_video_get_backlight_type() and only registering their backlight >> if the return value matches their type. >> >> acpi_video_get_backlight_type() uses >> backlight_device_get_by_type(BACKLIGHT_RAW) to determine if a native >> driver is available and will never return native if this returns >> false. This means that the GPU's native backlight registering code >> cannot just call acpi_video_get_backlight_type() to determine if it >> should register its backlight, since acpi_video_get_backlight_type() will >> never return native until the native backlight has already registered. >> >> To fix this add a native function parameter to >> acpi_video_get_backlight_type(), which when set to true will make >> acpi_video_get_backlight_type() behave as if a native backlight has >> already been registered. >> >> Note that all current callers are updated to pass false for the new >> parameter, so this change in itself causes no functional changes. > > >> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c >> index becc198e4c22..0a06f0edd298 100644 >> --- a/drivers/acpi/video_detect.c >> +++ b/drivers/acpi/video_detect.c >> @@ -17,12 +17,14 @@ >> * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop, >> * sony_acpi,... can take care about backlight brightness. >> * >> - * Backlight drivers can use acpi_video_get_backlight_type() to determine >> - * which driver should handle the backlight. >> + * Backlight drivers can use acpi_video_get_backlight_type() to determine which >> + * driver should handle the backlight. RAW/GPU-driver backlight drivers must >> + * pass true for the native function argument, other drivers must pass false. >> * >> * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) >> * this file will not be compiled and acpi_video_get_backlight_type() will >> - * always return acpi_backlight_vendor. >> + * return acpi_backlight_native when its native argument is true and >> + * acpi_backlight_vendor when it is false. >> */ > > Frankly, I think the boolean native parameter here, and at the call > sites, is confusing, and the slightly different explanations in the > commit message and comment here aren't helping. Can you elaborate the "slightly different explanations in the commit message and comment" part a bit (so that I can fix this) ? > I suggest adding a separate function that the native backlight drivers > should use. I think it's more obvious all around, and easier to document > too. Code wise I think this would mean renaming the original and then adding 2 wrappers, but that is fine with me. I've no real preference either way and I'm happy with adding a new variant of acpi_video_get_backlight_type() for the native backlight drivers any suggestion for a name ? Regards, Hans From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 51446C433FE for ; Wed, 18 May 2022 10:06:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0850310E20D; Wed, 18 May 2022 10:06:42 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8609010E20D for ; Wed, 18 May 2022 10:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652868399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=h/8VbWj8GQ51056RjyL73PtFFfJfK6K49+ftweCWop2hdFAYol19TeioeczScsJymLaJ7C tfXK45oLf4zcHk+i4AgOzrotVvLbn5GL9xe6rIaDEUpJwP7MEpUUbI5kyBbEaboowJPWn2 oPtPvqF1AtOhIDedJVUNUSx7DrAQcoI= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-qlDaufNnMnGSYdv3dvPRJQ-1; Wed, 18 May 2022 06:06:38 -0400 X-MC-Unique: qlDaufNnMnGSYdv3dvPRJQ-1 Received: by mail-ej1-f70.google.com with SMTP id v13-20020a170906b00d00b006f51e289f7cso693382ejy.19 for ; Wed, 18 May 2022 03:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=dTzj+XaEM1s3GSPV/pb193j98PIx/XXaqOGCvFrwzW2xqDuL4rs05BRc8rBbcFl38K jYJ/HN3DY5QWP9Ljvqrb26wwMRxFD3dA/JjbAwVErswSQrIsCqj7IQ2VjduOg6xj8Obi 7zN8ZMgJCrLrnTJyu7YWAwQYKxOyU0dxgOj70yzoe/dTpeUeWTexs8XJk0i4cotrklk6 AVCNxtCw3FqCupbaluAXCpokCRMkrbgUjuWKKIQb6CaHW9nICyZQJldrFgo9oNvEQ3F6 N0irZqNIsP3CXW9uBb/PkIspn9iCGQGHBZ0d81AfCDsoUTT01hw0htTggpSHsTz5BQmt YUHw== X-Gm-Message-State: AOAM532G2Db+VShTnM0RYYwLDriPWinuzGLiDIkuhRwU0l+0JsOfdEZX SVR/y9aTVjFmiUwMryaGiqDyv5uJwJTG6/M8usdXsI+8xAxX5xHBswc64x2TfbbWILEnqzYnMRi Fv6gtZEGvgGZ1/hQGp2hfuqqAWGeD X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645151edr.405.1652868397585; Wed, 18 May 2022 03:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW5N5eEgYNDxxR01FDnen1+ArS6hUX6UjT6X85gxiN1WIP+fe7U2YYHCi6kVoLRTzUEVBJfw== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645102edr.405.1652868397330; Wed, 18 May 2022 03:06:37 -0700 (PDT) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id gx3-20020a1709068a4300b006f3ef214e0csm774697ejc.114.2022.05.18.03.06.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 03:06:36 -0700 (PDT) Message-ID: Date: Wed, 18 May 2022 12:06:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 To: Jani Nikula , Ben Skeggs , Karol Herbst , Lyude , Daniel Dadap , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "Pan, Xinhui" , "Rafael J . Wysocki" , Mika Westerberg , Mark Gross , Andy Shevchenko References: <20220517152331.16217-1-hdegoede@redhat.com> <20220517152331.16217-2-hdegoede@redhat.com> <87y1yzdxtk.fsf@intel.com> From: Hans de Goede In-Reply-To: <87y1yzdxtk.fsf@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hdegoede@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Intel-gfx] [PATCH 01/14] ACPI: video: Add a native function parameter to acpi_video_get_backlight_type() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , nouveau@lists.freedesktop.org, intel-gfx , amd-gfx@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Len Brown Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Hi, On 5/18/22 10:55, Jani Nikula wrote: > On Tue, 17 May 2022, Hans de Goede wrote: >> ATM on x86 laptops where we want userspace to use the acpi_video backlight >> device we often register both the GPU's native backlight device and >> acpi_video's firmware acpi_video# backlight device. This relies on >> userspace preferring firmware type backlight devices over native ones, but >> registering 2 backlight devices for a single display really is undesirable. >> >> On x86 laptops where the native GPU backlight device should be used, >> the registering of other backlight devices is avoided by their drivers >> using acpi_video_get_backlight_type() and only registering their backlight >> if the return value matches their type. >> >> acpi_video_get_backlight_type() uses >> backlight_device_get_by_type(BACKLIGHT_RAW) to determine if a native >> driver is available and will never return native if this returns >> false. This means that the GPU's native backlight registering code >> cannot just call acpi_video_get_backlight_type() to determine if it >> should register its backlight, since acpi_video_get_backlight_type() will >> never return native until the native backlight has already registered. >> >> To fix this add a native function parameter to >> acpi_video_get_backlight_type(), which when set to true will make >> acpi_video_get_backlight_type() behave as if a native backlight has >> already been registered. >> >> Note that all current callers are updated to pass false for the new >> parameter, so this change in itself causes no functional changes. > > >> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c >> index becc198e4c22..0a06f0edd298 100644 >> --- a/drivers/acpi/video_detect.c >> +++ b/drivers/acpi/video_detect.c >> @@ -17,12 +17,14 @@ >> * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop, >> * sony_acpi,... can take care about backlight brightness. >> * >> - * Backlight drivers can use acpi_video_get_backlight_type() to determine >> - * which driver should handle the backlight. >> + * Backlight drivers can use acpi_video_get_backlight_type() to determine which >> + * driver should handle the backlight. RAW/GPU-driver backlight drivers must >> + * pass true for the native function argument, other drivers must pass false. >> * >> * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) >> * this file will not be compiled and acpi_video_get_backlight_type() will >> - * always return acpi_backlight_vendor. >> + * return acpi_backlight_native when its native argument is true and >> + * acpi_backlight_vendor when it is false. >> */ > > Frankly, I think the boolean native parameter here, and at the call > sites, is confusing, and the slightly different explanations in the > commit message and comment here aren't helping. Can you elaborate the "slightly different explanations in the commit message and comment" part a bit (so that I can fix this) ? > I suggest adding a separate function that the native backlight drivers > should use. I think it's more obvious all around, and easier to document > too. Code wise I think this would mean renaming the original and then adding 2 wrappers, but that is fine with me. I've no real preference either way and I'm happy with adding a new variant of acpi_video_get_backlight_type() for the native backlight drivers any suggestion for a name ? Regards, Hans From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 6E5DEC433EF for ; Wed, 18 May 2022 13:01:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C88F210E4C0; Wed, 18 May 2022 13:01:07 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2CDC10E259 for ; Wed, 18 May 2022 10:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652868399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=h/8VbWj8GQ51056RjyL73PtFFfJfK6K49+ftweCWop2hdFAYol19TeioeczScsJymLaJ7C tfXK45oLf4zcHk+i4AgOzrotVvLbn5GL9xe6rIaDEUpJwP7MEpUUbI5kyBbEaboowJPWn2 oPtPvqF1AtOhIDedJVUNUSx7DrAQcoI= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-KqdXm9z1NuG6EniBcd5MTQ-1; Wed, 18 May 2022 06:06:38 -0400 X-MC-Unique: KqdXm9z1NuG6EniBcd5MTQ-1 Received: by mail-ed1-f70.google.com with SMTP id bc17-20020a056402205100b0042aa0e072d3so1281449edb.17 for ; Wed, 18 May 2022 03:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=C2r1rWBmdtu0FZ4mggyVs/7L7uA3dpDog4rnPbZik/0=; b=TMul8E/7VAXdfj5dbhHITQ1uoQ7gVLEo/tF3oVxTF/Pn+2IKR2JLAJD/3ksO5KAtW1 kNZRjWOfnMAN2wibuxN7TGMgOGM3a3xmQiHNeddgmwXYcp4TqqNgJ090D/CsZ9zThC8X tPZRmDY4D3mLVFv2U4qS2PIwpxBJIRuYxc2tbv5Xo8id2H0UWj087XespNoWftg6IE4o heiNStSOVNOgpDNmqjb4a7WwvWdLOWmNTm+hQfA/PApmqizdO+bZLH0epYTGwRBC3vYd x9Da5ZEk4079OWNe1MorpiphcvTuFfL2A0FAVXp52O5/OLr5TrCoybH3YjOjiir0nUYl AScQ== X-Gm-Message-State: AOAM532L1JFetY6veKVYoNrgjVKeAkHQEcb/unCOuXVAqTVFxd5clt6U HxQQTxwZ9ycqakp7omLhU8pcLCr4Cdl1tahK5Y3JIpkQn3RBMiOx95dV6H8ine1U2enQojzvAm0 XjdohPMDFStLq8BGXOqKN6ykJ2w== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645153edr.405.1652868397605; Wed, 18 May 2022 03:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW5N5eEgYNDxxR01FDnen1+ArS6hUX6UjT6X85gxiN1WIP+fe7U2YYHCi6kVoLRTzUEVBJfw== X-Received: by 2002:aa7:d2cf:0:b0:42a:c1b1:9d6b with SMTP id k15-20020aa7d2cf000000b0042ac1b19d6bmr10645102edr.405.1652868397330; Wed, 18 May 2022 03:06:37 -0700 (PDT) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id gx3-20020a1709068a4300b006f3ef214e0csm774697ejc.114.2022.05.18.03.06.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 03:06:36 -0700 (PDT) Message-ID: Date: Wed, 18 May 2022 12:06:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 01/14] ACPI: video: Add a native function parameter to acpi_video_get_backlight_type() To: Jani Nikula , Ben Skeggs , Karol Herbst , Lyude , Daniel Dadap , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "Pan, Xinhui" , "Rafael J . Wysocki" , Mika Westerberg , Mark Gross , Andy Shevchenko References: <20220517152331.16217-1-hdegoede@redhat.com> <20220517152331.16217-2-hdegoede@redhat.com> <87y1yzdxtk.fsf@intel.com> From: Hans de Goede In-Reply-To: <87y1yzdxtk.fsf@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hdegoede@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Wed, 18 May 2022 13:01:07 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , nouveau@lists.freedesktop.org, intel-gfx , amd-gfx@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Daniel Vetter , Len Brown Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" Hi, On 5/18/22 10:55, Jani Nikula wrote: > On Tue, 17 May 2022, Hans de Goede wrote: >> ATM on x86 laptops where we want userspace to use the acpi_video backlight >> device we often register both the GPU's native backlight device and >> acpi_video's firmware acpi_video# backlight device. This relies on >> userspace preferring firmware type backlight devices over native ones, but >> registering 2 backlight devices for a single display really is undesirable. >> >> On x86 laptops where the native GPU backlight device should be used, >> the registering of other backlight devices is avoided by their drivers >> using acpi_video_get_backlight_type() and only registering their backlight >> if the return value matches their type. >> >> acpi_video_get_backlight_type() uses >> backlight_device_get_by_type(BACKLIGHT_RAW) to determine if a native >> driver is available and will never return native if this returns >> false. This means that the GPU's native backlight registering code >> cannot just call acpi_video_get_backlight_type() to determine if it >> should register its backlight, since acpi_video_get_backlight_type() will >> never return native until the native backlight has already registered. >> >> To fix this add a native function parameter to >> acpi_video_get_backlight_type(), which when set to true will make >> acpi_video_get_backlight_type() behave as if a native backlight has >> already been registered. >> >> Note that all current callers are updated to pass false for the new >> parameter, so this change in itself causes no functional changes. > > >> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c >> index becc198e4c22..0a06f0edd298 100644 >> --- a/drivers/acpi/video_detect.c >> +++ b/drivers/acpi/video_detect.c >> @@ -17,12 +17,14 @@ >> * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop, >> * sony_acpi,... can take care about backlight brightness. >> * >> - * Backlight drivers can use acpi_video_get_backlight_type() to determine >> - * which driver should handle the backlight. >> + * Backlight drivers can use acpi_video_get_backlight_type() to determine which >> + * driver should handle the backlight. RAW/GPU-driver backlight drivers must >> + * pass true for the native function argument, other drivers must pass false. >> * >> * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) >> * this file will not be compiled and acpi_video_get_backlight_type() will >> - * always return acpi_backlight_vendor. >> + * return acpi_backlight_native when its native argument is true and >> + * acpi_backlight_vendor when it is false. >> */ > > Frankly, I think the boolean native parameter here, and at the call > sites, is confusing, and the slightly different explanations in the > commit message and comment here aren't helping. Can you elaborate the "slightly different explanations in the commit message and comment" part a bit (so that I can fix this) ? > I suggest adding a separate function that the native backlight drivers > should use. I think it's more obvious all around, and easier to document > too. Code wise I think this would mean renaming the original and then adding 2 wrappers, but that is fine with me. I've no real preference either way and I'm happy with adding a new variant of acpi_video_get_backlight_type() for the native backlight drivers any suggestion for a name ? Regards, Hans