Libav
|
00001 /* 00002 * This file is part of FFmpeg. 00003 * 00004 * FFmpeg is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * FFmpeg is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with FFmpeg; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00017 */ 00018 00019 00025 #ifdef __APPLE__ 00026 #undef _POSIX_C_SOURCE 00027 #include <sys/sysctl.h> 00028 #elif defined(__OpenBSD__) 00029 #include <sys/param.h> 00030 #include <sys/sysctl.h> 00031 #include <machine/cpu.h> 00032 #elif defined(__AMIGAOS4__) 00033 #include <exec/exec.h> 00034 #include <interfaces/exec.h> 00035 #include <proto/exec.h> 00036 #endif /* __APPLE__ */ 00037 00038 #include "config.h" 00039 #include "dsputil_altivec.h" 00040 00046 int has_altivec(void) 00047 { 00048 #ifdef __AMIGAOS4__ 00049 ULONG result = 0; 00050 extern struct ExecIFace *IExec; 00051 00052 IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); 00053 if (result == VECTORTYPE_ALTIVEC) return 1; 00054 return 0; 00055 #elif defined(__APPLE__) || defined(__OpenBSD__) 00056 #ifdef __OpenBSD__ 00057 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC}; 00058 #else 00059 int sels[2] = {CTL_HW, HW_VECTORUNIT}; 00060 #endif 00061 int has_vu = 0; 00062 size_t len = sizeof(has_vu); 00063 int err; 00064 00065 err = sysctl(sels, 2, &has_vu, &len, NULL, 0); 00066 00067 if (err == 0) return has_vu != 0; 00068 return 0; 00069 #elif CONFIG_RUNTIME_CPUDETECT 00070 int proc_ver; 00071 // Support of mfspr PVR emulation added in Linux 2.6.17. 00072 __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver)); 00073 proc_ver >>= 16; 00074 if (proc_ver & 0x8000 || 00075 proc_ver == 0x000c || 00076 proc_ver == 0x0039 || proc_ver == 0x003c || 00077 proc_ver == 0x0044 || proc_ver == 0x0045 || 00078 proc_ver == 0x0070) 00079 return 1; 00080 return 0; 00081 #else 00082 // Since we were compiled for AltiVec, just assume we have it 00083 // until someone comes up with a proper way (not involving signal hacks). 00084 return 1; 00085 #endif /* __AMIGAOS4__ */ 00086 } 00087