Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
svga_overlay.h
Go to the documentation of this 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 /*
27  * svga_overlay.h --
28  *
29  * Definitions for video-overlay support.
30  */
31 
32 #ifndef _SVGA_OVERLAY_H_
33 #define _SVGA_OVERLAY_H_
34 
35 #include "svga_reg.h"
36 
37 /*
38  * Video formats we support
39  */
40 
41 #define VMWARE_FOURCC_YV12 0x32315659 /* 'Y' 'V' '1' '2' */
42 #define VMWARE_FOURCC_YUY2 0x32595559 /* 'Y' 'U' 'Y' '2' */
43 #define VMWARE_FOURCC_UYVY 0x59565955 /* 'U' 'Y' 'V' 'Y' */
44 
45 typedef enum {
51 
52 #define SVGA_VIDEO_COLORKEY_MASK 0x00ffffff
53 
54 #define SVGA_ESCAPE_VMWARE_VIDEO 0x00020000
55 
56 #define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS 0x00020001
57  /* FIFO escape layout:
58  * Type, Stream Id, (Register Id, Value) pairs */
59 
60 #define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH 0x00020002
61  /* FIFO escape layout:
62  * Type, Stream Id */
63 
64 typedef
66  struct {
69  } header;
70 
71  /* May include zero or more items. */
72  struct {
75  } items[1];
77 
78 typedef
79 struct SVGAEscapeVideoFlush {
83 
84 
85 /*
86  * Struct definitions for the video overlay commands built on
87  * SVGAFifoCmdEscape.
88  */
89 typedef
90 struct {
94 
95 typedef
96 struct {
99 
100 typedef
101 struct {
103  struct {
106  } items[1];
108 
109 typedef
110 struct {
112  struct {
117 
118 
119 /*
120  *----------------------------------------------------------------------
121  *
122  * VMwareVideoGetAttributes --
123  *
124  * Computes the size, pitches and offsets for YUV frames.
125  *
126  * Results:
127  * TRUE on success; otherwise FALSE on failure.
128  *
129  * Side effects:
130  * Pitches and offsets for the given YUV frame are put in 'pitches'
131  * and 'offsets' respectively. They are both optional though.
132  *
133  *----------------------------------------------------------------------
134  */
135 
136 static inline bool
137 VMwareVideoGetAttributes(const SVGAOverlayFormat format, /* IN */
138  uint32 *width, /* IN / OUT */
139  uint32 *height, /* IN / OUT */
140  uint32 *size, /* OUT */
141  uint32 *pitches, /* OUT (optional) */
142  uint32 *offsets) /* OUT (optional) */
143 {
144  int tmp;
145 
146  *width = (*width + 1) & ~1;
147 
148  if (offsets) {
149  offsets[0] = 0;
150  }
151 
152  switch (format) {
153  case VMWARE_FOURCC_YV12:
154  *height = (*height + 1) & ~1;
155  *size = (*width + 3) & ~3;
156 
157  if (pitches) {
158  pitches[0] = *size;
159  }
160 
161  *size *= *height;
162 
163  if (offsets) {
164  offsets[1] = *size;
165  }
166 
167  tmp = ((*width >> 1) + 3) & ~3;
168 
169  if (pitches) {
170  pitches[1] = pitches[2] = tmp;
171  }
172 
173  tmp *= (*height >> 1);
174  *size += tmp;
175 
176  if (offsets) {
177  offsets[2] = *size;
178  }
179 
180  *size += tmp;
181  break;
182 
183  case VMWARE_FOURCC_YUY2:
184  case VMWARE_FOURCC_UYVY:
185  *size = *width * 2;
186 
187  if (pitches) {
188  pitches[0] = *size;
189  }
190 
191  *size *= *height;
192  break;
193 
194  default:
195  return false;
196  }
197 
198  return true;
199 }
200 
201 #endif /* _SVGA_OVERLAY_H_ */