PageRenderTime 1908ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/gpu/drm/vmwgfx/svga_overlay.h

https://gitlab.com/jhalayashraj/nkernel
C Header | 201 lines | 106 code | 38 blank | 57 comment | 7 complexity | a77be757cccc38b291ec1bec9e40e9dd MD5 | raw file
  1. /**********************************************************
  2. * Copyright 2007-2009 VMware, Inc. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person
  5. * obtaining a copy of this software and associated documentation
  6. * files (the "Software"), to deal in the Software without
  7. * restriction, including without limitation the rights to use, copy,
  8. * modify, merge, publish, distribute, sublicense, and/or sell copies
  9. * of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  19. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  20. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. *
  24. **********************************************************/
  25. /*
  26. * svga_overlay.h --
  27. *
  28. * Definitions for video-overlay support.
  29. */
  30. #ifndef _SVGA_OVERLAY_H_
  31. #define _SVGA_OVERLAY_H_
  32. #include "svga_reg.h"
  33. /*
  34. * Video formats we support
  35. */
  36. #define VMWARE_FOURCC_YV12 0x32315659 /* 'Y' 'V' '1' '2' */
  37. #define VMWARE_FOURCC_YUY2 0x32595559 /* 'Y' 'U' 'Y' '2' */
  38. #define VMWARE_FOURCC_UYVY 0x59565955 /* 'U' 'Y' 'V' 'Y' */
  39. typedef enum {
  40. SVGA_OVERLAY_FORMAT_INVALID = 0,
  41. SVGA_OVERLAY_FORMAT_YV12 = VMWARE_FOURCC_YV12,
  42. SVGA_OVERLAY_FORMAT_YUY2 = VMWARE_FOURCC_YUY2,
  43. SVGA_OVERLAY_FORMAT_UYVY = VMWARE_FOURCC_UYVY,
  44. } SVGAOverlayFormat;
  45. #define SVGA_VIDEO_COLORKEY_MASK 0x00ffffff
  46. #define SVGA_ESCAPE_VMWARE_VIDEO 0x00020000
  47. #define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS 0x00020001
  48. /* FIFO escape layout:
  49. * Type, Stream Id, (Register Id, Value) pairs */
  50. #define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH 0x00020002
  51. /* FIFO escape layout:
  52. * Type, Stream Id */
  53. typedef
  54. struct SVGAEscapeVideoSetRegs {
  55. struct {
  56. uint32 cmdType;
  57. uint32 streamId;
  58. } header;
  59. /* May include zero or more items. */
  60. struct {
  61. uint32 registerId;
  62. uint32 value;
  63. } items[1];
  64. } SVGAEscapeVideoSetRegs;
  65. typedef
  66. struct SVGAEscapeVideoFlush {
  67. uint32 cmdType;
  68. uint32 streamId;
  69. } SVGAEscapeVideoFlush;
  70. /*
  71. * Struct definitions for the video overlay commands built on
  72. * SVGAFifoCmdEscape.
  73. */
  74. typedef
  75. struct {
  76. uint32 command;
  77. uint32 overlay;
  78. } SVGAFifoEscapeCmdVideoBase;
  79. typedef
  80. struct {
  81. SVGAFifoEscapeCmdVideoBase videoCmd;
  82. } SVGAFifoEscapeCmdVideoFlush;
  83. typedef
  84. struct {
  85. SVGAFifoEscapeCmdVideoBase videoCmd;
  86. struct {
  87. uint32 regId;
  88. uint32 value;
  89. } items[1];
  90. } SVGAFifoEscapeCmdVideoSetRegs;
  91. typedef
  92. struct {
  93. SVGAFifoEscapeCmdVideoBase videoCmd;
  94. struct {
  95. uint32 regId;
  96. uint32 value;
  97. } items[SVGA_VIDEO_NUM_REGS];
  98. } SVGAFifoEscapeCmdVideoSetAllRegs;
  99. /*
  100. *----------------------------------------------------------------------
  101. *
  102. * VMwareVideoGetAttributes --
  103. *
  104. * Computes the size, pitches and offsets for YUV frames.
  105. *
  106. * Results:
  107. * TRUE on success; otherwise FALSE on failure.
  108. *
  109. * Side effects:
  110. * Pitches and offsets for the given YUV frame are put in 'pitches'
  111. * and 'offsets' respectively. They are both optional though.
  112. *
  113. *----------------------------------------------------------------------
  114. */
  115. static inline bool
  116. VMwareVideoGetAttributes(const SVGAOverlayFormat format, /* IN */
  117. uint32 *width, /* IN / OUT */
  118. uint32 *height, /* IN / OUT */
  119. uint32 *size, /* OUT */
  120. uint32 *pitches, /* OUT (optional) */
  121. uint32 *offsets) /* OUT (optional) */
  122. {
  123. int tmp;
  124. *width = (*width + 1) & ~1;
  125. if (offsets) {
  126. offsets[0] = 0;
  127. }
  128. switch (format) {
  129. case VMWARE_FOURCC_YV12:
  130. *height = (*height + 1) & ~1;
  131. *size = (*width + 3) & ~3;
  132. if (pitches) {
  133. pitches[0] = *size;
  134. }
  135. *size *= *height;
  136. if (offsets) {
  137. offsets[1] = *size;
  138. }
  139. tmp = ((*width >> 1) + 3) & ~3;
  140. if (pitches) {
  141. pitches[1] = pitches[2] = tmp;
  142. }
  143. tmp *= (*height >> 1);
  144. *size += tmp;
  145. if (offsets) {
  146. offsets[2] = *size;
  147. }
  148. *size += tmp;
  149. break;
  150. case VMWARE_FOURCC_YUY2:
  151. case VMWARE_FOURCC_UYVY:
  152. *size = *width * 2;
  153. if (pitches) {
  154. pitches[0] = *size;
  155. }
  156. *size *= *height;
  157. break;
  158. default:
  159. return false;
  160. }
  161. return true;
  162. }
  163. #endif /* _SVGA_OVERLAY_H_ */