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