lcd.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. extern char lcd_is_enabled;
  20. extern int lcd_line_length;
  21. extern struct vidinfo panel_info;
  22. void lcd_ctrl_init(void *lcdbase);
  23. void lcd_enable(void);
  24. void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
  25. struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
  26. void **alloc_addr);
  27. int bmp_display(ulong addr, int x, int y);
  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_MPC823
  36. #include <mpc823_lcd.h>
  37. #elif defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
  38. defined CONFIG_CPU_MONAHANS
  39. #include <pxa_lcd.h>
  40. #elif defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
  41. #include <atmel_lcd.h>
  42. #elif defined(CONFIG_EXYNOS_FB)
  43. #include <exynos_lcd.h>
  44. #else
  45. typedef struct vidinfo {
  46. ushort vl_col; /* Number of columns (i.e. 160) */
  47. ushort vl_row; /* Number of rows (i.e. 100) */
  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. int lcd_dt_simplefb_add_node(void *blob);
  112. int lcd_dt_simplefb_enable_existing_node(void *blob);
  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_WHITE 0xffff /* Must remain last / highest */
  172. #endif /* color definitions */
  173. #ifndef PAGE_SIZE
  174. #define PAGE_SIZE 4096
  175. #endif
  176. #endif /* _LCD_H_ */