Revision: 103 http://svn.sourceforge.net/mactel-linux/?rev=103&view=rev Author: nboichat Date: 2007-04-09 09:57:54 -0700 (Mon, 09 Apr 2007)
Log Message: ----------- Update AppleSMC: - Various input dev fixes. - Allow setting accelerometer interrupt parameters. Modified Paths: -------------- trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch Modified: trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch =================================================================== --- trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch 2007-04-09 10:54:35 UTC (rev 102) +++ trunk/kernel/mactel-patches-2.6.21/0009-applesmc_joydev.patch 2007-04-09 16:57:54 UTC (rev 103) @@ -1,26 +1,42 @@ -Fix y axis on applesmc input device. +- Invert y axis on input device. - Only activate the input device polling timer when the device is open. - Others fixes as asked by Dmitry Torokhov. From: Nicolas Boichat <[EMAIL PROTECTED]> --- - drivers/hwmon/applesmc.c | 2 ++ - 1 files changed, 2 insertions(+), 0 deletions(-) + drivers/hwmon/applesmc.c | 29 +++++++++++++++++++++++++---- + 1 files changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c -index 4060667..581ed3e 100644 +index 4060667..f7b59fc 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c -@@ -349,6 +349,7 @@ static void applesmc_calibrate(void) +@@ -349,9 +349,22 @@ static void applesmc_calibrate(void) { applesmc_read_motion_sensor(SENSOR_X, &rest_x); applesmc_read_motion_sensor(SENSOR_Y, &rest_y); + rest_x = -rest_x; } - static void applesmc_mousedev_poll(unsigned long unused) -@@ -366,6 +367,7 @@ static void applesmc_mousedev_poll(unsigned long unused) +-static void applesmc_mousedev_poll(unsigned long unused) ++static int applesmc_idev_open(struct input_dev *dev) ++{ ++ add_timer(&applesmc_timer); ++ ++ return 0; ++} ++ ++static void applesmc_idev_close(struct input_dev *dev) ++{ ++ del_timer_sync(&applesmc_timer); ++} ++ ++static void applesmc_idev_poll(unsigned long unused) + { + s16 x, y; + +@@ -366,6 +379,7 @@ static void applesmc_mousedev_poll(unsigned long unused) if (applesmc_read_motion_sensor(SENSOR_Y, &y)) goto out; @@ -28,3 +44,37 @@ input_report_abs(applesmc_idev, ABS_X, x - rest_x); input_report_abs(applesmc_idev, ABS_Y, y - rest_y); input_sync(applesmc_idev); +@@ -739,23 +753,30 @@ static int applesmc_create_accelerometer(void) + + /* initialize the input class */ + applesmc_idev->name = "applesmc"; ++ applesmc_idev->id.bustype = BUS_HOST; + applesmc_idev->cdev.dev = &pdev->dev; + applesmc_idev->evbit[0] = BIT(EV_ABS); ++ applesmc_idev->open = applesmc_idev_open; ++ applesmc_idev->close = applesmc_idev_close; + input_set_abs_params(applesmc_idev, ABS_X, + -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); + input_set_abs_params(applesmc_idev, ABS_Y, + -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); + +- input_register_device(applesmc_idev); ++ ret = input_register_device(applesmc_idev); ++ if (ret) ++ goto out_idev; + + /* start up our timer for the input device */ + init_timer(&applesmc_timer); +- applesmc_timer.function = applesmc_mousedev_poll; ++ applesmc_timer.function = applesmc_idev_poll; + applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD; +- add_timer(&applesmc_timer); + + return 0; + ++out_idev: ++ input_free_device(applesmc_idev); ++ + out: + printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret); + return ret; Modified: trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch =================================================================== --- trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch 2007-04-09 10:54:35 UTC (rev 102) +++ trunk/kernel/mactel-patches-2.6.21/0011-applesmc2.patch 2007-04-09 16:57:54 UTC (rev 103) @@ -5,11 +5,11 @@ --- - drivers/hwmon/applesmc.c | 471 ++++++++++++++++++++++++++++++++++++++++------ - 1 files changed, 410 insertions(+), 61 deletions(-) + drivers/hwmon/applesmc.c | 606 +++++++++++++++++++++++++++++++++++++++++----- + 1 files changed, 540 insertions(+), 66 deletions(-) diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c -index 581ed3e..c68391d 100644 +index f7b59fc..7c368a3 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c @@ -37,40 +37,71 @@ @@ -56,22 +56,18 @@ +#define BACKLIGHT_KEY "LKSB" /* w-o length 2 */ + +#define CLAMSHELL_KEY "MSLD" /* r-o ui8 (unused) */ -+ + +-#define CLAMSHELL_KEY "MSLD" /* r-o length 1 (unused) */ +#define MOTION_SENSOR_X_KEY "MO_X" /* r-o sp78 (2 bytes) */ +#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o sp78 (2 bytes) */ +#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o sp78 (2 bytes) */ +#define MOTION_SENSOR_KEY "MOCN" /* r/w ui16 */ - --#define CLAMSHELL_KEY "MSLD" /* r-o length 1 (unused) */ ++ +/* Interrupt controls. */ +/* Don't know what these parameters control. */ +#define MOTION_SENSOR_PARAM_1L "MOLD" /* r/w ui8 */ +#define MOTION_SENSOR_PARAM_1H "MOHD" /* r/w ui8 */ - --#define MOTION_SENSOR_X_KEY "MO_X" /* r-o length 2 */ --#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o length 2 */ --#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o length 2 */ --#define MOTION_SENSOR_KEY "MOCN" /* r/w length 2 */ ++ +/* + * If the norm of the position (sqrt(MO_X^2+MO_Y^2+MO_Z^2)) is smaller than + * MOLT (free fall), or bigger than MOHT (high acceleration), SMC will trigger @@ -79,7 +75,11 @@ + */ +#define MOTION_MIN_NORM "MOLT" /* r/w sp78 (2 bytes) */ +#define MOTION_MAX_NORM "MOHT" /* r/w sp78 (2 bytes) */ -+ + +-#define MOTION_SENSOR_X_KEY "MO_X" /* r-o length 2 */ +-#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o length 2 */ +-#define MOTION_SENSOR_Z_KEY "MO_Z" /* r-o length 2 */ +-#define MOTION_SENSOR_KEY "MOCN" /* r/w length 2 */ +#define MSDW_KEY "MSDW" /* r/w flag (1 byte) */ -#define FANS_COUNT "FNum" /* r-o length 1 */ @@ -126,7 +126,7 @@ + if (len > APPLESMC_MAX_DATA_LENGTH) { + printk(KERN_ERR "applesmc_read_key: cannot read more than " -+ APPLESMC_MAX_DATA_LENGTH " bytes"); ++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH); + return -EINVAL; + } + @@ -173,7 +173,7 @@ + if (len > APPLESMC_MAX_DATA_LENGTH) { + printk(KERN_ERR "applesmc_write_key: cannot write more than " -+ APPLESMC_MAX_DATA_LENGTH " bytes"); ++ "%d bytes\n", APPLESMC_MAX_DATA_LENGTH); + return -EINVAL; + } + @@ -290,8 +290,8 @@ + + if (len > APPLESMC_MAX_DATA_LENGTH) { + printk(KERN_ERR "applesmc_init_check_key_value: cannot " -+ "read/write more than " -+ APPLESMC_MAX_DATA_LENGTH " bytes"); ++ "read/write more than %d bytes", ++ APPLESMC_MAX_DATA_LENGTH); + return -EINVAL; + } + @@ -436,16 +436,16 @@ + printk(KERN_WARNING "applesmc: failed to init " + "the accelerometer\n"); + goto out; - } - -- printk(KERN_WARNING "applesmc: failed to init the device\n"); ++ } ++ + ret1 = request_irq(APPLESMC_IRQ, applesmc_irq_handler, IRQF_DISABLED, + "applesmc_irq_handler", NULL); + + if (ret1) { + printk(KERN_WARNING "applesmc: cannot setup irq handler\n"); -+ } -+ + } + +- printk(KERN_WARNING "applesmc: failed to init the device\n"); + printk(KERN_DEBUG "applesmc: accelerometer " + "successfully initialized.\n"); + ret = 0; @@ -469,7 +469,7 @@ .driver = { .name = "applesmc", .owner = THIS_MODULE, -@@ -575,6 +799,33 @@ out: +@@ -587,6 +811,33 @@ out: return count; } @@ -503,7 +503,7 @@ static ssize_t applesmc_calibrate_show(struct device *dev, struct device_attribute *attr, char *sysfsbuf) { -@@ -591,6 +842,77 @@ static ssize_t applesmc_calibrate_store(struct device *dev, +@@ -603,6 +854,26 @@ static ssize_t applesmc_calibrate_store(struct device *dev, return count; } @@ -527,6 +527,13 @@ + return sprintf(sysfsbuf, "%d\n", count); +} + + static void applesmc_backlight_set(struct led_classdev *led_cdev, + enum led_brightness value) + { +@@ -615,6 +886,168 @@ static void applesmc_backlight_set(struct led_classdev *led_cdev, + mutex_unlock(&applesmc_lock); + } + +static ssize_t applesmc_key_at_index_show(struct device *dev, + struct device_attribute *attr, char *sysfsbuf) +{ @@ -578,20 +585,151 @@ + return count; +} + - static void applesmc_backlight_set(struct led_classdev *led_cdev, - enum led_brightness value) - { -@@ -615,6 +937,9 @@ static DEVICE_ATTR(calibrate, 0644, ++static ssize_t applesmc_param_show(char* key, int length, char *sysfsbuf) ++{ ++ int ret; ++ unsigned int value = 0; ++ u8 buffer[2]; ++ ++ mutex_lock(&applesmc_lock); ++ ++ ret = applesmc_read_key(key, buffer, length); ++ if (length == 2) { ++ value = ((unsigned int)buffer[0] << 8) | buffer[1]; ++ } ++ else if (length == 1) { ++ value = buffer[0]; ++ } ++ else { ++ printk("Invalid length for applesmc_param_show"); ++ ret = -EINVAL; ++ } ++ ++ mutex_unlock(&applesmc_lock); ++ if (ret) ++ return ret; ++ else ++ return sprintf(sysfsbuf, "%u\n", value); ++} ++ ++static ssize_t applesmc_param_store(char* key, int length, ++ const char *sysfsbuf, size_t count) ++{ ++ int ret; ++ u32 value; ++ u8 buffer[2]; ++ ++ value = simple_strtoul(sysfsbuf, NULL, 10); ++ ++ if (length == 2) { ++ if (value > 0xffff) ++ return -EINVAL; ++ ++ buffer[0] = (value >> 8) & 0xff; ++ buffer[1] = value & 0xff; ++ } else if (length == 1) { ++ if (value > 0xff) ++ return -EINVAL; ++ ++ buffer[0] = value & 0xff; ++ } else { ++ printk("Invalid length for applesmc_param_store"); ++ return -EINVAL; ++ } ++ ++ mutex_lock(&applesmc_lock); ++ ++ ret = applesmc_write_key(key, buffer, 2); ++ ++ mutex_unlock(&applesmc_lock); ++ if (ret) ++ return ret; ++ else ++ return count; ++} ++ ++static ssize_t applesmc_param_1_min_show(struct device *dev, ++ struct device_attribute *attr, char *sysfsbuf) ++{ ++ return applesmc_param_show(MOTION_SENSOR_PARAM_1L, 1, sysfsbuf); ++} ++ ++static ssize_t applesmc_param_1_max_show(struct device *dev, ++ struct device_attribute *attr, char *sysfsbuf) ++{ ++ return applesmc_param_show(MOTION_SENSOR_PARAM_1H, 1, sysfsbuf); ++} ++ ++static ssize_t applesmc_norm_min_show(struct device *dev, ++ struct device_attribute *attr, char *sysfsbuf) ++{ ++ return applesmc_param_show(MOTION_MIN_NORM, 2, sysfsbuf); ++} ++ ++static ssize_t applesmc_norm_max_show(struct device *dev, ++ struct device_attribute *attr, char *sysfsbuf) ++{ ++ return applesmc_param_show(MOTION_MAX_NORM, 2, sysfsbuf); ++} ++ ++static ssize_t applesmc_param_1_min_store(struct device *dev, ++ struct device_attribute *attr, const char *sysfsbuf, size_t count) ++{ ++ return applesmc_param_store(MOTION_SENSOR_PARAM_1L, 1, sysfsbuf, count); ++} ++ ++static ssize_t applesmc_param_1_max_store(struct device *dev, ++ struct device_attribute *attr, const char *sysfsbuf, size_t count) ++{ ++ return applesmc_param_store(MOTION_SENSOR_PARAM_1H, 1, sysfsbuf, count); ++} ++ ++static ssize_t applesmc_norm_min_store(struct device *dev, ++ struct device_attribute *attr, const char *sysfsbuf, size_t count) ++{ ++ return applesmc_param_store(MOTION_MIN_NORM, 2, sysfsbuf, count); ++} ++ ++static ssize_t applesmc_norm_max_store(struct device *dev, ++ struct device_attribute *attr, const char *sysfsbuf, size_t count) ++{ ++ return applesmc_param_store(MOTION_MAX_NORM, 2, sysfsbuf, count); ++} ++ + static struct led_classdev applesmc_backlight = { + .name = "smc:kbd_backlight", + .default_trigger = "nand-disk", +@@ -624,9 +1057,29 @@ static struct led_classdev applesmc_backlight = { + static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL); + static DEVICE_ATTR(calibrate, 0644, + applesmc_calibrate_show, applesmc_calibrate_store); ++static DEVICE_ATTR(param_1_min, 0644, applesmc_param_1_min_show, applesmc_param_1_min_store); ++static DEVICE_ATTR(param_1_max, 0644, applesmc_param_1_max_show, applesmc_param_1_max_store); ++static DEVICE_ATTR(norm_min, 0644, applesmc_norm_min_show, applesmc_norm_min_store); ++static DEVICE_ATTR(norm_max, 0644, applesmc_norm_max_show, applesmc_norm_max_store); static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL); +static DEVICE_ATTR(key_count, 0444, applesmc_key_count_show, NULL); +static DEVICE_ATTR(key_at_index, 0600, applesmc_key_at_index_show, applesmc_key_at_index_store); + ++static struct attribute *accelerometer_attributes[] = { ++ &dev_attr_position.attr, ++ &dev_attr_calibrate.attr, ++ &dev_attr_param_1_min.attr, ++ &dev_attr_param_1_max.attr, ++ &dev_attr_norm_min.attr, ++ &dev_attr_norm_max.attr, ++ NULL ++}; ++ ++static const struct attribute_group accelerometer_attributes_group = ++ { .attrs = accelerometer_attributes }; ++ /* * Macro defining SENSOR_DEVICE_ATTR for a fan sysfs entries. * - show actual speed -@@ -643,6 +968,9 @@ static SENSOR_DEVICE_ATTR_2(fan##offset##_target_speed, S_IRUGO | S_IWUSR, \ +@@ -655,6 +1108,9 @@ static SENSOR_DEVICE_ATTR_2(fan##offset##_target_speed, S_IRUGO | S_IWUSR, \ static SENSOR_DEVICE_ATTR(fan##offset##_manual, S_IRUGO | S_IWUSR, \ applesmc_show_fan_manual, applesmc_store_fan_manual, offset); \ \ @@ -601,7 +739,7 @@ static struct attribute *fan##offset##_attributes[] = { \ &sensor_dev_attr_fan##offset##_actual_speed.dev_attr.attr, \ &sensor_dev_attr_fan##offset##_minimum_speed.dev_attr.attr, \ -@@ -650,6 +978,7 @@ static struct attribute *fan##offset##_attributes[] = { \ +@@ -662,6 +1118,7 @@ static struct attribute *fan##offset##_attributes[] = { \ &sensor_dev_attr_fan##offset##_safe_speed.dev_attr.attr, \ &sensor_dev_attr_fan##offset##_target_speed.dev_attr.attr, \ &sensor_dev_attr_fan##offset##_manual.dev_attr.attr, \ @@ -609,7 +747,7 @@ NULL \ }; -@@ -682,6 +1011,16 @@ static SENSOR_DEVICE_ATTR(temperature_5, S_IRUGO, +@@ -694,6 +1151,16 @@ static SENSOR_DEVICE_ATTR(temperature_5, S_IRUGO, applesmc_show_temperature, NULL, 5); static SENSOR_DEVICE_ATTR(temperature_6, S_IRUGO, applesmc_show_temperature, NULL, 6); @@ -626,7 +764,7 @@ static struct attribute *temperature_attributes[] = { &sensor_dev_attr_temperature_0.dev_attr.attr, -@@ -691,6 +1030,11 @@ static struct attribute *temperature_attributes[] = { +@@ -703,6 +1170,11 @@ static struct attribute *temperature_attributes[] = { &sensor_dev_attr_temperature_4.dev_attr.attr, &sensor_dev_attr_temperature_5.dev_attr.attr, &sensor_dev_attr_temperature_6.dev_attr.attr, @@ -638,7 +776,21 @@ }; /* Module stuff */ -@@ -881,6 +1225,11 @@ static int __init applesmc_init(void) +@@ -734,11 +1206,8 @@ static int applesmc_create_accelerometer(void) + { + int ret; + +- ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_position.attr); +- if (ret) +- goto out; +- +- ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_calibrate.attr); ++ ret = sysfs_create_group(&pdev->dev.kobj, ++ &accelerometer_attributes_group); + if (ret) + goto out; + +@@ -900,6 +1369,11 @@ static int __init applesmc_init(void) goto out_accelerometer; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Mactel-linux-devel mailing list Mactel-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mactel-linux-devel