summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/svga/include/svga_escape.h89
-rw-r--r--src/gallium/drivers/svga/include/svga_overlay.h201
-rw-r--r--src/gallium/state_trackers/wgl/stw_device.c14
-rw-r--r--src/gallium/state_trackers/wgl/stw_framebuffer.c31
-rw-r--r--src/gallium/state_trackers/wgl/stw_framebuffer.h3
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c6
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h5
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h66
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/Makefile14
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_driver.h86
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_hook.h39
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c140
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_screen.c104
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_video.c1021
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c4
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_extensions.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_bitmap.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_copy.c2
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.c4
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.c7
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.h2
-rw-r--r--src/mesa/drivers/dri/r200/r200_state_init.c15
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c3
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_common.c4
-rw-r--r--src/mesa/main/texfetch_tmp.h2
-rw-r--r--src/mesa/main/texstore.c20
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c2
-rw-r--r--src/mesa/vbo/vbo_exec.h4
-rw-r--r--src/mesa/vbo/vbo_exec_api.c11
31 files changed, 1823 insertions, 86 deletions
diff --git a/src/gallium/drivers/svga/include/svga_escape.h b/src/gallium/drivers/svga/include/svga_escape.h
new file mode 100644
index 00000000000..7b85e9b8c85
--- /dev/null
+++ b/src/gallium/drivers/svga/include/svga_escape.h
@@ -0,0 +1,89 @@
+/**********************************************************
+ * Copyright 2007-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/*
+ * svga_escape.h --
+ *
+ * Definitions for our own (vendor-specific) SVGA Escape commands.
+ */
+
+#ifndef _SVGA_ESCAPE_H_
+#define _SVGA_ESCAPE_H_
+
+
+/*
+ * Namespace IDs for the escape command
+ */
+
+#define SVGA_ESCAPE_NSID_VMWARE 0x00000000
+#define SVGA_ESCAPE_NSID_DEVEL 0xFFFFFFFF
+
+
+/*
+ * Within SVGA_ESCAPE_NSID_VMWARE, we multiplex commands according to
+ * the first DWORD of escape data (after the nsID and size). As a
+ * guideline we're using the high word and low word as a major and
+ * minor command number, respectively.
+ *
+ * Major command number allocation:
+ *
+ * 0000: Reserved
+ * 0001: SVGA_ESCAPE_VMWARE_LOG (svga_binary_logger.h)
+ * 0002: SVGA_ESCAPE_VMWARE_VIDEO (svga_overlay.h)
+ * 0003: SVGA_ESCAPE_VMWARE_HINT (svga_escape.h)
+ */
+
+#define SVGA_ESCAPE_VMWARE_MAJOR_MASK 0xFFFF0000
+
+
+/*
+ * SVGA Hint commands.
+ *
+ * These escapes let the SVGA driver provide optional information to
+ * he host about the state of the guest or guest applications. The
+ * host can use these hints to make user interface or performance
+ * decisions.
+ *
+ * Notes:
+ *
+ * - SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN is deprecated for guests
+ * that use the SVGA Screen Object extension. Instead of sending
+ * this escape, use the SVGA_SCREEN_FULLSCREEN_HINT flag on your
+ * Screen Object.
+ */
+
+#define SVGA_ESCAPE_VMWARE_HINT 0x00030000
+#define SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN 0x00030001 // Deprecated
+
+typedef
+struct {
+ uint32 command;
+ uint32 fullscreen;
+ struct {
+ int32 x, y;
+ } monitorPosition;
+} SVGAEscapeHintFullscreen;
+
+#endif /* _SVGA_ESCAPE_H_ */
diff --git a/src/gallium/drivers/svga/include/svga_overlay.h b/src/gallium/drivers/svga/include/svga_overlay.h
new file mode 100644
index 00000000000..82c1d3ff3e2
--- /dev/null
+++ b/src/gallium/drivers/svga/include/svga_overlay.h
@@ -0,0 +1,201 @@
+/**********************************************************
+ * Copyright 2007-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/*
+ * svga_overlay.h --
+ *
+ * Definitions for video-overlay support.
+ */
+
+#ifndef _SVGA_OVERLAY_H_
+#define _SVGA_OVERLAY_H_
+
+#include "svga_reg.h"
+
+/*
+ * Video formats we support
+ */
+
+#define VMWARE_FOURCC_YV12 0x32315659 // 'Y' 'V' '1' '2'
+#define VMWARE_FOURCC_YUY2 0x32595559 // 'Y' 'U' 'Y' '2'
+#define VMWARE_FOURCC_UYVY 0x59565955 // 'U' 'Y' 'V' 'Y'
+
+typedef enum {
+ SVGA_OVERLAY_FORMAT_INVALID = 0,
+ SVGA_OVERLAY_FORMAT_YV12 = VMWARE_FOURCC_YV12,
+ SVGA_OVERLAY_FORMAT_YUY2 = VMWARE_FOURCC_YUY2,
+ SVGA_OVERLAY_FORMAT_UYVY = VMWARE_FOURCC_UYVY,
+} SVGAOverlayFormat;
+
+#define SVGA_VIDEO_COLORKEY_MASK 0x00ffffff
+
+#define SVGA_ESCAPE_VMWARE_VIDEO 0x00020000
+
+#define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS 0x00020001
+ /* FIFO escape layout:
+ * Type, Stream Id, (Register Id, Value) pairs */
+
+#define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH 0x00020002
+ /* FIFO escape layout:
+ * Type, Stream Id */
+
+typedef
+struct SVGAEscapeVideoSetRegs {
+ struct {
+ uint32 cmdType;
+ uint32 streamId;
+ } header;
+
+ // May include zero or more items.
+ struct {
+ uint32 registerId;
+ uint32 value;
+ } items[1];
+} SVGAEscapeVideoSetRegs;
+
+typedef
+struct SVGAEscapeVideoFlush {
+ uint32 cmdType;
+ uint32 streamId;
+} SVGAEscapeVideoFlush;
+
+
+/*
+ * Struct definitions for the video overlay commands built on
+ * SVGAFifoCmdEscape.
+ */
+typedef
+struct {
+ uint32 command;
+ uint32 overlay;
+} SVGAFifoEscapeCmdVideoBase;
+
+typedef
+struct {
+ SVGAFifoEscapeCmdVideoBase videoCmd;
+} SVGAFifoEscapeCmdVideoFlush;
+
+typedef
+struct {
+ SVGAFifoEscapeCmdVideoBase videoCmd;
+ struct {
+ uint32 regId;
+ uint32 value;
+ } items[1];
+} SVGAFifoEscapeCmdVideoSetRegs;
+
+typedef
+struct {
+ SVGAFifoEscapeCmdVideoBase videoCmd;
+ struct {
+ uint32 regId;
+ uint32 value;
+ } items[SVGA_VIDEO_NUM_REGS];
+} SVGAFifoEscapeCmdVideoSetAllRegs;
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMwareVideoGetAttributes --
+ *
+ * Computes the size, pitches and offsets for YUV frames.
+ *
+ * Results:
+ * TRUE on success; otherwise FALSE on failure.
+ *
+ * Side effects:
+ * Pitches and offsets for the given YUV frame are put in 'pitches'
+ * and 'offsets' respectively. They are both optional though.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static INLINE Bool
+VMwareVideoGetAttributes(const SVGAOverlayFormat format, // IN
+ uint32 *width, // IN / OUT
+ uint32 *height, // IN / OUT
+ uint32 *size, // OUT
+ uint32 *pitches, // OUT (optional)
+ uint32 *offsets) // OUT (optional)
+{
+ int tmp;
+
+ *width = (*width + 1) & ~1;
+
+ if (offsets) {
+ offsets[0] = 0;
+ }
+
+ switch (format) {
+ case VMWARE_FOURCC_YV12:
+ *height = (*height + 1) & ~1;
+ *size = (*width + 3) & ~3;
+
+ if (pitches) {
+ pitches[0] = *size;
+ }
+
+ *size *= *height;
+
+ if (offsets) {
+ offsets[1] = *size;
+ }
+
+ tmp = ((*width >> 1) + 3) & ~3;
+
+ if (pitches) {
+ pitches[1] = pitches[2] = tmp;
+ }
+
+ tmp *= (*height >> 1);
+ *size += tmp;
+
+ if (offsets) {
+ offsets[2] = *size;
+ }
+
+ *size += tmp;
+ break;
+
+ case VMWARE_FOURCC_YUY2:
+ case VMWARE_FOURCC_UYVY:
+ *size = *width * 2;
+
+ if (pitches) {
+ pitches[0] = *size;
+ }
+
+ *size *= *height;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#endif // _SVGA_OVERLAY_H_
diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c
index 985b8f0456a..7785aba4677 100644
--- a/src/gallium/state_trackers/wgl/stw_device.c
+++ b/src/gallium/state_trackers/wgl/stw_device.c
@@ -72,19 +72,7 @@ stw_flush_frontbuffer(struct pipe_screen *screen,
return;
}
-#if DEBUG
- {
- /* ensure that a random surface was not passed to us */
- struct pipe_surface *surface2;
-
- if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
- assert(0);
- else
- assert(surface2 == surface);
- }
-#endif
-
- stw_framebuffer_present_locked(hdc, fb, ST_SURFACE_FRONT_LEFT);
+ stw_framebuffer_present_locked(hdc, fb, surface);
}
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c
index 8a3e11b6b40..6d095019815 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c
@@ -475,8 +475,6 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
struct stw_framebuffer *fb;
struct pipe_screen *screen;
struct pipe_surface *surface;
- unsigned surface_index;
- BOOL ret = FALSE;
fb = stw_framebuffer_from_hdc( hdc );
if (fb == NULL)
@@ -484,9 +482,7 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
screen = stw_dev->screen;
- surface_index = (unsigned)(uintptr_t)data->pPrivateData;
- if(!st_get_framebuffer_surface( fb->stfb, surface_index, &surface ))
- goto fail;
+ surface = (struct pipe_surface *)data->pPrivateData;
#ifdef DEBUG
if(stw_dev->trace_running) {
@@ -520,15 +516,11 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data)
stw_dev->stw_winsys->present( screen, surface, hdc );
}
- ret = TRUE;
-
-fail:
-
stw_framebuffer_update(fb);
stw_framebuffer_release(fb);
- return ret;
+ return TRUE;
}
@@ -540,7 +532,7 @@ fail:
BOOL
stw_framebuffer_present_locked(HDC hdc,
struct stw_framebuffer *fb,
- unsigned surface_index)
+ struct pipe_surface *surface)
{
if(stw_dev->callbacks.wglCbPresentBuffers &&
stw_dev->stw_winsys->compose) {
@@ -551,7 +543,7 @@ stw_framebuffer_present_locked(HDC hdc,
data.magic2 = 0;
data.AdapterLuid = stw_dev->AdapterLuid;
data.rect = fb->client_rect;
- data.pPrivateData = (void *)(uintptr_t)surface_index;
+ data.pPrivateData = (void *)surface;
stw_framebuffer_release(fb);
@@ -559,13 +551,6 @@ stw_framebuffer_present_locked(HDC hdc,
}
else {
struct pipe_screen *screen = stw_dev->screen;
- struct pipe_surface *surface;
-
- if(!st_get_framebuffer_surface( fb->stfb, surface_index, &surface )) {
- /* FIXME: this shouldn't happen, but does on glean */
- stw_framebuffer_release(fb);
- return FALSE;
- }
#ifdef DEBUG
if(stw_dev->trace_running) {
@@ -590,6 +575,7 @@ DrvSwapBuffers(
HDC hdc )
{
struct stw_framebuffer *fb;
+ struct pipe_surface *surface = NULL;
fb = stw_framebuffer_from_hdc( hdc );
if (fb == NULL)
@@ -600,12 +586,9 @@ DrvSwapBuffers(
return TRUE;
}
- /* If we're swapping the buffer associated with the current context
- * we have to flush any pending rendering commands first.
- */
- st_notify_swapbuffers( fb->stfb );
+ st_swapbuffers(fb->stfb, &surface, NULL);
- return stw_framebuffer_present_locked(hdc, fb, ST_SURFACE_BACK_LEFT);
+ return stw_framebuffer_present_locked(hdc, fb, surface);
}
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.h b/src/gallium/state_trackers/wgl/stw_framebuffer.h
index 5afbe749086..b80d168a7ce 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.h
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.h
@@ -34,6 +34,7 @@
#include "pipe/p_thread.h"
+struct pipe_surface;
struct stw_pixelformat_info;
/**
@@ -140,7 +141,7 @@ stw_framebuffer_allocate(
BOOL
stw_framebuffer_present_locked(HDC hdc,
struct stw_framebuffer *fb,
- unsigned surface_index);
+ struct pipe_surface *surface);
void
stw_framebuffer_update(
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 12915912986..da86295c316 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -652,6 +652,9 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ if (ms->winsys_screen_init)
+ ms->winsys_screen_init(pScrn);
+
return drv_enter_vt(scrnIndex, 1);
}
@@ -768,6 +771,9 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
drv_leave_vt(scrnIndex, 0);
}
+ if (ms->winsys_screen_close)
+ ms->winsys_screen_close(pScrn);
+
#ifdef DRI2
if (ms->screen)
xorg_dri2_close(pScreen);
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index c6c7b2fe158..d5fc18448ef 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -114,6 +114,11 @@ typedef struct _modesettingRec
Bool noEvict;
Bool debug_fallback;
+ /* winsys hocks */
+ Bool (*winsys_screen_init)(ScrnInfoPtr pScr);
+ Bool (*winsys_screen_close)(ScrnInfoPtr pScr);
+ void *winsys_priv;
+
#ifdef DRM_MODE_FEATURE_DIRTYFB
DamagePtr damage;
#endif
diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
index 6705dd42897..6bf3183ff54 100644
--- a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
+++ b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
@@ -45,7 +45,7 @@
#define DRM_VMW_UNREF_DMABUF 10
#define DRM_VMW_FIFO_DEBUG 11
#define DRM_VMW_FENCE_WAIT 12
-
+#define DRM_VMW_OVERLAY 13
/*************************************************************************/
/**
@@ -439,4 +439,68 @@ struct drm_vmw_fence_wait_arg {
int32_t pad64;
};
+/*************************************************************************/
+/**
+ * DRM_VMW_OVERLAY - Control overlays.
+ *
+ * This IOCTL controls the overlay units of the svga device.
+ * The SVGA overlay units does not work like regular hardware units in
+ * that they do not automaticaly read back the contents of the given dma
+ * buffer. But instead only read back for each call to this ioctl, and
+ * at any point between this call being made and a following call that
+ * either changes the buffer or disables the stream.
+ */
+
+/**
+ * struct drm_vmw_rect
+ *
+ * Defines a rectangle. Used in the overlay ioctl to define
+ * source and destination rectangle.
+ */
+
+struct drm_vmw_rect {
+ int32_t x;
+ int32_t y;
+ uint32_t w;
+ uint32_t h;
+};
+
+/**
+ * struct drm_vmw_overlay_arg
+ *
+ * @stream_id: Stearm to control
+ * @enabled: If false all following arguments are ignored.
+ * @handle: Handle to buffer for getting data from.
+ * @format: Format of the overlay as understood by the host.
+ * @width: Width of the overlay.
+ * @height: Height of the overlay.
+ * @size: Size of the overlay in bytes.
+ * @pitch: Array of pitches, the two last are only used for YUV12 formats.
+ * @offset: Offset from start of dma buffer to overlay.
+ * @src: Source rect, must be within the defined area above.
+ * @dst: Destination rect, x and y may be negative.
+ *
+ * Argument to the DRM_VMW_OVERLAY Ioctl.
+ */
+
+struct drm_vmw_overlay_arg {
+ uint32_t stream_id;
+ uint32_t enabled;
+
+ uint32_t flags;
+ uint32_t color_key;
+
+ uint32_t handle;
+ uint32_t offset;
+ int32_t format;
+ uint32_t size;
+ uint32_t width;
+ uint32_t height;
+ uint32_t pitch[3];
+
+ uint32_t pad64;
+ struct drm_vmw_rect src;
+ struct drm_vmw_rect dst;
+};
+
#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/Makefile b/src/gallium/winsys/drm/vmware/xorg/Makefile
index 48a9b08aa76..49e28ae17f5 100644
--- a/src/gallium/winsys/drm/vmware/xorg/Makefile
+++ b/src/gallium/winsys/drm/vmware/xorg/Makefile
@@ -1,10 +1,17 @@
-TARGET = vmwgfx_drv.so
-CFILES = $(wildcard ./*.c)
-OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
TOP = ../../../../../..
include $(TOP)/configs/current
+TARGET = vmwgfx_drv.so
+
+CFILES = \
+ vmw_xorg.c \
+ vmw_video.c \
+ vmw_ioctl.c \
+ vmw_screen.c
+
+OBJECTS = $(patsubst %.c,%.o,$(CFILES))
+
INCLUDES = \
$(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
-I$(TOP)/src/gallium/include \
@@ -24,6 +31,7 @@ LINKS = \
$(shell pkg-config --libs libdrm)
DRIVER_DEFINES = \
+ -std=gnu99 \
-DHAVE_CONFIG_H
TARGET_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h
new file mode 100644
index 00000000000..04d446a2dfb
--- /dev/null
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h
@@ -0,0 +1,86 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the shared resources for VMware Xorg driver
+ * that sits ontop of the Xorg State Traker.
+ *
+ * It is initialized in vmw_screen.c.
+ *
+ * @author Jakob Bornecrantz <[email protected]>
+ */
+
+#ifndef VMW_DRIVER_H_
+#define VMW_DRIVER_H_
+
+#include "state_trackers/xorg/xorg_tracker.h"
+
+struct vmw_dma_buffer;
+
+struct vmw_driver
+{
+ int fd;
+
+ /* vmw_video.c */
+ void *video_priv;
+};
+
+static INLINE struct vmw_driver *
+vmw_driver(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ return ms ? (struct vmw_driver *)ms->winsys_priv : NULL;
+}
+
+
+/***********************************************************************
+ * vmw_video.c
+ */
+
+Bool vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+
+Bool vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+
+
+/***********************************************************************
+ * vmw_ioctl.c
+ */
+
+struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_driver *vmw,
+ uint32_t size,
+ unsigned *handle);
+
+void * vmw_ioctl_buffer_map(struct vmw_driver *vmw,
+ struct vmw_dma_buffer *buf);
+
+void vmw_ioctl_buffer_unmap(struct vmw_driver *vmw,
+ struct vmw_dma_buffer *buf);
+
+void vmw_ioctl_buffer_destroy(struct vmw_driver *vmw,
+ struct vmw_dma_buffer *buf);
+
+
+#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h b/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h
new file mode 100644
index 00000000000..224a2d92996
--- /dev/null
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_hook.h
@@ -0,0 +1,39 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#ifndef VMW_HOOK_H_
+#define VMW_HOOK_H_
+
+#include "state_trackers/xorg/xorg_winsys.h"
+
+
+/***********************************************************************
+ * vmw_screen.c
+ */
+
+void vmw_screen_set_functions(ScrnInfoPtr pScrn);
+
+
+#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c
new file mode 100644
index 00000000000..3cac5b7760c
--- /dev/null
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c
@@ -0,0 +1,140 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the functions for creating dma buffers by calling
+ * the kernel via driver specific ioctls.
+ *
+ * @author Jakob Bornecrantz <[email protected]>
+ */
+
+#define HAVE_STDINT_H
+#define _FILE_OFFSET_BITS 64
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/mman.h>
+#include "xf86drm.h"
+#include "../core/vmwgfx_drm.h"
+
+#include "vmw_driver.h"
+#include "util/u_debug.h"
+
+struct vmw_dma_buffer
+{
+ void *data;
+ unsigned handle;
+ uint64_t map_handle;
+ unsigned map_count;
+ uint32_t size;
+};
+
+struct vmw_dma_buffer *
+vmw_ioctl_buffer_create(struct vmw_driver *vmw, uint32_t size, unsigned *handle)
+{
+ struct vmw_dma_buffer *buf;
+ union drm_vmw_alloc_dmabuf_arg arg;
+ struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
+ struct drm_vmw_dmabuf_rep *rep = &arg.rep;
+ int ret;
+
+ buf = xcalloc(1, sizeof(*buf));
+ if (!buf)
+ goto err;
+
+ memset(&arg, 0, sizeof(arg));
+ req->size = size;
+ do {
+ ret = drmCommandWriteRead(vmw->fd, DRM_VMW_ALLOC_DMABUF, &arg, sizeof(arg));
+ } while (ret == -ERESTART);
+
+ if (ret) {
+ debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
+ goto err_free;
+ }
+
+
+ buf->data = NULL;
+ buf->handle = rep->handle;
+ buf->map_handle = rep->map_handle;
+ buf->map_count = 0;
+ buf->size = size;
+
+ *handle = rep->handle;
+
+ return buf;
+
+err_free:
+ xfree(buf);
+err:
+ return NULL;
+}
+
+void
+vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
+{
+ struct drm_vmw_unref_dmabuf_arg arg;
+
+ if (buf->data) {
+ munmap(buf->data, buf->size);
+ buf->data = NULL;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = buf->handle;
+ drmCommandWrite(vmw->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
+
+ xfree(buf);
+}
+
+void *
+vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
+{
+ void *map;
+
+ if (buf->data == NULL) {
+ map = mmap(NULL, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ vmw->fd, buf->map_handle);
+ if (map == MAP_FAILED) {
+ debug_printf("%s: Map failed.\n", __FUNCTION__);
+ return NULL;
+ }
+
+ buf->data = map;
+ }
+
+ ++buf->map_count;
+
+ return buf->data;
+}
+
+void
+vmw_ioctl_buffer_unmap(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
+{
+ --buf->map_count;
+}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c
new file mode 100644
index 00000000000..344ef0b3159
--- /dev/null
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c
@@ -0,0 +1,104 @@
+/**********************************************************
+ * Copyright 2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/**
+ * @file
+ * Contains the init code for the VMware Xorg driver.
+ *
+ * @author Jakob Bornecrantz <[email protected]>
+ */
+
+#include "vmw_hook.h"
+#include "vmw_driver.h"
+
+static Bool
+vmw_screen_init(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct vmw_driver *vmw;
+
+ /* if gallium is used then we don't need to do anything. */
+ if (ms->screen)
+ return TRUE;
+
+ vmw = xnfcalloc(sizeof(*vmw), 1);
+ if (!vmw)
+ return FALSE;
+
+ vmw->fd = ms->fd;
+ ms->winsys_priv = vmw;
+
+ vmw_video_init(pScrn, vmw);
+
+ return TRUE;
+}
+
+static Bool
+vmw_screen_close(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct vmw_driver *vmw = vmw_driver(pScrn);
+
+ if (!vmw)
+ return TRUE;
+
+ vmw_video_close(pScrn, vmw);
+
+ ms->winsys_priv = NULL;
+ xfree(vmw);
+
+ return TRUE;
+}
+
+/*
+ * Functions for setting up hooks into the xorg state tracker
+ */
+
+static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL;
+
+static Bool
+vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
+{
+ modesettingPtr ms;
+
+ pScrn->PreInit = vmw_screen_pre_init_saved;
+ if (!pScrn->PreInit(pScrn, flags))
+ return FALSE;
+
+ ms = modesettingPTR(pScrn);
+ ms->winsys_screen_init = vmw_screen_init;
+ ms->winsys_screen_close = vmw_screen_close;
+
+ return TRUE;
+}
+
+void
+vmw_screen_set_functions(ScrnInfoPtr pScrn)
+{
+ assert(!vmw_screen_pre_init_saved);
+
+ vmw_screen_pre_init_saved = pScrn->PreInit;
+ pScrn->PreInit = vmw_screen_pre_init;
+}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
new file mode 100644
index 00000000000..6e34aa21f38
--- /dev/null
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
@@ -0,0 +1,1021 @@
+/*
+ * Copyright 2007 by VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * vmwarevideo.c --
+ *
+ * Xv extension support.
+ * See http://www.xfree86.org/current/DESIGN16.html
+ *
+ */
+
+
+#include "xf86xv.h"
+#include "fourcc.h"
+
+#include "pipe/p_compiler.h"
+/*
+ * We can't incude svga_types.h due to conflicting types for Bool.
+ */
+typedef int64_t int64;
+typedef uint64_t uint64;
+
+typedef int32_t int32;
+typedef uint32_t uint32;
+
+typedef int16_t int16;
+typedef uint16_t uint16;
+
+typedef int8_t int8;
+typedef uint8_t uint8;
+
+#include "svga/include/svga_reg.h"
+#include "svga/include/svga_escape.h"
+#include "svga/include/svga_overlay.h"
+
+#include "vmw_driver.h"
+
+#include <X11/extensions/Xv.h>
+
+#include "xf86drm.h"
+#include "../core/vmwgfx_drm.h"
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+/*
+ * Number of videos that can be played simultaneously
+ */
+#define VMWARE_VID_NUM_PORTS 1
+
+/*
+ * Using a dark shade as the default colorKey
+ */
+#define VMWARE_VIDEO_COLORKEY 0x100701
+
+/*
+ * Maximum dimensions
+ */
+#define VMWARE_VID_MAX_WIDTH 2048
+#define VMWARE_VID_MAX_HEIGHT 2048
+
+#define VMWARE_VID_NUM_ENCODINGS 1
+static XF86VideoEncodingRec vmwareVideoEncodings[] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ VMWARE_VID_MAX_WIDTH, VMWARE_VID_MAX_HEIGHT,
+ {1, 1}
+ }
+};
+
+#define VMWARE_VID_NUM_FORMATS 2
+static XF86VideoFormatRec vmwareVideoFormats[] =
+{
+ { 16, TrueColor},
+ { 24, TrueColor}
+};
+
+#define VMWARE_VID_NUM_IMAGES 3
+static XF86ImageRec vmwareVideoImages[] =
+{
+ XVIMAGE_YV12,
+ XVIMAGE_YUY2,
+ XVIMAGE_UYVY
+};
+
+#define VMWARE_VID_NUM_ATTRIBUTES 2
+static XF86AttributeRec vmwareVideoAttributes[] =
+{
+ {
+ XvGettable | XvSettable,
+ 0x000000,
+ 0xffffff,
+ "XV_COLORKEY"
+ },
+ {
+ XvGettable | XvSettable,
+ 0,
+ 1,
+ "XV_AUTOPAINT_COLORKEY"
+ }
+};
+
+/*
+ * Video frames are stored in a circular list of buffers.
+ * Must be power or two, See vmw_video_port_play.
+ */
+#define VMWARE_VID_NUM_BUFFERS 1
+
+/*
+ * Defines the structure used to hold and pass video data to the host
+ */
+struct vmw_video_buffer
+{
+ unsigned handle;
+ int size;
+ void *data;
+ void *extra_data;
+ struct vmw_dma_buffer *buf;
+};
+
+
+/**
+ * Structure representing a single video stream, aka port.
+ *
+ * Ports maps one to one to a SVGA stream. Port is just
+ * what Xv calls a SVGA stream.
+ */
+struct vmw_video_port
+{
+ /*
+ * Function prototype same as XvPutImage.
+ *
+ * This is either set to vmw_video_port_init or vmw_video_port_play.
+ * At init this function is set to port_init. In port_init we set it
+ * to port_play and call it, after initializing the struct.
+ */
+ int (*play)(ScrnInfoPtr, struct vmw_video_port *,
+ short, short, short, short, short,
+ short, short, short, int, unsigned char*,
+ short, short, RegionPtr);
+
+ /* values to go into the SVGAOverlayUnit */
+ uint32 streamId;
+ uint32 colorKey;
+ uint32 flags;
+
+ /* round robin of buffers */
+ unsigned currBuf;
+ struct vmw_video_buffer bufs[VMWARE_VID_NUM_BUFFERS];
+
+ /* properties that applies to all buffers */
+ int size;
+ int pitches[3];
+ int offsets[3];
+
+ /* things for X */
+ RegionRec clipBoxes;
+ Bool isAutoPaintColorkey;
+};
+
+
+/**
+ * Structure holding all the infromation for video.
+ */
+struct vmw_video_private
+{
+ int fd;
+
+ /** ports */
+ struct vmw_video_port port[VMWARE_VID_NUM_PORTS];
+
+ /** Used to store port pointers pointers */
+ DevUnion port_ptr[VMWARE_VID_NUM_PORTS];
+};
+
+
+/*
+ * Callback functions exported to Xv, prefixed with vmw_xv_*.
+ */
+static int vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
+ short drw_x, short drw_y, short src_w, short src_h,
+ short drw_w, short drw_h, int image,
+ unsigned char *buf, short width, short height,
+ Bool sync, RegionPtr clipBoxes, pointer data,
+ DrawablePtr dst);
+static void vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool Cleanup);
+static int vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
+ unsigned short *width,
+ unsigned short *height, int *pitches,
+ int *offsets);
+static int vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+ INT32 value, pointer data);
+static int vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+ INT32 *value, pointer data);
+static void vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
+ short vid_w, short vid_h, short drw_w,
+ short drw_h, unsigned int *p_w,
+ unsigned int *p_h, pointer data);
+
+
+/*
+ * Local functions.
+ */
+static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+
+static int vmw_video_port_init(ScrnInfoPtr pScrn,
+ struct vmw_video_port *port,
+ short src_x, short src_y, short drw_x,
+ short drw_y, short src_w, short src_h,
+ short drw_w, short drw_h, int format,
+ unsigned char *buf, short width,
+ short height, RegionPtr clipBoxes);
+static int vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+ short src_x, short src_y, short drw_x,
+ short drw_y, short src_w, short src_h,
+ short drw_w, short drw_h, int format,
+ unsigned char *buf, short width,
+ short height, RegionPtr clipBoxes);
+static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port);
+
+static int vmw_video_buffer_alloc(struct vmw_driver *vmw, int size,
+ struct vmw_video_buffer *out);
+static int vmw_video_buffer_free(struct vmw_driver *vmw,
+ struct vmw_video_buffer *out);
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_init --
+ *
+ * Initializes Xv support.
+ *
+ * Results:
+ * TRUE on success, FALSE on error.
+ *
+ * Side effects:
+ * Xv support is initialized. Memory is allocated for all supported
+ * video streams.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+ ScreenPtr pScreen = pScrn->pScreen;
+ XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
+ XF86VideoAdaptorPtr newAdaptor = NULL;
+ int numAdaptors;
+
+ debug_printf("%s: enter\n", __func__);
+
+ numAdaptors = xf86XVListGenericAdaptors(pScrn, &overlayAdaptors);
+
+ newAdaptor = vmw_video_init_adaptor(pScrn, vmw);
+ if (!newAdaptor) {
+ debug_printf("Failed to initialize Xv extension\n");
+ return FALSE;
+ }
+
+ if (!numAdaptors) {
+ numAdaptors = 1;
+ overlayAdaptors = &newAdaptor;
+ } else {
+ newAdaptors = xalloc((numAdaptors + 1) *
+ sizeof(XF86VideoAdaptorPtr*));
+ if (!newAdaptors) {
+ xf86XVFreeVideoAdaptorRec(newAdaptor);
+ return FALSE;
+ }
+
+ memcpy(newAdaptors, overlayAdaptors,
+ numAdaptors * sizeof(XF86VideoAdaptorPtr));
+ newAdaptors[numAdaptors++] = newAdaptor;
+ overlayAdaptors = newAdaptors;
+ }
+
+ if (!xf86XVScreenInit(pScreen, overlayAdaptors, numAdaptors)) {
+ debug_printf("Failed to initialize Xv extension\n");
+ xf86XVFreeVideoAdaptorRec(newAdaptor);
+ return FALSE;
+ }
+
+ if (newAdaptors) {
+ xfree(newAdaptors);
+ }
+
+ debug_printf("Initialized VMware Xv extension successfully\n");
+
+ return TRUE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_close --
+ *
+ * Unitializes video.
+ *
+ * Results:
+ * TRUE.
+ *
+ * Side effects:
+ * vmw->video_priv = NULL
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+ struct vmw_video_private *video;
+ int i;
+
+ debug_printf("%s: enter\n", __func__);
+
+ video = vmw->video_priv;
+
+ for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+ vmw_video_port_cleanup(pScrn, &video->port[i]);
+ }
+
+ /* XXX: I'm sure this function is missing code for turning off Xv */
+
+ free(vmw->video_priv);
+ vmw->video_priv = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_init_adaptor --
+ *
+ * Initializes a XF86VideoAdaptor structure with the capabilities and
+ * functions supported by this video driver.
+ *
+ * Results:
+ * On success initialized XF86VideoAdaptor struct or NULL on error
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static XF86VideoAdaptorPtr
+vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+{
+ XF86VideoAdaptorPtr adaptor;
+ struct vmw_video_private *video;
+ int i;
+
+ debug_printf("%s: enter \n", __func__);
+
+ adaptor = xf86XVAllocateVideoAdaptorRec(pScrn);
+ if (!adaptor) {
+ debug_printf("Not enough memory\n");
+ return NULL;
+ }
+
+ video = xcalloc(1, sizeof(*video));
+ if (!video) {
+ debug_printf("Not enough memory.\n");
+ xf86XVFreeVideoAdaptorRec(adaptor);
+ return NULL;
+ }
+
+ vmw->video_priv = video;
+
+ adaptor->type = XvInputMask | XvImageMask | XvWindowMask;
+ adaptor->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ adaptor->name = "VMware Video Engine";
+ adaptor->nEncodings = VMWARE_VID_NUM_ENCODINGS;
+ adaptor->pEncodings = vmwareVideoEncodings;
+ adaptor->nFormats = VMWARE_VID_NUM_FORMATS;
+ adaptor->pFormats = vmwareVideoFormats;
+ adaptor->nPorts = VMWARE_VID_NUM_PORTS;
+ adaptor->pPortPrivates = video->port_ptr;
+
+ for (i = 0; i < VMWARE_VID_NUM_PORTS; ++i) {
+ video->port[i].streamId = i;
+ video->port[i].play = vmw_video_port_init;
+ video->port[i].flags = SVGA_VIDEO_FLAG_COLORKEY;
+ video->port[i].colorKey = VMWARE_VIDEO_COLORKEY;
+ video->port[i].isAutoPaintColorkey = TRUE;
+ adaptor->pPortPrivates[i].ptr = &video->port[i];
+ }
+
+ adaptor->nAttributes = VMWARE_VID_NUM_ATTRIBUTES;
+ adaptor->pAttributes = vmwareVideoAttributes;
+
+ adaptor->nImages = VMWARE_VID_NUM_IMAGES;
+ adaptor->pImages = vmwareVideoImages;
+
+ adaptor->PutVideo = NULL;
+ adaptor->PutStill = NULL;
+ adaptor->GetVideo = NULL;
+ adaptor->GetStill = NULL;
+ adaptor->StopVideo = vmw_xv_stop_video;
+ adaptor->SetPortAttribute = vmw_xv_set_port_attribute;
+ adaptor->GetPortAttribute = vmw_xv_get_port_attribute;
+ adaptor->QueryBestSize = vmw_xv_query_best_size;
+ adaptor->PutImage = vmw_xv_put_image;
+ adaptor->QueryImageAttributes = vmw_xv_query_image_attributes;
+
+ debug_printf("%s: done %p\n", __func__, adaptor);
+
+ return adaptor;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_init --
+ *
+ * Initializes a video stream in response to the first PutImage() on a
+ * video stream. The process goes as follows:
+ * - Figure out characteristics according to format
+ * - Allocate offscreen memory
+ * - Pass on video to Play() functions
+ *
+ * Results:
+ * Success or XvBadAlloc on failure.
+ *
+ * Side effects:
+ * Video stream is initialized and its first frame sent to the host
+ * (done by VideoPlay() function called at the end)
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+ short src_x, short src_y, short drw_x,
+ short drw_y, short src_w, short src_h,
+ short drw_w, short drw_h, int format,
+ unsigned char *buf, short width,
+ short height, RegionPtr clipBoxes)
+{
+ struct vmw_driver *vmw = vmw_driver(pScrn);
+ unsigned short w, h;
+ int i, ret;
+
+ debug_printf("\t%s: id %d, format %d\n", __func__, port->streamId, format);
+
+ w = width;
+ h = height;
+ /* init all the format attributes, used for buffers */
+ port->size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
+ port->pitches, port->offsets);
+
+ if (port->size == -1)
+ return XvBadAlloc;
+
+ port->play = vmw_video_port_play;
+
+ for (i = 0; i < VMWARE_VID_NUM_BUFFERS; ++i) {
+ ret = vmw_video_buffer_alloc(vmw, port->size, &port->bufs[i]);
+ if (ret != Success)
+ break;
+ }
+
+ /* Free all allocated buffers on failure */
+ if (ret != Success) {
+ for (--i; i >= 0; --i) {
+ vmw_video_buffer_free(vmw, &port->bufs[i]);
+ }
+ return ret;
+ }
+
+ port->currBuf = 0;
+
+ REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
+
+ if (port->isAutoPaintColorkey)
+ xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
+
+ return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
+ drw_w, drw_h, format, buf, width, height, clipBoxes);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_play --
+ *
+ * Sends all the attributes associated with the video frame using the
+ * FIFO ESCAPE mechanism to the host.
+ *
+ * Results:
+ * Always returns Success.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
+ short src_x, short src_y, short drw_x,
+ short drw_y, short src_w, short src_h,
+ short drw_w, short drw_h, int format,
+ unsigned char *buf, short width,
+ short height, RegionPtr clipBoxes)
+{
+ struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct drm_vmw_overlay_arg arg;
+ unsigned short w, h;
+ int size;
+ int ret;
+
+ debug_printf("\t%s: enter\n", __func__);
+
+ w = width;
+ h = height;
+
+ /* we don't update the ports size */
+ size = vmw_xv_query_image_attributes(pScrn, format, &w, &h,
+ port->pitches, port->offsets);
+
+ if (size > port->size) {
+ debug_printf("\t%s: Increase in size of Xv video frame streamId:%d.\n",
+ __func__, port->streamId);
+ vmw_xv_stop_video(pScrn, port, TRUE);
+ return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w,
+ src_h, drw_w, drw_h, format, buf, width, height,
+ clipBoxes);
+ }
+
+ memcpy(port->bufs[port->currBuf].data, buf, port->size);
+
+ memset(&arg, 0, sizeof(arg));
+
+ arg.stream_id = port->streamId;
+ arg.enabled = TRUE;
+ arg.flags = port->flags;
+ arg.color_key = port->colorKey;
+ arg.handle = port->bufs[port->currBuf].handle;
+ arg.format = format;
+ arg.size = port->size;
+ arg.width = w;
+ arg.height = h;
+ arg.src.x = src_x;
+ arg.src.y = src_y;
+ arg.src.w = src_w;
+ arg.src.h = src_h;
+ arg.dst.x = drw_x;
+ arg.dst.y = drw_y;
+ arg.dst.w = drw_w;
+ arg.dst.h = drw_h;
+ arg.pitch[0] = port->pitches[0];
+ arg.pitch[1] = port->pitches[1];
+ arg.pitch[2] = port->pitches[2];
+ arg.offset = 0;
+
+ /*
+ * Update the clipList and paint the colorkey, if required.
+ */
+ if (!REGION_EQUAL(pScrn->pScreen, &port->clipBoxes, clipBoxes)) {
+ REGION_COPY(pScrn->pScreen, &port->clipBoxes, clipBoxes);
+ if (port->isAutoPaintColorkey) {
+ xf86XVFillKeyHelper(pScrn->pScreen, port->colorKey, clipBoxes);
+ }
+ }
+
+ ret = drmCommandWrite(vmw->fd, DRM_VMW_OVERLAY, &arg, sizeof(arg));
+ if (ret) {
+ vmw_video_port_cleanup(pScrn, port);
+ return XvBadAlloc;
+ }
+
+ port->currBuf = ++port->currBuf & (VMWARE_VID_NUM_BUFFERS - 1);
+
+ return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_port_cleanup --
+ *
+ * Frees up all resources (if any) taken by a video stream.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Same as above.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port)
+{
+ struct vmw_driver *vmw = vmw_driver(pScrn);
+ uint32 id, colorKey, flags;
+ Bool isAutoPaintColorkey;
+ int i;
+
+ debug_printf("\t%s: enter\n", __func__);
+
+ for (i = 0; i < VMWARE_VID_NUM_BUFFERS; i++) {
+ vmw_video_buffer_free(vmw, &port->bufs[i]);
+ }
+
+ /*
+ * reset stream for next video
+ */
+ id = port->streamId;
+ colorKey = port->colorKey;
+ flags = port->flags;
+ isAutoPaintColorkey = port->isAutoPaintColorkey;
+
+ memset(port, 0, sizeof(*port));
+
+ port->streamId = id;
+ port->play = vmw_video_port_init;
+ port->colorKey = colorKey;
+ port->flags = flags;
+ port->isAutoPaintColorkey = isAutoPaintColorkey;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_buffer_alloc --
+ *
+ * Allocates and map a kernel buffer to be used as data storage.
+ *
+ * Results:
+ * XvBadAlloc on failure, otherwise Success.
+ *
+ * Side effects:
+ * Calls into the kernel, sets members of out.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_buffer_alloc(struct vmw_driver *vmw, int size,
+ struct vmw_video_buffer *out)
+{
+ out->buf = vmw_ioctl_buffer_create(vmw, size, &out->handle);
+ if (!out->buf)
+ return XvBadAlloc;
+
+ out->data = vmw_ioctl_buffer_map(vmw, out->buf);
+ if (!out->data) {
+ vmw_ioctl_buffer_destroy(vmw, out->buf);
+
+ out->handle = 0;
+ out->buf = NULL;
+
+ return XvBadAlloc;
+ }
+
+ out->size = size;
+ out->extra_data = xcalloc(1, size);
+
+ debug_printf("\t\t%s: allocated buffer %p of size %i\n", __func__, out, size);
+
+ return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_video_buffer_free --
+ *
+ * Frees and unmaps an allocated kernel buffer.
+ *
+ * Results:
+ * Success.
+ *
+ * Side effects:
+ * Calls into the kernel, sets members of out to 0.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_video_buffer_free(struct vmw_driver *vmw,
+ struct vmw_video_buffer *out)
+{
+ if (out->size == 0)
+ return Success;
+
+ xfree(out->extra_data);
+ vmw_ioctl_buffer_unmap(vmw, out->buf);
+ vmw_ioctl_buffer_destroy(vmw, out->buf);
+
+ out->buf = NULL;
+ out->data = NULL;
+ out->handle = 0;
+ out->size = 0;
+
+ debug_printf("\t\t%s: freed buffer %p\n", __func__, out);
+
+ return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_put_image --
+ *
+ * Main video playback function. It copies the passed data which is in
+ * the specified format (e.g. FOURCC_YV12) into the overlay.
+ *
+ * If sync is TRUE the driver should not return from this
+ * function until it is through reading the data from buf.
+ *
+ * Results:
+ * Success or XvBadAlloc on failure
+ *
+ * Side effects:
+ * Video port will be played(initialized if 1st frame) on success
+ * or will fail on error.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
+ short drw_x, short drw_y, short src_w, short src_h,
+ short drw_w, short drw_h, int format,
+ unsigned char *buf, short width, short height,
+ Bool sync, RegionPtr clipBoxes, pointer data,
+ DrawablePtr dst)
+{
+ struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_video_port *port = data;
+
+ debug_printf("%s: enter (%u, %u) (%ux%u) (%u, %u) (%ux%u) (%ux%u)\n", __func__,
+ src_x, src_y, src_w, src_h,
+ drw_x, drw_y, drw_w, drw_h,
+ width, height);
+
+ if (!vmw->video_priv)
+ return XvBadAlloc;
+
+ return port->play(pScrn, port, src_x, src_y, drw_x, drw_y, src_w, src_h,
+ drw_w, drw_h, format, buf, width, height, clipBoxes);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_stop_video --
+ *
+ * Called when we should stop playing video for a particular stream. If
+ * Cleanup is FALSE, the "stop" operation is only temporary, and thus we
+ * don't do anything. If Cleanup is TRUE we kill the video port by
+ * sending a message to the host and freeing up the stream.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * See above.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
+{
+ struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_video_port *port = data;
+ struct drm_vmw_overlay_arg arg;
+ int ret;
+
+ debug_printf("%s: cleanup is %s\n", __func__, cleanup ? "TRUE" : "FALSE");
+
+ if (!vmw->video_priv)
+ return;
+
+ if (!cleanup)
+ return;
+
+
+ memset(&arg, 0, sizeof(arg));
+ arg.stream_id = port->streamId;
+ arg.enabled = FALSE;
+
+ ret = drmCommandWrite(vmw->fd, DRM_VMW_OVERLAY, &arg, sizeof(arg));
+ assert(ret == 0);
+
+ vmw_video_port_cleanup(pScrn, port);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_query_image_attributes --
+ *
+ * From the spec: This function is called to let the driver specify how data
+ * for a particular image of size width by height should be stored.
+ * Sometimes only the size and corrected width and height are needed. In
+ * that case pitches and offsets are NULL.
+ *
+ * Results:
+ * The size of the memory required for the image, or -1 on error.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_query_image_attributes(ScrnInfoPtr pScrn, int format,
+ unsigned short *width, unsigned short *height,
+ int *pitches, int *offsets)
+{
+ INT32 size, tmp;
+
+ if (*width > VMWARE_VID_MAX_WIDTH) {
+ *width = VMWARE_VID_MAX_WIDTH;
+ }
+ if (*height > VMWARE_VID_MAX_HEIGHT) {
+ *height = VMWARE_VID_MAX_HEIGHT;
+ }
+
+ *width = (*width + 1) & ~1;
+ if (offsets != NULL) {
+ offsets[0] = 0;
+ }
+
+ switch (format) {
+ case FOURCC_YV12:
+ *height = (*height + 1) & ~1;
+ size = (*width + 3) & ~3;
+ if (pitches) {
+ pitches[0] = size;
+ }
+ size *= *height;
+ if (offsets) {
+ offsets[1] = size;
+ }
+ tmp = ((*width >> 1) + 3) & ~3;
+ if (pitches) {
+ pitches[1] = pitches[2] = tmp;
+ }
+ tmp *= (*height >> 1);
+ size += tmp;
+ if (offsets) {
+ offsets[2] = size;
+ }
+ size += tmp;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ size = *width * 2;
+ if (pitches) {
+ pitches[0] = size;
+ }
+ size *= *height;
+ break;
+ default:
+ debug_printf("Query for invalid video format %d\n", format);
+ return -1;
+ }
+ return size;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_set_port_attribute --
+ *
+ * From the spec: A port may have particular attributes such as colorKey, hue,
+ * saturation, brightness or contrast. Xv clients set these
+ * attribute values by sending attribute strings (Atoms) to the server.
+ *
+ * Results:
+ * Success if the attribute exists and XvBadAlloc otherwise.
+ *
+ * Side effects:
+ * The respective attribute gets the new value.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_set_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+ INT32 value, pointer data)
+{
+ struct vmw_video_port *port = data;
+ Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+ Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
+
+ if (attribute == xvColorKey) {
+ debug_printf("%s: Set colorkey:0x%x\n", __func__, (unsigned)value);
+ port->colorKey = value;
+ } else if (attribute == xvAutoPaint) {
+ debug_printf("%s: Set autoPaint: %s\n", __func__, value? "TRUE": "FALSE");
+ port->isAutoPaintColorkey = value;
+ } else {
+ return XvBadAlloc;
+ }
+
+ return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_get_port_attribute --
+ *
+ * From the spec: A port may have particular attributes such as hue,
+ * saturation, brightness or contrast. Xv clients get these
+ * attribute values by sending attribute strings (Atoms) to the server
+ *
+ * Results:
+ * Success if the attribute exists and XvBadAlloc otherwise.
+ *
+ * Side effects:
+ * "value" contains the requested attribute on success.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+vmw_xv_get_port_attribute(ScrnInfoPtr pScrn, Atom attribute,
+ INT32 *value, pointer data)
+{
+ struct vmw_video_port *port = data;
+ Atom xvColorKey = MAKE_ATOM("XV_COLORKEY");
+ Atom xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
+
+ if (attribute == xvColorKey) {
+ *value = port->colorKey;
+ } else if (attribute == xvAutoPaint) {
+ *value = port->isAutoPaintColorkey;
+ } else {
+ return XvBadAlloc;
+ }
+
+ return Success;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * vmw_xv_query_best_size --
+ *
+ * From the spec: QueryBestSize provides the client with a way to query what
+ * the destination dimensions would end up being if they were to request
+ * that an area vid_w by vid_h from the video stream be scaled to rectangle
+ * of drw_w by drw_h on the screen. Since it is not expected that all
+ * hardware will be able to get the target dimensions exactly, it is
+ * important that the driver provide this function.
+ *
+ * This function seems to never be called, but to be on the safe side
+ * we apply the same logic that QueryImageAttributes has for width
+ * and height.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
+ short vid_w, short vid_h, short drw_w,
+ short drw_h, unsigned int *p_w,
+ unsigned int *p_h, pointer data)
+{
+ *p_w = (drw_w + 1) & ~1;
+ *p_h = drw_h;
+
+ return;
+}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
index 3acc110ae79..4b208719ca3 100644
--- a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c
@@ -31,7 +31,7 @@
* @author Jakob Bornecrantz <[email protected]>
*/
-#include "state_trackers/xorg/xorg_winsys.h"
+#include "vmw_hook.h"
static void vmw_xorg_identify(int flags);
static Bool vmw_xorg_pci_probe(DriverPtr driver,
@@ -145,6 +145,8 @@ vmw_xorg_pci_probe(DriverPtr driver,
/* Use all the functions from the xorg tracker */
xorg_tracker_set_functions(scrn);
+
+ vmw_screen_set_functions(scrn);
}
return scrn != NULL;
}
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index 13e609f58fe..5f8dc2ab241 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -291,6 +291,7 @@ xm_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
unsigned usage,
+ unsigned tex_usage,
unsigned *stride)
{
const unsigned alignment = 64;
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
index f5fe543b5df..86dc42cc510 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -124,7 +124,6 @@ static const struct dri_extension card_extensions[] = {
{ "GL_MESA_pack_invert", NULL },
{ "GL_MESA_ycbcr_texture", NULL },
{ "GL_NV_blend_square", NULL },
- { "GL_NV_point_sprite", GL_NV_point_sprite_functions },
{ "GL_NV_vertex_program", GL_NV_vertex_program_functions },
{ "GL_NV_vertex_program1_1", NULL },
{ "GL_SGIS_generate_mipmap", NULL },
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 5615040946f..b6e0d823ed2 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -126,7 +126,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_RGB16:
rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
- irb->texformat = MESA_FORMAT_ARGB8888; /* XXX: Need xrgb8888 */
+ irb->texformat = MESA_FORMAT_XRGB8888;
cpp = 4;
break;
case GL_RGBA:
@@ -314,10 +314,6 @@ intel_create_renderbuffer(gl_format format)
irb->Base.DataType = GL_UNSIGNED_BYTE;
break;
case MESA_FORMAT_XRGB8888:
- /* XXX this is a hack since XRGB surfaces don't seem to work
- * properly yet. Reading the alpha channel returns 0 instead of 1.
- */
- format = MESA_FORMAT_ARGB8888;
irb->Base._BaseFormat = GL_RGB;
irb->Base.DataType = GL_UNSIGNED_BYTE;
break;
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
index 9572b673269..668697cb5eb 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
@@ -335,6 +335,8 @@ out:
unpack->BufferObj);
}
+ intel_check_front_buffer_rendering(intel);
+
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
index f058b3c8e4d..622aaa22d67 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
@@ -222,6 +222,8 @@ do_blit_copypixels(GLcontext * ctx,
out:
UNLOCK_HARDWARE(intel);
+ intel_check_front_buffer_rendering(intel);
+
DBG("%s: success\n", __FUNCTION__);
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index e3ae839235e..5f985d624d8 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -325,9 +325,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
_mesa_init_driver_functions(&functions);
r200InitDriverFuncs(&functions);
r200InitIoctlFuncs(&functions);
- r200InitStateFuncs(&functions, screen->kernel_mm);
+ r200InitStateFuncs(&functions);
r200InitTextureFuncs(&functions);
- r200InitShaderFuncs(&functions);
+ r200InitShaderFuncs(&functions);
radeonInitQueryObjFunctions(&functions);
if (!radeonInitContext(&rmesa->radeon, &functions,
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index d28e96d9d98..6d99c039ded 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -2476,7 +2476,7 @@ static void r200PolygonStipple( GLcontext *ctx, const GLubyte *mask )
}
/* Initialize the driver's state functions.
*/
-void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 )
+void r200InitStateFuncs( struct dd_function_table *functions )
{
functions->UpdateState = r200InvalidateState;
functions->LightingSpaceChange = r200LightingSpaceChange;
@@ -2510,10 +2510,7 @@ void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 )
functions->LogicOpcode = r200LogicOpCode;
functions->PolygonMode = r200PolygonMode;
functions->PolygonOffset = r200PolygonOffset;
- if (dri2)
- functions->PolygonStipple = r200PolygonStipple;
- else
- functions->PolygonStipple = radeonPolygonStipplePreKMS;
+ functions->PolygonStipple = r200PolygonStipple;
functions->PointParameterfv = r200PointParameter;
functions->PointSize = r200PointSize;
functions->RenderMode = r200RenderMode;
diff --git a/src/mesa/drivers/dri/r200/r200_state.h b/src/mesa/drivers/dri/r200/r200_state.h
index 9c62f0a6446..7b9b0c106aa 100644
--- a/src/mesa/drivers/dri/r200/r200_state.h
+++ b/src/mesa/drivers/dri/r200/r200_state.h
@@ -38,7 +38,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r200_context.h"
extern void r200InitState( r200ContextPtr rmesa );
-extern void r200InitStateFuncs( struct dd_function_table *functions, GLboolean dri2 );
+extern void r200InitStateFuncs( struct dd_function_table *functions );
extern void r200InitTnlFuncs( GLcontext *ctx );
extern void r200UpdateMaterial( GLcontext *ctx );
diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c
index e53fd72290c..6c5a0b79eed 100644
--- a/src/mesa/drivers/dri/r200/r200_state_init.c
+++ b/src/mesa/drivers/dri/r200/r200_state_init.c
@@ -887,10 +887,8 @@ void r200InitState( r200ContextPtr rmesa )
}
}
}
- /* polygon stipple is done with irq for non-kms */
- if (rmesa->radeon.radeonScreen->kernel_mm) {
- ALLOC_STATE( stp, always, STP_STATE_SIZE, "STP/stp", 0 );
- }
+
+ ALLOC_STATE( stp, always, STP_STATE_SIZE, "STP/stp", 0 );
for (i = 0; i < 6; i++)
if (rmesa->radeon.radeonScreen->kernel_mm)
@@ -1122,12 +1120,11 @@ void r200InitState( r200ContextPtr rmesa )
rmesa->hw.sci.cmd[SCI_CMD_1] = CP_PACKET0(R200_RE_TOP_LEFT, 0);
rmesa->hw.sci.cmd[SCI_CMD_2] = CP_PACKET0(R200_RE_WIDTH_HEIGHT, 0);
- if (rmesa->radeon.radeonScreen->kernel_mm) {
-
- rmesa->hw.stp.cmd[STP_CMD_0] = CP_PACKET0(RADEON_RE_STIPPLE_ADDR, 0);
- rmesa->hw.stp.cmd[STP_DATA_0] = 0;
- rmesa->hw.stp.cmd[STP_CMD_1] = CP_PACKET0_ONE(RADEON_RE_STIPPLE_DATA, 31);
+ rmesa->hw.stp.cmd[STP_CMD_0] = CP_PACKET0(RADEON_RE_STIPPLE_ADDR, 0);
+ rmesa->hw.stp.cmd[STP_DATA_0] = 0;
+ rmesa->hw.stp.cmd[STP_CMD_1] = CP_PACKET0_ONE(RADEON_RE_STIPPLE_DATA, 31);
+ if (rmesa->radeon.radeonScreen->kernel_mm) {
rmesa->hw.mtl[0].emit = mtl_emit;
rmesa->hw.mtl[1].emit = mtl_emit;
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 1fd32d497b4..ac20c08e201 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1741,8 +1741,7 @@ static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
r300SetPolygonOffsetState(ctx, state);
break;
case GL_SCISSOR_TEST:
- if (!rmesa->radeon.radeonScreen->kernel_mm)
- radeon_firevertices(&rmesa->radeon);
+ radeon_firevertices(&rmesa->radeon);
rmesa->radeon.state.scissor.enabled = state;
radeonUpdateScissor( ctx );
break;
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c
index 3b4366aa61c..184287aa44c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -257,9 +257,7 @@ void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
radeonContextPtr radeon = RADEON_CONTEXT(ctx);
if (ctx->Scissor.Enabled) {
/* We don't pipeline cliprect changes */
- if (!radeon->radeonScreen->kernel_mm) {
- radeon_firevertices(radeon);
- }
+ radeon_firevertices(radeon);
radeonUpdateScissor(ctx);
}
}
diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h
index 1f0d4362361..e6772c89f36 100644
--- a/src/mesa/main/texfetch_tmp.h
+++ b/src/mesa/main/texfetch_tmp.h
@@ -864,7 +864,7 @@ static void store_texel_al88_rev(struct gl_texture_image *texImage,
static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLuint s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 5387eb12837..792c83141ec 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2197,18 +2197,22 @@ _mesa_texstore_al1616(TEXSTORE_PARAMS)
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == MESA_FORMAT_AL1616) {
for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
- dstUI[col] = PACK_COLOR_1616( FLOAT_TO_USHORT(src[1]),
- FLOAT_TO_USHORT(src[0]) );
- src += 2;
+ GLushort l, a;
+
+ UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
+ dstUI[col] = PACK_COLOR_1616(a, l);
+ src += 2;
}
}
else {
for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
- dstUI[col] = PACK_COLOR_1616_REV( FLOAT_TO_UBYTE(src[1]),
- FLOAT_TO_UBYTE(src[0]) );
- src += 2;
+ GLushort l, a;
+
+ UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
+ dstUI[col] = PACK_COLOR_1616_REV(a, l);
+ src += 2;
}
}
dstRow += dstRowStride;
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 5e8e61135e6..5e76f4db4eb 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -278,7 +278,7 @@ static struct ureg_src swizzle_4v( struct ureg_src src,
/**
- * Translate SWZ instructions into a single MAD. EG:
+ * Translate a SWZ instruction into a MOV, MUL or MAD instruction. EG:
*
* SWZ dst, src.x-y10
*
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 0a05b8df894..98c1f363d98 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -138,6 +138,10 @@ struct vbo_exec_context
*/
const struct gl_client_array *inputs[VERT_ATTRIB_MAX];
} array;
+
+#ifdef DEBUG
+ GLint flush_call_depth;
+#endif
};
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index c90565eae8c..f0a7eeadd0f 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -876,9 +876,8 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
#ifdef DEBUG
/* debug check: make sure we don't get called recursively */
- static GLuint callDepth = 0;
- callDepth++;
- assert(callDepth == 1);
+ exec->flush_call_depth++;
+ assert(exec->flush_call_depth == 1);
#endif
if (0) _mesa_printf("%s\n", __FUNCTION__);
@@ -886,7 +885,8 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
if (0) _mesa_printf("%s - inside begin/end\n", __FUNCTION__);
#ifdef DEBUG
- callDepth--;
+ exec->flush_call_depth--;
+ assert(exec->flush_call_depth == 0);
#endif
return;
}
@@ -903,7 +903,8 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags )
exec->ctx->Driver.NeedFlush &= ~flags;
#ifdef DEBUG
- callDepth--;
+ exec->flush_call_depth--;
+ assert(exec->flush_call_depth == 0);
#endif
}