summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/cpu_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/cpu_state.c')
-rw-r--r--apps/plugins/mpegplayer/cpu_state.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/cpu_state.c b/apps/plugins/mpegplayer/cpu_state.c
new file mode 100644
index 0000000000..4406853626
--- /dev/null
+++ b/apps/plugins/mpegplayer/cpu_state.c
@@ -0,0 +1,129 @@
1/*
2 * cpu_state.c
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5 *
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * See http://libmpeg2.sourceforge.net/ for updates.
8 *
9 * mpeg2dec is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * mpeg2dec is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include "plugin.h"
25
26#include "mpeg2dec_config.h"
27
28#include "mpeg2.h"
29#include "attributes.h"
30#include "mpeg2_internal.h"
31#ifdef ARCH_X86
32#include "mmx.h"
33#endif
34
35void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
36void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
37
38#ifdef ARCH_X86
39static void state_restore_mmx (cpu_state_t * state)
40{
41 emms ();
42}
43#endif
44
45#ifdef ARCH_PPC
46#ifdef HAVE_ALTIVEC_H /* gnu */
47#define LI(a,b) "li " #a "," #b "\n\t"
48#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
49#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
50#define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t"
51#define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t"
52#else /* apple */
53#define LI(a,b) "li r" #a "," #b "\n\t"
54#define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t"
55#define STVX(a,b,c) "stvx v" #a ",r" #b ",r" #c "\n\t"
56#define LVX0(a,b,c) "lvx v" #a ",0,r" #c "\n\t"
57#define LVX(a,b,c) "lvx v" #a ",r" #b ",r" #c "\n\t"
58#endif
59
60static void state_save_altivec (cpu_state_t * state)
61{
62 asm (LI (9, 16)
63 STVX0 (20, 0, 3)
64 LI (11, 32)
65 STVX (21, 9, 3)
66 LI (9, 48)
67 STVX (22, 11, 3)
68 LI (11, 64)
69 STVX (23, 9, 3)
70 LI (9, 80)
71 STVX (24, 11, 3)
72 LI (11, 96)
73 STVX (25, 9, 3)
74 LI (9, 112)
75 STVX (26, 11, 3)
76 LI (11, 128)
77 STVX (27, 9, 3)
78 LI (9, 144)
79 STVX (28, 11, 3)
80 LI (11, 160)
81 STVX (29, 9, 3)
82 LI (9, 176)
83 STVX (30, 11, 3)
84 STVX (31, 9, 3));
85}
86
87static void state_restore_altivec (cpu_state_t * state)
88{
89 asm (LI (9, 16)
90 LVX0 (20, 0, 3)
91 LI (11, 32)
92 LVX (21, 9, 3)
93 LI (9, 48)
94 LVX (22, 11, 3)
95 LI (11, 64)
96 LVX (23, 9, 3)
97 LI (9, 80)
98 LVX (24, 11, 3)
99 LI (11, 96)
100 LVX (25, 9, 3)
101 LI (9, 112)
102 LVX (26, 11, 3)
103 LI (11, 128)
104 LVX (27, 9, 3)
105 LI (9, 144)
106 LVX (28, 11, 3)
107 LI (11, 160)
108 LVX (29, 9, 3)
109 LI (9, 176)
110 LVX (30, 11, 3)
111 LVX (31, 9, 3));
112}
113#endif
114
115void mpeg2_cpu_state_init (uint32_t accel)
116{
117 (void)accel;
118#ifdef ARCH_X86
119 if (accel & MPEG2_ACCEL_X86_MMX) {
120 mpeg2_cpu_state_restore = state_restore_mmx;
121 }
122#endif
123#ifdef ARCH_PPC
124 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
125 mpeg2_cpu_state_save = state_save_altivec;
126 mpeg2_cpu_state_restore = state_restore_altivec;
127 }
128#endif
129}