From e91e9a573068a225a8b02b218b4dabefe600f01a Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 24 Apr 2010 13:06:15 +0200 Subject: Update applesmc.c to kernel version 2.6.34-rc5 This version will work for karmic and lucid packages. --- Makefile | 2 +- debian/changelog | 6 ++++ debian/postinst | 2 +- debian/postrm | 2 +- debian/prerm | 2 +- debian/rules | 2 +- usr/src/dkms_source_tree/applesmc.c | 61 ++++++++++++++++++++++++++++--------- usr/src/dkms_source_tree/dkms.conf | 2 +- 8 files changed, 59 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 246fb9f..adeaff1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME = applesmc -VERSION = 0.14.4 +VERSION = 0.15.1 SRC = usr/src TARBALL = $(NAME)-$(VERSION).dkms.tar.gz diff --git a/debian/changelog b/debian/changelog index 1975276..ae48e19 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +applesmc-dkms (0.15.1) unstable; urgency=low + + * Update to kernel 2.6.34-rc5 + + -- Henrik Rydberg Sat, 24 Apr 2010 12:59:47 +0200 + applesmc-dkms (0.14.4) unstable; urgency=low * Rebuild for jaunty diff --git a/debian/postinst b/debian/postinst index 29d68f7..f4ef2fd 100644 --- a/debian/postinst +++ b/debian/postinst @@ -3,7 +3,7 @@ set -e NAME=applesmc -VERSION=0.14.4 +VERSION=0.15.1 case "$1" in configure) diff --git a/debian/postrm b/debian/postrm index 66a9926..a548ec9 100644 --- a/debian/postrm +++ b/debian/postrm @@ -1,7 +1,7 @@ #!/bin/sh NAME=applesmc -VERSION=0.14.4 +VERSION=0.15.1 set -e diff --git a/debian/prerm b/debian/prerm index bdeaad0..3207094 100644 --- a/debian/prerm +++ b/debian/prerm @@ -1,7 +1,7 @@ #!/bin/sh NAME=applesmc -VERSION=0.14.4 +VERSION=0.15.1 set -e diff --git a/debian/rules b/debian/rules index d804964..048bc63 100755 --- a/debian/rules +++ b/debian/rules @@ -5,7 +5,7 @@ #export DH_VERBOSE=1 NAME=applesmc -VERSION=0.14.4 +VERSION=0.15.1 configure: configure-stamp configure-stamp: diff --git a/usr/src/dkms_source_tree/applesmc.c b/usr/src/dkms_source_tree/applesmc.c index b007023..0f28d91 100644 --- a/usr/src/dkms_source_tree/applesmc.c +++ b/usr/src/dkms_source_tree/applesmc.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -142,6 +142,12 @@ static const char *temperature_sensors_sets[][41] = { "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S", "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S", NULL }, +/* Set 17: iMac 9,1 */ + { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TH0P", "TL0P", + "TN0D", "TN0H", "TN0P", "TO0P", "Tm0P", "Tp0P", NULL }, +/* Set 18: MacBook Pro 2,2 */ + { "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "TM0P", "TTF0", + "Th0H", "Th1H", "Tm0P", "Ts0P", NULL }, }; /* List of keys used to read/write fan speeds */ @@ -178,6 +184,8 @@ static const int debug; static struct platform_device *pdev; static s16 rest_x; static s16 rest_y; +static u8 backlight_state[2]; + static struct device *hwmon_dev; static struct input_polled_dev *applesmc_idev; @@ -497,17 +505,36 @@ static int applesmc_probe(struct platform_device *dev) return 0; } -static int applesmc_resume(struct platform_device *dev) +/* Synchronize device with memorized backlight state */ +static int applesmc_pm_resume(struct device *dev) { - return applesmc_device_init(); + mutex_lock(&applesmc_lock); + if (applesmc_light) + applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2); + mutex_unlock(&applesmc_lock); + return 0; } +/* Reinitialize device on resume from hibernation */ +static int applesmc_pm_restore(struct device *dev) +{ + int ret = applesmc_device_init(); + if (ret) + return ret; + return applesmc_pm_resume(dev); +} + +static const struct dev_pm_ops applesmc_pm_ops = { + .resume = applesmc_pm_resume, + .restore = applesmc_pm_restore, +}; + static struct platform_driver applesmc_driver = { .probe = applesmc_probe, - .resume = applesmc_resume, .driver = { .name = "applesmc", .owner = THIS_MODULE, + .pm = &applesmc_pm_ops, }, }; @@ -591,7 +618,7 @@ static ssize_t applesmc_light_show(struct device *dev, ret = applesmc_get_key_type(LIGHT_SENSOR_LEFT_KEY, query); if (ret) goto out; - data_length = query[0]; + data_length = clamp_val(query[0], 0, 10); printk(KERN_INFO "applesmc: light sensor data length set to " "%d\n", data_length); } @@ -804,17 +831,10 @@ static ssize_t applesmc_calibrate_store(struct device *dev, return count; } -/* Store the next backlight value to be written by the work */ -static unsigned int backlight_value; - static void applesmc_backlight_set(struct work_struct *work) { - u8 buffer[2]; - mutex_lock(&applesmc_lock); - buffer[0] = backlight_value; - buffer[1] = 0x00; - applesmc_write_key(BACKLIGHT_KEY, buffer, 2); + applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2); mutex_unlock(&applesmc_lock); } static DECLARE_WORK(backlight_work, &applesmc_backlight_set); @@ -824,7 +844,7 @@ static void applesmc_brightness_set(struct led_classdev *led_cdev, { int ret; - backlight_value = value; + backlight_state[0] = value; ret = queue_work(applesmc_led_wq, &backlight_work); if (debug && (!ret)) @@ -1336,6 +1356,10 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = { { .accelerometer = 1, .light = 1, .temperature_set = 15 }, /* MacPro3,1: temperature set 16 */ { .accelerometer = 0, .light = 0, .temperature_set = 16 }, +/* iMac 9,1: light sensor only, temperature set 17 */ + { .accelerometer = 0, .light = 0, .temperature_set = 17 }, +/* MacBook Pro 2,2: accelerometer, backlight and temperature set 18 */ + { .accelerometer = 1, .light = 1, .temperature_set = 18 }, }; /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". @@ -1361,6 +1385,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3") }, &applesmc_dmi_data[9]}, + { applesmc_dmi_match, "Apple MacBook Pro 2,2", { + DMI_MATCH(DMI_BOARD_VENDOR, "Apple Computer, Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2") }, + &applesmc_dmi_data[18]}, { applesmc_dmi_match, "Apple MacBook Pro", { DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") }, @@ -1401,6 +1429,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, &applesmc_dmi_data[4]}, + { applesmc_dmi_match, "Apple iMac 9,1", { + DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "iMac9,1") }, + &applesmc_dmi_data[17]}, { applesmc_dmi_match, "Apple iMac 8", { DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") }, @@ -1607,3 +1639,4 @@ module_exit(applesmc_exit); MODULE_AUTHOR("Nicolas Boichat"); MODULE_DESCRIPTION("Apple SMC"); MODULE_LICENSE("GPL v2"); +MODULE_DEVICE_TABLE(dmi, applesmc_whitelist); diff --git a/usr/src/dkms_source_tree/dkms.conf b/usr/src/dkms_source_tree/dkms.conf index acdcd2b..7f37bde 100644 --- a/usr/src/dkms_source_tree/dkms.conf +++ b/usr/src/dkms_source_tree/dkms.conf @@ -1,5 +1,5 @@ NAME=applesmc -VERSION=0.14.4 +VERSION=0.15.1 PACKAGE_NAME="$NAME" PACKAGE_VERSION="$VERSION" MAKE[0]="make -C ${kernel_source_dir} -- cgit v1.2.3