fn key doesn't work in hardy with macbook pro fourth generation (4,1)

Bug #207127 reported by Eitan on 2008-03-26
10
Affects Status Importance Assigned to Milestone
Mactel Support
Medium
Alex Karpenko
linux (Ubuntu)
Low
Tim Gardner
Hardy
Low
Tim Gardner
Intrepid
Low
Tim Gardner

Bug Description

hardware: macbook pro generation 4,1 (feb 2008)
problem: fn key not detected
test: run xev. press fn key. nothing happens.
consequences: home/end/pgup/pgdown don't work.

i was able to fix this issue by compiling my own kernel.
i downloaded linux-source from ubuntu hardy
(VERSION = 2,PATCHLEVEL = 6,SUBLEVEL = 24,EXTRAVERSION = .3)

and revised this file:
 drivers/hid/usbhid/hid-quirks.c

used lsusb to grab the id of the internal keyboard device:
  Bus 005 Device 003: ID 05ac:0230 Apple Computer, Inc.

and revised the c file accordingly:

/* next line commented out by eitan and replaced with line below;
  changing address for device from 0x021b to 0x0230 which is what lsusb tells me
  my internal keyboard device id actually is
#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
 */
#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x0230

rebooting with the new kernel, the fn key now works.
i don't know if this breaks other versions of the macbook pro
and am otherwise ignorant of the linux kernel source code.

thanks,
/ eitan

Ricky Campbell (cyberdork33) wrote :

Come on this is an easy fix...

Changed in mactel-support:
importance: Undecided → Medium
Changed in linux-meta:
status: New → Confirmed
Alex Karpenko (alexkarpenko) wrote :

I can confirm the bug as described: nothing happens when fn key is pressed in xev.

Scott Seaward (scottseaward) wrote :

I used the fix listed in this bug report and can confirm it works, although I had to use a slightly different Device ID - mine was 0x0231. The problem not only affects the PgDn, PgUp, End and Home keys, but also stops brightness and volume controls on the Function keys from working.

Ricky Campbell (cyberdork33) wrote :

This needs to be fixed so that it can support all those IDs without having to change the source for your particular model.

David Harrigan (dharrigan) wrote :

Hi,

I too would like to see this fixed. Yes, I could recompile my own kernel as described above, but for those out there not comfortable about doing this, having this bug squashed and released as an official kernel update would be great!

-=david=-

emmeelle (manulotta) wrote :

Hi,
me too would like to see an official kernel update!!!

Alex Karpenko (alexkarpenko) wrote :

For me the device ID is as described:
Bus 005 Device 003: ID 05ac:0230

seaward, which macbook model are you using?

This bug affects all new macbook pro models. It is imperative that it gets fixed as it prevents the user from adjusting/accessing screen brightness, volume, media controls, delete, PgUp, and PgDn.

Scott Seaward (scottseaward) wrote :

17" MacBook Pro, 2.5 GHz

Alex Karpenko (alexkarpenko) wrote :

For those who don't want to wait for an official patch, or compile their own kernel, I've attached the recompiled hid module for amd64 hardy with the above fix. Follow the instructions in the README and you should get a functioning fn key ;)

Only tested on 15" Macbook Pro (penryn) running *64bit* Hardy. TRY AT YOUR OWN RISK!

If some devs who have worked with hid quircks before could chime in with suggestions as to how to add this fix to the kernel properly, I'd be willing to write and and/or test the code.

Alex Karpenko (alexkarpenko) wrote :

Ok I've figured it out. Working from the discussion here: http://<email address hidden>/msg01343.html

We need to add 3 new device IDs for the new generation macbooks (the id varies depending on whether the keyboard is ansi, iso, or jis) for the apple vendor ID, which is: "#define USB_VENDOR_ID_APPLE 0x05ac".
I propose to add the following to hid-quirks.c

#define USB_DEVICE_ID_APPLE_GEYSER5_ANSI 0x0230 /* i'm guessing this is correct, i need you to confirm this */
#define USB_DEVICE_ID_APPLE_GEYSER5_ISO 0x0231
#define USB_DEVICE_ID_APPLE_GEYSER5_JIS 0x0232

Corresponding entries will have to be made inside hid_blacklist[] in the same file (just a copy&paste of the GEYSER4 entries). This way older Macbook models will not be affected, and the new ones will work for all those device IDs.

*** What I need from you: execute "lsusb -v" at the shell. And report the output for the block that contains:
   Bus 005 Device 003: ID 05ac:0230 Apple Computer, Inc.
...
      bInterfaceProtocol 1 Keyboard
...

Note your ID might not be 05ac:0230. I've attached the block for mine for reference. The important line here is the device ID, and country code. For me it is:
        bCountryCode 33 US

I'm guessing Scott's line will read:
       bCountryCode 13 International (ISO)

or something similar. Once I've confirmed the device IDs with your help, I'll try to make a patch and submit it. We should also probably submit it upstream as this is not exclusive to Ubuntu.

Alex Karpenko (alexkarpenko) wrote :

I've detailed a proper fix that doesn't require patching/kernel recompile/or the compiled module I've provided above.
The fix is found here:
http://ubuntuforums.org/showthread.php?p=4984452&posted=1#post4984452

The fix loads the usbhid module with an option that adds the new DeviceID to the quirk list dynamically.
Sorry to spam this bug report. I'll move further discussion there.

The patch I outlined above should still be implemented so that in future the keyboard is recognized automatically.

Scott Seaward (scottseaward) wrote :

lsusb -v output from my keyboard attached. You're right about bCountryCode, mine is International (ISO).

Alex Karpenko (alexkarpenko) wrote :

Attached is a patch to fix the fn keys on all new Macbook Pros (v4,1). The naming scheme follows the one defined by Apple in:
/System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/Contents/Info.plist

The keyboard name is WellspringII, and the Device ID is 0x0230, 0x0231, 0x0232 for ANSI, ISO, JIS respectively (as defined in Info.plist, and confirmed for ANSI and ISO by me and Scott).
Some debugging has been done using dynamically loaded quirks here:
http://ubuntuforums.org/showthread.php?p=4984452&posted=1#post4984452

This patch simply adds the findings to hid-quirks.c, so that the keyboard is recognized automatically in the future.

Paco (nunuxboy) wrote :

ok, i'm with a macbook air, but same problem, tried the solution explained does not work, as my lsusb send my this i can understand but cannot correct it:

Bus 005 Device 003: ID 05ac:0224 Apple Computer, Inc.

can anyone help me to make this little modification?

Ricky Campbell (cyberdork33) wrote :

Bus 005 Device 003 may not be the keyboard. You need to amek sure that the output contains the other line mentioned:

"bInterfaceProtocol 1 Keyboard"

Paco (nunuxboy) wrote :

oh, ok, so now i've seen this "bInterfaceProtocol 1 Keyboard" and so i was wrong, on my macbook air the device attached to this protocol is the following:

Bus 003 Device 006: ID 05ac:820a Apple Computer, Inc.

what sould i write then?

  • unnamed Edit (900 bytes, text/html; charset=ISO-8859-1)

On Sun, May 18, 2008 at 12:38 AM, Alex Karpenko <email address hidden>
wrote:

> I've detailed a proper fix that doesn't require patching/kernel
> recompile/or the compiled module I've provided above.
> The fix is found here:
> http://ubuntuforums.org/showthread.php?p=4984452&posted=1#post4984452
>
> The fix loads the usbhid module with an option that adds the new DeviceID
> to the quirk list dynamically.
>

hi alex,
  thank you!!! fn key now works for me with dynamic fix.
/ eitan

Alex Karpenko (alexkarpenko) wrote :

Paco,

Could you please attach the Info.plist file located on your OS X partition:
/System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/Contents/Info.plist

Also execute the following command in Ubuntu at the shell:
lsusb -v > lsusb.txt

And attach the resulting lsusb.txt file.

Paco (nunuxboy) wrote :

ok, here you have the plist file

Paco (nunuxboy) wrote :

and here the lsusb -v

Paco (nunuxboy) wrote :

i tried with start with 224 for keyboard id, it's to say on macbook air this result line:

options usbhid quirks=0x05ac:0x0224:0x00000800,0x05ac:0x0225:0x00004800,0x05ac:0x0226:0x00000800

and now FN key work, but not every Fx key, F5 and F6 (keyboard lights) still remains F5 and F6 with or without FN key, xev confirms, ideas/similar problem on macbook pro 4.1?

Eitan (eitan-u2d) wrote :
  • unnamed Edit (1.4 KiB, text/html; charset=ISO-8859-1)

On Mon, May 19, 2008 at 3:13 PM, Paco <email address hidden> wrote:

> i tried with start with 224 for keyboard id, it's to say on macbook air
> this result line:
>
> options usbhid
>
> quirks=0x05ac:0x0224:0x00000800,0x05ac:0x0225:0x00004800,0x05ac:0x0226:0x00000800
>
> and now FN key work, but not every Fx key, F5 and F6 (keyboard lights)
> still remains F5 and F6 with or without FN key, xev confirms,
> ideas/similar problem on macbook pro 4.1?
>

Fn-F4, Fn-F5, and Fn-F6 appear to not be detected on my macbook pro 4,1.
also, after turning on dynamic hidquirks, my tilde/grave key started echoing
<> instead, which i corrected via xmodmap.

/ eitan

>
> --
> fn key doesn't work in hardy with macbook pro fourth generation (4,1)
> https://bugs.launchpad.net/bugs/207127
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Alex Karpenko (alexkarpenko) wrote :

I've updated the patch to include Macbook Air keyboards as per the spec in Info.plist.

The dynamic fix for Macbook Air is:
options usbhid quirks=0x05ac:0x0223:0x00000800,0x05ac:0x0224:0x00004800,0x05ac:0x0225:0x00000800

Regarding the function keys, I can confirm your findings, but I believe it's an issue with pommed, and not the hid module. Perhaps it's fixed in pommed 1.17, but I've not tried compiling it.

Eitan, I can't reproduce the ~ problem. Is your keyboard ISO (as specified in "lsusb -v")?

Ricky Campbell (cyberdork33) wrote :

pommed 1.18 just came out and claims support for more IDs. might want to check that out...

Alex, I assigned the bug to you on the Mactel-Support side of things since you have taken the initiative.

Changed in mactel-support:
assignee: nobody → alexkarpenko
status: New → In Progress
Eitan (eitan-u2d) wrote :
  • unnamed Edit (915 bytes, text/html; charset=ISO-8859-1)

>
> Eitan, I can't reproduce the ~ problem. Is your keyboard ISO (as
> specified in "lsusb -v")?
>
>
the output of lsusb -v shows bCountryCode = 33 US

i believe it's specific to my setup. in the gnome keyboard setup i specified
my keyboard layout to be:
   Macbook/MacbookPro, USA International (AltGr dead keys)
so that i'd have an easy way to input e's with accents, for example.
anyhow, it was easy enough to fix and i'm sure it's not related to the
hidquirks issue. i'm very thankful for your fix as i'd been going without
now since february or march (surprisingly i'd gotten used to it). :-)

/ eitan

Alex Karpenko (alexkarpenko) wrote :

Okay, I did some more digging regarding the F4-F6 keys: turns out older macbooks had no secondary functionality for those keys, so the lookup table in drivers/hid/hid-input.c reads:

static struct hidinput_key_translation apple_fn_keys[] = {
 { KEY_BACKSPACE, KEY_DELETE },
 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
 { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */
 { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */
 { KEY_F5, KEY_FN_F5 },
 { KEY_F6, KEY_FN_F6 },
 { KEY_F7, KEY_BACK, APPLE_FLAG_FKEY },
 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
 { KEY_F9, KEY_FORWARD, APPLE_FLAG_FKEY },
 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
 { KEY_UP, KEY_PAGEUP },
 { KEY_DOWN, KEY_PAGEDOWN },
 { KEY_LEFT, KEY_HOME },
 { KEY_RIGHT, KEY_END },
 { }
};

Changing the F4, F5 lines to:
 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },

Adds the desired functionality (that is you get key codes in xev when pressing fn+F5/F6). However, it does not affect the backlight state of my keyboard (running pommed 1.18).

Key observations:
KEY_FN_F* does not produce key codes in xev.
KEY_KBDILLUMUP, KEY_KBDILLUMDOWN seems to be the correct setting for fn+F5, fn+F6. Looking at the source, no constant seems to have been defined for the dashboard key... APPLE_FLAG_FKEY specifies the default key state.

This cannot be fixed dynamically. As it's unrelated to the fn key problem I won't add it to the above patch. However, I've included a compiled hid module for amd64, with the above changes (it also has my patch applied so the fn key will work out of the box without the dynamic quirk).

I consider the fn key problem fixed. Hopefully someone with more experience than me will commit this patch to the source so that it makes it into the next update cycle ;)

Alex Karpenko (alexkarpenko) wrote :

I just realized my notation might be a bit confusing. When I say fn+F5, I mean the secondary functionality of F5 (that is decreasing brightness)...

Eitan (eitan-u2d) wrote :
  • unnamed Edit (1.3 KiB, text/html; charset=ISO-8859-1)

strange: fn key stopped working for me entirely.
i can't figure out what caused this change. my
/etc/modprobe.d/options still says:
  options usbhid quirks=0x05ac:0x0230:0x00024800
i haven't changed that.
i suspect perhaps some change that's come down through
software update.

is anyone else seeing this? running hardy heron with
gnome and all the software updates installed.

/ eitan

On Wed, May 21, 2008 at 9:19 PM, Alex Karpenko <email address hidden>
wrote:

> I just realized my notation might be a bit confusing. When I say fn+F5,
> I mean the secondary functionality of F5 (that is decreasing
> brightness)...
>
> --
> fn key doesn't work in hardy with macbook pro fourth generation (4,1)
> https://bugs.launchpad.net/bugs/207127
> You received this bug notification because you are a direct subscriber
> of the bug.
>

zkennan (zivkennan) wrote :

Well, I've tried the fix, and it doesn't work on my Macbook Pro. I just bought it (new), so I'm wondering if something has changed. I've attached the lsusb output. Hope it helps.

Alex Karpenko (alexkarpenko) wrote :

zkennan,

Are you using the dynamic fix, or have you compiled a custom kernel with the patch applied?
Your keyboard device id has not changed so things should work. Note, in order to change brightness etc you need to install pommed 1.16+.

zkennan (zivkennan) wrote :

I'm using the dynamic fix. I also have the latest version of pommed installed from source. Despite the modification to the options file, fn+delete still behaves as if i pressed only the backspace key.

Alex Karpenko (alexkarpenko) wrote :

Perhaps your problem is related to eitan's. We have the same keyboards, but it works fine for me with the latest updates.
If you're running Ubuntu 64bit, you can try the hid module I've attached above.

I suspect the dynamic quirk is overridden by some configuration specific to your setup.

zkennan (zivkennan) wrote :

All's well now. It turns out that I had replaced my hid modules previously, and that was preventing the modprobe options from being used. I reinstalled 2.6.24-17 and now everything works. Thanks for your help. :-)

Alex Karpenko (alexkarpenko) wrote :

Cool!

By the way, my patch has been accepted upstream and I've also submitted it to get it into ubuntu sooner.
I guess I'll change this bug's status once it's in the ubuntu source tree.

Eitan (eitan-u2d) wrote :
  • unnamed Edit (771 bytes, text/html; charset=ISO-8859-1)

On Thu, May 29, 2008 at 9:03 PM, Alex Karpenko <email address hidden>
wrote:

> Cool!
>
> By the way, my patch has been accepted upstream and I've also submitted it
> to get it into ubuntu sooner.
> I guess I'll change this bug's status once it's in the ubuntu source tree.

very cool! by the way, i forgot to follow up.. the fn key is working for me
again.
not sure why it didn't for a couple of days; but all's well at the moment.

/ eitan

Tim Gardner (timg-tpi) wrote :

SRU Justification:

Impact: Function keys on newer Macbooks don't work.

Patch Description: Add function key identifiers to the USB HID quirk table.

Patch: http://launchpadlibrarian.net/14613817/fix_fn_key_on_macbookpro_4_1_and_mb_air.patch
http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-hardy.git;a=commit;h=97ea54575ec58a5bcf13ccf20556f4e68d961bf1

TEST CASE: See bug description

Changed in linux-meta:
assignee: nobody → timg-tpi
importance: Undecided → Low
milestone: none → ubuntu-8.04.1
status: Confirmed → Fix Committed
Changed in mactel-support:
status: In Progress → Fix Committed
Steve Langasek (vorlon) on 2008-05-30
Changed in linux:
milestone: ubuntu-8.04.1 → none
assignee: nobody → timg-tpi
importance: Undecided → Low
status: New → Triaged
Martin Pitt (pitti) wrote :

Accepted into -proposed, please test and give feedback here

Changed in linux:
status: Triaged → Fix Committed
Launchpad Janitor (janitor) wrote :
Download full text (3.3 KiB)

This bug was fixed in the package linux - 2.6.26-1.1

---------------
linux (2.6.26-1.1) intrepid; urgency=low

  [Amit Kucheria]

  * SAUCE: make fc transport removal of target configurable
  * SAUCE: Add AGP support for Radeon Mobility 9000 chipset
  * SAUCE: pm: Config option to disable handling of console during
    suspend/resume

  [Ben Collins]

  * SAUCE: input/mouse/alps: Do not call psmouse_reset() for alps
  * SAUCE: irda: Default to dongle type 9 on IBM hardware
  * SAUCE: tulip: Let dmfe handle davicom on non-sparc
  * SAUCE: tulip: Define ULI PCI ID's
  * SAUCE: version: Implement version_signature proc file.
  * build: Remove remnants of unused binary-custom infrastructure
  * mmc_block: Fix bad allocation on 64-bit (zero len array)
  * ubuntu: New modules, acer-acpi
  * build: Remove -virtual, and rebuild configs
  * ubuntu: Add drbd module
  * ubuntu: Add iscsitarget module
  * ubuntu: Add squashfs driver
  * build/configs: The Great Config Consistency Check of 2008
  * ubuntu: Add aufs module
  * ubuntu: Added atl2 driver
  * ubuntu: Add dm-radi4-5 driver
  * build: Add CONFIG_DEBUG_SECTION_MISMATCH=y to get old style warnings
    from build
  * squashfs: Fixes for VFS changes
  * ubuntu/dm-raid4-5: Fixups for moved/renamed headers/functions in core
    md
  * ubuntu: Add ndiswrapper driver
  * d-i: Update module listings

  [Chuck Short]

  * SAUCE: ata: blacklist FUJITSU MHW2160BH PL
  * SAUCE: [USB]: add ASUS LCM to the blacklist

  [Colin Ian King]

  * SAUCE: Enable speedstep for sonoma processors.
  * SAUCE: airprime.c supports more devices

  [Kyle McMartin]

  * SAUCE: fix orinoco_cs oops

  [Mario Limonciello]

  * SAUCE: Enable Reset and SCO workaround on Dell 410 BT adapter

  [Matthew Garrett]

  * SAUCE: hostap: send events on data interface as well as master
    interface

  [Phillip Lougher]

  * SAUCE: r8169: disable TSO by default for RTL8111/8168B chipsets.

  [Stefan Bader]

  * SAUCE: Export dm_disk function of device-mapper
  * SAUCE: Restore VT fonts on switch
  * SAUCE: Always use SCO protocol (disable eSCO support) Bug: #39414
  * SAUCE: mmc: Increase power_up deleay to fix TI readers
  * SAUCE: Add blacklist support to fix Belkin bluetooth dongle.
  * SAUCE: Lower warning level of pci resource allocation messages.
  * SAUCE: Lower message level for PCI memory and I/O allocation.
    - LP: #159241
  * Modify log generation to catch bug numbers when adding with git-am.

  [Tim Gardner]

  * SAUCE: hdaps module does not load on Thinkpad T61P
  * SAUCE: Add extra headers to linux-libc-dev
  * SAUCE: Export symbols for aufs (in lum).
  * SAUCE: USB bluetooth device 0x0e5e:0x6622 floods errors to syslog
  * SAUCE: Blacklist Bluetooth Dell Wireless 370 for SCO MTU
  * SAUCE: Catch nonsense keycodes and silently ignore
  * SAUCE: frame buffer regression - screen blank except for blinking
    cursor after fbcon vtswitch
  * SAUCE: Added support for HDAPS on various ThinkPads from Lenovo and IBM
  * SAUCE: Guest OS does not recognize a lun with non zero target id on
    Vmware ESX Server
  * SAUCE: Modualrize vesafb
  * SAUCE: DVB-USB UMT-010 driver oops on install
  * SAUCE: fn key doesn't work in hardy with ...

Read more...

Changed in linux:
status: Fix Committed → Fix Released
Martin Pitt (pitti) wrote :

Eitan, can you please test the kernel in hardy-proposed on your system?

Martin Pitt (pitti) wrote :

Copied to hardy-updates. The new kernel was tested extensively by many people, who reported back in other bug reports. Due to lack of feedback, this particular bug was not confirmed to be tested, though. Please report back here if the bug still occurs for you with the new kernel packages, then we will reopen this bug.

Changed in linux:
status: Fix Committed → Fix Released
Alex Karpenko (alexkarpenko) wrote :

I can confirm that the bug is now fixed.

Changed in mactel-support:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers