annotate src/video/ps3/spulibs/fb_writer.c @ 4494:621dc91c7a04

Whoops, updated the copyright date
author Sam Lantinga <slouken@libsdl.org>
date Wed, 07 Jul 2010 23:26:07 -0700
parents 94fb40a4a9a7
children
rev   line source
3257
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 * SDL - Simple DirectMedia Layer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 * CELL BE Support for PS3 Framebuffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 * Copyright (C) 2008, 2009 International Business Machines Corporation
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 *
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or modify it
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 * under the terms of the GNU Lesser General Public License as published
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 * by the Free Software Foundation; either version 2.1 of the License, or
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 * (at your option) any later version.
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 *
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful, but
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 * Lesser General Public License for more details.
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 *
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 * USA
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 *
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 * Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 * Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 * SPE code based on research by:
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 * Rene Becker
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 * Thimo Emmerich
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "spu_common.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include <spu_intrinsics.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <spu_mfcio.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include <stdio.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include <string.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 // Debugging
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 //#define DEBUG
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #ifdef DEBUG
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #define deprintf(fmt, args... ) \
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 fprintf( stdout, fmt, ##args ); \
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 fflush( stdout );
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #else
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #define deprintf( fmt, args... )
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 #endif
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 void cpy_to_fb(unsigned int);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 /* fb_writer_spu parms */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static volatile struct fb_writer_parms_t parms __attribute__ ((aligned(128)));
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 /* Code running on SPU */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 int main(unsigned long long spe_id __attribute__ ((unused)), unsigned long long argp __attribute__ ((unused)))
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 deprintf("[SPU] fb_writer_spu is up... (on SPE #%llu)\n", spe_id);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 uint32_t ea_mfc, mbox;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 // send ready message
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 spu_write_out_mbox(SPU_READY);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 while (1) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 /* Check mailbox */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 mbox = spu_read_in_mbox();
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 deprintf("[SPU] Message is %u\n", mbox);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 switch (mbox) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 case SPU_EXIT:
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 deprintf("[SPU] fb_writer goes down...\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 return 0;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 case SPU_START:
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 break;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 default:
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 deprintf("[SPU] Cannot handle message\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 continue;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 /* Tag Manager setup */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 unsigned int tags;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 tags = mfc_multi_tag_reserve(5);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 if (tags == MFC_TAG_INVALID) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 deprintf("[SPU] Failed to reserve mfc tags on fb_writer\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 return 0;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 /* Framebuffer parms */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 ea_mfc = spu_read_in_mbox();
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 deprintf("[SPU] Message on fb_writer is %u\n", ea_mfc);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 spu_mfcdma32(&parms, (unsigned int)ea_mfc,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 sizeof(struct fb_writer_parms_t), tags,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 MFC_GET_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 deprintf("[SPU] argp = %u\n", (unsigned int)argp);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 DMA_WAIT_TAG(tags);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 /* Copy parms->data to framebuffer */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 deprintf("[SPU] Copying to framebuffer started\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 cpy_to_fb(tags);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 deprintf("[SPU] Copying to framebuffer done!\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 mfc_multi_tag_release(tags, 5);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 deprintf("[SPU] fb_writer_spu... done!\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 /* Send FIN msg */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 spu_write_out_mbox(SPU_FIN);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 return 0;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 void cpy_to_fb(unsigned int tag_id_base)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 unsigned int i;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 unsigned char current_buf;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 uint8_t *in = parms.data;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 /* Align fb pointer which was centered before */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 uint8_t *fb =
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 (unsigned char *)((unsigned int)parms.center & 0xFFFFFFF0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 uint32_t bounded_input_height = parms.bounded_input_height;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 uint32_t bounded_input_width = parms.bounded_input_width;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 uint32_t fb_pixel_size = parms.fb_pixel_size;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 uint32_t out_line_stride = parms.out_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 uint32_t in_line_stride = parms.in_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 uint32_t in_line_size = bounded_input_width * fb_pixel_size;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 current_buf = 0;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 /* Local store buffer */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 static volatile uint8_t buf[4][BUFFER_SIZE]
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 __attribute__ ((aligned(128)));
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 /* do 4-times multibuffering using DMA list, process in two steps */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 for (i = 0; i < bounded_input_height >> 2; i++) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 /* first buffer */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 DMA_WAIT_TAG(tag_id_base + 1);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 // retrieve buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 spu_mfcdma32(buf[0], (unsigned int)in, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 tag_id_base + 1, MFC_GETB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 DMA_WAIT_TAG(tag_id_base + 1);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 // store buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 spu_mfcdma32(buf[0], (unsigned int)fb, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 tag_id_base + 1, MFC_PUTB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 in += in_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 fb += out_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 deprintf("[SPU] 1st buffer copied in=0x%x, fb=0x%x\n", in,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 fb);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 /* second buffer */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 DMA_WAIT_TAG(tag_id_base + 2);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 // retrieve buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 spu_mfcdma32(buf[1], (unsigned int)in, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 tag_id_base + 2, MFC_GETB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 DMA_WAIT_TAG(tag_id_base + 2);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 // store buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 spu_mfcdma32(buf[1], (unsigned int)fb, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 tag_id_base + 2, MFC_PUTB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 in += in_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 fb += out_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 deprintf("[SPU] 2nd buffer copied in=0x%x, fb=0x%x\n", in,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 fb);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 /* third buffer */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 DMA_WAIT_TAG(tag_id_base + 3);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 // retrieve buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 spu_mfcdma32(buf[2], (unsigned int)in, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 tag_id_base + 3, MFC_GETB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 DMA_WAIT_TAG(tag_id_base + 3);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 // store buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 spu_mfcdma32(buf[2], (unsigned int)fb, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 tag_id_base + 3, MFC_PUTB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 in += in_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 fb += out_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 deprintf("[SPU] 3rd buffer copied in=0x%x, fb=0x%x\n", in,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 fb);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 /* fourth buffer */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 DMA_WAIT_TAG(tag_id_base + 4);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 // retrieve buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 spu_mfcdma32(buf[3], (unsigned int)in, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 tag_id_base + 4, MFC_GETB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 DMA_WAIT_TAG(tag_id_base + 4);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 // store buffer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 spu_mfcdma32(buf[3], (unsigned int)fb, in_line_size,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 tag_id_base + 4, MFC_PUTB_CMD);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 in += in_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 fb += out_line_stride;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 deprintf("[SPU] 4th buffer copied in=0x%x, fb=0x%x\n", in,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 fb);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 deprintf("[SPU] Loop #%i, bounded_input_height=%i\n", i,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 bounded_input_height >> 2);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 DMA_WAIT_TAG(tag_id_base + 2);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 DMA_WAIT_TAG(tag_id_base + 3);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 DMA_WAIT_TAG(tag_id_base + 4);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193