video.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. */
  62. struct video_priv {
  63. /* Things set up by the driver: */
  64. ushort xsize;
  65. ushort ysize;
  66. ushort rot;
  67. enum video_log2_bpp bpix;
  68. const char *vidconsole_drv_name;
  69. int font_size;
  70. /*
  71. * Things that are private to the uclass: don't use these in the
  72. * driver
  73. */
  74. void *fb;
  75. int fb_size;
  76. int line_length;
  77. int colour_fg;
  78. int colour_bg;
  79. bool flush_dcache;
  80. ushort *cmap;
  81. };
  82. /* Placeholder - there are no video operations at present */
  83. struct video_ops {
  84. };
  85. #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops)
  86. /**
  87. * video_reserve() - Reserve frame-buffer memory for video devices
  88. *
  89. * Note: This function is for internal use.
  90. *
  91. * This uses the uclass platdata's @size and @align members to figure out
  92. * a size and position for each frame buffer as part of the pre-relocation
  93. * process of determining the post-relocation memory layout.
  94. *
  95. * gd->video_top is set to the initial value of *@addrp and gd->video_bottom
  96. * is set to the final value.
  97. *
  98. * @addrp: On entry, the top of available memory. On exit, the new top,
  99. * after allocating the required memory.
  100. * @return 0
  101. */
  102. int video_reserve(ulong *addrp);
  103. /**
  104. * video_sync() - Sync a device's frame buffer with its hardware
  105. *
  106. * Some frame buffers are cached or have a secondary frame buffer. This
  107. * function syncs these up so that the current contents of the U-Boot frame
  108. * buffer are displayed to the user.
  109. *
  110. * @dev: Device to sync
  111. */
  112. void video_sync(struct udevice *vid);
  113. /**
  114. * video_sync_all() - Sync all devices' frame buffers with there hardware
  115. *
  116. * This calls video_sync() on all active video devices.
  117. */
  118. void video_sync_all(void);
  119. /**
  120. * video_bmp_display() - Display a BMP file
  121. *
  122. * @dev: Device to display the bitmap on
  123. * @bmp_image: Address of bitmap image to display
  124. * @x: X position in pixels from the left
  125. * @y: Y position in pixels from the top
  126. * @align: true to adjust the coordinates to centre the image. If false
  127. * the coordinates are used as is. If true:
  128. *
  129. * - if a coordinate is 0x7fff then the image will be centred in
  130. * that direction
  131. * - if a coordinate is -ve then it will be offset to the
  132. * left/top of the centre by that many pixels
  133. * - if a coordinate is positive it will be used unchnaged.
  134. * @return 0 if OK, -ve on error
  135. */
  136. int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
  137. bool align);
  138. /**
  139. * video_get_xsize() - Get the width of the display in pixels
  140. *
  141. * @dev: Device to check
  142. * @return device frame buffer width in pixels
  143. */
  144. int video_get_xsize(struct udevice *dev);
  145. /**
  146. * video_get_ysize() - Get the height of the display in pixels
  147. *
  148. * @dev: Device to check
  149. * @return device frame buffer height in pixels
  150. */
  151. int video_get_ysize(struct udevice *dev);
  152. /**
  153. * Set whether we need to flush the dcache when changing the image. This
  154. * defaults to off.
  155. *
  156. * @param flush non-zero to flush cache after update, 0 to skip
  157. */
  158. void video_set_flush_dcache(struct udevice *dev, bool flush);
  159. #endif /* CONFIG_DM_VIDEO */
  160. #ifndef CONFIG_DM_VIDEO
  161. /* Video functions */
  162. struct stdio_dev;
  163. int video_init(void *videobase);
  164. void video_putc(struct stdio_dev *dev, const char c);
  165. void video_puts(struct stdio_dev *dev, const char *s);
  166. /**
  167. * Display a BMP format bitmap on the screen
  168. *
  169. * @param bmp_image Address of BMP image
  170. * @param x X position to draw image
  171. * @param y Y position to draw image
  172. */
  173. int video_display_bitmap(ulong bmp_image, int x, int y);
  174. /**
  175. * Get the width of the screen in pixels
  176. *
  177. * @return width of screen in pixels
  178. */
  179. int video_get_pixel_width(void);
  180. /**
  181. * Get the height of the screen in pixels
  182. *
  183. * @return height of screen in pixels
  184. */
  185. int video_get_pixel_height(void);
  186. /**
  187. * Get the number of text lines/rows on the screen
  188. *
  189. * @return number of rows
  190. */
  191. int video_get_screen_rows(void);
  192. /**
  193. * Get the number of text columns on the screen
  194. *
  195. * @return number of columns
  196. */
  197. int video_get_screen_columns(void);
  198. /**
  199. * Set the position of the text cursor
  200. *
  201. * @param col Column to place cursor (0 = left side)
  202. * @param row Row to place cursor (0 = top line)
  203. */
  204. void video_position_cursor(unsigned col, unsigned row);
  205. /* Clear the display */
  206. void video_clear(void);
  207. #if defined(CONFIG_FORMIKE)
  208. int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs,
  209. unsigned int max_hz, unsigned int spi_mode);
  210. #endif
  211. #if defined(CONFIG_LG4573)
  212. int lg4573_spi_startup(unsigned int bus, unsigned int cs,
  213. unsigned int max_hz, unsigned int spi_mode);
  214. #endif
  215. /*
  216. * video_get_info_str() - obtain a board string: type, speed, etc.
  217. *
  218. * This is called if CONFIG_CONSOLE_EXTRA_INFO is enabled.
  219. *
  220. * line_number: location to place info string beside logo
  221. * info: buffer for info string (empty if nothing to display on this
  222. * line)
  223. */
  224. void video_get_info_str(int line_number, char *info);
  225. #endif /* CONFIG_DM_VIDEO */
  226. #endif