video_osd.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2017
  4. * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
  5. */
  6. #ifndef _VIDEO_OSD_H_
  7. #define _VIDEO_OSD_H_
  8. struct video_osd_info {
  9. /* The width of the OSD display in columns */
  10. uint width;
  11. /* The height of the OSD display in rows */
  12. uint height;
  13. /* The major version of the OSD device */
  14. uint major_version;
  15. /* The minor version of the OSD device */
  16. uint minor_version;
  17. };
  18. /**
  19. * struct video_osd_ops - driver operations for OSD uclass
  20. *
  21. * The OSD uclass implements support for text-oriented on-screen displays,
  22. * which are taken to be devices that independently display a graphical
  23. * text-based overlay over the video output of an associated display.
  24. *
  25. * The functions defined by the uclass support writing text to the display in
  26. * either a generic form (by specifying a string, a driver-specific color value
  27. * for the text, and screen coordinates in rows and columns) or a
  28. * driver-specific form (by specifying "raw" driver-specific data to display at
  29. * a given coordinate).
  30. *
  31. * Functions to read device information and set the size of the virtual OSD
  32. * screen (in rows and columns) are also supported.
  33. *
  34. * Drivers should support these operations unless otherwise noted. These
  35. * operations are intended to be used by uclass code, not directly from
  36. * other code.
  37. */
  38. struct video_osd_ops {
  39. /**
  40. * get_info() - Get information about a OSD instance
  41. *
  42. * A OSD instance may keep some internal data about itself. This
  43. * function can be used to access this data.
  44. *
  45. * @dev: OSD instance to query.
  46. * @info: Pointer to a structure that takes the information read
  47. * from the OSD instance.
  48. * @return 0 if OK, -ve on error.
  49. */
  50. int (*get_info)(struct udevice *dev, struct video_osd_info *info);
  51. /**
  52. * set_mem() - Write driver-specific text data to OSD screen
  53. *
  54. * The passed data are device-specific, and it's up to the driver how
  55. * to interpret them. How the count parameter is interpreted is also
  56. * driver-specific; most likely the given data will be written to the
  57. * OSD count times back-to-back, which is e.g. convenient for filling
  58. * areas of the OSD with a single character.
  59. *
  60. * For example a invocation of
  61. *
  62. * video_osd_set_mem(dev, 0, 0, "A", 1, 10);
  63. *
  64. * will write the device-specific text data "A" to the positions (0, 0)
  65. * to (9, 0) on the OSD.
  66. *
  67. * Device-specific text data may, e.g. be a special encoding of glyphs
  68. * to display and color values in binary format.
  69. *
  70. * @dev: OSD instance to write to.
  71. * @col: Horizontal character coordinate to write to.
  72. * @row Vertical character coordinate to write to.
  73. * @buf: Array containing device-specific data to write to the
  74. * specified coordinate on the OSD screen.
  75. * @buflen: Length of the data in the passed buffer (in byte).
  76. * @count: Write count many repetitions of the given text data
  77. * @return 0 if OK, -ve on error.
  78. */
  79. int (*set_mem)(struct udevice *dev, uint col, uint row, u8 *buf,
  80. size_t buflen, uint count);
  81. /**
  82. * set_size() - Set the position and dimension of the OSD's
  83. * writeable window
  84. *
  85. * @dev: OSD instance to write to.
  86. * @col The number of characters in the window's columns
  87. * @row The number of characters in the window's rows
  88. * @return 0 if OK, -ve on error.
  89. */
  90. int (*set_size)(struct udevice *dev, uint col, uint row);
  91. /**
  92. * print() - Print a string in a given color to specified coordinates
  93. * on the OSD
  94. *
  95. * @dev: OSD instance to write to.
  96. * @col The x-coordinate of the position the string should be
  97. * written to
  98. * @row The y-coordinate of the position the string should be
  99. * written to
  100. * @color: The color in which the specified string should be
  101. * printed; the interpretation of the value is
  102. * driver-specific, and possible values should be defined
  103. * e.g. in a driver include file.
  104. * @text: The string data that should be printed on the OSD
  105. * @return 0 if OK, -ve on error.
  106. */
  107. int (*print)(struct udevice *dev, uint col, uint row, ulong color,
  108. char *text);
  109. };
  110. #define video_osd_get_ops(dev) ((struct video_osd_ops *)(dev)->driver->ops)
  111. /**
  112. * video_osd_get_info() - Get information about a OSD instance
  113. *
  114. * A OSD instance may keep some internal data about itself. This function can
  115. * be used to access this data.
  116. *
  117. * @dev: OSD instance to query.
  118. * @info: Pointer to a structure that takes the information read from the
  119. * OSD instance.
  120. * @return 0 if OK, -ve on error.
  121. */
  122. int video_osd_get_info(struct udevice *dev, struct video_osd_info *info);
  123. /**
  124. * video_osd_set_mem() - Write text data to OSD memory
  125. *
  126. * The passed data are device-specific, and it's up to the driver how to
  127. * interpret them. How the count parameter is interpreted is also
  128. * driver-specific; most likely the given data will be written to the OSD count
  129. * times back-to-back, which is e.g. convenient for filling areas of the OSD
  130. * with a single character.
  131. *
  132. * For example a invocation of
  133. *
  134. * video_osd_set_mem(dev, 0, 0, "A", 1, 10);
  135. *
  136. * will write the device-specific text data "A" to the positions (0, 0) to (9,
  137. * 0) on the OSD.
  138. *
  139. * Device-specific text data may, e.g. be a special encoding of glyphs to
  140. * display and color values in binary format.
  141. *
  142. * @dev: OSD instance to write to.
  143. * @col: Horizontal character coordinate to write to.
  144. * @row Vertical character coordinate to write to.
  145. * @buf: Array containing device-specific data to write to the specified
  146. * coordinate on the OSD screen.
  147. * @buflen: Length of the data in the passed buffer (in byte).
  148. * @count: Write count many repetitions of the given text data
  149. * @return 0 if OK, -ve on error.
  150. */
  151. int video_osd_set_mem(struct udevice *dev, uint col, uint row, u8 *buf,
  152. size_t buflen, uint count);
  153. /**
  154. * video_osd_set_size() - Set the position and dimension of the OSD's
  155. * writeable window
  156. *
  157. * @dev: OSD instance to write to.
  158. * @col The number of characters in the window's columns
  159. * @row The number of characters in the window's rows
  160. * @return 0 if OK, -ve on error.
  161. */
  162. int video_osd_set_size(struct udevice *dev, uint col, uint row);
  163. /**
  164. * video_osd_print() - Print a string in a given color to specified coordinates
  165. * on the OSD
  166. *
  167. * @dev: OSD instance to write to.
  168. * @col The x-coordinate of the position the string should be written
  169. * to
  170. * @row The y-coordinate of the position the string should be written
  171. * to
  172. * @color: The color in which the specified string should be printed; the
  173. * interpretation of the value is driver-specific, and possible
  174. * values should be defined e.g. in a driver include file.
  175. * @text: The string data that should be printed on the OSD
  176. * @return 0 if OK, -ve on error.
  177. */
  178. int video_osd_print(struct udevice *dev, uint col, uint row, ulong color,
  179. char *text);
  180. #endif /* !_VIDEO_OSD_H_ */