Advertisement
Guest User

Untitled

a guest
Dec 29th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.87 KB | None | 0 0
  1. Index: firmware/export/config/samsungypr0.h
  2. ===================================================================
  3. --- firmware/export/config/samsungypr0.h (revision 31464)
  4. +++ firmware/export/config/samsungypr0.h (working copy)
  5. @@ -33,7 +33,6 @@
  6. #define HAVE_LCD_COLOR
  7.  
  8. /* define this if the LCD needs to be shutdown */
  9. -/* TODO: Our framebuffer must be closed... */
  10. #define HAVE_LCD_SHUTDOWN
  11.  
  12. /* define this if you want album art for this target */
  13. @@ -90,7 +89,6 @@
  14. //#define HAVE_RTC_RAM
  15.  
  16. /* define this if you have a real-time clock */
  17. -//#define CONFIG_RTC APPLICATION
  18. #define CONFIG_RTC RTC_AS3514
  19. #define HAVE_RTC_ALARM
  20.  
  21. @@ -122,8 +120,7 @@
  22. /* #define CONFIG_TUNER SI4700 */
  23. /* #define HAVE_TUNER_PWR_CTRL*/
  24.  
  25. -/*TODO: In R0 there is an interrupt for this (figure out ioctls)*/
  26. -/* #define HAVE_HEADPHONE_DETECTION */
  27. +#define HAVE_HEADPHONE_DETECTION
  28.  
  29. /* Define current usage levels. */
  30. /* TODO: to be filled with correct values after implementing power management */
  31. Index: firmware/SOURCES
  32. ===================================================================
  33. --- firmware/SOURCES (revision 31464)
  34. +++ firmware/SOURCES (working copy)
  35. @@ -82,6 +82,7 @@
  36. #endif
  37. target/hosted/ypr0/ascodec-ypr0.c
  38. target/hosted/ypr0/powermgmt-ypr0.c
  39. +target/hosted/ypr0/gpio_ypr0.c
  40. #endif
  41.  
  42. /* Maemo specific files */
  43. Index: firmware/target/hosted/ypr0/button-ypr0.c
  44. ===================================================================
  45. --- firmware/target/hosted/ypr0/button-ypr0.c (revision 31464)
  46. +++ firmware/target/hosted/ypr0/button-ypr0.c (working copy)
  47. @@ -28,6 +28,7 @@
  48. #include "kernel.h"
  49. #include "system.h"
  50. #include "button-target.h"
  51. +#include <gpio_ypr0.h> /* For headphones sense */
  52.  
  53. /* R0 physical key codes */
  54. enum ypr0_buttons {
  55. @@ -45,6 +46,7 @@
  56.  
  57.  
  58. static int r0_btn_fd = 0;
  59. +
  60. /* Samsung keypad driver doesn't allow multiple key combinations :( */
  61. static enum ypr0_buttons r0_read_key(void)
  62. {
  63. @@ -82,6 +84,11 @@
  64. return key_to_button(r0_read_key());
  65. }
  66.  
  67. +bool headphones_inserted(void)
  68. +{
  69. + /* GPIO low - 0 - means headphones inserted */
  70. + return (gpio_control(MXC_GET_GPIO_DATAIN, GPIO_HEADPHONE_SENSE) == 1) ? false : true;
  71. +}
  72.  
  73. /* Open the keypad device: it is offered by r0Btn.ko module */
  74. void button_init_device(void)
  75. @@ -89,6 +96,9 @@
  76. r0_btn_fd = open("/dev/r0Btn", O_RDONLY);
  77. if (r0_btn_fd < 0)
  78. printf("/dev/r0Btn open error!");
  79. +
  80. + /* As done in the OF...But it's not necessary (or is the ioctl that doesn't work :D) */
  81. + gpio_control(MXC_SET_GPIO_DIRECTION_TO_INPUT, GPIO_HEADPHONE_SENSE);
  82. }
  83.  
  84. #ifdef BUTTON_DRIVER_CLOSE
  85. Index: firmware/target/hosted/ypr0/button-target.h
  86. ===================================================================
  87. --- firmware/target/hosted/ypr0/button-target.h (revision 31464)
  88. +++ firmware/target/hosted/ypr0/button-target.h (working copy)
  89. @@ -5,7 +5,7 @@
  90. * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
  91. * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
  92. * \/ \/ \/ \/ \/
  93. - * $Id: button-target.h 29248 2011-02-08 20:05:25Z thomasjfox $
  94. + * $Id$
  95. *
  96. * Copyright (C) 2011 by Lorenzo Miori
  97. *
  98. @@ -25,6 +25,8 @@
  99. #include <stdbool.h>
  100. #include "config.h"
  101.  
  102. +bool headphones_inserted(void);
  103. +
  104. void button_init_device(void);
  105. void button_close_device(void);
  106. int button_read_device(void);
  107. Index: firmware/target/hosted/ypr0/gpio_ypr0.c
  108. ===================================================================
  109. --- firmware/target/hosted/ypr0/gpio_ypr0.c (revision 0)
  110. +++ firmware/target/hosted/ypr0/gpio_ypr0.c (revision 0)
  111. @@ -0,0 +1,53 @@
  112. +/***************************************************************************
  113. + * __________ __ ___.
  114. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___
  115. + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
  116. + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
  117. + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
  118. + * \/ \/ \/ \/ \/
  119. + * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
  120. + *
  121. + * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
  122. + *
  123. + * Copyright (c) 2011 Lorenzo Miori
  124. + *
  125. + * This program is free software; you can redistribute it and/or
  126. + * modify it under the terms of the GNU General Public License
  127. + * as published by the Free Software Foundation; either version 2
  128. + * of the License, or (at your option) any later version.
  129. + *
  130. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  131. + * KIND, either express or implied.
  132. + *
  133. + ****************************************************************************/
  134. +
  135. +#include <stdio.h>
  136. +#include <unistd.h>
  137. +#include <fcntl.h>
  138. +#include <gpio_ypr0.h>
  139. +#include <sys/ioctl.h>
  140. +
  141. +static int r0_gpio_dev = 0;
  142. +
  143. +void gpio_init(void)
  144. +{
  145. + /* to_be_removed ... Had to place the opening there, since otherwise rockbox seemed to be like freezed, if
  146. + * I put the file opening in the headphones_inserted function. Shouldn't we perhaps also take care about
  147. + * charger_inserted function?
  148. + * It seems that opening the device just one time it's a lot better for performances...
  149. + */
  150. + r0_gpio_dev = open("/dev/r0GPIO", O_RDONLY);
  151. + if (r0_gpio_dev < 0)
  152. + printf("/dev/r0GPIO open error!");
  153. +}
  154. +
  155. +void gpio_close(void)
  156. +{
  157. + if (r0_gpio_dev < 0)
  158. + close(r0_gpio_dev);
  159. +}
  160. +
  161. +int gpio_control(int request, int pin)
  162. +{
  163. + return ioctl(r0_gpio_dev, request, &pin);
  164. +}
  165. \ No newline at end of file
  166. Index: firmware/target/hosted/ypr0/system-ypr0.c
  167. ===================================================================
  168. --- firmware/target/hosted/ypr0/system-ypr0.c (revision 31464)
  169. +++ firmware/target/hosted/ypr0/system-ypr0.c (working copy)
  170. @@ -31,6 +31,7 @@
  171. #endif
  172.  
  173. #include "ascodec-target.h"
  174. +#include <gpio_ypr0.h>
  175.  
  176. void sim_do_exit(void)
  177. {
  178. @@ -41,6 +42,7 @@
  179. {
  180. /* Something that we need to do before exit on our platform YPR0 */
  181. ascodec_close();
  182. + gpio_close();
  183. sim_do_exit();
  184. }
  185.  
  186. @@ -57,6 +59,7 @@
  187. #endif
  188. /* Here begins our platform specific initilization for various things */
  189. ascodec_init();
  190. + gpio_init();
  191. }
  192.  
  193.  
  194. Index: firmware/target/hosted/ypr0/gpio_ypr0.h
  195. ===================================================================
  196. --- firmware/target/hosted/ypr0/gpio_ypr0.h (revision 0)
  197. +++ firmware/target/hosted/ypr0/gpio_ypr0.h (revision 0)
  198. @@ -0,0 +1,57 @@
  199. +/***************************************************************************
  200. + * __________ __ ___.
  201. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___
  202. + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
  203. + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
  204. + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
  205. + * \/ \/ \/ \/ \/
  206. + * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
  207. + *
  208. + * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
  209. + *
  210. + * Copyright (c) 2011 Lorenzo Miori
  211. + *
  212. + * This program is free software; you can redistribute it and/or
  213. + * modify it under the terms of the GNU General Public License
  214. + * as published by the Free Software Foundation; either version 2
  215. + * of the License, or (at your option) any later version.
  216. + *
  217. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  218. + * KIND, either express or implied.
  219. + *
  220. + ****************************************************************************/
  221. +
  222. +#ifndef GPIO_YPR0_H
  223. +#define GPIO_YPR0_H
  224. +
  225. +/* Defines for the available ioctls for the device */
  226. +
  227. +#define MXC_REQUEST_IOMUX 0x400C4700
  228. +#define MXC_IOMUX_SET_PAD 0x400C4701
  229. +#define MXC_FREE_IOMUX 0x400C4702
  230. +#define MXC_SET_GPIO_DIRECTION_TO_OUTPUT 0x400C4703
  231. +#define MXC_SET_GPIO_DIRECTION_TO_INPUT 0x400C4704
  232. +#define MXC_SET_GPIO_DATAOUT_TO_1 0x400C4705
  233. +#define MXC_SET_GPIO_DATAOUT_TO_0 0x400C4706
  234. +/* The first appears to be 7 in IDA, but it's 8 in a reversed OF lib
  235. + Maybe, some IDs are to be switched by 1...CHECK THAT!
  236. +*/
  237. +/* Perhaps this isn't used... */
  238. +#define MXC_GET_GPIO_DATAIN_UNKNOWN 0x400C4707
  239. +/* This one works fine */
  240. +#define MXC_GET_GPIO_DATAIN 0x400C4708
  241. +
  242. +/* Don't know if it is correct...*/
  243. +#define PINS 145
  244. +
  245. +/* Some meaningful pins that are used on R0 */
  246. +
  247. +#define GPIO_HEADPHONE_SENSE 5
  248. +#define GPIO_EXT_PWR_SENSE 26
  249. +#define GPIO_SD_SENSE 59
  250. +
  251. +void gpio_init(void);
  252. +void gpio_close(void);
  253. +int gpio_control(int request, int pin);
  254. +
  255. +#endif
  256. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement