From 38e6ceae7ab4e2a88e7bc78658ac02497ac89676 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 30 Jul 2010 15:39:09 +0200 Subject: [PATCH] Build the main binary and play music \o/ --- apps/codec_thread.c | 2 +- apps/codecs.c | 3 +- apps/codecs/codec_crt0.c | 3 + apps/codecs/codecs.make | 2 +- apps/codecs/libwavpack/wavpack.h | 4 + apps/codecs/mpa.c | 2 + apps/playback.c | 1 + firmware/SOURCES | 2 + firmware/drivers/audio/android.c | 57 ++++++ firmware/export/audiohw.h | 2 +- firmware/export/config.h | 2 +- firmware/export/debug.h | 2 +- firmware/export/thread.h | 2 +- firmware/target/hosted/android/kernel-android.c | 17 +- firmware/target/hosted/android/lcd-android.c | 203 +++++++++++++++++++++ firmware/target/hosted/android/pcm-android.c | 176 ++++++++++++++++++ firmware/target/hosted/android/system-android.c | 11 +- .../target/hosted/android/thread-android-arm.c | 11 +- firmware/thread.c | 10 +- tools/configure | 7 +- uisimulator/common/io.c | 14 ++ uisimulator/common/stubs.c | 4 +- uisimulator/uisimulator.make | 2 +- 23 files changed, 513 insertions(+), 26 deletions(-) create mode 100644 firmware/drivers/audio/android.c create mode 100644 firmware/target/hosted/android/pcm-android.c diff --git a/apps/codec_thread.c b/apps/codec_thread.c index 21d55a777..bde85402d 100644 --- a/apps/codec_thread.c +++ b/apps/codec_thread.c @@ -90,7 +90,7 @@ extern struct codec_api ci; /* from codecs.c */ unsigned int codec_thread_id; /* For modifying thread priority later. Used by playback.c and pcmbuf.c */ static struct queue_sender_list codec_queue_sender_list; -static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] +static long codec_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)] IBSS_ATTR; static const char codec_thread_name[] = "codec"; diff --git a/apps/codecs.c b/apps/codecs.c index 29a664425..e1db1b7c5 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -222,7 +222,6 @@ static int codec_load_ram(int size, struct codec_api *api) #elif (CONFIG_PLATFORM & PLATFORM_HOSTED) void *pd; - hdr = sim_codec_load_ram(codecbuf, size, &pd); if (pd == NULL) @@ -248,6 +247,7 @@ static int codec_load_ram(int size, struct codec_api *api) return CODEC_ERROR; } + LOG("%s(), %p %p %d %d", __func__, (void*)dlsym(pd, "codec_start"), hdr->entry_point, hdr->api_version, hdr->target_id); *(hdr->api) = api; cpucache_invalidate(); status = hdr->entry_point(); @@ -292,4 +292,5 @@ int codec_load_file(const char *plugin, struct codec_api *api) } return codec_load_ram((size_t)rc, api); + LOG("%s(): after codec_load_ram()", __func__); } diff --git a/apps/codecs/codec_crt0.c b/apps/codecs/codec_crt0.c index dd0f99ffd..6ef9d3c43 100644 --- a/apps/codecs/codec_crt0.c +++ b/apps/codecs/codec_crt0.c @@ -34,8 +34,11 @@ extern unsigned char plugin_end_addr[]; extern enum codec_status codec_main(void); +int _start(void) {} + enum codec_status codec_start(void) { + LOG("%s()", __func__); #if (CONFIG_PLATFORM & PLATFORM_NATIVE) #ifdef USE_IRAM ci->memcpy(iramstart, iramcopy, iramend - iramstart); diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make index 4ca54ce36..14982b47c 100644 --- a/apps/codecs/codecs.make +++ b/apps/codecs/codecs.make @@ -130,7 +130,7 @@ $(CODECDIR)/%.codec: $(CODECDIR)/%.o $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*.elf \ $(filter %.o, $^) \ $(filter %.a, $+) \ - -lgcc $(CODECLDFLAGS) + -lgcc $(CODECLDFLAGS) -nostdlib -lc -llog -Wl,-rpath,/home/kugel/android-ndk-r4/build/platforms/android-4/arch-arm/usr/lib/ -L/home/kugel/android-ndk-r4/build/platforms/android-4/arch-arm/usr/lib/ -Wl,-T,$(BUILDDIR)/armelf.xsc ifdef APP_TYPE $(SILENT)cp $(CODECDIR)/$*.elf $@ else diff --git a/apps/codecs/libwavpack/wavpack.h b/apps/codecs/libwavpack/wavpack.h index 5b5385a52..b9b08c831 100644 --- a/apps/codecs/libwavpack/wavpack.h +++ b/apps/codecs/libwavpack/wavpack.h @@ -16,7 +16,11 @@ typedef unsigned char uchar; typedef unsigned short ushort; +#ifndef uint +/* typedef unsigned int uint; +*/ +#endif #include diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index c0e0f38c6..daf187cdc 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c @@ -312,6 +312,8 @@ enum codec_status codec_main(void) unsigned long current_frequency = 0; int framelength; int padding = MAD_BUFFER_GUARD; /* to help mad decode the last frame */ + ci->debugf("Hello codec"); + if (codec_init()) return CODEC_ERROR; diff --git a/apps/playback.c b/apps/playback.c index e8a6efc10..2a6f144d2 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -2080,6 +2080,7 @@ void audio_init(void) talk_init(); make_codec_thread(); + LOG("codec thread created"); audio_thread_id = create_thread(audio_thread, audio_stack, sizeof(audio_stack), CREATE_THREAD_FROZEN, diff --git a/firmware/SOURCES b/firmware/SOURCES index 72af26e97..5aab71a31 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -1704,6 +1704,8 @@ target/coldfire/mpio/fmradio_i2c-mpio.c 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/drivers/audio/android.c b/firmware/drivers/audio/android.c new file mode 100644 index 000000000..a0eb8ab15 --- /dev/null +++ b/firmware/drivers/audio/android.c @@ -0,0 +1,57 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright © 2010 Thomas Martitz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + +#include "config.h" +#include "audiohw.h" + +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25}, +/* Bass and treble tone controls */ +#ifdef AUDIOHW_HAVE_BASS + [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, +#endif +#ifdef AUDIOHW_HAVE_TREBLE + [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, +#endif + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, +#if defined(HAVE_RECORDING) + [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, + [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, + [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, +#endif +#if defined(AUDIOHW_HAVE_BASS_CUTOFF) + [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1}, +#endif +#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF) + [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1}, +#endif +}; + +int audiohw_set_volume(int volume) +{ +} + +int audiohw_set_balance(int balance) +{ +} diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index 05fdb67e1..94067b035 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) || defined(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 ff8264581..8e8e87dad 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -488,7 +488,7 @@ Lyre prototype 1 */ #define ARM_ARCH 6 /* ARMv6 */ #elif defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320) \ - || (CONFIG_CPU == AT91SAM9260) || (CONFIG_CPU == AS3525v2) + || (CONFIG_CPU == AT91SAM9260) || (CONFIG_CPU == AS3525v2) || defined(ANDROID) #define CPU_ARM #define ARM_ARCH 5 /* ARMv5 */ diff --git a/firmware/export/debug.h b/firmware/export/debug.h index f7f0f3242..01e4f7c30 100644 --- a/firmware/export/debug.h +++ b/firmware/export/debug.h @@ -32,7 +32,7 @@ extern void ldebugf(const char* file, int line, const char *fmt, ...) #ifdef __GNUC__ /* */ -#if defined(SIMULATOR) && !defined(__PCTOOL__) +#if defined(SIMULATOR) && !defined(__PCTOOL__) || defined(ANDROID) #define DEBUGF debugf #define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__) #else diff --git a/firmware/export/thread.h b/firmware/export/thread.h index 197793e2d..1489c7f9f 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h @@ -79,7 +79,7 @@ #define MAXTHREADS (BASETHREADS+TARGET_EXTRA_THREADS) -#define DEFAULT_STACK_SIZE 0x400 /* Bytes */ +#define DEFAULT_STACK_SIZE 0x4000 /* Bytes */ #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(ANDROID) /* Need to keep structures inside the header file because debug_menu diff --git a/firmware/target/hosted/android/kernel-android.c b/firmware/target/hosted/android/kernel-android.c index 528017e99..41633d7a6 100644 --- a/firmware/target/hosted/android/kernel-android.c +++ b/firmware/target/hosted/android/kernel-android.c @@ -51,5 +51,20 @@ void tick_start(unsigned int interval_in_ms) RockboxTimer_class = (*env_ptr)->GetObjectClass(env_ptr, RockboxTimer_instance); jmethodID java_tick_start = (*env_ptr)->GetMethodID(env_ptr, RockboxTimer_class, "java_tick_start", "(J)V"); - (*env_ptr)->CallVoidMethod(env_ptr, RockboxTimer_instance, java_tick_start, (long)interval_in_ms); + (*env_ptr)->CallVoidMethod(env_ptr, RockboxTimer_instance, java_tick_start, (jlong)interval_in_ms); +} + +bool timer_register(int reg_prio, void (*unregister_callback)(void), + long cycles, void (*timer_callback)(void)) +{ + return false; +} + +bool timer_set_period(long cycles) +{ + return false; +} + +void timer_unregister(void) +{ } diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index 2cedc1ebb..f0c4d9f7d 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c @@ -58,3 +58,206 @@ void lcd_update_rect(int x, int y, int height, int width) (void)x; (void)y; (void)height; (void)width; lcd_update(); } + +/** + * |R| |1.000000 -0.000001 1.402000| |Y'| + * |G| = |1.000000 -0.334136 -0.714136| |Pb| + * |B| |1.000000 1.772000 0.000000| |Pr| + * Scaled, normalized, rounded and tweaked to yield RGB 565: + * |R| |74 0 101| |Y' - 16| >> 9 + * |G| = |74 -24 -51| |Cb - 128| >> 8 + * |B| |74 128 0| |Cr - 128| >> 9 + */ +#define YFAC (74) +#define RVFAC (101) +#define GUFAC (-24) +#define GVFAC (-51) +#define BUFAC (128) + +static inline int clamp(int val, int min, int max) +{ + if (val < min) + val = min; + else if (val > max) + val = max; + return val; +} + +void lcd_yuv_set_options(unsigned options) +{ + (void)options; +} + +/* Draw a partial YUV colour bitmap - similiar behavior to lcd_blit_yuv + in the core */ +void lcd_blit_yuv(unsigned char * const src[3], + int src_x, int src_y, int stride, + int x, int y, int width, int height) +{ + const unsigned char *ysrc, *usrc, *vsrc; + int linecounter; + fb_data *dst, *row_end; + long z; + + /* width and height must be >= 2 and an even number */ + width &= ~1; + linecounter = height >> 1; + +#if LCD_WIDTH >= LCD_HEIGHT + dst = &lcd_framebuffer[y][x]; + row_end = dst + width; +#else + dst = &lcd_framebuffer[x][LCD_WIDTH - y - 1]; + row_end = dst + LCD_WIDTH * width; +#endif + + z = stride * src_y; + ysrc = src[0] + z + src_x; + usrc = src[1] + (z >> 2) + (src_x >> 1); + vsrc = src[2] + (usrc - src[1]); + + /* stride => amount to jump from end of last row to start of next */ + stride -= width; + + /* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */ + + do + { + do + { + int y, cb, cr, rv, guv, bu, r, g, b; + + y = YFAC*(*ysrc++ - 16); + cb = *usrc++ - 128; + cr = *vsrc++ - 128; + + rv = RVFAC*cr; + guv = GUFAC*cb + GVFAC*cr; + bu = BUFAC*cb; + + r = y + rv; + g = y + guv; + b = y + bu; + + if ((unsigned)(r | g | b) > 64*256-1) + { + r = clamp(r, 0, 64*256-1); + g = clamp(g, 0, 64*256-1); + b = clamp(b, 0, 64*256-1); + } + + *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); + +#if LCD_WIDTH >= LCD_HEIGHT + dst++; +#else + dst += LCD_WIDTH; +#endif + + y = YFAC*(*ysrc++ - 16); + r = y + rv; + g = y + guv; + b = y + bu; + + if ((unsigned)(r | g | b) > 64*256-1) + { + r = clamp(r, 0, 64*256-1); + g = clamp(g, 0, 64*256-1); + b = clamp(b, 0, 64*256-1); + } + + *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); + +#if LCD_WIDTH >= LCD_HEIGHT + dst++; +#else + dst += LCD_WIDTH; +#endif + } + while (dst < row_end); + + ysrc += stride; + usrc -= width >> 1; + vsrc -= width >> 1; + +#if LCD_WIDTH >= LCD_HEIGHT + row_end += LCD_WIDTH; + dst += LCD_WIDTH - width; +#else + row_end -= 1; + dst -= LCD_WIDTH*width + 1; +#endif + + do + { + int y, cb, cr, rv, guv, bu, r, g, b; + + y = YFAC*(*ysrc++ - 16); + cb = *usrc++ - 128; + cr = *vsrc++ - 128; + + rv = RVFAC*cr; + guv = GUFAC*cb + GVFAC*cr; + bu = BUFAC*cb; + + r = y + rv; + g = y + guv; + b = y + bu; + + if ((unsigned)(r | g | b) > 64*256-1) + { + r = clamp(r, 0, 64*256-1); + g = clamp(g, 0, 64*256-1); + b = clamp(b, 0, 64*256-1); + } + + *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); + +#if LCD_WIDTH >= LCD_HEIGHT + dst++; +#else + dst += LCD_WIDTH; +#endif + + y = YFAC*(*ysrc++ - 16); + r = y + rv; + g = y + guv; + b = y + bu; + + if ((unsigned)(r | g | b) > 64*256-1) + { + r = clamp(r, 0, 64*256-1); + g = clamp(g, 0, 64*256-1); + b = clamp(b, 0, 64*256-1); + } + + *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); + +#if LCD_WIDTH >= LCD_HEIGHT + dst++; +#else + dst += LCD_WIDTH; +#endif + } + while (dst < row_end); + + ysrc += stride; + usrc += stride >> 1; + vsrc += stride >> 1; + +#if LCD_WIDTH >= LCD_HEIGHT + row_end += LCD_WIDTH; + dst += LCD_WIDTH - width; +#else + row_end -= 1; + dst -= LCD_WIDTH*width + 1; +#endif + } + while (--linecounter > 0); + +#if LCD_WIDTH >= LCD_HEIGHT + lcd_update_rect(x, y, width, height); +#else + lcd_update_rect(LCD_WIDTH - y - height, x, height, width); +#endif +} diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c new file mode 100644 index 000000000..7e780619d --- /dev/null +++ b/firmware/target/hosted/android/pcm-android.c @@ -0,0 +1,176 @@ +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of the nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include "pcm.h" + +extern JNIEnv *env_ptr; +extern jclass RbBl_class; +extern jobject RbBl_instance; +static size_t pcm_data_size; +static char *pcm_data_start; +static jmethodID play_pause; +static jmethodID stop_method; + +/* + * transfer our raw data into a java array + */ +#undef LOG +#define LOG(...) +void Java_com_example_rbboot_RockboxBootloader_pcmSamplesToByteArray(JNIEnv *env, jobject this, + jbyteArray arr) +{ + LOG("%s()", __func__); +#if 1 + size_t len; + size_t array_size = (*env)->GetArrayLength(env, arr); + if (array_size > pcm_data_size) + len = pcm_data_size; + else + len = array_size; +/* + LOG("Giving %d bytes", len); +*/ + (*env)->SetByteArrayRegion(env, arr, 0, len, pcm_data_start); + + if (array_size > pcm_data_size) + { /* didn't have enough data for the array ? */ + size_t remaining = array_size - pcm_data_size; + size_t offset = len; + retry: + pcm_play_get_more_callback((void**)&pcm_data_start, &pcm_data_size); + if (pcm_data_size == 0) + return; +/* + LOG("Giving a further %d bytes", remaining); +*/ + if (remaining > pcm_data_size) + { /* got too little data, get more ... */ + (*env)->SetByteArrayRegion(env, arr, offset, pcm_data_size, pcm_data_start); + /* advance in the java array by the amount we copied */ + offset += pcm_data_size; + /* we copied at least a bit */ + remaining -= pcm_data_size; + /* let's get another buch of data and try again */ + goto retry; + } + else + (*env)->SetByteArrayRegion(env, arr, offset, remaining, pcm_data_start); + len = remaining; + } + pcm_data_start += len; + pcm_data_size -= len; +/* + LOG("pcm data remaining: %d\n", pcm_data_size); +*/ +#endif +} + +void pcm_play_lock(void) +{ + LOG("%s()", __func__); +} +void pcm_play_unlock(void) +{ + LOG("%s()", __func__); +} +void pcm_dma_apply_settings(void) +{ + LOG("%s()", __func__); +} +void pcm_play_dma_start(const void *addr, size_t size) +{ + LOG("%s()", __func__); +#if 1 + pcm_data_start = (char*)addr; + pcm_data_size = size; + + pcm_play_dma_pause(false); +#endif +} +void pcm_play_dma_stop(void) +{ + LOG("%s", __func__); + static bool got_method = false; + if (!got_method) + { + stop_method = (*env_ptr)->GetMethodID(env_ptr, RbBl_class, "stop", "()V"); + got_method = true; + } + (*env_ptr)->CallVoidMethod(env_ptr, RbBl_instance, stop_method); +} + +void pcm_play_dma_pause(bool pause) +{ + LOG("%s()", __func__); +#if 1 + (*env_ptr)->CallVoidMethod(env_ptr, RbBl_instance, play_pause, (int)pause); + LOG("%s() return", __func__); +#endif +} + +size_t pcm_get_bytes_waiting(void) +{ + LOG("%s", __func__); + return 0; + +} +const void * pcm_play_dma_get_peak_buffer(int *count) +{ + LOG("%s", __func__); + uintptr_t addr = (uintptr_t)pcm_data_start; + *count = pcm_data_size / 4; + return (void *)((addr + 3) & ~3); +} + +void pcm_play_dma_init(void) +{ + LOG("%s", __func__); +#if 1 + JNIEnv e = *env_ptr; + jmethodID m = e->GetMethodID(env_ptr, RbBl_class, "pcmInit", "()V"); + play_pause = e->GetMethodID(env_ptr, RbBl_class, "play_pause", "(Z)V"); + + pcm_play_get_more_callback((void*)&pcm_data_start, &pcm_data_size); + LOG("%s(): Initial pcm data: %dKB\n", __func__, pcm_data_size>>10); + + e->CallVoidMethod(env_ptr, RbBl_instance, m); + LOG("%s(): initialized AudioTrack\n", __func__); +#endif +} + +void pcm_postinit(void) +{ + LOG("%s()", __func__); +} +void pcm_set_mixer_volume(int volume) +{ + LOG("%s()", __func__); +} diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index a3aec4d15..758ad9733 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c @@ -20,7 +20,9 @@ ****************************************************************************/ +#include #include "config.h" +#include "system.h" void system_exception_wait(void) { } void system_reboot(void) { } @@ -29,8 +31,8 @@ void system_init(void) { } -char *stackbegin; -char *stackend; +uintptr_t *stackbegin; +uintptr_t *stackend; JNIEnv *env_ptr; jobject RbBl_instance; jclass RbBl_class; @@ -39,8 +41,9 @@ jclass RbBl_class; void Java_com_example_rbboot_RockboxBootloader_main(JNIEnv *env, jobject this) { /* hack!!! */ - volatile int stack = 0; - stackbegin = stackend = (char*)&stack; + volatile uintptr_t stack = 0; + stackbegin = stackend = &stack; + LOG("%s() %d", __func__, stackend - stackbegin); env_ptr = env; RbBl_instance = this; RbBl_class = (*env)->GetObjectClass(env, this); diff --git a/firmware/target/hosted/android/thread-android-arm.c b/firmware/target/hosted/android/thread-android-arm.c index 49217d339..0f7683be9 100644 --- a/firmware/target/hosted/android/thread-android-arm.c +++ b/firmware/target/hosted/android/thread-android-arm.c @@ -82,14 +82,17 @@ static inline void load_context(const void* addr) extern JNIEnv *env_ptr; extern jclass RbBl_class; extern jobject RbBl_instance; +static jmethodID java_core_sleep; +static bool got_method_id = false; static inline void core_sleep(void) { - LOG("%s()", __func__); - jmethodID id = (*env_ptr)->GetMethodID(env_ptr, RbBl_class, "java_core_sleep", "()V"); - (*env_ptr)->CallVoidMethod(env_ptr, RbBl_instance, id); - LOG("%s() return", __func__); +#if 1 + if (UNLIKELY(!got_method_id)) + java_core_sleep = (*env_ptr)->GetMethodID(env_ptr, RbBl_class, "java_core_sleep", "()V"); + (*env_ptr)->CallVoidMethod(env_ptr, RbBl_instance, java_core_sleep); enable_irq(); +#endif } diff --git a/firmware/thread.c b/firmware/thread.c index 08f3d4264..97923e089 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -202,7 +202,9 @@ static void thread_panicf(const char *msg, struct thread_entry *thread) IF_COP( const unsigned int core = thread->core; ) static char name[32]; thread_get_name(name, 32, thread); - panicf ("%s %s" IF_COP(" (%d)"), msg, name IF_COP(, core)); + + LOG("%s(): %s %s %d", __func__, msg, name, thread->stack_size); + panicf ("%s %s %d" IF_COP(" (%d)"), msg, name, thread->stack_size IF_COP(, core)); } static void thread_stkov(struct thread_entry *thread) { @@ -1152,11 +1154,8 @@ void switch_thread(void) store_context(&thread->context); /* Check if the current thread stack is overflown */ -/* if (UNLIKELY(thread->stack[0] != DEADBEEF) && thread->stack_size > 0) thread_stkov(thread); -*/ - LOG("%s()", __func__); #if NUM_CORES > 1 /* Run any blocking operations requested before switching/sleeping */ @@ -2267,7 +2266,8 @@ void init_threads(void) if (core == CPU) { thread->stack = stackbegin; - thread->stack_size = (uintptr_t)stackend - (uintptr_t)stackbegin; + thread->stack_size = 0;//(uintptr_t)stackend - (uintptr_t)stackbegin; + LOG("%s() %d", __func__, stackend - stackbegin); #if NUM_CORES > 1 /* This code path will not be run on single core targets */ /* Wait for other processors to finish their inits since create_thread * isn't safe to call until the kernel inits are done. The first diff --git a/tools/configure b/tools/configure index b62a2718e..1a3cebcb6 100755 --- a/tools/configure +++ b/tools/configure @@ -413,10 +413,11 @@ 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 -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fomit-frame-pointer -fno-strict-aliasing" - LDOPTS="-lm -ldl -lc -Wl,--no-undefined -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" + GCCOPTS="$GCCOPTS -std=gnu99 -ffunction-sections -fno-short-enums -march=armv5te -mtune=xscale -msoft-float -fomit-frame-pointer" + LDOPTS="-lm -ldl -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" extradefines="$extradefines -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID" endian="little" + SHARED_FLAG="-shared" } whichadvanced () { @@ -2672,7 +2673,7 @@ fi boottool="cp " bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 4" - output="rockbox" + output="librockbox.so" bootoutput="librockbox.so" appextra="recorder:gui:radio" plugins="" diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 41136d174..fb6a1c1b5 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c @@ -72,6 +72,12 @@ #define O_BINARY 0 #endif +#include +#define LOG_TAG "RockboxBootloader" +#define LOG(args...) \ + __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, ##args); + + /* Unicode compatibility for win32 */ #if defined __MINGW32__ /* Rockbox unicode functions */ @@ -541,6 +547,8 @@ void *sim_codec_load_ram(char* codecptr, int size, void **pd) #endif *pd = NULL; + char foo[] = "/data/data/com.example.rbboot/app_codec"; + /* We have to create the dynamic link library file from ram so we can simulate the codec loading. With voice and crossfade, @@ -550,7 +558,10 @@ void *sim_codec_load_ram(char* codecptr, int size, void **pd) { char name[MAX_PATH]; const char *_name = get_user_file_path(ROCKBOX_DIR, 0, name, sizeof(name)); +/* snprintf(path, sizeof(path), "%s/_temp_codec%d.dll", get_sim_pathname(_name), codec_count); +*/ + snprintf(path, sizeof(path), "%s/_temp_codec%d.dll", foo, codec_count); fd = OPEN(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU); if (fd >= 0) break; /* Created a file ok */ @@ -659,8 +670,11 @@ void debug_init(void) void debugf(const char *fmt, ...) { va_list ap; + char buf[100]; va_start( ap, fmt ); vfprintf( stderr, fmt, ap ); + vsnprintf(buf, sizeof(buf), fmt, ap); + LOG(buf); va_end( ap ); } diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index f3773d83e..9ddbaa236 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -39,7 +39,6 @@ #include "ata.h" /* for volume definitions */ -extern char having_new_lcd; static bool storage_spinning = false; #if CONFIG_CODEC != SWCODEC @@ -215,10 +214,13 @@ bool spdif_powered(void) } #endif +#ifdef ARCHOS_PLAYER bool is_new_player(void) { + extern char having_new_lcd; return having_new_lcd; } +#endif #ifdef HAVE_USB_POWER bool usb_powered(void) diff --git a/uisimulator/uisimulator.make b/uisimulator/uisimulator.make index efeba0d76..2bf93d4bc 100644 --- a/uisimulator/uisimulator.make +++ b/uisimulator/uisimulator.make @@ -38,7 +38,7 @@ $(BUILDDIR)/$(BINARY): $$(OBJ) $$(FIRMLIB) $$(SIMLIB) $$(FIRMLIB) else ifeq (1,1) $(BUILDDIR)/$(BINARY): $$(OBJ) $(SIMLIB) $(VOICESPEEXLIB) $(FIRMLIB) $(SKINLIB) - $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -nostdlib -o $@ $^ \ + $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -nostdlib -g -o $@ $^ \ $(FIRMLIB) -lgcc $(LDOPTS) -L$(BUILDDIR)/firmware $(GLOBAL_LDOPTS) \ -Wl,-shared,-Bsymbolic -Wl,-soname,$(BINARY) -llog -Wl,-Map,$(BUILDDIR)/rockbox.map else -- 2.11.4.GIT