blob: a8676cc645f7ec160777ad8f09131c62b54798b7 [file] [log] [blame]
Anatolij Gustschinbed53752008-01-11 14:30:01 +01001/*
2 * (C) Copyright 2007
3 * DENX Software Engineering, Anatolij Gustschin, agust@denx.de
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jerry Van Barenae0b05d2009-02-05 22:18:02 -050015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Anatolij Gustschinbed53752008-01-11 14:30:01 +010016 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
25 * mb862xx.c - Graphic interface for Fujitsu CoralP/Lime
26 * PCI and video mode code was derived from smiLynxEM driver.
27 */
28
29#include <common.h>
30
Anatolij Gustschinbed53752008-01-11 14:30:01 +010031#include <asm/io.h>
32#include <pci.h>
33#include <video_fb.h>
34#include "videomodes.h"
35#include <mb862xx.h>
36
Yuri Tikhonov0d489262008-03-24 11:30:54 +010037#if defined(CONFIG_POST)
38#include <post.h>
39#endif
Anatolij Gustschine8652862009-07-07 13:24:08 +020040
Anatolij Gustschinbed53752008-01-11 14:30:01 +010041/*
42 * Graphic Device
43 */
44GraphicDevice mb862xx;
45
46/*
47 * 32MB external RAM - 256K Chip MMIO = 0x1FC0000 ;
48 */
49#define VIDEO_MEM_SIZE 0x01FC0000
50
51#if defined(CONFIG_PCI)
52#if defined(CONFIG_VIDEO_CORALP)
53
54static struct pci_device_id supported[] = {
55 { PCI_VENDOR_ID_FUJITSU, PCI_DEVICE_ID_CORAL_P },
56 { PCI_VENDOR_ID_FUJITSU, PCI_DEVICE_ID_CORAL_PA },
57 { }
58};
59
60/* Internal clock frequency divider table, index is mode number */
61unsigned int fr_div[] = { 0x00000f00, 0x00000900, 0x00000500 };
62#endif
63#endif
64
65#if defined(CONFIG_VIDEO_CORALP)
66#define rd_io in32r
67#define wr_io out32r
68#else
Anatolij Gustschine8652862009-07-07 13:24:08 +020069#define rd_io(addr) in_be32((volatile unsigned *)(addr))
70#define wr_io(addr, val) out_be32((volatile unsigned *)(addr), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010071#endif
72
Anatolij Gustschincce99b22009-07-07 13:27:07 +020073#define HOST_RD_REG(off) rd_io((dev->frameAdrs + GC_HOST_BASE + (off)))
74#define HOST_WR_REG(off, val) wr_io((dev->frameAdrs + GC_HOST_BASE + (off)), \
Anatolij Gustschine8652862009-07-07 13:24:08 +020075 (val))
Anatolij Gustschincce99b22009-07-07 13:27:07 +020076#define DISP_RD_REG(off) rd_io((dev->frameAdrs + GC_DISP_BASE + (off)))
77#define DISP_WR_REG(off, val) wr_io((dev->frameAdrs + GC_DISP_BASE + (off)), \
Anatolij Gustschine8652862009-07-07 13:24:08 +020078 (val))
79#define DE_RD_REG(off) rd_io((dev->dprBase + (off)))
80#define DE_WR_REG(off, val) wr_io((dev->dprBase + (off)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010081
82#if defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschincce99b22009-07-07 13:27:07 +020083#define DE_WR_FIFO(val) wr_io((dev->dprBase + (GC_GEO_FIFO)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010084#else
Anatolij Gustschincce99b22009-07-07 13:27:07 +020085#define DE_WR_FIFO(val) wr_io((dev->dprBase + (GC_FIFO)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010086#endif
87
Anatolij Gustschincce99b22009-07-07 13:27:07 +020088#define L0PAL_WR_REG(idx, val) wr_io((dev->frameAdrs + \
89 (GC_DISP_BASE | GC_L0PAL0) + \
Anatolij Gustschine8652862009-07-07 13:24:08 +020090 ((idx) << 2)), (val))
Anatolij Gustschinbed53752008-01-11 14:30:01 +010091
Anatolij Gustschine8652862009-07-07 13:24:08 +020092static void gdc_sw_reset (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +010093{
Anatolij Gustschine8652862009-07-07 13:24:08 +020094 GraphicDevice *dev = &mb862xx;
95
Anatolij Gustschincce99b22009-07-07 13:27:07 +020096 HOST_WR_REG (GC_SRST, 0x1);
Anatolij Gustschinbed53752008-01-11 14:30:01 +010097 udelay (500);
98 video_hw_init ();
99}
100
101
Anatolij Gustschine8652862009-07-07 13:24:08 +0200102static void de_wait (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100103{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200104 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100105 int lc = 0x10000;
106
Anatolij Gustschine8652862009-07-07 13:24:08 +0200107 /*
108 * Sync with software writes to framebuffer,
109 * try to reset if engine locked
110 */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200111 while (DE_RD_REG (GC_CTR) & 0x00000131)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100112 if (lc-- < 0) {
113 gdc_sw_reset ();
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200114 puts ("gdc reset done after drawing engine lock.\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100115 break;
116 }
117}
118
Anatolij Gustschine8652862009-07-07 13:24:08 +0200119static void de_wait_slots (int slots)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100120{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200121 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100122 int lc = 0x10000;
123
124 /* Wait for free fifo slots */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200125 while (DE_RD_REG (GC_IFCNT) < slots)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100126 if (lc-- < 0) {
127 gdc_sw_reset ();
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200128 puts ("gdc reset done after drawing engine lock.\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100129 break;
130 }
131}
132
133#if !defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200134static void board_disp_init (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100135{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200136 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100137 const gdc_regs *regs = board_get_regs ();
138
139 while (regs->index) {
140 DISP_WR_REG (regs->index, regs->value);
141 regs++;
142 }
143}
144#endif
145
146/*
147 * Init drawing engine
148 */
149static void de_init (void)
150{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200151 GraphicDevice *dev = &mb862xx;
152 int cf = (dev->gdfBytesPP == 1) ? 0x0000 : 0x8000;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100153
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200154 dev->dprBase = dev->frameAdrs + GC_DRAW_BASE;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100155
156 /* Setup mode and fbbase, xres, fg, bg */
157 de_wait_slots (2);
158 DE_WR_FIFO (0xf1010108);
159 DE_WR_FIFO (cf | 0x0300);
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200160 DE_WR_REG (GC_FBR, 0x0);
161 DE_WR_REG (GC_XRES, dev->winSizeX);
162 DE_WR_REG (GC_FC, 0x0);
163 DE_WR_REG (GC_BC, 0x0);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100164 /* Reset clipping */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200165 DE_WR_REG (GC_CXMIN, 0x0);
166 DE_WR_REG (GC_CXMAX, dev->winSizeX);
167 DE_WR_REG (GC_CYMIN, 0x0);
168 DE_WR_REG (GC_CYMAX, dev->winSizeY);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100169
170 /* Clear framebuffer using drawing engine */
171 de_wait_slots (3);
172 DE_WR_FIFO (0x09410000);
173 DE_WR_FIFO (0x00000000);
Anatolij Gustschine8652862009-07-07 13:24:08 +0200174 DE_WR_FIFO (dev->winSizeY << 16 | dev->winSizeX);
Anatolij Gustschin322716a2008-07-12 17:31:36 +0200175 /* sync with SW access to framebuffer */
176 de_wait ();
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100177}
178
179#if defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200180unsigned int pci_video_init (void)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100181{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200182 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100183 pci_dev_t devbusfn;
184
Anatolij Gustschine8652862009-07-07 13:24:08 +0200185 if ((devbusfn = pci_find_devices (supported, 0)) < 0) {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200186 puts ("PCI video controller not found!\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100187 return 0;
188 }
189
190 /* PCI setup */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200191 pci_write_config_dword (devbusfn, PCI_COMMAND,
192 (PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
193 pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0, &dev->frameAdrs);
194 dev->frameAdrs = pci_mem_to_phys (devbusfn, dev->frameAdrs);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100195
Anatolij Gustschine8652862009-07-07 13:24:08 +0200196 if (dev->frameAdrs == 0) {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200197 puts ("PCI config: failed to get base address\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100198 return 0;
199 }
200
Anatolij Gustschine8652862009-07-07 13:24:08 +0200201 dev->pciBase = dev->frameAdrs;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100202
203 /* Setup clocks and memory mode for Coral-P Eval. Board */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200204 HOST_WR_REG (GC_CCF, 0x00090000);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100205 udelay (200);
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200206 HOST_WR_REG (GC_MMR, 0x11d7fa13);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100207 udelay (100);
Anatolij Gustschine8652862009-07-07 13:24:08 +0200208 return dev->frameAdrs;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100209}
210
211unsigned int card_init (void)
212{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200213 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100214 unsigned int cf, videomode, div = 0;
215 unsigned long t1, hsync, vsync;
216 char *penv;
217 int tmp, i, bpp;
218 struct ctfb_res_modes *res_mode;
219 struct ctfb_res_modes var_mode;
220
Anatolij Gustschine8652862009-07-07 13:24:08 +0200221 memset (dev, 0, sizeof (GraphicDevice));
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100222
Anatolij Gustschine8652862009-07-07 13:24:08 +0200223 if (!pci_video_init ())
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100224 return 0;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100225
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200226 puts ("CoralP\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100227
228 tmp = 0;
229 videomode = 0x310;
230 /* get video mode via environment */
231 if ((penv = getenv ("videomode")) != NULL) {
Anatolij Gustschine8652862009-07-07 13:24:08 +0200232 /* decide if it is a string */
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100233 if (penv[0] <= '9') {
234 videomode = (int) simple_strtoul (penv, NULL, 16);
235 tmp = 1;
236 }
237 } else {
238 tmp = 1;
239 }
Anatolij Gustschine8652862009-07-07 13:24:08 +0200240
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100241 if (tmp) {
Anatolij Gustschine8652862009-07-07 13:24:08 +0200242 /* parameter are vesa modes, search params */
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100243 for (i = 0; i < VESA_MODES_COUNT; i++) {
244 if (vesa_modes[i].vesanr == videomode)
245 break;
246 }
247 if (i == VESA_MODES_COUNT) {
Anatolij Gustschine8652862009-07-07 13:24:08 +0200248 printf ("\tno VESA Mode found, fallback to mode 0x%x\n",
249 videomode);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100250 i = 0;
251 }
Anatolij Gustschine8652862009-07-07 13:24:08 +0200252 res_mode = (struct ctfb_res_modes *)
253 &res_mode_init[vesa_modes[i].resindex];
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100254 if (vesa_modes[i].resindex > 2) {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200255 puts ("\tUnsupported resolution, using default\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100256 bpp = vesa_modes[1].bits_per_pixel;
257 div = fr_div[1];
258 }
259 bpp = vesa_modes[i].bits_per_pixel;
260 div = fr_div[vesa_modes[i].resindex];
261 } else {
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100262 res_mode = (struct ctfb_res_modes *) &var_mode;
263 bpp = video_get_params (res_mode, penv);
264 }
265
266 /* calculate hsync and vsync freq (info only) */
267 t1 = (res_mode->left_margin + res_mode->xres +
268 res_mode->right_margin + res_mode->hsync_len) / 8;
269 t1 *= 8;
270 t1 *= res_mode->pixclock;
271 t1 /= 1000;
272 hsync = 1000000000L / t1;
273 t1 *= (res_mode->upper_margin + res_mode->yres +
274 res_mode->lower_margin + res_mode->vsync_len);
275 t1 /= 1000;
276 vsync = 1000000000L / t1;
277
278 /* fill in Graphic device struct */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200279 sprintf (dev->modeIdent, "%dx%dx%d %ldkHz %ldHz", res_mode->xres,
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100280 res_mode->yres, bpp, (hsync / 1000), (vsync / 1000));
Anatolij Gustschine8652862009-07-07 13:24:08 +0200281 printf ("\t%s\n", dev->modeIdent);
282 dev->winSizeX = res_mode->xres;
283 dev->winSizeY = res_mode->yres;
284 dev->memSize = VIDEO_MEM_SIZE;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100285
286 switch (bpp) {
287 case 8:
Anatolij Gustschine8652862009-07-07 13:24:08 +0200288 dev->gdfIndex = GDF__8BIT_INDEX;
289 dev->gdfBytesPP = 1;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100290 break;
291 case 15:
292 case 16:
Anatolij Gustschine8652862009-07-07 13:24:08 +0200293 dev->gdfIndex = GDF_15BIT_555RGB;
294 dev->gdfBytesPP = 2;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100295 break;
296 default:
Anatolij Gustschine8652862009-07-07 13:24:08 +0200297 printf ("\t%d bpp configured, but only 8,15 and 16 supported\n",
298 bpp);
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200299 puts ("\tfallback to 15bpp\n");
Anatolij Gustschine8652862009-07-07 13:24:08 +0200300 dev->gdfIndex = GDF_15BIT_555RGB;
301 dev->gdfBytesPP = 2;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100302 }
303
304 /* Setup dot clock (internal pll, division rate) */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200305 DISP_WR_REG (GC_DCM1, div);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100306 /* L0 init */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200307 cf = (dev->gdfBytesPP == 1) ? 0x00000000 : 0x80000000;
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200308 DISP_WR_REG (GC_L0M, ((dev->winSizeX * dev->gdfBytesPP) / 64) << 16 |
Anatolij Gustschine8652862009-07-07 13:24:08 +0200309 (dev->winSizeY - 1) | cf);
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200310 DISP_WR_REG (GC_L0OA0, 0x0);
311 DISP_WR_REG (GC_L0DA0, 0x0);
312 DISP_WR_REG (GC_L0DY_L0DX, 0x0);
313 DISP_WR_REG (GC_L0EM, 0x0);
314 DISP_WR_REG (GC_L0WY_L0WX, 0x0);
315 DISP_WR_REG (GC_L0WH_L0WW, (dev->winSizeY - 1) << 16 | dev->winSizeX);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100316
317 /* Display timing init */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200318 DISP_WR_REG (GC_HTP_A, (dev->winSizeX +
319 res_mode->left_margin +
320 res_mode->right_margin +
321 res_mode->hsync_len - 1) << 16);
322 DISP_WR_REG (GC_HDB_HDP_A, (dev->winSizeX - 1) << 16 |
323 (dev->winSizeX - 1));
324 DISP_WR_REG (GC_VSW_HSW_HSP_A, (res_mode->vsync_len - 1) << 24 |
325 (res_mode->hsync_len - 1) << 16 |
326 (dev->winSizeX +
327 res_mode->right_margin - 1));
328 DISP_WR_REG (GC_VTR_A, (dev->winSizeY + res_mode->lower_margin +
329 res_mode->upper_margin +
330 res_mode->vsync_len - 1) << 16);
331 DISP_WR_REG (GC_VDP_VSP_A, (dev->winSizeY-1) << 16 |
332 (dev->winSizeY +
333 res_mode->lower_margin - 1));
334 DISP_WR_REG (GC_WY_WX, 0x0);
335 DISP_WR_REG (GC_WH_WW, dev->winSizeY << 16 | dev->winSizeX);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100336 /* Display enable, L0 layer */
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200337 DISP_WR_REG (GC_DCM1, 0x80010000 | div);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100338
Anatolij Gustschine8652862009-07-07 13:24:08 +0200339 return dev->frameAdrs;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100340}
341#endif
342
343void *video_hw_init (void)
344{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200345 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100346
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200347 puts ("Video: Fujitsu ");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100348
Anatolij Gustschine8652862009-07-07 13:24:08 +0200349 memset (dev, 0, sizeof (GraphicDevice));
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100350
351#if defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200352 if (card_init () == 0)
353 return NULL;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100354#else
Anatolij Gustschine8652862009-07-07 13:24:08 +0200355 /*
356 * Preliminary init of the onboard graphic controller,
357 * retrieve base address
358 */
359 if ((dev->frameAdrs = board_video_init ()) == 0) {
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200360 puts ("Controller not found!\n");
Anatolij Gustschine8652862009-07-07 13:24:08 +0200361 return NULL;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100362 } else
Anatolij Gustschin9d173e02009-07-07 13:11:36 +0200363 puts ("Lime\n");
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100364#endif
365
366 de_init ();
367
368#if !defined(CONFIG_VIDEO_CORALP)
Anatolij Gustschine8652862009-07-07 13:24:08 +0200369 board_disp_init ();
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100370#endif
371
Anatolij Gustschine64987a2008-08-15 15:42:13 +0200372#if (defined(CONFIG_LWMON5) || \
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200373 defined(CONFIG_SOCRATES)) && !(CONFIG_POST & CONFIG_SYS_POST_SYSMON)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100374 /* Lamp on */
375 board_backlight_switch (1);
376#endif
377
Anatolij Gustschine8652862009-07-07 13:24:08 +0200378 return dev;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100379}
380
381/*
382 * Set a RGB color in the LUT
383 */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200384void video_set_lut (unsigned int index, unsigned char r,
385 unsigned char g, unsigned char b)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100386{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200387 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100388
389 L0PAL_WR_REG (index, (r << 16) | (g << 8) | (b));
390}
391
392/*
393 * Drawing engine Fill and BitBlt screen region
394 */
Anatolij Gustschine8652862009-07-07 13:24:08 +0200395void video_hw_rectfill (unsigned int bpp, unsigned int dst_x,
396 unsigned int dst_y, unsigned int dim_x,
397 unsigned int dim_y, unsigned int color)
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100398{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200399 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100400
401 de_wait_slots (3);
Anatolij Gustschincce99b22009-07-07 13:27:07 +0200402 DE_WR_REG (GC_FC, color);
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100403 DE_WR_FIFO (0x09410000);
404 DE_WR_FIFO ((dst_y << 16) | dst_x);
405 DE_WR_FIFO ((dim_y << 16) | dim_x);
406 de_wait ();
407}
408
Anatolij Gustschine8652862009-07-07 13:24:08 +0200409void video_hw_bitblt (unsigned int bpp, unsigned int src_x,
410 unsigned int src_y, unsigned int dst_x,
411 unsigned int dst_y, unsigned int width,
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100412 unsigned int height)
413{
Anatolij Gustschine8652862009-07-07 13:24:08 +0200414 GraphicDevice *dev = &mb862xx;
Anatolij Gustschinbed53752008-01-11 14:30:01 +0100415 unsigned int ctrl = 0x0d000000L;
416
417 if (src_x >= dst_x && src_y >= dst_y)
418 ctrl |= 0x00440000L;
419 else if (src_x >= dst_x && src_y <= dst_y)
420 ctrl |= 0x00460000L;
421 else if (src_x <= dst_x && src_y >= dst_y)
422 ctrl |= 0x00450000L;
423 else
424 ctrl |= 0x00470000L;
425
426 de_wait_slots (4);
427 DE_WR_FIFO (ctrl);
428 DE_WR_FIFO ((src_y << 16) | src_x);
429 DE_WR_FIFO ((dst_y << 16) | dst_x);
430 DE_WR_FIFO ((height << 16) | width);
431 de_wait (); /* sync */
432}