linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks
@ 2022-10-24 14:12 Dmitry Osipenko
  2022-10-24 14:32 ` Hans de Goede
  2022-10-24 14:52 ` Akihiko Odaki
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Osipenko @ 2022-10-24 14:12 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, Hans de Goede, Akihiko Odaki,
	Dmitry Torokhov, Sean Paul
  Cc: kernel, linux-acpi, dri-devel, linux-kernel

Chromebooks don't have backlight in ACPI table, they suppose to use
native backlight in this case. Check presence of the CrOS embedded
controller ACPI device and prefer the native backlight if EC found.

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Fixes: 2600bfa3df99 ("ACPI: video: Add acpi_video_backlight_use_native() helper")
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---

Changelog:

v2: - Added explanatory comment to the code and added check for the
      native backlight presence, like was requested by Hans de Goede.

 drivers/acpi/video_detect.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 0d9064a9804c..9cd8797d12bb 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -668,6 +668,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 	{ },
 };
 
+static bool google_cros_ec_present(void)
+{
+	return acpi_dev_found("GOOG0004");
+}
+
 /*
  * Determine which type of backlight interface to use on this system,
  * First check cmdline, then dmi quirks, then do autodetect.
@@ -730,6 +735,13 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
 			return acpi_backlight_video;
 	}
 
+	/*
+	 * Chromebooks that don't have backlight handle in ACPI table
+	 * are supposed to use native backlight if it's available.
+	 */
+	if (google_cros_ec_present() && native_available)
+		return acpi_backlight_native;
+
 	/* No ACPI video (old hw), use vendor specific fw methods. */
 	return acpi_backlight_vendor;
 }
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks
  2022-10-24 14:12 [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks Dmitry Osipenko
@ 2022-10-24 14:32 ` Hans de Goede
  2022-10-24 14:45   ` Rafael J. Wysocki
  2022-10-24 14:52 ` Akihiko Odaki
  1 sibling, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2022-10-24 14:32 UTC (permalink / raw)
  To: Dmitry Osipenko, Rafael J. Wysocki, Len Brown, Akihiko Odaki,
	Dmitry Torokhov, Sean Paul
  Cc: kernel, linux-acpi, dri-devel, linux-kernel

Hi,

On 10/24/22 16:12, Dmitry Osipenko wrote:
> Chromebooks don't have backlight in ACPI table, they suppose to use
> native backlight in this case. Check presence of the CrOS embedded
> controller ACPI device and prefer the native backlight if EC found.
> 
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Fixes: 2600bfa3df99 ("ACPI: video: Add acpi_video_backlight_use_native() helper")
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> ---
> 
> Changelog:
> 
> v2: - Added explanatory comment to the code and added check for the
>       native backlight presence, like was requested by Hans de Goede.

Thanks this version looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Rafael, can you pick this up and send it in a fixes pull-req
for 6.1 to Linus? Or shall I pick this one up and include it
in my next pull-req?

Regards,

Hans





> 
>  drivers/acpi/video_detect.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
> index 0d9064a9804c..9cd8797d12bb 100644
> --- a/drivers/acpi/video_detect.c
> +++ b/drivers/acpi/video_detect.c
> @@ -668,6 +668,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
>  	{ },
>  };
>  
> +static bool google_cros_ec_present(void)
> +{
> +	return acpi_dev_found("GOOG0004");
> +}
> +
>  /*
>   * Determine which type of backlight interface to use on this system,
>   * First check cmdline, then dmi quirks, then do autodetect.
> @@ -730,6 +735,13 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
>  			return acpi_backlight_video;
>  	}
>  
> +	/*
> +	 * Chromebooks that don't have backlight handle in ACPI table
> +	 * are supposed to use native backlight if it's available.
> +	 */
> +	if (google_cros_ec_present() && native_available)
> +		return acpi_backlight_native;
> +
>  	/* No ACPI video (old hw), use vendor specific fw methods. */
>  	return acpi_backlight_vendor;
>  }


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks
  2022-10-24 14:32 ` Hans de Goede
@ 2022-10-24 14:45   ` Rafael J. Wysocki
  2022-10-24 15:12     ` Hans de Goede
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2022-10-24 14:45 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Dmitry Osipenko, Rafael J. Wysocki, Len Brown, Akihiko Odaki,
	Dmitry Torokhov, Sean Paul, kernel, linux-acpi, dri-devel,
	linux-kernel

On Mon, Oct 24, 2022 at 4:32 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Hi,
>
> On 10/24/22 16:12, Dmitry Osipenko wrote:
> > Chromebooks don't have backlight in ACPI table, they suppose to use
> > native backlight in this case. Check presence of the CrOS embedded
> > controller ACPI device and prefer the native backlight if EC found.
> >
> > Suggested-by: Hans de Goede <hdegoede@redhat.com>
> > Fixes: 2600bfa3df99 ("ACPI: video: Add acpi_video_backlight_use_native() helper")
> > Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> > ---
> >
> > Changelog:
> >
> > v2: - Added explanatory comment to the code and added check for the
> >       native backlight presence, like was requested by Hans de Goede.
>
> Thanks this version looks good to me:
>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>
> Rafael, can you pick this up and send it in a fixes pull-req
> for 6.1 to Linus? Or shall I pick this one up and include it
> in my next pull-req?

It would be better if you could pick this up IMV, so please free to add

Acled-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

to it.

Thanks!

> >
> >  drivers/acpi/video_detect.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
> > index 0d9064a9804c..9cd8797d12bb 100644
> > --- a/drivers/acpi/video_detect.c
> > +++ b/drivers/acpi/video_detect.c
> > @@ -668,6 +668,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
> >       { },
> >  };
> >
> > +static bool google_cros_ec_present(void)
> > +{
> > +     return acpi_dev_found("GOOG0004");
> > +}
> > +
> >  /*
> >   * Determine which type of backlight interface to use on this system,
> >   * First check cmdline, then dmi quirks, then do autodetect.
> > @@ -730,6 +735,13 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
> >                       return acpi_backlight_video;
> >       }
> >
> > +     /*
> > +      * Chromebooks that don't have backlight handle in ACPI table
> > +      * are supposed to use native backlight if it's available.
> > +      */
> > +     if (google_cros_ec_present() && native_available)
> > +             return acpi_backlight_native;
> > +
> >       /* No ACPI video (old hw), use vendor specific fw methods. */
> >       return acpi_backlight_vendor;
> >  }
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks
  2022-10-24 14:12 [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks Dmitry Osipenko
  2022-10-24 14:32 ` Hans de Goede
@ 2022-10-24 14:52 ` Akihiko Odaki
  2022-10-24 14:59   ` Hans de Goede
  1 sibling, 1 reply; 7+ messages in thread
From: Akihiko Odaki @ 2022-10-24 14:52 UTC (permalink / raw)
  To: Dmitry Osipenko, Rafael J. Wysocki, Len Brown, Hans de Goede,
	Dmitry Torokhov, Sean Paul
  Cc: kernel, linux-acpi, dri-devel, linux-kernel

On 2022/10/24 23:12, Dmitry Osipenko wrote:
> Chromebooks don't have backlight in ACPI table, they suppose to use
> native backlight in this case. Check presence of the CrOS embedded
> controller ACPI device and prefer the native backlight if EC found.
> 
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Fixes: 2600bfa3df99 ("ACPI: video: Add acpi_video_backlight_use_native() helper")
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> ---
> 
> Changelog:
> 
> v2: - Added explanatory comment to the code and added check for the
>        native backlight presence, like was requested by Hans de Goede.
> 
>   drivers/acpi/video_detect.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
> index 0d9064a9804c..9cd8797d12bb 100644
> --- a/drivers/acpi/video_detect.c
> +++ b/drivers/acpi/video_detect.c
> @@ -668,6 +668,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
>   	{ },
>   };
>   
> +static bool google_cros_ec_present(void)
> +{
> +	return acpi_dev_found("GOOG0004");
> +}
> +
>   /*
>    * Determine which type of backlight interface to use on this system,
>    * First check cmdline, then dmi quirks, then do autodetect.
> @@ -730,6 +735,13 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
>   			return acpi_backlight_video;
>   	}
>   
> +	/*
> +	 * Chromebooks that don't have backlight handle in ACPI table
> +	 * are supposed to use native backlight if it's available.
> +	 */
> +	if (google_cros_ec_present() && native_available)
> +		return acpi_backlight_native;
> +
>   	/* No ACPI video (old hw), use vendor specific fw methods. */
>   	return acpi_backlight_vendor;
>   }

Hi,

The native_available check does not prevent duplicate registration if 
vendor backlight registers first. It was enough for the combination of 
ACPI video and native because ACPI video delays its registration, but it 
is not the case for vendor/native combination.

Regards,
Akihiko Odaki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks
  2022-10-24 14:52 ` Akihiko Odaki
@ 2022-10-24 14:59   ` Hans de Goede
  2022-10-24 15:07     ` Akihiko Odaki
  0 siblings, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2022-10-24 14:59 UTC (permalink / raw)
  To: Akihiko Odaki, Dmitry Osipenko, Rafael J. Wysocki, Len Brown,
	Dmitry Torokhov, Sean Paul
  Cc: kernel, linux-acpi, dri-devel, linux-kernel

Hi,

On 10/24/22 16:52, Akihiko Odaki wrote:
> On 2022/10/24 23:12, Dmitry Osipenko wrote:
>> Chromebooks don't have backlight in ACPI table, they suppose to use
>> native backlight in this case. Check presence of the CrOS embedded
>> controller ACPI device and prefer the native backlight if EC found.
>>
>> Suggested-by: Hans de Goede <hdegoede@redhat.com>
>> Fixes: 2600bfa3df99 ("ACPI: video: Add acpi_video_backlight_use_native() helper")
>> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>> ---
>>
>> Changelog:
>>
>> v2: - Added explanatory comment to the code and added check for the
>>        native backlight presence, like was requested by Hans de Goede.
>>
>>   drivers/acpi/video_detect.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
>> index 0d9064a9804c..9cd8797d12bb 100644
>> --- a/drivers/acpi/video_detect.c
>> +++ b/drivers/acpi/video_detect.c
>> @@ -668,6 +668,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
>>       { },
>>   };
>>   +static bool google_cros_ec_present(void)
>> +{
>> +    return acpi_dev_found("GOOG0004");
>> +}
>> +
>>   /*
>>    * Determine which type of backlight interface to use on this system,
>>    * First check cmdline, then dmi quirks, then do autodetect.
>> @@ -730,6 +735,13 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
>>               return acpi_backlight_video;
>>       }
>>   +    /*
>> +     * Chromebooks that don't have backlight handle in ACPI table
>> +     * are supposed to use native backlight if it's available.
>> +     */
>> +    if (google_cros_ec_present() && native_available)
>> +        return acpi_backlight_native;
>> +
>>       /* No ACPI video (old hw), use vendor specific fw methods. */
>>       return acpi_backlight_vendor;
>>   }
> 
> Hi,
> 
> The native_available check does not prevent duplicate registration if vendor backlight registers first. It was enough for the combination of ACPI video and native because ACPI video delays its registration, but it is not the case for vendor/native combination.

There are no drivers providing acpi_backlight_vendor functionality on chromebooks.

All the drivers providing acpi_backlight_vendor functionality use vendor (Dell, Acer, Asus, etc.)
specific firmware (smbios, EC bitbanging or ACPI) backlight control method which are not available
on CoreBoot based ChromeBooks.

Also notice that the theoretical problem of a vendor driver loading first was already present
before the backlight refactor which landed in 6.1 and this has never been an issue.

Regards,

Hans


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks
  2022-10-24 14:59   ` Hans de Goede
@ 2022-10-24 15:07     ` Akihiko Odaki
  0 siblings, 0 replies; 7+ messages in thread
From: Akihiko Odaki @ 2022-10-24 15:07 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Osipenko, Rafael J. Wysocki, Len Brown,
	Dmitry Torokhov, Sean Paul
  Cc: kernel, linux-acpi, dri-devel, linux-kernel



On 2022/10/24 23:59, Hans de Goede wrote:
> Hi,
> 
> On 10/24/22 16:52, Akihiko Odaki wrote:
>> On 2022/10/24 23:12, Dmitry Osipenko wrote:
>>> Chromebooks don't have backlight in ACPI table, they suppose to use
>>> native backlight in this case. Check presence of the CrOS embedded
>>> controller ACPI device and prefer the native backlight if EC found.
>>>
>>> Suggested-by: Hans de Goede <hdegoede@redhat.com>
>>> Fixes: 2600bfa3df99 ("ACPI: video: Add acpi_video_backlight_use_native() helper")
>>> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>>> ---
>>>
>>> Changelog:
>>>
>>> v2: - Added explanatory comment to the code and added check for the
>>>         native backlight presence, like was requested by Hans de Goede.
>>>
>>>    drivers/acpi/video_detect.c | 12 ++++++++++++
>>>    1 file changed, 12 insertions(+)
>>>
>>> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
>>> index 0d9064a9804c..9cd8797d12bb 100644
>>> --- a/drivers/acpi/video_detect.c
>>> +++ b/drivers/acpi/video_detect.c
>>> @@ -668,6 +668,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
>>>        { },
>>>    };
>>>    +static bool google_cros_ec_present(void)
>>> +{
>>> +    return acpi_dev_found("GOOG0004");
>>> +}
>>> +
>>>    /*
>>>     * Determine which type of backlight interface to use on this system,
>>>     * First check cmdline, then dmi quirks, then do autodetect.
>>> @@ -730,6 +735,13 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
>>>                return acpi_backlight_video;
>>>        }
>>>    +    /*
>>> +     * Chromebooks that don't have backlight handle in ACPI table
>>> +     * are supposed to use native backlight if it's available.
>>> +     */
>>> +    if (google_cros_ec_present() && native_available)
>>> +        return acpi_backlight_native;
>>> +
>>>        /* No ACPI video (old hw), use vendor specific fw methods. */
>>>        return acpi_backlight_vendor;
>>>    }
>>
>> Hi,
>>
>> The native_available check does not prevent duplicate registration if vendor backlight registers first. It was enough for the combination of ACPI video and native because ACPI video delays its registration, but it is not the case for vendor/native combination.
> 
> There are no drivers providing acpi_backlight_vendor functionality on chromebooks.
> 
> All the drivers providing acpi_backlight_vendor functionality use vendor (Dell, Acer, Asus, etc.)
> specific firmware (smbios, EC bitbanging or ACPI) backlight control method which are not available
> on CoreBoot based ChromeBooks.

Hi,

Isn't the "native_available" check is for the case when 
acpi_backlight_vendor functionality gets implemented on Chromebooks? If 
it is, you don't want it to get broken when it actually happens. If you 
can ignore the case, native_available check is simply unnecessary.

> 
> Also notice that the theoretical problem of a vendor driver loading first was already present
> before the backlight refactor which landed in 6.1 and this has never been an issue.

The situation is even a bit better than it was before the refactor since 
duplication happened even when vendor driver loads later if I understand 
it correctly.

Regards,
Akihiko Odaki

> 
> Regards,
> 
> Hans
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks
  2022-10-24 14:45   ` Rafael J. Wysocki
@ 2022-10-24 15:12     ` Hans de Goede
  0 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2022-10-24 15:12 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Dmitry Osipenko, Len Brown, Akihiko Odaki, Dmitry Torokhov,
	Sean Paul, kernel, linux-acpi, dri-devel, linux-kernel

Hi,

On 10/24/22 16:45, Rafael J. Wysocki wrote:
> On Mon, Oct 24, 2022 at 4:32 PM Hans de Goede <hdegoede@redhat.com> wrote:
>>
>> Hi,
>>
>> On 10/24/22 16:12, Dmitry Osipenko wrote:
>>> Chromebooks don't have backlight in ACPI table, they suppose to use
>>> native backlight in this case. Check presence of the CrOS embedded
>>> controller ACPI device and prefer the native backlight if EC found.
>>>
>>> Suggested-by: Hans de Goede <hdegoede@redhat.com>
>>> Fixes: 2600bfa3df99 ("ACPI: video: Add acpi_video_backlight_use_native() helper")
>>> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>>> ---
>>>
>>> Changelog:
>>>
>>> v2: - Added explanatory comment to the code and added check for the
>>>       native backlight presence, like was requested by Hans de Goede.
>>
>> Thanks this version looks good to me:
>>
>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>>
>> Rafael, can you pick this up and send it in a fixes pull-req
>> for 6.1 to Linus? Or shall I pick this one up and include it
>> in my next pull-req?
> 
> It would be better if you could pick this up IMV, so please free to add
> 
> Acled-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Ok, I've merged this now and I'll send out fixes pull-req with this
to Linus before coming Friday.

Dmitry, Thank you for your patch, I've applied this patch to my
fixes branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes

Regards,

Hans




> 
> to it.
> 
> Thanks!
> 
>>>
>>>  drivers/acpi/video_detect.c | 12 ++++++++++++
>>>  1 file changed, 12 insertions(+)
>>>
>>> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
>>> index 0d9064a9804c..9cd8797d12bb 100644
>>> --- a/drivers/acpi/video_detect.c
>>> +++ b/drivers/acpi/video_detect.c
>>> @@ -668,6 +668,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
>>>       { },
>>>  };
>>>
>>> +static bool google_cros_ec_present(void)
>>> +{
>>> +     return acpi_dev_found("GOOG0004");
>>> +}
>>> +
>>>  /*
>>>   * Determine which type of backlight interface to use on this system,
>>>   * First check cmdline, then dmi quirks, then do autodetect.
>>> @@ -730,6 +735,13 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
>>>                       return acpi_backlight_video;
>>>       }
>>>
>>> +     /*
>>> +      * Chromebooks that don't have backlight handle in ACPI table
>>> +      * are supposed to use native backlight if it's available.
>>> +      */
>>> +     if (google_cros_ec_present() && native_available)
>>> +             return acpi_backlight_native;
>>> +
>>>       /* No ACPI video (old hw), use vendor specific fw methods. */
>>>       return acpi_backlight_vendor;
>>>  }
>>
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-24 23:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 14:12 [PATCH v2] ACPI: video: Fix missing native backlight on Chromebooks Dmitry Osipenko
2022-10-24 14:32 ` Hans de Goede
2022-10-24 14:45   ` Rafael J. Wysocki
2022-10-24 15:12     ` Hans de Goede
2022-10-24 14:52 ` Akihiko Odaki
2022-10-24 14:59   ` Hans de Goede
2022-10-24 15:07     ` Akihiko Odaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).