From 75cce7fb4d0c07280a00773714237846107bcb4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 7 Jul 2013 19:22:54 +0200 Subject: [PATCH] (Pandora) Add static preliminary Makefile for Pandora (Alsathread) Name functions uniquely vs. alsa to resolve symbol namespace conflicts when compiling with Griffin --- Makefile.openpandora | 45 ++++++++++++++++++++++++++++++ audio/alsa.c | 4 +++ audio/alsathread.c | 66 +++++++++++++++++++++++--------------------- griffin/griffin.c | 12 ++++++-- 4 files changed, 94 insertions(+), 33 deletions(-) create mode 100644 Makefile.openpandora diff --git a/Makefile.openpandora b/Makefile.openpandora new file mode 100644 index 0000000000..2691773281 --- /dev/null +++ b/Makefile.openpandora @@ -0,0 +1,45 @@ +RARCH_VERSION = "0.9.9.3" + +DEBUG = 0 + +CC = $(PNDSDK)/bin/arm-none-linux-gnueabi-gcc +LD = $(PNDSDK)/bin/arm-none-linux-gnueabi-gcc -o + +TARGET := retroarch-pandora + +LDDIRS = -L. -L$(PNDSDK)/usr/lib +INCDIRS = -I. -I$(PNDSDK)/usr/include + +OBJ = griffin/griffin.o audio/sinc_neon.o audio/utils_neon.o + +LIBS = -lIMGegl -lsrv_um -lGLESv2 -lEGL -ldl -lm -lpthread -lrt -lasound +DEFINES = -std=gnu99 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -DHAVE_THREADS -DHAVE_GETOPT_LONG=1 -DHAVE_GRIFFIN +DEFINES += -D__ARM_ARCH_6__ -DHAVE_NEON -DSINC_LOWER_QUALITY -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DHAVE_DYNAMIC -DWANT_RPNG -DWANT_MINIZ -DHAVE_OVERLAY -DHAVE_ALSA +DEFINES += $(INCDIRS) +DEFINES += -D__OPENPANDORA__ -DPANDORA +DEFINES += -marm -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize + +ifeq ($(DEBUG), 1) + OPTIMIZE_LV := -O0 -g +else + OPTIMIZE_LV := -O3 +endif + +all: $(TARGET) + +CFLAGS := $(OPTIMIZE_LV) $(DEFINES) + +$(TARGET): $(OBJ) + $(CC) -o $@ $(OBJ) $(LDFLAGS) $(LDDIRS) $(LIBS) + +%.o: %.S + $(CC) $(CFLAGS) -c -o $@ $< + +%.o: %.c config.h + $(CC) $(CFLAGS) -c -o $@ $< + +clean: + rm -f $(TARGET) + rm -f $(OBJ) + +.PHONY: clean diff --git a/audio/alsa.c b/audio/alsa.c index b338668017..c64e4b371e 100644 --- a/audio/alsa.c +++ b/audio/alsa.c @@ -16,7 +16,11 @@ #include "../driver.h" #include +#ifdef PANDORA +#include +#else #include +#endif #include "../general.h" #define TRY_ALSA(x) if (x < 0) { \ diff --git a/audio/alsathread.c b/audio/alsathread.c index d87e62d8ca..53ba2c931a 100644 --- a/audio/alsathread.c +++ b/audio/alsathread.c @@ -17,7 +17,11 @@ #include "../driver.h" #include +#ifdef PANDORA +#include +#else #include +#endif #include "../general.h" #include "../thread.h" #include "../fifo_buffer.h" @@ -26,7 +30,7 @@ goto error; \ } -typedef struct alsa +typedef struct alsa_thread { snd_pcm_t *pcm; bool nonblock; @@ -42,11 +46,11 @@ typedef struct alsa slock_t *fifo_lock; scond_t *cond; slock_t *cond_lock; -} alsa_t; +} alsa_thread_t; static void alsa_worker_thread(void *data) { - alsa_t *alsa = (alsa_t*)data; + alsa_thread_t *alsa = (alsa_thread_t*)data; uint8_t *buf = (uint8_t *)calloc(1, alsa->period_size); if (!buf) @@ -95,13 +99,13 @@ end: free(buf); } -static bool alsa_use_float(void *data) +static bool alsa_thread_use_float(void *data) { - alsa_t *alsa = (alsa_t*)data; + alsa_thread_t *alsa = (alsa_thread_t*)data; return alsa->has_float; } -static bool find_float_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +static bool alsathread_find_float_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { if (snd_pcm_hw_params_test_format(pcm, params, SND_PCM_FORMAT_FLOAT) == 0) { @@ -112,9 +116,9 @@ static bool find_float_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) return false; } -static void alsa_free(void *data) +static void alsa_thread_free(void *data) { - alsa_t *alsa = (alsa_t*)data; + alsa_thread_t *alsa = (alsa_thread_t*)data; if (alsa) { @@ -140,9 +144,9 @@ static void alsa_free(void *data) } } -static void *alsa_init(const char *device, unsigned rate, unsigned latency) +static void *alsa_thread_init(const char *device, unsigned rate, unsigned latency) { - alsa_t *alsa = (alsa_t*)calloc(1, sizeof(alsa_t)); + alsa_thread_t *alsa = (alsa_thread_t*)calloc(1, sizeof(alsa_thread_t)); if (!alsa) return NULL; @@ -163,7 +167,7 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency) TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, 0)); TRY_ALSA(snd_pcm_hw_params_malloc(¶ms)); - alsa->has_float = find_float_format(alsa->pcm, params); + alsa->has_float = alsathread_find_float_format(alsa->pcm, params); format = alsa->has_float ? SND_PCM_FORMAT_FLOAT : SND_PCM_FORMAT_S16; TRY_ALSA(snd_pcm_hw_params_any(alsa->pcm, params)); @@ -216,14 +220,14 @@ error: if (sw_params) snd_pcm_sw_params_free(sw_params); - alsa_free(alsa); + alsa_thread_free(alsa); return NULL; } -static ssize_t alsa_write(void *data, const void *buf, size_t size) +static ssize_t alsa_thread_write(void *data, const void *buf, size_t size) { - alsa_t *alsa = (alsa_t*)data; + alsa_thread_t *alsa = (alsa_thread_t*)data; if (alsa->thread_dead) return -1; @@ -265,27 +269,27 @@ static ssize_t alsa_write(void *data, const void *buf, size_t size) } } -static bool alsa_stop(void *data) +static bool alsa_thread_stop(void *data) { (void)data; return true; } -static void alsa_set_nonblock_state(void *data, bool state) +static void alsa_thread_set_nonblock_state(void *data, bool state) { - alsa_t *alsa = (alsa_t*)data; + alsa_thread_t *alsa = (alsa_thread_t*)data; alsa->nonblock = state; } -static bool alsa_start(void *data) +static bool alsa_thread_start(void *data) { (void)data; return true; } -static size_t alsa_write_avail(void *data) +static size_t alsa_thread_write_avail(void *data) { - alsa_t *alsa = (alsa_t*)data; + alsa_thread_t *alsa = (alsa_thread_t*)data; if (alsa->thread_dead) return 0; @@ -295,21 +299,21 @@ static size_t alsa_write_avail(void *data) return val; } -static size_t alsa_buffer_size(void *data) +static size_t alsa_thread_buffer_size(void *data) { - alsa_t *alsa = (alsa_t*)data; + alsa_thread_t *alsa = (alsa_thread_t*)data; return alsa->buffer_size; } const audio_driver_t audio_alsathread = { - alsa_init, - alsa_write, - alsa_stop, - alsa_start, - alsa_set_nonblock_state, - alsa_free, - alsa_use_float, + alsa_thread_init, + alsa_thread_write, + alsa_thread_stop, + alsa_thread_start, + alsa_thread_set_nonblock_state, + alsa_thread_free, + alsa_thread_use_float, "alsathread", - alsa_write_avail, - alsa_buffer_size, + alsa_thread_write_avail, + alsa_thread_buffer_size, }; diff --git a/griffin/griffin.c b/griffin/griffin.c index f7bfa964b4..04c361565e 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -143,8 +143,11 @@ VIDEO IMAGE #include "../ps3/image.c" #elif defined(_XBOX1) #include "../xdk/image.c" -#elif defined(RARCH_MOBILE) +#else #include "../gfx/image.c" +#endif + +#if defined(WANT_RPNG) || defined(RARCH_MOBILE) #include "../gfx/rpng/rpng.c" #endif @@ -267,6 +270,11 @@ INPUT #include "../blackberry-qnx/qnx_input.c" #endif +#if defined(PANDORA) +#include "../input/linuxraw_input.c" +#include "../input/linuxraw_joypad.c" +#endif + #if defined(HAVE_NULLINPUT) #include "../input/null.c" #endif @@ -415,7 +423,7 @@ MAIN #include "../frontend/frontend_objc.c" #endif -#if defined(RARCH_CONSOLE) || defined(__QNX__) && !defined(HAVE_BB10) +#if defined(RARCH_CONSOLE) || defined(__QNX__) && !defined(HAVE_BB10) || defined(PANDORA) #include "../frontend/frontend.c" #endif