summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android/system-android.c
diff options
context:
space:
mode:
authorUdo Schläpfer <rockbox-2014.10@desktopwarrior.net>2015-02-02 21:44:29 +0100
committerUdo Schläpfer <rockbox-2014.10@desktopwarrior.net>2015-02-02 21:57:55 +0100
commitdbabd0d9c34a33bc0c51243ec37f230d117db955 (patch)
tree46de348929ce739702a230a2587fdb5539585753 /firmware/target/hosted/android/system-android.c
parentcef17e3d59ad93f766e8ee23b1610540a33dfe5e (diff)
downloadrockbox-dbabd0d9c34a33bc0c51243ec37f230d117db955.tar.gz
rockbox-dbabd0d9c34a33bc0c51243ec37f230d117db955.zip
iBasso DX50/DX90: Major code cleanup and reorganization.
Reorganization - Separated iBasso devices from PLATFORM_ANDROID. These are now standlone hosted targets. Most device specific code is in the firmware/target/hosted/ibasso directory. - No dependency on Android SDK, only the Android NDK is needed. 32 bit Android NDK and Android API Level 16. - Separate implementation for each device where feasible. Code cleanup - Rewrite of existing code, from simple reformat to complete reimplementation. - New backlight interface, seperating backlight from touchscreen. - Rewrite of device button handler, removing unneeded code and fixing memory leaks. - New Debug messages interface logging to Android adb logcat (DEBUGF, panicf, logf). - Rewrite of lcd device handler, removing unneeded code and fixing memory leaks. - Rewrite of audiohw device handler/pcm interface, removing unneeded code and fixing memory leaks, enabling 44.1/48kHz pthreaded playback. - Rewrite of power and powermng, proper shutdown, using batterylog results (see http://gerrit.rockbox.org/r/#/c/1047/). - Rewrite of configure (Android NDK) and device specific config. - Rewrite of the Android NDK specific Makefile. Misc - All plugins/games/demos activated. - Update tinyalsa to latest from https://github.com/tinyalsa/tinyalsa. Includes - http://gerrit.rockbox.org/r/#/c/993/ - http://gerrit.rockbox.org/r/#/c/1010/ - http://gerrit.rockbox.org/r/#/c/1035/ Does not include http://gerrit.rockbox.org/r/#/c/1007/ due to new backlight interface and new option for hold switch, touchscreen, physical button interaction. Rockbox needs the iBasso DX50/DX90 loader for startup, see http://gerrit.rockbox.org/r/#/c/1099/ The loader expects Rockbox to be installed in /mnt/sdcard/.rockbox/. If /mnt/sdcard/ is accessed as USB mass storage device, Rockbox will exit gracefully and the loader will restart Rockbox on USB disconnect. Tested on iBasso DX50. Compiled (not tested) for iBasso DX90. Compiled (not tested) for PLATFORM_ANDROID. Change-Id: I5f5e22e68f5b4cf29c28e2b40b2c265f2beb7ab7
Diffstat (limited to 'firmware/target/hosted/android/system-android.c')
-rw-r--r--firmware/target/hosted/android/system-android.c54
1 files changed, 2 insertions, 52 deletions
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c
index 6279504e48..d13b8d6462 100644
--- a/firmware/target/hosted/android/system-android.c
+++ b/firmware/target/hosted/android/system-android.c
@@ -23,12 +23,6 @@
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 */
32#include <unistd.h> 26#include <unistd.h>
33#include "config.h" 27#include "config.h"
34#include "system.h" 28#include "system.h"
@@ -37,83 +31,40 @@
37 31
38 32
39 33
40#if !defined(DX50) && !defined(DX90)
41/* global fields for use with various JNI calls */ 34/* global fields for use with various JNI calls */
42static JavaVM *vm_ptr; 35static JavaVM *vm_ptr;
43JNIEnv *env_ptr; 36JNIEnv *env_ptr;
44jobject RockboxService_instance; 37jobject RockboxService_instance;
45jclass RockboxService_class; 38jclass RockboxService_class;
46#endif /* !DX50 && !DX90 */
47 39
48uintptr_t *stackbegin; 40uintptr_t *stackbegin;
49uintptr_t *stackend; 41uintptr_t *stackend;
50 42
51extern int main(void); 43extern int main(void);
52#if !defined(DX50) && !defined(DX90)
53extern void telephony_init_device(void); 44extern void telephony_init_device(void);
54#endif 45
55void system_exception_wait(void) 46void system_exception_wait(void)
56{ 47{
57#if defined(DX50) || defined(DX90)
58 while(1);
59#else
60 intptr_t dummy = 0; 48 intptr_t dummy = 0;
61 while(button_read_device(&dummy) != BUTTON_BACK); 49 while(button_read_device(&dummy) != BUTTON_BACK);
62#endif /* DX50 || DX90 */
63} 50}
64 51
65void system_reboot(void) 52void system_reboot(void)
66{ 53{
67#if defined(DX50) || defined(DX90)
68 reboot(RB_AUTOBOOT);
69#else
70 power_off(); 54 power_off();
71#endif /* DX50 || DX90 */
72} 55}
73 56
74#if !defined(DX50) && !defined(DX90)
75/* this is used to return from the entry point of the native library. */ 57/* this is used to return from the entry point of the native library. */
76static jmp_buf poweroff_buf; 58static jmp_buf poweroff_buf;
77#endif
78
79void power_off(void) 59void power_off(void)
80{ 60{
81#if defined(DX50) || defined(DX90)
82 reboot(RB_POWER_OFF);
83#else
84 longjmp(poweroff_buf, 1); 61 longjmp(poweroff_buf, 1);
85#endif /* DX50 || DX90 */
86} 62}
87 63
88void system_init(void) 64void system_init(void)
89{ 65{
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
114 /* no better place yet */ 66 /* no better place yet */
115 telephony_init_device(); 67 telephony_init_device();
116#endif /* DX50 || DX90 */
117} 68}
118 69
119int hostfs_init(void) 70int hostfs_init(void)
@@ -128,7 +79,6 @@ int hostfs_flush(void)
128 return 0; 79 return 0;
129} 80}
130 81
131#if !defined(DX50) && !defined(DX90)
132JNIEXPORT jint JNICALL 82JNIEXPORT jint JNICALL
133JNI_OnLoad(JavaVM *vm, void* reserved) 83JNI_OnLoad(JavaVM *vm, void* reserved)
134{ 84{
@@ -169,7 +119,7 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this)
169 /* simply return here. this will allow the VM to clean up objects and do 119 /* simply return here. this will allow the VM to clean up objects and do
170 * garbage collection */ 120 * garbage collection */
171} 121}
172#endif /* !DX50 && !DX90 */ 122
173 123
174/* below is the facility for external (from other java threads) to safely call 124/* below is the facility for external (from other java threads) to safely call
175 * into our snative code. When extracting rockbox.zip the main function is 125 * into our snative code. When extracting rockbox.zip the main function is