Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- techmik@techmik-acer ~/android/system/kernel/samsung/aries $ git diff led
- diff --git a/arch/arm/configs/aries_captivatemtd_defconfig b/arch/arm/configs/ar
- index d457f3b..6625461 100644
- --- a/arch/arm/configs/aries_captivatemtd_defconfig
- +++ b/arch/arm/configs/aries_captivatemtd_defconfig
- @@ -1117,7 +1117,6 @@ CONFIG_KEYBOARD_ATKBD=y
- # CONFIG_KEYBOARD_XTKBD is not set
- CONFIG_KEYPAD_CYPRESS_TOUCH=y
- CONFIG_KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE=y
- -CONFIG_KEYPAD_CYPRESS_TOUCH_BLN=y
- # CONFIG_INPUT_MOUSE is not set
- # CONFIG_INPUT_JOYSTICK is not set
- # CONFIG_INPUT_TABLET is not set
- diff --git a/arch/arm/mach-s5pv210/mach-aries.c b/arch/arm/mach-s5pv210/mach-ari
- index 6089dc4..ae8f6ca 100644
- --- a/arch/arm/mach-s5pv210/mach-aries.c
- +++ b/arch/arm/mach-s5pv210/mach-aries.c
- @@ -4461,7 +4461,7 @@ static unsigned int aries_sleep_gpio_table[][3] = {
- // GPJ3 ---------------------------------------------------
- { S5PV210_GPJ3(0), S3C_GPIO_SLP_INPUT, S3C_GPIO_PULL_DOWN}, //_3_TOU
- { S5PV210_GPJ3(1), S3C_GPIO_SLP_INPUT, S3C_GPIO_PULL_DOWN}, //_3_TOU
- - { S5PV210_GPJ3(2), S3C_GPIO_SLP_PREV, S3C_GPIO_PULL_NONE}, //_3_GPI
- + { S5PV210_GPJ3(2), S3C_GPIO_SLP_OUT0, S3C_GPIO_PULL_NONE}, //_3_GPI
- #if defined (CONFIG_SAMSUNG_CAPTIVATE)
- { S5PV210_GPJ3(3), S3C_GPIO_SLP_OUT0, S3C_GPIO_PULL_NONE}, //GPIO_G
- #else
- diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
- index 7341aba..a94790c 100644
- --- a/drivers/input/keyboard/Kconfig
- +++ b/drivers/input/keyboard/Kconfig
- @@ -441,13 +441,4 @@ config KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE
- default n
- help
- Say Y here if your device uses legacy keycodes.
- -
- -config KEYPAD_CYPRESS_TOUCH_BLN
- - bool "Cypress touch keypad: use backlight notification"
- - depends on KEYPAD_CYPRESS_TOUCH
- - default y
- - help
- - Say Y here to enable the backlighth notification
- - for android led-notification (modified liblight needed)
- -
- endif
- diff --git a/drivers/input/keyboard/cypress-touchkey.c b/drivers/input/keyboard/
- index 3ca9339..3188211 100755
- --- a/drivers/input/keyboard/cypress-touchkey.c
- +++ b/drivers/input/keyboard/cypress-touchkey.c
- @@ -1,6 +1,7 @@
- /*
- * Copyright 2006-2010, Cypress Semiconductor Corporation.
- * Copyright (C) 2010, Samsung Electronics Co. Ltd. All Rights Reserved.
- + * Copyright (C) 2011 <kang@insecure.ws>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- @@ -19,6 +20,8 @@
- *
- */
- #include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/timer.h>
- #include <linux/init.h>
- #include <linux/i2c.h>
- #include <linux/slab.h>
- @@ -26,6 +29,7 @@
- #include <linux/delay.h>
- #include <linux/input.h>
- #include <linux/earlysuspend.h>
- +#include <linux/miscdevice.h>
- #include <linux/input/cypress-touchkey.h>
- #define SCANCODE_MASK 0x07
- @@ -38,17 +42,15 @@
- #define OLD_BACKLIGHT_ON 0x1
- #define OLD_BACKLIGHT_OFF 0x2
- -#define DEVICE_NAME "cypress-touchkey"
- +#define BACKLIGHT_TIMEOUT 1600
- -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
- -#include <linux/miscdevice.h>
- -#define BACKLIGHTNOTIFICATION_VERSION 8
- +#define DEVICE_NAME "cypress-touchkey"
- -bool bln_enabled = false; // indicates if BLN function is enabled/allowed (defa
- -bool bln_notification_ongoing= false; // indicates ongoing LED Notification
- -bool bln_blink_enabled = false; // indicates blink is set
- -struct cypress_touchkey_devdata *bln_devdata; // keep a reference to the devdat
- -#endif
- +int bl_on = 0;
- +struct cypress_touchkey_devdata *bl_devdata;
- +static struct timer_list bl_timer;
- +static void bl_off(struct work_struct *bl_off_work);
- +static DECLARE_WORK(bl_off_work, bl_off);
- struct cypress_touchkey_devdata {
- struct i2c_client *client;
- @@ -60,6 +62,7 @@ struct cypress_touchkey_devdata {
- bool is_dead;
- bool is_powering_on;
- bool has_legacy_keycode;
- + bool is_sleeping;
- };
- static int i2c_touchkey_read_byte(struct cypress_touchkey_devdata *devdata,
- @@ -90,7 +93,6 @@ static int i2c_touchkey_write_byte(struct cypress_touchkey_dev
- {
- int ret;
- int retry = 2;
- - unsigned long flags;
- while (true) {
- ret = i2c_smbus_write_byte(devdata->client, val);
- @@ -118,6 +120,24 @@ static void all_keys_up(struct cypress_touchkey_devdata *de
- input_sync(devdata->input_dev);
- }
- +static void bl_off(struct work_struct *bl_off_work)
- +{
- + if (bl_devdata == NULL || unlikely(bl_devdata->is_dead) ||
- + bl_devdata->is_powering_on || bl_on || bl_devdata->is_sleeping)
- + return;
- +
- + if (bl_devdata == NULL || unlikely(bl_devdata->is_dead) ||
- + bl_devdata->is_powering_on || bl_devdata->is_sleeping)
- + return;
- +
- + i2c_touchkey_write_byte(bl_devdata, bl_devdata->backlight_off);
- +}
- +
- +void bl_timer_callback(unsigned long data)
- +{
- + schedule_work(&bl_off_work);
- +}
- +
- static int recovery_routine(struct cypress_touchkey_devdata *devdata)
- {
- int ret = -1;
- @@ -141,7 +161,8 @@ static int recovery_routine(struct cypress_touchkey_devdata
- devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
- ret = i2c_touchkey_read_byte(devdata, &data);
- if (!ret) {
- - enable_irq(irq_eint);
- + if (!devdata->is_sleeping)
- + enable_irq(irq_eint);
- goto out;
- }
- dev_err(&devdata->client->dev, "%s: i2c transfer error retry = "
- @@ -155,6 +176,9 @@ out:
- return ret;
- }
- +// Accidental touch key prevention (see mxt224.c)
- +extern unsigned int touch_state_val;
- +
- static irqreturn_t touchkey_interrupt_thread(int irq, void *touchkey_devdata)
- {
- u8 data;
- @@ -180,9 +204,15 @@ static irqreturn_t touchkey_interrupt_thread(int irq, void
- "range\n", __func__);
- goto err;
- }
- - input_report_key(devdata->input_dev,
- - devdata->pdata->keycode[scancode],
- - !(data & UPDOWN_EVENT_MASK));
- +
- + /* Don't send down event while the touch screen is being pressed
- + * to prevent accidental touch key hit.
- + */
- + if ((data & UPDOWN_EVENT_MASK) || !touch_state_val) {
- + input_report_key(devdata->input_dev,
- + devdata->pdata->keycode[scancode],
- + !(data & UPDOWN_EVENT_MASK));
- + }
- } else {
- for (i = 0; i < devdata->pdata->keycode_cnt; i++)
- input_report_key(devdata->input_dev,
- @@ -191,6 +221,7 @@ static irqreturn_t touchkey_interrupt_thread(int irq, void *
- }
- input_sync(devdata->input_dev);
- + mod_timer(&bl_timer, jiffies + msecs_to_jiffies(BACKLIGHT_TIMEOUT));
- err:
- return IRQ_HANDLED;
- }
- @@ -200,12 +231,44 @@ static irqreturn_t touchkey_interrupt_handler(int irq, voi
- struct cypress_touchkey_devdata *devdata = touchkey_devdata;
- if (devdata->is_powering_on) {
- + dev_dbg(&devdata->client->dev, "%s: ignoring spurious boot "
- + "interrupt\n", __func__);
- return IRQ_HANDLED;
- }
- return IRQ_WAKE_THREAD;
- }
- +static void notify_led_on(void) {
- + unsigned long flags;
- + if (unlikely(bl_devdata->is_dead))
- + return;
- +
- + if (bl_devdata->is_sleeping) {
- + bl_devdata->pdata->touchkey_sleep_onoff(TOUCHKEY_ON);
- + bl_devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
- + }
- + i2c_touchkey_write_byte(bl_devdata, bl_devdata->backlight_on);
- + bl_on = 1;
- + printk(KERN_DEBUG "%s: notification led enabled\n", __FUNCTION__);
- +}
- +
- +static void notify_led_off(void) {
- + unsigned long flags;
- + if (unlikely(bl_devdata->is_dead))
- + return;
- +
- + if (bl_on)
- + i2c_touchkey_write_byte(bl_devdata, bl_devdata->backlight_off);
- +
- + bl_devdata->pdata->touchkey_sleep_onoff(TOUCHKEY_OFF);
- + if (bl_devdata->is_sleeping)
- + bl_devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
- +
- + bl_on = 0;
- + printk(KERN_DEBUG "%s: notification led disabled\n", __FUNCTION__);
- +}
- +
- #ifdef CONFIG_HAS_EARLYSUSPEND
- static void cypress_touchkey_early_suspend(struct early_suspend *h)
- {
- @@ -218,17 +281,12 @@ static void cypress_touchkey_early_suspend(struct early_su
- return;
- disable_irq(devdata->client->irq);
- -
- -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
- - /*
- - * Disallow powering off the touchkey controller
- - * while a led notification is ongoing
- - */
- - if(!bln_notification_ongoing)
- -#endif
- devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
- -
- all_keys_up(devdata);
- + devdata->is_sleeping = true;
- +
- + if (bl_on)
- + notify_led_on();
- }
- static void cypress_touchkey_early_resume(struct early_suspend *h)
- @@ -237,6 +295,7 @@ static void cypress_touchkey_early_resume(struct early_suspe
- container_of(h, struct cypress_touchkey_devdata, early_suspend);
- devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
- +
- if (i2c_touchkey_write_byte(devdata, devdata->backlight_on)) {
- devdata->is_dead = true;
- devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
- @@ -247,179 +306,43 @@ static void cypress_touchkey_early_resume(struct early_su
- devdata->is_dead = false;
- enable_irq(devdata->client->irq);
- devdata->is_powering_on = false;
- + devdata->is_sleeping = false;
- + mod_timer(&bl_timer, jiffies + msecs_to_jiffies(BACKLIGHT_TIMEOUT));
- }
- #endif
- -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
- -/* bln start */
- -
- -static void enable_touchkey_backlights(void){
- - i2c_touchkey_write_byte(bln_devdata, bln_devdata->backlight_on);
- -}
- -
- -static void disable_touchkey_backlights(void){
- - i2c_touchkey_write_byte(bln_devdata, bln_devdata->backlight_off);
- +static ssize_t led_status_read(struct device *dev, struct device_attribute *att
- + return sprintf(buf,"%u\n", bl_on);
- }
- -static void enable_led_notification(void){
- - if (bln_enabled){
- - /* is_powering_on signals whether touchkey lights are used for t
- - pr_info("%s: bln interface enabled\n", __FUNCTION__); //remove m
- -
- - if (bln_devdata->is_powering_on){
- - pr_info("%s: not in touchmode\n", __FUNCTION__); //remove me
- - /* signal ongoing led notification */
- - bln_notification_ongoing = true;
- -
- - /*
- - * power on the touchkey controller
- - * This is actually not needed, but it is intentionally
- - * left for the case that the early_resume() function
- - * did not power on the touchkey controller for some rea
- - */
- - pr_info("%s: enable vdd\n", __FUNCTION__); //remove me
- - bln_devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
- -
- - /* write to i2cbus, enable backlights */
- - pr_info("%s: enable lights\n", __FUNCTION__); //remove m
- - enable_touchkey_backlights();
- -
- - pr_info("%s: notification led enabled\n", __FUNCTION__);
- - }
- - else
- - pr_info("%s: cannot set notification led, touchkeys are
- - }
- -}
- -
- -static void disable_led_notification(void){
- - pr_info("%s: notification led disabled\n", __FUNCTION__);
- -
- - /* disable the blink state */
- - bln_blink_enabled = false;
- -
- - /* if touchkeys lights are not used for touchmode */
- - if (bln_devdata->is_powering_on){
- - disable_touchkey_backlights();
- - }
- -
- - /* signal led notification is disabled */
- - bln_notification_ongoing = false;
- -}
- -
- -static ssize_t backlightnotification_status_read(struct device *dev, struct dev
- - return sprintf(buf,"%u\n",(bln_enabled ? 1 : 0));
- -}
- -static ssize_t backlightnotification_status_write(struct device *dev, struct de
- +static ssize_t led_status_write(struct device *dev, struct device_attribute *at
- {
- unsigned int data;
- - if(sscanf(buf, "%u\n", &data) == 1) {
- - pr_devel("%s: %u \n", __FUNCTION__, data);
- - if(data == 0 || data == 1){
- -
- - if(data == 1){
- - pr_info("%s: backlightnotification function enab
- - bln_enabled = true;
- - }
- -
- - if(data == 0){
- - pr_info("%s: backlightnotification function disa
- - bln_enabled = false;
- - if (bln_notification_ongoing)
- - disable_led_notification();
- - }
- - }
- +
- + if (sscanf(buf, "%u\n", &data)) {
- + if (data == 1)
- + notify_led_on();
- else
- - pr_info("%s: invalid input range %u\n", __FUNCTION__, da
- + notify_led_off();
- }
- - else
- - pr_info("%s: invalid input\n", __FUNCTION__);
- -
- return size;
- }
- -static ssize_t notification_led_status_read(struct device *dev, struct device_a
- - return sprintf(buf,"%u\n", (bln_notification_ongoing ? 1 : 0));
- -}
- -
- -static ssize_t notification_led_status_write(struct device *dev, struct device_
- -{
- - unsigned int data;
- -
- - if(sscanf(buf, "%u\n", &data) == 1) {
- - if(data == 0 || data == 1){
- - pr_devel("%s: %u \n", __FUNCTION__, data);
- - if (data == 1)
- - enable_led_notification();
- -
- - if(data == 0)
- - disable_led_notification();
- -
- - } else
- - pr_info("%s: wrong input %u\n", __FUNCTION__, data);
- - } else
- - pr_info("%s: input error\n", __FUNCTION__);
- +static DEVICE_ATTR(led, S_IRUGO | S_IWUGO , led_status_read, led_status_write);
- - return size;
- -}
- -
- -static ssize_t blink_control_read(struct device *dev, struct device_attribute *
- - return sprintf(buf,"%u\n", (bln_blink_enabled ? 1 : 0));
- -}
- -
- -static ssize_t blink_control_write(struct device *dev, struct device_attribute
- -{
- - unsigned int data;
- -
- - if(sscanf(buf, "%u\n", &data) == 1) {
- - if(data == 0 || data == 1){
- - if (bln_notification_ongoing){
- - pr_devel("%s: %u \n", __FUNCTION__, data);
- - if (data == 1){
- - bln_blink_enabled = true;
- - disable_touchkey_backlights();
- - }
- -
- - if(data == 0){
- - bln_blink_enabled = false;
- - enable_touchkey_backlights();
- - }
- - }
- -
- - } else
- - pr_info("%s: wrong input %u\n", __FUNCTION__, data);
- - } else
- - pr_info("%s: input error\n", __FUNCTION__);
- -
- - return size;
- -}
- -
- -static ssize_t backlightnotification_version(struct device *dev, struct device_
- - return sprintf(buf, "%u\n", BACKLIGHTNOTIFICATION_VERSION);
- -}
- -
- -static DEVICE_ATTR(blink_control, S_IRUGO | S_IWUGO , blink_control_read, blink
- -static DEVICE_ATTR(enabled, S_IRUGO | S_IWUGO , backlightnotification_status_re
- -static DEVICE_ATTR(notification_led, S_IRUGO | S_IWUGO , notification_led_statu
- -static DEVICE_ATTR(version, S_IRUGO , backlightnotification_version, NULL);
- -
- -static struct attribute *bln_interface_attributes[] = {
- - &dev_attr_blink_control.attr,
- - &dev_attr_enabled.attr,
- - &dev_attr_notification_led.attr,
- - &dev_attr_version.attr,
- +static struct attribute *bl_led_attributes[] = {
- + &dev_attr_led.attr,
- NULL
- };
- -static struct attribute_group bln_interface_attributes_group = {
- - .attrs = bln_interface_attributes,
- +static struct attribute_group bl_led_group = {
- + .attrs = bl_led_attributes,
- };
- -static struct miscdevice backlightnotification_device = {
- +static struct miscdevice bl_led_device = {
- .minor = MISC_DYNAMIC_MINOR,
- - .name = "backlightnotification",
- + .name = "notification",
- };
- -/* bln end */
- -#endif
- static int cypress_touchkey_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
- @@ -474,10 +397,12 @@ static int cypress_touchkey_probe(struct i2c_client *clien
- goto err_input_reg_dev;
- devdata->is_powering_on = true;
- + devdata->is_sleeping = false;
- devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
- err = i2c_master_recv(client, data, sizeof(data));
- +
- if (err < sizeof(data)) {
- if (err >= 0)
- err = -EIO;
- @@ -487,8 +412,17 @@ static int cypress_touchkey_probe(struct i2c_client *client
- dev_info(dev, "%s: hardware rev1 = %#02x, rev2 = %#02x\n", __func__,
- data[1], data[2]);
- +
- +#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE
- + devdata->has_legacy_keycode = true;
- +#else
- + devdata->has_legacy_keycode = data[1] >= 0xc4 || data[1] < 0x9 ||
- + (data[1] == 0x9 && data[2] < 0x9);
- +#endif
- +
- if (data[1] < 0xc4 && (data[1] >= 0x8 ||
- - (data[1] == 0x8 && data[2] >= 0x9))) {
- + (data[1] == 0x8 && data[2] >= 0x9)) &&
- + devdata->has_legacy_keycode == false) {
- devdata->backlight_on = BACKLIGHT_ON;
- devdata->backlight_off = BACKLIGHT_OFF;
- } else {
- @@ -496,24 +430,19 @@ static int cypress_touchkey_probe(struct i2c_client *clien
- devdata->backlight_off = OLD_BACKLIGHT_OFF;
- }
- -
- -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_HAS_LEGACY_KEYCODE
- - devdata->has_legacy_keycode = true;
- -#else
- - devdata->has_legacy_keycode = data[1] >= 0xc4 || data[1] < 0x9 ||
- - (data[1] == 0x9 && data[2] < 0x9);
- -#endif
- -
- - err = i2c_touchkey_write_byte(devdata, devdata->backlight_on);
- + err = i2c_touchkey_write_byte(devdata, devdata->backlight_off);
- if (err) {
- dev_err(dev, "%s: touch keypad backlight on failed\n",
- __func__);
- - goto err_backlight_on;
- + /* The device may not be responding because of bad firmware
- + */
- + goto err_backlight_off;
- }
- - if (request_threaded_irq(client->irq, touchkey_interrupt_handler,
- + err = request_threaded_irq(client->irq, touchkey_interrupt_handler,
- touchkey_interrupt_thread, IRQF_TRIGGER_FALLING,
- - DEVICE_NAME, devdata)) {
- + DEVICE_NAME, devdata);
- + if (err) {
- dev_err(dev, "%s: Can't allocate irq.\n", __func__);
- goto err_req_irq;
- }
- @@ -526,37 +455,28 @@ static int cypress_touchkey_probe(struct i2c_client *clien
- devdata->is_powering_on = false;
- -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
- - pr_info("%s misc_register(%s)\n", __FUNCTION__, backlightnotification_de
- - err = misc_register(&backlightnotification_device);
- - if (err) {
- - pr_err("%s misc_register(%s) fail\n", __FUNCTION__, backlightnot
- - }else {
- - /*
- - * keep a reference to the devdata,
- - * misc driver does not give access to it (or i missed that som
- - */
- - bln_devdata = devdata;
- -
- - /* add the backlightnotification attributes */
- - if (sysfs_create_group(&backlightnotification_device.this_device
- - {
- - pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
- - pr_err("Failed to create sysfs group for device (%s)!\n"
- - }
- + if (misc_register(&bl_led_device))
- + printk("%s misc_register(%s) failed\n", __FUNCTION__, bl_led_dev
- + else {
- + if (sysfs_create_group(&bl_led_device.this_device->kobj, &bl_led
- + pr_err("failed to create sysfs group for device %s\n", b
- }
- -#endif
- +
- + bl_devdata = devdata;
- + setup_timer(&bl_timer, bl_timer_callback, 0);
- return 0;
- err_req_irq:
- -err_backlight_on:
- -err_read:
- - devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
- +err_backlight_off:
- input_unregister_device(input_dev);
- - goto err_input_alloc_dev;
- + goto touchkey_off;
- err_input_reg_dev:
- +err_read:
- input_free_device(input_dev);
- +touchkey_off:
- + devdata->is_powering_on = false;
- + devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
- err_input_alloc_dev:
- err_null_keycodes:
- kfree(devdata);
- @@ -567,20 +487,21 @@ static int __devexit i2c_touchkey_remove(struct i2c_client
- {
- struct cypress_touchkey_devdata *devdata = i2c_get_clientdata(client);
- -#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_BLN
- - misc_deregister(&backlightnotification_device);
- -#endif
- -
- dev_err(&client->dev, "%s: i2c_touchkey_remove\n", __func__);
- +
- + misc_deregister(&bl_led_device);
- unregister_early_suspend(&devdata->early_suspend);
- /* If the device is dead IRQs are disabled, we need to rebalance them */
- if (unlikely(devdata->is_dead))
- enable_irq(client->irq);
- - else
- + else {
- devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
- + devdata->is_powering_on = false;
- + }
- free_irq(client->irq, devdata);
- all_keys_up(devdata);
- input_unregister_device(devdata->input_dev);
- + del_timer(&bl_timer);
- kfree(devdata);
- return 0;
- }
- @@ -623,4 +544,3 @@ module_exit(touchkey_exit);
- MODULE_LICENSE("GPL");
- MODULE_AUTHOR("@@@");
- MODULE_DESCRIPTION("cypress touch keypad");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement