vi.c
4.36 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*====================================================================
* vi.c
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/**************************************************************************
*
* $Revision: 1.1.1.2 $
* $Date: 2002/10/29 08:06:43 $
* $Source: /root/leakn64/depot/rf/sw/bbplayer/libultra/monegi/vi/vi.c,v $
*
**************************************************************************/
#include "osint.h"
#include "rcp.h"
#include "viint.h"
#include "assert.h"
/***************************************************************************
*
* Design:
* There are 2 pointers to __osViContext structure: one to the current
* mode of current field and the other to the mode of the next field.
* We simply swap these 2 pointers after a vertical retrace interrupt.
* There are also VI state variables to track what special
* features have been enabled/disabled.
* The goal is to allow the user to modify the "next" VI context (i.e.,
* mode, x-scale, y-scale) - as often as he wishes - up until the vertical
* retrace interrupt which is when osViSwapBuffer() is called to update
* the HW registers with data from "next".
*
* Note:
* All osVixxx functions simply manipulate internal VI structure.
* Only the __osViSwapBuffer() routine actually programs the VI registers.
*
***************************************************************************/
/**************************************************************************
*
* Defines
*/
/**************************************************************************
*
* Static variables
*/
static __OSViContext vi[2] = {0};
/**************************************************************************
*
* Global variables
*/
__OSViContext *__osViCurr = &vi[VI_FIELD1];
__OSViContext *__osViNext = &vi[VI_FIELD2];
/*
int osViClock = VI_NTSC_CLOCK; Now this value defined in osIniitialize
*/
/**************************************************************************
*
* External declarations
*/
/**************************************************************************
*
* Functions
*/
/*
* Name: __osViInit
*
* Description:
* Initialize all VI global data structures with default values.
* This routine is called by osInitialize().
*
* Globals Referenced:
* osTvType, vi, __osViCurr, __osViNext
*/
void
__osViInit(void)
{
/*
* Since this routine is called only once by osInitialize(), we don't
* need to worry about protecting the global VI context array.
*/
/* Zero out the 2 VI context structures */
bzero((void *)vi, sizeof(vi));
/* Initialize the 2 context pointers */
__osViCurr = &vi[VI_FIELD1];
__osViNext = &vi[VI_FIELD2];
__osViNext->retraceCount = 1;
__osViCurr->retraceCount = 1;
__osViNext->framep = 0x80000000;
__osViCurr->framep = 0x80000000;
/* Initialize the default VI mode which is
* LAN1: lo-res, anti-aliased, non-interlaced, 16-bit
*/
if (osTvType == OS_TV_PAL)
__osViNext->modep = &osViModePalLan1;
else if (osTvType == OS_TV_MPAL)
__osViNext->modep = &osViModeMpalLan1;
else /* for now, we assume that it's NTSC */
__osViNext->modep = &osViModeNtscLan1;
__osViNext->state = (VI_STATE_NORMAL | VI_STATE_BLACK);
__osViNext->control = __osViNext->modep->comRegs.ctrl;
/* Spin until we are in the pre-blank stage */
while (IO_READ(VI_CURRENT_REG) > 10);
/* Zero out control register so that NMI reset to LAN1 is safe */
IO_WRITE(VI_CONTROL_REG, 0); /* Turn off video, reset counters */
/* Update hardware register to start receiving vsync */
__osViSwapContext();
} /* __osViInit */