Libav 0.7.1
|
00001 /* 00002 * This file is part of Libav. 00003 * 00004 * Libav 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 * Libav 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 Libav; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00017 */ 00018 00019 #ifdef __APPLE__ 00020 #include <sys/sysctl.h> 00021 #elif defined(__OpenBSD__) 00022 #include <sys/param.h> 00023 #include <sys/sysctl.h> 00024 #include <machine/cpu.h> 00025 #elif defined(__AMIGAOS4__) 00026 #include <exec/exec.h> 00027 #include <interfaces/exec.h> 00028 #include <proto/exec.h> 00029 #endif /* __APPLE__ */ 00030 00031 #include "libavutil/cpu.h" 00032 #include "config.h" 00033 00038 int ff_get_cpu_flags_ppc(void) 00039 { 00040 #if HAVE_ALTIVEC 00041 #ifdef __AMIGAOS4__ 00042 ULONG result = 0; 00043 extern struct ExecIFace *IExec; 00044 00045 IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); 00046 if (result == VECTORTYPE_ALTIVEC) 00047 return AV_CPU_FLAG_ALTIVEC; 00048 return 0; 00049 #elif defined(__APPLE__) || defined(__OpenBSD__) 00050 #ifdef __OpenBSD__ 00051 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC}; 00052 #else 00053 int sels[2] = {CTL_HW, HW_VECTORUNIT}; 00054 #endif 00055 int has_vu = 0; 00056 size_t len = sizeof(has_vu); 00057 int err; 00058 00059 err = sysctl(sels, 2, &has_vu, &len, NULL, 0); 00060 00061 if (err == 0) 00062 return has_vu ? AV_CPU_FLAG_ALTIVEC : 0; 00063 return 0; 00064 #elif CONFIG_RUNTIME_CPUDETECT 00065 int proc_ver; 00066 // Support of mfspr PVR emulation added in Linux 2.6.17. 00067 __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver)); 00068 proc_ver >>= 16; 00069 if (proc_ver & 0x8000 || 00070 proc_ver == 0x000c || 00071 proc_ver == 0x0039 || proc_ver == 0x003c || 00072 proc_ver == 0x0044 || proc_ver == 0x0045 || 00073 proc_ver == 0x0070) 00074 return AV_CPU_FLAG_ALTIVEC; 00075 return 0; 00076 #else 00077 // Since we were compiled for AltiVec, just assume we have it 00078 // until someone comes up with a proper way (not involving signal hacks). 00079 return AV_CPU_FLAG_ALTIVEC; 00080 #endif /* __AMIGAOS4__ */ 00081 #endif /* HAVE_ALTIVEC */ 00082 return 0; 00083 }