summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/xorg
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/xorg')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c14
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c1
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c20
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c6
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c1
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h7
-rw-r--r--src/gallium/state_trackers/xorg/xorg_xv.c128
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/surface.c11
8 files changed, 105 insertions, 83 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index fe994d1..c776faa 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -201,7 +201,6 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
templat.width0 = 64;
templat.height0 = 64;
- util_format_get_block(templat.format, &templat.block);
crtcp->cursor_tex = ms->screen->texture_create(ms->screen,
&templat);
@@ -217,7 +216,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
PIPE_TRANSFER_WRITE,
0, 0, 64, 64);
ptr = ms->screen->transfer_map(ms->screen, transfer);
- util_copy_rect(ptr, &crtcp->cursor_tex->block,
+ util_copy_rect(ptr, crtcp->cursor_tex->format,
transfer->stride, 0, 0,
64, 64, (void*)image, 64 * 4, 0, 0);
ms->screen->transfer_unmap(ms->screen, transfer);
@@ -258,7 +257,7 @@ crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image)
return;
err_bo_destroy:
- kms_bo_destroy(crtcp->cursor_bo);
+ kms_bo_destroy(&crtcp->cursor_bo);
}
#endif
@@ -306,10 +305,8 @@ xorg_crtc_cursor_destroy(xf86CrtcPtr crtc)
pipe_texture_reference(&crtcp->cursor_tex, NULL);
#ifdef HAVE_LIBKMS
if (crtcp->cursor_bo)
- kms_bo_destroy(crtcp->cursor_bo);
+ kms_bo_destroy(&crtcp->cursor_bo);
#endif
-
- xfree(crtcp);
}
/*
@@ -321,11 +318,12 @@ crtc_destroy(xf86CrtcPtr crtc)
{
struct crtc_private *crtcp = crtc->driver_private;
- if (crtcp->cursor_tex)
- pipe_texture_reference(&crtcp->cursor_tex, NULL);
+ xorg_crtc_cursor_destroy(crtc);
drmModeFreeCrtc(crtcp->drm_crtc);
+
xfree(crtcp);
+ crtc->driver_private = NULL;
}
static const xf86CrtcFuncsRec crtc_funcs = {
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index fe2e0f6..fd82f4f 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -109,7 +109,6 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
else
template.format = ms->ds_depth_bits_last ?
PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM;
- util_format_get_block(template.format, &template.block);
template.width0 = pDraw->width;
template.height0 = pDraw->height;
template.depth0 = 1;
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 1291591..5391595 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -260,8 +260,7 @@ drv_close_resource_management(ScrnInfoPtr pScrn)
#ifdef HAVE_LIBKMS
if (ms->kms)
- kms_destroy(ms->kms);
- ms->kms = NULL;
+ kms_destroy(&ms->kms);
#endif
return TRUE;
@@ -652,6 +651,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);
}
@@ -685,6 +687,9 @@ drv_leave_vt(int scrnIndex, int flags)
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
int o;
+ if (ms->winsys_leave_vt)
+ ms->winsys_leave_vt(pScrn);
+
for (o = 0; o < config->num_crtc; o++) {
xf86CrtcPtr crtc = config->crtc[o];
@@ -747,6 +752,9 @@ drv_enter_vt(int scrnIndex, int flags)
if (!xf86SetDesiredModes(pScrn))
return FALSE;
+ if (ms->winsys_enter_vt)
+ ms->winsys_enter_vt(pScrn);
+
return TRUE;
}
@@ -768,6 +776,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);
@@ -892,8 +903,7 @@ drv_destroy_front_buffer_kms(ScrnInfoPtr pScrn)
return TRUE;
kms_bo_unmap(ms->root_bo);
- kms_bo_destroy(ms->root_bo);
- ms->root_bo = NULL;
+ kms_bo_destroy(&ms->root_bo);
return TRUE;
}
@@ -939,7 +949,7 @@ drv_create_front_buffer_kms(ScrnInfoPtr pScrn)
return TRUE;
err_destroy:
- kms_bo_destroy(bo);
+ kms_bo_destroy(&bo);
return FALSE;
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index f79e1ef..1769c12 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -203,7 +203,7 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst,
x, y, w, h, dst_pitch);
#endif
- util_copy_rect((unsigned char*)dst, &priv->tex->block, dst_pitch, 0, 0,
+ util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0,
w, h, exa->scrn->transfer_map(exa->scrn, transfer),
transfer->stride, 0, 0);
@@ -243,7 +243,7 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
#endif
util_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer),
- &priv->tex->block, transfer->stride, 0, 0, w, h,
+ priv->tex->format, transfer->stride, 0, 0, w, h,
(unsigned char*)src, src_pitch, 0, 0);
exa->scrn->transfer_unmap(exa->scrn, transfer);
@@ -900,7 +900,6 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &priv->picture_format);
- util_format_get_block(template.format, &template.block);
if (ROUND_UP_TEXTURES && priv->flags == 0) {
template.width0 = util_next_power_of_two(width);
template.height0 = util_next_power_of_two(height);
@@ -986,7 +985,6 @@ xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &dummy);
- util_format_get_block(template.format, &template.block);
template.width0 = width;
template.height0 = height;
template.depth0 = 1;
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index 7cac91e..ba15f8a 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -513,7 +513,6 @@ renderer_clone_texture(struct xorg_renderer *r,
templ.width0 = src->width0;
templ.height0 = src->height0;
templ.depth0 = 1;
- util_format_get_block(format, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
pt = screen->texture_create(screen, &templ);
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index c6c7b2f..c0cfbe6 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -114,6 +114,13 @@ typedef struct _modesettingRec
Bool noEvict;
Bool debug_fallback;
+ /* winsys hocks */
+ Bool (*winsys_screen_init)(ScrnInfoPtr pScr);
+ Bool (*winsys_screen_close)(ScrnInfoPtr pScr);
+ Bool (*winsys_enter_vt)(ScrnInfoPtr pScr);
+ Bool (*winsys_leave_vt)(ScrnInfoPtr pScr);
+ void *winsys_priv;
+
#ifdef DRM_MODE_FEATURE_DIRTYFB
DamagePtr damage;
#endif
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index 8c491c0..6b5a41a 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -172,7 +172,6 @@ create_component_texture(struct pipe_context *pipe,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- util_format_get_block(PIPE_FORMAT_L8_UNORM, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
tex = screen->texture_create(screen, &templ);
@@ -215,17 +214,67 @@ check_yuv_textures(struct xorg_xv_port_priv *priv, int width, int height)
return Success;
}
+static int
+query_image_attributes(ScrnInfoPtr pScrn,
+ int id,
+ unsigned short *w, unsigned short *h,
+ int *pitches, int *offsets)
+{
+ int size, tmp;
+
+ if (*w > IMAGE_MAX_WIDTH)
+ *w = IMAGE_MAX_WIDTH;
+ if (*h > IMAGE_MAX_HEIGHT)
+ *h = IMAGE_MAX_HEIGHT;
+
+ *w = (*w + 1) & ~1;
+ if (offsets)
+ offsets[0] = 0;
+
+ switch (id) {
+ case FOURCC_YV12:
+ *h = (*h + 1) & ~1;
+ size = (*w + 3) & ~3;
+ if (pitches) {
+ pitches[0] = size;
+ }
+ size *= *h;
+ if (offsets) {
+ offsets[1] = size;
+ }
+ tmp = ((*w >> 1) + 3) & ~3;
+ if (pitches) {
+ pitches[1] = pitches[2] = tmp;
+ }
+ tmp *= (*h >> 1);
+ size += tmp;
+ if (offsets) {
+ offsets[2] = size;
+ }
+ size += tmp;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ size = *w << 1;
+ if (pitches)
+ pitches[0] = size;
+ size *= *h;
+ break;
+ }
+
+ return size;
+}
+
static void
copy_packed_data(ScrnInfoPtr pScrn,
struct xorg_xv_port_priv *port,
int id,
unsigned char *buf,
- int srcPitch,
int left,
int top,
- int w, int h)
+ unsigned short w, unsigned short h)
{
- unsigned char *src;
int i, j;
struct pipe_texture **dst = port->yuv[port->current_set];
struct pipe_transfer *ytrans, *utrans, *vtrans;
@@ -235,8 +284,6 @@ copy_packed_data(ScrnInfoPtr pScrn,
int yidx, uidx, vidx;
int y_array_size = w * h;
- src = buf + (top * srcPitch) + (left << 1);
-
ytrans = screen->get_tex_transfer(screen, dst[0],
0, 0, 0,
PIPE_TRANSFER_WRITE,
@@ -258,15 +305,22 @@ copy_packed_data(ScrnInfoPtr pScrn,
switch (id) {
case FOURCC_YV12: {
- for (i = 0; i < w; ++i) {
- for (j = 0; j < h; ++j) {
- /*XXX use src? */
- y1 = buf[j*w + i];
- u = buf[(j/2) * (w/2) + i/2 + y_array_size];
- v = buf[(j/2) * (w/2) + i/2 + y_array_size + y_array_size/4];
- ymap[yidx++] = y1;
- umap[uidx++] = u;
- vmap[vidx++] = v;
+ int pitches[3], offsets[3];
+ unsigned char *y, *u, *v;
+ query_image_attributes(pScrn, FOURCC_YV12,
+ &w, &h, pitches, offsets);
+
+ y = buf + offsets[0];
+ v = buf + offsets[1];
+ u = buf + offsets[2];
+ for (i = 0; i < h; ++i) {
+ for (j = 0; j < w; ++j) {
+ int yoffset = (w*i+j);
+ int ii = (i|1), jj = (j|1);
+ int vuoffset = (w/2)*(ii/2) + (jj/2);
+ ymap[yidx++] = y[yoffset];
+ umap[uidx++] = u[vuoffset];
+ vmap[vidx++] = v[vuoffset];
}
}
}
@@ -513,7 +567,6 @@ put_image(ScrnInfoPtr pScrn,
ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
PixmapPtr pPixmap;
INT32 x1, x2, y1, y2;
- int srcPitch;
BoxRec dstBox;
int ret;
@@ -532,21 +585,12 @@ put_image(ScrnInfoPtr pScrn,
width, height))
return Success;
- switch (id) {
- case FOURCC_UYVY:
- case FOURCC_YUY2:
- case FOURCC_YV12:
- default:
- srcPitch = width << 1;
- break;
- }
-
ret = check_yuv_textures(pPriv, width, height);
if (ret)
return ret;
- copy_packed_data(pScrn, pPriv, id, buf, srcPitch,
+ copy_packed_data(pScrn, pPriv, id, buf,
src_x, src_y, width, height);
if (pDraw->type == DRAWABLE_WINDOW) {
@@ -564,38 +608,6 @@ put_image(ScrnInfoPtr pScrn,
return Success;
}
-static int
-query_image_attributes(ScrnInfoPtr pScrn,
- int id,
- unsigned short *w, unsigned short *h,
- int *pitches, int *offsets)
-{
- int size;
-
- if (*w > IMAGE_MAX_WIDTH)
- *w = IMAGE_MAX_WIDTH;
- if (*h > IMAGE_MAX_HEIGHT)
- *h = IMAGE_MAX_HEIGHT;
-
- *w = (*w + 1) & ~1;
- if (offsets)
- offsets[0] = 0;
-
- switch (id) {
- case FOURCC_UYVY:
- case FOURCC_YUY2:
- case FOURCC_YV12:
- default:
- size = *w << 1;
- if (pitches)
- pitches[0] = size;
- size *= *h;
- break;
- }
-
- return size;
-}
-
static struct xorg_xv_port_priv *
port_priv_create(struct xorg_renderer *r)
{
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index 5059424..0e39a39 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -1,8 +1,8 @@
/**************************************************************************
- *
+ *
* Copyright 2009 Younes Manton.
* 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
@@ -10,11 +10,11 @@
* distribute, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
@@ -22,7 +22,7 @@
* 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.
- *
+ *
**************************************************************************/
#include <assert.h>
@@ -106,7 +106,6 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u
template.width0 = width;
template.height0 = height;
template.depth0 = 1;
- util_format_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
tex = vpipe->screen->texture_create(vpipe->screen, &template);