lcd.h 5.5 KB

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