Solved Macbook Pro backlit keyboard with asmc driver

I have been struggling to find a way to control the Macbook keyboard backlight brightness under FreeBSD. After stumbling across this man page, I enabled the asmc(4) kernel module and attempted to change some of the values using sysctl. However, there don't seem to be any MIBs related to smc:
Code:
# sysctl -a | grep smc
#
So my question becomes: is there a better way to go about setting the keyboard brightness, or is my Macbook model (13-inch, 2012) simply not supported by the kernel module?

Note: I'm using 10.1-RELEASE due to problems with Broadcom drivers in 10.2
 
By hacking around in the kernel source, I made the following changes (reflected in this patch) in /usr/src/sys/dev/asmc/asmc.c:
Code:
--- asmc.c    2014-11-11 14:02:57.000000000 -0600
+++ asmc.c    2015-11-11 12:50:43.000000000 -0600
@@ -197,6 +197,13 @@
     ASMC_MBP4_TEMPS, ASMC_MBP4_TEMPNAMES, ASMC_MBP4_TEMPDESCS
    },

+    {
+         "MacBookPro8,1", "Apple SMC MacBook Pro Core i5",
+     NULL, NULL, NULL,
+     ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS,
+     ASMC_MBP_TEMPS, ASMC_MBP_TEMPNAMES, ASMC_MBP_TEMPDESCS
+    },
+
    /* The Mac Mini has no SMS */
    {
     "Macmini1,1", "Apple SMC Mac Mini",

Note that this will only work for the Macbook Pro 2011 13-inch. You will need to find and replace your corresponding device identifier where I have "MacBookPro8,1". I haven't tested this on any other devices, but I assume there are many models that are technically supported but not included in the driver.

EDIT: make sure to recompile the kernel per the FreeBSD handbook, of course
 
This patch seems to work. I also added:

Code:
dev.asmc.0.light.control=100

to /etc/sysctl.conf and

Code:
asmc_load="YES"

to /boot/loader.conf
 
There are two patches available in Buzilla, already for my Macbook Pro 8,1 : https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217505

Is there anything else I can do to get this in the next kernel?

The patch in the PR you referenced above was committed to head, stable-11 and stable-12 in December last year.

You don't mention what version of FreeBSD you're using, but if it is dated after last December, then it should already include the patch.
 
The patch in the PR you referenced above was committed to head, stable-11 and stable-12 in December .last year.

You don't mention what version of FreeBSD you're using, but if it is dated after last December, then it should already include the patch.
Thank you.

I was on FreeBSD 12 Stable when I wrote the above but I've gone to GhostBSD (which is 13). When I built the custom kernel I was on FreeBSD 12 Stable. So, what I'm learning is that I didn't even have to do that. Problem is I can kldload asmc but I really don't know what to do next.

Code:
#sysctl dev.asmc.0.light.control=50

Doesn't seem to work. I'd rather not make a custom kernel again if I can avoid it.

Thank you for your help.
 
Okay, Ghost is flashy at first but really unstable!

I went back to FreeBSD 12 on the Macbook. I'm just going to patch the kernel again. It's not a big deal on FreeBSD.

Thanks for your help.

That worked. I do have to patch and recompile the kernel. For some reason, loading the module doesn't work. Even in 12 Stable.
 
Back
Top