Path: blob/21.2-virgl/src/gallium/drivers/svga/include/svga_overlay.h
4574 views
/**********************************************************1* Copyright 2007-2015 VMware, Inc. All rights reserved.2*3* Permission is hereby granted, free of charge, to any person4* obtaining a copy of this software and associated documentation5* files (the "Software"), to deal in the Software without6* restriction, including without limitation the rights to use, copy,7* modify, merge, publish, distribute, sublicense, and/or sell copies8* of the Software, and to permit persons to whom the Software is9* furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be12* included in all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,15* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND17* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS18* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN19* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN20* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23**********************************************************/2425/*26* svga_overlay.h --27*28* Definitions for video-overlay support.29*/3031#ifndef _SVGA_OVERLAY_H_32#define _SVGA_OVERLAY_H_3334#include "svga_reg.h"3536/*37* Video formats we support38*/3940#define VMWARE_FOURCC_YV12 0x32315659 /* 'Y' 'V' '1' '2' */41#define VMWARE_FOURCC_YUY2 0x32595559 /* 'Y' 'U' 'Y' '2' */42#define VMWARE_FOURCC_UYVY 0x59565955 /* 'U' 'Y' 'V' 'Y' */4344typedef enum {45SVGA_OVERLAY_FORMAT_INVALID = 0,46SVGA_OVERLAY_FORMAT_YV12 = VMWARE_FOURCC_YV12,47SVGA_OVERLAY_FORMAT_YUY2 = VMWARE_FOURCC_YUY2,48SVGA_OVERLAY_FORMAT_UYVY = VMWARE_FOURCC_UYVY,49} SVGAOverlayFormat;5051#define SVGA_VIDEO_COLORKEY_MASK 0x00ffffff5253#define SVGA_ESCAPE_VMWARE_VIDEO 0x000200005455#define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS 0x0002000156/* FIFO escape layout:57* Type, Stream Id, (Register Id, Value) pairs */5859#define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH 0x0002000260/* FIFO escape layout:61* Type, Stream Id */6263typedef64struct SVGAEscapeVideoSetRegs {65struct {66uint32 cmdType;67uint32 streamId;68} header;6970/* May include zero or more items. */71struct {72uint32 registerId;73uint32 value;74} items[1];75} SVGAEscapeVideoSetRegs;7677typedef78struct SVGAEscapeVideoFlush {79uint32 cmdType;80uint32 streamId;81} SVGAEscapeVideoFlush;828384/*85* Struct definitions for the video overlay commands built on86* SVGAFifoCmdEscape.87*/88typedef89struct {90uint32 command;91uint32 overlay;92} SVGAFifoEscapeCmdVideoBase;9394typedef95struct {96SVGAFifoEscapeCmdVideoBase videoCmd;97} SVGAFifoEscapeCmdVideoFlush;9899typedef100struct {101SVGAFifoEscapeCmdVideoBase videoCmd;102struct {103uint32 regId;104uint32 value;105} items[1];106} SVGAFifoEscapeCmdVideoSetRegs;107108typedef109struct {110SVGAFifoEscapeCmdVideoBase videoCmd;111struct {112uint32 regId;113uint32 value;114} items[SVGA_VIDEO_NUM_REGS];115} SVGAFifoEscapeCmdVideoSetAllRegs;116117118/*119*----------------------------------------------------------------------120*121* VMwareVideoGetAttributes --122*123* Computes the size, pitches and offsets for YUV frames.124*125* Results:126* TRUE on success; otherwise FALSE on failure.127*128* Side effects:129* Pitches and offsets for the given YUV frame are put in 'pitches'130* and 'offsets' respectively. They are both optional though.131*132*----------------------------------------------------------------------133*/134135static inline Bool136VMwareVideoGetAttributes(const SVGAOverlayFormat format, /* IN */137uint32 *width, /* IN / OUT */138uint32 *height, /* IN / OUT */139uint32 *size, /* OUT */140uint32 *pitches, /* OUT (optional) */141uint32 *offsets) /* OUT (optional) */142{143int tmp;144145*width = (*width + 1) & ~1;146147if (offsets) {148offsets[0] = 0;149}150151switch (format) {152case VMWARE_FOURCC_YV12:153*height = (*height + 1) & ~1;154*size = (*width) * (*height);155156if (pitches) {157pitches[0] = *width;158}159160if (offsets) {161offsets[1] = *size;162}163164tmp = *width >> 1;165166if (pitches) {167pitches[1] = pitches[2] = tmp;168}169170tmp *= (*height >> 1);171*size += tmp;172173if (offsets) {174offsets[2] = *size;175}176177*size += tmp;178break;179180case VMWARE_FOURCC_YUY2:181case VMWARE_FOURCC_UYVY:182*size = *width * 2;183184if (pitches) {185pitches[0] = *size;186}187188*size *= *height;189break;190191default:192return FALSE;193}194195return TRUE;196}197198#endif /* _SVGA_OVERLAY_H_ */199200201