6 * Copyright (c) 2006 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
25 #define PVR_BASE 0xA05F8000
26 #define PVR_RESET (PVR_BASE+0x008)
27 #define YUV_ADDR (PVR_BASE+0x148)
28 #define YUV_CONFIG (PVR_BASE+0x14C)
29 #define YUV_STATUS (PVR_BASE+0x150)
30 #define TEXSIZE (PVR_BASE+0x0E4)
31 #define DISPLAY_MODE (PVR_BASE+0x044)
32 #define DISPLAY_ADDR1 (PVR_BASE+0x050)
33 #define DISPLAY_ADDR2 (PVR_BASE+0x054)
34 #define DISPLAY_SIZE (PVR_BASE+0x05C)
36 #define OBJ_START 0x00010000
37 #define OBJ_LENGTH 0x00010000
38 #define TILE_START 0x00060000
39 #define TILE_LENGTH 0x00010000
40 #define TILEMAP_ADDR 0x050B2C8
41 #define RENDER_ADDR 0x00600000
43 #define OBJCFG 0xA05F807C
44 #define ISPCFG 0xA05F8098
46 struct ta_config default_ta_config = { 0x00100002, GRID_SIZE(640,480), OBJ_START,
47 OBJ_START+OBJ_LENGTH, TILE_START+TILE_LENGTH,
48 TILE_START, TILE_START+TILE_LENGTH };
52 struct render_config default_render_config = { OBJ_START, TILEMAP_ADDR, RENDER_ADDR, 640, 480,
53 0x00000009, 0.0001f, 1.0f };
57 uint32_t mode1, mode2, mode3;
68 #define BG_COLOUR 0xFF808080
70 struct backplane default_backplane = { 0x90800000, 0x20800440, 0,
71 0.0, 0.0, 0.2, BG_COLOUR,
72 640.0, 0.0, 0.2, BG_COLOUR,
73 0.0, 480.0, 0.2, BG_COLOUR };
84 } test_yuv_poly = { { 0x808C010A, 0xE0000000, 0x2091A4F6, 0x1E000000, 0, 0, 0, 0 },
85 { { 0xE0000000, 0.0, 0.0, 2.0, 0.0, 0.0, 0xFFFFFFFF, 0 },
86 { 0xE0000000, 640.0, 0.0, 2.0, 0.625, 0.0, 0xFFFFFFFF, 0 },
87 { 0xE0000000, 0.0, 480.0, 2.0, 0.0, 0.9375, 0xFFFFFFFF, 0 },
88 { 0xF0000000, 640.0, 480.0, 2.0, 0.625, 0.9375, 0xFFFFFFFF, 0 } },
89 { 0,0,0,0,0,0,0,0 } };
94 int test_yuv( test_data_t test_case )
98 char *p = DMA_ALIGN(&tabuf);
101 test_data_block_t input = get_test_data(test_case, "input");
102 if( input == NULL ) {
103 fprintf( stderr, "Skipping test '%s' - no input\n", test_case->test_name );
107 memset( (void *)(0xA5000000), 0xFE, 512000 );
112 fprintf( stdout, "Writing %d bytes\n", input->length );
113 long_write( YUV_CONFIG, 0x00001D14 );
114 long_write( YUV_ADDR, 0x00000000 );
116 uint32_t status1 = long_read( YUV_STATUS );
117 if( pvr_dma_write( 0x10800000, input->data, input->length, 0 ) != 0 ) {
120 uint32_t timeus = timer_gettime_us();
121 uint32_t status2 = long_read( YUV_STATUS );
123 struct ta_config *config = &default_ta_config;
129 memcpy( p, &test_yuv_poly, sizeof(test_yuv_poly) );
130 if( pvr_dma_write( 0x10000000, p, sizeof(test_yuv_poly), 0 ) != 0 ) {
133 asic_wait( EVENT_PVR_OPAQUE_DONE );
134 if( asic_check( EVENT_PVR_PRIM_ALLOC_FAIL ) ||
135 asic_check( EVENT_PVR_MATRIX_ALLOC_FAIL ) ||
136 asic_check( EVENT_PVR_BAD_INPUT ) ) {
141 /* Write backplane (if any) */
142 uint32_t bgplane = pvr_get_objbuf_posn();
143 memcpy( (char *)(PVR_VRAM_BASE + bgplane), &default_backplane, sizeof(default_backplane) );
144 bgplane -= default_render_config.polybuf;
145 render_set_backplane( (bgplane << 1) | 0x01000000 );
147 /* Render the damn thing */
148 long_write( OBJCFG, 0x0027DF77 );
149 long_write( ISPCFG, 0x00800409 );
150 long_write( TEXSIZE, 0x0000000A );
151 pvr_build_tilemap2( TILEMAP_ADDR, config, 0x10000000 );
152 render_start( &default_render_config );
153 if( asic_wait( EVENT_PVR_RENDER_DONE ) == -1 ) {
154 fprintf( stderr, "Test render failed (timeout waiting for render)\n" );
160 asic_wait( EVENT_RETRACE );
161 display_render( &default_render_config );
163 asic_wait(EVENT_RETRACE);
165 asic_wait(EVENT_RETRACE);
167 asic_wait(EVENT_RETRACE);
169 asic_wait(EVENT_RETRACE);
173 int main( int argc, char *argv[] )
176 int test_failures = 0;
177 test_data_t test_data = load_test_dataset(stdin);
178 test_data_t test_case = test_data;
183 while( test_case != NULL ) {
185 int result = test_yuv(test_case);
189 test_case = test_case->next;
191 free_test_dataset(test_data);
192 if( test_failures != 0 ) {
193 fprintf( stderr, "%d/%d test failures!\n", test_failures, test_cases );
196 fprintf( stderr, "%d tests OK\n", test_cases );
.