最近在开发板上飞了一块新的lcd,不晓得是不是因为飞线太复杂的缘故,通过kernel的时候屏幕就是不亮,通过spec配置基本都一样。然后就想通过最原始的方式来验证lcd,就是在uboot里初始化lcd,smdkc110里默认的是没有初始化lcd的,而且编译的话好像还有错,所以就自己写了一个lcd.c。用到以下两个文件就可以了
核心源码是/common/lcd.c /cpu/s5pc11x /fimd.c
下面是lcd.c的代码
- #include <config.h>
- #include <common.h>
- #include <command.h>
- #include <version.h>
- #include <stdarg.h>
- #include <linux/types.h>
- #include <devices.h>
- #if defined(CONFIG_POST)
- #include <post.h>
- #endif
- #include <lcd.h>
- #include <watchdog.h>
- #ifdef CONFIG_LCD
- /************************************************************************/
- /* ** FONT DATA */
- /************************************************************************/
- //#include <fonts.h> /* Get font data, width and height*/
- #define LCD_WIDTH 1024
- #define LCD_HEIGHT 600
- #define LCD_BGCOLOR 0xffffff
- #define LCD_SETCURSOR(Xpos,Ypos) (CFG_LCD_FBUFFER + Xpos*LCD_WIDTH*4 + Ypos*4)
- static unsigned int TextColor = 0x0000;
- static unsigned int BackColor = LCD_BGCOLOR;
- void LCD_Initialize_NONAME1(void); //fimd.c中的LCD初始化函数
- typedef struct vidinfo
- {
- ushort vl_col; /* Number of columns (i.e. 640) */
- ushort vl_row; /* Number of rows (i.e. 480) */
- ushort vl_width; /* Width of display area in millimeters */
- ushort vl_height; /* Height of display area in millimeters */ /* LCD configuration register */
- u_char vl_clkp; /* Clock polarity */
- u_char vl_oep; /* Output Enable polarity */
- u_char vl_hsp; /* Horizontal Sync polarity */
- u_char vl_vsp; /* Vertical Sync polarity */
- u_char vl_dp; /* Data polarity */
- u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */
- u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */
- u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */
- u_char vl_clor; /* Color, 0 = mono, 1 = color */
- u_char vl_tft; /* 0 = passive, 1 = TFT */ /* Horizontal control register. Timing from data sheet */
- ushort vl_hpw; /* Horz sync pulse width */
- u_char vl_blw; /* Wait before of line */
- u_char vl_elw; /* Wait end of line */ /* Vertical control register. */
- u_char vl_vpw; /* Vertical sync pulse width */
- u_char vl_bfw; /* Wait before of frame */
- u_char vl_efw; /* Wait end of frame */ /* PXA LCD controller params */
- //struct pxafb_info pxa;
- } vidinfo_t;
- vidinfo_t panel_info = {1024,600,1024,600,1,1,1,1,1,24,0,0,0,1,40,56,56,20,8,8};
- /*
- * Frame buffer memory information
- */
- //void *lcd_base; /* Start of framebuffer memory*/
- static int lcd_init ();
- void lcd_Enable (void);
- /************************************************************************/
- /* ** GENERIC Initialization Routines */
- /************************************************************************/
- int drv_lcd_init (void)
- {
- device_t lcddev;
- int rc;
- // lcd_base = (void*)CFG_LCD_FBUFFER;
- lcd_init (); /* LCD initialization */
- #ifdef CONFIG_NO_VIDEO_CONSOLE
- return 0;
- #endif
- // Device initialization
- memset (&lcddev, 0, sizeof (lcddev));
- strcpy (lcddev.name, "lcd");
- lcddev.ext = 0;
- lcddev.flags = DEV_FLAGS_OUTPUT;
- ///cddev.putc = lcd_putc;
- //lcddev.puts = lcd_puts;
- rc = device_register (&lcddev); //重定向输出信息
- return (rc == 0) ? 1 : rc;
- }
- /*----------------------------------------------------------------------*/
- static int lcd_init ()
- {
- /* Initialize the lcd controller */
- printf("LCD Initializing......");
- //LCD_Initialize_NONAME1();
- LCD_Init(1);//上面的其实也可以初始化lcd
- printf("complete\n");
- LCD_clear(); //刷蓝色背景色
- //LCD_DisplayChar(0,0,'E'); //在(0,0)处写字母”E”
- return 0;
- }
- #if 0
- void LCD_DrawChar(u16 Xpos, u16 Ypos, char *c)
- {
- u32 index = 0, i = 0;
- u16 Xaddress = 0;
- Xaddress = Xpos;
- u32* pBuffer = (u32*)LCD_SETCURSOR(Xaddress, Ypos);
- for(index = 0; index < 24; index++)
- {
- for(i = 0; i < 16; i++)
- {
- if((c[index] & (1 << i)) == 0x00)
- {
- *pBuffer++ = BackColor;
- }
- else
- {
- *pBuffer++ = TextColor;
- }
- }
- Xaddress++;
- pBuffer = (u32*)LCD_SETCURSOR(Xaddress, Ypos);
- }
- }
- void LCD_DisplayChar(u16 Line, u16 Column, u8 Ascii)
- {
- Ascii -= 32;
- LCD_DrawChar(Line, Column, &ASCII_Table[Ascii * 24]);
- }
- #endif
- void LCD_clear()
- {
- u16 i, j;
- u32* pBuffer = (u32*)CFG_LCD_FBUFFER;
- for (i=0; i < LCD_HEIGHT; i++)
- {
- for (j=0; j < LCD_WIDTH; j++)
- {
- *pBuffer++ = BackColor;
- }
- }
- }
- ulong calc_fbsize (void)
- {
- ulong size;
-
- int line_length = (panel_info.vl_col * panel_info.vl_bpix) / 8;
- size = line_length * panel_info.vl_row;
- #ifdef CFG_LCD_FBUFFER
- size = 2457600;
- #endif
- return size;
- }
- /************************************************************************/
- /* ** ROM capable initialization part - needed to reserve FB memory*/
- /************************************************************************/
- /*
- * This is called early in the system initialization to grab memory
- * for the LCD controller.
- * Returns new address for monitor, after reserving LCD buffer memory
- *
- * Note that this is running from ROM, so no write access to global data.
- */
- ulong lcd_setmem (ulong addr)
- {
- ulong size;
- int line_length = (panel_info.vl_col * panel_info.vl_bpix) / 8;
- debug ("LCD panel info: %d x %d, %d bit/pix\n",
- panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
- size = line_length * panel_info.vl_row;
- #ifdef CFG_LCD_FBUFFER
- size = 2457600; //1024*600*4 bytes
- #endif
- /* Round up to nearest full page */
- size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
- /* Allocate pages for the frame buffer. */
- addr -= size;
- debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr);
- return (addr);
- }
- int do_clearlcd(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
- {
- printf("huabinbin test do_clearlcd");
- drv_lcd_init();
- }
- #endif /* CONFIG_LCD */
如果有需要的话你还可以再LCD_Init(1)这个函数去修改一些极性配置,我的平台
Outp32(0xf8000004, 0x016EC080); 这里可以修改那四个参数的极性配置。
只是很遗憾,屏幕显示的效果还是和kernel一样,但我想应该不影响这篇文章的正确性,等打好板子再来确认一下,这也是怕自己到时忘了,所以先记录下来!
阅读(2503) | 评论(1) | 转发(2) |