Add linux-next specific files for 20110831
[linux-2.6/next.git] / drivers / gpu / drm / vmwgfx / svga_overlay.h
blobf753d73c14b44c5c023c070d90cbd0f87ce3cf29
1 /**********************************************************
2 * Copyright 2007-2009 VMware, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
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.
24 **********************************************************/
27 * svga_overlay.h --
29 * Definitions for video-overlay support.
32 #ifndef _SVGA_OVERLAY_H_
33 #define _SVGA_OVERLAY_H_
35 #include "svga_reg.h"
38 * Video formats we support
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'
45 typedef enum {
46 SVGA_OVERLAY_FORMAT_INVALID = 0,
47 SVGA_OVERLAY_FORMAT_YV12 = VMWARE_FOURCC_YV12,
48 SVGA_OVERLAY_FORMAT_YUY2 = VMWARE_FOURCC_YUY2,
49 SVGA_OVERLAY_FORMAT_UYVY = VMWARE_FOURCC_UYVY,
50 } SVGAOverlayFormat;
52 #define SVGA_VIDEO_COLORKEY_MASK 0x00ffffff
54 #define SVGA_ESCAPE_VMWARE_VIDEO 0x00020000
56 #define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS 0x00020001
57 /* FIFO escape layout:
58 * Type, Stream Id, (Register Id, Value) pairs */
60 #define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH 0x00020002
61 /* FIFO escape layout:
62 * Type, Stream Id */
64 typedef
65 struct SVGAEscapeVideoSetRegs {
66 struct {
67 uint32 cmdType;
68 uint32 streamId;
69 } header;
71 // May include zero or more items.
72 struct {
73 uint32 registerId;
74 uint32 value;
75 } items[1];
76 } SVGAEscapeVideoSetRegs;
78 typedef
79 struct SVGAEscapeVideoFlush {
80 uint32 cmdType;
81 uint32 streamId;
82 } SVGAEscapeVideoFlush;
86 * Struct definitions for the video overlay commands built on
87 * SVGAFifoCmdEscape.
89 typedef
90 struct {
91 uint32 command;
92 uint32 overlay;
93 } SVGAFifoEscapeCmdVideoBase;
95 typedef
96 struct {
97 SVGAFifoEscapeCmdVideoBase videoCmd;
98 } SVGAFifoEscapeCmdVideoFlush;
100 typedef
101 struct {
102 SVGAFifoEscapeCmdVideoBase videoCmd;
103 struct {
104 uint32 regId;
105 uint32 value;
106 } items[1];
107 } SVGAFifoEscapeCmdVideoSetRegs;
109 typedef
110 struct {
111 SVGAFifoEscapeCmdVideoBase videoCmd;
112 struct {
113 uint32 regId;
114 uint32 value;
115 } items[SVGA_VIDEO_NUM_REGS];
116 } SVGAFifoEscapeCmdVideoSetAllRegs;
120 *----------------------------------------------------------------------
122 * VMwareVideoGetAttributes --
124 * Computes the size, pitches and offsets for YUV frames.
126 * Results:
127 * TRUE on success; otherwise FALSE on failure.
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.
133 *----------------------------------------------------------------------
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)
144 int tmp;
146 *width = (*width + 1) & ~1;
148 if (offsets) {
149 offsets[0] = 0;
152 switch (format) {
153 case VMWARE_FOURCC_YV12:
154 *height = (*height + 1) & ~1;
155 *size = (*width + 3) & ~3;
157 if (pitches) {
158 pitches[0] = *size;
161 *size *= *height;
163 if (offsets) {
164 offsets[1] = *size;
167 tmp = ((*width >> 1) + 3) & ~3;
169 if (pitches) {
170 pitches[1] = pitches[2] = tmp;
173 tmp *= (*height >> 1);
174 *size += tmp;
176 if (offsets) {
177 offsets[2] = *size;
180 *size += tmp;
181 break;
183 case VMWARE_FOURCC_YUY2:
184 case VMWARE_FOURCC_UYVY:
185 *size = *width * 2;
187 if (pitches) {
188 pitches[0] = *size;
191 *size *= *height;
192 break;
194 default:
195 return false;
198 return true;
201 #endif // _SVGA_OVERLAY_H_