lcd.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. * SPDX-License-Identifier: GPL-2.0+
  11. */
  12. #ifndef _LCD_H_
  13. #define _LCD_H_
  14. #include <lcd_console.h>
  15. #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
  16. #include <bmp_layout.h>
  17. #include <asm/byteorder.h>
  18. #endif
  19. int bmp_display(ulong addr, int x, int y);
  20. struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
  21. void **alloc_addr);
  22. #ifndef CONFIG_DM_VIDEO
  23. extern char lcd_is_enabled;
  24. extern int lcd_line_length;
  25. extern struct vidinfo panel_info;
  26. void lcd_ctrl_init(void *lcdbase);
  27. void lcd_enable(void);
  28. void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
  29. /**
  30. * Set whether we need to flush the dcache when changing the LCD image. This
  31. * defaults to off.
  32. *
  33. * @param flush non-zero to flush cache after update, 0 to skip
  34. */
  35. void lcd_set_flush_dcache(int flush);
  36. #if defined CONFIG_MPC823
  37. #include <mpc823_lcd.h>
  38. #elif defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
  39. defined CONFIG_CPU_MONAHANS
  40. #include <pxa_lcd.h>
  41. #elif defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
  42. #include <atmel_lcd.h>
  43. #elif defined(CONFIG_EXYNOS_FB)
  44. #include <exynos_lcd.h>
  45. #else
  46. typedef struct vidinfo {
  47. ushort vl_col; /* Number of columns (i.e. 160) */
  48. ushort vl_row; /* Number of rows (i.e. 100) */
  49. ushort vl_rot; /* Rotation of Display (0, 1, 2, 3) */
  50. u_char vl_bpix; /* Bits per pixel, 0 = 1 */
  51. ushort *cmap; /* Pointer to the colormap */
  52. void *priv; /* Pointer to driver-specific data */
  53. } vidinfo_t;
  54. static __maybe_unused ushort *configuration_get_cmap(void)
  55. {
  56. return panel_info.cmap;
  57. }
  58. #endif
  59. ushort *configuration_get_cmap(void);
  60. extern vidinfo_t panel_info;
  61. void lcd_putc(const char c);
  62. void lcd_puts(const char *s);
  63. void lcd_printf(const char *fmt, ...);
  64. void lcd_clear(void);
  65. int lcd_display_bitmap(ulong bmp_image, int x, int y);
  66. /**
  67. * Get the width of the LCD in pixels
  68. *
  69. * @return width of LCD in pixels
  70. */
  71. int lcd_get_pixel_width(void);
  72. /**
  73. * Get the height of the LCD in pixels
  74. *
  75. * @return height of LCD in pixels
  76. */
  77. int lcd_get_pixel_height(void);
  78. /**
  79. * Get the number of text lines/rows on the LCD
  80. *
  81. * @return number of rows
  82. */
  83. int lcd_get_screen_rows(void);
  84. /**
  85. * Get the number of text columns on the LCD
  86. *
  87. * @return number of columns
  88. */
  89. int lcd_get_screen_columns(void);
  90. /**
  91. * Get the background color of the LCD
  92. *
  93. * @return background color value
  94. */
  95. int lcd_getbgcolor(void);
  96. /**
  97. * Get the foreground color of the LCD
  98. *
  99. * @return foreground color value
  100. */
  101. int lcd_getfgcolor(void);
  102. /**
  103. * Set the position of the text cursor
  104. *
  105. * @param col Column to place cursor (0 = left side)
  106. * @param row Row to place cursor (0 = top line)
  107. */
  108. void lcd_position_cursor(unsigned col, unsigned row);
  109. /* Allow boards to customize the information displayed */
  110. void lcd_show_board_info(void);
  111. /* Return the size of the LCD frame buffer, and the line length */
  112. int lcd_get_size(int *line_length);
  113. /* Update the LCD / flush the cache */
  114. void lcd_sync(void);
  115. /*
  116. * Information about displays we are using. This is for configuring
  117. * the LCD controller and memory allocation. Someone has to know what
  118. * is connected, as we can't autodetect anything.
  119. */
  120. #define CONFIG_SYS_HIGH 0 /* Pins are active high */
  121. #define CONFIG_SYS_LOW 1 /* Pins are active low */
  122. #define LCD_MONOCHROME 0
  123. #define LCD_COLOR2 1
  124. #define LCD_COLOR4 2
  125. #define LCD_COLOR8 3
  126. #define LCD_COLOR16 4
  127. #define LCD_COLOR32 5
  128. #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
  129. #define LCD_INFO_X 0
  130. #define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
  131. #elif defined(CONFIG_LCD_LOGO)
  132. #define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
  133. #define LCD_INFO_Y VIDEO_FONT_HEIGHT
  134. #else
  135. #define LCD_INFO_X VIDEO_FONT_WIDTH
  136. #define LCD_INFO_Y VIDEO_FONT_HEIGHT
  137. #endif
  138. /* Default to 8bpp if bit depth not specified */
  139. #ifndef LCD_BPP
  140. #define LCD_BPP LCD_COLOR8
  141. #endif
  142. #ifndef LCD_DF
  143. #define LCD_DF 1
  144. #endif
  145. /* Calculate nr. of bits per pixel and nr. of colors */
  146. #define NBITS(bit_code) (1 << (bit_code))
  147. #define NCOLORS(bit_code) (1 << NBITS(bit_code))
  148. #if LCD_BPP == LCD_COLOR8
  149. # define CONSOLE_COLOR_BLACK 0
  150. # define CONSOLE_COLOR_RED 1
  151. # define CONSOLE_COLOR_GREEN 2
  152. # define CONSOLE_COLOR_YELLOW 3
  153. # define CONSOLE_COLOR_BLUE 4
  154. # define CONSOLE_COLOR_MAGENTA 5
  155. # define CONSOLE_COLOR_CYAN 6
  156. # define CONSOLE_COLOR_GREY 14
  157. # define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
  158. #elif LCD_BPP == LCD_COLOR32
  159. #define CONSOLE_COLOR_RED 0x00ff0000
  160. #define CONSOLE_COLOR_GREEN 0x0000ff00
  161. #define CONSOLE_COLOR_YELLOW 0x00ffff00
  162. #define CONSOLE_COLOR_BLUE 0x000000ff
  163. #define CONSOLE_COLOR_MAGENTA 0x00ff00ff
  164. #define CONSOLE_COLOR_CYAN 0x0000ffff
  165. #define CONSOLE_COLOR_GREY 0x00aaaaaa
  166. #define CONSOLE_COLOR_BLACK 0x00000000
  167. #define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest */
  168. #define NBYTES(bit_code) (NBITS(bit_code) >> 3)
  169. #else /* 16bpp color definitions */
  170. # define CONSOLE_COLOR_BLACK 0x0000
  171. # define CONSOLE_COLOR_RED 0xF800
  172. # define CONSOLE_COLOR_GREEN 0x07E0
  173. # define CONSOLE_COLOR_YELLOW 0xFFE0
  174. # define CONSOLE_COLOR_BLUE 0x001F
  175. # define CONSOLE_COLOR_MAGENTA 0xF81F
  176. # define CONSOLE_COLOR_CYAN 0x07FF
  177. # define CONSOLE_COLOR_GREY 0xC618
  178. # define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
  179. #endif /* color definitions */
  180. #if LCD_BPP == LCD_COLOR16
  181. #define fbptr_t ushort
  182. #elif LCD_BPP == LCD_COLOR32
  183. #define fbptr_t u32
  184. #else
  185. #define fbptr_t uchar
  186. #endif
  187. #ifndef PAGE_SIZE
  188. #define PAGE_SIZE 4096
  189. #endif
  190. #endif /* !CONFIG_DM_VIDEO */
  191. #endif /* _LCD_H_ */