Skip to content

Commit 38106b2

Browse files
committed
z2_plus: Fix home button bug
1 parent a8733e5 commit 38106b2

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

drivers/input/keyboard/gpio_keys.c

100644100755
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ struct gpio_keys_drvdata {
5454
struct gpio_button_data data[0];
5555
};
5656

57+
extern bool reset_gpio(void);
58+
59+
5760
static struct device *global_dev;
5861
static struct syscore_ops gpio_keys_syscore_pm_ops;
5962

@@ -332,6 +335,8 @@ static struct attribute_group gpio_keys_attr_group = {
332335
.attrs = gpio_keys_attrs,
333336
};
334337

338+
bool home_button_status;
339+
335340
static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
336341
{
337342
const struct gpio_keys_button *button = bdata->button;
@@ -340,7 +345,10 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
340345
int state;
341346

342347
state = (__gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
343-
348+
pr_info("key gpio value = %d active_low = %d state=%d home_button_status=%d\n" , (int)__gpio_get_value(button->gpio),button->active_low,state, home_button_status);
349+
if (state == 1) {
350+
home_button_status = 1;
351+
}
344352
if (type == EV_ABS) {
345353
if (state)
346354
input_event(input, type, button->code, button->value);
@@ -350,6 +358,13 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
350358
input_sync(input);
351359
}
352360

361+
void reset_home_button(int i)
362+
{
363+
home_button_status = i;
364+
pr_info("key home button reset ok, home_button_status=%d",i);
365+
}
366+
367+
353368
static void gpio_keys_gpio_work_func(struct work_struct *work)
354369
{
355370
struct gpio_button_data *bdata =
@@ -1008,6 +1023,11 @@ static void __exit gpio_keys_exit(void)
10081023
platform_driver_unregister(&gpio_keys_device_driver);
10091024
}
10101025

1026+
bool home_button_pressed(void)
1027+
{
1028+
return home_button_status;
1029+
}
1030+
10111031
late_initcall(gpio_keys_init);
10121032
module_exit(gpio_keys_exit);
10131033

drivers/misc/fpc1020_ree.c

100644100755
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ struct fpc1020_data {
5757
int screen_on;
5858
};
5959

60+
extern bool home_button_pressed(void);
61+
extern void reset_home_button(bool);
62+
63+
bool reset;
64+
6065
static int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data);
6166

6267
static ssize_t irq_get(struct device* device,
@@ -84,6 +89,7 @@ static ssize_t irq_set(struct device* device,
8489
return -ENOENT;
8590
return strnlen(buffer, count);
8691
}
92+
8793
static DEVICE_ATTR(irq, S_IRUSR | S_IWUSR, irq_get, irq_set);
8894

8995
static ssize_t fp_wl_get(struct device* device,
@@ -111,6 +117,7 @@ static ssize_t fp_wl_set(struct device* device,
111117
}
112118
return strnlen(buffer, count);
113119
}
120+
114121
static DEVICE_ATTR(wl, S_IRUSR | S_IWUSR, fp_wl_get, fp_wl_set);
115122

116123
static ssize_t get_wakeup_status(struct device* device,
@@ -143,12 +150,13 @@ static ssize_t set_wakeup_status(struct device* device,
143150

144151
return strnlen(buffer, count);
145152
}
153+
146154
static DEVICE_ATTR(wakeup, S_IRUSR | S_IWUSR, get_wakeup_status, set_wakeup_status);
147155

148156
static ssize_t get_key(struct device* device, struct device_attribute* attribute, char* buffer)
149157
{
150158
struct fpc1020_data* fpc1020 = dev_get_drvdata(device);
151-
return scnprintf(buffer, PAGE_SIZE, "%i\n", fpc1020->report_key);
159+
return scnprintf(buffer, PAGE_SIZE, "%i\n", fpc1020->report_key);
152160
}
153161

154162
static ssize_t set_key(struct device* device,
@@ -163,13 +171,26 @@ static ssize_t set_key(struct device* device,
163171
if (!retval) {
164172
if (val == KEY_HOME)
165173
val = KEY_NAVI_LONG; //Convert to U-touch long press keyValue
174+
if (val != 0 && home_button_pressed()) val = 0;
175+
176+
pr_info("home key pressed = %d\n", (int)home_button_pressed());
166177
fpc1020->report_key = (int)val;
167178
queue_work(fpc1020->fpc1020_wq, &fpc1020->input_report_work);
179+
180+
if (val == 0) {
181+
pr_info("calling home key reset");
182+
reset_home_button(0);
183+
}
168184
} else
169185
return -ENOENT;
170186
return strnlen(buffer, count);
187+
}
171188

189+
bool reset_gpio(void)
190+
{
191+
return reset;
172192
}
193+
173194
static DEVICE_ATTR(key, S_IRUSR | S_IWUSR, get_key, set_key);
174195

175196
static ssize_t get_screen_stat(struct device* device, struct device_attribute* attribute, char* buffer)
@@ -184,6 +205,7 @@ static ssize_t set_screen_stat(struct device* device,
184205
{
185206
return 1;
186207
}
208+
187209
static DEVICE_ATTR(screen, S_IRUSR | S_IWUSR, get_screen_stat, set_screen_stat);
188210

189211
static struct attribute *attributes[] = {
@@ -194,6 +216,7 @@ static struct attribute *attributes[] = {
194216
&dev_attr_screen.attr,
195217
NULL
196218
};
219+
197220
static const struct attribute_group attribute_group = {
198221
.attrs = attributes,
199222
};
@@ -316,7 +339,6 @@ static int fpc1020_manage_sysfs(struct fpc1020_data *fpc1020)
316339
return 0;
317340
}
318341

319-
320342
static int fpc1020_alloc_input_dev(struct fpc1020_data *fpc1020)
321343
{
322344
int retval = 0;

0 commit comments

Comments
 (0)