summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2010-02-15 14:10:19 +0100
committerJakob Bornecrantz <[email protected]>2010-02-27 02:12:47 +0000
commit55e5737bae6b88c2d1bc4c0d94e11548518659b8 (patch)
treee5d629c13e145d4b0b82d9754846de25ce3f263d /src/gallium/winsys
parentab8a232b2cad965501e3778219e957509a078757 (diff)
st/xorg: Encapsulate all customizable stuff in a separate class.
This avoids exposing the ms driver structure to the winsys, and nicely encapsulates driver customizable stuff. In the future more things might be customizable by the winsys, like throttling, 3D readback etc. Signed-off-by: Thomas Hellstrom <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_driver.h36
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c20
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_screen.c72
-rw-r--r--src/gallium/winsys/drm/vmware/xorg/vmw_video.c31
4 files changed, 82 insertions, 77 deletions
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h
index 3efe851a4be..ba754b51e47 100644
--- a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h
@@ -40,8 +40,11 @@
struct vmw_dma_buffer;
-struct vmw_driver
+struct vmw_customizer
{
+ CustomizerRec base;
+ ScrnInfoPtr pScrn;
+
int fd;
void *cursor_priv;
@@ -50,11 +53,10 @@ struct vmw_driver
void *video_priv;
};
-static INLINE struct vmw_driver *
-vmw_driver(ScrnInfoPtr pScrn)
+static INLINE struct vmw_customizer *
+vmw_customizer(CustomizerPtr cust)
{
- modesettingPtr ms = modesettingPTR(pScrn);
- return ms ? (struct vmw_driver *)ms->winsys_priv : NULL;
+ return cust ? (struct vmw_customizer *) cust : NULL;
}
@@ -62,40 +64,40 @@ vmw_driver(ScrnInfoPtr pScrn)
* vmw_video.c
*/
-Bool vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+Bool vmw_video_init(struct vmw_customizer *vmw);
-Bool vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+Bool vmw_video_close(struct vmw_customizer *vmw);
-void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+void vmw_video_stop_all(struct vmw_customizer *vmw);
/***********************************************************************
* vmw_ioctl.c
*/
-int vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot);
+int vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot);
-struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_driver *vmw,
+struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_customizer *vmw,
uint32_t size,
unsigned *handle);
-void * vmw_ioctl_buffer_map(struct vmw_driver *vmw,
+void * vmw_ioctl_buffer_map(struct vmw_customizer *vmw,
struct vmw_dma_buffer *buf);
-void vmw_ioctl_buffer_unmap(struct vmw_driver *vmw,
+void vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw,
struct vmw_dma_buffer *buf);
-void vmw_ioctl_buffer_destroy(struct vmw_driver *vmw,
+void vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw,
struct vmw_dma_buffer *buf);
-int vmw_ioctl_supports_streams(struct vmw_driver *vmw);
+int vmw_ioctl_supports_streams(struct vmw_customizer *vmw);
-int vmw_ioctl_num_streams(struct vmw_driver *vmw,
+int vmw_ioctl_num_streams(struct vmw_customizer *vmw,
uint32_t *ntot, uint32_t *nfree);
-int vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id);
+int vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id);
-int vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out);
+int vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out);
#endif
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c
index ab2b5fadc49..521578ab35d 100644
--- a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c
@@ -57,7 +57,7 @@ struct vmw_dma_buffer
};
static int
-vmw_ioctl_get_param(struct vmw_driver *vmw, uint32_t param, uint64_t *out)
+vmw_ioctl_get_param(struct vmw_customizer *vmw, uint32_t param, uint64_t *out)
{
struct drm_vmw_getparam_arg gp_arg;
int ret;
@@ -75,7 +75,7 @@ vmw_ioctl_get_param(struct vmw_driver *vmw, uint32_t param, uint64_t *out)
}
int
-vmw_ioctl_supports_streams(struct vmw_driver *vmw)
+vmw_ioctl_supports_streams(struct vmw_customizer *vmw)
{
uint64_t value;
int ret;
@@ -88,7 +88,7 @@ vmw_ioctl_supports_streams(struct vmw_driver *vmw)
}
int
-vmw_ioctl_num_streams(struct vmw_driver *vmw,
+vmw_ioctl_num_streams(struct vmw_customizer *vmw,
uint32_t *ntot, uint32_t *nfree)
{
uint64_t v1, v2;
@@ -109,7 +109,7 @@ vmw_ioctl_num_streams(struct vmw_driver *vmw,
}
int
-vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out)
+vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out)
{
struct drm_vmw_stream_arg s_arg;
int ret;
@@ -125,7 +125,7 @@ vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out)
}
int
-vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id)
+vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id)
{
struct drm_vmw_stream_arg s_arg;
int ret;
@@ -140,7 +140,7 @@ vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id)
}
int
-vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot)
+vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot)
{
struct drm_vmw_cursor_bypass_arg arg;
int ret;
@@ -157,7 +157,7 @@ vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot)
}
struct vmw_dma_buffer *
-vmw_ioctl_buffer_create(struct vmw_driver *vmw, uint32_t size, unsigned *handle)
+vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle)
{
struct vmw_dma_buffer *buf;
union drm_vmw_alloc_dmabuf_arg arg;
@@ -198,7 +198,7 @@ err:
}
void
-vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
+vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
{
struct drm_vmw_unref_dmabuf_arg arg;
@@ -215,7 +215,7 @@ vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
}
void *
-vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf)
+vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
{
void *map;
@@ -236,7 +236,7 @@ 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)
+vmw_ioctl_buffer_unmap(struct vmw_customizer *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
index 0d255d2726f..f43f91e5c0d 100644
--- a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c
@@ -41,7 +41,8 @@ xf86CrtcFuncsRec vmw_screen_crtc_funcs;
static void
vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image)
{
- struct vmw_driver *vmw = modesettingPTR(crtc->scrn)->winsys_priv;
+ struct vmw_customizer *vmw =
+ vmw_customizer(xorg_customizer(crtc->scrn));
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
xf86CrtcFuncsPtr funcs = vmw->cursor_priv;
CursorPtr c = config->cursor;
@@ -53,8 +54,9 @@ vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image)
}
static void
-vmw_screen_cursor_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+vmw_screen_cursor_init(struct vmw_customizer *vmw)
{
+ ScrnInfoPtr pScrn = vmw->pScrn;
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
int i;
@@ -70,9 +72,9 @@ vmw_screen_cursor_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
}
static void
-vmw_screen_cursor_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+vmw_screen_cursor_close(struct vmw_customizer *vmw)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(vmw->pScrn);
int i;
vmw_ioctl_cursor_bypass(vmw, 0, 0);
@@ -82,50 +84,39 @@ vmw_screen_cursor_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
}
static Bool
-vmw_screen_init(ScrnInfoPtr pScrn)
+vmw_screen_init(CustomizerPtr cust, int fd)
{
- modesettingPtr ms = modesettingPTR(pScrn);
- struct vmw_driver *vmw;
-
- vmw = xnfcalloc(1, sizeof(*vmw));
- if (!vmw)
- return FALSE;
-
- vmw->fd = ms->fd;
- ms->winsys_priv = vmw;
+ struct vmw_customizer *vmw = vmw_customizer(cust);
- vmw_screen_cursor_init(pScrn, vmw);
+ vmw->fd = fd;
+ vmw_screen_cursor_init(vmw);
/* if gallium is used then we don't need to do anything more. */
- if (ms->screen)
+ if (xorg_has_gallium(vmw->pScrn))
return TRUE;
- vmw_video_init(pScrn, vmw);
+ vmw_video_init(vmw);
return TRUE;
}
static Bool
-vmw_screen_close(ScrnInfoPtr pScrn)
+vmw_screen_close(CustomizerPtr cust)
{
- modesettingPtr ms = modesettingPTR(pScrn);
- struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_customizer *vmw = vmw_customizer(cust);
if (!vmw)
return TRUE;
- vmw_screen_cursor_close(pScrn, vmw);
+ vmw_screen_cursor_close(vmw);
- vmw_video_close(pScrn, vmw);
-
- ms->winsys_priv = NULL;
- xfree(vmw);
+ vmw_video_close(vmw);
return TRUE;
}
static Bool
-vmw_screen_enter_vt(ScrnInfoPtr pScrn)
+vmw_screen_enter_vt(CustomizerPtr cust)
{
debug_printf("%s: enter\n", __func__);
@@ -133,13 +124,13 @@ vmw_screen_enter_vt(ScrnInfoPtr pScrn)
}
static Bool
-vmw_screen_leave_vt(ScrnInfoPtr pScrn)
+vmw_screen_leave_vt(CustomizerPtr cust)
{
- struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_customizer *vmw = vmw_customizer(cust);
debug_printf("%s: enter\n", __func__);
- vmw_video_stop_all(pScrn, vmw);
+ vmw_video_stop_all(vmw);
return TRUE;
}
@@ -153,18 +144,27 @@ static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL;
static Bool
vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
{
- modesettingPtr ms;
+ struct vmw_customizer *vmw;
+ CustomizerPtr cust;
+
+ vmw = xnfcalloc(1, sizeof(*vmw));
+ if (!vmw)
+ return FALSE;
+
+ cust = &vmw->base;
+
+ cust->winsys_screen_init = vmw_screen_init;
+ cust->winsys_screen_close = vmw_screen_close;
+ cust->winsys_enter_vt = vmw_screen_enter_vt;
+ cust->winsys_leave_vt = vmw_screen_leave_vt;
+ vmw->pScrn = pScrn;
+
+ pScrn->driverPrivate = cust;
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;
- ms->winsys_enter_vt = vmw_screen_enter_vt;
- ms->winsys_leave_vt = vmw_screen_leave_vt;
-
return TRUE;
}
diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
index ff3b992d078..de28f06a475 100644
--- a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
+++ b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c
@@ -226,7 +226,7 @@ static void vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion,
/*
* Local functions.
*/
-static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw);
+static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw);
static int vmw_video_port_init(ScrnInfoPtr pScrn,
struct vmw_video_port *port,
@@ -243,9 +243,9 @@ static int vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
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,
+static int vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size,
struct vmw_video_buffer *out);
-static int vmw_video_buffer_free(struct vmw_driver *vmw,
+static int vmw_video_buffer_free(struct vmw_customizer *vmw,
struct vmw_video_buffer *out);
@@ -267,8 +267,9 @@ static int vmw_video_buffer_free(struct vmw_driver *vmw,
*/
Bool
-vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+vmw_video_init(struct vmw_customizer *vmw)
{
+ ScrnInfoPtr pScrn = vmw->pScrn;
ScreenPtr pScreen = pScrn->pScreen;
XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
XF86VideoAdaptorPtr newAdaptor = NULL;
@@ -345,8 +346,9 @@ vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
*/
Bool
-vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+vmw_video_close(struct vmw_customizer *vmw)
{
+ ScrnInfoPtr pScrn = vmw->pScrn;
struct vmw_video_private *video;
int i;
@@ -387,8 +389,9 @@ vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
*-----------------------------------------------------------------------------
*/
-void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+void vmw_video_stop_all(struct vmw_customizer *vmw)
{
+ ScrnInfoPtr pScrn = vmw->pScrn;
struct vmw_video_private *video = vmw->video_priv;
int i;
@@ -421,7 +424,7 @@ void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
*/
static XF86VideoAdaptorPtr
-vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw)
+vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw)
{
XF86VideoAdaptorPtr adaptor;
struct vmw_video_private *video;
@@ -515,7 +518,7 @@ vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port,
unsigned char *buf, short width,
short height, RegionPtr clipBoxes)
{
- struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
unsigned short w, h;
int i, ret;
@@ -583,7 +586,7 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
unsigned char *buf, short width,
short height, RegionPtr clipBoxes)
{
- struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
struct drm_vmw_control_stream_arg arg;
unsigned short w, h;
int size;
@@ -675,7 +678,7 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port,
static void
vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port)
{
- struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
uint32 id, colorKey, flags;
Bool isAutoPaintColorkey;
int i;
@@ -721,7 +724,7 @@ vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port)
*/
static int
-vmw_video_buffer_alloc(struct vmw_driver *vmw, int size,
+vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size,
struct vmw_video_buffer *out)
{
out->buf = vmw_ioctl_buffer_create(vmw, size, &out->handle);
@@ -764,7 +767,7 @@ vmw_video_buffer_alloc(struct vmw_driver *vmw, int size,
*/
static int
-vmw_video_buffer_free(struct vmw_driver *vmw,
+vmw_video_buffer_free(struct vmw_customizer *vmw,
struct vmw_video_buffer *out)
{
if (out->size == 0)
@@ -814,7 +817,7 @@ vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
Bool sync, RegionPtr clipBoxes, pointer data,
DrawablePtr dst)
{
- struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
struct vmw_video_port *port = data;
debug_printf("%s: enter (%u, %u) (%ux%u) (%u, %u) (%ux%u) (%ux%u)\n", __func__,
@@ -852,7 +855,7 @@ vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y,
static void
vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
{
- struct vmw_driver *vmw = vmw_driver(pScrn);
+ struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
struct vmw_video_port *port = data;
struct drm_vmw_control_stream_arg arg;
int ret;