Re: Volume control on T400

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 26 Apr 2009, Yang Zhe wrote:
> By echo 0x30 0x** > ecdump, I discover something...
> 
> In the driver thinkpad_acpi.c, file /proc/acpi/ibm/volume is handled
> in lines 5652~5737, function volume_read(), volume_write(), and it's
> read through acpi_ec_read(). But in function hotkey_read_nvram, at
> line 1621, volume_level is read from nvram offset 0x60..

Yes, that's very old code, and it does these strange things.  I recently
fixed the brightness code that did similar stuff.

If it works like brightness does (and it probably does), on any non-ancient
thinkpad, the EC register is what matters, but if you don't update the
NVRAM, your settings are lost when you reboot/shutdown.

Bit 0x80 of the NVRAM is used as a flag that means "a button was pressed if
this bit changes state".  This can be used to detect multiple "mute"
pressions, etc.  If you really want to know what is there for, look at the
hotkey polling code of thinkpad-acpi.

> byte in nvram never changes. By reading the code volume_write(), I
> realized that the cmos_cmd TP_CMOS_VOLUME_UP only xor an 0x80 to
> nvram, TP_CMOS_VOLUME_DOWN xor 0x80 to nvram and decrease the lower 4
> bit by 1. TP_CMOS_VOLUME_MUTE handles 0x40 correctly.

The UCMS commands often only "Update CMoS" (i.e. the NVRAM), but it is not
always like that :-(  it depends a lot on the UCMS function being called,
AND on the thinkpad model.

> And the mute button will mute the volume and correct the nvram byte.
> (And erase the 0x80)

It probably changes the 0x80 bit to on and off every time you press a
volume or mute button.  Try it :-)

> So that, it's easy to correct the behavior of the thinkpad_acpi
> driver, just increase the lower 4bits of nvram offset 0x60, and after
> detect an 0x80, toggle it off.

There is no volume suport in your thinkpad (I got that directly from a
Lenovo engineer), so we just need to look at the MUTE bit.

> And I did a further experiment, I blacklist the thinkpad_acpi driver,
> and find that xorg recognize Volume Up Button and Volume Down Button,
> and KDE mixer react with it.

It should recognize these buttons regardless.  They do NOT go through
thinkpad-acpi on your thinkpad.

> Then I think that ACPI should ignore the IBM HOTKEY about volume
> up/down, but let some userspace program, or some acpi volume script to
> handle (toggle)mute.

This is a lot more complicated than what you think, especially because of
some horrible hacks done to do on-screen-display of volume changes by the
userspace people.

Still, thinkpad-acpi DOES ignore all volume and mute keys BY DEFAULT, it is
stupid distro scripts that keep enabling those functions.

And thinkpad-acpi is not supposed to even GET volume change events from the
firmware on your thinkpad, that's what the Lenovo engineers said: the events
will get reported as regular keys on the regular keyboard interface, and are
NOT sent to the ACPI system by the firmware.

> Since neither mute button nor volume up/down button generate 0x80, the
> volume_toggle = !!(d & TP_MASK_HKT_VOLUME) (code from line 1625 in
> thinkpad_acpi.c) never become 1, then the driver fails to handle mute
> button.

That code needs to be rewritten.  Thanks for this note.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel

[Index of Archives]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Photo]     [Yosemite Photos]     [Yosemite Advice]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux