Mercurial > libavutil.hg
annotate ppc/cpu.h @ 1009:40b8596460af libavutil
Move mm_support() from libavcodec to libavutil, make it a public
function and rename it to av_get_cpu_flags().
author | stefano |
---|---|
date | Wed, 08 Sep 2010 15:07:14 +0000 |
parents | |
children |
rev | line source |
---|---|
1009
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
1 /* |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
2 * This file is part of FFmpeg. |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
3 * |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
4 * FFmpeg is free software; you can redistribute it and/or |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
5 * modify it under the terms of the GNU Lesser General Public |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
6 * License as published by the Free Software Foundation; either |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
7 * version 2.1 of the License, or (at your option) any later version. |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
8 * |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
9 * FFmpeg is distributed in the hope that it will be useful, |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
12 * Lesser General Public License for more details. |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
13 * |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
14 * You should have received a copy of the GNU Lesser General Public |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
15 * License along with FFmpeg; if not, write to the Free Software |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
17 */ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
18 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
19 #ifndef AVUTIL_PPC_CPU_H |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
20 #define AVUTIL_PPC_CPU_H |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
21 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
22 #ifdef __APPLE__ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
23 #undef _POSIX_C_SOURCE |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
24 #include <sys/sysctl.h> |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
25 #elif defined(__OpenBSD__) |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
26 #include <sys/param.h> |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
27 #include <sys/sysctl.h> |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
28 #include <machine/cpu.h> |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
29 #elif defined(__AMIGAOS4__) |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
30 #include <exec/exec.h> |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
31 #include <interfaces/exec.h> |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
32 #include <proto/exec.h> |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
33 #endif /* __APPLE__ */ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
34 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
35 #include "config.h" |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
36 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
37 /** |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
38 * This function MAY rely on signal() or fork() in order to make sure AltiVec |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
39 * is present. |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
40 */ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
41 int av_get_cpu_flags(void) |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
42 { |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
43 #if HAVE_ALTIVEC |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
44 #ifdef __AMIGAOS4__ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
45 ULONG result = 0; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
46 extern struct ExecIFace *IExec; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
47 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
48 IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
49 if (result == VECTORTYPE_ALTIVEC) |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
50 return AV_CPU_FLAG_ALTIVEC; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
51 return 0; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
52 #elif defined(__APPLE__) || defined(__OpenBSD__) |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
53 #ifdef __OpenBSD__ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
54 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC}; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
55 #else |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
56 int sels[2] = {CTL_HW, HW_VECTORUNIT}; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
57 #endif |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
58 int has_vu = 0; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
59 size_t len = sizeof(has_vu); |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
60 int err; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
61 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
62 err = sysctl(sels, 2, &has_vu, &len, NULL, 0); |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
63 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
64 if (err == 0) |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
65 return has_vu ? AV_CPU_FLAG_ALTIVEC : 0; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
66 return 0; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
67 #elif CONFIG_RUNTIME_CPUDETECT |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
68 int proc_ver; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
69 // Support of mfspr PVR emulation added in Linux 2.6.17. |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
70 __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver)); |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
71 proc_ver >>= 16; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
72 if (proc_ver & 0x8000 || |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
73 proc_ver == 0x000c || |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
74 proc_ver == 0x0039 || proc_ver == 0x003c || |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
75 proc_ver == 0x0044 || proc_ver == 0x0045 || |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
76 proc_ver == 0x0070) |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
77 return AV_CPU_FLAG_ALTIVEC; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
78 return 0; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
79 #else |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
80 // Since we were compiled for AltiVec, just assume we have it |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
81 // until someone comes up with a proper way (not involving signal hacks). |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
82 return AV_CPU_FLAG_ALTIVEC; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
83 #endif /* __AMIGAOS4__ */ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
84 #endif /* HAVE_ALTIVEC */ |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
85 return 0; |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
86 } |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
87 |
40b8596460af
Move mm_support() from libavcodec to libavutil, make it a public
stefano
parents:
diff
changeset
|
88 #endif /* AVUTIL_PPC_CPU_H */ |