summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android/system-android.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/android/system-android.c')
-rw-r--r--firmware/target/hosted/android/system-android.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c
index d13b8d6462..6279504e48 100644
--- a/firmware/target/hosted/android/system-android.c
+++ b/firmware/target/hosted/android/system-android.c
@@ -23,6 +23,12 @@
23#include <setjmp.h> 23#include <setjmp.h>
24#include <jni.h> 24#include <jni.h>
25#include <pthread.h> 25#include <pthread.h>
26#if defined(DX50) || defined(DX90)
27#include <stdlib.h>
28#include <sys/reboot.h>
29#include <sys/stat.h>
30#include <stdio.h>
31#endif /* DX50 || DX90 */
26#include <unistd.h> 32#include <unistd.h>
27#include "config.h" 33#include "config.h"
28#include "system.h" 34#include "system.h"
@@ -31,40 +37,83 @@
31 37
32 38
33 39
40#if !defined(DX50) && !defined(DX90)
34/* global fields for use with various JNI calls */ 41/* global fields for use with various JNI calls */
35static JavaVM *vm_ptr; 42static JavaVM *vm_ptr;
36JNIEnv *env_ptr; 43JNIEnv *env_ptr;
37jobject RockboxService_instance; 44jobject RockboxService_instance;
38jclass RockboxService_class; 45jclass RockboxService_class;
46#endif /* !DX50 && !DX90 */
39 47
40uintptr_t *stackbegin; 48uintptr_t *stackbegin;
41uintptr_t *stackend; 49uintptr_t *stackend;
42 50
43extern int main(void); 51extern int main(void);
52#if !defined(DX50) && !defined(DX90)
44extern void telephony_init_device(void); 53extern void telephony_init_device(void);
45 54#endif
46void system_exception_wait(void) 55void system_exception_wait(void)
47{ 56{
57#if defined(DX50) || defined(DX90)
58 while(1);
59#else
48 intptr_t dummy = 0; 60 intptr_t dummy = 0;
49 while(button_read_device(&dummy) != BUTTON_BACK); 61 while(button_read_device(&dummy) != BUTTON_BACK);
62#endif /* DX50 || DX90 */
50} 63}
51 64
52void system_reboot(void) 65void system_reboot(void)
53{ 66{
67#if defined(DX50) || defined(DX90)
68 reboot(RB_AUTOBOOT);
69#else
54 power_off(); 70 power_off();
71#endif /* DX50 || DX90 */
55} 72}
56 73
74#if !defined(DX50) && !defined(DX90)
57/* this is used to return from the entry point of the native library. */ 75/* this is used to return from the entry point of the native library. */
58static jmp_buf poweroff_buf; 76static jmp_buf poweroff_buf;
77#endif
78
59void power_off(void) 79void power_off(void)
60{ 80{
81#if defined(DX50) || defined(DX90)
82 reboot(RB_POWER_OFF);
83#else
61 longjmp(poweroff_buf, 1); 84 longjmp(poweroff_buf, 1);
85#endif /* DX50 || DX90 */
62} 86}
63 87
64void system_init(void) 88void system_init(void)
65{ 89{
90#if defined(DX50) || defined(DX90)
91 volatile uintptr_t stack = 0;
92 stackbegin = stackend = (uintptr_t*) &stack;
93
94 struct stat m1, m2;
95 stat("/mnt/", &m1);
96 do
97 {
98 /* waiting for storage to get mounted */
99 stat("/sdcard/", &m2);
100 usleep(100000);
101 }
102 while(m1.st_dev == m2.st_dev);
103/* here would be the correct place for 'system("/system/bin/muteopen");' (headphone-out relay) but in pcm-dx50.c, pcm_play_dma_start()
104 the output capacitors are charged already a bit and the click of the headphone-connection-relay is softer */
105
106#if defined(DX90)
107 /* DAC needs to be unmuted on DX90 */
108 FILE * f = fopen("/sys/class/codec/wm8740_mute", "w");
109 fputc(0, f);
110 fclose(f);
111#endif /* DX90 */
112
113#else
66 /* no better place yet */ 114 /* no better place yet */
67 telephony_init_device(); 115 telephony_init_device();
116#endif /* DX50 || DX90 */
68} 117}
69 118
70int hostfs_init(void) 119int hostfs_init(void)
@@ -79,6 +128,7 @@ int hostfs_flush(void)
79 return 0; 128 return 0;
80} 129}
81 130
131#if !defined(DX50) && !defined(DX90)
82JNIEXPORT jint JNICALL 132JNIEXPORT jint JNICALL
83JNI_OnLoad(JavaVM *vm, void* reserved) 133JNI_OnLoad(JavaVM *vm, void* reserved)
84{ 134{
@@ -119,7 +169,7 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this)
119 /* simply return here. this will allow the VM to clean up objects and do 169 /* simply return here. this will allow the VM to clean up objects and do
120 * garbage collection */ 170 * garbage collection */
121} 171}
122 172#endif /* !DX50 && !DX90 */
123 173
124/* below is the facility for external (from other java threads) to safely call 174/* below is the facility for external (from other java threads) to safely call
125 * into our snative code. When extracting rockbox.zip the main function is 175 * into our snative code. When extracting rockbox.zip the main function is