Search
lxdream.org :: lxdream/test/testyuv.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/testyuv.c
changeset 283:b1fbeaaff6bb
next288:a42f998226fb
author nkeynes
date Mon Jan 15 08:30:50 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Commit testyuv WIP
view annotate diff log raw
     1 /**
     2  * $Id: testyuv.c,v 1.1 2007-01-15 08:30:50 nkeynes Exp $
     3  * 
     4  * Renderer test cases
     5  *
     6  * Copyright (c) 2006 Nathan Keynes.
     7  *
     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.
    12  *
    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.
    17  */
    18 #include <stdio.h>
    19 #include "timer.h"
    20 #include "testdata.h"
    21 #include "pvr.h"
    22 #include "lib.h"
    23 #include "asic.h"
    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 DISPLAY_MODE    (PVR_BASE+0x044)
    31 #define DISPLAY_ADDR1   (PVR_BASE+0x050)
    32 #define DISPLAY_ADDR2   (PVR_BASE+0x054)
    33 #define DISPLAY_SIZE    (PVR_BASE+0x05C)
    35 struct yuv_poly {
    36     uint32_t poly[8];
    37     struct {
    38 	uint32_t mode;
    39 	float x,y,z,u,v;
    40 	uint32_t colour;
    41 	uint32_t pad;
    42     } vertex[4];
    43     uint32_t end[8];
    44 } test_yuv_poly = { { 0x8084000A, 0xE0000000, 0x2083242D, 0, 0, 0, 0, 0 },
    45 		    { { 0xE0000000, 0.0, 0.0, 0.2, 0.0, 0.0, 0xFFFFFFFF, 0 },
    46 		      { 0xE0000000, 640.0, 0.0, 0.2, 0.625, 0.0, 0xFFFFFFFF, 0 },
    47 		      { 0xE0000000, 0.0, 480.0, 0.2, 0.0, 0.9375, 0xFFFFFFFF, 0 },
    48 		      { 0xF0000000, 640.0, 480.0, 0.2, 0.625, 0.9375, 0xFFFFFFFF, 0 } },
    49 		    { 0,0,0,0,0,0,0,0 } };
    51 int test_yuv( test_data_t test_case )
    52 {
    53     int i;
    54     char tabuf[512];
    55     char *p = DMA_ALIGN(&tabuf);
    57     /* Check input */
    58     test_data_block_t input = get_test_data(test_case, "input");
    59     if( input == NULL ) {
    60 	fprintf( stderr, "Skipping test '%s' - no input\n", test_case->test_name );
    61 	return -1;
    62     }
    64     memset( (void *)(0xA5000000), 0xFE, 512000 );
    66     pvr_init();
    67     asic_clear();
    69     fprintf( stdout, "Writing %d bytes\n", input->length );
    70     long_write( YUV_CONFIG, 0x00001D14 );
    71     long_write( YUV_ADDR, 0x00000000 );
    72     timer_start();
    73     uint32_t status1 = long_read( YUV_STATUS );
    74     if( pvr_dma_write( 0x10800000, input->data, input->length, 0 ) != 0 ) {
    75 	return -1; 
    76     }
    77     uint32_t timeus = timer_gettime_us();
    78     uint32_t status2 = long_read( YUV_STATUS );
    80     /* Render the thing */
    81     memcpy( p, &test_yuv_poly, sizeof(test_yuv_poly) );
    82     if( pvr_dma_write( 0x10000000, p, sizeof(test_yuv_poly) ) != 0 ) {
    83 	return -1;
    84     }
    86     return 0;
    87 }
    89 int main( int argc, char *argv[] ) 
    90 {
    91     int test_cases = 0;
    92     int test_failures = 0;
    93     test_data_t test_data = load_test_dataset(stdin);
    94     test_data_t test_case = test_data;
    96     asic_mask_all();
    97     pvr_init();
    99     while( test_case != NULL ) {
   100 	test_cases++;
   101 	int result = test_yuv(test_case);
   102 	if( result != 0 ) {
   103 	    test_failures++;
   104 	}
   105 	test_case = test_case->next;
   106     }
   107     free_test_dataset(test_data);
   108     if( test_failures != 0 ) {
   109 	fprintf( stderr, "%d/%d test failures!\n", test_failures, test_cases );
   110 	return 1;
   111     } else {
   112 	fprintf( stderr, "%d tests OK\n", test_cases );
   113 	return 0;
   114     }
   115 }
.