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
file annotate diff log raw
nkeynes@283
     1
/**
nkeynes@283
     2
 * $Id: testyuv.c,v 1.1 2007-01-15 08:30:50 nkeynes Exp $
nkeynes@283
     3
 * 
nkeynes@283
     4
 * Renderer test cases
nkeynes@283
     5
 *
nkeynes@283
     6
 * Copyright (c) 2006 Nathan Keynes.
nkeynes@283
     7
 *
nkeynes@283
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@283
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@283
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@283
    11
 * (at your option) any later version.
nkeynes@283
    12
 *
nkeynes@283
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@283
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@283
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@283
    16
 * GNU General Public License for more details.
nkeynes@283
    17
 */
nkeynes@283
    18
#include <stdio.h>
nkeynes@283
    19
#include "timer.h"
nkeynes@283
    20
#include "testdata.h"
nkeynes@283
    21
#include "pvr.h"
nkeynes@283
    22
#include "lib.h"
nkeynes@283
    23
#include "asic.h"
nkeynes@283
    24
nkeynes@283
    25
#define PVR_BASE 0xA05F8000
nkeynes@283
    26
#define PVR_RESET (PVR_BASE+0x008)
nkeynes@283
    27
#define YUV_ADDR (PVR_BASE+0x148)
nkeynes@283
    28
#define YUV_CONFIG (PVR_BASE+0x14C)
nkeynes@283
    29
#define YUV_STATUS (PVR_BASE+0x150)
nkeynes@283
    30
#define DISPLAY_MODE    (PVR_BASE+0x044)
nkeynes@283
    31
#define DISPLAY_ADDR1   (PVR_BASE+0x050)
nkeynes@283
    32
#define DISPLAY_ADDR2   (PVR_BASE+0x054)
nkeynes@283
    33
#define DISPLAY_SIZE    (PVR_BASE+0x05C)
nkeynes@283
    34
nkeynes@283
    35
struct yuv_poly {
nkeynes@283
    36
    uint32_t poly[8];
nkeynes@283
    37
    struct {
nkeynes@283
    38
	uint32_t mode;
nkeynes@283
    39
	float x,y,z,u,v;
nkeynes@283
    40
	uint32_t colour;
nkeynes@283
    41
	uint32_t pad;
nkeynes@283
    42
    } vertex[4];
nkeynes@283
    43
    uint32_t end[8];
nkeynes@283
    44
} test_yuv_poly = { { 0x8084000A, 0xE0000000, 0x2083242D, 0, 0, 0, 0, 0 },
nkeynes@283
    45
		    { { 0xE0000000, 0.0, 0.0, 0.2, 0.0, 0.0, 0xFFFFFFFF, 0 },
nkeynes@283
    46
		      { 0xE0000000, 640.0, 0.0, 0.2, 0.625, 0.0, 0xFFFFFFFF, 0 },
nkeynes@283
    47
		      { 0xE0000000, 0.0, 480.0, 0.2, 0.0, 0.9375, 0xFFFFFFFF, 0 },
nkeynes@283
    48
		      { 0xF0000000, 640.0, 480.0, 0.2, 0.625, 0.9375, 0xFFFFFFFF, 0 } },
nkeynes@283
    49
		    { 0,0,0,0,0,0,0,0 } };
nkeynes@283
    50
nkeynes@283
    51
int test_yuv( test_data_t test_case )
nkeynes@283
    52
{
nkeynes@283
    53
    int i;
nkeynes@283
    54
    char tabuf[512];
nkeynes@283
    55
    char *p = DMA_ALIGN(&tabuf);
nkeynes@283
    56
nkeynes@283
    57
    /* Check input */
nkeynes@283
    58
    test_data_block_t input = get_test_data(test_case, "input");
nkeynes@283
    59
    if( input == NULL ) {
nkeynes@283
    60
	fprintf( stderr, "Skipping test '%s' - no input\n", test_case->test_name );
nkeynes@283
    61
	return -1;
nkeynes@283
    62
    }
nkeynes@283
    63
nkeynes@283
    64
    memset( (void *)(0xA5000000), 0xFE, 512000 );
nkeynes@283
    65
nkeynes@283
    66
    pvr_init();
nkeynes@283
    67
    asic_clear();
nkeynes@283
    68
nkeynes@283
    69
    fprintf( stdout, "Writing %d bytes\n", input->length );
nkeynes@283
    70
    long_write( YUV_CONFIG, 0x00001D14 );
nkeynes@283
    71
    long_write( YUV_ADDR, 0x00000000 );
nkeynes@283
    72
    timer_start();
nkeynes@283
    73
    uint32_t status1 = long_read( YUV_STATUS );
nkeynes@283
    74
    if( pvr_dma_write( 0x10800000, input->data, input->length, 0 ) != 0 ) {
nkeynes@283
    75
	return -1; 
nkeynes@283
    76
    }
nkeynes@283
    77
    uint32_t timeus = timer_gettime_us();
nkeynes@283
    78
    uint32_t status2 = long_read( YUV_STATUS );
nkeynes@283
    79
nkeynes@283
    80
    /* Render the thing */
nkeynes@283
    81
    memcpy( p, &test_yuv_poly, sizeof(test_yuv_poly) );
nkeynes@283
    82
    if( pvr_dma_write( 0x10000000, p, sizeof(test_yuv_poly) ) != 0 ) {
nkeynes@283
    83
	return -1;
nkeynes@283
    84
    }
nkeynes@283
    85
nkeynes@283
    86
    return 0;
nkeynes@283
    87
}
nkeynes@283
    88
nkeynes@283
    89
int main( int argc, char *argv[] ) 
nkeynes@283
    90
{
nkeynes@283
    91
    int test_cases = 0;
nkeynes@283
    92
    int test_failures = 0;
nkeynes@283
    93
    test_data_t test_data = load_test_dataset(stdin);
nkeynes@283
    94
    test_data_t test_case = test_data;
nkeynes@283
    95
nkeynes@283
    96
    asic_mask_all();
nkeynes@283
    97
    pvr_init();
nkeynes@283
    98
nkeynes@283
    99
    while( test_case != NULL ) {
nkeynes@283
   100
	test_cases++;
nkeynes@283
   101
	int result = test_yuv(test_case);
nkeynes@283
   102
	if( result != 0 ) {
nkeynes@283
   103
	    test_failures++;
nkeynes@283
   104
	}
nkeynes@283
   105
	test_case = test_case->next;
nkeynes@283
   106
    }
nkeynes@283
   107
    free_test_dataset(test_data);
nkeynes@283
   108
    if( test_failures != 0 ) {
nkeynes@283
   109
	fprintf( stderr, "%d/%d test failures!\n", test_failures, test_cases );
nkeynes@283
   110
	return 1;
nkeynes@283
   111
    } else {
nkeynes@283
   112
	fprintf( stderr, "%d tests OK\n", test_cases );
nkeynes@283
   113
	return 0;
nkeynes@283
   114
    }
nkeynes@283
   115
}
.