From 133c72daf2aa36cd4eb88bd40380944690a44bc4 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 1 Aug 2010 21:05:33 +0200 Subject: [PATCH] Change application selection in configure. Make android raaa compile. --- apps/codecs/libwavpack/wavpack.h | 3 +- apps/main.c | 12 +-- firmware/SOURCES | 10 ++ firmware/export/audiohw.h | 2 +- firmware/export/config.h | 5 +- firmware/export/config/application.h | 8 +- firmware/export/thread.h | 9 ++ firmware/target/hosted/android/button-android.c | 5 + firmware/target/hosted/android/kernel-android.c | 5 + firmware/target/hosted/android/system-android.c | 1 + firmware/thread.c | 4 +- tools/configure | 124 ++++++++++++++++++------ uisimulator/common/io.c | 22 +++-- uisimulator/common/stubs.c | 9 +- 14 files changed, 168 insertions(+), 51 deletions(-) diff --git a/apps/codecs/libwavpack/wavpack.h b/apps/codecs/libwavpack/wavpack.h index 5b5385a52..4ce1e8069 100644 --- a/apps/codecs/libwavpack/wavpack.h +++ b/apps/codecs/libwavpack/wavpack.h @@ -15,9 +15,10 @@ // This header file contains all the definitions required by WavPack. typedef unsigned char uchar; +#if 0 typedef unsigned short ushort; typedef unsigned int uint; - +#endif #include #define FALSE 0 diff --git a/apps/main.c b/apps/main.c index 67cd6d2f0..742447c82 100644 --- a/apps/main.c +++ b/apps/main.c @@ -116,24 +116,19 @@ #include "sim_tasks.h" #endif -#ifdef HAVE_SDL -#include "system-sdl.h" -#endif - /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */ static void init(void); #ifdef HAVE_SDL +#include "system-sdl.h" + #if defined(WIN32) && defined(main) /* Don't use SDL_main on windows -> no more stdio redirection */ #undef main #endif int main(int argc, char *argv[]) { -#ifdef APPLICATION - paths_init(); -#endif sys_handle_argv(argc, argv); #else /* main(), and various functions called by main() and init() may be @@ -144,6 +139,9 @@ int main(void) INIT_ATTR __attribute__((noreturn)); int main(void) { #endif +#ifdef APPLICATION + paths_init(); +#endif int i; CHART(">init"); init(); diff --git a/firmware/SOURCES b/firmware/SOURCES index d8cfadef1..66d45f24e 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -1698,3 +1698,13 @@ target/coldfire/mpio/fmradio_i2c-mpio.c #endif /* BOOTLOADER */ #endif /* SIMULATOR */ #endif + +#if (CONFIG_PLATFORM & PLATFORM_ANDROID) +target/hosted/android/lcd-android.c +target/hosted/android/button-android.c +target/hosted/android/kernel-android.c +target/hosted/android/pcm-android.c +target/hosted/android/system-android.c +drivers/audio/android.c +thread.c +#endif diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index d4861aac5..8df5ab218 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h @@ -66,7 +66,7 @@ #elif defined(HAVE_AK4537) #include "ak4537.h" #endif -#if defined(HAVE_SDL_AUDIO) +#if defined(HAVE_SDL_AUDIO) || (CONFIG_PLATFORM & PLATFORM_ANDROID) /* #include gives errors in other code areas, * we don't really need it here, so don't. but it should maybe be fixed */ #ifndef SIMULATOR /* simulator gets values from the target .h files */ diff --git a/firmware/export/config.h b/firmware/export/config.h index 1b8a782f3..fe69ef499 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -78,8 +78,9 @@ * bit fields to allow PLATFORM_HOSTED to be OR'ed e.g. with a * possible future PLATFORM_ANDROID (some OSes might need totally different * handling to run on them than a stand-alone application) */ -#define PLATFORM_NATIVE (1<<0) -#define PLATFORM_HOSTED (1<<1) +#define PLATFORM_NATIVE (1<<0) +#define PLATFORM_HOSTED (1<<1) +#define PLATFORM_ANDROID (1<<2) /* CONFIG_KEYPAD */ #define PLAYER_PAD 1 diff --git a/firmware/export/config/application.h b/firmware/export/config/application.h index a5583ded7..1a1e4087b 100644 --- a/firmware/export/config/application.h +++ b/firmware/export/config/application.h @@ -4,7 +4,11 @@ #define TARGET_TREE /* this target is using the target tree system */ /* We don't run on hardware directly */ -#define CONFIG_PLATFORM PLATFORM_HOSTED +#ifdef ANDROID +#define CONFIG_PLATFORM (PLATFORM_HOSTED|PLATFORM_ANDROID) +#else +#define CONFIG_PLATFORM +#endif /* For Rolo and boot loader */ /* #define MODEL_NUMBER 24 @@ -63,7 +67,9 @@ #define CONFIG_KEYPAD COWON_D2_PAD /* Use SDL audio/pcm in a SDL app build */ +#if !(CONFIG_PLATFORM & PLATFORM_ANDROID) #define HAVE_SDL +#endif #ifdef HAVE_SDL #define HAVE_SDL_AUDIO diff --git a/firmware/export/thread.h b/firmware/export/thread.h index c4b7d1fa2..d6e38d1db 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h @@ -135,6 +135,15 @@ struct regs uint32_t start; /* 44 - Thread start address, or NULL when started */ }; #endif /* CONFIG_CPU */ +#elif (CONFIG_PLATFORM & PLATFORM_ANDROID) +/* same as for CPU_ARM */ +struct regs +{ + uint32_t r[8]; /* 0-28 - Registers r4-r11 */ + uint32_t sp; /* 32 - Stack pointer (r13) */ + uint32_t lr; /* 36 - r14 (lr) */ + uint32_t start; /* 40 - Thread start address, or NULL when started */ +}; #elif (CONFIG_PLATFORM & PLATFORM_HOSTED) struct regs { diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c index 0cac35fa2..67e8ca1f8 100644 --- a/firmware/target/hosted/android/button-android.c +++ b/firmware/target/hosted/android/button-android.c @@ -25,6 +25,7 @@ #include "config.h" #include "kernel.h" #include "system.h" +#include "touchscreen.h" static long last_touch; static int last_y, last_x; @@ -43,6 +44,8 @@ JNIEXPORT void JNICALL Java_org_rockbox_RockboxFramebuffer_pixelHandler(JNIEnv*env, jobject this, int x, int y) { + (void)env; + (void)this; last_x = x; last_y = y; last_touch = current_tick; @@ -55,6 +58,8 @@ JNIEXPORT void JNICALL Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this, int down) { + (void)env; + (void)this; if (down) last_state = STATE_DOWN; else diff --git a/firmware/target/hosted/android/kernel-android.c b/firmware/target/hosted/android/kernel-android.c index d590a960f..121f65200 100644 --- a/firmware/target/hosted/android/kernel-android.c +++ b/firmware/target/hosted/android/kernel-android.c @@ -74,11 +74,16 @@ void tick_start(unsigned int interval_in_ms) bool timer_register(int reg_prio, void (*unregister_callback)(void), long cycles, void (*timer_callback)(void)) { + (void)reg_prio; + (void)unregister_callback; + (void)cycles; + (void)timer_callback; return false; } bool timer_set_period(long cycles) { + (void)cycles; return false; } diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index 9b3bb6304..07dff2ed5 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c @@ -38,6 +38,7 @@ jclass RockboxActivity_class; uintptr_t *stackbegin; uintptr_t *stackend; +extern int main(void); /* this is the entry point of the android app initially called by jni */ JNIEXPORT void JNICALL Java_org_rockbox_RockboxActivity_main(JNIEnv *env, jobject this) diff --git a/firmware/thread.c b/firmware/thread.c index c00fc36e3..45a74b013 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -170,7 +170,9 @@ void switch_thread(void) /**************************************************************************** * Processor-specific section - include necessary core support */ -#if defined(CPU_ARM) +#if (CONFIG_PLATFORM & PLATFORM_ANDROID) +#include "thread-android-arm.c" +#elif defined(CPU_ARM) #include "thread-arm.c" #if defined (CPU_PP) #include "thread-pp.c" diff --git a/tools/configure b/tools/configure index ce23c2a96..311af7140 100755 --- a/tools/configure +++ b/tools/configure @@ -14,6 +14,7 @@ CCOPTS="-W -Wall -Wundef -O -nostdlib -ffreestanding -Wstrict-prototypes -pipe" # global LD options for all platforms GLOBAL_LDOPTS="" +extradefines="" use_logf="#undef ROCKBOX_HAS_LOGF" use_bootchart="#undef DO_BOOTCHART" @@ -25,7 +26,10 @@ bindir= libdir= bindir_full= libdir_full= - + +app_platform= +app_lcd_width= +app_lcd_height= # # Begin Function Definitions # @@ -47,6 +51,57 @@ prefixtools () { OC=${prefix}objcopy } +app_get_platform() { + echo "Select your platform: (S)DL, (A)ndroid (default: Android)" + choice=`input` + case $choice in + s|S*) app_platform="sdl-app" ;; + *|a|A*) app_platform="android" ;; + esac + + echo "Selected $app_platform platform" + echo "Select the LCD resolution seperated with enter: XxY (default: 320x480)" + app_lcd_width=`input` + if [ -z "$app_lcd_width" ]; then app_lcd_width="320"; fi + app_lcd_height=`input` + if [ -z "$app_lcd_height" ]; then app_lcd_height="480"; fi + echo "Selected $app_lcd_width x $app_lcd_height resolution" + + # setup files and paths depending on the platform + if [ "$app_platform" = "sdl" ]; then + if [ -z "$PREFIX" ]; then + rbdir="/usr/local/share/rockbox" + bindir="/usr/local/bin" + bindir_full=$bindir + libdir="/usr/local/lib" + libdir_full=$libdir + else + rbdir=`realpath $PREFIX/share/rockbox` + bindir="$PREFIX/bin" + libdir="$PREFIX/lib" + if [ -d bindir ]; then + bindir_full=`realpath $bindir` + fi + if [ -d libdir ]; then + libdir_full=`realpath $libdir` + fi + fi + output="rockbox" + bootoutput="rockbox" + elif [ "$app_platform" = "android" ]; then + if [ -n "$PREFIX" ]; then + echo "WARNING: PREFIX not supported on Android. You can however use --rbdir" + fi + rbdir="/sdcard/rockbox" + bindir="/data/data/org.rockbox/lib" + bindir_full=$bindir + libdir="/data/data/org.rockbox/app_rockbox" + libdir_full=$libdir + output="librockbox.so" + bootoutput="librockbox.so" + fi +} + findarmgcc() { if [ "$ARG_ARM_EABI" != "0" ]; then prefixtools arm-elf-eabi- @@ -102,6 +157,15 @@ findsdl(){ done } +appcc () { + if [ "$1" = "sdl" ]; then + simcc $1 + elif [ "$1" = "android" ]; then + app_type=$1 + androidcc + fi +} + simcc () { # default tool setup for native building @@ -188,6 +252,7 @@ simcc () { LDOPTS="$LDOPTS `$sdl --libs`" fi fi + GCCOPTS="$GCCOPTS -I\$(SIMDIR)" @@ -379,6 +444,18 @@ mipselcc () { gccchoice="4.1.2" } +androidcc () { + gccchoice="4.4.0" + prefixtools $ANDROID_NDK_PATH/build/prebuilt/linux-x86/arm-eabi-$gccchoice/bin/arm-eabi- + GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef//` + GCCOPTS="$GCCOPTS -std=gnu99 -ffunction-sections -fno-short-enums -march=armv5te -mtune=xscale -msoft-float -fomit-frame-pointer" + GLOBAL_LDOPTS="$GLOBAL_LDOPTS -nostdlib -lc -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -L$ANDROID_NDK_PATH/build/platforms/android-4/arch-arm/usr/lib/ -Wl,-rpath-link=$ANDROID_NKD_PATH/build/platforms/android-4/arch-arm/usr/lib" + LDOPTS="$LDOPTS -shared -nostdlib -lm -ldl" + extradefines="$extradefines -DANDROID" + endian="little" + SHARED_FLAG="-shared" +} + whichadvanced () { atype=`echo "$1" | cut -c 2-` ################################################################## @@ -975,7 +1052,7 @@ cat < #include #include -#ifndef WIN32 + +#define HAVE_STATVFS (!defined(WIN32) && !defined(ANDROID)) + +#if HAVE_STATVFS #include #endif @@ -41,14 +44,19 @@ #endif #include +#ifdef HAVE_SDL #include #include +#include "thread-sdl.h" +#else +#define sim_thread_unlock() NULL +#define sim_thread_lock(a) +#endif #include "thread.h" #include "kernel.h" #include "debug.h" #include "config.h" #include "ata.h" /* for IF_MV2 et al. */ -#include "thread-sdl.h" #include "rbpaths.h" /* keep this in sync with file.h! */ @@ -193,7 +201,7 @@ static unsigned int rockbox2sim(int opt) /** Simulator I/O engine routines **/ #define IO_YIELD_THRESHOLD 512 -enum +enum io_dir { IO_READ, IO_WRITE, @@ -225,7 +233,7 @@ int ata_spinup_time(void) return HZ; } -static ssize_t io_trigger_and_wait(int cmd) +static ssize_t io_trigger_and_wait(enum io_dir cmd) { void *mythread = NULL; ssize_t result; @@ -480,7 +488,7 @@ void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free) if (free) *free = free_clusters * secperclus / 2 * (bytespersec / 512); } -#else +#elif HAVE_STATVFS struct statvfs vfs; if (!statvfs(".", &vfs)) { @@ -490,9 +498,9 @@ void fat_size(IF_MV2(int volume,) unsigned long* size, unsigned long* free) *size = vfs.f_blocks / 2 * (vfs.f_frsize / 512); if (free) *free = vfs.f_bfree / 2 * (vfs.f_frsize / 512); - } + } else #endif - else { + { if (size) *size = 0; if (free) diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 6d7d7de06..38f94e97f 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -18,10 +18,15 @@ * KIND, either express or implied. * ****************************************************************************/ + #include #include #include +#include + +#ifdef HAVE_SDL #include "thread-sdl.h" +#endif #include "debug.h" @@ -35,7 +40,6 @@ #include "ata.h" /* for volume definitions */ -extern char having_new_lcd; static bool storage_spinning = false; #if CONFIG_CODEC != SWCODEC @@ -211,10 +215,13 @@ bool spdif_powered(void) } #endif +#ifdef HAVE_LCD_CHARCELLS +extern char having_new_lcd; bool is_new_player(void) { return having_new_lcd; } +#endif #ifdef HAVE_USB_POWER bool usb_powered(void) -- 2.11.4.GIT