OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [altera_de0_nano_soc/] [software/] [libs/] [gfx/] [gfx_controller.h] - Blame information for rev 221

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 221 olivier.gi
#ifndef GFX_CONTROLLER_H
2
#define GFX_CONTROLLER_H
3
 
4
#include "timerA.h"
5
#include <in430.h>
6
#include <stdint.h>
7
 
8
//----------------------------------------------------------
9
// GLOBAL CONFIGURATION
10
//----------------------------------------------------------
11
 
12
#ifdef VERILOG_SIMULATION
13
  #define SCREEN_WIDTH         5
14
  #define SCREEN_HEIGHT        3
15
#else
16
  #define SCREEN_WIDTH         320
17
  #define SCREEN_HEIGHT        240
18
#endif
19
 
20
#define   FRAME_MEMORY_KB_SIZE 75*2
21
 
22
//#define LT24_ROTATE
23
 
24
//----------------------------------------------------------
25
// UTILITY MACROS
26
//----------------------------------------------------------
27
 
28
// Convert pixel coordinates into memory address
29
#define PIX_ADDR(X, Y) ((((uint32_t)(Y)) * ((uint32_t)(SCREEN_WIDTH))) + ((uint32_t)(X)))
30
 
31
 
32
//----------------------------------------------------------
33
// FUNCTIONS
34
//----------------------------------------------------------
35
 
36
// Initialization functions
37
void init_gfx_ctrl (uint16_t gfx_mode, uint16_t refresh_rate);
38
void start_gfx_ctrl(void);
39
 
40
// LT24 specific functions
41
void init_lt24(uint16_t lt24_clk_div);
42
void start_lt24(void);
43
 
44
// GPU Functions
45
void gpu_fill (uint32_t addr, uint16_t width, uint16_t length, uint16_t color, uint16_t configuration);
46
void gpu_copy (uint32_t src_addr, uint32_t dst_addr, uint16_t width, uint16_t length, uint16_t configuration);
47
void gpu_copy_transparent (uint32_t src_addr, uint32_t dst_addr, uint16_t width, uint16_t length, uint16_t trans_color, uint16_t configuration);
48
inline void gpu_wait_done (void);
49
 
50
// Other Functions
51
void sync_screen_refresh_done(void);
52
void sync_screen_refresh_start(void);
53
 
54
 
55
//----------------------------------------------------------
56
// GRAPHIC CONTROLLER REGISTERS
57
//----------------------------------------------------------
58
#define  GFX_CTRL          (*(volatile uint16_t  *) 0x0200)
59
#define  GFX_STATUS        (*(volatile uint16_t  *) 0x0208)
60
#define  GFX_IRQ           (*(volatile uint16_t  *) 0x020A)
61
 
62
#define  DISPLAY_WIDTH     (*(volatile uint16_t  *) 0x0210)
63
#define  DISPLAY_HEIGHT    (*(volatile uint16_t  *) 0x0212)
64
#define  DISPLAY_SIZE      (*(volatile uint32_t  *) 0x0214)
65
#define  DISPLAY_CFG       (*(volatile uint16_t  *) 0x0218)
66
#define  DISPLAY_REFR_CNT  (*(volatile uint16_t  *) 0x021A)
67
 
68
#define  LT24_CFG          (*(volatile uint16_t  *) 0x0220)
69
#define  LT24_REFRESH      (*(volatile uint16_t  *) 0x0222)
70
#define  LT24_REFRESH_SYNC (*(volatile uint16_t  *) 0x0224)
71
#define  LT24_CMD          (*(volatile uint16_t  *) 0x0226)
72
#define  LT24_CMD_PARAM    (*(volatile uint16_t  *) 0x0228)
73
#define  LT24_CMD_DFILL    (*(volatile uint16_t  *) 0x022A)
74
#define  LT24_STATUS       (*(volatile uint16_t  *) 0x022C)
75
 
76
#define  LUT_RAM_ADDR      (*(volatile uint16_t  *) 0x0230)
77
#define  LUT_RAM_DATA      (*(volatile uint16_t  *) 0x0232)
78
 
79
#define  FRAME_SELECT      (*(volatile uint16_t  *) 0x023E)
80
#define  FRAME0_PTR        (*(volatile uint32_t  *) 0x0240)
81
#define  FRAME1_PTR        (*(volatile uint32_t  *) 0x0244)
82
#define  FRAME2_PTR        (*(volatile uint32_t  *) 0x0248)
83
#define  FRAME3_PTR        (*(volatile uint32_t  *) 0x024C)
84
 
85
#define  VID_RAM0_CFG      (*(volatile uint16_t  *) 0x0250)
86
#define  VID_RAM0_WIDTH    (*(volatile uint16_t  *) 0x0252)
87
#define  VID_RAM0_ADDR     (*(volatile uint32_t  *) 0x0254)
88
#define  VID_RAM0_DATA     (*(volatile uint16_t  *) 0x0258)
89
 
90
#define  VID_RAM1_CFG      (*(volatile uint16_t  *) 0x0260)
91
#define  VID_RAM1_WIDTH    (*(volatile uint16_t  *) 0x0262)
92
#define  VID_RAM1_ADDR     (*(volatile uint32_t  *) 0x0264)
93
#define  VID_RAM1_DATA     (*(volatile uint16_t  *) 0x0268)
94
 
95
#define  GPU_CMD           (*(volatile uint16_t  *) 0x0270)
96
#define  GPU_CMD32         (*(volatile uint32_t  *) 0x0270)
97
#define  GPU_STAT          (*(volatile uint16_t  *) 0x0274)
98
 
99
 
100
//----------------------------------------------------------
101
// GRAPHIC CONTROLLER REGISTER FIELD MAPPING
102
//----------------------------------------------------------
103
 
104
// GFX_CTRL Register
105
#define  GFX_REFR_DONE_IRQ_EN      0x0001
106
#define  GFX_REFR_DONE_IRQ_DIS     0x0000
107
#define  GFX_REFR_START_IRQ_EN     0x0002
108
#define  GFX_REFR_START_IRQ_DIS    0x0000
109
#define  GFX_GPU_FIFO_DONE_IRQ_EN  0x0010
110
#define  GFX_GPU_FIFO_DONE_IRQ_DIS 0x0000
111
#define  GFX_GPU_FIFO_OVFL_IRQ_EN  0x0020
112
#define  GFX_GPU_FIFO_OVFL_IRQ_DIS 0x0000
113
#define  GFX_GPU_CMD_DONE_IRQ_EN   0x0040
114
#define  GFX_GPU_CMD_DONE_IRQ_DIS  0x0000
115
#define  GFX_GPU_CMD_ERROR_IRQ_EN  0x0080
116
#define  GFX_GPU_CMD_ERROR_IRQ_DIS 0x0000
117
#define  GFX_16_BPP                0x0400
118
#define  GFX_8_BPP                 0x0300
119
#define  GFX_4_BPP                 0x0200
120
#define  GFX_2_BPP                 0x0100
121
#define  GFX_1_BPP                 0x0000
122
#define  GFX_GPU_EN                0x1000
123
#define  GFX_GPU_DIS               0x0000
124
 
125
// GFX_STATUS Register
126
#define  STATUS_REFRESH_BUSY       0x0001
127
 
128
// GFX_IRQ Register
129
#define  GFX_IRQ_REFRESH_DONE      0x0001
130
#define  GFX_IRQ_REFRESH_START     0x0002
131
#define  GFX_IRQ_GPU_FIFO_DONE     0x0010
132
#define  GFX_IRQ_GPU_FIFO_OVFL     0x0020
133
#define  GFX_IRQ_GPU_CMD_DONE      0x0040
134
#define  GFX_IRQ_GPU_CMD_ERROR     0x0080
135
 
136
// DISPLAY_CFG Register
137
#define  DISPLAY_CL_SWAP           0x0001
138
#define  DISPLAY_Y_SWAP            0x0002
139
#define  DISPLAY_X_SWAP            0x0004
140
#define  DISPLAY_NO_CL_SWAP        0x0000
141
#define  DISPLAY_NO_Y_SWAP         0x0000
142
#define  DISPLAY_NO_X_SWAP         0x0000
143
 
144
// LT24_CFG Register
145
#define  LT24_ON                   0x0001
146
#define  LT24_RESET                0x0002
147
#define  LT24_CLK_DIV1             0x0000
148
#define  LT24_CLK_DIV2             0x0010
149
#define  LT24_CLK_DIV3             0x0020
150
#define  LT24_CLK_DIV4             0x0030
151
#define  LT24_CLK_DIV5             0x0040
152
#define  LT24_CLK_DIV6             0x0050
153
#define  LT24_CLK_DIV7             0x0060
154
#define  LT24_CLK_DIV8             0x0070
155
#define  LT24_CLK_MASK             0x0070
156
 
157
// LT24_REFRESH Register
158
#define  LT24_REFR_START           0x0001
159
#define  LT24_REFR_MANUAL          0x0000
160
#define  LT24_REFR_21_FPS          (((48000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
161
#define  LT24_REFR_24_FPS          (((40000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
162
#define  LT24_REFR_31_FPS          (((32000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
163
#define  LT24_REFR_42_FPS          (((24000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
164
#define  LT24_REFR_62_FPS          (((16000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
165
#define  LT24_REFR_125_FPS         ((( 8000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
166
#define  LT24_REFR_250_FPS         ((( 4000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
167
#define  LT24_REFR_500_FPS         ((( 2000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
168
#define  LT24_REFR_1000_FPS        ((( 1000000/DCO_CLK_PERIOD)>>8) & 0xFFF0)
169
#define  LT24_REFR_MASK            0xFFF0
170
 
171
// LT24_REFRESH_SYNC Register
172
#define  LT24_REFR_SYNC            0x8000
173
#define  LT24_REFR_NO_SYNC         0x0000
174
 
175
// LT24_CMD Register
176
#define  LT24_CMD_MSK              0x00FF
177
#define  LT24_CMD_HAS_PARAM        0x0100
178
#define  LT24_CMD_NO_PARAM         0x0000
179
 
180
// LT24_STATUS Register
181
#define  LT24_STATUS_FSM_BUSY      0x0001
182
#define  LT24_STATUS_WAIT_PARAM    0x0002
183
#define  LT24_STATUS_REFRESH_BUSY  0x0004
184
#define  LT24_STATUS_REFRESH_WAIT  0x0008
185
#define  LT24_STATUS_DFILL_BUSY    0x0010
186
 
187
// FRAME_SELECT Register
188
#define  REFRESH_FRAME0_SELECT     0x0000
189
#define  REFRESH_FRAME1_SELECT     0x0001
190
#define  REFRESH_FRAME2_SELECT     0x0002
191
#define  REFRESH_FRAME3_SELECT     0x0003
192
#define  REFRESH_FRAME_MASK        0x0003
193
 
194
#define  REFRESH_SW_LUT_DISABLE    0x0000
195
#define  REFRESH_SW_LUT_ENABLE     0x0004
196
#define  REFRESH_SW_LUT0_SELECT    0x0000
197
#define  REFRESH_SW_LUT1_SELECT    0x0008
198
 
199
#define  VID_RAM0_FRAME0_SELECT    0x0000
200
#define  VID_RAM0_FRAME1_SELECT    0x0010
201
#define  VID_RAM0_FRAME2_SELECT    0x0020
202
#define  VID_RAM0_FRAME3_SELECT    0x0030
203
#define  VID_RAM0_FRAME_MASK       0x0030
204
 
205
#define  VID_RAM1_FRAME0_SELECT    0x0000
206
#define  VID_RAM1_FRAME1_SELECT    0x0040
207
#define  VID_RAM1_FRAME2_SELECT    0x0080
208
#define  VID_RAM1_FRAME3_SELECT    0x00C0
209
#define  VID_RAM1_FRAME_MASK       0x00C0
210
 
211
#define  LUT_BANK0_SELECT          0x0000
212
#define  LUT_BANK1_SELECT          0x8000
213
 
214
// VID_RAMx_CFG Register
215
#define  VID_RAM_RMW_MODE          0x0010
216
#define  VID_RAM_MSK_MODE          0x0020
217
#define  VID_RAM_WIN_MODE          0x0040
218
#define  VID_RAM_NO_RMW_MODE       0x0000
219
#define  VID_RAM_NO_MSK_MODE       0x0000
220
#define  VID_RAM_NO_WIN_MODE       0x0000
221
#define  VID_RAM_WIN_CL_SWAP       0x0001
222
#define  VID_RAM_WIN_Y_SWAP        0x0002
223
#define  VID_RAM_WIN_X_SWAP        0x0004
224
#define  VID_RAM_WIN_NO_CL_SWAP    0x0000
225
#define  VID_RAM_WIN_NO_Y_SWAP     0x0000
226
#define  VID_RAM_WIN_NO_X_SWAP     0x0000
227
 
228
// GPU_STAT Register
229
#define  GPU_STAT_FIFO_CNT_EMPTY   0x000F
230
#define  GPU_STAT_FIFO_CNT         0x00F0
231
#define  GPU_STAT_FIFO_EMPTY       0x0100
232
#define  GPU_STAT_FIFO_FULL        0x0200
233
#define  GPU_STAT_DMA_BUSY         0x1000
234
#define  GPU_STAT_BUSY             0x8000
235
 
236
//----------------------------------------------------------
237
// GPU COMMANDS
238
//----------------------------------------------------------
239
 
240
// GPU COMMAND
241
#define  GPU_EXEC_FILL             0x0000
242
#define  GPU_EXEC_COPY             0x4000
243
#define  GPU_EXEC_COPY_TRANS       0x8000
244
#define  GPU_REC_WIDTH             0xC000
245
#define  GPU_REC_HEIGHT            0xD000
246
#define  GPU_SRC_PX_ADDR           0xF800
247
#define  GPU_DST_PX_ADDR           0xF801
248
#define  GPU_OF0_ADDR              0xF810
249
#define  GPU_OF1_ADDR              0xF811
250
#define  GPU_OF2_ADDR              0xF812
251
#define  GPU_OF3_ADDR              0xF813
252
#define  GPU_SET_FILL              0xF420
253
#define  GPU_SET_TRANS             0xF421
254
 
255
// ADDRESS SOURCE SELECTION
256
#define  GPU_SRC_OF0               0x0000
257
#define  GPU_SRC_OF1               0x1000
258
#define  GPU_SRC_OF2               0x2000
259
#define  GPU_SRC_OF3               0x3000
260
#define  GPU_DST_OF0               0x0000
261
#define  GPU_DST_OF1               0x0008
262
#define  GPU_DST_OF2               0x0010
263
#define  GPU_DST_OF3               0x0018
264
 
265
// DMA CONFIGURATION
266
#define  GPU_DST_CL_SWP            0x0001
267
#define  GPU_DST_Y_SWP             0x0002
268
#define  GPU_DST_X_SWP             0x0004
269
#define  GPU_SRC_CL_SWP            0x0200
270
#define  GPU_SRC_Y_SWP             0x0400
271
#define  GPU_SRC_X_SWP             0x0800
272
#define  GPU_DST_NO_CL_SWP         0x0000
273
#define  GPU_DST_NO_Y_SWP          0x0000
274
#define  GPU_DST_NO_X_SWP          0x0000
275
#define  GPU_SRC_NO_CL_SWP         0x0000
276
#define  GPU_SRC_NO_Y_SWP          0x0000
277
#define  GPU_SRC_NO_X_SWP          0x0000
278
 
279
#define  DST_SWAP_NONE             0x0000
280
#define  DST_SWAP_CL               0x0001
281
#define  DST_SWAP_Y                0x0002
282
#define  DST_SWAP_Y_CL             0x0003
283
#define  DST_SWAP_X                0x0004
284
#define  DST_SWAP_X_CL             0x0005
285
#define  DST_SWAP_X_Y              0x0006
286
#define  DST_SWAP_X_Y_CL           0x0007
287
#define  DST_SWAP_MSK              0xFFF8
288
 
289
#define  SRC_SWAP_NONE             0x0000
290
#define  SRC_SWAP_CL               0x0200
291
#define  SRC_SWAP_Y                0x0400
292
#define  SRC_SWAP_Y_CL             0x0600
293
#define  SRC_SWAP_X                0x0800
294
#define  SRC_SWAP_X_CL             0x0A00
295
#define  SRC_SWAP_X_Y              0x0C00
296
#define  SRC_SWAP_X_Y_CL           0x0E00
297
#define  SRC_SWAP_MSK              0xF1FF
298
 
299
// PIXEL OPERATION
300
#define  GPU_PXOP_0                0x0000  // S
301
#define  GPU_PXOP_1                0x0020  // not S
302
#define  GPU_PXOP_2                0x0040  // not D
303
#define  GPU_PXOP_3                0x0060  // S and D
304
#define  GPU_PXOP_4                0x0080  // S or  D
305
#define  GPU_PXOP_5                0x00A0  // S xor D
306
#define  GPU_PXOP_6                0x00C0  // not (S and D)
307
#define  GPU_PXOP_7                0x00E0  // not (S or  D)
308
#define  GPU_PXOP_8                0x0100  // not (S xor D)
309
#define  GPU_PXOP_9                0x0120  // (not S) and      D
310
#define  GPU_PXOP_A                0x0140  //      S  and (not D)
311
#define  GPU_PXOP_B                0x0160  // (not S) or       D
312
#define  GPU_PXOP_C                0x0180  //      S  or  (not D)
313
#define  GPU_PXOP_D                0x01A0  // Fill 0            if S not transparent (only COPY_TRANSPARENT command)
314
#define  GPU_PXOP_E                0x01C0  // Fill 1            if S not transparent (only COPY_TRANSPARENT command)
315
#define  GPU_PXOP_F                0x01E0  // Fill 'fill_color' if S not transparent (only COPY_TRANSPARENT command)
316
 
317
 
318
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.