Advertisement
Guest User

Untitled

a guest
Nov 17th, 2011
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.25 KB | None | 0 0
  1. commit d100cff8c72292b8ab2408c7cdb815080be358df
  2. Author: Marcin Bukat <marcin.bukat@gmail.com>
  3. Date:   Thu Nov 17 01:05:29 2011 +0100
  4.  
  5.     fix scrollstrip problems at driver level
  6.  
  7. diff --git a/firmware/target/coldfire/mpio/hd300/button-hd300.c b/firmware/target/coldfire/mpio/hd300/button-hd300.c
  8. index 8239b54..ae0b1e1 100644
  9. --- a/firmware/target/coldfire/mpio/hd300/button-hd300.c
  10. +++ b/firmware/target/coldfire/mpio/hd300/button-hd300.c
  11. @@ -29,10 +29,17 @@
  12.  #include "powermgmt.h"
  13.  
  14.  #define SLIDER_BASE_SENSITIVITY 8
  15. +#define SLIDER_REL_TIMEOUT HZ
  16.  
  17.  /* GPI7 H-L, GPI6 H-L, GPI7 L-H, GPI6 L-H */
  18.  #define SLIDER_GPIO_MASK ((1<<15)|(1<<14)|(1<<7)|(1<<6))
  19.  
  20. +static volatile struct scroll_state_t {
  21. +    signed char dir;
  22. +    long timeout;
  23. +    bool rel;
  24. +} scroll;
  25. +
  26.  static inline void disable_scrollstrip_interrupts(void)
  27.  {
  28.     and_l(~SLIDER_GPIO_MASK,&GPIO_INT_EN);
  29. @@ -89,10 +96,20 @@ void scrollstrip_isr(void)
  30.  
  31.      scroll_dir = scroll_state[prev_scroll_lines][new_scroll_lines];
  32.      prev_scroll_lines = new_scroll_lines;
  33. -    
  34. +
  35. +    /* catch sequence error */
  36. +    if (scroll_dir == BUTTON_NONE)
  37. +        return;
  38. +
  39. +    /* direction reversal */
  40.      if (direction != scroll_dir)
  41.      {
  42. -        /* direction reversal */
  43. +        /* post release event to the button queue */
  44. +        if (queue_empty(&button_queue))
  45. +            queue_post(&button_queue, direction|BUTTON_REL, 0);
  46. +
  47. +        scroll.rel = true;
  48. +
  49.          direction = scroll_dir;
  50.          count = 0;
  51.          ack_scrollstrip_interrupt();
  52. @@ -121,6 +138,10 @@ void scrollstrip_isr(void)
  53.      if (queue_empty(&button_queue))
  54.          queue_post(&button_queue, scroll_dir, 0);
  55.  
  56. +    scroll.dir = scroll_dir;
  57. +    scroll.timeout = current_tick + SLIDER_REL_TIMEOUT;
  58. +    scroll.rel = false;
  59. +
  60.      ack_scrollstrip_interrupt();
  61.      enable_scrollstrip_interrupts();
  62.  }
  63. @@ -235,5 +256,15 @@ int button_read_device(void)
  64.  
  65.      } /* !button_hold() */
  66.  
  67. +    if (!scroll.rel)
  68. +        if (TIME_AFTER(current_tick, scroll.timeout))
  69. +        {
  70. +            if (queue_empty(&button_queue))
  71. +            {
  72. +                queue_post(&button_queue, scroll.dir|BUTTON_REL, 0);
  73. +                scroll.rel = true;
  74. +            }
  75. +        }
  76. +
  77.      return btn;
  78.  }
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement