Advertisement
techmik

lights diff

Aug 28th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.35 KB | None | 0 0
  1. techmik@techmik-acer ~ $ diff -bBw ~/Desktop/kang-lights.c ~/Desktop/neldar-lights.c
  2. 1a2,3
  3. >  * modified by Michael Richter
  4. >  *
  5. 3c5
  6. <  * Copyright (C) 2011 <kang@insecure.ws>
  7. ---
  8. >  * Copyright (C) 2010 Michael Richter (alias neldar)
  9. 17a20,21
  10. >
  11. > //#define LOG_NDEBUG 0
  12. 21a28
  13. > #include <unistd.h>
  14. 28a38,39
  15. > /******************************************************************************/
  16. >
  17. 30a42,58
  18. > static int g_haveTrackballLight = 0;
  19. > static struct light_state_t g_notification;
  20. > static struct light_state_t g_battery;
  21. > static int g_backlight = 170;     //modified by mr
  22. > static int g_trackball = -1;
  23. > static int g_buttons = 0;
  24. > static int g_attention = 0;
  25. >
  26. >
  27. > // begin modified by mr
  28. > char const*const LCD_FILE
  29. >         = "/sys/class/backlight/s5p_bl/brightness";
  30. >
  31. > #if 0
  32. > /* samsung  does have this sys/file in their liblights, may be they
  33. > *  implemented a specific light intensity/lcd-backlight brightness function
  34. > */
  35. 32,33c60,73
  36. < char const *const LCD_FILE = "/sys/class/backlight/s5p_bl/brightness";
  37. < char const *const LED_FILE = "/sys/class/misc/notification/led";
  38. ---
  39. > char const*const LIGHTSENSOR_FILE
  40. >         = "/sys/class/lightsensor/switch_cmd/lightsensor_file_state";
  41. > #endif
  42. >
  43. > char const*const BUTTON_FILE
  44. >         = "/sys/class/misc/melfas_touchkey/brightness";
  45. >  
  46. > char const*const NOTIFICATION_FILE
  47. >         = "/sys/class/misc/backlightnotification/notification_led";
  48. >  
  49. > //end modified by mr
  50. > /**
  51. >  * device methods
  52. >  */
  53. 35c75
  54. < static int write_int(char const *path, int value)
  55. ---
  56. > void init_globals(void)
  57. 37,38c77,78
  58. <   int fd;
  59. <   static int already_warned;
  60. ---
  61. >     // init the mutex
  62. >     pthread_mutex_init(&g_lock, NULL);
  63. 40c80
  64. <   already_warned = 0;
  65. ---
  66. > }
  67. 42,43c82,86
  68. <   LOGV("write_int: path %s, value %d", path, value);
  69. <   fd = open(path, O_RDWR);
  70. ---
  71. > static int
  72. > write_int(char const* path, int value)
  73. > {
  74. >     int fd;
  75. >     static int already_warned = 0;
  76. 44a88
  77. >     fd = open(path, O_RDWR);
  78. 60c104,105
  79. < static int rgb_to_brightness(struct light_state_t const *state)
  80. ---
  81. > static int
  82. > is_lit(struct light_state_t const* state)
  83. 62c107,108
  84. <   int color = state->color & 0x00ffffff;
  85. ---
  86. >     return state->color & 0x00ffffff;
  87. > }
  88. 63a110,113
  89. > static int
  90. > rgb_to_brightness(struct light_state_t const* state)
  91. > {
  92. >     int color = state->color & 0x00ffffff;
  93. 68c118,119
  94. < static int set_light_notifications(struct light_device_t* dev,
  95. ---
  96. > static int
  97. > set_light_backlight(struct light_device_t* dev,
  98. 70a122
  99. >     int err = 0;
  100. 72,73d123
  101. <   int v = 0;
  102. <   int ret = 0;
  103. 75,83c125,126
  104. <
  105. <   if (brightness+state->color == 0 || brightness > 100) {
  106. <       if (state->color & 0x00ffffff)
  107. <           v = 1;
  108. <   } else
  109. <       v = 0;
  110. <
  111. <   LOGI("color %u fm %u status %u is lit %u brightness", state->color, state->flashMode, v, (state->color & 0x00ffffff), brightness);
  112. <   ret = write_int(LED_FILE, v);
  113. ---
  114. >     g_backlight = brightness;
  115. >     err = write_int(LCD_FILE, brightness);
  116. 85c128
  117. <   return ret;
  118. ---
  119. >     return err;
  120. 88c131,132
  121. < static int set_light_backlight(struct light_device_t *dev,
  122. ---
  123. > static int
  124. > set_light_buttons(struct light_device_t* dev,
  125. 92,93c136
  126. <   int brightness = rgb_to_brightness(state);
  127. <
  128. ---
  129. >     int on = is_lit(state);
  130. 95,96c138,139
  131. <   err = write_int(LCD_FILE, brightness);
  132. <
  133. ---
  134. >     g_buttons = on;
  135. >     err = write_int(BUTTON_FILE, on?1:2);
  136. 101c144,160
  137. < static int close_lights(struct light_device_t *dev)
  138. ---
  139. > static int
  140. > set_light_notifications(struct light_device_t* dev,
  141. >         struct light_state_t const* state)
  142. > {
  143. >     int err = 0;
  144. >     int on = is_lit(state);
  145. >     LOGV("%s color=%08x flashMode=%d flashOnMS=%d flashOffMS=%d\n", __func__,
  146. >           state->color, state->flashMode, state->flashOnMS, state->flashOffMS);
  147. >     pthread_mutex_lock(&g_lock);
  148. >     g_buttons = on;
  149. >     err = write_int(NOTIFICATION_FILE, on?1:0);
  150. >     pthread_mutex_unlock(&g_lock);
  151. >     return err;
  152. > }
  153. > /** Close the lights device */
  154. > static int
  155. > close_lights(struct light_device_t *dev)
  156. 103,104c162
  157. <   LOGV("close_light is called");
  158. <   if (dev)
  159. ---
  160. >     if (dev) {
  161. 106c164
  162. <
  163. ---
  164. >     }
  165. 109a168,175
  166. >
  167. > /******************************************************************************/
  168. >
  169. > /**
  170. >  * module methods
  171. >  */
  172. >
  173. > /** Open a new instance of a lights device using name */
  174. 115,118c181
  175. <
  176. <   LOGV("open_lights: open with %s", name);
  177. <
  178. <   if (0 == strcmp(LIGHT_ID_BACKLIGHT, name))
  179. ---
  180. >     if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) {
  181. 120c183,192
  182. <   else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name))
  183. ---
  184. >     }
  185. >     else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) {
  186. >         set_light = set_light_buttons;
  187. >     }
  188. > #if 0 //modified by mr
  189. >     else if (0 == strcmp(LIGHT_ID_BATTERY, name)) {
  190. >         set_light = set_light_battery; //to notification
  191. >     }
  192. > #endif
  193. >     else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) {
  194. 122c194,195
  195. <   else
  196. ---
  197. >     }
  198. >     else {
  199. 123a197
  200. >     }
  201. 125c199,200
  202. <   pthread_mutex_init(&g_lock, NULL);
  203. ---
  204. >
  205. >     pthread_once(&g_init, init_globals);
  206. 144a220,222
  207. > /*
  208. >  * The lights Module
  209. >  */
  210. 150,151c228,229
  211. <   .name = "lights Module",
  212. <   .author = "Google, Inc.",
  213. ---
  214. >     .name = "Samsung i9000 custom lights module",
  215. >     .author = "Michael Richter (alias mr)",
  216. techmik@techmik-acer ~ $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement