2 * (C) Copyright 2006 by OpenMoko, Inc.
3 * Author: Harald Welte <laforge@openmoko.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 #if defined(CONFIG_VIDEO_S3C2410)
26 #include "videomodes.h"
29 * Export Graphic Device
33 #define VIDEO_MEM_SIZE 0x200000 /* 480x640x16bit = 614400 bytes */
35 extern void board_video_init(GraphicDevice
*pGD
);
37 /*******************************************************************************
39 * Init video chip with common Linux graphic modes (lilo)
41 void *video_hw_init (void)
43 S3C24X0_LCD
* const lcd
= S3C24X0_GetBase_LCD();
44 GraphicDevice
*pGD
= (GraphicDevice
*)&smi
;
46 unsigned long t1
, hsynch
, vsynch
;
48 int tmp
, i
, bits_per_pixel
;
49 struct ctfb_res_modes
*res_mode
;
50 struct ctfb_res_modes var_mode
;
51 unsigned char videoout
;
53 /* Search for video chip */
58 videomode
= CFG_DEFAULT_VIDEO_MODE
;
59 /* get video mode via environment */
60 if ((penv
= getenv ("videomode")) != NULL
) {
61 /* deceide if it is a string */
63 videomode
= (int) simple_strtoul (penv
, NULL
, 16);
70 /* parameter are vesa modes */
72 for (i
= 0; i
< VESA_MODES_COUNT
; i
++) {
73 if (vesa_modes
[i
].vesanr
== videomode
)
76 if (i
== VESA_MODES_COUNT
) {
77 printf ("no VESA Mode found, switching to mode 0x%x ", CFG_DEFAULT_VIDEO_MODE
);
81 (struct ctfb_res_modes
*) &res_mode_init
[vesa_modes
[i
].
83 bits_per_pixel
= vesa_modes
[i
].bits_per_pixel
;
86 res_mode
= (struct ctfb_res_modes
*) &var_mode
;
87 bits_per_pixel
= video_get_params (res_mode
, penv
);
90 /* calculate hsynch and vsynch freq (info only) */
91 t1
= (res_mode
->left_margin
+ res_mode
->xres
+
92 res_mode
->right_margin
+ res_mode
->hsync_len
) / 8;
94 t1
*= res_mode
->pixclock
;
96 hsynch
= 1000000000L / t1
;
98 (res_mode
->upper_margin
+ res_mode
->yres
+
99 res_mode
->lower_margin
+ res_mode
->vsync_len
);
101 vsynch
= 1000000000L / t1
;
103 /* fill in Graphic device struct */
104 sprintf (pGD
->modeIdent
, "%dx%dx%d %ldkHz %ldHz", res_mode
->xres
,
105 res_mode
->yres
, bits_per_pixel
, (hsynch
/ 1000),
107 printf ("%s\n", pGD
->modeIdent
);
108 pGD
->winSizeX
= res_mode
->xres
;
109 pGD
->winSizeY
= res_mode
->yres
;
110 pGD
->plnSizeX
= res_mode
->xres
;
111 pGD
->plnSizeY
= res_mode
->yres
;
112 switch (bits_per_pixel
) {
115 pGD
->gdfIndex
= GDF__8BIT_INDEX
;
119 pGD
->gdfIndex
= GDF_15BIT_555RGB
;
123 pGD
->gdfIndex
= GDF_16BIT_565RGB
;
127 pGD
->gdfIndex
= GDF_24BIT_888RGB
;
131 /* statically configure settings */
132 pGD
->winSizeX
= pGD
->plnSizeX
= 480;
133 pGD
->winSizeY
= pGD
->plnSizeY
= 640;
135 pGD
->gdfIndex
= GDF_16BIT_565RGB
;
137 pGD
->frameAdrs
= LCD_VIDEO_ADDR
;
138 pGD
->memSize
= VIDEO_MEM_SIZE
;
140 board_video_init(pGD
);
142 lcd
->LCDSADDR1
= pGD
->frameAdrs
>> 1;
144 /* This marks the end of the frame buffer. */
145 lcd
->LCDSADDR2
= (lcd
->LCDSADDR1
&0x1fffff) + (pGD
->winSizeX
+0) * pGD
->winSizeY
;
146 lcd
->LCDSADDR3
= pGD
->winSizeX
;
148 /* Clear video memory */
149 memset(pGD
->frameAdrs
, 0, pGD
->memSize
);
152 lcd
->LCDCON1
|= 0x01; /* ENVID = 1 */
154 return ((void*)&smi
);
158 video_set_lut (unsigned int index
, /* color number */
159 unsigned char r
, /* red */
160 unsigned char g
, /* green */
161 unsigned char b
/* blue */
166 #endif /* CONFIG_VIDEO_S3C2410 */