video.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * Video uclass and legacy implementation
  3. *
  4. * Copyright (c) 2015 Google, Inc
  5. *
  6. * MPC823 Video Controller
  7. * =======================
  8. * (C) 2000 by Paolo Scaffardi (arsenio@tin.it)
  9. * AIRVENT SAM s.p.a - RIMINI(ITALY)
  10. *
  11. */
  12. #ifndef _VIDEO_H_
  13. #define _VIDEO_H_
  14. #ifdef CONFIG_DM_VIDEO
  15. #include <stdio_dev.h>
  16. struct video_uc_platdata {
  17. uint align;
  18. uint size;
  19. ulong base;
  20. };
  21. enum video_polarity {
  22. VIDEO_ACTIVE_HIGH, /* Pins are active high */
  23. VIDEO_ACTIVE_LOW, /* Pins are active low */
  24. };
  25. /*
  26. * Bits per pixel selector. Each value n is such that the bits-per-pixel is
  27. * 2 ^ n
  28. */
  29. enum video_log2_bpp {
  30. VIDEO_BPP1 = 0,
  31. VIDEO_BPP2,
  32. VIDEO_BPP4,
  33. VIDEO_BPP8,
  34. VIDEO_BPP16,
  35. VIDEO_BPP32,
  36. };
  37. /*
  38. * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer
  39. * brackets to allow multiplication by fractional pixels.
  40. */
  41. #define VNBYTES(bpix) (1 << (bpix)) / 8
  42. #define VNBITS(bpix) (1 << (bpix))
  43. /**
  44. * struct video_priv - Device information used by the video uclass
  45. *
  46. * @xsize: Number of pixel columns (e.g. 1366)
  47. * @ysize: Number of pixels rows (e.g.. 768)
  48. * @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.)
  49. * @bpix: Encoded bits per pixel
  50. * @vidconsole_drv_name: Driver to use for the text console, NULL to
  51. * select automatically
  52. * @font_size: Font size in pixels (0 to use a default value)
  53. * @fb: Frame buffer
  54. * @fb_size: Frame buffer size
  55. * @line_length: Length of each frame buffer line, in bytes
  56. * @colour_fg: Foreground colour (pixel value)
  57. * @colour_bg: Background colour (pixel value)
  58. * @flush_dcache: true to enable flushing of the data cache after
  59. * the LCD is updated
  60. * @cmap: Colour map for 8-bit-per-pixel displays
  61. * @fg_col_idx: Foreground color code (bit 3 = bold, bit 0-2 = color)
  62. */
  63. struct video_priv {
  64. /* Things set up by the driver: */
  65. ushort xsize;
  66. ushort ysize;
  67. ushort rot;
  68. enum video_log2_bpp bpix;
  69. const char *vidconsole_drv_name;
  70. int font_size;
  71. /*
  72. * Things that are private to the uclass: don't use these in the
  73. * driver
  74. */
  75. void *fb;
  76. int fb_size;
  77. int line_length;
  78. u32 colour_fg;
  79. u32 colour_bg;
  80. bool flush_dcache;
  81. ushort *cmap;
  82. u8 fg_col_idx;
  83. };
  84. /* Placeholder - there are no video operations at present */
  85. struct video_ops {
  86. };
  87. #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops)
  88. /**
  89. * video_reserve() - Reserve frame-buffer memory for video devices
  90. *
  91. * Note: This function is for internal use.
  92. *
  93. * This uses the uclass platdata's @size and @align members to figure out
  94. * a size and position for each frame buffer as part of the pre-relocation
  95. * process of determining the post-relocation memory layout.
  96. *
  97. * gd->video_top is set to the initial value of *@addrp and gd->video_bottom
  98. * is set to the final value.
  99. *
  100. * @addrp: On entry, the top of available memory. On exit, the new top,
  101. * after allocating the required memory.
  102. * @return 0
  103. */
  104. int video_reserve(ulong *addrp);
  105. /**
  106. * video_clear() - Clear a device's frame buffer to background color.
  107. *
  108. * @dev: Device to clear
  109. */
  110. void video_clear(struct udevice *dev);
  111. /**
  112. * video_sync() - Sync a device's frame buffer with its hardware
  113. *
  114. * Some frame buffers are cached or have a secondary frame buffer. This
  115. * function syncs these up so that the current contents of the U-Boot frame
  116. * buffer are displayed to the user.
  117. *
  118. * @dev: Device to sync
  119. */
  120. void video_sync(struct udevice *vid);
  121. /**
  122. * video_sync_all() - Sync all devices' frame buffers with there hardware
  123. *
  124. * This calls video_sync() on all active video devices.
  125. */
  126. void video_sync_all(void);
  127. /**
  128. * video_bmp_display() - Display a BMP file
  129. *
  130. * @dev: Device to display the bitmap on
  131. * @bmp_image: Address of bitmap image to display
  132. * @x: X position in pixels from the left
  133. * @y: Y position in pixels from the top
  134. * @align: true to adjust the coordinates to centre the image. If false
  135. * the coordinates are used as is. If true:
  136. *
  137. * - if a coordinate is 0x7fff then the image will be centred in
  138. * that direction
  139. * - if a coordinate is -ve then it will be offset to the
  140. * left/top of the centre by that many pixels
  141. * - if a coordinate is positive it will be used unchnaged.
  142. * @return 0 if OK, -ve on error
  143. */
  144. int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
  145. bool align);
  146. /**
  147. * video_get_xsize() - Get the width of the display in pixels
  148. *
  149. * @dev: Device to check
  150. * @return device frame buffer width in pixels
  151. */
  152. int video_get_xsize(struct udevice *dev);
  153. /**
  154. * video_get_ysize() - Get the height of the display in pixels
  155. *
  156. * @dev: Device to check
  157. * @return device frame buffer height in pixels
  158. */
  159. int video_get_ysize(struct udevice *dev);
  160. /**
  161. * Set whether we need to flush the dcache when changing the image. This
  162. * defaults to off.
  163. *
  164. * @param flush non-zero to flush cache after update, 0 to skip
  165. */
  166. void video_set_flush_dcache(struct udevice *dev, bool flush);
  167. /**
  168. * Set default colors and attributes
  169. *
  170. * @priv device information
  171. */
  172. void video_set_default_colors(struct video_priv *priv);
  173. #endif /* CONFIG_DM_VIDEO */
  174. #ifndef CONFIG_DM_VIDEO
  175. /* Video functions */
  176. struct stdio_dev;
  177. int video_init(void *videobase);
  178. void video_putc(struct stdio_dev *dev, const char c);
  179. void video_puts(struct stdio_dev *dev, const char *s);
  180. /**
  181. * Display a BMP format bitmap on the screen
  182. *
  183. * @param bmp_image Address of BMP image
  184. * @param x X position to draw image
  185. * @param y Y position to draw image
  186. */
  187. int video_display_bitmap(ulong bmp_image, int x, int y);
  188. /**
  189. * Get the width of the screen in pixels
  190. *
  191. * @return width of screen in pixels
  192. */
  193. int video_get_pixel_width(void);
  194. /**
  195. * Get the height of the screen in pixels
  196. *
  197. * @return height of screen in pixels
  198. */
  199. int video_get_pixel_height(void);
  200. /**
  201. * Get the number of text lines/rows on the screen
  202. *
  203. * @return number of rows
  204. */
  205. int video_get_screen_rows(void);
  206. /**
  207. * Get the number of text columns on the screen
  208. *
  209. * @return number of columns
  210. */
  211. int video_get_screen_columns(void);
  212. /**
  213. * Set the position of the text cursor
  214. *
  215. * @param col Column to place cursor (0 = left side)
  216. * @param row Row to place cursor (0 = top line)
  217. */
  218. void video_position_cursor(unsigned col, unsigned row);
  219. /* Clear the display */
  220. void video_clear(void);
  221. #if defined(CONFIG_FORMIKE)
  222. int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs,
  223. unsigned int max_hz, unsigned int spi_mode);
  224. #endif
  225. #if defined(CONFIG_LG4573)
  226. int lg4573_spi_startup(unsigned int bus, unsigned int cs,
  227. unsigned int max_hz, unsigned int spi_mode);
  228. #endif
  229. /*
  230. * video_get_info_str() - obtain a board string: type, speed, etc.
  231. *
  232. * This is called if CONFIG_CONSOLE_EXTRA_INFO is enabled.
  233. *
  234. * line_number: location to place info string beside logo
  235. * info: buffer for info string (empty if nothing to display on this
  236. * line)
  237. */
  238. void video_get_info_str(int line_number, char *info);
  239. #endif /* CONFIG_DM_VIDEO */
  240. #endif