From nobody Fri Nov 10 11:10:53 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 4SRbjR4VT5z50G9x for ; Fri, 10 Nov 2023 11:11:07 +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 4SRbjQ30FLz3Vcn for ; Fri, 10 Nov 2023 11:11:06 +0000 (UTC) (envelope-from manu@bidouilliste.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bidouilliste.com header.s=mx header.b=GE6ObA3s; spf=pass (mx1.freebsd.org: domain of manu@bidouilliste.com designates 212.83.155.74 as permitted sender) smtp.mailfrom=manu@bidouilliste.com; dmarc=pass (policy=none) header.from=bidouilliste.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1699614658; 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=+jmIuKoN+lLj0QiFWYZRne5WJNHURwH5YTyKIz4Akpk=; b=GE6ObA3sdeBSP7oZbnmx4+CWRwT9f+bDyF/QkWKNaFG9TINkgK/l4V8hr79k9ak9kyWdv2 Q7DJxq8xsbRyLlXRHuAa0Cd7y0iZgRE0u+LcuxRD/QVYNugh8wRxloKG4ad6ipatIfR9jW nv4xamLx2jlJt2BBcyiX9wYbB10D3fE= 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 e0ba77fb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 10 Nov 2023 11:10:58 +0000 (UTC) Date: Fri, 10 Nov 2023 12:10:53 +0100 From: Emmanuel Vadot To: Emmanuel Vadot Cc: "Dr. Amr Osman" , freebsd-hackers@freebsd.org Subject: Re: Brightness 100% when connect or disconnect charger Message-Id: <20231110121053.42e78f4b7f44eba5e91da898@bidouilliste.com> In-Reply-To: <20231109091931.983f45f8fad4305569faddcb@bidouilliste.com> References: <20231109091931.983f45f8fad4305569faddcb@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=US-ASCII Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-3.40 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[bidouilliste.com,none]; R_SPF_ALLOW(-0.20)[+ip4:212.83.155.74/32]; R_DKIM_ALLOW(-0.20)[bidouilliste.com:s=mx]; MIME_GOOD(-0.10)[text/plain]; ONCE_RECEIVED(0.10)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; RCVD_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org]; ASN(0.00)[asn:12876, ipnet:212.83.128.0/19, country:FR]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; DKIM_TRACE(0.00)[bidouilliste.com:+]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[manu]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 4SRbjQ30FLz3Vcn X-Spamd-Bar: --- 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 desktop 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 when 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/dce1b3ba0d1ff8ccbbbec09d74480a3a0de346e4/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