From owner-freebsd-acpi@FreeBSD.ORG  Sun May 27 19:14:33 2012
Return-Path: <owner-freebsd-acpi@FreeBSD.ORG>
Delivered-To: freebsd-acpi@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 321151065673
	for <freebsd-acpi@freebsd.org>; Sun, 27 May 2012 19:14:33 +0000 (UTC)
	(envelope-from kob6558@gmail.com)
Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com
	[209.85.212.172])
	by mx1.freebsd.org (Postfix) with ESMTP id B50D98FC2B
	for <freebsd-acpi@freebsd.org>; Sun, 27 May 2012 19:14:32 +0000 (UTC)
Received: by wibhj8 with SMTP id hj8so847428wib.13
	for <freebsd-acpi@freebsd.org>; Sun, 27 May 2012 12:14:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	bh=EW65DaRmVNNw5Wfo10APmhxh7Nd1Th4McfH+HfmcmPs=;
	b=Dk/1u2wTKcG5FNXSKiBIvH3Qi+o0VFwCgQV2ldoSDRdvzu8Gy8xJCZR64y6rFm8OtW
	obL7HgoaGMw0T3iERuZPAA8lhFI87rkQ0F3A9mFrGBZAq2FCYPOShptuT3SErEkYzG0k
	mLN3FmoW6VmTJJkahzOkEqAA5wmco2aAXX3Kfn4QOm5146iNUnG2LExdTmAQQoScRroK
	Z0IS4/RSXprqI7BJL6cc0K4qeApi6MrRhSXS2G6QeBU+MvMgvRUfQxld58dk4jSTuDRQ
	whqBopsjFDt+KyrLbPqVgIHY6etda0V6YYEUf7gHOsKaaLGv7x64BcVDI8914tz3g8Na
	0HBA==
MIME-Version: 1.0
Received: by 10.216.215.194 with SMTP id e44mr3227627wep.61.1338146071396;
	Sun, 27 May 2012 12:14:31 -0700 (PDT)
Received: by 10.223.155.4 with HTTP; Sun, 27 May 2012 12:14:31 -0700 (PDT)
In-Reply-To: <20120526124542.GK39168@e-new.0x20.net>
References: <20120523151357.GC97037@sigil.instinctive.eu>
	<CAN6yY1vbc5DJcc4GrktyJaokA6CPNgTdx5X+HH7J1W_NvLJPxA@mail.gmail.com>
	<20120524065532.GB39168@e-new.0x20.net>
	<CAN6yY1u6DzSyGBCRB4zbstDP7ES7p4SjuyXkFQU5KkE264W6xw@mail.gmail.com>
	<20120526124542.GK39168@e-new.0x20.net>
Date: Sun, 27 May 2012 12:14:31 -0700
Message-ID: <CAN6yY1tZdNxm+__Orx+kvAkd53yS+sg_LD6SFazqiQKxKhDoyg@mail.gmail.com>
From: Kevin Oberman <kob6558@gmail.com>
To: Lars Engels <lars.engels@0x20.net>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: freebsd-acpi@freebsd.org,
	=?ISO-8859-1?Q?Natacha_Port=E9?= <natbsd@instinctive.eu>
Subject: Re: How can I help with thinkpad x220 issues?
X-BeenThere: freebsd-acpi@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: ACPI and power management development <freebsd-acpi.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-acpi>,
	<mailto:freebsd-acpi-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-acpi>
List-Post: <mailto:freebsd-acpi@freebsd.org>
List-Help: <mailto:freebsd-acpi-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-acpi>,
	<mailto:freebsd-acpi-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 27 May 2012 19:14:33 -0000

On Sat, May 26, 2012 at 5:45 AM, Lars Engels <lars.engels@0x20.net> wrote:
> On Fri, May 25, 2012 at 08:25:47PM -0700, Kevin Oberman wrote:
>> On Wed, May 23, 2012 at 11:55 PM, Lars Engels <lars.engels@0x20.net> wro=
te:
>> > On Wed, May 23, 2012 at 03:19:14PM -0700, Kevin Oberman wrote:
>> >> On Wed, May 23, 2012 at 8:13 AM, Natacha Port=E9 <natbsd@instinctive.=
eu> wrote:
>> >> > Hello,
>> >> >
>> >> > I happen to be the owner of a brand new Lenovo Thinkpad X220. From =
a
>> >> > recent thread here I gather it almost works with FreeBSD, and the
>> >> > remaining problems are screen brightness and screen left unpowered =
at
>> >> > resume. Is that right?
>> >> >
>> >> > So my question is, how can I help make progress in any of these are=
a?
>> >> > (though I admit I'm more interested in having the brightness proble=
m
>> >> > solved than the resume one)
>> >> >
>> >> > I don't know anything about ACPI or about FreeBSD or Linux internal=
s,
>> >> > but I'm quite proficient in C and somewhat used to navigate in unkn=
own
>> >> > huge code bases.
>> >> >
>> >> > So I guess the first steps to help would be to first learn stuff.
>> >> >
>> >> > However I don't have much time available. I guess FreeBSD 11 would =
reach
>> >> > end-of-life before I could reach a level of understanding I find
>> >> > satisfying (though I admit I have high standards there), so I would=
 have
>> >> > to prioritize. So my question is rather *what* should I learn to pr=
ovide
>> >> > help as soon as possible?
>> >> >
>> >> > For example, if the brightness issue is just a matter of extracting=
 the
>> >> > right numbers from linux kernel code and plug them into FreeBSD, I
>> >> > probably won't need to learn anything more about ACPI than what I w=
ould
>> >> > gather looking at the code. I guess if it was that simple someone w=
ould
>> >> > have already done it, but that illustrate well my point about
>> >> > prioritizing learning.
>> >> >
>> >> > Or is the barrier of entry too high for me to be of any use?
>> >>
>> >> If it has not been committed, the minor fix to make acpi_ibm work on
>> >> modern ThinkPads needs to be committed. Once done, the issues
>> >> mentioned need to be addressed.This includes getting brightness to be
>> >> setable from both the keypad hot-keys and from applications. ATM, I
>> >> can set the brightness, but making the hot-keys work will require the
>> >> ability to extract the current level so that it may be adjusted
>> >> plus/minus one.
>> >>
>> >> The other issue is volume control keys don't work. I suspect it will
>> >> be similar to brightness, but I don't know just how to figure it out.
>> >>
>> >> I should also mention that I don't have an X220. I have a T520, but
>> >> the issues seem to be identical, so fixing one will probably fix a lo=
t
>> >> of recent ThinkPads.
>> >
>> > About the key:
>> >
>> > Did you try loading "acpi_ibm", "sysctl dev.acpi_ibm.0.events=3D1",
>> > "cat /var/run/devd.pipe" and then press the keys. Does anything show u=
p?
>>
>> After adding LEN0068 ti the ACPI IDs, I tried this and I get no ACPI
>> event when pressing either button, but I do get regular key press
>> events:
>> KeyPress event, serial 30, synthetic NO, window 0x4600001,
>> =A0 =A0 root 0x121, subw 0x0, time 166670035, (96,121), root:(100,750),
>> =A0 =A0 state 0x0, keycode 176 (keysym 0x1008ff13, XF86AudioRaiseVolume)=
,
>> same_screen YES,
>> =A0 =A0 XLookupString gives 0 bytes:
>> =A0 =A0 XmbLookupString gives 0 bytes:
>> =A0 =A0 XFilterEvent returns: False
>>
>> KeyRelease event, serial 33, synthetic NO, window 0x4600001,
>> =A0 =A0 root 0x121, subw 0x0, time 166670185, (96,121), root:(100,750),
>> =A0 =A0 state 0x0, keycode 176 (keysym 0x1008ff13, XF86AudioRaiseVolume)=
,
>> same_screen YES,
>> =A0 =A0 XLookupString gives 0 bytes:
>> =A0 =A0 XFilterEvent returns: False
>>
>> KeyPress event, serial 33, synthetic NO, window 0x4600001,
>> =A0 =A0 root 0x121, subw 0x0, time 166927339, (98,0), root:(102,629),
>> =A0 =A0 state 0x0, keycode 174 (keysym 0x1008ff11, XF86AudioLowerVolume)=
,
>> same_screen YES,
>> =A0 =A0 XLookupString gives 0 bytes:
>> =A0 =A0 XmbLookupString gives 0 bytes:
>> =A0 =A0 XFilterEvent returns: False
>>
>> KeyRelease event, serial 33, synthetic NO, window 0x4600001,
>> =A0 =A0 root 0x121, subw 0x0, time 166927451, (98,0), root:(102,629),
>> =A0 =A0 state 0x0, keycode 174 (keysym 0x1008ff11, XF86AudioLowerVolume)=
,
>> same_screen YES,
>> =A0 =A0 XLookupString gives 0 bytes:
>> =A0 =A0 XFilterEvent returns: False
>
> Hmm, okay, that's not too bad. At least the keys are recognized.
>
>
>>
>> I can set these up as hot keys and issue a command, but I have no idea
>> what I can set to adjust the hardware volume. But I will also need to
>> read out the current volume so I know what value to which is should be
>> set. (Same issue as with brightness.)
>
> Do you have dev.acpi_ibm.0.lcd_brightness and .volume?
>
> If you cou can write a script that raises / lowers the values with
> sysctl.

Unfortunately newer Lenovo systems no longer play correctly with the
acpi_ibm module. Some things do work, but brightness, volume, and fan
speed control don't use the same ACPI methods as older units.
Brightness now uses /VBRC instead of /_BCL and can be accessed via the
call_acpi port do do raw ACPI operations.

See http://lists.freebsd.org/pipermail/freebsd-current/2012-March/032511.ht=
ml

Of course, you need to add LEN0068 to the list of IDs to get acpi_ibm
to work at all. Guess I need to open a PR to get this "fix" added, but
the proper one would be to fork off acpi_lenovo to use the ACPI
methods now used by ThinkPads. (I wonder if the ID is the only things
needed to detect the switch?)

--=20
R. Kevin Oberman, Network Engineer
E-mail: kob6558@gmail.com