lcd.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * MPC823 and PXA LCD Controller
  3. *
  4. * Modeled after video interface by Paolo Scaffardi
  5. *
  6. *
  7. * (C) Copyright 2001
  8. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #ifndef _LCD_H_
  29. #define _LCD_H_
  30. extern char lcd_is_enabled;
  31. extern int lcd_line_length;
  32. extern int lcd_color_fg;
  33. extern int lcd_color_bg;
  34. /*
  35. * Frame buffer memory information
  36. */
  37. extern void *lcd_base; /* Start of framebuffer memory */
  38. extern void *lcd_console_address; /* Start of console buffer */
  39. extern short console_col;
  40. extern short console_row;
  41. #if defined CONFIG_MPC823
  42. /*
  43. * LCD controller stucture for MPC823 CPU
  44. */
  45. typedef struct vidinfo {
  46. ushort vl_col; /* Number of columns (i.e. 640) */
  47. ushort vl_row; /* Number of rows (i.e. 480) */
  48. ushort vl_width; /* Width of display area in millimeters */
  49. ushort vl_height; /* Height of display area in millimeters */
  50. /* LCD configuration register */
  51. u_char vl_clkp; /* Clock polarity */
  52. u_char vl_oep; /* Output Enable polarity */
  53. u_char vl_hsp; /* Horizontal Sync polarity */
  54. u_char vl_vsp; /* Vertical Sync polarity */
  55. u_char vl_dp; /* Data polarity */
  56. u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
  57. u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */
  58. u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */
  59. u_char vl_clor; /* Color, 0 = mono, 1 = color */
  60. u_char vl_tft; /* 0 = passive, 1 = TFT */
  61. /* Horizontal control register. Timing from data sheet */
  62. ushort vl_wbl; /* Wait between lines */
  63. /* Vertical control register */
  64. u_char vl_vpw; /* Vertical sync pulse width */
  65. u_char vl_lcdac; /* LCD AC timing */
  66. u_char vl_wbf; /* Wait between frames */
  67. } vidinfo_t;
  68. extern vidinfo_t panel_info;
  69. #elif defined CONFIG_PXA250
  70. /*
  71. * PXA LCD DMA descriptor
  72. */
  73. struct pxafb_dma_descriptor {
  74. u_long fdadr; /* Frame descriptor address register */
  75. u_long fsadr; /* Frame source address register */
  76. u_long fidr; /* Frame ID register */
  77. u_long ldcmd; /* Command register */
  78. };
  79. /*
  80. * PXA LCD info
  81. */
  82. struct pxafb_info {
  83. /* Misc registers */
  84. u_long reg_lccr3;
  85. u_long reg_lccr2;
  86. u_long reg_lccr1;
  87. u_long reg_lccr0;
  88. u_long fdadr0;
  89. u_long fdadr1;
  90. /* DMA descriptors */
  91. struct pxafb_dma_descriptor * dmadesc_fblow;
  92. struct pxafb_dma_descriptor * dmadesc_fbhigh;
  93. struct pxafb_dma_descriptor * dmadesc_palette;
  94. u_long screen; /* physical address of frame buffer */
  95. u_long palette; /* physical address of palette memory */
  96. u_int palette_size;
  97. };
  98. /*
  99. * LCD controller stucture for PXA CPU
  100. */
  101. typedef struct vidinfo {
  102. ushort vl_col; /* Number of columns (i.e. 640) */
  103. ushort vl_row; /* Number of rows (i.e. 480) */
  104. ushort vl_width; /* Width of display area in millimeters */
  105. ushort vl_height; /* Height of display area in millimeters */
  106. /* LCD configuration register */
  107. u_char vl_clkp; /* Clock polarity */
  108. u_char vl_oep; /* Output Enable polarity */
  109. u_char vl_hsp; /* Horizontal Sync polarity */
  110. u_char vl_vsp; /* Vertical Sync polarity */
  111. u_char vl_dp; /* Data polarity */
  112. u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */
  113. u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */
  114. u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */
  115. u_char vl_clor; /* Color, 0 = mono, 1 = color */
  116. u_char vl_tft; /* 0 = passive, 1 = TFT */
  117. /* Horizontal control register. Timing from data sheet */
  118. ushort vl_hpw; /* Horz sync pulse width */
  119. u_char vl_blw; /* Wait before of line */
  120. u_char vl_elw; /* Wait end of line */
  121. /* Vertical control register. */
  122. u_char vl_vpw; /* Vertical sync pulse width */
  123. u_char vl_bfw; /* Wait before of frame */
  124. u_char vl_efw; /* Wait end of frame */
  125. /* PXA LCD controller params */
  126. struct pxafb_info pxa;
  127. } vidinfo_t;
  128. extern vidinfo_t panel_info;
  129. #elif defined(CONFIG_MCC200)
  130. typedef struct vidinfo {
  131. ushort vl_col; /* Number of columns (i.e. 160) */
  132. ushort vl_row; /* Number of rows (i.e. 100) */
  133. u_char vl_bpix; /* Bits per pixel, 0 = 1 */
  134. } vidinfo_t;
  135. #elif defined(CONFIG_ATMEL_LCD)
  136. typedef struct vidinfo {
  137. u_long vl_col; /* Number of columns (i.e. 640) */
  138. u_long vl_row; /* Number of rows (i.e. 480) */
  139. u_long vl_clk; /* pixel clock in ps */
  140. /* LCD configuration register */
  141. u_long vl_sync; /* Horizontal / vertical sync */
  142. u_long vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */
  143. u_long vl_tft; /* 0 = passive, 1 = TFT */
  144. /* Horizontal control register. */
  145. u_long vl_hsync_len; /* Length of horizontal sync */
  146. u_long vl_left_margin; /* Time from sync to picture */
  147. u_long vl_right_margin; /* Time from picture to sync */
  148. /* Vertical control register. */
  149. u_long vl_vsync_len; /* Length of vertical sync */
  150. u_long vl_upper_margin; /* Time from sync to picture */
  151. u_long vl_lower_margin; /* Time from picture to sync */
  152. u_long mmio; /* Memory mapped registers */
  153. } vidinfo_t;
  154. extern vidinfo_t panel_info;
  155. #endif /* CONFIG_MPC823, CONFIG_PXA250 or CONFIG_MCC200 or CONFIG_ATMEL_LCD */
  156. /* Video functions */
  157. #if defined(CONFIG_RBC823)
  158. void lcd_disable (void);
  159. #endif
  160. /* int lcd_init (void *lcdbase); */
  161. void lcd_putc (const char c);
  162. void lcd_puts (const char *s);
  163. void lcd_printf (const char *fmt, ...);
  164. /************************************************************************/
  165. /* ** BITMAP DISPLAY SUPPORT */
  166. /************************************************************************/
  167. #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
  168. # include <bmp_layout.h>
  169. # include <asm/byteorder.h>
  170. #endif
  171. /*
  172. * Information about displays we are using. This is for configuring
  173. * the LCD controller and memory allocation. Someone has to know what
  174. * is connected, as we can't autodetect anything.
  175. */
  176. #define CFG_HIGH 0 /* Pins are active high */
  177. #define CFG_LOW 1 /* Pins are active low */
  178. #define LCD_MONOCHROME 0
  179. #define LCD_COLOR2 1
  180. #define LCD_COLOR4 2
  181. #define LCD_COLOR8 3
  182. #define LCD_COLOR16 4
  183. /*----------------------------------------------------------------------*/
  184. #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
  185. # define LCD_INFO_X 0
  186. # define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
  187. #elif defined(CONFIG_LCD_LOGO)
  188. # define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
  189. # define LCD_INFO_Y (VIDEO_FONT_HEIGHT)
  190. #else
  191. # define LCD_INFO_X (VIDEO_FONT_WIDTH)
  192. # define LCD_INFO_Y (VIDEO_FONT_HEIGHT)
  193. #endif
  194. /* Default to 8bpp if bit depth not specified */
  195. #ifndef LCD_BPP
  196. # define LCD_BPP LCD_COLOR8
  197. #endif
  198. #ifndef LCD_DF
  199. # define LCD_DF 1
  200. #endif
  201. /* Calculate nr. of bits per pixel and nr. of colors */
  202. #define NBITS(bit_code) (1 << (bit_code))
  203. #define NCOLORS(bit_code) (1 << NBITS(bit_code))
  204. /************************************************************************/
  205. /* ** CONSOLE CONSTANTS */
  206. /************************************************************************/
  207. #if LCD_BPP == LCD_MONOCHROME
  208. /*
  209. * Simple black/white definitions
  210. */
  211. # define CONSOLE_COLOR_BLACK 0
  212. # define CONSOLE_COLOR_WHITE 1 /* Must remain last / highest */
  213. #elif LCD_BPP == LCD_COLOR8
  214. /*
  215. * 8bpp color definitions
  216. */
  217. # define CONSOLE_COLOR_BLACK 0
  218. # define CONSOLE_COLOR_RED 1
  219. # define CONSOLE_COLOR_GREEN 2
  220. # define CONSOLE_COLOR_YELLOW 3
  221. # define CONSOLE_COLOR_BLUE 4
  222. # define CONSOLE_COLOR_MAGENTA 5
  223. # define CONSOLE_COLOR_CYAN 6
  224. # define CONSOLE_COLOR_GREY 14
  225. # define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
  226. #else
  227. /*
  228. * 16bpp color definitions
  229. */
  230. # define CONSOLE_COLOR_BLACK 0x0000
  231. # define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
  232. #endif /* color definitions */
  233. /************************************************************************/
  234. #ifndef PAGE_SIZE
  235. # define PAGE_SIZE 4096
  236. #endif
  237. /************************************************************************/
  238. /* ** CONSOLE DEFINITIONS & FUNCTIONS */
  239. /************************************************************************/
  240. #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
  241. # define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \
  242. / VIDEO_FONT_HEIGHT)
  243. #else
  244. # define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT)
  245. #endif
  246. #define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH)
  247. #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length)
  248. #define CONSOLE_ROW_FIRST (lcd_console_address)
  249. #define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE)
  250. #define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \
  251. - CONSOLE_ROW_SIZE)
  252. #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
  253. #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
  254. #if LCD_BPP == LCD_MONOCHROME
  255. # define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \
  256. (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
  257. #elif LCD_BPP == LCD_COLOR8
  258. # define COLOR_MASK(c) (c)
  259. #else
  260. # error Unsupported LCD BPP.
  261. #endif
  262. /************************************************************************/
  263. #endif /* _LCD_H_ */