Esempio n. 1
0
static void gpio_keys_report_event(struct gpio_button_data *bdata)
{
	static int64_t homekey_lasttime = 0;
	static int homekey_count = 0;
	struct gpio_keys_button *button = bdata->button;
	struct input_dev *input = bdata->input;
	unsigned int type = button->type ?: EV_KEY;
	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0)
		^ button->active_low;
	//mdnie negative effect toggle by gm
	if(button->code == HOME_KEY_VAL)
	{
		if(state) {
			if (  get_time_inms() - homekey_lasttime < 300) {
				homekey_count++;
				printk(KERN_INFO "repeated home_key action %d.\n", homekey_count);
			}
			else
			{
				homekey_count = 0;
			}
		}
		else {
			if(homekey_count==3)
			{
				mdnie_toggle_negative();
				homekey_count = 0;
			}
			homekey_lasttime = get_time_inms();
		}
	}
#ifdef CONFIG_MACH_GC1
	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
	struct gpio_button_data *tmp_bdata;
	static bool overlapped;
	static unsigned int hotkey;
	unsigned int index_hotkey = 0;
	bool zoomkey = false;

#ifdef CONFIG_FAST_BOOT
	/*Fake pwr off control*/
	if (fake_shut_down) {
		if (button->code == KEY_POWER) {
			if (!!state) {
				printk(KERN_DEBUG"[Keys] start fake check\n");
				fake_pressed = true;
				mod_timer(&fake_timer,
					jiffies + msecs_to_jiffies(1000));
			} else {
				printk(KERN_DEBUG"[Keys] end fake checkPwr 0\n");
				fake_pressed = false;
			}
		}
		return ;
	}
#endif
	if (system_rev < 6 && system_rev >= 2) {
		if (overlapped) {
			if (hotkey == button->code && !state) {
				bdata->key_state = !!state;
				bdata->wakeup = false;
				overlapped = false;
#ifdef CONFIG_SAMSUNG_PRODUCT_SHIP
				printk(KERN_DEBUG"[KEYS] Ignored\n");
#else
				printk(KERN_DEBUG"[KEYS] Ignore %d %d\n",
						hotkey, state);
#endif
				return;
			}
		}

		gpio_keys_check_zoom_exception(button->code, &zoomkey,
				&hotkey, &index_hotkey);
	}
#endif

	if (type == EV_ABS) {
		if (state) {
			input_event(input, type, button->code, button->value);
			input_sync(input);
			}
	} else {
		if (bdata->wakeup && !state) {
			input_event(input, type, button->code, !state);
			input_sync(input);
			if (button->code == KEY_POWER)
				printk(KERN_DEBUG"[keys] f PWR %d\n", !state);
		}

		bdata->key_state = !!state;
		bdata->wakeup = false;


#ifdef CONFIG_MACH_GC1
		if (system_rev < 6 && system_rev >= 2
				&& zoomkey && state) {
			tmp_bdata = &ddata->data[index_hotkey];

			if (tmp_bdata->key_state) {
#ifdef CONFIG_SAMSUNG_PRODUCT_SHIP
				printk(KERN_DEBUG"[KEYS] overlapped\n");
#else
				printk(KERN_DEBUG"[KEYS] overlapped. Forced release c %d h %d\n",
					tmp_bdata->button->code, hotkey);
#endif
				input_event(input, type, hotkey, 0);
				input_sync(input);

				overlapped = true;
			}
		}
#endif
#ifdef CONFIG_SENSORS_HALL
	      if(!flip_cover_open && button->code == KEY_POWER){
	        printk(KERN_DEBUG" cover closed...ignoring PWR button");
	      }else{ 
#endif
		input_event(input, type, button->code, !!state);
		input_sync(input);
#ifdef CONFIG_SENSORS_HALL
	      }
#endif
		if (button->code == KEY_POWER)
			printk(KERN_DEBUG"[keys]PWR %d\n", !!state);
	}
}
Esempio n. 2
0
static void gpio_keys_report_event(struct gpio_button_data *bdata)
{
	struct gpio_keys_button *button = bdata->button;
	struct input_dev *input = bdata->input;
	unsigned int type = button->type ?: EV_KEY;
	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0)
		^ button->active_low;
#ifdef CONFIG_MACH_GC1
	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
	struct gpio_button_data *tmp_bdata;
	static bool overlapped;
	static unsigned int hotkey;
	unsigned int index_hotkey = 0;
	bool zoomkey = false;

#ifdef CONFIG_FAST_BOOT

	/*Fake pwr off control*/
	if (fake_shut_down || fake_pressed) {
		if (button->code == KEY_POWER) {
			if (!!state) {
				printk(KERN_DEBUG"[Keys] start fake check\n");
				fake_pressed = true;
				if (!wake_lock_active(&fake_lock))
					wake_lock(&fake_lock);
				mod_timer(&fake_timer,
					jiffies + msecs_to_jiffies(500));
			} else {
				printk(KERN_DEBUG"[Keys] end fake checkPwr 0\n");
				fake_pressed = false;
				if (wake_lock_active(&fake_lock))
					wake_unlock(&fake_lock);
			}
		}
		bdata->wakeup = false;
		return ;
	}
#endif
	if (system_rev < 6 && system_rev >= 2) {
		if (overlapped) {
			if (hotkey == button->code && !state) {
				bdata->key_state = !!state;
				bdata->wakeup = false;
				overlapped = false;
#ifdef CONFIG_SAMSUNG_PRODUCT_SHIP
				printk(KERN_DEBUG"[KEYS] Ignored\n");
#else
				printk(KERN_DEBUG"[KEYS] Ignore %d %d\n",
						hotkey, state);
#endif
				return;
			}
		}

		gpio_keys_check_zoom_exception(button->code, &zoomkey,
				&hotkey, &index_hotkey);
	} else if (system_rev >= 6) {
		/*exclusive check for zoom dial*/
		unsigned int zoom_type = 0;
		unsigned int current_zoom_state = 0;
		bool pass_cur_event = false;

		if (is_zoom_key(button->code, &zoom_type)) {
			current_zoom_state = check_zoom_state(ddata);

			if (zoom_type == ZOOM_IN
				&& current_zoom_state == ZOOM_OUT)
					pass_cur_event = true;
			else if (zoom_type == ZOOM_OUT
				&& current_zoom_state == ZOOM_IN)
					pass_cur_event = true;

			if (pass_cur_event) {
#if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
				printk(KERN_DEBUG "[keys] Pass zoom"
					"current %d, code %d\n",
					current_zoom_state, button->code);
#endif
				return ;
			}
		}
	}
#endif

	if (type == EV_ABS) {
		if (state) {
			input_event(input, type, button->code, button->value);
			input_sync(input);
			}
	} else {
		if (bdata->wakeup && !state) {
			input_event(input, type, button->code, !state);
			input_sync(input);
			if (button->code == KEY_POWER)
				printk(KERN_DEBUG"[keys] f PWR %d\n", !state);
		}

		bdata->key_state = !!state;
		bdata->wakeup = false;


#ifdef CONFIG_MACH_GC1
		if (system_rev < 6 && system_rev >= 2
				&& zoomkey && state) {
			tmp_bdata = &ddata->data[index_hotkey];

			if (tmp_bdata->key_state) {
#ifdef CONFIG_SAMSUNG_PRODUCT_SHIP
				printk(KERN_DEBUG"[KEYS] overlapped\n");
#else
				printk(KERN_DEBUG"[KEYS] overlapped. Forced release c %d h %d\n",
					tmp_bdata->button->code, hotkey);
#endif
				input_event(input, type, hotkey, 0);
				input_sync(input);

				overlapped = true;
			}
		}

		if (system_rev >= 6) {
			/* forced release*/
			if (button->code == KEY_CAMERA_ZOOMIN && !state) {
				tmp_bdata = &ddata->data[5];
				if (tmp_bdata->key_state) {
					input_event(input, type, 0x221,
						!!state);
					input_sync(input);
					printk(KERN_DEBUG"[KEYS] forced 0x221 key release\n");
				}
			}

			if (button->code == KEY_CAMERA_ZOOMOUT && !state) {
				tmp_bdata = &ddata->data[6];
				if (tmp_bdata->key_state) {
					input_event(input, type, 0x222,
						!!state);
					input_sync(input);
					printk(KERN_DEBUG"[KEYS] forced 0x222 key release\n");
				}
			}

			/*forced press*/
			if (button->code == 0x221 && state) {
				tmp_bdata = &ddata->data[3];
				if (!tmp_bdata->key_state) {
					input_event(input, type,
						KEY_CAMERA_ZOOMIN, !!state);
					input_sync(input);
					printk(KERN_DEBUG"[KEYS] forced 0x215 key press\n");
				}
			}

			if (button->code == 0x222 && state) {
				tmp_bdata = &ddata->data[4];
				if (!tmp_bdata->key_state) {
					input_event(input, type,
						KEY_CAMERA_ZOOMOUT, !!state);
					input_sync(input);
					printk(KERN_DEBUG"[KEYS] forced 0x216 key press\n");
				}
			}
		}

#endif
		input_event(input, type, button->code, !!state);
		input_sync(input);

		if (button->code == KEY_POWER)
			printk(KERN_DEBUG"[keys]PWR %d\n", !!state);
	}
}
Esempio n. 3
0
static void gpio_keys_report_event(struct gpio_button_data *bdata)
{
	struct gpio_keys_button *button = bdata->button;
	struct input_dev *input = bdata->input;
	unsigned int type = button->type ?: EV_KEY;
	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0)
		^ button->active_low;
#ifdef CONFIG_MACH_GC1
	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
	struct gpio_button_data *tmp_bdata;
	static bool overlapped;
	static unsigned int hotkey;
	unsigned int index_hotkey = 0;
	bool zoomkey = false;

#ifdef CONFIG_FAST_BOOT
	/*Fake pwr off control*/
	if (fake_shut_down) {
		if (button->code == KEY_POWER) {
			if (!!state) {
				printk(KERN_DEBUG"[Keys] start fake check\n");
				fake_pressed = true;
				mod_timer(&fake_timer,
					jiffies + msecs_to_jiffies(1000));
			} else {
				printk(KERN_DEBUG"[Keys] end fake checkPwr 0\n");
				fake_pressed = false;
			}
		}
		return ;
	}
#endif
	if (system_rev < 6 && system_rev >= 2) {
		if (overlapped) {
			if (hotkey == button->code && !state) {
				bdata->key_state = !!state;
				bdata->wakeup = false;
				overlapped = false;
#ifdef CONFIG_SAMSUNG_PRODUCT_SHIP
				printk(KERN_DEBUG"[KEYS] Ignored\n");
#else
				printk(KERN_DEBUG"[KEYS] Ignore %d %d\n",
						hotkey, state);
#endif
				return;
			}
		}

		gpio_keys_check_zoom_exception(button->code, &zoomkey,
				&hotkey, &index_hotkey);
	}
#endif

	if (type == EV_ABS) {
		if (state) {
			input_event(input, type, button->code, button->value);
			input_sync(input);
			}
	} else {
		if (bdata->wakeup && !state) {
			input_event(input, type, button->code, !state);
			input_sync(input);
			if (button->code == KEY_POWER)
				printk(KERN_DEBUG"[keys] f PWR %d\n", !state);
		}

		bdata->key_state = !!state;
		bdata->wakeup = false;


#ifdef CONFIG_MACH_GC1
		if (system_rev < 6 && system_rev >= 2
				&& zoomkey && state) {
			tmp_bdata = &ddata->data[index_hotkey];

			if (tmp_bdata->key_state) {
#ifdef CONFIG_SAMSUNG_PRODUCT_SHIP
				printk(KERN_DEBUG"[KEYS] overlapped\n");
#else
				printk(KERN_DEBUG"[KEYS] overlapped. Forced release c %d h %d\n",
					tmp_bdata->button->code, hotkey);
#endif
				input_event(input, type, hotkey, 0);
				input_sync(input);

				overlapped = true;
			}
		}
#endif
		input_event(input, type, button->code, !!state);
		input_sync(input);

		if (button->code == KEY_POWER)
			printk(KERN_DEBUG"[keys]PWR %d\n", !!state);
	}
}