Search
lxdream.org :: lxdream :: r283:b1fbeaaff6bb
lxdream 0.9.1
released Jun 29
Download Now
changeset283:b1fbeaaff6bb
parent282:01e53698ff38
child284:808617ee7135
authornkeynes
dateMon Jan 15 08:30:50 2007 +0000 (13 years ago)
Commit testyuv WIP
test/testyuv.c
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/testyuv.c Mon Jan 15 08:30:50 2007 +0000
1.3 @@ -0,0 +1,115 @@
1.4 +/**
1.5 + * $Id: testyuv.c,v 1.1 2007-01-15 08:30:50 nkeynes Exp $
1.6 + *
1.7 + * Renderer test cases
1.8 + *
1.9 + * Copyright (c) 2006 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +#include <stdio.h>
1.22 +#include "timer.h"
1.23 +#include "testdata.h"
1.24 +#include "pvr.h"
1.25 +#include "lib.h"
1.26 +#include "asic.h"
1.27 +
1.28 +#define PVR_BASE 0xA05F8000
1.29 +#define PVR_RESET (PVR_BASE+0x008)
1.30 +#define YUV_ADDR (PVR_BASE+0x148)
1.31 +#define YUV_CONFIG (PVR_BASE+0x14C)
1.32 +#define YUV_STATUS (PVR_BASE+0x150)
1.33 +#define DISPLAY_MODE (PVR_BASE+0x044)
1.34 +#define DISPLAY_ADDR1 (PVR_BASE+0x050)
1.35 +#define DISPLAY_ADDR2 (PVR_BASE+0x054)
1.36 +#define DISPLAY_SIZE (PVR_BASE+0x05C)
1.37 +
1.38 +struct yuv_poly {
1.39 + uint32_t poly[8];
1.40 + struct {
1.41 + uint32_t mode;
1.42 + float x,y,z,u,v;
1.43 + uint32_t colour;
1.44 + uint32_t pad;
1.45 + } vertex[4];
1.46 + uint32_t end[8];
1.47 +} test_yuv_poly = { { 0x8084000A, 0xE0000000, 0x2083242D, 0, 0, 0, 0, 0 },
1.48 + { { 0xE0000000, 0.0, 0.0, 0.2, 0.0, 0.0, 0xFFFFFFFF, 0 },
1.49 + { 0xE0000000, 640.0, 0.0, 0.2, 0.625, 0.0, 0xFFFFFFFF, 0 },
1.50 + { 0xE0000000, 0.0, 480.0, 0.2, 0.0, 0.9375, 0xFFFFFFFF, 0 },
1.51 + { 0xF0000000, 640.0, 480.0, 0.2, 0.625, 0.9375, 0xFFFFFFFF, 0 } },
1.52 + { 0,0,0,0,0,0,0,0 } };
1.53 +
1.54 +int test_yuv( test_data_t test_case )
1.55 +{
1.56 + int i;
1.57 + char tabuf[512];
1.58 + char *p = DMA_ALIGN(&tabuf);
1.59 +
1.60 + /* Check input */
1.61 + test_data_block_t input = get_test_data(test_case, "input");
1.62 + if( input == NULL ) {
1.63 + fprintf( stderr, "Skipping test '%s' - no input\n", test_case->test_name );
1.64 + return -1;
1.65 + }
1.66 +
1.67 + memset( (void *)(0xA5000000), 0xFE, 512000 );
1.68 +
1.69 + pvr_init();
1.70 + asic_clear();
1.71 +
1.72 + fprintf( stdout, "Writing %d bytes\n", input->length );
1.73 + long_write( YUV_CONFIG, 0x00001D14 );
1.74 + long_write( YUV_ADDR, 0x00000000 );
1.75 + timer_start();
1.76 + uint32_t status1 = long_read( YUV_STATUS );
1.77 + if( pvr_dma_write( 0x10800000, input->data, input->length, 0 ) != 0 ) {
1.78 + return -1;
1.79 + }
1.80 + uint32_t timeus = timer_gettime_us();
1.81 + uint32_t status2 = long_read( YUV_STATUS );
1.82 +
1.83 + /* Render the thing */
1.84 + memcpy( p, &test_yuv_poly, sizeof(test_yuv_poly) );
1.85 + if( pvr_dma_write( 0x10000000, p, sizeof(test_yuv_poly) ) != 0 ) {
1.86 + return -1;
1.87 + }
1.88 +
1.89 + return 0;
1.90 +}
1.91 +
1.92 +int main( int argc, char *argv[] )
1.93 +{
1.94 + int test_cases = 0;
1.95 + int test_failures = 0;
1.96 + test_data_t test_data = load_test_dataset(stdin);
1.97 + test_data_t test_case = test_data;
1.98 +
1.99 + asic_mask_all();
1.100 + pvr_init();
1.101 +
1.102 + while( test_case != NULL ) {
1.103 + test_cases++;
1.104 + int result = test_yuv(test_case);
1.105 + if( result != 0 ) {
1.106 + test_failures++;
1.107 + }
1.108 + test_case = test_case->next;
1.109 + }
1.110 + free_test_dataset(test_data);
1.111 + if( test_failures != 0 ) {
1.112 + fprintf( stderr, "%d/%d test failures!\n", test_failures, test_cases );
1.113 + return 1;
1.114 + } else {
1.115 + fprintf( stderr, "%d tests OK\n", test_cases );
1.116 + return 0;
1.117 + }
1.118 +}
.