Guest User

Untitled

a guest
Dec 10th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.57 KB | None | 0 0
  1. diff --git a/drivers/input/input.c b/drivers/input/input.c
  2. index 9c79bd5..5000394 100644
  3. --- a/drivers/input/input.c
  4. +++ b/drivers/input/input.c
  5. @@ -27,6 +27,10 @@
  6. #include <linux/smp_lock.h>
  7. #include "input-compat.h"
  8.  
  9. +#ifdef CONFIG_TOUCH_WAKE
  10. +#include <linux/touch_wake.h>
  11. +#endif
  12. +
  13. MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
  14. MODULE_DESCRIPTION("Input core");
  15. MODULE_LICENSE("GPL");
  16. @@ -211,6 +215,15 @@ static void input_handle_event(struct input_dev *dev,
  17. if (is_event_supported(code, dev->keybit, KEY_MAX) &&
  18. !!test_bit(code, dev->key) != value) {
  19.  
  20. +#ifdef CONFIG_TOUCH_WAKE
  21. + if (code == KEY_POWER && value == 1)
  22. + {
  23. + pr_info("KEY_POWER pressed\n");
  24. +
  25. + powerkey_press();
  26. + }
  27. +#endif
  28. +
  29. if (value != 2) {
  30. __change_bit(code, dev->key);
  31. if (value)
  32. diff --git a/drivers/input/keyboard/cypress-touchkey.c b/drivers/input/keyboard/cypress-touchkey.c
  33. index 845cb85..a969393 100644
  34. --- a/drivers/input/keyboard/cypress-touchkey.c
  35. +++ b/drivers/input/keyboard/cypress-touchkey.c
  36. @@ -35,6 +35,10 @@
  37. #include <linux/bld.h>
  38. #endif
  39.  
  40. +#ifdef CONFIG_TOUCH_WAKE
  41. +#include <linux/touch_wake.h>
  42. +#endif
  43. +
  44. #define SCANCODE_MASK 0x07
  45. #define UPDOWN_EVENT_MASK 0x08
  46. #define ESD_STATE_MASK 0x10
  47. @@ -67,6 +71,10 @@ static struct cypress_touchkey_devdata *blndevdata;
  48. static struct cypress_touchkey_devdata *blddevdata;
  49. #endif
  50.  
  51. +#ifdef CONFIG_TOUCH_WAKE
  52. +static struct cypress_touchkey_devdata *touchwakedevdata;
  53. +#endif
  54. +
  55. static int i2c_touchkey_read_byte(struct cypress_touchkey_devdata *devdata,
  56. u8 *val)
  57. {
  58. @@ -215,6 +223,12 @@ static void cypress_touchkey_early_suspend(struct early_suspend *h)
  59. struct cypress_touchkey_devdata *devdata =
  60. container_of(h, struct cypress_touchkey_devdata, early_suspend);
  61.  
  62. +#ifdef CONFIG_TOUCH_WAKE
  63. +#ifdef CONFIG_GENERIC_BLN
  64. + if(!bln_is_ongoing())
  65. +#endif
  66. + i2c_touchkey_write_byte(devdata, devdata->backlight_off);
  67. +#else
  68. devdata->is_powering_on = true;
  69.  
  70. if (unlikely(devdata->is_dead))
  71. @@ -232,6 +246,7 @@ static void cypress_touchkey_early_suspend(struct early_suspend *h)
  72. devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  73.  
  74. all_keys_up(devdata);
  75. +#endif
  76. }
  77.  
  78. static void cypress_touchkey_early_resume(struct early_suspend *h)
  79. @@ -239,6 +254,9 @@ static void cypress_touchkey_early_resume(struct early_suspend *h)
  80. struct cypress_touchkey_devdata *devdata =
  81. container_of(h, struct cypress_touchkey_devdata, early_suspend);
  82.  
  83. +#ifdef CONFIG_TOUCH_WAKE
  84. + i2c_touchkey_write_byte(devdata, devdata->backlight_on);
  85. +#else
  86. devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
  87. if (i2c_touchkey_write_byte(devdata, devdata->backlight_on)) {
  88. devdata->is_dead = true;
  89. @@ -250,7 +268,56 @@ static void cypress_touchkey_early_resume(struct early_suspend *h)
  90. devdata->is_dead = false;
  91. enable_irq(devdata->client->irq);
  92. devdata->is_powering_on = false;
  93. +#endif
  94. +}
  95. +#endif
  96. +
  97. +#ifdef CONFIG_TOUCH_WAKE
  98. +static void cypress_touchwake_disable(void)
  99. +{
  100. + touchwakedevdata->is_powering_on = true;
  101. +
  102. + if (unlikely(touchwakedevdata->is_dead))
  103. + return;
  104. +
  105. + disable_irq(touchwakedevdata->client->irq);
  106. +
  107. +#ifdef CONFIG_GENERIC_BLN
  108. + /*
  109. + * Disallow powering off the touchkey controller
  110. + * while a led notification is ongoing
  111. + */
  112. + if(!bln_is_ongoing())
  113. +#endif
  114. + touchwakedevdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  115. +
  116. + all_keys_up(touchwakedevdata);
  117. +
  118. + return;
  119. +}
  120. +
  121. +static void cypress_touchwake_enable(void)
  122. +{
  123. + touchwakedevdata->pdata->touchkey_onoff(TOUCHKEY_ON);
  124. + if (i2c_touchkey_write_byte(touchwakedevdata, touchwakedevdata->backlight_on)) {
  125. + touchwakedevdata->is_dead = true;
  126. + touchwakedevdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
  127. + dev_err(&touchwakedevdata->client->dev, "%s: touch keypad not responding"
  128. + " to commands, disabling\n", __func__);
  129. + return;
  130. + }
  131. + touchwakedevdata->is_dead = false;
  132. + enable_irq(touchwakedevdata->client->irq);
  133. + touchwakedevdata->is_powering_on = false;
  134. +
  135. + return;
  136. }
  137. +
  138. +static struct touchwake_implementation cypress_touchwake =
  139. + {
  140. + .enable = cypress_touchwake_enable,
  141. + .disable = cypress_touchwake_disable,
  142. + };
  143. #endif
  144.  
  145. static void set_device_params(struct cypress_touchkey_devdata *devdata,
  146. @@ -533,6 +600,11 @@ static int cypress_touchkey_probe(struct i2c_client *client,
  147. register_bld_implementation(&cypress_touchkey_bld);
  148. #endif
  149.  
  150. +#ifdef CONFIG_TOUCH_WAKE
  151. + touchwakedevdata = devdata;
  152. + register_touchwake_implementation(&cypress_touchwake);
  153. +#endif
  154. +
  155. return 0;
  156.  
  157.  
  158. diff --git a/drivers/input/misc/gpio_event.c b/drivers/input/misc/gpio_event.c
  159. index a98be67..0438a6e 100644
  160. --- a/drivers/input/misc/gpio_event.c
  161. +++ b/drivers/input/misc/gpio_event.c
  162. @@ -21,6 +21,12 @@
  163. #include <linux/platform_device.h>
  164. #include <linux/slab.h>
  165.  
  166. +#ifdef CONFIG_TOUCH_WAKE
  167. +#include <linux/touch_wake.h>
  168. +
  169. +extern void set_powerkeydev(struct input_dev * input_device);
  170. +#endif
  171. +
  172. struct gpio_event {
  173. struct gpio_event_input_devs *input_devs;
  174. const struct gpio_event_platform_data *info;
  175. @@ -166,6 +172,14 @@ static int gpio_event_probe(struct platform_device *pdev)
  176. event_info->name : event_info->names[i];
  177. input_dev->event = gpio_input_event;
  178. ip->input_devs->dev[i] = input_dev;
  179. +#ifdef CONFIG_TOUCH_WAKE
  180. + if (!strcmp(input_dev->name, "herring-keypad"))
  181. + {
  182. + pr_info("powerkey device set\n");
  183. +
  184. + set_powerkeydev(input_dev);
  185. + }
  186. +#endif
  187. }
  188. ip->input_devs->count = dev_count;
  189. ip->info = event_info;
  190. diff --git a/drivers/input/touchscreen/mxt224.c b/drivers/input/touchscreen/mxt224.c
  191. index 09c3b3b..d431bae 100644
  192. --- a/drivers/input/touchscreen/mxt224.c
  193. +++ b/drivers/input/touchscreen/mxt224.c
  194. @@ -29,6 +29,10 @@
  195. #include <linux/screen_dimmer.h>
  196. #endif
  197.  
  198. +#ifdef CONFIG_TOUCH_WAKE
  199. +#include <linux/touch_wake.h>
  200. +#endif
  201. +
  202. #define OBJECT_TABLE_START_ADDRESS 7
  203. #define OBJECT_TABLE_ELEMENT_SIZE 6
  204.  
  205. @@ -313,6 +317,10 @@ static void report_input_data(struct mxt224_data *data)
  206. touchscreen_pressed();
  207. #endif
  208.  
  209. +#ifdef CONFIG_TOUCH_WAKE
  210. + touch_press();
  211. +#endif
  212. +
  213. input_report_abs(data->input_dev, ABS_MT_POSITION_X,
  214. data->fingers[i].x);
  215. input_report_abs(data->input_dev, ABS_MT_POSITION_Y,
  216. @@ -428,19 +436,46 @@ static int mxt224_internal_resume(struct mxt224_data *data)
  217.  
  218. static void mxt224_early_suspend(struct early_suspend *h)
  219. {
  220. +#ifndef CONFIG_TOUCH_WAKE
  221. struct mxt224_data *data = container_of(h, struct mxt224_data,
  222. early_suspend);
  223. disable_irq(data->client->irq);
  224. mxt224_internal_suspend(data);
  225. +#endif
  226. }
  227.  
  228. static void mxt224_late_resume(struct early_suspend *h)
  229. {
  230. +#ifndef CONFIG_TOUCH_WAKE
  231. struct mxt224_data *data = container_of(h, struct mxt224_data,
  232. early_suspend);
  233. mxt224_internal_resume(data);
  234. enable_irq(data->client->irq);
  235. +#endif
  236. }
  237. +
  238. +#ifdef CONFIG_TOUCH_WAKE
  239. +struct mxt224_data * touchwake_data;
  240. +
  241. +void touchscreen_disable(void)
  242. +{
  243. + disable_irq(touchwake_data->client->irq);
  244. + mxt224_internal_suspend(touchwake_data);
  245. +
  246. + return;
  247. +}
  248. +EXPORT_SYMBOL(touchscreen_disable);
  249. +
  250. +void touchscreen_enable(void)
  251. +{
  252. + mxt224_internal_resume(touchwake_data);
  253. + enable_irq(touchwake_data->client->irq);
  254. +
  255. + return;
  256. +}
  257. +EXPORT_SYMBOL(touchscreen_enable);
  258. +#endif
  259. +
  260. #else
  261. static int mxt224_suspend(struct device *dev)
  262. {
  263. @@ -581,6 +616,10 @@ static int __devinit mxt224_probe(struct i2c_client *client,
  264. register_early_suspend(&data->early_suspend);
  265. #endif
  266.  
  267. +#ifdef CONFIG_TOUCH_WAKE
  268. + touchwake_data = data;
  269. +#endif
  270. +
  271. return 0;
  272.  
  273. err_irq:
  274. diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
  275. index b101c1e..6f2f2dd 100755
  276. --- a/drivers/misc/Kconfig
  277. +++ b/drivers/misc/Kconfig
  278. @@ -480,4 +480,10 @@ config SCREEN_DIMMER
  279. help
  280. Say Y here to enable the screen dimmer
  281.  
  282. +config TOUCH_WAKE
  283. + bool "Support for touch wake"
  284. + default y
  285. + help
  286. + Say Y here to enable touch wake
  287. +
  288. endif # MISC_DEVICES
  289. diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
  290. index 8db22d3..d6dff9f 100755
  291. --- a/drivers/misc/Makefile
  292. +++ b/drivers/misc/Makefile
  293. @@ -46,3 +46,4 @@ obj-$(CONFIG_SAMSUNG_MODEMCTL) += samsung_modemctl/
  294. obj-$(CONFIG_GENERIC_BLN) += bln.o
  295. obj-$(CONFIG_BLD) += bld.o
  296. obj-$(CONFIG_SCREEN_DIMMER) += screen_dimmer.o
  297. +obj-$(CONFIG_TOUCH_WAKE) += touch_wake.o
  298. diff --git a/drivers/misc/touch_wake.c b/drivers/misc/touch_wake.c
  299. new file mode 100644
  300. index 0000000..0c65be7
  301. --- /dev/null
  302. +++ b/drivers/misc/touch_wake.c
  303. @@ -0,0 +1,328 @@
  304. +/* drivers/misc/touch_wake.c
  305. + *
  306. + * Copyright 2011 Ezekeel
  307. + *
  308. + * This program is free software; you can redistribute it and/or modify
  309. + * it under the terms of the GNU General Public License version 2 as
  310. + * published by the Free Software Foundation.
  311. + */
  312. +
  313. +#include <linux/init.h>
  314. +#include <linux/device.h>
  315. +#include <linux/miscdevice.h>
  316. +#include <linux/touch_wake.h>
  317. +#include <linux/workqueue.h>
  318. +#include <linux/earlysuspend.h>
  319. +#include <linux/mutex.h>
  320. +#include <linux/delay.h>
  321. +#include <linux/wakelock.h>
  322. +#include <linux/input.h>
  323. +
  324. +extern void touchscreen_enable(void);
  325. +extern void touchscreen_disable(void);
  326. +
  327. +static bool touchwake_enabled = false;
  328. +
  329. +static bool touch_disabled = false;
  330. +
  331. +static bool device_suspended = false;
  332. +
  333. +static bool powerkey_pressed = false;
  334. +
  335. +static unsigned int touchoff_delay = 45000;
  336. +
  337. +static const unsigned int presspower_delay = 100;
  338. +
  339. +static void touchwake_touchoff(struct work_struct * touchoff_work);
  340. +
  341. +static DECLARE_DELAYED_WORK(touchoff_work, touchwake_touchoff);
  342. +
  343. +static void press_powerkey(struct work_struct * presspower_work);
  344. +
  345. +static DECLARE_WORK(presspower_work, press_powerkey);
  346. +
  347. +static DEFINE_MUTEX(lock);
  348. +
  349. +static struct touchwake_implementation * touchwake_imp = NULL;
  350. +
  351. +static struct input_dev * powerkey_device;
  352. +
  353. +static struct wake_lock touchwake_wake_lock;
  354. +
  355. +#define TOUCHWAKE_VERSION 1
  356. +
  357. +static void touchwake_disable_touch(void)
  358. +{
  359. + pr_info("disable touch controls\n");
  360. +
  361. + touchscreen_disable();
  362. +
  363. + if (touchwake_imp)
  364. + {
  365. + touchwake_imp->disable();
  366. + }
  367. +
  368. + touch_disabled = true;
  369. +
  370. + return;
  371. +}
  372. +
  373. +static void touchwake_enable_touch(void)
  374. +{
  375. + pr_info("enable touch controls\n");
  376. +
  377. + touchscreen_enable();
  378. +
  379. + if (touchwake_imp)
  380. + {
  381. + touchwake_imp->enable();
  382. + }
  383. +
  384. + touch_disabled = false;
  385. +
  386. + return;
  387. +}
  388. +
  389. +static void touchwake_early_suspend(struct early_suspend * h)
  390. +{
  391. + if (touchwake_enabled)
  392. + {
  393. + if (touchoff_delay > 0)
  394. + {
  395. + if (!powerkey_pressed)
  396. + {
  397. + wake_lock(&touchwake_wake_lock);
  398. +
  399. + schedule_delayed_work(&touchoff_work, msecs_to_jiffies(touchoff_delay));
  400. + }
  401. + else
  402. + {
  403. + touchwake_disable_touch();
  404. + }
  405. + }
  406. + else
  407. + {
  408. + wake_lock(&touchwake_wake_lock);
  409. + }
  410. + }
  411. + else
  412. + {
  413. + touchwake_disable_touch();
  414. + }
  415. +
  416. + device_suspended = true;
  417. +
  418. + return;
  419. +}
  420. +
  421. +static void touchwake_late_resume(struct early_suspend * h)
  422. +{
  423. + cancel_delayed_work(&touchoff_work);
  424. + flush_scheduled_work();
  425. +
  426. + wake_unlock(&touchwake_wake_lock);
  427. +
  428. + if (touch_disabled)
  429. + {
  430. + touchwake_enable_touch();
  431. + }
  432. +
  433. + powerkey_pressed = false;
  434. +
  435. + device_suspended = false;
  436. +
  437. + return;
  438. +}
  439. +
  440. +static struct early_suspend touchwake_suspend_data =
  441. + {
  442. + .level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1,
  443. + .suspend = touchwake_early_suspend,
  444. + .resume = touchwake_late_resume,
  445. + };
  446. +
  447. +static void touchwake_touchoff(struct work_struct * touchoff_work)
  448. +{
  449. + touchwake_disable_touch();
  450. +
  451. + wake_unlock(&touchwake_wake_lock);
  452. +
  453. + return;
  454. +}
  455. +
  456. +static void press_powerkey(struct work_struct * presspower_work)
  457. +{
  458. + input_event(powerkey_device, EV_KEY, KEY_POWER, 1);
  459. +
  460. + msleep(presspower_delay);
  461. +
  462. + input_event(powerkey_device, EV_KEY, KEY_POWER, 0);
  463. +
  464. + msleep(presspower_delay);
  465. +
  466. + mutex_unlock(&lock);
  467. +
  468. + return;
  469. +}
  470. +
  471. +static ssize_t touchwake_status_read(struct device * dev, struct device_attribute * attr, char * buf)
  472. +{
  473. + return sprintf(buf, "%u\n", (touchwake_enabled ? 1 : 0));
  474. +}
  475. +
  476. +static ssize_t touchwake_status_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
  477. +{
  478. + unsigned int data;
  479. +
  480. + if(sscanf(buf, "%u\n", &data) == 1)
  481. + {
  482. + pr_devel("%s: %u \n", __FUNCTION__, data);
  483. +
  484. + if (data == 1)
  485. + {
  486. + pr_info("%s: TOUCHWAKE function enabled\n", __FUNCTION__);
  487. +
  488. + touchwake_enabled = true;
  489. + }
  490. + else if (data == 0)
  491. + {
  492. + pr_info("%s: TOUCHWAKE function disabled\n", __FUNCTION__);
  493. +
  494. + touchwake_enabled = false;
  495. + }
  496. + else
  497. + {
  498. + pr_info("%s: invalid input range %u\n", __FUNCTION__, data);
  499. + }
  500. + }
  501. + else
  502. + {
  503. + pr_info("%s: invalid input\n", __FUNCTION__);
  504. + }
  505. +
  506. + return size;
  507. +}
  508. +
  509. +static ssize_t touchwake_delay_read(struct device * dev, struct device_attribute * attr, char * buf)
  510. +{
  511. + return sprintf(buf, "%u\n", touchoff_delay);
  512. +}
  513. +
  514. +static ssize_t touchwake_delay_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
  515. +{
  516. + unsigned int data;
  517. +
  518. + if(sscanf(buf, "%u\n", &data) == 1)
  519. + {
  520. + touchoff_delay = data;
  521. +
  522. + pr_info("TOUCHWAKE delay set to %u\n", touchoff_delay);
  523. + }
  524. + else
  525. + {
  526. + pr_info("%s: invalid input\n", __FUNCTION__);
  527. + }
  528. +
  529. + return size;
  530. +}
  531. +
  532. +static ssize_t touchwake_version(struct device * dev, struct device_attribute * attr, char * buf)
  533. +{
  534. + return sprintf(buf, "%u\n", TOUCHWAKE_VERSION);
  535. +}
  536. +
  537. +static DEVICE_ATTR(enabled, S_IRUGO | S_IWUGO, touchwake_status_read, touchwake_status_write);
  538. +static DEVICE_ATTR(delay, S_IRUGO | S_IWUGO, touchwake_delay_read, touchwake_delay_write);
  539. +static DEVICE_ATTR(version, S_IRUGO , touchwake_version, NULL);
  540. +
  541. +static struct attribute *touchwake_notification_attributes[] =
  542. + {
  543. + &dev_attr_enabled.attr,
  544. + &dev_attr_delay.attr,
  545. + &dev_attr_version.attr,
  546. + NULL
  547. + };
  548. +
  549. +static struct attribute_group touchwake_notification_group =
  550. + {
  551. + .attrs = touchwake_notification_attributes,
  552. + };
  553. +
  554. +static struct miscdevice touchwake_device =
  555. + {
  556. + .minor = MISC_DYNAMIC_MINOR,
  557. + .name = "touchwake",
  558. + };
  559. +
  560. +void powerkey_press(void)
  561. +{
  562. + powerkey_pressed = true;
  563. +
  564. + return;
  565. +}
  566. +EXPORT_SYMBOL(powerkey_press);
  567. +
  568. +void touch_press(void)
  569. +{
  570. + if (device_suspended && touchwake_enabled && !mutex_is_locked(&lock))
  571. + {
  572. + mutex_lock(&lock);
  573. +
  574. + schedule_work(&presspower_work);
  575. + }
  576. +
  577. + return;
  578. +}
  579. +EXPORT_SYMBOL(touch_press);
  580. +
  581. +void set_powerkeydev(struct input_dev * input_device)
  582. +{
  583. + powerkey_device = input_device;
  584. +
  585. + return;
  586. +}
  587. +EXPORT_SYMBOL(set_powerkeydev);
  588. +
  589. +bool device_is_suspended(void)
  590. +{
  591. + return device_suspended;
  592. +}
  593. +EXPORT_SYMBOL(device_is_suspended);
  594. +
  595. +void register_touchwake_implementation(struct touchwake_implementation * imp)
  596. +{
  597. + touchwake_imp = imp;
  598. +
  599. + return;
  600. +}
  601. +EXPORT_SYMBOL(register_touchwake_implementation);
  602. +
  603. +static int __init touchwake_control_init(void)
  604. +{
  605. + int ret;
  606. +
  607. + pr_info("%s misc_register(%s)\n", __FUNCTION__, touchwake_device.name);
  608. +
  609. + ret = misc_register(&touchwake_device);
  610. +
  611. + if (ret)
  612. + {
  613. + pr_err("%s misc_register(%s) fail\n", __FUNCTION__, touchwake_device.name);
  614. +
  615. + return 1;
  616. + }
  617. +
  618. + if (sysfs_create_group(&touchwake_device.this_device->kobj, &touchwake_notification_group) < 0)
  619. + {
  620. + pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
  621. + pr_err("Failed to create sysfs group for device (%s)!\n", touchwake_device.name);
  622. + }
  623. +
  624. + register_early_suspend(&touchwake_suspend_data);
  625. +
  626. + wake_lock_init(&touchwake_wake_lock, WAKE_LOCK_SUSPEND, "touchwake_wake");
  627. +
  628. + return 0;
  629. +}
  630. +
  631. +device_initcall(touchwake_control_init);
  632. diff --git a/include/linux/input.h b/include/linux/input.h
  633. index f2b0f5a..d4108ca 100644
  634. --- a/include/linux/input.h
  635. +++ b/include/linux/input.h
  636. @@ -27,6 +27,10 @@
  637. #include <linux/screen_dimmer.h>
  638. #endif
  639.  
  640. +#ifdef CONFIG_TOUCH_WAKE
  641. +#include <linux/touch_wake.h>
  642. +#endif
  643. +
  644. /*
  645. * The event structure itself
  646. */
  647. @@ -1382,15 +1386,45 @@ void input_inject_event(struct input_handle *handle, unsigned int type, unsigned
  648. static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
  649. {
  650. #ifdef CONFIG_SCREEN_DIMMER
  651. +#ifdef CONFIG_TOUCH_WAKE
  652. + if (!screen_is_dimmed() && !device_is_suspended())
  653. + {
  654. + input_event(dev, EV_KEY, code, !!value);
  655. + }
  656. +#else
  657. if (!screen_is_dimmed())
  658. {
  659. input_event(dev, EV_KEY, code, !!value);
  660. }
  661. +#endif
  662. +#else
  663. +#ifdef CONFIG_TOUCH_WAKE
  664. + if (!device_is_suspended())
  665. + {
  666. + input_event(dev, EV_KEY, code, !!value);
  667. + }
  668. #else
  669. input_event(dev, EV_KEY, code, !!value);
  670. #endif
  671. +#endif
  672.  
  673. #ifdef CONFIG_BLD
  674. +#ifdef CONFIG_TOUCH_WAKE
  675. + if (!device_is_suspended())
  676. + {
  677. + if (code == KEY_MENU || code == KEY_HOME || code == KEY_BACK || code == KEY_SEARCH)
  678. + {
  679. + if (value == 1)
  680. + {
  681. + touchkey_pressed();
  682. +
  683. +#ifdef CONFIG_SCREEN_DIMMER
  684. + touchscreen_pressed();
  685. +#endif
  686. + }
  687. + }
  688. + }
  689. +#else
  690. if (code == KEY_MENU || code == KEY_HOME || code == KEY_BACK || code == KEY_SEARCH)
  691. {
  692. if (value == 1)
  693. @@ -1402,17 +1436,41 @@ static inline void input_report_key(struct input_dev *dev, unsigned int code, in
  694. #endif
  695. }
  696. }
  697. +#endif
  698. #else
  699. #ifdef CONFIG_SCREEN_DIMMER
  700. +#ifdef CONFIG_TOUCH_WAKE
  701. + if (!device_is_suspended())
  702. + {
  703. + if (code == KEY_MENU || code == KEY_HOME || code == KEY_BACK || code == KEY_SEARCH)
  704. + {
  705. + if (value == 1)
  706. + {
  707. + touchscreen_pressed();
  708. + }
  709. + }
  710. + }
  711. +#else
  712. if (code == KEY_MENU || code == KEY_HOME || code == KEY_BACK || code == KEY_SEARCH)
  713. {
  714. if (value == 1)
  715. {
  716. - touchscreen_pressed();
  717. + touchscreen_pressed();
  718. }
  719. }
  720. #endif
  721. #endif
  722. +#endif
  723. +
  724. +#ifdef CONFIG_TOUCH_WAKE
  725. + if (code == KEY_MENU || code == KEY_HOME || code == KEY_BACK || code == KEY_SEARCH)
  726. + {
  727. + if (value == 1)
  728. + {
  729. + touch_press();
  730. + }
  731. + }
  732. +#endif
  733. }
  734.  
  735. static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value)
  736. @@ -1423,13 +1481,27 @@ static inline void input_report_rel(struct input_dev *dev, unsigned int code, in
  737. static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value)
  738. {
  739. #ifdef CONFIG_SCREEN_DIMMER
  740. +#ifdef CONFIG_TOUCH_WAKE
  741. + if (!screen_is_dimmed() && !device_is_suspended())
  742. + {
  743. + input_event(dev, EV_ABS, code, value);
  744. + }
  745. +#else
  746. if (!screen_is_dimmed())
  747. {
  748. input_event(dev, EV_ABS, code, value);
  749. }
  750. +#endif
  751. +#else
  752. +#ifdef CONFIG_TOUCH_WAKE
  753. + if (!device_is_suspended())
  754. + {
  755. + input_event(dev, EV_ABS, code, value);
  756. + }
  757. #else
  758. input_event(dev, EV_ABS, code, value);
  759. #endif
  760. +#endif
  761. }
  762.  
  763. static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value)
  764. diff --git a/include/linux/touch_wake.h b/include/linux/touch_wake.h
  765. new file mode 100644
  766. index 0000000..25d8c8e
  767. --- /dev/null
  768. +++ b/include/linux/touch_wake.h
  769. @@ -0,0 +1,17 @@
  770. +/* include/linux/touch_wake.h */
  771. +
  772. +#ifndef _LINUX_TOUCH_WAKE_H
  773. +#define _LINUX_TOUCH_WAKE_H
  774. +
  775. +struct touchwake_implementation
  776. +{
  777. + void (* enable)(void);
  778. + void (* disable)(void);
  779. +};
  780. +
  781. +void register_touchwake_implementation(struct touchwake_implementation * imp);
  782. +void powerkey_press(void);
  783. +void touch_press(void);
  784. +bool device_is_suspended(void);
  785. +
  786. +#endif
Add Comment
Please, Sign In to add comment