00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef __APPLE__
00020 #undef _POSIX_C_SOURCE
00021 #include <sys/sysctl.h>
00022 #elif defined(__OpenBSD__)
00023 #include <sys/param.h>
00024 #include <sys/sysctl.h>
00025 #include <machine/cpu.h>
00026 #elif defined(__AMIGAOS4__)
00027 #include <exec/exec.h>
00028 #include <interfaces/exec.h>
00029 #include <proto/exec.h>
00030 #endif
00031
00032 #include "libavutil/cpu.h"
00033 #include "config.h"
00034
00039 int ff_get_cpu_flags_ppc(void)
00040 {
00041 #if HAVE_ALTIVEC
00042 #ifdef __AMIGAOS4__
00043 ULONG result = 0;
00044 extern struct ExecIFace *IExec;
00045
00046 IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);
00047 if (result == VECTORTYPE_ALTIVEC)
00048 return AV_CPU_FLAG_ALTIVEC;
00049 return 0;
00050 #elif defined(__APPLE__) || defined(__OpenBSD__)
00051 #ifdef __OpenBSD__
00052 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
00053 #else
00054 int sels[2] = {CTL_HW, HW_VECTORUNIT};
00055 #endif
00056 int has_vu = 0;
00057 size_t len = sizeof(has_vu);
00058 int err;
00059
00060 err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
00061
00062 if (err == 0)
00063 return has_vu ? AV_CPU_FLAG_ALTIVEC : 0;
00064 return 0;
00065 #elif CONFIG_RUNTIME_CPUDETECT
00066 int proc_ver;
00067
00068 __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver));
00069 proc_ver >>= 16;
00070 if (proc_ver & 0x8000 ||
00071 proc_ver == 0x000c ||
00072 proc_ver == 0x0039 || proc_ver == 0x003c ||
00073 proc_ver == 0x0044 || proc_ver == 0x0045 ||
00074 proc_ver == 0x0070)
00075 return AV_CPU_FLAG_ALTIVEC;
00076 return 0;
00077 #else
00078
00079
00080 return AV_CPU_FLAG_ALTIVEC;
00081 #endif
00082 #endif
00083 return 0;
00084 }