summaryrefslogtreecommitdiff
path: root/src/xine-utils/cpu_accel.c
diff options
context:
space:
mode:
authorRobin KAY <komadori@users.sourceforge.net>2004-04-28 00:38:08 +0000
committerRobin KAY <komadori@users.sourceforge.net>2004-04-28 00:38:08 +0000
commit2b18f4ca9e2984dc6cf9aa0352385242bb761fdc (patch)
treef876916012addaecb95d94f7dead9085c3e92612 /src/xine-utils/cpu_accel.c
parentc99e97ef0af36e3f3a081760a7bfdca4cfd7eeeb (diff)
downloadxine-lib-2b18f4ca9e2984dc6cf9aa0352385242bb761fdc.tar.gz
xine-lib-2b18f4ca9e2984dc6cf9aa0352385242bb761fdc.tar.bz2
Backport VIS motion_comp code from libmpeg2 CVS so libmpeg2 uses these routines as well as the recently synced ffmpeg tree.
CVS patchset: 6454 CVS date: 2004/04/28 00:38:08
Diffstat (limited to 'src/xine-utils/cpu_accel.c')
-rw-r--r--src/xine-utils/cpu_accel.c115
1 files changed, 81 insertions, 34 deletions
diff --git a/src/xine-utils/cpu_accel.c b/src/xine-utils/cpu_accel.c
index 962eb7456..60ae51cba 100644
--- a/src/xine-utils/cpu_accel.c
+++ b/src/xine-utils/cpu_accel.c
@@ -140,68 +140,115 @@ static void sigill_handler (int n) {
}
#endif /* ARCH_X86 */
-#if defined (ARCH_PPC) && defined (ENABLE_ALTIVEC)
+#if defined(ARCH_PPC) && defined(ENABLE_ALTIVEC)
static sigjmp_buf jmpbuf;
static volatile sig_atomic_t canjump = 0;
static void sigill_handler (int sig)
{
- if (!canjump) {
- signal (sig, SIG_DFL);
- raise (sig);
- }
+ if (!canjump) {
+ signal (sig, SIG_DFL);
+ raise (sig);
+ }
- canjump = 0;
- siglongjmp (jmpbuf, 1);
+ canjump = 0;
+ siglongjmp (jmpbuf, 1);
}
static uint32_t arch_accel (void)
{
- /* FIXME: Autodetect cache line size via AUX ELF vector or otherwise */
- uint32_t flags = MM_ACCEL_PPC_CACHE32;
-
- signal (SIGILL, sigill_handler);
- if (sigsetjmp (jmpbuf, 1)) {
- signal (SIGILL, SIG_DFL);
- return flags;
- }
+ /* FIXME: Autodetect cache line size via AUX ELF vector or otherwise */
+ uint32_t flags = MM_ACCEL_PPC_CACHE32;
- canjump = 1;
+ signal (SIGILL, sigill_handler);
+ if (sigsetjmp (jmpbuf, 1)) {
+ signal (SIGILL, SIG_DFL);
+ return flags;
+ }
- __asm__ volatile ("mtspr 256, %0\n\t"
- "vand %%v0, %%v0, %%v0"
- :
- : "r" (-1));
+ canjump = 1;
+ __asm__ volatile ("mtspr 256, %0\n\t"
+ "vand %%v0, %%v0, %%v0"
+ :
+ : "r" (-1));
- signal (SIGILL, SIG_DFL);
- return flags|MM_ACCEL_PPC_ALTIVEC;
+ signal (SIGILL, SIG_DFL);
+ return flags|MM_ACCEL_PPC_ALTIVEC;
}
#endif /* ARCH_PPC */
+#if defined(ARCH_SPARC) && defined(ENABLE_VIS)
+static sigjmp_buf jmpbuf;
+static volatile sig_atomic_t canjump = 0;
+
+static void sigill_handler (int sig)
+{
+ if (!canjump) {
+ signal(sig, SIG_DFL);
+ raise(sig);
+ }
+
+ canjump = 0;
+ siglongjmp(jmpbuf, 1);
+}
+
+static uint32_t arch_accel (void)
+{
+ uint32_t flags = 0;
+
+ signal(SIGILL, sigill_handler);
+ if (sigsetjmp(jmpbuf, 1)) {
+ signal(SIGILL, SIG_DFL);
+ return flags;
+ }
+
+ canjump = 1;
+
+ /* pdist %f0, %f0, %f0 */
+ __asm__ __volatile__(".word\t0x81b007c0");
+
+ canjump = 0;
+ flags |= MM_ACCEL_SPARC_VIS;
+
+ if (sigsetjmp(jmpbuf, 1)) {
+ signal(SIGILL, SIG_DFL);
+ return flags;
+ }
+
+ canjump = 1;
+
+ /* edge8n %g0, %g0, %g0 */
+ __asm__ __volatile__(".word\t0x81b00020");
+
+ canjump = 0;
+ flags |= MM_ACCEL_SPARC_VIS2;
+
+ signal(SIGILL, SIG_DFL);
+ return flags;
+}
+#endif /* ARCH_SPARC */
+
uint32_t xine_mm_accel (void)
{
static int initialized = 0;
- static uint32_t accel;
+ static uint32_t accel = 0;
if (!initialized) {
-#if defined (ARCH_X86) || (defined (ARCH_PPC) && defined (ENABLE_ALTIVEC))
- accel = arch_accel ();
-#elif defined (HAVE_MLIB)
+#ifdef HAVE_MLIB
#ifdef MLIB_LAZYLOAD
void *hndl;
- if ((hndl = dlopen("libmlib.so.2", RTLD_LAZY | RTLD_GLOBAL | RTLD_NODELETE)) == NULL) {
- accel = 0;
- }
- else {
+ if ((hndl = dlopen("libmlib.so.2", RTLD_LAZY | RTLD_GLOBAL | RTLD_NODELETE)) != NULL) {
dlclose(hndl);
- accel = MM_ACCEL_MLIB;
+ accel |= MM_ACCEL_MLIB;
}
#else
- accel = MM_ACCEL_MLIB;
+ accel |= MM_ACCEL_MLIB;
#endif
-#else
- accel = 0;
+#endif
+
+#if defined(ARCH_X86) || (defined(ARCH_PPC) && defined(ENABLE_ALTIVEC)) || (defined(ARCH_SPARC) && defined(ENABLE_VIS))
+ accel |= arch_accel();
#endif
#if defined(ARCH_X86) || defined(ARCH_X86_64)