summaryrefslogtreecommitdiff
path: root/r600_basic.c
blob: abf12134842c95c333140bc7156d18db396dd9e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * r600_demo
 *
 * Copyright (C) 2008-2009  Matthias Hopf
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/*
 * Basic tests
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "r600_reg.h"
#include "r600_emit.h"
#include "r600_lib.h"


/* Test for working CP */
void test_cp (adapter_t *adapt)
{
    printf      ("\n* CP test: PACK0 scratch reg\n\n");

    /* Test for CP working by simple register writes (CP_PACKET0) */
    reg_write32 (SCRATCH_REG7, 0xdeadbeef);
    wait_reg    (adapt, SCRATCH_REG7, 0xdeadbeef, "PACK0: init");
    
    pack0       (SCRATCH_REG7, 1);
    e32         (0xcafebabe);
    flush_cmds  ();
    wait_reg    (adapt, SCRATCH_REG7, 0xcafebabe, "CP: scratch");
}


/* Test CP + DMA */
void test_packets (adapter_t *adapt)
{
    printf      ("\n* PACK0 scratch reg test\n\n");

    /* Test for CP working by simple register writes (CP_PACKET0) */
    reg_write32 (SCRATCH_REG7, 0xdeadbeef);
    wait_reg    (adapt, SCRATCH_REG7, 0xdeadbeef, "PACK0: init");

    pack0       (SCRATCH_REG7, 1);
    e32         (0xcafebabe);
    flush_cmds  ();
    wait_reg    (adapt, SCRATCH_REG7, 0xcafebabe, "PACK0: scratch");
    pack0       (SCRATCH_REG7, 1);
    e32         (0xfeedface);
    flush_cmds  ();
    wait_reg    (adapt, SCRATCH_REG7, 0xfeedface, "PACK0: scratch2");

}

void simple_clear (adapter_t* adapt)
{
    uint32_t *dst = adapt->display;
    int i, j;
    uint32_t col = 0x00008000;

    for (i = 0; i < adapt->display_height; i++) {
	for (j = 0; j < adapt->display_pitch; j++) {
	    *dst++ = col;
	    if (j % 32 == 31)
		col ^= 0x00008080;
	}
	if (i % 32 == 31)
	    col ^= 0x00008080;
    }
}