From nobody Fri Nov 10 15:50:57 2023 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SRjwP2b2Cz4ysZr for ; Fri, 10 Nov 2023 15:51:01 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mx.blih.net (mx.blih.net [212.83.155.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4SRjwN6Y8bz3KbY for ; Fri, 10 Nov 2023 15:51:00 +0000 (UTC) (envelope-from manu@bidouilliste.com) Authentication-Results: mx1.freebsd.org; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1699631458; 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=Vn2pZYVfh3+J6DXa1OWWXVY+nhPncheG7Wll5/SwM3U=; b=sqCeFKrqgeE6coDeoPJp/kkNBTZHVurULzWO6OMJuSTVJjSqZxG75ndmG/C9PDG6nEBCaH E/uk6l2b3bf5XJbee+VNuI/GAqBaLUxjRUM/jLc1dio2eF4GUnxoc13MeZnzh/fm3EaBvw XEtcF/wgpBRDoM5LW+Unr7dw8c94sHk= Received: from skull.home.blih.net (lfbn-lyo-1-2174-135.w90-66.abo.wanadoo.fr [90.66.97.135]) by mx.blih.net (OpenSMTPD) with ESMTPSA id 6f2eaf52 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 10 Nov 2023 15:50:58 +0000 (UTC) Date: Fri, 10 Nov 2023 16:50:57 +0100 From: Emmanuel Vadot To: "Dr. Amr Osman" Cc: freebsd-hackers@freebsd.org Subject: Re: Brightness 100% when connect or disconnect charger Message-Id: <20231110165057.7e55ad6c62354294219fa980@bidouilliste.com> In-Reply-To: References: <20231109091931.983f45f8fad4305569faddcb@bidouilliste.com> <20231110121053.42e78f4b7f44eba5e91da898@bidouilliste.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd15.0) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:12876, ipnet:212.83.128.0/19, country:FR] X-Rspamd-Queue-Id: 4SRjwN6Y8bz3KbY On Fri, 10 Nov 2023 15:58:30 +0200 "Dr. Amr Osman" wrote: > It's working! > I just added >=20 > return 0; >=20 > below if_def_linux so it will always return 0 and when I plug and > unplug my charger it never goes to 100 >=20 > Thank You > Dr. Amr Osman >=20 >=20 > Thank You > Dr. Amr Osman >=20 The theory that I have now is that the value set back when an event happen is the one that was set with the keyboard keys, for me it's 100% as this is how it's set at boot and since my keys don't work it stays that way. Can someone with functional keys for brightness can confirm ? >=20 >=20 > On Fri, Nov 10, 2023 at 1:10?PM Emmanuel Vadot wr= ote: > > > > On Thu, 9 Nov 2023 09:19:31 +0100 > > Emmanuel Vadot wrote: > > > > > On Wed, 8 Nov 2023 21:57:21 +0200 > > > "Dr. Amr Osman" wrote: > > > > > > > Hello, > > > > I have installed freeBSD 14rc4 on Lenovo Thinkpad x270 and xfce des= ktop and > > > > when I > > > > 1) connect the charger > > > > 2) disconnect the charger > > > > 3) resume from suspend > > > > The LCD brightness is 100% which is really disturbing specially whe= n I am > > > > in dark room > > > > > > I don't have the issue on my Thinkpad X390 with suspend/resume but I > > > do have it with the charger. > > > I'm pretty sure that it's a hardware thing and we can't do anything > > > about it without having some framework for sensors that can handle > > > power supply connection/disconnection and events. > > > > > > > hw.acpi.video.lcd0.economy: 20 > > > > hw.acpi.video.lcd0.fullpower: 30 > > > > I have loaded acpi_video and acpi_ibm > > > > and if I tried to adjust brightness it goes suddenly from 100 to 20= if I > > > > press fn +f5/f6 > > > > > > You shouldn't need to load acpi_video on modern laptop, backlight(9) > > > and backlight(8) is enought (if you have drm loaded). > > > > > > > What can I do to fix this issue? > > > > So I had a better look at I was only ~50% right :) > > There is some harware thing that happens, when some external events > > happens (docking, plugging charger, suspend/resume etc ...) the > > gpu firmware (or the IP not sure about which) generates some interrupts > > and the i915 driver get some messages via some mailbox. We seem to get > > a set backlight message for those events, it's happening > > https://github.com/freebsd/drm-kmod/blob/dce1b3ba0d1ff8ccbbbec09d74480a= 3a0de346e4/drivers/gpu/drm/i915/display/intel_opregion.c#L420 > > There is a few things that I still don't understand : > > - Why do we get a message to set the backlight at 100% for any of > > those events ? > > - Linux checks the backlight type and if it's "native" they discard > > this call. Still unsure what "native" really means, looking at some > > code it seems that if acpi_video is used it's not considered as a > > native backlight unless there is a quirk for the computer or if in the > > ACPI table it's says that it's a windows 8 laptop or some chromebook. > > - Modifying the above function to always returns 0 (so faking that we > > have a "native" backlight) obviously don't change the backlight value, > > but I'm unsure if this is the correct hack or if there will be some > > problems with it. > > > > So it will be interesting for people who have this problem to know if > > modifying the code to always do a return 0; at the beginning fixes > > everything. I'd also like to know if the keyboard keys to modify the > > backlight still works correctly after this (mine don't do a thing and > > never did, one day I should have a look at how to use them). > > > > Cheers, > > > > -- > > Emmanuel Vadot >=20 --=20 Emmanuel Vadot