vimodesplit.c
4.94 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
/**************************************************************************
*
* Module: vimodesplit.c
*
* $Revision: 1.4 $
* $Date: 2003/07/15 00:32:34 $
* $Author: blythe $
* $Source: /root/leakn64/depot/rf/sw/bbplayer/libultra/monegi/vi/vimodesplit.c,v $
*
* Description:
* Utility to split the global osViModeTable structure (in vitbl.c) to
* individual .c files, each contains a unique VI mode.
*
**************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "os.h"
/*
* This define needs to change if additional TV types are supported
* Currently, only 3 types are listed here: NTSC, PAL, MPAL, FPAL
*/
#define NUM_TV_TYPE 4
/*
* Currently, there are 14 different modes (ie., lan1, lan2) for each
* different TV type
*/
#define VI_MODE_PER_TV_TYPE 14
typedef struct {
char *tvType;
char *partFileName;
int numOfModes;
} tvModeStruct ;
tvModeStruct tvModeTable[NUM_TV_TYPE] = {
{ "Ntsc", "vimodentsc", VI_MODE_PER_TV_TYPE },
{ "Pal", "vimodepal", VI_MODE_PER_TV_TYPE },
{ "Mpal", "vimodempal", VI_MODE_PER_TV_TYPE },
{ "Fpal", "vimodefpal", VI_MODE_PER_TV_TYPE },
};
/* Extern from vitbl.c */
extern OSViMode osViModeTable[];
static char *
viModeNameTable[VI_MODE_PER_TV_TYPE] = {
"Lpn1",
"Lpf1",
"Lan1",
"Laf1",
"Lpn2",
"Lpf2",
"Lan2",
"Laf2",
"Hpn1",
"Hpf1",
"Han1",
"Haf1",
"Hpn2",
"Hpf2",
};
static char *
str2lower(char *name)
{
int i;
static char buf[256];
char *s = name;
i = 0;
while (*s) {
buf[i++] = tolower(*s++);
}
buf[i] = '\0';
return(buf);
} /* str2lower */
static void
printHeader(FILE *fp, char *type, char *name, OSViMode *me)
{
fprintf(fp, "/*\n");
fprintf(fp, " * VI mode: %s\n", name);
fprintf(fp, " * Created automatically by vimodesplit utility.\n");
fprintf(fp, " */\n\n");
fprintf(fp, "#include \"os.h\"\n");
fprintf(fp, "#include \"rcp.h\"\n\n");
fprintf(fp, "OSViMode osViMode%s%s = {\n", type, name);
fprintf(fp, "\t0x%08x,\t/* type */\n", me->type);
} /* printHeader */
static void
printCommonRegs(FILE *fp, OSViCommonRegs *cr)
{
fprintf(fp, "\t/* Common regs */\n\t{\n");
fprintf(fp, "\t0x%08x,\t/* ctrl */\t0x%08x,\t/* width */\n",
cr->ctrl, cr->width);
fprintf(fp, "\t0x%08x,\t/* burst */\t0x%08x,\t/* vSync */\n",
cr->burst, cr->vSync);
fprintf(fp, "\t0x%08x,\t/* hSync */\t0x%08x,\t/* leap */\n",
cr->hSync, cr->leap);
fprintf(fp, "\t0x%08x,\t/* hStart */\t0x%08x,\t/* xScale */\n",
cr->hStart, cr->xScale);
fprintf(fp, "\t0x%08x,\t/* vCurrent */\n\t},\n",
cr->vCurrent);
} /* printCommonRegs */
static void
printFieldRegs(FILE *fp, int fieldno, OSViFieldRegs *fr)
{
fprintf(fp, "\t/* Field %d regs */\n\t{\n", fieldno);
fprintf(fp, "\t0x%08x,\t/* origin */\t0x%08x,\t/* yScale */\n",
fr->origin, fr->yScale);
fprintf(fp, "\t0x%08x,\t/* vStart */\t0x%08x,\t/* vBurst */\n",
fr->vStart, fr->vBurst);
fprintf(fp, "\t0x%08x,\t/* vIntr */\n\t},\n",
fr->vIntr);
}
main(int argc, char **argv)
{
FILE *fp;
int i, j, k;
char fileName[256];
register char *name;
tvModeStruct *tvmp;
/* Create VI mode files */
for (i = 0; i < NUM_TV_TYPE; i++) {
tvmp = &tvModeTable[i];
for (j = 0; j < tvmp->numOfModes; j++) {
name = viModeNameTable[j];
sprintf(fileName, "%s%s.c", tvmp->partFileName, str2lower(name));
#ifdef _DEBUG
printf("Creating file %s...\n", fileName);
#endif
fp = fopen(fileName, "w+");
if (fp == NULL) {
fprintf(stderr, "ERROR: Unable to create file %s\n", fileName);
exit(1);
}
k = (i*tvmp->numOfModes)+j;
printHeader(fp, tvmp->tvType, name, &osViModeTable[k]);
printCommonRegs(fp, &(osViModeTable[k].comRegs));
fprintf(fp, "\t{\n");
printFieldRegs(fp, 1, &(osViModeTable[k].fldRegs[0]));
printFieldRegs(fp, 2, &(osViModeTable[k].fldRegs[1]));
fprintf(fp, "\t}\n");
fprintf(fp, "};\n\n");
fclose(fp);
} /* for */
} /* for */
return 0;
} /* main */