lcd.h 5.5 KB

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