Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 29th, 2011  |  syntax: None  |  size: 8.16 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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 */
  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/gpio_ypr0.h
  167. ===================================================================
  168. --- firmware/target/hosted/ypr0/gpio_ypr0.h     (revision 0)
  169. +++ firmware/target/hosted/ypr0/gpio_ypr0.h     (revision 0)
  170. @@ -0,0 +1,57 @@
  171. +/***************************************************************************
  172. + *             __________               __   ___.
  173. + *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  174. + *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  175. + *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  176. + *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  177. + *                     \/            \/     \/    \/            \/
  178. + * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
  179. + *
  180. + * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0
  181. + *
  182. + * Copyright (c) 2011 Lorenzo Miori
  183. + *
  184. + * This program is free software; you can redistribute it and/or
  185. + * modify it under the terms of the GNU General Public License
  186. + * as published by the Free Software Foundation; either version 2
  187. + * of the License, or (at your option) any later version.
  188. + *
  189. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  190. + * KIND, either express or implied.
  191. + *
  192. + ****************************************************************************/
  193. +
  194. +#ifndef GPIO_YPR0_H
  195. +#define GPIO_YPR0_H
  196. +
  197. +/* Defines for the available ioctls for the device */
  198. +
  199. +#define MXC_REQUEST_IOMUX                       0x400C4700
  200. +#define MXC_IOMUX_SET_PAD                       0x400C4701
  201. +#define MXC_FREE_IOMUX                          0x400C4702
  202. +#define MXC_SET_GPIO_DIRECTION_TO_OUTPUT        0x400C4703
  203. +#define MXC_SET_GPIO_DIRECTION_TO_INPUT         0x400C4704
  204. +#define MXC_SET_GPIO_DATAOUT_TO_1               0x400C4705
  205. +#define MXC_SET_GPIO_DATAOUT_TO_0               0x400C4706
  206. +/* The first appears to be 7 in IDA, but it's 8 in a reversed OF lib
  207. +   Maybe, some IDs are to be switched by 1...CHECK THAT!
  208. +*/
  209. +/* Perhaps this isn't used... */
  210. +#define MXC_GET_GPIO_DATAIN_UNKNOWN             0x400C4707
  211. +/* This one works fine */
  212. +#define MXC_GET_GPIO_DATAIN                     0x400C4708
  213. +
  214. +/* Don't know if it is correct...*/
  215. +#define PINS 145
  216. +
  217. +/* Some meaningful pins that are used on R0 */
  218. +
  219. +#define GPIO_HEADPHONE_SENSE          5
  220. +#define GPIO_EXT_PWR_SENSE            26
  221. +#define GPIO_SD_SENSE                 59
  222. +
  223. +void gpio_init(void);
  224. +void gpio_close(void);
  225. +int gpio_control(int request, int pin);
  226. +
  227. +#endif
  228. \ No newline at end of file