X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=drivers%2Finput%2Fremotectl%2Frockchip_pwm_remotectl.c;h=2b58628880860a3b8f8600d87cc4a9167a1c14b0;hb=2ae05321496aa27767bc33a5cc19451b3db67919;hp=831d46cc9bb5df32c6180445d584e5da462eae15;hpb=45cd824a30a8f289e9f7786574a9f29dbded8211;p=firefly-linux-kernel-4.4.55.git diff --git a/drivers/input/remotectl/rockchip_pwm_remotectl.c b/drivers/input/remotectl/rockchip_pwm_remotectl.c index 831d46cc9bb5..2b5862888086 100644 --- a/drivers/input/remotectl/rockchip_pwm_remotectl.c +++ b/drivers/input/remotectl/rockchip_pwm_remotectl.c @@ -12,13 +12,14 @@ #include #include #include "rockchip_pwm_remotectl.h" - - +#include +#include /*sys/module/rk_pwm_remotectl/parameters, modify code_print to change the value*/ static int rk_remote_print_code; +static bool remote_suspend = false; module_param_named(code_print, rk_remote_print_code, int, 0644); #define DBG_CODE(args...) \ do { \ @@ -36,7 +37,19 @@ module_param_named(dbg_level, rk_remote_pwm_dbg_level, int, 0644); } \ } while (0) +#define BLINK_DELAY 50 +DEFINE_LED_TRIGGER(ledtrig_ir_click); +static unsigned long ir_blink_delay = BLINK_DELAY; + +bool get_state_remotectl(void) +{ + return remote_suspend; +} +void ledtrig_ir_activity(void) +{ + led_trigger_blink_oneshot(ledtrig_ir_click, &ir_blink_delay, &ir_blink_delay,1); +} struct rkxx_remote_key_table { int scancode; int keycode; @@ -220,6 +233,13 @@ static void rk_pwm_remotectl_do_something(unsigned long data) } break; case RMC_GETDATA: { + if(!get_state_remotectl() && (ddata->keycode != KEY_POWER)) + { + ledtrig_ir_activity(); + } + if(ddata->keycode != KEY_POWER) + led_trigger_blink_oneshot(ledtrig_ir_click, &ir_blink_delay, &ir_blink_delay,1); + if ((RK_PWM_TIME_BIT1_MIN < ddata->period) && (ddata->period < RK_PWM_TIME_BIT1_MAX)) ddata->scandata |= (0x01<count); @@ -231,6 +251,9 @@ static void rk_pwm_remotectl_do_something(unsigned long data) ((~ddata->scandata >> 8) & 0x0ff)) { if (remotectl_keycode_lookup(ddata)) { ddata->press = 1; + if(ddata->keycode== KEY_POWER && !get_state_remotectl()){ + led_trigger_event(ledtrig_ir_click,LED_OFF); + } input_event(ddata->input, EV_KEY, ddata->keycode, 1); input_sync(ddata->input); @@ -322,8 +345,10 @@ static irqreturn_t rockchip_pwm_irq(int irq, void *dev_id) } } writel_relaxed(PWM_CH_INT(id), ddata->base + PWM_REG_INTSTS(id)); +#if ! defined(CONFIG_RK_IR_NO_DEEP_SLEEP) if (ddata->state == RMC_PRELOAD) wake_lock_timeout(&ddata->remotectl_wake_lock, HZ); +#endif return IRQ_HANDLED; } @@ -376,6 +401,35 @@ static int rk_pwm_remotectl_hw_init(struct rkxx_remotectl_drvdata *ddata) return 0; } +static int remotectl_fb_event_notify(struct notifier_block *self, unsigned long action, void *data) +{ + struct fb_event *event = data; + + if (action == FB_EARLY_EVENT_BLANK) { + switch (*((int *)event->data)) { + case FB_BLANK_UNBLANK: + break; + default: + led_trigger_event(ledtrig_ir_click,LED_OFF); + remote_suspend = true; + break; + } + } + else if (action == FB_EVENT_BLANK) { + switch (*((int *)event->data)) { + case FB_BLANK_UNBLANK: + remote_suspend = false; + led_trigger_event(ledtrig_ir_click,LED_FULL); + break; + default: + break; + } + } + return NOTIFY_OK; +} +static struct notifier_block remotectl_fb_notifier = { + .notifier_call = remotectl_fb_event_notify, +}; static int rk_pwm_probe(struct platform_device *pdev) { @@ -437,8 +491,12 @@ static int rk_pwm_probe(struct platform_device *pdev) input->id.version = 0x0100; ddata->input = input; ddata->input = input; + fb_register_client(&remotectl_fb_notifier); wake_lock_init(&ddata->remotectl_wake_lock, WAKE_LOCK_SUSPEND, "rk29_pwm_remote"); +#if defined(CONFIG_RK_IR_NO_DEEP_SLEEP) + wake_lock(&ddata->remotectl_wake_lock); +#endif ret = clk_prepare_enable(clk); if (ret) return ret; @@ -488,11 +546,20 @@ static int rk_pwm_probe(struct platform_device *pdev) rk_pwm_remotectl_hw_init(ddata); pwm_freq = clk_get_rate(clk) / 64; ddata->pwm_freq_nstime = 1000000000 / pwm_freq; + led_trigger_register_simple("ir-power-click", &ledtrig_ir_click); + return ret; } static int rk_pwm_remove(struct platform_device *pdev) { +#if defined(CONFIG_RK_IR_NO_DEEP_SLEEP) + struct rkxx_remotectl_drvdata *ddata = platform_get_drvdata(pdev); +#endif + led_trigger_unregister_simple(ledtrig_ir_click); +#if defined(CONFIG_RK_IR_NO_DEEP_SLEEP) + wake_unlock(&ddata->remotectl_wake_lock); +#endif return 0; } @@ -517,6 +584,7 @@ static int remotectl_resume(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct rkxx_remotectl_drvdata *ddata = platform_get_drvdata(pdev); + led_trigger_event(ledtrig_ir_click,LED_FULL); cpumask_clear(&cpumask); cpumask_set_cpu(ddata->handle_cpu_id, &cpumask); irq_set_affinity(ddata->irq, &cpumask);