From marcoz at kemper.freedesktop.org Sat Oct 1 00:58:21 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Sat, 1 Oct 2011 00:58:21 -0700 (PDT) Subject: bigreqsproto: Changes to 'master' Message-ID: <20111001075821.E3F0910009@kemper.freedesktop.org> specs/bigreq.xml | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) New commits: commit cc6006cb0db1373fffe92e9f00a8d06c8387e914 Author: Matt Dew Date: Sat Oct 1 01:52:59 2011 -0600 1 - fix the capitolization of the ID attriutes to match either the or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From alanc at kemper.freedesktop.org Sat Oct 1 08:56:37 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Sat, 1 Oct 2011 08:56:37 -0700 (PDT) Subject: libxtrans: Changes to 'master' Message-ID: <20111001155638.1C73710009@kemper.freedesktop.org> Xtrans.c | 135 ++++++++++----------- Xtrans.h | 20 +-- Xtransint.h | 115 ++++++++++-------- Xtranslcl.c | 369 ++++++++++++++++++++++++++++------------------------------- Xtranssock.c | 336 +++++++++++++++++++++++++---------------------------- Xtranstli.c | 283 +++++++++++++++++++++------------------------ Xtransutil.c | 59 ++++----- transport.c | 3 8 files changed, 650 insertions(+), 670 deletions(-) New commits: commit 0f942e5f015cb3270e6f2e17c308bee894cb5fe3 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Sun Sep 25 11:39:13 2011 -0700 Convert a bunch of sprintf calls to snprintf Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit eb9a8904fbef61a57ff01c90627ead57055ed62b Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Sun Sep 25 11:18:26 2011 -0700 Add const attributes to fix gcc -Wwrite-strings warnings Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit 4e610d4bbcf29cca9dc5dbad29ca820996aaa8c7 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Sun Sep 25 10:59:45 2011 -0700 Fix warning: unused variable 'tmpport' with various configurations Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit a74c5d915c3095059356f83d1b845192e5c472c2 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Sun Sep 25 10:57:00 2011 -0700 Add _X_UNUSED attributes to silence unused parameter warnings Not all the transport variants use all the arguments to every function, but as long as one transport type needs it, they all get the args passed. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit 64f765de138cb9b757df315469b3136d32222ea2 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Sat Sep 24 00:04:40 2011 -0700 Mark __xtransname strings for debug messages as const char * Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit ea921932dae7049b231bead7f8f3f088d7beaf9e Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Sep 23 23:03:09 2011 -0700 Fix unused variable warnings Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit c1968d10f97d62ac05d698822c2688151f70a9eb Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Sep 23 22:59:11 2011 -0700 Fix warning: ISO C90 forbids mixed declarations and code Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit 225c45b3accab56fab361104a3d14b80f6cec954 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Sep 23 22:57:56 2011 -0700 Fix printf format string warnings Now that prmsg lets arguments types actually be checked, fix the warnings found. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit b1b69ce8e8e4fe0f190c8bd85b537309e71055c8 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Sep 23 22:35:03 2011 -0700 Convert PRMSG macro to prmsg inline function Allows using varargs to have the correct number of arguments passed to get rid of the many gcc warnings about variable printf format strings, and to reduce the duplication from having 5 implementations of the PRMSG macro depending on the debug options defined & output method used. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit cbdb434033da1725a69014cc6e4d89c691a6fd95 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Sat Sep 24 07:43:07 2011 -0700 Fix warnings about static functions declared but never defined Add #define XTRANS_TRANSPORT_C to transport.c and check for it before making static function declarations and other bits needed only when compiling the Xtrans code itself, not from other sources that include the Xtransint.h header for the struct definitions. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From alanc at kemper.freedesktop.org Sat Oct 1 09:03:30 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Sat, 1 Oct 2011 09:03:30 -0700 (PDT) Subject: xdm: Changes to 'master' Message-ID: <20111001160330.6E47E10009@kemper.freedesktop.org> Makefile.am | 9 +++++++-- configure.ac | 16 ++++++++++++++++ greeter/greet.c | 4 ++-- greeter/verify.c | 6 +++--- include/dm.h | 10 +++++----- include/greet.h | 8 ++++---- xdm.service.in | 2 ++ xdm/Makefile.am | 4 ++-- xdm/access.c | 2 +- xdm/auth.c | 2 +- xdm/dm.c | 2 +- xdm/file.c | 2 +- xdm/resource.c | 29 +++++++++++++++-------------- xdm/server.c | 4 ++-- xdm/session.c | 10 ++++++++++ xdm/util.c | 10 +++++----- xdm/xdmauth.c | 6 +++--- xdm/xdmcp.c | 10 +++++----- 18 files changed, 85 insertions(+), 51 deletions(-) New commits: commit 8eee942be0db913511b4c53f94829e1201dfdf00 Author: Micha?? G??rny <mgorny at gentoo.org> Date: Wed Sep 28 21:25:17 2011 +0200 Support systemd startup notification. If libsystemd-daemon support is enabled, xdm uses it to announce its startup as soon as the session is established. This gives the user opportunity to delay I/O-intensive operations until the X server is started so that they would not interfere with its loading while keeping the machine busy when user types in his/her login. Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Gaetan Nadon <memsize at videotron.ca> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit c43eb799774743bc50233eff6643c51a5fbe6899 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Tue Sep 20 19:22:48 2011 -0700 Fix warnings about printing longs with int type format strings Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 618039261b0c7f14eb3b32c8f636464369724407 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Tue Sep 20 19:11:20 2011 -0700 Mark some chars as const to fix gcc -Wwrite-strings warnings Can't fix all the warnings, due to the Xt API, but can fix a bunch. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From kettenis at kemper.freedesktop.org Sun Oct 2 05:54:16 2011 From: kettenis at kemper.freedesktop.org (Mark Kettenis) Date: Sun, 2 Oct 2011 05:54:16 -0700 (PDT) Subject: xf86-video-chips: Changes to 'master' Message-ID: <20111002125416.21507D8002@kemper.freedesktop.org> src/ct_driver.h | 2 ++ 1 file changed, 2 insertions(+) New commits: commit 5f8a7320123255408b393eab9ecfae783920622a Author: Mark Kettenis <kettenis at openbsd.org> Date: Mon Sep 26 21:26:26 2011 +0200 PciTag is unused when using libpciaccess Signed-off-by: Mark Kettenis <kettenis at openbsd.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Julien Cristau <jcristau at debian.org> From jeremyhu at kemper.freedesktop.org Sun Oct 2 13:36:26 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 2 Oct 2011 13:36:26 -0700 (PDT) Subject: libXt: Changes to 'master' Message-ID: <20111002203626.1C4A8D8002@kemper.freedesktop.org> src/Varargs.c | 2 ++ 1 file changed, 2 insertions(+) New commits: commit 6c0b44caa9b424c7e05327e8ddc9273b87a0f81f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 2 13:35:26 2011 -0700 LP64 fix for TypedArgToArg() https://bugs.freedesktop.org/show_bug.cgi?id=12662 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From ickle at kemper.freedesktop.org Sun Oct 2 15:28:59 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 2 Oct 2011 15:28:59 -0700 (PDT) Subject: xf86-video-intel: 13 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_io.c src/sna/sna_reg.h src/sna/sna_render.c src/sna/sna_render.h Message-ID: <20111002222859.D8A88D8002@kemper.freedesktop.org> src/sna/gen2_render.c | 83 +++++++++++++++++ src/sna/gen3_render.c | 85 ++++++++++++++++++ src/sna/kgem.c | 85 ++++++++++++++---- src/sna/kgem.h | 11 ++ src/sna/sna_accel.c | 233 ++++++++++++++++++++++++++++++++++++++++---------- src/sna/sna_blt.c | 80 ++++++++++------- src/sna/sna_io.c | 2 src/sna/sna_reg.h | 3 src/sna/sna_render.c | 21 ++++ src/sna/sna_render.h | 4 10 files changed, 512 insertions(+), 95 deletions(-) New commits: commit d8c96a6a1d50cd3dd40fd4b78958c8f78337a2fb Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 2 12:57:53 2011 +0100 sna/blt: Use SETUP_MONO to reduce the number of fill relocations Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 43a7cad..43aaef0 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -2003,6 +2003,87 @@ gen2_render_fill(struct sna *sna, uint8_t alu, return TRUE; } +static Bool +gen2_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + +static Bool +gen2_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint8_t alu) +{ + struct sna_composite_op tmp; + +#if NO_FILL_BOXES + return gen2_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); +#endif + + /* Prefer to use the BLT if already engaged */ + if (sna->kgem.mode != KGEM_RENDER && + gen2_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + + /* Must use the BLT if we can't RENDER... */ + if (!(alu == GXcopy || alu == GXclear) || + dst->drawable.width > 2048 || dst->drawable.height > 2048 || + bo->pitch > 8192) + return gen2_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); + + if (alu == GXclear) + color = 0; + + memset(&tmp, 0, sizeof(tmp)); + tmp.op = color == 0 ? PictOpClear : PictOpSrc; + tmp.dst.pixmap = dst; + tmp.dst.width = dst->drawable.width; + tmp.dst.height = dst->drawable.height; + tmp.dst.format = sna_format_for_depth(dst->drawable.depth); + tmp.dst.bo = bo; + tmp.floats_per_vertex = 2; + + tmp.src.u.gen2.pixel = + sna_rgba_for_color(color, dst->drawable.depth); + + if (!kgem_check_bo(&sna->kgem, bo, NULL)) { + kgem_submit(&sna->kgem); + if (gen2_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + } + + gen2_emit_fill_state(sna, &tmp); + gen2_get_rectangles(sna, &tmp, 1); + DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, pixel)); + OUT_VERTEX(x2); + OUT_VERTEX(y2); + OUT_VERTEX(x1); + OUT_VERTEX(y2); + OUT_VERTEX(x1); + OUT_VERTEX(y1); + gen2_vertex_flush(sna); + + return TRUE; +} + static void gen2_render_copy_setup_source(struct sna_composite_channel *channel, PixmapPtr pixmap, @@ -2297,8 +2378,8 @@ Bool gen2_render_init(struct sna *sna) render->composite = gen2_render_composite; render->composite_spans = gen2_render_composite_spans; render->fill_boxes = gen2_render_fill_boxes; - render->fill = gen2_render_fill; + render->fill_one = gen2_render_fill_one; render->copy = gen2_render_copy; render->copy_boxes = gen2_render_copy_boxes; diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index bac0353..65176ed 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3659,6 +3659,90 @@ gen3_render_fill(struct sna *sna, uint8_t alu, return TRUE; } + +static Bool +gen3_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + +static Bool +gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint8_t alu) +{ + struct sna_composite_op tmp; + +#if NO_FILL_BOXES + return gen3_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); +#endif + + /* Prefer to use the BLT if already engaged */ + if (sna->kgem.mode != KGEM_RENDER && + gen3_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + + /* Must use the BLT if we can't RENDER... */ + if (!(alu == GXcopy || alu == GXclear) || + dst->drawable.width > 2048 || dst->drawable.height > 2048 || + bo->pitch > 8192) + return gen3_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); + + if (alu == GXclear) + color = 0; + + memset(&tmp, 0, sizeof(tmp)); + tmp.op = color == 0 ? PictOpClear : PictOpSrc; + tmp.dst.pixmap = dst; + tmp.dst.width = dst->drawable.width; + tmp.dst.height = dst->drawable.height; + tmp.dst.format = sna_format_for_depth(dst->drawable.depth); + tmp.dst.bo = bo; + tmp.floats_per_vertex = 2; + + tmp.src.u.gen3.type = SHADER_CONSTANT; + tmp.src.u.gen3.mode = + sna_rgba_for_color(color, dst->drawable.depth); + + if (!kgem_check_bo(&sna->kgem, bo, NULL)) { + kgem_submit(&sna->kgem); + if (gen3_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + } + + gen3_emit_composite_state(sna, &tmp); + gen3_align_vertex(sna, &tmp); + gen3_get_rectangles(sna, &tmp, 1); + DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, pixel)); + OUT_VERTEX(x2); + OUT_VERTEX(y2); + OUT_VERTEX(x1); + OUT_VERTEX(y2); + OUT_VERTEX(x1); + OUT_VERTEX(y1); + gen3_vertex_flush(sna); + + return TRUE; +} + static void gen3_render_flush(struct sna *sna) { gen3_vertex_finish(sna, TRUE); @@ -3683,6 +3767,7 @@ Bool gen3_render_init(struct sna *sna) render->fill_boxes = gen3_render_fill_boxes; render->fill = gen3_render_fill; + render->fill_one = gen3_render_fill_one; render->reset = gen3_render_reset; render->flush = gen3_render_flush; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 1b43a8b..a6e639b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1650,6 +1650,29 @@ sna_spans_extents(DrawablePtr drawable, GCPtr gc, return box_empty(&box); } +static struct sna_damage ** +reduce_damage(DrawablePtr drawable, + struct sna_damage **damage, + const BoxRec *box) +{ + PixmapPtr pixmap = get_drawable_pixmap(drawable); + int16_t dx, dy; + BoxRec r; + + if (*damage == NULL) + return damage; + + get_drawable_deltas(drawable, pixmap, &dx, &dy); + + r = *box; + r.x1 += dx; r.x2 += dx; + r.y1 += dy; r.y2 += dy; + if (sna_damage_contains_box(*damage, &r) == PIXMAN_REGION_IN) + return NULL; + else + return damage; +} + static void sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect); @@ -1702,13 +1725,14 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, if (sna_drawable_use_gpu_bo(drawable, &extents) && sna_fill_spans_blt(drawable, priv->gpu_bo, - priv->gpu_only ? NULL : &priv->gpu_damage, + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, &extents), gc, n, pt, width, sorted)) return; if (sna_drawable_use_cpu_bo(drawable, &extents) && sna_fill_spans_blt(drawable, - priv->cpu_bo, &priv->cpu_damage, + priv->cpu_bo, + reduce_damage(drawable, &priv->cpu_damage, &extents), gc, n, pt, width, sorted)) return; } else if (gc->fillStyle == FillTiled) { @@ -2556,6 +2580,33 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, DBG(("%s x %d [(%d, %d)+(%d, %d)...]\n", __FUNCTION__, n, rect->x, rect->y, rect->width, rect->height)); + if (n == 1 && REGION_NUM_RECTS(clip) == 1) { + BoxPtr box = REGION_RECTS(clip); + BoxRec r; + bool success = true; + + r.x1 = rect->x + drawable->x; + r.y1 = rect->y + drawable->y; + r.x2 = bound(r.x1, rect->width); + r.y2 = bound(r.y1, rect->height); + if (box_intersect(&r, box)) { + get_drawable_deltas(drawable, pixmap, &dx, &dy); + r.x1 += dx; r.y1 += dy; + r.x2 += dx; r.y2 += dy; + if (sna->render.fill_one(sna, pixmap, bo, pixel, + r.x1, r.y1, r.x2, r.y2, + gc->alu)) { + if (damage) { + assert_pixmap_contains_box(pixmap, &r); + sna_damage_add_box(damage, &r); + } + } else + success = false; + } + + return success; + } + if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, pixel)) { DBG(("%s: unsupported blt\n", __FUNCTION__)); return FALSE; @@ -2935,14 +2986,14 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) if (sna_drawable_use_gpu_bo(draw, &extents) && sna_poly_fill_rect_blt(draw, priv->gpu_bo, - priv->gpu_only ? NULL : &priv->gpu_damage, + priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, &extents), gc, n, rect)) return; if (sna_drawable_use_cpu_bo(draw, &extents) && sna_poly_fill_rect_blt(draw, priv->cpu_bo, - &priv->cpu_damage, + reduce_damage(draw, &priv->cpu_damage, &extents), gc, n, rect)) return; } else if (gc->fillStyle == FillTiled) { @@ -2953,14 +3004,14 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) if (sna_drawable_use_gpu_bo(draw, &extents) && sna_poly_fill_rect_tiled(draw, priv->gpu_bo, - priv->gpu_only ? NULL : &priv->gpu_damage, + priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, &extents), gc, n, rect)) return; if (sna_drawable_use_cpu_bo(draw, &extents) && sna_poly_fill_rect_tiled(draw, priv->cpu_bo, - &priv->cpu_damage, + reduce_damage(draw, &priv->cpu_damage, &extents), gc, n, rect)) return; } diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 5abfb02..86388a8 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -117,10 +117,9 @@ static bool sna_blt_fill_init(struct sna *sna, struct kgem *kgem = &sna->kgem; int pitch; - blt->bo[0] = bo; - blt->cmd = XY_COLOR_BLT_CMD; + blt->cmd = XY_SETUP_MONO_PATTERN_SL_BLT; if (bpp == 32) blt->cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; @@ -133,7 +132,7 @@ static bool sna_blt_fill_init(struct sna *sna, return FALSE; blt->overwrites = alu == GXcopy || alu == GXclear; - blt->br13 = (fill_ROP[alu] << 16) | pitch; + blt->br13 = 1<<31 | (fill_ROP[alu] << 16) | pitch; switch (bpp) { default: assert(0); case 32: blt->br13 |= 1 << 25; /* RGB8888 */ @@ -144,8 +143,29 @@ static bool sna_blt_fill_init(struct sna *sna, blt->pixel = pixel; kgem_set_mode(kgem, KGEM_BLT); - if (!kgem_check_bo_fenced(kgem, bo, NULL)) + if (!kgem_check_bo_fenced(kgem, bo, NULL) || + !kgem_check_batch(kgem, 3)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } + + { + uint32_t *b = kgem->batch + kgem->nbatch; + b[0] = blt->cmd; + b[1] = blt->br13; + b[2] = 0; + b[3] = 0; + b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, bo, + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = pixel; + b[6] = pixel; + b[7] = 0; + b[8] = 0; + kgem->nbatch += 9; + } return TRUE; } @@ -165,36 +185,34 @@ static void sna_blt_fill_one(struct sna *sna, assert(y >= 0); assert((y+height) * blt->bo[0]->pitch <= blt->bo[0]->size); - /* All too frequently one blt completely overwrites the previous */ - if (kgem->nbatch >= 6 && - blt->overwrites && - kgem->batch[kgem->nbatch-6] == blt->cmd && - kgem->batch[kgem->nbatch-4] == ((uint32_t)y << 16 | (uint16_t)x) && - kgem->batch[kgem->nbatch-3] == ((uint32_t)(y+height) << 16 | (uint16_t)(x+width)) && - kgem->reloc[kgem->nreloc-1].target_handle == blt->bo[0]->handle) { - DBG(("%s: replacing last fill\n", __FUNCTION__)); - kgem->batch[kgem->nbatch-5] = blt->br13; - kgem->batch[kgem->nbatch-1] = blt->pixel; - return; - } - - if (!kgem_check_batch(kgem, 6) || - kgem->nreloc + 1 > KGEM_RELOC_SIZE(kgem)) + if (!kgem_check_batch(kgem, 3)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + + b = kgem->batch + kgem->nbatch; + b[0] = blt->cmd; + b[1] = blt->br13; + b[2] = 0; + b[3] = 0; + b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, blt->bo[0], + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = blt->pixel; + b[6] = blt->pixel; + b[7] = 0; + b[8] = 0; + kgem->nbatch += 9; + } b = kgem->batch + kgem->nbatch; - b[0] = blt->cmd; - b[1] = blt->br13; - b[2] = (y << 16) | x; - b[3] = ((y + height) << 16) | (x + width); - b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, - blt->bo[0], - I915_GEM_DOMAIN_RENDER << 16 | - I915_GEM_DOMAIN_RENDER | - KGEM_RELOC_FENCED, - 0); - b[5] = blt->pixel; - kgem->nbatch += 6; + b[0] = XY_SCANLINE_BLT; + if (kgem->gen >= 40 && blt->bo[0]->tiling) + b[0] |= 1 << 11; + b[1] = (y << 16) | x; + b[2] = ((y + height) << 16) | (x + width); + kgem->nbatch += 3; } static Bool sna_blt_copy_init(struct sna *sna, diff --git a/src/sna/sna_reg.h b/src/sna/sna_reg.h index f6e5397..f16c64d 100644 --- a/src/sna/sna_reg.h +++ b/src/sna/sna_reg.h @@ -78,7 +78,10 @@ #define COLOR_BLT_CMD ((2<<29)|(0x40<<22)|(0x3)) #define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|(0x4)) +#define XY_SETUP_BLT_CMD ((2<<29)|(1<<22)|6) +#define XY_SETUP_MONO_PATTERN_SL_BLT ((2<<29)|(0x11<<22)|7) #define XY_SETUP_CLIP_BLT_CMD ((2<<29)|(3<<22)|1) +#define XY_SCANLINE_BLT ((2<<29)|(0x25<<22)|1) #define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6) #define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|0x4) #define XY_PAT_BLT_IMMEDIATE ((2<<29)|(0x72<<22)) diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index 292853a..7ab0de1 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -179,6 +179,26 @@ no_render_fill(struct sna *sna, uint8_t alu, tmp); } +static Bool +no_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + DBG(("%s (alu=%d, color=%08x) (%d,%d), (%d, %d)\n", + __FUNCTION__, alu, color, x1, y1, x2, y2)); + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + static void no_render_reset(struct sna *sna) { (void)sna; @@ -216,6 +236,7 @@ void no_render_init(struct sna *sna) render->fill_boxes = no_render_fill_boxes; render->fill = no_render_fill; + render->fill_one = no_render_fill_one; render->reset = no_render_reset; render->flush = no_render_flush; diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 80a9d00..e46f027 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -201,6 +201,10 @@ struct sna_render { PixmapPtr dst, struct kgem_bo *dst_bo, uint32_t color, struct sna_fill_op *tmp); + Bool (*fill_one)(struct sna *sna, PixmapPtr dst, struct kgem_bo *dst_bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu); Bool (*copy_boxes)(struct sna *sna, uint8_t alu, PixmapPtr src, struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy, commit 4d227d43f0dfca1fa1822207d68539635aac37b3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 2 12:03:21 2011 +0100 sna/accel: Correct syntax for constifying BoxPtr Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 524f76d..1b43a8b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -559,7 +559,7 @@ done: } static inline Bool -_sna_drawable_use_gpu_bo(DrawablePtr drawable, const BoxPtr box) +_sna_drawable_use_gpu_bo(DrawablePtr drawable, const BoxRec *box) { PixmapPtr pixmap = get_drawable_pixmap(drawable); struct sna_pixmap *priv = sna_pixmap(pixmap); @@ -588,7 +588,7 @@ _sna_drawable_use_gpu_bo(DrawablePtr drawable, const BoxPtr box) } static inline Bool -sna_drawable_use_gpu_bo(DrawablePtr drawable, const BoxPtr box) +sna_drawable_use_gpu_bo(DrawablePtr drawable, const BoxRec *box) { Bool ret = _sna_drawable_use_gpu_bo(drawable, box); DBG(("%s((%d, %d), (%d, %d)) = %d\n", __FUNCTION__, @@ -597,7 +597,7 @@ sna_drawable_use_gpu_bo(DrawablePtr drawable, const BoxPtr box) } static inline Bool -_sna_drawable_use_cpu_bo(DrawablePtr drawable, const BoxPtr box) +_sna_drawable_use_cpu_bo(DrawablePtr drawable, const BoxRec *box) { PixmapPtr pixmap = get_drawable_pixmap(drawable); struct sna_pixmap *priv = sna_pixmap(pixmap); @@ -625,7 +625,7 @@ _sna_drawable_use_cpu_bo(DrawablePtr drawable, const BoxPtr box) } static inline Bool -sna_drawable_use_cpu_bo(DrawablePtr drawable, const BoxPtr box) +sna_drawable_use_cpu_bo(DrawablePtr drawable, const BoxRec *box) { Bool ret = _sna_drawable_use_cpu_bo(drawable, box); DBG(("%s((%d, %d), (%d, %d)) = %d\n", __FUNCTION__, @@ -1462,7 +1462,7 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, } static Bool -box_intersect(BoxPtr a, const BoxPtr b) +box_intersect(BoxPtr a, const BoxRec *b) { if (a->x1 < b->x1) a->x1 = b->x1; @@ -2747,7 +2747,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, } if (REGION_NUM_RECTS(clip) == 1) { - const BoxPtr box = REGION_RECTS(clip); + const BoxRec *box = REGION_RECTS(clip); while (n--) { BoxRec r; commit 3dd80524160d6b6cf0fb668afcc766f2bc6f8383 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 2 09:59:03 2011 +0100 sna/accel: Only throttle after flushing Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 69e6dec..524f76d 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3589,13 +3589,13 @@ static void sna_accel_throttle(struct sna *sna) void sna_accel_block_handler(struct sna *sna) { - if (sna_accel_do_flush(sna)) + if (sna_accel_do_flush(sna)) { sna_accel_flush(sna); + sna_accel_throttle(sna); + } if (sna_accel_do_expire(sna)) sna_accel_expire(sna); - - sna_accel_throttle(sna); } void sna_accel_wakeup_handler(struct sna *sna) commit 04b8f0a5a16ff71c5e55e0281dbcaa32554703ec Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 2 09:36:38 2011 +0100 sna/accel: Add a compile option to force flushing on every blockhandler Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 008e552..69e6dec 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -56,6 +56,7 @@ #define FORCE_GPU_ONLY 0 #define FORCE_FALLBACK 0 +#define FORCE_FLUSH 0 #define USE_SPANS 0 @@ -3310,14 +3311,6 @@ static void sna_deferred_free(struct sna *sna) } } -static uint64_t read_timer(int fd) -{ - uint64_t count = 0; - int ret = read(fd, &count, sizeof(count)); - return count; - (void)ret; -} - static struct sna_pixmap *sna_accel_scanout(struct sna *sna) { PixmapPtr front = sna->shadow ? sna->shadow : sna->front; @@ -3325,10 +3318,18 @@ static struct sna_pixmap *sna_accel_scanout(struct sna *sna) return priv && priv->gpu_bo ? priv : NULL; } -#if HAVE_SYS_TIMERFD_H +#if HAVE_SYS_TIMERFD_H && !FORCE_FLUSH #include <sys/timerfd.h> #include <errno.h> +static uint64_t read_timer(int fd) +{ + uint64_t count = 0; + int ret = read(fd, &count, sizeof(count)); + return count; + (void)ret; +} + static void _sna_accel_disarm_timer(struct sna *sna, int id) { struct itimerspec to; commit 32cef71efe231692f7b24f66913a8ae57bc00aa8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 2 08:55:55 2011 +0100 sna/accel: Add an compile option to disable use of spans Using spans has a tremendous effect (~100x) on x11perf, some good but mostly bad. However, in reality operations are mixed and so preventing migration on alternate opertaions is a win. In the x11perf slowdowns, it appears to be CPU bound and so it seems like there should be plenty of scope for recovering the lost performance. However, for the time being, just go back to the old fallbacks. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 683bd1b..008e552 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -57,6 +57,8 @@ #define FORCE_GPU_ONLY 0 #define FORCE_FALLBACK 0 +#define USE_SPANS 0 + DevPrivateKeyRec sna_pixmap_index; #define PM_IS_SOLID(_draw, _pm) \ @@ -2155,7 +2157,7 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, return; } - if (can_fill_spans(drawable, gc) && + if (USE_SPANS && can_fill_spans(drawable, gc) && sna_drawable_use_gpu_bo(drawable, &extents)) { DBG(("%s: converting line into spans\n", __FUNCTION__)); switch (gc->lineStyle) { @@ -2390,7 +2392,7 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) } /* XXX Do we really want to base this decision on the amalgam ? */ - if (can_fill_spans(drawable, gc) && + if (USE_SPANS && can_fill_spans(drawable, gc) && sna_drawable_use_gpu_bo(drawable, &extents)) { void (*line)(DrawablePtr, GCPtr, int, int, DDXPointPtr); int i; @@ -2515,7 +2517,7 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) } /* For "simple" cases use the miPolyArc to spans path */ - if (arc_to_spans(gc, n) && can_fill_spans(drawable, gc) && + if (USE_SPANS && arc_to_spans(gc, n) && can_fill_spans(drawable, gc) && sna_drawable_use_gpu_bo(drawable, &extents)) { DBG(("%s: converting arcs into spans\n", __FUNCTION__)); miPolyArc(drawable, gc, n, arc); commit dc1ec0dd1a5f66114ee4249309d3a283ad84d584 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 20:11:47 2011 +0100 sna/accel: Only disable the flush migitration if nothing changed Previously we ignored updating the scanout in place, and so we were not amoritizing the shadow cost of common core rendering operations. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index e837050..683bd1b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3428,14 +3428,19 @@ static void _sna_accel_disarm_timer(struct sna *sna, int id) { } static void sna_accel_flush(struct sna *sna) { struct sna_pixmap *priv = sna_accel_scanout(sna); + bool nothing_to_do = + priv->cpu_damage == NULL && priv->gpu_bo->rq == NULL; - DBG(("%s (time=%ld)\n", __FUNCTION__, (long)GetTimeInMillis())); + DBG(("%s (time=%ld), nothing_to_do=%d\n", + __FUNCTION__, (long)GetTimeInMillis(), nothing_to_do)); + + if (nothing_to_do) { + _sna_accel_disarm_timer(sna, FLUSH_TIMER); + return; + } sna_pixmap_move_to_gpu(priv->pixmap); kgem_bo_flush(&sna->kgem, priv->gpu_bo); - - if (priv->gpu_bo->rq == NULL) - _sna_accel_disarm_timer(sna, FLUSH_TIMER); } static void sna_accel_expire(struct sna *sna) commit c6acf1325833b8679ef09ab74f0cb0fd82a8cd92 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 11:26:54 2011 +0100 sna/accel: Micro-optimise sna_fill_spans_blt Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 60ac9dd..e837050 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1504,10 +1504,11 @@ sna_fill_spans_blt(DrawablePtr drawable, { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); - struct sna_fill_op fill; - BoxPtr extents, clip; - int nclip; + BoxPtr extents; + int nclip = REGION_NUM_RECTS(gc->pCompositeClip); + int need_translation = !gc->miTranslate; int16_t dx, dy; + struct sna_fill_op fill; if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return false; @@ -1525,7 +1526,7 @@ sna_fill_spans_blt(DrawablePtr drawable, int y = pt->y; int X2 = X1 + (int)*width; - if (!gc->miTranslate) { + if (need_translation) { X1 += drawable->x; X2 += drawable->x; y += drawable->y; @@ -1546,22 +1547,19 @@ sna_fill_spans_blt(DrawablePtr drawable, if (X1 >= X2) continue; - nclip = REGION_NUM_RECTS(gc->pCompositeClip); + y += dy; if (nclip == 1) { X1 += dx; - if (X1 < 0) - X1 = 0; X2 += dx; - if (X2 > pixmap->drawable.width) - X2 = pixmap->drawable.width; + assert(X1 >= 0 && X2 <= pixmap->drawable.width); if (X2 > X1) { - fill.blt(sna, &fill, X1, y+dy, X2-X1, 1); + fill.blt(sna, &fill, X1, y, X2-X1, 1); if (damage) { BoxRec box; box.x1 = X1; box.x2 = X2; - box.y1 = y + dy; + box.y1 = y; box.y2 = box.y1 + 1; assert_pixmap_contains_box(pixmap, &box); @@ -1569,8 +1567,9 @@ sna_fill_spans_blt(DrawablePtr drawable, } } } else { - clip = REGION_RECTS(gc->pCompositeClip); - while (nclip--) { + int nc = nclip; + BoxPtr clip = REGION_RECTS(gc->pCompositeClip); + while (nc--) { if (clip->y1 <= y && y < clip->y2) { int x1 = clip->x1; int x2 = clip->x2; @@ -1588,13 +1587,12 @@ sna_fill_spans_blt(DrawablePtr drawable, if (x2 > x1) { fill.blt(sna, &fill, - x1, y + dy, - x2-x1, 1); + x1, y, x2-x1, 1); if (damage) { BoxRec box; box.x1 = x1; - box.y1 = y + dy; + box.y1 = y; box.x2 = x2; box.y2 = box.y1 + 1; commit 8029765515399b130bee18db0a2830eb83f47a07 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 11:19:49 2011 +0100 sna/accel: Don't attempt converting to spans if we will only fallback As the span code does not yet handle plane masks or stippling, it is disadvantageous to convert to spans only to fallback. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4f50c81..60ac9dd 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1652,6 +1652,15 @@ sna_spans_extents(DrawablePtr drawable, GCPtr gc, static void sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect); +static bool +can_fill_spans(DrawablePtr drawable, GCPtr gc) +{ + if (!PM_IS_SOLID(drawable, gc->planemask)) + return false; + + return gc->fillStyle == FillSolid || gc->fillStyle == FillTiled; +} + static void sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, DDXPointPtr pt, int *width, int sorted) @@ -2148,7 +2157,8 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, return; } - if (sna_drawable_use_gpu_bo(drawable, &extents)) { + if (can_fill_spans(drawable, gc) && + sna_drawable_use_gpu_bo(drawable, &extents)) { DBG(("%s: converting line into spans\n", __FUNCTION__)); switch (gc->lineStyle) { case LineSolid: @@ -2382,7 +2392,8 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) } /* XXX Do we really want to base this decision on the amalgam ? */ - if (sna_drawable_use_gpu_bo(drawable, &extents)) { + if (can_fill_spans(drawable, gc) && + sna_drawable_use_gpu_bo(drawable, &extents)) { void (*line)(DrawablePtr, GCPtr, int, int, DDXPointPtr); int i; @@ -2487,6 +2498,7 @@ arc_to_spans(GCPtr gc, int n) static void sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) { + struct sna *sna = to_sna_from_drawable(drawable); BoxRec extents; RegionRec region; @@ -2496,14 +2508,23 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, extents.x1, extents.y1, extents.x2, extents.y2)); + if (FORCE_FALLBACK) + goto fallback; + + if (sna->kgem.wedged) { + DBG(("%s: fallback -- wedged\n", __FUNCTION__)); + goto fallback; + } + /* For "simple" cases use the miPolyArc to spans path */ - if (arc_to_spans(gc, n) && + if (arc_to_spans(gc, n) && can_fill_spans(drawable, gc) && sna_drawable_use_gpu_bo(drawable, &extents)) { DBG(("%s: converting arcs into spans\n", __FUNCTION__)); miPolyArc(drawable, gc, n, arc); return; } +fallback: RegionInit(®ion, &extents, 1); if (gc->pCompositeClip) RegionIntersect(®ion, ®ion, gc->pCompositeClip); commit cd11bd69f4c1b961593886945946c7d7c9269900 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 10:45:18 2011 +0100 sna/accel: Use miPolyArc to convert arcs into spans for gpu bo This is actually tricker than it looks since miPolyArc() sometimes uses an intermediate bitmap which performs worse than the fbPolyArc() fallback. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 2614e47..4f50c81 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2469,6 +2469,21 @@ sna_poly_arc_extents(DrawablePtr drawable, GCPtr gc, return box_empty(&box); } +static bool +arc_to_spans(GCPtr gc, int n) +{ + if (gc->lineStyle != LineSolid) + return false; + + if (gc->lineWidth == 0) + return true; + + if (n == 1) + return true; + + return false; +} + static void sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) { @@ -2481,6 +2496,14 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, extents.x1, extents.y1, extents.x2, extents.y2)); + /* For "simple" cases use the miPolyArc to spans path */ + if (arc_to_spans(gc, n) && + sna_drawable_use_gpu_bo(drawable, &extents)) { + DBG(("%s: converting arcs into spans\n", __FUNCTION__)); + miPolyArc(drawable, gc, n, arc); + return; + } + RegionInit(®ion, &extents, 1); if (gc->pCompositeClip) RegionIntersect(®ion, ®ion, gc->pCompositeClip); commit d07256cc3360cf94d131d9a1b24d9f1c6a70ee04 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 10:42:45 2011 +0100 sna/accel: Convert segments into spans similarly to PolyLine Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 8f3aabc..2614e47 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2381,6 +2381,33 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) return; } + /* XXX Do we really want to base this decision on the amalgam ? */ + if (sna_drawable_use_gpu_bo(drawable, &extents)) { + void (*line)(DrawablePtr, GCPtr, int, int, DDXPointPtr); + int i; + + DBG(("%s: converting segments into spans\n", __FUNCTION__)); + + switch (gc->lineStyle) { + default: + case LineSolid: + if (gc->lineWidth == 0) + line = miZeroLine; + else + line = miWideLine; + break; + case LineOnOffDash: + case LineDoubleDash: + line = miWideDash; + break; + } + + for (i = 0; i < n; i++) + line(drawable, gc, CoordModeOrigin, 2, + (DDXPointPtr)&seg[i]); + return; + } + fallback: DBG(("%s: fallback\n", __FUNCTION__)); RegionInit(®ion, &extents, 1); commit d09a229e32468c810f5056bfd0043f2fb68038d3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 10:01:21 2011 +0100 sna/accel: Use the mi*Line routines to convert the line into spans for gpu bo Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 55dd2cd..8f3aabc 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2148,6 +2148,23 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, return; } + if (sna_drawable_use_gpu_bo(drawable, &extents)) { + DBG(("%s: converting line into spans\n", __FUNCTION__)); + switch (gc->lineStyle) { + case LineSolid: + if (gc->lineWidth == 0) + miZeroLine(drawable, gc, mode, n, pt); + else + miWideLine(drawable, gc, mode, n, pt); + break; + case LineOnOffDash: + case LineDoubleDash: + miWideDash(drawable, gc, mode, n, pt); + break; + } + return; + } + fallback: DBG(("%s: fallback\n", __FUNCTION__)); RegionInit(®ion, &extents, 1); commit e7a662b92e3012735f7a3d72d4f7860ca61a3810 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 09:26:52 2011 +0100 sna: Sort partials by remaining space Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 4dd876b..c31e71f 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -732,7 +732,6 @@ static void kgem_finish_partials(struct kgem *kgem) } list_del(&bo->base.list); - if (bo->write && bo->need_io) { DBG(("%s: handle=%d, uploading %d/%d\n", __FUNCTION__, bo->base.handle, bo->used, bo->alloc)); @@ -740,22 +739,20 @@ static void kgem_finish_partials(struct kgem *kgem) gem_write(kgem->fd, bo->base.handle, 0, bo->used, bo+1); bo->need_io = 0; + } - /* transfer the handle to a minimum bo */ - if (bo->base.refcnt == 1) { - struct kgem_bo *base = malloc(sizeof(*base)); - if (base) { - memcpy(base, &bo->base, sizeof (*base)); - base->reusable = true; - list_init(&base->list); - list_replace(&bo->base.request, - &base->request); - free(bo); - bo = (struct kgem_partial_bo *)base; - } + /* transfer the handle to a minimum bo */ + if (bo->base.refcnt == 1) { + struct kgem_bo *base = malloc(sizeof(*base)); + if (base) { + memcpy(base, &bo->base, sizeof (*base)); + base->reusable = true; + list_init(&base->list); + list_replace(&bo->base.request, &base->request); + free(bo); + bo = (struct kgem_partial_bo *)base; } } - kgem_bo_unref(kgem, &bo->base); } } @@ -1891,6 +1888,30 @@ struct kgem_bo *kgem_create_proxy(struct kgem_bo *target, return bo; } +#ifndef NDEBUG +static bool validate_partials(struct kgem *kgem) +{ + struct kgem_partial_bo *bo, *next; + + list_for_each_entry_safe(bo, next, &kgem->partial, base.list) { + if (bo->base.list.next == &kgem->partial) + return true; + if (bo->alloc - bo->used < next->alloc - next->used) { + ErrorF("this rem: %d, next rem: %d\n", + bo->alloc - bo->used, + next->alloc - next->used); + goto err; + } + } + return true; + +err: + list_for_each_entry(bo, &kgem->partial, base.list) + ErrorF("bo: used=%d / %d\n", bo->used, bo->alloc); + return false; +} +#endif + struct kgem_bo *kgem_create_buffer(struct kgem *kgem, uint32_t size, uint32_t flags, void **ret) @@ -1900,11 +1921,15 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, int offset, alloc; uint32_t handle; - DBG(("%s: size=%d, flags=%x\n", __FUNCTION__, size, flags)); + DBG(("%s: size=%d, flags=%x [write=%d, last=%d]\n", + __FUNCTION__, size, flags, write, flags & KGEM_BUFFER_LAST)); list_for_each_entry(bo, &kgem->partial, base.list) { - if (bo->write != write) + if (bo->write != write) { + DBG(("%s: skip write %d buffer, need %d\n", + __FUNCTION__, bo->write, write)); continue; + } if (bo->base.refcnt == 1 && bo->base.exec == NULL) /* no users, so reset */ @@ -1915,10 +1940,12 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, __FUNCTION__, bo->used, size, bo->alloc)); offset = bo->used; bo->used += size; - if (kgem->partial.next != &bo->base.list) - list_move(&bo->base.list, &kgem->partial); goto done; } + + DBG(("%s: too small (%d < %d)\n", + __FUNCTION__, bo->alloc - bo->used, size)); + break; } alloc = (flags & KGEM_BUFFER_LAST) ? 4096 : 32 * 1024; @@ -1974,6 +2001,28 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, __FUNCTION__, alloc, bo->base.handle)); done: + /* adjust the position within the list to maintain decreasing order */ + alloc = bo->alloc - bo->used; + { + struct kgem_partial_bo *p, *first; + + first = p = list_first_entry(&bo->base.list, + struct kgem_partial_bo, + base.list); + while (&p->base.list != &kgem->partial && + alloc < p->alloc - p->used) { + DBG(("%s: this=%d, right=%d\n", + __FUNCTION__, alloc, p->alloc -p->used)); + p = list_first_entry(&p->base.list, + struct kgem_partial_bo, + base.list); + } + if (p != first) { + __list_del(bo->base.list.prev, bo->base.list.next); + list_add_tail(&bo->base.list, &kgem->partial); + } + assert(validate_partials(kgem)); + } *ret = (char *)(bo+1) + offset; return kgem_create_proxy(&bo->base, offset, size); } diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 8f0c838..af6203c 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -34,6 +34,12 @@ #ifndef KGEM_H #define KGEM_H +#if DEBUG_KGEM +#define DBG_HDR(x) ErrorF x +#else +#define DBG_HDR(x) +#endif + struct kgem_bo { struct kgem_bo *proxy; @@ -299,6 +305,9 @@ Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo, static inline bool kgem_bo_is_busy(struct kgem_bo *bo) { + DBG_HDR(("%s: exec? %d, gpu? %d, rq? %d\n", + __FUNCTION__, bo->exec != NULL, bo->gpu, bo->rq != NULL)); + if (bo->exec) return true; if (!bo->gpu) @@ -346,4 +355,6 @@ static inline void __kgem_batch_debug(struct kgem *kgem, uint32_t nbatch) } #endif +#undef DBG_HDR + #endif /* KGEM_H */ commit 13b9b5d8d6b6f6db59fe2418270ac93d9b74436c Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 1 09:23:41 2011 +0100 sna/io: Only mark the buffer as LAST if we know we will flush the IO Otherwise we can continue to batch up the data upload into larger buffers. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c index 3207dc1..649a359 100644 --- a/src/sna/sna_io.c +++ b/src/sna/sna_io.c @@ -339,7 +339,7 @@ void sna_write_boxes(struct sna *sna, } src_bo = kgem_create_buffer(kgem, offset, - KGEM_BUFFER_WRITE | KGEM_BUFFER_LAST, + KGEM_BUFFER_WRITE | (nbox ? KGEM_BUFFER_LAST : 0), &ptr); if (!src_bo) break; From ickle at kemper.freedesktop.org Sun Oct 2 16:11:15 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 2 Oct 2011 16:11:15 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_blt.c Message-ID: <20111002231115.CEF60D8002@kemper.freedesktop.org> src/sna/sna_blt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 1067335305a6b8123217518085f70a77b7f0334f Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 3 00:11:55 2011 +0100 sna/blt: SETUP_BLT needs 9 dwords of batch space, not 3! Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 86388a8..aff8fac 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -144,7 +144,7 @@ static bool sna_blt_fill_init(struct sna *sna, kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_bo_fenced(kgem, bo, NULL) || - !kgem_check_batch(kgem, 3)) { + !kgem_check_batch(kgem, 9)) { _kgem_submit(kgem); _kgem_set_mode(kgem, KGEM_BLT); } From marcoz at kemper.freedesktop.org Sun Oct 2 19:21:49 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Sun, 2 Oct 2011 19:21:49 -0700 (PDT) Subject: fontsproto: Changes to 'master' Message-ID: <20111003022149.4D853D8002@kemper.freedesktop.org> specs/fsproto.xml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) New commits: commit 419c6b31ffc3a87caf2861b6eec546cfc661d113 Author: Matt Dew <marcoz at osource.org> Date: Sun Oct 2 20:15:53 2011 -0600 1 - fix the capitolization of the ID attriutes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From marcoz at kemper.freedesktop.org Sun Oct 2 19:30:01 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Sun, 2 Oct 2011 19:30:01 -0700 (PDT) Subject: xcmiscproto: Changes to 'master' Message-ID: <20111003023001.315F6D8002@kemper.freedesktop.org> specs/xc-misc.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) New commits: commit 8bdaa79348896ecbf4f69df9773ec4681eb46410 Author: Matt Dew <marcoz at osource.org> Date: Sun Oct 2 20:29:17 2011 -0600 1 - fix the capitalization of the ID attriutes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From jeremyhu at kemper.freedesktop.org Mon Oct 3 00:24:48 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 3 Oct 2011 00:24:48 -0700 (PDT) Subject: xwd: Changes to 'master' Message-ID: <20111003072448.BBB79D8002@kemper.freedesktop.org> multiVis.c | 7 ++++--- wsutils.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) New commits: commit 7d88d8ab44b17247753f7225a1d8133d55d8423e Author: P??r Lidberg <par.lidberg at elekta.com> Date: Mon Oct 3 00:24:06 2011 -0700 Fix LP64 bug https://bugs.freedesktop.org/show_bug.cgi?id=14321 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From ickle at kemper.freedesktop.org Mon Oct 3 00:56:57 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 3 Oct 2011 00:56:57 -0700 (PDT) Subject: xf86-video-intel: src/sna/kgem.c src/sna/sna_blt.c src/sna/sna.h src/sna/sna_io.c Message-ID: <20111003075657.EA858D8002@kemper.freedesktop.org> src/sna/kgem.c | 1 + src/sna/sna.h | 4 ++++ src/sna/sna_blt.c | 7 +++++++ src/sna/sna_io.c | 2 ++ 4 files changed, 14 insertions(+) New commits: commit 413c9f7111c605a3842d4d0a85f8cf01470e5faa Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 3 00:24:50 2011 +0100 sna/blt: Suppress repeated SETUP_BLT Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index c31e71f..fb24563 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -92,6 +92,7 @@ static void kgem_sna_reset(struct kgem *kgem) struct sna *sna = container_of(kgem, struct sna, kgem); sna->render.reset(sna); + sna->blt_state.fill_bo = 0; } static void kgem_sna_flush(struct kgem *kgem) diff --git a/src/sna/sna.h b/src/sna/sna.h index 091fed5..189e3d4 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -234,6 +234,10 @@ struct sna { void *WakeupData; CloseScreenProcPtr CloseScreen; + struct { + uint32_t fill_bo; + uint32_t fill_pixel; + } blt_state; union { struct gen2_render_state gen2; struct gen3_render_state gen3; diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index aff8fac..d82f845 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -149,6 +149,8 @@ static bool sna_blt_fill_init(struct sna *sna, _kgem_set_mode(kgem, KGEM_BLT); } + if (sna->blt_state.fill_bo != bo->handle || + sna->blt_state.fill_pixel != pixel) { uint32_t *b = kgem->batch + kgem->nbatch; b[0] = blt->cmd; @@ -165,6 +167,9 @@ static bool sna_blt_fill_init(struct sna *sna, b[7] = 0; b[8] = 0; kgem->nbatch += 9; + + sna->blt_state.fill_bo = bo->handle; + sna->blt_state.fill_pixel = pixel; } return TRUE; @@ -260,6 +265,7 @@ static Bool sna_blt_copy_init(struct sna *sna, if (!kgem_check_bo_fenced(kgem, src, dst, NULL)) _kgem_submit(kgem); + sna->blt_state.fill_bo = 0; return TRUE; } @@ -1273,6 +1279,7 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, } while (nbox); _kgem_set_mode(kgem, KGEM_BLT); + sna->blt_state.fill_bo = 0; return TRUE; } diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c index 649a359..321247a 100644 --- a/src/sna/sna_io.c +++ b/src/sna/sna_io.c @@ -234,6 +234,7 @@ void sna_read_boxes(struct sna *sna, } while (--nbox); assert(src - (char *)ptr == dst_bo->size); kgem_bo_destroy(kgem, dst_bo); + sna->blt_state.fill_bo = 0; } static void write_boxes_inplace(struct kgem *kgem, @@ -401,6 +402,7 @@ void sna_write_boxes(struct sna *sna, } while (nbox); _kgem_set_mode(kgem, KGEM_BLT); + sna->blt_state.fill_bo = 0; } struct kgem_bo *sna_replace(struct sna *sna, From airlied at kemper.freedesktop.org Mon Oct 3 03:30:24 2011 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Mon, 3 Oct 2011 03:30:24 -0700 (PDT) Subject: xf86-video-modesetting: 14 commits - configure.ac .gitignore man/Makefile.am man/modesetting.man src/crtc.c src/dri2.c src/driver.c src/driver.h src/drmmode_display.c src/drmmode_display.h src/exa.c src/Makefile.am src/output.c Message-ID: <20111003103024.8DF4CD8002@kemper.freedesktop.org> .gitignore | 79 ++ configure.ac | 137 ----- man/Makefile.am | 31 - man/modesetting.man | 54 ++ src/Makefile.am | 12 src/crtc.c | 307 ----------- src/dri2.c | 128 ---- src/driver.c | 673 +++++++++--------------- src/driver.h | 20 src/drmmode_display.c | 1349 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/drmmode_display.h | 101 +++ src/exa.c | 850 ------------------------------- src/output.c | 292 ---------- 13 files changed, 1884 insertions(+), 2149 deletions(-) New commits: commit d68278caa04f165c85f5d927abcf5fcc084eaa94 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 16:06:52 2011 +0100 check drm support dumb buffer capability diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 375170f..dcf3eb3 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1016,6 +1016,17 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = { Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) { int i, num_dvi = 0, num_hdmi = 0; + int ret; + + /* check for dumb capability */ + { + uint64_t value = 0; + ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_BUFFER, &value); + if (ret > 0 || value != 1) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS doesn't support dumb interface\n"); + return FALSE; + } + } xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs); commit 82ba85fca8416635ff28c19c4b38fa2fe9820481 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 16:00:50 2011 +0100 add initial man page diff --git a/man/modesetting.man b/man/modesetting.man index e69de29..34baa9c 100644 --- a/man/modesetting.man +++ b/man/modesetting.man @@ -0,0 +1,54 @@ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH MODESETTING __drivermansuffix__ __vendorversion__ +.SH NAME +modesetting \- video driver for framebuffer device +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qmodesetting\*q" +.BI " BusID \*qpci:" bus : dev : func \*q +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B modesetting +is an __xservername__ driver for KMS devices. This is a non-accelerated +driver, the following framebuffer depths are supported: 8, 15, 16, 24. +All visual types are supported for depth 8, and TrueColor visual is +supported for the other depths. RandR 1.2 is supported. +.SH SUPPORTED HARDWARE +The +.B modesetting +driver supports all hardware where a KMS driver is available. +modesetting uses the Linux DRM KMS ioctls and dumb object create/map. +.SH CONFIGURATION DETAILS +Please refer to __xconfigfile__(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to +this driver. +.PP +For this driver it is not required to specify modes in the screen +section of the config file. The +.B modesetting +driver can pick up the currently used video mode from the kernel +driver and will use it if there are no video modes configured. +.PP +For PCI boards you might have to add a BusID line to the Device +section. See above for a sample line. +.PP +The following driver +.B Options +are supported: +.TP +.BI "Option \*qkmsdev\*q \*q" string \*q +The framebuffer device to use. Default: /dev/dri/card0. +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Enable or disable use of the shadow framebuffer layer. Default: on. +.TP +.SH "SEE ALSO" +__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), +X(__miscmansuffix__) +.SH AUTHORS +Authors include: Dave Airlie commit bb848a788f8dae6f54eb2c03eb2046066732e6e8 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 15:55:36 2011 +0100 add shadowfb support, default to on. we should probably expose a bit from kernel to say if shadow is preferred or wasteful. diff --git a/src/driver.c b/src/driver.c index 1192878..bde690c 100644 --- a/src/driver.c +++ b/src/driver.c @@ -49,6 +49,7 @@ #include "xf86Crtc.h" #include "miscstruct.h" #include "dixstruct.h" +#include "shadow.h" #include "xf86xv.h" #include <X11/extensions/Xv.h> #include <xorg-server.h> @@ -110,11 +111,13 @@ typedef enum { OPTION_SW_CURSOR, OPTION_DEVICE_PATH, + OPTION_SHADOW_FB, } modesettingOpts; static const OptionInfoRec Options[] = { {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE }, + {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, {-1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -472,6 +475,8 @@ PreInit(ScrnInfoPtr pScrn, int flags) ms->SWCursor = TRUE; } + ms->shadow_enable = xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, TRUE); + ms->drmmode.fd = ms->fd; if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n"); @@ -504,11 +509,31 @@ PreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } + if (ms->shadow_enable) { + if (!xf86LoadSubModule(pScrn, "shadow")) { + return FALSE; + } + } + return TRUE; fail: return FALSE; } +static void * +msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode, + CARD32 *size, void *closure) +{ + ScrnInfoPtr pScrn = xf86Screens[screen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + int stride; + + stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8; + *size = stride; + + return ((uint8_t *)ms->drmmode.front_bo->ptr + row * stride + offset); +} + static Bool CreateScreenResources(ScreenPtr pScreen) { @@ -532,9 +557,19 @@ CreateScreenResources(ScreenPtr pScreen) return FALSE; rootPixmap = pScreen->GetScreenPixmap(pScreen); + + if (ms->shadow_enable) + pixels = ms->shadow_fb; + if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels)) FatalError("Couldn't adjust screen pixmap\n"); + if (ms->shadow_enable) { + if (!shadowAdd(pScreen, rootPixmap, shadowUpdatePackedWeak(), + msShadowWindow, 0, 0)) + return FALSE; + } + ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE, pScreen, rootPixmap); @@ -551,6 +586,15 @@ CreateScreenResources(ScreenPtr pScreen) } static Bool +msShadowInit(ScreenPtr pScreen) +{ + if (!shadowSetup(pScreen)) { + return FALSE; + } + return TRUE; +} + +static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -571,6 +615,13 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (!drmmode_create_initial_bos(pScrn, &ms->drmmode)) return FALSE; + if (ms->shadow_enable) { + ms->shadow_fb = calloc(1, pScrn->displayWidth * pScrn->virtualY * + ((pScrn->bitsPerPixel + 7) >> 3)); + if (!ms->shadow_fb) + ms->shadow_enable = FALSE; + } + miClearVisualTypes(); if (!miSetVisualTypes(pScrn->depth, @@ -607,6 +658,12 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) fbPictureInit(pScreen, NULL, 0); + if (ms->shadow_enable && !msShadowInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "shadow fb init failed\n"); + return FALSE; + } + ms->createScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = CreateScreenResources; @@ -715,6 +772,11 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) ms->damage = NULL; } + if (ms->shadow_enable) { + shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen)); + free(ms->shadow_fb); + ms->shadow_fb = NULL; + } drmmode_uevent_fini(pScrn, &ms->drmmode); drmmode_free_bos(pScrn, &ms->drmmode); diff --git a/src/driver.h b/src/driver.h index beb5f8d..494ca0c 100644 --- a/src/driver.h +++ b/src/driver.h @@ -76,6 +76,8 @@ typedef struct _modesettingRec DamagePtr damage; Bool dirty_enabled; + Bool shadow_enable; + void *shadow_fb; } modesettingRec, *modesettingPtr; #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) commit f699c4dc6fd2a34555045950d75ba287723a1e06 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 15:55:24 2011 +0100 remove unused debug diff --git a/src/driver.c b/src/driver.c index d1348c9..1192878 100644 --- a/src/driver.c +++ b/src/driver.c @@ -558,7 +558,6 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) VisualPtr visual; int ret; - ErrorF("ms is %p\n", ms); pScrn->pScreen = pScreen; ret = drmSetMaster(ms->fd); commit 9772f3e16b0e15ea48463c8af7e5c28ece116dea Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 14:13:58 2011 +0100 add -Wall, cleanup warnings diff --git a/configure.ac b/configure.ac index 3d4d267..12251fe 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,10 @@ AC_PROG_LIBTOOL AC_PROG_CC AM_PROG_CC_C_O +if test "x$GCC" = "xyes"; then + CPPFLAGS="$CPPFLAGS -Wall" +fi + AH_TOP([#include "xorg-server.h"]) AC_ARG_WITH(xorg-module-dir, diff --git a/src/driver.c b/src/driver.c index b56db94..d1348c9 100644 --- a/src/driver.c +++ b/src/driver.c @@ -33,6 +33,7 @@ #include "config.h" #endif +#include <unistd.h> #include <fcntl.h> #include "xf86.h" #include "xf86_OSproc.h" @@ -199,8 +200,6 @@ ms_pci_probe(DriverPtr driver, int entity_num, struct pci_device *dev, intptr_t match_data) { ScrnInfoPtr scrn = NULL; - EntityInfoPtr entity; - DevUnion *private; scrn = xf86ConfigPciEntity(scrn, 0, entity_num, NULL, NULL, NULL, NULL, NULL, NULL); @@ -239,14 +238,11 @@ ms_pci_probe(DriverPtr driver, static Bool Probe(DriverPtr drv, int flags) { - int i, numUsed, numDevSections, *usedChips; - EntPtr msEnt = NULL; - DevUnion *pPriv; + int i, numDevSections; GDevPtr *devSections; Bool foundScreen = FALSE; - int numDevs; char *dev; - ScrnInfoPtr scrn; + ScrnInfoPtr scrn = NULL; /* For now, just bail out for PROBE_DETECT. */ if (flags & PROBE_DETECT) @@ -268,7 +264,7 @@ Probe(DriverPtr drv, int flags) int entity; entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE); scrn = xf86ConfigFbEntity(scrn, 0, entity, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL); } if (scrn) @@ -376,17 +372,11 @@ FreeRec(ScrnInfoPtr pScrn) static Bool PreInit(ScrnInfoPtr pScrn, int flags) { - xf86CrtcConfigPtr xf86_config; modesettingPtr ms; - MessageType from = X_PROBED; rgb defaultWeight = { 0, 0, 0 }; EntityInfoPtr pEnt; EntPtr msEnt = NULL; char *BusID; - int i; - char *s; - int num_pipe; - int max_width, max_height; if (pScrn->numEntities != 1) return FALSE; @@ -526,7 +516,6 @@ CreateScreenResources(ScreenPtr pScreen) modesettingPtr ms = modesettingPTR(pScrn); PixmapPtr rootPixmap; Bool ret; - int flags; void *pixels; pScreen->CreateScreenResources = ms->createScreenResources; ret = pScreen->CreateScreenResources(pScreen); @@ -567,9 +556,6 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); VisualPtr visual; - unsigned long sys_mem; - int c; - MessageType from; int ret; ErrorF("ms is %p\n", ms); diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 4f25bbe..375170f 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -108,11 +108,13 @@ static int dumb_bo_map(int fd, struct dumb_bo *bo) return 0; } +#if 0 static int dumb_bo_unmap(int fd, struct dumb_bo *bo) { bo->map_count--; return 0; } +#endif static int dumb_bo_destroy(int fd, struct dumb_bo *bo) { @@ -260,7 +262,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, int x, int y) { ScrnInfoPtr pScrn = crtc->scrn; - // RADEONInfoPtr info = RADEONPTR(pScrn); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; drmmode_ptr drmmode = drmmode_crtc->drmmode; @@ -273,11 +274,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, int i; int fb_id; drmModeModeInfo kmode; - int pitch; - uint32_t tiling_flags = 0; int height; - pitch = pScrn->displayWidth; height = pScrn->virtualY; if (drmmode->fb_id == 0) { @@ -795,7 +793,6 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dv drmModePropertyPtr props; char name[32]; int i; - const char *s; koutput = drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]); if (!koutput) @@ -938,10 +935,7 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) ScreenPtr screen = screenInfo.screens[scrn->scrnIndex]; uint32_t old_fb_id; int i, pitch, old_width, old_height, old_pitch; - int screen_size; int cpp = (scrn->bitsPerPixel + 1) / 8; - struct dumb_bo *front_bo; - uint32_t tiling_flags = 0; PixmapPtr ppix = screen->GetScreenPixmap(screen); void *new_pixels; @@ -949,12 +943,12 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) return TRUE; xf86DrvMsg(scrn->scrnIndex, X_INFO, - "Allocate new frame buffer %dx%d stride %d\n", - width, height, pitch / cpp); + "Allocate new frame buffer %dx%d stride\n", + width, height); old_width = scrn->virtualX; old_height = scrn->virtualY; - old_pitch = scrn->displayWidth; + old_pitch = drmmode->front_bo->pitch; old_fb_id = drmmode->fb_id; old_front = drmmode->front_bo; @@ -1009,7 +1003,7 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) drmmode->front_bo = old_front; scrn->virtualX = old_width; scrn->virtualY = old_height; - scrn->displayWidth = old_pitch; + scrn->displayWidth = old_pitch / cpp; drmmode->fb_id = old_fb_id; return FALSE; @@ -1021,11 +1015,9 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = { Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) { - xf86CrtcConfigPtr xf86_config; int i, num_dvi = 0, num_hdmi = 0; xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs); - xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); drmmode->scrn = pScrn; drmmode->cpp = cpp; commit 1b9690d2b1f1bc33f149ff7ab8950b24029c030c Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 14:05:43 2011 +0100 fix server recycling diff --git a/src/driver.c b/src/driver.c index bc80e30..b56db94 100644 --- a/src/driver.c +++ b/src/driver.c @@ -570,31 +570,17 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) unsigned long sys_mem; int c; MessageType from; + int ret; - /* deal with server regeneration */ - if (ms->fd < 0) { - char *BusID; - - BusID = malloc(64); - sprintf(BusID, "PCI:%d:%d:%d", -#if XSERVER_LIBPCIACCESS - ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), - ms->PciInfo->dev, ms->PciInfo->func -#else - ((pciConfigPtr) ms->PciInfo->thisCard)->busnum, - ((pciConfigPtr) ms->PciInfo->thisCard)->devnum, - ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum -#endif - ); - - ms->fd = drmOpen(NULL, BusID); - - if (ms->fd < 0) - return FALSE; - } - + ErrorF("ms is %p\n", ms); pScrn->pScreen = pScreen; + ret = drmSetMaster(ms->fd); + if (ret) { + ErrorF("Unable to set master\n"); + return FALSE; + } + /* HW dependent - FIXME */ pScrn->displayWidth = pScrn->virtualX; if (!drmmode_create_initial_bos(pScrn, &ms->drmmode)) @@ -716,7 +702,9 @@ EnterVT(int scrnIndex, int flags) ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; modesettingPtr ms = modesettingPTR(pScrn); - if (!xf86SetDesiredModes(pScrn)) + pScrn->vtSema = TRUE; + + if (!drmmode_set_desired_modes(pScrn, &ms->drmmode)) return FALSE; return TRUE; @@ -752,8 +740,8 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) pScreen->CreateScreenResources = ms->createScreenResources; pScreen->BlockHandler = ms->BlockHandler; - drmClose(ms->fd); - ms->fd = -1; + + drmDropMaster(ms->fd); pScrn->vtSema = FALSE; pScreen->CloseScreen = ms->CloseScreen; diff --git a/src/drmmode_display.c b/src/drmmode_display.c index d94ce03..4f25bbe 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1329,6 +1329,12 @@ void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) { xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); int i; + + if (drmmode->fb_id) { + drmModeRmFB(drmmode->fd, drmmode->fb_id); + drmmode->fb_id = 0; + } + dumb_bo_destroy(drmmode->fd, drmmode->front_bo); drmmode->front_bo = NULL; commit 59a4776f7b4e0f9bbbafe62972487354a8fabda0 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 12:38:26 2011 +0100 port damage tracking code from st/xorg diff --git a/src/driver.c b/src/driver.c index 0aaafd1..bc80e30 100644 --- a/src/driver.c +++ b/src/driver.c @@ -307,6 +307,58 @@ GetRec(ScrnInfoPtr pScrn) return TRUE; } +static void dispatch_dirty(ScreenPtr pScreen) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(scrn); + RegionPtr dirty = DamageRegion(ms->damage); + unsigned num_cliprects = REGION_NUM_RECTS(dirty); + + if (num_cliprects) { + drmModeClip *clip = alloca(num_cliprects * sizeof(drmModeClip)); + BoxPtr rect = REGION_RECTS(dirty); + int i, ret; + + /* XXX no need for copy? */ + for (i = 0; i < num_cliprects; i++, rect++) { + clip[i].x1 = rect->x1; + clip[i].y1 = rect->y1; + clip[i].x2 = rect->x2; + clip[i].y2 = rect->y2; + } + + /* TODO query connector property to see if this is needed */ + ret = drmModeDirtyFB(ms->fd, ms->fb_id, clip, num_cliprects); + if (ret) { + if (ret == -EINVAL) { + ms->dirty_enabled = FALSE; + DamageUnregister(&pScreen->GetScreenPixmap(pScreen)->drawable, ms->damage); + DamageDestroy(ms->damage); + ms->damage = NULL; + xf86DrvMsg(scrn->scrnIndex, X_INFO, "Disabling kernel dirty updates, not required.\n"); + return; + } else + ErrorF("%s: failed to send dirty (%i, %s)\n", + __func__, ret, strerror(-ret)); + } + + DamageEmpty(ms->damage); + } +} + +static void msBlockHandler(int i, pointer blockData, pointer pTimeout, + pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + modesettingPtr ms = modesettingPTR(xf86Screens[pScreen->myNum]); + + pScreen->BlockHandler = ms->BlockHandler; + pScreen->BlockHandler(i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = msBlockHandler; + if (ms->dirty_enabled) + dispatch_dirty(pScreen); +} + static void FreeRec(ScrnInfoPtr pScrn) { @@ -494,6 +546,18 @@ CreateScreenResources(ScreenPtr pScreen) if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels)) FatalError("Couldn't adjust screen pixmap\n"); + ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE, + pScreen, rootPixmap); + + if (ms->damage) { + DamageRegister(&rootPixmap->drawable, ms->damage); + ms->dirty_enabled = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to create screen damage record\n"); + return FALSE; + } return ret; } @@ -596,6 +660,9 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) ms->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = CloseScreen; + ms->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = msBlockHandler; + if (!xf86CrtcScreenInit(pScreen)) return FALSE; @@ -669,6 +736,12 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; modesettingPtr ms = modesettingPTR(pScrn); + if (ms->damage) { + DamageUnregister(&pScreen->GetScreenPixmap(pScreen)->drawable, ms->damage); + DamageDestroy(ms->damage); + ms->damage = NULL; + } + drmmode_uevent_fini(pScrn, &ms->drmmode); drmmode_free_bos(pScrn, &ms->drmmode); @@ -678,7 +751,7 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) } pScreen->CreateScreenResources = ms->createScreenResources; - + pScreen->BlockHandler = ms->BlockHandler; drmClose(ms->fd); ms->fd = -1; diff --git a/src/driver.h b/src/driver.h index 255dede..beb5f8d 100644 --- a/src/driver.h +++ b/src/driver.h @@ -30,6 +30,7 @@ #include <errno.h> #include <drm.h> #include <xf86drm.h> +#include <damage.h> #include "drmmode_display.h" #define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); @@ -68,10 +69,13 @@ typedef struct _modesettingRec unsigned int SaveGeneration; CreateScreenResourcesProcPtr createScreenResources; - + ScreenBlockHandlerProcPtr BlockHandler; void *driver; drmmode_rec drmmode; + + DamagePtr damage; + Bool dirty_enabled; } modesettingRec, *modesettingPtr; #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) commit 7307ff4dd1a6cbfa1e4311ec2c6efc26eb81a434 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 12:34:27 2011 +0100 drop loading dri2 diff --git a/src/driver.c b/src/driver.c index dee9cff..0aaafd1 100644 --- a/src/driver.c +++ b/src/driver.c @@ -462,10 +462,6 @@ PreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } -#ifdef DRI2 - xf86LoadSubModule(pScrn, "dri2"); -#endif - return TRUE; fail: return FALSE; commit 0ca055f7b19e60df8ba4aa44522e06e06c1222f1 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 12:34:17 2011 +0100 update authors/copyright diff --git a/src/driver.c b/src/driver.c index 9bb1cb4..dee9cff 100644 --- a/src/driver.c +++ b/src/driver.c @@ -1,5 +1,6 @@ /* * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2011 Dave Airlie * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,7 +24,8 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * - * Author: Alan Hourihane <alanh at tungstengraphics.com> + * Original Author: Alan Hourihane <alanh at tungstengraphics.com> + * Rewrite: Dave Airlie <airlied at redhat.com> * */ commit ac7b8e43842858b8787b1f7ede4d547eece77e5e Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 12:30:46 2011 +0100 gut some more unneeded code diff --git a/src/driver.c b/src/driver.c index be781bc..9bb1cb4 100644 --- a/src/driver.c +++ b/src/driver.c @@ -638,24 +638,6 @@ static void LeaveVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - modesettingPtr ms = modesettingPTR(pScrn); - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - int o; - - for (o = 0; o < config->num_crtc; o++) { - xf86CrtcPtr crtc = config->crtc[o]; - - // cursor_destroy(crtc); - - if (crtc->rotatedPixmap || crtc->rotatedData) { - crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap, - crtc->rotatedData); - crtc->rotatedPixmap = NULL; - crtc->rotatedData = NULL; - } - } - - drmModeRmFB(ms->fd, ms->fb_id); pScrn->vtSema = FALSE; } commit ffb6bb4deb827c369faadd77495d7cae4acc2a42 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 12:28:59 2011 +0100 modesetting: rewrite probing based on fbdev. This isn't perfect, it should really do more with bus id matching and finding the write drm device using sysfs if it can. but it removes lots of hardcoding of pci ids. diff --git a/src/driver.c b/src/driver.c index 47ffb07..be781bc 100644 --- a/src/driver.c +++ b/src/driver.c @@ -31,6 +31,7 @@ #include "config.h" #endif +#include <fcntl.h> #include "xf86.h" #include "xf86_OSproc.h" #include "compiler.h" @@ -68,18 +69,19 @@ static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv); static Bool PreInit(ScrnInfoPtr pScrn, int flags); -#if XSERVER_LIBPCIACCESS -static Bool -pci_probe(DriverPtr driver, - int entity_num, struct pci_device *device, intptr_t match_data); -#else static Bool Probe(DriverPtr drv, int flags); -#endif +static Bool ms_pci_probe(DriverPtr driver, + int entity_num, struct pci_device *device, + intptr_t match_data); -#if XSERVER_LIBPCIACCESS -static const struct pci_id_match device_match[] = { - {0x8086, 0x0046, 0xffff, 0xffff, 0, 0, 0}, - {0, 0, 0}, +#ifdef XSERVER_LIBPCIACCESS +static const struct pci_id_match ms_device_match[] = { + { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + 0x00030000, 0x00ffffff, 0 + }, + + { 0, 0, 0 }, }; #endif @@ -87,38 +89,29 @@ _X_EXPORT DriverRec modesetting = { 1, "modesetting", Identify, -#if XSERVER_LIBPCIACCESS - NULL, -#else Probe, -#endif AvailableOptions, NULL, 0, NULL, -#if XSERVER_LIBPCIACCESS - device_match, - pci_probe -#endif + ms_device_match, + ms_pci_probe, }; static SymTabRec Chipsets[] = { - {0x0046, "Intel Graphics Device"}, + {0, "kms" }, {-1, NULL} }; -static PciChipsets PciDevices[] = { - {0x2592, 0x0046, RES_SHARED_VGA}, - {-1, -1, RES_UNDEFINED} -}; - typedef enum { OPTION_SW_CURSOR, + OPTION_DEVICE_PATH, } modesettingOpts; static const OptionInfoRec Options[] = { {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE }, {-1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -171,6 +164,27 @@ Identify(int flags) Chipsets); } +static Bool probe_hw(char *dev) +{ + int fd; + if (dev) + fd = open(dev, O_RDWR, 0); + else { + dev = getenv("KMSDEVICE"); + if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) { + dev = "/dev/dri/card0"; + fd = open(dev,O_RDWR, 0); + } + } + if (fd == -1) { + xf86DrvMsg(-1, X_ERROR,"open %s: %s\n", dev, strerror(errno)); + return FALSE; + } + close(fd); + return TRUE; + +} + static const OptionInfoRec * AvailableOptions(int chipid, int busid) { @@ -179,25 +193,26 @@ AvailableOptions(int chipid, int busid) #if XSERVER_LIBPCIACCESS static Bool -pci_probe(DriverPtr driver, - int entity_num, struct pci_device *device, intptr_t match_data) +ms_pci_probe(DriverPtr driver, + int entity_num, struct pci_device *dev, intptr_t match_data) { ScrnInfoPtr scrn = NULL; EntityInfoPtr entity; DevUnion *private; - scrn = xf86ConfigPciEntity(scrn, 0, entity_num, PciDevices, + scrn = xf86ConfigPciEntity(scrn, 0, entity_num, NULL, NULL, NULL, NULL, NULL, NULL); - if (scrn != NULL) { - scrn->driverVersion = 1; - scrn->driverName = "modesetting"; - scrn->name = "modesetting"; - scrn->Probe = NULL; - - entity = xf86GetEntityInfo(entity_num); - - switch (device->device_id) { - case 0x0046: + if (scrn) { + char *devpath; + GDevPtr devSection = xf86GetDevFromEntity(scrn->entityList[0], + scrn->entityInstanceList[0]); + + devpath = xf86FindOptionValue(devSection->options, "kmsdev"); + if (probe_hw(devpath)) { + scrn->driverVersion = 1; + scrn->driverName = "modesetting"; + scrn->name = "modeset"; + scrn->Probe = NULL; scrn->PreInit = PreInit; scrn->ScreenInit = ScreenInit; scrn->SwitchMode = SwitchMode; @@ -206,12 +221,19 @@ pci_probe(DriverPtr driver, scrn->LeaveVT = LeaveVT; scrn->FreeScreen = FreeScreen; scrn->ValidMode = ValidMode; - break; - } + + xf86DrvMsg(scrn->scrnIndex, X_CONFIG, + "claimed PCI slot %d@%d:%d:%d\n", + dev->bus, dev->domain, dev->dev, dev->func); + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "using %s\n", devpath ? devpath : "default device"); + } else + scrn = NULL; } return scrn != NULL; } -#else +#endif + static Bool Probe(DriverPtr drv, int flags) { @@ -220,9 +242,13 @@ Probe(DriverPtr drv, int flags) DevUnion *pPriv; GDevPtr *devSections; Bool foundScreen = FALSE; - pciVideoPtr *VideoInfo; - pciVideoPtr *ppPci; int numDevs; + char *dev; + ScrnInfoPtr scrn; + + /* For now, just bail out for PROBE_DETECT. */ + if (flags & PROBE_DETECT) + return FALSE; /* * Find the config file Device sections that match this @@ -232,110 +258,41 @@ Probe(DriverPtr drv, int flags) return FALSE; } - /* - * This probing is just checking the PCI data the server already - * collected. - */ - if (!(VideoInfo = xf86GetPciVideoInfo())) - return FALSE; + for (i = 0; i < numDevSections; i++) { -#if 0 - numUsed = 0; - for (ppPci = VideoInfo; ppPci != NULL && *ppPci != NULL; ppPci++) { - for (numDevs = 0; numDevs < numDevSections; numDevs++) { - if (devSections[numDevs]->busID && *devSections[numDevs]->busID) { - if (xf86ComparePciBusString - (devSections[numDevs]->busID, (*ppPci)->bus, - (*ppPci)->device, (*ppPci)->func)) { - /* Claim slot */ - if (xf86CheckPciSlot((*ppPci)->bus, (*ppPci)->device, - (*ppPci)->func)) { - usedChips[numUsed++] = - xf86ClaimPciSlot((*ppPci)->bus, (*ppPci)->device, - (*ppPci)->func, drv, - (*ppPci)->chipType, NULL, TRUE); - ErrorF("CLAIMED %d %d %d\n", (*ppPci)->bus, - (*ppPci)->device, (*ppPci)->func); - } - } + dev = xf86FindOptionValue(devSections[i]->options,"kmsdev"); + if (devSections[i]->busID) { + if (probe_hw(dev)) { + int entity; + entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE); + scrn = xf86ConfigFbEntity(scrn, 0, entity, + NULL, NULL, NULL, NULL); } - } - } -#else - /* Look for Intel i8xx devices. */ - numUsed = xf86MatchPciInstances("modesetting", PCI_VENDOR_INTEL, - Chipsets, PciDevices, - devSections, numDevSections, - drv, &usedChips); -#endif - if (flags & PROBE_DETECT) { - if (numUsed > 0) - foundScreen = TRUE; - } else { - for (i = 0; i < numUsed; i++) { - ScrnInfoPtr pScrn = NULL; - - /* Allocate new ScrnInfoRec and claim the slot */ - if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], - PciDevices, NULL, NULL, NULL, - NULL, NULL))) { - EntityInfoPtr pEnt; - - pEnt = xf86GetEntityInfo(usedChips[i]); - - pScrn->driverVersion = 1; - pScrn->driverName = "modesetting"; - pScrn->name = "modesetting"; - pScrn->Probe = Probe; + if (scrn) foundScreen = TRUE; - { - /* Allocate an entity private if necessary */ - if (modesettingEntityIndex < 0) - modesettingEntityIndex = - xf86AllocateEntityPrivateIndex(); - - pPriv = xf86GetEntityPrivate(pScrn->entityList[0], - modesettingEntityIndex); - if (!pPriv->ptr) { - pPriv->ptr = xnfcalloc(sizeof(EntRec), 1); - msEnt = pPriv->ptr; - msEnt->lastInstance = -1; - } else { - msEnt = pPriv->ptr; - } - - /* - * Set the entity instance for this instance of the driver. - * For dual head per card, instance 0 is the "master" - * instance, driving the primary head, and instance 1 is - * the "slave". - */ - msEnt->lastInstance++; - xf86SetEntityInstanceForScreen(pScrn, - pScrn->entityList[0], - msEnt->lastInstance); - pScrn->PreInit = PreInit; - pScrn->ScreenInit = ScreenInit; - pScrn->SwitchMode = SwitchMode; - pScrn->AdjustFrame = AdjustFrame; - pScrn->EnterVT = EnterVT; - pScrn->LeaveVT = LeaveVT; - pScrn->FreeScreen = FreeScreen; - pScrn->ValidMode = ValidMode; - break; - } - } else - ErrorF("FAILED PSCRN\n"); + scrn->driverVersion = 1; + scrn->driverName = "modesetting"; + scrn->name = "modesetting"; + scrn->Probe = Probe; + scrn->PreInit = PreInit; + scrn->ScreenInit = ScreenInit; + scrn->SwitchMode = SwitchMode; + scrn->AdjustFrame = AdjustFrame; + scrn->EnterVT = EnterVT; + scrn->LeaveVT = LeaveVT; + scrn->FreeScreen = FreeScreen; + scrn->ValidMode = ValidMode; + + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "using %s\n", dev ? dev : "default device"); } } - free(usedChips); free(devSections); return foundScreen; } -#endif static Bool GetRec(ScrnInfoPtr pScrn) commit ec9374e4210ab36a07209e27a79922545eafd5e2 Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 11:52:51 2011 +0100 cleanup some the drmmode_display header file diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 2d72505..845207a 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -33,49 +33,33 @@ #endif struct dumb_bo { - uint32_t handle; - uint32_t size; - void *ptr; - int map_count; - uint32_t pitch; + uint32_t handle; + uint32_t size; + void *ptr; + int map_count; + uint32_t pitch; }; typedef struct { - int fd; - unsigned fb_id; - drmModeResPtr mode_res; - drmModeFBPtr mode_fb; - int cpp; - ScrnInfoPtr scrn; + int fd; + unsigned fb_id; + drmModeResPtr mode_res; + drmModeFBPtr mode_fb; + int cpp; + ScrnInfoPtr scrn; #ifdef HAVE_UDEV - struct udev_monitor *uevent_monitor; - InputHandlerProc uevent_handler; + struct udev_monitor *uevent_monitor; + InputHandlerProc uevent_handler; #endif - drmEventContext event_context; - struct dumb_bo *front_bo; + drmEventContext event_context; + struct dumb_bo *front_bo; } drmmode_rec, *drmmode_ptr; typedef struct { - drmmode_ptr drmmode; - unsigned old_fb_id; - int flip_count; - void *event_data; - unsigned int fe_frame; - unsigned int fe_tv_sec; - unsigned int fe_tv_usec; -} drmmode_flipdata_rec, *drmmode_flipdata_ptr; - -typedef struct { - drmmode_flipdata_ptr flipdata; - Bool dispatch_me; -} drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr; - -typedef struct { drmmode_ptr drmmode; drmModeCrtcPtr mode_crtc; int hw_id; struct dumb_bo *cursor_bo; - // struct radeon_bo *rotate_bo; unsigned rotate_fb_id; uint16_t lut_r[256], lut_g[256], lut_b[256]; } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; @@ -103,21 +87,13 @@ typedef struct { extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); -//extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr); -//extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo); void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y, int flags); extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode); -extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode); extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); -extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling); -extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); -extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); - -//Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id); Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); void *drmmode_map_front_bo(drmmode_ptr drmmode); Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); commit 74c284ac4ee24cd32309843d8d191e0a0339677b Author: Dave Airlie <airlied at redhat.com> Date: Thu Sep 29 11:49:26 2011 +0100 modesetting: restart driver effort from other codebases This starts a randr 1.2 compatible driver with cursors. TODO: libkms dirty handling server recycling. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4cada5a --- /dev/null +++ b/.gitignore @@ -0,0 +1,79 @@ +# +# X.Org module default exclusion patterns +# The next section if for module specific patterns +# +# Do not edit the following section +# GNU Build System (Autotools) +aclocal.m4 +autom4te.cache/ +autoscan.log +ChangeLog +compile +config.guess +config.h +config.h.in +config.log +config-ml.in +config.py +config.status +config.status.lineno +config.sub +configure +configure.scan +depcomp +.deps/ +INSTALL +install-sh +.libs/ +libtool +libtool.m4 +ltmain.sh +lt~obsolete.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 +Makefile +Makefile.in +mdate-sh +missing +mkinstalldirs +*.pc +py-compile +stamp-h? +symlink-tree +texinfo.tex +ylwrap + +# Do not edit the following section +# Edit Compile Debug Document Distribute +*~ +*.[0-9] +*.[0-9]x +*.bak +*.bin +core +*.dll +*.exe +*-ISO*.bdf +*-JIS*.bdf +*-KOI8*.bdf +*.kld +*.ko +*.ko.cmd +*.lai +*.l[oa] +*.[oa] +*.obj +*.patch +*.so +*.pcf.gz +*.pdb +*.tar.bz2 +*.tar.gz +# +# Add & Override patterns for xf86-video-intel +# +# Edit the following section as needed +# For example, !report.pc overrides *.pc. See 'man gitignore' +# +cscope* diff --git a/configure.ac b/configure.ac index d1bdf10..3d4d267 100644 --- a/configure.ac +++ b/configure.ac @@ -20,24 +20,30 @@ # # Process this file with autoconf to produce a configure script -AC_PREREQ(2.57) +AC_PREREQ([2.60]) AC_INIT([xf86-video-modesetting], - 0.1.0, + [0.1.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], - xf86-video-modesetting) + [xf86-video-modesetting]) AC_CONFIG_SRCDIR([Makefile.am]) AM_CONFIG_HEADER([config.h]) + +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.8 or later before runnign autoconf/autogen])]) +XORG_MACROS_VERSION(1.8) +XORG_DEFAULT_OPTIONS + AC_CONFIG_AUX_DIR(.) -AM_INIT_AUTOMAKE([dist-bzip2]) +AM_INIT_AUTOMAKE([foreign dist-bzip2]) +AC_SYS_LARGEFILE AM_MAINTAINER_MODE # Checks for programs. AC_DISABLE_STATIC AC_PROG_LIBTOOL -DOLT AC_PROG_CC AM_PROG_CC_C_O @@ -49,11 +55,6 @@ AC_ARG_WITH(xorg-module-dir, [moduledir="$withval"], [moduledir="$libdir/xorg/modules"]) -AC_ARG_WITH(gallium-dir, - AC_HELP_STRING([--with-gallium-dir=DIR], - [gallium directory [[default=none]]]), - [GALLIUM_DIR="$withval"]) - AC_ARG_ENABLE(dri, AC_HELP_STRING([--disable-dri], [Disable DRI support [[default=auto]]]), [DRI="$enableval"], @@ -74,115 +75,23 @@ sdkdir=$(pkg-config --variable=sdkdir xorg-server) # Checks for header files. AC_HEADER_STDC -AC_MSG_CHECKING([whether to include DRI support]) -if test x$DRI = xauto; then - AC_CHECK_FILE([${sdkdir}/dri.h], - [have_dri_h="yes"], [have_dri_h="no"]) - AC_CHECK_FILE([${sdkdir}/sarea.h], - [have_sarea_h="yes"], [have_sarea_h="no"]) - AC_CHECK_FILE([${sdkdir}/dristruct.h], - [have_dristruct_h="yes"], [have_dristruct_h="no"]) - AC_CHECK_FILE([${sdkdir}/damage.h], - [have_damage_h="yes"], [have_damage_h="no"]) - - if test "$have_dri_h" = yes -a \ - "$have_sarea_h" = yes -a \ - "$have_dristruct_h" = yes; then - DRI="yes" - else - DRI="no" - fi -fi -AC_MSG_RESULT([$DRI]) - -save_CFLAGS="$CFLAGS" -CFLAGS="$XORG_CFLAGS" -AC_CHECK_DECL(XSERVER_LIBPCIACCESS, - [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no], - [#include "xorg-server.h"]) -CFLAGS="$save_CFLAGS" - -if test x$XSERVER_LIBPCIACCESS = xyes; then - PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10]) -else - PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10], - have_libpciaccess=yes, - have_libpciaccess=no) -fi -AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes) -AM_CONDITIONAL(LIBPCIACCESS, - test "x$XSERVER_LIBPCIACCESS" = xyes -o "x$have_libpciaccess" = xyes) - -if test "x$XSERVER_SOURCE" = x; then - if test -d ../../xserver; then - XSERVER_SOURCE="`cd ../../xserver && pwd`" - fi -fi - -if test -d "$XSERVER_SOURCE"; then - case "$XSERVER_SOURCE" in - /*) - ;; - *) - XSERVER_SOURCE="`cd $XSERVER_SOURCE && pwd`" - ;; - esac - if test -f $srcdir/src/modes/xf86Modes.h; then - : - else - ln -sf $XSERVER_SOURCE/hw/xfree86/modes $srcdir/src/modes - fi - - if test -f $srcdir/src/parser/xf86Parser.h; then - : - else - ln -sf $XSERVER_SOURCE/hw/xfree86/parser $srcdir/src/parser - fi -fi - -dnl Use lots of warning flags with GCC - -WARN_CFLAGS="" +PKG_CHECK_MODULES(DRM, [libdrm >= 2.2]) +PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10]) +AM_CONDITIONAL(DRM, test "x$DRM" = xyes) -if test "x$GCC" = "xyes"; then - WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \ - -Wmissing-prototypes -Wmissing-declarations \ - -Wnested-externs -fno-strict-aliasing" +PKG_CHECK_MODULES(UDEV, [libudev], [udev=yes], [udev=no]) +if test x"$udev" = xyes; then + AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection]) fi -AM_CONDITIONAL(DRI, test x$DRI = xyes) -if test "$DRI" = yes; then - PKG_CHECK_MODULES(DRI, [libdrm xf86driproto]) - AC_DEFINE(XF86DRI,1,[Enable DRI driver support]) - AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support]) - PKG_CHECK_MODULES(DRI_MM, [libdrm >= 2.3.1],[DRI_MM=yes], [DRI_MM=no]) - if test "x$DRI_MM" = xyes; then - AC_DEFINE(XF86DRI_MM,1,[Extended DRI memory management]) - fi - if test "$have_damage_h" = yes; then - AC_DEFINE(DAMAGE,1,[Use Damage extension]) - fi - CFLAGS="$XORG_CFLAGS $DRI_CFLAGS" -fi - -AC_SUBST([DRI_CFLAGS]) -AC_SUBST([XORG_CFLAGS]) -AC_SUBST([WARN_CFLAGS]) -AC_SUBST([GALLIUM_DIR]) -AC_SUBST([moduledir]) - DRIVER_NAME=modesetting AC_SUBST([DRIVER_NAME]) +AC_SUBST([moduledir]) -m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.1.3 or later before running autoconf/autogen])]) -XORG_MACROS_VERSION(1.1.3) -XORG_MANPAGE_SECTIONS -XORG_RELEASE_VERSION - -XORG_CHECK_LINUXDOC - -AC_OUTPUT([ +AC_CONFIG_FILES([ Makefile src/Makefile man/Makefile ]) + +AC_OUTPUT diff --git a/man/Makefile.am b/man/Makefile.am index 89ca862..936821c 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -25,14 +25,7 @@ # drivermandir = $(DRIVER_MAN_DIR) - -DRIVER_MAN_DIR_SUFFIX = $(DRIVER_MAN_DIR:@mandir@/man%=%) - -driverman_PRE = @DRIVER_NAME at .man - -driverman_DATA = \ - $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@) \ - modesetting. at DRIVER_MAN_SUFFIX@ +driverman_DATA = $(DRIVER_NAME).$(DRIVER_MAN_SUFFIX) EXTRA_DIST = @DRIVER_NAME at .man @@ -40,30 +33,8 @@ CLEANFILES = $(driverman_DATA) SED = sed -# Strings to replace in man pages -XORGRELSTRING = @PACKAGE_STRING@ - XORGMANNAME = X Version 11 - -MAN_SUBSTS = \ - -e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \ - -e 's|__xorgversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \ - -e 's|__xservername__|Xorg|g' \ - -e 's|__xconfigfile__|xorg.conf|g' \ - -e 's|__projectroot__|$(prefix)|g' \ - -e 's|__appmansuffix__|$(APP_MAN_SUFFIX)|g' \ - -e 's|__drivermansuffix__|$(DRIVER_MAN_SUFFIX)|g' \ - -e 's|__adminmansuffix__|$(ADMIN_MAN_SUFFIX)|g' \ - -e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \ - -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' - SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man .man.$(DRIVER_MAN_SUFFIX): sed $(MAN_SUBSTS) < $< > $@ -BUILT_SOURCES = shadows.DONE - -shadows.DONE: - -rm -f modesetting. at DRIVER_MAN_SUFFIX@ - echo .so man$(DRIVER_MAN_DIR_SUFFIX)/modesetting.$(DRIVER_MAN_SUFFIX) > \ - modesetting. at DRIVER_MAN_SUFFIX@ diff --git a/src/Makefile.am b/src/Makefile.am index 23e78b7..4337977 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,19 +25,16 @@ SUBDIRS = # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ @PCIACCESS_CFLAGS@ \ - -I at GALLIUM_DIR@/src/gallium/include \ - -I at GALLIUM_DIR@/src/gallium/auxiliary +AM_CFLAGS = @XORG_CFLAGS@ @DRM_CFLAGS@ @UDEV_CFLAGS@ modesetting_drv_la_LTLIBRARIES = modesetting_drv.la -modesetting_drv_la_LDFLAGS = -module -avoid-version -ldrm +modesetting_drv_la_LDFLAGS = -module -avoid-version +modesetting_drv_la_LIBADD = @UDEV_LIBS@ @DRM_LIBS@ modesetting_drv_ladir = @moduledir@/drivers modesetting_drv_la_SOURCES = \ driver.c \ driver.h \ - output.c \ - crtc.c \ - dri2.c + drmmode_display.c EXTRA_DIST = diff --git a/src/crtc.c b/src/crtc.c deleted file mode 100644 index d4f449b..0000000 --- a/src/crtc.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, 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. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - * - * Author: Alan Hourihane <alanh at tungstengraphics.com> - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <unistd.h> -#include <string.h> -#include <assert.h> -#include <stdlib.h> -#include <math.h> -#include <stdint.h> - -#include <xf86.h> -#include <xf86i2c.h> -#include <xf86Crtc.h> -#include "driver.h" -#include "xf86Modes.h" - -#define DPMS_SERVER -#include <X11/extensions/dpms.h> - -struct crtc_private -{ - drmModeCrtcPtr drm_crtc; - - /* hwcursor */ - drmBO cursor_bo; -}; - -static void -crtc_dpms(xf86CrtcPtr crtc, int mode) -{ - ScrnInfoPtr pScrn = crtc->scrn; - - switch (mode) { - case DPMSModeOn: - case DPMSModeStandby: - case DPMSModeSuspend: - break; - case DPMSModeOff: - break; - } -} - -static Bool -crtc_lock(xf86CrtcPtr crtc) -{ - return FALSE; -} - -static void -crtc_unlock(xf86CrtcPtr crtc) -{ -} - -static void -crtc_prepare(xf86CrtcPtr crtc) -{ -} - -static void -crtc_commit(xf86CrtcPtr crtc) -{ -} - -static Bool -crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode, - DisplayModePtr adjusted_mode) -{ - return TRUE; -} - -static void -crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, - DisplayModePtr adjusted_mode, int x, int y) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); - modesettingPtr ms = modesettingPTR(crtc->scrn); - xf86OutputPtr output = config->output[config->compat_output]; - drmModeConnectorPtr drm_connector = output->driver_private; - struct crtc_private *crtcp = crtc->driver_private; - drmModeCrtcPtr drm_crtc = crtcp->drm_crtc; - struct drm_mode_modeinfo drm_mode; - - drm_mode.clock = mode->Clock; - drm_mode.hdisplay = mode->HDisplay; - drm_mode.hsync_start = mode->HSyncStart; - drm_mode.hsync_end = mode->HSyncEnd; - drm_mode.htotal = mode->HTotal; - drm_mode.vdisplay = mode->VDisplay; - drm_mode.vsync_start = mode->VSyncStart; - drm_mode.vsync_end = mode->VSyncEnd; - drm_mode.vtotal = mode->VTotal; - drm_mode.flags = mode->Flags; - drm_mode.hskew = mode->HSkew; - drm_mode.vscan = mode->VScan; - drm_mode.vrefresh = mode->VRefresh; - if (!mode->name) - xf86SetModeDefaultName(mode); - strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN); - - drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, - &drm_connector->connector_id, 1, &drm_mode); -} - -void -crtc_load_lut(xf86CrtcPtr crtc) -{ - ScrnInfoPtr pScrn = crtc->scrn; -} - -static void -crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue, - int size) -{ -} - -static void * -crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) -{ - ScrnInfoPtr pScrn = crtc->scrn; - - return NULL; -} - -static PixmapPtr -crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) -{ - ScrnInfoPtr pScrn = crtc->scrn; - - return NULL; -} - -static void -crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) -{ - ScrnInfoPtr pScrn = crtc->scrn; -} - -static void -crtc_destroy(xf86CrtcPtr crtc) -{ - modesettingPtr ms = modesettingPTR(crtc->scrn); - struct crtc_private *crtcp = crtc->driver_private; - - if (crtcp->cursor_bo.handle) - drmBOUnreference(ms->fd, &crtcp->cursor_bo); - - drmModeFreeCrtc(crtcp->drm_crtc); - xfree(crtcp); -} - -static void -crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image) -{ - unsigned char *ptr; - modesettingPtr ms = modesettingPTR(crtc->scrn); - struct crtc_private *crtcp = crtc->driver_private; - - if (!crtcp->cursor_bo.handle) - drmBOCreate(ms->fd, 64 * 64 * 4, 0, NULL, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE - | DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_MAPPABLE | - DRM_BO_FLAG_MEM_VRAM, - DRM_BO_HINT_DONT_FENCE, &crtcp->cursor_bo); - - drmBOMap(ms->fd, &crtcp->cursor_bo, DRM_BO_FLAG_WRITE, - DRM_BO_HINT_DONT_FENCE, (void **)&ptr); - - if (ptr) - memcpy(ptr, image, 64 * 64 * 4); - - drmBOUnmap(ms->fd, &crtcp->cursor_bo); -} - -static void -crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) -{ - modesettingPtr ms = modesettingPTR(crtc->scrn); - struct crtc_private *crtcp = crtc->driver_private; - - drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y); -} - -static void -crtc_show_cursor(xf86CrtcPtr crtc) -{ - modesettingPtr ms = modesettingPTR(crtc->scrn); - struct crtc_private *crtcp = crtc->driver_private; - - if (crtcp->cursor_bo.handle) - drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, - crtcp->cursor_bo.handle, 64, 64); -} - -static void -crtc_hide_cursor(xf86CrtcPtr crtc) -{ - modesettingPtr ms = modesettingPTR(crtc->scrn); - struct crtc_private *crtcp = crtc->driver_private; - - drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0); -} - -static const xf86CrtcFuncsRec crtc_funcs = { - .dpms = crtc_dpms, - .save = NULL, - .restore = NULL, - .lock = crtc_lock, - .unlock = crtc_unlock, - .mode_fixup = crtc_mode_fixup, - .prepare = crtc_prepare, - .mode_set = crtc_mode_set, - .commit = crtc_commit, - .gamma_set = crtc_gamma_set, - .shadow_create = crtc_shadow_create, - .shadow_allocate = crtc_shadow_allocate, - .shadow_destroy = crtc_shadow_destroy, - .set_cursor_position = crtc_set_cursor_position, - .show_cursor = crtc_show_cursor, - .hide_cursor = crtc_hide_cursor, - .load_cursor_image = NULL, /* lets convert to argb only */ - .set_cursor_colors = NULL, /* using argb only */ - .load_cursor_argb = crtc_load_cursor_argb, - .destroy = crtc_destroy, -}; - -void -cursor_destroy(xf86CrtcPtr crtc) -{ - modesettingPtr ms = modesettingPTR(crtc->scrn); - struct crtc_private *crtcp = crtc->driver_private; - - if (crtcp->cursor_bo.handle) { - drmBOSetStatus(ms->fd, &crtcp->cursor_bo, 0, 0, 0, 0, 0); - drmBOUnreference(ms->fd, &crtcp->cursor_bo); - } -} - -void -crtc_init(ScrnInfoPtr pScrn) -{ - modesettingPtr ms = modesettingPTR(pScrn); - xf86CrtcPtr crtc; - drmModeResPtr res; - drmModeCrtcPtr drm_crtc = NULL; - struct crtc_private *crtcp; - int c, k, p; - - res = drmModeGetResources(ms->fd); - if (res == 0) { - ErrorF("Failed drmModeGetResources %d\n", errno); - return; - } - - for (c = 0; c < res->count_crtcs; c++) { - drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]); - if (!drm_crtc) - continue; - - crtc = xf86CrtcCreate(pScrn, &crtc_funcs); - if (crtc == NULL) - goto out; - - crtcp = xcalloc(1, sizeof(struct crtc_private)); - if (!crtcp) { - xf86CrtcDestroy(crtc); - goto out; - } - - crtcp->drm_crtc = drm_crtc; - - crtc->driver_private = crtcp; - - } - - out: - drmModeFreeResources(res); -} diff --git a/src/dri2.c b/src/dri2.c deleted file mode 100644 index 7fd9fca..0000000 --- a/src/dri2.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, 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. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - * - * Author: Alan Hourihane <alanh at tungstengraphics.com> - * - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "xf86.h" -#include "xf86_OSproc.h" - -#include "driver.h" - -#include "dri2.h" - -extern unsigned int -driGetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags); - -void -driLock(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - - if (!ms->lock_held) - DRM_LOCK(ms->fd, ms->lock, ms->context, 0); - - ms->lock_held = 1; -} - -void -driUnlock(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - - if (ms->lock_held) - DRM_UNLOCK(ms->fd, ms->lock, ms->context); - - ms->lock_held = 0; -} - -static void -driBeginClipNotify(ScreenPtr pScreen) -{ - driLock(pScreen); -} - -static void -driEndClipNotify(ScreenPtr pScreen) -{ - driUnlock(pScreen); -} - -struct __DRILock -{ - unsigned int block_header; - drm_hw_lock_t lock; - unsigned int next_id; -}; - -#define DRI2_SAREA_BLOCK_HEADER(type, size) (((type) << 16) | (size)) -#define DRI2_SAREA_BLOCK_LOCK 0x0001 - -void -driScreenInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - DRI2InfoRec dri2info; - const char *driverName; - unsigned int sarea_handle; - struct __DRILock *DRILock; - void *p; - - dri2info.version = 1; - dri2info.fd = ms->fd; - dri2info.driverSareaSize = sizeof(struct __DRILock); - dri2info.driverName = "i915"; /* FIXME */ - dri2info.getPixmapHandle = driGetPixmapHandle; - dri2info.beginClipNotify = driBeginClipNotify; - dri2info.endClipNotify = driEndClipNotify; - - p = DRI2ScreenInit(pScreen, &dri2info); - if (!p) - return; - - DRILock = p; - DRILock->block_header = - DRI2_SAREA_BLOCK_HEADER(DRI2_SAREA_BLOCK_LOCK, sizeof *DRILock); - ms->lock = &DRILock->lock; - ms->context = 1; - DRILock->next_id = 2; - driLock(pScreen); - - DRI2Connect(pScreen, &ms->fd, &driverName, &sarea_handle); -} - -void -driCloseScreen(ScreenPtr pScreen) -{ - driUnlock(pScreen); - DRI2CloseScreen(pScreen); -} diff --git a/src/driver.c b/src/driver.c index 6b70d4b..47ffb07 100644 --- a/src/driver.c +++ b/src/driver.c @@ -34,10 +34,8 @@ #include "xf86.h" #include "xf86_OSproc.h" #include "compiler.h" -#include "xf86RAC.h" #include "xf86PciInfo.h" #include "xf86Pci.h" -#include "xf86Resources.h" #include "mipointer.h" #include "micmap.h" #include <X11/extensions/randr.h> @@ -59,8 +57,6 @@ static void AdjustFrame(int scrnIndex, int x, int y, int flags); static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool EnterVT(int scrnIndex, int flags); -static Bool SaveHWState(ScrnInfoPtr pScrn); -static Bool RestoreHWState(ScrnInfoPtr pScrn); static void Identify(int flags); static const OptionInfoRec *AvailableOptions(int chipid, int busid); static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, @@ -82,7 +78,7 @@ static Bool Probe(DriverPtr drv, int flags); #if XSERVER_LIBPCIACCESS static const struct pci_id_match device_match[] = { - {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0}, + {0x8086, 0x0046, 0xffff, 0xffff, 0, 0, 0}, {0, 0, 0}, }; #endif @@ -107,12 +103,12 @@ _X_EXPORT DriverRec modesetting = { }; static SymTabRec Chipsets[] = { - {0x2592, "Intel Graphics Device"}, + {0x0046, "Intel Graphics Device"}, {-1, NULL} }; static PciChipsets PciDevices[] = { - {0x2592, 0x2592, RES_SHARED_VGA}, + {0x2592, 0x0046, RES_SHARED_VGA}, {-1, -1, RES_UNDEFINED} }; @@ -126,24 +122,6 @@ static const OptionInfoRec Options[] = { {-1, NULL, OPTV_NONE, {0}, FALSE} }; -static const char *fbSymbols[] = { - "fbPictureInit", - "fbScreenInit", - NULL -}; - -static const char *ddcSymbols[] = { - "xf86PrintEDID", - "xf86SetDDCproperties", - NULL -}; - -static const char *i2cSymbols[] = { - "xf86CreateI2CBusRec", - "xf86I2CBusInit", - NULL -}; - int modesettingEntityIndex = -1; static MODULESETUPPROTO(Setup); @@ -175,12 +153,6 @@ Setup(pointer module, pointer opts, int *errmaj, int *errmin) xf86AddDriver(&modesetting, module, HaveDriverFuncs); /* - * Tell the loader about symbols from other modules that this module - * might refer to. - */ - LoaderRefSymLists(fbSymbols, ddcSymbols, NULL); - - /* * The return value must be non-NULL on success even though there * is no TearDownProc. */ @@ -225,7 +197,7 @@ pci_probe(DriverPtr driver, entity = xf86GetEntityInfo(entity_num); switch (device->device_id) { - case 0x2592: + case 0x0046: scrn->PreInit = PreInit; scrn->ScreenInit = ScreenInit; scrn->SwitchMode = SwitchMode; @@ -358,8 +330,8 @@ Probe(DriverPtr drv, int flags) } } - xfree(usedChips); - xfree(devSections); + free(usedChips); + free(devSections); return foundScreen; } @@ -385,76 +357,11 @@ FreeRec(ScrnInfoPtr pScrn) if (!pScrn->driverPrivate) return; - xfree(pScrn->driverPrivate); + free(pScrn->driverPrivate); pScrn->driverPrivate = NULL; } -static void -ProbeDDC(ScrnInfoPtr pScrn, int index) -{ - ConfiguredMonitor = NULL; -} - -static Bool -CreateFrontBuffer(ScrnInfoPtr pScrn) -{ - modesettingPtr ms = modesettingPTR(pScrn); - ScreenPtr pScreen = pScrn->pScreen; - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - Bool fbAccessDisabled; - int flags; - - pScreen->ModifyPixmapHeader(rootPixmap, - pScrn->virtualX, pScrn->virtualY, - pScrn->depth, pScrn->bitsPerPixel, - pScrn->displayWidth * pScrn->bitsPerPixel / 8, - NULL); - drmModeAddFB(ms->fd, - pScrn->virtualX, - pScrn->virtualY, - pScrn->depth, - pScrn->bitsPerPixel, - pScrn->displayWidth * pScrn->bitsPerPixel / 8, - driGetPixmapHandle(rootPixmap, &flags), &ms->fb_id); - - pScrn->frameX0 = 0; - pScrn->frameY0 = 0; - AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - - return TRUE; -} - -static Bool -crtc_resize(ScrnInfoPtr pScrn, int width, int height) -{ - modesettingPtr ms = modesettingPTR(pScrn); - ScreenPtr pScreen = pScrn->pScreen; - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - Bool fbAccessDisabled; - CARD8 *fbstart; - - if (width == pScrn->virtualX && height == pScrn->virtualY) - return TRUE; - - ErrorF("RESIZING TO %dx%d\n", width, height); - - pScrn->virtualX = width; - pScrn->virtualY = height; - - /* HW dependent - FIXME */ - pScrn->displayWidth = pScrn->virtualX; - - drmModeRmFB(ms->fd, ms->fb_id); - - /* now create new frontbuffer */ - return CreateFrontBuffer(pScrn); -} - -static const xf86CrtcConfigFuncsRec crtc_config_funcs = { - crtc_resize -}; - static Bool PreInit(ScrnInfoPtr pScrn, int flags) { @@ -476,8 +383,7 @@ PreInit(ScrnInfoPtr pScrn, int flags) pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (flags & PROBE_DETECT) { - ProbeDDC(pScrn, pEnt->index); - return TRUE; + return FALSE; } /* Allocate driverPrivate */ @@ -503,10 +409,6 @@ PreInit(ScrnInfoPtr pScrn, int flags) } else ms->entityPrivate = NULL; - if (xf86RegisterResources(ms->pEnt->index, NULL, ResNone)) { - return FALSE; - } - if (xf86IsEntityShared(pScrn->entityList[0])) { if (xf86IsPrimInitDone(pScrn->entityList[0])) { /* do something */ @@ -515,7 +417,7 @@ PreInit(ScrnInfoPtr pScrn, int flags) } } - BusID = xalloc(64); + BusID = malloc(64); sprintf(BusID, "PCI:%d:%d:%d", #if XSERVER_LIBPCIACCESS ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), @@ -528,11 +430,9 @@ PreInit(ScrnInfoPtr pScrn, int flags) ); ms->fd = drmOpen(NULL, BusID); - if (ms->fd < 0) return FALSE; - pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; pScrn->monitor = pScrn->confScreen->monitor; pScrn->progClock = TRUE; pScrn->rgbBits = 8; @@ -562,36 +462,21 @@ PreInit(ScrnInfoPtr pScrn, int flags) /* Process the options */ xf86CollectOptions(pScrn, NULL); - if (!(ms->Options = xalloc(sizeof(Options)))) + if (!(ms->Options = malloc(sizeof(Options)))) return FALSE; memcpy(ms->Options, Options, sizeof(Options)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options); - /* Allocate an xf86CrtcConfig */ - xf86CrtcConfigInit(pScrn, &crtc_config_funcs); - xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - - max_width = 8192; - max_height = 8192; - xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height); - if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) { ms->SWCursor = TRUE; } - SaveHWState(pScrn); - - crtc_init(pScrn); - output_init(pScrn); - - if (!xf86InitialConfiguration(pScrn, TRUE)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); - RestoreHWState(pScrn); - return FALSE; + ms->drmmode.fd = ms->fd; + if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n"); + goto fail; } - RestoreHWState(pScrn); - /* * If the driver can do gamma correction, it should call xf86SetGamma() here. */ @@ -618,29 +503,13 @@ PreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } - xf86LoaderReqSymLists(fbSymbols, NULL); - #ifdef DRI2 xf86LoadSubModule(pScrn, "dri2"); #endif return TRUE; -} - -static Bool -SaveHWState(ScrnInfoPtr pScrn) -{ - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - - return TRUE; -} - -static Bool -RestoreHWState(ScrnInfoPtr pScrn) -{ - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - - return TRUE; + fail: + return FALSE; } static Bool @@ -651,25 +520,24 @@ CreateScreenResources(ScreenPtr pScreen) PixmapPtr rootPixmap; Bool ret; int flags; - + void *pixels; pScreen->CreateScreenResources = ms->createScreenResources; ret = pScreen->CreateScreenResources(pScreen); pScreen->CreateScreenResources = CreateScreenResources; - rootPixmap = pScreen->GetScreenPixmap(pScreen); + if (!drmmode_set_desired_modes(pScrn, &ms->drmmode)) + return FALSE; - if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL)) - FatalError("Couldn't adjust screen pixmap\n"); + drmmode_uevent_init(pScrn, &ms->drmmode); - drmModeAddFB(ms->fd, - pScrn->virtualX, - pScrn->virtualY, - pScrn->depth, - pScrn->bitsPerPixel, - pScrn->displayWidth * pScrn->bitsPerPixel / 8, - driGetPixmapHandle(rootPixmap, &flags), &ms->fb_id); + drmmode_map_cursor_bos(pScrn, &ms->drmmode); + pixels = drmmode_map_front_bo(&ms->drmmode); + if (!pixels) + return FALSE; - AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + rootPixmap = pScreen->GetScreenPixmap(pScreen); + if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels)) + FatalError("Couldn't adjust screen pixmap\n"); return ret; } @@ -688,7 +556,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (ms->fd < 0) { char *BusID; - BusID = xalloc(64); + BusID = malloc(64); sprintf(BusID, "PCI:%d:%d:%d", #if XSERVER_LIBPCIACCESS ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), @@ -710,6 +578,8 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* HW dependent - FIXME */ pScrn->displayWidth = pScrn->virtualX; + if (!drmmode_create_initial_bos(pScrn, &ms->drmmode)) + return FALSE; miClearVisualTypes(); @@ -782,10 +652,6 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (serverGeneration == 1) xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); -#ifdef DRI2 - driScreenInit(pScreen); -#endif - return EnterVT(scrnIndex, 1); } @@ -822,7 +688,7 @@ LeaveVT(int scrnIndex, int flags) for (o = 0; o < config->num_crtc; o++) { xf86CrtcPtr crtc = config->crtc[o]; - cursor_destroy(crtc); + // cursor_destroy(crtc); if (crtc->rotatedPixmap || crtc->rotatedData) { crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap, @@ -834,16 +700,6 @@ LeaveVT(int scrnIndex, int flags) drmModeRmFB(ms->fd, ms->fb_id); - RestoreHWState(pScrn); - -#if 0 - drmMMLock(ms->fd, DRM_BO_MEM_VRAM, 1, 0); - drmMMLock(ms->fd, DRM_BO_MEM_TT, 1, 0); -#endif -#ifdef DRI2 - driLock(pScrn->pScreen); -#endif - pScrn->vtSema = FALSE; } @@ -856,29 +712,6 @@ EnterVT(int scrnIndex, int flags) ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; modesettingPtr ms = modesettingPTR(pScrn); -#if 0 - if (pScrn->vtSema) { - drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1); - drmMMUnlock(ms->fd, DRM_BO_MEM_TT, 1); - } -#endif - -#ifdef DRI2 - driUnlock(pScrn->pScreen); -#endif - - /* - * Only save state once per server generation since that's what most - * drivers do. Could change this to save state at each VT enter. - */ - if (ms->SaveGeneration != serverGeneration) { - ms->SaveGeneration = serverGeneration; - SaveHWState(pScrn); - } - - if (!flags) /* signals startup as we'll do this in CreateScreenResources */ - CreateFrontBuffer(pScrn); - if (!xf86SetDesiredModes(pScrn)) return FALSE; @@ -899,16 +732,13 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; modesettingPtr ms = modesettingPTR(pScrn); + drmmode_uevent_fini(pScrn, &ms->drmmode); + + drmmode_free_bos(pScrn, &ms->drmmode); + if (pScrn->vtSema) { LeaveVT(scrnIndex, 0); -#if 0 - drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1); - drmMMUnlock(ms->fd, DRM_BO_MEM_TT, 1); -#endif } -#ifdef DRI2 - driCloseScreen(pScreen); -#endif pScreen->CreateScreenResources = ms->createScreenResources; diff --git a/src/driver.h b/src/driver.h index a673f8f..255dede 100644 --- a/src/driver.h +++ b/src/driver.h @@ -30,9 +30,8 @@ #include <errno.h> #include <drm.h> #include <xf86drm.h> -#include <xf86drmMode.h> -#include <xf86mm.h> +#include "drmmode_display.h" #define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); typedef struct @@ -72,10 +71,7 @@ typedef struct _modesettingRec void *driver; - /* dri2 */ - drm_context_t context; - drm_hw_lock_t *lock; - int lock_held; + drmmode_rec drmmode; } modesettingRec, *modesettingPtr; #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) diff --git a/src/drmmode_display.c b/src/drmmode_display.c new file mode 100644 index 0000000..d94ce03 --- /dev/null +++ b/src/drmmode_display.c @@ -0,0 +1,1340 @@ +/* + * Copyright ?? 2007 Red Hat, 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 (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 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. + * + * Authors: + * Dave Airlie <airlied at redhat.com> + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <errno.h> +#include <sys/ioctl.h> +#include <sys/mman.h> +#include "xf86str.h" +#include "X11/Xatom.h" +#include "micmap.h" +#include "xf86cmap.h" +#include "xf86DDC.h" + +#include <xf86drm.h> +#include "xf86Crtc.h" +#include "drmmode_display.h" + +/* DPMS */ +#ifdef HAVE_XEXTPROTO_71 +#include <X11/extensions/dpmsconst.h> +#else +#define DPMS_SERVER +#include <X11/extensions/dpms.h> +#endif + +static struct dumb_bo *dumb_bo_create(int fd, + const unsigned width, const unsigned height, + const unsigned bpp) +{ + struct drm_mode_create_dumb arg; + struct dumb_bo *bo; + int ret; + + bo = calloc(1, sizeof(*bo)); + if (!bo) + return NULL; + + memset(&arg, 0, sizeof(arg)); + arg.width = width; + arg.height = height; + arg.bpp = bpp; + + ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); + if (ret) + goto err_free; + + bo->handle = arg.handle; + bo->size = arg.size; + bo->pitch = arg.pitch; + + return bo; + err_free: + free(bo); + return NULL; +} + +static int dumb_bo_map(int fd, struct dumb_bo *bo) +{ + struct drm_mode_map_dumb arg; + int ret; + void *map; + + if (bo->ptr) { + bo->map_count++; + return 0; + } + + memset(&arg, 0, sizeof(arg)); + arg.handle = bo->handle; + + ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg); + if (ret) + return ret; + + map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, + fd, arg.offset); + if (map == MAP_FAILED) + return -errno; + + bo->ptr = map; + return 0; +} + +static int dumb_bo_unmap(int fd, struct dumb_bo *bo) +{ + bo->map_count--; + return 0; +} + +static int dumb_bo_destroy(int fd, struct dumb_bo *bo) +{ + struct drm_mode_destroy_dumb arg; + int ret; + + if (bo->ptr) { + munmap(bo->ptr, bo->size); + bo->ptr = NULL; + } + + memset(&arg, 0, sizeof(arg)); + arg.handle = bo->handle; + ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg); + if (ret) + return -errno; + + free(bo); + return 0; +} + +static void +drmmode_ConvertFromKMode(ScrnInfoPtr scrn, + drmModeModeInfo *kmode, + DisplayModePtr mode) +{ + memset(mode, 0, sizeof(DisplayModeRec)); + mode->status = MODE_OK; + + mode->Clock = kmode->clock; + + mode->HDisplay = kmode->hdisplay; + mode->HSyncStart = kmode->hsync_start; + mode->HSyncEnd = kmode->hsync_end; + mode->HTotal = kmode->htotal; + mode->HSkew = kmode->hskew; + + mode->VDisplay = kmode->vdisplay; + mode->VSyncStart = kmode->vsync_start; + mode->VSyncEnd = kmode->vsync_end; + mode->VTotal = kmode->vtotal; + mode->VScan = kmode->vscan; + + mode->Flags = kmode->flags; //& FLAG_BITS; + mode->name = strdup(kmode->name); + + if (kmode->type & DRM_MODE_TYPE_DRIVER) + mode->type = M_T_DRIVER; + if (kmode->type & DRM_MODE_TYPE_PREFERRED) + mode->type |= M_T_PREFERRED; + xf86SetModeCrtc (mode, scrn->adjustFlags); +} + +static void +drmmode_ConvertToKMode(ScrnInfoPtr scrn, + drmModeModeInfo *kmode, + DisplayModePtr mode) +{ + memset(kmode, 0, sizeof(*kmode)); + + kmode->clock = mode->Clock; + kmode->hdisplay = mode->HDisplay; + kmode->hsync_start = mode->HSyncStart; + kmode->hsync_end = mode->HSyncEnd; + kmode->htotal = mode->HTotal; + kmode->hskew = mode->HSkew; + + kmode->vdisplay = mode->VDisplay; + kmode->vsync_start = mode->VSyncStart; + kmode->vsync_end = mode->VSyncEnd; + kmode->vtotal = mode->VTotal; + kmode->vscan = mode->VScan; + + kmode->flags = mode->Flags; //& FLAG_BITS; + if (mode->name) + strncpy(kmode->name, mode->name, DRM_DISPLAY_MODE_LEN); + kmode->name[DRM_DISPLAY_MODE_LEN-1] = 0; + +} + +static void +drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode) +{ +#if 0 + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); +// drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +// drmmode_ptr drmmode = drmmode_crtc->drmmode; + + /* bonghits in the randr 1.2 - uses dpms to disable crtc - bad buzz */ + if (mode == DPMSModeOff) { +// drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, +// 0, 0, 0, NULL, 0, NULL); + } +#endif +} + +#if 0 +static PixmapPtr +create_pixmap_for_fbcon(drmmode_ptr drmmode, + ScrnInfoPtr pScrn, int crtc_id) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + drmmode_crtc_private_ptr drmmode_crtc; + ScreenPtr pScreen = pScrn->pScreen; + PixmapPtr pixmap; + struct radeon_bo *bo; + drmModeFBPtr fbcon; + struct drm_gem_flink flink; + + drmmode_crtc = xf86_config->crtc[crtc_id]->driver_private; + + fbcon = drmModeGetFB(drmmode->fd, drmmode_crtc->mode_crtc->buffer_id); + if (fbcon == NULL) + return NULL; + + flink.handle = fbcon->handle; + if (ioctl(drmmode->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Couldn't flink fbcon handle\n"); + return NULL; + } + + bo = radeon_bo_open(drmmode->bufmgr, flink.name, 0, 0, 0, 0); + if (bo == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Couldn't allocate bo for fbcon handle\n"); + return NULL; + } + + pixmap = drmmode_create_bo_pixmap(pScreen, fbcon->width, fbcon->height, + fbcon->depth, fbcon->bpp, + fbcon->pitch, bo); + if (!pixmap) + return NULL; + + radeon_bo_unref(bo); + drmModeFreeFB(fbcon); + return pixmap; +} + +#endif + +static Bool +drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, + Rotation rotation, int x, int y) +{ + ScrnInfoPtr pScrn = crtc->scrn; + // RADEONInfoPtr info = RADEONPTR(pScrn); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; + int saved_x, saved_y; + Rotation saved_rotation; + DisplayModeRec saved_mode; + uint32_t *output_ids; + int output_count = 0; + Bool ret = TRUE; + int i; + int fb_id; + drmModeModeInfo kmode; + int pitch; + uint32_t tiling_flags = 0; + int height; + + pitch = pScrn->displayWidth; + height = pScrn->virtualY; + + if (drmmode->fb_id == 0) { + ret = drmModeAddFB(drmmode->fd, + pScrn->virtualX, height, + pScrn->depth, pScrn->bitsPerPixel, + drmmode->front_bo->pitch, + drmmode->front_bo->handle, + &drmmode->fb_id); + if (ret < 0) { + ErrorF("failed to add fb %d\n", ret); + return FALSE; + } + } + + saved_mode = crtc->mode; + saved_x = crtc->x; + saved_y = crtc->y; + saved_rotation = crtc->rotation; + + if (mode) { + crtc->mode = *mode; + crtc->x = x; + crtc->y = y; + crtc->rotation = rotation; +#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,5,99,0,0) + crtc->transformPresent = FALSE; +#endif + } + + output_ids = calloc(sizeof(uint32_t), xf86_config->num_output); + if (!output_ids) { + ret = FALSE; + goto done; + } + + if (mode) { + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + drmmode_output_private_ptr drmmode_output; + + if (output->crtc != crtc) + continue; + + drmmode_output = output->driver_private; + output_ids[output_count] = drmmode_output->mode_output->connector_id; + output_count++; + } + + if (!xf86CrtcRotate(crtc)) { + goto done; + } +#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,0,0,0) + crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green, + crtc->gamma_blue, crtc->gamma_size); +#endif + + drmmode_ConvertToKMode(crtc->scrn, &kmode, mode); + + fb_id = drmmode->fb_id; + if (drmmode_crtc->rotate_fb_id) { + fb_id = drmmode_crtc->rotate_fb_id; + x = y = 0; + } + ret = drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, + fb_id, x, y, output_ids, output_count, &kmode); + if (ret) + xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, + "failed to set mode: %s", strerror(-ret)); + else + ret = TRUE; + + if (crtc->scrn->pScreen) + xf86CrtcSetScreenSubpixelOrder(crtc->scrn->pScreen); + /* go through all the outputs and force DPMS them back on? */ + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + + if (output->crtc != crtc) + continue; + + output->funcs->dpms(output, DPMSModeOn); + } + } + +#if 0 + if (pScrn->pScreen && + !xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) + xf86_reload_cursors(pScrn->pScreen); +#endif +done: + if (!ret) { + crtc->x = saved_x; + crtc->y = saved_y; + crtc->rotation = saved_rotation; + crtc->mode = saved_mode; + } +#if defined(XF86_CRTC_VERSION) && XF86_CRTC_VERSION >= 3 + else + crtc->active = TRUE; +#endif + + return ret; +} + +static void +drmmode_set_cursor_colors (xf86CrtcPtr crtc, int bg, int fg) +{ + +} + +static void +drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y) +{ + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; + + drmModeMoveCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, x, y); +} + +static void +drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image) +{ + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + int i; + uint32_t *ptr; + + /* cursor should be mapped already */ + ptr = (uint32_t *)(drmmode_crtc->cursor_bo->ptr); + + for (i = 0; i < 64 * 64; i++) + ptr[i] = image[i];// cpu_to_le32(image[i]); +} + + +static void +drmmode_hide_cursor (xf86CrtcPtr crtc) +{ + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; + + drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0, 64, 64); + +} + +static void +drmmode_show_cursor (xf86CrtcPtr crtc) +{ + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; + uint32_t handle = drmmode_crtc->cursor_bo->handle; + + drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, 64, 64); +} + +static void +drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t *red, uint16_t *green, + uint16_t *blue, int size) +{ + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; + + drmModeCrtcSetGamma(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, + size, red, green, blue); +} + +static const xf86CrtcFuncsRec drmmode_crtc_funcs = { + .dpms = drmmode_crtc_dpms, + .set_mode_major = drmmode_set_mode_major, + .set_cursor_colors = drmmode_set_cursor_colors, + .set_cursor_position = drmmode_set_cursor_position, + .show_cursor = drmmode_show_cursor, + .hide_cursor = drmmode_hide_cursor, + .load_cursor_argb = drmmode_load_cursor_argb, + + .gamma_set = drmmode_crtc_gamma_set, + .destroy = NULL, /* XXX */ +}; + +int drmmode_get_crtc_id(xf86CrtcPtr crtc) +{ + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + return drmmode_crtc->hw_id; +} + +static void +drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num) +{ + xf86CrtcPtr crtc; + drmmode_crtc_private_ptr drmmode_crtc; + + crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs); + if (crtc == NULL) + return; + + drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1); + drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]); + drmmode_crtc->drmmode = drmmode; + crtc->driver_private = drmmode_crtc; +} + +static xf86OutputStatus +drmmode_output_detect(xf86OutputPtr output) +{ + /* go to the hw and retrieve a new output struct */ + drmmode_output_private_ptr drmmode_output = output->driver_private; + drmmode_ptr drmmode = drmmode_output->drmmode; + xf86OutputStatus status; + drmModeFreeConnector(drmmode_output->mode_output); + + drmmode_output->mode_output = drmModeGetConnector(drmmode->fd, drmmode_output->output_id); + + switch (drmmode_output->mode_output->connection) { + case DRM_MODE_CONNECTED: + status = XF86OutputStatusConnected; + break; + case DRM_MODE_DISCONNECTED: + status = XF86OutputStatusDisconnected; + break; + default: + case DRM_MODE_UNKNOWNCONNECTION: + status = XF86OutputStatusUnknown; + break; + } + return status; +} + +static Bool +drmmode_output_mode_valid(xf86OutputPtr output, DisplayModePtr pModes) +{ + return MODE_OK; +} + +static DisplayModePtr +drmmode_output_get_modes(xf86OutputPtr output) +{ + drmmode_output_private_ptr drmmode_output = output->driver_private; + drmModeConnectorPtr koutput = drmmode_output->mode_output; + drmmode_ptr drmmode = drmmode_output->drmmode; + int i; + DisplayModePtr Modes = NULL, Mode; + drmModePropertyPtr props; + xf86MonPtr mon = NULL; + + /* look for an EDID property */ + for (i = 0; i < koutput->count_props; i++) { + props = drmModeGetProperty(drmmode->fd, koutput->props[i]); + if (props && (props->flags & DRM_MODE_PROP_BLOB)) { + if (!strcmp(props->name, "EDID")) { + if (drmmode_output->edid_blob) + drmModeFreePropertyBlob(drmmode_output->edid_blob); + drmmode_output->edid_blob = drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]); + } + drmModeFreeProperty(props); + } + } + + if (drmmode_output->edid_blob) { + mon = xf86InterpretEDID(output->scrn->scrnIndex, + drmmode_output->edid_blob->data); + if (mon && drmmode_output->edid_blob->length > 128) + mon->flags |= MONITOR_EDID_COMPLETE_RAWDATA; + } + xf86OutputSetEDID(output, mon); + + /* modes should already be available */ + for (i = 0; i < koutput->count_modes; i++) { + Mode = xnfalloc(sizeof(DisplayModeRec)); + + drmmode_ConvertFromKMode(output->scrn, &koutput->modes[i], Mode); + Modes = xf86ModesAdd(Modes, Mode); + + } + return Modes; +} + +static void +drmmode_output_destroy(xf86OutputPtr output) +{ + drmmode_output_private_ptr drmmode_output = output->driver_private; + int i; + + if (drmmode_output->edid_blob) + drmModeFreePropertyBlob(drmmode_output->edid_blob); + for (i = 0; i < drmmode_output->num_props; i++) { + drmModeFreeProperty(drmmode_output->props[i].mode_prop); + free(drmmode_output->props[i].atoms); + } + for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) { + drmModeFreeEncoder(drmmode_output->mode_encoders[i]); + free(drmmode_output->mode_encoders); + } + free(drmmode_output->props); + drmModeFreeConnector(drmmode_output->mode_output); + free(drmmode_output); + output->driver_private = NULL; +} + +static void +drmmode_output_dpms(xf86OutputPtr output, int mode) +{ + drmmode_output_private_ptr drmmode_output = output->driver_private; + drmModeConnectorPtr koutput = drmmode_output->mode_output; + drmmode_ptr drmmode = drmmode_output->drmmode; + + drmModeConnectorSetProperty(drmmode->fd, koutput->connector_id, + drmmode_output->dpms_enum_id, mode); + return; +} + + +static Bool +drmmode_property_ignore(drmModePropertyPtr prop) +{ + if (!prop) + return TRUE; + /* ignore blob prop */ + if (prop->flags & DRM_MODE_PROP_BLOB) + return TRUE; + /* ignore standard property */ + if (!strcmp(prop->name, "EDID") || + !strcmp(prop->name, "DPMS")) + return TRUE; + + return FALSE; +} + +static void +drmmode_output_create_resources(xf86OutputPtr output) +{ + drmmode_output_private_ptr drmmode_output = output->driver_private; + drmModeConnectorPtr mode_output = drmmode_output->mode_output; + drmmode_ptr drmmode = drmmode_output->drmmode; + drmModePropertyPtr drmmode_prop; + int i, j, err; + + drmmode_output->props = calloc(mode_output->count_props, sizeof(drmmode_prop_rec)); + if (!drmmode_output->props) + return; + + drmmode_output->num_props = 0; + for (i = 0, j = 0; i < mode_output->count_props; i++) { + drmmode_prop = drmModeGetProperty(drmmode->fd, mode_output->props[i]); + if (drmmode_property_ignore(drmmode_prop)) { + drmModeFreeProperty(drmmode_prop); + continue; + } + drmmode_output->props[j].mode_prop = drmmode_prop; + drmmode_output->props[j].value = mode_output->prop_values[i]; + drmmode_output->num_props++; + j++; + } + + for (i = 0; i < drmmode_output->num_props; i++) { + drmmode_prop_ptr p = &drmmode_output->props[i]; + drmmode_prop = p->mode_prop; + + if (drmmode_prop->flags & DRM_MODE_PROP_RANGE) { + INT32 range[2]; + INT32 value = p->value; + + p->num_atoms = 1; + p->atoms = calloc(p->num_atoms, sizeof(Atom)); + if (!p->atoms) + continue; + p->atoms[0] = MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE); + range[0] = drmmode_prop->values[0]; + range[1] = drmmode_prop->values[1]; + err = RRConfigureOutputProperty(output->randr_output, p->atoms[0], + FALSE, TRUE, + drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE, + 2, range); + if (err != 0) { + xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, + "RRConfigureOutputProperty error, %d\n", err); + } + err = RRChangeOutputProperty(output->randr_output, p->atoms[0], + XA_INTEGER, 32, PropModeReplace, 1, &value, FALSE, TRUE); + if (err != 0) { + xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, + "RRChangeOutputProperty error, %d\n", err); + } + } else if (drmmode_prop->flags & DRM_MODE_PROP_ENUM) { + p->num_atoms = drmmode_prop->count_enums + 1; + p->atoms = calloc(p->num_atoms, sizeof(Atom)); + if (!p->atoms) + continue; + p->atoms[0] = MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE); + for (j = 1; j <= drmmode_prop->count_enums; j++) { + struct drm_mode_property_enum *e = &drmmode_prop->enums[j-1]; + p->atoms[j] = MakeAtom(e->name, strlen(e->name), TRUE); + } + err = RRConfigureOutputProperty(output->randr_output, p->atoms[0], + FALSE, FALSE, + drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE, + p->num_atoms - 1, (INT32 *)&p->atoms[1]); + if (err != 0) { + xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, + "RRConfigureOutputProperty error, %d\n", err); + } + for (j = 0; j < drmmode_prop->count_enums; j++) + if (drmmode_prop->enums[j].value == p->value) + break; + /* there's always a matching value */ + err = RRChangeOutputProperty(output->randr_output, p->atoms[0], + XA_ATOM, 32, PropModeReplace, 1, &p->atoms[j+1], FALSE, TRUE); + if (err != 0) { + xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, + "RRChangeOutputProperty error, %d\n", err); + } + } + } +} + +static Bool +drmmode_output_set_property(xf86OutputPtr output, Atom property, + RRPropertyValuePtr value) +{ + drmmode_output_private_ptr drmmode_output = output->driver_private; + drmmode_ptr drmmode = drmmode_output->drmmode; + int i; + + for (i = 0; i < drmmode_output->num_props; i++) { + drmmode_prop_ptr p = &drmmode_output->props[i]; + + if (p->atoms[0] != property) + continue; + + if (p->mode_prop->flags & DRM_MODE_PROP_RANGE) { + uint32_t val; + + if (value->type != XA_INTEGER || value->format != 32 || + value->size != 1) + return FALSE; + val = *(uint32_t *)value->data; + + drmModeConnectorSetProperty(drmmode->fd, drmmode_output->output_id, + p->mode_prop->prop_id, (uint64_t)val); + return TRUE; + } else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) { + Atom atom; + const char *name; + int j; + + if (value->type != XA_ATOM || value->format != 32 || value->size != 1) + return FALSE; + memcpy(&atom, value->data, 4); + name = NameForAtom(atom); + + /* search for matching name string, then set its value down */ + for (j = 0; j < p->mode_prop->count_enums; j++) { + if (!strcmp(p->mode_prop->enums[j].name, name)) { + drmModeConnectorSetProperty(drmmode->fd, drmmode_output->output_id, + p->mode_prop->prop_id, p->mode_prop->enums[j].value); + return TRUE; + } + } + } + } + + return TRUE; +} + +static Bool +drmmode_output_get_property(xf86OutputPtr output, Atom property) +{ + return TRUE; +} + +static const xf86OutputFuncsRec drmmode_output_funcs = { + .dpms = drmmode_output_dpms, + .create_resources = drmmode_output_create_resources, +#ifdef RANDR_12_INTERFACE + .set_property = drmmode_output_set_property, + .get_property = drmmode_output_get_property, +#endif + .detect = drmmode_output_detect, + .mode_valid = drmmode_output_mode_valid, + + .get_modes = drmmode_output_get_modes, + .destroy = drmmode_output_destroy +}; + +static int subpixel_conv_table[7] = { 0, SubPixelUnknown, + SubPixelHorizontalRGB, + SubPixelHorizontalBGR, + SubPixelVerticalRGB, + SubPixelVerticalBGR, + SubPixelNone }; + +const char *output_names[] = { "None", + "VGA", + "DVI", + "DVI", + "DVI", + "Composite", + "S-video", + "LVDS", + "CTV", + "DIN", + "DisplayPort", + "HDMI", + "HDMI", + "TV", + "eDP" +}; + +static void +drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dvi, int *num_hdmi) +{ + xf86OutputPtr output; + drmModeConnectorPtr koutput; + drmModeEncoderPtr *kencoders = NULL; + drmmode_output_private_ptr drmmode_output; + drmModePropertyPtr props; + char name[32]; + int i; + const char *s; + + koutput = drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]); + if (!koutput) + return; + + kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders); + if (!kencoders) { + goto out_free_encoders; + } + + for (i = 0; i < koutput->count_encoders; i++) { + kencoders[i] = drmModeGetEncoder(drmmode->fd, koutput->encoders[i]); + if (!kencoders[i]) { + goto out_free_encoders; + } + } + + /* need to do smart conversion here for compat with non-kms ATI driver */ + snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], koutput->connector_type_id - 1); + + output = xf86OutputCreate (pScrn, &drmmode_output_funcs, name); + if (!output) { + goto out_free_encoders; + } + + drmmode_output = calloc(sizeof(drmmode_output_private_rec), 1); + if (!drmmode_output) { + xf86OutputDestroy(output); + goto out_free_encoders; + } + + drmmode_output->output_id = drmmode->mode_res->connectors[num]; + drmmode_output->mode_output = koutput; + drmmode_output->mode_encoders = kencoders; + drmmode_output->drmmode = drmmode; + output->mm_width = koutput->mmWidth; + output->mm_height = koutput->mmHeight; + + output->subpixel_order = subpixel_conv_table[koutput->subpixel]; + output->interlaceAllowed = TRUE; + output->doubleScanAllowed = TRUE; + output->driver_private = drmmode_output; + + output->possible_crtcs = 0x7f; + for (i = 0; i < koutput->count_encoders; i++) { + output->possible_crtcs &= kencoders[i]->possible_crtcs; + } + /* work out the possible clones later */ + output->possible_clones = 0; + + for (i = 0; i < koutput->count_props; i++) { + props = drmModeGetProperty(drmmode->fd, koutput->props[i]); + if (props && (props->flags & DRM_MODE_PROP_ENUM)) { + if (!strcmp(props->name, "DPMS")) { + drmmode_output->dpms_enum_id = koutput->props[i]; + drmModeFreeProperty(props); + break; + } + drmModeFreeProperty(props); + } + } + + return; +out_free_encoders: + if (kencoders){ + for (i = 0; i < koutput->count_encoders; i++) + drmModeFreeEncoder(kencoders[i]); + free(kencoders); + } + drmModeFreeConnector(koutput); + +} + +uint32_t find_clones(ScrnInfoPtr scrn, xf86OutputPtr output) +{ + drmmode_output_private_ptr drmmode_output = output->driver_private, clone_drmout; + int i; + xf86OutputPtr clone_output; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int index_mask = 0; + + if (drmmode_output->enc_clone_mask == 0) + return index_mask; + + for (i = 0; i < xf86_config->num_output; i++) { + clone_output = xf86_config->output[i]; + clone_drmout = clone_output->driver_private; + if (output == clone_output) + continue; + + if (clone_drmout->enc_mask == 0) + continue; + if (drmmode_output->enc_clone_mask == clone_drmout->enc_mask) + index_mask |= (1 << i); + } + return index_mask; +} + + +static void +drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode) +{ + int i, j; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + drmmode_output_private_ptr drmmode_output; + + drmmode_output = output->driver_private; + drmmode_output->enc_clone_mask = 0xff; + /* and all the possible encoder clones for this output together */ + for (j = 0; j < drmmode_output->mode_output->count_encoders; j++) + { + int k; + for (k = 0; k < drmmode->mode_res->count_encoders; k++) { + if (drmmode->mode_res->encoders[k] == drmmode_output->mode_encoders[j]->encoder_id) + drmmode_output->enc_mask |= (1 << k); + } + + drmmode_output->enc_clone_mask &= drmmode_output->mode_encoders[j]->possible_clones; + } + } + + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + output->possible_clones = find_clones(scrn, output); + } +} + +static Bool +drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + drmmode_crtc_private_ptr + drmmode_crtc = xf86_config->crtc[0]->driver_private; + drmmode_ptr drmmode = drmmode_crtc->drmmode; + struct dumb_bo *old_front = NULL; + Bool ret; + ScreenPtr screen = screenInfo.screens[scrn->scrnIndex]; + uint32_t old_fb_id; + int i, pitch, old_width, old_height, old_pitch; + int screen_size; + int cpp = (scrn->bitsPerPixel + 1) / 8; + struct dumb_bo *front_bo; + uint32_t tiling_flags = 0; + PixmapPtr ppix = screen->GetScreenPixmap(screen); + void *new_pixels; + + if (scrn->virtualX == width && scrn->virtualY == height) + return TRUE; + + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "Allocate new frame buffer %dx%d stride %d\n", + width, height, pitch / cpp); + + old_width = scrn->virtualX; + old_height = scrn->virtualY; + old_pitch = scrn->displayWidth; + old_fb_id = drmmode->fb_id; + old_front = drmmode->front_bo; + + drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, scrn->bitsPerPixel); + if (!drmmode->front_bo) + goto fail; + + pitch = drmmode->front_bo->pitch; + + scrn->virtualX = width; + scrn->virtualY = height; + scrn->displayWidth = pitch / cpp; + + ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth, + scrn->bitsPerPixel, pitch, + drmmode->front_bo->handle, + &drmmode->fb_id); + if (ret) + goto fail; + + new_pixels = drmmode_map_front_bo(drmmode); + if (!new_pixels) + goto fail; + + screen->ModifyPixmapHeader(ppix, width, height, -1, -1, + pitch, new_pixels); + +#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,9,99,1,0) + scrn->pixmapPrivate.ptr = ppix->devPrivate.ptr; +#endif + + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + + if (!crtc->enabled) + continue; + + drmmode_set_mode_major(crtc, &crtc->mode, + crtc->rotation, crtc->x, crtc->y); + } + + if (old_fb_id) { + drmModeRmFB(drmmode->fd, old_fb_id); + dumb_bo_destroy(drmmode->fd, old_front); + } + + return TRUE; + + fail: + if (drmmode->front_bo) + dumb_bo_destroy(drmmode->fd, drmmode->front_bo); + drmmode->front_bo = old_front; + scrn->virtualX = old_width; + scrn->virtualY = old_height; + scrn->displayWidth = old_pitch; + drmmode->fb_id = old_fb_id; + + return FALSE; +} + +static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = { + drmmode_xf86crtc_resize +}; + +Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) +{ + xf86CrtcConfigPtr xf86_config; + int i, num_dvi = 0, num_hdmi = 0; + + xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs); + xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + + drmmode->scrn = pScrn; + drmmode->cpp = cpp; + drmmode->mode_res = drmModeGetResources(drmmode->fd); + if (!drmmode->mode_res) + return FALSE; + + xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width, drmmode->mode_res->max_height); + for (i = 0; i < drmmode->mode_res->count_crtcs; i++) + if (!xf86IsEntityShared(pScrn->entityList[0]) || pScrn->confScreen->device->screen == i) + drmmode_crtc_init(pScrn, drmmode, i); + + for (i = 0; i < drmmode->mode_res->count_connectors; i++) + drmmode_output_init(pScrn, drmmode, i, &num_dvi, &num_hdmi); + + /* workout clones */ + drmmode_clones_init(pScrn, drmmode); + + xf86InitialConfiguration(pScrn, TRUE); + + return TRUE; +} + +void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct dumb_bo *bo) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CrtcPtr crtc = xf86_config->crtc[id]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + + drmmode_crtc->cursor_bo = bo; +} + +void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y, int flags) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86OutputPtr output = config->output[config->compat_output]; + xf86CrtcPtr crtc = output->crtc; + + if (crtc && crtc->enabled) { + drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation, + x, y); + } +} + +Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + + for (c = 0; c < config->num_crtc; c++) { + xf86CrtcPtr crtc = config->crtc[c]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + xf86OutputPtr output = NULL; + int o; + + /* Skip disabled CRTCs */ + if (!crtc->enabled) { + drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, + 0, 0, 0, NULL, 0, NULL); + continue; + } + + if (config->output[config->compat_output]->crtc == crtc) + output = config->output[config->compat_output]; + else + { + for (o = 0; o < config->num_output; o++) + if (config->output[o]->crtc == crtc) + { + output = config->output[o]; + break; + } + } + /* paranoia */ + if (!output) + continue; + + /* Mark that we'll need to re-set the mode for sure */ + memset(&crtc->mode, 0, sizeof(crtc->mode)); + if (!crtc->desiredMode.CrtcHDisplay) + { + DisplayModePtr mode = xf86OutputFindClosestMode (output, pScrn->currentMode); + + if (!mode) + return FALSE; + crtc->desiredMode = *mode; + crtc->desiredRotation = RR_Rotate_0; + crtc->desiredX = 0; + crtc->desiredY = 0; + } + + if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation, + crtc->desiredX, crtc->desiredY)) + return FALSE; + } + return TRUE; +} + +static void drmmode_load_palette(ScrnInfoPtr pScrn, int numColors, + int *indices, LOCO *colors, VisualPtr pVisual) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + uint16_t lut_r[256], lut_g[256], lut_b[256]; + int index, j, i; + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + + for (i = 0 ; i < 256; i++) { + lut_r[i] = drmmode_crtc->lut_r[i] << 6; + lut_g[i] = drmmode_crtc->lut_g[i] << 6; + lut_b[i] = drmmode_crtc->lut_b[i] << 6; + } + + switch(pScrn->depth) { + case 15: + for (i = 0; i < numColors; i++) { + index = indices[i]; + for (j = 0; j < 8; j++) { + lut_r[index * 8 + j] = colors[index].red << 6; + lut_g[index * 8 + j] = colors[index].green << 6; + lut_b[index * 8 + j] = colors[index].blue << 6; + } + } + break; + case 16: + for (i = 0; i < numColors; i++) { + index = indices[i]; + + if (i <= 31) { + for (j = 0; j < 8; j++) { + lut_r[index * 8 + j] = colors[index].red << 6; + lut_b[index * 8 + j] = colors[index].blue << 6; + } + } + + for (j = 0; j < 4; j++) { + lut_g[index * 4 + j] = colors[index].green << 6; + } + } + break; + default: + for (i = 0; i < numColors; i++) { + index = indices[i]; + lut_r[index] = colors[index].red << 6; + lut_g[index] = colors[index].green << 6; + lut_b[index] = colors[index].blue << 6; + } + break; + } + + /* Make the change through RandR */ +#ifdef RANDR_12_INTERFACE + if (crtc->randr_crtc) + RRCrtcGammaSet(crtc->randr_crtc, lut_r, lut_g, lut_b); + else +#endif + crtc->funcs->gamma_set(crtc, lut_r, lut_g, lut_b, 256); + } +} + +Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn) +{ + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, + "Initializing kms color map\n"); + if (!miCreateDefColormap(pScreen)) + return FALSE; + /* all radeons support 10 bit CLUTs */ + if (!xf86HandleColormaps(pScreen, 256, 10, + drmmode_load_palette, NULL, + CMAP_PALETTED_TRUECOLOR +#if 0 /* This option messes up text mode! (eich at suse.de) */ + | CMAP_LOAD_EVEN_IF_OFFSCREEN +#endif + | CMAP_RELOAD_ON_MODE_SWITCH)) + return FALSE; + return TRUE; +} + +#ifdef HAVE_UDEV +static void +drmmode_handle_uevents(int fd, void *closure) +{ + drmmode_ptr drmmode = closure; + ScrnInfoPtr scrn = drmmode->scrn; + struct udev_device *dev; + dev = udev_monitor_receive_device(drmmode->uevent_monitor); + if (!dev) + return; + + RRGetInfo(screenInfo.screens[scrn->scrnIndex], TRUE); + udev_device_unref(dev); +} +#endif + +void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode) +{ +#ifdef HAVE_UDEV + struct udev *u; + struct udev_monitor *mon; + + u = udev_new(); + if (!u) + return; + mon = udev_monitor_new_from_netlink(u, "udev"); + if (!mon) { + udev_unref(u); + return; + } + + if (udev_monitor_filter_add_match_subsystem_devtype(mon, + "drm", + "drm_minor") < 0 || + udev_monitor_enable_receiving(mon) < 0) { + udev_monitor_unref(mon); + udev_unref(u); + return; + } + + drmmode->uevent_handler = + xf86AddGeneralHandler(udev_monitor_get_fd(mon), + drmmode_handle_uevents, + drmmode); + + drmmode->uevent_monitor = mon; +#endif +} + +void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode) +{ +#ifdef HAVE_UDEV + if (drmmode->uevent_handler) { + struct udev *u = udev_monitor_get_udev(drmmode->uevent_monitor); + xf86RemoveGeneralHandler(drmmode->uevent_handler); + + udev_monitor_unref(drmmode->uevent_monitor); + udev_unref(u); + } +#endif +} + +/* create front and cursor BOs */ +Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int width; + int height; + int bpp; + int i; + + width = pScrn->virtualX; + height = pScrn->virtualY; + bpp = pScrn->bitsPerPixel; + drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, bpp); + if (!drmmode->front_bo) + return FALSE; + + + width = height = 64; + bpp = 32; + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + drmmode_crtc->cursor_bo = dumb_bo_create(drmmode->fd, width, height, bpp); + } + return TRUE; +} + +void *drmmode_map_front_bo(drmmode_ptr drmmode) +{ + int ret; + + if (drmmode->front_bo->ptr) + return drmmode->front_bo->ptr; + + ret = dumb_bo_map(drmmode->fd, drmmode->front_bo); + if (ret) + return NULL; + + return drmmode->front_bo->ptr; + +} + +Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int i, ret; + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + ret = dumb_bo_map(drmmode->fd, drmmode_crtc->cursor_bo); + if (ret) + return FALSE; + } + return TRUE; +} + +void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int i; + dumb_bo_destroy(drmmode->fd, drmmode->front_bo); + drmmode->front_bo = NULL; + + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + dumb_bo_destroy(drmmode->fd, drmmode_crtc->cursor_bo); + } +} diff --git a/src/drmmode_display.h b/src/drmmode_display.h new file mode 100644 index 0000000..2d72505 --- /dev/null +++ b/src/drmmode_display.h @@ -0,0 +1,125 @@ +/* + * Copyright ?? 2007 Red Hat, 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 (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 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. + * + * Authors: + * Dave Airlie <airlied at redhat.com> + * + */ +#ifndef DRMMODE_DISPLAY_H +#define DRMMODE_DISPLAY_H + +#include "xf86drmMode.h" +#ifdef HAVE_UDEV +#include "libudev.h" +#endif + +struct dumb_bo { + uint32_t handle; + uint32_t size; + void *ptr; + int map_count; + uint32_t pitch; +}; + +typedef struct { + int fd; + unsigned fb_id; + drmModeResPtr mode_res; + drmModeFBPtr mode_fb; + int cpp; + ScrnInfoPtr scrn; +#ifdef HAVE_UDEV + struct udev_monitor *uevent_monitor; + InputHandlerProc uevent_handler; +#endif + drmEventContext event_context; + struct dumb_bo *front_bo; +} drmmode_rec, *drmmode_ptr; + +typedef struct { + drmmode_ptr drmmode; + unsigned old_fb_id; + int flip_count; + void *event_data; + unsigned int fe_frame; + unsigned int fe_tv_sec; + unsigned int fe_tv_usec; +} drmmode_flipdata_rec, *drmmode_flipdata_ptr; + +typedef struct { + drmmode_flipdata_ptr flipdata; + Bool dispatch_me; +} drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr; + +typedef struct { + drmmode_ptr drmmode; + drmModeCrtcPtr mode_crtc; + int hw_id; + struct dumb_bo *cursor_bo; + // struct radeon_bo *rotate_bo; + unsigned rotate_fb_id; + uint16_t lut_r[256], lut_g[256], lut_b[256]; +} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; + +typedef struct { + drmModePropertyPtr mode_prop; + uint64_t value; + int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */ + Atom *atoms; +} drmmode_prop_rec, *drmmode_prop_ptr; + + +typedef struct { + drmmode_ptr drmmode; + int output_id; + drmModeConnectorPtr mode_output; + drmModeEncoderPtr *mode_encoders; + drmModePropertyBlobPtr edid_blob; + int dpms_enum_id; + int num_props; + drmmode_prop_ptr props; + int enc_mask; + int enc_clone_mask; +} drmmode_output_private_rec, *drmmode_output_private_ptr; + + +extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); +//extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr); +//extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo); +void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y, int flags); +extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); + +extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); +extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); + +extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling); +extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); +extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); + +//Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id); +Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +void *drmmode_map_front_bo(drmmode_ptr drmmode); +Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +#endif diff --git a/src/output.c b/src/output.c deleted file mode 100644 index 1f95a2f..0000000 --- a/src/output.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, 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. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - * - * Author: Alan Hourihane <alanh at tungstengraphics.com> - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <xf86.h> -#include <xf86i2c.h> -#include <xf86Crtc.h> -#include <errno.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string.h> -#include <sys/stat.h> -#include <sys/types.h> - -#define DPMS_SERVER -#include <X11/extensions/dpms.h> - -#include "X11/Xatom.h" - -#include "driver.h" - -static char *connector_enum_list[] = { - "Unknown", - "VGA", - "DVI-I", - "DVI-D", - "DVI-A", - "Composite", - "SVIDEO", - "LVDS", - "Component", - "9-pin DIN", - "DisplayPort", - "HDMI Type A", - "HDMI Type B", -}; - -static void -dpms(xf86OutputPtr output, int mode) -{ -} - -static void -save(xf86OutputPtr output) -{ -} - -static void -restore(xf86OutputPtr output) -{ -} - -static int -mode_valid(xf86OutputPtr output, DisplayModePtr pMode) -{ - return MODE_OK; -} - -static Bool -mode_fixup(xf86OutputPtr output, DisplayModePtr mode, - DisplayModePtr adjusted_mode) -{ - return TRUE; -} - -static void -prepare(xf86OutputPtr output) -{ - dpms(output, DPMSModeOff); -} - -static void -mode_set(xf86OutputPtr output, DisplayModePtr mode, - DisplayModePtr adjusted_mode) -{ -} - -static void -commit(xf86OutputPtr output) -{ - dpms(output, DPMSModeOn); - - if (output->scrn->pScreen != NULL) - xf86_reload_cursors(output->scrn->pScreen); -} - -static xf86OutputStatus -detect(xf86OutputPtr output) -{ - drmModeConnectorPtr drm_connector = output->driver_private; - - switch (drm_connector->connection) { - case DRM_MODE_CONNECTED: - return XF86OutputStatusConnected; - case DRM_MODE_DISCONNECTED: - return XF86OutputStatusDisconnected; - default: - return XF86OutputStatusUnknown; - } -} - -static DisplayModePtr -get_modes(xf86OutputPtr output) -{ - drmModeConnectorPtr drm_connector = output->driver_private; - struct drm_mode_modeinfo *drm_mode = NULL; - DisplayModePtr modes = NULL, mode = NULL; - int i; - - for (i = 0; i < drm_connector->count_modes; i++) { - drm_mode = &drm_connector->modes[i]; - if (drm_mode) { - mode = xcalloc(1, sizeof(DisplayModeRec)); - if (!mode) - continue; - mode->type = 0; - mode->Clock = drm_mode->clock; - mode->HDisplay = drm_mode->hdisplay; - mode->HSyncStart = drm_mode->hsync_start; - mode->HSyncEnd = drm_mode->hsync_end; - mode->HTotal = drm_mode->htotal; - mode->VDisplay = drm_mode->vdisplay; - mode->VSyncStart = drm_mode->vsync_start; - mode->VSyncEnd = drm_mode->vsync_end; - mode->VTotal = drm_mode->vtotal; - mode->Flags = drm_mode->flags; - mode->HSkew = drm_mode->hskew; - mode->VScan = drm_mode->vscan; - mode->VRefresh = xf86ModeVRefresh(mode); - mode->Private = (void *)drm_mode; - xf86SetModeDefaultName(mode); - modes = xf86ModesAdd(modes, mode); - xf86PrintModeline(0, mode); - } - } - - return modes; -} - -static void -destroy(xf86OutputPtr output) -{ - drmModeFreeConnector(output->driver_private); -} - -static void -create_resources(xf86OutputPtr output) -{ -#ifdef RANDR_12_INTERFACE -#endif /* RANDR_12_INTERFACE */ -} - -#ifdef RANDR_12_INTERFACE -static Bool -set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value) -{ - return TRUE; -} -#endif /* RANDR_12_INTERFACE */ - -#ifdef RANDR_13_INTERFACE -static Bool -get_property(xf86OutputPtr output, Atom property) -{ - return TRUE; -} -#endif /* RANDR_13_INTERFACE */ - -#ifdef RANDR_GET_CRTC_INTERFACE -static xf86CrtcPtr -get_crtc(xf86OutputPtr output) -{ - return NULL; -} -#endif - -static const xf86OutputFuncsRec output_funcs = { - .create_resources = create_resources, - .dpms = dpms, - .save = save, - .restore = restore, - .mode_valid = mode_valid, - .mode_fixup = mode_fixup, - .prepare = prepare, - .mode_set = mode_set, - .commit = commit, - .detect = detect, - .get_modes = get_modes, -#ifdef RANDR_12_INTERFACE - .set_property = set_property, -#endif -#ifdef RANDR_13_INTERFACE - .get_property = get_property, -#endif - .destroy = destroy, -#ifdef RANDR_GET_CRTC_INTERFACE - .get_crtc = get_crtc, -#endif -}; - -void -output_init(ScrnInfoPtr pScrn) -{ - modesettingPtr ms = modesettingPTR(pScrn); - xf86OutputPtr output; - drmModeResPtr res; - drmModeConnectorPtr drm_connector = NULL; - drmModeEncoderPtr drm_encoder = NULL; - drmModeCrtcPtr crtc; - char *name; - int c, v, p; - - res = drmModeGetResources(ms->fd); - if (res == 0) { - DRV_ERROR("Failed drmModeGetResources\n"); - return; - } - - for (c = 0; c < res->count_connectors; c++) { - drm_connector = drmModeGetConnector(ms->fd, res->connectors[c]); - if (!drm_connector) - goto out; - - for (p = 0; p < drm_connector->count_props; p++) { - drmModePropertyPtr prop; - - prop = drmModeGetProperty(ms->fd, drm_connector->props[p]); - - name = NULL; - if (prop) { - ErrorF("VALUES %d\n", prop->count_values); - - for (v = 0; v < prop->count_values; v++) - ErrorF("%s %lld\n", prop->name, prop->values[v]); - } - } - - name = connector_enum_list[drm_connector->connector_type]; - - output = xf86OutputCreate(pScrn, &output_funcs, name); - if (!output) - continue; - - drm_encoder = drmModeGetEncoder(ms->fd, drm_connector->encoders[0]); - if (drm_encoder) { - output->possible_crtcs = drm_encoder->crtcs; - output->possible_clones = drm_encoder->clones; - } else { - output->possible_crtcs = 0; - output->possible_clones = 0; - } - output->driver_private = drm_connector; - output->subpixel_order = SubPixelHorizontalRGB; - output->interlaceAllowed = FALSE; - output->doubleScanAllowed = FALSE; - } - - out: - drmModeFreeResources(res); -} commit 4828e4172cc363e17943334ab7d75243e75d344b Author: Dave Airlie <airlied at redhat.com> Date: Thu Mar 10 09:13:50 2011 +1000 drop exa don't provide accel in this framework diff --git a/src/Makefile.am b/src/Makefile.am index e3cc3cc..23e78b7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,7 +38,6 @@ modesetting_drv_la_SOURCES = \ driver.h \ output.c \ crtc.c \ - exa.c \ dri2.c EXTRA_DIST = diff --git a/src/driver.c b/src/driver.c index 0e6f4c8..6b70d4b 100644 --- a/src/driver.c +++ b/src/driver.c @@ -126,16 +126,6 @@ static const OptionInfoRec Options[] = { {-1, NULL, OPTV_NONE, {0}, FALSE} }; -static const char *exaSymbols[] = { - "exaGetVersion", - "exaDriverInit", - "exaDriverFini", - "exaOffscreenAlloc", - "exaOffscreenFree", - "exaWaitSync", - NULL -}; - static const char *fbSymbols[] = { "fbPictureInit", "fbScreenInit", @@ -188,7 +178,7 @@ Setup(pointer module, pointer opts, int *errmaj, int *errmin) * Tell the loader about symbols from other modules that this module * might refer to. */ - LoaderRefSymLists(exaSymbols, fbSymbols, ddcSymbols, NULL); + LoaderRefSymLists(fbSymbols, ddcSymbols, NULL); /* * The return value must be non-NULL on success even though there @@ -415,14 +405,11 @@ CreateFrontBuffer(ScrnInfoPtr pScrn) Bool fbAccessDisabled; int flags; - ms->noEvict = TRUE; pScreen->ModifyPixmapHeader(rootPixmap, pScrn->virtualX, pScrn->virtualY, pScrn->depth, pScrn->bitsPerPixel, pScrn->displayWidth * pScrn->bitsPerPixel / 8, NULL); - ms->noEvict = FALSE; - drmModeAddFB(ms->fd, pScrn->virtualX, pScrn->virtualY, @@ -633,8 +620,6 @@ PreInit(ScrnInfoPtr pScrn, int flags) xf86LoaderReqSymLists(fbSymbols, NULL); - xf86LoadSubModule(pScrn, "exa"); - #ifdef DRI2 xf86LoadSubModule(pScrn, "dri2"); #endif @@ -667,8 +652,6 @@ CreateScreenResources(ScreenPtr pScreen) Bool ret; int flags; - ms->noEvict = TRUE; - pScreen->CreateScreenResources = ms->createScreenResources; ret = pScreen->CreateScreenResources(pScreen); pScreen->CreateScreenResources = CreateScreenResources; @@ -678,8 +661,6 @@ CreateScreenResources(ScreenPtr pScreen) if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL)) FatalError("Couldn't adjust screen pixmap\n"); - ms->noEvict = FALSE; - drmModeAddFB(ms->fd, pScrn->virtualX, pScrn->virtualY, @@ -771,8 +752,6 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetBlackWhitePixels(pScreen); - ms->exa = ExaInit(pScrn); - miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); xf86SetSilkenMouse(pScreen); @@ -933,9 +912,6 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) pScreen->CreateScreenResources = ms->createScreenResources; - if (ms->exa) - ExaClose(pScrn); - drmClose(ms->fd); ms->fd = -1; diff --git a/src/driver.h b/src/driver.h index 5b31188..a673f8f 100644 --- a/src/driver.h +++ b/src/driver.h @@ -32,7 +32,6 @@ #include <xf86drm.h> #include <xf86drmMode.h> #include <xf86mm.h> -#include "exa.h" #define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); @@ -71,10 +70,7 @@ typedef struct _modesettingRec CreateScreenResourcesProcPtr createScreenResources; - /* exa */ - void *exa; void *driver; - Bool noEvict; /* dri2 */ drm_context_t context; diff --git a/src/exa.c b/src/exa.c deleted file mode 100644 index f688472..0000000 --- a/src/exa.c +++ /dev/null @@ -1,850 +0,0 @@ -/* - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, 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. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - * - * Author: Alan Hourihane <alanh at tungstengraphics.com> - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* FIXME ! */ -#define DRI_DRIVER_PATH "/ISO/X.Org/modular/i386/lib/dri" - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "driver.h" -#include <dlfcn.h> - -#include "pipe/p_winsys.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "pipe/p_util.h" -#include "pipe/p_state.h" -#include "pipe/p_inlines.h" - -/* EXA winsys */ -struct exa_context -{ -}; - -struct exa_winsys -{ - struct pipe_winsys base; - modesettingPtr ms; -}; - -struct exa_buffer -{ - struct pipe_buffer base; - drmBO bo; - boolean userBuffer; /** Is this a user-space buffer? */ - //void *data; - //void *mapped; -}; - -struct exa_surface -{ - struct pipe_surface surface; -}; - -struct exa_entity -{ - ExaDriverPtr pExa; - struct exa_context *c; - struct pipe_winsys *ws; - struct pipe_context *ctx; - struct pipe_screen *scrn; -}; - -static INLINE struct exa_winsys * -exa_get_winsys(struct pipe_winsys *ws) -{ - return (struct exa_winsys *)ws; -} - -static INLINE struct exa_surface * -exa_get_surface(struct pipe_surface *ps) -{ - return (struct exa_surface *)ps; -} - -static INLINE struct exa_buffer * -exa_get_buffer(struct pipe_buffer *buf) -{ - return (struct exa_buffer *)buf; -} - -static void * -exa_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, - unsigned flags) -{ - struct exa_buffer *exa_buf = exa_get_buffer(buf); - struct exa_winsys *exa_winsys = exa_get_winsys(pws); - void *virtual; - - drmBOMap(exa_winsys->ms->fd, - &exa_buf->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &virtual); - - return virtual; -} - -static void -exa_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct exa_buffer *exa_buf = exa_get_buffer(buf); - struct exa_winsys *exa_winsys = exa_get_winsys(pws); - - drmBOUnmap(exa_winsys->ms->fd, &exa_buf->bo); -} - -static void -exa_buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct exa_winsys *exa_winsys = exa_get_winsys(pws); - struct exa_buffer *exa_buf = exa_get_buffer(buf); - - drmBOUnreference(exa_winsys->ms->fd, &exa_buf->bo); - - free(exa_buf); -} - -static void -exa_flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *surf, void *context_private) -{ - struct exa_buffer *exa_buf = exa_get_buffer(surf->buffer); - - ErrorF("WANT TO FLUSH\n"); -} - -static const char * -exa_get_name(struct pipe_winsys *pws) -{ - return "EXA"; -} - -static struct pipe_buffer * -exa_buffer_create(struct pipe_winsys *pws, - unsigned alignment, unsigned usage, unsigned size) -{ - struct exa_buffer *buffer = xcalloc(1, sizeof(struct exa_buffer)); - struct exa_winsys *exa_winsys = exa_get_winsys(pws); - unsigned int flags = 0; - - buffer->base.refcount = 1; - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - if (exa_winsys->ms->noEvict) { - flags = DRM_BO_FLAG_NO_EVICT; - ErrorF("DISPLAY TARGET\n"); - } - - ErrorF("SIZE %d %d\n", size, alignment); - if (!buffer->bo.handle) { - // buffer->data = align_malloc(size, alignment); - drmBOCreate(exa_winsys->ms->fd, size, 0, NULL, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | - DRM_BO_FLAG_SHAREABLE | DRM_BO_FLAG_MEM_TT | - DRM_BO_FLAG_MAPPABLE | flags, - 0, &buffer->bo); - } - - return &buffer->base; -} - -static struct pipe_buffer * -exa_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct exa_buffer *buffer = xcalloc(1, sizeof(struct exa_buffer)); - - buffer->base.refcount = 1; - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - //buffer->data = ptr; - ErrorF("USERBUFFER\n"); - - return &buffer->base; -} - -/** - * Round n up to next multiple. - */ -static INLINE unsigned -round_up(unsigned n, unsigned multiple) -{ - return (n + multiple - 1) & ~(multiple - 1); -} - -static int -exa_surface_alloc_storage(struct pipe_winsys *winsys, - struct pipe_surface *surf, - unsigned width, unsigned height, - enum pipe_format format, - unsigned flags, unsigned tex_usage) -{ - const unsigned alignment = 64; - - surf->width = width; - surf->height = height; - surf->format = format; - pf_get_block(format, &surf->block); - surf->stride = round_up(surf->nblocksx * surf->block.size, alignment); - - assert(!surf->buffer); - surf->buffer = winsys->buffer_create(winsys, alignment, - PIPE_BUFFER_USAGE_PIXEL, - surf->stride * height); - if (!surf->buffer) - return -1; - - return 0; -} - -/** - * Called via winsys->surface_alloc() to create new surfaces. - */ -static struct pipe_surface * -exa_surface_alloc(struct pipe_winsys *ws) -{ - struct exa_surface *wms = xcalloc(1, sizeof(struct exa_surface)); - - assert(ws); - - wms->surface.refcount = 1; - wms->surface.winsys = ws; - - return &wms->surface; -} - -static void -exa_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) -{ - struct pipe_surface *surf = *s; - - surf->refcount--; - if (surf->refcount == 0) { - if (surf->buffer) - pipe_buffer_reference(winsys, &surf->buffer, NULL); - free(surf); - } - *s = NULL; -} - -/* - * Fence functions - basically nothing to do, as we don't create any actual - * fence objects. - */ -static void -exa_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - -static int -exa_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - -static int -exa_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - -struct pipe_winsys * -exa_get_pipe_winsys(modesettingPtr ms) -{ - static struct exa_winsys *ws = NULL; - - if (!ws) { - ws = xcalloc(1, sizeof(struct exa_winsys)); - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->base.buffer_create = exa_buffer_create; - ws->base.user_buffer_create = exa_user_buffer_create; - ws->base.buffer_map = exa_buffer_map; - ws->base.buffer_unmap = exa_buffer_unmap; - ws->base.buffer_destroy = exa_buffer_destroy; - - ws->base.surface_alloc = exa_surface_alloc; - ws->base.surface_alloc_storage = exa_surface_alloc_storage; - ws->base.surface_release = exa_surface_release; - - ws->base.fence_reference = exa_fence_reference; - ws->base.fence_signalled = exa_fence_signalled; - ws->base.fence_finish = exa_fence_finish; - - ws->base.flush_frontbuffer = exa_flush_frontbuffer; - ws->base.get_name = exa_get_name; - - ws->ms = ms; - } - - return &ws->base; -} - -/* EXA functions */ - -struct PixmapPriv -{ - drmBO bo; -#if 0 - dri_fence *fence; -#endif - int flags; - - struct pipe_texture *tex; - unsigned int color; - struct pipe_surface *src_surf; /* for copies */ -}; - -static enum pipe_format -exa_get_pipe_format(int depth) -{ - switch (depth) { - case 32: - case 24: - return PIPE_FORMAT_A8R8G8B8_UNORM; - case 16: - return PIPE_FORMAT_R5G6B5_UNORM; - case 15: - return PIPE_FORMAT_A1R5G5B5_UNORM; - case 8: - case 4: - case 1: - return PIPE_FORMAT_A8R8G8B8_UNORM; /* bad bad bad */ - default: - assert(0); - return 0; - } -} - -/* - * EXA functions - */ - -static void -ExaWaitMarker(ScreenPtr pScreen, int marker) -{ -} - -static int -ExaMarkSync(ScreenPtr pScreen) -{ - return 1; -} - -Bool -ExaPrepareAccess(PixmapPtr pPix, int index) -{ - ScreenPtr pScreen = pPix->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - struct exa_entity *exa = ms->exa; - struct PixmapPriv *priv; - int ret; - - priv = exaGetPixmapDriverPrivate(pPix); - - if (!priv) - return FALSE; - - if (!priv->tex) - return FALSE; - { - struct pipe_surface *surf = - exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); - pPix->devPrivate.ptr = - exa->scrn->surface_map(exa->scrn, surf, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); - exa->scrn->tex_surface_release(exa->scrn, &surf); - } - - return TRUE; -} - -void -ExaFinishAccess(PixmapPtr pPix, int index) -{ - ScreenPtr pScreen = pPix->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - struct PixmapPriv *priv; - struct exa_entity *exa = ms->exa; - int ret; - - priv = exaGetPixmapDriverPrivate(pPix); - - if (!priv) - return; - - if (!priv->tex) - return; - { - struct pipe_surface *surf = - exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); - exa->scrn->surface_unmap(exa->scrn, surf); - exa->scrn->tex_surface_release(exa->scrn, &surf); - pPix->devPrivate.ptr = NULL; - } -} - -static void -ExaDone(PixmapPtr pPixmap) -{ - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); - struct exa_entity *exa = ms->exa; - - if (!priv) - return; - - if (priv->src_surf) - exa->scrn->tex_surface_release(exa->scrn, &priv->src_surf); - priv->src_surf = NULL; -} - -static void -ExaDoneComposite(PixmapPtr pPixmap) -{ - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; -} - -static Bool -ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) -{ - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); - struct exa_entity *exa = ms->exa; - - if (pPixmap->drawable.depth < 15) - return FALSE; - - if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask)) - return FALSE; - - if (!priv || !priv->tex) - return FALSE; - - if (alu != GXcopy) - return FALSE; - - if (!exa->ctx || !exa->ctx->surface_fill) - return FALSE; - - priv->color = fg; - - return TRUE; -} - -static void -ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) -{ - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_entity *exa = ms->exa; - struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); - struct pipe_surface *surf = - exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - exa->ctx->surface_fill(exa->ctx, surf, x0, y0, x1 - x0, y1 - y0, - priv->color); - - exa->scrn->tex_surface_release(exa->scrn, &surf); -} - -static Bool -ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, - int ydir, int alu, Pixel planeMask) -{ - ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_entity *exa = ms->exa; - struct pipe_surface *src_surf; - struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap); - struct PixmapPriv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap); - - if (alu != GXcopy) - return FALSE; - - if (pSrcPixmap->drawable.depth < 15 || pDstPixmap->drawable.depth < 15) - return FALSE; - - if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask)) - return FALSE; - - if (!priv || !src_priv) - return FALSE; - - if (!priv->tex || !src_priv->tex) - return FALSE; - - if (!exa->ctx || !exa->ctx->surface_copy) - return FALSE; - - priv->src_surf = - exa->scrn->get_tex_surface(exa->scrn, src_priv->tex, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - return FALSE; -} - -static void -ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, - int width, int height) -{ - ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_entity *exa = ms->exa; - struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap); - struct pipe_surface *surf = - exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - exa->ctx->surface_copy(exa->ctx, 0, surf, dstX, dstY, priv->src_surf, - srcX, srcY, width, height); - exa->scrn->tex_surface_release(exa->scrn, &surf); -} - -static Bool -ExaPrepareComposite(int op, PicturePtr pSrcPicture, - PicturePtr pMaskPicture, PicturePtr pDstPicture, - PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) -{ - ScreenPtr pScreen = pDst->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - - return FALSE; -} - -static Bool -ExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, - int src_pitch) -{ - ScreenPtr pScreen = pDst->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - - ErrorF("UPLOAD\n"); - - return FALSE; -} - -static void -ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, - int dstX, int dstY, int width, int height) -{ - ScreenPtr pScreen = pDst->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; -} - -static Bool -ExaCheckComposite(int op, - PicturePtr pSrcPicture, PicturePtr pMaskPicture, - PicturePtr pDstPicture) -{ - DrawablePtr pDraw = pSrcPicture->pDrawable; - int w = pDraw->width; - int h = pDraw->height; - - return FALSE; -} - -static void * -ExaCreatePixmap(ScreenPtr pScreen, int size, int align) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct PixmapPriv *priv; - void *virtual; - - priv = xcalloc(1, sizeof(struct PixmapPriv)); - if (!priv) - return NULL; - - return priv; -} - -static void -ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv) -{ - struct PixmapPriv *priv = (struct PixmapPriv *)dPriv; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_entity *exa = ms->exa; - - if (!priv) - return; - - if (priv->tex) - exa->scrn->texture_release(exa->scrn, &priv->tex); - - xfree(priv); -} - -static Bool -ExaPixmapIsOffscreen(PixmapPtr pPixmap) -{ - struct PixmapPriv *priv; - ScreenPtr pScreen = pPixmap->drawable.pScreen; - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - - priv = exaGetPixmapDriverPrivate(pPixmap); - - if (!priv) - return FALSE; - - if (priv->tex) - return TRUE; - - return FALSE; -} - -/* FIXME !! */ -unsigned int -driGetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_entity *exa = ms->exa; - struct exa_buffer *exa_buf; - struct pipe_surface *surf; - struct PixmapPriv *priv; - - *flags = 0; - - if (!ms->exa) { - FatalError("NO MS->EXA\n"); - return 0; - } - - priv = exaGetPixmapDriverPrivate(pPixmap); - - if (!priv) { - FatalError("NO PIXMAP PRIVATE\n"); - return 0; - } - - surf = - exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); - exa_buf = exa_get_buffer(surf->buffer); - exa->scrn->tex_surface_release(exa->scrn, &surf); - - if (exa_buf->bo.handle) - return exa_buf->bo.handle; - - return 0; -} - -static Bool -ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, - int depth, int bitsPerPixel, int devKind, - pointer pPixData) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); - modesettingPtr ms = modesettingPTR(pScrn); - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - struct exa_entity *exa = ms->exa; - - if (!priv) - return FALSE; - - if (depth <= 0) - depth = pPixmap->drawable.depth; - - if (bitsPerPixel <= 0) - bitsPerPixel = pPixmap->drawable.bitsPerPixel; - - if (width <= 0) - width = pPixmap->drawable.width; - - if (height <= 0) - height = pPixmap->drawable.height; - - if (width <= 0 || height <= 0 || depth <= 0) - return FALSE; - - miModifyPixmapHeader(pPixmap, width, height, depth, - bitsPerPixel, devKind, NULL); - - /* Deal with screen resize */ - if (priv->tex) { - struct pipe_surface *surf = - exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); - - ErrorF("RESIZE %d %d to %d %d\n", surf->width, surf->height, width, - height); - if (surf->width != width || surf->height != height) { - exa->scrn->texture_release(exa->scrn, &priv->tex); - priv->tex = NULL; - } - exa->scrn->tex_surface_release(exa->scrn, &surf); - } - - if (!priv->tex) { - struct pipe_texture template; - - memset(&template, 0, sizeof(template)); - template.target = PIPE_TEXTURE_2D; - template.compressed = 0; - template.format = exa_get_pipe_format(depth); - pf_get_block(template.format, &template.block); - template.width[0] = width; - template.height[0] = height; - template.depth[0] = 1; - template.last_level = 0; - template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - priv->tex = exa->scrn->texture_create(exa->scrn, &template); - } - - return TRUE; -} - -void -ExaClose(ScrnInfoPtr pScrn) -{ - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_entity *exa = ms->exa; - - exaDriverFini(pScrn->pScreen); - - dlclose(ms->driver); -} - -void * -ExaInit(ScrnInfoPtr pScrn) -{ - modesettingPtr ms = modesettingPTR(pScrn); - struct exa_entity *exa; - ExaDriverPtr pExa; - - exa = xcalloc(1, sizeof(struct exa_entity)); - if (!exa) - return NULL; - - pExa = exaDriverAlloc(); - if (!pExa) { - goto out_err; - } - - memset(pExa, 0, sizeof(*pExa)); - pExa->exa_major = 2; - pExa->exa_minor = 4; - pExa->memoryBase = 0; - pExa->memorySize = 0; - pExa->offScreenBase = 0; - pExa->pixmapOffsetAlign = 0; - pExa->pixmapPitchAlign = 1; - pExa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS; - pExa->maxX = 8191; /* FIXME */ - pExa->maxY = 8191; /* FIXME */ - pExa->WaitMarker = ExaWaitMarker; - pExa->MarkSync = ExaMarkSync; - pExa->PrepareSolid = ExaPrepareSolid; - pExa->Solid = ExaSolid; - pExa->DoneSolid = ExaDone; - pExa->PrepareCopy = ExaPrepareCopy; - pExa->Copy = ExaCopy; - pExa->DoneCopy = ExaDone; - pExa->CheckComposite = ExaCheckComposite; - pExa->PrepareComposite = ExaPrepareComposite; - pExa->Composite = ExaComposite; - pExa->DoneComposite = ExaDoneComposite; - pExa->PixmapIsOffscreen = ExaPixmapIsOffscreen; - pExa->PrepareAccess = ExaPrepareAccess; - pExa->FinishAccess = ExaFinishAccess; - pExa->UploadToScreen = ExaUploadToScreen; - pExa->CreatePixmap = ExaCreatePixmap; - pExa->DestroyPixmap = ExaDestroyPixmap; - pExa->ModifyPixmapHeader = ExaModifyPixmapHeader; - - if (!exaDriverInit(pScrn->pScreen, pExa)) { - goto out_err; - } - - { - char filename[128]; - char dri_driver_path[] = DRI_DRIVER_PATH; - - snprintf(filename, sizeof filename, - "%s/%s_dri.so", dri_driver_path, "i915"); - - ms->driver = dlopen(filename, RTLD_NOW | RTLD_DEEPBIND | RTLD_GLOBAL); - if (!ms->driver) - FatalError("failed to initialize i915 - for softpipe only.\n"); - - exa->c = xcalloc(1, sizeof(struct exa_context)); - - exa->ws = exa_get_pipe_winsys(ms); - if (!exa->ws) - FatalError("BAD WINSYS\n"); - - exa->scrn = softpipe_create_screen(exa->ws); - if (!exa->scrn) - FatalError("BAD SCREEN\n"); - - exa->ctx = softpipe_create(exa->scrn, exa->ws, NULL); - if (!exa->ctx) - FatalError("BAD CTX\n"); - - exa->ctx->priv = exa->c; - } - - return (void *)exa; - - out_err: - ExaClose(pScrn); - - return NULL; -} From airlied at kemper.freedesktop.org Mon Oct 3 03:35:54 2011 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Mon, 3 Oct 2011 03:35:54 -0700 (PDT) Subject: xf86-video-modesetting: src/Makefile.am Message-ID: <20111003103554.13161D8002@kemper.freedesktop.org> src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) New commits: commit 5b8167833eee5c6cab9e01bbcfe27296c6a63157 Author: Dave Airlie <airlied at redhat.com> Date: Mon Oct 3 11:35:39 2011 +0100 fix make distcheck diff --git a/src/Makefile.am b/src/Makefile.am index 4337977..efc4bc0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,6 +35,7 @@ modesetting_drv_ladir = @moduledir@/drivers modesetting_drv_la_SOURCES = \ driver.c \ driver.h \ - drmmode_display.c + drmmode_display.c \ + drmmode_display.h EXTRA_DIST = From airlied at kemper.freedesktop.org Mon Oct 3 08:09:28 2011 From: airlied at kemper.freedesktop.org (Dave Airlie) Date: Mon, 3 Oct 2011 08:09:28 -0700 (PDT) Subject: xf86-video-modesetting: src/driver.c src/driver.h Message-ID: <20111003150928.B7C40D8002@kemper.freedesktop.org> src/driver.c | 2 +- src/driver.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) New commits: commit cab577dbb308c18929aecab24d1a1801eefcaf30 Author: Dave Airlie <airlied at redhat.com> Date: Mon Oct 3 16:09:12 2011 +0100 fix fb_id for dirty reporting diff --git a/src/driver.c b/src/driver.c index bde690c..7df587e 100644 --- a/src/driver.c +++ b/src/driver.c @@ -327,7 +327,7 @@ static void dispatch_dirty(ScreenPtr pScreen) } /* TODO query connector property to see if this is needed */ - ret = drmModeDirtyFB(ms->fd, ms->fb_id, clip, num_cliprects); + ret = drmModeDirtyFB(ms->fd, ms->drmmode.fb_id, clip, num_cliprects); if (ret) { if (ret == -EINVAL) { ms->dirty_enabled = FALSE; diff --git a/src/driver.h b/src/driver.h index 494ca0c..2e51089 100644 --- a/src/driver.h +++ b/src/driver.h @@ -46,7 +46,6 @@ typedef struct typedef struct _modesettingRec { int fd; - unsigned int fb_id; EntPtr entityPrivate; From alanc at kemper.freedesktop.org Mon Oct 3 09:35:24 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Mon, 3 Oct 2011 09:35:24 -0700 (PDT) Subject: libXt: Changes to 'master' Message-ID: <20111003163525.10A96D8002@kemper.freedesktop.org> Makefile.am | 6 README | 10 - include/Makefile.am | 2 include/X11/CallbackI.h | 8 include/X11/Composite.h | 8 include/X11/CompositeP.h | 10 - include/X11/ConstrainP.h | 8 include/X11/Constraint.h | 8 include/X11/ConvertI.h | 8 include/X11/Core.h | 8 include/X11/CoreP.h | 8 include/X11/EventI.h | 4 include/X11/InitialI.h | 10 - include/X11/Object.h | 8 include/X11/ObjectP.h | 8 include/X11/PassivGraI.h | 16 - include/X11/RectObj.h | 8 include/X11/RectObjP.h | 8 include/X11/ResConfigP.h | 4 include/X11/ShellP.h | 14 - include/X11/TranslateI.h | 4 include/X11/VarargsI.h | 6 include/X11/Vendor.h | 8 include/X11/VendorP.h | 12 - man/XtAddActions.man | 10 - man/XtAddCallback.man | 18 - man/XtAddEventHandler.man | 46 ++--- man/XtAddExposureToRegion.man | 4 man/XtAddGrab.man | 26 +- man/XtAddInput.man | 34 +-- man/XtAllocateGC.man | 32 +-- man/XtAppAddActionHook.man | 34 +-- man/XtAppAddActions.man | 2 man/XtAppAddBlockHook.man | 34 +-- man/XtAppAddConverter.man | 4 man/XtAppAddInput.man | 8 man/XtAppAddSignal.man | 50 ++--- man/XtAppAddTimeOut.man | 4 man/XtAppAddWorkProc.man | 4 man/XtAppCreateShell.man | 38 ++-- man/XtAppError.man | 8 man/XtAppErrorMsg.man | 8 man/XtAppGetErrorDatabase.man | 6 man/XtAppGetSelectionTimeout.man | 8 man/XtAppInitialize.man | 36 +-- man/XtAppLock.man | 38 ++-- man/XtAppNextEvent.man | 42 ++-- man/XtAppReleaseCacheRefs.man | 34 +-- man/XtAppSetExitFlag.man | 34 +-- man/XtAppSetFallbackResources.man | 36 +-- man/XtAppSetTypeConverter.man | 36 +-- man/XtBuildEventMask.man | 4 man/XtCallAcceptFocus.man | 2 man/XtCallActionProc.man | 32 +-- man/XtCallCallbacks.man | 38 ++-- man/XtClass.man | 34 +-- man/XtConfigureWidget.man | 10 - man/XtConvert.man | 6 man/XtConvertAndStore.man | 38 ++-- man/XtCreateApplicationContext.man | 8 man/XtCreateApplicationShell.man | 2 man/XtCreatePopupShell.man | 4 man/XtCreateSelectionRequest.man | 40 ++-- man/XtCreateWidget.man | 34 +-- man/XtCreateWindow.man | 4 man/XtDisplay.man | 38 ++-- man/XtDisplayInitialize.man | 54 ++--- man/XtDisplayStringConversionWarning.man | 14 - man/XtDisplayToApplicationContext.man | 32 +-- man/XtError.man | 38 ++-- man/XtErrorMsg.man | 38 ++-- man/XtFindFile.man | 32 +-- man/XtGetActionKeysym.man | 34 +-- man/XtGetActionList.man | 32 +-- man/XtGetApplicationNameAndClass.man | 32 +-- man/XtGetApplicationResources.man | 4 man/XtGetClassExtension.man | 38 ++-- man/XtGetDisplays.man | 32 +-- man/XtGetErrorDatabase.man | 6 man/XtGetGC.man | 6 man/XtGetKeyboardFocusWidget.man | 32 +-- man/XtGetKeysymTable.man | 16 - man/XtGetResourceList.man | 14 - man/XtGetSelectionParameters.man | 34 +-- man/XtGetSelectionRequest.man | 32 +-- man/XtGetSelectionTimeout.man | 34 +-- man/XtGetSelectionValue.man | 28 +-- man/XtGetSelectionValueIncremental.man | 36 +-- man/XtGetSubresources.man | 4 man/XtGrabKey.man | 50 ++--- man/XtHooksOfDisplay.man | 32 +-- man/XtInitialize.man | 34 +-- man/XtInitializeWidgetClass.man | 34 +-- man/XtInsertEventTypeHandler.man | 42 ++-- man/XtLastEventProcessed.man | 38 ++-- man/XtMakeGeometryRequest.man | 18 - man/XtMalloc.man | 18 - man/XtManageChildren.man | 32 +-- man/XtMapWidget.man | 12 - man/XtName.man | 32 +-- man/XtNameToWidget.man | 8 man/XtNextEvent.man | 20 +- man/XtOffset.man | 40 ++-- man/XtOpenApplication.man | 40 ++-- man/XtOwnSelection.man | 40 ++-- man/XtParent.man | 2 man/XtParseAcceleratorTable.man | 14 - man/XtParseTranslationTable.man | 6 man/XtPopdown.man | 22 +- man/XtPopup.man | 36 +-- man/XtProcessLock.man | 38 ++-- man/XtQueryGeometry.man | 2 man/XtRealizeWidget.man | 30 +-- man/XtRegisterDrawable.man | 34 +-- man/XtRegisterGrabAction.man | 32 +-- man/XtReservePropertyAtom.man | 34 +-- man/XtResolvePathname.man | 34 +-- man/XtSessionGetToken.man | 4 man/XtSetArg.man | 8 man/XtSetKeyTranslator.man | 24 +- man/XtSetKeyboardFocus.man | 10 - man/XtSetLanguageProc.man | 8 man/XtSetMultiClickTime.man | 30 +-- man/XtSetSelectionParameters.man | 34 +-- man/XtSetSensitive.man | 26 +- man/XtSetValues.man | 48 ++--- man/XtSetWMColormapWindows.man | 32 +-- man/XtStringConversionWarning.man | 2 man/XtToolkitThreadInitialize.man | 32 +-- man/XtTranslateCoords.man | 4 man/XtVaCreateArgsList.man | 2 specs/CH01 | 140 +++++++-------- specs/CH02 | 192 ++++++++++----------- specs/CH03 | 62 +++--- specs/CH04 | 154 ++++++++--------- specs/CH05 | 56 +++--- specs/CH06 | 86 ++++----- specs/CH07 | 280 +++++++++++++++---------------- specs/CH08 | 24 +- specs/CH09 | 104 +++++------ specs/CH10 | 74 ++++---- specs/CH11 | 272 +++++++++++++++--------------- specs/CH12 | 20 +- specs/CH13 | 88 ++++----- specs/Xtk.intr.front | 28 +-- specs/appA | 14 - specs/appB | 66 +++---- specs/appC | 74 ++++---- specs/appD | 14 - specs/appE | 16 - specs/appF | 36 +-- src/ActionHook.c | 2 src/Alloc.c | 2 src/Makefile.am | 10 - src/PopupCB.c | 8 src/Resources.c | 32 +-- src/Selection.c | 5 src/SetSens.c | 4 src/TMaction.c | 2 src/VarCreate.c | 26 +- src/Varargs.c | 2 src/Vendor.c | 14 - src/sharedlib.c | 6 test/Converters.c | 6 util/Shell.ht | 10 - util/StrDefs.ct | 8 util/StrDefs.ht | 8 util/makestrs.c | 136 +++++++-------- util/makestrs.man | 72 +++---- util/string.list | 2 170 files changed, 2470 insertions(+), 2467 deletions(-) New commits: commit df2008411a5c6a735af2b0fced01df660bb6978a Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Mon Sep 26 15:29:45 2011 -0700 makestrs: Add const attributes to fix gcc -Wwrite-strings warnings Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 9347b890ba24db41c7cb6c6e76564e4896bc8cac Author: Olivier Fourdan <fourdan at xfce.org> Date: Tue Sep 20 16:45:02 2011 -0700 Bug 40577 - Missing bound checking in FreeSelectionProperty() https://bugs.freedesktop.org/show_bug.cgi?id=40577 FreeSelectionProperty() did not check for the count of items in array and relied on a NULL terminated list, which can cause libXt to crash if FreeSelectionProperty() follows a call to GetSelectionProperty() which reallocates the array. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 5691187ced24b16a951e2b8308bcc2b65dd36eee Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Sep 16 22:54:05 2011 -0700 Strip trailing whitespace Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From keithp at kemper.freedesktop.org Mon Oct 3 11:32:05 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 11:32:05 -0700 (PDT) Subject: xserver: Branch 'master' - 3 commits Message-ID: <20111003183205.99052D8002@kemper.freedesktop.org> configure.ac | 10 +-- hw/xfree86/modes/xf86Crtc.h | 24 +++++++ hw/xfree86/modes/xf86Cursors.c | 88 ++++++++++++++++----------- hw/xfree86/modes/xf86Rotate.c | 131 +++++++++++++++++++++-------------------- 4 files changed, 151 insertions(+), 102 deletions(-) New commits: commit 57cd32e93425597317b4b7722859155419836e4c Author: Aaron Plattner <aplattner at nvidia.com> Date: Thu Aug 25 15:41:55 2011 -0700 xfree86/modes: Make cursor position transform a helper function When the driver can handle the crtc transform in hardware, it sets crtc->driverIsPerformingTransform, which turns off both the shadow layer and the cursor's position-transforming code. However, some drivers actually do require the cursor position to still be transformed in these cases. Move the cursor position transform into a helper function that can be called by such drivers. Signed-off-by: Aaron Plattner <aplattner at nvidia.com> diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 0d7a6a6..ffb2eff 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -948,6 +948,14 @@ xf86_hide_cursors (ScrnInfoPtr scrn); extern _X_EXPORT void xf86_cursors_fini (ScreenPtr screen); +/** + * Transform the cursor's coordinates based on the crtc transform. Normally + * this is done by the server, but if crtc->driverIsPerformingTransform is TRUE, + * then the server does not transform the cursor position automatically. + */ +extern _X_EXPORT void +xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y); + /* * For overlay video, compute the relevant CRTC and * clip video to that. diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 02dea5c..4a03428 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -337,7 +337,36 @@ xf86_show_cursors (ScrnInfoPtr scrn) xf86_crtc_show_cursor (crtc); } } - + +void xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y) +{ + ScrnInfoPtr scrn = crtc->scrn; + ScreenPtr screen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + xf86CursorScreenPtr ScreenPriv = + (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates, + xf86CursorScreenKey); + struct pict_f_vector v; + int dx, dy; + + v.v[0] = (*x + ScreenPriv->HotX) + 0.5; + v.v[1] = (*y + ScreenPriv->HotY) + 0.5; + v.v[2] = 1; + pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v); + /* cursor will have 0.5 added to it already so floor is sufficent */ + *x = floor (v.v[0]); + *y = floor (v.v[1]); + /* + * Transform position of cursor upper left corner + */ + xf86_crtc_rotate_coord_back (crtc->rotation, cursor_info->MaxWidth, + cursor_info->MaxHeight, ScreenPriv->HotX, + ScreenPriv->HotY, &dx, &dy); + *x -= dx; + *y -= dy; +} + static void xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y) { @@ -346,36 +375,12 @@ xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y) xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; DisplayModePtr mode = &crtc->mode; Bool in_range; - int dx, dy; /* * Transform position of cursor on screen */ if (crtc->transform_in_use && !crtc->driverIsPerformingTransform) - { - ScreenPtr screen = scrn->pScreen; - xf86CursorScreenPtr ScreenPriv = - (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates, - xf86CursorScreenKey); - struct pict_f_vector v; - - v.v[0] = (x + ScreenPriv->HotX) + 0.5; - v.v[1] = (y + ScreenPriv->HotY) + 0.5; - v.v[2] = 1; - pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v); - /* cursor will have 0.5 added to it already so floor is sufficent */ - x = floor (v.v[0]); - y = floor (v.v[1]); - /* - * Transform position of cursor upper left corner - */ - xf86_crtc_rotate_coord_back (crtc->rotation, - cursor_info->MaxWidth, - cursor_info->MaxHeight, - ScreenPriv->HotX, ScreenPriv->HotY, &dx, &dy); - x -= dx; - y -= dy; - } + xf86CrtcTransformCursorPos(crtc, &x, &y); else { x -= crtc->x; commit 245cb8e94fd15990e1b7d6622added460f104dba Author: Aaron Plattner <aplattner at nvidia.com> Date: Thu Aug 25 10:19:48 2011 -0700 xfree86/modes: Let the driver handle the transform If a driver can use hardware to handle the crtc transform, then there's no need for the server's shadow layer to do it. Add a crtc flag that lets the driver indicate that it is handling the transform. If it's set, consider the transformed size of the screen but don't actually enable the shadow layer. Also stop adjusting the cursor image and position. Signed-off-by: Aaron Plattner <aplattner at nvidia.com> diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 68a968c..0d7a6a6 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -1,5 +1,6 @@ /* * Copyright ?? 2006 Keith Packard + * Copyright ?? 2011 Aaron Plattner * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -223,7 +224,7 @@ typedef struct _xf86CrtcFuncs { } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; -#define XF86_CRTC_VERSION 3 +#define XF86_CRTC_VERSION 4 struct _xf86Crtc { /** @@ -361,6 +362,19 @@ struct _xf86Crtc { * Clear the shadow */ Bool shadowClear; + + /** + * Indicates that the driver is handling the transform, so the shadow + * surface should be disabled. The driver writes this field before calling + * xf86CrtcRotate to indicate that it is handling the transform (including + * rotation and reflection). + * + * Setting this flag also causes the server to stop adjusting the cursor + * image and position. + * + * Added in ABI version 4 + */ + Bool driverIsPerformingTransform; }; typedef struct _xf86OutputFuncs { diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 23c48eb..02dea5c 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -1,6 +1,6 @@ /* * Copyright ?? 2007 Keith Packard - * Copyright ?? 2010 Aaron Plattner + * Copyright ?? 2010-2011 Aaron Plattner * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -47,6 +47,18 @@ #include "inputstr.h" /* + * Returns the rotation being performed by the server. If the driver indicates + * that it's handling the screen transform, then this returns RR_Rotate_0. + */ +static Rotation +xf86_crtc_cursor_rotation (xf86CrtcPtr crtc) +{ + if (crtc->driverIsPerformingTransform) + return RR_Rotate_0; + return crtc->rotation; +} + +/* * Given a screen coordinate, rotate back to a cursor source coordinate */ static void @@ -214,6 +226,7 @@ xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src) int xin, yin; int flags = cursor_info->Flags; CARD32 bits; + const Rotation rotation = xf86_crtc_cursor_rotation(crtc); #ifdef ARGB_CURSOR crtc->cursor_argb = FALSE; @@ -222,7 +235,7 @@ xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src) for (y = 0; y < cursor_info->MaxHeight; y++) for (x = 0; x < cursor_info->MaxWidth; x++) { - xf86_crtc_rotate_coord (crtc->rotation, + xf86_crtc_rotate_coord (rotation, cursor_info->MaxWidth, cursor_info->MaxHeight, x, y, &xin, &yin); @@ -338,7 +351,7 @@ xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y) /* * Transform position of cursor on screen */ - if (crtc->transform_in_use) + if (crtc->transform_in_use && !crtc->driverIsPerformingTransform) { ScreenPtr screen = scrn->pScreen; xf86CursorScreenPtr ScreenPriv = @@ -420,12 +433,13 @@ xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; CARD8 *cursor_image; + const Rotation rotation = xf86_crtc_cursor_rotation(crtc); #ifdef ARGB_CURSOR crtc->cursor_argb = FALSE; #endif - if (crtc->rotation == RR_Rotate_0) + if (rotation == RR_Rotate_0) cursor_image = src; else { @@ -439,7 +453,7 @@ xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src) for (y = 0; y < cursor_info->MaxHeight; y++) for (x = 0; x < cursor_info->MaxWidth; x++) { - xf86_crtc_rotate_coord (crtc->rotation, + xf86_crtc_rotate_coord (rotation, cursor_info->MaxWidth, cursor_info->MaxHeight, x, y, &xin, &yin); @@ -532,12 +546,13 @@ xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor) int source_height = cursor->bits->height; int image_width = cursor_info->MaxWidth; int image_height = cursor_info->MaxHeight; - + const Rotation rotation = xf86_crtc_cursor_rotation(crtc); + for (y = 0; y < image_height; y++) for (x = 0; x < image_width; x++) { - xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height, - x, y, &xin, &yin); + xf86_crtc_rotate_coord (rotation, image_width, image_height, x, y, + &xin, &yin); if (xin < source_width && yin < source_height) bits = cursor_source[yin * source_width + xin]; else diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 57c3499..45aabf0 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -1,5 +1,6 @@ /* * Copyright ?? 2006 Keith Packard + * Copyright ?? 2011 Aaron Plattner * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -84,7 +85,10 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) int n = RegionNumRects(region); BoxPtr b = RegionRects(region); XID include_inferiors = IncludeInferiors; - + + if (crtc->driverIsPerformingTransform) + return; + src = CreatePicture (None, &root->drawable, format, @@ -290,7 +294,7 @@ xf86RotateDestroy (xf86CrtcPtr crtc) } for (c = 0; c < xf86_config->num_crtc; c++) - if (xf86_config->crtc[c]->transform_in_use) + if (xf86_config->crtc[c]->rotatedData) return; /* @@ -414,52 +418,73 @@ xf86CrtcRotate (xf86CrtcPtr crtc) } else { - /* - * these are the size of the shadow pixmap, which - * matches the mode, not the pre-rotated copy in the - * frame buffer - */ - int width = crtc->mode.HDisplay; - int height = crtc->mode.VDisplay; - void *shadowData = crtc->rotatedData; - PixmapPtr shadow = crtc->rotatedPixmap; - int old_width = shadow ? shadow->drawable.width : 0; - int old_height = shadow ? shadow->drawable.height : 0; - - /* Allocate memory for rotation */ - if (old_width != width || old_height != height) - { - if (shadow || shadowData) + if (crtc->driverIsPerformingTransform) { + xf86RotateDestroy(crtc); + } else { + /* + * these are the size of the shadow pixmap, which + * matches the mode, not the pre-rotated copy in the + * frame buffer + */ + int width = crtc->mode.HDisplay; + int height = crtc->mode.VDisplay; + void *shadowData = crtc->rotatedData; + PixmapPtr shadow = crtc->rotatedPixmap; + int old_width = shadow ? shadow->drawable.width : 0; + int old_height = shadow ? shadow->drawable.height : 0; + + /* Allocate memory for rotation */ + if (old_width != width || old_height != height) { - crtc->funcs->shadow_destroy (crtc, shadow, shadowData); - crtc->rotatedPixmap = NULL; - crtc->rotatedData = NULL; + if (shadow || shadowData) + { + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + shadowData = crtc->funcs->shadow_allocate (crtc, width, height); + if (!shadowData) + goto bail1; + crtc->rotatedData = shadowData; + /* shadow will be damaged in xf86RotatePrepare */ + } + else + { + /* mark shadowed area as damaged so it will be repainted */ + damage = TRUE; } - shadowData = crtc->funcs->shadow_allocate (crtc, width, height); - if (!shadowData) - goto bail1; - crtc->rotatedData = shadowData; - /* shadow will be damaged in xf86RotatePrepare */ - } - else - { - /* mark shadowed area as damaged so it will be repainted */ - damage = TRUE; - } - if (!xf86_config->rotation_damage) - { - /* Create damage structure */ - xf86_config->rotation_damage = DamageCreate (NULL, NULL, - DamageReportNone, - TRUE, pScreen, pScreen); if (!xf86_config->rotation_damage) - goto bail2; - - /* Wrap block handler */ - if (!xf86_config->BlockHandler) { - xf86_config->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = xf86RotateBlockHandler; + { + /* Create damage structure */ + xf86_config->rotation_damage = DamageCreate (NULL, NULL, + DamageReportNone, + TRUE, pScreen, pScreen); + if (!xf86_config->rotation_damage) + goto bail2; + + /* Wrap block handler */ + if (!xf86_config->BlockHandler) { + xf86_config->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = xf86RotateBlockHandler; + } + } + + if (0) + { + bail2: + if (shadow || shadowData) + { + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + bail1: + if (old_width && old_height) + crtc->rotatedPixmap = + crtc->funcs->shadow_create (crtc, NULL, old_width, + old_height); + return FALSE; } } #ifdef RANDR_12_INTERFACE @@ -482,24 +507,6 @@ xf86CrtcRotate (xf86CrtcPtr crtc) } } #endif - - if (0) - { - bail2: - if (shadow || shadowData) - { - crtc->funcs->shadow_destroy (crtc, shadow, shadowData); - crtc->rotatedPixmap = NULL; - crtc->rotatedData = NULL; - } - bail1: - if (old_width && old_height) - crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, - NULL, - old_width, - old_height); - return FALSE; - } crtc->transform_in_use = TRUE; } crtc->crtc_to_framebuffer = crtc_to_fb; commit e089737fb13868bd3a72b7ac4799d502d188f03e Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 3 11:23:16 2011 -0700 Add AC_LANG_SOURCE wrappers around configure.ac code fragments Current autoconf versions are very unhappy when code fragments are not wrapped in AC_LANG_SOURCE macros, generating errors like: configure.ac:723: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2662: _AC_LINK_IFELSE is expanded from... ../../lib/autoconf/general.m4:2679: AC_LINK_IFELSE is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... configure.ac:723: the top level Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/configure.ac b/configure.ac index b0d2643..60ebbcb 100644 --- a/configure.ac +++ b/configure.ac @@ -723,7 +723,7 @@ case $host_os in AC_CACHE_CHECK([whether to build Xquartz],xorg_cv_Carbon_framework,[ save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -framework Carbon" - AC_LINK_IFELSE([char FSFindFolder(); int main() { FSFindFolder(); return 0;}], + AC_LINK_IFELSE([AC_LANG_SOURCE([char FSFindFolder(); int main() { FSFindFolder(); return 0;}])], [xorg_cv_Carbon_framework=yes], [xorg_cv_Carbon_framework=no]) LDFLAGS=$save_LDFLAGS]) @@ -874,12 +874,12 @@ AC_DEFINE_UNQUOTED([USE_SIGIO_BY_DEFAULT], [$USE_SIGIO_BY_DEFAULT_VALUE], [Use SIGIO handlers for input device events by default]) AC_MSG_CHECKING([for glibc...]) -AC_PREPROC_IFELSE([ +AC_PREPROC_IFELSE([AC_LANG_SOURCE([ #include <features.h> #ifndef __GLIBC__ #error #endif -], glibc=yes, glibc=no) +])], glibc=yes, glibc=no) AC_MSG_RESULT([$glibc]) AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], @@ -903,7 +903,7 @@ if ! test "x$have_clock_gettime" = xno; then CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L" fi - AC_RUN_IFELSE([ + AC_RUN_IFELSE([AC_LANG_SOURCE([ #include <time.h> int main(int argc, char *argv[[]]) { @@ -914,7 +914,7 @@ int main(int argc, char *argv[[]]) { else return 1; } - ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no], + ])], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no], [MONOTONIC_CLOCK="cross compiling"]) LIBS="$LIBS_SAVE" From keithp at kemper.freedesktop.org Mon Oct 3 11:40:37 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 11:40:37 -0700 (PDT) Subject: xserver: Branch 'master' - 44 commits Message-ID: <20111003184037.9EFC2D8002@kemper.freedesktop.org> Xi/exevents.c | 64 +++ Xi/xiproperty.c | 5 Xi/xiquerydevice.c | 73 ++++ Xi/xiquerydevice.h | 1 Xi/xiwarppointer.c | 2 configure.ac | 2 dix/devices.c | 12 dix/eventconvert.c | 22 - dix/events.c | 92 ++++- dix/getevents.c | 618 ++++++++++++++++++++++---------------- dix/inpututils.c | 32 + dix/ptrveloc.c | 259 ++++++--------- hw/xfree86/common/xf86Module.h | 2 hw/xfree86/common/xf86Xinput.c | 8 hw/xfree86/common/xf86Xinput.h | 2 include/eventstr.h | 11 include/exevents.h | 25 + include/input.h | 6 include/inputstr.h | 23 + include/inpututils.h | 2 include/protocol-versions.h | 2 include/ptrveloc.h | 32 - include/xserver-properties.h | 2 test/input.c | 78 ++++ test/xi2/protocol-common.c | 63 +++ test/xi2/protocol-eventconvert.c | 40 +- test/xi2/protocol-xiquerydevice.c | 49 ++- xkb/xkbAccessX.c | 1 28 files changed, 1032 insertions(+), 496 deletions(-) New commits: commit f5d50b46ddeb039ab6564141f61261e94ee67637 Merge: 57cd32e... 524e544... Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 3 11:36:28 2011 -0700 Merge remote-tracking branch 'whot/next' commit 524e5445c0b6df5247d4aac5368470bb89ef4080 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Sat Oct 1 08:43:52 2011 -0700 Add #include "inpututils.h" to xkbAccessX.c for init_device_event Fixes Sun compiler warning: "xkbAccessX.c", line 128: warning: implicit function declaration: init_device_event Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index 4115ff2..d246827 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -37,6 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/extensions/XIproto.h> #include "inputstr.h" #include "eventstr.h" +#include "inpututils.h" #include <xkbsrv.h> #if !defined(WIN32) #include <sys/time.h> commit f32c827d513c44f07e1d0fbcc0c96cef18c9a4d9 Author: Max Schwarz <Max at x-quadraht.de> Date: Sun Sep 25 20:44:26 2011 +0200 Input: Fix frac calculation on [Raw]DeviceEvent conversion (1UL << 32) evaluates to 0 (at least here), so do the fraction calculation in two steps as in libXi. Fractions on xXIRawEvent were not multiplied at all, which also gave 0 as result. Signed-off-by: Max Schwarz <Max at x-quadraht.de> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 9cc177e..f9aafa5 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -635,7 +635,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) SetBit(ptr, i); axisval->integral = trunc(ev->valuators.data[i]); axisval->frac = (ev->valuators.data[i] - axisval->integral) * - (1UL << 32); + (1 << 16) * (1 << 16); axisval++; } } @@ -679,10 +679,12 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) { SetBit(ptr, i); axisval->integral = trunc(ev->valuators.data[i]); - axisval->frac = ev->valuators.data[i] - axisval->integral; + axisval->frac = (ev->valuators.data[i] - axisval->integral) * + (1 << 16) * (1 << 16); axisval_raw->integral = trunc(ev->valuators.data_raw[i]); - axisval_raw->frac = ev->valuators.data_raw[i] - - axisval_raw->integral; + axisval_raw->frac = + (ev->valuators.data_raw[i] - axisval_raw->integral) * + (1 << 16) * (1 << 16); axisval++; axisval_raw++; } commit 4c6bc0e76599dbe5ede2e1f48c9936a0e996b638 Merge: 057cc92... 3304bbf... Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Sep 30 09:24:56 2011 +1000 Merge branch 'smooth-scrolling' into next commit 3304bbff9b4ed63f1a47410a5320a136420ba2c6 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Feb 15 18:49:58 2011 +0000 Input: Add smooth-scrolling support to GetPointerEvents For scroll wheel support, we used to send buttons 4/5 and 6/7 for horizontal/vertical positive/negative scroll events. For touchpads, we really want more fine-grained scroll values. GetPointerEvents now accepts both old-school scroll button presses, and new-style scroll axis events, while emitting both types of events to support both old and new clients. This works with the new XIScrollClass to mark axes as scrolling axes. Drivers mark any valuators that send scroll events with SetScrollValuator. (Currently missing: the XIDeviceChangeEvent being sent when a driver changes a scroll axis at run-time. This can be added later.) Note: the SCROLL_TYPE enums are intentionally different values to the XI2 proto values to avoid copy/overlapping range bugs. Co-authored-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index a6455e6..74a78ec 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1091,6 +1091,55 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int if (mode & OutOfProximity) dev->proximity->in_proximity = FALSE; + return SetScrollValuator(dev, axnum, SCROLL_TYPE_NONE, 0, SCROLL_FLAG_NONE); +} + +/** + * Set the given axis number as a scrolling valuator. + */ +Bool +SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double increment, int flags) +{ + AxisInfoPtr ax; + int *current_ax; + + if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes) + return FALSE; + + switch (type) + { + case SCROLL_TYPE_VERTICAL: + current_ax = &dev->valuator->v_scroll_axis; + break; + case SCROLL_TYPE_HORIZONTAL: + current_ax = &dev->valuator->h_scroll_axis; + break; + case SCROLL_TYPE_NONE: + ax = &dev->valuator->axes[axnum]; + ax->scroll.type = type; + return TRUE; + default: + return FALSE; + } + + if (increment == 0.0) + return FALSE; + + if (*current_ax != -1 && axnum != *current_ax) + { + ax = &dev->valuator->axes[*current_ax]; + if (ax->scroll.type == type && + (flags & SCROLL_FLAG_PREFERRED) && (ax->scroll.flags & SCROLL_FLAG_PREFERRED)) + return FALSE; + } + *current_ax = axnum; + + ax = &dev->valuator->axes[axnum]; + ax->scroll.type = type; + ax->scroll.increment = increment; + ax->scroll.flags = flags; + /* FIXME: generate DeviceChanged Events */ + return TRUE; } diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 902eb91..9961d1b 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -229,7 +229,16 @@ SizeDeviceClasses(DeviceIntPtr dev) } if (dev->valuator) - len += sizeof(xXIValuatorInfo) * dev->valuator->numAxes; + { + int i; + len += (sizeof(xXIValuatorInfo)) * dev->valuator->numAxes; + + for (i = 0; i < dev->valuator->numAxes; i++) { + if (dev->valuator->axes[i].scroll.type != SCROLL_TYPE_NONE) + len += sizeof(xXIScrollInfo); + } + } + return len; } @@ -369,6 +378,56 @@ SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info) swaps(&info->sourceid); } +int +ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo *info, int axisnumber) +{ + ValuatorClassPtr v = dev->valuator; + AxisInfoPtr axis = &v->axes[axisnumber]; + + if (axis->scroll.type == SCROLL_TYPE_NONE) + return 0; + + info->type = XIScrollClass; + info->length = sizeof(xXIScrollInfo)/4; + info->number = axisnumber; + switch(axis->scroll.type) + { + case SCROLL_TYPE_VERTICAL: + info->scroll_type = XIScrollTypeVertical; + break; + case SCROLL_TYPE_HORIZONTAL: + info->scroll_type = XIScrollTypeHorizontal; + break; + default: + ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", axis->scroll.type); + break; + } + info->increment.integral = (int)axis->scroll.increment; + info->increment.frac = (unsigned int)(axis->scroll.increment * (1UL << 16) * (1UL << 16)); + info->sourceid = v->sourceid; + + info->flags = 0; + + if (axis->scroll.flags & SCROLL_FLAG_DONT_EMULATE) + info->flags |= XIScrollFlagNoEmulation; + if (axis->scroll.flags & SCROLL_FLAG_PREFERRED) + info->flags |= XIScrollFlagPreferred; + + return info->length * 4; +} + +static void +SwapScrollInfo(DeviceIntPtr dev, xXIScrollInfo* info) +{ + swaps(&info->type); + swaps(&info->length); + swaps(&info->number); + swaps(&info->sourceid); + swaps(&info->scroll_type); + swapl(&info->increment.integral); + swapl(&info->increment.frac); +} + int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) { DeviceIntPtr master = GetMaster(dev, MASTER_ATTACHED); @@ -458,6 +517,15 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev, total_len += len; } + for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++) + { + len = ListScrollInfo(dev, (xXIScrollInfo*)any, i); + if (len) + (*nclasses)++; + any += len; + total_len += len; + } + return total_len; } @@ -484,6 +552,9 @@ SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info) case XIValuatorClass: SwapValuatorInfo(dev, (xXIValuatorInfo*)any); break; + case XIScrollClass: + SwapScrollInfo(dev, (xXIScrollInfo*)any); + break; } any += len * 4; diff --git a/Xi/xiquerydevice.h b/Xi/xiquerydevice.h index 02f0659..9db6aa2 100644 --- a/Xi/xiquerydevice.h +++ b/Xi/xiquerydevice.h @@ -44,4 +44,5 @@ int ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState); int ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info); int ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber, Bool reportState); +int ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo* info, int axisnumber); #endif /* QUERYDEV_H */ diff --git a/dix/devices.c b/dix/devices.c index ab8a648..64557aa 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -260,6 +260,8 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE); if (!dev) return (DeviceIntPtr)NULL; + + dev->last.scroll = NULL; dev->id = devid; dev->public.processInputProc = ProcessOtherEvent; dev->public.realInputProc = ProcessOtherEvent; @@ -939,6 +941,7 @@ CloseDevice(DeviceIntPtr dev) free(dev->deviceGrab.sync.event); free(dev->config_info); /* Allocated in xf86ActivateDevice. */ + free(dev->last.scroll); dev->config_info = NULL; dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE); } @@ -1277,10 +1280,19 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, if (!valc) return FALSE; + dev->last.scroll = valuator_mask_new(numAxes); + if (!dev->last.scroll) + { + free(valc); + return FALSE; + } + valc->sourceid = dev->id; valc->motion = NULL; valc->first_motion = 0; valc->last_motion = 0; + valc->h_scroll_axis = -1; + valc->v_scroll_axis = -1; valc->numMotionEvents = numMotionEvents; valc->motionHintWindow = NullWindow; diff --git a/dix/getevents.c b/dix/getevents.c index 45243df..c429715 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -2,6 +2,7 @@ * Copyright ?? 2006 Nokia Corporation * Copyright ?? 2006-2007 Daniel Stone * Copyright ?? 2008 Red Hat, Inc. + * Copyright ?? 2011 The Chromium Authors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -603,8 +604,10 @@ GetMaximumEventsNum(void) { /* One raw event * One device event * One possible device changed event + * Lots of possible separate button scroll events (horiz + vert) + * Lots of possible separate raw button scroll events (horiz + vert) */ - return 3; + return 100; } @@ -1171,6 +1174,95 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, } /** + * Generate events for each scroll axis that changed between before/after + * for the device. + * + * @param events The pointer to the event list to fill the events + * @param dev The device to generate the events for + * @param axis The axis number to generate events for + * @param mask State before this event in absolute coords + * @param[in,out] last Last scroll state posted in absolute coords (modified + * in-place) + * @param ms Current time in ms + * @param max_events Max number of events to be generated + * @return The number of events generated + */ +static int +emulate_scroll_button_events(InternalEvent *events, + DeviceIntPtr dev, + int axis, + const ValuatorMask *mask, + ValuatorMask *last, + CARD32 ms, + int max_events) +{ + AxisInfoPtr ax; + double delta; + double incr; + int num_events = 0; + double total; + int b; + + if (dev->valuator->axes[axis].scroll.type == SCROLL_TYPE_NONE) + return 0; + + if (!valuator_mask_isset(mask, axis)) + return 0; + + ax = &dev->valuator->axes[axis]; + incr = ax->scroll.increment; + + if (!valuator_mask_isset(last, axis)) + valuator_mask_set_double(last, axis, 0); + + delta = valuator_mask_get_double(mask, axis) - valuator_mask_get_double(last, axis); + total = delta; + b = (ax->scroll.type == SCROLL_TYPE_VERTICAL) ? 5 : 7; + + if ((incr > 0 && delta < 0) || + (incr < 0 && delta > 0)) + b--; /* we're scrolling up or left ??? button 4 or 6 */ + + while (fabs(delta) >= fabs(incr)) + { + int nev_tmp; + + if (delta > 0) + delta -= fabs(incr); + else if (delta < 0) + delta += fabs(incr); + + /* fill_pointer_events() generates four events: one normal and one raw + * event for button press and button release. + * We may get a bigger scroll delta than we can generate events + * for. In that case, we keep decreasing delta, but skip events. + */ + if (num_events + 4 < max_events) + { + nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms, + POINTER_EMULATED, NULL); + events += nev_tmp; + num_events += nev_tmp; + nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms, + POINTER_EMULATED, NULL); + events += nev_tmp; + num_events += nev_tmp; + } + } + + /* We emulated, update last.scroll */ + if (total != delta) + { + total -= delta; + valuator_mask_set_double(last, axis, + valuator_mask_get_double(last, axis) + total); + } + + return num_events; +} + + +/** * Generate a complete series of InternalEvents (filled into the EventList) * representing pointer motion, or button presses. If the device is a slave * device, also potentially generate a DeviceClassesChangedEvent to update @@ -1193,7 +1285,12 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons, int flags, const ValuatorMask *mask_in) { CARD32 ms = GetTimeInMillis(); - int num_events = 0; + int num_events = 0, nev_tmp; + int h_scroll_axis = pDev->valuator->h_scroll_axis; + int v_scroll_axis = pDev->valuator->v_scroll_axis; + ValuatorMask mask; + ValuatorMask scroll; + int i; /* refuse events from disabled devices */ if (!pDev->enabled) @@ -1204,8 +1301,73 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events); - num_events += fill_pointer_events(events, pDev, type, buttons, ms, flags, - mask_in); + + valuator_mask_copy(&mask, mask_in); + + /* Turn a scroll button press into a smooth-scrolling event if + * necessary. This only needs to cater for the XIScrollFlagPreferred + * axis (if more than one scrolling axis is present) */ + if (type == ButtonPress) + { + double val, adj; + int axis; + + switch (buttons) { + case 4: + adj = 1.0; + axis = v_scroll_axis; + break; + case 5: + adj = -1.0; + axis = v_scroll_axis; + break; + case 6: + adj = 1.0; + axis = h_scroll_axis; + break; + case 7: + adj = -1.0; + axis = h_scroll_axis; + break; + default: + adj = 0.0; + axis = -1; + break; + } + + if (adj != 0.0 && axis != -1) + { + adj *= pDev->valuator->axes[axis].scroll.increment; + val = valuator_mask_get_double(&mask, axis) + adj; + valuator_mask_set_double(&mask, axis, val); + type = MotionNotify; + buttons = 0; + } + } + + /* First fill out the original event set, with smooth-scrolling axes. */ + nev_tmp = fill_pointer_events(events, pDev, type, buttons, ms, flags, + &mask); + events += nev_tmp; + num_events += nev_tmp; + + valuator_mask_zero(&scroll); + + /* Now turn the smooth-scrolling axes back into emulated button presses + * for legacy clients, based on the integer delta between before and now */ + for (i = 0; i < valuator_mask_size(&mask); i++) { + if (!valuator_mask_isset(&mask, i)) + continue; + + valuator_mask_set_double(&scroll, i, pDev->last.valuators[i]); + + nev_tmp = emulate_scroll_button_events(events, pDev, i, &scroll, + pDev->last.scroll, ms, + GetMaximumEventsNum() - num_events); + events += nev_tmp; + num_events += nev_tmp; + } + return num_events; } diff --git a/include/exevents.h b/include/exevents.h index 731f31e..4fe6c61 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -37,6 +37,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * Interface available to drivers * ***************************************************************/ +/** + * Scroll flags for ::SetScrollValuator. + */ +enum ScrollFlags { + SCROLL_FLAG_NONE = 0, + /** + * Do not emulate legacy button events for valuator events on this axis. + */ + SCROLL_FLAG_DONT_EMULATE = (1 << 1), + /** + * This axis is the preferred axis for valuator emulation for this axis' + * scroll type. + */ + SCROLL_FLAG_PREFERRED = (1 << 2) +}; + extern _X_EXPORT int InitProximityClassDeviceStruct( DeviceIntPtr /* dev */); @@ -51,6 +67,13 @@ extern _X_EXPORT Bool InitValuatorAxisStruct( int /* max_res */, int /* mode */); +extern _X_EXPORT Bool SetScrollValuator( + DeviceIntPtr /* dev */, + int /* axnum */, + enum ScrollType /* type */, + double /* increment */, + int /* flags */); + /* Input device properties */ extern _X_EXPORT void XIDeleteAllDeviceProperties( DeviceIntPtr /* device */ diff --git a/include/inputstr.h b/include/inputstr.h index c25f5c6..9d4108e 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -75,6 +75,16 @@ extern _X_EXPORT int CountBits(const uint8_t *mask, int len); #define XI2MASKSIZE ((XI2LASTEVENT + 7)/8) /* no of bits for masks */ /** + * Scroll types for ::SetScrollValuator and the scroll type in the + * ::ScrollInfoPtr. + */ +enum ScrollType { + SCROLL_TYPE_NONE = 0, /**< Not a scrolling valuator */ + SCROLL_TYPE_VERTICAL = 8, + SCROLL_TYPE_HORIZONTAL = 9, +}; + +/** * This struct stores the core event mask for each client except the client * that created the window. * @@ -252,6 +262,12 @@ typedef struct _KeyClassRec { struct _XkbSrvInfo *xkbInfo; } KeyClassRec, *KeyClassPtr; +typedef struct _ScrollInfo { + enum ScrollType type; + double increment; + int flags; +} ScrollInfo, *ScrollInfoPtr; + typedef struct _AxisInfo { int resolution; int min_resolution; @@ -260,6 +276,7 @@ typedef struct _AxisInfo { int max_value; Atom label; CARD8 mode; + ScrollInfo scroll; } AxisInfo, *AxisInfoPtr; typedef struct _ValuatorAccelerationRec { @@ -283,6 +300,8 @@ typedef struct _ValuatorClassRec { unsigned short numAxes; double *axisVal; /* always absolute, but device-coord system */ ValuatorAccelerationRec accelScheme; + int h_scroll_axis; /* horiz smooth-scrolling axis */ + int v_scroll_axis; /* vert smooth-scrolling axis */ } ValuatorClassRec; typedef struct _ButtonClassRec { @@ -524,6 +543,7 @@ typedef struct _DeviceIntRec { double valuators[MAX_VALUATORS]; int numValuators; DeviceIntPtr slave; + ValuatorMask *scroll; } last; /* Input device property handling. */ diff --git a/test/input.c b/test/input.c index 2501d59..afc4d4d 100644 --- a/test/input.c +++ b/test/input.c @@ -52,6 +52,7 @@ static void dix_init_valuators(void) { DeviceIntRec dev; ValuatorClassPtr val; + AxisInfoPtr axis; const int num_axes = 2; int i; Atom atoms[MAX_VALUATORS] = { 0 }; @@ -78,6 +79,62 @@ static void dix_init_valuators(void) } assert(dev.last.numValuators == num_axes); + + /* invalid increment */ + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 0.0, SCROLL_FLAG_NONE) == FALSE); + /* invalid type */ + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL - 1, 1.0, SCROLL_FLAG_NONE) == FALSE); + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL + 1, 1.0, SCROLL_FLAG_NONE) == FALSE); + /* invalid axisnum */ + assert(SetScrollValuator(&dev, 2, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE) == FALSE); + + /* valid */ + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE); + axis = &dev.valuator->axes[0]; + assert(axis->scroll.increment == 3.0); + assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); + assert(axis->scroll.flags == 0); + + /* valid */ + assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_HORIZONTAL, 2.0, SCROLL_FLAG_NONE) == TRUE); + axis = &dev.valuator->axes[1]; + assert(axis->scroll.increment == 2.0); + assert(axis->scroll.type == SCROLL_TYPE_HORIZONTAL); + assert(axis->scroll.flags == 0); + + /* can add another non-preffered axis */ + assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE); + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL, 5.0, SCROLL_FLAG_NONE) == TRUE); + + /* can overwrite with Preferred */ + assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_VERTICAL, 5.5, SCROLL_FLAG_PREFERRED) == TRUE); + axis = &dev.valuator->axes[1]; + assert(axis->scroll.increment == 5.5); + assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); + assert(axis->scroll.flags == SCROLL_FLAG_PREFERRED); + + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL, 8.8, SCROLL_FLAG_PREFERRED) == TRUE); + axis = &dev.valuator->axes[0]; + assert(axis->scroll.increment == 8.8); + assert(axis->scroll.type == SCROLL_TYPE_HORIZONTAL); + assert(axis->scroll.flags == SCROLL_FLAG_PREFERRED); + + /* can overwrite as none */ + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_NONE, 5.0, + SCROLL_FLAG_NONE) == TRUE); + axis = &dev.valuator->axes[0]; + assert(axis->scroll.type == SCROLL_TYPE_NONE); + + /* can overwrite axis with new settings */ + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE); + axis = &dev.valuator->axes[0]; + assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); + assert(axis->scroll.increment == 5.0); + assert(axis->scroll.flags == SCROLL_FLAG_NONE); + assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE); + assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); + assert(axis->scroll.increment == 3.0); + assert(axis->scroll.flags == SCROLL_FLAG_NONE); } /* just check the known success cases, and that error cases set the client's diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c index 4234533..56d6bd2 100644 --- a/test/xi2/protocol-common.c +++ b/test/xi2/protocol-common.c @@ -29,6 +29,8 @@ #include "extinit.h" /* for XInputExtensionInit */ #include "exglobals.h" #include "xkbsrv.h" /* for XkbInitPrivates */ +#include "xserver-properties.h" +#include <X11/extensions/XI2.h> #include "protocol-common.h" @@ -63,6 +65,65 @@ static void fake_init_sprite(DeviceIntPtr dev) sprite->physLimits.y2 = screen.height; } +/* This is essentially CorePointerProc with ScrollAxes added */ +static int +TestPointerProc(DeviceIntPtr pDev, int what) +{ +#define NBUTTONS 10 +#define NAXES 4 + BYTE map[NBUTTONS + 1]; + int i = 0; + Atom btn_labels[NBUTTONS] = {0}; + Atom axes_labels[NAXES] = {0}; + + switch (what) { + case DEVICE_INIT: + for (i = 1; i <= NBUTTONS; i++) + map[i] = i; + + btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); + /* don't know about the rest */ + + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL); + + if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels, + (PtrCtrlProcPtr)NoopDDA, + GetMotionHistorySize(), NAXES, axes_labels)) + { + ErrorF("Could not initialize device '%s'. Out of memory.\n", + pDev->name); + return BadAlloc; + } + pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2; + pDev->last.valuators[0] = pDev->valuator->axisVal[0]; + pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; + pDev->last.valuators[1] = pDev->valuator->axisVal[1]; + + SetScrollValuator(pDev, 2, SCROLL_TYPE_VERTICAL, 2.4, SCROLL_FLAG_NONE); + SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, SCROLL_FLAG_PREFERRED); + break; + + case DEVICE_CLOSE: + break; + + default: + break; + } + + return Success; + +#undef NBUTTONS +#undef NAXES +} /** * Create and init 2 master devices (VCP + VCK) and two slave devices, one * default mouse, one default keyboard. @@ -84,7 +145,7 @@ struct devices init_devices(void) EnableDevice(devices.vck, FALSE); AllocDevicePair(&client, "", &devices.mouse, &devices.kbd, - CorePointerProc, CoreKeyboardProc, FALSE); + TestPointerProc, CoreKeyboardProc, FALSE); ActivateDevice(devices.mouse, FALSE); ActivateDevice(devices.kbd, FALSE); EnableDevice(devices.mouse, FALSE); diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c index 47eb5b1..63d725f 100644 --- a/test/xi2/protocol-xiquerydevice.c +++ b/test/xi2/protocol-xiquerydevice.c @@ -127,7 +127,7 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void dev = devices.mouse; assert(info->use == XISlavePointer); assert(info->attachment == devices.vcp->id); - assert(info->num_classes == 3); /* 2 axes + button */ + assert(info->num_classes == 7); /* 4 axes + button + 2 scroll*/ break; case 5: /* keyboard */ dev = devices.kbd; @@ -183,11 +183,48 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void } break; } - case 2: /* VCP and mouse have the same properties */ case 4: { assert(any->type == XIButtonClass || - any->type == XIValuatorClass); + any->type == XIValuatorClass || + any->type == XIScrollClass); + + if (any->type == XIScrollClass) + { + xXIScrollInfo *si = (xXIScrollInfo*)any; + + if (client->swapped) + { + swaps(&si->number); + swaps(&si->scroll_type); + swapl(&si->increment.integral); + swapl(&si->increment.frac); + } + assert(si->length == 6); + assert(si->number == 2 || si->number == 3); + if (si->number == 2) { + assert(si->scroll_type == XIScrollTypeVertical); + assert(!si->flags); + } + if (si->number == 3) { + assert(si->scroll_type == XIScrollTypeHorizontal); + assert(si->flags & XIScrollFlagPreferred); + assert(!(si->flags & ~XIScrollFlagPreferred)); + } + + assert(si->increment.integral == si->number); + /* FIXME: frac testing with float/FP issues? */ + assert(si->increment.frac > 0.3 * (1UL << 32)); + assert(si->increment.frac < 0.6 * (1UL << 32)); + } + + } + /* fall through */ + case 2: /* VCP and mouse have the same properties except for scroll */ + { + if (info->deviceid == 2 ) /* VCP */ + assert(any->type == XIButtonClass || + any->type == XIValuatorClass); if (any->type == XIButtonClass) { @@ -217,8 +254,10 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void } assert(vi->length == 11); - assert(vi->number == 0 || - vi->number == 1); + assert(vi->number >= 0 && vi->number < 4); + if (info->deviceid == 2) /* VCP */ + assert(vi->number < 2); + assert(vi->mode == XIModeRelative); /* device was set up as relative, so standard * values here. */ commit 057cc92ebfeebe81b7d01ff2c6aa2c066c8d1a64 Merge: afb1fe6... 52c9b59... Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Thu Sep 29 14:18:35 2011 +1000 Merge branch 'raw-events' into next Conflicts: configure.ac dix/events.c diff --cc configure.ac index b0d2643,da33c16..58ec3fb --- a/configure.ac +++ b/configure.ac @@@ -778,7 -785,7 +778,7 @@@ WINDOWSWMPROTO="windowswmproto APPLEWMPROTO="applewmproto >= 1.4" dnl Core modules for most extensions, et al. - SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 1.9.99.902] [kbproto >= 1.0.3] fontsproto" -SDK_REQUIRED_MODULES="[xproto >= 7.0.17] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto" ++SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto" # Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc AC_SUBST(SDK_REQUIRED_MODULES) diff --cc dix/events.c index fbe4fc9,6b74b1a..4e21c2d --- a/dix/events.c +++ b/dix/events.c @@@ -2275,28 -2297,42 +2322,41 @@@ DeliverRawEvent(RawDeviceEvent *ev, Dev if (grab) DeliverGrabbedEvent((InternalEvent*)ev, device, FALSE); - else { /* deliver to all root windows */ - xEvent *xi; - int i; - int filter; - i = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); - if (i != Success) - { - ErrorF("[Xi] %s: XI2 conversion failed in %s (%d)\n", - __func__, device->name, i); - return; - } + filter = GetEventFilter(device, xi); + + for (i = 0; i < screenInfo.numScreens; i++) + { + WindowPtr root; + InputClients *inputclients; - filter = GetEventFilter(device, xi); + root = screenInfo.screens[i]->root; + if (!GetClientsForDelivery(device, root, xi, filter, &inputclients)) + continue; - for (i = 0; i < screenInfo.numScreens; i++) - DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1, - filter, NullGrab); - free(xi); + for (; inputclients; inputclients = inputclients->next) + { + ClientPtr c; /* unused */ + Mask m; /* unused */ + InputClients ic = *inputclients; + + /* Because we run through the list manually, copy the actual + * list, shorten the copy to only have one client and then pass + * that down to DeliverEventToInputClients. This way we avoid + * double events on XI 2.1 clients that have a grab on the + * device. + */ + ic.next = NULL; + + if (!FilterRawEvents(rClient(&ic), grab)) + DeliverEventToInputClients(device, &ic, root, xi, 1, + filter, NULL, &c, &m); + } } + + free(xi); } - /* If the event goes to dontClient, don't send it and return 0. if send works, return 1 or if send didn't work, return 2. Only works for core events. commit 52c9b59a9fed6abfeca775a7a04133cee18eac0b Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon May 30 09:47:06 2011 +1000 dix: use 'rc' for return code in DeliverRawEvent Reported-by: Walter Harms <wharms at bfs.de> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Cyril Brulebois <kibi at debian.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/events.c b/dix/events.c index 2112a47..6b74b1a 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2284,14 +2284,14 @@ DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) { GrabPtr grab = device->deviceGrab.grab; xEvent *xi; - int i; + int i, rc; int filter; - i = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); - if (i != Success) + rc = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); + if (rc != Success) { ErrorF("[Xi] %s: XI2 conversion failed in %s (%d)\n", - __func__, device->name, i); + __func__, device->name, rc); return; } commit b6b1f1b514bf14ddf6b265b8d4551f892ded0dd2 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed May 11 13:56:08 2011 +1000 input: deliver raw events unconditionally for XI 2.1 clients. Deliver raw events regardless whether there is a grab on or not for clients supporting 2.1 or later. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/events.c b/dix/events.c index 8a4c6b9..2112a47 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2243,35 +2243,96 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent return nondeliveries; } +/** + * Filter out raw events for XI 2.0 and XI 2.1 clients. + * + * If there is a grab on the device, 2.0 clients only get raw events if they + * have the grab. 2.1+ clients get raw events in all cases. + * + * @return TRUE if the event should be discarded, FALSE otherwise. + */ +static BOOL +FilterRawEvents(const ClientPtr client, const GrabPtr grab) +{ + XIClientPtr client_xi_version; + int cmp; + + /* device not grabbed -> don't filter */ + if (!grab) + return FALSE; + + client_xi_version = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + + cmp = version_compare(client_xi_version->major_version, + client_xi_version->minor_version, 2, 0); + /* XI 2.0: if device is grabbed, skip + XI 2.1: if device is grabbed by us, skip, we've already delivered */ + return (cmp == 0) ? TRUE : SameClient(grab, client); +} + +/** + * Deliver a raw event to the grab owner (if any) and to all root windows. + * + * Raw event delivery differs between XI 2.0 and XI 2.1. + * XI 2.0: events delivered to the grabbing client (if any) OR to all root + * windows + * XI 2.1: events delivered to all root windows, regardless of grabbing + * state. + */ void DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) { GrabPtr grab = device->deviceGrab.grab; + xEvent *xi; + int i; + int filter; + + i = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); + if (i != Success) + { + ErrorF("[Xi] %s: XI2 conversion failed in %s (%d)\n", + __func__, device->name, i); + return; + } if (grab) DeliverGrabbedEvent((InternalEvent*)ev, device, FALSE); - else { /* deliver to all root windows */ - xEvent *xi; - int i; - int filter; - i = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); - if (i != Success) - { - ErrorF("[Xi] %s: XI2 conversion failed in %s (%d)\n", - __func__, device->name, i); - return; - } + filter = GetEventFilter(device, xi); - filter = GetEventFilter(device, xi); + for (i = 0; i < screenInfo.numScreens; i++) + { + WindowPtr root; + InputClients *inputclients; + + root = screenInfo.screens[i]->root; + if (!GetClientsForDelivery(device, root, xi, filter, &inputclients)) + continue; - for (i = 0; i < screenInfo.numScreens; i++) - DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1, - filter, NullGrab); - free(xi); + for (; inputclients; inputclients = inputclients->next) + { + ClientPtr c; /* unused */ + Mask m; /* unused */ + InputClients ic = *inputclients; + + /* Because we run through the list manually, copy the actual + * list, shorten the copy to only have one client and then pass + * that down to DeliverEventToInputClients. This way we avoid + * double events on XI 2.1 clients that have a grab on the + * device. + */ + ic.next = NULL; + + if (!FilterRawEvents(rClient(&ic), grab)) + DeliverEventToInputClients(device, &ic, root, xi, 1, + filter, NULL, &c, &m); + } } + + free(xi); } + /* If the event goes to dontClient, don't send it and return 0. if send works, return 1 or if send didn't work, return 2. Only works for core events. commit 16244fba001826190445302f56784f5de9c59c01 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Thu Jun 2 13:50:13 2011 +1000 Support (and require) XI 2.1 Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/configure.ac b/configure.ac index 22566c9..da33c16 100644 --- a/configure.ac +++ b/configure.ac @@ -785,7 +785,7 @@ WINDOWSWMPROTO="windowswmproto" APPLEWMPROTO="applewmproto >= 1.4" dnl Core modules for most extensions, et al. -SDK_REQUIRED_MODULES="[xproto >= 7.0.17] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 1.9.99.902] [kbproto >= 1.0.3] fontsproto" +SDK_REQUIRED_MODULES="[xproto >= 7.0.17] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto" # Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc AC_SUBST(SDK_REQUIRED_MODULES) diff --git a/include/protocol-versions.h b/include/protocol-versions.h index 7b7a9f5..832bcf7 100644 --- a/include/protocol-versions.h +++ b/include/protocol-versions.h @@ -127,7 +127,7 @@ /* X Input */ #define SERVER_XI_MAJOR_VERSION 2 -#define SERVER_XI_MINOR_VERSION 0 +#define SERVER_XI_MINOR_VERSION 1 /* XKB */ #define SERVER_XKB_MAJOR_VERSION 1 commit 54e05d80a122bac57920fce1704c0f57492b849c Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri May 27 14:21:39 2011 +1000 dix: rename ProcessRawEvents to dix/events.c:DeliverRawEvent No functional changes, prep work for future changes. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Cyril Brulebois <kibi at debian.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index 042ea69..3e3c67b 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -876,35 +876,6 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) return DEFAULT; } -static void -ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) -{ - GrabPtr grab = device->deviceGrab.grab; - - if (grab) - DeliverGrabbedEvent((InternalEvent*)ev, device, FALSE); - else { /* deliver to all root windows */ - xEvent *xi; - int i; - int filter; - - i = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); - if (i != Success) - { - ErrorF("[Xi] %s: XI2 conversion failed in %s (%d)\n", - __func__, device->name, i); - return; - } - - filter = GetEventFilter(device, xi); - - for (i = 0; i < screenInfo.numScreens; i++) - DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1, - filter, NullGrab); - free(xi); - } -} - /** * Main device event processing function. * Called from when processing the events from the event queue. @@ -932,7 +903,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) ev->any.type == ET_RawButtonRelease || ev->any.type == ET_RawMotion) { - ProcessRawEvent(&ev->raw_event, device); + DeliverRawEvent(&ev->raw_event, device); return; } diff --git a/dix/events.c b/dix/events.c index 9063c28..8a4c6b9 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2243,6 +2243,35 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent return nondeliveries; } +void +DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) +{ + GrabPtr grab = device->deviceGrab.grab; + + if (grab) + DeliverGrabbedEvent((InternalEvent*)ev, device, FALSE); + else { /* deliver to all root windows */ + xEvent *xi; + int i; + int filter; + + i = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); + if (i != Success) + { + ErrorF("[Xi] %s: XI2 conversion failed in %s (%d)\n", + __func__, device->name, i); + return; + } + + filter = GetEventFilter(device, xi); + + for (i = 0; i < screenInfo.numScreens; i++) + DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1, + filter, NullGrab); + free(xi); + } +} + /* If the event goes to dontClient, don't send it and return 0. if send works, return 1 or if send didn't work, return 2. Only works for core events. diff --git a/include/dix.h b/include/dix.h index 9a111e8..b1bf9ed 100644 --- a/include/dix.h +++ b/include/dix.h @@ -387,6 +387,11 @@ extern _X_EXPORT int DeliverEventsToWindow( Mask /* filter */, GrabPtr /* grab */); +extern _X_EXPORT void DeliverRawEvent( + RawDeviceEvent* /* ev */, + DeviceIntPtr /* dev */ +); + extern int DeliverDeviceEvents( WindowPtr /* pWin */, InternalEvent* /* event */, commit c48133f133c64d356a1208f185619bfdf7e9a5f2 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri May 27 14:19:45 2011 +1000 Xi: use temporary variable for filter. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index 3b0411d..042ea69 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -886,6 +886,7 @@ ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) else { /* deliver to all root windows */ xEvent *xi; int i; + int filter; i = EventToXI2((InternalEvent*)ev, (xEvent**)&xi); if (i != Success) @@ -895,9 +896,11 @@ ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) return; } + filter = GetEventFilter(device, xi); + for (i = 0; i < screenInfo.numScreens; i++) DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1, - GetEventFilter(device, xi), NULL); + filter, NullGrab); free(xi); } } commit ac0850e86f22191091a1eb07237cae9de49ee00d Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri May 27 12:14:32 2011 +1000 dix: split DeliverEventToWindowMask up a bit more. Move out the actual event delivery, it needs to be used from elsewhere. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/events.c b/dix/events.c index 66fbe9a..9063c28 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2076,35 +2076,27 @@ out: } /** - * Deliver events to clients registered on the window. - * - * @param client_return On successful delivery, set to the recipient. - * @param mask_return On successful delivery, set to the recipient's event - * mask for this event. + * Try delivery on each client in inputclients, provided the event mask + * accepts it and there is no interfering core grab.. */ static enum EventDeliveryState -DeliverEventToWindowMask(DeviceIntPtr dev, WindowPtr win, xEvent *events, - int count, Mask filter, GrabPtr grab, - ClientPtr *client_return, Mask *mask_return) +DeliverEventToInputClients(DeviceIntPtr dev, InputClients *inputclients, + WindowPtr win, xEvent *events, + int count, Mask filter, GrabPtr grab, + ClientPtr *client_return, Mask *mask_return) { int attempt; - enum EventDeliveryState rc = EVENT_SKIP; - InputClients *other; + enum EventDeliveryState rc = EVENT_NOT_DELIVERED; - if (!GetClientsForDelivery(dev, win, events, filter, &other)) - goto out; - - rc = EVENT_NOT_DELIVERED; - - for (; other; other = other->next) + for (; inputclients; inputclients = inputclients->next) { Mask mask; - ClientPtr client = rClient(other); + ClientPtr client = rClient(inputclients); if (IsInterferingGrab(client, dev, events)) continue; - mask = GetEventMask(dev, events, other); + mask = GetEventMask(dev, events, inputclients); if (XaceHook(XACE_RECEIVE_ACCESS, client, win, events, count)) @@ -2125,12 +2117,34 @@ DeliverEventToWindowMask(DeviceIntPtr dev, WindowPtr win, xEvent *events, } } -out: return rc; } /** + * Deliver events to clients registered on the window. + * + * @param client_return On successful delivery, set to the recipient. + * @param mask_return On successful delivery, set to the recipient's event + * mask for this event. + */ +static enum EventDeliveryState +DeliverEventToWindowMask(DeviceIntPtr dev, WindowPtr win, xEvent *events, + int count, Mask filter, GrabPtr grab, + ClientPtr *client_return, Mask *mask_return) +{ + InputClients *clients; + + if (!GetClientsForDelivery(dev, win, events, filter, &clients)) + return EVENT_SKIP; + + return DeliverEventToInputClients(dev, clients, win, events, count, filter, + grab, client_return, mask_return); + +} + + +/** * Deliver events to a window. At this point, we do not yet know if the event * actually needs to be delivered. May activate a grab if the event is a * button press. commit 5ea2fb389fce235366e9fce83d20abdc8874f4e2 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri May 27 11:43:50 2011 +1000 dix: rename DeliverEventsToClients to DeliverEventsToWindowMask To avoid confusion with a future patch and it better describes what this does anyway - delivering events to all clients that have the event mask on the window. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/events.c b/dix/events.c index 20754f0..66fbe9a 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2083,9 +2083,9 @@ out: * mask for this event. */ static enum EventDeliveryState -DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events, - int count, Mask filter, GrabPtr grab, - ClientPtr *client_return, Mask *mask_return) +DeliverEventToWindowMask(DeviceIntPtr dev, WindowPtr win, xEvent *events, + int count, Mask filter, GrabPtr grab, + ClientPtr *client_return, Mask *mask_return) { int attempt; enum EventDeliveryState rc = EVENT_SKIP; @@ -2192,8 +2192,8 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent { enum EventDeliveryState rc; - rc = DeliverEventToClients(pDev, pWin, pEvents, count, filter, grab, - &client, &deliveryMask); + rc = DeliverEventToWindowMask(pDev, pWin, pEvents, count, filter, + grab, &client, &deliveryMask); switch(rc) { commit 016413dae947fe4e8e918f728c87354fa4928275 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri May 27 11:40:56 2011 +1000 dix: split client list retrieval out of DeliverEventToClients No functional change, but "other" was renamed to "clients". Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/events.c b/dix/events.c index 3c7bd50..20754f0 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2037,31 +2037,29 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win, return EVENT_NOT_DELIVERED; } + /** - * Deliver events to clients registered on the window. + * Get the list of clients that should be tried for event delivery on the + * given window. * - * @param client_return On successful delivery, set to the recipient. - * @param mask_return On successful delivery, set to the recipient's event - * mask for this event. + * @return 1 if the client list should be traversed, zero if the event + * should be skipped. */ -static enum EventDeliveryState -DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events, - int count, Mask filter, GrabPtr grab, - ClientPtr *client_return, Mask *mask_return) +static Bool +GetClientsForDelivery(DeviceIntPtr dev, WindowPtr win, + xEvent *events, Mask filter, InputClients **clients) { - int attempt; - enum EventDeliveryState rc = EVENT_SKIP; - InputClients *other; + int rc = 0; if (core_get_type(events) != 0) - other = (InputClients *)wOtherClients(win); + *clients = (InputClients *)wOtherClients(win); else if (xi2_get_type(events) != 0) { OtherInputMasks *inputMasks = wOtherInputMasks(win); /* Has any client selected for the event? */ if (!GetWindowXI2Mask(dev, win, events)) goto out; - other = inputMasks->inputClients; + *clients = inputMasks->inputClients; } else { OtherInputMasks *inputMasks = wOtherInputMasks(win); /* Has any client selected for the event? */ @@ -2069,9 +2067,33 @@ DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events, !(inputMasks->inputEvents[dev->id] & filter)) goto out; - other = inputMasks->inputClients; + *clients = inputMasks->inputClients; } + rc = 1; +out: + return rc; +} + +/** + * Deliver events to clients registered on the window. + * + * @param client_return On successful delivery, set to the recipient. + * @param mask_return On successful delivery, set to the recipient's event + * mask for this event. + */ +static enum EventDeliveryState +DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events, + int count, Mask filter, GrabPtr grab, + ClientPtr *client_return, Mask *mask_return) +{ + int attempt; + enum EventDeliveryState rc = EVENT_SKIP; + InputClients *other; + + if (!GetClientsForDelivery(dev, win, events, filter, &other)) + goto out; + rc = EVENT_NOT_DELIVERED; for (; other; other = other->next) commit 537c5f631d1f8d526e63355b7d88cb1fb2793492 Author: Cyril Brulebois <kibi at debian.org> Date: Sun Jun 5 03:21:18 2011 +0200 xkb: Fix case checks for Latin 4. That one was missing _XkbKSLower: XK_kra: U+0138 LATIN SMALL LETTER KRA Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Cyril Brulebois <kibi at debian.org> diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c index e042671..d8202b4 100644 --- a/xkb/xkbfmisc.c +++ b/xkb/xkbfmisc.c @@ -92,7 +92,8 @@ unsigned set,rtrn; ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) { rtrn|= _XkbKSUpper; } - if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))|| + if ((ks==XK_kra)|| + ((ks>=XK_rcedilla)&&(ks<=XK_tslash))|| (ks==XK_eng)|| ((ks>=XK_amacron)&&(ks<=XK_umacron))) { rtrn|= _XkbKSLower; commit 0b56a7f0ad01d3a86cdd7a14d5e567a00a3553f6 Author: Cyril Brulebois <kibi at debian.org> Date: Sun Jun 5 03:12:44 2011 +0200 xkb: Fix case checks for Latin 2. Those ones were getting _XkbKSLower for no reasons: XK_ogonek: U+02DB OGONEK XK_doubleacute: U+02DD DOUBLE ACUTE ACCENT Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Cyril Brulebois <kibi at debian.org> diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c index c36cc7b..e042671 100644 --- a/xkb/xkbfmisc.c +++ b/xkb/xkbfmisc.c @@ -71,7 +71,7 @@ unsigned set,rtrn; ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) { rtrn|= _XkbKSUpper; } - if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))|| + if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_ogonek)&&(ks!=XK_caron)&&(ks!=XK_doubleacute))|| ((ks>=XK_racute)&&(ks<=XK_tcedilla))) { rtrn|= _XkbKSLower; } commit 512a9750c197437889ff7f26a8d2bd242e030745 Author: Cyril Brulebois <kibi at debian.org> Date: Sun Jun 5 03:03:47 2011 +0200 xkb: Fix case checks for Latin 1. That one was missing _XkbKSLower: XK_ssharp: U+00DF LATIN SMALL LETTER SHARP S That one was getting _XkbKSLower for no reasons: XK_division: U+00F7 DIVISION SIGN For reference, XK_multiply was already excluded from the _XkbKSUpper check, it's no big surprise XK_division has to be excluded from the _XkbKSLower check. Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Cyril Brulebois <kibi at debian.org> diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c index 1ac9d82..c36cc7b 100644 --- a/xkb/xkbfmisc.c +++ b/xkb/xkbfmisc.c @@ -62,7 +62,7 @@ unsigned set,rtrn; rtrn|= _XkbKSUpper; } if (((ks>=XK_a)&&(ks<=XK_z))|| - ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) { + ((ks>=XK_ssharp)&&(ks<=XK_ydiaeresis)&&(ks!=XK_division))) { rtrn|= _XkbKSLower; } break; commit 635a1f50bc65512ec491fe71b9dfa8cf9118e2c2 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Sep 23 12:04:39 2011 +1000 input: allow for max < min for relative axes on InitValuatorAxisStruct Relative axes are initialized with 0, -1 but so far this never had any effect as all users of this function (for relative axes) just set it to the defaults anyway. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index 8a3c256..a6455e6 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1073,7 +1073,7 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int { AxisInfoPtr ax; - if (!dev || !dev->valuator || minval > maxval) + if (!dev || !dev->valuator || (minval > maxval && mode == Absolute)) return FALSE; if (axnum >= dev->valuator->numAxes) return FALSE; commit 8d1a414cca51e7f8a93470c5aa2e998f5ca1bc9a Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Sep 23 12:03:48 2011 +1000 input: switch InitValuatorAxisStruct to return Bool Return errors instead of silently ignoring them. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index 4dd9b85..8a3c256 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1067,16 +1067,16 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev) * * @see InitValuatorClassDeviceStruct */ -void +Bool InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval, int resolution, int min_res, int max_res, int mode) { AxisInfoPtr ax; if (!dev || !dev->valuator || minval > maxval) - return; + return FALSE; if (axnum >= dev->valuator->numAxes) - return; + return FALSE; ax = dev->valuator->axes + axnum; @@ -1090,6 +1090,8 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int if (mode & OutOfProximity) dev->proximity->in_proximity = FALSE; + + return TRUE; } static void diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 9fbcba9..49b2fb2 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -1363,15 +1363,15 @@ xf86XInputSetScreen(InputInfoPtr pInfo, } -void +Bool xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval, int resolution, int min_res, int max_res, int mode) { if (!dev || !dev->valuator) - return; + return FALSE; - InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res, - max_res, mode); + return InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res, + max_res, mode); } /* diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h index a4d9e58..189f7ab 100644 --- a/hw/xfree86/common/xf86Xinput.h +++ b/hw/xfree86/common/xf86Xinput.h @@ -145,7 +145,7 @@ extern _X_EXPORT InputInfoPtr xf86FirstLocalDevice(void); extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min); extern _X_EXPORT void xf86XInputSetScreen(InputInfoPtr pInfo, int screen_number, int x, int y); extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, XF86OptionPtr options); -extern _X_EXPORT void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, +extern _X_EXPORT Bool xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval, int resolution, int min_res, int max_res, int mode); extern _X_EXPORT void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum); diff --git a/include/exevents.h b/include/exevents.h index 2b22698..731f31e 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -40,7 +40,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern _X_EXPORT int InitProximityClassDeviceStruct( DeviceIntPtr /* dev */); -extern _X_EXPORT void InitValuatorAxisStruct( +extern _X_EXPORT Bool InitValuatorAxisStruct( DeviceIntPtr /* dev */, int /* axnum */, Atom /* label */, commit 5ac1f885f5c106b970835de36e13a9a7ea413df4 Author: Daniel Stone <daniel at fooishbar.org> Date: Tue Feb 15 19:44:53 2011 +0000 Input: Add POINTER_EMULATED flag to GetPointerEvents POINTER_EMULATED merely sets XIPointerEmulated in the generated DeviceEvent. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index 4eb1b3a..45243df 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -58,6 +58,7 @@ #endif #include <X11/extensions/XI.h> +#include <X11/extensions/XI2.h> #include <X11/extensions/XIproto.h> #include <pixman.h> #include "exglobals.h" @@ -1159,6 +1160,11 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, event->root_x_frac = screenx - trunc(screenx); event->root_y_frac = screeny - trunc(screeny); + if (flags & POINTER_EMULATED) { + raw->flags = XIPointerEmulated; + event->flags = XIPointerEmulated; + } + set_valuators(pDev, event, &mask); return num_events; diff --git a/include/input.h b/include/input.h index 577f5d9..6ba1ab2 100644 --- a/include/input.h +++ b/include/input.h @@ -68,6 +68,7 @@ SOFTWARE. #define POINTER_ACCELERATE (1 << 3) #define POINTER_SCREEN (1 << 4) /* Data in screen coordinates */ #define POINTER_NORAW (1 << 5) /* Don't generate RawEvents */ +#define POINTER_EMULATED (1 << 6) /* Event was emulated from another event */ /*int constants for pointer acceleration schemes*/ #define PtrAccelNoOp 0 diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index d7a9ee4..bfa23b5 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -41,6 +41,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, int nvals = 0; int bits_set; int len; + uint32_t flagmask = 0; if (swap) { @@ -62,7 +63,17 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, assert(out->detail == in->detail.button); assert(out->deviceid == in->deviceid); assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask)))); - assert(out->flags == 0); /* FIXME: we don't set the flags yet */ + + switch (in->type) { + case ET_RawMotion: + case ET_RawButtonPress: + case ET_RawButtonRelease: + flagmask = XIPointerEmulated; + break; + default: + flagmask = 0; + } + assert((out->flags & ~flagmask) == 0); ptr = (unsigned char*)&out[1]; bits_set = 0; @@ -304,6 +315,11 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, assert(out->sourceid == in->sourceid); switch (in->type) { + case ET_ButtonPress: + case ET_Motion: + case ET_ButtonRelease: + flagmask = XIPointerEmulated; + break; case ET_KeyPress: flagmask = XIKeyRepeat; break; commit 78d8d6dd7f31cb903d5c8baf64181795736f33ed Author: Daniel Stone <daniel at fooishbar.org> Date: Tue Feb 15 14:23:25 2011 +0000 Input: Add vertical and horizontal scroll axes To be used for smooth scrolling with future driver APIs, replacing Rel Vert Wheel and Rel Horiz Wheel axes, which have not been used in any open driver to date. Combined with double-granularity ValuatorMasks, these axes allow for fine-grained scroll data to be sent to clients. Future commits allow drivers to post these scroll axes to QueuePointerEvents/GetPointerEvents, which take care of emulating legacy scroll button events. Signed-off-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c index fa0d811..14f1491 100644 --- a/Xi/xiproperty.c +++ b/Xi/xiproperty.c @@ -52,11 +52,14 @@ static struct dev_properties } dev_properties[] = { {0, XI_PROP_ENABLED}, {0, XI_PROP_XTEST_DEVICE}, + {0, XATOM_FLOAT}, + {0, ACCEL_PROP_PROFILE_NUMBER}, {0, ACCEL_PROP_CONSTANT_DECELERATION}, {0, ACCEL_PROP_ADAPTIVE_DECELERATION}, {0, ACCEL_PROP_VELOCITY_SCALING}, + {0, AXIS_LABEL_PROP}, {0, AXIS_LABEL_PROP_REL_X}, {0, AXIS_LABEL_PROP_REL_Y}, @@ -68,6 +71,8 @@ static struct dev_properties {0, AXIS_LABEL_PROP_REL_DIAL}, {0, AXIS_LABEL_PROP_REL_WHEEL}, {0, AXIS_LABEL_PROP_REL_MISC}, + {0, AXIS_LABEL_PROP_REL_VSCROLL}, + {0, AXIS_LABEL_PROP_REL_HSCROLL}, {0, AXIS_LABEL_PROP_ABS_X}, {0, AXIS_LABEL_PROP_ABS_Y}, {0, AXIS_LABEL_PROP_ABS_Z}, diff --git a/include/xserver-properties.h b/include/xserver-properties.h index bf50042..18b54ba 100644 --- a/include/xserver-properties.h +++ b/include/xserver-properties.h @@ -77,6 +77,8 @@ #define AXIS_LABEL_PROP_REL_DIAL "Rel Dial" #define AXIS_LABEL_PROP_REL_WHEEL "Rel Vert Wheel" #define AXIS_LABEL_PROP_REL_MISC "Rel Misc" +#define AXIS_LABEL_PROP_REL_VSCROLL "Rel Vert Scroll" +#define AXIS_LABEL_PROP_REL_HSCROLL "Rel Horiz Scroll" /* * Absolute axes commit d8e42decbad4abe13265f4c546a0c561905d018f Author: Daniel Stone <daniel at fooishbar.org> Date: Tue Feb 15 18:54:14 2011 +0000 Input: Split GetPointerEvents body into a helper function For smooth-scrolling support, we want GetPointerEvents to generate multiple events, so split the body of the function out into a helper function in order to call it multiple times. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index 7cb2968..4eb1b3a 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1043,40 +1043,25 @@ QueuePointerEvents(DeviceIntPtr device, int type, } /** - * Generate a series of InternalEvents representing pointer motion, or - * button presses. + * Helper function for GetPointerEvents, which only generates motion and + * raw motion events for the slave device: does not update the master device. * - * The DDX is responsible for allocating the events in the first - * place via InitEventList() and GetMaximumEventsNum(), and for freeing it. - * - * In the generated events rootX/Y will be in absolute screen coords and - * the valuator information in the absolute or relative device coords. - * - * last.valuators[x] of the device is always in absolute device coords. - * last.valuators[x] of the master device is in absolute screen coords. - * - * master->last.valuators[x] for x > 2 is undefined. + * Should not be called by anyone other than GetPointerEvents. * * @return the number of events written into events. */ -int -GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons, - int flags, const ValuatorMask *mask_in) { +static int +fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, + int buttons, CARD32 ms, int flags, + const ValuatorMask *mask_in) +{ int num_events = 1, i; - CARD32 ms; DeviceEvent *event; - RawDeviceEvent *raw; + RawDeviceEvent *raw; double screenx = 0.0, screeny = 0.0; ScreenPtr scr = miPointerGetScreen(pDev); ValuatorMask mask; - /* refuse events from disabled devices */ - if (!pDev->enabled) - return 0; - - if (!scr) - return 0; - switch (type) { case MotionNotify: @@ -1092,10 +1077,6 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons return 0; } - ms = GetTimeInMillis(); /* before pointer update to help precision */ - - events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events); - valuator_mask_copy(&mask, mask_in); if ((flags & POINTER_NORAW) == 0) @@ -1184,6 +1165,45 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons } /** + * Generate a complete series of InternalEvents (filled into the EventList) + * representing pointer motion, or button presses. If the device is a slave + * device, also potentially generate a DeviceClassesChangedEvent to update + * the master device. + * + * events is not NULL-terminated; the return value is the number of events. + * The DDX is responsible for allocating the event structure in the first + * place via InitEventList() and GetMaximumEventsNum(), and for freeing it. + * + * In the generated events rootX/Y will be in absolute screen coords and + * the valuator information in the absolute or relative device coords. + * + * last.valuators[x] of the device is always in absolute device coords. + * last.valuators[x] of the master device is in absolute screen coords. + * + * master->last.valuators[x] for x > 2 is undefined. + */ +int +GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, + int buttons, int flags, const ValuatorMask *mask_in) +{ + CARD32 ms = GetTimeInMillis(); + int num_events = 0; + + /* refuse events from disabled devices */ + if (!pDev->enabled) + return 0; + + if (!miPointerGetScreen(pDev)) + return 0; + + events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, + &num_events); + num_events += fill_pointer_events(events, pDev, type, buttons, ms, flags, + mask_in); + return num_events; +} + +/** * Generate internal events representing this proximity event and enqueue * them on the event queue. * commit bc8aad2376207b5ca9c74effae67fb8183222d2e Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Mar 3 19:48:15 2011 +0000 Input: Set last valuators in GetPointerEvents only Previously, various pieces of code, including acceleration, used to drop the values into DeviceIntRec::last.valuators. Remove all this and only do it in GetPointerEvents after all transformation, acceleration and clipping, so we're guaranteed to always have the correct values. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index db47315..7cb2968 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -701,7 +701,6 @@ moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask) continue; val = valuator_mask_get_double(mask, i); clipAxis(dev, i, &val); - dev->last.valuators[i] = val; valuator_mask_set_double(mask, i, val); } } @@ -731,7 +730,6 @@ moveRelative(DeviceIntPtr dev, ValuatorMask *mask) if (valuator_get_mode(dev, i) == Absolute && ((i != 0 && i != 1) || clip_xy)) clipAxis(dev, i, &val); - dev->last.valuators[i] = val; valuator_mask_set_double(mask, i, val); } } @@ -821,10 +819,6 @@ positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, master->last.valuators[1] = *screeny; } - /* dropy x/y (device coordinates) back into valuators for next event */ - dev->last.valuators[0] = x; - dev->last.valuators[1] = y; - if (valuator_mask_isset(mask, 0)) valuator_mask_set_double(mask, 0, x); if (valuator_mask_isset(mask, 1)) @@ -1068,7 +1062,7 @@ QueuePointerEvents(DeviceIntPtr device, int type, int GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons, int flags, const ValuatorMask *mask_in) { - int num_events = 1; + int num_events = 1, i; CARD32 ms; DeviceEvent *event; RawDeviceEvent *raw; @@ -1153,6 +1147,12 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons clipValuators(pDev, &mask); + for (i = 0; i < valuator_mask_size(&mask); i++) + { + if (valuator_mask_isset(&mask, i)) + pDev->last.valuators[i] = valuator_mask_get_double(&mask, i); + } + event = &events->device_event; init_device_event(event, pDev, ms); commit 94c19a0a72403fc522e3d05eeb57f35e111a2562 Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Mar 3 15:46:45 2011 +0000 Input: Convert DeviceIntRec::last to use doubles Change the last real user of a split integer/fractional co-ordinate system, DeviceIntRec's last->{valuators,remainder} to just have one set of doubles. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c index 8fcb4d1..11ab241 100644 --- a/Xi/xiwarppointer.c +++ b/Xi/xiwarppointer.c @@ -190,8 +190,6 @@ ProcXIWarpPointer(ClientPtr client) /* if we don't update the device, we get a jump next time it moves */ pDev->last.valuators[0] = x; pDev->last.valuators[1] = y; - pDev->last.remainder[0] = 0; - pDev->last.remainder[1] = 0; miPointerUpdateSprite(pDev); /* FIXME: XWarpPointer is supposed to generate an event. It doesn't do it diff --git a/dix/getevents.c b/dix/getevents.c index fac845e..db47315 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -291,15 +291,12 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev) { ScreenPtr scr = miPointerGetScreen(pDev); int i; - double val, ret; DeviceIntPtr lastSlave; /* master->last.valuators[0]/[1] is in screen coords and the actual * position of the pointer */ pDev->last.valuators[0] = master->last.valuators[0]; pDev->last.valuators[1] = master->last.valuators[1]; - pDev->last.remainder[0] = master->last.remainder[0]; - pDev->last.remainder[1] = master->last.remainder[1]; if (!pDev->valuator) return; @@ -307,19 +304,17 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev) /* scale back to device coordinates */ if(pDev->valuator->numAxes > 0) { - val = pDev->last.valuators[0] + pDev->last.remainder[0]; - ret = rescaleValuatorAxis(val, NULL, pDev->valuator->axes + 0, - scr->width); - pDev->last.valuators[0] = trunc(ret); - pDev->last.remainder[0] = ret - trunc(ret); + pDev->last.valuators[0] = rescaleValuatorAxis(pDev->last.valuators[0], + NULL, + pDev->valuator->axes + 0, + scr->width); } if(pDev->valuator->numAxes > 1) { - val = pDev->last.valuators[1] + pDev->last.remainder[1]; - ret = rescaleValuatorAxis(val, NULL, pDev->valuator->axes + 1, - scr->height); - pDev->last.valuators[1] = trunc(ret); - pDev->last.remainder[1] = ret - trunc(ret); + pDev->last.valuators[1] = rescaleValuatorAxis(pDev->last.valuators[1], + NULL, + pDev->valuator->axes + 1, + scr->height); } /* calculate the other axis as well based on info from the old @@ -331,15 +326,13 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev) if (i >= lastSlave->valuator->numAxes) { pDev->last.valuators[i] = 0; - pDev->last.remainder[i] = 0; } else { - val = pDev->last.valuators[i] + pDev->last.remainder[i]; - ret = rescaleValuatorAxis(val, lastSlave->valuator->axes + i, + double val = pDev->last.valuators[i]; + val = rescaleValuatorAxis(val, lastSlave->valuator->axes + i, pDev->valuator->axes + i, 0); - pDev->last.valuators[i] = trunc(ret); - pDev->last.remainder[i] = ret - trunc(ret); + pDev->last.valuators[i] = val; } } } @@ -523,7 +516,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start, */ static void updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, ValuatorMask *mask, - int *valuators) + double *valuators) { char *buff = (char *) pDev->valuator->motion; ValuatorClassPtr v; @@ -545,6 +538,7 @@ updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, ValuatorMask *mask, for (i = 0; i < v->numAxes; i++) { + int val; /* XI1 doesn't support mixed mode devices */ if (valuator_get_mode(pDev, i) != valuator_get_mode(pDev, 0)) break; @@ -557,7 +551,8 @@ updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, ValuatorMask *mask, buff += sizeof(INT32); memcpy(buff, &v->axes[i].max_value, sizeof(INT32)); buff += sizeof(INT32); - memcpy(buff, &valuators[i], sizeof(INT32)); + val = valuators[i]; + memcpy(buff, &val, sizeof(INT32)); buff += sizeof(INT32); } } else @@ -573,12 +568,14 @@ updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, ValuatorMask *mask, for (i = 0; i < MAX_VALUATORS; i++) { + int val; if (valuator_mask_size(mask) <= i || !valuator_mask_isset(mask, i)) { buff += sizeof(INT32); continue; } - memcpy(buff, &valuators[i], sizeof(INT32)); + val = valuators[i]; + memcpy(buff, &val, sizeof(INT32)); buff += sizeof(INT32); } } @@ -704,8 +701,7 @@ moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask) continue; val = valuator_mask_get_double(mask, i); clipAxis(dev, i, &val); - dev->last.valuators[i] = trunc(val); - dev->last.remainder[i] = val - trunc(val); + dev->last.valuators[i] = val; valuator_mask_set_double(mask, i, val); } } @@ -725,7 +721,7 @@ moveRelative(DeviceIntPtr dev, ValuatorMask *mask) /* calc other axes, clip, drop back into valuators */ for (i = 0; i < valuator_mask_size(mask); i++) { - double val = dev->last.valuators[i] + dev->last.remainder[i]; + double val = dev->last.valuators[i]; if (!valuator_mask_isset(mask, i)) continue; @@ -735,8 +731,7 @@ moveRelative(DeviceIntPtr dev, ValuatorMask *mask) if (valuator_get_mode(dev, i) == Absolute && ((i != 0 && i != 1) || clip_xy)) clipAxis(dev, i, &val); - dev->last.valuators[i] = trunc(val); - dev->last.remainder[i] = val - trunc(val); + dev->last.valuators[i] = val; valuator_mask_set_double(mask, i, val); } } @@ -786,11 +781,11 @@ positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, if (valuator_mask_isset(mask, 0)) x = valuator_mask_get_double(mask, 0); else - x = dev->last.valuators[0] + dev->last.remainder[0]; + x = dev->last.valuators[0]; if (valuator_mask_isset(mask, 1)) y = valuator_mask_get_double(mask, 1); else - y = dev->last.valuators[1] + dev->last.remainder[1]; + y = dev->last.valuators[1]; /* scale x&y to screen */ *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL, @@ -822,17 +817,13 @@ positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, /* Update the MD's co-ordinates, which are always in screen space. */ if (!IsMaster(dev) || !IsFloating(dev)) { DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); - master->last.valuators[0] = trunc(*screenx); - master->last.remainder[0] = *screenx - trunc(*screenx); - master->last.valuators[1] = trunc(*screeny); - master->last.remainder[1] = *screeny - trunc(*screeny); + master->last.valuators[0] = *screenx; + master->last.valuators[1] = *screeny; } /* dropy x/y (device coordinates) back into valuators for next event */ - dev->last.valuators[0] = trunc(x); - dev->last.valuators[1] = trunc(y); - dev->last.remainder[0] = x - trunc(x); - dev->last.remainder[1] = y - trunc(y); + dev->last.valuators[0] = x; + dev->last.valuators[1] = y; if (valuator_mask_isset(mask, 0)) valuator_mask_set_double(mask, 0, x); @@ -1018,12 +1009,12 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask) if (valuator_mask_isset(mask, 0)) ox = x = valuator_mask_get_double(mask, 0); else - ox = x = dev->last.valuators[0] + dev->last.remainder[0]; + ox = x = dev->last.valuators[0]; if (valuator_mask_isset(mask, 1)) oy = y = valuator_mask_get_double(mask, 1); else - oy = y = dev->last.valuators[1] + dev->last.remainder[1]; + oy = y = dev->last.valuators[1]; transform(&dev->transform, &x, &y); diff --git a/include/inputstr.h b/include/inputstr.h index 480e956..c25f5c6 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -521,8 +521,7 @@ typedef struct _DeviceIntRec { * remainder supports acceleration */ struct { - int valuators[MAX_VALUATORS]; - float remainder[MAX_VALUATORS]; + double valuators[MAX_VALUATORS]; int numValuators; DeviceIntPtr slave; } last; commit 2d9beeb2174661d0a0732403ad4e49e9ff56718d Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Mar 3 15:36:55 2011 +0000 Input: Make DeviceEvent use doubles internally Change the DeviceEvent InternalEvent to use doubles for its valuators, instead of data and data_frac. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/Xi/exevents.c b/Xi/exevents.c index 38089a2..4dd9b85 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -774,12 +774,9 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) for (i = 0; i <= last_valuator && i < v->numAxes; i++) { + /* XXX: Relative/Absolute mode */ if (BitIsOn(&event->valuators.mask, i)) - { - /* XXX: Relative/Absolute mode */ v->axisVal[i] = event->valuators.data[i]; - v->axisVal[i] += (event->valuators.data_frac[i] * 1.0f / (1 << 16) / (1 << 16)); - } } if (event->type == ET_KeyPress) { diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 54e9020..9cc177e 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -633,8 +633,9 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); - axisval->integral = ev->valuators.data[i]; - axisval->frac = ev->valuators.data_frac[i]; + axisval->integral = trunc(ev->valuators.data[i]); + axisval->frac = (ev->valuators.data[i] - axisval->integral) * + (1UL << 32); axisval++; } } diff --git a/dix/getevents.c b/dix/getevents.c index d04f412..fac845e 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -196,9 +196,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask) SetBit(event->valuators.mask, i); if (valuator_get_mode(dev, i) == Absolute) SetBit(event->valuators.mode, i); - event->valuators.data[i] = valuator_mask_get(mask, i); - event->valuators.data_frac[i] = - dev->last.remainder[i] * (1 << 16) * (1 << 16); + event->valuators.data[i] = valuator_mask_get_double(mask, i); } else if (valuator_get_mode(dev, i) == Absolute) event->valuators.data[i] = dev->valuator->axisVal[i]; diff --git a/include/eventstr.h b/include/eventstr.h index 0645585..2de077f 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -95,8 +95,7 @@ struct _DeviceEvent struct { uint8_t mask[(MAX_VALUATORS + 7)/8]; /**< Valuator mask */ uint8_t mode[(MAX_VALUATORS + 7)/8]; /**< Valuator mode (Abs or Rel)*/ - int32_t data[MAX_VALUATORS]; /**< Valuator data */ - int32_t data_frac[MAX_VALUATORS]; /**< Fractional part for data */ + double data[MAX_VALUATORS]; /**< Valuator data */ } valuators; struct { uint32_t base; /**< XKB base modifiers */ diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index 6df9af0..d7a9ee4 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -374,8 +374,8 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, { FP3232 vi, vo; - vi.integral = in->valuators.data[i]; - vi.frac = in->valuators.data_frac[i]; + vi.integral = trunc(in->valuators.data[i]); + vi.frac = (in->valuators.data[i] - vi.integral) * (1UL << 32); vo = *values; @@ -617,8 +617,7 @@ static void test_convert_XIDeviceEvent(void) { XISetMask(in.valuators.mask, i); - in.valuators.data[i] = i; - in.valuators.data_frac[i] = i + 20; + in.valuators.data[i] = i + (i * 0.0020); test_XIDeviceEvent(&in); XIClearMask(in.valuators.mask, i); } commit 626f487b97c99b48bf1d8c8ef4367a686639c3e6 Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Mar 3 15:06:45 2011 +0000 Input: Make RawDeviceEvent use doubles internally Change RawDeviceEvent to use doubles for valuators internally, rather than data(_raw) and data(_raw)_frac. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/eventconvert.c b/dix/eventconvert.c index fa8ba9e..54e9020 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -649,7 +649,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) int vallen, nvals; int i, len = sizeof(xXIRawEvent); char *ptr; - FP3232 *axisval; + FP3232 *axisval, *axisval_raw; nvals = count_bits(ev->valuators.mask, sizeof(ev->valuators.mask)); len += nvals * sizeof(FP3232) * 2; /* 8 byte per valuator, once @@ -671,16 +671,19 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) ptr = (char*)&raw[1]; axisval = (FP3232*)(ptr + raw->valuators_len * 4); + axisval_raw = axisval + nvals; for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++) { if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); - axisval->integral = ev->valuators.data[i]; - axisval->frac = ev->valuators.data_frac[i]; - (axisval + nvals)->integral = ev->valuators.data_raw[i]; - (axisval + nvals)->frac = ev->valuators.data_raw_frac[i]; + axisval->integral = trunc(ev->valuators.data[i]); + axisval->frac = ev->valuators.data[i] - axisval->integral; + axisval_raw->integral = trunc(ev->valuators.data_raw[i]); + axisval_raw->frac = ev->valuators.data_raw[i] - + axisval_raw->integral; axisval++; + axisval_raw++; } } diff --git a/dix/getevents.c b/dix/getevents.c index ec79fcf..d04f412 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -167,20 +167,16 @@ init_raw(DeviceIntPtr dev, RawDeviceEvent *event, Time ms, int type, int detail) } static void -set_raw_valuators(RawDeviceEvent *event, ValuatorMask *mask, int32_t* data, - int32_t* data_frac) +set_raw_valuators(RawDeviceEvent *event, ValuatorMask *mask, double* data) { int i; - double val; for (i = 0; i < valuator_mask_size(mask); i++) { if (valuator_mask_isset(mask, i)) { SetBit(event->valuators.mask, i); - val = valuator_mask_get_double(mask, i); - data[i] = trunc(val); - data_frac[i] = (val - data[i]) * (1UL << 32); + data[i] = valuator_mask_get_double(mask, i); } } } @@ -950,13 +946,11 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type, valuator_mask_copy(&mask, mask_in); init_raw(pDev, raw, ms, type, key_code); - set_raw_valuators(raw, &mask, raw->valuators.data_raw, - raw->valuators.data_raw_frac); + set_raw_valuators(raw, &mask, raw->valuators.data_raw); clipValuators(pDev, &mask); - set_raw_valuators(raw, &mask, raw->valuators.data, - raw->valuators.data_frac); + set_raw_valuators(raw, &mask, raw->valuators.data); event = &events->device_event; init_device_event(event, pDev, ms); @@ -1128,8 +1122,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons num_events++; init_raw(pDev, raw, ms, type, buttons); - set_raw_valuators(raw, &mask, raw->valuators.data_raw, - raw->valuators.data_raw_frac); + set_raw_valuators(raw, &mask, raw->valuators.data_raw); } if (flags & POINTER_ABSOLUTE) @@ -1163,8 +1156,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons } if ((flags & POINTER_NORAW) == 0) - set_raw_valuators(raw, &mask, raw->valuators.data, - raw->valuators.data_frac); + set_raw_valuators(raw, &mask, raw->valuators.data); positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, scr, &mask, &screenx, &screeny); diff --git a/include/eventstr.h b/include/eventstr.h index ecaeddc..0645585 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -199,10 +199,8 @@ struct _RawDeviceEvent } detail; struct { uint8_t mask[(MAX_VALUATORS + 7)/8]; /**< Valuator mask */ - int32_t data[MAX_VALUATORS]; /**< Valuator data */ - int32_t data_frac[MAX_VALUATORS]; /**< Fractional part for data */ - int32_t data_raw[MAX_VALUATORS]; /**< Valuator data as posted */ - int32_t data_raw_frac[MAX_VALUATORS];/**< Fractional part for data_raw */ + double data[MAX_VALUATORS]; /**< Valuator data */ + double data_raw[MAX_VALUATORS]; /**< Valuator data as posted */ } valuators; uint32_t flags; /**< Flags to be copied into the generated event */ }; diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index 80c47b0..6df9af0 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -93,8 +93,8 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4); value += nvals; - vi.integral = in->valuators.data[i]; - vi.frac = in->valuators.data_frac[i]; + vi.integral = trunc(in->valuators.data[i]); + vi.frac = in->valuators.data[i] - vi.integral; vo.integral = value->integral; vo.frac = value->frac; @@ -109,8 +109,8 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, raw_value = value + bits_set; - vi.integral = in->valuators.data_raw[i]; - vi.frac = in->valuators.data_raw_frac[i]; + vi.integral = trunc(in->valuators.data_raw[i]); + vi.frac = in->valuators.data_raw[i] - vi.integral; vo.integral = raw_value->integral; vo.frac = raw_value->frac; @@ -248,10 +248,8 @@ static void test_convert_XIRawEvent(void) { XISetMask(in.valuators.mask, i); - in.valuators.data[i] = i; - in.valuators.data_raw[i] = i + 10; - in.valuators.data_frac[i] = i + 20; - in.valuators.data_raw_frac[i] = i + 30; + in.valuators.data[i] = i + (i * 0.0010); + in.valuators.data_raw[i] = (i + 10) + (i * 0.0030); test_XIRawEvent(&in); XIClearMask(in.valuators.mask, i); } commit 3b7fb0f68dc0d40c968c2cfc9bb74b1d0fb48bc8 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 17:18:48 2011 +0000 Input: Modify mask in-place in positionSprite Instead of taking pointers to x and y values to modify in positionSprite, just modify the mask (as well as dev->last) in place. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index a9409b4..ec79fcf 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -774,26 +774,34 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms) * * @param dev The device to be moved. * @param mode Movement mode (Absolute or Relative) - * @param x Pointer to current x-axis value, may be modified. - * @param y Pointer to current y-axis value, may be modified. * @param scr Screen the device's sprite is currently on. + * @param mask Mask of axis values for this event * @param screenx Screen x coordinate the sprite is on after the update. * @param screeny Screen y coordinate the sprite is on after the update. */ static void -positionSprite(DeviceIntPtr dev, int mode, double *x, double *y, ScreenPtr scr, +positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, double *screenx, double *screeny) { int isx, isy; /* screen {x, y}, in int */ + double x, y; if (!dev->valuator || dev->valuator->numAxes < 2) return; + if (valuator_mask_isset(mask, 0)) + x = valuator_mask_get_double(mask, 0); + else + x = dev->last.valuators[0] + dev->last.remainder[0]; + if (valuator_mask_isset(mask, 1)) + y = valuator_mask_get_double(mask, 1); + else + y = dev->last.valuators[1] + dev->last.remainder[1]; + /* scale x&y to screen */ - *screenx = rescaleValuatorAxis(*x, dev->valuator->axes + 0, NULL, + *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL, scr->width); - - *screeny = rescaleValuatorAxis(*y, dev->valuator->axes + 1, NULL, + *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL, scr->height); /* miPointerSetPosition takes care of crossing screens for us, as well as @@ -807,14 +815,14 @@ positionSprite(DeviceIntPtr dev, int mode, double *x, double *y, ScreenPtr scr, if (isx != trunc(*screenx)) { *screenx -= trunc(*screenx) - isx; - *x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0, - scr->width); + x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0, + scr->width); } if (isy != trunc(*screeny)) { *screeny -= trunc(*screeny) - isy; - *y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1, - scr->height); + y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1, + scr->height); } /* Update the MD's co-ordinates, which are always in screen space. */ @@ -827,10 +835,15 @@ positionSprite(DeviceIntPtr dev, int mode, double *x, double *y, ScreenPtr scr, } /* dropy x/y (device coordinates) back into valuators for next event */ - dev->last.valuators[0] = trunc(*x); - dev->last.valuators[1] = trunc(*y); - dev->last.remainder[0] = *x - trunc(*x); - dev->last.remainder[1] = *y - trunc(*y); + dev->last.valuators[0] = trunc(x); + dev->last.valuators[1] = trunc(y); + dev->last.remainder[0] = x - trunc(x); + dev->last.remainder[1] = y - trunc(y); + + if (valuator_mask_isset(mask, 0)) + valuator_mask_set_double(mask, 0, x); + if (valuator_mask_isset(mask, 1)) + valuator_mask_set_double(mask, 1, y); } /** @@ -1076,8 +1089,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons CARD32 ms; DeviceEvent *event; RawDeviceEvent *raw; - double x = 0.0, y = 0.0; /* device coords */ - double screenx = 0.0, screeny = 0.0; /* screen coords */ + double screenx = 0.0, screeny = 0.0; ScreenPtr scr = miPointerGetScreen(pDev); ValuatorMask mask; @@ -1154,29 +1166,10 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons set_raw_valuators(raw, &mask, raw->valuators.data, raw->valuators.data_frac); - if (valuator_mask_isset(&mask, 0)) - x = valuator_mask_get_double(&mask, 0); - else - x = pDev->last.valuators[0] + pDev->last.remainder[0]; - if (valuator_mask_isset(&mask, 1)) - y = valuator_mask_get_double(&mask, 1); - else - y = pDev->last.valuators[1] + pDev->last.remainder[1]; - - positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, - &x, &y, scr, &screenx, &screeny); - if (valuator_mask_isset(&mask, 0)) - valuator_mask_set_double(&mask, 0, x); - if (valuator_mask_isset(&mask, 1)) - valuator_mask_set_double(&mask, 1, y); + positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, scr, + &mask, &screenx, &screeny); updateHistory(pDev, &mask, ms); - /* Update the valuators with the true value sent to the client*/ - if (valuator_mask_isset(&mask, 0)) - valuator_mask_set(&mask, 0, x); - if (valuator_mask_isset(&mask, 1)) - valuator_mask_set(&mask, 1, y); - clipValuators(pDev, &mask); event = &events->device_event; commit 629a575261c08ca67324fea4c975636a1a95dc75 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 17:04:57 2011 +0000 Input: Convert positionSprite and GetPointerEvents to double Use doubles internally in both of these functions, eliminating most of the remaining int co-ordinate usage. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index 94da143..a9409b4 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -776,91 +776,61 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms) * @param mode Movement mode (Absolute or Relative) * @param x Pointer to current x-axis value, may be modified. * @param y Pointer to current y-axis value, may be modified. - * @param x_frac Fractional part of current x-axis value, may be modified. - * @param y_frac Fractional part of current y-axis value, may be modified. * @param scr Screen the device's sprite is currently on. * @param screenx Screen x coordinate the sprite is on after the update. * @param screeny Screen y coordinate the sprite is on after the update. - * @param screenx_frac Fractional part of screen x coordinate, as above. - * @param screeny_frac Fractional part of screen y coordinate, as above. */ static void -positionSprite(DeviceIntPtr dev, int mode, - int *x, int *y, float x_frac, float y_frac, - ScreenPtr scr, int *screenx, int *screeny, float *screenx_frac, float *screeny_frac) +positionSprite(DeviceIntPtr dev, int mode, double *x, double *y, ScreenPtr scr, + double *screenx, double *screeny) { - int old_screenx, old_screeny; - double val, ret; + int isx, isy; /* screen {x, y}, in int */ if (!dev->valuator || dev->valuator->numAxes < 2) return; /* scale x&y to screen */ - val = *x + x_frac; - ret = rescaleValuatorAxis(val, dev->valuator->axes + 0, NULL, scr->width); - *screenx = trunc(ret); - *screenx_frac = ret - trunc(ret); - - val = *y + y_frac; - ret = rescaleValuatorAxis(val, dev->valuator->axes + 1, NULL, scr->height); - *screeny = trunc(ret); - *screeny_frac = ret - trunc(ret); - - /* Hit the left screen edge? */ - if (*screenx <= 0 && *screenx_frac < 0.0f) + *screenx = rescaleValuatorAxis(*x, dev->valuator->axes + 0, NULL, + scr->width); + + *screeny = rescaleValuatorAxis(*y, dev->valuator->axes + 1, NULL, + scr->height); + + /* miPointerSetPosition takes care of crossing screens for us, as well as + * clipping to the current screen. In the event we actually change screen, + * we just drop the float component on the floor, then convert from + * screenx back into device co-ordinates. */ + isx = trunc(*screenx); + isy = trunc(*screeny); + miPointerSetPosition(dev, mode, &isx, &isy); + scr = miPointerGetScreen(dev); + if (isx != trunc(*screenx)) { - *screenx_frac = 0.0f; - x_frac = 0.0f; + *screenx -= trunc(*screenx) - isx; + *x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0, + scr->width); } - if (*screeny <= 0 && *screeny_frac < 0.0f) + if (isy != trunc(*screeny)) { - *screeny_frac = 0.0f; - y_frac = 0.0f; + *screeny -= trunc(*screeny) - isy; + *y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1, + scr->height); } - - old_screenx = *screenx; - old_screeny = *screeny; - /* This takes care of crossing screens for us, as well as clipping - * to the current screen. */ - miPointerSetPosition(dev, mode, screenx, screeny); - - if(!IsMaster(dev) && !IsFloating(dev)) { + /* Update the MD's co-ordinates, which are always in screen space. */ + if (!IsMaster(dev) || !IsFloating(dev)) { DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); - master->last.valuators[0] = *screenx; - master->last.valuators[1] = *screeny; - master->last.remainder[0] = *screenx_frac; - master->last.remainder[1] = *screeny_frac; - } - - if (dev->valuator) - { - /* Crossed screen? Scale back to device coordiantes */ - if(*screenx != old_screenx) - { - scr = miPointerGetScreen(dev); - val = *screenx + *screenx_frac; - ret = rescaleValuatorAxis(val, NULL, dev->valuator->axes + 0, - scr->width); - *x = trunc(ret); - x_frac = ret - trunc(ret); - } - if(*screeny != old_screeny) - { - scr = miPointerGetScreen(dev); - val = *screeny + *screeny_frac; - ret = rescaleValuatorAxis(val, NULL, dev->valuator->axes + 1, - scr->height); - *y = trunc(ret); - y_frac = ret - trunc(ret); - } + master->last.valuators[0] = trunc(*screenx); + master->last.remainder[0] = *screenx - trunc(*screenx); + master->last.valuators[1] = trunc(*screeny); + master->last.remainder[1] = *screeny - trunc(*screeny); } /* dropy x/y (device coordinates) back into valuators for next event */ - dev->last.valuators[0] = *x; - dev->last.valuators[1] = *y; - dev->last.remainder[0] = x_frac; - dev->last.remainder[1] = y_frac; + dev->last.valuators[0] = trunc(*x); + dev->last.valuators[1] = trunc(*y); + dev->last.remainder[0] = *x - trunc(*x); + dev->last.remainder[1] = *y - trunc(*y); } /** @@ -1106,9 +1076,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons CARD32 ms; DeviceEvent *event; RawDeviceEvent *raw; - int x = 0, y = 0, /* device coords */ - cx, cy; /* only screen coordinates */ - float x_frac = 0.0, y_frac = 0.0, cx_frac, cy_frac; + double x = 0.0, y = 0.0; /* device coords */ + double screenx = 0.0, screeny = 0.0; /* screen coords */ ScreenPtr scr = miPointerGetScreen(pDev); ValuatorMask mask; @@ -1155,7 +1124,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons { if (flags & POINTER_SCREEN) /* valuators are in screen coords */ { - int scaled; + double scaled; if (valuator_mask_isset(&mask, 0)) { @@ -1185,27 +1154,21 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons set_raw_valuators(raw, &mask, raw->valuators.data, raw->valuators.data_frac); - if (valuator_mask_isset(&mask, 0)) { - double tmp = valuator_mask_get_double(&mask, 0); - x = trunc(tmp); - x_frac = tmp - x; - } - else { - x = pDev->last.valuators[0]; - x_frac = pDev->last.remainder[0]; - } - if (valuator_mask_isset(&mask, 1)) { - double tmp = valuator_mask_get_double(&mask, 1); - y = trunc(tmp); - y_frac = tmp - y; - } - else { - y = pDev->last.valuators[1]; - y_frac = pDev->last.remainder[1]; - } + if (valuator_mask_isset(&mask, 0)) + x = valuator_mask_get_double(&mask, 0); + else + x = pDev->last.valuators[0] + pDev->last.remainder[0]; + if (valuator_mask_isset(&mask, 1)) + y = valuator_mask_get_double(&mask, 1); + else + y = pDev->last.valuators[1] + pDev->last.remainder[1]; positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, - &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac); + &x, &y, scr, &screenx, &screeny); + if (valuator_mask_isset(&mask, 0)) + valuator_mask_set_double(&mask, 0, x); + if (valuator_mask_isset(&mask, 1)) + valuator_mask_set_double(&mask, 1, y); updateHistory(pDev, &mask, ms); /* Update the valuators with the true value sent to the client*/ @@ -1235,10 +1198,11 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons event->detail.button = buttons; } - event->root_x = cx; /* root_x/y always in screen coords */ - event->root_y = cy; - event->root_x_frac = cx_frac; - event->root_y_frac = cy_frac; + /* root_x and root_y must be in screen co-ordinates */ + event->root_x = trunc(screenx); + event->root_y = trunc(screeny); + event->root_x_frac = screenx - trunc(screenx); + event->root_y_frac = screeny - trunc(screeny); set_valuators(pDev, event, &mask); commit 51437995a5041a8c53c33b508b1607c78a5fa463 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 16:50:55 2011 +0000 Input: Don't call positionSprite for non-pointer devices If the device doesn't have any valuators, or if it has less than two of them, don't bother calling positionSprite. Users with one-dimensional pointing devices may be upset. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index 2c51388..94da143 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -792,28 +792,19 @@ positionSprite(DeviceIntPtr dev, int mode, int old_screenx, old_screeny; double val, ret; - /* scale x&y to screen */ - if (dev->valuator && dev->valuator->numAxes > 0) { - val = *x + x_frac; - ret = rescaleValuatorAxis(val, dev->valuator->axes + 0, NULL, - scr->width); - *screenx = trunc(ret); - *screenx_frac = ret - trunc(ret); - } else { - *screenx = dev->last.valuators[0]; - *screenx_frac = dev->last.remainder[0]; - } + if (!dev->valuator || dev->valuator->numAxes < 2) + return; - if (dev->valuator && dev->valuator->numAxes > 1) { - val = *y + y_frac; - ret = rescaleValuatorAxis(val, dev->valuator->axes + 1, NULL, - scr->height); - *screeny = trunc(ret); - *screeny_frac = ret - trunc(ret); - } else { - *screeny = dev->last.valuators[1]; - *screeny_frac = dev->last.remainder[1]; - } + /* scale x&y to screen */ + val = *x + x_frac; + ret = rescaleValuatorAxis(val, dev->valuator->axes + 0, NULL, scr->width); + *screenx = trunc(ret); + *screenx_frac = ret - trunc(ret); + + val = *y + y_frac; + ret = rescaleValuatorAxis(val, dev->valuator->axes + 1, NULL, scr->height); + *screeny = trunc(ret); + *screeny_frac = ret - trunc(ret); /* Hit the left screen edge? */ if (*screenx <= 0 && *screenx_frac < 0.0f) commit 4c364a312daf2b743a0a60b9907f671804a1b1b6 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 16:49:53 2011 +0000 Input: Convert rescaleValuatorAxis to double Instead of passing fractional pointers around everywhere, just pass doubles instead. Much easier. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index dcd8263..2c51388 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -259,39 +259,29 @@ CreateClassesChangedEvent(InternalEvent* event, /** * Rescale the coord between the two axis ranges. */ -static int -rescaleValuatorAxis(int coord, float remainder, float *remainder_return, AxisInfoPtr from, AxisInfoPtr to, - int defmax) +static double +rescaleValuatorAxis(double coord, AxisInfoPtr from, AxisInfoPtr to, + double defmax) { - int fmin = 0, tmin = 0, fmax = defmax, tmax = defmax, coord_return; - float value; + double fmin = 0.0, fmax = defmax; + double tmin = 0.0, tmax = defmax; - if(from && from->min_value < from->max_value) { + if (from && from->min_value < from->max_value) { fmin = from->min_value; fmax = from->max_value; } - if(to && to->min_value < to->max_value) { + if (to && to->min_value < to->max_value) { tmin = to->min_value; tmax = to->max_value; } - if(fmin == tmin && fmax == tmax) { - if (remainder_return) - *remainder_return = remainder; + if (fmin == tmin && fmax == tmax) return coord; - } - if(fmax == fmin) { /* avoid division by 0 */ - if (remainder_return) - *remainder_return = 0.0; - return 0; - } + if (fmax == fmin) /* avoid division by 0 */ + return 0.0; - value = (coord + remainder - fmin) * (tmax - tmin) / (fmax - fmin) + tmin; - coord_return = lroundf(value); - if (remainder_return) - *remainder_return = value - coord_return; - return coord_return; + return (coord - fmin) * (tmax - tmin) / (fmax - fmin) + tmin; } /** @@ -307,6 +297,7 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev) { ScreenPtr scr = miPointerGetScreen(pDev); int i; + double val, ret; DeviceIntPtr lastSlave; /* master->last.valuators[0]/[1] is in screen coords and the actual @@ -321,11 +312,21 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev) /* scale back to device coordinates */ if(pDev->valuator->numAxes > 0) - pDev->last.valuators[0] = rescaleValuatorAxis(pDev->last.valuators[0], pDev->last.remainder[0], - &pDev->last.remainder[0], NULL, pDev->valuator->axes + 0, scr->width); + { + val = pDev->last.valuators[0] + pDev->last.remainder[0]; + ret = rescaleValuatorAxis(val, NULL, pDev->valuator->axes + 0, + scr->width); + pDev->last.valuators[0] = trunc(ret); + pDev->last.remainder[0] = ret - trunc(ret); + } if(pDev->valuator->numAxes > 1) - pDev->last.valuators[1] = rescaleValuatorAxis(pDev->last.valuators[1], pDev->last.remainder[1], - &pDev->last.remainder[1], NULL, pDev->valuator->axes + 1, scr->height); + { + val = pDev->last.valuators[1] + pDev->last.remainder[1]; + ret = rescaleValuatorAxis(val, NULL, pDev->valuator->axes + 1, + scr->height); + pDev->last.valuators[1] = trunc(ret); + pDev->last.remainder[1] = ret - trunc(ret); + } /* calculate the other axis as well based on info from the old * slave-device. If the old slave had less axes than this one, @@ -340,12 +341,11 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev) } else { - pDev->last.valuators[i] = - rescaleValuatorAxis(pDev->last.valuators[i], - pDev->last.remainder[i], - &pDev->last.remainder[i], - lastSlave->valuator->axes + i, - pDev->valuator->axes + i, 0); + val = pDev->last.valuators[i] + pDev->last.remainder[i]; + ret = rescaleValuatorAxis(val, lastSlave->valuator->axes + i, + pDev->valuator->axes + i, 0); + pDev->last.valuators[i] = trunc(ret); + pDev->last.remainder[i] = ret - trunc(ret); } } } @@ -456,7 +456,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start, /* scale to screen coords */ to = &core_axis; to->max_value = pScreen->width; - coord = rescaleValuatorAxis(coord, 0.0, NULL, &from, to, pScreen->width); + coord = rescaleValuatorAxis(coord, &from, to, pScreen->width); memcpy(corebuf, &coord, sizeof(INT16)); corebuf++; @@ -467,7 +467,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start, memcpy(&coord, icbuf++, sizeof(INT32)); to->max_value = pScreen->height; - coord = rescaleValuatorAxis(coord, 0.0, NULL, &from, to, pScreen->height); + coord = rescaleValuatorAxis(coord, &from, to, pScreen->height); memcpy(corebuf, &coord, sizeof(INT16)); } else if (IsMaster(pDev)) @@ -495,7 +495,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start, from.max_value = pScreen->height; /* scale from stored range into current range */ - coord = rescaleValuatorAxis(coord, 0.0, NULL, &from, to, 0); + coord = rescaleValuatorAxis(coord, &from, to, 0); memcpy(ocbuf, &coord, sizeof(INT32)); ocbuf++; } @@ -790,19 +790,26 @@ positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, int *screenx, int *screeny, float *screenx_frac, float *screeny_frac) { int old_screenx, old_screeny; + double val, ret; /* scale x&y to screen */ if (dev->valuator && dev->valuator->numAxes > 0) { - *screenx = rescaleValuatorAxis(*x, x_frac, screenx_frac, - dev->valuator->axes + 0, NULL, scr->width); + val = *x + x_frac; + ret = rescaleValuatorAxis(val, dev->valuator->axes + 0, NULL, + scr->width); + *screenx = trunc(ret); + *screenx_frac = ret - trunc(ret); } else { *screenx = dev->last.valuators[0]; *screenx_frac = dev->last.remainder[0]; } if (dev->valuator && dev->valuator->numAxes > 1) { - *screeny = rescaleValuatorAxis(*y, y_frac, screeny_frac, - dev->valuator->axes + 1, NULL, scr->height); + val = *y + y_frac; + ret = rescaleValuatorAxis(val, dev->valuator->axes + 1, NULL, + scr->height); + *screeny = trunc(ret); + *screeny_frac = ret - trunc(ret); } else { *screeny = dev->last.valuators[1]; *screeny_frac = dev->last.remainder[1]; @@ -841,14 +848,20 @@ positionSprite(DeviceIntPtr dev, int mode, if(*screenx != old_screenx) { scr = miPointerGetScreen(dev); - *x = rescaleValuatorAxis(*screenx, *screenx_frac, &x_frac, NULL, - dev->valuator->axes + 0, scr->width); + val = *screenx + *screenx_frac; + ret = rescaleValuatorAxis(val, NULL, dev->valuator->axes + 0, + scr->width); + *x = trunc(ret); + x_frac = ret - trunc(ret); } if(*screeny != old_screeny) { scr = miPointerGetScreen(dev); - *y = rescaleValuatorAxis(*screeny, *screeny_frac, &y_frac, NULL, - dev->valuator->axes + 1, scr->height); + val = *screeny + *screeny_frac; + ret = rescaleValuatorAxis(val, NULL, dev->valuator->axes + 1, + scr->height); + *y = trunc(ret); + y_frac = ret - trunc(ret); } } @@ -1155,19 +1168,17 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons if (valuator_mask_isset(&mask, 0)) { - scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 0), - 0.0, &x_frac, NULL, - pDev->valuator->axes + 0, + scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 0), + NULL, pDev->valuator->axes + 0, scr->width); - valuator_mask_set(&mask, 0, scaled); + valuator_mask_set_double(&mask, 0, scaled); } if (valuator_mask_isset(&mask, 1)) { - scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 1), - 0.0, &y_frac, NULL, - pDev->valuator->axes + 1, + scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 1), + NULL, pDev->valuator->axes + 1, scr->height); - valuator_mask_set(&mask, 1, scaled); + valuator_mask_set_double(&mask, 1, scaled); } } commit 5680fa41ea3373651f7017898a307e97cf29b0d3 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 16:30:30 2011 +0000 Input: Remove x and y from moveAbsolute/moveRelative Both these functions modify the mask and pDev->last.{valuators,remainder} in-place now, so there's no need to pass in pointers to local x and y values. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index 483d65f..dcd8263 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -695,12 +695,10 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve * Move the device's pointer to the position given in the valuators. * * @param dev The device whose pointer is to be moved. - * @param x Returns the x position of the pointer after the move. - * @param y Returns the y position of the pointer after the move. * @param mask Valuator data for this event. */ static void -moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) +moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask) { int i; @@ -716,21 +714,16 @@ moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) dev->last.remainder[i] = val - trunc(val); valuator_mask_set_double(mask, i, val); } - - *x_out = dev->last.valuators[0]; - *y_out = dev->last.valuators[1]; } /** * Move the device's pointer by the values given in @valuators. * * @param dev The device whose pointer is to be moved. - * @param x Returns the x position of the pointer after the move. - * @param y Returns the y position of the pointer after the move. * @param mask Valuator data for this event. */ static void -moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) +moveRelative(DeviceIntPtr dev, ValuatorMask *mask) { int i; Bool clip_xy = IsMaster(dev) || !IsFloating(dev); @@ -752,9 +745,6 @@ moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) dev->last.remainder[i] = val - trunc(val); valuator_mask_set_double(mask, i, val); } - - *x_out = dev->last.valuators[0]; - *y_out = dev->last.valuators[1]; } /** @@ -1182,26 +1172,34 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons } transformAbsolute(pDev, &mask); - moveAbsolute(pDev, &x, &y, &mask); + moveAbsolute(pDev, &mask); } else { if (flags & POINTER_ACCELERATE) accelPointer(pDev, &mask, ms); - moveRelative(pDev, &x, &y, &mask); + moveRelative(pDev, &mask); } if ((flags & POINTER_NORAW) == 0) set_raw_valuators(raw, &mask, raw->valuators.data, raw->valuators.data_frac); - if (valuator_mask_isset(&mask, 0)) - { - x_frac = valuator_mask_get_double(&mask, 0); - x_frac -= trunc(x_frac); + if (valuator_mask_isset(&mask, 0)) { + double tmp = valuator_mask_get_double(&mask, 0); + x = trunc(tmp); + x_frac = tmp - x; } - if (valuator_mask_isset(&mask, 1)) - { - y_frac = valuator_mask_get_double(&mask, 1); - y_frac -= trunc(y_frac); + else { + x = pDev->last.valuators[0]; + x_frac = pDev->last.remainder[0]; + } + if (valuator_mask_isset(&mask, 1)) { + double tmp = valuator_mask_get_double(&mask, 1); + y = trunc(tmp); + y_frac = tmp - y; + } + else { + y = pDev->last.valuators[1]; + y_frac = pDev->last.remainder[1]; } positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, commit 0882b788da97c75e464eb352dac1d83c938a148e Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 16:27:31 2011 +0000 Input: Convert acceleration code to using ValuatorMask Instead of passing a set of int* to the acceleration code, pass it a mask instead, which avoids an unfortunate loss of precision. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Simon Thum <simon.thum at gmx.de> diff --git a/dix/getevents.c b/dix/getevents.c index b8f4a8c..483d65f 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1184,13 +1184,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons transformAbsolute(pDev, &mask); moveAbsolute(pDev, &x, &y, &mask); } else { - if (flags & POINTER_ACCELERATE) { + if (flags & POINTER_ACCELERATE) accelPointer(pDev, &mask, ms); - /* The pointer acceleration code modifies the fractional part - * in-place, so we need to extract this information first */ - x_frac = pDev->last.remainder[0]; - y_frac = pDev->last.remainder[1]; - } moveRelative(pDev, &x, &y, &mask); } @@ -1198,6 +1193,17 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons set_raw_valuators(raw, &mask, raw->valuators.data, raw->valuators.data_frac); + if (valuator_mask_isset(&mask, 0)) + { + x_frac = valuator_mask_get_double(&mask, 0); + x_frac -= trunc(x_frac); + } + if (valuator_mask_isset(&mask, 1)) + { + y_frac = valuator_mask_get_double(&mask, 1); + y_frac -= trunc(y_frac); + } + positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac); updateHistory(pDev, &mask, ms); diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 6271a6d..53a0d03 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -1115,11 +1115,10 @@ acceleratePointerPredictable( CARD32 evtime) { double dx = 0, dy = 0; - int tmpi; DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev); Bool soften = TRUE; - if (!velocitydata) + if (valuator_mask_num_valuators(val) == 0 || !velocitydata) return; if (velocitydata->statistics.profile_number == AccelProfileNone && @@ -1128,11 +1127,11 @@ acceleratePointerPredictable( } if (valuator_mask_isset(val, 0)) { - dx = valuator_mask_get(val, 0); + dx = valuator_mask_get_double(val, 0); } if (valuator_mask_isset(val, 1)) { - dy = valuator_mask_get(val, 1); + dy = valuator_mask_get_double(val, 1); } if (dx != 0.0 || dy != 0.0) { @@ -1155,24 +1154,12 @@ acceleratePointerPredictable( ApplySoftening(velocitydata, &dx, &dy); ApplyConstantDeceleration(velocitydata, &dx, &dy); - /* Calculate the new delta (with accel) and drop it back - * into the valuator masks */ - if (dx != 0.0) { - double tmp; - tmp = mult * dx + dev->last.remainder[0]; - tmpi = trunc(tmp); - valuator_mask_set(val, 0, tmpi); - dev->last.remainder[0] = tmp - (double)tmpi; - } - if (dy != 0.0) { - double tmp; - tmp = mult * dy + dev->last.remainder[1]; - tmpi = trunc(tmp); - valuator_mask_set(val, 1, tmpi); - dev->last.remainder[1] = tmp - (double)tmpi; - } - DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n", - *px, *py, dev->last.remainder[0], dev->last.remainder[1], dx, dy); + if (dx != 0.0) + valuator_mask_set_double(val, 0, mult * dx); + if (dy != 0.0) + valuator_mask_set_double(val, 1, mult * dy); + DebugAccelF("pos (%i | %i) delta x:%.3f y:%.3f\n", mult * dx, + mult * dy); } } } @@ -1195,7 +1182,6 @@ acceleratePointerLightweight( { double mult = 0.0, tmpf; double dx = 0.0, dy = 0.0; - int tmpi; if (valuator_mask_isset(val, 0)) { dx = valuator_mask_get(val, 0); @@ -1205,53 +1191,35 @@ acceleratePointerLightweight( dy = valuator_mask_get(val, 1); } - if (dx == 0.0 && dy == 0.0) + if (valuator_mask_num_valuators(val) == 0) return; if (dev->ptrfeed && dev->ptrfeed->ctrl.num) { /* modeled from xf86Events.c */ if (dev->ptrfeed->ctrl.threshold) { - if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) { - tmpf = ((double)dx * - (double)(dev->ptrfeed->ctrl.num)) / - (double)(dev->ptrfeed->ctrl.den) + - dev->last.remainder[0]; + if ((fabs(dx) + fabs(dy)) >= dev->ptrfeed->ctrl.threshold) { if (dx != 0.0) { - tmpi = (int) tmpf; - valuator_mask_set(val, 0, tmpi); - dev->last.remainder[0] = tmpf - (double)tmpi; + tmpf = (dx * (double)(dev->ptrfeed->ctrl.num)) / + (double)(dev->ptrfeed->ctrl.den); + valuator_mask_set_double(val, 0, tmpf); } - tmpf = ((double)dy * - (double)(dev->ptrfeed->ctrl.num)) / - (double)(dev->ptrfeed->ctrl.den) + - dev->last.remainder[1]; if (dy != 0.0) { - tmpi = (int) tmpf; - valuator_mask_set(val, 1, tmpi); - dev->last.remainder[1] = tmpf - (double)tmpi; + tmpf = (dy * (double)(dev->ptrfeed->ctrl.num)) / + (double)(dev->ptrfeed->ctrl.den); + valuator_mask_set_double(val, 1, tmpf); } } } else { - mult = pow((double)dx * (double)dx + (double)dy * (double)dy, + mult = pow(dx * dx + dy * dy, ((double)(dev->ptrfeed->ctrl.num) / (double)(dev->ptrfeed->ctrl.den) - 1.0) / 2.0) / 2.0; - if (dx != 0.0) { - tmpf = mult * (double)dx + - dev->last.remainder[0]; - tmpi = (int) tmpf; - valuator_mask_set(val, 0, tmpi); - dev->last.remainder[0] = tmpf - (double)tmpi; - } - if (dy != 0.0) { - tmpf = mult * (double)dy + - dev->last.remainder[1]; - tmpi = (int)tmpf; - valuator_mask_set(val, 1, tmpi); - dev->last.remainder[1] = tmpf - (double)tmpi; - } + if (dx != 0.0) + valuator_mask_set_double(val, 0, mult * dx); + if (dy != 0.0) + valuator_mask_set_double(val, 1, mult * dy); } } } commit 2b8f1d07bd42c9d3db3dbacfe6a1335e47236a6c Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 15:37:53 2011 +0000 Input: Widen pointer acceleration types to double This widens almost all of the float-using code in ptrveloc.[ch] to doubles, other than values coming from properties which are specified to be floats by the property API. Bumps input API to v14 as this changes the AccelScheme signature, as used by xf86-input-synaptics. Signed-off-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index c506791..6271a6d 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -63,9 +63,9 @@ /* fwds */ int SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num); -static float -SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, float velocity, - float threshold, float acc); +static double +SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, double velocity, + double threshold, double acc); static PointerAccelerationProfileFunc GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num); static BOOL @@ -478,14 +478,10 @@ DoGetDirection(int dx, int dy){ else dir = UNDEFINED; /* shouldn't happen */ } else { /* compute angle and set appropriate flags */ - float r; + double r; int i1, i2; -#ifdef _ISOC99_SOURCE - r = atan2f(dy, dx); -#else r = atan2(dy, dx); -#endif /* find direction. * * Add 360?? to avoid r become negative since C has no well-defined @@ -524,8 +520,7 @@ static int GetDirection(int dx, int dy){ static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE]; int dir; - if (abs(dx) <= DIRECTION_CACHE_RANGE && - abs(dy) <= DIRECTION_CACHE_RANGE) { + if (abs(dx) <= DIRECTION_CACHE_RANGE && abs(dy) <= DIRECTION_CACHE_RANGE) { /* cacheable */ dir = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy]; if(dir == 0) { @@ -553,7 +548,7 @@ GetDirection(int dx, int dy){ * 0/0 and set it as the current one. */ static inline void -FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t) +FeedTrackers(DeviceVelocityPtr vel, double dx, double dy, int cur_t) { int n; for(n = 0; n < vel->num_tracker; n++){ @@ -561,8 +556,8 @@ FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t) vel->tracker[n].dy += dy; } n = (vel->cur_tracker + 1) % vel->num_tracker; - vel->tracker[n].dx = 0; - vel->tracker[n].dy = 0; + vel->tracker[n].dx = 0.0; + vel->tracker[n].dy = 0.0; vel->tracker[n].time = cur_t; vel->tracker[n].dir = GetDirection(dx, dy); DebugAccelF("(dix prtacc) motion [dx: %i dy: %i dir:%i diff: %i]\n", @@ -576,9 +571,9 @@ FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t) * velocity scaling. * This assumes linear motion. */ -static float +static double CalcTracker(const MotionTracker *tracker, int cur_t){ - float dist = sqrt(tracker->dx * tracker->dx + tracker->dy * tracker->dy); + double dist = sqrt(tracker->dx * tracker->dx + tracker->dy * tracker->dy); int dtime = cur_t - tracker->time; if(dtime > 0) return dist / dtime; @@ -593,16 +588,16 @@ CalcTracker(const MotionTracker *tracker, int cur_t){ * * @return The tracker's velocity or 0 if the above conditions are unmet */ -static float +static double QueryTrackers(DeviceVelocityPtr vel, int cur_t){ int offset, dir = UNDEFINED, used_offset = -1, age_ms; /* initial velocity: a low-offset, valid velocity */ - float initial_velocity = 0, result = 0, velocity_diff; - float velocity_factor = vel->corr_mul * vel->const_acceleration; /* premultiply */ + double initial_velocity = 0, result = 0, velocity_diff; + double velocity_factor = vel->corr_mul * vel->const_acceleration; /* premultiply */ /* loop from current to older data */ for(offset = 1; offset < vel->num_tracker; offset++){ MotionTracker *tracker = TRACKER(vel, offset); - float tracker_velocity; + double tracker_velocity; age_ms = cur_t - tracker->time; @@ -674,11 +669,11 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){ BOOL ProcessVelocityData2D( DeviceVelocityPtr vel, - int dx, - int dy, + double dx, + double dy, int time) { - float velocity; + double velocity; vel->last_velocity = vel->velocity; @@ -694,12 +689,12 @@ ProcessVelocityData2D( * this flattens significant ( > 1) mickeys a little bit for more steady * constant-velocity response */ -static inline float -ApplySimpleSoftening(int prev_delta, int delta) +static inline double +ApplySimpleSoftening(double prev_delta, double delta) { - float result = delta; + double result = delta; - if (delta < -1 || delta > 1) { + if (delta < -1.0 || delta > 1.0) { if (delta > prev_delta) result -= 0.5; else if (delta < prev_delta) @@ -718,8 +713,8 @@ ApplySimpleSoftening(int prev_delta, int delta) static void ApplySoftening( DeviceVelocityPtr vel, - float* fdx, - float* fdy) + double* fdx, + double* fdy) { if (vel->use_softening) { *fdx = ApplySimpleSoftening(vel->last_dx, *fdx); @@ -728,7 +723,7 @@ ApplySoftening( } static void -ApplyConstantDeceleration(DeviceVelocityPtr vel, float *fdx, float *fdy) +ApplyConstantDeceleration(DeviceVelocityPtr vel, double *fdx, double *fdy) { *fdx *= vel->const_acceleration; *fdy *= vel->const_acceleration; @@ -737,15 +732,15 @@ ApplyConstantDeceleration(DeviceVelocityPtr vel, float *fdx, float *fdy) /* * compute the acceleration for given velocity and enforce min_acceleartion */ -float +double BasicComputeAcceleration( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc){ + double velocity, + double threshold, + double acc){ - float result; + double result; result = vel->Profile(dev, vel, velocity, threshold, acc); /* enforce min_acceleration */ @@ -759,13 +754,13 @@ BasicComputeAcceleration( * If the velocity has changed, an average is taken of 6 velocity factors: * current velocity, last velocity and 4 times the average between the two. */ -static float +static double ComputeAcceleration( DeviceIntPtr dev, DeviceVelocityPtr vel, - float threshold, - float acc){ - float result; + double threshold, + double acc){ + double result; if(vel->velocity <= 0){ DebugAccelF("(dix ptracc) profile skipped\n"); @@ -808,13 +803,13 @@ ComputeAcceleration( /** * Polynomial function similar previous one, but with f(1) = 1 */ -static float +static double PolynomialAccelerationProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float ignored, - float acc) + double velocity, + double ignored, + double acc) { return pow(velocity, (acc - 1.0) * 0.5); } @@ -824,13 +819,13 @@ PolynomialAccelerationProfile( * returns acceleration for velocity. * This profile selects the two functions like the old scheme did */ -static float +static double ClassicProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc) + double velocity, + double threshold, + double acc) { if (threshold > 0) { return SimpleSmoothProfile (dev, @@ -856,15 +851,15 @@ ClassicProfile( * This has the expense of overall response dependency on min-acceleration. * In effect, min_acceleration mimics const_acceleration in this profile. */ -static float +static double PowerProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc) + double velocity, + double threshold, + double acc) { - float vel_dist; + double vel_dist; acc = (acc-1.0) * 0.1f + 1.0; /* without this, acc of 2 is unuseable */ @@ -882,11 +877,11 @@ PowerProfile( * - starts faster than a sinoid * - smoothness C1 (Cinf if you dare to ignore endpoints) */ -static inline float -CalcPenumbralGradient(float x){ +static inline double +CalcPenumbralGradient(double x){ x *= 2.0f; x -= 1.0f; - return 0.5f + (x * sqrt(1.0f - x*x) + asin(x))/M_PI; + return 0.5f + (x * sqrt(1.0 - x*x) + asin(x))/M_PI; } @@ -894,13 +889,13 @@ CalcPenumbralGradient(float x){ * acceleration function similar to classic accelerated/unaccelerated, * but with smooth transition in between (and towards zero for adaptive dec.). */ -static float +static double SimpleSmoothProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc) + double velocity, + double threshold, + double acc) { if(velocity < 1.0f) return CalcPenumbralGradient(0.5 + velocity*0.5) * 2.0f - 1.0f; @@ -920,15 +915,15 @@ SimpleSmoothProfile( * This profile uses the first half of the penumbral gradient as a start * and then scales linearly. */ -static float +static double SmoothLinearProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc) + double velocity, + double threshold, + double acc) { - float res, nv; + double res, nv; if(acc > 1.0f) acc -= 1.0f; /*this is so acc = 1 is no acceleration */ @@ -955,15 +950,15 @@ SmoothLinearProfile( * From 0 to threshold, the response graduates smoothly from min_accel to * acceleration. Beyond threshold it is exactly the specified acceleration. */ -static float +static double SmoothLimitedProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc) + double velocity, + double threshold, + double acc) { - float res; + double res; if(velocity >= threshold || threshold == 0.0f) return acc; @@ -976,24 +971,24 @@ SmoothLimitedProfile( } -static float +static double LinearProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc) + double velocity, + double threshold, + double acc) { return acc * velocity; } -static float +static double NoProfile( DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, - float threshold, - float acc) + double velocity, + double threshold, + double acc) { return 1.0f; } @@ -1119,7 +1114,8 @@ acceleratePointerPredictable( ValuatorMask* val, CARD32 evtime) { - int dx = 0, dy = 0, tmpi; + double dx = 0, dy = 0; + int tmpi; DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev); Bool soften = TRUE; @@ -1139,47 +1135,44 @@ acceleratePointerPredictable( dy = valuator_mask_get(val, 1); } - if (dx || dy){ + if (dx != 0.0 || dy != 0.0) { /* reset non-visible state? */ if (ProcessVelocityData2D(velocitydata, dx , dy, evtime)) { soften = FALSE; } if (dev->ptrfeed && dev->ptrfeed->ctrl.num) { - float mult; + double mult; /* invoke acceleration profile to determine acceleration */ mult = ComputeAcceleration (dev, velocitydata, - dev->ptrfeed->ctrl.threshold, - (float)dev->ptrfeed->ctrl.num / - (float)dev->ptrfeed->ctrl.den); + dev->ptrfeed->ctrl.threshold, + (double)dev->ptrfeed->ctrl.num / + (double)dev->ptrfeed->ctrl.den); if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) { - float fdx = dx, - fdy = dy; - if (mult > 1.0f && soften) - ApplySoftening(velocitydata, &fdx, &fdy); - ApplyConstantDeceleration(velocitydata, &fdx, &fdy); + ApplySoftening(velocitydata, &dx, &dy); + ApplyConstantDeceleration(velocitydata, &dx, &dy); /* Calculate the new delta (with accel) and drop it back * into the valuator masks */ - if (dx) { - float tmp; - tmp = mult * fdx + dev->last.remainder[0]; + if (dx != 0.0) { + double tmp; + tmp = mult * dx + dev->last.remainder[0]; tmpi = trunc(tmp); valuator_mask_set(val, 0, tmpi); - dev->last.remainder[0] = tmp - (float)tmpi; + dev->last.remainder[0] = tmp - (double)tmpi; } - if (dy) { - float tmp; - tmp = mult * fdy + dev->last.remainder[1]; + if (dy != 0.0) { + double tmp; + tmp = mult * dy + dev->last.remainder[1]; tmpi = trunc(tmp); valuator_mask_set(val, 1, tmpi); - dev->last.remainder[1] = tmp - (float)tmpi; + dev->last.remainder[1] = tmp - (double)tmpi; } DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n", - *px, *py, dev->last.remainder[0], dev->last.remainder[1], fdx, fdy); + *px, *py, dev->last.remainder[0], dev->last.remainder[1], dx, dy); } } } @@ -1200,8 +1193,9 @@ acceleratePointerLightweight( ValuatorMask* val, CARD32 ignored) { - float mult = 0.0, tmpf; - int dx = 0, dy = 0, tmpi; + double mult = 0.0, tmpf; + double dx = 0.0, dy = 0.0; + int tmpi; if (valuator_mask_isset(val, 0)) { dx = valuator_mask_get(val, 0); @@ -1211,52 +1205,52 @@ acceleratePointerLightweight( dy = valuator_mask_get(val, 1); } - if (!dx && !dy) + if (dx == 0.0 && dy == 0.0) return; if (dev->ptrfeed && dev->ptrfeed->ctrl.num) { /* modeled from xf86Events.c */ if (dev->ptrfeed->ctrl.threshold) { if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) { - tmpf = ((float)dx * - (float)(dev->ptrfeed->ctrl.num)) / - (float)(dev->ptrfeed->ctrl.den) + + tmpf = ((double)dx * + (double)(dev->ptrfeed->ctrl.num)) / + (double)(dev->ptrfeed->ctrl.den) + dev->last.remainder[0]; - if (dx) { + if (dx != 0.0) { tmpi = (int) tmpf; valuator_mask_set(val, 0, tmpi); - dev->last.remainder[0] = tmpf - (float)tmpi; + dev->last.remainder[0] = tmpf - (double)tmpi; } - tmpf = ((float)dy * - (float)(dev->ptrfeed->ctrl.num)) / - (float)(dev->ptrfeed->ctrl.den) + + tmpf = ((double)dy * + (double)(dev->ptrfeed->ctrl.num)) / + (double)(dev->ptrfeed->ctrl.den) + dev->last.remainder[1]; - if (dy) { + if (dy != 0.0) { tmpi = (int) tmpf; valuator_mask_set(val, 1, tmpi); - dev->last.remainder[1] = tmpf - (float)tmpi; + dev->last.remainder[1] = tmpf - (double)tmpi; } } } else { - mult = pow((float)dx * (float)dx + (float)dy * (float)dy, - ((float)(dev->ptrfeed->ctrl.num) / - (float)(dev->ptrfeed->ctrl.den) - 1.0) / + mult = pow((double)dx * (double)dx + (double)dy * (double)dy, + ((double)(dev->ptrfeed->ctrl.num) / + (double)(dev->ptrfeed->ctrl.den) - 1.0) / 2.0) / 2.0; - if (dx) { - tmpf = mult * (float)dx + + if (dx != 0.0) { + tmpf = mult * (double)dx + dev->last.remainder[0]; tmpi = (int) tmpf; valuator_mask_set(val, 0, tmpi); - dev->last.remainder[0] = tmpf - (float)tmpi; + dev->last.remainder[0] = tmpf - (double)tmpi; } - if (dy) { - tmpf = mult * (float)dy + + if (dy != 0.0) { + tmpf = mult * (double)dy + dev->last.remainder[1]; tmpi = (int)tmpf; valuator_mask_set(val, 1, tmpi); - dev->last.remainder[1] = tmpf - (float)tmpi; + dev->last.remainder[1] = tmpf - (double)tmpi; } } } diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index 3038c04..330d87a 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -83,7 +83,7 @@ typedef enum { */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) #define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0) -#define ABI_XINPUT_VERSION SET_ABI_VERSION(13, 0) +#define ABI_XINPUT_VERSION SET_ABI_VERSION(14, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(6, 0) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) diff --git a/include/ptrveloc.h b/include/ptrveloc.h index 6ca309c..4f76b00 100644 --- a/include/ptrveloc.h +++ b/include/ptrveloc.h @@ -47,9 +47,9 @@ struct _DeviceVelocityRec; * profile * returns actual acceleration depending on velocity, acceleration control,... */ -typedef float (*PointerAccelerationProfileFunc) +typedef double (*PointerAccelerationProfileFunc) (DeviceIntPtr dev, struct _DeviceVelocityRec* vel, - float velocity, float threshold, float accelCoeff); + double velocity, double threshold, double accelCoeff); /** * a motion history, with just enough information to @@ -57,8 +57,8 @@ typedef float (*PointerAccelerationProfileFunc) * a more or less straight line */ typedef struct _MotionTracker { - int dx, dy; /* accumulated delta for each axis */ - int time; /* time of creation */ + double dx, dy; /* accumulated delta for each axis */ + int time; /* time of creation */ int dir; /* initial direction bitfield */ } MotionTracker, *MotionTrackerPtr; @@ -69,17 +69,17 @@ typedef struct _DeviceVelocityRec { MotionTrackerPtr tracker; int num_tracker; int cur_tracker; /* current index */ - float velocity; /* velocity as guessed by algorithm */ - float last_velocity; /* previous velocity estimate */ - int last_dx; /* last time-difference */ - int last_dy ; /* phase of last/current estimate */ - float corr_mul; /* config: multiply this into velocity */ - float const_acceleration; /* config: (recipr.) const deceleration */ - float min_acceleration; /* config: minimum acceleration */ + double velocity; /* velocity as guessed by algorithm */ + double last_velocity; /* previous velocity estimate */ + double last_dx; /* last time-difference */ + double last_dy; /* phase of last/current estimate */ + double corr_mul; /* config: multiply this into velocity */ + double const_acceleration; /* config: (recipr.) const deceleration */ + double min_acceleration; /* config: minimum acceleration */ short reset_time; /* config: reset non-visible state after # ms */ short use_softening; /* config: use softening of mouse values */ - float max_rel_diff; /* config: max. relative difference */ - float max_diff; /* config: max. difference */ + double max_rel_diff; /* config: max. relative difference */ + double max_diff; /* config: max. difference */ int initial_range; /* config: max. offset used as initial velocity */ Bool average_accel; /* config: average acceleration over velocity */ PointerAccelerationProfileFunc Profile; @@ -107,11 +107,11 @@ extern _X_EXPORT void InitTrackers(DeviceVelocityPtr vel, int ntracker); extern _X_EXPORT BOOL -ProcessVelocityData2D(DeviceVelocityPtr vel, int dx, int dy, int time); +ProcessVelocityData2D(DeviceVelocityPtr vel, double dx, double dy, int time); -extern _X_EXPORT float +extern _X_EXPORT double BasicComputeAcceleration(DeviceIntPtr dev, DeviceVelocityPtr vel, - float velocity, float threshold, float acc); + double velocity, double threshold, double acc); extern _X_EXPORT void FreeVelocityData(DeviceVelocityPtr vel); commit 8a4a4e1b8a33899653d68a21bb7ff0557a576338 Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Jun 9 15:26:55 2011 +0100 Input: Use trunc instead of lrintf in acceleration code For compatibility with all the rest of the input code. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Simon Thum <simon.thum at gmx.de> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index dfccf15..c506791 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -1167,19 +1167,14 @@ acceleratePointerPredictable( if (dx) { float tmp; tmp = mult * fdx + dev->last.remainder[0]; - /* Since it may not be apparent: lrintf() does not offer - * strong statements about rounding; however because we - * process each axis conditionally, there's no danger - * of a toggling remainder. Its lack of guarantees likely - * makes it faster on the average target. */ - tmpi = lrintf(tmp); + tmpi = trunc(tmp); valuator_mask_set(val, 0, tmpi); dev->last.remainder[0] = tmp - (float)tmpi; } if (dy) { float tmp; tmp = mult * fdy + dev->last.remainder[1]; - tmpi = lrintf(tmp); + tmpi = trunc(tmp); valuator_mask_set(val, 1, tmpi); dev->last.remainder[1] = tmp - (float)tmpi; } commit e1df51421bc392d57f88c831fe0661871a8aa769 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 13:34:32 2011 +0000 Input: Set fractional member in set_raw_valuators RawDeviceEvents have space for fractional valuator members, so might as well start using them. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index 76e8a32..b8f4a8c 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -167,16 +167,20 @@ init_raw(DeviceIntPtr dev, RawDeviceEvent *event, Time ms, int type, int detail) } static void -set_raw_valuators(RawDeviceEvent *event, ValuatorMask *mask, int32_t* data) +set_raw_valuators(RawDeviceEvent *event, ValuatorMask *mask, int32_t* data, + int32_t* data_frac) { int i; + double val; for (i = 0; i < valuator_mask_size(mask); i++) { if (valuator_mask_isset(mask, i)) { SetBit(event->valuators.mask, i); - data[i] = valuator_mask_get(mask, i); + val = valuator_mask_get_double(mask, i); + data[i] = trunc(val); + data_frac[i] = (val - data[i]) * (1UL << 32); } } } @@ -969,11 +973,13 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type, valuator_mask_copy(&mask, mask_in); init_raw(pDev, raw, ms, type, key_code); - set_raw_valuators(raw, &mask, raw->valuators.data_raw); + set_raw_valuators(raw, &mask, raw->valuators.data_raw, + raw->valuators.data_raw_frac); clipValuators(pDev, &mask); - set_raw_valuators(raw, &mask, raw->valuators.data); + set_raw_valuators(raw, &mask, raw->valuators.data, + raw->valuators.data_frac); event = &events->device_event; init_device_event(event, pDev, ms); @@ -1147,7 +1153,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons num_events++; init_raw(pDev, raw, ms, type, buttons); - set_raw_valuators(raw, &mask, raw->valuators.data_raw); + set_raw_valuators(raw, &mask, raw->valuators.data_raw, + raw->valuators.data_raw_frac); } if (flags & POINTER_ABSOLUTE) @@ -1188,7 +1195,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons } if ((flags & POINTER_NORAW) == 0) - set_raw_valuators(raw, &mask, raw->valuators.data); + set_raw_valuators(raw, &mask, raw->valuators.data, + raw->valuators.data_frac); positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, &x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac); commit cdf202250ef616f3b261db70da30e421ea59a630 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 14:50:29 2011 +0000 Input: Convert transformAbsolute to work on doubles Change transformAbsolute to use doubles internally. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index 30044ba..76e8a32 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1026,32 +1026,37 @@ FreeEventList(InternalEvent *list, int num_events) * back into x/y. */ static void -transform(struct pixman_f_transform *m, int *x, int *y) +transform(struct pixman_f_transform *m, double *x, double *y) { struct pixman_f_vector p = {.v = {*x, *y, 1}}; pixman_f_transform_point(m, &p); - *x = lround(p.v[0]); - *y = lround(p.v[1]); + *x = p.v[0]; + *y = p.v[1]; } static void transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask) { - int x, y, ox, oy; + double x, y, ox, oy; - ox = x = valuator_mask_isset(mask, 0) ? valuator_mask_get(mask, 0) : - dev->last.valuators[0]; - oy = y = valuator_mask_isset(mask, 1) ? valuator_mask_get(mask, 1) : - dev->last.valuators[1]; + if (valuator_mask_isset(mask, 0)) + ox = x = valuator_mask_get_double(mask, 0); + else + ox = x = dev->last.valuators[0] + dev->last.remainder[0]; + + if (valuator_mask_isset(mask, 1)) + oy = y = valuator_mask_get_double(mask, 1); + else + oy = y = dev->last.valuators[1] + dev->last.remainder[1]; transform(&dev->transform, &x, &y); if (valuator_mask_isset(mask, 0) || ox != x) - valuator_mask_set(mask, 0, x); + valuator_mask_set_double(mask, 0, x); if (valuator_mask_isset(mask, 1) || oy != y) - valuator_mask_set(mask, 1, y); + valuator_mask_set_double(mask, 1, y); } /** commit 3463078f9697fad0ee11837d80e88889fc6a28a4 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 13:29:24 2011 +0000 Input: Convert clipAxis, moveAbsolute and moveRelative to double Change all these three to use doubles internally, though the outputs of moveAbsolute and moveRelative are still truncated to int. Signed-off-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index fd8b098..30044ba 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -617,7 +617,7 @@ GetMaximumEventsNum(void) { * InitValuatorAxisClassStruct. */ static void -clipAxis(DeviceIntPtr pDev, int axisNum, int *val) +clipAxis(DeviceIntPtr pDev, int axisNum, double *val) { AxisInfoPtr axis; @@ -647,9 +647,9 @@ clipValuators(DeviceIntPtr pDev, ValuatorMask *mask) for (i = 0; i < valuator_mask_size(mask); i++) if (valuator_mask_isset(mask, i)) { - int val = valuator_mask_get(mask, i); + double val = valuator_mask_get_double(mask, i); clipAxis(pDev, i, &val); - valuator_mask_set(mask, i, val); + valuator_mask_set_double(mask, i, val); } } @@ -699,17 +699,18 @@ static void moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) { int i; - int x, y; for (i = 0; i < valuator_mask_size(mask); i++) { - if (valuator_mask_isset(mask, i)) - { - int val = valuator_mask_get(mask, i); - clipAxis(dev, i, &val); - dev->last.valuators[i] = val; - valuator_mask_set(mask, i, val); - } + double val; + + if (!valuator_mask_isset(mask, i)) + continue; + val = valuator_mask_get_double(mask, i); + clipAxis(dev, i, &val); + dev->last.valuators[i] = trunc(val); + dev->last.remainder[i] = val - trunc(val); + valuator_mask_set_double(mask, i, val); } *x_out = dev->last.valuators[0]; @@ -733,18 +734,19 @@ moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) /* calc other axes, clip, drop back into valuators */ for (i = 0; i < valuator_mask_size(mask); i++) { - if (valuator_mask_isset(mask, i)) - { - int val = dev->last.valuators[i]; - val += valuator_mask_get(mask, i); - /* x & y need to go over the limits to cross screens if the SD - * isn't currently attached; otherwise, clip to screen bounds. */ - if (valuator_get_mode(dev, i) == Absolute && - ((i != 0 && i != 1) || clip_xy)) - clipAxis(dev, i, &val); - dev->last.valuators[i] = val; - valuator_mask_set(mask, i, val); - } + double val = dev->last.valuators[i] + dev->last.remainder[i]; + + if (!valuator_mask_isset(mask, i)) + continue; + val += valuator_mask_get_double(mask, i); + /* x & y need to go over the limits to cross screens if the SD + * isn't currently attached; otherwise, clip to screen bounds. */ + if (valuator_get_mode(dev, i) == Absolute && + ((i != 0 && i != 1) || clip_xy)) + clipAxis(dev, i, &val); + dev->last.valuators[i] = trunc(val); + dev->last.remainder[i] = val - trunc(val); + valuator_mask_set_double(mask, i, val); } *x_out = dev->last.valuators[0]; commit 4e52cc0ef48145134cd58d357fb7289e6f8bb709 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 13:20:37 2011 +0000 Input: Prepare moveRelative for conversion to double Shuffle some code around in moveRelative to make the conversion to double easier later. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index bcac6aa..fd8b098 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -719,48 +719,36 @@ moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) /** * Move the device's pointer by the values given in @valuators. * - * @param dev The device which's pointer is to be moved. + * @param dev The device whose pointer is to be moved. * @param x Returns the x position of the pointer after the move. * @param y Returns the y position of the pointer after the move. - * @param mask Bit mask of valid valuators. - * @param valuators Valuator data for each axis between @first and - * @first+ at num. + * @param mask Valuator data for this event. */ static void -moveRelative(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask) +moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) { int i; - - *x = dev->last.valuators[0]; - *y = dev->last.valuators[1]; - - if (valuator_mask_isset(mask, 0)) - *x += valuator_mask_get(mask, 0); - - if (valuator_mask_isset(mask, 1)) - *y += valuator_mask_get(mask, 1); - - /* if attached, clip both x and y to the defined limits (usually - * co-ord space limit). If it is attached, we need x/y to go over the - * limits to be able to change screens. */ - if (dev->valuator && (IsMaster(dev) || !IsFloating(dev))) { - if (valuator_get_mode(dev, 0) == Absolute) - clipAxis(dev, 0, x); - if (valuator_get_mode(dev, 1) == Absolute) - clipAxis(dev, 1, y); - } + Bool clip_xy = IsMaster(dev) || !IsFloating(dev); /* calc other axes, clip, drop back into valuators */ - for (i = 2; i < valuator_mask_size(mask); i++) + for (i = 0; i < valuator_mask_size(mask); i++) { if (valuator_mask_isset(mask, i)) { - dev->last.valuators[i] += valuator_mask_get(mask, i); - if (valuator_get_mode(dev, i) == Absolute) - clipAxis(dev, i, &dev->last.valuators[i]); - valuator_mask_set(mask, i, dev->last.valuators[i]); + int val = dev->last.valuators[i]; + val += valuator_mask_get(mask, i); + /* x & y need to go over the limits to cross screens if the SD + * isn't currently attached; otherwise, clip to screen bounds. */ + if (valuator_get_mode(dev, i) == Absolute && + ((i != 0 && i != 1) || clip_xy)) + clipAxis(dev, i, &val); + dev->last.valuators[i] = val; + valuator_mask_set(mask, i, val); } } + + *x_out = dev->last.valuators[0]; + *y_out = dev->last.valuators[1]; } /** commit 80fdf9ca33a8f50f98a4b1a3279e66b040353b80 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 13:19:00 2011 +0000 Input: Prepare moveAbsolute for conversion to double Shuffle some code around to make moving to double easier later. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index d9c5c0d..bcac6aa 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -690,40 +690,30 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve /** * Move the device's pointer to the position given in the valuators. * - * @param dev The device which's pointer is to be moved. + * @param dev The device whose pointer is to be moved. * @param x Returns the x position of the pointer after the move. * @param y Returns the y position of the pointer after the move. - * @param mask Bit mask of valid valuators. - * @param valuators Valuator data for each axis between @first and - * @first+ at num. + * @param mask Valuator data for this event. */ static void -moveAbsolute(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask) +moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask) { int i; + int x, y; - if (valuator_mask_isset(mask, 0)) - *x = valuator_mask_get(mask, 0); - else - *x = dev->last.valuators[0]; - - if (valuator_mask_isset(mask, 1)) - *y = valuator_mask_get(mask, 1); - else - *y = dev->last.valuators[1]; - - clipAxis(dev, 0, x); - clipAxis(dev, 1, y); - - for (i = 2; i < valuator_mask_size(mask); i++) + for (i = 0; i < valuator_mask_size(mask); i++) { if (valuator_mask_isset(mask, i)) { - dev->last.valuators[i] = valuator_mask_get(mask, i); - clipAxis(dev, i, &dev->last.valuators[i]); - valuator_mask_set(mask, i, dev->last.valuators[i]); + int val = valuator_mask_get(mask, i); + clipAxis(dev, i, &val); + dev->last.valuators[i] = val; + valuator_mask_set(mask, i, val); } } + + *x_out = dev->last.valuators[0]; + *y_out = dev->last.valuators[1]; } /** commit 6a6b4eb05c7822860e2362fa9b8441fc67055e27 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Mar 2 17:22:59 2011 +0000 Input: Store clipped absolute axes in the mask Change moveAbsolute to be more symmetric with moveRelative by storing a clipped axis value back in the mask, rather than just in dev->last.valuators. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index be2840c..d9c5c0d 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -721,6 +721,7 @@ moveAbsolute(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask) { dev->last.valuators[i] = valuator_mask_get(mask, i); clipAxis(dev, i, &dev->last.valuators[i]); + valuator_mask_set(mask, i, dev->last.valuators[i]); } } } commit 7e919ef5bfa94d51a06eefb150ab947bdbfb6885 Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Feb 23 17:28:18 2011 +0000 Input: Add double-precision valuator_mask API Add API for valuator_mask that accepts and returns doubles, rather than ints. No double API is provided for set_range at the moment. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/inpututils.c b/dix/inpututils.c index 1c4af8e..0a3d3d8 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -497,10 +497,10 @@ valuator_mask_isset(const ValuatorMask *mask, int valuator) } /** - * Set the valuator to the given data. + * Set the valuator to the given floating-point data. */ void -valuator_mask_set(ValuatorMask *mask, int valuator, int data) +valuator_mask_set_double(ValuatorMask *mask, int valuator, double data) { mask->last_bit = max(valuator, mask->last_bit); SetBit(mask->mask, valuator); @@ -508,13 +508,33 @@ valuator_mask_set(ValuatorMask *mask, int valuator, int data) } /** - * Return the requested valuator value. If the mask bit is not set for the - * given valuator, the returned value is undefined. + * Set the valuator to the given integer data. + */ +void +valuator_mask_set(ValuatorMask *mask, int valuator, int data) +{ + valuator_mask_set_double(mask, valuator, data); +} + +/** + * Return the requested valuator value as a double. If the mask bit is not + * set for the given valuator, the returned value is undefined. + */ +double +valuator_mask_get_double(const ValuatorMask *mask, int valuator) +{ + return mask->valuators[valuator]; +} + +/** + * Return the requested valuator value as an integer, rounding towards zero. + * If the mask bit is not set for the given valuator, the returned value is + * undefined. */ int valuator_mask_get(const ValuatorMask *mask, int valuator) { - return trunc(mask->valuators[valuator]); + return trunc(valuator_mask_get_double(mask, valuator)); } /** diff --git a/include/input.h b/include/input.h index 0258f4f..577f5d9 100644 --- a/include/input.h +++ b/include/input.h @@ -583,6 +583,9 @@ extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask, extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask, int valuator, int data); +extern _X_EXPORT void valuator_mask_set_double(ValuatorMask *mask, + int valuator, + double data); extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask); extern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask); extern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit); @@ -591,6 +594,8 @@ extern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask); extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest, const ValuatorMask *src); extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum); +extern _X_EXPORT double valuator_mask_get_double(const ValuatorMask *mask, + int valnum); /* InputOption handling interface */ extern _X_EXPORT InputOption* input_option_new(InputOption *list, const char *key, const char *value); diff --git a/test/input.c b/test/input.c index b8dad1c..2501d59 100644 --- a/test/input.c +++ b/test/input.c @@ -1089,12 +1089,16 @@ static void dix_input_valuator_masks(void) { ValuatorMask *mask = NULL, *copy; int nvaluators = MAX_VALUATORS; - int valuators[nvaluators]; + double valuators[nvaluators]; + int val_ranged[nvaluators]; int i; int first_val, num_vals; for (i = 0; i < nvaluators; i++) - valuators[i] = i; + { + valuators[i] = i + 0.5; + val_ranged[i] = i; + } mask = valuator_mask_new(nvaluators); assert(mask != NULL); @@ -1104,9 +1108,10 @@ static void dix_input_valuator_masks(void) for (i = 0; i < nvaluators; i++) { assert(!valuator_mask_isset(mask, i)); - valuator_mask_set(mask, i, valuators[i]); + valuator_mask_set_double(mask, i, valuators[i]); assert(valuator_mask_isset(mask, i)); - assert(valuator_mask_get(mask, i) == valuators[i]); + assert(valuator_mask_get(mask, i) == trunc(valuators[i])); + assert(valuator_mask_get_double(mask, i) == valuators[i]); assert(valuator_mask_size(mask) == i + 1); assert(valuator_mask_num_valuators(mask) == i + 1); } @@ -1132,7 +1137,7 @@ static void dix_input_valuator_masks(void) first_val = 5; num_vals = 6; - valuator_mask_set_range(mask, first_val, num_vals, valuators); + valuator_mask_set_range(mask, first_val, num_vals, val_ranged); assert(valuator_mask_size(mask) == first_val + num_vals); assert(valuator_mask_num_valuators(mask) == num_vals); for (i = 0; i < nvaluators; i++) @@ -1142,7 +1147,9 @@ static void dix_input_valuator_masks(void) else { assert(valuator_mask_isset(mask, i)); - assert(valuator_mask_get(mask, i) == valuators[i - first_val]); + assert(valuator_mask_get(mask, i) == val_ranged[i - first_val]); + assert(valuator_mask_get_double(mask, i) == + val_ranged[i - first_val]); } } @@ -1156,6 +1163,8 @@ static void dix_input_valuator_masks(void) { assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i)); assert(valuator_mask_get(mask, i) == valuator_mask_get(copy, i)); + assert(valuator_mask_get_double(mask, i) == + valuator_mask_get_double(copy, i)); } valuator_mask_free(&mask); commit 79d4deb76d5612b75ef26b4549b7ade3a656687d Author: Daniel Stone <daniel at fooishbar.org> Date: Wed Feb 23 14:31:01 2011 +0000 Input: Convert ValuatorMask to double-precision internally Switch the ValuatorMask struct to using doubles instead of ints for the actual values. Preserve the old int API, and (attempt to) round towards zero for values we return. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/inpututils.c b/dix/inpututils.c index 7aeb1e5..1c4af8e 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -514,7 +514,7 @@ valuator_mask_set(ValuatorMask *mask, int valuator, int data) int valuator_mask_get(const ValuatorMask *mask, int valuator) { - return mask->valuators[valuator]; + return trunc(mask->valuators[valuator]); } /** @@ -527,7 +527,7 @@ valuator_mask_unset(ValuatorMask *mask, int valuator) int i, lastbit = -1; ClearBit(mask->mask, valuator); - mask->valuators[valuator] = 0; + mask->valuators[valuator] = 0.0; for (i = 0; i <= mask->last_bit; i++) if (valuator_mask_isset(mask, i)) diff --git a/include/inpututils.h b/include/inpututils.h index 63e1a26..47e242d 100644 --- a/include/inpututils.h +++ b/include/inpututils.h @@ -34,7 +34,7 @@ struct _ValuatorMask { int8_t last_bit; /* highest bit set in mask */ uint8_t mask[(MAX_VALUATORS + 7)/8]; - int valuators[MAX_VALUATORS]; /* valuator data */ + double valuators[MAX_VALUATORS]; /* valuator data */ }; extern void verify_internal_event(const InternalEvent *ev); commit 60a766a96f9ec97adf6d0273f70ec23f313a11c6 Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Jun 9 16:02:47 2011 +0100 Input: Add flags to RawDeviceEvent Add a flags member which will be copied wholesale into the resultant xXIRawEvent. Signed-off-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 6ddcf9e..fa8ba9e 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -667,6 +667,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) raw->detail = ev->detail.button; raw->deviceid = ev->deviceid; raw->valuators_len = vallen; + raw->flags = ev->flags; ptr = (char*)&raw[1]; axisval = (FP3232*)(ptr + raw->valuators_len * 4); diff --git a/include/eventstr.h b/include/eventstr.h index 0885883..ecaeddc 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -204,6 +204,7 @@ struct _RawDeviceEvent int32_t data_raw[MAX_VALUATORS]; /**< Valuator data as posted */ int32_t data_raw_frac[MAX_VALUATORS];/**< Fractional part for data_raw */ } valuators; + uint32_t flags; /**< Flags to be copied into the generated event */ }; #ifdef XQUARTZ diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index 6ec94be..80c47b0 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -51,6 +51,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, swapl(&out->time); swapl(&out->detail); swaps(&out->valuators_len); + swapl(&out->flags); } commit 5d62c32981dbe9630bed32567b55008b536c81c5 Author: Daniel Stone <daniel at fooishbar.org> Date: Mon Dec 27 13:24:35 2010 +0000 Input: Add flags to DeviceEvent Add a flags member which will be copied wholesale into the resultant xXIDeviceEvent. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Chase Douglas <chase.douglas at canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 024f2e8..6ddcf9e 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -605,6 +605,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) xde->root_x = FP1616(ev->root_x, ev->root_x_frac); xde->root_y = FP1616(ev->root_y, ev->root_y_frac); + xde->flags = ev->flags; if (ev->key_repeat) xde->flags |= XIKeyRepeat; diff --git a/include/eventstr.h b/include/eventstr.h index 049688c..0885883 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -113,6 +113,7 @@ struct _DeviceEvent Window root; /**< Root window of the event */ int corestate; /**< Core key/button state BEFORE the event */ int key_repeat; /**< Internally-generated key repeat event */ + uint32_t flags; /**< Flags to be copied into the generated event */ }; From keithp at kemper.freedesktop.org Mon Oct 3 11:41:48 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 11:41:48 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111003184148.0BD1CD8002@kemper.freedesktop.org> hw/xfree86/modes/xf86Rotate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 463dd87062edaa974cb8c7163328a53197f237e1 Author: Pauli Nieminen <pauli.nieminen at linux.intel.com> Date: Thu Sep 22 18:38:53 2011 +0300 xf86/modes: Fix shadow rotation crashing when screen pixmap changes Driver may change screen pixmaps after page flipping that would then make damage lose track of the root pixmap. Using root window for shadow damages fixes the problem because SetWindowPixmap is implemented in shadow code. Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com> Reviewed-by: Keith Packard <keithp at keithp.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 45aabf0..ff7000b 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -198,7 +198,7 @@ xf86RotatePrepare (ScreenPtr pScreen) if (!xf86_config->rotation_damage_registered) { /* Hook damage to screen pixmap */ - DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + DamageRegister (&pScreen->root->drawable, xf86_config->rotation_damage); xf86_config->rotation_damage_registered = TRUE; EnableLimitedSchedulingLatency(); @@ -305,7 +305,7 @@ xf86RotateDestroy (xf86CrtcPtr crtc) /* Free damage structure */ if (xf86_config->rotation_damage_registered) { - DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + DamageUnregister (&pScreen->root->drawable, xf86_config->rotation_damage); xf86_config->rotation_damage_registered = FALSE; DisableLimitedSchedulingLatency(); From keithp at kemper.freedesktop.org Mon Oct 3 11:46:58 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 11:46:58 -0700 (PDT) Subject: xserver: Branch 'master' - 4 commits Message-ID: <20111003184658.723EED8002@kemper.freedesktop.org> hw/xquartz/X11Application.m | 2 +- include/misc.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) New commits: commit cf11ca360c2ded5ca309faa9d039160947387bb8 Merge: 463dd87... 6eae9fa... Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 3 11:44:59 2011 -0700 Merge remote-tracking branch 'jeremyhu/for-keith' commit 6eae9fa28445b6cfa09061b338242df5116aafe8 Author: Matt Turner <mattst88 at gmail.com> Date: Wed Sep 28 17:27:45 2011 -0400 Remove incorrect & in swap_uint32 Caused by commit 893e86a4, and hidden by the (char *) cast. Signed-off-by: Matt Turner <mattst88 at gmail.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Aaron Plattner <aplattner at nvidia.com> Tested-by: Aaron Plattner <aplattner at nvidia.com> diff --git a/include/misc.h b/include/misc.h index 0867746..dc03911 100644 --- a/include/misc.h +++ b/include/misc.h @@ -279,7 +279,7 @@ static inline int __builtin_constant_p(int x) /* byte swap a 32-bit value */ static inline void swap_uint32(uint32_t *x) { - char n = ((char *) &x)[0]; + char n = ((char *) x)[0]; ((char *) x)[0] = ((char *) x)[3]; ((char *) x)[3] = n; n = ((char *) x)[1]; commit 38e9e28ba2fbffee52ad9889ef6d4e94c7af3e10 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Sep 20 20:39:06 2011 -0700 XQuartz: Use set_front_process rather than X11ApplicationSetFrontProcess since we're already in the AppKit thread Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 7fd7dab..12ff53c 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -356,7 +356,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) { */ _appFlags._active = YES; - X11ApplicationSetFrontProcess(); + [self set_front_process:nil]; /* Get the Spaces preference for SwitchOnActivate */ (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock")); commit 206b30ebc608d29a91cc18665d89e887cac4dba3 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Sep 22 18:55:19 2011 -0700 Address regressions from e8ff555b95ba and d206d52f657c to work with other compilers 1) The error attribute appeared in gcc-4.3 2) The return type of __builtin_constant_p is int 3) Sun Studio 12.0 and later builtin support for __builtin_constant_p Found by Tinderbox. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Matt Turner <mattst88 at gmail.com> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Aaron Plattner <aplattner at nvidia.com> diff --git a/include/misc.h b/include/misc.h index 1fea73e..0867746 100644 --- a/include/misc.h +++ b/include/misc.h @@ -261,14 +261,16 @@ version_compare(uint16_t a_major, uint16_t a_minor, #define SwapRestL(stuff) \ SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff)) -#ifdef __GNUC__ +#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) void __attribute__((error("wrong sized variable passed to swap"))) wrong_size(void); #else static inline void wrong_size(void) { } +#endif -static inline void __builtin_constant_p(int x) +#if !(defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C < 0x590))) +static inline int __builtin_constant_p(int x) { return 0; } From keithp at kemper.freedesktop.org Mon Oct 3 11:50:12 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 11:50:12 -0700 (PDT) Subject: xserver: Branch 'master' - 6 commits Message-ID: <20111003185012.63DE0D8002@kemper.freedesktop.org> Xext/xcmisc.c | 5 ----- dbe/dbe.c | 5 ----- dix/.gitignore | 1 + doc/dtrace/Xserver-DTrace.xml | 22 +++++++++++----------- include/dix-config.h.in | 3 --- os/.gitignore | 1 + render/render.c | 4 ---- 7 files changed, 13 insertions(+), 28 deletions(-) New commits: commit 9a55b3661b4172f9a32cd6fefb254e06edb1a88a Merge: cf11ca3... 84bb020... Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 3 11:49:23 2011 -0700 Merge remote-tracking branch 'alanc/master' commit 84bb0207f6db433a8d387d933393357da87ca23e Author: Gaetan Nadon <memsize at videotron.ca> Date: Fri Sep 23 20:03:03 2011 -0400 dix and os: gitignore dix.O and os.O Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Gaetan Nadon <memsize at videotron.ca> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> diff --git a/dix/.gitignore b/dix/.gitignore index c1b4f20..65f2f8c 100644 --- a/dix/.gitignore +++ b/dix/.gitignore @@ -1,2 +1,3 @@ # Add & Override for this directory and it's subdirectories Xserver-dtrace.h +dix.O diff --git a/os/.gitignore b/os/.gitignore new file mode 100644 index 0000000..bba633b --- /dev/null +++ b/os/.gitignore @@ -0,0 +1 @@ +os.O commit 3d41939d0349569dcfd2aef9b846c739d0ba0060 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Sep 22 17:41:38 2011 -0700 Unconditionally #include <stdint.h> The more recent inclusions of this file haven't been checking for HAVE_STDINT_H, so might as well make the older ones consistent. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c index 8e3c9cd..745135e 100644 --- a/Xext/xcmisc.c +++ b/Xext/xcmisc.c @@ -40,12 +40,7 @@ from The Open Group. #include <X11/extensions/xcmiscproto.h> #include "modinit.h" -#if HAVE_STDINT_H #include <stdint.h> -#elif !defined(UINT32_MAX) -#define UINT32_MAX 0xffffffffU -#endif - static int ProcXCMiscGetVersion(ClientPtr client) diff --git a/dbe/dbe.c b/dbe/dbe.c index 86d8220..a468676 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -38,12 +38,7 @@ #endif #include <string.h> -#if HAVE_STDINT_H #include <stdint.h> -#elif !defined(UINT32_MAX) -#define UINT32_MAX 0xffffffffU -#endif - #include <X11/X.h> #include <X11/Xproto.h> #include "scrnintstr.h" diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 5facb11..aa7de60 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -178,9 +178,6 @@ /* Define to 1 if you have the `shmctl64' function. */ #undef HAVE_SHMCTL64 -/* Define to 1 if you have the <stdint.h> header file. */ -#undef HAVE_STDINT_H - /* Define to 1 if you have the <stdlib.h> header file. */ #undef HAVE_STDLIB_H diff --git a/render/render.c b/render/render.c index cc13dbc..ff75409 100644 --- a/render/render.c +++ b/render/render.c @@ -52,11 +52,7 @@ #include "panoramiXsrv.h" #endif -#if HAVE_STDINT_H #include <stdint.h> -#elif !defined(UINT32_MAX) -#define UINT32_MAX 0xffffffffU -#endif static int ProcRenderQueryVersion (ClientPtr pClient); static int ProcRenderQueryPictFormats (ClientPtr pClient); commit 46d5ae5b551cc926331324073f2686b47e8aea07 Author: Gaetan Nadon <memsize at videotron.ca> Date: Fri Sep 23 09:38:25 2011 -0400 dtrace: fix typo in title The word provider should be capitalized. Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Gaetan Nadon <memsize at videotron.ca> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> diff --git a/doc/dtrace/Xserver-DTrace.xml b/doc/dtrace/Xserver-DTrace.xml index 2427202..fa8bc80 100644 --- a/doc/dtrace/Xserver-DTrace.xml +++ b/doc/dtrace/Xserver-DTrace.xml @@ -6,7 +6,7 @@ <article id="Xserver-DTrace"> <articleinfo> - <title>Xserver provider for DTrace + Xserver Provider for DTrace AlanCoopersmith commit 6cae6224994e3252b3b7c7608f983ce73e0206fc Author: Gaetan Nadon Date: Fri Sep 23 09:38:24 2011 -0400 dtrace: use docbook copyright markup for copyright holder No content change to copyright text. Reviewed-by: Alan Coopersmith Signed-off-by: Gaetan Nadon Signed-off-by: Alan Coopersmith diff --git a/doc/dtrace/Xserver-DTrace.xml b/doc/dtrace/Xserver-DTrace.xml index cd8a812..2427202 100644 --- a/doc/dtrace/Xserver-DTrace.xml +++ b/doc/dtrace/Xserver-DTrace.xml @@ -15,11 +15,11 @@ X.Org Xserver version &xserver.version; + 2005200620072010 + Oracle and/or its affiliates. All rights reserved. + -Copyright (c) 2005, 2006, 2007, 2010, Oracle and/or its affiliates. -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 commit 58d3d46d6cc0d7a81db6bad61d158f3b9af8af71 Author: Alan Coopersmith Date: Thu Sep 1 16:48:37 2011 -0700 Assign ids to more tags in Xserver-Dtrace.xml Keeps xsltproc from adding random-number id tags to html output so that it's easier to see real changes vs. different random numbers. Signed-off-by: Alan Coopersmith Reviewed-by: Matt Dew diff --git a/doc/dtrace/Xserver-DTrace.xml b/doc/dtrace/Xserver-DTrace.xml index 69cd30e..cd8a812 100644 --- a/doc/dtrace/Xserver-DTrace.xml +++ b/doc/dtrace/Xserver-DTrace.xml @@ -15,7 +15,7 @@ X.Org Xserver version &xserver.version; - + Copyright (c) 2005, 2006, 2007, 2010, Oracle and/or its affiliates. All rights reserved. @@ -79,7 +79,7 @@ DEALINGS IN THE SOFTWARE. arg2, etc. These tables should help you determine what the real data is for each of the probe arguments. - +
Probes and their arguments @@ -195,7 +195,7 @@ DEALINGS IN THE SOFTWARE. To access data buffers referenced via uintptr_t's, you will need to use copyin(). -
+
Probe Arguments @@ -313,7 +313,7 @@ DEALINGS IN THE SOFTWARE. Examples - + Counting requests by request name @@ -370,7 +370,7 @@ Xserver*:::request-start - + Get average CPU time per request This script records the CPU time used between the probes at @@ -419,7 +419,7 @@ Xserver*:::request-done - + Monitoring clients that connect and disconnect @@ -476,7 +476,7 @@ CPU ID FUNCTION:NAME - + Monitoring clients creating Pixmaps From keithp at kemper.freedesktop.org Mon Oct 3 11:54:10 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 11:54:10 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111003185410.97A6ED8002@kemper.freedesktop.org> hw/kdrive/src/kinfo.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) New commits: commit 77743f877d573cdf70fcb5cb5897250f668ebf9b Author: Jamey Sharp Date: Mon Sep 26 22:38:44 2011 -0700 kdrive: Fix build for opaque InputOption structure. Commit 05284a03f9002b03a66ae355b34790ec02b726f0 missed fixing up kdrive's use of the old non-opaque structure. Signed-off-by: Jamey Sharp Reviewed-by: Peter Hutterer Signed-off-by: Keith Packard diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c index 7055fbf..0055b16 100644 --- a/hw/kdrive/src/kinfo.c +++ b/hw/kdrive/src/kinfo.c @@ -134,19 +134,9 @@ KdNewPointer (void) void KdFreePointer(KdPointerInfo *pi) { - InputOption *option, *prev = NULL; - free(pi->name); free(pi->path); - - for (option = pi->options; option; option = option->next) { - free(prev); - free(option->key); - free(option->value); - prev = option; - } - - free(prev); + input_option_free_list(&pi->options); free(pi); } From keithp at kemper.freedesktop.org Mon Oct 3 11:57:17 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 11:57:17 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111003185717.F2F73D8002@kemper.freedesktop.org> config/udev.c | 4 ++++ configure.ac | 9 +++++++++ include/dix-config.h.in | 6 ++++++ 3 files changed, 19 insertions(+) New commits: commit fad04dd9701aa76249a0bab31676103debb84307 Author: Lennart Poettering Date: Tue Sep 27 18:04:06 2011 +0100 udev: make use of udev_enumerate_add_match_tag() only when it is available udev_enumerate_add_match_tag() and udev_monitor_filter_add_match_tag() are mostly optimizations, hence simply skip these calls if they are not available in the installed version of libudev. This should fix the build on older versions of udev. [airlied: fixes tinderbox failures on RHEL6] Signed-off-by: Lennart Poettering Reviewed-by: Dave Airlie Tested-by: Dave Airlie Reviewed-by: Peter Hutterer Signed-off-by: Keith Packard diff --git a/config/udev.c b/config/udev.c index 1ba0d50..e2b3726 100644 --- a/config/udev.c +++ b/config/udev.c @@ -285,8 +285,10 @@ config_udev_init(void) udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input", NULL); udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "tty", NULL); /* For Wacom serial devices */ +#ifdef HAVE_UDEV_MONITOR_FILTER_ADD_MATCH_TAG if (SeatId && strcmp(SeatId, "seat0")) udev_monitor_filter_add_match_tag(udev_monitor, SeatId); +#endif if (udev_monitor_enable_receiving(udev_monitor)) { ErrorF("config/udev: failed to bind the udev monitor\n"); @@ -300,8 +302,10 @@ config_udev_init(void) udev_enumerate_add_match_subsystem(enumerate, "input"); udev_enumerate_add_match_subsystem(enumerate, "tty"); +#ifdef HAVE_UDEV_ENUMERATE_ADD_MATCH_TAG if (SeatId && strcmp(SeatId, "seat0")) udev_enumerate_add_match_tag(enumerate, SeatId); +#endif udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); diff --git a/configure.ac b/configure.ac index ecd5386..7c5aaaf 100644 --- a/configure.ac +++ b/configure.ac @@ -822,6 +822,15 @@ if test "x$CONFIG_UDEV" = xyes; then AC_MSG_ERROR([udev configuration API requested, but libudev is not installed]) fi AC_DEFINE(CONFIG_UDEV, 1, [Use libudev for input hotplug]) + + SAVE_LIBS=$LIBS + SAVE_CFLAGS=$CFLAGS + CFLAGS=$UDEV_CFLAGS + LIBS=$UDEV_LIBS + AC_CHECK_FUNCS([udev_monitor_filter_add_match_tag]) + AC_CHECK_FUNCS([udev_enumerate_add_match_tag]) + LIBS=$SAVE_LIBS + CFLAGS=$SAVE_CFLAGS fi dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas diff --git a/include/dix-config.h.in b/include/dix-config.h.in index aa7de60..7d6cb96 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -399,6 +399,12 @@ /* Use libudev for input hotplug */ #undef CONFIG_UDEV +/* Use udev_monitor_filter_add_match_tag() */ +#undef HAVE_UDEV_MONITOR_FILTER_ADD_MATCH_TAG + +/* Use udev_enumerate_add_match_tag() */ +#undef HAVE_UDEV_ENUMERATE_ADD_MATCH_TAG + /* Use D-Bus for input hotplug */ #undef CONFIG_NEED_DBUS From keithp at kemper.freedesktop.org Mon Oct 3 12:17:58 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 12:17:58 -0700 (PDT) Subject: xserver: Branch 'master' - 2 commits Message-ID: <20111003191758.B67B0D8002@kemper.freedesktop.org> doc/Xinput.xml | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) New commits: commit 2f09f6e3f610e585aeb5bd1023323a909d1ba20d Author: Gaetan Nadon Date: Thu Sep 29 07:53:16 2011 -0400 Xinput: use appropriate copyright markup for a multi licensed doc Removed a duplicate paragraph. Acked-by: Peter Hutterer Signed-off-by: Gaetan Nadon Signed-off-by: Keith Packard diff --git a/doc/Xinput.xml b/doc/Xinput.xml index 87c6d7f..0a7ec8d 100644 --- a/doc/Xinput.xml +++ b/doc/Xinput.xml @@ -16,16 +16,9 @@ X server version &xserver.version; - X Consortium Standard - 1989Hewlett-Packard Company - 1990Hewlett-Packard Company - 1991Hewlett-Packard Company - - 1989X Consortium - 1990X Consortium - 1991X Consortium - X Consortium - X Version 11, Release 6.7 + 198919901991 + Hewlett-Packard Company + @@ -37,11 +30,11 @@ Hewlett-Packard makes no representations about the suitability for any purpose o document. It is provided "as is" without express or implied warranty. This document is only a draft stan- dard of the X Consortium and is therefore subject to change. + + +Copyright ?? 1989, 1990, 1991 X Consortium 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: - -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 X CONSORTIUM 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. commit 597348e969bf78dc2de4cf9bae7b76c110144266 Author: Gaetan Nadon Date: Thu Sep 29 07:53:15 2011 -0400 Xinput: replace hard coded X11 version with X server version Which is more useful. Reviewed-by: Alan Coopersmith Signed-off-by: Gaetan Nadon Signed-off-by: Keith Packard diff --git a/doc/Xinput.xml b/doc/Xinput.xml index 1ae7afe..87c6d7f 100644 --- a/doc/Xinput.xml +++ b/doc/Xinput.xml @@ -1,20 +1,21 @@ - + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"[ + %defs; +]> X11 Input Extension Porting Document - X Version 11, Release 6.7 GeorgeSachs Hewlett-Packard + X server version &xserver.version; X Consortium Standard 1989Hewlett-Packard Company 1990Hewlett-Packard Company From keithp at kemper.freedesktop.org Mon Oct 3 12:19:19 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 12:19:19 -0700 (PDT) Subject: xserver: Branch 'master' - 3 commits Message-ID: <20111003191919.251CFD8002@kemper.freedesktop.org> hw/xfree86/doc/ddxDesign.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) New commits: commit ee3e26079e120bf9914cc27871d50501b35e75df Author: Gaetan Nadon Date: Fri Sep 30 07:16:34 2011 -0400 ddxDesign: drop the url in the coporate authors list It was such an eyesore once rendered in html. Now it looks like other authors. Reviewed-by: Alan Coopersmith Signed-off-by: Gaetan Nadon Signed-off-by: Keith Packard diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml index af8f901..a4baad5 100644 --- a/hw/xfree86/doc/ddxDesign.xml +++ b/hw/xfree86/doc/ddxDesign.xml @@ -23,10 +23,8 @@ XFree86 DDX Design - - The XFree86 Project, Inc. - - The X.Org Foundation, Inc. + The XFree86 Project + The X.Org Foundation JimGettys commit 0ed71b48c0c7bd65cd05eda6c06b9c29b4e3f607 Author: Gaetan Nadon Date: Fri Sep 30 07:16:33 2011 -0400 ddxDesign: remove server version from the document title Such version information is already written in the appropriate location Reviewed-by: Peter Hutterer Signed-off-by: Gaetan Nadon Signed-off-by: Keith Packard diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml index a564716..af8f901 100644 --- a/hw/xfree86/doc/ddxDesign.xml +++ b/hw/xfree86/doc/ddxDesign.xml @@ -20,7 +20,7 @@
- XFree86 DDX Design (Xorg server version &xserver.version;) + XFree86 DDX Design commit 83ec3bf1aa72848421660c44c4503fec655f5924 Author: Gaetan Nadon Date: Fri Sep 30 07:16:32 2011 -0400 ddx-Design: add X Version and Release information Acked-by: Peter Hutterer Signed-off-by: Gaetan Nadon Signed-off-by: Keith Packard diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml index bc25c56..a564716 100644 --- a/hw/xfree86/doc/ddxDesign.xml +++ b/hw/xfree86/doc/ddxDesign.xml @@ -1,6 +1,7 @@ %xorg-defs; %defs; @@ -34,6 +35,7 @@ &xserver.reldate; + X Version 11, Release &fullrelvers; Xorg server version &xserver.version; From keithp at kemper.freedesktop.org Mon Oct 3 12:20:22 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 12:20:22 -0700 (PDT) Subject: xserver: Branch 'master' - 3 commits Message-ID: <20111003192022.E1781D8002@kemper.freedesktop.org> doc/Xserver-spec.xml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) New commits: commit 466e4b3f174bdd7a69a76eb06e6c3e3344b8adc2 Author: Gaetan Nadon Date: Fri Sep 30 07:21:57 2011 -0400 Xserver-spec: use appropriate copyright markup Use docbook copyright markup for year and holder. Reviewed-by: Peter Hutterer Signed-off-by: Gaetan Nadon Signed-off-by: Keith Packard diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml index aabd262..37fd2b2 100644 --- a/doc/Xserver-spec.xml +++ b/doc/Xserver-spec.xml @@ -44,8 +44,9 @@ The X.Org Foundation X Version 11, Release &fullrelvers; X server version &xserver.version; + 1994X Consortium, Inc. + 2004X.org Foundation, Inc. - Copyright © 1994 X Consortium, Inc., 2004 X.org Foundation, 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 X CONSORTIUM 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. commit 62940bf38f70e3d9fb80521de40d6361548a0ea5 Author: Gaetan Nadon Date: Fri Sep 30 07:21:56 2011 -0400 Xserver-spec: re-order markup to follow outpout order No content change, no layout/ordering change. It is easier to find at the top. Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Gaetan Nadon <memsize at videotron.ca> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml index 30c6127..aabd262 100644 --- a/doc/Xserver-spec.xml +++ b/doc/Xserver-spec.xml @@ -7,6 +7,8 @@ <article> <articleinfo> + <title>Definition of the Porting Layer for the X v11 Sample Server + X Porting Layer SusanAngebranndt Digital Equipment Corporation @@ -40,11 +42,16 @@ X.org Foundation and Hewlett Packard The X.Org Foundation - &xserver.reldate; X Version 11, Release &fullrelvers; X server version &xserver.version; - Definition of the Porting Layer for the X v11 Sample Server - X Porting Layer + + Copyright © 1994 X Consortium, Inc., 2004 X.org Foundation, 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 X CONSORTIUM 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. + LK201 and DEC are trademarks of Digital Equipment Corporation. Macintosh and Apple are trademarks of Apple Computer, Inc. PostScript is a trademark of Adobe Systems, Inc. Ethernet is a trademark of Xerox Corporation. X Window System is a trademark of the X.org Foundation, Inc. Cray is a trademark of Cray Research, Inc. + + &xserver.reldate; 1.0 @@ -102,13 +109,6 @@ and 1.8 CreateNewResourceType changes - - Copyright © 1994 X Consortium, Inc., 2004 X.org Foundation, 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 X CONSORTIUM 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. - LK201 and DEC are trademarks of Digital Equipment Corporation. Macintosh and Apple are trademarks of Apple Computer, Inc. PostScript is a trademark of Adobe Systems, Inc. Ethernet is a trademark of Xerox Corporation. X Window System is a trademark of the X.org Foundation, Inc. Cray is a trademark of Cray Research, Inc. - The following document explains the structure of the X Window System display server and the interfaces among the larger pieces. It is intended as a reference for programmers who are implementing an X Display Server on their workstation hardware. It is included with the X Window System source tape, along with the document "Strategies for Porting the X v11 Sample Server." The order in which you should read these documents is: commit 365bc2f5b132ac76a1f827923a99a75b33b158ac Author: Gaetan Nadon Date: Fri Sep 30 07:21:55 2011 -0400 Xserver-spec: add release information It has been added in all docs (X Version 11, Release 7.6) Reviewed-by: Peter Hutterer Signed-off-by: Gaetan Nadon Signed-off-by: Keith Packard diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml index b14e489..30c6127 100644 --- a/doc/Xserver-spec.xml +++ b/doc/Xserver-spec.xml @@ -1,6 +1,7 @@ %xorg-defs; %defs; ]> @@ -40,6 +41,7 @@ The X.Org Foundation &xserver.reldate; + X Version 11, Release &fullrelvers; X server version &xserver.version; Definition of the Porting Layer for the X v11 Sample Server X Porting Layer From keithp at kemper.freedesktop.org Mon Oct 3 13:50:15 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 13:50:15 -0700 (PDT) Subject: xserver: Branch 'master' - 9 commits Message-ID: <20111003205017.00044D8002@kemper.freedesktop.org> hw/xfree86/common/xf86Config.c | 13 ------- hw/xfree86/common/xf86Globals.c | 2 - hw/xfree86/common/xf86Privstr.h | 3 - hw/xfree86/man/xorg.conf.man | 12 ------- hw/xfree86/os-support/bsd/alpha_video.c | 2 - hw/xfree86/os-support/bsd/arm_video.c | 6 +-- hw/xfree86/os-support/bsd/bsd_bell.c | 4 -- hw/xfree86/os-support/bsd/bsd_init.c | 51 +++++------------------------- hw/xfree86/os-support/bsd/i386_video.c | 2 - hw/xfree86/os-support/bsd/ppc_video.c | 4 +- hw/xfree86/os-support/bsd/sparc64_video.c | 2 - hw/xfree86/os-support/xf86_OSlib.h | 42 ++++++------------------ hw/xfree86/parser/xf86tokens.h | 2 - 13 files changed, 28 insertions(+), 117 deletions(-) New commits: commit 6e965d8a185087a55b2100b817e18f05b3ce5a00 Merge: 466e4b3... ac5881d... Author: Keith Packard Date: Mon Oct 3 13:47:49 2011 -0700 Merge remote-tracking branch 'koba/reviewed' commit ac5881d6d0bcf4bcc66a5d6ddde4eca950db1a5b Author: Alexandr Shadchin Date: Thu Sep 15 23:05:24 2011 +0600 Remove unused vtSysreq Signed-off-by: Alexandr Shadchin Reviewed-by: Jamey Sharp Tested-by: Matthieu Herrb diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index e6c4d8f..d195399 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -670,7 +670,6 @@ typedef enum { FLAG_DISABLEVIDMODE, FLAG_ALLOWNONLOCAL, FLAG_ALLOWMOUSEOPENFAIL, - FLAG_VTSYSREQ, FLAG_SAVER_BLANKTIME, FLAG_DPMS_STANDBYTIME, FLAG_DPMS_SUSPENDTIME, @@ -711,8 +710,6 @@ static OptionInfoRec FlagOptions[] = { {0}, FALSE }, { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN, {0}, FALSE }, - { FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN, - {0}, FALSE }, { FLAG_SAVER_BLANKTIME, "BlankTime" , OPTV_INTEGER, {0}, FALSE }, { FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER, @@ -850,16 +847,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value)) xf86Info.allowMouseOpenFail = value; - if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) { -#ifdef USE_VT_SYSREQ - xf86Info.vtSysreq = value; - xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled"); -#else - if (value) - xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n"); -#endif - } - xf86Info.pmFlag = TRUE; if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value)) xf86Info.pmFlag = !value; diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index 9a42bb9..e0c3da2 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -96,7 +96,6 @@ InputInfoPtr xf86InputDevs = NULL; xf86InfoRec xf86Info = { .consoleFd = -1, .vtno = -1, - .vtSysreq = FALSE, .lastEventTime = -1, .vtRequestsPending = FALSE, #ifdef sun diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h index feab5c1..79bc8a0 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h @@ -57,7 +57,6 @@ typedef enum { typedef struct { int consoleFd; int vtno; - Bool vtSysreq; /* event handler part */ int lastEventTime; diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man index 62c491c..7f98851 100644 --- a/hw/xfree86/man/xorg.conf.man +++ b/hw/xfree86/man/xorg.conf.man @@ -560,18 +560,6 @@ drivers to not report failure if the mouse device can't be opened/initialised. It has no effect on the evdev(__drivermansuffix__) or other drivers. Default: false. .TP 7 -.BI "Option \*qVTSysReq\*q \*q" boolean \*q -enables the SYSV\-style VT switch sequence for non\-SYSV systems -which support VT switching. -This sequence is -.B Alt\-SysRq -followed by a function key -.RB ( Fn ). -This prevents the __xservername__ server trapping the -keys used for the default VT switch sequence, which means that clients can -access them. -Default: off. -.TP 7 .BI "Option \*qBlankTime\*q \*q" time \*q sets the inactivity timeout for the .B blank diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index fddde8a..1d59060 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -168,11 +168,6 @@ # define POSIX_TTY # endif /* SVR4 */ - -# if defined(sun) && defined(HAS_USL_VTS) -# define USE_VT_SYSREQ -# endif - #endif /* (SYSV || SVR4) */ /**************************************************************************/ @@ -207,7 +202,6 @@ # define LDSMAP PIO_SCRNMAP # define LDNMAP LDSMAP # define CLEARDTR_SUPPORT -# define USE_VT_SYSREQ # endif # define POSIX_TTY @@ -343,10 +337,6 @@ # define CLEARDTR_SUPPORT -# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) -# define USE_VT_SYSREQ -# endif - #endif /* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ || __bsdi__ */ diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h index abcafcf..a985606 100644 --- a/hw/xfree86/parser/xf86tokens.h +++ b/hw/xfree86/parser/xf86tokens.h @@ -207,8 +207,6 @@ typedef enum { XKBLAYOUT, XKBVARIANT, XKBOPTIONS, - /* The next two have become ServerFlags options */ - VTSYSREQ, /* Obsolete keyboard tokens */ SERVERNUM, LEFTALT, commit 0be1640dbbdd072f26d937de2e49f5ed58d54ef9 Author: Alexandr Shadchin Date: Sat Aug 27 02:02:36 2011 +0600 bsd: ioctl KDENABIO/KDDISABIO do not matter for OpenBSD Signed-off-by: Alexandr Shadchin Tested-by: Matthieu Herrb diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index f4c0302..8446179 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -291,13 +291,13 @@ acquire_vt: { FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed"); } - #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) +#if !defined(__OpenBSD__) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) { FatalError("xf86OpenConsole: KDENABIO failed (%s)", strerror(errno)); } - #endif +#endif if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed"); @@ -648,7 +648,7 @@ xf86CloseConsole() VT.mode = VT_AUTO; ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */ } -#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) +#if !defined(__OpenBSD__) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) { xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)", commit 91042b98afdc6cecc746e101a88f79e56db1c0d0 Author: Alexandr Shadchin Date: Sat Aug 27 00:47:34 2011 +0600 bsd: OpenBSD and NetBSD not need extra headers in PCVT_SUPPORT Signed-off-by: Alexandr Shadchin Tested-by: Matthieu Herrb diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index cf92821..fddde8a 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -277,20 +277,14 @@ # include # endif # endif /* SYSCONS_SUPPORT */ -# if defined(PCVT_SUPPORT) +# if defined(PCVT_SUPPORT) && !defined(__NetBSD__) && !defined(__OpenBSD__) # if !defined(SYSCONS_SUPPORT) /* no syscons, so include pcvt specific header file */ # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include # else -# if defined(__NetBSD__) || defined(__OpenBSD__) -# if !defined(WSCONS_SUPPORT) -# include -# endif /* WSCONS_SUPPORT */ -# else -# include -# endif /* __NetBSD__ */ -# endif /* __FreeBSD_kernel__ || __OpenBSD__ */ +# include +# endif /* __FreeBSD_kernel__ */ # else /* pcvt and syscons: hard-code the ID magic */ # define VGAPCVTID _IOWR('V',113, struct pcvtid) struct pcvtid { commit 86eaa9bbe4ed59f89d6509d5e13211ab7f5a8038 Author: Alexandr Shadchin Date: Sat Aug 27 01:03:28 2011 +0600 bsd: Some clean up OpenBSD and NetBSD does not support syscons Signed-off-by: Alexandr Shadchin Tested-by: Matthieu Herrb diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index 0f92ace..f4c0302 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -446,11 +446,7 @@ xf86OpenSyscons() } close(fd); -#ifndef __OpenBSD__ sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1); -#else - sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1); -#endif if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0) { FatalError("xf86OpenSyscons: Cannot open %s (%s)", diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index 24c92fb..cf92821 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -266,19 +266,15 @@ # else /* __bsdi__ */ # ifdef SYSCONS_SUPPORT # define COMPAT_SYSCONS -# if defined(__NetBSD__) || defined(__OpenBSD__) -# include +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +# if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000) +# include +# include +# else +# include +# endif /* FreeBSD 4.1 RELEASE or lator */ # else -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -# if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000) -# include -# include -# else -# include -# endif /* FreeBSD 4.1 RELEASE or lator */ -# else -# include -# endif +# include # endif # endif /* SYSCONS_SUPPORT */ # if defined(PCVT_SUPPORT) commit dc864770d47fc1e4ec993e37a59e5aecb5b0a85e Author: Alexandr Shadchin Date: Fri Aug 26 22:40:19 2011 +0600 bsd: Remove dead code Since OsInit closes stdin before the xfree86 DDX opens the console, fstat on stdin will always fail, so it's safe to delete code that attempts it. Signed-off-by: Alexandr Shadchin Reviewed-by: Jamey Sharp Tested-by: Matthieu Herrb diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index 5f5008f..0f92ace 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -210,9 +210,6 @@ xf86OpenConsole() "%s: No console driver found\n\tSupported drivers: %s\n\t%s", "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG); } -#if 0 /* stdin is already closed in OsInit() */ - fclose(stdin); -#endif xf86Info.consoleFd = fd; switch (xf86Info.consType) @@ -372,7 +369,6 @@ xf86OpenSyscons() int fd = -1; vtmode_t vtmode; char vtname[12]; - struct stat status; long syscons_version; MessageType from; @@ -425,20 +421,11 @@ xf86OpenSyscons() { /* * All VTs are in use. If initialVT was found, use it. - * Otherwise, if stdin is a VT, use that one. - * XXX stdin is already closed, so this won't work. */ if (initialVT != -1) { xf86Info.vtno = initialVT; } - else if ((fstat(0, &status) >= 0) - && S_ISCHR(status.st_mode) - && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) - { - /* stdin is a VT */ - xf86Info.vtno = minor(status.st_rdev) + 1; - } else { if (syscons_version >= 0x100) @@ -508,7 +495,6 @@ xf86OpenPcvt() int fd = -1; vtmode_t vtmode; char vtname[12], *vtprefix; - struct stat status; struct pcvtid pcvt_version; #ifndef __OpenBSD__ @@ -554,20 +540,11 @@ xf86OpenPcvt() { /* * All VTs are in use. If initialVT was found, use it. - * Otherwise, if stdin is a VT, use that one. - * XXX stdin is already closed, so this won't work. */ if (initialVT != -1) { xf86Info.vtno = initialVT; } - else if ((fstat(0, &status) >= 0) - && S_ISCHR(status.st_mode) - && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) - { - /* stdin is a VT */ - xf86Info.vtno = minor(status.st_rdev) + 1; - } else { FatalError("%s: Cannot find a free VT", commit cbb842666fa7ff26bbdd1e89a7f41b835a677c5e Author: Alexandr Shadchin Date: Fri Aug 26 21:42:41 2011 +0600 bsd: Variable devConsoleFd need only if defined PCCONS_SUPPORT Signed-off-by: Alexandr Shadchin Reviewed-by: Jamey Sharp Tested-by: Matthieu Herrb diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index f9d546f..5f5008f 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -41,7 +41,10 @@ #include static Bool KeepTty = FALSE; + +#ifdef PCCONS_SUPPORT static int devConsoleFd = -1; +#endif #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) static int VTnum = -1; static int initialVT = -1; @@ -694,8 +697,10 @@ xf86CloseConsole() } close(xf86Info.consoleFd); +#ifdef PCCONS_SUPPORT if (devConsoleFd >= 0) close(devConsoleFd); +#endif return; } commit 38bd1e123d959e0a13514ec415afc8bfb5a170f2 Author: Alexandr Shadchin Date: Fri Aug 26 18:54:01 2011 +0600 bsd: Replacement screenFd on consoleFd because they are equivalent Signed-off-by: Alexandr Shadchin Reviewed-by: Jamey Sharp Tested-by: Matthieu Herrb diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index 93533ec..9a42bb9 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -111,7 +111,6 @@ xf86InfoRec xf86Info = { .caughtSignal = FALSE, .currentScreen = NULL, #ifdef CSRG_BASED - .screenFd = -1, .consType = -1, #endif .allowMouseOpenFail = FALSE, diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h index 14cd56a..feab5c1 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h @@ -76,8 +76,6 @@ typedef struct { /* graphics part */ ScreenPtr currentScreen; #if defined(CSRG_BASED) || defined(__FreeBSD_kernel__) - int screenFd; /* fd for memory mapped access to - * vga card */ int consType; /* Which console driver? */ #endif diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c index bb3a5cb..15eb2a4 100644 --- a/hw/xfree86/os-support/bsd/alpha_video.c +++ b/hw/xfree86/os-support/bsd/alpha_video.c @@ -340,7 +340,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) base = mmap(0, Size, (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, + MAP_FLAGS, xf86Info.consoleFd, (unsigned long)Base + BUS_BASE); if (base == MAP_FAILED) { diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c index 482d53f..eb631a7 100644 --- a/hw/xfree86/os-support/bsd/arm_video.c +++ b/hw/xfree86/os-support/bsd/arm_video.c @@ -213,7 +213,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) base = mmap(0, Size, (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, + MAP_FLAGS, xf86Info.consoleFd, (unsigned long)Base - 0xA0000); if (base == MAP_FAILED) { @@ -306,7 +306,7 @@ checkMapInfo(Bool warn, int Region) if(!memAccP->Checked) { - if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1) + if(ioctl(xf86Info.consoleFd, memAccP->ioctl, &(memAccP->memInfo)) == -1) { if(warn) { @@ -360,7 +360,7 @@ xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size) Size, PROT_READ | PROT_WRITE, MAP_SHARED, - xf86Info.screenFd, + xf86Info.consoleFd, (unsigned long)mapInfoP->u.map_info_mmap.map_offset)) == (pointer)-1) { diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index 837a2f4..f9d546f 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -211,7 +211,6 @@ xf86OpenConsole() fclose(stdin); #endif xf86Info.consoleFd = fd; - xf86Info.screenFd = fd; switch (xf86Info.consType) { @@ -688,22 +687,12 @@ xf86CloseConsole() case WSCONS: { int mode = WSDISPLAYIO_MODE_EMUL; - ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode); + ioctl(xf86Info.consoleFd, WSDISPLAYIO_SMODE, &mode); break; } #endif } - if (xf86Info.screenFd != xf86Info.consoleFd) - { - close(xf86Info.screenFd); - close(xf86Info.consoleFd); - if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0) - { - xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)", - strerror(errno)); - } - } close(xf86Info.consoleFd); if (devConsoleFd >= 0) close(devConsoleFd); diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index 7aef079..525bfb6 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -258,7 +258,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) base = mmap(0, Size, (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, + MAP_FLAGS, xf86Info.consoleFd, (unsigned long)Base - 0xA0000 ); if (base == MAP_FAILED) diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c index 7e3fcdb..aeaf183 100644 --- a/hw/xfree86/os-support/bsd/ppc_video.c +++ b/hw/xfree86/os-support/bsd/ppc_video.c @@ -73,7 +73,7 @@ volatile unsigned char *ioBase = MAP_FAILED; static pointer ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { - int fd = xf86Info.screenFd; + int fd = xf86Info.consoleFd; pointer base; #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", @@ -125,7 +125,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, Bool xf86EnableIO() { - int fd = xf86Info.screenFd; + int fd = xf86Info.consoleFd; xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd); if (ioBase == MAP_FAILED) diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c index c838792..a2a30c9 100644 --- a/hw/xfree86/os-support/bsd/sparc64_video.c +++ b/hw/xfree86/os-support/bsd/sparc64_video.c @@ -58,7 +58,7 @@ static pointer sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { - int fd = xf86Info.screenFd; + int fd = xf86Info.consoleFd; pointer base; #ifdef DEBUG commit f015351c73bb24ce4172911c3e95d67922de42ab Author: Alexandr Shadchin Date: Fri Aug 26 18:27:02 2011 +0600 bsd: Remove unused macros KBD_FD Signed-off-by: Alexandr Shadchin Reviewed-by: Jamey Sharp Reviewed-by: Jeremy Huddleston Tested-by: Matthieu Herrb diff --git a/hw/xfree86/os-support/bsd/bsd_bell.c b/hw/xfree86/os-support/bsd/bsd_bell.c index 55eb752..fb457db 100644 --- a/hw/xfree86/os-support/bsd/bsd_bell.c +++ b/hw/xfree86/os-support/bsd/bsd_bell.c @@ -37,10 +37,6 @@ #include "xf86Priv.h" #include "xf86_OSlib.h" -#ifdef WSCONS_SUPPORT -#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd) -#endif - void xf86OSRingBell(int loudness, int pitch, int duration) { From keithp at kemper.freedesktop.org Mon Oct 3 13:58:31 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 3 Oct 2011 13:58:31 -0700 (PDT) Subject: xserver: Branch 'master' - 3 commits Message-ID: <20111003205831.4D2E5D8002@kemper.freedesktop.org> config/Makefile.am | 6 config/config-backends.h | 5 config/config.c | 5 config/wscons.c | 268 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 16 ++ hw/xfree86/Makefile.am | 2 hw/xfree86/common/xf86Config.c | 6 hw/xfree86/common/xf86Globals.c | 2 hw/xfree86/common/xf86Xinput.c | 3 9 files changed, 308 insertions(+), 5 deletions(-) New commits: commit 6378d0233d21088b6429755627b4253859892c72 Merge: 6e965d8... 98b2306... Author: Keith Packard Date: Mon Oct 3 13:56:06 2011 -0700 Merge remote-tracking branch 'herrb/master' commit 98b230669f591bf5b8b8764db3b287d91857ee9e Author: Matthieu Herrb Date: Sun Jul 31 20:43:39 2011 +0200 sdksyms.sh may not be executable. Use $(SHELL) to run it. Someone may want to build out of a source tree in a filesystem with the noexec mount flag set. Signed-off-by: Matthieu Herrb Reviewed-by: Gaetan Nadon Reviewed-by: Alan Coopersmith diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index e3ef14f..4f08772 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -111,7 +111,7 @@ CLEANFILES = sdksyms.c sdksyms.dep EXTRA_DIST += sdksyms.sh sdksyms.dep sdksyms.c: sdksyms.sh - CPP='$(CPP)' AWK='$(AWK)' $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(INCLUDES) + CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(INCLUDES) SDKSYMS_DEP = sdksyms.dep include $(SDKSYMS_DEP) commit f54852edc35a2831a4cd91906188101ea19904e1 Author: Matthieu Herrb Date: Sun Sep 18 12:46:52 2011 +0200 Add a 'wscons' autoconf mechanism to configure input devices on BSD. This does not really handle hotplug (it's handled inside the kernel, by the 'mux' devices), but uses the wscons console driver configuration to figure out the keyboard layout and the list of pointing devices found by the kernel. Signed-off-by: Matthieu Herrb Acked-by: Peter Hutterer diff --git a/config/Makefile.am b/config/Makefile.am index 4a2e873..69bdcf7 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -34,6 +34,12 @@ libconfig_la_SOURCES += hal.c libconfig_la_LIBADD += $(HAL_LIBS) endif +else + +if CONFIG_WSCONS +libconfig_la_SOURCES += wscons.c +endif # CONFIG_WSCONS + endif # CONFIG_NEED_DBUS endif # !CONFIG_UDEV diff --git a/config/config-backends.h b/config/config-backends.h index 35ab8a0..10743c3 100644 --- a/config/config-backends.h +++ b/config/config-backends.h @@ -68,3 +68,8 @@ int config_hal_init(void); void config_hal_fini(void); # endif #endif + +#ifdef CONFIG_WSCONS +int config_wscons_init(void); +void config_wscons_fini(void); +#endif diff --git a/config/config.c b/config/config.c index 9c28785..0dae3ad 100644 --- a/config/config.c +++ b/config/config.c @@ -52,6 +52,9 @@ config_init(void) else { ErrorF("[config] failed to initialise D-Bus core\n"); } +#elif defined(CONFIG_WSCONS) + if (!config_wscons_init()) + ErrorF("[config] failed to initialise wscons\n"); #endif } @@ -68,6 +71,8 @@ config_fini(void) config_dbus_fini(); # endif config_dbus_core_fini(); +#elif defined(CONFIG_WSCONS) + config_wscons_fini(); #endif } diff --git a/config/wscons.c b/config/wscons.c new file mode 100644 index 0000000..27c1f63 --- /dev/null +++ b/config/wscons.c @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2011 Matthieu Herrb + * + * 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 (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 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. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include + +#include "input.h" +#include "inputstr.h" +#include "os.h" +#include "config-backends.h" + +#define WSCONS_KBD_DEVICE "/dev/wskbd" +#define WSCONS_MOUSE_PREFIX "/dev/wsmouse" + +#define KB_OVRENC \ + { KB_UK, "gb" }, \ + { KB_SV, "se" }, \ + { KB_SG, "ch" }, \ + { KB_SF, "ch" }, \ + { KB_LA, "latam" }, \ + { KB_CF, "ca" } + +struct nameint { + int val; + char *name; +} kbdenc[] = { KB_OVRENC, KB_ENCTAB, { 0 } }; + +struct nameint kbdvar[] = { + { KB_NODEAD | KB_SG, "de_nodeadkeys" }, + { KB_NODEAD | KB_SF, "fr_nodeadkeys" }, + { KB_SF, "fr" }, + { KB_DVORAK | KB_CF, "fr-dvorak" }, + { KB_DVORAK | KB_FR, "bepo" }, + { KB_DVORAK, "dvorak" }, + { KB_CF, "fr-legacy" }, + { KB_NODEAD, "nodeadkeys" }, + { 0 } +}; + +struct nameint kbdopt[] = { + { KB_SWAPCTRLCAPS, "ctrl:swapcaps" }, + { 0 } +}; + +struct nameint kbdmodel[] = { + { WSKBD_TYPE_ZAURUS, "zaurus" }, + { 0 } +}; + +static void +wscons_add_keyboard(void) +{ + InputAttributes attrs = {}; + DeviceIntPtr dev = NULL; + InputOption *input_options = NULL; + char *config_info = NULL; + int fd, i, rc; + unsigned int type; + kbd_t wsenc = 0; + + /* Find keyboard configuration */ + fd = open(WSCONS_KBD_DEVICE, O_RDWR | O_NONBLOCK | O_EXCL); + if (fd == -1) { + LogMessage(X_ERROR, "wskbd: open %s: %s\n", + WSCONS_KBD_DEVICE, strerror(errno)); + return; + } + if (ioctl(fd, WSKBDIO_GETENCODING, &wsenc) == -1) { + LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GETENCODING) " + "failed: %s\n", strerror(errno)); + close(fd); + return; + } + if (ioctl(fd, WSKBDIO_GTYPE, &type) == -1) { + LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GTYPE) " + "failed: %s\n", strerror(errno)); + close(fd); + return; + } + close (fd); + + input_options = input_option_new(input_options, "_source", + "server/wscons"); + if (input_options == NULL) + return; + + LogMessage(X_INFO, "config/wscons: checking input device %s\n", + WSCONS_KBD_DEVICE); + input_options = input_option_new(input_options, "name", + WSCONS_KBD_DEVICE); + input_options = input_option_new(input_options, "driver", "kbd"); + + config_info = Xprintf("wscons:%s", WSCONS_KBD_DEVICE); + if (!config_info) + goto unwind; + if (KB_ENCODING(wsenc) == KB_USER) { + /* Ignore wscons "user" layout */ + LogMessageVerb(X_INFO, 3, "wskbd: ignoring \"user\" layout\n"); + goto kbd_config_done; + } + for (i = 0; kbdenc[i].val; i++) + if(KB_ENCODING(wsenc) == kbdenc[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using layout %s\n", + kbdenc[i].name); + input_options = input_option_new(input_options, + "xkb_layout", kbdenc[i].name); + break; + } + for (i = 0; kbdvar[i].val; i++) + if (wsenc == kbdvar[i].val || + KB_VARIANT(wsenc) == kbdvar[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using variant %s\n", + kbdvar[i].name); + input_options = input_option_new(input_options, + "xkb_variant", kbdvar[i].name); + break; + } + for (i = 0; kbdopt[i].val; i++) + if (KB_VARIANT(wsenc) == kbdopt[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using option %s\n", + kbdopt[i].name); + input_options = input_option_new(input_options, + "xkb_options", kbdopt[i].name); + break; + } + for (i = 0; kbdmodel[i].val; i++) + if (type == kbdmodel[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using model %s\n", + kbdmodel[i].name); + input_options = input_option_new(input_options, + "xkb_model", kbdmodel[i].name); + break; + } + +kbd_config_done: + attrs.flags |= ATTR_KEYBOARD; + rc = NewInputDeviceRequest(input_options, &attrs, &dev); + if (rc != Success) + goto unwind; + + for (; dev; dev = dev->next) { + free(dev->config_info); + dev->config_info = strdup(config_info); + } +unwind: + input_option_free_list(&input_options); +} + +static void +wscons_add_pointer(const char *path, const char *driver, int flags) +{ + InputAttributes attrs = {}; + DeviceIntPtr dev = NULL; + InputOption *input_options = NULL; + char *config_info = NULL; + int rc; + + config_info = Xprintf("wscons:%s", path); + if (!config_info) + return; + + input_options = input_option_new(input_options, "_source", + "server/wscons"); + if (input_options == NULL) + return; + + input_options = input_option_new(input_options, "name", + strdup(path)); + input_options = input_option_new(input_options, "driver", + strdup(driver)); + input_options = input_option_new(input_options, "device", + strdup(path)); + LogMessage(X_INFO, "config/wscons: checking input device %s\n", path); + attrs.flags |= flags; + rc = NewInputDeviceRequest(input_options, &attrs, &dev); + if (rc != Success) + goto unwind; + + for (; dev; dev = dev->next) { + free(dev->config_info); + dev->config_info = strdup(config_info); + } +unwind: + input_option_free_list(&input_options); +} + +static void +wscons_add_pointers(void) +{ + char devname[256]; + int fd, i, wsmouse_type; + + /* Check pointing devices */ + for (i = 0; i < 4; i++) { + snprintf(devname, sizeof(devname), "%s%d", + WSCONS_MOUSE_PREFIX, i); + LogMessageVerb(X_INFO, 10, "wsmouse: checking %s\n", devname); + fd = open_device(devnamem O_RDWR | O_NONBLOCK | O_EXCL); + if (fd == -1) { + LogMessageVerb(X_WARNING, 10, "%s: %s\n", devname, + strerror(errno)); + continue; + } + if (ioctl(fd, WSMOUSEIO_GTYPE, &wsmouse_type) != 0) { + LogMessageVerb(X_WARNING, 10, + "%s: WSMOUSEIO_GTYPE failed\n", devname); + close(fd); + continue; + } + close(fd); + switch (wsmouse_type) { + case WSMOUSE_TYPE_SYNAPTICS: + wscons_add_pointer(devname, "synaptics", + ATTR_TOUCHPAD); + break; + case WSMOUSE_TYPE_TPANEL: + wscons_add_pointer(devname, "ws", ATTR_TOUCHSCREEN); + break; + default: + break; + } + } + /* Add a default entry catching all other mux elements as "mouse" */ + wscons_add_pointer(WSCONS_MOUSE_PREFIX, "mouse", ATTR_POINTER); +} + +int +config_wscons_init(void) +{ + wscons_add_keyboard(); + wscons_add_pointers(); + return 1; +} + +void +config_wscons_fini(void) +{ + /* Not much to do ? */ +} diff --git a/configure.ac b/configure.ac index b0d2643..ac5e887 100644 --- a/configure.ac +++ b/configure.ac @@ -629,6 +629,7 @@ AC_ARG_ENABLE(dpms, AS_HELP_STRING([--disable-dpms], [Build DPMS exten AC_ARG_ENABLE(config-udev, AS_HELP_STRING([--enable-config-udev], [Build udev support (default: auto)]), [CONFIG_UDEV=$enableval], [CONFIG_UDEV=auto]) AC_ARG_ENABLE(config-dbus, AS_HELP_STRING([--enable-config-dbus], [Build D-BUS API support (default: no)]), [CONFIG_DBUS_API=$enableval], [CONFIG_DBUS_API=no]) AC_ARG_ENABLE(config-hal, AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto]) +AC_ARG_ENABLE(config-wscons, AS_HELP_STRING([--enable-config-wscons], [Build wscons config support (default: auto)]), [CONFIG_WSCONS=$enableval], [CONFIG_WSCONS=auto]) AC_ARG_ENABLE(xfree86-utils, AS_HELP_STRING([--enable-xfree86-utils], [Build xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes]) AC_ARG_ENABLE(xaa, AS_HELP_STRING([--enable-xaa], [Build XAA (default: enabled)]), [XAA=$enableval], [XAA=yes]) AC_ARG_ENABLE(vgahw, AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), [VGAHW=$enableval], [VGAHW=yes]) @@ -865,6 +866,21 @@ if test "x$CONFIG_NEED_DBUS" = xyes; then fi AM_CONDITIONAL(CONFIG_NEED_DBUS, [test "x$CONFIG_NEED_DBUS" = xyes]) +if test "x$CONFIG_WSCONS" = xauto; then + case $host_os in + *openbsd*) + CONFIG_WSCONS=yes; + ;; + *) + CONFIG_WSCONS=no; + ;; + esac +fi +AM_CONDITIONAL(CONFIG_WSCONS, [test "x$CONFIG_WSCONS" = xyes]) +if test "x$CONFIG_WSCONS" = xyes; then + AC_DEFINE(CONFIG_WSCONS, 1, [Use wscons for input auto configuration]) +fi + if test "x$USE_SIGIO_BY_DEFAULT" = xyes; then USE_SIGIO_BY_DEFAULT_VALUE=TRUE else diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index e6c4d8f..01b4efa 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1331,12 +1331,14 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) } if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) { -#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) +#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) const char *config_backend; #if defined(CONFIG_HAL) config_backend = "HAL"; -#else +#elif defined(CONFIG_UDEV) config_backend = "udev"; +#else + config_backend = "wscons"; #endif xf86Msg(X_INFO, "The server relies on %s to provide the list of " "input devices.\n\tIf no devices become available, " diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index 93533ec..5370e4c 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -125,7 +125,7 @@ xf86InfoRec xf86Info = { .log = LogNone, .disableRandR = FALSE, .randRFrom = X_DEFAULT, -#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) +#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) .forceInputDevices = FALSE, .autoAddDevices = TRUE, .autoEnableDevices = TRUE diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 9fbcba9..41c9340 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -936,7 +936,8 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, if (strcmp(input_option_get_key(option), "_source") == 0 && (strcmp(input_option_get_value(option), "server/hal") == 0 || - strcmp(input_option_get_value(option), "server/udev") == 0)) { + strcmp(input_option_get_value(option), "server/udev") == 0 || + strcmp(input_option_get_value(option), "server/wscons") == 0)) { is_auto = 1; if (!xf86Info.autoAddDevices) { rval = BadMatch; From marcoz at kemper.freedesktop.org Mon Oct 3 17:13:01 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Mon, 3 Oct 2011 17:13:01 -0700 (PDT) Subject: kbproto: Changes to 'master' Message-ID: <20111004001301.2E92BD8002@kemper.freedesktop.org> specs/appA.xml | 26 ++++----- specs/appB.xml | 10 +-- specs/appC.xml | 12 ++-- specs/appD.xml | 14 ++--- specs/ch01.xml | 4 - specs/ch02.xml | 24 ++++----- specs/ch03.xml | 10 +-- specs/ch04.xml | 64 ++++++++++++------------ specs/ch05.xml | 14 ++--- specs/ch06.xml | 28 +++++----- specs/ch07.xml | 32 ++++++------ specs/ch08.xml | 6 +- specs/ch09.xml | 18 +++--- specs/ch10.xml | 14 ++--- specs/ch11.xml | 14 ++--- specs/ch12.xml | 54 ++++++++++---------- specs/ch13.xml | 24 ++++----- specs/ch14.xml | 4 - specs/ch15.xml | 12 ++-- specs/ch16.xml | 150 ++++++++++++++++++++++++++++----------------------------- 20 files changed, 267 insertions(+), 267 deletions(-) New commits: commit cb49f95af605bd5019e194eeb656d8789d57756a Author: Matt Dew Date: Mon Oct 3 18:06:16 2011 -0600 1 - fix the capitolization of the ID attriutes to match either the or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From marcoz at kemper.freedesktop.org Mon Oct 3 17:34:24 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Mon, 3 Oct 2011 17:34:24 -0700 (PDT) Subject: x11proto: Changes to 'master' Message-ID: <20111004003424.A3D4CD8002@kemper.freedesktop.org> specs/encoding.xml | 30 +++++++++++++++--------------- specs/keysyms.xml | 16 ++++++++-------- specs/sect1-9.xml | 52 ++++++++++++++++++++++++++-------------------------- 3 files changed, 49 insertions(+), 49 deletions(-) New commits: commit 3d7be5c61b991a3b33526546acda2ab663cdc1d5 Author: Matt Dew <marcoz at osource.org> Date: Mon Oct 3 18:26:22 2011 -0600 1 - fix the capitolization of the ID attriutes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From marcoz at kemper.freedesktop.org Mon Oct 3 19:28:20 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Mon, 3 Oct 2011 19:28:20 -0700 (PDT) Subject: libXfont: Changes to 'master' Message-ID: <20111004022820.580DFD8002@kemper.freedesktop.org> doc/fontlib.xml | 96 +++++++++++++++----------------------------------------- 1 file changed, 27 insertions(+), 69 deletions(-) New commits: commit bb97dbf56dff50bef936c0631587ed08dd6c8fa9 Author: Matt Dew <marcoz at osource.org> Date: Mon Oct 3 20:23:47 2011 -0600 1 - fix the capitalization of the ID attriutes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From alanc at kemper.freedesktop.org Mon Oct 3 21:04:34 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Mon, 3 Oct 2011 21:04:34 -0700 (PDT) Subject: xf86-input-keyboard: Changes to 'master' Message-ID: <20111004040434.C2ADCD8002@kemper.freedesktop.org> man/kbd.man | 5 +++++ 1 file changed, 5 insertions(+) New commits: commit 45f9f4552c4dab2efc29fd4d3d5c1a9dcd7c34b3 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 4 09:16:17 2011 +1000 man: link to xkeyboard-config(7) (#14494) X.Org Bug 14494 <http://bugs.freedesktop.org/show_bug.cgi?id=14494> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Gaetan Nadon <memsize at videotron.ca> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From marcoz at kemper.freedesktop.org Mon Oct 3 21:06:29 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Mon, 3 Oct 2011 21:06:29 -0700 (PDT) Subject: libXi: Changes to 'master' Message-ID: <20111004040629.88364D8002@kemper.freedesktop.org> specs/encoding.xml | 2 specs/library.xml | 446 ++++++++++++++++++++++++++--------------------------- 2 files changed, 224 insertions(+), 224 deletions(-) New commits: commit e97c3dd00369b47af067e30e910335b199a2f147 Author: Matt Dew <marcoz at osource.org> Date: Mon Oct 3 22:05:51 2011 -0600 1 - fix the capitalization of the ID attriutes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From ickle at kemper.freedesktop.org Tue Oct 4 11:37:35 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Tue, 4 Oct 2011 11:37:35 -0700 (PDT) Subject: xf86-video-intel: 4 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_reg.h Message-ID: <20111004183735.78921D8002@kemper.freedesktop.org> src/sna/gen2_render.c | 2 src/sna/gen3_render.c | 2 src/sna/kgem.h | 2 src/sna/sna_accel.c | 248 +++++++++++++++++++++++++++++++++++++++++++++++--- src/sna/sna_reg.h | 3 5 files changed, 243 insertions(+), 14 deletions(-) New commits: commit c5414ec992d935e10156a2b513d5ec2dded2f689 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 2 12:02:41 2011 +0100 sna: Use BLT operations to avoid fallbacks in core glyph rendering Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 5a94fbd..1edd3a3 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -30,6 +30,7 @@ #endif #include "sna.h" +#include "sna_reg.h" #include <X11/fonts/font.h> #include <X11/fonts/fontstruct.h> @@ -1689,9 +1690,13 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect); static bool can_fill_spans(DrawablePtr drawable, GCPtr gc) { + DBG(("%s: is-solid-mask? %d\n", __FUNCTION__, + PM_IS_SOLID(drawable, gc->planemask))); if (!PM_IS_SOLID(drawable, gc->planemask)) return false; + DBG(("%s: non-stipple fill? %d\n", __FUNCTION__, + gc->fillStyle != FillStippled)); return gc->fillStyle == FillSolid || gc->fillStyle == FillTiled; } @@ -3045,11 +3050,198 @@ fallback: fbPolyFillRect(draw, gc, n, rect); } +static uint8_t byte_reverse(uint8_t b) +{ + return ((b * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32; +} + +static uint8_t blt_depth(int depth) +{ + switch (depth) { + case 8: return 0; + case 15: return 0x2; + case 16: return 0x1; + default: return 0x3; + } +} + +static bool +sna_glyph_blt(DrawablePtr drawable, GCPtr gc, + int x, int y, unsigned int n, + CharInfoPtr *info, pointer base, + bool transparent, + const BoxRec *extents) +{ + struct sna *sna = to_sna_from_drawable(drawable); + PixmapPtr pixmap = get_drawable_pixmap(drawable); + struct sna_pixmap *priv = sna_pixmap(pixmap); + struct sna_damage **damage; + uint32_t *b; + int16_t dx, dy; + + /* XXX sna_blt! */ + static const uint8_t ROP[] = { + ROP_0, /* GXclear */ + ROP_DSa, /* GXand */ + ROP_SDna, /* GXandReverse */ + ROP_S, /* GXcopy */ + ROP_DSna, /* GXandInverted */ + ROP_D, /* GXnoop */ + ROP_DSx, /* GXxor */ + ROP_DSo, /* GXor */ + ROP_DSon, /* GXnor */ + ROP_DSxn, /* GXequiv */ + ROP_Dn, /* GXinvert */ + ROP_SDno, /* GXorReverse */ + ROP_Sn, /* GXcopyInverted */ + ROP_DSno, /* GXorInverted */ + ROP_DSan, /* GXnand */ + ROP_1 /* GXset */ + }; + uint8_t rop = transparent ? ROP[gc->alu] : ROP_S; + RegionRec clip; + + if (priv->gpu_bo->tiling == I915_TILING_Y) + return false; + + RegionInit(&clip, (BoxPtr)extents, 1); + if (gc->pCompositeClip && gc->pCompositeClip->data) + RegionIntersect(&clip, &clip, gc->pCompositeClip); + + /* XXX loop over clips using SETUP_CLIP? */ + if (REGION_NUM_RECTS(&clip) != 1) { + RegionUninit(&clip); + return false; + } + + damage = priv->gpu_only ? NULL : + reduce_damage(drawable, &priv->gpu_damage, extents), + + get_drawable_deltas(drawable, pixmap, &dx, &dy); + x += drawable->x + dx; + y += drawable->y + dy; + + kgem_set_mode(&sna->kgem, KGEM_BLT); + if (!kgem_check_batch(&sna->kgem, 16) || + !kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) { + _kgem_submit(&sna->kgem); + _kgem_set_mode(&sna->kgem, KGEM_BLT); + } + b = sna->kgem.batch + sna->kgem.nbatch; + b[0] = XY_SETUP_BLT | 1 << 20; + b[1] = priv->gpu_bo->pitch; + if (sna->kgem.gen >= 40) { + if (priv->gpu_bo->tiling) + b[0] |= 1 << 11; + b[1] >>= 2; + } + b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16; + b[2] = (dy + clip.extents.y1) << 16 | (dx + clip.extents.x1); + b[3] = (dy + clip.extents.y2) << 16 | (dx + clip.extents.x2); + b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4, + priv->gpu_bo, + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = gc->bgPixel; + b[6] = gc->fgPixel; + b[7] = 0; + sna->kgem.nbatch += 8; + + while (n--) { + CharInfoPtr c = *info++; + uint8_t *glyph = FONTGLYPHBITS(base, c); + int w = GLYPHWIDTHPIXELS(c); + int h = GLYPHHEIGHTPIXELS(c); + int stride = GLYPHWIDTHBYTESPADDED(c); + int w8 = (w + 7) >> 3; + int x1, y1, len, i; + uint8_t *byte; + + if (w == 0 || h == 0) + goto skip; + + len = (w8 * h + 7) >> 3 << 1; + DBG(("%s glyph: (%d, %d) x (%d[%d], %d), len=%d\n" ,__FUNCTION__, + x,y, w, w8, h, len)); + + x1 = x + c->metrics.leftSideBearing; + y1 = y - c->metrics.ascent; + + if (!kgem_check_batch(&sna->kgem, 3+len)) { + _kgem_submit(&sna->kgem); + _kgem_set_mode(&sna->kgem, KGEM_BLT); + + b = sna->kgem.batch + sna->kgem.nbatch; + b[0] = XY_SETUP_BLT | 1 << 20; + b[1] = priv->gpu_bo->pitch; + if (sna->kgem.gen >= 40) { + if (priv->gpu_bo->tiling) + b[0] |= 1 << 11; + b[1] >>= 2; + } + b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16; + b[2] = (dy + clip.extents.y1) << 16 | (dx + clip.extents.x1); + b[3] = (dy + clip.extents.y2) << 16 | (dx + clip.extents.x2); + b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4, + priv->gpu_bo, + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = gc->bgPixel; + b[6] = gc->fgPixel; + b[7] = 0; + sna->kgem.nbatch += 8; + } + + b = sna->kgem.batch + sna->kgem.nbatch; + b[0] = XY_TEXT_IMMEDIATE_BLT | (1 + len); + if (priv->gpu_bo->tiling && sna->kgem.gen >= 40) + b[0] |= 1 << 11; + b[1] = (uint16_t)y1 << 16 | (uint16_t)x1; + b[2] = (uint16_t)(y1+h) << 16 | (uint16_t)(x1+w); + + byte = (uint8_t *)&b[3]; + stride -= w8; + do { + i = w8; + do { + *byte++ = byte_reverse(*glyph++); + } while (--i); + glyph += stride; + } while (--h); + while ((byte - (uint8_t *)&b[3]) & 7) + *byte++ = 0; + sna->kgem.nbatch += 3 + len; + assert((uint32_t *)byte == sna->kgem.batch + sna->kgem.nbatch); + + if (damage) { + BoxRec r; + + r.x1 = x1; + r.y1 = y1; + r.x2 = x1 + w; + r.y2 = y1 + h; + if (box_intersect(&r, extents)) + sna_damage_add_box(damage, &r); + } +skip: + x += c->metrics.characterWidth; + } + + RegionUninit(&clip); + sna->blt_state.fill_bo = 0; + return true; +} + static void sna_image_glyph(DrawablePtr drawable, GCPtr gc, int x, int y, unsigned int n, CharInfoPtr *info, pointer base) { + struct sna *sna = to_sna_from_drawable(drawable); ExtentInfoRec extents; BoxRec box; RegionRec region; @@ -3058,15 +3250,11 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, return; QueryGlyphExtents(gc->font, info, n, &extents); - if (extents.overallWidth >= 0) { - box.x1 = x; - box.x2 = x + extents.overallWidth; - } else { - box.x2 = x; - box.x1 = x + extents.overallWidth; - } - box.y1 = y - FONTASCENT(gc->font); - box.y2 = y + FONTDESCENT(gc->font); + box.x1 = x + extents.overallLeft; + box.y1 = y - extents.overallAscent; + box.x2 = x + extents.overallRight; + box.y2 = y + extents.overallDescent; + trim_box(&box, drawable); if (box_empty(&box)) return; @@ -3075,6 +3263,19 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); + if (FORCE_FALLBACK) + goto fallback; + + if (sna->kgem.wedged) { + DBG(("%s: fallback -- wedged\n", __FUNCTION__)); + goto fallback; + } + + if (sna_drawable_use_gpu_bo(drawable, &box) && + sna_glyph_blt(drawable, gc, x, y, n, info, base, false, &box)) + return; + +fallback: RegionInit(®ion, &box, 1); if (gc->pCompositeClip) RegionIntersect(®ion, ®ion, gc->pCompositeClip); @@ -3085,6 +3286,7 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, sna_drawable_move_region_to_cpu(drawable, ®ion, true); RegionUninit(®ion); + DBG(("%s: fallback -- fbImageGlyphBlt\n", __FUNCTION__)); fbImageGlyphBlt(drawable, gc, x, y, n, info, base); } @@ -3093,6 +3295,7 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, int x, int y, unsigned int n, CharInfoPtr *info, pointer base) { + struct sna *sna = to_sna_from_drawable(drawable); ExtentInfoRec extents; BoxRec box; RegionRec region; @@ -3114,6 +3317,20 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); + if (FORCE_FALLBACK) + goto fallback; + + if (sna->kgem.wedged) { + DBG(("%s: fallback -- wedged\n", __FUNCTION__)); + goto fallback; + } + + if (sna_drawable_use_gpu_bo(drawable, &box) && + sna_glyph_blt(drawable, gc, x, y, n, info, base, true, &box)) + + return; + +fallback: RegionInit(®ion, &box, 1); if (gc->pCompositeClip) RegionIntersect(®ion, ®ion, gc->pCompositeClip); @@ -3124,6 +3341,7 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, sna_drawable_move_region_to_cpu(drawable, ®ion, true); RegionUninit(®ion); + DBG(("%s: fallback -- fbPolyGlyphBlt\n", __FUNCTION__)); fbPolyGlyphBlt(drawable, gc, x, y, n, info, base); } diff --git a/src/sna/sna_reg.h b/src/sna/sna_reg.h index f16c64d..8ca9089 100644 --- a/src/sna/sna_reg.h +++ b/src/sna/sna_reg.h @@ -78,10 +78,11 @@ #define COLOR_BLT_CMD ((2<<29)|(0x40<<22)|(0x3)) #define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|(0x4)) -#define XY_SETUP_BLT_CMD ((2<<29)|(1<<22)|6) +#define XY_SETUP_BLT ((2<<29)|(1<<22)|6) #define XY_SETUP_MONO_PATTERN_SL_BLT ((2<<29)|(0x11<<22)|7) #define XY_SETUP_CLIP_BLT_CMD ((2<<29)|(3<<22)|1) #define XY_SCANLINE_BLT ((2<<29)|(0x25<<22)|1) +#define XY_TEXT_IMMEDIATE_BLT ((2<<29)|(0x31<<22)|(1<<16)) #define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6) #define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|0x4) #define XY_PAT_BLT_IMMEDIATE ((2<<29)|(0x72<<22)) commit 6b62b9d7c4301457a024f840383fb4515704ebdb Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 4 19:30:06 2011 +0100 sna: Increase reserved space in batch to accommodate gen5 workaround Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.h b/src/sna/kgem.h index af6203c..49ca3d7 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -120,7 +120,7 @@ struct kgem { struct drm_i915_gem_relocation_entry reloc[384]; }; -#define KGEM_BATCH_RESERVED 2 +#define KGEM_BATCH_RESERVED 4 /* need a bit of extra room for workarounds */ #define KGEM_RELOC_RESERVED 4 #define KGEM_EXEC_RESERVED 1 commit 6351d8eb823dbfffb4792af8592d1ce565211e23 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 4 19:29:46 2011 +0100 sna/gen[23]: Fix compilation with debugging enabled Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 43aaef0..935dffe 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -2072,7 +2072,7 @@ gen2_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, gen2_emit_fill_state(sna, &tmp); gen2_get_rectangles(sna, &tmp, 1); - DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, pixel)); + DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, color)); OUT_VERTEX(x2); OUT_VERTEX(y2); OUT_VERTEX(x1); diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 65176ed..57c57b9 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3731,7 +3731,7 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, gen3_emit_composite_state(sna, &tmp); gen3_align_vertex(sna, &tmp); gen3_get_rectangles(sna, &tmp, 1); - DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, pixel)); + DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, color)); OUT_VERTEX(x2); OUT_VERTEX(y2); OUT_VERTEX(x1); commit 1ec6a0e27753027a68beeaff0276ae65c658d468 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 3 16:14:18 2011 +0100 sna: Move the source to the GPU if it is reused We attempt to skip upload a source pixmap to the GPU in the event it is used only once (for example during image upload by firefox). However, if we continue to use the CPU source pixmap then it obviously was worth uploading to the GPU. So if we use the CPU pixmap a second time, do the upload and then blit. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index a6e639b..5a94fbd 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1142,6 +1142,15 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth, RegionUninit(®ion); } +static Bool +move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv, const BoxRec *box) +{ + int w = box->x2 - box->x1; + int h = box->y2 - box->y1; + + return ++priv->source_count * w*h >= 2 * pixmap->drawable.width * pixmap->drawable.height; +} + static void sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, BoxPtr box, int n, @@ -1233,7 +1242,8 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, goto fallback; } - if (src_priv && src_priv->gpu_bo && + if (src_priv && + move_to_gpu(src_pixmap, src_priv, ®ion.extents) && sna_pixmap_move_to_gpu(src_pixmap)) { if (!sna->render.copy_boxes(sna, alu, src_pixmap, src_priv->gpu_bo, src_dx, src_dy, From cloos at kemper.freedesktop.org Tue Oct 4 14:20:00 2011 From: cloos at kemper.freedesktop.org (James Cloos) Date: Tue, 4 Oct 2011 14:20:00 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111004212000.43371D8002@kemper.freedesktop.org> nls/iso8859-1/Compose.pre | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit f858f3326adbc0c5711669b92a64a84a9083a055 Author: James Cloos <cloos at jhcloos.com> Date: Tue Oct 4 17:11:11 2011 -0400 [nls] Fix typo/synco. The iso8859-1 Compose table includes an optional section which uses Ctrl<T> as a substitute for <Multi_key>. In that section the sequence to generate an @ (at) either was incorrectly copied from the Multi_key section or was not kept in sync with the Multi_key section. Fixing this eliminates the warning from compose-check.pl: ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??? Clash with existing sequence in iso8859-1/Compose.pre ??? on line 661: Ctrl<T> <A> <A> ??? line #661: Ctrl<T> <A> <A> : "\305" Aring ??? line #480: Ctrl<T> <A> <A> : "@" at ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Signed-off-by: James Cloos <cloos at jhcloos.com> From marcoz at kemper.freedesktop.org Tue Oct 4 19:53:28 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Tue, 4 Oct 2011 19:53:28 -0700 (PDT) Subject: libXmu: Branch 'master' Message-ID: <20111005025328.DF47FD8002@kemper.freedesktop.org> doc/Xmu.xml | 162 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 81 insertions(+), 81 deletions(-) New commits: commit 004d535c707251bd4fb47426f90712c195c6dfc7 Author: Matt Dew <marcoz at osource.org> Date: Tue Oct 4 20:51:48 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> diff --git a/doc/Xmu.xml b/doc/Xmu.xml index 43d8047..2d363a9 100644 --- a/doc/Xmu.xml +++ b/doc/Xmu.xml @@ -49,8 +49,8 @@ is a trademark of The Open Group. </legalnotice> </articleinfo> - <sect1 id='introduction'> - <title>Introduction + +Introduction The Xmu Library is a collection of miscellaneous (some might say random) @@ -81,8 +81,8 @@ cc -o xapplication xapplication.o `pkg-config --libs xmu` - - Atom Functions + +Atom Functions To use the functions and macros defined in this section, you should include @@ -203,11 +203,11 @@ value is cached, such that subsequent requests do not cause another round-trip to the server. - + - XmuMakeAtom + - + AtomPtr XmuMakeAtom const char *name @@ -228,15 +228,15 @@ for an Atom with the given name. -XmuInternAtom + can be used to cache the Atom value for one or more displays. - + - XmuNameOfAtom + - + char *XmuNameOfAtom AtomPtr atom_ptr @@ -254,11 +254,11 @@ specifies the AtomPtr The function returns the name of an AtomPtr. - + - XmuInternAtom + - + Atom XmuInternAtom Display *dpy @@ -290,11 +290,11 @@ is cached, such that subsequent requests do not cause another round-trip to the server. - + - XmuGetAtomName + - + char *XmuGetAtomName Display *dpy @@ -322,11 +322,11 @@ The result is cached, such that subsequent requests do not cause another round-trip to the server. - + - XmuInternStrings + - + void XmuInternStrings Display *dpy @@ -371,8 +371,8 @@ The caller is responsible for preallocating the array pointed at by atoms. - - Error Handler Functions + +Error Handler Functions To use the functions defined in this section, you should include the header @@ -384,11 +384,11 @@ file and link against the libXmu or libXmuu library. - + - XmuPrintDefaultErrorMessage + - + int XmuPrintDefaultErrorMessage Display *dpy @@ -454,21 +454,21 @@ specifies the error This function ignores errors for BadWindow errors for -XQueryTree +XQueryTree and -XGetWindowAttributes, +XGetWindowAttributes, and ignores BadDrawable errors for -XGetGeometry; +XGetGeometry; it returns 0 in those cases. Otherwise, it prints the default error message, and returns a non-zero value if the caller should consider exiting, and 0 if the caller should not exit. - - System Utility Functions + +System Utility Functions To use the functions defined in this section, you should include the header @@ -550,8 +550,8 @@ in software that needs to continue to support non-Unix98 compliant platforms. - - Window Utility Functions + +Window Utility Functions To use the functions defined in this section, you should include the header @@ -675,17 +675,17 @@ and flags in the hints structure, and then stores the hints for the window using - XSetWMNormalHints + XSetWMNormalHints -XSetWMNormalHints +XSetWMNormalHints and returns True. If NULL is passed for the hints structure, then the current hints are read back from the window using - XGetWMNormalHints + XGetWMNormalHints -XGetWMNormalHints +XGetWMNormalHints and are used instead, and True is returned; otherwise @@ -695,8 +695,8 @@ is returned. - - Cursor Utility Functions + +Cursor Utility Functions To use the functions defined in this section, you should include the header @@ -736,8 +736,8 @@ manual. - - Graphics Functions + +Graphics Functions To use the functions defined in this section, you should include the header @@ -1128,10 +1128,10 @@ returns the y coordinate of the hotspot This function reads a standard bitmap file description from the specified stream, and returns the parsed data in a format suitable for passing to -XCreateBitmapFromData. +XCreateBitmapFromData. The return value of the function has the same interpretation as the return value for -XReadBitmapFile. +XReadBitmapFile. @@ -1190,10 +1190,10 @@ returns the y coordinate of the hotspot This function reads a standard bitmap file description from the specified file, and returns the parsed data in a format suitable for passing to -XCreateBitmapFromData. +XCreateBitmapFromData. The return value of the function has the same interpretation as the return value for -XReadBitmapFile. +XReadBitmapFile. @@ -1265,7 +1265,7 @@ returns the y coordinate of the hotspot This function reads a file in standard bitmap file format, using -XReadBitmapFile, +XReadBitmapFile, and returns the created bitmap. The filename may be absolute, or relative to the global resource named @@ -1352,7 +1352,7 @@ specifies the background pixel value This function creates a pixmap of the specified width, height, and depth, on the same screen as the specified drawable, and then performs an -XCopyPlane +XCopyPlane from the specified bitmap to the pixmap, using the specified foreground and background pixel values. The created pixmap is returned. @@ -1360,8 +1360,8 @@ The created pixmap is returned. - - Selection Functions + +Selection Functions To use the functions defined in this section, you should include the header @@ -1450,8 +1450,8 @@ if the conversion was successful, else it returns - - Type Converter Functions + +Type Converter Functions To use the functions defined in this section, you should include the header @@ -2310,8 +2310,8 @@ XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget, - - Character Set Functions + +Character Set Functions To use the functions defined in this section, you should include the header @@ -2517,8 +2517,8 @@ less than second. The two strings are assumed to be encoded using ISO - - Keyboard Event Translation Functions + +Keyboard Event Translation Functions To use the functions defined in this section, you should include the header @@ -2533,7 +2533,7 @@ and link against the libXmu library. The functions in this section are deprecated because they don't work in most locales now supported by X11; the function -XmbLookupString +XmbLookupString provides a better alternative. @@ -2585,7 +2585,7 @@ specifies or returns the compose state This function is identical to -XLookupString, +XLookupString, and exists only for naming symmetry with other functions. @@ -2637,7 +2637,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to an Latin-2 (ISO 8859-2) string, or to an ASCII control string. @@ -2690,7 +2690,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to an Latin-3 (ISO 8859-3) string, or to an ASCII control string. @@ -2743,7 +2743,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to an Latin-4 (ISO 8859-4) string, or to an ASCII control string. @@ -2796,7 +2796,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to a string in an encoding consisting of Latin-1 (ISO 8859-1) and ASCII control in the Graphics Left half (values 0 to 127), and Katakana in the @@ -2852,7 +2852,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to a string in the JIS X0201-1976 encoding, including ASCII control. @@ -2905,7 +2905,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to a Latin/Arabic (ISO 8859-6) string, or to an ASCII control string. @@ -2958,7 +2958,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to a Latin/Cyrillic (ISO 8859-5) string, or to an ASCII control string. @@ -3011,7 +3011,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to a Latin/Greek (ISO 8859-7) string, or to an ASCII control string. @@ -3064,7 +3064,7 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to a Latin/Hebrew (ISO 8859-8) string, or to an ASCII control string. @@ -3117,14 +3117,14 @@ specifies or returns the compose state This function is similar to -XLookupString, +XLookupString, except that it maps a key event to an APL string. - - Compound Text Functions + +Compound Text Functions The functions defined in this section are for parsing Compound Text strings, @@ -3478,8 +3478,8 @@ structure. - - CloseDisplay Hook Functions + +CloseDisplay Hook Functions To use the functions defined in this section, you should include the header @@ -3652,8 +3652,8 @@ if a matching callback exists, else returns - - Display Queue Functions + +Display Queue Functions To use the functions and types defined in this section, you should include the @@ -3917,8 +3917,8 @@ is not called on the display. - - Toolkit Convenience Functions + +Toolkit Convenience Functions To use the functions defined in this section, you should include the header @@ -3995,8 +3995,8 @@ Otherwise, this function does nothing. - - Standard Colormap Functions + +Standard Colormap Functions To use the functions defined in this section, you should include the header @@ -4534,8 +4534,8 @@ possible. - - Widget Description Functions + +Widget Description Functions The functions defined in this section are for building a description of @@ -4601,7 +4601,7 @@ specifies the widget class for which resources should be obtained. specifies the widget that should be used for creating an instance of node from which resources are extracted. This is typically the value returned -by XtAppInitialize. +by XtAppInitialize. @@ -4696,8 +4696,8 @@ widget name or widget class name. If no match is found, it returns - - Participation in the Editres Protocol + +Participation in the Editres Protocol From jeremyhu at kemper.freedesktop.org Tue Oct 4 20:07:05 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 4 Oct 2011 20:07:05 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' - 2 commits Message-ID: <20111005030705.833CED8002@kemper.freedesktop.org> Xext/shm.c | 6 +----- dix/dispatch.c | 1 - hw/xquartz/X11Application.m | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) New commits: commit 7b74bb67528033bf2d2a1714a801c38e7822642e Author: Jeremy Huddleston Date: Tue Sep 20 20:39:06 2011 -0700 XQuartz: Use set_front_process rather than X11ApplicationSetFrontProcess since we're already in the AppKit thread Signed-off-by: Jeremy Huddleston (cherry picked from commit 38e9e28ba2fbffee52ad9889ef6d4e94c7af3e10) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 7fd7dab..12ff53c 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -356,7 +356,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) { */ _appFlags._active = YES; - X11ApplicationSetFrontProcess(); + [self set_front_process:nil]; /* Get the Spaces preference for SwitchOnActivate */ (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock")); commit bd6ea85209e5ab80375d4ec9994d10a89fd1374a Author: Jamey Sharp Date: Tue Sep 14 18:35:21 2010 -0700 Fix pixmap double-frees on error paths. If AddResource fails, it will automatically free the object that was passed to it by calling the appropriate deleteFunc; and of course FreeResource also calls the deleteFunc. In both cases it's wrong to call the destroy hook manually. Commit by Jamey Sharp and Josh Triplett. Signed-off-by: Jamey Sharp Signed-off-by: Josh Triplett Reviewed-by: Peter Hutterer Reviewed-by: Aaron Plattner (cherry picked from commit 0f380a5005f800572773cd4667ce43c7459cc467) diff --git a/Xext/shm.c b/Xext/shm.c index b08af82..4141a8f 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -991,7 +991,6 @@ CreatePmap: pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = newPix->info[j].id; if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) { - (*pScreen->DestroyPixmap)(pMap); result = BadAlloc; break; } @@ -1002,10 +1001,8 @@ CreatePmap: } if(result == BadAlloc) { - while(j--) { - (*pScreen->DestroyPixmap)(pMap); + while(j--) FreeResource(newPix->info[j].id, RT_NONE); - } free(newPix); } else AddResource(stuff->pid, XRT_PIXMAP, newPix); @@ -1110,7 +1107,6 @@ CreatePmap: { return Success; } - pDraw->pScreen->DestroyPixmap(pMap); } return BadAlloc; } diff --git a/dix/dispatch.c b/dix/dispatch.c index 192c8c3..f8200b1 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1419,7 +1419,6 @@ CreatePmap: } if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) return Success; - (*pDraw->pScreen->DestroyPixmap)(pMap); } return BadAlloc; } From jeremyhu at kemper.freedesktop.org Tue Oct 4 20:08:44 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 4 Oct 2011 20:08:44 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' - 2 commits Message-ID: <20111005030844.B8720D8002@kemper.freedesktop.org> Xi/xipassivegrab.c | 13 ++++++++++--- dix/events.c | 14 +++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) New commits: commit e9ae33316012ffe9acfeeb7303ab3392c2ca2a2b Author: Sam Spilsbury Date: Wed Sep 14 09:58:34 2011 +0800 Remove the SendEvent bit (0x80) before doing range checks on event type. Some extension libraries may set this bit before converting the event to wire protocol and as such range checking the event will cause an invalid BadValue error to result. As the documentation suggests the the bit should be "forced on", remove it before doing range checks and continue to force it on in the server. Reviewed-by: Jamey Sharp Signed-off-by: Peter Hutterer (cherry picked from commit 2d2dce558d24eeea0eb011ec9ebaa6c5c2273c39) diff --git a/dix/events.c b/dix/events.c index 8a4c6b9..9e58edb 100644 --- a/dix/events.c +++ b/dix/events.c @@ -5224,6 +5224,8 @@ CloseDownEvents(void) InputEventList = NULL; } +#define SEND_EVENT_BIT 0x80 + /** * Server-side protocol handling for SendEvent request. * @@ -5241,6 +5243,16 @@ ProcSendEvent(ClientPtr client) REQUEST_SIZE_MATCH(xSendEventReq); + /* libXext and other extension libraries may set the bit indicating + * that this event came from a SendEvent request so remove it + * since otherwise the event type may fail the range checks + * and cause an invalid BadValue error to be returned. + * + * This is safe to do since we later add the SendEvent bit (0x80) + * back in once we send the event to the client */ + + stuff->event.u.u.type &= ~(SEND_EVENT_BIT); + /* The client's event type must be a core event type or one defined by an extension. */ @@ -5298,7 +5310,7 @@ ProcSendEvent(ClientPtr client) client->errorValue = stuff->propagate; return BadValue; } - stuff->event.u.u.type |= 0x80; + stuff->event.u.u.type |= SEND_EVENT_BIT; if (stuff->propagate) { for (;pWin; pWin = pWin->parent) commit 347f5610ca023fb31485aa19c20607af8bf9c834 Author: Carlos Garnacho Date: Wed Aug 31 00:46:52 2011 +0200 Xi: Fix passive XI2 ungrabs on XIAll[Master]Devices The corresponding DeviceIntPtr wasn't being gotten properly, resulting in BadDevice from dixLookupDevice(). Signed-off-by: Carlos Garnacho Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer (cherry picked from commit f52d5cd374563544dafe29587411f345e31bbdf8) diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index ae43433..5cdd8ac 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -261,9 +261,16 @@ ProcXIPassiveUngrabDevice(ClientPtr client) REQUEST(xXIPassiveUngrabDeviceReq); REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq); - rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); - if (rc != Success) - return rc; + if (stuff->deviceid == XIAllDevices) + dev = inputInfo.all_devices; + else if (stuff->deviceid == XIAllMasterDevices) + dev = inputInfo.all_master_devices; + else + { + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); + if (rc != Success) + return rc; + } if (stuff->grab_type != XIGrabtypeButton && stuff->grab_type != XIGrabtypeKeycode && From jeremyhu at kemper.freedesktop.org Tue Oct 4 20:22:50 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 4 Oct 2011 20:22:50 -0700 (PDT) Subject: mkfontscale: Changes to 'master' Message-ID: <20111005032250.B3C5ED8002@kemper.freedesktop.org> mkfontscale.c | 4 ++++ 1 file changed, 4 insertions(+) New commits: commit 8ee3b3f73a6c14c4326435fea7136c09fe2822d1 Author: Maxim Iorsh Date: Mon Oct 3 21:52:15 2011 +0200 mkfontscale: Support FontForge weight designations. Fontforge uses 'ExtraLight' and 'Heavy' weights in Type 1 fonts, which should be understood by mkfontscale. Other FontForge designations are already addressed. Signed-off-by: Maxim Iorsh Reviewed-by: Jeremy Huddleston From alanc at kemper.freedesktop.org Tue Oct 4 20:28:59 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Tue, 4 Oct 2011 20:28:59 -0700 (PDT) Subject: mkfontscale: Changes to 'master' Message-ID: <20111005032859.CE794D8002@kemper.freedesktop.org> list.c | 2 +- list.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 0f4f6462597841e5f8470571d56cfda61144ee8f Author: Alan Coopersmith Date: Mon Sep 26 15:55:12 2011 -0700 Mark format string argument to dsprintf as const char * Signed-off-by: Alan Coopersmith From marcoz at kemper.freedesktop.org Tue Oct 4 20:53:14 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Tue, 4 Oct 2011 20:53:14 -0700 (PDT) Subject: libXtst: Changes to 'master' Message-ID: <20111005035314.6CCE0D8002@kemper.freedesktop.org> specs/recordlib.xml | 208 +++++++++++++++++++++++++--------------------------- specs/xtestlib.xml | 50 ++++++------ 2 files changed, 126 insertions(+), 132 deletions(-) New commits: commit 558ec1d7194307d7ce73aeae2f4f61df9d44bba0 Author: Matt Dew Date: Tue Oct 4 21:50:03 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From marcoz at kemper.freedesktop.org Tue Oct 4 21:01:53 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Tue, 4 Oct 2011 21:01:53 -0700 (PDT) Subject: libxtrans: Changes to 'master' Message-ID: <20111005040153.49631D8002@kemper.freedesktop.org> doc/xtrans.xml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) New commits: commit 29c9e101f7ad72556aa6b3dbc17d66a1ace9b2b1 Author: Matt Dew <marcoz at osource.org> Date: Tue Oct 4 21:59:50 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From marcoz at kemper.freedesktop.org Tue Oct 4 21:18:24 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Tue, 4 Oct 2011 21:18:24 -0700 (PDT) Subject: libXdmcp: Changes to 'master' Message-ID: <20111005041824.B1212D8002@kemper.freedesktop.org> doc/xdmcp.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit e2bc94bbeeae5f0482c2c59556c9a3fb421573d2 Author: Matt Dew <marcoz at osource.org> Date: Tue Oct 4 22:17:41 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From marcoz at kemper.freedesktop.org Tue Oct 4 21:43:53 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Tue, 4 Oct 2011 21:43:53 -0700 (PDT) Subject: libSM: Changes to 'master' Message-ID: <20111005044353.7DCD5D8002@kemper.freedesktop.org> doc/SMlib.xml | 551 +++++++++++++++++++++++++++++----------------------------- doc/xsmp.xml | 40 ++-- 2 files changed, 296 insertions(+), 295 deletions(-) New commits: commit 79c785adf86ef06f09910b68019bc8a1e6fcb122 Author: Matt Dew <marcoz at osource.org> Date: Tue Oct 4 22:42:05 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From keithp at kemper.freedesktop.org Tue Oct 4 22:23:28 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Tue, 4 Oct 2011 22:23:28 -0700 (PDT) Subject: xserver: Branch 'master' - 4 commits Message-ID: <20111005052328.A2E62D8002@kemper.freedesktop.org> dix/dixfonts.c | 30 +++++++++++++++--------------- fb/fbpict.c | 4 +++- hw/xfree86/modes/xf86Crtc.c | 1 + hw/xquartz/pbproxy/Makefile.am | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) New commits: commit fae7ed62ad476114bd37b566202cf6b6546c0a1f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 4 21:40:03 2011 -0700 XQuartz: pbproxy: Add missing AM_OBJCFLAGS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am index b8b95d2..1b14dff 100644 --- a/hw/xquartz/pbproxy/Makefile.am +++ b/hw/xquartz/pbproxy/Makefile.am @@ -2,6 +2,7 @@ AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Framework -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\" AM_CFLAGS=$(XPBPROXY_CFLAGS) +AM_OBJCFLAGS=$(XPBPROXY_CFLAGS) noinst_LTLIBRARIES = libxpbproxy.la libxpbproxy_la_SOURCES = \ commit e4cddf509e1729e8ff40354275b65455111ad2bd Author: vdb at picaros.org <vdb at picaros.org> Date: Sat Sep 17 18:55:47 2011 +0200 Fix a rare memory leak Signed-off-by: Servaas Vandenberghe <vdb at picaros.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index c2814d4..3fae039 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -133,6 +133,7 @@ xf86CrtcCreate (ScrnInfoPtr scrn, crtcs = malloc((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); if (!crtcs) { + free(crtc->gamma_red); free(crtc); return NULL; } commit 53611213396479abfdce0f7752681572e0d26d78 Author: Kirill Elagin <kirelagin at gmail.com> Date: Tue Oct 4 23:02:20 2011 +0400 Fix server crash due to invalid images See https://bugs.freedesktop.org/show_bug.cgi?id=39383 Signed-off-by: Kirill Elagin <kirelagin at gmail.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/fb/fbpict.c b/fb/fbpict.c index d1fd0cb..57c93fd 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -163,7 +163,9 @@ create_bits_picture (PicturePtr pict, (pixman_format_code_t)pict->format, pixmap->drawable.width, pixmap->drawable.height, (uint32_t *)bits, stride * sizeof (FbStride)); - + + if (!image) + return NULL; #ifdef FB_ACCESS_WRAPPER #if FB_SHIFT==5 commit 7a33c5b934382b5554f41ab1502514e91c9bc52e Author: Alan Hourihane <alanh at vmware.com> Date: Tue Oct 4 19:42:46 2011 -0700 dixfonts: Don't overwrite local c variable until new_closure is safely initialized. Signed-off-by: Alan Hourihane <alanh at vmware.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/dix/dixfonts.c b/dix/dixfonts.c index fbac124..d2bcb84 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1302,31 +1302,30 @@ doPolyText(ClientPtr client, PTclosurePtr c) goto bail; } *new_closure = *c; - c = new_closure; - len = c->endReq - c->pElt; - c->data = malloc(len); - if (!c->data) + len = new_closure->endReq - new_closure->pElt; + new_closure->data = malloc(len); + if (!new_closure->data) { - free(c); + free(new_closure); err = BadAlloc; goto bail; } - memmove(c->data, c->pElt, len); - c->pElt = c->data; - c->endReq = c->pElt + len; + memmove(new_closure->data, new_closure->pElt, len); + new_closure->pElt = new_closure->data; + new_closure->endReq = new_closure->pElt + len; /* Step 2 */ - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); + pGC = GetScratchGC(new_closure->pGC->depth, new_closure->pGC->pScreen); if (!pGC) { - free(c->data); - free(c); + free(new_closure->data); + free(new_closure); err = BadAlloc; goto bail; } - if ((err = CopyGC(c->pGC, pGC, GCFunction | + if ((err = CopyGC(new_closure->pGC, pGC, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFillStyle | GCTile | GCStipple | @@ -1337,15 +1336,16 @@ doPolyText(ClientPtr client, PTclosurePtr c) Success) { FreeScratchGC(pGC); - free(c->data); - free(c); + free(new_closure->data); + free(new_closure); err = BadAlloc; goto bail; } + c = new_closure; origGC = c->pGC; c->pGC = pGC; ValidateGC(c->pDraw, c->pGC); - + ClientSleep(client, (ClientSleepProcPtr)doPolyText, c); /* Set up to perform steps 3 and 4 */ From marcoz at kemper.freedesktop.org Tue Oct 4 22:32:26 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Tue, 4 Oct 2011 22:32:26 -0700 (PDT) Subject: libICE: Changes to 'master' Message-ID: <20111005053226.56DC2D8002@kemper.freedesktop.org> doc/ICElib.xml | 569 +++++++++++++++++++++++++++------------------------------ specs/ice.xml | 60 ++---- 2 files changed, 308 insertions(+), 321 deletions(-) New commits: commit 4fbcba4ee19a49c05440861e1278bc97d29048e0 Author: Matt Dew <marcoz at osource.org> Date: Tue Oct 4 23:32:02 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From jeremyhu at kemper.freedesktop.org Tue Oct 4 23:38:56 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 4 Oct 2011 23:38:56 -0700 (PDT) Subject: xclock: Changes to 'master' Message-ID: <20111005063856.09B79D8002@kemper.freedesktop.org> Clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 251461d84de4220f05ffa35a3138aad1cd2e0302 Author: Peter Stuge <peter at stuge.se> Date: Thu Aug 26 04:14:27 2010 +0200 Calculate text and window size from LC_CTYPE instead of LC_TIME LC_TIME only defines what will be displayed, LC_CTYPE is what defines the character encoding. References: Bug 15903 - LANG=en_US xclock -digital -font fixed has wrong size https://bugs.freedesktop.org/show_bug.cgi?id=15903 Reviewed-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From thomash at kemper.freedesktop.org Wed Oct 5 04:59:11 2011 From: thomash at kemper.freedesktop.org (Thomas Hellstrom) Date: Wed, 5 Oct 2011 04:59:11 -0700 (PDT) Subject: xf86-video-vmware: Changes to 'master' Message-ID: <20111005115912.A8C6ED8002@kemper.freedesktop.org> configure.ac | 2 +- src/vmwarexinerama.c | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) New commits: commit de70a1d0cb79dad9e52baa43306264db80a163da Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Wed Oct 5 13:33:17 2011 +0200 xf86-video-vmware 11.0.99.901 Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> commit 26845eb54a15d43f09288a87c5f74beac8fb6ec7 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Tue Sep 27 19:31:22 2011 -0700 Use dixLookupWindow instead of LookupWindow on Xorg 1.5 & later The LookupWindow function was deprecated in xserver commit ed75b056511ccb4 and removed during the Xorg 1.11 merge window by commit 82a8677d9175732. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> From thomash at kemper.freedesktop.org Wed Oct 5 05:01:46 2011 From: thomash at kemper.freedesktop.org (Thomas Hellstrom) Date: Wed, 5 Oct 2011 05:01:46 -0700 (PDT) Subject: xf86-video-vmware: Changes to 'refs/tags/xf86-video-vmware-11.0.99.901' Message-ID: <20111005120146.4926DD8002@kemper.freedesktop.org> Tag 'xf86-video-vmware-11.0.99.901' created by Thomas Hellstrom <thellstrom at vmware.com> at 2011-10-05 12:37 -0700 xf86-video-vmware 11.0.99.901 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAk6MQXsACgkQwfXTzfUXZYAfBQCgpa8/PyuwFBS8sEU9VJoI7TGF NCkAoIDSvTQXu/z1fVouERqoW+KqWjRp =8x4R -----END PGP SIGNATURE----- Changes since xf86-video-vmware-11.0.3: Alan Coopersmith (1): Use dixLookupWindow instead of LookupWindow on Xorg 1.5 & later Alan Hourihane (1): vmwlegacy: Fix mode lookup Matt Turner (1): Fix wrong-sized swaps Michel D??nzer (1): vmwlegacy: Send ConfigureNotify events on Xinerama state changes with no mode change Thomas Hellstrom (15): vmwlegacy: Remove Write-Combining setups Fix crosscompile build for older Xservers Revert "Fix crosscompile build for older Xservers" Fix crosscompile build for older Xservers v2 vmwlegacy: Don't attempt to call RRSendConfigNotify on Xservers < 1.2 vmwlegacy: Add a missing include Remove unused variable vmwlegacy: Fix segfault and setup of initial mode. vmwlegacy: Silence a number of warnings vmwlegacy: Make sure we draw the colorkey to the right drawable vmwlegacy: Fix a bug in screen dimension calculation vmwlegacy: Fix up default mode VRefresh anc Clock calculation vmwlegacy: Don't prune modes based on the virtual size of the default mode vmwlegacy: Fix server termination due to pitch inconsistency. xf86-video-vmware 11.0.99.901 --- configure.ac | 6 -- src/vmware.c | 68 ++++++++++++++++------ src/vmware.h | 6 +- src/vmwarectrl.c | 41 ++++--------- src/vmwaremodes.c | 152 ++++++++++++++++++++++++++++++++------------------- src/vmwaremodule.c | 7 +- src/vmwarevideo.c | 50 ++++++++++++---- src/vmwarexinerama.c | 44 +++++++++++--- 8 files changed, 236 insertions(+), 138 deletions(-) --- From jeremyhu at kemper.freedesktop.org Wed Oct 5 20:59:57 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 5 Oct 2011 20:59:57 -0700 (PDT) Subject: libXv: Changes to 'master' Message-ID: <20111006035957.AD9F8D8002@kemper.freedesktop.org> man/XvQueryExtension.man | 4 ---- 1 file changed, 4 deletions(-) New commits: commit ff45155aa59c22aa5abc5ffe941dfe3b0f4c288f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 5 20:59:37 2011 -0700 XvQueryExtension doesn't return XvBadAlloc https://bugs.freedesktop.org/show_bug.cgi?id=22829 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From guillem at kemper.freedesktop.org Wed Oct 5 21:07:37 2011 From: guillem at kemper.freedesktop.org (Guillem Jover) Date: Wed, 5 Oct 2011 21:07:37 -0700 (PDT) Subject: xwininfo: Changes to 'master' Message-ID: <20111006040737.B28C4D8002@kemper.freedesktop.org> dsimple.c | 38 +++++++++++----------- xwininfo.c | 101 +++++++++++++++++++++++++++++++------------------------------ 2 files changed, 71 insertions(+), 68 deletions(-) New commits: commit 42d2c1e32167a33c0f2de04cea0c7bb8001dbe43 Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 07:04:38 2011 +0200 Use format string literals instead of variables to print atom names This allows the compiler to check the format against the argument types. Signed-off-by: Guillem Jover <guillem at hadrons.org> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 8ce8a54e75248164e17626c0866adbd636e42a7b Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 07:03:30 2011 +0200 Refactor atom name printing into a new Display_Atom_Name function Signed-off-by: Guillem Jover <guillem at hadrons.org> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit c1b6da1bc7e5ba715bbea52a24449cc91c26dfb3 Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 07:04:38 2011 +0200 Use format string literals instead of variables to print window ids This allows the compiler to check the format against the argument types. Signed-off-by: Guillem Jover <guillem at hadrons.org> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit d11e467728a7c7cb7b5b7a8e07cd543172c20aa1 Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 05:40:45 2011 +0200 Move leading ": " out from buffer to the error string printer Besides slightly reducing the binary size, this will be helpful when/if i18n support is added to translate the strings. Signed-off-by: Guillem Jover <guillem at hadrons.org> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> From marcoz at kemper.freedesktop.org Wed Oct 5 21:37:33 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Wed, 5 Oct 2011 21:37:33 -0700 (PDT) Subject: libXaw: Changes to 'master' Message-ID: <20111006043733.83A5BD8002@kemper.freedesktop.org> specs/AsciiSink.xml | 2 specs/AsciiSource.xml | 48 ++++++++--------- specs/AsciiText.xml | 4 - specs/Box.xml | 2 specs/CH1.xml | 6 +- specs/CH2.xml | 82 +++++++++++++++--------------- specs/CH3.xml | 2 specs/CH4.xml | 2 specs/CH5.xml | 6 +- specs/CH6.xml | 4 - specs/CH7.xml | 2 specs/Dialog.xml | 18 +++--- specs/Form.xml | 12 ++-- specs/Grip.xml | 2 specs/Label.xml | 2 specs/List.xml | 18 +++--- specs/MenuButton.xml | 4 - specs/Paned.xml | 26 ++++----- specs/Panner.xml | 4 - specs/Porthole.xml | 6 +- specs/Repeater.xml | 2 specs/Scrollbar.xml | 10 +-- specs/Simple.xml | 2 specs/SimpleMenu.xml | 16 ++--- specs/Sme.xml | 4 - specs/SmeBSB.xml | 2 specs/SmeLine.xml | 2 specs/StripChart.xml | 2 specs/Template.xml | 2 specs/Template_public_header_file.xml | 2 specs/Text.xml | 4 - specs/TextActions.xml | 4 - specs/TextActions_text_widget_actions.xml | 4 - specs/TextFuncs.xml | 80 ++++++++++++++--------------- specs/TextSink.xml | 50 +++++++++--------- specs/TextSource.xml | 34 ++++++------ specs/Toggle.xml | 40 +++++++------- specs/Tree.xml | 12 ++-- specs/Viewport.xml | 6 +- 39 files changed, 266 insertions(+), 264 deletions(-) New commits: commit fe00db0ecafd95f6e1353b1d5f11ee6012a9b64c Author: Matt Dew <marcoz at osource.org> Date: Wed Oct 5 22:33:05 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From alanc at kemper.freedesktop.org Wed Oct 5 23:09:46 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Wed, 5 Oct 2011 23:09:46 -0700 (PDT) Subject: libXau: Changes to 'master' Message-ID: <20111006060946.71892D8002@kemper.freedesktop.org> AuLock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 5c01ef69eee7dfe925c97558153fcd5e116252c6 Author: Matthew D. Fuller <fullermd at over-yonder.net> Date: Mon Sep 5 10:31:14 2011 -0500 Improve the handling of "normal" locking collisions. EEXIST is a perfectly normal and expected errno for open(O_CREAT | O_EXCL), and is a signal to loop around and retry, not return with an error. Signed-off-by: Matthew D. Fuller <fullermd at over-yonder.net> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From jeremyhu at kemper.freedesktop.org Thu Oct 6 00:54:39 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Thu, 6 Oct 2011 00:54:39 -0700 (PDT) Subject: xauth: Changes to 'master' Message-ID: <20111006075439.941B2D8002@kemper.freedesktop.org> gethost.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) New commits: commit fbc307f3445a549815efb2476e9476bd51250cf6 Author: Andreas Schwab <schwab at linux-m68k.org> Date: Fri Sep 3 13:45:49 2010 +0200 Remove alarm handler in get_hostname gethostbyaddr is not (required to be) async-signal-safe. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Thu Oct 6 10:31:08 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Thu, 6 Oct 2011 10:31:08 -0700 (PDT) Subject: mkfontdir: Changes to 'master' Message-ID: <20111006173108.BF9D5D8002@kemper.freedesktop.org> mkfontdir.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit e3ee2b17572a26b6a6e78fdbfa4e38059da6c170 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 6 10:29:42 2011 -0700 Fix issues where mkfontscale and mkfontdir are installed in different locations or bindir contains a space https://bugs.freedesktop.org/show_bug.cgi?id=24465 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Thu Oct 6 10:52:23 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Thu, 6 Oct 2011 10:52:23 -0700 (PDT) Subject: luit: Changes to 'master' Message-ID: <20111006175223.91042D8002@kemper.freedesktop.org> sys.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) New commits: commit 82bec8b84d90d37f75f10b3abe9ec34a3415a622 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 6 10:50:54 2011 -0700 Fix ifdef-foo for the BSDs which are still living in the 90s NetBSD and FreeBSD still don't _POSIX_SAVED_IDS https://bugs.freedesktop.org/show_bug.cgi?id=41513 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From mattst88 at kemper.freedesktop.org Thu Oct 6 12:24:57 2011 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 6 Oct 2011 12:24:57 -0700 (PDT) Subject: libXaw3d: Changes to 'master' Message-ID: <20111006192457.6BA69D8002@kemper.freedesktop.org> configure.ac | 1 + src/Scrollbar.c | 15 ++++++++++----- src/Text.c | 5 +++-- src/TextPop.c | 5 +++-- src/Viewport.c | 4 +++- src/laygram.y | 2 +- src/laylex.l | 2 ++ 7 files changed, 23 insertions(+), 11 deletions(-) New commits: commit 6b9e47e67cf05503d65194b05d1e3e424bc3ef73 Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 11:35:03 2011 +0000 Define call_data to 0 in NotifyScroll() Fixes gcc warning: Scrollbar.c: In function 'NotifyScroll': Scrollbar.c:950:12: warning: 'call_data' may be used uninitialized in this function [-Wuninitialized] Reviewed-by: Matt Turner <mattst88 at gmail.com> Signed-off-by: Guillem Jover <guillem at hadrons.org> commit 30326a08a2e38dab3e82a9233054e67818cd2a85 Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 11:35:02 2011 +0000 Use intptr_t instead of int when casting from and to XtPointer Fixes gcc warnings: Scrollbar.c: In function 'NotifyScroll': Scrollbar.c:955:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] Text.c: In function 'HScroll': Text.c:1274:41: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Text.c: In function 'VScroll': Text.c:1431:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] TextPop.c: In function 'DoSearch': TextPop.c:808:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] TextPop.c: In function 'Replace': TextPop.c:942:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Viewport.c: In function 'ScrollUpDownProc': Viewport.c:866:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Reviewed-by: Matt Turner <mattst88 at gmail.com> Signed-off-by: Guillem Jover <guillem at hadrons.org> commit f7d3fd257d1bf7a0313a45dccf023ed99c400da9 Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 11:35:01 2011 +0000 Only use variable t in MoveThumb() on XAW_ARROW_SCROLLBARS Fixes gcc warning: Scrollbar.c: In function 'MoveThumb': Scrollbar.c:1006:16: warning: variable 't' set but not used [-Wunused-but-set-variable] Reviewed-by: Matt Turner <mattst88 at gmail.com> Signed-off-by: Guillem Jover <guillem at hadrons.org> commit 67a927284dd554712cc743ed5dbbabf8d3a761af Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 11:35:00 2011 +0000 Remove unused label Fixes gcc warning: laygram.c: In function 'LayYYparse': laygram.y:242:7: warning: label 'unary' defined but not used [-Wunused-label] Reviewed-by: Matt Turner <mattst88 at gmail.com> Signed-off-by: Guillem Jover <guillem at hadrons.org> commit 712dd8b572114a3605e4f4c444eabefbfb0522aa Author: Guillem Jover <guillem at hadrons.org> Date: Tue Oct 4 11:34:59 2011 +0000 Disable unused input and unput lex functions Fixes gcc warnings: laylex.c:1316:17: warning: 'yyunput' defined but not used [-Wunused-function] laylex.c:1357:16: warning: 'input' defined but not used [-Wunused-function] Reviewed-by: Matt Turner <mattst88 at gmail.com> Signed-off-by: Guillem Jover <guillem at hadrons.org> From mattst88 at kemper.freedesktop.org Thu Oct 6 14:57:02 2011 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Thu, 6 Oct 2011 14:57:02 -0700 (PDT) Subject: pixman: Branch 'master' - 2 commits Message-ID: <20111006215702.697FDD8002@kemper.freedesktop.org> configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit 741eb8462c3ff72cbf2d9acfeb1e97208a414fcd Author: Matt Turner <mattst88 at gmail.com> Date: Thu Oct 6 17:56:09 2011 -0400 Correct the minimum gcc version needed for iwmmxt Spotted by S??ren Sandmann. Signed-off-by: Matt Turner <mattst88 at gmail.com> diff --git a/configure.ac b/configure.ac index 471a127..6f5aef5 100644 --- a/configure.ac +++ b/configure.ac @@ -555,7 +555,7 @@ AC_COMPILE_IFELSE([ #ifndef __arm__ #error "IWMMXT is only available on ARM" #endif -#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 3 && __GNUC_MINOR__ < 6)) +#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) #error "Need GCC >= 4.6 for IWMMXT intrinsics" #endif #include <mmintrin.h> commit 0a34277180d29f471a2554afc2e2b682fee33c79 Author: Matt Turner <mattst88 at gmail.com> Date: Wed Oct 5 22:54:36 2011 -0400 Make sure iwMMXt is only detected on ARM iwMMXt is incorrectly detected on x86 and amd64. This happens because the test uses standard _mm_* intrinsic functions which it compiles with -march=iwmmxt, but when the user has set CFLAGS=-march=k8 for instance, no error is generated from -march=iwmmxt, even though it's not a valid flag on x86/amd64. Passing CFLAGS=-march=native does not override the -march=iwmmxt flag though, which is why it wasn't noticed before. So, just #error out in the test if the __arm__ preprocessor directive isn't defined. Fixes https://bugs.gentoo.org/show_bug.cgi?id=385179 Signed-off-by: Matt Turner <mattst88 at gmail.com> diff --git a/configure.ac b/configure.ac index 481d0bb..471a127 100644 --- a/configure.ac +++ b/configure.ac @@ -552,6 +552,9 @@ AC_MSG_CHECKING(whether to use ARM IWMMXT intrinsics) xserver_save_CFLAGS=$CFLAGS CFLAGS="$IWMMXT_CFLAGS $CFLAGS" AC_COMPILE_IFELSE([ +#ifndef __arm__ +#error "IWMMXT is only available on ARM" +#endif #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 3 && __GNUC_MINOR__ < 6)) #error "Need GCC >= 4.6 for IWMMXT intrinsics" #endif From alanc at kemper.freedesktop.org Thu Oct 6 22:23:42 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Thu, 6 Oct 2011 22:23:42 -0700 (PDT) Subject: constype: Changes to 'master' Message-ID: <20111007052342.BDAE3D8002@kemper.freedesktop.org> README | 4 ++-- constype.c | 32 ++++++++++++++++---------------- constype.man | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) New commits: commit 0a21f2228a9b81fa3b69d10ae2f334f76f9505a2 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:21:19 2011 -0700 Strip trailing whitespace Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 11c06cace6b7d98c57207016b00f2a851633c4ce Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:20:57 2011 -0700 Add const attributes to fix gcc -Wwrite-strings warnings Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Thu Oct 6 22:31:46 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Thu, 6 Oct 2011 22:31:46 -0700 (PDT) Subject: xcompmgr: Changes to 'master' Message-ID: <20111007053146.19101D8002@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 2a40523ef8c658703eae3d17732e76298abf48e5 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:30:17 2011 -0700 Add xext to PKG_CHECK_MODULES for calls of shape ext. functions in libXext Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Thu Oct 6 22:43:38 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Thu, 6 Oct 2011 22:43:38 -0700 (PDT) Subject: xpr: Changes to 'master' Message-ID: <20111007054338.50769D8002@kemper.freedesktop.org> Makefile.am | 6 +++--- configure.ac | 4 ++-- x2jet.c | 36 ++++++++++++++++++------------------ x2pmp.c | 12 ++++++------ xdpr.man | 10 +++++----- xdpr.script | 6 +++--- xpr.c | 56 ++++++++++++++++++++++++++++---------------------------- xpr.h | 2 +- xpr.man | 8 ++++---- 9 files changed, 70 insertions(+), 70 deletions(-) New commits: commit 28eaec94f936534573907425cf0fb5198979aab3 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:40:45 2011 -0700 Add _X_NORETURN to usage() & leave() as suggested by gcc -Wmissing-noreturn Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 3b8fed17575db9d8d571d240bbaebd05d4547060 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:38:36 2011 -0700 Add const attributes to fix gcc -Wwrite-strings warnings Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit b7d620037e130de1b0b309119c045d4f6a6ba8c5 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:35:31 2011 -0700 Fix printf type warnings in LP64 builds x2jet.c:300:6: warning: format ???%ld??? expects type ???long int???, but argument 4 has type ???CARD32??? x2jet.c:300:6: warning: format ???%ld??? expects type ???long int???, but argument 5 has type ???CARD32??? Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 787f9d6d8f6dd6663af27e3cd21facaee6bed4f5 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:33:33 2011 -0700 Strip trailing whitespace Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Thu Oct 6 22:57:39 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Thu, 6 Oct 2011 22:57:39 -0700 (PDT) Subject: xfwp: Changes to 'master' Message-ID: <20111007055739.B8C92D8002@kemper.freedesktop.org> Makefile.am | 6 configure.ac | 4 io.c | 312 ++++++++++++++++++++++---------------------- io.h | 2 misc.c | 414 +++++++++++++++++++++++++++++------------------------------ misc.h | 24 +-- pm.c | 96 ++++++------- pm.h | 6 transport.c | 78 +++++------ transport.h | 6 xfwp.c | 58 ++++---- xfwp.h | 28 +-- xfwp.man | 224 +++++++++++++++---------------- 13 files changed, 629 insertions(+), 629 deletions(-) New commits: commit 42a2a79b3e1f5c9cbb076743965eba8268733989 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:57:24 2011 -0700 Fix typos Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit c24ac15bfa150aeed51d9ec5cb9f2a5054e6f91d Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:50:27 2011 -0700 Add const attributes to fix gcc -Wwrite-strings warnings Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 063daed4b43090a3e37f29e9796ffce0861573f1 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Oct 6 22:47:25 2011 -0700 Strip trailing whitespace Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From jeremyhu at kemper.freedesktop.org Fri Oct 7 12:07:37 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 7 Oct 2011 12:07:37 -0700 (PDT) Subject: libpciaccess: Changes to 'master' Message-ID: <20111007190737.953E4D8002@kemper.freedesktop.org> configure.ac | 2 - include/pciaccess.h | 8 +++++++ src/Makefile.am | 2 - src/common_interface.c | 44 ++++++++++++++++++++++++++++++++++++++++ src/linux_sysfs.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ src/pciaccess_private.h | 4 +++ 6 files changed, 110 insertions(+), 2 deletions(-) New commits: commit 30e9ec91107791835d722f99498d659dec048922 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 11:57:26 2011 -0700 configure.ac: Bump version to 0.12.901 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 12dbf6d2d346cfe7ba8b2a1697c56af3f9876be7 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 11:56:06 2011 -0700 Update library version to reflect new API Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 58e87933b3286f33cdeedd3a6b21f4ea795bea47 Author: Adam Jackson <ajax at redhat.com> Date: Tue May 10 17:56:35 2011 -0400 linux: Implement map_legacy Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit 8cc9a8fe57adfb52abaa90a8a2ac2316de8eb898 Author: Adam Jackson <ajax at redhat.com> Date: Tue May 10 17:56:34 2011 -0400 Add map_legacy interface This allows platforms to hand back mmaps of the low 1M (ISA) address space on a per-domain basis. Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Fri Oct 7 12:08:07 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 7 Oct 2011 12:08:07 -0700 (PDT) Subject: libpciaccess: Changes to 'refs/tags/libpciaccess-0.12.901' Message-ID: <20111007190807.6F5BCD8002@kemper.freedesktop.org> Tag 'libpciaccess-0.12.901' created by Jeremy Huddleston <jeremyhu at apple.com> at 2011-10-07 20:07 -0700 libpciaccess-0.12.901 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iD8DBQBOj04JjC1Anjf1NmMRAtx2AJ44o82SiokaFPRJBbLP7J5GTbIC/wCbBz4k oObwwNUsBriY5hBclxxJnxs= =DMCP -----END PGP SIGNATURE----- Changes since libpciaccess-0.12.1: Adam Jackson (3): linux: Fix a crash in populate_devices Add map_legacy interface linux: Implement map_legacy Alan Coopersmith (1): Strip trailing whitespace Chris Wilson (1): linux: Only set errno after an error Gaetan Nadon (1): config: comment, minor upgrade, quote and layout configure.ac Jeremy Huddleston (2): Update library version to reflect new API configure.ac: Bump version to 0.12.901 John Martin (1): Solaris support for multiple PCI segments (domains) --- COPYING | 2 Makefile.am | 2 configure.ac | 72 +-- include/pciaccess.h | 22 - src/Doxyfile | 1016 +++++++++++++++++++++++------------------------ src/Makefile.am | 4 src/common_bridge.c | 10 src/common_capability.c | 10 src/common_device_name.c | 28 - src/common_init.c | 12 src/common_interface.c | 92 +++- src/common_io.c | 2 src/common_iterator.c | 30 - src/freebsd_pci.c | 14 src/linux_devmem.c | 18 src/linux_devmem.h | 2 src/linux_sysfs.c | 104 +++- src/netbsd_pci.c | 2 src/pciaccess_private.h | 14 src/solx_devfs.c | 150 ++++-- 20 files changed, 871 insertions(+), 735 deletions(-) --- From jeremyhu at kemper.freedesktop.org Fri Oct 7 12:42:54 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 7 Oct 2011 12:42:54 -0700 (PDT) Subject: xf86-video-sis: Changes to 'master' Message-ID: <20111007194254.B7B75D8002@kemper.freedesktop.org> src/initextx.c | 18 ++--- src/sis.h | 8 ++ src/sis6326_video.c | 6 - src/sis_dga.c | 6 - src/sis_dri.c | 24 +++--- src/sis_driver.c | 184 ++++++++++++++++++++++++++-------------------------- src/sis_memcpy.c | 10 +- src/sis_opt.c | 12 +-- src/sis_utility.c | 46 ++++++------- src/sis_vga.c | 2 src/sis_video.c | 8 +- 11 files changed, 166 insertions(+), 158 deletions(-) New commits: commit 28f3a899a1e317b665cc1925ce7a4e34818cfd1f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 12:32:22 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit c530ebb5d4ad0663838a0132e3610d713eaaa640 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 12:24:40 2011 -0700 Fix build failures with recent server changes to swapl and swaps Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Fri Oct 7 12:47:12 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 7 Oct 2011 12:47:12 -0700 (PDT) Subject: xf86-video-sisusb: Changes to 'master' Message-ID: <20111007194712.913B2D8002@kemper.freedesktop.org> src/sisusb.h | 8 ++++++++ src/sisusb_driver.c | 2 +- src/sisusb_utility.c | 42 +++++++++++++++++++++--------------------- src/sisusb_video.c | 2 +- 4 files changed, 31 insertions(+), 23 deletions(-) New commits: commit 6272e69d8519c43293192b48ff39c8b3a84635d3 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 12:45:00 2011 -0700 Fix build failures with recent server changes to swapl and swaps Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit dc6d77656d14853b462a8792007e73c5dc07a4b1 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 12:45:50 2011 -0700 Also use calloc rather than xcalloc Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Fri Oct 7 13:11:48 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 7 Oct 2011 13:11:48 -0700 (PDT) Subject: xf86-video-vmware: Changes to 'master' Message-ID: <20111007201148.DFC22D8002@kemper.freedesktop.org> src/vmware.h | 8 +++++++ src/vmwarectrl.c | 40 ++++++++++++++++++------------------ src/vmwarexinerama.c | 56 +++++++++++++++++++++++++-------------------------- 3 files changed, 56 insertions(+), 48 deletions(-) New commits: commit 208ccbc7179b40a570a5943e325dd22740a67577 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 13:10:59 2011 -0700 Fix build failures resulting from changes to the swaps and swapl macros in recent xorg-server Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Fri Oct 7 17:16:27 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 7 Oct 2011 17:16:27 -0700 (PDT) Subject: libXt: Changes to 'master' Message-ID: <20111008001627.21707D8002@kemper.freedesktop.org> src/Resources.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) New commits: commit 1f48cadaa88423a012613a0b456ec8795c8c0992 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 17:08:07 2011 -0700 Whitespace changes related to cleaning up previous patch Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 9e898aa4fd964e888044e2fa2d64089505331f62 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 17:01:34 2011 -0700 Don't pop elements from our array while we're itterating through it. https://bugs.freedesktop.org/show_bug.cgi?id=22543 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From marcoz at kemper.freedesktop.org Fri Oct 7 21:54:38 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Fri, 7 Oct 2011 21:54:38 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111008045439.0E26DD8002@kemper.freedesktop.org> specs/XIM/xim.xml | 25 specs/XKB/ch01.xml | 22 specs/XKB/ch02.xml | 16 specs/XKB/ch03.xml | 12 specs/XKB/ch04.xml | 12 specs/XKB/ch05.xml | 14 specs/XKB/ch06.xml | 10 specs/XKB/ch07.xml | 16 specs/XKB/ch08.xml | 40 - specs/XKB/ch09.xml | 16 specs/XKB/ch10.xml | 78 +- specs/XKB/ch11.xml | 30 - specs/XKB/ch12.xml | 12 specs/XKB/ch13.xml | 26 specs/XKB/ch14.xml | 26 specs/XKB/ch15.xml | 44 - specs/XKB/ch16.xml | 56 +- specs/XKB/ch17.xml | 22 specs/XKB/ch18.xml | 16 specs/XKB/ch19.xml | 2 specs/XKB/ch20.xml | 10 specs/XKB/ch21.xml | 17 specs/XKB/ch22.xml | 2 specs/i18n/framework/framework.xml | 164 +++--- specs/i18n/localedb/localedb.xml | 6 specs/i18n/trans/trans.xml | 32 - specs/libX11/AppA.xml | 978 ++++++++++++++++++------------------- specs/libX11/AppB.xml | 2 specs/libX11/AppC.xml | 266 +++++----- specs/libX11/AppD.xml | 204 +++---- specs/libX11/CH01.xml | 20 specs/libX11/CH02.xml | 270 +++++----- specs/libX11/CH03.xml | 308 +++++------ specs/libX11/CH04.xml | 204 +++---- specs/libX11/CH05.xml | 74 +- specs/libX11/CH06.xml | 570 ++++++++++----------- specs/libX11/CH07.xml | 268 +++++----- specs/libX11/CH08.xml | 464 ++++++++--------- specs/libX11/CH09.xml | 232 ++++---- specs/libX11/CH10.xml | 194 +++---- specs/libX11/CH11.xml | 264 ++++----- specs/libX11/CH12.xml | 344 ++++++------- specs/libX11/CH13.xml | 852 ++++++++++++++++---------------- specs/libX11/CH14.xml | 530 ++++++++++---------- specs/libX11/CH15.xml | 246 ++++----- specs/libX11/CH16.xml | 394 +++++++------- specs/libX11/credits.xml | 16 specs/libX11/glossary.xml | 30 - 48 files changed, 3716 insertions(+), 3740 deletions(-) New commits: commit 22ba43d198dcca86c88eb15a56fc7d8fc47c422e Author: Matt Dew <marcoz at osource.org> Date: Fri Oct 7 22:52:30 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From marcoz at kemper.freedesktop.org Fri Oct 7 22:26:23 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Fri, 7 Oct 2011 22:26:23 -0700 (PDT) Subject: libXext: Changes to 'master' Message-ID: <20111008052623.8F679D8002@kemper.freedesktop.org> specs/dpmslib.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) New commits: commit a8f18777099ca5d61929bc37e4741457b6671e59 Author: Matt Dew <marcoz at osource.org> Date: Fri Oct 7 23:25:45 2011 -0600 more Cleanup of IDs and links in doc From jeremyhu at kemper.freedesktop.org Sat Oct 8 11:46:23 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 8 Oct 2011 11:46:23 -0700 (PDT) Subject: edid-decode: Changes to 'master' Message-ID: <20111008184623.A04B6D8002@kemper.freedesktop.org> edid-decode.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) New commits: commit e55b8eb281db0ff6818aa6398921fe63440ba8fc Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 11:45:23 2011 -0700 Properly handle input > 1K for EDID exiting in log files Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 8 12:27:09 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 8 Oct 2011 12:27:09 -0700 (PDT) Subject: edid-decode: Changes to 'master' Message-ID: <20111008192709.A47AED8002@kemper.freedesktop.org> edid-decode.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) New commits: commit 6b587e4908d9a60ab7f44e80586420a5741593ce Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 12:00:57 2011 -0700 Fix some memory leaks in ENOMEM handling Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit cf95ba5233330c5793b69e0da4586c070996563b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 12:24:49 2011 -0700 Allow for some copy/paste issues in parsing Xorg.log Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 8 12:45:12 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 8 Oct 2011 12:45:12 -0700 (PDT) Subject: edid-decode: Changes to 'master' Message-ID: <20111008194512.A7FA7D8002@kemper.freedesktop.org> Rebased ref, commits from common ancestor: commit cc36404a2670e581eb9d7b2e90d9b91dc894f1dc Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 12:44:53 2011 -0700 Allow a second command line argument to dump EDID binary Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit d65ad6a0e1e1bb49f0b6bf3fa53c6dbb5ad71f0b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 12:00:57 2011 -0700 Fix some memory leaks in ENOMEM handling Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From tormod at kemper.freedesktop.org Sat Oct 8 13:08:33 2011 From: tormod at kemper.freedesktop.org (Tormod Volden) Date: Sat, 8 Oct 2011 13:08:33 -0700 (PDT) Subject: xf86-video-savage: Changes to 'master' Message-ID: <20111008200833.765CAD8002@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 8b9c81bacf45a9f56b0ec275e1b48e1407380baf Author: Tormod Volden <debian.tormod at gmail.com> Date: Sat Oct 8 21:55:38 2011 +0200 Bump version to 2.3.3 From tormod at kemper.freedesktop.org Sat Oct 8 13:22:06 2011 From: tormod at kemper.freedesktop.org (Tormod Volden) Date: Sat, 8 Oct 2011 13:22:06 -0700 (PDT) Subject: xf86-video-savage: Changes to 'refs/tags/xf86-video-savage-2.3.3' Message-ID: <20111008202207.30C28D8002@kemper.freedesktop.org> Tag 'xf86-video-savage-2.3.3' created by Tormod Volden <debian.tormod at gmail.com> at 2011-10-08 21:16 -0700 xf86-video-savage 2.3.3 release -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEABECAAYFAk6Qr4YACgkQoy2Edrr0HQxsIACfQt9cupJUuG5jmRHBi6QYXMXr meYAoJqp2uN10I2esefPvF2sm/MQ+/Nk =o0/z -----END PGP SIGNATURE----- Changes since xf86-video-savage-2.3.2: Hans-Juergen Mauser (1): savage: Fix Xv scaling on non-native resolutions Tormod Volden (20): savage: Add casts to silence build warnings savage: Replace deprecated x(c)alloc/xfree with m/calloc/free savage: More (intermediate) casts to silence warnings savage: Drop unused variables and functions savage: Fix ambiguity in SavageLoadPaletteSavage4 savage: Cast all handles before printing them savage: Factor out a SAVAGEDRISetupTiledSurfaceRegs function savage: Setup tiled surface registers in SavageEnterVT savage: Fix building with TRACEON defined savage: Fix initialization typo in SAVAGEDRIMoveBuffers Use proper casts on framebuffer addresses Fix wrong frequency unit in trace output savage: Fix logic in waitHSync savage: New SAVAGEDRIResume function savage: Factor out a SAVAGESetAgpMode and call it on resume savage: Make SAVAGESelectBuffer() private (static) savage: Fix &/&& typo in "magical" register setup savage: Avoid unnecessary float calculation in video display savage: Warn if broken drm maps are detected Bump version to 2.3.3 --- configure.ac | 2 src/savage_accel.c | 3 src/savage_cursor.c | 6 - src/savage_dga.c | 8 - src/savage_dri.c | 269 ++++++++++++++++++++++++++++------------------------ src/savage_driver.c | 44 +++----- src/savage_driver.h | 15 -- src/savage_exa.c | 3 src/savage_hwmc.c | 10 - src/savage_vbe.c | 10 - src/savage_video.c | 66 ++++++------ 11 files changed, 227 insertions(+), 209 deletions(-) --- From jeremyhu at kemper.freedesktop.org Sat Oct 8 14:18:16 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 8 Oct 2011 14:18:16 -0700 (PDT) Subject: edid-decode: Changes to 'master' Message-ID: <20111008211817.133A8D8002@kemper.freedesktop.org> Makefile | 2 +- edid-decode.c | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) New commits: commit 3f3ff070319dd6a84cc04f4569e9e3eb5153f328 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 14:18:03 2011 -0700 Use $CC rather than gcc Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 0b1997840b2fb4394935b6731cb93dd8ef717650 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 14:16:16 2011 -0700 Support providing the EDID in hex (without log formatting) Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 65357390c48d2bc6f466c1af6a2adb3990e14047 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 8 12:46:06 2011 -0700 Fix a gcc warning edid-decode.c:777:10: warning: pointer targets in assignment differ in signedness [-Wpointer-sign] Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 9 01:38:57 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 01:38:57 -0700 (PDT) Subject: xserver: Branch 'server-1.10-branch' - 4 commits Message-ID: <20111009083857.910A0D8002@kemper.freedesktop.org> dix/dixfonts.c | 30 +++++++++++++++--------------- fb/fbpict.c | 4 +++- hw/xfree86/modes/xf86Crtc.c | 1 + hw/xquartz/pbproxy/Makefile.am | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) New commits: commit 22b97e74455d68f101a82675b583b60bfc50d0eb Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 4 21:40:03 2011 -0700 XQuartz: pbproxy: Add missing AM_OBJCFLAGS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit fae7ed62ad476114bd37b566202cf6b6546c0a1f) diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am index 1886642..7b8685d 100644 --- a/hw/xquartz/pbproxy/Makefile.am +++ b/hw/xquartz/pbproxy/Makefile.am @@ -2,6 +2,7 @@ AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Framework -DLAUNCHD_ID_PREFIX=\"$(LAUNCHD_ID_PREFIX)\" AM_CFLAGS=$(XPBPROXY_CFLAGS) +AM_OBJCFLAGS=$(XPBPROXY_CFLAGS) noinst_LTLIBRARIES = libxpbproxy.la libxpbproxy_la_SOURCES = \ commit 6bba71b15db827116a4b6d5ea318a4c3f79dd30c Author: vdb at picaros.org <vdb at picaros.org> Date: Sat Sep 17 18:55:47 2011 +0200 Fix a rare memory leak Signed-off-by: Servaas Vandenberghe <vdb at picaros.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit e4cddf509e1729e8ff40354275b65455111ad2bd) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index c2814d4..3fae039 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -133,6 +133,7 @@ xf86CrtcCreate (ScrnInfoPtr scrn, crtcs = malloc((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); if (!crtcs) { + free(crtc->gamma_red); free(crtc); return NULL; } commit d8de110883532dcd7b9ca15d499503b00e357506 Author: Kirill Elagin <kirelagin at gmail.com> Date: Tue Oct 4 23:02:20 2011 +0400 Fix server crash due to invalid images See https://bugs.freedesktop.org/show_bug.cgi?id=39383 Signed-off-by: Kirill Elagin <kirelagin at gmail.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 53611213396479abfdce0f7752681572e0d26d78) diff --git a/fb/fbpict.c b/fb/fbpict.c index 7636040..d438cdc 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -163,7 +163,9 @@ create_bits_picture (PicturePtr pict, pict->format, pixmap->drawable.width, pixmap->drawable.height, (uint32_t *)bits, stride * sizeof (FbStride)); - + + if (!image) + return NULL; #ifdef FB_ACCESS_WRAPPER #if FB_SHIFT==5 commit 2845aeb4d52fbf7709267e7bbaa45eabc489fba0 Author: Alan Hourihane <alanh at vmware.com> Date: Tue Oct 4 19:42:46 2011 -0700 dixfonts: Don't overwrite local c variable until new_closure is safely initialized. Signed-off-by: Alan Hourihane <alanh at vmware.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 7a33c5b934382b5554f41ab1502514e91c9bc52e) diff --git a/dix/dixfonts.c b/dix/dixfonts.c index fbac124..d2bcb84 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1302,31 +1302,30 @@ doPolyText(ClientPtr client, PTclosurePtr c) goto bail; } *new_closure = *c; - c = new_closure; - len = c->endReq - c->pElt; - c->data = malloc(len); - if (!c->data) + len = new_closure->endReq - new_closure->pElt; + new_closure->data = malloc(len); + if (!new_closure->data) { - free(c); + free(new_closure); err = BadAlloc; goto bail; } - memmove(c->data, c->pElt, len); - c->pElt = c->data; - c->endReq = c->pElt + len; + memmove(new_closure->data, new_closure->pElt, len); + new_closure->pElt = new_closure->data; + new_closure->endReq = new_closure->pElt + len; /* Step 2 */ - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); + pGC = GetScratchGC(new_closure->pGC->depth, new_closure->pGC->pScreen); if (!pGC) { - free(c->data); - free(c); + free(new_closure->data); + free(new_closure); err = BadAlloc; goto bail; } - if ((err = CopyGC(c->pGC, pGC, GCFunction | + if ((err = CopyGC(new_closure->pGC, pGC, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFillStyle | GCTile | GCStipple | @@ -1337,15 +1336,16 @@ doPolyText(ClientPtr client, PTclosurePtr c) Success) { FreeScratchGC(pGC); - free(c->data); - free(c); + free(new_closure->data); + free(new_closure); err = BadAlloc; goto bail; } + c = new_closure; origGC = c->pGC; c->pGC = pGC; ValidateGC(c->pDraw, c->pGC); - + ClientSleep(client, (ClientSleepProcPtr)doPolyText, c); /* Set up to perform steps 3 and 4 */ From jeremyhu at kemper.freedesktop.org Sun Oct 9 01:39:05 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 01:39:05 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' - 4 commits Message-ID: <20111009083905.5F244D8002@kemper.freedesktop.org> dix/dixfonts.c | 30 +++++++++++++++--------------- fb/fbpict.c | 4 +++- hw/xfree86/modes/xf86Crtc.c | 1 + hw/xquartz/pbproxy/Makefile.am | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) New commits: commit 603ad6608a0dbe2fb1bdc4bcd8b4117f2b0bc8b2 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 4 21:40:03 2011 -0700 XQuartz: pbproxy: Add missing AM_OBJCFLAGS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit fae7ed62ad476114bd37b566202cf6b6546c0a1f) diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am index b8b95d2..1b14dff 100644 --- a/hw/xquartz/pbproxy/Makefile.am +++ b/hw/xquartz/pbproxy/Makefile.am @@ -2,6 +2,7 @@ AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Framework -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\" AM_CFLAGS=$(XPBPROXY_CFLAGS) +AM_OBJCFLAGS=$(XPBPROXY_CFLAGS) noinst_LTLIBRARIES = libxpbproxy.la libxpbproxy_la_SOURCES = \ commit 65469f5ea98074ab27ce0a2d482157b9d5c2cbc7 Author: vdb at picaros.org <vdb at picaros.org> Date: Sat Sep 17 18:55:47 2011 +0200 Fix a rare memory leak Signed-off-by: Servaas Vandenberghe <vdb at picaros.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit e4cddf509e1729e8ff40354275b65455111ad2bd) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index c2814d4..3fae039 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -133,6 +133,7 @@ xf86CrtcCreate (ScrnInfoPtr scrn, crtcs = malloc((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); if (!crtcs) { + free(crtc->gamma_red); free(crtc); return NULL; } commit bec15eb73a17fb47963ff6b747ea504f7dc05deb Author: Kirill Elagin <kirelagin at gmail.com> Date: Tue Oct 4 23:02:20 2011 +0400 Fix server crash due to invalid images See https://bugs.freedesktop.org/show_bug.cgi?id=39383 Signed-off-by: Kirill Elagin <kirelagin at gmail.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 53611213396479abfdce0f7752681572e0d26d78) diff --git a/fb/fbpict.c b/fb/fbpict.c index d1fd0cb..57c93fd 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -163,7 +163,9 @@ create_bits_picture (PicturePtr pict, (pixman_format_code_t)pict->format, pixmap->drawable.width, pixmap->drawable.height, (uint32_t *)bits, stride * sizeof (FbStride)); - + + if (!image) + return NULL; #ifdef FB_ACCESS_WRAPPER #if FB_SHIFT==5 commit b45e22675364915c32560c26404cf30d77ab68aa Author: Alan Hourihane <alanh at vmware.com> Date: Tue Oct 4 19:42:46 2011 -0700 dixfonts: Don't overwrite local c variable until new_closure is safely initialized. Signed-off-by: Alan Hourihane <alanh at vmware.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 7a33c5b934382b5554f41ab1502514e91c9bc52e) diff --git a/dix/dixfonts.c b/dix/dixfonts.c index fbac124..d2bcb84 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1302,31 +1302,30 @@ doPolyText(ClientPtr client, PTclosurePtr c) goto bail; } *new_closure = *c; - c = new_closure; - len = c->endReq - c->pElt; - c->data = malloc(len); - if (!c->data) + len = new_closure->endReq - new_closure->pElt; + new_closure->data = malloc(len); + if (!new_closure->data) { - free(c); + free(new_closure); err = BadAlloc; goto bail; } - memmove(c->data, c->pElt, len); - c->pElt = c->data; - c->endReq = c->pElt + len; + memmove(new_closure->data, new_closure->pElt, len); + new_closure->pElt = new_closure->data; + new_closure->endReq = new_closure->pElt + len; /* Step 2 */ - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); + pGC = GetScratchGC(new_closure->pGC->depth, new_closure->pGC->pScreen); if (!pGC) { - free(c->data); - free(c); + free(new_closure->data); + free(new_closure); err = BadAlloc; goto bail; } - if ((err = CopyGC(c->pGC, pGC, GCFunction | + if ((err = CopyGC(new_closure->pGC, pGC, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFillStyle | GCTile | GCStipple | @@ -1337,15 +1336,16 @@ doPolyText(ClientPtr client, PTclosurePtr c) Success) { FreeScratchGC(pGC); - free(c->data); - free(c); + free(new_closure->data); + free(new_closure); err = BadAlloc; goto bail; } + c = new_closure; origGC = c->pGC; c->pGC = pGC; ValidateGC(c->pDraw, c->pGC); - + ClientSleep(client, (ClientSleepProcPtr)doPolyText, c); /* Set up to perform steps 3 and 4 */ From jeremyhu at kemper.freedesktop.org Sun Oct 9 02:31:03 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 02:31:03 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111009093103.48096D8002@kemper.freedesktop.org> modules/im/ximcp/imRmAttr.c | 7 +++++-- nls/locale.alias.pre | 19 ------------------- 2 files changed, 5 insertions(+), 21 deletions(-) New commits: commit 913603660c17ec59a4d39d3e3b9d60469ee5c060 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 02:26:45 2011 -0700 Fix potential uninitialized variable access in _XimMakeICAttrIDList Found by clang static analysis Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 566ceaf5a92c721ac7155528e4d0d2e5cbef023f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 02:25:50 2011 -0700 Remove self-resolving aliases https://bugs.freedesktop.org/show_bug.cgi?id=30112 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 9 02:38:47 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 02:38:47 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111009093847.13159D8002@kemper.freedesktop.org> nls/pt_BR.UTF-8/Compose.pre | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 25d7bb9c705623ebbb3afba3b86d0ded5b6bb4fb Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 02:38:28 2011 -0700 Fix nobreakspace for pt_BR.UTF-8 https://bugs.freedesktop.org/show_bug.cgi?id=31334 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 9 03:53:34 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 03:53:34 -0700 (PDT) Subject: libpciaccess: Changes to 'master' Message-ID: <20111009105334.4B656D8002@kemper.freedesktop.org> configure.ac | 2 ++ scanpci/scanpci.c | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) New commits: commit b9c5ce8083be53ea017bd15a63b173b4476fff23 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 03:53:05 2011 -0700 scanpci: Build fix for systems without <err.h> https://bugs.freedesktop.org/show_bug.cgi?id=31133 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From mattst88 at kemper.freedesktop.org Sun Oct 9 11:02:08 2011 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Sun, 9 Oct 2011 11:02:08 -0700 (PDT) Subject: libXaw3d: Changes to 'master' Message-ID: <20111009180208.2A5FBD8002@kemper.freedesktop.org> src/List.c | 1 + src/XawIm.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) New commits: commit 942a17a30cffbe2e0208e486ae6e076a25fbeae3 Author: Matt Turner <mattst88 at gmail.com> Date: Thu Oct 6 22:30:43 2011 -0400 Remove unused variable 'i' Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Matt Turner <mattst88 at gmail.com> commit 802fb7f2c23a8885cc17de2a15cc4f0746c0f233 Author: Matt Turner <mattst88 at gmail.com> Date: Thu Oct 6 22:28:13 2011 -0400 Include stdlib.h for abs() Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Matt Turner <mattst88 at gmail.com> From mattst88 at kemper.freedesktop.org Sun Oct 9 12:57:35 2011 From: mattst88 at kemper.freedesktop.org (Matt Turner) Date: Sun, 9 Oct 2011 12:57:35 -0700 (PDT) Subject: libXaw3d: Changes to 'master' Message-ID: <20111009195735.C43BBD8002@kemper.freedesktop.org> src/Paned.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) New commits: commit a3696bd0798e9f40277b0b105764cea85650659a Author: Matt Turner <mattst88 at gmail.com> Date: Thu Oct 6 15:32:23 2011 -0400 Remove worthless isupper/islower checks Was toupper() *really* expensive when this was written? :) Also, initialize action_type with toupper(), since the check immediately following assumes that its value is uppercase. Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Matt Turner <mattst88 at gmail.com> From whot at kemper.freedesktop.org Sun Oct 9 17:23:44 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Sun, 9 Oct 2011 17:23:44 -0700 (PDT) Subject: libXi: Changes to 'master' Message-ID: <20111010002344.A3685D8002@kemper.freedesktop.org> src/XIQueryDevice.c | 1 - 1 file changed, 1 deletion(-) New commits: commit 7ca05f3094958c04e8f78a786061124c58f8e1f3 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Sep 28 11:16:42 2011 +1000 Remove superfluous assignment of lib->classes in XIQueryDevices. A few lines south from here we malloc lib->classes, this assignment is a leftover from 225071e2e67fb65a0258397212f9826c9b25e078. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Chase Douglas <chase.douglas at canonical.com> From whot at kemper.freedesktop.org Sun Oct 9 17:25:58 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Sun, 9 Oct 2011 17:25:58 -0700 (PDT) Subject: libXi: Changes to 'master' Message-ID: <20111010002558.E7C95D8002@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit c25debae73be50b9a77454ed4d72ffeaab726846 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 10 10:24:38 2011 +1000 Bump to 1.4.99.1 Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> From jeremyhu at kemper.freedesktop.org Sun Oct 9 18:47:37 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 18:47:37 -0700 (PDT) Subject: xf86-video-tdfx: Changes to 'master' Message-ID: <20111010014737.F179AD8002@kemper.freedesktop.org> src/tdfx_accel.c | 4 ++-- src/tdfx_dga.c | 4 ++-- src/tdfx_dri.c | 36 ++++++++++++++++++------------------ src/tdfx_driver.c | 26 +++++++++++++------------- src/tdfx_priv.c | 4 ++-- src/tdfx_video.c | 28 ++++++++++++++-------------- 6 files changed, 51 insertions(+), 51 deletions(-) New commits: commit f53f5a192025bec5547c2db16741e2a4eda20d74 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 18:47:27 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 9 18:48:37 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 18:48:37 -0700 (PDT) Subject: xf86-video-tdfx: Changes to 'master' Message-ID: <20111010014837.34AEDD8002@kemper.freedesktop.org> src/tdfx_priv.c | 2 ++ 1 file changed, 2 insertions(+) New commits: commit 3cdf7e280c5be1bc72e38460d6c46f4ae04efc37 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 18:48:15 2011 -0700 gettimeofday is in <sys/time.h> tdfx_priv.c:116:3: warning: implicit declaration of function ???gettimeofday??? Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 9 18:52:42 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 9 Oct 2011 18:52:42 -0700 (PDT) Subject: xf86-video-tdfx: Changes to 'master' Message-ID: <20111010015242.96DBCD8002@kemper.freedesktop.org> src/tdfx_sli.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) New commits: commit 3a97ecb50f326dbe0e1a3b3656806a8a2d2a1c3d Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 18:46:10 2011 -0700 Fix compiler warnings about signedness tdfx_sli.c:23:7: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:31:7: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:40:7: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:45:7: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c: In function ???TDFXSetupSLI???: tdfx_sli.c:155:2: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:161:4: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:163:4: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:165:4: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:175:4: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:275:7: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:764:2: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? tdfx_sli.c:768:2: warning: pointer targets in passing argument 2 of ???pci_device_cfg_read_u32??? differ in signedness /var/tmp/jhbuild/include/pciaccess.h:153:5: note: expected ???uint32_t *??? but argument is of type ???int *??? Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From podain at kemper.freedesktop.org Sun Oct 9 20:17:59 2011 From: podain at kemper.freedesktop.org (Taekyun Kim) Date: Sun, 9 Oct 2011 20:17:59 -0700 (PDT) Subject: pixman: Branch 'master' - 3 commits Message-ID: <20111010031759.A869DD8002@kemper.freedesktop.org> pixman/pixman-sse2.c | 428 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 349 insertions(+), 79 deletions(-) New commits: commit 4dcf1b0107334857e1f0bb203c34efed1146535c Author: Taekyun Kim <tkq.kim at samsung.com> Date: Wed Sep 7 23:00:29 2011 +0900 sse2: Bilinear scaled over_8888_8_8888 diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c index 9a79bda..c419511 100644 --- a/pixman/pixman-sse2.c +++ b/pixman/pixman-sse2.c @@ -5496,6 +5496,169 @@ FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_normal_OVER, uint32_t, uint32_t, uint32_t, NORMAL, FLAG_NONE) +static force_inline void +scaled_bilinear_scanline_sse2_8888_8_8888_OVER (uint32_t * dst, + const uint8_t * mask, + const uint32_t * src_top, + const uint32_t * src_bottom, + int32_t w, + int wt, + int wb, + pixman_fixed_t vx, + pixman_fixed_t unit_x, + pixman_fixed_t max_vx, + pixman_bool_t zero_src) +{ + BILINEAR_DECLARE_VARIABLES; + uint32_t pix1, pix2, pix3, pix4; + uint32_t m; + + while (w && ((unsigned long)dst & 15)) + { + uint32_t sa; + + m = (uint32_t) *mask++; + + if (m) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + sa = pix1 >> 24; + + if (sa == 0xff && m == 0xff) + { + *dst = pix1; + } + else + { + __m128i ms, md, ma, msa; + + pix2 = *dst; + ma = expand_alpha_rev_1x128 (load_32_1x128 (m)); + ms = unpack_32_1x128 (pix1); + md = unpack_32_1x128 (pix2); + + msa = expand_alpha_rev_1x128 (load_32_1x128 (sa)); + + *dst = pack_1x128_32 (in_over_1x128 (&ms, &msa, &ma, &md)); + } + } + else + { + BILINEAR_SKIP_ONE_PIXEL (); + } + + w--; + dst++; + } + + while (w >= 4) + { + __m128i xmm_src, xmm_src_lo, xmm_src_hi, xmm_srca_lo, xmm_srca_hi; + __m128i xmm_dst, xmm_dst_lo, xmm_dst_hi; + __m128i xmm_mask, xmm_mask_lo, xmm_mask_hi; + + m = *(uint32_t*)mask; + + if (m) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix2); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix3); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix4); + + xmm_src = _mm_set_epi32 (pix4, pix3, pix2, pix1); + + if (m == 0xffffffff && is_opaque (xmm_src)) + { + save_128_aligned ((__m128i *)dst, xmm_src); + } + else + { + xmm_dst = load_128_aligned ((__m128i *)dst); + + xmm_mask = _mm_unpacklo_epi16 (unpack_32_1x128 (m), _mm_setzero_si128()); + + unpack_128_2x128 (xmm_src, &xmm_src_lo, &xmm_src_hi); + unpack_128_2x128 (xmm_mask, &xmm_mask_lo, &xmm_mask_hi); + unpack_128_2x128 (xmm_dst, &xmm_dst_lo, &xmm_dst_hi); + + expand_alpha_2x128 (xmm_src_lo, xmm_src_hi, &xmm_srca_lo, &xmm_srca_hi); + expand_alpha_rev_2x128 (xmm_mask_lo, xmm_mask_hi, &xmm_mask_lo, &xmm_mask_hi); + + in_over_2x128 (&xmm_src_lo, &xmm_src_hi, &xmm_srca_lo, &xmm_srca_hi, + &xmm_mask_lo, &xmm_mask_hi, &xmm_dst_lo, &xmm_dst_hi); + + save_128_aligned ((__m128i*)dst, pack_2x128_128 (xmm_dst_lo, xmm_dst_hi)); + } + } + else + { + BILINEAR_SKIP_ONE_PIXEL (); + BILINEAR_SKIP_ONE_PIXEL (); + BILINEAR_SKIP_ONE_PIXEL (); + BILINEAR_SKIP_ONE_PIXEL (); + } + + w -= 4; + dst += 4; + mask += 4; + } + + while (w) + { + uint32_t sa; + + m = (uint32_t) *mask++; + + if (m) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + sa = pix1 >> 24; + + if (sa == 0xff && m == 0xff) + { + *dst = pix1; + } + else + { + __m128i ms, md, ma, msa; + + pix2 = *dst; + ma = expand_alpha_rev_1x128 (load_32_1x128 (m)); + ms = unpack_32_1x128 (pix1); + md = unpack_32_1x128 (pix2); + + msa = expand_alpha_rev_1x128 (load_32_1x128 (sa)); + + *dst = pack_1x128_32 (in_over_1x128 (&ms, &msa, &ma, &md)); + } + } + else + { + BILINEAR_SKIP_ONE_PIXEL (); + } + + w--; + dst++; + } +} + +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_cover_OVER, + scaled_bilinear_scanline_sse2_8888_8_8888_OVER, + uint32_t, uint8_t, uint32_t, + COVER, FLAG_HAVE_NON_SOLID_MASK) +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_pad_OVER, + scaled_bilinear_scanline_sse2_8888_8_8888_OVER, + uint32_t, uint8_t, uint32_t, + PAD, FLAG_HAVE_NON_SOLID_MASK) +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_none_OVER, + scaled_bilinear_scanline_sse2_8888_8_8888_OVER, + uint32_t, uint8_t, uint32_t, + NONE, FLAG_HAVE_NON_SOLID_MASK) +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_normal_OVER, + scaled_bilinear_scanline_sse2_8888_8_8888_OVER, + uint32_t, uint8_t, uint32_t, + NORMAL, FLAG_HAVE_NON_SOLID_MASK) static const pixman_fast_path_t sse2_fast_paths[] = { @@ -5607,6 +5770,11 @@ static const pixman_fast_path_t sse2_fast_paths[] = SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, sse2_8888_8888), SIMPLE_BILINEAR_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, sse2_8888_8888), + SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, sse2_8888_8_8888), + SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, sse2_8888_8_8888), + SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, sse2_8888_8_8888), + SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, sse2_8888_8_8888), + { PIXMAN_OP_NONE }, }; commit 81050f2784407b260a1897efa921631a19eeec6b Author: Taekyun Kim <tkq.kim at samsung.com> Date: Wed Sep 7 22:57:29 2011 +0900 sse2: Bilinear scaled over_8888_8888 diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c index 0bfd26b..9a79bda 100644 --- a/pixman/pixman-sse2.c +++ b/pixman/pixman-sse2.c @@ -5396,6 +5396,107 @@ FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_normal_SRC, uint32_t, uint32_t, uint32_t, NORMAL, FLAG_NONE) +static force_inline void +scaled_bilinear_scanline_sse2_8888_8888_OVER (uint32_t * dst, + const uint32_t * mask, + const uint32_t * src_top, + const uint32_t * src_bottom, + int32_t w, + int wt, + int wb, + pixman_fixed_t vx, + pixman_fixed_t unit_x, + pixman_fixed_t max_vx, + pixman_bool_t zero_src) +{ + BILINEAR_DECLARE_VARIABLES; + uint32_t pix1, pix2, pix3, pix4; + + while (w && ((unsigned long)dst & 15)) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + + if (pix1) + { + pix2 = *dst; + *dst = core_combine_over_u_pixel_sse2 (pix1, pix2); + } + + w--; + dst++; + } + + while (w >= 4) + { + __m128i xmm_src; + __m128i xmm_src_hi, xmm_src_lo, xmm_dst_hi, xmm_dst_lo; + __m128i xmm_alpha_hi, xmm_alpha_lo; + + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix2); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix3); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix4); + + xmm_src = _mm_set_epi32 (pix4, pix3, pix2, pix1); + + if (!is_zero (xmm_src)) + { + if (is_opaque (xmm_src)) + { + save_128_aligned ((__m128i *)dst, xmm_src); + } + else + { + __m128i xmm_dst = load_128_aligned ((__m128i *)dst); + + unpack_128_2x128 (xmm_src, &xmm_src_lo, &xmm_src_hi); + unpack_128_2x128 (xmm_dst, &xmm_dst_lo, &xmm_dst_hi); + + expand_alpha_2x128 (xmm_src_lo, xmm_src_hi, &xmm_alpha_lo, &xmm_alpha_hi); + over_2x128 (&xmm_src_lo, &xmm_src_hi, &xmm_alpha_lo, &xmm_alpha_hi, + &xmm_dst_lo, &xmm_dst_hi); + + save_128_aligned ((__m128i *)dst, pack_2x128_128 (xmm_dst_lo, xmm_dst_hi)); + } + } + + w -= 4; + dst += 4; + } + + while (w) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + + if (pix1) + { + pix2 = *dst; + *dst = core_combine_over_u_pixel_sse2 (pix1, pix2); + } + + w--; + dst++; + } +} + +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_cover_OVER, + scaled_bilinear_scanline_sse2_8888_8888_OVER, + uint32_t, uint32_t, uint32_t, + COVER, FLAG_NONE) +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_pad_OVER, + scaled_bilinear_scanline_sse2_8888_8888_OVER, + uint32_t, uint32_t, uint32_t, + PAD, FLAG_NONE) +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_none_OVER, + scaled_bilinear_scanline_sse2_8888_8888_OVER, + uint32_t, uint32_t, uint32_t, + NONE, FLAG_NONE) +FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_normal_OVER, + scaled_bilinear_scanline_sse2_8888_8888_OVER, + uint32_t, uint32_t, uint32_t, + NORMAL, FLAG_NONE) + + static const pixman_fast_path_t sse2_fast_paths[] = { /* PIXMAN_OP_OVER */ @@ -5501,10 +5602,14 @@ static const pixman_fast_path_t sse2_fast_paths[] = SIMPLE_BILINEAR_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, sse2_8888_8888), SIMPLE_BILINEAR_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, sse2_8888_8888), + SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, sse2_8888_8888), + SIMPLE_BILINEAR_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, sse2_8888_8888), + SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, sse2_8888_8888), + SIMPLE_BILINEAR_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, sse2_8888_8888), + { PIXMAN_OP_NONE }, }; - static pixman_bool_t sse2_blt (pixman_implementation_t *imp, uint32_t * src_bits, commit d67c0b883daeeaacf3f21f1ddbdcf9ecf94fac43 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Wed Sep 7 22:51:46 2011 +0900 sse2: Macros for assembling bilinear interpolation code fractions Primitive bilinear interpolation code is reusable to implement other bilinear functions. BILINEAR_DECLARE_VARIABLES - Declare variables needed to interpolate src pixels. BILINEAR_INTERPOLATE_ONE_PIXEL - Interpolate one pixel and advance to next pixel BILINEAR_SKIP_ONE_PIXEL - Skip interpolation and just advance to next pixel This is useful for skipping zero mask diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c index 6689c53..0bfd26b 100644 --- a/pixman/pixman-sse2.c +++ b/pixman/pixman-sse2.c @@ -5287,83 +5287,53 @@ FAST_NEAREST_MAINLOOP_COMMON (sse2_8888_n_8888_none_OVER, scaled_nearest_scanline_sse2_8888_n_8888_OVER, uint32_t, uint32_t, uint32_t, NONE, TRUE, TRUE) -static void -bilinear_interpolate_line_sse2 (uint32_t * out, - const uint32_t * top, - const uint32_t * bottom, - int wt, - int wb, - pixman_fixed_t x, - pixman_fixed_t ux, - int width) -{ - const __m128i xmm_wt = _mm_set_epi16 (wt, wt, wt, wt, wt, wt, wt, wt); - const __m128i xmm_wb = _mm_set_epi16 (wb, wb, wb, wb, wb, wb, wb, wb); - const __m128i xmm_xorc = _mm_set_epi16 (0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff); - const __m128i xmm_addc = _mm_set_epi16 (0, 0, 0, 0, 1, 1, 1, 1); - const __m128i xmm_ux = _mm_set_epi16 (ux, ux, ux, ux, ux, ux, ux, ux); - const __m128i xmm_zero = _mm_setzero_si128 (); - __m128i xmm_x = _mm_set_epi16 (x, x, x, x, x, x, x, x); - uint32_t pix1, pix2, pix3, pix4; - - #define INTERPOLATE_ONE_PIXEL(pix) \ - do { \ - __m128i xmm_wh, xmm_lo, xmm_hi, a; \ - /* fetch 2x2 pixel block into sse2 register */ \ - uint32_t tl = top [pixman_fixed_to_int (x)]; \ - uint32_t tr = top [pixman_fixed_to_int (x) + 1]; \ - uint32_t bl = bottom [pixman_fixed_to_int (x)]; \ - uint32_t br = bottom [pixman_fixed_to_int (x) + 1]; \ - a = _mm_set_epi32 (tr, tl, br, bl); \ - x += ux; \ - /* vertical interpolation */ \ - a = _mm_add_epi16 (_mm_mullo_epi16 (_mm_unpackhi_epi8 (a, xmm_zero), \ - xmm_wt), \ - _mm_mullo_epi16 (_mm_unpacklo_epi8 (a, xmm_zero), \ - xmm_wb)); \ - /* calculate horizontal weights */ \ - xmm_wh = _mm_add_epi16 (xmm_addc, \ - _mm_xor_si128 (xmm_xorc, \ - _mm_srli_epi16 (xmm_x, 8))); \ - xmm_x = _mm_add_epi16 (xmm_x, xmm_ux); \ - /* horizontal interpolation */ \ - xmm_lo = _mm_mullo_epi16 (a, xmm_wh); \ - xmm_hi = _mm_mulhi_epu16 (a, xmm_wh); \ - a = _mm_add_epi32 (_mm_unpacklo_epi16 (xmm_lo, xmm_hi), \ - _mm_unpackhi_epi16 (xmm_lo, xmm_hi)); \ - /* shift and pack the result */ \ - a = _mm_srli_epi32 (a, 16); \ - a = _mm_packs_epi32 (a, a); \ - a = _mm_packus_epi16 (a, a); \ - pix = _mm_cvtsi128_si32 (a); \ - } while (0) - - while ((width -= 4) >= 0) - { - INTERPOLATE_ONE_PIXEL (pix1); - INTERPOLATE_ONE_PIXEL (pix2); - INTERPOLATE_ONE_PIXEL (pix3); - INTERPOLATE_ONE_PIXEL (pix4); - *out++ = pix1; - *out++ = pix2; - *out++ = pix3; - *out++ = pix4; - } - if (width & 2) - { - INTERPOLATE_ONE_PIXEL (pix1); - INTERPOLATE_ONE_PIXEL (pix2); - *out++ = pix1; - *out++ = pix2; - } - if (width & 1) - { - INTERPOLATE_ONE_PIXEL (pix1); - *out = pix1; - } - - #undef INTERPOLATE_ONE_PIXEL -} +#define BILINEAR_DECLARE_VARIABLES \ + const __m128i xmm_wt = _mm_set_epi16 (wt, wt, wt, wt, wt, wt, wt, wt); \ + const __m128i xmm_wb = _mm_set_epi16 (wb, wb, wb, wb, wb, wb, wb, wb); \ + const __m128i xmm_xorc = _mm_set_epi16 (0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff);\ + const __m128i xmm_addc = _mm_set_epi16 (0, 0, 0, 0, 1, 1, 1, 1); \ + const __m128i xmm_ux = _mm_set_epi16 (unit_x, unit_x, unit_x, unit_x, \ + unit_x, unit_x, unit_x, unit_x); \ + const __m128i xmm_zero = _mm_setzero_si128 (); \ + __m128i xmm_x = _mm_set_epi16 (vx, vx, vx, vx, vx, vx, vx, vx) + +#define BILINEAR_INTERPOLATE_ONE_PIXEL(pix) \ +do { \ + __m128i xmm_wh, xmm_lo, xmm_hi, a; \ + /* fetch 2x2 pixel block into sse2 register */ \ + uint32_t tl = src_top [pixman_fixed_to_int (vx)]; \ + uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1]; \ + uint32_t bl = src_bottom [pixman_fixed_to_int (vx)]; \ + uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1]; \ + a = _mm_set_epi32 (tr, tl, br, bl); \ + vx += unit_x; \ + /* vertical interpolation */ \ + a = _mm_add_epi16 (_mm_mullo_epi16 (_mm_unpackhi_epi8 (a, xmm_zero), \ + xmm_wt), \ + _mm_mullo_epi16 (_mm_unpacklo_epi8 (a, xmm_zero), \ + xmm_wb)); \ + /* calculate horizontal weights */ \ + xmm_wh = _mm_add_epi16 (xmm_addc, \ + _mm_xor_si128 (xmm_xorc, \ + _mm_srli_epi16 (xmm_x, 8))); \ + xmm_x = _mm_add_epi16 (xmm_x, xmm_ux); \ + /* horizontal interpolation */ \ + xmm_lo = _mm_mullo_epi16 (a, xmm_wh); \ + xmm_hi = _mm_mulhi_epu16 (a, xmm_wh); \ + a = _mm_add_epi32 (_mm_unpacklo_epi16 (xmm_lo, xmm_hi), \ + _mm_unpackhi_epi16 (xmm_lo, xmm_hi)); \ + /* shift and pack the result */ \ + a = _mm_srli_epi32 (a, 16); \ + a = _mm_packs_epi32 (a, a); \ + a = _mm_packus_epi16 (a, a); \ + pix = _mm_cvtsi128_si32 (a); \ +} while (0) + +#define BILINEAR_SKIP_ONE_PIXEL() \ +do { \ + vx += unit_x; \ + xmm_x = _mm_add_epi16 (xmm_x, xmm_ux); \ +} while(0) static force_inline void scaled_bilinear_scanline_sse2_8888_8888_SRC (uint32_t * dst, @@ -5378,8 +5348,35 @@ scaled_bilinear_scanline_sse2_8888_8888_SRC (uint32_t * dst, pixman_fixed_t max_vx, pixman_bool_t zero_src) { - bilinear_interpolate_line_sse2 (dst, src_top, src_bottom, - wt, wb, vx, unit_x, w); + BILINEAR_DECLARE_VARIABLES; + uint32_t pix1, pix2, pix3, pix4; + + while ((w -= 4) >= 0) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix2); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix3); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix4); + *dst++ = pix1; + *dst++ = pix2; + *dst++ = pix3; + *dst++ = pix4; + } + + if (w & 2) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + BILINEAR_INTERPOLATE_ONE_PIXEL (pix2); + *dst++ = pix1; + *dst++ = pix2; + } + + if (w & 1) + { + BILINEAR_INTERPOLATE_ONE_PIXEL (pix1); + *dst = pix1; + } + } FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_cover_SRC, @@ -5399,7 +5396,6 @@ FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_normal_SRC, uint32_t, uint32_t, uint32_t, NORMAL, FLAG_NONE) - static const pixman_fast_path_t sse2_fast_paths[] = { /* PIXMAN_OP_OVER */ @@ -5508,6 +5504,7 @@ static const pixman_fast_path_t sse2_fast_paths[] = { PIXMAN_OP_NONE }, }; + static pixman_bool_t sse2_blt (pixman_implementation_t *imp, uint32_t * src_bits, From podain at kemper.freedesktop.org Sun Oct 9 20:23:50 2011 From: podain at kemper.freedesktop.org (Taekyun Kim) Date: Sun, 9 Oct 2011 20:23:50 -0700 (PDT) Subject: pixman: Branch 'master' - 6 commits Message-ID: <20111010032350.378D7D8002@kemper.freedesktop.org> pixman/pixman-bits-image.c | 74 +++++++++++------- pixman/pixman-fast-path.c | 178 +++++++++++++++++++++++++++++++++++++++++++++ pixman/pixman-image.c | 111 +++++++++++++++------------- pixman/pixman-private.h | 29 +++++++ pixman/pixman-utils.c | 112 ++++++++++++++++++++++++++++ pixman/pixman.c | 123 +------------------------------ 6 files changed, 435 insertions(+), 192 deletions(-) New commits: commit a43946a51fbbdc76be1af9bc25fe7c5c2a6314bb Author: Taekyun Kim <tkq.kim at samsung.com> Date: Thu Sep 22 18:42:38 2011 +0900 Simple repeat: Extend too short source scanlines into temporary buffer Too short scanlines can cause repeat handling overhead and optimized pixman composite functions usually process a bunch of pixels in a single loop iteration it might be beneficial to pre-extend source scanlines. The temporary buffers will usually reside in cache, so accessing them should be quite efficient. diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c index 89c973a..038dcf7 100644 --- a/pixman/pixman-fast-path.c +++ b/pixman/pixman-fast-path.c @@ -1191,6 +1191,8 @@ FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE) FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD) FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL) +#define REPEAT_MIN_WIDTH 32 + static void fast_composite_tiled_repeat (pixman_implementation_t *imp, pixman_composite_info_t *info) @@ -1224,27 +1226,111 @@ fast_composite_tiled_repeat (pixman_implementation_t *imp, int32_t sx, sy; int32_t width_remain; int32_t num_pixels; + int32_t src_width; + int32_t i, j; + pixman_image_t extended_src_image; + uint32_t extended_src[REPEAT_MIN_WIDTH * 2]; + pixman_bool_t need_src_extension; + uint32_t *src_line; + int32_t src_stride; + int32_t src_bpp; pixman_composite_info_t info2 = *info; + src_bpp = PIXMAN_FORMAT_BPP (src_image->bits.format); + + if (src_image->bits.width < REPEAT_MIN_WIDTH && + (src_bpp == 32 || src_bpp == 16 || src_bpp == 8)) + { + sx = src_x; + sx = MOD (sx, src_image->bits.width); + sx += width; + src_width = 0; + + while (src_width < REPEAT_MIN_WIDTH && src_width <= sx) + src_width += src_image->bits.width; + + src_stride = (src_width * (src_bpp >> 3) + 3) / (int) sizeof (uint32_t); + + /* Initialize/validate stack-allocated temporary image */ + _pixman_bits_image_init (&extended_src_image, src_image->bits.format, + src_width, 1, &extended_src[0], src_stride); + _pixman_image_validate (&extended_src_image); + + info2.src_image = &extended_src_image; + need_src_extension = TRUE; + } + else + { + src_width = src_image->bits.width; + need_src_extension = FALSE; + } + sx = src_x; sy = src_y; while (--height >= 0) { - sx = MOD (sx, src_image->bits.width); + sx = MOD (sx, src_width); sy = MOD (sy, src_image->bits.height); + if (need_src_extension) + { + if (src_bpp == 32) + { + PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint32_t, src_stride, src_line, 1); + + for (i = 0; i < src_width; ) + { + for (j = 0; j < src_image->bits.width; j++, i++) + extended_src[i] = src_line[j]; + } + } + else if (src_bpp == 16) + { + uint16_t *src_line_16; + + PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint16_t, src_stride, + src_line_16, 1); + src_line = (uint32_t*)src_line_16; + + for (i = 0; i < src_width; ) + { + for (j = 0; j < src_image->bits.width; j++, i++) + ((uint16_t*)extended_src)[i] = ((uint16_t*)src_line)[j]; + } + } + else if (src_bpp == 8) + { + uint8_t *src_line_8; + + PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint8_t, src_stride, + src_line_8, 1); + src_line = (uint32_t*)src_line_8; + + for (i = 0; i < src_width; ) + { + for (j = 0; j < src_image->bits.width; j++, i++) + ((uint8_t*)extended_src)[i] = ((uint8_t*)src_line)[j]; + } + } + + info2.src_y = 0; + } + else + { + info2.src_y = sy; + } + width_remain = width; while (width_remain > 0) { - num_pixels = src_image->bits.width - sx; + num_pixels = src_width - sx; if (num_pixels > width_remain) num_pixels = width_remain; info2.src_x = sx; - info2.src_y = sy; info2.width = num_pixels; info2.height = 1; @@ -1263,6 +1349,9 @@ fast_composite_tiled_repeat (pixman_implementation_t *imp, info2.dest_x = info->dest_x; info2.dest_y++; } + + if (need_src_extension) + _pixman_image_fini (&extended_src_image); } else { commit eaff774a3f8af6651a245711b9ab8af3211eeb10 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Mon Aug 29 21:44:36 2011 +0900 Simple repeat fast path We can implement simple repeat by stitching existing fast path functions. First lookup COVER_CLIP function for given input and then stitch horizontally using the function. diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c index 033efd7..89c973a 100644 --- a/pixman/pixman-fast-path.c +++ b/pixman/pixman-fast-path.c @@ -1191,6 +1191,85 @@ FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE) FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD) FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL) +static void +fast_composite_tiled_repeat (pixman_implementation_t *imp, + pixman_composite_info_t *info) +{ + PIXMAN_COMPOSITE_ARGS (info); + pixman_composite_func_t func; + pixman_format_code_t mask_format; + uint32_t src_flags, mask_flags; + + src_flags = (info->src_flags & ~FAST_PATH_NORMAL_REPEAT) | + FAST_PATH_SAMPLES_COVER_CLIP_NEAREST; + + if (mask_image) + { + mask_format = mask_image->common.extended_format_code; + mask_flags = info->mask_flags; + } + else + { + mask_format = PIXMAN_null; + mask_flags = FAST_PATH_IS_OPAQUE; + } + + if (_pixman_lookup_composite_function ( + imp->toplevel, info->op, + src_image->common.extended_format_code, src_flags, + mask_format, mask_flags, + dest_image->common.extended_format_code, info->dest_flags, + &imp, &func)) + { + int32_t sx, sy; + int32_t width_remain; + int32_t num_pixels; + pixman_composite_info_t info2 = *info; + + sx = src_x; + sy = src_y; + + while (--height >= 0) + { + sx = MOD (sx, src_image->bits.width); + sy = MOD (sy, src_image->bits.height); + + width_remain = width; + + while (width_remain > 0) + { + num_pixels = src_image->bits.width - sx; + + if (num_pixels > width_remain) + num_pixels = width_remain; + + info2.src_x = sx; + info2.src_y = sy; + info2.width = num_pixels; + info2.height = 1; + + func (imp, &info2); + + width_remain -= num_pixels; + info2.mask_x += num_pixels; + info2.dest_x += num_pixels; + sx = 0; + } + + sx = src_x; + sy++; + info2.mask_x = info->mask_x; + info2.mask_y++; + info2.dest_x = info->dest_x; + info2.dest_y++; + } + } + else + { + _pixman_log_error (FUNC, "Didn't find a suitable function "); + } +} + /* Use more unrolling for src_0565_0565 because it is typically CPU bound */ static force_inline void scaled_nearest_scanline_565_565_SRC (uint16_t * dst, @@ -1787,6 +1866,16 @@ static const pixman_fast_path_t c_fast_paths[] = SIMPLE_ROTATE_FAST_PATH (SRC, r5g6b5, r5g6b5, 565), SIMPLE_ROTATE_FAST_PATH (SRC, a8, a8, 8), + /* Simple repeat fast path entry. */ + { PIXMAN_OP_any, + PIXMAN_any, + (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE | + FAST_PATH_NORMAL_REPEAT), + PIXMAN_any, 0, + PIXMAN_any, FAST_PATH_STD_DEST_FLAGS, + fast_composite_tiled_repeat + }, + { PIXMAN_OP_NONE }, }; commit a258e33fcb6cf08a2ef76e374cb92a12c9adb171 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Thu Sep 22 16:33:02 2011 +0900 Move _pixman_lookup_composite_function() to pixman-utils.c diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index c315220..cbd48f3 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -730,6 +730,17 @@ pixman_contract (uint32_t * dst, const uint64_t *src, int width); +pixman_bool_t +_pixman_lookup_composite_function (pixman_implementation_t *toplevel, + pixman_op_t op, + pixman_format_code_t src_format, + uint32_t src_flags, + pixman_format_code_t mask_format, + uint32_t mask_flags, + pixman_format_code_t dest_format, + uint32_t dest_flags, + pixman_implementation_t **out_imp, + pixman_composite_func_t *out_func); /* Region Helpers */ pixman_bool_t diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c index 768ca1b..d2af51a 100644 --- a/pixman/pixman-utils.c +++ b/pixman/pixman-utils.c @@ -30,6 +30,118 @@ #include "pixman-private.h" +#define N_CACHED_FAST_PATHS 8 + +typedef struct +{ + struct + { + pixman_implementation_t * imp; + pixman_fast_path_t fast_path; + } cache [N_CACHED_FAST_PATHS]; +} cache_t; + +PIXMAN_DEFINE_THREAD_LOCAL (cache_t, fast_path_cache); + +pixman_bool_t +_pixman_lookup_composite_function (pixman_implementation_t *toplevel, + pixman_op_t op, + pixman_format_code_t src_format, + uint32_t src_flags, + pixman_format_code_t mask_format, + uint32_t mask_flags, + pixman_format_code_t dest_format, + uint32_t dest_flags, + pixman_implementation_t **out_imp, + pixman_composite_func_t *out_func) +{ + pixman_implementation_t *imp; + cache_t *cache; + int i; + + /* Check cache for fast paths */ + cache = PIXMAN_GET_THREAD_LOCAL (fast_path_cache); + + for (i = 0; i < N_CACHED_FAST_PATHS; ++i) + { + const pixman_fast_path_t *info = &(cache->cache[i].fast_path); + + /* Note that we check for equality here, not whether + * the cached fast path matches. This is to prevent + * us from selecting an overly general fast path + * when a more specific one would work. + */ + if (info->op == op && + info->src_format == src_format && + info->mask_format == mask_format && + info->dest_format == dest_format && + info->src_flags == src_flags && + info->mask_flags == mask_flags && + info->dest_flags == dest_flags && + info->func) + { + *out_imp = cache->cache[i].imp; + *out_func = cache->cache[i].fast_path.func; + + goto update_cache; + } + } + + for (imp = toplevel; imp != NULL; imp = imp->delegate) + { + const pixman_fast_path_t *info = imp->fast_paths; + + while (info->op != PIXMAN_OP_NONE) + { + if ((info->op == op || info->op == PIXMAN_OP_any) && + /* Formats */ + ((info->src_format == src_format) || + (info->src_format == PIXMAN_any)) && + ((info->mask_format == mask_format) || + (info->mask_format == PIXMAN_any)) && + ((info->dest_format == dest_format) || + (info->dest_format == PIXMAN_any)) && + /* Flags */ + (info->src_flags & src_flags) == info->src_flags && + (info->mask_flags & mask_flags) == info->mask_flags && + (info->dest_flags & dest_flags) == info->dest_flags) + { + *out_imp = imp; + *out_func = info->func; + + /* Set i to the last spot in the cache so that the + * move-to-front code below will work + */ + i = N_CACHED_FAST_PATHS - 1; + + goto update_cache; + } + + ++info; + } + } + return FALSE; + +update_cache: + if (i) + { + while (i--) + cache->cache[i + 1] = cache->cache[i]; + + cache->cache[0].imp = *out_imp; + cache->cache[0].fast_path.op = op; + cache->cache[0].fast_path.src_format = src_format; + cache->cache[0].fast_path.src_flags = src_flags; + cache->cache[0].fast_path.mask_format = mask_format; + cache->cache[0].fast_path.mask_flags = mask_flags; + cache->cache[0].fast_path.dest_format = dest_format; + cache->cache[0].fast_path.dest_flags = dest_flags; + cache->cache[0].fast_path.func = *out_func; + } + + return TRUE; +} + pixman_bool_t _pixman_multiply_overflows_size (size_t a, size_t b) { diff --git a/pixman/pixman.c b/pixman/pixman.c index 8ff78e9..8fb5356 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -335,117 +335,6 @@ pixman_compute_composite_region32 (pixman_region32_t * region, return TRUE; } -#define N_CACHED_FAST_PATHS 8 - -typedef struct -{ - struct - { - pixman_implementation_t * imp; - pixman_fast_path_t fast_path; - } cache [N_CACHED_FAST_PATHS]; -} cache_t; - -PIXMAN_DEFINE_THREAD_LOCAL (cache_t, fast_path_cache); - -static force_inline pixman_bool_t -lookup_composite_function (pixman_op_t op, - pixman_format_code_t src_format, - uint32_t src_flags, - pixman_format_code_t mask_format, - uint32_t mask_flags, - pixman_format_code_t dest_format, - uint32_t dest_flags, - pixman_implementation_t **out_imp, - pixman_composite_func_t *out_func) -{ - pixman_implementation_t *imp; - cache_t *cache; - int i; - - /* Check cache for fast paths */ - cache = PIXMAN_GET_THREAD_LOCAL (fast_path_cache); - - for (i = 0; i < N_CACHED_FAST_PATHS; ++i) - { - const pixman_fast_path_t *info = &(cache->cache[i].fast_path); - - /* Note that we check for equality here, not whether - * the cached fast path matches. This is to prevent - * us from selecting an overly general fast path - * when a more specific one would work. - */ - if (info->op == op && - info->src_format == src_format && - info->mask_format == mask_format && - info->dest_format == dest_format && - info->src_flags == src_flags && - info->mask_flags == mask_flags && - info->dest_flags == dest_flags && - info->func) - { - *out_imp = cache->cache[i].imp; - *out_func = cache->cache[i].fast_path.func; - - goto update_cache; - } - } - - for (imp = get_implementation (); imp != NULL; imp = imp->delegate) - { - const pixman_fast_path_t *info = imp->fast_paths; - - while (info->op != PIXMAN_OP_NONE) - { - if ((info->op == op || info->op == PIXMAN_OP_any) && - /* Formats */ - ((info->src_format == src_format) || - (info->src_format == PIXMAN_any)) && - ((info->mask_format == mask_format) || - (info->mask_format == PIXMAN_any)) && - ((info->dest_format == dest_format) || - (info->dest_format == PIXMAN_any)) && - /* Flags */ - (info->src_flags & src_flags) == info->src_flags && - (info->mask_flags & mask_flags) == info->mask_flags && - (info->dest_flags & dest_flags) == info->dest_flags) - { - *out_imp = imp; - *out_func = info->func; - - /* Set i to the last spot in the cache so that the - * move-to-front code below will work - */ - i = N_CACHED_FAST_PATHS - 1; - - goto update_cache; - } - - ++info; - } - } - return FALSE; - -update_cache: - if (i) - { - while (i--) - cache->cache[i + 1] = cache->cache[i]; - - cache->cache[0].imp = *out_imp; - cache->cache[0].fast_path.op = op; - cache->cache[0].fast_path.src_format = src_format; - cache->cache[0].fast_path.src_flags = src_flags; - cache->cache[0].fast_path.mask_format = mask_format; - cache->cache[0].fast_path.mask_flags = mask_flags; - cache->cache[0].fast_path.dest_format = dest_format; - cache->cache[0].fast_path.dest_flags = dest_flags; - cache->cache[0].fast_path.func = *out_func; - } - - return TRUE; -} - typedef struct { pixman_fixed_48_16_t x1; @@ -790,11 +679,10 @@ pixman_image_composite32 (pixman_op_t op, */ op = optimize_operator (op, src_flags, mask_flags, dest_flags); - if (lookup_composite_function (op, - src_format, src_flags, - mask_format, mask_flags, - dest_format, dest_flags, - &imp, &func)) + if (_pixman_lookup_composite_function ( + get_implementation (), op, + src_format, src_flags, mask_format, mask_flags, dest_format, dest_flags, + &imp, &func)) { pixman_composite_info_t info; const pixman_box32_t *pbox; commit fc62785aabbe890b656c9cbaa57f2e65e74bbcc2 Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Mon Jun 27 21:17:04 2011 +0000 Add src, mask, and dest flags to the composite args struct. These flags are useful in the various compositing routines, and the flags stored in the image structs are missing some bits of information that can only be computed when pixman_image_composite() is called. diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 741fa7e..c315220 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -373,6 +373,10 @@ typedef struct int32_t dest_y; int32_t width; int32_t height; + + uint32_t src_flags; + uint32_t mask_flags; + uint32_t dest_flags; } pixman_composite_info_t; #define PIXMAN_COMPOSITE_ARGS(info) \ diff --git a/pixman/pixman.c b/pixman/pixman.c index 87f5a93..8ff78e9 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -804,6 +804,9 @@ pixman_image_composite32 (pixman_op_t op, info.src_image = src; info.mask_image = mask; info.dest_image = dest; + info.src_flags = src_flags; + info.mask_flags = mask_flags; + info.dest_flags = dest_flags; pbox = pixman_region32_rectangles (®ion, &n); commit fa6523d13ae9b7986bb890df5ad66e8599bc3ed8 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Thu Sep 22 16:26:55 2011 +0900 Add new fast path flag FAST_PATH_BITS_IMAGE This fast path flag indicate that type of the image is bits image. diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index d22698c..afe587f 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -375,6 +375,7 @@ compute_image_info (pixman_image_t *image) else { code = image->bits.format; + flags |= FAST_PATH_BITS_IMAGE; } if (!PIXMAN_FORMAT_A (image->bits.format) && diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 69971ea..741fa7e 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -631,6 +631,7 @@ _pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask); #define FAST_PATH_ROTATE_270_TRANSFORM (1 << 22) #define FAST_PATH_SAMPLES_COVER_CLIP_NEAREST (1 << 23) #define FAST_PATH_SAMPLES_COVER_CLIP_BILINEAR (1 << 24) +#define FAST_PATH_BITS_IMAGE (1 << 25) #define FAST_PATH_PAD_REPEAT \ (FAST_PATH_NO_NONE_REPEAT | \ commit 7272e2fcd2ff8e546cef19929cd370ae2f946135 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Thu Sep 22 16:20:03 2011 +0900 init/fini functions for pixman_image_t pixman_image_t itself can be on stack or heap. So segregating init/fini from create/unref can be useful when we want to use pixman_image_t on stack or other memory. diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index f382c65..99c0dfe 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -1437,40 +1437,30 @@ create_bits (pixman_format_code_t format, return calloc (buf_size, 1); } -PIXMAN_EXPORT pixman_image_t * -pixman_image_create_bits (pixman_format_code_t format, - int width, - int height, - uint32_t * bits, - int rowstride_bytes) +pixman_bool_t +_pixman_bits_image_init (pixman_image_t * image, + pixman_format_code_t format, + int width, + int height, + uint32_t * bits, + int rowstride) { - pixman_image_t *image; uint32_t *free_me = NULL; - /* must be a whole number of uint32_t's - */ - return_val_if_fail ( - bits == NULL || (rowstride_bytes % sizeof (uint32_t)) == 0, NULL); - - return_val_if_fail (PIXMAN_FORMAT_BPP (format) >= PIXMAN_FORMAT_DEPTH (format), NULL); - if (!bits && width && height) { - free_me = bits = create_bits (format, width, height, &rowstride_bytes); - if (!bits) - return NULL; - } + int rowstride_bytes; - image = _pixman_image_allocate (); + free_me = bits = create_bits (format, width, height, &rowstride_bytes); - if (!image) - { - if (free_me) - free (free_me); + if (!bits) + return FALSE; - return NULL; + rowstride = rowstride_bytes / (int) sizeof (uint32_t); } + _pixman_image_init (image); + image->type = BITS; image->bits.format = format; image->bits.width = width; @@ -1479,15 +1469,43 @@ pixman_image_create_bits (pixman_format_code_t format, image->bits.free_me = free_me; image->bits.read_func = NULL; image->bits.write_func = NULL; - - /* The rowstride is stored in number of uint32_t */ - image->bits.rowstride = rowstride_bytes / (int) sizeof (uint32_t); - + image->bits.rowstride = rowstride; image->bits.indexed = NULL; image->common.property_changed = bits_image_property_changed; _pixman_image_reset_clip_region (image); + return TRUE; +} + +PIXMAN_EXPORT pixman_image_t * +pixman_image_create_bits (pixman_format_code_t format, + int width, + int height, + uint32_t * bits, + int rowstride_bytes) +{ + pixman_image_t *image; + + /* must be a whole number of uint32_t's + */ + return_val_if_fail ( + bits == NULL || (rowstride_bytes % sizeof (uint32_t)) == 0, NULL); + + return_val_if_fail (PIXMAN_FORMAT_BPP (format) >= PIXMAN_FORMAT_DEPTH (format), NULL); + + image = _pixman_image_allocate (); + + if (!image) + return NULL; + + if (!_pixman_bits_image_init (image, format, width, height, bits, + rowstride_bytes / (int) sizeof (uint32_t))) + { + free (image); + return NULL; + } + return image; } diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index a3bb9b6..d22698c 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -49,56 +49,33 @@ _pixman_init_gradient (gradient_t * gradient, return TRUE; } -pixman_image_t * -_pixman_image_allocate (void) -{ - pixman_image_t *image = malloc (sizeof (pixman_image_t)); - - if (image) - { - image_common_t *common = &image->common; - - pixman_region32_init (&common->clip_region); - - common->alpha_count = 0; - common->have_clip_region = FALSE; - common->clip_sources = FALSE; - common->transform = NULL; - common->repeat = PIXMAN_REPEAT_NONE; - common->filter = PIXMAN_FILTER_NEAREST; - common->filter_params = NULL; - common->n_filter_params = 0; - common->alpha_map = NULL; - common->component_alpha = FALSE; - common->ref_count = 1; - common->property_changed = NULL; - common->client_clip = FALSE; - common->destroy_func = NULL; - common->destroy_data = NULL; - common->dirty = TRUE; - } - - return image; -} - -static void -image_property_changed (pixman_image_t *image) -{ - image->common.dirty = TRUE; -} - -/* Ref Counting */ -PIXMAN_EXPORT pixman_image_t * -pixman_image_ref (pixman_image_t *image) +void +_pixman_image_init (pixman_image_t *image) { - image->common.ref_count++; - - return image; + image_common_t *common = &image->common; + + pixman_region32_init (&common->clip_region); + + common->alpha_count = 0; + common->have_clip_region = FALSE; + common->clip_sources = FALSE; + common->transform = NULL; + common->repeat = PIXMAN_REPEAT_NONE; + common->filter = PIXMAN_FILTER_NEAREST; + common->filter_params = NULL; + common->n_filter_params = 0; + common->alpha_map = NULL; + common->component_alpha = FALSE; + common->ref_count = 1; + common->property_changed = NULL; + common->client_clip = FALSE; + common->destroy_func = NULL; + common->destroy_data = NULL; + common->dirty = TRUE; } -/* returns TRUE when the image is freed */ -PIXMAN_EXPORT pixman_bool_t -pixman_image_unref (pixman_image_t *image) +pixman_bool_t +_pixman_image_fini (pixman_image_t *image) { image_common_t *common = (image_common_t *)image; @@ -131,8 +108,45 @@ pixman_image_unref (pixman_image_t *image) if (image->type == BITS && image->bits.free_me) free (image->bits.free_me); - free (image); + return TRUE; + } + return FALSE; +} + +pixman_image_t * +_pixman_image_allocate (void) +{ + pixman_image_t *image = malloc (sizeof (pixman_image_t)); + + if (image) + _pixman_image_init (image); + + return image; +} + +static void +image_property_changed (pixman_image_t *image) +{ + image->common.dirty = TRUE; +} + +/* Ref Counting */ +PIXMAN_EXPORT pixman_image_t * +pixman_image_ref (pixman_image_t *image) +{ + image->common.ref_count++; + + return image; +} + +/* returns TRUE when the image is freed */ +PIXMAN_EXPORT pixman_bool_t +pixman_image_unref (pixman_image_t *image) +{ + if (_pixman_image_fini (image)) + { + free (image); return TRUE; } diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 4d645fe..69971ea 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -250,6 +250,19 @@ _pixman_radial_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); void _pixman_conical_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); +void +_pixman_image_init (pixman_image_t *image); + +pixman_bool_t +_pixman_bits_image_init (pixman_image_t * image, + pixman_format_code_t format, + int width, + int height, + uint32_t * bits, + int rowstride); +pixman_bool_t +_pixman_image_fini (pixman_image_t *image); + pixman_image_t * _pixman_image_allocate (void); From jeremyhu at kemper.freedesktop.org Mon Oct 10 13:50:17 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 10 Oct 2011 13:50:17 -0700 (PDT) Subject: edid-decode: Changes to 'master' Message-ID: <20111010205017.EF6B1D8002@kemper.freedesktop.org> edid-decode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) New commits: commit c54f21be9563a423730b57b8f23668b1caa56530 Author: Tormod Volden <debian.tormod at gmail.com> Date: Tue Aug 30 06:10:11 2011 +0000 edid-decode: Be explicit about valid checksums Also fix some formatting and typos. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 10 14:01:34 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 10 Oct 2011 14:01:34 -0700 (PDT) Subject: libXft: Changes to 'master' Message-ID: <20111010210134.77A4FD8002@kemper.freedesktop.org> configure.ac | 39 --- src/xftdpy.c | 16 - src/xftfreetype.c | 43 +-- src/xftglyphs.c | 657 +++++++++++++++++++++++++++++++----------------------- src/xftint.h | 1 5 files changed, 409 insertions(+), 347 deletions(-) New commits: commit 550b2f76401c292d982700b60326e0a837e391b4 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 10 13:00:35 2011 -0700 Remove fontconfig and freetype ifdef-fu and instead require non-ancinet versions of both Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 21a59c10803582c8f90d3b5f32e8f0240c050adf Author: Tom \"spot\" Callaway <tcallawa at redhat.com> Date: Thu Oct 6 15:58:29 2011 -0400 compiler noise cleanups related to subpixel LCD support Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit 6f1d7bcdd461b1f6cc64370793f52d7c170187d0 Author: Tom \"spot\" Callaway <tcallawa at redhat.com> Date: Thu Oct 6 15:41:10 2011 -0400 Subpixel LCD text rendering improvements Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 10 14:13:57 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 10 Oct 2011 14:13:57 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111010211357.33EF8D8002@kemper.freedesktop.org> include/X11/Xlib.h | 1 + 1 file changed, 1 insertion(+) New commits: commit f2651e03f3295a453a2965c3749bc8b6e66f1c09 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 10 14:09:17 2011 -0700 Mark XKeycodeToKeysym as _X_DEPRECATED Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 10 14:45:08 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 10 Oct 2011 14:45:08 -0700 (PDT) Subject: libXfont: Changes to 'master' Message-ID: <20111010214508.D5784D8002@kemper.freedesktop.org> src/fontfile/decompress.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) New commits: commit 8d130ac0fcf19e0e0dd0a404d9317fd8860baad4 Author: Tomas Hoger <thoger at redhat.com> Date: Mon Oct 10 14:38:06 2011 -0700 Support compress files with maxbits < 12 The compress decompression code used by libXfont rejects valid archives with maxbits less than 12 (compress allows values 9 - 16, 16 is the default). This is because maxbits-12 is used as index to hsize_table[]. That looks like an incorrect port of the original compress code, where: - hsize depended on BITS, the maximum maxbits value supported by particular build, rather than on maxbits value from the particular input file - the same hsize was used for all BITS <= 12 The quick way to verify the problem is: compress -b 11 fontfile.bdf bdftopcf -o /dev/null fontfile.bdf.Z which fails, while 12-16 works correctly. This fix removes hsize_table and uses 1 << maxbits (aka maxmaxcode) as tab_prefix size. As decompression code does not use hashing as compression code, there does not seem to be a reason to allocate any extra space. Note: In this fix, maxbits == 9 is still rejected early. AFAICS compress is able to generate such files (unknown how correct such output is), but is unable to uncompress them correctly. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From marcoz at kemper.freedesktop.org Mon Oct 10 19:44:38 2011 From: marcoz at kemper.freedesktop.org (Matt Dew) Date: Mon, 10 Oct 2011 19:44:38 -0700 (PDT) Subject: xorg-docs: Changes to 'master' Message-ID: <20111011024438.1D492D8002@kemper.freedesktop.org> general/ReleaseNotes.xml | 8 general/fonts/fonts.xml | 78 +++--- general/input/XKB-Enhancing.xml | 6 specs/ICCCM/icccm.xml | 457 ++++++++++++++++------------------------ specs/XLFD/xlfd.xml | 230 ++++++++++---------- specs/Xext/lbxalg.xml | 10 specs/Xserver/XACE-Spec.xml | 14 - specs/Xserver/analysis.xml | 206 ++++++++---------- specs/Xserver/appgroup.xml | 2 specs/Xserver/secint.xml | 20 - 10 files changed, 473 insertions(+), 558 deletions(-) New commits: commit 315de17bb44850a4f584f92541f1276a5f589595 Author: Matt Dew <marcoz at osource.org> Date: Mon Oct 10 20:43:26 2011 -0600 Cleanup IDs and links in doc 1 - fix the capitalization of the ID attributes to match either the <title> or <funcdef> string it goes with. 2 - fix any <linkend>'s that were affected by 1. 3 - any <function> in the docs that has an actual funcdef, will become an olink. Signed-off-by: Matt Dew <marcoz at osource.org> From ickle at kemper.freedesktop.org Tue Oct 11 00:51:24 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Tue, 11 Oct 2011 00:51:24 -0700 (PDT) Subject: xf86-video-intel: 3 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/sna_blt.c src/sna/sna_render.h src/sna/sna_trapezoids.c Message-ID: <20111011075124.4E96AD8002@kemper.freedesktop.org> src/sna/gen2_render.c | 26 +++++++++ src/sna/gen3_render.c | 54 ++++++++++++++++++ src/sna/gen4_render.c | 17 +++++ src/sna/gen5_render.c | 26 +++++++++ src/sna/gen6_render.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++ src/sna/gen7_render.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++ src/sna/sna_blt.c | 102 ++++++++++++++++++++++++++++++++++- src/sna/sna_render.h | 3 + src/sna/sna_trapezoids.c | 8 +- 9 files changed, 498 insertions(+), 8 deletions(-) New commits: commit 4a2e833ab17e4facf0f90166b82a5696a1deef91 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 08:45:47 2011 +0100 sna/gen7: Add render support for fill one To prevent the RENDER to BLT transition and potential stall. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index ec5a016..30de36f 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2942,6 +2942,114 @@ gen7_render_fill(struct sna *sna, uint8_t alu, return TRUE; } +static Bool +gen7_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + +static Bool +gen7_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint8_t alu) +{ + struct sna_composite_op tmp; + +#if NO_FILL_BOXES + return gen7_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); +#endif + + /* Prefer to use the BLT if already engaged */ + if (sna->kgem.mode != KGEM_RENDER && + gen7_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + + /* Must use the BLT if we can't RENDER... */ + if (!(alu == GXcopy || alu == GXclear) || + dst->drawable.width > 8192 || dst->drawable.height > 8192) + return gen7_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); + + if (alu == GXclear) + color = 0; + + tmp.op = color == 0 ? PictOpClear : PictOpSrc; + + tmp.dst.pixmap = dst; + tmp.dst.width = dst->drawable.width; + tmp.dst.height = dst->drawable.height; + tmp.dst.format = sna_format_for_depth(dst->drawable.depth); + tmp.dst.bo = bo; + tmp.dst.x = tmp.dst.y = 0; + + tmp.src.bo = + sna_render_get_solid(sna, + sna_rgba_for_color(color, + dst->drawable.depth)); + tmp.src.filter = SAMPLER_FILTER_NEAREST; + tmp.src.repeat = SAMPLER_EXTEND_REPEAT; + + tmp.mask.bo = NULL; + tmp.mask.filter = SAMPLER_FILTER_NEAREST; + tmp.mask.repeat = SAMPLER_EXTEND_NONE; + + tmp.is_affine = TRUE; + tmp.floats_per_vertex = 3; + tmp.has_component_alpha = 0; + tmp.need_magic_ca_pass = FALSE; + + tmp.u.gen7.wm_kernel = GEN6_WM_KERNEL_NOMASK; + tmp.u.gen7.nr_surfaces = 2; + tmp.u.gen7.nr_inputs = 1; + tmp.u.gen7.ve_id = 1; + + if (!kgem_check_bo(&sna->kgem, bo, NULL)) + _kgem_submit(&sna->kgem); + + gen7_emit_fill_state(sna, &tmp); + gen7_align_vertex(sna, &tmp); + + if (!gen7_get_rectangles(sna, &tmp, 1)) { + gen7_emit_fill_state(sna, &tmp); + gen7_get_rectangles(sna, &tmp, 1); + } + + DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2)); + OUT_VERTEX(x2, y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + + gen7_vertex_flush(sna); + kgem_bo_destroy(&sna->kgem, tmp.src.bo); + _kgem_set_mode(&sna->kgem, KGEM_RENDER); + + return TRUE; +} + static void gen7_render_flush(struct sna *sna) { gen7_vertex_finish(sna, TRUE); @@ -3041,6 +3149,7 @@ Bool gen7_render_init(struct sna *sna) sna->render.fill_boxes = gen7_render_fill_boxes; sna->render.fill = gen7_render_fill; + sna->render.fill_one = gen7_render_fill_one; sna->render.flush = gen7_render_flush; sna->render.reset = gen7_render_reset; commit 41f525fab5a82c24adafc7e8c8409417d16a0e9a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 00:22:11 2011 +0100 sna/gen6: Add render support for fill-one-box Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 90f4036..2ba7c39 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2797,6 +2797,114 @@ gen6_render_fill(struct sna *sna, uint8_t alu, return TRUE; } +static Bool +gen6_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + +static Bool +gen6_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint8_t alu) +{ + struct sna_composite_op tmp; + +#if NO_FILL_BOXES + return gen6_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); +#endif + + /* Prefer to use the BLT if already engaged */ + if (sna->kgem.mode != KGEM_RENDER && + gen6_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + + /* Must use the BLT if we can't RENDER... */ + if (!(alu == GXcopy || alu == GXclear) || + dst->drawable.width > 8192 || dst->drawable.height > 8192) + return gen6_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); + + if (alu == GXclear) + color = 0; + + tmp.op = color == 0 ? PictOpClear : PictOpSrc; + + tmp.dst.pixmap = dst; + tmp.dst.width = dst->drawable.width; + tmp.dst.height = dst->drawable.height; + tmp.dst.format = sna_format_for_depth(dst->drawable.depth); + tmp.dst.bo = bo; + tmp.dst.x = tmp.dst.y = 0; + + tmp.src.bo = + sna_render_get_solid(sna, + sna_rgba_for_color(color, + dst->drawable.depth)); + tmp.src.filter = SAMPLER_FILTER_NEAREST; + tmp.src.repeat = SAMPLER_EXTEND_REPEAT; + + tmp.mask.bo = NULL; + tmp.mask.filter = SAMPLER_FILTER_NEAREST; + tmp.mask.repeat = SAMPLER_EXTEND_NONE; + + tmp.is_affine = TRUE; + tmp.floats_per_vertex = 3; + tmp.has_component_alpha = 0; + tmp.need_magic_ca_pass = FALSE; + + tmp.u.gen6.wm_kernel = GEN6_WM_KERNEL_NOMASK; + tmp.u.gen6.nr_surfaces = 2; + tmp.u.gen6.nr_inputs = 1; + tmp.u.gen6.ve_id = 1; + + if (!kgem_check_bo(&sna->kgem, bo, NULL)) + _kgem_submit(&sna->kgem); + + gen6_emit_fill_state(sna, &tmp); + gen6_align_vertex(sna, &tmp); + + if (!gen6_get_rectangles(sna, &tmp, 1)) { + gen6_emit_fill_state(sna, &tmp); + gen6_get_rectangles(sna, &tmp, 1); + } + + DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2)); + OUT_VERTEX(x2, y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + + gen6_vertex_flush(sna); + kgem_bo_destroy(&sna->kgem, tmp.src.bo); + _kgem_set_mode(&sna->kgem, KGEM_RENDER); + + return TRUE; +} + static void gen6_render_flush(struct sna *sna) { gen6_vertex_finish(sna, TRUE); @@ -2896,6 +3004,7 @@ Bool gen6_render_init(struct sna *sna) sna->render.fill_boxes = gen6_render_fill_boxes; sna->render.fill = gen6_render_fill; + sna->render.fill_one = gen6_render_fill_one; sna->render.flush = gen6_render_flush; sna->render.reset = gen6_render_reset; commit 5b6575bdded4b24ec1c9515203f44798225c10b6 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 10 16:39:02 2011 +0100 sna: Support a fast composite hook for solitary boxes Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 935dffe..c0d357d 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -950,6 +950,31 @@ gen2_render_composite_blt(struct sna *sna, op->prim_emit(sna, op, r); } +fastcall static void +gen2_render_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + struct sna_composite_rectangles r; + + if (!gen2_get_rectangles(sna, op, 1)) { + gen2_emit_composite_state(sna, op); + gen2_get_rectangles(sna, op, 1); + } + + DBG((" %s: (%d, %d) x (%d, %d)\n", __FUNCTION__, + box->x1, box->y1, + box->x2 - box->x1, + box->y2 - box->y1)); + + r.dst.x = box->x1; r.dst.y = box->y1; + r.width = box->x2 - box->x1; + r.height = box->y2 - box->y1; + r.src = r.mask = r.dst; + + op->prim_emit(sna, op, &r); +} + static void gen2_render_composite_boxes(struct sna *sna, const struct sna_composite_op *op, @@ -1344,6 +1369,7 @@ gen2_render_composite(struct sna *sna, } tmp->blt = gen2_render_composite_blt; + tmp->box = gen2_render_composite_box; tmp->boxes = gen2_render_composite_boxes; tmp->done = gen2_render_composite_done; diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 57c57b9..dcaf0ff 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -1568,6 +1568,33 @@ gen3_render_composite_blt(struct sna *sna, op->prim_emit(sna, op, r); } +fastcall static void +gen3_render_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + struct sna_composite_rectangles r; + + DBG(("%s: src=+(%d, %d), mask=+(%d, %d), dst=+(%d, %d)\n", + __FUNCTION__, + op->src.offset[0], op->src.offset[1], + op->mask.offset[0], op->mask.offset[1], + op->dst.x, op->dst.y)); + + if (!gen3_get_rectangles(sna, op, 1)) { + gen3_emit_composite_state(sna, op); + gen3_get_rectangles(sna, op, 1); + } + + r.dst.x = box->x1; + r.dst.y = box->y1; + r.width = box->x2 - box->x1; + r.height = box->y2 - box->y1; + r.src = r.mask = r.dst; + + op->prim_emit(sna, op, &r); +} + static void gen3_render_composite_boxes(struct sna *sna, const struct sna_composite_op *op, @@ -2060,6 +2087,26 @@ gen3_align_vertex(struct sna *sna, } } +static void +reduce_damage(struct sna_composite_op *op, + int dst_x, int dst_y, + int width, int height) +{ + BoxRec r; + + if (op->damage == NULL) + return; + + r.x1 = dst_x + op->dst.x; + r.x2 = r.x1 + width; + + r.y1 = dst_y + op->dst.y; + r.y2 = r.y1 + height; + + if (sna_damage_contains_box(*op->damage, &r) == PIXMAN_REGION_IN) + op->damage = NULL; +} + static Bool gen3_composite_set_target(struct sna_composite_op *op, PicturePtr dst) { @@ -2166,6 +2213,9 @@ gen3_render_composite(struct sna *sna, return FALSE; } + if (width && height) + reduce_damage(tmp, dst_x, dst_y, width, height); + tmp->op = op; tmp->rb_reversed = gen3_dst_rb_reversed(tmp->dst.format); if (tmp->dst.width > 2048 || tmp->dst.height > 2048 || @@ -2335,6 +2385,7 @@ gen3_render_composite(struct sna *sna, tmp->floats_per_vertex)); tmp->blt = gen3_render_composite_blt; + tmp->box = gen3_render_composite_box; tmp->boxes = gen3_render_composite_boxes; tmp->done = gen3_render_composite_done; @@ -2675,6 +2726,9 @@ gen3_render_composite_spans(struct sna *sna, return FALSE; } + if (width && height) + reduce_damage(&tmp->base, dst_x, dst_y, width, height); + tmp->base.op = op; tmp->base.rb_reversed = gen3_dst_rb_reversed(tmp->base.dst.format); if (tmp->base.dst.width > 2048 || tmp->base.dst.height > 2048 || diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 3c133be..95d9a9d 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -1472,6 +1472,22 @@ gen4_render_composite_blt(struct sna *sna, FLUSH(); } +fastcall static void +gen4_render_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + struct sna_composite_rectangles r; + + r.dst.x = box->x1; + r.dst.y = box->y1; + r.width = box->x2 - box->x1; + r.height = box->y2 - box->y1; + r.mask = r.src = r.dst; + + gen4_render_composite_blt(sna, op, &r); +} + static void gen4_render_composite_boxes(struct sna *sna, const struct sna_composite_op *op, @@ -2029,6 +2045,7 @@ gen4_render_composite(struct sna *sna, tmp->u.gen4.ve_id = (tmp->mask.bo != NULL) << 1 | tmp->is_affine; tmp->blt = gen4_render_composite_blt; + tmp->box = gen4_render_composite_box; tmp->boxes = gen4_render_composite_boxes; tmp->done = gen4_render_composite_done; diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index ad27d90..ab30c9c 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -1486,6 +1486,31 @@ gen5_render_composite_blt(struct sna *sna, op->prim_emit(sna, op, r); } +fastcall static void +gen5_render_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + struct sna_composite_rectangles r; + + DBG((" %s: (%d, %d), (%d, %d)\n", + __FUNCTION__, + box->x1, box->y1, box->x2, box->y2)); + + if (!gen5_get_rectangles(sna, op, 1)) { + gen5_bind_surfaces(sna, op); + gen5_get_rectangles(sna, op, 1); + } + + r.dst.x = box->x1; + r.dst.y = box->y1; + r.width = box->x2 - box->x1; + r.height = box->y2 - box->y1; + r.mask = r.src = r.dst; + + op->prim_emit(sna, op, &r); +} + static void gen5_render_composite_boxes(struct sna *sna, const struct sna_composite_op *op, @@ -2040,6 +2065,7 @@ gen5_render_composite(struct sna *sna, tmp->u.gen5.ve_id = (tmp->mask.bo != NULL) << 1 | tmp->is_affine; tmp->blt = gen5_render_composite_blt; + tmp->box = gen5_render_composite_box; tmp->boxes = gen5_render_composite_boxes; tmp->done = gen5_render_composite_done; diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 044704d..90f4036 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -1620,6 +1620,31 @@ gen6_render_composite_blt(struct sna *sna, op->prim_emit(sna, op, r); } +fastcall static void +gen6_render_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + struct sna_composite_rectangles r; + + if (!gen6_get_rectangles(sna, op, 1)) { + gen6_emit_composite_state(sna, op); + gen6_get_rectangles(sna, op, 1); + } + + DBG((" %s: (%d, %d), (%d, %d)\n", + __FUNCTION__, + box->x1, box->y1, box->x2, box->y2)); + + r.dst.x = box->x1; + r.dst.y = box->y1; + r.width = box->x2 - box->x1; + r.height = box->y2 - box->y1; + r.src = r.mask = r.dst; + + op->prim_emit(sna, op, &r); +} + static void gen6_render_composite_boxes(struct sna *sna, const struct sna_composite_op *op, @@ -2217,6 +2242,7 @@ gen6_render_composite(struct sna *sna, tmp->u.gen6.ve_id = gen6_choose_composite_vertex_buffer(tmp); tmp->blt = gen6_render_composite_blt; + tmp->box = gen6_render_composite_box; tmp->boxes = gen6_render_composite_boxes; tmp->done = gen6_render_composite_done; diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 8c21693..ec5a016 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -1754,6 +1754,31 @@ gen7_render_composite_blt(struct sna *sna, op->prim_emit(sna, op, r); } +fastcall static void +gen7_render_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + struct sna_composite_rectangles r; + + if (!gen7_get_rectangles(sna, op, 1)) { + gen7_emit_composite_state(sna, op); + gen7_get_rectangles(sna, op, 1); + } + + DBG((" %s: (%d, %d), (%d, %d)\n", + __FUNCTION__, + box->x1, box->y1, box->x2, box->y2)); + + r.dst.x = box->x1; + r.dst.y = box->y1; + r.width = box->x2 - box->x1; + r.height = box->y2 - box->y1; + r.src = r.mask = r.dst; + + op->prim_emit(sna, op, &r); +} + static void gen7_render_composite_boxes(struct sna *sna, const struct sna_composite_op *op, @@ -2351,6 +2376,7 @@ gen7_render_composite(struct sna *sna, tmp->u.gen7.ve_id = gen7_choose_composite_vertex_buffer(tmp); tmp->blt = gen7_render_composite_blt; + tmp->box = gen7_render_composite_box; tmp->boxes = gen7_render_composite_boxes; tmp->done = gen7_render_composite_done; diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index d82f845..a8d39bd 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -610,6 +610,17 @@ static void blt_fill_composite(struct sna *sna, sna_blt_fill_one(sna, &op->u.blt, x1, y1, x2-x1, y2-y1); } +fastcall static void blt_fill_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + sna_blt_fill_one(sna, &op->u.blt, + box->x1 + op->dst.x, + box->y1 + op->dst.y, + box->x2 - box->x1, + box->y2 - box->y1); +} + static void blt_fill_composite_boxes(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box, int n) @@ -629,6 +640,7 @@ prepare_blt_clear(struct sna *sna, DBG(("%s\n", __FUNCTION__)); op->blt = blt_fill_composite; + op->box = blt_fill_composite_box; op->boxes = blt_fill_composite_boxes; op->done = blt_done; @@ -645,9 +657,10 @@ prepare_blt_fill(struct sna *sna, { DBG(("%s\n", __FUNCTION__)); - op->blt = blt_fill_composite; + op->blt = blt_fill_composite; + op->box = blt_fill_composite_box; op->boxes = blt_fill_composite_boxes; - op->done = blt_done; + op->done = blt_done; return sna_blt_fill_init(sna, &op->u.blt, op->dst.bo, op->dst.pixmap->drawable.bitsPerPixel, @@ -702,6 +715,21 @@ blt_copy_composite(struct sna *sna, x1, y1); } +fastcall static void blt_copy_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + DBG(("%s: box (%d, %d), (%d, %d)\n", + __FUNCTION__, box->x1, box->y1, box->x2, box->y2)); + sna_blt_copy_one(sna, &op->u.blt, + box->x1 + op->u.blt.sx, + box->y1 + op->u.blt.sy, + box->x2 - box->x1, + box->y2 - box->y1, + box->x1 + op->dst.x, + box->y1 + op->dst.y); +} + static void blt_copy_composite_boxes(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box, int nbox) @@ -734,6 +762,7 @@ prepare_blt_copy(struct sna *sna, DBG(("%s\n", __FUNCTION__)); op->blt = blt_copy_composite; + op->box = blt_copy_composite_box; op->boxes = blt_copy_composite_boxes; op->done = blt_done; @@ -799,6 +828,45 @@ blt_put_composite(struct sna *sna, } } +fastcall static void blt_put_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + PixmapPtr src = op->u.blt.src_pixmap; + struct sna_pixmap *dst_priv = sna_pixmap(op->dst.pixmap); + + DBG(("%s: src=(%d, %d), dst=(%d, %d)\n", __FUNCTION__, + op->u.blt.sx, op->u.blt.sy, + op->dst.x, op->dst.y)); + + if (!dst_priv->pinned && + box->x2 - box->x1 == op->dst.width && + box->y2 - box->y1 == op->dst.height) { + int pitch = src->devKind; + int bpp = src->drawable.bitsPerPixel / 8; + char *data = src->devPrivate.ptr; + + data += (box->y1 + op->u.blt.sy) * pitch; + data += (box->x1 + op->u.blt.sx) * bpp; + + dst_priv->gpu_bo = + sna_replace(sna, + op->dst.bo, + op->dst.width, + op->dst.height, + src->drawable.bitsPerPixel, + data, pitch); + } else { + sna_write_boxes(sna, + op->dst.bo, op->dst.x, op->dst.y, + src->devPrivate.ptr, + src->devKind, + src->drawable.bitsPerPixel, + op->u.blt.sx, op->u.blt.sy, + box, 1); + } +} + static void blt_put_composite_boxes(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box, int n) @@ -868,7 +936,8 @@ prepare_blt_put(struct sna *sna, free_bo = src_bo; } if (src_bo) { - op->blt = blt_copy_composite; + op->blt = blt_copy_composite; + op->box = blt_copy_composite_box; op->boxes = blt_copy_composite_boxes; op->u.blt.src_pixmap = (void *)free_bo; @@ -882,6 +951,7 @@ prepare_blt_put(struct sna *sna, return FALSE; } else { op->blt = blt_put_composite; + op->box = blt_put_composite_box; op->boxes = blt_put_composite_boxes; op->done = nop_done; } @@ -935,6 +1005,26 @@ has_cpu_area(PixmapPtr pixmap, int x, int y, int w, int h) &area) == PIXMAN_REGION_OUT; } +static void +reduce_damage(struct sna_composite_op *op, + int dst_x, int dst_y, + int width, int height) +{ + BoxRec r; + + if (op->damage == NULL) + return; + + r.x1 = dst_x + op->dst.x; + r.x2 = r.x1 + width; + + r.y1 = dst_y + op->dst.y; + r.y2 = r.y1 + height; + + if (sna_damage_contains_box(*op->damage, &r) == PIXMAN_REGION_IN) + op->damage = NULL; +} + Bool sna_blt_composite(struct sna *sna, uint32_t op, @@ -983,8 +1073,12 @@ sna_blt_composite(struct sna *sna, get_drawable_deltas(dst->pDrawable, tmp->dst.pixmap, &tmp->dst.x, &tmp->dst.y); tmp->dst.bo = priv->gpu_bo; - if (!priv->gpu_only) + if (!priv->gpu_only && + !sna_damage_is_all(&priv->gpu_damage, + tmp->dst.width, tmp->dst.height)) tmp->damage = &priv->gpu_damage; + if (width && height) + reduce_damage(tmp, dst_x, dst_y, width, height); if (!kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) _kgem_submit(&sna->kgem); diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index e46f027..2cc39f0 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -20,6 +20,9 @@ struct sna_composite_rectangles { struct sna_composite_op { fastcall void (*blt)(struct sna *sna, const struct sna_composite_op *op, const struct sna_composite_rectangles *r); + fastcall void (*box)(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box); void (*boxes)(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box, int nbox); void (*done)(struct sna *sna, const struct sna_composite_op *op); diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index d1602e0..86593a9 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -1539,7 +1539,7 @@ mono_add_line(struct mono *mono, e->dxdy = floored_muldivrem (dx, pixman_fixed_1, dy); e->dy = dy; - e->x = floored_muldivrem (ytop * pixman_fixed_1 + pixman_fixed_1_minus_e/2 - (p1->y + dst_y*pixman_fixed_1), + e->x = floored_muldivrem ((ytop-dst_y) * pixman_fixed_1 + pixman_fixed_1_minus_e/2 - p1->y, dx, dy); e->x.quo += p1->x; e->x.rem -= dy; @@ -1602,8 +1602,8 @@ start_with_b: static struct mono_edge * mono_sort_edges(struct mono_edge *list, - unsigned int level, - struct mono_edge **head_out) + unsigned int level, + struct mono_edge **head_out) { struct mono_edge *head_other, *remaining; unsigned int i; @@ -1715,7 +1715,7 @@ mono_span(struct mono *c, int x1, int x2, BoxPtr box) } pixman_region_fini(®ion); } else { - c->op.boxes(c->sna, &c->op, box, 1); + c->op.box(c->sna, &c->op, box); apply_damage_box(&c->op, box); } } From danvet at kemper.freedesktop.org Tue Oct 11 01:55:43 2011 From: danvet at kemper.freedesktop.org (Daniel Vetter) Date: Tue, 11 Oct 2011 01:55:43 -0700 (PDT) Subject: xf86-video-intel: src/i965_reg.h src/intel.h src/intel_batchbuffer.c src/intel_driver.c Message-ID: <20111011085543.2F7F3D8002@kemper.freedesktop.org> src/i965_reg.h | 2 + src/intel.h | 1 src/intel_batchbuffer.c | 50 ++++++++++++++++++++++++++++++++++++++++-------- src/intel_driver.c | 7 ++++++ 4 files changed, 52 insertions(+), 8 deletions(-) New commits: commit d0184b59095d5b8fab1a65ceba075d29189130d4 Author: Daniel Vetter <daniel.vetter at ffwll.ch> Date: Sun Oct 9 18:43:14 2011 +0200 snb: implement PIPE_CONTROL workaround Sandybdrige requires an elaborate dance to flush caches without hanging the gpu. See public docs Vol2Part1 1.7.4.1 PIPE_CONTROL or the corrensponding code in mesa/kernel. This (together with the corresponding patch for the kernel) seems to fix the hangs in cairo-perf-traces I'm seeing on my snb machine. v2: Incorporate review from Chris Wilson. For paranoia keep all three PIPE_CONTROL cmds in the same batchbuffer to avoid upsetting the gpu. Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch> diff --git a/src/i965_reg.h b/src/i965_reg.h index 904e506..e7b0d15 100644 --- a/src/i965_reg.h +++ b/src/i965_reg.h @@ -294,6 +294,7 @@ #define BRW_CLIP_ENABLE 1 /* for BRW_PIPE_CONTROL */ +#define BRW_PIPE_CONTROL_CS_STALL (1 << 20) #define BRW_PIPE_CONTROL_NOWRITE (0 << 14) #define BRW_PIPE_CONTROL_WRITE_QWORD (1 << 14) #define BRW_PIPE_CONTROL_WRITE_DEPTH (2 << 14) @@ -305,6 +306,7 @@ #define BRW_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8) #define BRW_PIPE_CONTROL_GLOBAL_GTT (1 << 2) #define BRW_PIPE_CONTROL_LOCAL_PGTT (0 << 2) +#define BRW_PIPE_CONTROL_STALL_AT_SCOREBOARD (1 << 1) #define BRW_PIPE_CONTROL_DEPTH_CACHE_FLUSH (1 << 0) /* VERTEX_BUFFER_STATE Structure */ diff --git a/src/intel.h b/src/intel.h index 899d250..2f72830 100644 --- a/src/intel.h +++ b/src/intel.h @@ -283,6 +283,7 @@ typedef struct intel_screen_private { struct list batch_pixmaps; struct list flush_pixmaps; struct list in_flight; + drm_intel_bo *wa_scratch_bo; /* For Xvideo */ Bool use_overlay; diff --git a/src/intel_batchbuffer.c b/src/intel_batchbuffer.c index d0a41aa..89a9969 100644 --- a/src/intel_batchbuffer.c +++ b/src/intel_batchbuffer.c @@ -137,6 +137,35 @@ void intel_batch_do_flush(ScrnInfoPtr scrn) list_del(intel->flush_pixmaps.next); } +static void intel_emit_post_sync_nonzero_flush(ScrnInfoPtr scrn) +{ + intel_screen_private *intel = intel_get_screen_private(scrn); + + /* keep this entire sequence of 3 PIPE_CONTROL cmds in one batch to + * avoid upsetting the gpu. */ + BEGIN_BATCH(3*4); + OUT_BATCH(BRW_PIPE_CONTROL | (4 - 2)); + OUT_BATCH(BRW_PIPE_CONTROL_CS_STALL | + BRW_PIPE_CONTROL_STALL_AT_SCOREBOARD); + OUT_BATCH(0); /* address */ + OUT_BATCH(0); /* write data */ + + OUT_BATCH(BRW_PIPE_CONTROL | (4 - 2)); + OUT_BATCH(BRW_PIPE_CONTROL_WRITE_QWORD); + OUT_RELOC(intel->wa_scratch_bo, + I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); + OUT_BATCH(0); /* write data */ + + /* now finally the _real flush */ + OUT_BATCH(BRW_PIPE_CONTROL | (4 - 2)); + OUT_BATCH(BRW_PIPE_CONTROL_WC_FLUSH | + BRW_PIPE_CONTROL_TC_FLUSH | + BRW_PIPE_CONTROL_NOWRITE); + OUT_BATCH(0); /* write address */ + OUT_BATCH(0); /* write data */ + ADVANCE_BATCH(); +} + void intel_batch_emit_flush(ScrnInfoPtr scrn) { intel_screen_private *intel = intel_get_screen_private(scrn); @@ -154,14 +183,19 @@ void intel_batch_emit_flush(ScrnInfoPtr scrn) OUT_BATCH(0); ADVANCE_BATCH(); } else { - BEGIN_BATCH(4); - OUT_BATCH(BRW_PIPE_CONTROL | (4 - 2)); - OUT_BATCH(BRW_PIPE_CONTROL_WC_FLUSH | - BRW_PIPE_CONTROL_TC_FLUSH | - BRW_PIPE_CONTROL_NOWRITE); - OUT_BATCH(0); /* write address */ - OUT_BATCH(0); /* write data */ - ADVANCE_BATCH(); + if ((INTEL_INFO(intel)->gen == 60)) { + /* HW-Workaround for Sandybdrige */ + intel_emit_post_sync_nonzero_flush(scrn); + } else { + BEGIN_BATCH(4); + OUT_BATCH(BRW_PIPE_CONTROL | (4 - 2)); + OUT_BATCH(BRW_PIPE_CONTROL_WC_FLUSH | + BRW_PIPE_CONTROL_TC_FLUSH | + BRW_PIPE_CONTROL_NOWRITE); + OUT_BATCH(0); /* write address */ + OUT_BATCH(0); /* write data */ + ADVANCE_BATCH(); + } } } else { flags = MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE; diff --git a/src/intel_driver.c b/src/intel_driver.c index 7fc1c1a..24696da 100644 --- a/src/intel_driver.c +++ b/src/intel_driver.c @@ -416,11 +416,18 @@ static int intel_init_bufmgr(intel_screen_private *intel) list_init(&intel->flush_pixmaps); list_init(&intel->in_flight); + if ((INTEL_INFO(intel)->gen == 60)) { + intel->wa_scratch_bo = + drm_intel_bo_alloc(intel->bufmgr, "wa scratch", + 4096, 4096); + } + return TRUE; } static void intel_bufmgr_fini(intel_screen_private *intel) { + drm_intel_bo_unreference(intel->wa_scratch_bo); drm_intel_bufmgr_destroy(intel->bufmgr); } From ickle at kemper.freedesktop.org Tue Oct 11 02:59:58 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Tue, 11 Oct 2011 02:59:58 -0700 (PDT) Subject: xf86-video-intel: 3 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/sna_render.h src/sna/sna_trapezoids.c Message-ID: <20111011095958.44B15D8002@kemper.freedesktop.org> src/sna/gen2_render.c | 12 +++++----- src/sna/gen3_render.c | 56 +++++++++++++++++++++++++++++++++++++---------- src/sna/sna_render.h | 20 ++++++++++------ src/sna/sna_trapezoids.c | 11 +++++---- 4 files changed, 70 insertions(+), 29 deletions(-) New commits: commit a9b53c48774078d404149e86267c39eb82234c3a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 10:37:25 2011 +0100 sna: Mark the spans render functions as fastcall This reduces the amount of dancing required to call into the span functions as we can pass the arguments in both the integer and floating point registers. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index c0d357d..a7ace88 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -1403,7 +1403,7 @@ cleanup_dst: return FALSE; } -static void +fastcall static void gen2_emit_composite_spans_primitive_constant(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -1426,7 +1426,7 @@ gen2_emit_composite_spans_primitive_constant(struct sna *sna, *((uint32_t *)v + 8) = alpha; } -static void +fastcall static void gen2_emit_composite_spans_primitive_identity_source(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -1455,7 +1455,7 @@ gen2_emit_composite_spans_primitive_identity_source(struct sna *sna, v[14] = (op->base.src.offset[1] + box->y1) * op->base.src.scale[1]; } -static void +fastcall static void gen2_emit_composite_spans_primitive_affine_source(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -1509,7 +1509,7 @@ gen2_emit_composite_spans_vertex(struct sna *sna, gen2_emit_composite_texcoord(sna, &op->base.src, x, y); } -static void +fastcall static void gen2_emit_composite_spans_primitive(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -1588,7 +1588,7 @@ static void gen2_emit_composite_spans_state(struct sna *sna, } } -static void +fastcall static void gen2_render_composite_spans_box(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, float opacity) @@ -1643,7 +1643,7 @@ gen2_render_composite_spans_boxes(struct sna *sna, } while (nbox); } -static void +fastcall static void gen2_render_composite_spans_done(struct sna *sna, const struct sna_composite_spans_op *op) { diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index e25e71b..e7d8bb2 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -2434,7 +2434,7 @@ gen3_emit_composite_spans_vertex(struct sna *sna, OUT_VERTEX(opacity); } -static void +fastcall static void gen3_emit_composite_spans_primitive_zero(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2453,7 +2453,7 @@ gen3_emit_composite_spans_primitive_zero(struct sna *sna, v[5] = op->base.dst.x + box->y1; } -static void +fastcall static void gen3_emit_composite_spans_primitive_zero_no_offset(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2468,7 +2468,7 @@ gen3_emit_composite_spans_primitive_zero_no_offset(struct sna *sna, v[5] = box->y1; } -static void +fastcall static void gen3_emit_composite_spans_primitive_constant(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2484,7 +2484,7 @@ gen3_emit_composite_spans_primitive_constant(struct sna *sna, v[8] = v[5] = v[2] = opacity; } -static void +fastcall static void gen3_emit_composite_spans_primitive_constant_no_offset(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2500,7 +2500,7 @@ gen3_emit_composite_spans_primitive_constant_no_offset(struct sna *sna, v[8] = v[5] = v[2] = opacity; } -static void +fastcall static void gen3_emit_composite_spans_primitive_identity_source(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2528,7 +2528,7 @@ gen3_emit_composite_spans_primitive_identity_source(struct sna *sna, v[14] = opacity; } -static void +fastcall static void gen3_emit_composite_spans_primitive_affine_source(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2570,7 +2570,7 @@ gen3_emit_composite_spans_primitive_affine_source(struct sna *sna, v[13] = y * op->base.src.scale[1]; } -static void +fastcall static void gen3_emit_composite_spans_primitive_identity_gradient(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2598,7 +2598,7 @@ gen3_emit_composite_spans_primitive_identity_gradient(struct sna *sna, v[14] = opacity; } -static void +fastcall static void gen3_emit_composite_spans_primitive_affine_gradient(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2633,7 +2633,7 @@ gen3_emit_composite_spans_primitive_affine_gradient(struct sna *sna, v[14] = opacity; } -static void +fastcall static void gen3_emit_composite_spans_primitive(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2650,7 +2650,7 @@ gen3_emit_composite_spans_primitive(struct sna *sna, opacity); } -static void +fastcall static void gen3_render_composite_spans_box(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, float opacity) @@ -2705,7 +2705,7 @@ gen3_render_composite_spans_boxes(struct sna *sna, } while (nbox); } -static void +fastcall static void gen3_render_composite_spans_done(struct sna *sna, const struct sna_composite_spans_op *op) { diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 2cc39f0..9e658a8 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -137,17 +137,21 @@ struct sna_composite_op { struct sna_composite_spans_op { struct sna_composite_op base; - void (*box)(struct sna *sna, const struct sna_composite_spans_op *op, - const BoxRec *box, float opacity); - void (*boxes)(struct sna *sna, const struct sna_composite_spans_op *op, + fastcall void (*box)(struct sna *sna, + const struct sna_composite_spans_op *op, + const BoxRec *box, + float opacity); + void (*boxes)(struct sna *sna, + const struct sna_composite_spans_op *op, const BoxRec *box, int nbox, float opacity); - void (*done)(struct sna *sna, const struct sna_composite_spans_op *op); + fastcall void (*done)(struct sna *sna, + const struct sna_composite_spans_op *op); - void (*prim_emit)(struct sna *sna, - const struct sna_composite_spans_op *op, - const BoxRec *box, - float opacity); + fastcall void (*prim_emit)(struct sna *sna, + const struct sna_composite_spans_op *op, + const BoxRec *box, + float opacity); }; struct sna_fill_op { commit 208fa8e6b88daf8446239a1a001a68ceb7d02e76 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 10:08:42 2011 +0100 sna/trapezoid: Perform the NULL check for damage in the caller Save the function call overhead in the common case. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index 86593a9..b0331cb 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -110,13 +110,10 @@ static void apply_damage(struct sna_composite_op *op, RegionPtr region) sna_damage_add(op->damage, region); } -static void apply_damage_box(struct sna_composite_op *op, const BoxRec *box) +static void _apply_damage_box(struct sna_composite_op *op, const BoxRec *box) { BoxRec r; - if (op->damage == NULL) - return; - r.x1 = box->x1 + op->dst.x; r.x2 = box->x2 + op->dst.x; r.y1 = box->y1 + op->dst.y; @@ -126,6 +123,12 @@ static void apply_damage_box(struct sna_composite_op *op, const BoxRec *box) sna_damage_add_box(op->damage, &r); } +inline static void apply_damage_box(struct sna_composite_op *op, const BoxRec *box) +{ + if (op->damage) + _apply_damage_box(op, box); +} + typedef int grid_scaled_x_t; typedef int grid_scaled_y_t; commit 5050fead0ef81785a2a9be735852921463377e04 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 09:59:13 2011 +0100 sna/gen3: avoid applying zero offset to common spans Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index dcaf0ff..e25e71b 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -2454,6 +2454,21 @@ gen3_emit_composite_spans_primitive_zero(struct sna *sna, } static void +gen3_emit_composite_spans_primitive_zero_no_offset(struct sna *sna, + const struct sna_composite_spans_op *op, + const BoxRec *box, + float opacity) +{ + float *v = sna->render.vertex_data + sna->render.vertex_used; + sna->render.vertex_used += 6; + + v[0] = box->x2; + v[3] = v[1] = box->y2; + v[4] = v[2] = box->x1; + v[5] = box->y1; +} + +static void gen3_emit_composite_spans_primitive_constant(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2470,6 +2485,22 @@ gen3_emit_composite_spans_primitive_constant(struct sna *sna, } static void +gen3_emit_composite_spans_primitive_constant_no_offset(struct sna *sna, + const struct sna_composite_spans_op *op, + const BoxRec *box, + float opacity) +{ + float *v = sna->render.vertex_data + sna->render.vertex_used; + sna->render.vertex_used += 9; + + v[0] = box->x2; + v[6] = v[3] = box->x1; + v[4] = v[1] = box->y2; + v[7] = box->y1; + v[8] = v[5] = v[2] = opacity; +} + +static void gen3_emit_composite_spans_primitive_identity_source(struct sna *sna, const struct sna_composite_spans_op *op, const BoxRec *box, @@ -2698,6 +2729,8 @@ gen3_render_composite_spans(struct sna *sna, int16_t width, int16_t height, struct sna_composite_spans_op *tmp) { + bool no_offset; + DBG(("%s(src=(%d, %d), dst=(%d, %d), size=(%d, %d))\n", __FUNCTION__, src_x, src_y, dst_x, dst_y, width, height)); @@ -2759,15 +2792,16 @@ gen3_render_composite_spans(struct sna *sna, if (tmp->base.src.u.gen3.type != SHADER_ZERO) tmp->base.mask.u.gen3.type = SHADER_OPACITY; + no_offset = tmp->base.dst.x == 0 && tmp->base.dst.y == 0; tmp->prim_emit = gen3_emit_composite_spans_primitive; switch (tmp->base.src.u.gen3.type) { case SHADER_NONE: assert(0); case SHADER_ZERO: - tmp->prim_emit = gen3_emit_composite_spans_primitive_zero; + tmp->prim_emit = no_offset ? gen3_emit_composite_spans_primitive_zero_no_offset : gen3_emit_composite_spans_primitive_zero; break; case SHADER_CONSTANT: - tmp->prim_emit = gen3_emit_composite_spans_primitive_constant; + tmp->prim_emit = no_offset ? gen3_emit_composite_spans_primitive_constant_no_offset : gen3_emit_composite_spans_primitive_constant; break; case SHADER_LINEAR: case SHADER_RADIAL: From sandmann at kemper.freedesktop.org Tue Oct 11 03:10:18 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Tue, 11 Oct 2011 03:10:18 -0700 (PDT) Subject: pixman: Branch 'master' - 2 commits Message-ID: <20111011101018.BA7B5D8002@kemper.freedesktop.org> configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit bb7142d361d56d66ac40debb60a7c4d099764ba8 Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Tue Oct 11 06:10:39 2011 -0400 Post-release version bump to 0.23.7 diff --git a/configure.ac b/configure.ac index f547e06..6c88c84 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ AC_PREREQ([2.57]) m4_define([pixman_major], 0) m4_define([pixman_minor], 23) -m4_define([pixman_micro], 6) +m4_define([pixman_micro], 7) m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro]) commit e20ac40bd30484f0f711b52d0c1993ef08760284 Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Tue Oct 11 06:00:51 2011 -0400 Pre-release version bump to 0.23.6 diff --git a/configure.ac b/configure.ac index 6f5aef5..f547e06 100644 --- a/configure.ac +++ b/configure.ac @@ -26,8 +26,8 @@ AC_PREREQ([2.57]) # # - The version in git has an odd MICRO version number # -# - Released versions both development and stable have an even MICRO -# version number +# - Released versions, both development and stable, have an +# even MICRO version number # # - Released development versions have an odd MINOR number # @@ -54,7 +54,7 @@ AC_PREREQ([2.57]) m4_define([pixman_major], 0) m4_define([pixman_minor], 23) -m4_define([pixman_micro], 5) +m4_define([pixman_micro], 6) m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro]) From sandmann at kemper.freedesktop.org Tue Oct 11 03:10:24 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Tue, 11 Oct 2011 03:10:24 -0700 (PDT) Subject: pixman: Changes to 'refs/tags/pixman-0.23.6' Message-ID: <20111011101024.4392DD8002@kemper.freedesktop.org> Tag 'pixman-0.23.6' created by S??ren Sandmann Pedersen <ssp at redhat.com> at 2011-10-11 11:09 -0700 pixman 0.23.6 release -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEABECAAYFAk6UFbwACgkQmxfmIW/3wajOJQCfX2qS0b4RNr9+aA+PBnpDxjHe 8qAAnj9fbq6JkL91eFxEG629s9P9Eweg =by5X -----END PGP SIGNATURE----- Changes since pixman-0.23.4-53: --- 0 files changed --- From ickle at kemper.freedesktop.org Tue Oct 11 06:03:07 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Tue, 11 Oct 2011 06:03:07 -0700 (PDT) Subject: xf86-video-intel: 4 commits - src/sna/gen3_render.c src/sna/kgem.c src/sna/sna_accel.c Message-ID: <20111011130307.5D2D6D8002@kemper.freedesktop.org> src/sna/gen3_render.c | 3 + src/sna/kgem.c | 5 +-- src/sna/sna_accel.c | 79 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 76 insertions(+), 11 deletions(-) New commits: commit 823a4272c50247482428a16cb08741bf87a302ea Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 13:51:41 2011 +0100 sna/gen3: Avoid RENDER/BLT context switch for fill boxes Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index e7d8bb2..1d4df78 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3603,7 +3603,8 @@ gen3_render_fill_boxes(struct sna *sna, dst, dst_bo, box, n); - if (gen3_render_fill_boxes_try_blt(sna, op, format, color, + if (sna->kgem.mode != KGEM_RENDER && + gen3_render_fill_boxes_try_blt(sna, op, format, color, dst, dst_bo, box, n)) return TRUE; commit 887361de173e082841453902089427447c5a158a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 13:51:25 2011 +0100 sna: Enable single fill fast path for PolySegment Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index dab396e..227123d 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2250,16 +2250,76 @@ static Bool sna_poly_segment_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, - GCPtr gc, int n, xSegment *seg) + GCPtr gc, int n, xSegment *seg, + const BoxRec *extents) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); - RegionPtr clip = fbGetCompositeClip(gc); + RegionRec clip; struct sna_fill_op fill; int16_t dx, dy; DBG(("%s: alu=%d, fg=%08lx\n", __FUNCTION__, gc->alu, gc->fgPixel)); + RegionInit(&clip, (BoxPtr)extents, 1); + if (gc->pCompositeClip && gc->pCompositeClip->data) + RegionIntersect(&clip, &clip, gc->pCompositeClip); + + if (n == 1 && clip.data == NULL) { + BoxRec r; + int width, height; + bool success = true; + + DBG(("%s: trying single fill fast-path\n", __FUNCTION__)); + + if (seg->x1 < seg->x2) { + r.x1 = seg->x1; + width = seg->x2; + } else { + r.x1 = seg->x2; + width = seg->x1; + } + width -= r.x1 - 1; + r.x1 += drawable->x; + + if (seg->y1 < seg->y2) { + r.y1 = seg->y1; + height = seg->y2; + } else { + r.y1 = seg->y2; + height = seg->y1; + } + height -= r.y1- 1; + r.y1 += drawable->y; + + /* don't paint last pixel */ + if (gc->capStyle == CapNotLast) { + if (width == 1) + height--; + else + width--; + } + r.x2 = r.x1 + width; + r.y2 = r.y1 + height; + + if (box_intersect(&r, &clip.extents)) { + get_drawable_deltas(drawable, pixmap, &dx, &dy); + r.x1 += dx; r.y1 += dy; + r.x2 += dx; r.y2 += dy; + if (sna->render.fill_one(sna, pixmap, bo, gc->fgPixel, + r.x1, r.y1, r.x2, r.y2, + gc->alu)) { + if (damage) { + assert_pixmap_contains_box(pixmap, &r); + sna_damage_add_box(damage, &r); + } + } else + success = false; + } + + return success; + } + if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return FALSE; @@ -2298,7 +2358,7 @@ sna_poly_segment_blt(DrawablePtr drawable, DBG(("%s: [%d] (%d, %d)x(%d, %d) + (%d, %d)\n", __FUNCTION__, n, x, y, width, height, dx, dy)); - for (nclip = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nclip--; box++) { + for (nclip = REGION_NUM_RECTS(&clip), box = REGION_RECTS(&clip); nclip--; box++) { BoxRec r = { x, y, x + width, y + height }; if (box_intersect(&r, box)) { r.x1 += dx; @@ -2422,15 +2482,15 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) if (sna_drawable_use_gpu_bo(drawable, &extents) && sna_poly_segment_blt(drawable, priv->gpu_bo, - priv->gpu_only ? NULL : &priv->gpu_damage, - gc, n, seg)) + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, &extents), + gc, n, seg, &extents)) return; if (sna_drawable_use_cpu_bo(drawable, &extents) && sna_poly_segment_blt(drawable, priv->cpu_bo, - &priv->cpu_damage, - gc, n, seg)) + reduce_damage(drawable, &priv->cpu_damage, &extents), + gc, n, seg, &extents)) return; } commit 721cf30e9eeb0102c77f337332ad8259463b7fef Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 13:28:45 2011 +0100 sna/accel: If the data is already on the GPU, use it for the source Fixes regression from 1ec6a0e2775 (sna: Move the source to the GPU if it is reused). Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 1edd3a3..dab396e 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1143,12 +1143,15 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth, RegionUninit(®ion); } -static Bool +static bool move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv, const BoxRec *box) { int w = box->x2 - box->x1; int h = box->y2 - box->y1; + if (priv->gpu_bo) + return TRUE; + return ++priv->source_count * w*h >= 2 * pixmap->drawable.width * pixmap->drawable.height; } commit 15a4410cec111c3b3bd15ec33f29bc1f4cb709c1 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 13:28:30 2011 +0100 sna: use correct insertion point for sorting partials Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index fb24563..ffcfd9f 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1908,7 +1908,8 @@ static bool validate_partials(struct kgem *kgem) err: list_for_each_entry(bo, &kgem->partial, base.list) - ErrorF("bo: used=%d / %d\n", bo->used, bo->alloc); + ErrorF("bo: used=%d / %d, rem=%d\n", + bo->used, bo->alloc, bo->alloc - bo->used); return false; } #endif @@ -2020,7 +2021,7 @@ done: } if (p != first) { __list_del(bo->base.list.prev, bo->base.list.next); - list_add_tail(&bo->base.list, &kgem->partial); + list_add_tail(&bo->base.list, &p->base.list); } assert(validate_partials(kgem)); } From jeremyhu at kemper.freedesktop.org Tue Oct 11 09:59:07 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 11 Oct 2011 09:59:07 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111011165907.2CBA2D8002@kemper.freedesktop.org> modules/im/ximcp/imRm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) New commits: commit b5a108624331fabf393223c0891914cc54d4caf4 Author: Yann Droneaud <yann at droneaud.fr> Date: Tue Oct 11 17:27:59 2011 +0200 Return name instead of False in XSetICValues() In case of error, XSetICValues() must return the first argument that failed to be set. But in some error paths, it returns False, which is converted to NULL, so the function returns OK in case of error. Signed-off-by: Yann Droneaud <yann at droneaud.fr> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> commit 10992cb8dc5e4d938e7e5a633b68a81b5875f3ba Author: Yann Droneaud <yann at droneaud.fr> Date: Sun Oct 9 17:56:45 2011 +0200 Return name instead of value in XGetIMValues() and XSetIMValues() As stated in man page (XOpenIM) and Xlib documentation (chapter 13.5.3), XGetIMValues() and XSetImValues() "returns the name of the first argument that could not be obtained." But currently, err = XGetIMValues(im, "invalid", &arg, NULL); returns &arg instead of "invalid". This patch fixes https://bugs.freedesktop.org/show_bug.cgi?id=12897 Signed-off-by: Yann Droneaud <yann at droneaud.fr> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Tue Oct 11 10:24:39 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 11 Oct 2011 10:24:39 -0700 (PDT) Subject: libpciaccess: Changes to 'master' Message-ID: <20111011172439.45446D8002@kemper.freedesktop.org> src/linux_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit af4478c52c960bee08209293aa14b784ac30dc05 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 11 10:22:49 2011 -0700 linux sysfs: Fix read-write access in map_legacy O_RDONLY | O_WRONLY != O_RDWR >< Reported-by: Javier Pello <javier.pello at urjc.es> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Tue Oct 11 10:46:18 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 11 Oct 2011 10:46:18 -0700 (PDT) Subject: xf86-video-neomagic: Changes to 'master' Message-ID: <20111011174618.A27ABD8002@kemper.freedesktop.org> src/neo_dga.c | 4 ++-- src/neo_driver.c | 19 ++++++++++--------- src/neo_video.c | 26 +++++++++++++------------- 3 files changed, 25 insertions(+), 24 deletions(-) New commits: commit f2a771c6d2a2308245a0d46301e579b50fb2b6bd Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 11 10:45:11 2011 -0700 Include <stdlib.h> for abs() Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit c3cf7e328d7e9c276a3e237dbf9d1772b57a370e Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 11 10:43:51 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From daniels at kemper.freedesktop.org Tue Oct 11 11:06:54 2011 From: daniels at kemper.freedesktop.org (Daniel Stone) Date: Tue, 11 Oct 2011 11:06:54 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111011180654.833C0D8002@kemper.freedesktop.org> include/X11/Xutil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 50e15379331c436851abb194251cde96999e67b3 Author: Bodo Graumann <mail at bodograumann.de> Date: Mon Oct 10 16:40:52 2011 +0200 libX11: Fixing modifier key range in Xutil.h (Bug #21910) IsModifierKey, defined in include/X11/Xutil.h, is a macro determining, which keys are regarded as modifiers. The constants ISO_Level5_Shift, ISO_Level5_Latch and ISO_Level5_Lock where excluded previously, leaving some Neo2 modifiers functionless in combination with compose. This patch adjusts the range to include the correct, full range of modifier constants. Neo2 Bug 277 <http://wiki.neo-layout.org/ticket/277> X.Org Bug 21910 <http://bugs.freedesktop.org/show_bug.cgi?id=21910> Signed-off-by: Bodo Graumann <mail at bodograumann.de> Reviewed-by: Daniel Stone <daniel at fooishbar.org> From whot at kemper.freedesktop.org Tue Oct 11 18:23:29 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Tue, 11 Oct 2011 18:23:29 -0700 (PDT) Subject: xf86-input-synaptics:master: 1 commit(s) Message-ID: <20111012012329.A3077D8002@kemper.freedesktop.org> Reporting from xf86-input-synaptics: xf86-input-synaptics driver Please visit: http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics Or get your own copy by using: git-clone git://anongit.freedesktop.org/xorg/driver/xf86-input-synaptics Commit against master at ba981e22...: commit a15af628154ac37f24896a30614f3be6ecdb65c4 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Oct 12 11:20:06 2011 +1000 test: wrap ABI 14 xf86OptionRec type changes ABI 13 still uses pointer as type for most option calls, ABI 14 uses the proper type now. Wrap this so we can build against both versions. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diffstat: test/fake-symbols.c | 42 +++++++++++++++++++++--------------------- test/fake-symbols.h | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 48 insertions(+), 42 deletions(-) gitweb url: http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics;a=commit;h=a15af628 From sandmann at kemper.freedesktop.org Wed Oct 12 03:31:39 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Wed, 12 Oct 2011 03:31:39 -0700 (PDT) Subject: modular: Changes to 'master' Message-ID: <20111012103139.15311D8002@kemper.freedesktop.org> xorg.modules | 1 + 1 file changed, 1 insertion(+) New commits: commit 65d860a187822fdb7fe683b5ea3123765ca8fbf7 Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Wed Oct 12 06:28:14 2011 -0400 xorg.modules: Add libpciaccess as a dependency of libdrm Signed-off-by: S??ren Sandmann <ssp at redhat.com> From haihao at kemper.freedesktop.org Wed Oct 12 23:40:21 2011 From: haihao at kemper.freedesktop.org (Haihao Xiang) Date: Wed, 12 Oct 2011 23:40:21 -0700 (PDT) Subject: intel-gen4asm: Changes to 'master' Message-ID: <20111013064021.49E62D8002@kemper.freedesktop.org> src/gram.y | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 8 deletions(-) New commits: commit d40a1acd45012602e7ce689038507930ce70f693 Author: Xiang, Haihao <haihao.xiang at intel.com> Date: Thu Aug 11 15:35:14 2011 +0800 A new syntax of SEND intruction on Ivybridge [(<pred>)] send (<exec_size>) reg greg imm6 reg32a Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com> From ickle at kemper.freedesktop.org Thu Oct 13 09:47:43 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 13 Oct 2011 09:47:43 -0700 (PDT) Subject: xf86-video-intel: 10 commits - src/intel.h src/sna/gen2_render.c src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna.h src/sna/sna_render.h Message-ID: <20111013164743.E7FB7D8002@kemper.freedesktop.org> src/intel.h | 2 src/sna/gen2_render.c | 138 +++++++++++++++++++++++++++++--------- src/sna/kgem.c | 6 - src/sna/sna.h | 1 src/sna/sna_accel.c | 177 +++++++++++++++++++++++++++----------------------- src/sna/sna_blt.c | 9 ++ src/sna/sna_render.h | 1 7 files changed, 214 insertions(+), 120 deletions(-) New commits: commit b7fd6906c41e328649b97e16c42848a39f6e48f8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 13 17:46:48 2011 +0100 sna/accel: Actually apply the clip to the glyph extents References: https://bugs.freedesktop.org/show_bug.cgi?id=41718 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 99b0cef..4926499 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3339,6 +3339,9 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, if (box_empty(&box)) return; translate_box(&box, drawable); + clip_box(&box, gc); + if (box_empty(&box)) + return; DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); @@ -3392,6 +3395,9 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, if (box_empty(&box)) return; translate_box(&box, drawable); + clip_box(&box, gc); + if (box_empty(&box)) + return; DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); commit eb5f86b78181b174664aaa9bc689db5421b7e7bd Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 13 17:32:54 2011 +0100 sna/accel: Correctly offset the damage intersection for glyph runs Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4d41881..99b0cef 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3179,6 +3179,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + if (RegionNotEmpty(&clip)) + return false; /* XXX loop over clips using SETUP_CLIP? */ if (clip.data != NULL) { @@ -3193,6 +3195,11 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, x += drawable->x + dx; y += drawable->y + dy; + clip.extents.x1 += dx; + clip.extents.x2 += dx; + clip.extents.y1 += dy; + clip.extents.y2 += dy; + kgem_set_mode(&sna->kgem, KGEM_BLT); if (!kgem_check_batch(&sna->kgem, 16) || !kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL) || @@ -3209,8 +3216,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, b[1] >>= 2; } b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16; - b[2] = (dy + clip.extents.y1) << 16 | (dx + clip.extents.x1); - b[3] = (dy + clip.extents.y2) << 16 | (dx + clip.extents.x2); + b[2] = clip.extents.y1 << 16 | clip.extents.x1; + b[3] = clip.extents.y2 << 16 | clip.extents.x2; b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4, priv->gpu_bo, I915_GEM_DOMAIN_RENDER << 16 | @@ -3255,8 +3262,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, b[1] >>= 2; } b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16; - b[2] = (dy + clip.extents.y1) << 16 | (dx + clip.extents.x1); - b[3] = (dy + clip.extents.y2) << 16 | (dx + clip.extents.x2); + b[2] = clip.extents.y1 << 16 | clip.extents.x1; + b[3] = clip.extents.y2 << 16 | clip.extents.x2; b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4, priv->gpu_bo, I915_GEM_DOMAIN_RENDER << 16 | @@ -3297,7 +3304,7 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, r.y1 = y1; r.x2 = x1 + w; r.y2 = y1 + h; - if (box_intersect(&r, extents)) + if (box_intersect(&r, &clip.extents)) sna_damage_add_box(damage, &r); } skip: commit a4766026ad0aa14283e35598d33f13d311cc029b Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 13 17:32:30 2011 +0100 sna/accel: Check for reloc overflow when adding a new glyph run Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index f40c132..4d41881 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3195,7 +3195,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, kgem_set_mode(&sna->kgem, KGEM_BLT); if (!kgem_check_batch(&sna->kgem, 16) || - !kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) { + !kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL) || + !kgem_check_reloc(&sna->kgem, 1)) { _kgem_submit(&sna->kgem); _kgem_set_mode(&sna->kgem, KGEM_BLT); } commit b10850af4125b8dbc36d13fa83f1dcce13ac6684 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 13 17:09:25 2011 +0100 sna/blt: Check for reloc overflow when initialising solid fills Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index a8d39bd..1375a7a 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -152,7 +152,14 @@ static bool sna_blt_fill_init(struct sna *sna, if (sna->blt_state.fill_bo != bo->handle || sna->blt_state.fill_pixel != pixel) { - uint32_t *b = kgem->batch + kgem->nbatch; + uint32_t *b; + + if (kgem->nreloc + 1 > KGEM_RELOC_SIZE(kgem)) { + _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } + + b = kgem->batch + kgem->nbatch; b[0] = blt->cmd; b[1] = blt->br13; b[2] = 0; commit d5242565ef17cb4265177338df5b564b960e3692 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 12 21:14:43 2011 +0100 sna/gen2: Trim some surplus state commands Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index a7ace88..d862235 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -310,30 +310,12 @@ gen2_emit_texture(struct sna *sna, OUT_BATCH((channel->bo->pitch / 4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D); OUT_BATCH(filter); OUT_BATCH(0); /* default color */ + OUT_BATCH(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | texcoordtype | ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(wrap_mode) | ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); - /* map texel stream */ - OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD); - if (unit == 0) - OUT_BATCH(TEXBIND_SET0(TEXCOORDSRC_VTXSET_0) | - TEXBIND_SET1(TEXCOORDSRC_KEEP) | - TEXBIND_SET2(TEXCOORDSRC_KEEP) | - TEXBIND_SET3(TEXCOORDSRC_KEEP)); - else - OUT_BATCH(TEXBIND_SET0(TEXCOORDSRC_VTXSET_0) | - TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) | - TEXBIND_SET2(TEXCOORDSRC_KEEP) | - TEXBIND_SET3(TEXCOORDSRC_KEEP)); - OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | - (unit << 16) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | - TEX_STREAM_COORD_SET(unit) | - ENABLE_TEX_STREAM_MAP_IDX | - TEX_STREAM_MAP_IDX(unit)); } static void @@ -640,13 +622,14 @@ static void gen2_enable_logic_op(struct sna *sna, int op) static void gen2_emit_composite_state(struct sna *sna, const struct sna_composite_op *op) { - uint32_t texcoordfmt; + uint32_t texcoordfmt, v, unwind; uint32_t cblend, ablend; int tex; gen2_get_batch(sna); gen2_emit_target(sna, op); + unwind = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); OUT_BATCH((!op->src.is_solid + (op->mask.bo != NULL)) << 12); @@ -656,14 +639,27 @@ static void gen2_emit_composite_state(struct sna *sna, op->has_component_alpha, op->dst.format) | S8_ENABLE_COLOR_BUFFER_WRITE); + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, + sna->kgem.batch + unwind, + 4 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = unwind; + else + sna->render_state.gen2.ls1 = unwind; gen2_disable_logic_op(sna); gen2_get_blend_factors(op, op->op, &cblend, &ablend); + unwind = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0) | 1); OUT_BATCH(cblend); OUT_BATCH(ablend); + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, + sna->kgem.batch + unwind + 1, + 2 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = unwind; + else + sna->render_state.gen2.ls2 = unwind; tex = texcoordfmt = 0; if (!op->src.is_solid) { @@ -683,7 +679,12 @@ static void gen2_emit_composite_state(struct sna *sna, texcoordfmt |= TEXCOORDFMT_3D << (2*tex); gen2_emit_texture(sna, &op->mask, tex++); } - OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD | texcoordfmt); + + v = _3DSTATE_VERTEX_FORMAT_2_CMD | texcoordfmt; + if (sna->render_state.gen2.vft != v) { + OUT_BATCH(v); + sna->render_state.gen2.vft = v; + } } static inline void @@ -871,12 +872,14 @@ static void gen2_magic_ca_pass(struct sna *sna, OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | gen2_get_blend_cntl(PictOpAdd, TRUE, op->dst.format) | S8_ENABLE_COLOR_BUFFER_WRITE); + sna->render_state.gen2.ls1 = 0; gen2_get_blend_factors(op, PictOpAdd, &cblend, &ablend); OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0) | 1); OUT_BATCH(cblend); OUT_BATCH(ablend); + sna->render_state.gen2.ls2 = 0; memcpy(sna->kgem.batch + sna->kgem.nbatch, sna->kgem.batch + sna->render_state.gen2.vertex_offset, @@ -1525,6 +1528,7 @@ gen2_emit_spans_pipeline(struct sna *sna, const struct sna_composite_spans_op *op) { uint32_t cblend, ablend; + uint32_t unwind; cblend = TB0C_LAST_STAGE | TB0C_RESULT_SCALE_1X | TB0C_OP_MODULATE | @@ -1555,18 +1559,28 @@ gen2_emit_spans_pipeline(struct sna *sna, ablend |= TB0A_ARG2_SEL_TEXEL0; } + unwind = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0) | 1); OUT_BATCH(cblend); OUT_BATCH(ablend); + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, + sna->kgem.batch + unwind + 1, + 2 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = unwind; + else + sna->render_state.gen2.ls2 = unwind; } static void gen2_emit_composite_spans_state(struct sna *sna, const struct sna_composite_spans_op *op) { + uint32_t unwind; + gen2_get_batch(sna); gen2_emit_target(sna, &op->base); + unwind = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); OUT_BATCH(!op->base.src.is_solid << 12); @@ -1574,6 +1588,12 @@ static void gen2_emit_composite_spans_state(struct sna *sna, OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | gen2_get_blend_cntl(op->base.op, FALSE, op->base.dst.format) | S8_ENABLE_COLOR_BUFFER_WRITE); + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, + sna->kgem.batch + unwind, + 4 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = unwind; + else + sna->render_state.gen2.ls1 = unwind; gen2_disable_logic_op(sna); gen2_emit_spans_pipeline(sna, op); @@ -1582,8 +1602,12 @@ static void gen2_emit_composite_spans_state(struct sna *sna, OUT_BATCH(_3DSTATE_DFLT_SPECULAR_CMD); OUT_BATCH(op->base.src.u.gen2.pixel); } else { - OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD | - (op->base.src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_3D)); + uint32_t v =_3DSTATE_VERTEX_FORMAT_2_CMD | + (op->base.src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_3D); + if (sna->render_state.gen2.vft != v) { + OUT_BATCH(v); + sna->render_state.gen2.vft = v; + } gen2_emit_texture(sna, &op->base.src, 0); } } @@ -1761,8 +1785,9 @@ cleanup_dst: static void gen2_emit_fill_pipeline(struct sna *sna, const struct sna_composite_op *op) { - uint32_t blend; + uint32_t blend, unwind; + unwind = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0) | 1); @@ -1776,15 +1801,25 @@ gen2_emit_fill_pipeline(struct sna *sna, const struct sna_composite_op *op) OUT_BATCH(TB0A_RESULT_SCALE_1X | TB0A_OP_ARG1 | TB0A_ARG1_SEL_DIFFUSE | TB0A_OUTPUT_WRITE_CURRENT); + + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, + sna->kgem.batch + unwind + 1, + 2 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = unwind; + else + sna->render_state.gen2.ls2 = unwind; } static void gen2_emit_fill_composite_state(struct sna *sna, const struct sna_composite_op *op, uint32_t pixel) { + uint32_t ls1; + gen2_get_batch(sna); gen2_emit_target(sna, op); + ls1 = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); OUT_BATCH(0); @@ -1792,6 +1827,12 @@ static void gen2_emit_fill_composite_state(struct sna *sna, OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | gen2_get_blend_cntl(op->op, FALSE, op->dst.format) | S8_ENABLE_COLOR_BUFFER_WRITE); + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, + sna->kgem.batch + ls1, + 4 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = ls1; + else + sna->render_state.gen2.ls1 = ls1; gen2_emit_fill_pipeline(sna, op); @@ -1934,17 +1975,23 @@ gen2_render_fill_boxes(struct sna *sna, static void gen2_emit_fill_state(struct sna *sna, const struct sna_composite_op *op) { + uint32_t ls1; + gen2_get_batch(sna); gen2_emit_target(sna, op); + ls1 = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | - I1_LOAD_S(3) | - I1_LOAD_S(8) | - 2); + I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); OUT_BATCH(0); OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); OUT_BATCH(S8_ENABLE_COLOR_BUFFER_WRITE); + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, + sna->kgem.batch + ls1, + 4 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = ls1; + else + sna->render_state.gen2.ls1 = ls1; gen2_enable_logic_op(sna, op->op); gen2_emit_fill_pipeline(sna, op); @@ -2131,8 +2178,9 @@ gen2_render_copy_setup_source(struct sna_composite_channel *channel, static void gen2_emit_copy_pipeline(struct sna *sna, const struct sna_composite_op *op) { - uint32_t blend; + uint32_t blend, unwind; + unwind = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0) | 1); @@ -2153,26 +2201,44 @@ gen2_emit_copy_pipeline(struct sna *sna, const struct sna_composite_op *op) else blend |= TB0A_ARG1_SEL_TEXEL0; OUT_BATCH(blend); + + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, + sna->kgem.batch + unwind + 1, + 2 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = unwind; + else + sna->render_state.gen2.ls2 = unwind; } static void gen2_emit_copy_state(struct sna *sna, const struct sna_composite_op *op) { + uint32_t ls1, v; + gen2_get_batch(sna); gen2_emit_target(sna, op); + ls1 = sna->kgem.nbatch; OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | - I1_LOAD_S(3) | - I1_LOAD_S(8) | - 2); + I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); OUT_BATCH(1<<12); OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); OUT_BATCH(S8_ENABLE_COLOR_BUFFER_WRITE); + if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, + sna->kgem.batch + ls1, + 4 * sizeof(uint32_t)) == 0) + sna->kgem.nbatch = ls1; + else + sna->render_state.gen2.ls1 = ls1; gen2_enable_logic_op(sna, op->op); gen2_emit_copy_pipeline(sna, op); - OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD | TEXCOORDFMT_2D); + v = _3DSTATE_VERTEX_FORMAT_2_CMD | TEXCOORDFMT_2D; + if (sna->render_state.gen2.vft != v) { + OUT_BATCH(v); + sna->render_state.gen2.vft = v; + } + gen2_emit_texture(sna, &op->src, 0); } @@ -2386,6 +2452,10 @@ gen2_render_reset(struct sna *sna) sna->render_state.gen2.logic_op_enabled = FALSE; sna->render_state.gen2.vertex_offset = 0; sna->render_state.gen2.target = 0; + + sna->render_state.gen2.ls1 = 0; + sna->render_state.gen2.ls2 = 0; + sna->render_state.gen2.vft = 0; } static void diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 9e658a8..223cae6 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -269,6 +269,7 @@ struct gen2_render_state { uint32_t target; Bool need_invariant; Bool logic_op_enabled; + uint32_t ls1, ls2, vft; uint16_t vertex_offset; }; commit 7c5020532335c07d9b0f6cecb0b004de4af6d273 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 12 20:36:53 2011 +0100 Remove vestigial includes from DRI1 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/intel.h b/src/intel.h index 2f72830..4acd0f2 100644 --- a/src/intel.h +++ b/src/intel.h @@ -65,9 +65,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <pciaccess.h> #include "xf86drm.h" -#include "sarea.h" #define _XF86DRI_SERVER_ -#include "dri.h" #include "dri2.h" #include "intel_bufmgr.h" #include "i915_drm.h" diff --git a/src/sna/sna.h b/src/sna/sna.h index 189e3d4..e27c333 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -60,7 +60,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86drmMode.h" #define _XF86DRI_SERVER_ -#include "dri.h" #include "dri2.h" #include "i915_drm.h" commit b6b3bb9b5e56949cbd9189d9857ffa1ff46377fd Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Sep 20 19:41:03 2011 +0100 sna: compare against the right array of cache buckets Fortunately harmless today as there are the same number of inactive/active buckets. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index ffcfd9f..15ddd7a 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -309,15 +309,15 @@ static struct list *active(struct kgem *kgem, int size) { uint32_t order = __fls(size / PAGE_SIZE); - if (order >= ARRAY_SIZE(kgem->inactive)) - order = ARRAY_SIZE(kgem->inactive)-1; + if (order >= ARRAY_SIZE(kgem->active)) + order = ARRAY_SIZE(kgem->active)-1; return &kgem->active[order]; } static size_t agp_aperture_size(struct pci_device *dev, int gen) { - return dev->regions[gen < 30 ? 0 :2].size; + return dev->regions[gen < 30 ? 0 : 2].size; } void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen) commit 1f70095837a30d6a88b9e313d3583d38ea55221d Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 16:06:31 2011 +0100 sna: And free the clip after creation for PolySegments Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 599f070..f40c132 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2330,8 +2330,10 @@ sna_poly_segment_blt(DrawablePtr drawable, return success; } - if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) + if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) { + RegionUninit(&clip); return FALSE; + } get_drawable_deltas(drawable, pixmap, &dx, &dy); while (n--) { @@ -2388,6 +2390,7 @@ sna_poly_segment_blt(DrawablePtr drawable, seg++; } fill.done(sna, &fill); + RegionUninit(&clip); return TRUE; } commit 92f4d978c8b1f5e9a6cf3affa15d90bfb3d4e7b9 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 15:52:13 2011 +0100 sna: More micro-optimisation of messing around with clip regions Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 88c21c5..599f070 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -63,6 +63,18 @@ DevPrivateKeyRec sna_pixmap_index; +static inline void region_set(RegionRec *r, const BoxRec *b) +{ + r->extents = *b; + r->data = NULL; +} + +static inline void region_maybe_clip(RegionRec *r, RegionRec *clip) +{ + if (clip && clip->data) + RegionIntersect(r, r, clip); +} + #define PM_IS_SOLID(_draw, _pm) \ (((_pm) & FbFullMask((_draw)->depth)) == FbFullMask((_draw)->depth)) @@ -1118,7 +1130,7 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth, if (box_empty(&box)) return; - RegionInit(®ion, &box, 1); + region_set(®ion, &box); clip = fbGetCompositeClip(gc); if (clip) { @@ -1451,8 +1463,7 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, box.y1 = dst_y + dst->y; box.x2 = box.x1 + width; box.y2 = box.y1 + height; - RegionInit(®ion, &box, 1); - + region_set(®ion, &box); if (gc->pCompositeClip) RegionIntersect(®ion, ®ion, gc->pCompositeClip); @@ -1517,12 +1528,12 @@ static Bool sna_fill_spans_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, GCPtr gc, int n, - DDXPointPtr pt, int *width, int sorted) + DDXPointPtr pt, int *width, int sorted, + const BoxRec *extents) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); - BoxPtr extents; - int nclip = REGION_NUM_RECTS(gc->pCompositeClip); + RegionRec clip; int need_translation = !gc->miTranslate; int16_t dx, dy; struct sna_fill_op fill; @@ -1530,10 +1541,12 @@ sna_fill_spans_blt(DrawablePtr drawable, if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return false; - extents = REGION_EXTENTS(gc->screen, gc->pCompositeClip); + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); + DBG(("%s: clip %d x [(%d, %d), (%d, %d)] x %d [(%d, %d)...]\n", __FUNCTION__, - REGION_NUM_RECTS(gc->pCompositeClip), + REGION_NUM_RECTS(&clip), extents->x1, extents->y1, extents->x2, extents->y2, n, pt->x, pt->y)); @@ -1565,7 +1578,7 @@ sna_fill_spans_blt(DrawablePtr drawable, continue; y += dy; - if (nclip == 1) { + if (clip.data == NULL) { X1 += dx; X2 += dx; assert(X1 >= 0 && X2 <= pixmap->drawable.width); @@ -1584,12 +1597,12 @@ sna_fill_spans_blt(DrawablePtr drawable, } } } else { - int nc = nclip; - BoxPtr clip = REGION_RECTS(gc->pCompositeClip); + int nc = clip.data->numRects; + const BoxRec *b = RegionBoxptr(&clip); while (nc--) { - if (clip->y1 <= y && y < clip->y2) { - int x1 = clip->x1; - int x2 = clip->x2; + if (b->y1 <= y && y < b->y2) { + int x1 = b->x1; + int x2 = b->x2; if (x1 < X1) x1 = X1; @@ -1618,11 +1631,12 @@ sna_fill_spans_blt(DrawablePtr drawable, } } } - clip++; + b++; } } } fill.done(sna, &fill); + RegionUninit(&clip); return TRUE; } @@ -1744,14 +1758,16 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, sna_fill_spans_blt(drawable, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, &extents), - gc, n, pt, width, sorted)) + gc, n, pt, width, sorted, + &extents)) return; if (sna_drawable_use_cpu_bo(drawable, &extents) && sna_fill_spans_blt(drawable, priv->cpu_bo, reduce_damage(drawable, &priv->cpu_damage, &extents), - gc, n, pt, width, sorted)) + gc, n, pt, width, sorted, + &extents)) return; } else if (gc->fillStyle == FillTiled) { xRectangle *rect; @@ -1778,9 +1794,8 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, fallback: DBG(("%s: fallback\n", __FUNCTION__)); - RegionInit(®ion, &extents, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &extents); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -1804,9 +1819,8 @@ sna_set_spans(DrawablePtr drawable, GCPtr gc, char *src, DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, extents.x1, extents.y1, extents.x2, extents.y2)); - RegionInit(®ion, &extents, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &extents); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -1834,9 +1848,8 @@ sna_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc, box.x2 = box.x1 + w; box.y2 = box.y1 + h; - RegionInit(®ion, &box, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &box); + region_maybe_clip(®ion, gc->pCompositeClip); sna_drawable_move_region_to_cpu(dst, ®ion, true); RegionTranslate(®ion, @@ -1977,9 +1990,8 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc, fallback: DBG(("%s: fallback\n", __FUNCTION__)); - RegionInit(®ion, &extents, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &extents); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2220,9 +2232,8 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, fallback: DBG(("%s: fallback\n", __FUNCTION__)); - RegionInit(®ion, &extents, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &extents); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2261,9 +2272,8 @@ sna_poly_segment_blt(DrawablePtr drawable, DBG(("%s: alu=%d, fg=%08lx\n", __FUNCTION__, gc->alu, gc->fgPixel)); - RegionInit(&clip, (BoxPtr)extents, 1); - if (gc->pCompositeClip && gc->pCompositeClip->data) - RegionIntersect(&clip, &clip, gc->pCompositeClip); + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); if (n == 1 && clip.data == NULL) { BoxRec r; @@ -2524,9 +2534,8 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) fallback: DBG(("%s: fallback\n", __FUNCTION__)); - RegionInit(®ion, &extents, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &extents); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2628,9 +2637,8 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) } fallback: - RegionInit(®ion, &extents, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &extents); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2728,7 +2736,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, r.y2 = bound(r.y1, rect->height); rect++; - RegionInit(®ion, &r, 1); + region_set(®ion, &r); RegionIntersect(®ion, ®ion, clip); nbox = REGION_NUM_RECTS(®ion); @@ -2836,7 +2844,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, r.y2 = bound(r.y1, rect->height); rect++; - RegionInit(®ion, &r, 1); + region_set(®ion, &r); RegionIntersect(®ion, ®ion, clip); nbox = REGION_NUM_RECTS(®ion); @@ -2939,7 +2947,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, r.y2 = bound(r.y1, rect->height); rect++; - RegionInit(®ion, &r, 1); + region_set(®ion, &r); RegionIntersect(®ion, ®ion, clip); nbox = REGION_NUM_RECTS(®ion); @@ -3097,9 +3105,8 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) fallback: DBG(("%s: fallback (%d, %d), (%d, %d)\n", __FUNCTION__, extents.x1, extents.y1, extents.x2, extents.y2)); - RegionInit(®ion, &extents, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &extents); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) { DBG(("%s: nothing to do, all clipped\n", __FUNCTION__)); return; @@ -3167,9 +3174,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, if (priv->gpu_bo->tiling == I915_TILING_Y) return false; - RegionInit(&clip, (BoxPtr)extents, 1); - if (gc->pCompositeClip && gc->pCompositeClip->data) - RegionIntersect(&clip, &clip, gc->pCompositeClip); + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); /* XXX loop over clips using SETUP_CLIP? */ if (clip.data != NULL) { @@ -3339,9 +3345,8 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, return; fallback: - RegionInit(®ion, &box, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &box); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -3390,13 +3395,11 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, if (sna_drawable_use_gpu_bo(drawable, &box) && sna_glyph_blt(drawable, gc, x, y, n, info, base, true, &box)) - return; fallback: - RegionInit(®ion, &box, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &box); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -3437,9 +3440,8 @@ sna_push_pixels(GCPtr gc, PixmapPtr bitmap, DrawablePtr drawable, DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); - RegionInit(®ion, &box, 1); - if (gc->pCompositeClip) - RegionIntersect(®ion, ®ion, gc->pCompositeClip); + region_set(®ion, &box); + region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -3537,7 +3539,7 @@ sna_get_image(DrawablePtr drawable, extents.y1 = y + drawable->y; extents.x2 = extents.x1 + w; extents.y2 = extents.y1 + h; - RegionInit(®ion, &extents, 1); + region_set(®ion, &extents); sna_drawable_move_region_to_cpu(drawable, ®ion, false); fbGetImage(drawable, x, y, w, h, format, mask, dst); @@ -3555,7 +3557,7 @@ sna_get_spans(DrawablePtr drawable, int wMax, if (sna_spans_extents(drawable, NULL, n, pt, width, &extents)) return; - RegionInit(®ion, &extents, 1); + region_set(®ion, &extents); sna_drawable_move_region_to_cpu(drawable, ®ion, false); RegionUninit(®ion); commit 57151f654752ed64716358ecb5e9217b59784da8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 11 15:23:17 2011 +0100 sna: Micro-optimise checking for singular clip boxes Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 227123d..88c21c5 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -405,7 +405,7 @@ region_subsumes_drawable(RegionPtr region, DrawablePtr drawable) { const BoxRec *extents; - if (REGION_NUM_RECTS(region) != 1) + if (region->data) return false; extents = RegionExtents(region); @@ -2658,8 +2658,8 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, DBG(("%s x %d [(%d, %d)+(%d, %d)...]\n", __FUNCTION__, n, rect->x, rect->y, rect->width, rect->height)); - if (n == 1 && REGION_NUM_RECTS(clip) == 1) { - BoxPtr box = REGION_RECTS(clip); + if (n == 1 && clip->data == NULL) { + BoxPtr box = &clip->extents; BoxRec r; bool success = true; @@ -2691,8 +2691,8 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, } get_drawable_deltas(drawable, pixmap, &dx, &dy); - if (REGION_NUM_RECTS(clip) == 1) { - BoxPtr box = REGION_RECTS(clip); + if (clip->data == NULL) { + BoxPtr box = &clip->extents; while (n--) { BoxRec r; @@ -2799,8 +2799,8 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, return FALSE; } - if (REGION_NUM_RECTS(clip) == 1) { - BoxPtr box = REGION_RECTS(clip); + if (clip->data == NULL) { + BoxPtr box = &clip->extents; while (n--) { BoxRec r; @@ -2875,8 +2875,8 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, return FALSE; } - if (REGION_NUM_RECTS(clip) == 1) { - const BoxRec *box = REGION_RECTS(clip); + if (clip->data == NULL) { + const BoxRec *box = &clip->extents; while (n--) { BoxRec r; @@ -3172,7 +3172,7 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, RegionIntersect(&clip, &clip, gc->pCompositeClip); /* XXX loop over clips using SETUP_CLIP? */ - if (REGION_NUM_RECTS(&clip) != 1) { + if (clip.data != NULL) { RegionUninit(&clip); return false; } From ickle at kemper.freedesktop.org Thu Oct 13 14:30:46 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 13 Oct 2011 14:30:46 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111013213047.15967D8002@kemper.freedesktop.org> src/sna/sna_accel.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) New commits: commit 020d84d2d09c71a8209dd774a0735a3c11cb148d Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 13 22:32:00 2011 +0100 sna/accel: Fix sense of nothing-to-do due to clipping A missing not due to a hasty conversion from an assert. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4926499..1073757 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3174,16 +3174,20 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, uint8_t rop = transparent ? ROP[gc->alu] : ROP_S; RegionRec clip; - if (priv->gpu_bo->tiling == I915_TILING_Y) + if (priv->gpu_bo->tiling == I915_TILING_Y) { + DBG(("%s -- fallback, dst uses Y-tiling\n", __FUNCTION__)); return false; + } region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); - if (RegionNotEmpty(&clip)) - return false; + if (!RegionNotEmpty(&clip)) + return true; /* XXX loop over clips using SETUP_CLIP? */ if (clip.data != NULL) { + DBG(("%s -- fallback too many clip rects [%d]\n", + __FUNCTION__, REGION_NUM_RECTS(&clip))); RegionUninit(&clip); return false; } From alanc at kemper.freedesktop.org Thu Oct 13 18:00:54 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Thu, 13 Oct 2011 18:00:54 -0700 (PDT) Subject: luit: Changes to 'master' Message-ID: <20111014010054.D20B2D8002@kemper.freedesktop.org> configure.ac | 2 +- sys.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) New commits: commit 525785fd7beca872ebeeb8bb6c22d82459128788 Author: Ed Schouten <ed at 80386.nl> Date: Wed Oct 12 20:53:21 2011 +0200 Add support for posix_openpt(). Instead of opening /dev/ptmx directly, we should use the proper posix_openpt() function to obtain a pseudo-terminal. Some operating systems, such as FreeBSD 8 and later, implement pseudo-terminal master device nodes as a special file descriptor type, like sockets. They do not support creation of pseudo-terminals through /dev/ptmx. Signed-off-by: Ed Schouten <ed at 80386.nl> Reviewed-by: Guillem Jover <guillem at hadrons.org> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From jeremyhu at kemper.freedesktop.org Fri Oct 14 01:16:58 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 14 Oct 2011 01:16:58 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' - 7 commits Message-ID: <20111014081658.2D22FD8002@kemper.freedesktop.org> config/udev.c | 2 +- dix/events.c | 25 ++++++++++++++++--------- dix/grabs.c | 2 +- test/input.c | 2 +- xkb/xkb.c | 3 +++ 5 files changed, 22 insertions(+), 12 deletions(-) New commits: commit bbe6a69da398dba93679c23c3c50f9916cb562ca Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Jul 29 16:33:54 2011 +1000 dix: don't XWarpPointer through the last slave anymore (#38313) This line was introduced pre-1.6 to fix Bug 19297. The effect of warping through the VCP then was that if a device had custom valuator ranges, the warp position would be wrong. The better device for this effect is the the XTest device. This fixes a server crash where the lastSlave is a pointer device without valuators (Bug 38313#0). And while we're at it, make sure the Xinerama code-path does the same. X.Org Bug 38313 <http://bugs.freedesktop.org/show_bug.cgi?id=38313> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> (cherry picked from commit 2bfb802839688ecf328119c4c6979390fc60348d) diff --git a/dix/events.c b/dix/events.c index 8e7f9c3..8068fc7 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3351,16 +3351,21 @@ XineramaWarpPointer(ClientPtr client) { WindowPtr dest = NULL; int x, y, rc; - SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite; + DeviceIntPtr dev; + SpritePtr pSprite; REQUEST(xWarpPointerReq); - if (stuff->dstWid != None) { rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess); if (rc != Success) return rc; } + + /* Post through the XTest device */ + dev = PickPointer(client); + dev = GetXTestDevice(dev); + pSprite = dev->spriteInfo->sprite; x = pSprite->hotPhys.x; y = pSprite->hotPhys.y; @@ -3410,9 +3415,9 @@ XineramaWarpPointer(ClientPtr client) else if (y >= pSprite->physLimits.y2) y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) - ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y); + ConfineToShape(dev, pSprite->hotShape, &x, &y); - XineramaSetCursorPosition(PickPointer(client), x, y, TRUE); + XineramaSetCursorPosition(dev, x, y, TRUE); return Success; } @@ -3430,7 +3435,7 @@ ProcWarpPointer(ClientPtr client) WindowPtr dest = NULL; int x, y, rc; ScreenPtr newScreen; - DeviceIntPtr dev, tmp; + DeviceIntPtr dev, tmp, xtest_dev = NULL; SpritePtr pSprite; REQUEST(xWarpPointerReq); @@ -3443,11 +3448,13 @@ ProcWarpPointer(ClientPtr client) rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess); if (rc != Success) return rc; + if (IsXTestDevice(tmp, dev)) + xtest_dev = tmp; } } - if (dev->lastSlave) - dev = dev->lastSlave; + /* Use the XTest device to actually move the pointer */ + dev = xtest_dev; pSprite = dev->spriteInfo->sprite; #ifdef PANORAMIX commit 2e28ff155ffc30707d42d885d5f6fc891bc82252 Author: Nobuhiro Iwamatsu <iwamatsu at nigauri.org> Date: Tue Aug 9 11:00:34 2011 +0900 Disable check of double-aligned in test/input.c on Renesas SH Renesas SH is not aligned at size of double. When structure has double value, It is aligned in 4byte (long). Signed-off-by: Nobuhiro Iwamatsu <iwamatsu at nigauri.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> (cherry picked from commit b29ce0726d55ec41cfbce0814e21b0217ef64efe) diff --git a/test/input.c b/test/input.c index 837ce49..6a0c523 100644 --- a/test/input.c +++ b/test/input.c @@ -1223,7 +1223,7 @@ static void dix_valuator_alloc(void) assert(v); assert(v->numAxes == num_axes); -#ifndef __i386__ +#if !defined(__i386__) && !defined(__sh__) /* must be double-aligned on 64 bit */ assert(((void*)v->axisVal - (void*)v) % sizeof(double) == 0); assert(((void*)v->axes - (void*)v) % sizeof(double) == 0); commit 79ac611d3121801c34f111c91b5ace5769719695 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Aug 1 14:12:41 2011 +1000 dix: don't use the pointer as modifier device in UngrabKey. Modifier device is always the keyboard. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> (cherry picked from commit 8c5a4d6fbecf79f2dc4f2d836d741203b2d5e856) diff --git a/dix/events.c b/dix/events.c index 89f6810..8e7f9c3 100644 --- a/dix/events.c +++ b/dix/events.c @@ -5372,7 +5372,7 @@ ProcUngrabKey(ClientPtr client) tempGrab.window = pWin; tempGrab.modifiersDetail.exact = stuff->modifiers; tempGrab.modifiersDetail.pMask = NULL; - tempGrab.modifierDevice = GetPairedDevice(keybd); + tempGrab.modifierDevice = keybd; tempGrab.type = KeyPress; tempGrab.grabtype = GRABTYPE_CORE; tempGrab.detail.exact = stuff->key; commit 843737b4f979fed3a6d74cdfc7047ce5ca886639 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Thu Jul 28 15:56:08 2011 +1000 dix: ignore devices when adding passive core grabs to list (#39545) Passive core grabs are mostly device-independent. In an MPX scenario, they may change to reflect whichever master pair activated the grab last. For adding new grabs to the list, ignore the device for core grabs to return failures when trying to set the same grab combo twice on a window. X.Org Bug 39545 <http://bugs.freedesktop.org/show_bug.cgi?id=39545> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> (cherry picked from commit 09496996accfdaf7bc01097a25db400912004d97) diff --git a/dix/grabs.c b/dix/grabs.c index 85ca9ee..c28356d 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -479,7 +479,7 @@ AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab) for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next) { - if (GrabMatchesSecond(pGrab, grab, FALSE)) + if (GrabMatchesSecond(pGrab, grab, (pGrab->grabtype == GRABTYPE_CORE))) { if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource)) { commit cb9c1d6d6cb25f55b1e4ac382e5af72a044e06aa Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Thu Jul 28 15:43:10 2011 +1000 dix: avoid using the VCP as modifier device Core grabs may change device when they're activated to reflect the master they apply to. If the device is a keyboard, modifierDevice is erroneously set to the Virtual Core Pointer. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> (cherry picked from commit 80c37048539daa1d257d127d66502bde45c97c85) diff --git a/dix/events.c b/dix/events.c index 9e58edb..89f6810 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3678,7 +3678,7 @@ CheckPassiveGrabsOnWindow( if (tempGrab.type < GenericEvent) { grab->device = device; - grab->modifierDevice = GetPairedDevice(device); + grab->modifierDevice = GetMaster(device, MASTER_KEYBOARD); } for (other = inputInfo.devices; other; other = other->next) commit ef5c31430c891cf44148ea31058ed4cfb9bec21a Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Jul 20 16:21:28 2011 +1000 config: fix a log message PRODUCT was taken from the parent, hence ppath. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> (cherry picked from commit e684e816acb617b4dc66a68e2b0ba8f80399170a) diff --git a/config/udev.c b/config/udev.c index e7383dc..42713e9 100644 --- a/config/udev.c +++ b/config/udev.c @@ -114,7 +114,7 @@ device_added(struct udev_device *udev_device) == -1) attrs.usb_id = NULL; else - LOG_PROPERTY(path, "PRODUCT", product); + LOG_PROPERTY(ppath, "PRODUCT", product); } } if (!name) commit ec8ee3a9f76cc94d6fa4e7245c1a8fb68a42783c Author: Peter Harris <pharris at opentext.com> Date: Fri Sep 2 18:45:16 2011 -0400 xkb: add missing swaps for xkbGetDeviceInfoReply Caught during review of e095369bf. Signed-off-by: Peter Harris <pharris at opentext.com> Reviewed-by-by: Matt Turner <mattst88 at gmail.com> Signed-off-by: Matt Turner <mattst88 at gmail.com> (cherry picked from commit c90903b4f7a826ae6826a8dd0a901c8362500e46) Conflicts: xkb/xkb.c Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/xkb/xkb.c b/xkb/xkb.c index 9c66955..6e0f542 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -6240,6 +6240,9 @@ char * str; swaps(&rep.unsupported,n); swaps(&rep.nDeviceLedFBs,n); swapl(&rep.type,n); + swaps(&rep.dfltKbdFB, n); + swaps(&rep.dfltLedFB, n); + swapl(&rep.devType, n); } WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep); From ickle at kemper.freedesktop.org Fri Oct 14 04:31:50 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Fri, 14 Oct 2011 04:31:50 -0700 (PDT) Subject: xf86-video-intel: 5 commits - src/i965_render.c src/intel_video.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_tiling.c src/sna/sna_trapezoids.c Message-ID: <20111014113150.E9572D8002@kemper.freedesktop.org> src/i965_render.c | 1 - src/intel_video.c | 13 +++++++------ src/sna/sna_accel.c | 15 +++++++-------- src/sna/sna_blt.c | 28 ++++++++++++++++++++++++++++ src/sna/sna_tiling.c | 19 +++++++++++++++++++ src/sna/sna_trapezoids.c | 8 +++++--- 6 files changed, 66 insertions(+), 18 deletions(-) New commits: commit 33f17b996dd0fcbb8e07875770e11571380d6509 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 14 12:01:34 2011 +0100 Remove a couple of trivial compile warnings for unused variables Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/i965_render.c b/src/i965_render.c index bc0bd93..825fc13 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -182,7 +182,6 @@ i965_check_composite(int op, int width, int height) { ScrnInfoPtr scrn = xf86Screens[dest_picture->pDrawable->pScreen->myNum]; - intel_screen_private *intel = intel_get_screen_private(scrn); /* Check for unsupported compositing operations. */ if (op >= sizeof(i965_blend_op) / sizeof(i965_blend_op[0])) { diff --git a/src/intel_video.c b/src/intel_video.c index a35445d..d1d6126 100644 --- a/src/intel_video.c +++ b/src/intel_video.c @@ -210,14 +210,13 @@ static Bool intel_has_overlay(intel_screen_private *intel) gp.value = &has_overlay; ret = drmCommandWriteRead(intel->drmSubFD, DRM_I915_GETPARAM, &gp, sizeof(gp)); - return !! has_overlay; + return ret == 0 && !! has_overlay; } -static void intel_overlay_update_attrs(intel_screen_private *intel) +static Bool intel_overlay_update_attrs(intel_screen_private *intel) { intel_adaptor_private *adaptor_priv = intel_get_adaptor_private(intel); struct drm_intel_overlay_attrs attrs; - int ret; attrs.flags = I915_OVERLAY_UPDATE_ATTRS; attrs.brightness = adaptor_priv->brightness; @@ -231,8 +230,8 @@ static void intel_overlay_update_attrs(intel_screen_private *intel) attrs.gamma4 = adaptor_priv->gamma4; attrs.gamma5 = adaptor_priv->gamma5; - ret = drmCommandWriteRead(intel->drmSubFD, DRM_I915_OVERLAY_ATTRS, - &attrs, sizeof(attrs)); + return drmCommandWriteRead(intel->drmSubFD, DRM_I915_OVERLAY_ATTRS, + &attrs, sizeof(attrs)) == 0; } static void intel_overlay_off(intel_screen_private *intel) @@ -244,6 +243,7 @@ static void intel_overlay_off(intel_screen_private *intel) ret = drmCommandWrite(intel->drmSubFD, DRM_I915_OVERLAY_PUT_IMAGE, &request, sizeof(request)); + (void) ret; } static Bool @@ -713,7 +713,8 @@ I830SetPortAttributeOverlay(ScrnInfoPtr scrn, OVERLAY_DEBUG("GAMMA\n"); } - intel_overlay_update_attrs(intel); + if (!intel_overlay_update_attrs(intel)) + return BadValue; if (attribute == xvColorKey) REGION_EMPTY(scrn->pScreen, &adaptor_priv->clip); commit e5e27528ffeb74f404823c678e04e847cf2109aa Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 14 11:51:44 2011 +0100 sna/blt: Add a pair of operator reductions for opaque fills Extend the coverage of the BLT for a couple more composite operations, though they be relatively infrequent. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 1375a7a..9d84747 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -580,6 +580,20 @@ pixel_is_opaque(uint32_t pixel, uint32_t format) } static Bool +pixel_is_white(uint32_t pixel, uint32_t format) +{ + switch (PICT_FORMAT_TYPE(format)) { + case PICT_TYPE_A: + case PICT_TYPE_ARGB: + case PICT_TYPE_ABGR: + case PICT_TYPE_BGRA: + return pixel == ((1 << PICT_FORMAT_BPP(format)) - 1); + default: + return FALSE; + } +} + +static Bool is_opaque_solid(PicturePtr picture) { if (picture->pSourcePict) { @@ -589,6 +603,16 @@ is_opaque_solid(PicturePtr picture) return pixel_is_opaque(get_pixel(picture), picture->format); } +static Bool +is_white(PicturePtr picture) +{ + if (picture->pSourcePict) { + PictSolidFill *fill = (PictSolidFill *) picture->pSourcePict; + return fill->color == 0xffffffff; + } else + return pixel_is_white(get_pixel(picture), picture->format); +} + fastcall static void blt_fill_composite(struct sna *sna, const struct sna_composite_op *op, @@ -1096,6 +1120,10 @@ sna_blt_composite(struct sna *sna, if (is_solid(src)) { if (op == PictOpOver && is_opaque_solid(src)) op = PictOpSrc; + if (op == PictOpAdd && is_white(src)) + op = PictOpSrc; + if (op == PictOpOutReverse && is_opaque_solid(src)) + return prepare_blt_clear(sna, tmp); if (op != PictOpSrc) { DBG(("%s: unsuported op [%d] for blitting\n", commit 3f5289b29962c3e5d94deb30782a156292d20053 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 14 11:31:46 2011 +0100 sna/trapezoids: Fallback if the composite operation is not supported Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index b0331cb..1549ef5 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -2641,7 +2641,7 @@ mono_trapezoids_span_converter(CARD8 op, PicturePtr src, PicturePtr dst, } memset(&mono.op, 0, sizeof(mono.op)); - if (mono.sna->render.composite(mono.sna, op, src, NULL, dst, + if (!mono.sna->render.composite(mono.sna, op, src, NULL, dst, src_x + mono.clip.extents.x1 - dst_x - dx, src_y + mono.clip.extents.y1 - dst_y - dy, 0, 0, @@ -2649,9 +2649,11 @@ mono_trapezoids_span_converter(CARD8 op, PicturePtr src, PicturePtr dst, mono.clip.extents.x2 - mono.clip.extents.x1, mono.clip.extents.y2 - mono.clip.extents.y1, &mono.op)) { - mono_render(&mono); - mono.op.done(mono.sna, &mono.op); + mono_fini(&mono); + return false; } + mono_render(&mono); + mono.op.done(mono.sna, &mono.op); mono_fini(&mono); if (!operator_is_bounded(op)) { commit 3d79264ef8a8be225d9b13efd14f37a7478e6b1b Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 14 11:31:00 2011 +0100 sna/tiling: Hook up composite_box Now used for spans and so triggering death by NULL function pointer on older chipsets. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_tiling.c b/src/sna/sna_tiling.c index 80989d8..295936b 100644 --- a/src/sna/sna_tiling.c +++ b/src/sna/sna_tiling.c @@ -95,6 +95,24 @@ sna_tiling_composite_blt(struct sna *sna, (void)sna; } +fastcall static void +sna_tiling_composite_box(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + struct sna_composite_rectangles r; + + r.dst.x = box->x1; + r.dst.y = box->y1; + r.mask = r.src = r.dst; + + r.width = box->x2 - box->x1; + r.height = box->y2 - box->y1; + + sna_tiling_composite_add_rect(op->u.priv, &r); + (void)sna; +} + static void sna_tiling_composite_boxes(struct sna *sna, const struct sna_composite_op *op, @@ -258,6 +276,7 @@ sna_tiling_composite(uint32_t op, tile->rect_size = ARRAY_SIZE(tile->rects_embedded); tmp->blt = sna_tiling_composite_blt; + tmp->box = sna_tiling_composite_box; tmp->boxes = sna_tiling_composite_boxes; tmp->done = sna_tiling_composite_done; commit f5f3135e3cc1f4740508773cfefca0954aed2fd3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 14 10:40:39 2011 +0100 sna: Ensure that the scanout is flushed before we sleep So that we do not see any delayed rendering on i965+. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 1073757..963ff9b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3793,7 +3793,7 @@ static Bool sna_accel_do_expire(struct sna *sna) { return sna->kgem.need_expire; static void _sna_accel_disarm_timer(struct sna *sna, int id) { } #endif -static void sna_accel_flush(struct sna *sna) +static bool sna_accel_flush(struct sna *sna) { struct sna_pixmap *priv = sna_accel_scanout(sna); bool nothing_to_do = @@ -3802,13 +3802,12 @@ static void sna_accel_flush(struct sna *sna) DBG(("%s (time=%ld), nothing_to_do=%d\n", __FUNCTION__, (long)GetTimeInMillis(), nothing_to_do)); - if (nothing_to_do) { + if (nothing_to_do) _sna_accel_disarm_timer(sna, FLUSH_TIMER); - return; - } - - sna_pixmap_move_to_gpu(priv->pixmap); + else + sna_pixmap_move_to_gpu(priv->pixmap); kgem_bo_flush(&sna->kgem, priv->gpu_bo); + return !nothing_to_do; } static void sna_accel_expire(struct sna *sna) @@ -3955,8 +3954,8 @@ static void sna_accel_throttle(struct sna *sna) void sna_accel_block_handler(struct sna *sna) { if (sna_accel_do_flush(sna)) { - sna_accel_flush(sna); - sna_accel_throttle(sna); + if (sna_accel_flush(sna)) + sna_accel_throttle(sna); } if (sna_accel_do_expire(sna)) From jeremyhu at kemper.freedesktop.org Fri Oct 14 16:40:20 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 14 Oct 2011 16:40:20 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' Message-ID: <20111014234020.9045ED8002@kemper.freedesktop.org> configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 374be44d13bc8f04a2413b6d5b2006e73d5a8f53 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 14 16:29:54 2011 -0700 configure.ac: Bump to 1.11.1.901 (1.11.2 RC1) Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/configure.ac b/configure.ac index 51d01e4..cc4292b 100644 --- a/configure.ac +++ b/configure.ac @@ -26,8 +26,8 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([xorg-server], 1.11.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) -RELEASE_DATE="2011-09-24" +AC_INIT([xorg-server], 1.11.1.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +RELEASE_DATE="2011-10-14" AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE From jeremyhu at kemper.freedesktop.org Fri Oct 14 16:41:05 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 14 Oct 2011 16:41:05 -0700 (PDT) Subject: xserver: Changes to 'refs/tags/xorg-server-1.11.1.901' Message-ID: <20111014234105.120EAD8002@kemper.freedesktop.org> Tag 'xorg-server-1.11.1.901' created by Jeremy Huddleston <jeremyhu at apple.com> at 2011-10-15 00:40 -0700 xorg-server-1.11.1.901 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iD8DBQBOmMhqjC1Anjf1NmMRAuX8AJ9k5a+9t/nx+3gt9hX+QzXcep/fkQCfZXYt ULiKSmplshruorBAaq1leKY= =VFQl -----END PGP SIGNATURE----- Changes since xorg-server-1.11.1: Alan Hourihane (1): dixfonts: Don't overwrite local c variable until new_closure is safely initialized. Carlos Garnacho (1): Xi: Fix passive XI2 ungrabs on XIAll[Master]Devices Jamey Sharp (1): Fix pixmap double-frees on error paths. Jeremy Huddleston (3): XQuartz: Use set_front_process rather than X11ApplicationSetFrontProcess since we're already in the AppKit thread XQuartz: pbproxy: Add missing AM_OBJCFLAGS configure.ac: Bump to 1.11.1.901 (1.11.2 RC1) Kirill Elagin (1): Fix server crash due to invalid images Nobuhiro Iwamatsu (1): Disable check of double-aligned in test/input.c on Renesas SH Peter Harris (1): xkb: add missing swaps for xkbGetDeviceInfoReply Peter Hutterer (5): config: fix a log message dix: avoid using the VCP as modifier device dix: ignore devices when adding passive core grabs to list (#39545) dix: don't use the pointer as modifier device in UngrabKey. dix: don't XWarpPointer through the last slave anymore (#38313) Sam Spilsbury (1): Remove the SendEvent bit (0x80) before doing range checks on event type. vdb at picaros.org (1): Fix a rare memory leak --- Xext/shm.c | 6 +----- Xi/xipassivegrab.c | 13 ++++++++++--- config/udev.c | 2 +- configure.ac | 4 ++-- dix/dispatch.c | 1 - dix/dixfonts.c | 30 +++++++++++++++--------------- dix/events.c | 39 +++++++++++++++++++++++++++++---------- dix/grabs.c | 2 +- fb/fbpict.c | 4 +++- hw/xfree86/modes/xf86Crtc.c | 1 + hw/xquartz/X11Application.m | 2 +- hw/xquartz/pbproxy/Makefile.am | 1 + test/input.c | 2 +- xkb/xkb.c | 3 +++ 14 files changed, 69 insertions(+), 41 deletions(-) --- From jeremyhu at kemper.freedesktop.org Fri Oct 14 17:19:43 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 14 Oct 2011 17:19:43 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111015001943.29C76D8002@kemper.freedesktop.org> modules/im/ximcp/imDefFlt.c | 16 ++++++---------- modules/im/ximcp/imDefIc.c | 4 ---- modules/im/ximcp/imDefLkup.c | 12 ++++-------- modules/im/ximcp/imExten.c | 2 +- src/xlibi18n/XimintP.h | 40 ++++++++++++++++------------------------ 5 files changed, 27 insertions(+), 47 deletions(-) New commits: commit 738f7b867341c1da87ee667d48815822715c3e75 Author: Choe Hwanjin <choe.hwanjin at gmail.com> Date: Thu Oct 13 07:58:02 2011 +0900 XIM: Make Xim handle NEED_SYNC_REPLY flag NEED_SYNC_REPLY flag should be in Xim not in Xic. Because the focused Xic can be changed before sending sync reply. After focused Xic changed, the new Xic doesn't have NEED_SYNC_REPLY flag enabled, so libX11 doesn't send XIM_SYNC_REPLY packet. This patch adds sync reply flag to Xim and removes sync reply from Xic. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=7869 Signed-off-by: Choe Hwanjin <choe.hwanjin at gmail.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Fri Oct 14 17:21:08 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 14 Oct 2011 17:21:08 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111015002108.1613CD8002@kemper.freedesktop.org> nls/en_US.UTF-8/Compose.pre | 13 +++++++++++++ 1 file changed, 13 insertions(+) New commits: commit 9b8d8c9e5b27273e8856a3851ba9b68022bed3cd Author: Marko Myllynen <myllynen at redhat.com> Date: Mon Oct 10 09:41:13 2011 +0300 Add new compose sequences This patch adds few new compose sequences to the en_US map, ligatures common in typesetting and sequences already in use in the fi_FI map. https://bugs.freedesktop.org/show_bug.cgi?id=30621 https://bugs.freedesktop.org/show_bug.cgi?id=34523 Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From alanc at kemper.freedesktop.org Fri Oct 14 17:35:10 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 14 Oct 2011 17:35:10 -0700 (PDT) Subject: libpciaccess: Changes to 'master' Message-ID: <20111015003510.AEF0BD8002@kemper.freedesktop.org> src/solx_devfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) New commits: commit 803bf3aa28de0f1260e479e2036159d4fead0a87 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Tue Oct 4 21:46:05 2011 -0700 Solaris: Give better error on realloc failure commit a18460b385ae03 converted from a fixed maximum number of devices to dynamically growing the list via realloc, but didn't update the error message shown on failure. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Dirk Wallenstein <halsmit at t-online.de> Reviewed-by: Mark Kettenis <kettenis at openbsd.org> From alanc at kemper.freedesktop.org Fri Oct 14 22:30:41 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 14 Oct 2011 22:30:41 -0700 (PDT) Subject: bitmap: Changes to 'master' Message-ID: <20111015053041.7FB33D8002@kemper.freedesktop.org> BitEdit.c | 234 ++++++++--------- Bitmap.c | 610 ++++++++++++++++++++++----------------------- Bitmap.h | 18 - BitmapP.h | 16 - CutPaste.c | 40 +- Dialog.c | 52 +-- Graphics.c | 468 +++++++++++++++++----------------- Handlers.c | 302 +++++++++++----------- Makefile.am | 6 ReqMach.c | 68 ++--- Requests.h | 10 app-defaults/Bitmap | 6 app-defaults/Bitmap-nocase | 6 atobm.c | 24 - bmtoa.c | 14 - configure.ac | 4 16 files changed, 940 insertions(+), 938 deletions(-) New commits: commit a8ee8e937e8d939522f18fa5723afea084221467 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 21:25:06 2011 -0700 Strip trailing whitespace Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 64eacd3665306283d126d0df7cf63a071e576c38 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 21:22:26 2011 -0700 Constify filename string handling Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit ca7bf97b6e83b25e7142b321e5f2325b1e47c2d0 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 21:03:48 2011 -0700 Add const to char * in BWRequest typedef Fixes many gcc --Wwrite-string warnings of the form: Bitmap.c: In function ???BWTPaste???: Bitmap.c:1913:7: warning: passing argument 2 of ???BWEngageRequest??? discards qualifiers from pointer target type Bitmap.h:190:16: note: expected ???BWRequest??? but argument is of type ???const char *??? Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Fri Oct 14 22:42:18 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 14 Oct 2011 22:42:18 -0700 (PDT) Subject: bitmap: Changes to 'master' Message-ID: <20111015054219.2084BD8002@kemper.freedesktop.org> bmtoa.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) New commits: commit 3fc1a649f1e81c4d93c6e00119267208877a8f02 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 22:38:44 2011 -0700 Constify strings in bmtoa Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Fri Oct 14 22:50:23 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 14 Oct 2011 22:50:23 -0700 (PDT) Subject: bitmap: Changes to 'master' Message-ID: <20111015055023.9F873D8002@kemper.freedesktop.org> atobm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) New commits: commit 1c2b70d13c42f5461a2d7c3cae7adf8d9b2e3cea Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 22:48:31 2011 -0700 Constify strings in atobm Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Fri Oct 14 22:59:08 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 14 Oct 2011 22:59:08 -0700 (PDT) Subject: oclock: Changes to 'master' Message-ID: <20111015055908.4740FD8002@kemper.freedesktop.org> Clock.c | 31 +++++++++++++++---------------- Clock.h | 2 -- ClockP.h | 4 +--- Makefile.am | 6 +++--- app-defaults/Clock-color | 1 - configure.ac | 4 ++-- man/oclock.man | 2 -- oclock.c | 19 +++++++++---------- transform.c | 6 ++---- transform.h | 14 ++++++-------- 10 files changed, 38 insertions(+), 51 deletions(-) New commits: commit 18873da4921369f687023522bc0f07e8e51c8f05 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 22:57:06 2011 -0700 Strip CVS/RCS id tags Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 9e9ba1248f9fa8a43bb98be9bea024aaaa4f0d64 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 22:53:52 2011 -0700 Strip trailing whitespace Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From ickle at kemper.freedesktop.org Sun Oct 16 11:40:38 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 16 Oct 2011 11:40:38 -0700 (PDT) Subject: xf86-video-intel: src/sna/gen7_render.c Message-ID: <20111016184038.2C216C0001@kemper.freedesktop.org> src/sna/gen7_render.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit b89592b16e373da1fe259ad067f65ba95021dc49 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 19:39:14 2011 +0100 sna/gen7: Add missing tail to 3DSTATE_SBE I was a few NULs short of the declared amount. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 30de36f..16c1462 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -793,8 +793,11 @@ gen7_emit_sf(struct sna *sna, Bool has_mask) OUT_BATCH(0); OUT_BATCH(0); OUT_BATCH(0); + OUT_BATCH(0); /* dw8 */ OUT_BATCH(0); - OUT_BATCH(0); /* DW9 */ + OUT_BATCH(0); + OUT_BATCH(0); + OUT_BATCH(0); /* dw12 */ OUT_BATCH(0); OUT_BATCH(0); } From jeremyhu at kemper.freedesktop.org Sun Oct 16 15:18:27 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 16 Oct 2011 15:18:27 -0700 (PDT) Subject: xf86-video-cyrix: Changes to 'master' Message-ID: <20111016221827.46963C0001@kemper.freedesktop.org> src/cyrix.h | 2 +- src/cyrix_driver.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) New commits: commit 4cf15cbff44217d0ef50fc9b2b1ace936becd010 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 16 15:12:54 2011 -0700 Fix a couple of compilation errors. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 3a26fe8fcef9ce36036de58570ab0b0f268ae596 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 16 15:10:57 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 17 01:42:05 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 17 Oct 2011 01:42:05 -0700 (PDT) Subject: xf86-video-cirrus: Changes to 'master' Message-ID: <20111017084205.C4FB9C0001@kemper.freedesktop.org> src/alp_driver.c | 12 ++++++------ src/cir_dga.c | 4 ++-- src/cir_driver.c | 4 ++-- src/lg_driver.c | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) New commits: commit 80f60e4af0e0b124335c5a09cad0b1eb42583536 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 17 01:42:00 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 3e5ebc4c1b9c2f751e50415b0d1bbb670c659eac Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 17 01:40:17 2011 -0700 GD5436 timings are the same as GD5446 Based on information from http://www.xfree86.org/3.3.6/cirrus1.html See: https://bugs.freedesktop.org/show_bug.cgi?id=4169 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 17 03:54:55 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 17 Oct 2011 03:54:55 -0700 (PDT) Subject: xinit: Changes to 'master' Message-ID: <20111017105455.CD8F9C0001@kemper.freedesktop.org> startx.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) New commits: commit 27be391123f5143fdccdfe975bf18bbff7517537 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 17 03:53:17 2011 -0700 startx: Choose an unused $DISPLAY by default on all platforms Now everyone can benefit from this code that I previously added for darwin https://bugs.freedesktop.org/show_bug.cgi?id=1789 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From ickle at kemper.freedesktop.org Mon Oct 17 05:20:06 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 17 Oct 2011 05:20:06 -0700 (PDT) Subject: xf86-video-intel: 12 commits - configure.ac src/intel_uxa.c src/sna/gen2_render.c src/sna/gen3_render.c src/sna/kgem.c src/sna/kgem_debug.c src/sna/kgem_debug_gen3.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna.h src/sna/sna_render.h Message-ID: <20111017122006.43AB3C0001@kemper.freedesktop.org> configure.ac | 4 src/intel_uxa.c | 25 +- src/sna/gen2_render.c | 575 +++++++++++++++++++++++----------------------- src/sna/gen3_render.c | 69 +++-- src/sna/kgem.c | 19 - src/sna/kgem.h | 13 - src/sna/kgem_debug.c | 6 src/sna/kgem_debug_gen3.c | 1 src/sna/sna.h | 1 src/sna/sna_accel.c | 167 ++++++++++++- src/sna/sna_render.h | 8 11 files changed, 525 insertions(+), 363 deletions(-) New commits: commit 46f97127c22ea42bc8fdae59d2a133e4b8b6c997 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 21:40:15 2011 +0100 snb,ivb: Workaround unknown blitter death The first workaround was a performance killing MI_FLUSH_DW after every op. This workaround appears to be a stable compromise instead, only requiring a redundant command after every BLT command with little impact on throughput. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=27892 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=39524 Tested-by: Daniel Vetter <daniel.vetter at ffwll.ch> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/intel_uxa.c b/src/intel_uxa.c index 30717d0..9e58c69 100644 --- a/src/intel_uxa.c +++ b/src/intel_uxa.c @@ -340,13 +340,6 @@ static void intel_uxa_solid(PixmapPtr pixmap, int x1, int y1, int x2, int y2) } } -static void intel_uxa_done_solid(PixmapPtr pixmap) -{ - ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum]; - - intel_debug_flush(scrn); -} - /** * TODO: * - support planemask using FULL_BLT_CMD? @@ -501,9 +494,19 @@ intel_uxa_copy(PixmapPtr dest, int src_x1, int src_y1, int dst_x1, } } -static void intel_uxa_done_copy(PixmapPtr dest) +static void intel_uxa_done(PixmapPtr pixmap) { - ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum]; + ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum]; + intel_screen_private *intel = intel_get_screen_private(scrn); + + if (IS_GEN6(intel) || IS_GEN7(intel)) { + /* workaround a random BLT hang */ + BEGIN_BATCH_BLT(3); + OUT_BATCH(XY_SETUP_CLIP_BLT_CMD); + OUT_BATCH(0); + OUT_BATCH(0); + ADVANCE_BATCH(); + } intel_debug_flush(scrn); } @@ -1225,13 +1228,13 @@ Bool intel_uxa_init(ScreenPtr screen) intel->uxa_driver->check_solid = intel_uxa_check_solid; intel->uxa_driver->prepare_solid = intel_uxa_prepare_solid; intel->uxa_driver->solid = intel_uxa_solid; - intel->uxa_driver->done_solid = intel_uxa_done_solid; + intel->uxa_driver->done_solid = intel_uxa_done; /* Copy */ intel->uxa_driver->check_copy = intel_uxa_check_copy; intel->uxa_driver->prepare_copy = intel_uxa_prepare_copy; intel->uxa_driver->copy = intel_uxa_copy; - intel->uxa_driver->done_copy = intel_uxa_done_copy; + intel->uxa_driver->done_copy = intel_uxa_done; /* Composite */ if (IS_GEN2(intel)) { commit 71bf291e563ec5224777b4907a5347a3fbfe64c5 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 12:53:19 2011 +0100 sna/gen3: Micro-optimise gen3_rectangle_begin() We only need to emit the vbo description either at the beginning of a new op (when the state may have changed) or after finishing a full vbo. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 50883a5..0a51e64 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -1457,21 +1457,16 @@ static void gen3_vertex_finish(struct sna *sna, Bool last) static bool gen3_rectangle_begin(struct sna *sna, const struct sna_composite_op *op) { - int ndwords, i1_cmd = 0, i1_len = 0; struct gen3_render_state *state = &sna->render_state.gen3; + int ndwords, i1_cmd = 0, i1_len = 0; - ndwords = 0; - if (state->vertex_offset == 0) { - ndwords += 2; - if (op->need_magic_ca_pass) - ndwords += 100; - } + ndwords = 2; + if (op->need_magic_ca_pass) + ndwords += 100; if (sna->render.vertex_reloc[0] == 0) i1_len++, i1_cmd |= I1_LOAD_S(0), ndwords++; if (state->floats_per_vertex != op->floats_per_vertex) i1_len++, i1_cmd |= I1_LOAD_S(1), ndwords++; - if (ndwords == 0) - return true; if (!kgem_check_batch(&sna->kgem, ndwords+1)) return false; @@ -1487,16 +1482,14 @@ static bool gen3_rectangle_begin(struct sna *sna, } } - if (state->vertex_offset == 0) { - if (sna->kgem.nbatch == 2 + state->last_vertex_offset) { - state->vertex_offset = state->last_vertex_offset; - } else { - state->vertex_offset = sna->kgem.nbatch; - OUT_BATCH(MI_NOOP); /* to be filled later */ - OUT_BATCH(MI_NOOP); - sna->render.vertex_start = sna->render.vertex_index; - state->last_vertex_offset = state->vertex_offset; - } + if (sna->kgem.nbatch == 2 + state->last_vertex_offset) { + state->vertex_offset = state->last_vertex_offset; + } else { + state->vertex_offset = sna->kgem.nbatch; + OUT_BATCH(MI_NOOP); /* to be filled later */ + OUT_BATCH(MI_NOOP); + sna->render.vertex_start = sna->render.vertex_index; + state->last_vertex_offset = state->vertex_offset; } return true; @@ -1535,7 +1528,8 @@ inline static int gen3_get_rectangles(struct sna *sna, return 0; } - if (!gen3_rectangle_begin(sna, op)) { + if (sna->render_state.gen3.vertex_offset == 0 && + !gen3_rectangle_begin(sna, op)) { DBG(("%s: flushing batch\n", __FUNCTION__)); return 0; } commit a032feb2531439b9945d7ae1e0c2e3ab95a960e1 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 12:41:21 2011 +0100 sna/gen3: Store floats_per_rect alongside floats_per_vertex Moves a multiply out of the hot path. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 4e24e03..50883a5 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -1524,12 +1524,12 @@ inline static int gen3_get_rectangles(struct sna *sna, int rem = vertex_space(sna); DBG(("%s: want=%d, rem=%d\n", - __FUNCTION__, 3*want*op->floats_per_vertex, rem)); + __FUNCTION__, want*op->floats_per_rect, rem)); assert(sna->render.vertex_index * op->floats_per_vertex == sna->render.vertex_used); - if (op->floats_per_vertex*3 > rem) { + if (op->floats_per_rect > rem) { DBG(("flushing vbo for %s: %d < %d\n", - __FUNCTION__, rem, 3*op->floats_per_vertex)); + __FUNCTION__, rem, op->floats_per_rect)); rem = gen3_get_rectangles__flush(sna, op->need_magic_ca_pass); if (rem == 0) return 0; @@ -1540,8 +1540,8 @@ inline static int gen3_get_rectangles(struct sna *sna, return 0; } - if (want > 1 && want * op->floats_per_vertex*3 > rem) - want = rem / (3*op->floats_per_vertex); + if (want > 1 && want * op->floats_per_rect > rem) + want = rem / op->floats_per_rect; sna->render.vertex_index += 3*want; assert(want); @@ -2383,6 +2383,7 @@ gen3_render_composite(struct sna *sna, tmp->mask.u.gen3.type != SHADER_CONSTANT) ? tmp->mask.is_affine ? 2 : 4 : 0, tmp->floats_per_vertex)); + tmp->floats_per_rect = 3 * tmp->floats_per_vertex; tmp->blt = gen3_render_composite_blt; tmp->box = gen3_render_composite_box; @@ -2824,6 +2825,7 @@ gen3_render_composite_spans(struct sna *sna, tmp->base.floats_per_vertex += tmp->base.src.is_affine ? 2 : 3; tmp->base.floats_per_vertex += tmp->base.mask.u.gen3.type == SHADER_OPACITY; + tmp->base.floats_per_rect = 3 * tmp->base.floats_per_vertex; tmp->box = gen3_render_composite_spans_box; tmp->boxes = gen3_render_composite_spans_boxes; @@ -3387,6 +3389,7 @@ gen3_render_copy_boxes(struct sna *sna, uint8_t alu, gen3_render_copy_setup_source(&tmp.src, src, src_bo); tmp.floats_per_vertex = 4; + tmp.floats_per_rect = 12; tmp.mask.u.gen3.type = SHADER_NONE; gen3_emit_composite_state(sna, &tmp); @@ -3515,6 +3518,7 @@ gen3_render_copy(struct sna *sna, uint8_t alu, gen3_render_copy_setup_source(&tmp->base.src, src, src_bo); tmp->base.floats_per_vertex = 4; + tmp->base.floats_per_rect = 12; tmp->base.mask.u.gen3.type = SHADER_NONE; if (!kgem_check_bo(&sna->kgem, dst_bo, src_bo, NULL)) @@ -3639,6 +3643,7 @@ gen3_render_fill_boxes(struct sna *sna, tmp.dst.format = format; tmp.dst.bo = dst_bo; tmp.floats_per_vertex = 2; + tmp.floats_per_rect = 6; tmp.src.u.gen3.type = op == PictOpClear ? SHADER_ZERO : SHADER_CONSTANT; tmp.src.u.gen3.mode = pixel; @@ -3740,6 +3745,7 @@ gen3_render_fill(struct sna *sna, uint8_t alu, tmp->base.dst.format = sna_format_for_depth(dst->drawable.depth); tmp->base.dst.bo = dst_bo; tmp->base.floats_per_vertex = 2; + tmp->base.floats_per_rect = 6; tmp->base.src.u.gen3.type = SHADER_CONSTANT; tmp->base.src.u.gen3.mode = @@ -3813,6 +3819,7 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, tmp.dst.format = sna_format_for_depth(dst->drawable.depth); tmp.dst.bo = bo; tmp.floats_per_vertex = 2; + tmp.floats_per_rect = 6; tmp.src.u.gen3.type = SHADER_CONSTANT; tmp.src.u.gen3.mode = diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index f0a99a7..1cbd0f5 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -72,7 +72,8 @@ struct sna_composite_op { uint32_t need_magic_ca_pass : 1; uint32_t rb_reversed : 1; - int floats_per_vertex; + int16_t floats_per_vertex; + int16_t floats_per_rect; fastcall void (*prim_emit)(struct sna *sna, const struct sna_composite_op *op, const struct sna_composite_rectangles *r); commit 2cbe79b85b46796d561105afa980e7a52f4f1889 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 11:57:07 2011 +0100 sna/gen3: Improve reduction of render operator to blt Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 1d4df78..4e24e03 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3541,6 +3541,9 @@ gen3_render_fill_boxes_try_blt(struct sna *sna, uint8_t alu = GXcopy; uint32_t pixel; + if (dst_bo->tiling == I915_TILING_Y) + return FALSE; + if (!sna_get_pixel_from_rgba(&pixel, color->red, color->green, @@ -3549,17 +3552,22 @@ gen3_render_fill_boxes_try_blt(struct sna *sna, format)) return FALSE; + if (color->alpha >= 0xff00) { + if (op == PictOpOver) + op = PictOpSrc; + else if (op == PictOpOutReverse) + op = PictOpClear; + else if (op == PictOpAdd && + (color->red & color->green & color->blue) >= 0xff00) + op = PictOpSrc; + } + if (op == PictOpClear) { alu = GXclear; pixel = 0; op = PictOpSrc; } - if (op == PictOpOver) { - if ((pixel & 0xff000000) == 0xff000000) - op = PictOpSrc; - } - if (op != PictOpSrc) return FALSE; commit 606e18bd360d904a8aed01aef43644fb4a51d929 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 10:50:33 2011 +0100 configure: Add a check for pixman version As SNA requires a fairly recent release and calls directly into pixman. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/configure.ac b/configure.ac index e269006..0a60bd7 100644 --- a/configure.ac +++ b/configure.ac @@ -129,8 +129,10 @@ AM_CONDITIONAL(SNA, test x$SNA != xno) AC_MSG_CHECKING([whether to include SNA support]) required_xorg_xserver_version=1.6 +required_pixman_version=0.16 if test "x$SNA" != "xno"; then required_xorg_xserver_version=1.10 + required_pixman_version=0.23 AC_DEFINE(USE_SNA, 1, [Enable SNA support]) fi AC_MSG_RESULT([$SNA]) @@ -160,7 +162,7 @@ XORG_DRIVER_CHECK_EXT(XF86DRI, xextproto x11) XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto) # Obtain compiler/linker options for the driver dependencies -PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_xserver_version xproto fontsproto $REQUIRED_MODULES]) +PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_xserver_version xproto fontsproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES]) PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.23]) PKG_CHECK_MODULES(DRI, [xf86driproto], , DRI=no) PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6]) commit 17acaf8e232a8bad9bc2c653a9fceb06f0f65f6b Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 00:55:51 2011 +0100 sna: Defer CPU fallback if fb calls into mi If the fb routine does not access the pixel data directly, but instead calls into an mi routine, we can defer the readback and possibly avoid it. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 51d51f3..49bd604 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2365,6 +2365,14 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, } fallback: + if (gc->lineWidth) { + if (gc->lineStyle != LineSolid) + miWideDash(drawable, gc, mode, n, pt); + else + miWideLine(drawable, gc, mode, n, pt); + return; + } + DBG(("%s: fallback\n", __FUNCTION__)); region_set(®ion, &extents); region_maybe_clip(®ion, gc->pCompositeClip); @@ -2670,6 +2678,11 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) } fallback: + if (gc->lineWidth) { + miPolySegment(drawable, gc, n, seg); + return; + } + DBG(("%s: fallback\n", __FUNCTION__)); region_set(®ion, &extents); region_maybe_clip(®ion, gc->pCompositeClip); @@ -2774,6 +2787,11 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) } fallback: + if (gc->lineWidth) { + miPolyArc(drawable, gc, n, arc); + return; + } + region_set(®ion, &extents); region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) @@ -2783,6 +2801,7 @@ fallback: sna_drawable_move_region_to_cpu(drawable, ®ion, true); RegionUninit(®ion); + /* XXX may still fallthrough to miZeroPolyArc */ fbPolyArc(drawable, gc, n, arc); } commit c348b69f66cbe1cafc88396523da9768e1006889 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 18:23:33 2011 +0100 sna: Prefer to accelerate non-RENDER operations if already using the GPU Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna.h b/src/sna/sna.h index e27c333..4ba3f57 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -140,6 +140,7 @@ struct sna_pixmap { uint8_t pinned :1; uint8_t gpu_only :1; uint8_t flush :1; + uint8_t gpu :1; }; static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 3d0d1cf..51d51f3 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -410,6 +410,8 @@ done: if (priv->flush) list_move(&priv->list, &sna->dirty_pixmaps); } + + priv->gpu = false; } static Bool @@ -569,6 +571,72 @@ done: if (dx | dy) RegionTranslate(region, -dx, -dy); + + priv->gpu = false; +} + +static void +sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box) +{ + struct sna *sna = to_sna_from_drawable(&pixmap->drawable); + struct sna_pixmap *priv = sna_pixmap(pixmap); + RegionRec i, r; + + DBG(("%s()\n", __FUNCTION__)); + + assert(priv->gpu); + assert(priv->gpu_bo); + + sna_damage_reduce(&priv->cpu_damage); + DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL)); + + if (priv->cpu_damage == NULL) + goto done; + + region_set(&r, box); + if (sna_damage_intersect(priv->cpu_damage, &r, &i)) { + BoxPtr box = REGION_RECTS(&i); + int n = REGION_NUM_RECTS(&i); + struct kgem_bo *src_bo; + Bool ok = FALSE; + + src_bo = pixmap_vmap(&sna->kgem, pixmap); + if (src_bo) + ok = sna->render.copy_boxes(sna, GXcopy, + pixmap, src_bo, 0, 0, + pixmap, priv->gpu_bo, 0, 0, + box, n); + if (!ok) { + if (n == 1 && !priv->pinned && + box->x1 <= 0 && box->y1 <= 0 && + box->x2 >= pixmap->drawable.width && + box->y2 >= pixmap->drawable.height) { + priv->gpu_bo = + sna_replace(sna, + priv->gpu_bo, + pixmap->drawable.width, + pixmap->drawable.height, + pixmap->drawable.bitsPerPixel, + pixmap->devPrivate.ptr, + pixmap->devKind); + } else { + sna_write_boxes(sna, + priv->gpu_bo, 0, 0, + pixmap->devPrivate.ptr, + pixmap->devKind, + pixmap->drawable.bitsPerPixel, + 0, 0, + box, n); + } + } + + sna_damage_subtract(&priv->cpu_damage, &r); + RegionUninit(&i); + } + +done: + if (priv->cpu_damage == NULL) + list_del(&priv->list); } static inline Bool @@ -596,8 +664,19 @@ _sna_drawable_use_gpu_bo(DrawablePtr drawable, const BoxRec *box) extents.y1 += dy; extents.y2 += dy; - return sna_damage_contains_box(priv->cpu_damage, - &extents) == PIXMAN_REGION_OUT; + if (sna_damage_contains_box(priv->cpu_damage, + &extents) == PIXMAN_REGION_OUT) + return TRUE; + + if (!priv->gpu || priv->gpu_damage == NULL) + return FALSE; + + if (sna_damage_contains_box(priv->gpu_damage, + &extents) == PIXMAN_REGION_OUT) + return FALSE; + + sna_pixmap_move_area_to_gpu(pixmap, &extents); + return TRUE; } static inline Bool @@ -822,6 +901,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap) sna_damage_reduce(&priv->gpu_damage); done: list_del(&priv->list); + priv->gpu = true; return priv; } commit 6fdc9e3fd3f8defb7ad62de11f8cb069a10e5736 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 17:57:55 2011 +0100 sna: Simplify busy tracking by trusting the bo->gpu flag Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 15ddd7a..d27ba78 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -190,9 +190,8 @@ Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo, return FALSE; bo->needs_flush = false; - if (bo->rq) + if (bo->gpu) kgem_retire(kgem); - bo->gpu = false; return TRUE; } @@ -510,6 +509,7 @@ void _kgem_add_bo(struct kgem *kgem, struct kgem_bo *bo) { bo->exec = kgem_add_handle(kgem, bo); bo->rq = kgem->next_request; + bo->gpu = true; list_move(&bo->request, &kgem->next_request->buffers); kgem->flush |= bo->flush; } @@ -665,7 +665,6 @@ static void kgem_commit(struct kgem *kgem) bo->presumed_offset = bo->exec->offset; bo->exec = NULL; bo->dirty = false; - bo->gpu = true; bo->cpu_read = false; bo->cpu_write = false; @@ -841,7 +840,6 @@ void kgem_reset(struct kgem *kgem) bo->src_bound = bo->dst_bound = 0; bo->exec = NULL; bo->dirty = false; - bo->gpu = true; bo->cpu_read = false; bo->cpu_write = false; @@ -1713,11 +1711,8 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo, int prot) return NULL; bo->needs_flush = false; - if (prot & PROT_WRITE) { - if (bo->rq) - kgem_retire(kgem); - bo->gpu = false; - } + if (prot & PROT_WRITE && bo->gpu) + kgem_retire(kgem); return ptr; } @@ -1820,9 +1815,8 @@ void kgem_bo_sync(struct kgem *kgem, struct kgem_bo *bo, bool for_write) drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain); bo->needs_flush = false; - if (bo->rq) + if (bo->gpu) kgem_retire(kgem); - bo->gpu = false; bo->cpu_read = true; if (for_write) bo->cpu_write = true; @@ -2136,9 +2130,8 @@ void kgem_buffer_sync(struct kgem *kgem, struct kgem_bo *_bo) else gem_read(kgem->fd, bo->base.handle, bo+1, bo->used); bo->base.needs_flush = false; - if (bo->base.rq) + if (bo->base.gpu) kgem_retire(kgem); - bo->base.gpu = false; bo->need_io = 0; } diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 49ca3d7..aba8d3f 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -305,15 +305,12 @@ Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo, static inline bool kgem_bo_is_busy(struct kgem_bo *bo) { - DBG_HDR(("%s: exec? %d, gpu? %d, rq? %d\n", - __FUNCTION__, bo->exec != NULL, bo->gpu, bo->rq != NULL)); + DBG_HDR(("%s: gpu? %d exec? %d, rq? %d\n", + __FUNCTION__, bo->gpu, bo->exec != NULL, bo->rq != NULL)); - if (bo->exec) - return true; - if (!bo->gpu) - return false; - - return bo->rq != NULL; + assert(bo->proxy == NULL); + assert(bo->gpu || bo->rq == NULL); + return bo->gpu; } static inline bool kgem_bo_is_dirty(struct kgem_bo *bo) commit 30dff81cd62b5fc5a28d5175a08c5a3ee09667bd Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 17:41:34 2011 +0100 sna/accel: Upload source to GPU for !copy CopyAreas Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 67693b3..3d0d1cf 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1156,7 +1156,8 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth, } static bool -move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv, const BoxRec *box) +move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv, + const BoxRec *box, uint8_t alu) { int w = box->x2 - box->x1; int h = box->y2 - box->y1; @@ -1164,6 +1165,9 @@ move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv, const BoxRec *box) if (priv->gpu_bo) return TRUE; + if (alu != GXcopy) + return TRUE; + return ++priv->source_count * w*h >= 2 * pixmap->drawable.width * pixmap->drawable.height; } @@ -1259,7 +1263,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, } if (src_priv && - move_to_gpu(src_pixmap, src_priv, ®ion.extents) && + move_to_gpu(src_pixmap, src_priv, ®ion.extents, alu) && sna_pixmap_move_to_gpu(src_pixmap)) { if (!sna->render.copy_boxes(sna, alu, src_pixmap, src_priv->gpu_bo, src_dx, src_dy, commit eefa925e3d3e009b21ecc0b428d93a6c732bfa14 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 17:39:06 2011 +0100 sna/accel: Fall-forward for handling a non-copy CopyArea to a dst gpu bo Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem_debug.c b/src/sna/kgem_debug.c index 2cc7b3a..ad0a533 100644 --- a/src/sna/kgem_debug.c +++ b/src/sna/kgem_debug.c @@ -255,8 +255,9 @@ decode_2d(struct kgem *kgem, uint32_t offset) break; } - kgem_debug_print(data, offset, 1, "format %s, pitch %d, " + kgem_debug_print(data, offset, 1, "format %s, rop %x, pitch %d, " "clipping %sabled\n", format, + (data[1] >> 16) & 0xff, (short)(data[1] & 0xffff), data[1] & (1 << 30) ? "en" : "dis"); kgem_debug_print(data, offset, 2, "(%d,%d)\n", @@ -303,8 +304,9 @@ decode_2d(struct kgem *kgem, uint32_t offset) break; } - kgem_debug_print(data, offset, 1, "format %s, dst pitch %d, " + kgem_debug_print(data, offset, 1, "format %s, rop %x, dst pitch %d, " "clipping %sabled\n", format, + (data[1] >> 16) & 0xff, (short)(data[1] & 0xffff), data[1] & (1 << 30) ? "en" : "dis"); kgem_debug_print(data, offset, 2, "dst (%d,%d)\n", diff --git a/src/sna/kgem_debug_gen3.c b/src/sna/kgem_debug_gen3.c index 17ddb6b..d152b60 100644 --- a/src/sna/kgem_debug_gen3.c +++ b/src/sna/kgem_debug_gen3.c @@ -1156,7 +1156,6 @@ gen3_decode_3d_1d(struct kgem *kgem, uint32_t offset) if (data[1] & (1 << map)) { int width, height, pitch, dword; struct drm_i915_gem_relocation_entry *reloc; - struct kgem_bo *bo = NULL; const char *tiling; reloc = kgem_debug_get_reloc_entry(kgem, &data[i] - kgem->batch); diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 963ff9b..67693b3 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1285,13 +1285,63 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, ®ion); RegionTranslate(®ion, -dst_dx, -dst_dy); } - } else { - if (alu != GXcopy) { - DBG(("%s: fallback - not a copy and source is on the CPU\n", + } else if (alu != GXcopy) { + PixmapPtr tmp; + int i; + + assert (src_pixmap->drawable.depth != 1); + + DBG(("%s: creating temporary source upload for non-copy alu [%d]\n", + __FUNCTION__, alu)); + + tmp = sna_pixmap_create_upload(src->pScreen, + src->width, + src->height, + src->depth); + if (tmp == NullPixmap) + return; + + for (i = 0; i < n; i++) { + assert(box->x1 + src_dx >= 0); + assert(box->y1 + src_dy >= 0); + assert(box->x2 + src_dx <= src_pixmap->drawable.width); + assert(box->y2 + src_dy <= src_pixmap->drawable.height); + + assert(box->x1 + dx >= 0); + assert(box->y1 + dy >= 0); + assert(box->x2 + dx <= tmp->drawable.width); + assert(box->y2 + dy <= tmp->drawable.height); + + memcpy_blt(src_pixmap->devPrivate.ptr, + tmp->devPrivate.ptr, + src_pixmap->drawable.bitsPerPixel, + src_pixmap->devKind, + tmp->devKind, + box[i].x1 + src_dx, + box[i].y1 + src_dy, + box[i].x1 + dx, + box[i].y1 + dy, + box[i].x2 - box[i].x1, + box[i].y2 - box[i].y1); + } + + if (!sna->render.copy_boxes(sna, alu, + tmp, sna_pixmap_get_bo(tmp), dx, dy, + dst_pixmap, dst_priv->gpu_bo, dst_dx, dst_dy, + box, n)) { + DBG(("%s: fallback - accelerated copy boxes failed\n", __FUNCTION__)); + tmp->drawable.pScreen->DestroyPixmap(tmp); goto fallback; } + tmp->drawable.pScreen->DestroyPixmap(tmp); + RegionTranslate(®ion, dst_dx, dst_dy); + assert_pixmap_contains_box(dst_pixmap, + RegionExtents(®ion)); + sna_damage_add(&dst_priv->gpu_damage, ®ion); + RegionTranslate(®ion, -dst_dx, -dst_dy); + } else { if (src_priv) { RegionTranslate(®ion, src_dx, src_dy); sna_drawable_move_region_to_cpu(&src_pixmap->drawable, commit 01f41e624b31af88d433a25eaefce557e7ff3d62 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 17:38:26 2011 +0100 sna/gen2: Eliminate redundant diffuse and rectlist emission Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index f1f5e72..34c4432 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -652,8 +652,11 @@ static void gen2_emit_composite_state(struct sna *sna, texcoordfmt |= TEXCOORDFMT_3D << (2*tex); gen2_emit_texture(sna, &op->src, tex++); } else { - BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); - BATCH(op->src.u.gen2.pixel); + if (op->src.u.gen2.pixel != sna->render_state.gen2.diffuse) { + BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); + BATCH(op->src.u.gen2.pixel); + sna->render_state.gen2.diffuse = op->src.u.gen2.pixel; + } } if (op->mask.bo) { if (op->mask.is_affine) @@ -911,8 +914,17 @@ inline static int gen2_get_rectangles(struct sna *sna, rem -= need; if (state->vertex_offset == 0) { - state->vertex_offset = sna->kgem.nbatch; - BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST); + if ((sna->kgem.batch[sna->kgem.nbatch-1] & ~0xffff) == + (PRIM3D_INLINE | PRIM3D_RECTLIST)) { + uint32_t *b = &sna->kgem.batch[sna->kgem.nbatch-1]; + sna->render.vertex_index = 1 + (*b & 0xffff); + *b = PRIM3D_INLINE | PRIM3D_RECTLIST; + state->vertex_offset = sna->kgem.nbatch - 1; + assert(!op->need_magic_ca_pass); + } else { + state->vertex_offset = sna->kgem.nbatch; + BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST); + } } if (want > 1 && want * size > rem) @@ -1819,8 +1831,11 @@ static void gen2_emit_fill_composite_state(struct sna *sna, gen2_emit_fill_pipeline(sna, op); - BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); - BATCH(pixel); + if (pixel != sna->render_state.gen2.diffuse) { + BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); + BATCH(pixel); + sna->render_state.gen2.diffuse = pixel; + } } static Bool @@ -1895,7 +1910,7 @@ gen2_render_fill_boxes(struct sna *sna, dst, dst_bo, box, n); - if (!PREFER_3D_FILL_BOXES && + if (!PREFER_3D_FILL_BOXES && sna->kgem.mode != KGEM_RENDER && gen2_render_fill_boxes_try_blt(sna, op, format, color, dst, dst_bo, box, n)) @@ -1979,8 +1994,11 @@ static void gen2_emit_fill_state(struct sna *sna, gen2_enable_logic_op(sna, op->op); gen2_emit_fill_pipeline(sna, op); - BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); - BATCH(op->src.u.gen2.pixel); + if (op->src.u.gen2.pixel != sna->render_state.gen2.diffuse) { + BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); + BATCH(op->src.u.gen2.pixel); + sna->render_state.gen2.diffuse = op->src.u.gen2.pixel; + } } static void @@ -2441,6 +2459,8 @@ gen2_render_reset(struct sna *sna) sna->render_state.gen2.ls1 = 0; sna->render_state.gen2.ls2 = 0; sna->render_state.gen2.vft = 0; + + sna->render_state.gen2.diffuse = 0x0c0ffee0; } static void diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 979ff85..f0a99a7 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -267,6 +267,7 @@ struct gen2_render_state { Bool logic_op_enabled; uint32_t ls1, ls2, vft; uint16_t vertex_offset; + uint32_t diffuse; }; struct gen3_render_state { commit d9e3dbffcb7e6cff35e10100d81544936813095a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 12:48:23 2011 +0100 sna/gen2: Fix fill-one-box Lets only have one special gen2 value for the source channel pixel colour and so remove the confusion and misrendering. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index d862235..f1f5e72 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -50,16 +50,17 @@ #define NO_COPY 0 #define NO_COPY_BOXES 0 #define NO_FILL 0 +#define NO_FILL_ONE 0 #define NO_FILL_BOXES 0 -#define PREFER_COPY 0 -#define PREFER_COPY_BOXES 0 -#define PREFER_FILL 0 -#define PREFER_FILL_BOXES 0 +#define PREFER_3D_COPY 0 +#define PREFER_3D_COPY_BOXES 0 +#define PREFER_3D_FILL 0 +#define PREFER_3D_FILL_BOXES 0 -#define OUT_BATCH(v) batch_emit(sna, v) -#define OUT_BATCH_F(v) batch_emit_float(sna, v) -#define OUT_VERTEX(v) batch_emit_float(sna, v) +#define BATCH(v) batch_emit(sna, v) +#define BATCH_F(v) batch_emit_float(sna, v) +#define VERTEX(v) batch_emit_float(sna, v) /* TODO: Remaining items for the sufficiently motivated reader * @@ -298,24 +299,24 @@ gen2_emit_texture(struct sna *sna, break; } - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_MAP(unit) | 4); - OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, - channel->bo, - I915_GEM_DOMAIN_SAMPLER << 16, - 0)); - OUT_BATCH(((channel->height - 1) << TM0S1_HEIGHT_SHIFT) | - ((channel->width - 1) << TM0S1_WIDTH_SHIFT) | - gen2_get_card_format(sna, channel->pict_format) | - gen2_sampler_tiling_bits(channel->bo->tiling)); - OUT_BATCH((channel->bo->pitch / 4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D); - OUT_BATCH(filter); - OUT_BATCH(0); /* default color */ - - OUT_BATCH(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | - ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | - texcoordtype | - ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(wrap_mode) | - ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_MAP(unit) | 4); + BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, + channel->bo, + I915_GEM_DOMAIN_SAMPLER << 16, + 0)); + BATCH(((channel->height - 1) << TM0S1_HEIGHT_SHIFT) | + ((channel->width - 1) << TM0S1_WIDTH_SHIFT) | + gen2_get_card_format(sna, channel->pict_format) | + gen2_sampler_tiling_bits(channel->bo->tiling)); + BATCH((channel->bo->pitch / 4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D); + BATCH(filter); + BATCH(0); /* default color */ + + BATCH(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | + ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | + texcoordtype | + ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(wrap_mode) | + ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); } static void @@ -434,81 +435,62 @@ static uint32_t gen2_get_blend_cntl(int op, static void gen2_emit_invariant(struct sna *sna) { - OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(0)); - OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(1)); - OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(2)); - OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(3)); - - OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | MAP_UNIT(0) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | TEX_STREAM_COORD_SET(0) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0)); - OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | MAP_UNIT(1) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | TEX_STREAM_COORD_SET(1) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1)); - OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | MAP_UNIT(2) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | TEX_STREAM_COORD_SET(2) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2)); - OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | MAP_UNIT(3) | - DISABLE_TEX_STREAM_BUMP | - ENABLE_TEX_STREAM_COORD_SET | TEX_STREAM_COORD_SET(3) | - ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3)); - - OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM); - OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(0)); - OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM); - OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(1)); - OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM); - OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(2)); - OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM); - OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(3)); - - OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD); - OUT_BATCH(TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) | - TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) | - TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) | - TEXBIND_SET0(TEXCOORDSRC_VTXSET_0)); - - OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); - - OUT_BATCH(_3DSTATE_VERTEX_TRANSFORM); - OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE); - - OUT_BATCH(_3DSTATE_W_STATE_CMD); - OUT_BATCH(MAGIC_W_STATE_DWORD1); - OUT_BATCH_F(1.0); - - OUT_BATCH(_3DSTATE_INDPT_ALPHA_BLEND_CMD | - DISABLE_INDPT_ALPHA_BLEND | - ENABLE_ALPHA_BLENDFUNC | ABLENDFUNC_ADD); - - OUT_BATCH(_3DSTATE_CONST_BLEND_COLOR_CMD); - OUT_BATCH(0); - - OUT_BATCH(_3DSTATE_MODES_1_CMD | - ENABLE_COLR_BLND_FUNC | BLENDFUNC_ADD | - ENABLE_SRC_BLND_FACTOR | SRC_BLND_FACT(BLENDFACTOR_ONE) | - ENABLE_DST_BLND_FACTOR | DST_BLND_FACT(BLENDFACTOR_ZERO)); - - OUT_BATCH(_3DSTATE_ENABLES_1_CMD | - DISABLE_LOGIC_OP | - DISABLE_STENCIL_TEST | - DISABLE_DEPTH_BIAS | - DISABLE_SPEC_ADD | - DISABLE_FOG | - DISABLE_ALPHA_TEST | - DISABLE_DEPTH_TEST | - ENABLE_COLOR_BLEND); - - OUT_BATCH(_3DSTATE_ENABLES_2_CMD | - DISABLE_STENCIL_WRITE | - DISABLE_DITHER | - DISABLE_DEPTH_WRITE | - ENABLE_COLOR_MASK | - ENABLE_COLOR_WRITE | - ENABLE_TEX_CACHE); + int i; + + for (i = 0; i < 4; i++) { + BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(i)); + BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | MAP_UNIT(i) | + DISABLE_TEX_STREAM_BUMP | + ENABLE_TEX_STREAM_COORD_SET | TEX_STREAM_COORD_SET(i) | + ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(i)); + BATCH(_3DSTATE_MAP_COORD_TRANSFORM); + BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(i)); + } + + BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD); + BATCH(TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) | + TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) | + TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) | + TEXBIND_SET0(TEXCOORDSRC_VTXSET_0)); + + BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); + + BATCH(_3DSTATE_VERTEX_TRANSFORM); + BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE); + + BATCH(_3DSTATE_W_STATE_CMD); + BATCH(MAGIC_W_STATE_DWORD1); + BATCH_F(1.0); + + BATCH(_3DSTATE_INDPT_ALPHA_BLEND_CMD | + DISABLE_INDPT_ALPHA_BLEND | + ENABLE_ALPHA_BLENDFUNC | ABLENDFUNC_ADD); + + BATCH(_3DSTATE_CONST_BLEND_COLOR_CMD); + BATCH(0); + + BATCH(_3DSTATE_MODES_1_CMD | + ENABLE_COLR_BLND_FUNC | BLENDFUNC_ADD | + ENABLE_SRC_BLND_FACTOR | SRC_BLND_FACT(BLENDFACTOR_ONE) | + ENABLE_DST_BLND_FACTOR | DST_BLND_FACT(BLENDFACTOR_ZERO)); + + BATCH(_3DSTATE_ENABLES_1_CMD | + DISABLE_LOGIC_OP | + DISABLE_STENCIL_TEST | + DISABLE_DEPTH_BIAS | + DISABLE_SPEC_ADD | + DISABLE_FOG | + DISABLE_ALPHA_TEST | + DISABLE_DEPTH_TEST | + ENABLE_COLOR_BLEND); + + BATCH(_3DSTATE_ENABLES_2_CMD | + DISABLE_STENCIL_WRITE | + DISABLE_DITHER | + DISABLE_DEPTH_WRITE | + ENABLE_COLOR_MASK | + ENABLE_COLOR_WRITE | + ENABLE_TEX_CACHE); sna->render_state.gen2.need_invariant = FALSE; } @@ -554,25 +536,25 @@ static void gen2_emit_target(struct sna *sna, const struct sna_composite_op *op) return; } - OUT_BATCH(_3DSTATE_BUF_INFO_CMD); - OUT_BATCH(BUF_3D_ID_COLOR_BACK | - gen2_buf_tiling(op->dst.bo->tiling) | - BUF_3D_PITCH(op->dst.bo->pitch)); - OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, - op->dst.bo, - I915_GEM_DOMAIN_RENDER << 16 | - I915_GEM_DOMAIN_RENDER, - 0)); - - OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD); - OUT_BATCH(gen2_get_dst_format(op->dst.format)); - - OUT_BATCH(_3DSTATE_DRAW_RECT_CMD); - OUT_BATCH(0); - OUT_BATCH(0); /* ymin, xmin */ - OUT_BATCH(DRAW_YMAX(op->dst.height - 1) | - DRAW_XMAX(op->dst.width - 1)); - OUT_BATCH(0); /* yorig, xorig */ + BATCH(_3DSTATE_BUF_INFO_CMD); + BATCH(BUF_3D_ID_COLOR_BACK | + gen2_buf_tiling(op->dst.bo->tiling) | + BUF_3D_PITCH(op->dst.bo->pitch)); + BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, + op->dst.bo, + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER, + 0)); + + BATCH(_3DSTATE_DST_BUF_VARS_CMD); + BATCH(gen2_get_dst_format(op->dst.format)); + + BATCH(_3DSTATE_DRAW_RECT_CMD); + BATCH(0); + BATCH(0); /* ymin, xmin */ + BATCH(DRAW_YMAX(op->dst.height - 1) | + DRAW_XMAX(op->dst.width - 1)); + BATCH(0); /* yorig, xorig */ sna->render_state.gen2.target = op->dst.bo->unique_id; } @@ -582,15 +564,15 @@ static void gen2_disable_logic_op(struct sna *sna) if (!sna->render_state.gen2.logic_op_enabled) return; - OUT_BATCH(_3DSTATE_ENABLES_1_CMD | - DISABLE_LOGIC_OP | ENABLE_COLOR_BLEND); + BATCH(_3DSTATE_ENABLES_1_CMD | + DISABLE_LOGIC_OP | ENABLE_COLOR_BLEND); sna->render_state.gen2.logic_op_enabled = 0; } static void gen2_enable_logic_op(struct sna *sna, int op) { - uint8_t logic_op[] = { + static const uint8_t logic_op[] = { LOGICOP_CLEAR, /* GXclear */ LOGICOP_AND, /* GXand */ LOGICOP_AND_RVRSE, /* GXandReverse */ @@ -609,14 +591,15 @@ static void gen2_enable_logic_op(struct sna *sna, int op) LOGICOP_SET /* GXset */ }; - if (!sna->render_state.gen2.logic_op_enabled) { - OUT_BATCH(_3DSTATE_ENABLES_1_CMD | - ENABLE_LOGIC_OP | DISABLE_COLOR_BLEND); - sna->render_state.gen2.logic_op_enabled = 1; - } + if (sna->render_state.gen2.logic_op_enabled != op+1) { + if (!sna->render_state.gen2.logic_op_enabled) + BATCH(_3DSTATE_ENABLES_1_CMD | + ENABLE_LOGIC_OP | DISABLE_COLOR_BLEND); - OUT_BATCH(_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(logic_op[op])); + BATCH(_3DSTATE_MODES_4_CMD | + ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(logic_op[op])); + sna->render_state.gen2.logic_op_enabled = op+1; + } } static void gen2_emit_composite_state(struct sna *sna, @@ -630,15 +613,15 @@ static void gen2_emit_composite_state(struct sna *sna, gen2_emit_target(sna, op); unwind = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); - OUT_BATCH((!op->src.is_solid + (op->mask.bo != NULL)) << 12); - OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); - OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | - gen2_get_blend_cntl(op->op, - op->has_component_alpha, - op->dst.format) | - S8_ENABLE_COLOR_BUFFER_WRITE); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | + I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); + BATCH((!op->src.is_solid + (op->mask.bo != NULL)) << 12); + BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); + BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | + gen2_get_blend_cntl(op->op, + op->has_component_alpha, + op->dst.format) | + S8_ENABLE_COLOR_BUFFER_WRITE); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, sna->kgem.batch + unwind, 4 * sizeof(uint32_t)) == 0) @@ -650,10 +633,10 @@ static void gen2_emit_composite_state(struct sna *sna, gen2_get_blend_factors(op, op->op, &cblend, &ablend); unwind = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - LOAD_TEXTURE_BLEND_STAGE(0) | 1); - OUT_BATCH(cblend); - OUT_BATCH(ablend); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + LOAD_TEXTURE_BLEND_STAGE(0) | 1); + BATCH(cblend); + BATCH(ablend); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, sna->kgem.batch + unwind + 1, 2 * sizeof(uint32_t)) == 0) @@ -669,8 +652,8 @@ static void gen2_emit_composite_state(struct sna *sna, texcoordfmt |= TEXCOORDFMT_3D << (2*tex); gen2_emit_texture(sna, &op->src, tex++); } else { - OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_BATCH(op->src.u.gen2.pixel); + BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); + BATCH(op->src.u.gen2.pixel); } if (op->mask.bo) { if (op->mask.is_affine) @@ -682,7 +665,7 @@ static void gen2_emit_composite_state(struct sna *sna, v = _3DSTATE_VERTEX_FORMAT_2_CMD | texcoordfmt; if (sna->render_state.gen2.vft != v) { - OUT_BATCH(v); + BATCH(v); sna->render_state.gen2.vft = v; } } @@ -690,8 +673,8 @@ static void gen2_emit_composite_state(struct sna *sna, static inline void gen2_emit_composite_dstcoord(struct sna *sna, int dstX, int dstY) { - OUT_VERTEX(dstX); - OUT_VERTEX(dstY); + VERTEX(dstX); + VERTEX(dstY); } static void @@ -708,15 +691,15 @@ gen2_emit_composite_texcoord(struct sna *sna, sna_get_transformed_coordinates(x, y, channel->transform, &s, &t); - OUT_VERTEX(s * channel->scale[0]); - OUT_VERTEX(t * channel->scale[1]); + VERTEX(s * channel->scale[0]); + VERTEX(t * channel->scale[1]); } else { sna_get_transformed_coordinates_3d(x, y, channel->transform, &s, &t, &w); - OUT_VERTEX(s * channel->scale[0]); - OUT_VERTEX(t * channel->scale[1]); - OUT_VERTEX(w); + VERTEX(s * channel->scale[0]); + VERTEX(t * channel->scale[1]); + VERTEX(w); } } @@ -817,22 +800,22 @@ gen2_emit_composite_primitive_affine(struct sna *sna, &sx, &sy); gen2_emit_composite_dstcoord(sna, dst_x + r->width, dst_y + r->height); - OUT_VERTEX(sx * op->src.scale[0]); - OUT_VERTEX(sy * op->src.scale[1]); + VERTEX(sx * op->src.scale[0]); + VERTEX(sy * op->src.scale[1]); _sna_get_transformed_coordinates(src_x, src_y + r->height, transform, &sx, &sy); gen2_emit_composite_dstcoord(sna, dst_x, dst_y + r->height); - OUT_VERTEX(sx * op->src.scale[0]); - OUT_VERTEX(sy * op->src.scale[1]); + VERTEX(sx * op->src.scale[0]); + VERTEX(sy * op->src.scale[1]); _sna_get_transformed_coordinates(src_x, src_y, transform, &sx, &sy); gen2_emit_composite_dstcoord(sna, dst_x, dst_y); - OUT_VERTEX(sx * op->src.scale[0]); - OUT_VERTEX(sy * op->src.scale[1]); + VERTEX(sx * op->src.scale[0]); + VERTEX(sy * op->src.scale[1]); } fastcall static void @@ -868,17 +851,17 @@ static void gen2_magic_ca_pass(struct sna *sna, if (!op->need_magic_ca_pass) return; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(8) | 0); - OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | - gen2_get_blend_cntl(PictOpAdd, TRUE, op->dst.format) | - S8_ENABLE_COLOR_BUFFER_WRITE); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(8) | 0); + BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | + gen2_get_blend_cntl(PictOpAdd, TRUE, op->dst.format) | + S8_ENABLE_COLOR_BUFFER_WRITE); sna->render_state.gen2.ls1 = 0; gen2_get_blend_factors(op, PictOpAdd, &cblend, &ablend); - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - LOAD_TEXTURE_BLEND_STAGE(0) | 1); - OUT_BATCH(cblend); - OUT_BATCH(ablend); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + LOAD_TEXTURE_BLEND_STAGE(0) | 1); + BATCH(cblend); + BATCH(ablend); sna->render_state.gen2.ls2 = 0; memcpy(sna->kgem.batch + sna->kgem.nbatch, @@ -929,7 +912,7 @@ inline static int gen2_get_rectangles(struct sna *sna, rem -= need; if (state->vertex_offset == 0) { state->vertex_offset = sna->kgem.nbatch; - OUT_BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST); + BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST); } if (want > 1 && want * size > rem) @@ -1385,9 +1368,9 @@ gen2_render_composite(struct sna *sna, if (tmp->src.bo == tmp->dst.bo || tmp->mask.bo == tmp->dst.bo) { kgem_emit_flush(&sna->kgem); } else { - OUT_BATCH(_3DSTATE_MODES_5_CMD | - PIPELINE_FLUSH_RENDER_CACHE | - PIPELINE_FLUSH_TEXTURE_CACHE); + BATCH(_3DSTATE_MODES_5_CMD | + PIPELINE_FLUSH_RENDER_CACHE | + PIPELINE_FLUSH_TEXTURE_CACHE); kgem_clear_dirty(&sna->kgem); } } @@ -1508,7 +1491,7 @@ gen2_emit_composite_spans_vertex(struct sna *sna, float opacity) { gen2_emit_composite_dstcoord(sna, x + op->base.dst.x, y + op->base.dst.y); - OUT_BATCH((uint8_t)(opacity * 255) << 24); + BATCH((uint8_t)(opacity * 255) << 24); gen2_emit_composite_texcoord(sna, &op->base.src, x, y); } @@ -1560,10 +1543,10 @@ gen2_emit_spans_pipeline(struct sna *sna, } unwind = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - LOAD_TEXTURE_BLEND_STAGE(0) | 1); - OUT_BATCH(cblend); - OUT_BATCH(ablend); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + LOAD_TEXTURE_BLEND_STAGE(0) | 1); + BATCH(cblend); + BATCH(ablend); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, sna->kgem.batch + unwind + 1, 2 * sizeof(uint32_t)) == 0) @@ -1581,13 +1564,13 @@ static void gen2_emit_composite_spans_state(struct sna *sna, gen2_emit_target(sna, &op->base); unwind = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); - OUT_BATCH(!op->base.src.is_solid << 12); - OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY | S3_DIFFUSE_PRESENT); - OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | - gen2_get_blend_cntl(op->base.op, FALSE, op->base.dst.format) | - S8_ENABLE_COLOR_BUFFER_WRITE); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | + I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); + BATCH(!op->base.src.is_solid << 12); + BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY | S3_DIFFUSE_PRESENT); + BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | + gen2_get_blend_cntl(op->base.op, FALSE, op->base.dst.format) | + S8_ENABLE_COLOR_BUFFER_WRITE); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, sna->kgem.batch + unwind, 4 * sizeof(uint32_t)) == 0) @@ -1599,13 +1582,13 @@ static void gen2_emit_composite_spans_state(struct sna *sna, gen2_emit_spans_pipeline(sna, op); if (op->base.src.is_solid) { - OUT_BATCH(_3DSTATE_DFLT_SPECULAR_CMD); - OUT_BATCH(op->base.src.u.gen2.pixel); + BATCH(_3DSTATE_DFLT_SPECULAR_CMD); + BATCH(op->base.src.u.gen2.pixel); } else { uint32_t v =_3DSTATE_VERTEX_FORMAT_2_CMD | (op->base.src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_3D); if (sna->render_state.gen2.vft != v) { - OUT_BATCH(v); + BATCH(v); sna->render_state.gen2.vft = v; } gen2_emit_texture(sna, &op->base.src, 0); @@ -1756,9 +1739,9 @@ gen2_render_composite_spans(struct sna *sna, if (tmp->base.src.bo == tmp->base.dst.bo) { kgem_emit_flush(&sna->kgem); } else { - OUT_BATCH(_3DSTATE_MODES_5_CMD | - PIPELINE_FLUSH_RENDER_CACHE | - PIPELINE_FLUSH_TEXTURE_CACHE); + BATCH(_3DSTATE_MODES_5_CMD | + PIPELINE_FLUSH_RENDER_CACHE | + PIPELINE_FLUSH_TEXTURE_CACHE); kgem_clear_dirty(&sna->kgem); } } @@ -1788,19 +1771,19 @@ gen2_emit_fill_pipeline(struct sna *sna, const struct sna_composite_op *op) uint32_t blend, unwind; unwind = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - LOAD_TEXTURE_BLEND_STAGE(0) | 1); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + LOAD_TEXTURE_BLEND_STAGE(0) | 1); blend = TB0C_LAST_STAGE | TB0C_RESULT_SCALE_1X | TB0C_OP_ARG1 | TB0C_ARG1_SEL_DIFFUSE | TB0C_OUTPUT_WRITE_CURRENT; if (op->dst.format == PICT_a8) blend |= TB0C_ARG1_REPLICATE_ALPHA; - OUT_BATCH(blend); + BATCH(blend); - OUT_BATCH(TB0A_RESULT_SCALE_1X | TB0A_OP_ARG1 | - TB0A_ARG1_SEL_DIFFUSE | - TB0A_OUTPUT_WRITE_CURRENT); + BATCH(TB0A_RESULT_SCALE_1X | TB0A_OP_ARG1 | + TB0A_ARG1_SEL_DIFFUSE | + TB0A_OUTPUT_WRITE_CURRENT); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, sna->kgem.batch + unwind + 1, @@ -1820,13 +1803,13 @@ static void gen2_emit_fill_composite_state(struct sna *sna, gen2_emit_target(sna, op); ls1 = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); - OUT_BATCH(0); - OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); - OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | - gen2_get_blend_cntl(op->op, FALSE, op->dst.format) | - S8_ENABLE_COLOR_BUFFER_WRITE); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | + I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); + BATCH(0); + BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); + BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | + gen2_get_blend_cntl(op->op, FALSE, op->dst.format) | + S8_ENABLE_COLOR_BUFFER_WRITE); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, sna->kgem.batch + ls1, 4 * sizeof(uint32_t)) == 0) @@ -1836,8 +1819,8 @@ static void gen2_emit_fill_composite_state(struct sna *sna, gen2_emit_fill_pipeline(sna, op); - OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_BATCH(pixel); + BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); + BATCH(pixel); } static Bool @@ -1912,7 +1895,7 @@ gen2_render_fill_boxes(struct sna *sna, dst, dst_bo, box, n); - if (!PREFER_FILL_BOXES && + if (!PREFER_3D_FILL_BOXES && gen2_render_fill_boxes_try_blt(sna, op, format, color, dst, dst_bo, box, n)) @@ -1957,12 +1940,12 @@ gen2_render_fill_boxes(struct sna *sna, do { DBG((" (%d, %d), (%d, %d): %x\n", box->x1, box->y1, box->x2, box->y2, pixel)); - OUT_VERTEX(box->x2); - OUT_VERTEX(box->y2); - OUT_VERTEX(box->x1); - OUT_VERTEX(box->y2); - OUT_VERTEX(box->x1); - OUT_VERTEX(box->y1); + VERTEX(box->x2); + VERTEX(box->y2); + VERTEX(box->x1); + VERTEX(box->y2); + VERTEX(box->x1); + VERTEX(box->y1); box++; } while (--n_this_time); } while (n); @@ -1981,11 +1964,11 @@ static void gen2_emit_fill_state(struct sna *sna, gen2_emit_target(sna, op); ls1 = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); - OUT_BATCH(0); - OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); - OUT_BATCH(S8_ENABLE_COLOR_BUFFER_WRITE); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | + I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); + BATCH(0); + BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); + BATCH(S8_ENABLE_COLOR_BUFFER_WRITE); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, sna->kgem.batch + ls1, 4 * sizeof(uint32_t)) == 0) @@ -1996,8 +1979,8 @@ static void gen2_emit_fill_state(struct sna *sna, gen2_enable_logic_op(sna, op->op); gen2_emit_fill_pipeline(sna, op); - OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_BATCH(op->u.gen2.pixel); + BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); + BATCH(op->src.u.gen2.pixel); } static void @@ -2010,12 +1993,12 @@ gen2_render_fill_blt(struct sna *sna, gen2_get_rectangles(sna, &op->base, 1); } - OUT_VERTEX(x+w); - OUT_VERTEX(y+h); - OUT_VERTEX(x); - OUT_VERTEX(y+h); - OUT_VERTEX(x); - OUT_VERTEX(y); + VERTEX(x+w); + VERTEX(y+h); + VERTEX(x); + VERTEX(y+h); + VERTEX(x); + VERTEX(y); } static void @@ -2039,7 +2022,7 @@ gen2_render_fill(struct sna *sna, uint8_t alu, #endif /* Prefer to use the BLT if already engaged */ - if (!PREFER_FILL && sna->kgem.mode != KGEM_RENDER && + if (!PREFER_3D_FILL && sna->kgem.mode != KGEM_RENDER && sna_blt_fill(sna, alu, dst_bo, dst->drawable.bitsPerPixel, color, @@ -2063,11 +2046,16 @@ gen2_render_fill(struct sna *sna, uint8_t alu, tmp->base.dst.bo = dst_bo; tmp->base.floats_per_vertex = 2; - tmp->base.u.gen2.pixel = + tmp->base.src.u.gen2.pixel = sna_rgba_for_color(color, dst->drawable.depth); - if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) + if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) { kgem_submit(&sna->kgem); + return sna_blt_fill(sna, alu, + dst_bo, dst->drawable.bitsPerPixel, + color, + tmp); + } tmp->blt = gen2_render_fill_blt; tmp->done = gen2_render_fill_done; @@ -2103,55 +2091,52 @@ gen2_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, { struct sna_composite_op tmp; -#if NO_FILL_BOXES +#if NO_FILL_ONE return gen2_render_fill_one_try_blt(sna, dst, bo, color, x1, y1, x2, y2, alu); #endif /* Prefer to use the BLT if already engaged */ - if (sna->kgem.mode != KGEM_RENDER && + if (!PREFER_3D_FILL && sna->kgem.mode != KGEM_RENDER && gen2_render_fill_one_try_blt(sna, dst, bo, color, x1, y1, x2, y2, alu)) return TRUE; /* Must use the BLT if we can't RENDER... */ - if (!(alu == GXcopy || alu == GXclear) || - dst->drawable.width > 2048 || dst->drawable.height > 2048 || + if (dst->drawable.width > 2048 || dst->drawable.height > 2048 || bo->pitch > 8192) return gen2_render_fill_one_try_blt(sna, dst, bo, color, x1, y1, x2, y2, alu); - if (alu == GXclear) - color = 0; + if (!kgem_check_bo(&sna->kgem, bo, NULL)) { + kgem_submit(&sna->kgem); + if (gen2_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + } - memset(&tmp, 0, sizeof(tmp)); - tmp.op = color == 0 ? PictOpClear : PictOpSrc; + tmp.op = alu; tmp.dst.pixmap = dst; tmp.dst.width = dst->drawable.width; tmp.dst.height = dst->drawable.height; tmp.dst.format = sna_format_for_depth(dst->drawable.depth); tmp.dst.bo = bo; tmp.floats_per_vertex = 2; + tmp.need_magic_ca_pass = false; tmp.src.u.gen2.pixel = sna_rgba_for_color(color, dst->drawable.depth); - if (!kgem_check_bo(&sna->kgem, bo, NULL)) { - kgem_submit(&sna->kgem); - if (gen2_render_fill_one_try_blt(sna, dst, bo, color, - x1, y1, x2, y2, alu)) - return TRUE; - } - gen2_emit_fill_state(sna, &tmp); gen2_get_rectangles(sna, &tmp, 1); - DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, color)); - OUT_VERTEX(x2); - OUT_VERTEX(y2); - OUT_VERTEX(x1); - OUT_VERTEX(y2); - OUT_VERTEX(x1); - OUT_VERTEX(y1); + DBG(("%s: (%d, %d), (%d, %d): %x\n", __FUNCTION__, + x1, y1, x2, y2, tmp.src.u.gen2.pixel)); + VERTEX(x2); + VERTEX(y2); + VERTEX(x1); + VERTEX(y2); + VERTEX(x1); + VERTEX(y1); gen2_vertex_flush(sna); return TRUE; @@ -2181,8 +2166,8 @@ gen2_emit_copy_pipeline(struct sna *sna, const struct sna_composite_op *op) uint32_t blend, unwind; unwind = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - LOAD_TEXTURE_BLEND_STAGE(0) | 1); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + LOAD_TEXTURE_BLEND_STAGE(0) | 1); blend = TB0C_LAST_STAGE | TB0C_RESULT_SCALE_1X | TB0C_OP_ARG1 | TB0C_OUTPUT_WRITE_CURRENT; @@ -2192,7 +2177,7 @@ gen2_emit_copy_pipeline(struct sna *sna, const struct sna_composite_op *op) blend |= TB0C_ARG1_SEL_TEXEL0; else blend |= TB0C_ARG1_SEL_ONE | TB0C_ARG1_INVERT; /* 0.0 */ - OUT_BATCH(blend); + BATCH(blend); blend = TB0A_RESULT_SCALE_1X | TB0A_OP_ARG1 | TB0A_OUTPUT_WRITE_CURRENT; @@ -2200,7 +2185,7 @@ gen2_emit_copy_pipeline(struct sna *sna, const struct sna_composite_op *op) blend |= TB0A_ARG1_SEL_ONE; else blend |= TB0A_ARG1_SEL_TEXEL0; - OUT_BATCH(blend); + BATCH(blend); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls2 + 1, sna->kgem.batch + unwind + 1, @@ -2218,11 +2203,11 @@ static void gen2_emit_copy_state(struct sna *sna, const struct sna_composite_op gen2_emit_target(sna, op); ls1 = sna->kgem.nbatch; - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); - OUT_BATCH(1<<12); - OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); - OUT_BATCH(S8_ENABLE_COLOR_BUFFER_WRITE); + BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | + I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2); + BATCH(1<<12); + BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); + BATCH(S8_ENABLE_COLOR_BUFFER_WRITE); if (memcmp (sna->kgem.batch + sna->render_state.gen2.ls1, sna->kgem.batch + ls1, 4 * sizeof(uint32_t)) == 0) @@ -2235,7 +2220,7 @@ static void gen2_emit_copy_state(struct sna *sna, const struct sna_composite_op v = _3DSTATE_VERTEX_FORMAT_2_CMD | TEXCOORDFMT_2D; if (sna->render_state.gen2.vft != v) { - OUT_BATCH(v); + BATCH(v); sna->render_state.gen2.vft = v; } @@ -2264,7 +2249,7 @@ gen2_render_copy_boxes(struct sna *sna, uint8_t alu, DBG(("%s (%d, %d)->(%d, %d) x %d\n", __FUNCTION__, src_dx, src_dy, dst_dx, dst_dy, n)); - if (!PREFER_COPY_BOXES && + if (!PREFER_3D_COPY_BOXES && sna_blt_compare_depth(&src->drawable, &dst->drawable) && sna_blt_copy_boxes(sna, alu, src_bo, src_dx, src_dy, @@ -2324,20 +2309,20 @@ gen2_render_copy_boxes(struct sna *sna, uint8_t alu, box->x1 + src_dx, box->y1 + src_dy, box->x1 + dst_dx, box->y1 + dst_dy, box->x2 - box->x1, box->y2 - box->y1)); - OUT_VERTEX(box->x2 + dst_dx); - OUT_VERTEX(box->y2 + dst_dy); - OUT_VERTEX((box->x2 + src_dx) * tmp.src.scale[0]); - OUT_VERTEX((box->y2 + src_dy) * tmp.src.scale[1]); + VERTEX(box->x2 + dst_dx); + VERTEX(box->y2 + dst_dy); + VERTEX((box->x2 + src_dx) * tmp.src.scale[0]); + VERTEX((box->y2 + src_dy) * tmp.src.scale[1]); - OUT_VERTEX(box->x1 + dst_dx); - OUT_VERTEX(box->y2 + dst_dy); - OUT_VERTEX((box->x1 + src_dx) * tmp.src.scale[0]); - OUT_VERTEX((box->y2 + src_dy) * tmp.src.scale[1]); + VERTEX(box->x1 + dst_dx); + VERTEX(box->y2 + dst_dy); + VERTEX((box->x1 + src_dx) * tmp.src.scale[0]); + VERTEX((box->y2 + src_dy) * tmp.src.scale[1]); - OUT_VERTEX(box->x1 + dst_dx); - OUT_VERTEX(box->y1 + dst_dy); - OUT_VERTEX((box->x1 + src_dx) * tmp.src.scale[0]); - OUT_VERTEX((box->y1 + src_dy) * tmp.src.scale[1]); + VERTEX(box->x1 + dst_dx); + VERTEX(box->y1 + dst_dy); + VERTEX((box->x1 + src_dx) * tmp.src.scale[0]); + VERTEX((box->y1 + src_dy) * tmp.src.scale[1]); box++; } while (--n_this_time); @@ -2360,20 +2345,20 @@ gen2_render_copy_blt(struct sna *sna, gen2_get_rectangles(sna, &op->base, 1); } - OUT_VERTEX(dx+w); - OUT_VERTEX(dy+h); - OUT_VERTEX((sx+w)*op->base.src.scale[0]); - OUT_VERTEX((sy+h)*op->base.src.scale[1]); + VERTEX(dx+w); + VERTEX(dy+h); + VERTEX((sx+w)*op->base.src.scale[0]); + VERTEX((sy+h)*op->base.src.scale[1]); - OUT_VERTEX(dx); - OUT_VERTEX(dy+h); - OUT_VERTEX(sx*op->base.src.scale[0]); - OUT_VERTEX((sy+h)*op->base.src.scale[1]); + VERTEX(dx); + VERTEX(dy+h); + VERTEX(sx*op->base.src.scale[0]); + VERTEX((sy+h)*op->base.src.scale[1]); - OUT_VERTEX(dx); - OUT_VERTEX(dy); - OUT_VERTEX(sx*op->base.src.scale[0]); - OUT_VERTEX(sy*op->base.src.scale[1]); + VERTEX(dx); + VERTEX(dy); + VERTEX(sx*op->base.src.scale[0]); + VERTEX(sy*op->base.src.scale[1]); } static void @@ -2400,7 +2385,7 @@ gen2_render_copy(struct sna *sna, uint8_t alu, #endif /* Prefer to use the BLT */ - if (!PREFER_COPY && sna->kgem.mode != KGEM_RENDER && + if (!PREFER_3D_COPY && sna->kgem.mode != KGEM_RENDER && sna_blt_compare_depth(&src->drawable, &dst->drawable) && sna_blt_copy(sna, alu, src_bo, dst_bo, diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 223cae6..979ff85 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -98,10 +98,6 @@ struct sna_composite_op { } blt; struct { - uint32_t pixel; - } gen2; - - struct { float constants[8]; uint32_t num_constants; } gen3; From ickle at kemper.freedesktop.org Mon Oct 17 06:26:21 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 17 Oct 2011 06:26:21 -0700 (PDT) Subject: xf86-video-intel: src/sna/gen4_render.c src/sna/sna_composite.c src/sna/sna_damage.c Message-ID: <20111017132621.87C54C0001@kemper.freedesktop.org> src/sna/gen4_render.c | 4 ++++ src/sna/sna_composite.c | 10 +++++++--- src/sna/sna_damage.c | 13 ++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) New commits: commit f1bb4ebfd8991f2f9eb9c38b9259792c11e7c86a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 14:22:58 2011 +0100 sna/damage: Clear damage->all when subtracting I missed clearing the all-damaged flag on the subtract fast paths, causing us to disregard further GPU damage and losing track of render coherency. Reported-by: Roman Jarosz <kedgedev at gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41769 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 95d9a9d..fb60c39 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -1855,6 +1855,10 @@ gen4_composite_set_target(PicturePtr dst, struct sna_composite_op *op) if (!priv->gpu_only && !sna_damage_is_all(&priv->gpu_damage, op->dst.width, op->dst.height)) op->damage = &priv->gpu_damage; + DBG(("%s: gpu_only=%d, all-damaged=%d, damage=%p\n", + __FUNCTION__, priv->gpu_only, + sna_damage_is_all(&priv->gpu_damage, op->dst.width, op->dst.height), + op->damage)); get_drawable_deltas(dst->pDrawable, op->dst.pixmap, &op->dst.x, &op->dst.y); diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index 200ab73..e0b1ca3 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -388,13 +388,17 @@ static void _assert_pixmap_contains_box(PixmapPtr pixmap, BoxPtr box, const char static void apply_damage(struct sna_composite_op *op, RegionPtr region) { - DBG(("%s: damage=%p, region=%d\n", - __FUNCTION__, op->damage, REGION_NUM_RECTS(region))); + DBG(("%s: damage=%p, region=%d [(%d, %d), (%d, %d) + (%d, %d)]\n", + __FUNCTION__, op->damage, REGION_NUM_RECTS(region), + region->extents.x1, region->extents.y1, + region->extents.x2, region->extents.y2, + op->dst.x, op->dst.y)); if (op->damage == NULL) return; - RegionTranslate(region, op->dst.x, op->dst.y); + if (op->dst.x | op->dst.y) + RegionTranslate(region, op->dst.x, op->dst.y); assert_pixmap_contains_box(op->dst.pixmap, RegionExtents(region)); sna_damage_add(op->damage, region); diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 7358c3a..efb1cfe 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -247,6 +247,8 @@ static void __sna_damage_reduce(struct sna_damage *damage) BoxPtr boxes; pixman_region16_t tmp, *region = &damage->region; + assert(!damage->all); + DBG((" reduce: before damage.n=%d region.n=%d\n", damage->n, REGION_NUM_RECTS(region))); @@ -461,7 +463,6 @@ struct sna_damage *_sna_damage_all(struct sna_damage *damage, pixman_region_fini(&damage->region); damage->n = 0; damage->last_box = NULL; - damage->all = 1; } else damage = _sna_damage_create(); @@ -484,7 +485,7 @@ struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, box.x1 = box.y1 = 0; box.x2 = width; box.y2 = height; - + if (pixman_region_contains_rectangle(&damage->region, &box) != PIXMAN_REGION_IN) return damage; @@ -540,6 +541,7 @@ static struct sna_damage *__sna_damage_subtract(struct sna_damage *damage, &damage->region, region); damage->extents = damage->region.extents; + damage->all = 0; return damage; } } @@ -607,10 +609,12 @@ inline static struct sna_damage *__sna_damage_subtract_box(struct sna_damage *da &damage->region, ®ion); damage->extents = damage->region.extents; + damage->all = 0; return damage; } } + damage->all = 0; damage->mode = SUBTRACT; _sna_damage_create_elt(damage, SUBTRACT, box, 1); @@ -646,7 +650,10 @@ static int _sna_damage_contains_box(struct sna_damage *damage, const BoxRec *box) { if (!damage) - return PIXMAN_REGION_OUT;; + return PIXMAN_REGION_OUT; + + if (damage->all) + return PIXMAN_REGION_IN; if (!sna_damage_maybe_contains_box(damage, box)) return PIXMAN_REGION_OUT; From keithp at kemper.freedesktop.org Mon Oct 17 13:52:43 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 17 Oct 2011 13:52:43 -0700 (PDT) Subject: xserver: Branch 'master' - 17 commits Message-ID: <20111017205243.7DC55C0001@kemper.freedesktop.org> dix/eventconvert.c | 1 dix/events.c | 25 +++---- dix/getevents.c | 168 ++++++++++++++++++++++++++++++++++------------------- dix/inpututils.c | 8 ++ include/input.h | 2 mi/mipointer.c | 57 ++++++++++------- mi/mipointer.h | 6 - 7 files changed, 168 insertions(+), 99 deletions(-) New commits: commit fb84be47db7cdaff406792c08e34670e8e0cbda9 Merge: fae7ed6... 32b289e... Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 17 13:50:25 2011 -0700 Merge remote-tracking branch 'whot/next' commit 32b289e46cc2d5ec32ff0c4ba5bbfbf602afb388 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 3 13:58:01 2011 +1000 dix: move MD last.valuator update into fill_pointer_events Don't update the MD where it's not expected, positionSprite should really just do that - position the sprite. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index ade3ca1..874189f 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -844,12 +844,6 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1, scr->height); - /* Update the MD's co-ordinates, which are always in screen space. */ - if (!IsMaster(dev) || !IsFloating(dev)) { - DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); - master->last.valuators[0] = *screenx; - master->last.valuators[1] = *screeny; - } if (valuator_mask_isset(mask, 0)) valuator_mask_set_double(mask, 0, x); @@ -1189,6 +1183,13 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, pDev->last.valuators[i] = valuator_mask_get_double(&mask, i); } + /* Update the MD's co-ordinates, which are always in screen space. */ + if (!IsMaster(pDev) || !IsFloating(pDev)) { + DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER); + master->last.valuators[0] = screenx; + master->last.valuators[1] = screeny; + } + event = &events->device_event; init_device_event(event, pDev, ms); commit 3b36fd1b49030ead44358945f62e5abe7f4609ce Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 3 13:10:53 2011 +1000 mi: switch miPointerSetPosition to take doubles Don't switch between doubles and ints in the caller, instead take doubles in miPointerSetPosition and do the conversion there. For full feature we should change everything down from here for doubles too. Functional change: previously we'd restore the remainder regardless of screen switching/confinement (despite what the comment said). Now, screen changing or cursor constraints will cause the remainder be clipped off. This should happen for cursor constraints but arguably not for screen crossing. This also corrects a currently wrong comment about miPointerSetPosition's input coordinates. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index bb1f5c9..ade3ca1 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -805,8 +805,8 @@ static ScreenPtr positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, double *screenx, double *screeny) { - int isx, isy; /* screen {x, y}, in int */ double x, y; + double tmpx, tmpy; ScreenPtr scr = miPointerGetScreen(dev); if (!dev->valuator || dev->valuator->numAxes < 2) @@ -827,25 +827,22 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL, scr->height); + tmpx = *screenx; + tmpy = *screeny; /* miPointerSetPosition takes care of crossing screens for us, as well as - * clipping to the current screen. In the event we actually change screen, - * we just drop the float component on the floor, then convert from - * screenx back into device co-ordinates. */ - isx = trunc(*screenx); - isy = trunc(*screeny); - scr = miPointerSetPosition(dev, mode, &isx, &isy); - if (isx != trunc(*screenx)) - { - *screenx -= trunc(*screenx) - isx; + * clipping to the current screen. */ + scr = miPointerSetPosition(dev, mode, screenx, screeny); + + /* If we were constrained, rescale x/y from the screen coordinates so + * the device valuators reflect the correct position. For screen + * crossing this doesn't matter much, the coords would be 0 or max. + */ + if (tmpx != *screenx) x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0, scr->width); - } - if (isy != trunc(*screeny)) - { - *screeny -= trunc(*screeny) - isy; + if (tmpy != *screeny) y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1, scr->height); - } /* Update the MD's co-ordinates, which are always in screen space. */ if (!IsMaster(dev) || !IsFloating(dev)) { diff --git a/mi/mipointer.c b/mi/mipointer.c index 4901d13..55e4081 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -569,17 +569,16 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, * * @param pDev The device to move * @param mode Movement mode (Absolute or Relative) - * @param[in,out] x The x coordinate in screen coordinates (in regards to total - * desktop size) - * @param[in,out] y The y coordinate in screen coordinates (in regards to total - * desktop size) + * @param[in,out] screenx The x coordinate in screen coordinates + * @param[in,out] screeny The y coordinate in screen coordinates */ ScreenPtr -miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) +miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *screeny) { miPointerScreenPtr pScreenPriv; ScreenPtr pScreen; ScreenPtr newScreen; + int x, y; miPointerPtr pPointer; @@ -591,13 +590,16 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) if (!pScreen) return NULL; /* called before ready */ - if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height) + x = trunc(*screenx); + y = trunc(*screeny); + + if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height) { pScreenPriv = GetScreenPrivate (pScreen); if (!pPointer->confined) { newScreen = pScreen; - (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, x, y); + (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y); if (newScreen != pScreen) { pScreen = newScreen; @@ -610,21 +612,30 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) } } /* Constrain the sprite to the current limits. */ - if (*x < pPointer->limits.x1) - *x = pPointer->limits.x1; - if (*x >= pPointer->limits.x2) - *x = pPointer->limits.x2 - 1; - if (*y < pPointer->limits.y1) - *y = pPointer->limits.y1; - if (*y >= pPointer->limits.y2) - *y = pPointer->limits.y2 - 1; + if (x < pPointer->limits.x1) + x = pPointer->limits.x1; + if (x >= pPointer->limits.x2) + x = pPointer->limits.x2 - 1; + if (y < pPointer->limits.y1) + y = pPointer->limits.y1; + if (y >= pPointer->limits.y2) + y = pPointer->limits.y2 - 1; if (pScreen->ConstrainCursorHarder) - pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y); + pScreen->ConstrainCursorHarder(pDev, pScreen, mode, &x, &y); - if (pPointer->x != *x || pPointer->y != *y || + if (pPointer->x != x || pPointer->y != y || pPointer->pScreen != pScreen) - miPointerMoveNoEvent(pDev, pScreen, *x, *y); + miPointerMoveNoEvent(pDev, pScreen, x, y); + + /* In the event we actually change screen or we get confined, we just + * drop the float component on the floor + * FIXME: only drop remainder for ConstrainCursorHarder, not for screen + * crossings */ + if (x != trunc(*screenx)) + *screenx = x; + if (y != trunc(*screeny)) + *screeny = y; return pScreen; } diff --git a/mi/mipointer.h b/mi/mipointer.h index 35428df..45abb5b 100644 --- a/mi/mipointer.h +++ b/mi/mipointer.h @@ -134,8 +134,8 @@ extern _X_EXPORT void miPointerGetPosition( extern _X_EXPORT ScreenPtr miPointerSetPosition( DeviceIntPtr pDev, int mode, - int *x, - int *y); + double *x, + double *y); extern _X_EXPORT void miPointerUpdateSprite( DeviceIntPtr pDev); commit 81cfe44b1ed0de84ad1941fe2ca74bebef3fc58d Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 3 12:49:49 2011 +1000 mi: return the screen from miPointerSetPosition miPointerSetPosition may switch screens. Always return the screen the sprite is on instead of relying on callers to call miPointerGetScreen(). Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 4206ca9..bb1f5c9 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -833,8 +833,7 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, * screenx back into device co-ordinates. */ isx = trunc(*screenx); isy = trunc(*screeny); - miPointerSetPosition(dev, mode, &isx, &isy); - scr = miPointerGetScreen(dev); + scr = miPointerSetPosition(dev, mode, &isx, &isy); if (isx != trunc(*screenx)) { *screenx -= trunc(*screenx) - isx; diff --git a/mi/mipointer.c b/mi/mipointer.c index 670f63b..4901d13 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -574,7 +574,7 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, * @param[in,out] y The y coordinate in screen coordinates (in regards to total * desktop size) */ -void +ScreenPtr miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) { miPointerScreenPtr pScreenPriv; @@ -584,12 +584,12 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) miPointerPtr pPointer; if (!pDev || !pDev->coreEvents) - return; + return NULL; pPointer = MIPOINTER(pDev); pScreen = pPointer->pScreen; if (!pScreen) - return; /* called before ready */ + return NULL; /* called before ready */ if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height) { @@ -622,11 +622,11 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) if (pScreen->ConstrainCursorHarder) pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y); - if (pPointer->x == *x && pPointer->y == *y && - pPointer->pScreen == pScreen) - return; + if (pPointer->x != *x || pPointer->y != *y || + pPointer->pScreen != pScreen) + miPointerMoveNoEvent(pDev, pScreen, *x, *y); - miPointerMoveNoEvent(pDev, pScreen, *x, *y); + return pScreen; } /** diff --git a/mi/mipointer.h b/mi/mipointer.h index c4265f9..35428df 100644 --- a/mi/mipointer.h +++ b/mi/mipointer.h @@ -131,7 +131,7 @@ extern _X_EXPORT void miPointerGetPosition( /* Moves the cursor to the specified position. May clip the co-ordinates: * x and y are modified in-place. */ -extern _X_EXPORT void miPointerSetPosition( +extern _X_EXPORT ScreenPtr miPointerSetPosition( DeviceIntPtr pDev, int mode, int *x, commit 88dfe5366d9855e0ebf8bbff74967b793ede57d1 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 3 12:37:28 2011 +1000 dix: drop screen argument from positionSprite We can just get this in the function, no effective functional changes. Also return the screen to the caller. Though we don't use it yet, we will in a follow-up patch. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 3ef7a5c..4206ca9 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -797,20 +797,20 @@ scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask) * * @param dev The device to be moved. * @param mode Movement mode (Absolute or Relative) - * @param scr Screen the device's sprite is currently on. * @param mask Mask of axis values for this event * @param screenx Screen x coordinate the sprite is on after the update. * @param screeny Screen y coordinate the sprite is on after the update. */ -static void -positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, +static ScreenPtr +positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, double *screenx, double *screeny) { int isx, isy; /* screen {x, y}, in int */ double x, y; + ScreenPtr scr = miPointerGetScreen(dev); if (!dev->valuator || dev->valuator->numAxes < 2) - return; + return scr; if (valuator_mask_isset(mask, 0)) x = valuator_mask_get_double(mask, 0); @@ -859,6 +859,8 @@ positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, valuator_mask_set_double(mask, 0, x); if (valuator_mask_isset(mask, 1)) valuator_mask_set_double(mask, 1, y); + + return scr; } /** @@ -1124,7 +1126,6 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, DeviceEvent *event; RawDeviceEvent *raw; double screenx = 0.0, screeny = 0.0; - ScreenPtr scr = miPointerGetScreen(pDev); ValuatorMask mask; switch (type) @@ -1180,7 +1181,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, if ((flags & POINTER_NORAW) == 0) set_raw_valuators(raw, &mask, raw->valuators.data); - positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, scr, + positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, &mask, &screenx, &screeny); updateHistory(pDev, &mask, ms); commit 967bc25da221a69c8fc390253465145ce534fcb9 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 3 11:42:08 2011 +1000 dix: move screen- to device coordinate scaling to separate function No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 98d8cf0..3ef7a5c 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -753,6 +753,37 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms) } /** + * Scale from absolute screen coordinates to absolute coordinates in the + * device's coordinate range. + * + * @param dev The device to scale for. + * @param[in, out] mask The mask in sceen coordinates, modified in place to + * contain device coordinate range. + */ +static void +scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask) +{ + double scaled; + ScreenPtr scr = miPointerGetScreen(dev); + + if (valuator_mask_isset(mask, 0)) + { + scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 0), + NULL, dev->valuator->axes + 0, + scr->width); + valuator_mask_set_double(mask, 0, scaled); + } + if (valuator_mask_isset(mask, 1)) + { + scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 1), + NULL, dev->valuator->axes + 1, + scr->height); + valuator_mask_set_double(mask, 1, scaled); + } +} + + +/** * If we have HW cursors, this actually moves the visible sprite. If not, we * just do all the screen crossing, etc. * @@ -1136,24 +1167,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, if (flags & POINTER_ABSOLUTE) { if (flags & POINTER_SCREEN) /* valuators are in screen coords */ - { - double scaled; - - if (valuator_mask_isset(&mask, 0)) - { - scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 0), - NULL, pDev->valuator->axes + 0, - scr->width); - valuator_mask_set_double(&mask, 0, scaled); - } - if (valuator_mask_isset(&mask, 1)) - { - scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 1), - NULL, pDev->valuator->axes + 1, - scr->height); - valuator_mask_set_double(&mask, 1, scaled); - } - } + scale_from_screen(pDev, &mask); transformAbsolute(pDev, &mask); clipAbsolute(pDev, &mask); commit b059e06e19ac9417ceeb8be58c1c91b159291865 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Aug 29 12:36:26 2011 +1000 dix: don't allow keyboard devices to submit motion or button events. GPE unconditionally dereferences pDev->valuator if a mask is present. This shouldn't really happen but if it does, don't crash, just ignore the events with an error. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 9926693..98d8cf0 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1099,6 +1099,11 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, switch (type) { case MotionNotify: + if (!pDev->valuator) + { + ErrorF("[dix] motion events from device %d without valuators\n", pDev->id); + return 0; + } if (!mask_in || valuator_mask_num_valuators(mask_in) <= 0) return 0; break; @@ -1106,6 +1111,11 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, case ButtonRelease: if (!pDev->button || !buttons) return 0; + if (mask_in && valuator_mask_size(mask_in) > 0 && !pDev->valuator) + { + ErrorF("[dix] button event with valuator from device %d without valuators\n", pDev->id); + return 0; + } break; default: return 0; commit bccff533184a051b614a26304ce77ad30bede5e0 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 3 12:19:21 2011 +1000 dix: moveRelative modifies parameter in-place, say so. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 6a812fb..9926693 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -713,7 +713,7 @@ clipAbsolute(DeviceIntPtr dev, ValuatorMask *mask) * Move the device's pointer by the values given in @valuators. * * @param dev The device whose pointer is to be moved. - * @param mask Valuator data for this event. + * @param[in,out] mask Valuator data for this event, modified in-place. */ static void moveRelative(DeviceIntPtr dev, ValuatorMask *mask) commit b966362ccf0fe6fdd44f4d778d47e3677f55f11b Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 3 12:18:20 2011 +1000 dix: rename moveAbsolute to clipAbsolute Let's be honest about what it does. moveRelative accumulates delta _and_ clips in some cases, so that one can keep it's name. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index cf82cbf..6a812fb 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -693,7 +693,7 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve * @param mask Valuator data for this event. */ static void -moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask) +clipAbsolute(DeviceIntPtr dev, ValuatorMask *mask) { int i; @@ -1146,7 +1146,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, } transformAbsolute(pDev, &mask); - moveAbsolute(pDev, &mask); + clipAbsolute(pDev, &mask); } else { if (flags & POINTER_ACCELERATE) accelPointer(pDev, &mask, ms); commit 959d18c3765e447897a8cfd358e9ee645df595d9 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Sep 30 10:50:51 2011 +1000 dix: fix missing verb in comment Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index e478355..cf82cbf 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -760,8 +760,9 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms) * miPointerSetPosition() and then scale back into device coordinates (if * needed). miPSP will change x/y if the screen was crossed. * - * The coordinates provided are always absolute. The parameter mode whether - * it was relative or absolute movement that landed us at those coordinates. + * The coordinates provided are always absolute. The parameter mode + * specifies whether it was relative or absolute movement that landed us at + * those coordinates. * * @param dev The device to be moved. * @param mode Movement mode (Absolute or Relative) commit 7074ec87bdf81699df172619aea7aae1ad4ec3c6 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Sep 30 10:47:00 2011 +1000 dix: document transformAbsolute Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 97c3937..e478355 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1020,6 +1020,14 @@ transform(struct pixman_f_transform *m, double *x, double *y) *y = p.v[1]; } +/** + * Apply the device's transformation matrix to the valuator mask and replace + * the scaled values in mask. This transformation only applies to valuators + * 0 and 1, others will be untouched. + * + * @param dev The device the valuators came from + * @param[in,out] mask The valuator mask. + */ static void transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask) { commit f4ca19ce3ab91a9c8ad9de60f7dc95466f21f589 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Jul 29 10:56:44 2011 +1000 dix: copy the source ID into the RawEvent (#34240) X.Org Bug 34240 <http://bugs.freedesktop.org/show_bug.cgi?id=34240> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/eventconvert.c b/dix/eventconvert.c index f9aafa5..189cb85 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -667,6 +667,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) raw->length = bytes_to_int32(len - sizeof(xEvent)); raw->detail = ev->detail.button; raw->deviceid = ev->deviceid; + raw->sourceid = ev->sourceid; raw->valuators_len = vallen; raw->flags = ev->flags; commit 765ef69295ddc473640c96f1b4f54e0b8bfc670e Author: Max Schwarz <max.schwarz at online.de> Date: Tue Oct 4 22:06:08 2011 +0200 dix: fix inverted handling of legacy scroll button events This bug led to inverted scrolling axes with drivers that support smooth scrolling axes but send legacy button events. Signed-off-by: Max Schwarz <Max at x-quadraht.de> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/dix/getevents.c b/dix/getevents.c index ebf2653..97c3937 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1330,21 +1330,22 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, double val, adj; int axis; + /* Up is negative on valuators, down positive */ switch (buttons) { case 4: - adj = 1.0; + adj = -1.0; axis = v_scroll_axis; break; case 5: - adj = -1.0; + adj = 1.0; axis = v_scroll_axis; break; case 6: - adj = 1.0; + adj = -1.0; axis = h_scroll_axis; break; case 7: - adj = -1.0; + adj = 1.0; axis = h_scroll_axis; break; default: commit 911e7368bf9c00d327e994a6f7a1d8d8f9b83c72 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Aug 30 16:58:04 2011 -0400 Move pointOnScreen to inpututils.c We need this from other files too. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/events.c b/dix/events.c index 0f5b042..f87d2bb 100644 --- a/dix/events.c +++ b/dix/events.c @@ -525,13 +525,6 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) { static void PostNewCursor(DeviceIntPtr pDev); static Bool -pointOnScreen(ScreenPtr pScreen, int x, int y) -{ - return x >= pScreen->x && x < pScreen->x + pScreen->width && - y >= pScreen->y && y < pScreen->y + pScreen->height; -} - -static Bool XineramaSetCursorPosition( DeviceIntPtr pDev, int x, @@ -550,13 +543,13 @@ XineramaSetCursorPosition( x += screenInfo.screens[0]->x; y += screenInfo.screens[0]->y; - if(!pointOnScreen(pScreen, x, y)) + if(!point_on_screen(pScreen, x, y)) { FOR_NSCREENS(i) { if(i == pScreen->myNum) continue; - if(pointOnScreen(screenInfo.screens[i], x, y)) + if(point_on_screen(screenInfo.screens[i], x, y)) { pScreen = screenInfo.screens[i]; break; diff --git a/dix/inpututils.c b/dix/inpututils.c index 0a3d3d8..eeae2a7 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -37,6 +37,7 @@ #include "xkbstr.h" #include "inpututils.h" #include "eventstr.h" +#include "scrnintstr.h" /* Check if a button map change is okay with the device. * Returns -1 for BadValue, as it collides with MappingBusy. */ @@ -619,6 +620,13 @@ void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms) event->sourceid = dev->id; } +Bool +point_on_screen(ScreenPtr pScreen, int x, int y) +{ + return x >= pScreen->x && x < pScreen->x + pScreen->width && + y >= pScreen->y && y < pScreen->y + pScreen->height; +} + /** * Delete the element with the key from the list, freeing all memory * associated with the element.. diff --git a/include/input.h b/include/input.h index 6ba1ab2..b7de5ca 100644 --- a/include/input.h +++ b/include/input.h @@ -608,4 +608,6 @@ extern _X_EXPORT const char* input_option_get_value(const InputOption *opt); extern _X_EXPORT void input_option_set_key(InputOption *opt, const char* key); extern _X_EXPORT void input_option_set_value(InputOption *opt, const char* value); +extern _X_HIDDEN Bool point_on_screen(ScreenPtr pScreen, int x, int y); + #endif /* INPUT_H */ commit d0a7cd759d4741a1ae118d579c90704410cde244 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Sep 2 09:53:02 2011 +1000 dix: NewCurrentScreen must work on pointers where possible When a screen switch is triggered by PointerKeys, the device for NewCurrentScreen is the keyboard. Submitting pointer events for this keyboard (without valuators) has no effect as GPE ignores the event. Force the dequeuing through the XTest device attached to this device. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/events.c b/dix/events.c index 4e21c2d..0f5b042 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3360,7 +3360,11 @@ WindowHasNewCursor(WindowPtr pWin) void NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) { - SpritePtr pSprite = pDev->spriteInfo->sprite; + DeviceIntPtr ptr; + SpritePtr pSprite; + + ptr = IsFloating(pDev) ? pDev : GetXTestDevice(GetMaster(pDev, MASTER_POINTER)); + pSprite = ptr->spriteInfo->sprite; pSprite->hotPhys.x = x; pSprite->hotPhys.y = y; @@ -3372,15 +3376,15 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) pSprite->screen = newScreen; /* Make sure we tell the DDX to update its copy of the screen */ if(pSprite->confineWin) - XineramaConfineCursorToWindow(pDev, + XineramaConfineCursorToWindow(ptr, pSprite->confineWin, TRUE); else - XineramaConfineCursorToWindow(pDev, screenInfo.screens[0]->root, TRUE); + XineramaConfineCursorToWindow(ptr, screenInfo.screens[0]->root, TRUE); /* if the pointer wasn't confined, the DDX won't get told of the pointer warp so we reposition it here */ if(!syncEvents.playingEvents) (*pSprite->screen->SetCursorPosition)( - pDev, + ptr, pSprite->screen, pSprite->hotPhys.x + screenInfo.screens[0]->x - pSprite->screen->x, @@ -3390,7 +3394,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) } else #endif if (newScreen != pSprite->hotPhys.pScreen) - ConfineCursorToWindow(pDev, newScreen->root, TRUE, FALSE); + ConfineCursorToWindow(ptr, newScreen->root, TRUE, FALSE); } #ifdef PANORAMIX commit 535b3789be3a7b43b5d9026e2b5150521d91e32b Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Aug 31 14:15:02 2011 +1000 dix: warn about keyboard events with valuator masks We don't actually handle the mask correctly. They're clipped and dropped into the event but that's about it. I don't think we did since 1.4, let's warn the user if this happens. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index b81562a..ebf2653 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -919,6 +919,11 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type, (key_code < 8 || key_code > 255)) return 0; + if (mask_in && valuator_mask_size(mask_in) > 1) { + ErrorF("[dix] the server does not handle valuator masks with " + "keyboard events. This is a bug. You may fix it.\n"); + } + num_events = 1; events = UpdateFromMaster(events, pDev, DEVCHANGE_KEYBOARD_EVENT, &num_events); commit 9537afb13f2750d22350b7441570332ae60e4860 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Aug 30 13:37:31 2011 +1000 dix: fill out root_x/y for keyboard events Switching screens relies on rootx/y to be set to the correct value. Note: though we technically take a mask for GetKeyboardEvents we don't actually handle it properly to move the pointer as required (and generate motion events if needed). Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index c429715..b81562a 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -859,6 +859,15 @@ queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents) mieqEnqueue(device, &events[i]); } +static void +event_set_root_coordinates(DeviceEvent* event, double x, double y) +{ + event->root_x = trunc(x); + event->root_y = trunc(y); + event->root_x_frac = x - trunc(x); + event->root_y_frac = y - trunc(y); +} + /** * Generate internal events representing this keyboard event and enqueue * them on the event queue. @@ -956,6 +965,13 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type, set_valuators(pDev, event, &mask); + if (!IsFloating(pDev)) { + DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER); + event_set_root_coordinates(event, + master->last.valuators[0], + master->last.valuators[1]); + } + return num_events; } @@ -1158,10 +1174,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, } /* root_x and root_y must be in screen co-ordinates */ - event->root_x = trunc(screenx); - event->root_y = trunc(screeny); - event->root_x_frac = screenx - trunc(screenx); - event->root_y_frac = screeny - trunc(screeny); + event_set_root_coordinates(event, screenx, screeny); if (flags & POINTER_EMULATED) { raw->flags = XIPointerEmulated; From podain at kemper.freedesktop.org Mon Oct 17 22:07:12 2011 From: podain at kemper.freedesktop.org (Taekyun Kim) Date: Mon, 17 Oct 2011 22:07:12 -0700 (PDT) Subject: pixman: Branch 'master' - 7 commits Message-ID: <20111018050712.C8AECC0001@kemper.freedesktop.org> pixman/pixman-arm-neon-asm-bilinear.S | 922 ++++++++++++++++++++++++++++------ pixman/pixman-arm-neon-asm.S | 139 +++++ pixman/pixman-arm-neon.c | 10 3 files changed, 909 insertions(+), 162 deletions(-) New commits: commit 19f118f41f8725f22395d31eac5670cb350b55ec Author: Taekyun Kim <tkq.kim at samsung.com> Date: Mon Sep 26 18:33:27 2011 +0900 ARM: NEON: Standard fast path src_n_8_8 Performance numbers of before/after on cortex-a8 @ 1GHz - before L1: 28.05 L2: 28.26 M: 26.97 ( 4.48%) HT: 19.79 VT: 19.14 R: 17.61 RT: 9.88 ( 101Kops/s) - after L1:1430.28 L2:1252.10 M:421.93 ( 75.48%) HT:170.16 VT:138.03 R:145.86 RT: 35.51 ( 255Kops/s) diff --git a/pixman/pixman-arm-neon-asm.S b/pixman/pixman-arm-neon-asm.S index 1db02db..da8f054 100644 --- a/pixman/pixman-arm-neon-asm.S +++ b/pixman/pixman-arm-neon-asm.S @@ -1292,6 +1292,72 @@ generate_composite_function \ /******************************************************************************/ +.macro pixman_composite_src_n_8_8_process_pixblock_head + vmull.u8 q0, d24, d16 + vmull.u8 q1, d25, d16 + vmull.u8 q2, d26, d16 + vmull.u8 q3, d27, d16 + vrsra.u16 q0, q0, #8 + vrsra.u16 q1, q1, #8 + vrsra.u16 q2, q2, #8 + vrsra.u16 q3, q3, #8 +.endm + +.macro pixman_composite_src_n_8_8_process_pixblock_tail + vrshrn.u16 d28, q0, #8 + vrshrn.u16 d29, q1, #8 + vrshrn.u16 d30, q2, #8 + vrshrn.u16 d31, q3, #8 +.endm + +.macro pixman_composite_src_n_8_8_process_pixblock_tail_head + fetch_mask_pixblock + PF add PF_X, PF_X, #8 + vrshrn.u16 d28, q0, #8 + PF tst PF_CTL, #0x0F + vrshrn.u16 d29, q1, #8 + PF addne PF_X, PF_X, #8 + vrshrn.u16 d30, q2, #8 + PF subne PF_CTL, PF_CTL, #1 + vrshrn.u16 d31, q3, #8 + PF cmp PF_X, ORIG_W + vmull.u8 q0, d24, d16 + PF pld, [PF_MASK, PF_X, lsl #mask_bpp_shift] + vmull.u8 q1, d25, d16 + PF subge PF_X, PF_X, ORIG_W + vmull.u8 q2, d26, d16 + PF subges PF_CTL, PF_CTL, #0x10 + vmull.u8 q3, d27, d16 + PF ldrgeb DUMMY, [PF_MASK, MASK_STRIDE, lsl #mask_bpp_shift]! + vst1.8 {d28, d29, d30, d31}, [DST_W, :128]! + vrsra.u16 q0, q0, #8 + vrsra.u16 q1, q1, #8 + vrsra.u16 q2, q2, #8 + vrsra.u16 q3, q3, #8 +.endm + +.macro pixman_composite_src_n_8_8_init + add DUMMY, sp, #ARGS_STACK_OFFSET + vld1.32 {d16[0]}, [DUMMY] + vdup.8 d16, d16[3] +.endm + +.macro pixman_composite_src_n_8_8_cleanup +.endm + +generate_composite_function \ + pixman_composite_src_n_8_8_asm_neon, 0, 8, 8, \ + FLAG_DST_WRITEONLY, \ + 32, /* number of pixels, processed in a single block */ \ + 5, /* prefetch distance */ \ + pixman_composite_src_n_8_8_init, \ + pixman_composite_src_n_8_8_cleanup, \ + pixman_composite_src_n_8_8_process_pixblock_head, \ + pixman_composite_src_n_8_8_process_pixblock_tail, \ + pixman_composite_src_n_8_8_process_pixblock_tail_head + +/******************************************************************************/ + .macro pixman_composite_over_n_8_8888_process_pixblock_head /* expecting deinterleaved source data in {d8, d9, d10, d11} */ /* d8 - blue, d9 - green, d10 - red, d11 - alpha */ diff --git a/pixman/pixman-arm-neon.c b/pixman/pixman-arm-neon.c index 3db9adf..ca139de 100644 --- a/pixman/pixman-arm-neon.c +++ b/pixman/pixman-arm-neon.c @@ -92,6 +92,8 @@ PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, neon, add_n_8_8888, uint8_t, 1, uint32_t, 1) PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (0, neon, src_n_8_8888, uint8_t, 1, uint32_t, 1) +PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (0, neon, src_n_8_8, + uint8_t, 1, uint8_t, 1) PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST (SKIP_ZERO_MASK, neon, over_8888_n_8888, uint32_t, 1, uint32_t, 1) @@ -295,6 +297,7 @@ static const pixman_fast_path_t arm_neon_fast_paths[] = PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8r8g8b8, neon_composite_src_n_8_8888), PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8b8g8r8, neon_composite_src_n_8_8888), PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8b8g8r8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8, neon_composite_src_n_8_8), PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8, neon_composite_over_n_8_8), PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, neon_composite_over_n_8_0565), commit 4db9e2bc13d3ed26416f249e57acec4b41f58b7f Author: Taekyun Kim <tkq.kim at samsung.com> Date: Mon Sep 26 17:03:54 2011 +0900 ARM: NEON: Standard fast path src_n_8_8888 Performance numbers of before/after on cortex-a8 @ 1GHz - before L1: 32.39 L2: 31.79 M: 30.84 ( 13.77%) HT: 21.58 VT: 19.75 R: 18.83 RT: 10.46 ( 106Kops/s) - after L1: 516.25 L2: 372.00 M:193.49 ( 85.59%) HT:136.93 VT:109.10 R:104.48 RT: 34.77 ( 253Kops/s) diff --git a/pixman/pixman-arm-neon-asm.S b/pixman/pixman-arm-neon-asm.S index 3fcd07d..1db02db 100644 --- a/pixman/pixman-arm-neon-asm.S +++ b/pixman/pixman-arm-neon-asm.S @@ -1219,6 +1219,79 @@ generate_composite_function \ /******************************************************************************/ +.macro pixman_composite_src_n_8_8888_process_pixblock_head + /* expecting solid source in {d0, d1, d2, d3} */ + /* mask is in d24 (d25, d26, d27 are unused) */ + + /* in */ + vmull.u8 q8, d24, d0 + vmull.u8 q9, d24, d1 + vmull.u8 q10, d24, d2 + vmull.u8 q11, d24, d3 + vrsra.u16 q8, q8, #8 + vrsra.u16 q9, q9, #8 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 +.endm + +.macro pixman_composite_src_n_8_8888_process_pixblock_tail + vrshrn.u16 d28, q8, #8 + vrshrn.u16 d29, q9, #8 + vrshrn.u16 d30, q10, #8 + vrshrn.u16 d31, q11, #8 +.endm + +.macro pixman_composite_src_n_8_8888_process_pixblock_tail_head + fetch_mask_pixblock + PF add PF_X, PF_X, #8 + vrshrn.u16 d28, q8, #8 + PF tst PF_CTL, #0x0F + vrshrn.u16 d29, q9, #8 + PF addne PF_X, PF_X, #8 + vrshrn.u16 d30, q10, #8 + PF subne PF_CTL, PF_CTL, #1 + vrshrn.u16 d31, q11, #8 + PF cmp PF_X, ORIG_W + vmull.u8 q8, d24, d0 + PF pld, [PF_MASK, PF_X, lsl #mask_bpp_shift] + vmull.u8 q9, d24, d1 + PF subge PF_X, PF_X, ORIG_W + vmull.u8 q10, d24, d2 + PF subges PF_CTL, PF_CTL, #0x10 + vmull.u8 q11, d24, d3 + PF ldrgeb DUMMY, [PF_MASK, MASK_STRIDE, lsl #mask_bpp_shift]! + vst4.8 {d28, d29, d30, d31}, [DST_W :128]! + vrsra.u16 q8, q8, #8 + vrsra.u16 q9, q9, #8 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 +.endm + +.macro pixman_composite_src_n_8_8888_init + add DUMMY, sp, #ARGS_STACK_OFFSET + vld1.32 {d3[0]}, [DUMMY] + vdup.8 d0, d3[0] + vdup.8 d1, d3[1] + vdup.8 d2, d3[2] + vdup.8 d3, d3[3] +.endm + +.macro pixman_composite_src_n_8_8888_cleanup +.endm + +generate_composite_function \ + pixman_composite_src_n_8_8888_asm_neon, 0, 8, 32, \ + FLAG_DST_WRITEONLY | FLAG_DEINTERLEAVE_32BPP, \ + 8, /* number of pixels, processed in a single block */ \ + 5, /* prefetch distance */ \ + pixman_composite_src_n_8_8888_init, \ + pixman_composite_src_n_8_8888_cleanup, \ + pixman_composite_src_n_8_8888_process_pixblock_head, \ + pixman_composite_src_n_8_8888_process_pixblock_tail, \ + pixman_composite_src_n_8_8888_process_pixblock_tail_head, \ + +/******************************************************************************/ + .macro pixman_composite_over_n_8_8888_process_pixblock_head /* expecting deinterleaved source data in {d8, d9, d10, d11} */ /* d8 - blue, d9 - green, d10 - red, d11 - alpha */ diff --git a/pixman/pixman-arm-neon.c b/pixman/pixman-arm-neon.c index effb50b..3db9adf 100644 --- a/pixman/pixman-arm-neon.c +++ b/pixman/pixman-arm-neon.c @@ -90,6 +90,8 @@ PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, neon, add_n_8_8, uint8_t, 1, uint8_t, 1) PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, neon, add_n_8_8888, uint8_t, 1, uint32_t, 1) +PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (0, neon, src_n_8_8888, + uint8_t, 1, uint32_t, 1) PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST (SKIP_ZERO_MASK, neon, over_8888_n_8888, uint32_t, 1, uint32_t, 1) @@ -289,6 +291,11 @@ static const pixman_fast_path_t arm_neon_fast_paths[] = PIXMAN_STD_FAST_PATH (SRC, pixbuf, pixbuf, a8b8g8r8, neon_composite_src_rpixbuf_8888), PIXMAN_STD_FAST_PATH (SRC, rpixbuf, rpixbuf, a8r8g8b8, neon_composite_src_rpixbuf_8888), PIXMAN_STD_FAST_PATH (SRC, rpixbuf, rpixbuf, a8b8g8r8, neon_composite_src_pixbuf_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8r8g8b8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8r8g8b8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8b8g8r8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8b8g8r8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8, neon_composite_over_n_8_8), PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, neon_composite_over_n_8_0565), PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, neon_composite_over_n_8_0565), commit 26659de6cd2775c83a9a6e6660324d5baacf61f9 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Mon Sep 26 19:04:53 2011 +0900 ARM: NEON: Instruction scheduling of bilinear over_8888_8_8888 Instructions are reordered to eliminate pipeline stalls and get better memory access. Performance of before/after on cortex-a8 @ 1GHz << 2000 x 2000 with scale factor close to 1.x >> before : 40.53 Mpix/s after : 50.76 Mpix/s diff --git a/pixman/pixman-arm-neon-asm-bilinear.S b/pixman/pixman-arm-neon-asm-bilinear.S index 82d248e..f7913ad 100644 --- a/pixman/pixman-arm-neon-asm-bilinear.S +++ b/pixman/pixman-arm-neon-asm-bilinear.S @@ -949,7 +949,7 @@ pixman_asm_function fname vshrn.u32 d0, q0, #16 vshrn.u32 d1, q1, #16 vld1.32 {d2, d3}, [OUT, :128] - pld [OUT, PF_OFFS] + pld [OUT, #(prefetch_offset * 4)] vshrn.u32 d4, q2, #16 vshr.u16 q15, q12, #8 vshrn.u32 d5, q3, #16 @@ -1061,15 +1061,169 @@ pixman_asm_function fname .endm .macro bilinear_over_8888_8_8888_process_pixblock_head - bilinear_over_8888_8_8888_process_four_pixels + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + vld1.32 {d0}, [TMP1], STRIDE + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + vld1.32 {d1}, [TMP1] + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + vld1.32 {d2}, [TMP2], STRIDE + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vld1.32 {d3}, [TMP2] + vmull.u8 q2, d0, d28 + vmull.u8 q3, d2, d28 + vmlal.u8 q2, d1, d29 + vmlal.u8 q3, d3, d29 + vshll.u16 q0, d4, #8 + vshll.u16 q1, d6, #8 + vmlsl.u16 q0, d4, d30 + vmlsl.u16 q1, d6, d31 + vmlal.u16 q0, d5, d30 + vmlal.u16 q1, d7, d31 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vld1.32 {d2}, [TMP3], STRIDE + vld1.32 {d3}, [TMP3] + pld [TMP4, PF_OFFS] + vld1.32 {d4}, [TMP4], STRIDE + vld1.32 {d5}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q3, d2, d28 + vmlal.u8 q3, d3, d29 + vmull.u8 q1, d4, d28 + vmlal.u8 q1, d5, d29 + vshr.u16 q15, q12, #8 + vld1.32 {d22[0]}, [MASK]! + pld [MASK, #prefetch_offset] + vadd.u16 q12, q12, q13 + vmovn.u16 d16, q0 .endm .macro bilinear_over_8888_8_8888_process_pixblock_tail + vshll.u16 q9, d6, #8 + vshll.u16 q10, d2, #8 + vmlsl.u16 q9, d6, d30 + vmlsl.u16 q10, d2, d31 + vmlal.u16 q9, d7, d30 + vmlal.u16 q10, d3, d31 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vdup.32 d22, d22[0] + vshrn.u32 d18, q9, #16 + vshrn.u32 d19, q10, #16 + vmovn.u16 d17, q9 + vld1.32 {d18, d19}, [OUT, :128] + pld [OUT, PF_OFFS] + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vmull.u8 q10, d16, d22 + vmull.u8 q11, d17, d22 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 + vrshrn.u16 d16, q10, #8 + vrshrn.u16 d17, q11, #8 + vdup.32 d22, d17[1] + vmvn.8 d22, d22 + vmull.u8 q10, d18, d22 + vmull.u8 q11, d19, d22 + vrshr.u16 q9, q10, #8 + vrshr.u16 q0, q11, #8 + vraddhn.u16 d18, q9, q10 + vraddhn.u16 d19, q0, q11 + vqadd.u8 q9, q8, q9 + vuzp.8 d18, d19 + vuzp.8 d18, d19 + vst1.32 {d18, d19}, [OUT, :128]! .endm .macro bilinear_over_8888_8_8888_process_pixblock_tail_head - bilinear_over_8888_8_8888_process_pixblock_tail - bilinear_over_8888_8_8888_process_pixblock_head + vshll.u16 q9, d6, #8 + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + vshll.u16 q10, d2, #8 + vld1.32 {d0}, [TMP1], STRIDE + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + vmlsl.u16 q9, d6, d30 + vmlsl.u16 q10, d2, d31 + vld1.32 {d1}, [TMP1] + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + vmlal.u16 q9, d7, d30 + vmlal.u16 q10, d3, d31 + vld1.32 {d2}, [TMP2], STRIDE + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vld1.32 {d3}, [TMP2] + vdup.32 d22, d22[0] + vshrn.u32 d18, q9, #16 + vshrn.u32 d19, q10, #16 + vmull.u8 q2, d0, d28 + vmull.u8 q3, d2, d28 + vmovn.u16 d17, q9 + vld1.32 {d18, d19}, [OUT, :128] + pld [OUT, #(prefetch_offset * 4)] + vmlal.u8 q2, d1, d29 + vmlal.u8 q3, d3, d29 + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vshll.u16 q0, d4, #8 + vshll.u16 q1, d6, #8 + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vmlsl.u16 q0, d4, d30 + vmlsl.u16 q1, d6, d31 + vmull.u8 q10, d16, d22 + vmull.u8 q11, d17, d22 + vmlal.u16 q0, d5, d30 + vmlal.u16 q1, d7, d31 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vrshrn.u16 d16, q10, #8 + vrshrn.u16 d17, q11, #8 + vld1.32 {d2}, [TMP3], STRIDE + vdup.32 d22, d17[1] + vld1.32 {d3}, [TMP3] + vmvn.8 d22, d22 + pld [TMP4, PF_OFFS] + vld1.32 {d4}, [TMP4], STRIDE + vmull.u8 q10, d18, d22 + vmull.u8 q11, d19, d22 + vld1.32 {d5}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q3, d2, d28 + vrshr.u16 q9, q10, #8 + vrshr.u16 q15, q11, #8 + vmlal.u8 q3, d3, d29 + vmull.u8 q1, d4, d28 + vraddhn.u16 d18, q9, q10 + vraddhn.u16 d19, q15, q11 + vmlal.u8 q1, d5, d29 + vshr.u16 q15, q12, #8 + vqadd.u8 q9, q8, q9 + vld1.32 {d22[0]}, [MASK]! + vuzp.8 d18, d19 + vadd.u16 q12, q12, q13 + vuzp.8 d18, d19 + vmovn.u16 d16, q0 + vst1.32 {d18, d19}, [OUT, :128]! .endm /* add_8888_8888 */ commit 4481920f405e47b3a92811a8cb06afbd37dee01b Author: Taekyun Kim <tkq.kim at samsung.com> Date: Wed Sep 21 15:52:13 2011 +0900 ARM: NEON: Instruction scheduling of bilinear over_8888_8888 Instructions are reordered to eliminate pipeline stalls and get better memory access. Performance of before/after on cortex-a8 @ 1GHz << 2000 x 2000 with scale factor close to 1.x >> before : 50.43 Mpix/s after : 61.09 Mpix/s diff --git a/pixman/pixman-arm-neon-asm-bilinear.S b/pixman/pixman-arm-neon-asm-bilinear.S index 25bcb24..82d248e 100644 --- a/pixman/pixman-arm-neon-asm-bilinear.S +++ b/pixman/pixman-arm-neon-asm-bilinear.S @@ -893,15 +893,158 @@ pixman_asm_function fname .endm .macro bilinear_over_8888_8888_process_pixblock_head - bilinear_over_8888_8888_process_four_pixels + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + + vld1.32 {d22}, [TMP1], STRIDE + vld1.32 {d23}, [TMP1] + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + vmull.u8 q8, d22, d28 + vmlal.u8 q8, d23, d29 + + vld1.32 {d22}, [TMP2], STRIDE + vld1.32 {d23}, [TMP2] + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vmull.u8 q9, d22, d28 + vmlal.u8 q9, d23, d29 + + vld1.32 {d22}, [TMP3], STRIDE + vld1.32 {d23}, [TMP3] + vmull.u8 q10, d22, d28 + vmlal.u8 q10, d23, d29 + + vshll.u16 q0, d16, #8 + vmlsl.u16 q0, d16, d30 + vmlal.u16 q0, d17, d30 + + pld [TMP4, PF_OFFS] + vld1.32 {d16}, [TMP4], STRIDE + vld1.32 {d17}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q11, d16, d28 + vmlal.u8 q11, d17, d29 + + vshll.u16 q1, d18, #8 + vmlsl.u16 q1, d18, d31 + vmlal.u16 q1, d19, d31 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 .endm .macro bilinear_over_8888_8888_process_pixblock_tail + vshll.u16 q2, d20, #8 + vmlsl.u16 q2, d20, d30 + vmlal.u16 q2, d21, d30 + vshll.u16 q3, d22, #8 + vmlsl.u16 q3, d22, d31 + vmlal.u16 q3, d23, d31 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vld1.32 {d2, d3}, [OUT, :128] + pld [OUT, PF_OFFS] + vshrn.u32 d4, q2, #16 + vshr.u16 q15, q12, #8 + vshrn.u32 d5, q3, #16 + vmovn.u16 d6, q0 + vmovn.u16 d7, q2 + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vdup.32 d4, d7[1] + vmvn.8 d4, d4 + vmull.u8 q11, d2, d4 + vmull.u8 q2, d3, d4 + vrshr.u16 q1, q11, #8 + vrshr.u16 q10, q2, #8 + vraddhn.u16 d2, q1, q11 + vraddhn.u16 d3, q10, q2 + vqadd.u8 q3, q1, q3 + vuzp.8 d6, d7 + vuzp.8 d6, d7 + vadd.u16 q12, q12, q13 + vst1.32 {d6, d7}, [OUT, :128]! .endm .macro bilinear_over_8888_8888_process_pixblock_tail_head - bilinear_over_8888_8888_process_pixblock_tail - bilinear_over_8888_8888_process_pixblock_head + vshll.u16 q2, d20, #8 + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + vmlsl.u16 q2, d20, d30 + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + vmlal.u16 q2, d21, d30 + vshll.u16 q3, d22, #8 + vld1.32 {d20}, [TMP1], STRIDE + vmlsl.u16 q3, d22, d31 + vmlal.u16 q3, d23, d31 + vld1.32 {d21}, [TMP1] + vmull.u8 q8, d20, d28 + vmlal.u8 q8, d21, d29 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vld1.32 {d2, d3}, [OUT, :128] + pld [OUT, PF_OFFS] + vshrn.u32 d4, q2, #16 + vshr.u16 q15, q12, #8 + vld1.32 {d22}, [TMP2], STRIDE + vshrn.u32 d5, q3, #16 + vmovn.u16 d6, q0 + vld1.32 {d23}, [TMP2] + vmull.u8 q9, d22, d28 + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vmlal.u8 q9, d23, d29 + vmovn.u16 d7, q2 + vld1.32 {d22}, [TMP3], STRIDE + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vdup.32 d4, d7[1] + vld1.32 {d23}, [TMP3] + vmvn.8 d4, d4 + vmull.u8 q10, d22, d28 + vmlal.u8 q10, d23, d29 + vmull.u8 q11, d2, d4 + vmull.u8 q2, d3, d4 + vshll.u16 q0, d16, #8 + vmlsl.u16 q0, d16, d30 + vrshr.u16 q1, q11, #8 + vmlal.u16 q0, d17, d30 + vrshr.u16 q8, q2, #8 + vraddhn.u16 d2, q1, q11 + vraddhn.u16 d3, q8, q2 + pld [TMP4, PF_OFFS] + vld1.32 {d16}, [TMP4], STRIDE + vqadd.u8 q3, q1, q3 + vld1.32 {d17}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q11, d16, d28 + vmlal.u8 q11, d17, d29 + vuzp.8 d6, d7 + vshll.u16 q1, d18, #8 + vuzp.8 d6, d7 + vmlsl.u16 q1, d18, d31 + vadd.u16 q12, q12, q13 + vmlal.u16 q1, d19, d31 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vst1.32 {d6, d7}, [OUT, :128]! .endm /* over_8888_8_8888 */ commit 1cd916f3a5ebeb943f66eecf0b8ce99af0b95d11 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Fri Sep 23 00:03:22 2011 +0900 ARM: NEON: Replace old bilinear scanline generator with new template Bilinear scanline functions in pixman-arm-neon-asm-bilinear.S can be replaced with new template just by wrapping existing macros. diff --git a/pixman/pixman-arm-neon-asm-bilinear.S b/pixman/pixman-arm-neon-asm-bilinear.S index 784e5df..25bcb24 100644 --- a/pixman/pixman-arm-neon-asm-bilinear.S +++ b/pixman/pixman-arm-neon-asm-bilinear.S @@ -582,198 +582,6 @@ fname: bilinear_store_&dst_fmt 4, q2, q3 .endm -.macro generate_bilinear_scanline_func_src_dst \ - fname, src_fmt, dst_fmt, op, \ - bpp_shift, prefetch_distance - -pixman_asm_function fname - OUT .req r0 - TOP .req r1 - BOTTOM .req r2 - WT .req r3 - WB .req r4 - X .req r5 - UX .req r6 - WIDTH .req ip - TMP1 .req r3 - TMP2 .req r4 - PF_OFFS .req r7 - TMP3 .req r8 - TMP4 .req r9 - STRIDE .req r2 - - mov ip, sp - push {r4, r5, r6, r7, r8, r9} - mov PF_OFFS, #prefetch_distance - ldmia ip, {WB, X, UX, WIDTH} - mul PF_OFFS, PF_OFFS, UX - - .set prefetch_offset, prefetch_distance - - sub STRIDE, BOTTOM, TOP - .unreq BOTTOM - - cmp WIDTH, #0 - ble 3f - - vdup.u16 q12, X - vdup.u16 q13, UX - vdup.u8 d28, WT - vdup.u8 d29, WB - vadd.u16 d25, d25, d26 - vadd.u16 q13, q13, q13 - vshr.u16 q15, q12, #8 - vadd.u16 q12, q12, q13 - - subs WIDTH, WIDTH, #4 - blt 1f - mov PF_OFFS, PF_OFFS, asr #(16 - bpp_shift) -0: - bilinear_interpolate_four_pixels src_fmt, x, dst_fmt, op - subs WIDTH, WIDTH, #4 - bge 0b -1: - tst WIDTH, #2 - beq 2f - bilinear_interpolate_two_pixels src_fmt, x, dst_fmt, op -2: - tst WIDTH, #1 - beq 3f - bilinear_interpolate_last_pixel src_fmt, x, dst_fmt, op -3: - pop {r4, r5, r6, r7, r8, r9} - bx lr - - .unreq OUT - .unreq TOP - .unreq WT - .unreq WB - .unreq X - .unreq UX - .unreq WIDTH - .unreq TMP1 - .unreq TMP2 - .unreq PF_OFFS - .unreq TMP3 - .unreq TMP4 - .unreq STRIDE -.endfunc - -.endm - -.macro generate_bilinear_scanline_func_src_a8_dst \ - fname, src_fmt, dst_fmt, op, \ - bpp_shift, prefetch_distance - -pixman_asm_function fname - OUT .req r0 - MASK .req r1 - TOP .req r2 - BOTTOM .req r3 - WT .req r4 - WB .req r5 - X .req r6 - UX .req r7 - WIDTH .req ip - TMP1 .req r4 - TMP2 .req r5 - PF_OFFS .req r8 - TMP3 .req r9 - TMP4 .req r10 - STRIDE .req r3 - - mov ip, sp - push {r4, r5, r6, r7, r8, r9, r10, ip} - mov PF_OFFS, #prefetch_distance - ldmia ip, {WT, WB, X, UX, WIDTH} - mul PF_OFFS, PF_OFFS, UX - - .set prefetch_offset, prefetch_distance - - sub STRIDE, BOTTOM, TOP - .unreq BOTTOM - - cmp WIDTH, #0 - ble 3f - - vdup.u16 q12, X - vdup.u16 q13, UX - vdup.u8 d28, WT - vdup.u8 d29, WB - vadd.u16 d25, d25, d26 - vadd.u16 q13, q13, q13 - vshr.u16 q15, q12, #8 - vadd.u16 q12, q12, q13 - - subs WIDTH, WIDTH, #4 - blt 1f - mov PF_OFFS, PF_OFFS, asr #(16 - bpp_shift) -0: - bilinear_interpolate_four_pixels src_fmt, 8, dst_fmt, op - subs WIDTH, WIDTH, #4 - bge 0b -1: - tst WIDTH, #2 - beq 2f - bilinear_interpolate_two_pixels src_fmt, 8, dst_fmt, op -2: - tst WIDTH, #1 - beq 3f - bilinear_interpolate_last_pixel src_fmt, 8, dst_fmt, op -3: - pop {r4, r5, r6, r7, r8, r9, r10, ip} - bx lr - - .unreq OUT - .unreq TOP - .unreq WT - .unreq WB - .unreq X - .unreq UX - .unreq WIDTH - .unreq MASK - .unreq TMP1 - .unreq TMP2 - .unreq PF_OFFS - .unreq TMP3 - .unreq TMP4 - .unreq STRIDE -.endfunc - -.endm - -generate_bilinear_scanline_func_src_dst \ - pixman_scaled_bilinear_scanline_8888_8888_OVER_asm_neon, \ - 8888, 8888, over, 2, 28 - -generate_bilinear_scanline_func_src_dst \ - pixman_scaled_bilinear_scanline_8888_8888_ADD_asm_neon, \ - 8888, 8888, add, 2, 28 - -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_8888_8_8888_SRC_asm_neon, \ - 8888, 8888, src, 2, 28 - -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_8888_8_0565_SRC_asm_neon, \ - 8888, 0565, src, 2, 28 - -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_0565_8_x888_SRC_asm_neon, \ - 0565, 8888, src, 1, 28 - -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_0565_8_0565_SRC_asm_neon, \ - 0565, 0565, src, 1, 28 - -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_8888_8_8888_OVER_asm_neon, \ - 8888, 8888, over, 2, 28 - -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_8888_8_8888_ADD_asm_neon, \ - 8888, 8888, add, 2, 28 - .set BILINEAR_FLAG_USE_MASK, 1 .set BILINEAR_FLAG_USE_ALL_NEON_REGS, 2 @@ -855,6 +663,8 @@ pixman_asm_function fname TMP4 .req r10 STRIDE .req r3 + .set prefetch_offset, prefetch_distance + mov ip, sp push {r4, r5, r6, r7, r8, r9, r10, ip} mov PF_OFFS, #prefetch_distance @@ -968,3 +778,293 @@ pixman_asm_function fname .endfunc .endm + +/* src_8888_8_8888 */ +.macro bilinear_src_8888_8_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 8888, src +.endm + +.macro bilinear_src_8888_8_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 8888, src +.endm + +.macro bilinear_src_8888_8_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 8888, src +.endm + +.macro bilinear_src_8888_8_8888_process_pixblock_head + bilinear_src_8888_8_8888_process_four_pixels +.endm + +.macro bilinear_src_8888_8_8888_process_pixblock_tail +.endm + +.macro bilinear_src_8888_8_8888_process_pixblock_tail_head + bilinear_src_8888_8_8888_process_pixblock_tail + bilinear_src_8888_8_8888_process_pixblock_head +.endm + +/* src_8888_8_0565 */ +.macro bilinear_src_8888_8_0565_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 0565, src +.endm + +.macro bilinear_src_8888_8_0565_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 0565, src +.endm + +.macro bilinear_src_8888_8_0565_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 0565, src +.endm + +.macro bilinear_src_8888_8_0565_process_pixblock_head + bilinear_src_8888_8_0565_process_four_pixels +.endm + +.macro bilinear_src_8888_8_0565_process_pixblock_tail +.endm + +.macro bilinear_src_8888_8_0565_process_pixblock_tail_head + bilinear_src_8888_8_0565_process_pixblock_tail + bilinear_src_8888_8_0565_process_pixblock_head +.endm + +/* src_0565_8_x888 */ +.macro bilinear_src_0565_8_x888_process_last_pixel + bilinear_interpolate_last_pixel 0565, 8, 8888, src +.endm + +.macro bilinear_src_0565_8_x888_process_two_pixels + bilinear_interpolate_two_pixels 0565, 8, 8888, src +.endm + +.macro bilinear_src_0565_8_x888_process_four_pixels + bilinear_interpolate_four_pixels 0565, 8, 8888, src +.endm + +.macro bilinear_src_0565_8_x888_process_pixblock_head + bilinear_src_0565_8_x888_process_four_pixels +.endm + +.macro bilinear_src_0565_8_x888_process_pixblock_tail +.endm + +.macro bilinear_src_0565_8_x888_process_pixblock_tail_head + bilinear_src_0565_8_x888_process_pixblock_tail + bilinear_src_0565_8_x888_process_pixblock_head +.endm + +/* src_0565_8_0565 */ +.macro bilinear_src_0565_8_0565_process_last_pixel + bilinear_interpolate_last_pixel 0565, 8, 0565, src +.endm + +.macro bilinear_src_0565_8_0565_process_two_pixels + bilinear_interpolate_two_pixels 0565, 8, 0565, src +.endm + +.macro bilinear_src_0565_8_0565_process_four_pixels + bilinear_interpolate_four_pixels 0565, 8, 0565, src +.endm + +.macro bilinear_src_0565_8_0565_process_pixblock_head + bilinear_src_0565_8_0565_process_four_pixels +.endm + +.macro bilinear_src_0565_8_0565_process_pixblock_tail +.endm + +.macro bilinear_src_0565_8_0565_process_pixblock_tail_head + bilinear_src_0565_8_0565_process_pixblock_tail + bilinear_src_0565_8_0565_process_pixblock_head +.endm + +/* over_8888_8888 */ +.macro bilinear_over_8888_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, x, 8888, over +.endm + +.macro bilinear_over_8888_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, x, 8888, over +.endm + +.macro bilinear_over_8888_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, x, 8888, over +.endm + +.macro bilinear_over_8888_8888_process_pixblock_head + bilinear_over_8888_8888_process_four_pixels +.endm + +.macro bilinear_over_8888_8888_process_pixblock_tail +.endm + +.macro bilinear_over_8888_8888_process_pixblock_tail_head + bilinear_over_8888_8888_process_pixblock_tail + bilinear_over_8888_8888_process_pixblock_head +.endm + +/* over_8888_8_8888 */ +.macro bilinear_over_8888_8_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 8888, over +.endm + +.macro bilinear_over_8888_8_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 8888, over +.endm + +.macro bilinear_over_8888_8_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 8888, over +.endm + +.macro bilinear_over_8888_8_8888_process_pixblock_head + bilinear_over_8888_8_8888_process_four_pixels +.endm + +.macro bilinear_over_8888_8_8888_process_pixblock_tail +.endm + +.macro bilinear_over_8888_8_8888_process_pixblock_tail_head + bilinear_over_8888_8_8888_process_pixblock_tail + bilinear_over_8888_8_8888_process_pixblock_head +.endm + +/* add_8888_8888 */ +.macro bilinear_add_8888_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, x, 8888, add +.endm + +.macro bilinear_add_8888_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, x, 8888, add +.endm + +.macro bilinear_add_8888_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, x, 8888, add +.endm + +.macro bilinear_add_8888_8888_process_pixblock_head + bilinear_add_8888_8888_process_four_pixels +.endm + +.macro bilinear_add_8888_8888_process_pixblock_tail +.endm + +.macro bilinear_add_8888_8888_process_pixblock_tail_head + bilinear_add_8888_8888_process_pixblock_tail + bilinear_add_8888_8888_process_pixblock_head +.endm + +/* add_8888_8_8888 */ +.macro bilinear_add_8888_8_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 8888, add +.endm + +.macro bilinear_add_8888_8_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 8888, add +.endm + +.macro bilinear_add_8888_8_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 8888, add +.endm + +.macro bilinear_add_8888_8_8888_process_pixblock_head + bilinear_add_8888_8_8888_process_four_pixels +.endm + +.macro bilinear_add_8888_8_8888_process_pixblock_tail +.endm + +.macro bilinear_add_8888_8_8888_process_pixblock_tail_head + bilinear_add_8888_8_8888_process_pixblock_tail + bilinear_add_8888_8_8888_process_pixblock_head +.endm + + +/* Bilinear scanline functions */ +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8_8888_SRC_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_src_8888_8_8888_process_last_pixel, \ + bilinear_src_8888_8_8888_process_two_pixels, \ + bilinear_src_8888_8_8888_process_four_pixels, \ + bilinear_src_8888_8_8888_process_pixblock_head, \ + bilinear_src_8888_8_8888_process_pixblock_tail, \ + bilinear_src_8888_8_8888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8_0565_SRC_asm_neon, \ + 8888, 0565, 2, 1, \ + bilinear_src_8888_8_0565_process_last_pixel, \ + bilinear_src_8888_8_0565_process_two_pixels, \ + bilinear_src_8888_8_0565_process_four_pixels, \ + bilinear_src_8888_8_0565_process_pixblock_head, \ + bilinear_src_8888_8_0565_process_pixblock_tail, \ + bilinear_src_8888_8_0565_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_0565_8_x888_SRC_asm_neon, \ + 0565, 8888, 1, 2, \ + bilinear_src_0565_8_x888_process_last_pixel, \ + bilinear_src_0565_8_x888_process_two_pixels, \ + bilinear_src_0565_8_x888_process_four_pixels, \ + bilinear_src_0565_8_x888_process_pixblock_head, \ + bilinear_src_0565_8_x888_process_pixblock_tail, \ + bilinear_src_0565_8_x888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_0565_8_0565_SRC_asm_neon, \ + 0565, 0565, 1, 1, \ + bilinear_src_0565_8_0565_process_last_pixel, \ + bilinear_src_0565_8_0565_process_two_pixels, \ + bilinear_src_0565_8_0565_process_four_pixels, \ + bilinear_src_0565_8_0565_process_pixblock_head, \ + bilinear_src_0565_8_0565_process_pixblock_tail, \ + bilinear_src_0565_8_0565_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8888_OVER_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_over_8888_8888_process_last_pixel, \ + bilinear_over_8888_8888_process_two_pixels, \ + bilinear_over_8888_8888_process_four_pixels, \ + bilinear_over_8888_8888_process_pixblock_head, \ + bilinear_over_8888_8888_process_pixblock_tail, \ + bilinear_over_8888_8888_process_pixblock_tail_head, \ + 4, 28, 0 + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8_8888_OVER_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_over_8888_8_8888_process_last_pixel, \ + bilinear_over_8888_8_8888_process_two_pixels, \ + bilinear_over_8888_8_8888_process_four_pixels, \ + bilinear_over_8888_8_8888_process_pixblock_head, \ + bilinear_over_8888_8_8888_process_pixblock_tail, \ + bilinear_over_8888_8_8888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8888_ADD_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_add_8888_8888_process_last_pixel, \ + bilinear_add_8888_8888_process_two_pixels, \ + bilinear_add_8888_8888_process_four_pixels, \ + bilinear_add_8888_8888_process_pixblock_head, \ + bilinear_add_8888_8888_process_pixblock_tail, \ + bilinear_add_8888_8888_process_pixblock_tail_head, \ + 4, 28, 0 + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8_8888_ADD_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_add_8888_8_8888_process_last_pixel, \ + bilinear_add_8888_8_8888_process_two_pixels, \ + bilinear_add_8888_8_8888_process_four_pixels, \ + bilinear_add_8888_8_8888_process_pixblock_head, \ + bilinear_add_8888_8_8888_process_pixblock_tail, \ + bilinear_add_8888_8_8888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK commit 6682b2b3597c9f431900bfe7b1b42dfbe006bae5 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Tue Sep 20 21:32:35 2011 +0900 ARM: NEON: Bilinear macro template for instruction scheduling This macro template takes 6 code blocks. 1. process_last_pixel 2. process_two_pixels 3. process_four_pixels 4. process_pixblock_head 5. process_pixblock_tail 6. process_pixblock_tail_head process_last_pixel does not need to update horizontal weight. This is done by the template. two and four code block should update horizontal weight inside of them. head/tail/tail_head blocks consist unrolled core loop. You can apply instruction scheduling to the tail_head blocks. You can also specify size of the pixel block. Supported size is 4 and 8. If you want to use mask, give BILINEAR_FLAG_USE_MASK flags to the template, then you can use register MASK. When using d8~d15 registers, give BILINEAR_FLAG_USE_ALL_NEON_REGS to make sure registers are properly saved on the stack and later restored. diff --git a/pixman/pixman-arm-neon-asm-bilinear.S b/pixman/pixman-arm-neon-asm-bilinear.S index c5ba929..784e5df 100644 --- a/pixman/pixman-arm-neon-asm-bilinear.S +++ b/pixman/pixman-arm-neon-asm-bilinear.S @@ -773,3 +773,198 @@ generate_bilinear_scanline_func_src_a8_dst \ generate_bilinear_scanline_func_src_a8_dst \ pixman_scaled_bilinear_scanline_8888_8_8888_ADD_asm_neon, \ 8888, 8888, add, 2, 28 + +.set BILINEAR_FLAG_USE_MASK, 1 +.set BILINEAR_FLAG_USE_ALL_NEON_REGS, 2 + +/* + * Main template macro for generating NEON optimized bilinear scanline functions. + * + * Bilinear scanline generator macro take folling arguments: + * fname - name of the function to generate + * src_fmt - source color format (8888 or 0565) + * dst_fmt - destination color format (8888 or 0565) + * src/dst_bpp_shift - (1 << bpp_shift) is the size of src/dst pixel in bytes + * process_last_pixel - code block that interpolate one pixel and does not + * update horizontal weight + * process_two_pixels - code block that interpolate two pixels and update + * horizontal weight + * process_four_pixels - code block that interpolate four pixels and update + * horizontal weight + * process_pixblock_head - head part of middle loop + * process_pixblock_tail - tail part of middle loop + * process_pixblock_tail_head - tail_head of middle loop + * pixblock_size - number of pixels processed in a single middle loop + * prefetch_distance - prefetch in the source image by that many pixels ahead + */ + +.macro generate_bilinear_scanline_func \ + fname, \ + src_fmt, dst_fmt, src_bpp_shift, dst_bpp_shift, \ + bilinear_process_last_pixel, \ + bilinear_process_two_pixels, \ + bilinear_process_four_pixels, \ + bilinear_process_pixblock_head, \ + bilinear_process_pixblock_tail, \ + bilinear_process_pixblock_tail_head, \ + pixblock_size, \ + prefetch_distance, \ + flags + +pixman_asm_function fname +.if pixblock_size == 8 +.elseif pixblock_size == 4 +.else + .error unsupported pixblock size +.endif + +.if ((flags) & BILINEAR_FLAG_USE_MASK) == 0 + OUT .req r0 + TOP .req r1 + BOTTOM .req r2 + WT .req r3 + WB .req r4 + X .req r5 + UX .req r6 + WIDTH .req ip + TMP1 .req r3 + TMP2 .req r4 + PF_OFFS .req r7 + TMP3 .req r8 + TMP4 .req r9 + STRIDE .req r2 + + mov ip, sp + push {r4, r5, r6, r7, r8, r9} + mov PF_OFFS, #prefetch_distance + ldmia ip, {WB, X, UX, WIDTH} +.else + OUT .req r0 + MASK .req r1 + TOP .req r2 + BOTTOM .req r3 + WT .req r4 + WB .req r5 + X .req r6 + UX .req r7 + WIDTH .req ip + TMP1 .req r4 + TMP2 .req r5 + PF_OFFS .req r8 + TMP3 .req r9 + TMP4 .req r10 + STRIDE .req r3 + + mov ip, sp + push {r4, r5, r6, r7, r8, r9, r10, ip} + mov PF_OFFS, #prefetch_distance + ldmia ip, {WT, WB, X, UX, WIDTH} +.endif + + mul PF_OFFS, PF_OFFS, UX + +.if ((flags) & BILINEAR_FLAG_USE_ALL_NEON_REGS) != 0 + vpush {d8-d15} +.endif + + sub STRIDE, BOTTOM, TOP + .unreq BOTTOM + + cmp WIDTH, #0 + ble 3f + + vdup.u16 q12, X + vdup.u16 q13, UX + vdup.u8 d28, WT + vdup.u8 d29, WB + vadd.u16 d25, d25, d26 + + /* ensure good destination alignment */ + cmp WIDTH, #1 + blt 0f + tst OUT, #(1 << dst_bpp_shift) + beq 0f + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + bilinear_process_last_pixel + sub WIDTH, WIDTH, #1 +0: + vadd.u16 q13, q13, q13 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + + cmp WIDTH, #2 + blt 0f + tst OUT, #(1 << (dst_bpp_shift + 1)) + beq 0f + bilinear_process_two_pixels + sub WIDTH, WIDTH, #2 +0: +.if pixblock_size == 8 + cmp WIDTH, #4 + blt 0f + tst OUT, #(1 << (dst_bpp_shift + 2)) + beq 0f + bilinear_process_four_pixels + sub WIDTH, WIDTH, #4 +0: +.endif + subs WIDTH, WIDTH, #pixblock_size + blt 1f + mov PF_OFFS, PF_OFFS, asr #(16 - src_bpp_shift) + bilinear_process_pixblock_head + subs WIDTH, WIDTH, #pixblock_size + blt 5f +0: + bilinear_process_pixblock_tail_head + subs WIDTH, WIDTH, #pixblock_size + bge 0b +5: + bilinear_process_pixblock_tail +1: +.if pixblock_size == 8 + tst WIDTH, #4 + beq 2f + bilinear_process_four_pixels +2: +.endif + /* handle the remaining trailing pixels */ + tst WIDTH, #2 + beq 2f + bilinear_process_two_pixels +2: + tst WIDTH, #1 + beq 3f + bilinear_process_last_pixel +3: +.if ((flags) & BILINEAR_FLAG_USE_ALL_NEON_REGS) != 0 + vpop {d8-d15} +.endif + +.if ((flags) & BILINEAR_FLAG_USE_MASK) == 0 + pop {r4, r5, r6, r7, r8, r9} +.else + pop {r4, r5, r6, r7, r8, r9, r10, ip} +.endif + bx lr + + .unreq OUT + .unreq TOP + .unreq WT + .unreq WB + .unreq X + .unreq UX + .unreq WIDTH + .unreq TMP1 + .unreq TMP2 + .unreq PF_OFFS + .unreq TMP3 + .unreq TMP4 + .unreq STRIDE +.if ((flags) & BILINEAR_FLAG_USE_MASK) != 0 + .unreq MASK +.endif + +.endfunc + +.endm commit b5e4355fa4973e3edd4abeb11bdc47c42371cc76 Author: Taekyun Kim <tkq.kim at samsung.com> Date: Tue Sep 20 19:46:25 2011 +0900 ARM: NEON: Some cleanup of bilinear scanline functions Use STRIDE and initial horizontal weight update is done before entering interpolation loop. Cache preload for mask and dst. diff --git a/pixman/pixman-arm-neon-asm-bilinear.S b/pixman/pixman-arm-neon-asm-bilinear.S index 3c7fe0f..c5ba929 100644 --- a/pixman/pixman-arm-neon-asm-bilinear.S +++ b/pixman/pixman-arm-neon-asm-bilinear.S @@ -44,10 +44,6 @@ * All temp registers can be used freely outside the code block. * Assume that symbol(register .req) OUT and MASK are defined at caller of these macro blocks. * - * TODOs - * Support 0565 pixel format - * Optimization for two and last pixel cases - * * Remarks * There can be lots of pipeline stalls inside code block and between code blocks. * Further optimizations will be done by new macro templates using head/tail_head/tail scheme. @@ -92,21 +88,19 @@ fname: */ .macro bilinear_load_8888 reg1, reg2, tmp - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #2 - add TMP2, BOTTOM, TMP2, asl #2 - vld1.32 {reg1}, [TMP1] - vld1.32 {reg2}, [TMP2] + add TMP1, TOP, TMP1, asl #2 + vld1.32 {reg1}, [TMP1], STRIDE + vld1.32 {reg2}, [TMP1] .endm .macro bilinear_load_0565 reg1, reg2, tmp - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - vld1.32 {reg2[0]}, [TMP1] - vld1.32 {reg2[1]}, [TMP2] + add TMP1, TOP, TMP1, asl #1 + vld1.32 {reg2[0]}, [TMP1], STRIDE + vld1.32 {reg2[1]}, [TMP1] convert_four_0565_to_x888_packed reg2, reg1, reg2, tmp .endm @@ -134,18 +128,16 @@ fname: .macro bilinear_load_and_vertical_interpolate_two_0565 \ acc1, acc2, reg1, reg2, reg3, reg4, acc2lo, acc2hi - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - mov TMP4, X, asr #16 + add TMP1, TOP, TMP1, asl #1 + mov TMP2, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - add TMP3, TOP, TMP4, asl #1 - add TMP4, BOTTOM, TMP4, asl #1 - vld1.32 {acc2lo[0]}, [TMP1] - vld1.32 {acc2hi[0]}, [TMP3] - vld1.32 {acc2lo[1]}, [TMP2] - vld1.32 {acc2hi[1]}, [TMP4] + add TMP2, TOP, TMP2, asl #1 + vld1.32 {acc2lo[0]}, [TMP1], STRIDE + vld1.32 {acc2hi[0]}, [TMP2], STRIDE + vld1.32 {acc2lo[1]}, [TMP1] + vld1.32 {acc2hi[1]}, [TMP2] convert_0565_to_x888 acc2, reg3, reg2, reg1 vzip.u8 reg1, reg3 vzip.u8 reg2, reg4 @@ -161,34 +153,30 @@ fname: xacc1, xacc2, xreg1, xreg2, xreg3, xreg4, xacc2lo, xacc2hi \ yacc1, yacc2, yreg1, yreg2, yreg3, yreg4, yacc2lo, yacc2hi - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - mov TMP4, X, asr #16 + add TMP1, TOP, TMP1, asl #1 + mov TMP2, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - add TMP3, TOP, TMP4, asl #1 - add TMP4, BOTTOM, TMP4, asl #1 - vld1.32 {xacc2lo[0]}, [TMP1] - vld1.32 {xacc2hi[0]}, [TMP3] - vld1.32 {xacc2lo[1]}, [TMP2] - vld1.32 {xacc2hi[1]}, [TMP4] + add TMP2, TOP, TMP2, asl #1 + vld1.32 {xacc2lo[0]}, [TMP1], STRIDE + vld1.32 {xacc2hi[0]}, [TMP2], STRIDE + vld1.32 {xacc2lo[1]}, [TMP1] + vld1.32 {xacc2hi[1]}, [TMP2] convert_0565_to_x888 xacc2, xreg3, xreg2, xreg1 - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - mov TMP4, X, asr #16 + add TMP1, TOP, TMP1, asl #1 + mov TMP2, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - add TMP3, TOP, TMP4, asl #1 - add TMP4, BOTTOM, TMP4, asl #1 - vld1.32 {yacc2lo[0]}, [TMP1] + add TMP2, TOP, TMP2, asl #1 + vld1.32 {yacc2lo[0]}, [TMP1], STRIDE vzip.u8 xreg1, xreg3 - vld1.32 {yacc2hi[0]}, [TMP3] + vld1.32 {yacc2hi[0]}, [TMP2], STRIDE vzip.u8 xreg2, xreg4 - vld1.32 {yacc2lo[1]}, [TMP2] + vld1.32 {yacc2lo[1]}, [TMP1] vzip.u8 xreg3, xreg4 - vld1.32 {yacc2hi[1]}, [TMP4] + vld1.32 {yacc2hi[1]}, [TMP2] vzip.u8 xreg1, xreg2 convert_0565_to_x888 yacc2, yreg3, yreg2, yreg1 vmull.u8 xacc1, xreg1, d28 @@ -252,6 +240,7 @@ fname: .else .error bilinear_load_mask_8 numpix is unsupported .endif + pld [MASK, #prefetch_offset] .endm .macro bilinear_load_mask mask_fmt, numpix, mask @@ -279,6 +268,7 @@ fname: .else .error bilinear_load_dst_8888 numpix is unsupported .endif + pld [OUT, #(prefetch_offset * 4)] .endm .macro bilinear_load_dst_8888_over numpix, dst0, dst1, dst01 @@ -303,7 +293,7 @@ fname: * For two pixel case * (r0, r1, x, x, g0, g1, x, x) x (m0, m1, m0, m1, m0, m1, m0, m1) * (b0, b1, x, x, a0, a1, x, x) x (m0, m1, m0, m1, m0, m1, m0, m1) - * We can do some optimizations for this including one pixel cases. + * We can do some optimizations for this including last pixel cases. */ .macro bilinear_duplicate_mask_x numpix, mask .endm @@ -497,8 +487,7 @@ fname: bilinear_load_dst dst_fmt, op, 1, d18, d19, q9 vmull.u8 q1, d0, d28 vmlal.u8 q1, d1, d29 - vshr.u16 d30, d24, #8 - /* 4 cycles bubble */ + /* 5 cycles bubble */ vshll.u16 q0, d2, #8 vmlsl.u16 q0, d2, d30 vmlal.u16 q0, d3, d30 @@ -525,18 +514,18 @@ fname: q1, q11, d0, d1, d20, d21, d22, d23 bilinear_load_mask mask_fmt, 2, d4 bilinear_load_dst dst_fmt, op, 2, d18, d19, q9 - vshr.u16 q15, q12, #8 - vadd.u16 q12, q12, q13 vshll.u16 q0, d2, #8 vmlsl.u16 q0, d2, d30 vmlal.u16 q0, d3, d30 vshll.u16 q10, d22, #8 vmlsl.u16 q10, d22, d31 vmlal.u16 q10, d23, d31 - vshrn.u32 d30, q0, #16 - vshrn.u32 d31, q10, #16 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q10, #16 bilinear_duplicate_mask mask_fmt, 2, d4 - vmovn.u16 d0, q15 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vmovn.u16 d0, q0 bilinear_interleave_src_dst \ mask_fmt, op, 2, d0, d1, q0, d18, d19, q9 bilinear_apply_mask_to_src \ @@ -554,8 +543,7 @@ fname: q1, q11, d0, d1, d20, d21, d22, d23 \ q3, q9, d4, d5, d16, d17, d18, d19 pld [TMP1, PF_OFFS] - vshr.u16 q15, q12, #8 - vadd.u16 q12, q12, q13 + sub TMP1, TMP1, STRIDE vshll.u16 q0, d2, #8 vmlsl.u16 q0, d2, d30 vmlal.u16 q0, d3, d30 @@ -567,9 +555,9 @@ fname: vmlsl.u16 q2, d6, d30 vmlal.u16 q2, d7, d30 vshll.u16 q8, d18, #8 - bilinear_load_mask mask_fmt, 4, d30 + bilinear_load_mask mask_fmt, 4, d22 bilinear_load_dst dst_fmt, op, 4, d2, d3, q1 - pld [TMP2, PF_OFFS] + pld [TMP1, PF_OFFS] vmlsl.u16 q8, d18, d31 vmlal.u16 q8, d19, d31 vadd.u16 q12, q12, q13 @@ -577,17 +565,19 @@ fname: vshrn.u32 d1, q10, #16 vshrn.u32 d4, q2, #16 vshrn.u32 d5, q8, #16 - bilinear_duplicate_mask mask_fmt, 4, d30 + bilinear_duplicate_mask mask_fmt, 4, d22 + vshr.u16 q15, q12, #8 vmovn.u16 d0, q0 vmovn.u16 d1, q2 + vadd.u16 q12, q12, q13 bilinear_interleave_src_dst \ mask_fmt, op, 4, d0, d1, q0, d2, d3, q1 bilinear_apply_mask_to_src \ - mask_fmt, 4, d0, d1, q0, d30, \ + mask_fmt, 4, d0, d1, q0, d22, \ q3, q8, q9, q10 bilinear_combine \ op, 4, d0, d1, q0, d2, d3, q1, \ - q3, q8, q9, q10, d22 + q3, q8, q9, q10, d23 bilinear_deinterleave_dst mask_fmt, op, 4, d0, d1, q0 bilinear_store_&dst_fmt 4, q2, q3 .endm @@ -610,6 +600,7 @@ pixman_asm_function fname PF_OFFS .req r7 TMP3 .req r8 TMP4 .req r9 + STRIDE .req r2 mov ip, sp push {r4, r5, r6, r7, r8, r9} @@ -617,6 +608,11 @@ pixman_asm_function fname ldmia ip, {WB, X, UX, WIDTH} mul PF_OFFS, PF_OFFS, UX + .set prefetch_offset, prefetch_distance + + sub STRIDE, BOTTOM, TOP + .unreq BOTTOM + cmp WIDTH, #0 ble 3f @@ -626,6 +622,8 @@ pixman_asm_function fname vdup.u8 d29, WB vadd.u16 d25, d25, d26 vadd.u16 q13, q13, q13 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 subs WIDTH, WIDTH, #4 blt 1f @@ -648,7 +646,6 @@ pixman_asm_function fname .unreq OUT .unreq TOP - .unreq BOTTOM .unreq WT .unreq WB .unreq X @@ -659,6 +656,7 @@ pixman_asm_function fname .unreq PF_OFFS .unreq TMP3 .unreq TMP4 + .unreq STRIDE .endfunc .endm @@ -682,6 +680,7 @@ pixman_asm_function fname PF_OFFS .req r8 TMP3 .req r9 TMP4 .req r10 + STRIDE .req r3 mov ip, sp push {r4, r5, r6, r7, r8, r9, r10, ip} @@ -689,6 +688,11 @@ pixman_asm_function fname ldmia ip, {WT, WB, X, UX, WIDTH} mul PF_OFFS, PF_OFFS, UX + .set prefetch_offset, prefetch_distance + + sub STRIDE, BOTTOM, TOP + .unreq BOTTOM + cmp WIDTH, #0 ble 3f @@ -698,6 +702,8 @@ pixman_asm_function fname vdup.u8 d29, WB vadd.u16 d25, d25, d26 vadd.u16 q13, q13, q13 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 subs WIDTH, WIDTH, #4 blt 1f @@ -720,7 +726,6 @@ pixman_asm_function fname .unreq OUT .unreq TOP - .unreq BOTTOM .unreq WT .unreq WB .unreq X @@ -732,6 +737,7 @@ pixman_asm_function fname .unreq PF_OFFS .unreq TMP3 .unreq TMP4 + .unreq STRIDE .endfunc .endm From whot at kemper.freedesktop.org Mon Oct 17 23:09:19 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Mon, 17 Oct 2011 23:09:19 -0700 (PDT) Subject: xf86-input-synaptics:master: 2 commit(s) Message-ID: <20111018060919.9ADBAC0001@kemper.freedesktop.org> Reporting from xf86-input-synaptics: xf86-input-synaptics driver Please visit: http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics Or get your own copy by using: git-clone git://anongit.freedesktop.org/xorg/driver/xf86-input-synaptics 2 commits against master at a15af628...: src/synaptics.c | 152 ++++++++++++++++++++++------------------------------- src/synapticsstr.h | 2 2 files changed, 66 insertions(+), 88 deletions(-) commit 26831a6eeac6762ad4d99532f62ebbab0827de10 Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Jun 9 20:03:10 2011 +0100 Scroll: Prepare ScrollData for smooth scrolling Convert ScrollData from up/down/left/right members for button presses, to more fine-grained delta_x and delta_y members, and move these to priv->scroll. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diffstat: src/synaptics.c | 135 ++++++++++++++++++------------------------------- src/synapticsstr.h | 2 2 files changed, 52 insertions(+), 85 deletions(-) gitweb url: http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics;a=commit;h=26831a6e commit 7c0361d4ec6b1f1325cb6551d0ee2e7f5cfae15b Author: Daniel Stone <daniel at fooishbar.org> Date: Thu Jun 9 20:03:05 2011 +0100 Adjust acceleration scheme for input ABI v14 v14 wants doubles, rather than floats, from acceleration schemes. Signed-off-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diffstat: src/synaptics.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) gitweb url: http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics;a=commit;h=26831a6e From whot at kemper.freedesktop.org Mon Oct 17 23:13:36 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Mon, 17 Oct 2011 23:13:36 -0700 (PDT) Subject: xf86-input-synaptics:master: 1 commit(s) Message-ID: <20111018061336.C94FAC0001@kemper.freedesktop.org> Reporting from xf86-input-synaptics: xf86-input-synaptics driver Please visit: http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics Or get your own copy by using: git-clone git://anongit.freedesktop.org/xorg/driver/xf86-input-synaptics Commit against master at 26831a6e...: commit cefc85ad44af340b3d2cad76ec1dc54ceba0558f Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 18 15:46:57 2011 +1000 Fix compiler warning - unused variable 'para' synaptics.c: In function 'post_scroll_events': synaptics.c:2426:26: warning: unused variable 'para' [-Wunused-variable] Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diffstat: src/synaptics.c | 1 - 1 file changed, 1 deletion(-) gitweb url: http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics;a=commit;h=cefc85ad From podain at kemper.freedesktop.org Tue Oct 18 06:18:22 2011 From: podain at kemper.freedesktop.org (Taekyun Kim) Date: Tue, 18 Oct 2011 06:18:22 -0700 (PDT) Subject: pixman: Branch 'master' Message-ID: <20111018131822.8B974C0001@kemper.freedesktop.org> pixman/pixman-arm-neon-asm.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 3d4d705d2ffa4aeab3dc02a23c2aadbea1374a3f Author: Taekyun Kim <tkq.kim at samsung.com> Date: Tue Oct 18 21:50:18 2011 +0900 ARM: NEON: Fix assembly typo error in src_n_8_8888 Binutils 2.21 does not complain about missing comma between ARM register and alignement specifier in vld/vst instructions which causes build error on binutils 2.20. diff --git a/pixman/pixman-arm-neon-asm.S b/pixman/pixman-arm-neon-asm.S index da8f054..87aae1d 100644 --- a/pixman/pixman-arm-neon-asm.S +++ b/pixman/pixman-arm-neon-asm.S @@ -1260,7 +1260,7 @@ generate_composite_function \ PF subges PF_CTL, PF_CTL, #0x10 vmull.u8 q11, d24, d3 PF ldrgeb DUMMY, [PF_MASK, MASK_STRIDE, lsl #mask_bpp_shift]! - vst4.8 {d28, d29, d30, d31}, [DST_W :128]! + vst4.8 {d28, d29, d30, d31}, [DST_W, :128]! vrsra.u16 q8, q8, #8 vrsra.u16 q9, q9, #8 vrsra.u16 q10, q10, #8 From ickle at kemper.freedesktop.org Tue Oct 18 07:35:36 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Tue, 18 Oct 2011 07:35:36 -0700 (PDT) Subject: xf86-video-intel: 20 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_glyphs.c src/sna/sna.h src/sna/sna_render.h Message-ID: <20111018143536.B890FC0001@kemper.freedesktop.org> src/sna/gen2_render.c | 47 +++++++--- src/sna/gen3_render.c | 226 +++++++++++++++++++++++++++++++++++++------------- src/sna/gen4_render.c | 119 ++++++++++++++++++++++++-- src/sna/gen5_render.c | 121 +++++++++++++++++++++++++- src/sna/gen6_render.c | 63 +++++++------ src/sna/kgem.c | 68 +++++++++------ src/sna/kgem.h | 3 src/sna/sna.h | 6 + src/sna/sna_accel.c | 136 +++++++++++++++++++++++++++--- src/sna/sna_blt.c | 37 +++++--- src/sna/sna_glyphs.c | 27 ++--- src/sna/sna_render.h | 1 12 files changed, 676 insertions(+), 178 deletions(-) New commits: commit 0b83abfb2bc3f65447205048ae0af1a94fa9ef15 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 14:43:37 2011 +0100 sna/gen6: Don't modify composite arguments whilst checking for BLT Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 2392c9b..badade0 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2592,18 +2592,15 @@ gen6_render_fill_boxes(struct sna *sna, dst->drawable.width > 8192 || dst->drawable.height > 8192 || !gen6_check_dst_format(format)) { - uint8_t alu = GXcopy; + uint8_t alu = -1; - if (op == PictOpClear) { + if (op == PictOpClear || (op == PictOpOutReverse && color->alpha >= 0xff00)) alu = GXclear; - pixel = 0; - op = PictOpSrc; - } - if (op == PictOpOver && color->alpha >= 0xff00) - op = PictOpSrc; + if (op == PictOpSrc || (op == PictOpOver && color->alpha >= 0xff00)) + alu = GXcopy; - if (op == PictOpSrc && + if (alu != -1 && sna_get_pixel_from_rgba(&pixel, color->red, color->green, commit ae7bd2bf70b42b8c12e5e5ae074891595827a1c0 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 11:54:05 2011 +0100 sna/blt: Move the conditional out of the fill-many hotpath Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 15b09bf..1597b1f 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -119,19 +119,15 @@ static bool sna_blt_fill_init(struct sna *sna, blt->bo[0] = bo; - blt->cmd = XY_SETUP_MONO_PATTERN_SL_BLT; - if (bpp == 32) - blt->cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; - pitch = bo->pitch; - if (kgem->gen >= 40 && bo->tiling) { - blt->cmd |= BLT_DST_TILED; + blt->cmd = XY_SCANLINE_BLT; + if (kgem->gen >= 40 && blt->bo[0]->tiling) { + blt->cmd |= 1 << 11; pitch >>= 2; } if (pitch > MAXSHORT) return FALSE; - blt->overwrites = alu == GXcopy || alu == GXclear; blt->br13 = 1<<31 | (fill_ROP[alu] << 16) | pitch; switch (bpp) { default: assert(0); @@ -141,6 +137,7 @@ static bool sna_blt_fill_init(struct sna *sna, } blt->pixel = pixel; + blt->bpp = bpp; kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_bo_fenced(kgem, bo, NULL) || @@ -160,7 +157,9 @@ static bool sna_blt_fill_init(struct sna *sna, } b = kgem->batch + kgem->nbatch; - b[0] = blt->cmd; + b[0] = XY_SETUP_MONO_PATTERN_SL_BLT; + if (bpp == 32) + b[0] |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; b[1] = blt->br13; b[2] = 0; b[3] = 0; @@ -202,7 +201,9 @@ static void sna_blt_fill_one(struct sna *sna, _kgem_set_mode(kgem, KGEM_BLT); b = kgem->batch + kgem->nbatch; - b[0] = blt->cmd; + b[0] = XY_SETUP_MONO_PATTERN_SL_BLT; + if (blt->bpp == 32) + b[0] |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; b[1] = blt->br13; b[2] = 0; b[3] = 0; @@ -219,9 +220,7 @@ static void sna_blt_fill_one(struct sna *sna, } b = kgem->batch + kgem->nbatch; - b[0] = XY_SCANLINE_BLT; - if (kgem->gen >= 40 && blt->bo[0]->tiling) - b[0] |= 1 << 11; + b[0] = blt->cmd; b[1] = (y << 16) | x; b[2] = ((y + height) << 16) | (x + width); kgem->nbatch += 3; diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 1cbd0f5..b4b4085 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -90,6 +90,7 @@ struct sna_composite_op { uint32_t inplace :1; uint32_t overwrites:1; + uint32_t bpp : 6; uint32_t cmd; uint32_t br13; commit 86f99379ee55b157634174c4c8aad61a30b4f57f Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 11:35:12 2011 +0100 sna/gen4: Add fill-one Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index fb60c39..2c988ff 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2370,9 +2370,9 @@ gen4_fill_bind_surfaces(struct sna *sna, const struct sna_composite_op *op) } static void -gen4_render_fill_one(struct sna *sna, - const struct sna_composite_op *op, - int x, int y, int w, int h) +gen4_render_fill_rectangle(struct sna *sna, + const struct sna_composite_op *op, + int x, int y, int w, int h) { if (!gen4_get_rectangles(sna, op, 1)) { gen4_fill_bind_surfaces(sna, op); @@ -2484,9 +2484,10 @@ gen4_render_fill_boxes(struct sna *sna, gen4_align_vertex(sna, &tmp); do { - gen4_render_fill_one(sna, &tmp, - box->x1, box->y1, - box->x2 - box->x1, box->y2 - box->y1); + gen4_render_fill_rectangle(sna, &tmp, + box->x1, box->y1, + box->x2 - box->x1, + box->y2 - box->y1); box++; } while (--n); @@ -2499,7 +2500,7 @@ static void gen4_render_fill_blt(struct sna *sna, const struct sna_fill_op *op, int16_t x, int16_t y, int16_t w, int16_t h) { - gen4_render_fill_one(sna, &op->base, x, y, w, h); + gen4_render_fill_rectangle(sna, &op->base, x, y, w, h); } static void @@ -2571,6 +2572,109 @@ gen4_render_fill(struct sna *sna, uint8_t alu, return TRUE; } +static Bool +gen4_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + +static Bool +gen4_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint8_t alu) +{ + struct sna_composite_op tmp; + +#if NO_FILL_ONE + return gen4_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); +#endif + + if (gen4_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + + /* Must use the BLT if we can't RENDER... */ + if (!(alu == GXcopy || alu == GXclear) || + dst->drawable.width > 8192 || dst->drawable.height > 8192) + return FALSE; + + if (alu == GXclear) + color = 0; + + tmp.op = color == 0 ? PictOpClear : PictOpSrc; + + tmp.dst.pixmap = dst; + tmp.dst.width = dst->drawable.width; + tmp.dst.height = dst->drawable.height; + tmp.dst.format = sna_format_for_depth(dst->drawable.depth); + tmp.dst.bo = bo; + tmp.dst.x = tmp.dst.y = 0; + + tmp.src.bo = + sna_render_get_solid(sna, + sna_rgba_for_color(color, + dst->drawable.depth)); + tmp.src.filter = SAMPLER_FILTER_NEAREST; + tmp.src.repeat = SAMPLER_EXTEND_REPEAT; + + tmp.mask.bo = NULL; + tmp.mask.filter = SAMPLER_FILTER_NEAREST; + tmp.mask.repeat = SAMPLER_EXTEND_NONE; + + tmp.is_affine = TRUE; + tmp.floats_per_vertex = 3; + tmp.has_component_alpha = 0; + tmp.need_magic_ca_pass = FALSE; + + tmp.u.gen4.wm_kernel = WM_KERNEL; + tmp.u.gen4.ve_id = 1; + + if (!kgem_check_bo(&sna->kgem, bo, NULL)) + _kgem_submit(&sna->kgem); + + gen4_fill_bind_surfaces(sna, &tmp); + gen4_align_vertex(sna, &tmp); + + if (!gen4_get_rectangles(sna, &tmp, 1)) { + gen4_fill_bind_surfaces(sna, &tmp); + gen4_get_rectangles(sna, &tmp, 1); + } + + DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2)); + OUT_VERTEX(x2, y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + + gen4_vertex_flush(sna); + kgem_bo_destroy(&sna->kgem, tmp.src.bo); + _kgem_set_mode(&sna->kgem, KGEM_RENDER); + + return TRUE; +} + static void gen4_render_flush(struct sna *sna) { @@ -2840,6 +2944,7 @@ Bool gen4_render_init(struct sna *sna) sna->render.fill_boxes = gen4_render_fill_boxes; sna->render.fill = gen4_render_fill; + sna->render.fill_one = gen4_render_fill_one; sna->render.flush = gen4_render_flush; sna->render.reset = gen4_render_reset; commit 26c082dbd3f89b987168d321f72e78db8c5ddc2c Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 10:50:53 2011 +0100 sna/gen6: Precompute floats_per_rect Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index f49cf31..2392c9b 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -1485,9 +1485,9 @@ inline static int gen6_get_rectangles(struct sna *sna, { int rem = vertex_space(sna); - if (rem < 3*op->floats_per_vertex) { + if (rem < op->floats_per_rect) { DBG(("flushing vbo for %s: %d < %d\n", - __FUNCTION__, rem, 3*op->floats_per_vertex)); + __FUNCTION__, rem, op->floats_per_rect)); rem = gen6_get_rectangles__flush(sna, op->need_magic_ca_pass); if (rem == 0) return 0; @@ -1497,8 +1497,8 @@ inline static int gen6_get_rectangles(struct sna *sna, !gen6_rectangle_begin(sna, op)) return 0; - if (want > 1 && want * op->floats_per_vertex*3 > rem) - want = rem / (3*op->floats_per_vertex); + if (want > 1 && want * op->floats_per_rect > rem) + want = rem / op->floats_per_rect; sna->render.vertex_index += 3*want; return want; @@ -1847,6 +1847,7 @@ gen6_render_video(struct sna *sna, tmp.is_affine = TRUE; tmp.floats_per_vertex = 3; + tmp.floats_per_rect = 9; if (is_planar_fourcc(frame->id)) { tmp.u.gen6.wm_kernel = GEN6_WM_KERNEL_VIDEO_PLANAR; @@ -2226,6 +2227,7 @@ gen6_render_composite(struct sna *sna, tmp->floats_per_vertex = 3 + !tmp->is_affine; } + tmp->floats_per_rect = 3 * tmp->floats_per_vertex; tmp->u.gen6.wm_kernel = gen6_choose_composite_kernel(tmp->op, @@ -2364,6 +2366,7 @@ gen6_render_copy_boxes(struct sna *sna, uint8_t alu, tmp.is_affine = TRUE; tmp.floats_per_vertex = 3; + tmp.floats_per_rect = 9; tmp.has_component_alpha = 0; tmp.need_magic_ca_pass = 0; @@ -2512,6 +2515,7 @@ gen6_render_copy(struct sna *sna, uint8_t alu, op->base.is_affine = true; op->base.floats_per_vertex = 3; + op->base.floats_per_rect = 9; op->base.u.gen6.wm_kernel = GEN6_WM_KERNEL_NOMASK; op->base.u.gen6.nr_surfaces = 2; @@ -2649,6 +2653,7 @@ gen6_render_fill_boxes(struct sna *sna, tmp.is_affine = TRUE; tmp.floats_per_vertex = 3; + tmp.floats_per_rect = 9; tmp.u.gen6.wm_kernel = GEN6_WM_KERNEL_NOMASK; tmp.u.gen6.nr_surfaces = 2; @@ -2775,6 +2780,7 @@ gen6_render_fill(struct sna *sna, uint8_t alu, op->base.is_affine = TRUE; op->base.floats_per_vertex = 3; + op->base.floats_per_rect = 9; op->base.u.gen6.wm_kernel = GEN6_WM_KERNEL_NOMASK; op->base.u.gen6.nr_surfaces = 2; @@ -2861,6 +2867,7 @@ gen6_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, tmp.is_affine = TRUE; tmp.floats_per_vertex = 3; + tmp.floats_per_rect = 9; tmp.has_component_alpha = 0; tmp.need_magic_ca_pass = FALSE; commit c69a7989b3c9cedc961e29b1a569b174207964ae Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 10:48:37 2011 +0100 sna/gen5: Add fill-one implementation Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index 516bc35..d246d01 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2571,6 +2571,112 @@ gen5_render_fill(struct sna *sna, uint8_t alu, return TRUE; } +static Bool +gen5_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint8_t alu) +{ + BoxRec box; + + box.x1 = x1; + box.y1 = y1; + box.x2 = x2; + box.y2 = y2; + + return sna_blt_fill_boxes(sna, alu, + bo, dst->drawable.bitsPerPixel, + color, &box, 1); +} + +static Bool +gen5_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, + uint32_t color, + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint8_t alu) +{ + struct sna_composite_op tmp; + +#if NO_FILL_ONE + return gen5_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); +#endif + + /* Prefer to use the BLT if already engaged */ + if (sna->kgem.mode != KGEM_RENDER && + gen5_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu)) + return TRUE; + + /* Must use the BLT if we can't RENDER... */ + if (!(alu == GXcopy || alu == GXclear) || + dst->drawable.width > 8192 || dst->drawable.height > 8192) + return gen5_render_fill_one_try_blt(sna, dst, bo, color, + x1, y1, x2, y2, alu); + + if (alu == GXclear) + color = 0; + + tmp.op = color == 0 ? PictOpClear : PictOpSrc; + + tmp.dst.pixmap = dst; + tmp.dst.width = dst->drawable.width; + tmp.dst.height = dst->drawable.height; + tmp.dst.format = sna_format_for_depth(dst->drawable.depth); + tmp.dst.bo = bo; + tmp.dst.x = tmp.dst.y = 0; + + tmp.src.bo = + sna_render_get_solid(sna, + sna_rgba_for_color(color, + dst->drawable.depth)); + tmp.src.filter = SAMPLER_FILTER_NEAREST; + tmp.src.repeat = SAMPLER_EXTEND_REPEAT; + + tmp.mask.bo = NULL; + tmp.mask.filter = SAMPLER_FILTER_NEAREST; + tmp.mask.repeat = SAMPLER_EXTEND_NONE; + + tmp.is_affine = TRUE; + tmp.floats_per_vertex = 3; + tmp.has_component_alpha = 0; + tmp.need_magic_ca_pass = FALSE; + + tmp.u.gen5.wm_kernel = WM_KERNEL; + tmp.u.gen5.ve_id = 1; + + if (!kgem_check_bo(&sna->kgem, bo, NULL)) + _kgem_submit(&sna->kgem); + + gen5_fill_bind_surfaces(sna, &tmp); + gen5_align_vertex(sna, &tmp); + + if (!gen5_get_rectangles(sna, &tmp, 1)) { + gen5_fill_bind_surfaces(sna, &tmp); + gen5_get_rectangles(sna, &tmp, 1); + } + + DBG((" (%d, %d), (%d, %d)\n", x1, y1, x2, y2)); + OUT_VERTEX(x2, y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(x1, y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + + gen5_vertex_flush(sna); + kgem_bo_destroy(&sna->kgem, tmp.src.bo); + _kgem_set_mode(&sna->kgem, KGEM_RENDER); + + return TRUE; +} + static void gen5_render_flush(struct sna *sna) { @@ -2863,6 +2969,7 @@ Bool gen5_render_init(struct sna *sna) sna->render.fill_boxes = gen5_render_fill_boxes; sna->render.fill = gen5_render_fill; + sna->render.fill_one = gen5_render_fill_one; sna->render.flush = gen5_render_flush; sna->render.reset = gen5_render_reset; commit 26a1918290b2d23de72a67805fe5e766da0c5309 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 10:42:48 2011 +0100 sna/gen6: Try continuing with the BLT if the last batch was also BLT In the vain hope of reducing switching between rings and introducing stalls between batches. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 147693d..f49cf31 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2086,7 +2086,7 @@ gen6_composite_set_target(struct sna_composite_op *op, PicturePtr dst) static Bool try_blt(struct sna *sna, int width, int height) { - if (sna->kgem.mode == KGEM_BLT) { + if (sna->kgem.ring == KGEM_BLT) { DBG(("%s: already performing BLT\n", __FUNCTION__)); return TRUE; } @@ -2125,7 +2125,7 @@ gen6_render_composite(struct sna *sna, #endif DBG(("%s: %dx%d, current mode=%d\n", __FUNCTION__, - width, height, sna->kgem.mode)); + width, height, sna->kgem.ring)); if (mask == NULL && try_blt(sna, width, height) && @@ -2318,7 +2318,7 @@ gen6_render_copy_boxes(struct sna *sna, uint8_t alu, __FUNCTION__, src_dx, src_dy, dst_dx, dst_dy, n, alu, src_bo == dst_bo)); - if (sna->kgem.mode == KGEM_BLT && + if (sna->kgem.ring == KGEM_BLT && sna_blt_compare_depth(&src->drawable, &dst->drawable) && sna_blt_copy_boxes(sna, alu, src_bo, src_dx, src_dy, @@ -2473,7 +2473,7 @@ gen6_render_copy(struct sna *sna, uint8_t alu, src->drawable.width, src->drawable.height, dst->drawable.width, dst->drawable.height)); - if (sna->kgem.mode == KGEM_BLT && + if (sna->kgem.ring == KGEM_BLT && sna_blt_compare_depth(&src->drawable, &dst->drawable) && sna_blt_copy(sna, alu, src_bo, dst_bo, @@ -2584,7 +2584,7 @@ gen6_render_fill_boxes(struct sna *sna, return FALSE; } - if (sna->kgem.mode != KGEM_RENDER || + if (sna->kgem.ring != KGEM_RENDER || dst->drawable.width > 8192 || dst->drawable.height > 8192 || !gen6_check_dst_format(format)) { @@ -2741,7 +2741,7 @@ gen6_render_fill(struct sna *sna, uint8_t alu, op); #endif - if (sna->kgem.mode != KGEM_RENDER && + if (sna->kgem.ring != KGEM_RENDER && sna_blt_fill(sna, alu, dst_bo, dst->drawable.bitsPerPixel, color, @@ -2825,7 +2825,7 @@ gen6_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, #endif /* Prefer to use the BLT if already engaged */ - if (sna->kgem.mode != KGEM_RENDER && + if (sna->kgem.ring != KGEM_RENDER && gen6_render_fill_one_try_blt(sna, dst, bo, color, x1, y1, x2, y2, alu)) return TRUE; @@ -2912,6 +2912,8 @@ gen6_render_context_switch(struct kgem *kgem, if (!new_mode) return; + DBG(("%s: from %d to %d\n", __FUNCTION__, kgem->mode, new_mode)); + if (kgem->mode) _kgem_submit(kgem); commit 4b1398f26d4de44167096c6548ff7384c24d5e06 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 00:29:18 2011 +0100 sna/gen6: Micro-optimise gen6_rectangle_begin We can only emit state between primitives, ergo we need only check for state updates if we've finished the vbo or are starting a new operation. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 2ba7c39..147693d 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -1448,25 +1448,19 @@ static void gen6_emit_primitive(struct sna *sna) static bool gen6_rectangle_begin(struct sna *sna, const struct sna_composite_op *op) { - int id = op->u.gen6.ve_id; + int id = 1 << op->u.gen6.ve_id; int ndwords; - ndwords = 0; - if ((sna->render_state.gen6.vb_id & (1 << id)) == 0) + ndwords = op->need_magic_ca_pass ? 60 : 6; + if ((sna->render_state.gen6.vb_id & id) == 0) ndwords += 5; - if (sna->render_state.gen6.vertex_offset == 0) - ndwords += op->need_magic_ca_pass ? 60 : 6; - if (ndwords == 0) - return true; - if (!kgem_check_batch(&sna->kgem, ndwords)) return false; - if ((sna->render_state.gen6.vb_id & (1 << id)) == 0) + if ((sna->render_state.gen6.vb_id & id) == 0) gen6_emit_vertex_buffer(sna, op); - if (sna->render_state.gen6.vertex_offset == 0) - gen6_emit_primitive(sna); + gen6_emit_primitive(sna); return true; } @@ -1499,7 +1493,8 @@ inline static int gen6_get_rectangles(struct sna *sna, return 0; } - if (!gen6_rectangle_begin(sna, op)) + if (sna->render_state.gen6.vertex_offset == 0 && + !gen6_rectangle_begin(sna, op)) return 0; if (want > 1 && want * op->floats_per_vertex*3 > rem) commit b2d842df5e3198dab401fbd450d4af83d44917dd Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 23:34:19 2011 +0100 sna/gen2: Precompute floats-per-rect Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 041b4c0..6b30069 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -899,7 +899,7 @@ inline static int gen2_get_rectangles(struct sna *sna, assert(op->floats_per_vertex); need = 1; - size = 3*op->floats_per_vertex; + size = op->floats_per_rect; if (op->need_magic_ca_pass) need += 6 + size*sna->render.vertex_index, size *= 2; @@ -929,7 +929,7 @@ inline static int gen2_get_rectangles(struct sna *sna, want = rem / size; assert(want); - sna->render.vertex_index += 3*want*op->floats_per_vertex; + sna->render.vertex_index += want*op->floats_per_rect; return want; } @@ -1348,6 +1348,7 @@ gen2_render_composite(struct sna *sna, tmp->floats_per_vertex += tmp->src.is_affine ? 2 : 3; if (tmp->mask.bo) tmp->floats_per_vertex += tmp->mask.is_affine ? 2 : 3; + tmp->floats_per_rect = 3*tmp->floats_per_vertex; tmp->prim_emit = gen2_emit_composite_primitive; if (tmp->mask.bo) { @@ -1756,6 +1757,7 @@ gen2_render_composite_spans(struct sna *sna, } } } + tmp->base.floats_per_rect = 3*tmp->base.floats_per_vertex; tmp->box = gen2_render_composite_spans_box; tmp->boxes = gen2_render_composite_spans_boxes; @@ -1954,6 +1956,7 @@ gen2_render_fill_boxes(struct sna *sna, tmp.dst.format = format; tmp.dst.bo = dst_bo; tmp.floats_per_vertex = 2; + tmp.floats_per_rect = 6; if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) kgem_submit(&sna->kgem); @@ -2079,6 +2082,7 @@ gen2_render_fill(struct sna *sna, uint8_t alu, tmp->base.dst.format = sna_format_for_depth(dst->drawable.depth); tmp->base.dst.bo = dst_bo; tmp->base.floats_per_vertex = 2; + tmp->base.floats_per_rect = 6; tmp->base.src.u.gen2.pixel = sna_rgba_for_color(color, dst->drawable.depth); @@ -2156,6 +2160,7 @@ gen2_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, tmp.dst.format = sna_format_for_depth(dst->drawable.depth); tmp.dst.bo = bo; tmp.floats_per_vertex = 2; + tmp.floats_per_rect = 6; tmp.need_magic_ca_pass = false; tmp.src.u.gen2.pixel = @@ -2325,6 +2330,7 @@ gen2_render_copy_boxes(struct sna *sna, uint8_t alu, tmp.dst.bo = dst_bo; tmp.floats_per_vertex = 4; + tmp.floats_per_rect = 12; gen2_render_copy_setup_source(&tmp.src, src, src_bo); gen2_emit_copy_state(sna, &tmp); @@ -2450,6 +2456,7 @@ gen2_render_copy(struct sna *sna, uint8_t alu, gen2_render_copy_setup_source(&tmp->base.src, src, src_bo); tmp->base.floats_per_vertex = 4; + tmp->base.floats_per_rect = 12; if (!kgem_check_bo(&sna->kgem, dst_bo, src_bo, NULL)) kgem_submit(&sna->kgem); commit 729f1ec7869167ff91fa969d06dbdfbf0e8b4126 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 23:20:20 2011 +0100 sna/gen2: Prefer to use the BLT Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 34c4432..041b4c0 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -53,10 +53,8 @@ #define NO_FILL_ONE 0 #define NO_FILL_BOXES 0 -#define PREFER_3D_COPY 0 -#define PREFER_3D_COPY_BOXES 0 -#define PREFER_3D_FILL 0 -#define PREFER_3D_FILL_BOXES 0 +#define PREFER_BLT_FILL 1 +#define PREFER_BLT_COPY 1 #define BATCH(v) batch_emit(sna, v) #define BATCH_F(v) batch_emit_float(sna, v) @@ -1220,7 +1218,7 @@ try_blt(struct sna *sna, { uint32_t color; - if (sna->kgem.mode == KGEM_BLT) { + if (sna->kgem.mode != KGEM_RENDER) { DBG(("%s: already performing BLT\n", __FUNCTION__)); return TRUE; } @@ -1875,6 +1873,24 @@ gen2_render_fill_boxes_try_blt(struct sna *sna, pixel, box, n); } +static inline Bool prefer_blt_fill(struct sna *sna) +{ +#if PREFER_BLT_FILL + return true; +#else + return sna->kgem.mode != KGEM_RENDER; +#endif +} + +static inline Bool prefer_blt_copy(struct sna *sna) +{ +#if PREFER_BLT_COPY + return true; +#else + return sna->kgem.mode != KGEM_RENDER; +#endif +} + static Bool gen2_render_fill_boxes(struct sna *sna, CARD8 op, @@ -1910,7 +1926,7 @@ gen2_render_fill_boxes(struct sna *sna, dst, dst_bo, box, n); - if (!PREFER_3D_FILL_BOXES && sna->kgem.mode != KGEM_RENDER && + if (prefer_blt_fill(sna) && gen2_render_fill_boxes_try_blt(sna, op, format, color, dst, dst_bo, box, n)) @@ -2040,7 +2056,7 @@ gen2_render_fill(struct sna *sna, uint8_t alu, #endif /* Prefer to use the BLT if already engaged */ - if (!PREFER_3D_FILL && sna->kgem.mode != KGEM_RENDER && + if (prefer_blt_fill(sna) && sna_blt_fill(sna, alu, dst_bo, dst->drawable.bitsPerPixel, color, @@ -2115,7 +2131,7 @@ gen2_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, #endif /* Prefer to use the BLT if already engaged */ - if (!PREFER_3D_FILL && sna->kgem.mode != KGEM_RENDER && + if (prefer_blt_fill(sna) && gen2_render_fill_one_try_blt(sna, dst, bo, color, x1, y1, x2, y2, alu)) return TRUE; @@ -2267,7 +2283,7 @@ gen2_render_copy_boxes(struct sna *sna, uint8_t alu, DBG(("%s (%d, %d)->(%d, %d) x %d\n", __FUNCTION__, src_dx, src_dy, dst_dx, dst_dy, n)); - if (!PREFER_3D_COPY_BOXES && + if (prefer_blt_copy(sna) && sna_blt_compare_depth(&src->drawable, &dst->drawable) && sna_blt_copy_boxes(sna, alu, src_bo, src_dx, src_dy, @@ -2403,7 +2419,7 @@ gen2_render_copy(struct sna *sna, uint8_t alu, #endif /* Prefer to use the BLT */ - if (!PREFER_3D_COPY && sna->kgem.mode != KGEM_RENDER && + if (prefer_blt_copy(sna) && sna_blt_compare_depth(&src->drawable, &dst->drawable) && sna_blt_copy(sna, alu, src_bo, dst_bo, commit adef3a56cde1210554dc8327baa37c36fc5f18e3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 23:08:32 2011 +0100 sna/gen3: Prefer to use the BLT where possible for composite ops Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 4dd027f..90797d7 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -2127,7 +2127,7 @@ try_blt(struct sna *sna, PicturePtr source, int width, int height) { - if (sna->kgem.mode == KGEM_BLT) { + if (sna->kgem.mode != KGEM_RENDER) { DBG(("%s: already performing BLT\n", __FUNCTION__)); return TRUE; } commit f40e6ab50b264ef7eb7750f72ab7418c0d3dc9c1 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 23:06:30 2011 +0100 sna/gen3: Prefer to use the BLT to clear the scratch glyph pixmaps Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index bae6505..4dd027f 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -49,8 +49,11 @@ #define NO_COPY 0 #define NO_COPY_BOXES 0 #define NO_FILL 0 +#define NO_FILL_ONE 0 #define NO_FILL_BOXES 0 +#define PREFER_BLT_FILL 1 + enum { SHADER_NONE = 0, SHADER_ZERO, @@ -2966,10 +2969,9 @@ gen3_emit_video_state(struct sna *sna, S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT)); - OUT_BATCH((2 << S6_DEPTH_TEST_FUNC_SHIFT) | - (2 << S6_CBUF_SRC_BLEND_FACT_SHIFT) | + OUT_BATCH((2 << S6_CBUF_SRC_BLEND_FACT_SHIFT) | (1 << S6_CBUF_DST_BLEND_FACT_SHIFT) | - S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT)); + S6_COLOR_WRITE_ENABLE); sna->render_state.gen3.last_blend = 0; sna->render_state.gen3.last_sampler = 0; @@ -3663,6 +3665,15 @@ gen3_render_fill_boxes_try_blt(struct sna *sna, pixel, box, n); } +static inline Bool prefer_fill_blt(struct sna *sna) +{ +#if PREFER_BLT_FILL + return true; +#else + return sna->kgem.mode != KGEM_RENDER; +#endif +} + static Bool gen3_render_fill_boxes(struct sna *sna, CARD8 op, @@ -3698,7 +3709,7 @@ gen3_render_fill_boxes(struct sna *sna, dst, dst_bo, box, n); - if (sna->kgem.mode != KGEM_RENDER && + if (prefer_fill_blt(sna) && gen3_render_fill_boxes_try_blt(sna, op, format, color, dst, dst_bo, box, n)) @@ -3803,7 +3814,7 @@ gen3_render_fill(struct sna *sna, uint8_t alu, #endif /* Prefer to use the BLT if already engaged */ - if (sna->kgem.mode != KGEM_RENDER && + if (prefer_fill_blt(sna) && sna_blt_fill(sna, alu, dst_bo, dst->drawable.bitsPerPixel, color, @@ -3875,13 +3886,13 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, { struct sna_composite_op tmp; -#if NO_FILL_BOXES +#if NO_FILL_ONE return gen3_render_fill_one_try_blt(sna, dst, bo, color, x1, y1, x2, y2, alu); #endif /* Prefer to use the BLT if already engaged */ - if (sna->kgem.mode != KGEM_RENDER && + if (prefer_fill_blt(sna) && gen3_render_fill_one_try_blt(sna, dst, bo, color, x1, y1, x2, y2, alu)) return TRUE; @@ -3905,10 +3916,17 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, tmp.floats_per_vertex = 2; tmp.floats_per_rect = 6; - tmp.src.u.gen3.type = SHADER_CONSTANT; - tmp.src.u.gen3.mode = - sna_rgba_for_color(color, dst->drawable.depth); - tmp.mask.u.gen3.mode = SHADER_NONE; + color = sna_rgba_for_color(color, dst->drawable.depth); + if (color == 0) + tmp.src.u.gen3.type = SHADER_ZERO; + else if (color == 0xff000000) + tmp.src.u.gen3.type = SHADER_BLACK; + else if (color == 0xffffffff) + tmp.src.u.gen3.type = SHADER_WHITE; + else + tmp.src.u.gen3.type = SHADER_CONSTANT; + tmp.src.u.gen3.mode = color; + tmp.mask.u.gen3.type = SHADER_NONE; tmp.u.gen3.num_constants = 0; if (!kgem_check_bo(&sna->kgem, bo, NULL)) { diff --git a/src/sna/kgem.c b/src/sna/kgem.c index a11e955..4d876db 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1313,30 +1313,29 @@ int kgem_choose_tiling(struct kgem *kgem, int tiling, int width, int height, int if (tiling < 0) return tiling; - if (tiling && width * bpp > 8 * 4096) { + if (tiling == I915_TILING_Y && height <= 16) { + DBG(("%s: too short [%d] for TILING_Y\n", + __FUNCTION__,height)); + tiling = I915_TILING_X; + } + if (tiling && width * bpp >= 8 * 4096) { DBG(("%s: TLB miss between lines %dx%d (pitch=%d), forcing tiling %d\n", __FUNCTION__, width, height, width*bpp/8, tiling)); return -tiling; } + if (tiling == I915_TILING_X && height < 4) { + DBG(("%s: too short [%d] for TILING_X\n", + __FUNCTION__, height)); + tiling = I915_TILING_NONE; + } /* Before the G33, we only have a small GTT to play with and tiled * surfaces always require full fence regions and so cause excessive * aperture thrashing. */ if (kgem->gen < 33) { - if (tiling == I915_TILING_Y && height < 16) { - DBG(("%s: too short [%d] for TILING_Y\n", - __FUNCTION__,height)); - tiling = I915_TILING_X; - } - if (tiling == I915_TILING_X && height < 4) { - DBG(("%s: too short [%d] for TILING_X\n", - __FUNCTION__, height)); - tiling = I915_TILING_NONE; - } - if (tiling == I915_TILING_X && width * bpp < 8*512/2) { DBG(("%s: too thin [%d] for TILING_X\n", __FUNCTION__, width)); diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index 4db5baf..13b0cca 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -651,19 +651,16 @@ next_glyph: return TRUE; } -static Bool -clear_pixmap(struct sna *sna, PixmapPtr pixmap, PictFormat format) +static void +clear_pixmap(struct sna *sna, PixmapPtr pixmap) { - BoxRec box; - xRenderColor color = { 0 }; - - box.x1 = box.y1 = 0; - box.x2 = pixmap->drawable.width; - box.y2 = pixmap->drawable.height; - - return sna->render.fill_boxes(sna, PictOpClear, format, &color, - pixmap, sna_pixmap_get_bo(pixmap), - &box, 1); + struct sna_pixmap *priv = sna_pixmap(pixmap); + assert(priv->gpu_only); + sna->render.fill_one(sna, pixmap, priv->gpu_bo, 0, + 0, 0, + pixmap->drawable.width, + pixmap->drawable.height, + GXclear); } static Bool @@ -742,11 +739,7 @@ glyphs_via_mask(struct sna *sna, return FALSE; ValidatePicture(mask); - - if (!clear_pixmap(sna, pixmap, mask->format)) { - FreePicture(mask, 0); - return FALSE; - } + clear_pixmap(sna, pixmap); memset(&tmp, 0, sizeof(tmp)); glyph_atlas = NULL; commit 941e3504e049be8af50ca9df2d0aafe9eb477983 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 19:51:33 2011 +0100 sna: Some more debug output for request/bo retirement Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index a95ce3d..a11e955 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -183,10 +183,22 @@ static int gem_read(int fd, uint32_t handle, const void *dst, int length) return drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread); } +static bool +kgem_busy(struct kgem *kgem, int handle) +{ + struct drm_i915_gem_busy busy; + + busy.handle = handle; + busy.busy = !kgem->wedged; + (void)drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy); + + return busy.busy; +} + Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo, const void *data, int length) { - assert(!gem_busy(kgem->fd, bo->handle)); + assert(!kgem_busy(kgem, bo->handle)); if (gem_write(kgem->fd, bo->handle, 0, length, data)) return FALSE; @@ -213,18 +225,6 @@ static uint32_t gem_create(int fd, int size) } static bool -kgem_busy(struct kgem *kgem, int handle) -{ - struct drm_i915_gem_busy busy; - - busy.handle = handle; - busy.busy = !kgem->wedged; - (void)drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy); - - return busy.busy; -} - -static bool gem_madvise(int fd, uint32_t handle, uint32_t state) { struct drm_i915_gem_madvise madv; @@ -570,6 +570,7 @@ static void __kgem_bo_destroy(struct kgem *kgem, struct kgem_bo *bo) list_add(&bo->request, &kgem->flushing); list_move(&bo->list, active(kgem, bo->size)); } else { + assert(bo->gpu == 0); list_move(&bo->list, inactive(kgem, bo->size)); } @@ -593,10 +594,14 @@ void kgem_retire(struct kgem *kgem) { struct kgem_bo *bo, *next; + DBG(("%s\n", __FUNCTION__)); + list_for_each_entry_safe(bo, next, &kgem->flushing, request) { if (kgem_busy(kgem, bo->handle)) break; + DBG(("%s: moving %d from flush to inactive\n", + __FUNCTION__, bo->handle)); bo->needs_flush = 0; bo->gpu = false; list_move(&bo->list, inactive(kgem, bo->size)); @@ -612,6 +617,9 @@ void kgem_retire(struct kgem *kgem) if (kgem_busy(kgem, rq->bo->handle)) break; + DBG(("%s: request %d complete\n", + __FUNCTION__, rq->bo->handle)); + while (!list_is_empty(&rq->buffers)) { bo = list_first_entry(&rq->buffers, struct kgem_bo, @@ -629,11 +637,17 @@ void kgem_retire(struct kgem *kgem) if (bo->refcnt == 0) { assert(bo->deleted); if (bo->needs_flush) { + DBG(("%s: moving %d to flushing\n", + __FUNCTION__, bo->handle)); list_add(&bo->request, &kgem->flushing); } else if (bo->reusable) { + DBG(("%s: moving %d to inactive\n", + __FUNCTION__, bo->handle)); list_move(&bo->list, inactive(kgem, bo->size)); } else { + DBG(("%s: closing %d\n", + __FUNCTION__, bo->handle)); gem_close(kgem->fd, bo->handle); free(bo); } @@ -644,6 +658,7 @@ void kgem_retire(struct kgem *kgem) assert(rq->bo->refcnt == 0); if (gem_madvise(kgem->fd, rq->bo->handle, I915_MADV_DONTNEED)) { rq->bo->deleted = 1; + assert(rq->bo->gpu == 0); list_move(&rq->bo->list, inactive(kgem, rq->bo->size)); } else { @@ -915,6 +930,7 @@ void _kgem_submit(struct kgem *kgem) kgem_fixup_self_relocs(kgem, rq->bo); kgem_finish_partials(kgem); + assert(rq->bo->gpu == 0); if (kgem_batch_write(kgem, handle) == 0) { struct drm_i915_gem_execbuffer2 execbuf; int ret; @@ -1210,6 +1226,7 @@ search_linear_cache(struct kgem *kgem, unsigned int size, bool use_active) use_active ? "active" : "inactive")); assert(bo->refcnt == 0); assert(bo->reusable); + assert(use_active || bo->gpu == 0); //assert(use_active || !kgem_busy(kgem, bo->handle)); return bo; } @@ -1512,6 +1529,7 @@ skip_active_search: bo->pitch, bo->tiling, bo->handle, bo->unique_id)); assert(bo->refcnt == 0); assert(bo->reusable); + assert((flags & CREATE_INACTIVE) == 0 || bo->gpu == 0); assert((flags & CREATE_INACTIVE) == 0 || !kgem_busy(kgem, bo->handle)); return kgem_bo_reference(bo); commit 1d82fe3e528578d11d2a258b586b67c807eb7cb4 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 19:47:03 2011 +0100 sna: Only retire the flush handler if nothing was submitted within the period Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index d27ba78..a95ce3d 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -186,6 +186,8 @@ static int gem_read(int fd, uint32_t handle, const void *dst, int length) Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo, const void *data, int length) { + assert(!gem_busy(kgem->fd, bo->handle)); + if (gem_write(kgem->fd, bo->handle, 0, length, data)) return FALSE; @@ -1022,6 +1024,7 @@ void _kgem_submit(struct kgem *kgem) kgem_cleanup(kgem); kgem_reset(kgem); + kgem->busy = 1; } void kgem_throttle(struct kgem *kgem) diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 988281c..a43a712 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -105,6 +105,7 @@ struct kgem { uint32_t flush:1; uint32_t need_expire:1; uint32_t need_purge:1; + uint32_t busy:1; uint32_t has_vmap :1; uint32_t has_relaxed_fencing :1; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index b58cfc8..4f5c152 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4064,13 +4064,15 @@ static bool sna_accel_flush(struct sna *sna) bool nothing_to_do = priv->cpu_damage == NULL && priv->gpu_bo->rq == NULL; - DBG(("%s (time=%ld), nothing_to_do=%d\n", - __FUNCTION__, (long)GetTimeInMillis(), nothing_to_do)); + DBG(("%s (time=%ld), nothing_to_do=%d, busy? %d\n", + __FUNCTION__, (long)GetTimeInMillis(), + nothing_to_do, sna->kgem.busy)); - if (nothing_to_do) + if (nothing_to_do && !sna->kgem.busy) _sna_accel_disarm_timer(sna, FLUSH_TIMER); else sna_pixmap_move_to_gpu(priv->pixmap); + sna->kgem.busy = 0; kgem_bo_flush(&sna->kgem, priv->gpu_bo); return !nothing_to_do; } commit 7758e333409409393c4c974adb2831a7b5b18fe4 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 19:32:44 2011 +0100 sna/gen3: Use immediates for black/white solid sources Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 11b56ac..bae6505 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -54,6 +54,8 @@ enum { SHADER_NONE = 0, SHADER_ZERO, + SHADER_BLACK, + SHADER_WHITE, SHADER_CONSTANT, SHADER_LINEAR, SHADER_RADIAL, @@ -620,6 +622,8 @@ gen3_emit_composite_texcoord(struct sna *sna, case SHADER_OPACITY: case SHADER_NONE: case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: case SHADER_CONSTANT: break; @@ -843,6 +847,8 @@ gen3_composite_emit_shader(struct sna *sna, case SHADER_OPACITY: assert(0); case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: break; case SHADER_CONSTANT: gen3_fs_dcl(FS_T8); @@ -858,9 +864,16 @@ gen3_composite_emit_shader(struct sna *sna, } if (mask == NULL) { - if (src->u.gen3.type == SHADER_ZERO) { + switch (src->u.gen3.type) { + case SHADER_ZERO: gen3_fs_mov(FS_OC, gen3_fs_operand_zero()); goto done; + case SHADER_BLACK: + gen3_fs_mov(FS_OC, gen3_fs_operand(FS_R0, ZERO, ZERO, ZERO, ONE)); + goto done; + case SHADER_WHITE: + gen3_fs_mov(FS_OC, gen3_fs_operand_one()); + goto done; } if (src->alpha_fixup && dst_is_alpha) { gen3_fs_mov(FS_OC, gen3_fs_operand_one()); @@ -893,7 +906,10 @@ gen3_composite_emit_shader(struct sna *sna, case SHADER_NONE: case SHADER_CONSTANT: + case SHADER_WHITE: + case SHADER_BLACK: case SHADER_ZERO: + assert(0); break; } @@ -930,6 +946,8 @@ gen3_composite_emit_shader(struct sna *sna, break; case SHADER_NONE: case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: assert(0); break; } @@ -962,6 +980,8 @@ gen3_composite_emit_shader(struct sna *sna, case SHADER_CONSTANT: case SHADER_NONE: case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: break; } if (src->alpha_fixup) @@ -991,20 +1011,36 @@ gen3_composite_emit_shader(struct sna *sna, break; case SHADER_OPACITY: - if (dst_is_alpha) { - gen3_fs_mul(out_reg, - gen3_fs_operand(src_reg, W, W, W, W), - gen3_fs_operand(FS_T0 + t, X, X, X, X)); - } else { - gen3_fs_mul(out_reg, - gen3_fs_operand(src_reg, X, Y, Z, W), - gen3_fs_operand(FS_T0 + t, X, X, X, X)); + switch (src->u.gen3.type) { + case SHADER_BLACK: + case SHADER_WHITE: + if (dst_is_alpha || src->u.gen3.type == SHADER_WHITE) { + gen3_fs_mov(out_reg, + gen3_fs_operand(FS_T0 + t, X, X, X, X)); + } else { + gen3_fs_mov(out_reg, + gen3_fs_operand(FS_T0 + t, ZERO, ZERO, ZERO, X)); + } + break; + default: + if (dst_is_alpha) { + gen3_fs_mul(out_reg, + gen3_fs_operand(src_reg, W, W, W, W), + gen3_fs_operand(FS_T0 + t, X, X, X, X)); + } else { + gen3_fs_mul(out_reg, + gen3_fs_operand(src_reg, X, Y, Z, W), + gen3_fs_operand(FS_T0 + t, X, X, X, X)); + } } goto mask_done; case SHADER_CONSTANT: - case SHADER_NONE: case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: + assert(0); + case SHADER_NONE: break; } if (mask->alpha_fixup) @@ -1013,9 +1049,18 @@ gen3_composite_emit_shader(struct sna *sna, gen3_fs_mov(mask_reg, gen3_fs_operand(mask_reg, Z, Y, X, W)); if (dst_is_alpha) { - gen3_fs_mul(out_reg, - gen3_fs_operand(src_reg, W, W, W, W), - gen3_fs_operand(mask_reg, W, W, W, W)); + switch (src->u.gen3.type) { + case SHADER_BLACK: + case SHADER_WHITE: + gen3_fs_mov(out_reg, + gen3_fs_operand(mask_reg, W, W, W, W)); + break; + default: + gen3_fs_mul(out_reg, + gen3_fs_operand(src_reg, W, W, W, W), + gen3_fs_operand(mask_reg, W, W, W, W)); + break; + } } else { /* If component alpha is active in the mask and the blend * operation uses the source alpha, then we know we don't @@ -1028,18 +1073,43 @@ gen3_composite_emit_shader(struct sna *sna, * source value (src.X * mask.A). */ if (op->has_component_alpha) { - if (gen3_blend_op[blend].src_alpha) - gen3_fs_mul(out_reg, - gen3_fs_operand(src_reg, W, W, W, W), - gen3_fs_operand_reg(mask_reg)); - else + switch (src->u.gen3.type) { + case SHADER_WHITE: + case SHADER_BLACK: + if (gen3_blend_op[blend].src_alpha) + gen3_fs_mov(out_reg, + gen3_fs_operand_reg(mask_reg)); + else + gen3_fs_mov(out_reg, + gen3_fs_operand(mask_reg, ZERO, ZERO, ZERO, W)); + break; + default: + if (gen3_blend_op[blend].src_alpha) + gen3_fs_mul(out_reg, + gen3_fs_operand(src_reg, W, W, W, W), + gen3_fs_operand_reg(mask_reg)); + else + gen3_fs_mul(out_reg, + gen3_fs_operand_reg(src_reg), + gen3_fs_operand_reg(mask_reg)); + break; + } + } else { + switch (src->u.gen3.type) { + case SHADER_WHITE: + gen3_fs_mov(out_reg, + gen3_fs_operand(mask_reg, W, W, W, W)); + break; + case SHADER_BLACK: + gen3_fs_mov(out_reg, + gen3_fs_operand(mask_reg, ZERO, ZERO, ZERO, W)); + break; + default: gen3_fs_mul(out_reg, gen3_fs_operand_reg(src_reg), - gen3_fs_operand_reg(mask_reg)); - } else { - gen3_fs_mul(out_reg, - gen3_fs_operand_reg(src_reg), - gen3_fs_operand(mask_reg, W, W, W, W)); + gen3_fs_operand(mask_reg, W, W, W, W)); + break; + } } } mask_done: @@ -1202,6 +1272,8 @@ static void gen3_emit_composite_state(struct sna *sna, case SHADER_NONE: assert(0); case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: break; case SHADER_CONSTANT: if (op->src.u.gen3.mode != state->last_diffuse) { @@ -1235,6 +1307,8 @@ static void gen3_emit_composite_state(struct sna *sna, switch (op->mask.u.gen3.type) { case SHADER_NONE: case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: break; case SHADER_CONSTANT: if (op->mask.u.gen3.mode != state->last_specular) { @@ -1765,6 +1839,10 @@ gen3_init_solid(struct sna_composite_channel *channel, uint32_t color) channel->u.gen3.type = SHADER_CONSTANT; if (color == 0) channel->u.gen3.type = SHADER_ZERO; + else if (color == 0xff000000) + channel->u.gen3.type = SHADER_BLACK; + else if (color == 0xffffffff) + channel->u.gen3.type = SHADER_WHITE; if ((color & 0xff000000) == 0xff000000) channel->is_opaque = true; @@ -2141,6 +2219,20 @@ static inline uint8_t mult(uint32_t s, uint32_t m, int shift) return (s * m) >> 8; } +static inline bool is_constant_ps(uint32_t type) +{ + switch (type) { + case SHADER_NONE: /* be warned! */ + case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: + case SHADER_CONSTANT: + return true; + default: + return false; + } +} + static Bool gen3_render_composite(struct sna *sna, uint8_t op, @@ -2276,18 +2368,16 @@ gen3_render_composite(struct sna *sna, * into the single source value that we get to blend with. */ tmp->has_component_alpha = TRUE; - if (tmp->mask.u.gen3.type == SHADER_CONSTANT && - tmp->mask.u.gen3.mode == 0xffffffff) { + if (tmp->mask.u.gen3.type == SHADER_WHITE) { tmp->mask.u.gen3.type = SHADER_NONE; tmp->has_component_alpha = FALSE; - } else if (tmp->src.u.gen3.type == SHADER_CONSTANT && - tmp->src.u.gen3.mode == 0xffffffff) { + } else if (tmp->src.u.gen3.type == SHADER_WHITE) { tmp->src = tmp->mask; tmp->mask.u.gen3.type = SHADER_NONE; tmp->mask.bo = NULL; tmp->has_component_alpha = FALSE; - } else if (tmp->src.u.gen3.type == SHADER_CONSTANT && - tmp->mask.u.gen3.type == SHADER_CONSTANT) { + } else if (is_constant_ps(tmp->src.u.gen3.type) && + is_constant_ps(tmp->mask.u.gen3.type)) { uint32_t a,r,g,b; a = mult(tmp->src.u.gen3.mode, @@ -2309,6 +2399,7 @@ gen3_render_composite(struct sna *sna, tmp->mask.u.gen3.mode, a << 24 | r << 16 | g << 8 | b)); + tmp->src.u.gen3.type = SHADER_CONSTANT; tmp->src.u.gen3.mode = a << 24 | r << 16 | g << 8 | b; @@ -2330,10 +2421,12 @@ gen3_render_composite(struct sna *sna, tmp->src.is_affine, tmp->mask.is_affine)); tmp->prim_emit = gen3_emit_composite_primitive; - if (tmp->mask.u.gen3.type == SHADER_NONE || - tmp->mask.u.gen3.type == SHADER_CONSTANT) { + if (is_constant_ps(tmp->mask.u.gen3.type)) { switch (tmp->src.u.gen3.type) { case SHADER_NONE: + case SHADER_ZERO: + case SHADER_BLACK: + case SHADER_WHITE: case SHADER_CONSTANT: tmp->prim_emit = gen3_emit_composite_primitive_constant; break; @@ -2353,7 +2446,7 @@ gen3_render_composite(struct sna *sna, } } else if (tmp->mask.u.gen3.type == SHADER_TEXTURE) { if (tmp->mask.transform == NULL) { - if (tmp->src.u.gen3.type == SHADER_CONSTANT) + if (is_constant_ps(tmp->src.u.gen3.type)) tmp->prim_emit = gen3_emit_composite_primitive_constant_identity_mask; else if (tmp->src.transform == NULL) tmp->prim_emit = gen3_emit_composite_primitive_identity_source_mask; @@ -2363,19 +2456,13 @@ gen3_render_composite(struct sna *sna, } tmp->floats_per_vertex = 2; - if (tmp->src.u.gen3.type != SHADER_CONSTANT && - tmp->src.u.gen3.type != SHADER_ZERO) + if (!is_constant_ps(tmp->src.u.gen3.type)) tmp->floats_per_vertex += tmp->src.is_affine ? 2 : 4; - if (tmp->mask.u.gen3.type != SHADER_NONE && - tmp->mask.u.gen3.type != SHADER_CONSTANT) + if (!is_constant_ps(tmp->mask.u.gen3.type)) tmp->floats_per_vertex += tmp->mask.is_affine ? 2 : 4; DBG(("%s: floats_per_vertex = 2 + %d + %d = %d\n", __FUNCTION__, - (tmp->src.u.gen3.type != SHADER_CONSTANT && - tmp->src.u.gen3.type != SHADER_ZERO) ? - tmp->src.is_affine ? 2 : 4 : 0, - (tmp->mask.u.gen3.type != SHADER_NONE && - tmp->mask.u.gen3.type != SHADER_CONSTANT) ? - tmp->mask.is_affine ? 2 : 4 : 0, + !is_constant_ps(tmp->src.u.gen3.type) ? tmp->src.is_affine ? 2 : 4 : 0, + !is_constant_ps(tmp->mask.u.gen3.type) ? tmp->mask.is_affine ? 2 : 4 : 0, tmp->floats_per_vertex)); tmp->floats_per_rect = 3 * tmp->floats_per_vertex; @@ -2795,6 +2882,8 @@ gen3_render_composite_spans(struct sna *sna, case SHADER_ZERO: tmp->prim_emit = no_offset ? gen3_emit_composite_spans_primitive_zero_no_offset : gen3_emit_composite_spans_primitive_zero; break; + case SHADER_BLACK: + case SHADER_WHITE: case SHADER_CONSTANT: tmp->prim_emit = no_offset ? gen3_emit_composite_spans_primitive_constant_no_offset : gen3_emit_composite_spans_primitive_constant; break; @@ -2814,8 +2903,7 @@ gen3_render_composite_spans(struct sna *sna, } tmp->base.floats_per_vertex = 2; - if (tmp->base.src.u.gen3.type != SHADER_CONSTANT && - tmp->base.src.u.gen3.type != SHADER_ZERO) + if (!is_constant_ps(tmp->base.src.u.gen3.type)) tmp->base.floats_per_vertex += tmp->base.src.is_affine ? 2 : 3; tmp->base.floats_per_vertex += tmp->base.mask.u.gen3.type == SHADER_OPACITY; @@ -2887,6 +2975,7 @@ gen3_emit_video_state(struct sna *sna, sna->render_state.gen3.last_sampler = 0; sna->render_state.gen3.floats_per_vertex = 4; sna->render_state.gen3.last_shader = -1; + sna->render_state.gen3.last_constants = 0; if (!is_planar_fourcc(frame->id)) { OUT_BATCH(_3DSTATE_PIXEL_SHADER_CONSTANTS | 4); commit 29ca1a3922cb0e6f3d7b71857a252e5de81941b5 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 17:16:16 2011 +0100 sna/gen3: More removal of memset(0) Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index a6afbb1..11b56ac 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3745,6 +3745,8 @@ gen3_render_fill(struct sna *sna, uint8_t alu, tmp->base.src.u.gen3.type = SHADER_CONSTANT; tmp->base.src.u.gen3.mode = sna_rgba_for_color(color, dst->drawable.depth); + tmp->base.mask.u.gen3.type = SHADER_NONE; + tmp->base.u.gen3.num_constants = 0; if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) kgem_submit(&sna->kgem); @@ -3757,7 +3759,6 @@ gen3_render_fill(struct sna *sna, uint8_t alu, return TRUE; } - static Bool gen3_render_fill_one_try_blt(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, uint32_t color, @@ -3806,7 +3807,6 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, if (alu == GXclear) color = 0; - memset(&tmp, 0, sizeof(tmp)); tmp.op = color == 0 ? PictOpClear : PictOpSrc; tmp.dst.pixmap = dst; tmp.dst.width = dst->drawable.width; @@ -3819,6 +3819,8 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, tmp.src.u.gen3.type = SHADER_CONSTANT; tmp.src.u.gen3.mode = sna_rgba_for_color(color, dst->drawable.depth); + tmp.mask.u.gen3.mode = SHADER_NONE; + tmp.u.gen3.num_constants = 0; if (!kgem_check_bo(&sna->kgem, bo, NULL)) { kgem_submit(&sna->kgem); commit 88bc10878830dffefda6ed905c1f598d7a7d67ef Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 20:05:49 2011 +0100 sna/gen5: Rearrange the BLT->RENDER workaround So that we can simply use the pending DRAWRECT as the non-pipelined flush required following use of a BLT command. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index ab30c9c..516bc35 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -1418,11 +1418,13 @@ gen5_emit_state(struct sna *sna, const struct sna_composite_op *op, uint16_t offset) { + /* drawrect must be first for Ironlake BLT workaround */ + gen5_emit_drawing_rectangle(sna, op); + gen5_emit_binding_table(sna, offset); if (gen5_emit_pipelined_pointers(sna, op, op->op, op->u.gen5.wm_kernel)) gen5_emit_urb(sna); gen5_emit_vertex_elements(sna, op); - gen5_emit_drawing_rectangle(sna, op); } static void gen5_bind_surfaces(struct sna *sna, @@ -2119,7 +2121,7 @@ gen5_copy_bind_surfaces(struct sna *sna, offset = sna->render_state.gen5.surface_table; } - gen5_emit_state(sna, op,offset); + gen5_emit_state(sna, op, offset); } static Bool @@ -2186,7 +2188,6 @@ gen5_render_copy_boxes(struct sna *sna, uint8_t alu, if (kgem_bo_is_dirty(src_bo)) kgem_emit_flush(&sna->kgem); - gen5_get_batch(sna); gen5_copy_bind_surfaces(sna, &tmp); gen5_align_vertex(sna, &tmp); @@ -2583,10 +2584,13 @@ gen5_render_context_switch(struct kgem *kgem, /* Ironlake has a limitation that a 3D or Media command can't * be the first command after a BLT, unless it's * non-pipelined. + * + * We do this by ensuring that the non-pipelined drawrect + * is always emitted first following a switch from BLT. */ if (kgem->mode == KGEM_BLT) { - kgem->batch[kgem->nbatch++] = CMD_POLY_STIPPLE_OFFSET << 16; - kgem->batch[kgem->nbatch++] = 0; + struct sna *sna = to_sna_from_kgem(kgem); + sna->render_state.gen5.drawrect_limit = -1; } } diff --git a/src/sna/kgem.h b/src/sna/kgem.h index aba8d3f..988281c 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -120,7 +120,7 @@ struct kgem { struct drm_i915_gem_relocation_entry reloc[384]; }; -#define KGEM_BATCH_RESERVED 4 /* need a bit of extra room for workarounds */ +#define KGEM_BATCH_RESERVED 1 #define KGEM_RELOC_RESERVED 4 #define KGEM_EXEC_RESERVED 1 diff --git a/src/sna/sna.h b/src/sna/sna.h index 4ba3f57..ae043ed 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -301,6 +301,12 @@ to_sna_from_drawable(DrawablePtr drawable) return to_sna_from_screen(drawable->pScreen); } +static inline struct sna * +to_sna_from_kgem(struct kgem *kgem) +{ + return container_of(kgem, struct sna, kgem); +} + #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif commit 18aed47ba37ccfbcdd72ed251fc97222741c66a7 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 16:41:14 2011 +0100 sna: Fast path common colour conversions Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 9d84747..15b09bf 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -433,6 +433,20 @@ sna_get_pixel_from_rgba(uint32_t * pixel, int rbits, bbits, gbits, abits; int rshift, bshift, gshift, ashift; + switch (format) { + case PICT_x8r8g8b8: + alpha = 0xffff; + case PICT_a8r8g8b8: + *pixel = ((alpha >> 8 << 24) | + (red >> 8 << 16) | + (green & 0xff00) | + (blue >> 8)); + return TRUE; + case PICT_a8: + *pixel = alpha >> 8; + return TRUE; + } + rbits = PICT_FORMAT_R(format); gbits = PICT_FORMAT_G(format); bbits = PICT_FORMAT_B(format); commit a3466c8b69afeda95180fcdc97b56d31f7a1d1ad Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 16 20:52:47 2011 +0100 sna/accel: Implement a simpler path for CopyArea between the same pixmaps Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index fe6ad48..b58cfc8 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1252,6 +1252,102 @@ move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv, } static void +sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, + BoxPtr box, int n, + int dx, int dy, + Bool reverse, Bool upsidedown, Pixel bitplane, + void *closure) +{ + struct sna *sna = to_sna_from_drawable(src); + PixmapPtr pixmap = get_drawable_pixmap(src); + struct sna_pixmap *priv = sna_pixmap(pixmap); + int alu = gc ? gc->alu : GXcopy; + RegionRec region; + int16_t tx, ty; + + if (n == 0 || (dx | dy) == 0) + return; + + DBG(("%s (boxes=%dx[(%d, %d), (%d, %d)...], src=+(%d, %d), alu=%d, pix.size=%dx%d)\n", + __FUNCTION__, n, + box[0].x1, box[0].y1, box[0].x2, box[0].y2, + dx, dy, alu, + pixmap->drawable.width, pixmap->drawable.height)); + + pixman_region_init_rects(®ion, box, n); + get_drawable_deltas(dst, pixmap, &tx, &ty); + RegionTranslate(®ion, tx, ty); + assert_pixmap_contains_box(pixmap, RegionExtents(®ion)); + + if (priv && priv->gpu_bo) { + if (!sna_pixmap_move_to_gpu(pixmap)) { + DBG(("%s: fallback - not a pure copy and failed to move dst to GPU\n", + __FUNCTION__)); + goto fallback; + } + + if (!sna->render.copy_boxes(sna, alu, + pixmap, priv->gpu_bo, dx, dy, + pixmap, priv->gpu_bo, 0, 0, + box, n)) { + DBG(("%s: fallback - accelerated copy boxes failed\n", + __FUNCTION__)); + goto fallback; + } + + sna_damage_add(&priv->gpu_damage, ®ion); + } else { + FbBits *dst_bits, *src_bits; + int stride, bpp; + +fallback: + DBG(("%s: fallback", __FUNCTION__)); + sna_pixmap_move_to_cpu(pixmap, true); + + stride = pixmap->devKind; + bpp = pixmap->drawable.bitsPerPixel; + if (alu == GXcopy && !reverse && !upsidedown && bpp >= 8) { + dst_bits = pixmap->devPrivate.ptr; + src_bits = (FbBits *) + ((char *)pixmap->devPrivate.ptr + + dy * stride + dx * bpp / 8); + + do { + memcpy_blt(src_bits, dst_bits, bpp, + stride, stride, + box->x1, box->y1, + box->x1, box->y1, + box->x2 - box->x1, + box->y2 - box->y1); + box++; + } while (--n); + } else { + DBG(("%s: alu==GXcopy? %d, reverse? %d, upsidedown? %d, bpp? %d\n", + __FUNCTION__, alu == GXcopy, reverse, upsidedown, bpp)); + dst_bits = pixmap->devPrivate.ptr; + stride /= sizeof(FbBits); + do { + fbBlt(dst_bits + (box->y1 + dy) * stride, + stride, + (box->x1 + dx) * bpp, + + dst_bits + box->y1 * stride, + stride, + box->x1 * bpp, + + (box->x2 - box->x1) * bpp, + (box->y2 - box->y1), + + alu, -1, bpp, + reverse, upsidedown); + box++; + }while (--n); + } + } + RegionUninit(®ion); +} + +static void sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, BoxPtr box, int n, int dx, int dy, @@ -1274,6 +1370,13 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, if (n == 0) return; + if (src_pixmap == dst_pixmap) + return sna_self_copy_boxes(src, dst, gc, + box, n, + dx, dy, + reverse, upsidedown, bitplane, + closure); + DBG(("%s (boxes=%dx[(%d, %d), (%d, %d)...], src=+(%d, %d), alu=%d, src.size=%dx%d, dst.size=%dx%d)\n", __FUNCTION__, n, box[0].x1, box[0].y1, box[0].x2, box[0].y2, @@ -1617,7 +1720,8 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, src_x, src_y, width, height, dst_x, dst_y, - sna_copy_boxes, 0, NULL); + src == dst ? sna_self_copy_boxes : sna_copy_boxes, + 0, NULL); } static Bool @@ -3775,7 +3879,7 @@ sna_copy_window(WindowPtr win, DDXPointRec origin, RegionPtr src) #endif miCopyRegion(&pixmap->drawable, &pixmap->drawable, - NULL, &dst, dx, dy, sna_copy_boxes, 0, NULL); + NULL, &dst, dx, dy, sna_self_copy_boxes, 0, NULL); RegionUninit(&dst); } commit 8afa05191a9a337ce6e02b1064de2876f5635435 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 00:55:51 2011 +0100 sna: Improve debug output for mi/fb fallbacks Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 49bd604..fe6ad48 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2304,8 +2304,8 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, BoxRec extents; RegionRec region; - DBG(("%s(mode=%d, n=%d, pt[0]=(%d, %d)\n", - __FUNCTION__, mode, n, pt[0].x, pt[0].y)); + DBG(("%s(mode=%d, n=%d, pt[0]=(%d, %d), lineWidth=%d\n", + __FUNCTION__, mode, n, pt[0].x, pt[0].y, gc->lineWidth)); if (sna_poly_line_extents(drawable, gc, mode, n, pt, &extents)) return; @@ -2365,6 +2365,7 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, } fallback: + DBG(("%s: fallback\n", __FUNCTION__)); if (gc->lineWidth) { if (gc->lineStyle != LineSolid) miWideDash(drawable, gc, mode, n, pt); @@ -2373,7 +2374,6 @@ fallback: return; } - DBG(("%s: fallback\n", __FUNCTION__)); region_set(®ion, &extents); region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) @@ -2383,6 +2383,7 @@ fallback: sna_drawable_move_region_to_cpu(drawable, ®ion, true); RegionUninit(®ion); + DBG(("%s: fbPolyLine\n", __FUNCTION__)); fbPolyLine(drawable, gc, mode, n, pt); } @@ -2607,8 +2608,10 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) BoxRec extents; RegionRec region; - DBG(("%s(n=%d, first=((%d, %d), (%d, %d))\n", __FUNCTION__, - n, seg->x1, seg->y1, seg->x2, seg->y2)); + DBG(("%s(n=%d, first=((%d, %d), (%d, %d)), lineWidth=%d\n", + __FUNCTION__, + n, seg->x1, seg->y1, seg->x2, seg->y2, + gc->lineWidth)); if (sna_poly_segment_extents(drawable, gc, n, seg, &extents)) return; @@ -2678,12 +2681,12 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) } fallback: + DBG(("%s: fallback\n", __FUNCTION__)); if (gc->lineWidth) { miPolySegment(drawable, gc, n, seg); return; } - DBG(("%s: fallback\n", __FUNCTION__)); region_set(®ion, &extents); region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) @@ -2693,6 +2696,7 @@ fallback: sna_drawable_move_region_to_cpu(drawable, ®ion, true); RegionUninit(®ion); + DBG(("%s: fbPolySegment\n", __FUNCTION__)); fbPolySegment(drawable, gc, n, seg); } @@ -2764,6 +2768,8 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) BoxRec extents; RegionRec region; + DBG(("%s(n=%d, lineWidth=%d\n", __FUNCTION__, n, gc->lineWidth)); + if (sna_poly_arc_extents(drawable, gc, n, arc, &extents)) return; @@ -2787,6 +2793,7 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) } fallback: + DBG(("%s -- fallback\n", __FUNCTION__)); if (gc->lineWidth) { miPolyArc(drawable, gc, n, arc); return; @@ -2802,6 +2809,7 @@ fallback: RegionUninit(®ion); /* XXX may still fallthrough to miZeroPolyArc */ + DBG(("%s -- fbPolyArc\n", __FUNCTION__)); fbPolyArc(drawable, gc, n, arc); } commit 2b118658d5b9cfa56132f91238f2ea61fba8b357 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 17 15:00:01 2011 +0100 sna/gen3: Remove memset(0) from fill_boxes And initialise only the state used for the operation. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 0a51e64..a6afbb1 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3629,7 +3629,6 @@ gen3_render_fill_boxes(struct sna *sna, if (pixel == 0) op = PictOpClear; - memset(&tmp, 0, sizeof(tmp)); tmp.op = op; tmp.dst.pixmap = dst; tmp.dst.width = dst->drawable.width; @@ -3641,6 +3640,8 @@ gen3_render_fill_boxes(struct sna *sna, tmp.src.u.gen3.type = op == PictOpClear ? SHADER_ZERO : SHADER_CONSTANT; tmp.src.u.gen3.mode = pixel; + tmp.mask.u.gen3.type = SHADER_NONE; + tmp.u.gen3.num_constants = 0; if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) kgem_submit(&sna->kgem); From keithp at kemper.freedesktop.org Tue Oct 18 07:47:42 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Tue, 18 Oct 2011 07:47:42 -0700 (PDT) Subject: xserver: Branch 'master' - 38 commits Message-ID: <20111018144742.3BCB6C0001@kemper.freedesktop.org> configure.ac | 90 ++--- dix/inpututils.c | 63 ++++ doc/Xserver-spec.xml | 10 hw/kdrive/ephyr/hostx.c | 11 hw/kdrive/ephyr/man/Xephyr.man | 32 +- hw/xfree86/common/Makefile.am | 9 hw/xfree86/common/xf86.h | 16 - hw/xfree86/common/xf86AutoConfig.c | 4 hw/xfree86/common/xf86Bus.c | 19 - hw/xfree86/common/xf86Bus.h | 1 hw/xfree86/common/xf86Config.c | 4 hw/xfree86/common/xf86Configure.c | 6 hw/xfree86/common/xf86DPMS.c | 3 hw/xfree86/common/xf86Helper.c | 90 ----- hw/xfree86/common/xf86Init.c | 7 hw/xfree86/common/xf86Module.h | 2 hw/xfree86/common/xf86VGAarbiter.c | 15 hw/xfree86/common/xf86fbBus.c | 2 hw/xfree86/common/xf86pciBus.c | 19 - hw/xfree86/common/xf86str.h | 8 hw/xfree86/dixmods/Makefile.am | 12 hw/xfree86/dixmods/extmod/Makefile.am | 2 hw/xfree86/exa/Makefile.am | 2 hw/xfree86/fbdevhw/Makefile.am | 2 hw/xfree86/fbdevhw/fbdevhw.h | 2 hw/xfree86/int10/generic.c | 72 ---- hw/xfree86/int10/helper_exec.c | 52 +-- hw/xfree86/int10/xf86int10.c | 61 +-- hw/xfree86/int10/xf86int10.h | 2 hw/xfree86/modes/xf86Crtc.c | 2 hw/xfree86/modes/xf86Crtc.h | 2 hw/xfree86/modes/xf86Cursors.c | 1 hw/xfree86/os-support/Makefile.am | 5 hw/xfree86/os-support/bsd/i386_video.c | 2 hw/xfree86/os-support/bus/Makefile.am | 9 hw/xfree86/os-support/bus/Pci.c | 8 hw/xfree86/os-support/bus/Pci.h | 16 - hw/xfree86/os-support/bus/bsd_pci.c | 16 - hw/xfree86/os-support/bus/linuxPci.c | 450 ----------------------------- hw/xfree86/os-support/bus/nobus.c | 1 hw/xfree86/os-support/bus/xf86Pci.h | 10 hw/xfree86/os-support/linux/Makefile.am | 4 hw/xfree86/os-support/linux/int10/linux.c | 3 hw/xfree86/os-support/shared/bios_devmem.c | 75 ---- hw/xfree86/os-support/shared/ia64Pci.c | 188 ------------ hw/xfree86/os-support/shared/vidmem.c | 6 hw/xfree86/os-support/stub/Makefile.am | 19 + hw/xfree86/os-support/stub/stub_bell.c | 10 hw/xfree86/os-support/stub/stub_bios.c | 12 hw/xfree86/os-support/stub/stub_init.c | 26 + hw/xfree86/os-support/stub/stub_video.c | 13 hw/xfree86/os-support/xf86_OSproc.h | 10 hw/xfree86/sdksyms.sh | 12 hw/xfree86/shadowfb/Makefile.am | 2 hw/xfree86/utils/cvt/cvt.c | 7 hw/xfree86/vbe/Makefile.am | 2 hw/xfree86/vgahw/vgaHW.c | 184 ++++++++--- hw/xfree86/vgahw/vgaHW.h | 24 - hw/xfree86/xaa/Makefile.am | 2 hw/xnest/Display.c | 15 hw/xnest/Events.c | 2 include/inpututils.h | 6 include/os.h | 1 include/xorg-config.h.in | 15 man/Xserver.man | 8 os/backtrace.c | 5 os/log.c | 14 os/utils.c | 4 os/xprintf.c | 5 test/input.c | 150 ++++++++- xorg-server.pc.in | 1 71 files changed, 717 insertions(+), 1248 deletions(-) New commits: commit c8413362049cee8c30e0a9d67f78f9ebefe8e71f Merge: 64d2d1b... b67581c... Author: Keith Packard <keithp at keithp.com> Date: Tue Oct 18 07:45:24 2011 -0700 Merge remote-tracking branch 'herrb/master' commit b67581cf825940fdf52bf2e0af4330e695d724a4 Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:27:35 2011 +0200 Fix CVE-2011-4029: File permission change vulnerability. Use fchmod() to change permissions of the lock file instead of chmod(), thus avoid the race that can be exploited to set a symbolic link to any file or directory in the system. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> diff --git a/os/utils.c b/os/utils.c index fe49254..07cf4c2 100644 --- a/os/utils.c +++ b/os/utils.c @@ -297,7 +297,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* commit 6ba44b91e37622ef8c146d8f2ac92d708a18ed34 Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:26:12 2011 +0200 Fix CVE-2011-4028: File disclosure vulnerability. use O_NOFOLLOW to open the existing lock file, so symbolic links aren't followed, thus avoid revealing if it point to an existing file. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> diff --git a/os/utils.c b/os/utils.c index e8ecb71..fe49254 100644 --- a/os/utils.c +++ b/os/utils.c @@ -318,7 +318,7 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(LockFile, O_RDONLY|O_NOFOLLOW); if (lfd < 0) { unlink(tmp); FatalError("Can't read lock file %s\n", LockFile); commit 64d2d1bef14c7ec7156bb3aae64eff69f9f7be54 Merge: fb84be4... 679c84b... Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 17 14:36:34 2011 -0700 Merge remote-tracking branch 'jeremyhu/master' commit 679c84bce9b03c17aa35fa69058e7e46267dbc7b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Sep 24 00:01:11 2011 -0700 Bump ABI_VIDEODRV_VERSION to 12 The ABI changed in the previous series of changes, so bump the ABI version for the next release. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index 330d87a..a9645e7 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -82,7 +82,7 @@ typedef enum { * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(12, 0) #define ABI_XINPUT_VERSION SET_ABI_VERSION(14, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(6, 0) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) commit a89cdcee4ebab6bbfa9ace94e1988a94cfb67087 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 02:59:12 2011 -0700 xfree86: Deprecate xf86MapVidMem and friends Drivers should transition over to using libpciaccess's instead. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h index 6a29fbd..78ea6e6 100644 --- a/hw/xfree86/os-support/xf86_OSproc.h +++ b/hw/xfree86/os-support/xf86_OSproc.h @@ -132,10 +132,10 @@ _XFUNCPROTOBEGIN /* public functions */ extern _X_EXPORT Bool xf86LinearVidMem(void); -extern _X_EXPORT Bool xf86CheckMTRR(int); -extern _X_EXPORT pointer xf86MapVidMem(int, int, unsigned long, unsigned long); -extern _X_EXPORT void xf86UnMapVidMem(int, pointer, unsigned long); -extern _X_EXPORT void xf86MapReadSideEffects(int, int, pointer, unsigned long); +extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int); +extern _X_EXPORT _X_DEPRECATED pointer xf86MapVidMem(int, int, unsigned long, unsigned long); +extern _X_EXPORT _X_DEPRECATED void xf86UnMapVidMem(int, pointer, unsigned long); +extern _X_EXPORT _X_DEPRECATED void xf86MapReadSideEffects(int, int, pointer, unsigned long); extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int); extern _X_EXPORT Bool xf86EnableIO(void); extern _X_EXPORT void xf86DisableIO(void); @@ -209,7 +209,7 @@ extern _X_EXPORT int xf86ProcessArgument(int, char **, int); extern _X_EXPORT void xf86UseMsg(void); extern _X_EXPORT PMClose xf86OSPMOpen(void); -extern _X_EXPORT void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer); +extern _X_EXPORT _X_DEPRECATED void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer); extern _X_EXPORT void xf86InitVidMem(void); #endif /* XF86_OS_PRIVS */ commit 41d903918a5721e53ed694880eab44170f9717cc Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Sep 14 13:45:18 2011 -0500 xorg-server.pc.in: Remove libpciaccess and pixman-1 from Requires Every module building against xorg-server does not *Require* pixman nor libpciaccess. If such modules need pixman or pciaccess, they should be depending on them directly rather than inheriting a dependency from xorg-server. To do this, they should use PKG_CHECK_MODULES in configure.ac to check for pixman-1 or pciaccess and include the apporpriate _LIBS variable to the appropriate _LDFLAGS variable in Makefile.am This also moves pixman-1 to Requires.private, so CPPFLAGS is set right to to satisfy include dependencies but avoid linking needlessly. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Gaetan Nadon <memsize at videotron.ca> diff --git a/configure.ac b/configure.ac index 50beb01..4bfa82c 100644 --- a/configure.ac +++ b/configure.ac @@ -784,11 +784,6 @@ VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1" WINDOWSWMPROTO="windowswmproto" APPLEWMPROTO="applewmproto >= 1.4" -dnl Core modules for most extensions, et al. -SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto" -# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc -AC_SUBST(SDK_REQUIRED_MODULES) - dnl List of libraries that require a specific version LIBAPPLEWM="applewm >= 1.4" LIBDMX="dmx >= 1.0.99.1" @@ -810,6 +805,11 @@ dnl specific modules against it PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN) REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau" +dnl Core modules for most extensions, et al. +SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto $LIBPIXMAN" +# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc +AC_SUBST(SDK_REQUIRED_MODULES) + REQUIRED_MODULES="[fixesproto >= 5.0] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES" if test "x$CONFIG_UDEV" = xyes && @@ -1583,6 +1583,7 @@ if test "x$XORG" = xyes; then if test "x$PCI" = xyes; then PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS) + SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $LIBPCIACCESS" XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS" XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" diff --git a/xorg-server.pc.in b/xorg-server.pc.in index fb238b5..a98eca8 100644 --- a/xorg-server.pc.in +++ b/xorg-server.pc.in @@ -15,7 +15,6 @@ abi_extension=@abi_extension@ Name: xorg-server Description: Modular X.Org X Server Version: @PACKAGE_VERSION@ -Requires: pixman-1 pciaccess Requires.private: @SDK_REQUIRED_MODULES@ Cflags: -I${sdkdir} @symbol_visibility@ Libs: -L${libdir} commit 40d338e9f723c4b3d63516aa62fdcded4d8af75e Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Sep 14 10:37:38 2011 -0500 darwin: configure: Force some irrelevant options to off on darwin This removes the need to pass the following to configure on darwin: --disable-pciaccess -disable-int10-module --disable-vbe --disable-vgahw --disable-libdrm Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/configure.ac b/configure.ac index 004c08d..50beb01 100644 --- a/configure.ac +++ b/configure.ac @@ -719,6 +719,11 @@ case $host_os in XV=no ;; darwin*) + PCI=no + INT10MODULE=no + VGAHW=no + VBE=no + DRM=no DRI2=no if test x$XQUARTZ = xauto; then commit 43d730c0e4b1a00b29843c0660dcc7c60da6725d Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Sep 14 15:42:19 2011 -0500 xfree86: Link modules with -module This makes a difference on darwin (and apparently nowhere else) https://www.gnu.org/s/libtool/manual/libtool.html#Modules-for-libltdl Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Gaetan Nadon <memsize at videotron.ca> diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am index 1a162ab..b6eb54f 100644 --- a/hw/xfree86/dixmods/Makefile.am +++ b/hw/xfree86/dixmods/Makefile.am @@ -30,21 +30,21 @@ INCLUDES = @XORG_INCS@ \ -I$(top_srcdir)/miext/shadow \ -I$(top_srcdir)/glx -libdbe_la_LDFLAGS = -avoid-version +libdbe_la_LDFLAGS = -module -avoid-version libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la libdbe_la_SOURCES = dbemodule.c -libfb_la_LDFLAGS = -avoid-version +libfb_la_LDFLAGS = -module -avoid-version libfb_la_LIBADD = $(top_builddir)/fb/libfb.la libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c libfb_la_CFLAGS = $(AM_CFLAGS) -libwfb_la_LDFLAGS = -avoid-version +libwfb_la_LDFLAGS = -module -avoid-version libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER -libglx_la_LDFLAGS = -avoid-version +libglx_la_LDFLAGS = -module -avoid-version if AIGLX_DRI_LOADER GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la endif @@ -53,11 +53,11 @@ libglx_la_LIBADD = \ $(GLXDRI_LIBRARY) libglx_la_SOURCES = glxmodule.c -librecord_la_LDFLAGS = -avoid-version +librecord_la_LDFLAGS = -module -avoid-version librecord_la_LIBADD = $(top_builddir)/record/librecord.la librecord_la_SOURCES = recordmod.c -libshadow_la_LDFLAGS = -avoid-version +libshadow_la_LDFLAGS = -module -avoid-version libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la libshadow_la_SOURCES = shmodule.c diff --git a/hw/xfree86/dixmods/extmod/Makefile.am b/hw/xfree86/dixmods/extmod/Makefile.am index cce19f7..87c28a4 100644 --- a/hw/xfree86/dixmods/extmod/Makefile.am +++ b/hw/xfree86/dixmods/extmod/Makefile.am @@ -21,7 +21,7 @@ INCLUDES = @XORG_INCS@ \ -I$(top_srcdir)/hw/xfree86/loader \ -I$(top_srcdir)/miext/shadow -libextmod_la_LDFLAGS = -avoid-version +libextmod_la_LDFLAGS = -module -avoid-version libextmod_la_SOURCES = modinit.c \ modinit.h \ $(DGA_SRCS) \ diff --git a/hw/xfree86/exa/Makefile.am b/hw/xfree86/exa/Makefile.am index 39f7a90..3ced531 100644 --- a/hw/xfree86/exa/Makefile.am +++ b/hw/xfree86/exa/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = man module_LTLIBRARIES = libexa.la -libexa_la_LDFLAGS = -avoid-version +libexa_la_LDFLAGS = -module -avoid-version INCLUDES = \ $(XORG_INCS) \ diff --git a/hw/xfree86/fbdevhw/Makefile.am b/hw/xfree86/fbdevhw/Makefile.am index 2a03890..4472acd 100644 --- a/hw/xfree86/fbdevhw/Makefile.am +++ b/hw/xfree86/fbdevhw/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = man module_LTLIBRARIES = libfbdevhw.la -libfbdevhw_la_LDFLAGS = -avoid-version +libfbdevhw_la_LDFLAGS = -module -avoid-version if FBDEVHW libfbdevhw_la_SOURCES = fbdevhw.c diff --git a/hw/xfree86/shadowfb/Makefile.am b/hw/xfree86/shadowfb/Makefile.am index 02d2dd4..39c6610 100644 --- a/hw/xfree86/shadowfb/Makefile.am +++ b/hw/xfree86/shadowfb/Makefile.am @@ -1,5 +1,5 @@ module_LTLIBRARIES = libshadowfb.la -libshadowfb_la_LDFLAGS = -avoid-version +libshadowfb_la_LDFLAGS = -module -avoid-version libshadowfb_la_SOURCES = sfbmodule.c shadow.c sdk_HEADERS = shadowfb.h diff --git a/hw/xfree86/vbe/Makefile.am b/hw/xfree86/vbe/Makefile.am index 85c6fd8..4b794e6 100644 --- a/hw/xfree86/vbe/Makefile.am +++ b/hw/xfree86/vbe/Makefile.am @@ -1,5 +1,5 @@ module_LTLIBRARIES = libvbe.la -libvbe_la_LDFLAGS = -avoid-version +libvbe_la_LDFLAGS = -module -avoid-version libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c sdk_HEADERS = vbe.h vbeModes.h diff --git a/hw/xfree86/xaa/Makefile.am b/hw/xfree86/xaa/Makefile.am index 5bfb4e9..7ebe0b9 100644 --- a/hw/xfree86/xaa/Makefile.am +++ b/hw/xfree86/xaa/Makefile.am @@ -8,7 +8,7 @@ MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c POLYSEG = s-xaaLine.c s-xaaDashLine.c -libxaa_la_LDFLAGS = -avoid-version +libxaa_la_LDFLAGS = -module -avoid-version if COMPOSITE libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la endif commit f7edc00a2af83764910ff89514a046dc5ce2ff9e Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Sep 14 12:14:56 2011 -0500 xfree86: fbdevhw: Remove unused include of pciaccess.h Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/fbdevhw/fbdevhw.h b/hw/xfree86/fbdevhw/fbdevhw.h index bc46b9c..34870c2 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.h +++ b/hw/xfree86/fbdevhw/fbdevhw.h @@ -5,8 +5,6 @@ #include "xf86str.h" #include "colormapst.h" -#include <pciaccess.h> - #define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ #define FBDEVHW_PLANES 1 /* Non interleaved planes */ #define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ commit 6817050f3196d460ba03a62da23fb46ffd5a0f97 Author: Tiago Vignatti <tiago.vignatti at nokia.com> Date: Tue Jun 1 13:05:47 2010 +0300 configure: wrap PCI code with macro and set it at build time --disable-pciaccess, used together with --disable-module-int10, can be used to disable all pci code inside the server. Note that XSERVER_LIBPCIACCESS was previously used only in the driver side and now it defines also whether the library is used inside the server. Also, XORG_BUS_PCI automake variable is introduced to track PCI code needs. Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com> Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/configure.ac b/configure.ac index 2edeb4d..004c08d 100644 --- a/configure.ac +++ b/configure.ac @@ -638,6 +638,7 @@ AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build X AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no]) AC_ARG_ENABLE(libdrm, AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes]) AC_ARG_ENABLE(clientids, AS_HELP_STRING([--disable-clientids], [Build Xorg with client ID tracking (default: enabled)]), [CLIENTIDS=$enableval], [CLIENTIDS=yes]) +AC_ARG_ENABLE(pciaccess, AS_HELP_STRING([--enable-pciaccess], [Build Xorg with pciaccess library (default: enabled)]), [PCI=$enableval], [PCI=yes]) dnl DDXes. AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto]) @@ -1573,6 +1574,9 @@ if test "x$XORG" = xyes; then xorg_bus_bsdpci=no xorg_bus_sparc=no + AC_MSG_CHECKING([whether to build Xorg PCI functions]) + if test "x$PCI" = xyes; then + PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS) XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS" XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" @@ -1589,6 +1593,9 @@ if test "x$XORG" = xyes; then xorg_bus_sparc="yes" ;; esac + fi + AC_MSG_RESULT([$PCI]) + dnl =================================================================== dnl ==================== end of PCI configuration ===================== dnl =================================================================== @@ -1768,6 +1775,7 @@ if test "x$XORG" = xyes; then AC_SUBST([abi_extension]) fi AM_CONDITIONAL([XORG], [test "x$XORG" = xyes]) +AM_CONDITIONAL([XORG_BUS_PCI], [test "x$PCI" = xyes]) AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes]) AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes]) AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes]) diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am index 23ddb5c..a273721 100644 --- a/hw/xfree86/common/Makefile.am +++ b/hw/xfree86/common/Makefile.am @@ -1,5 +1,10 @@ noinst_LTLIBRARIES = libcommon.la +if XORG_BUS_PCI +PCI_SOURCES = xf86pciBus.c xf86VGAarbiter.c xf86VGAarbiter.h \ + xf86VGAarbiterPriv.h +endif + if XORG_BUS_SPARC SBUS_SOURCES = xf86sbusBus.c endif @@ -19,7 +24,7 @@ endif RANDRSOURCES = xf86RandR.c -BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES) +BUSSOURCES = xf86fbBus.c xf86noBus.c $(PCI_SOURCES) $(SBUS_SOURCES) MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes @@ -33,7 +38,7 @@ AM_LDFLAGS = -r libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \ xf86Cursor.c $(DGASOURCES) xf86DPMS.c \ xf86Events.c xf86Globals.c xf86AutoConfig.c \ - xf86Option.c xf86Init.c xf86VGAarbiter.c \ + xf86Option.c xf86Init.c \ xf86VidMode.c xf86fbman.c xf86cmap.c \ xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \ xf86Mode.c xorgHelper.c \ diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index da9287b..3185baf 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -92,6 +92,7 @@ extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */ #ifndef _NO_XF86_PROTOTYPES /* PCI related */ +#ifdef XSERVER_LIBPCIACCESS #include <pciaccess.h> extern _X_EXPORT Bool pciSlotClaimed; @@ -118,6 +119,15 @@ extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init, EntityProc enter, EntityProc leave, pointer private); +#else +#define xf86VGAarbiterInit() do {} while (0) +#define xf86VGAarbiterFini() do {} while (0) +#define xf86VGAarbiterLock(x) do {} while (0) +#define xf86VGAarbiterUnlock(x) do {} while (0) +#define xf86VGAarbiterScrnInit(x) do {} while (0) +#define xf86VGAarbiterDeviceDecodes() do {} while (0) +#define xf86VGAarbiterWrapFunctions() do {} while (0) +#endif /* xf86Bus.c */ diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c index 5c6e721..7fc6518 100644 --- a/hw/xfree86/common/xf86AutoConfig.c +++ b/hw/xfree86/common/xf86AutoConfig.c @@ -255,9 +255,9 @@ listPossibleVideoDrivers(char *matches[], int nmatches) matches[i++] = xnfstrdup(sbusDriver); } #endif - +#ifdef XSERVER_LIBPCIACCESS i = xf86PciMatchDriver(matches, nmatches); - +#endif /* Fallback to platform default hardware */ if (i < (nmatches - 1)) { #if defined(__i386__) || defined(__amd64__) || defined(__hurd__) diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 8749a29..c665a20 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -47,8 +47,9 @@ #define XF86_OS_PRIVS #include "xf86_OSproc.h" +#ifdef XSERVER_LIBPCIACCESS #include "xf86VGAarbiter.h" - +#endif /* Entity data */ EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */ int xf86NumEntities = 0; @@ -75,7 +76,7 @@ Bool xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) { Bool foundScreen = FALSE; - +#ifdef XSERVER_LIBPCIACCESS if (drv->PciProbe != NULL) { if (xf86DoConfigure && xf86DoConfigurePass1) { assert(detect_only); @@ -86,7 +87,7 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) foundScreen = xf86PciProbeDev(drv); } } - +#endif if (!foundScreen && (drv->Probe != NULL)) { xf86Msg( X_WARNING, "Falling back to old probe method for %s\n", drv->driverName); @@ -195,7 +196,9 @@ xf86BusConfig(void) void xf86BusProbe(void) { +#ifdef XSERVER_LIBPCIACCESS xf86PciProbe(); +#endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) xf86SbusProbe(); #endif @@ -504,9 +507,14 @@ xf86PostProbe(void) { int i; - if (fbSlotClaimed && (pciSlotClaimed + if (fbSlotClaimed && ( #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) - || sbusSlotClaimed + sbusSlotClaimed || +#endif +#ifdef XSERVER_LIBPCIACCESS + pciSlotClaimed +#else + TRUE #endif )) FatalError("Cannot run in framebuffer mode. Please specify busIDs " diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index f8c1b65..5c46152 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -2398,7 +2398,7 @@ xf86HandleConfigFile(Bool autoconfig) } xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions); - +#ifdef XSERVER_LIBPCIACCESS if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) { ; /* IsolateDevice specified; overrides SingleCard */ } else { @@ -2413,7 +2413,7 @@ xf86HandleConfigFile(Bool autoconfig) } else xf86PciIsolateDevice(scanptr); } - +#endif /* Now process everything else */ if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){ ErrorF ("Problem when converting the config data structures\n"); diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index ab07515..99b8b48 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -87,9 +87,11 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int /* Check for duplicates */ for (i = 0; i < nDevToConfig; i++) { switch (bus) { +#ifdef XSERVER_LIBPCIACCESS case BUS_PCI: ret = xf86PciConfigure(busData, DevToConfig[i].pVideo); - break; + break; +#endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo); @@ -118,10 +120,12 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++); switch (bus) { +#ifdef XSERVER_LIBPCIACCESS case BUS_PCI: xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo, &DevToConfig[i].GDev, &chipset); break; +#endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo, diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c index cd025dc..613c7cf 100644 --- a/hw/xfree86/common/xf86DPMS.c +++ b/hw/xfree86/common/xf86DPMS.c @@ -42,8 +42,9 @@ #include <X11/extensions/dpmsconst.h> #include "dpmsproc.h" #endif +#ifdef XSERVER_LIBPCIACCESS #include "xf86VGAarbiter.h" - +#endif #ifdef DPMSExtension static DevPrivateKeyRec DPMSKeyRec; diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 350918d..74e0bc2 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -78,7 +78,9 @@ #include "picturestr.h" #include "xf86Bus.h" +#ifdef XSERVER_LIBPCIACCESS #include "xf86VGAarbiter.h" +#endif #include "globals.h" #include "xserver-properties.h" @@ -88,7 +90,6 @@ #endif #include <hotplug.h> - #ifdef XF86PM void (*xf86OSPMClose)(void) = NULL; #endif @@ -1355,6 +1356,7 @@ ddxProcessArgument(int argc, char **argv, int i) xf86DoShowOptions = TRUE; return 1; } +#ifdef XSERVER_LIBPCIACCESS if (!strcmp(argv[i], "-isolateDevice")) { CHECK_FOR_REQUIRED_ARGUMENT(); @@ -1364,6 +1366,7 @@ ddxProcessArgument(int argc, char **argv, int i) xf86PciIsolateDevice(argv[i]); return 2; } +#endif /* Notice cmdline xkbdir, but pass to dix as well */ if (!strcmp(argv[i], "-xkbdir")) { @@ -1432,7 +1435,9 @@ ddxUseMsg(void) #endif ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n"); ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); +#ifdef XSERVER_LIBPCIACCESS ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); +#endif ErrorF("-version show the server version\n"); ErrorF("-showDefaultModulePath show the server default module path\n"); ErrorF("-showDefaultLibPath show the server default library path\n"); diff --git a/hw/xfree86/common/xf86fbBus.c b/hw/xfree86/common/xf86fbBus.c index 059e378..4592980 100644 --- a/hw/xfree86/common/xf86fbBus.c +++ b/hw/xfree86/common/xf86fbBus.c @@ -54,8 +54,10 @@ xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active) EntityPtr p; int num; +#ifdef XSERVER_LIBPCIACCESS if (pciSlotClaimed) return -1; +#endif #if defined(__sparc__) || defined (__sparc64__) if (sbusSlotClaimed) return -1; diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index 43e9d1d..e2ca558 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -41,9 +41,6 @@ #include "colormapst.h" #include "xf86Module.h" #include "xf86Opt.h" -#include "xf86Pci.h" - -#include <pciaccess.h> /** * Integer type that is of the size of the addressable memory (machine size). @@ -309,6 +306,8 @@ typedef struct { struct _SymTabRec; struct _PciChipsets; +struct pci_device; + typedef struct _DriverRec { int driverVersion; char * driverName; @@ -350,8 +349,6 @@ typedef enum { BUS_last /* Keep last */ } BusType; -struct pci_device; - typedef struct { int fbNum; } SbusBusId; diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 4a03428..669da0d 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -33,6 +33,7 @@ #include <string.h> #include <stdio.h> +#include <X11/Xarch.h> #include "xf86.h" #include "xf86DDC.h" #include "xf86Crtc.h" diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am index 16c1021..e09d4d2 100644 --- a/hw/xfree86/os-support/bus/Makefile.am +++ b/hw/xfree86/os-support/bus/Makefile.am @@ -1,7 +1,10 @@ noinst_LTLIBRARIES = libbus.la sdk_HEADERS = xf86Pci.h -PCI_SOURCES = Pci.c Pci.h +PCI_SOURCES = +if XORG_BUS_PCI +PCI_SOURCES += Pci.c Pci.h +endif if XORG_BUS_BSDPCI PCI_SOURCES += bsd_pci.c diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh index 1755f02..b8e7023 100755 --- a/hw/xfree86/sdksyms.sh +++ b/hw/xfree86/sdksyms.sh @@ -120,14 +120,16 @@ cat > sdksyms.c << EOF #include "xf86.h" #include "xf86Module.h" #include "xf86Opt.h" -#include "xf86PciInfo.h" +#ifdef XSERVER_LIBPCIACCESS + #include "xf86PciInfo.h" + #include "xf86VGAarbiter.h" +#endif #include "xf86Priv.h" #include "xf86Privstr.h" #include "xf86cmap.h" #include "xf86fbman.h" #include "xf86str.h" #include "xf86Xinput.h" -#include "xf86VGAarbiter.h" #include "xisb.h" #if XV # include "xf86xv.h" @@ -172,7 +174,9 @@ cat > sdksyms.c << EOF /* hw/xfree86/os-support/bus/Makefile.am */ -#include "xf86Pci.h" +#ifdef XSERVER_LIBPCIACCESS +# include "xf86Pci.h" +#endif #if defined(__sparc__) || defined(__sparc) # include "xf86Sbus.h" #endif diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in index 33bf908..6b9230f 100644 --- a/include/xorg-config.h.in +++ b/include/xorg-config.h.in @@ -127,4 +127,7 @@ /* Build with libdrm support */ #undef WITH_LIBDRM +/* Use libpciaccess */ +#undef XSERVER_LIBPCIACCESS + #endif /* _XORG_CONFIG_H_ */ commit 5c12399b6c3a8def2df1bdde1d5d4d8d9e31fd84 Author: Tiago Vignatti <tiago.vignatti at nokia.com> Date: Mon May 31 19:27:07 2010 +0300 configure: make PCI configuration more sane No semantical changes. Just moved code around, grouping PCI related stuff in a single chunk. Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com> Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/configure.ac b/configure.ac index a7bec3d..2edeb4d 100644 --- a/configure.ac +++ b/configure.ac @@ -1270,7 +1270,6 @@ if test "x$XDMAUTH" = xyes; then fi AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path]) -AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path]) AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path]) AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path]) dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri` @@ -1521,9 +1520,6 @@ if test "x$XORG" = xauto; then fi AC_MSG_RESULT([$XORG]) -xorg_bus_bsdpci=no -xorg_bus_sparc=no - if test "x$XORG" = xyes; then XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common' XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os' @@ -1571,10 +1567,32 @@ if test "x$XORG" = xyes; then AC_SUBST([symbol_visibility]) dnl =================================================================== + dnl =================================================================== + dnl ================= beginning of PCI configuration ================== + dnl =================================================================== + xorg_bus_bsdpci=no + xorg_bus_sparc=no + PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS) XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS" XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" + AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation]) + AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path]) + case $host_os in + gnu* | freebsd* | kfreebsd*-gnu | netbsd* | openbsd* | solaris* | dragonfly*) + xorg_bus_bsdpci="yes" + ;; + esac + case $host_cpu in + sparc*) + xorg_bus_sparc="yes" + ;; + esac + dnl =================================================================== + dnl ==================== end of PCI configuration ===================== + dnl =================================================================== + case $host_os in linux*) if test "x$LNXAPM" = xyes; then @@ -1595,11 +1613,9 @@ if test "x$XORG" = xyes; then ;; freebsd* | kfreebsd*-gnu | dragonfly*) XORG_OS_SUBDIR="bsd" - xorg_bus_bsdpci="yes" ;; netbsd*) XORG_OS_SUBDIR="bsd" - xorg_bus_bsdpci="yes" ;; openbsd*) if test "x$ac_cv_BSD_APM" = xyes \ @@ -1607,14 +1623,10 @@ if test "x$XORG" = xyes; then XORG_CFLAGS="$XORG_CFLAGS -DXF86PM" fi XORG_OS_SUBDIR="bsd" - xorg_bus_bsdpci="yes" ;; solaris*) XORG_OS_SUBDIR="solaris" XORG_CFLAGS="$XORG_CFLAGS -DXF86PM" - # Use the same stubs as BSD for old functions, since we now - # use libpciaccess for PCI - xorg_bus_bsdpci="yes" AC_CHECK_HEADERS([sys/kd.h]) AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no]) # Check for minimum supported release @@ -1659,9 +1671,6 @@ if test "x$XORG" = xyes; then ;; gnu*) XORG_OS_SUBDIR="hurd" - # Use the same stubs as BSD for old functions, since we now - # use libpciaccess for PCI - xorg_bus_bsdpci="yes" ;; *) XORG_OS_SUBDIR="stub" @@ -1674,9 +1683,6 @@ if test "x$XORG" = xyes; then esac case $host_cpu in - sparc*) - xorg_bus_sparc="yes" - ;; i*86) ;; esac @@ -1733,7 +1739,6 @@ if test "x$XORG" = xyes; then AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path]) AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location]) AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support]) - AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation]) if test "x$VGAHW" = xyes; then AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module]) fi commit a319e9e697faa0faa241e0e9baf0bc41efdcdf8f Author: Tiago Vignatti <tiago.vignatti at nokia.com> Date: Mon May 31 18:50:50 2010 +0300 configure: change PCI function checking by a meaningful version of the library People that don't want VGA arbiter active can go to the library and enable the stubs there. Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com> Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/configure.ac b/configure.ac index 2ff247d..a7bec3d 100644 --- a/configure.ac +++ b/configure.ac @@ -1572,16 +1572,6 @@ if test "x$XORG" = xyes; then dnl =================================================================== PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS) - SAVE_LIBS=$LIBS - SAVE_CFLAGS=$CFLAGS - CFLAGS=$PCIACCESS_CFLAGS - LIBS=$PCIACCESS_LIBS - AC_CHECK_FUNCS([pci_system_init_dev_mem]) - AC_CHECK_FUNCS([pci_device_enable]) - AC_CHECK_FUNCS([pci_device_is_boot_vga]) - AC_CHECK_FUNCS([pci_device_vgaarb_init]) - LIBS=$SAVE_LIBS - CFLAGS=$SAVE_CFLAGS XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS" XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c index 215e845..819ad6e 100644 --- a/hw/xfree86/common/xf86VGAarbiter.c +++ b/hw/xfree86/common/xf86VGAarbiter.c @@ -31,8 +31,6 @@ #include "xorg-config.h" #include "xf86VGAarbiter.h" - -#ifdef HAVE_PCI_DEVICE_VGAARB_INIT #include "xf86VGAarbiterPriv.h" #include "xf86Bus.h" #include "xf86Priv.h" @@ -1112,16 +1110,3 @@ VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRe VGAPut(); PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects); } -#else -/* dummy functions */ -void xf86VGAarbiterInit(void) {} -void xf86VGAarbiterFini(void) {} - -void xf86VGAarbiterLock(ScrnInfoPtr pScrn) {} -void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) {} -Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) { return TRUE; } -void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) {} -void xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc) {} -Bool xf86VGAarbiterWrapFunctions(void) { return FALSE; } - -#endif diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 2acf486..eb5323c 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -121,12 +121,10 @@ xf86PciProbe(void) xf86PciVideoInfo[num - 1] = info; pci_device_probe(info); -#ifdef HAVE_PCI_DEVICE_IS_BOOT_VGA if (pci_device_is_boot_vga(info)) { primaryBus.type = BUS_PCI; primaryBus.id.pci = info; } -#endif info->user_data = 0; } } diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index 525bfb6..20dbde8 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -202,10 +202,8 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; -#if HAVE_PCI_SYSTEM_INIT_DEV_MEM if (useDevMem) pci_system_init_dev_mem(devMemFd); -#endif #ifdef HAS_MTRR_SUPPORT if (useDevMem) { diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c index 2965b37..564447f 100644 --- a/hw/xfree86/os-support/linux/int10/linux.c +++ b/hw/xfree86/os-support/linux/int10/linux.c @@ -261,10 +261,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) struct pci_device *rom_device = xf86GetPciInfoForEntity(pInt->entityIndex); -#if HAVE_PCI_DEVICE_ENABLE pci_device_enable(rom_device); -#endif - err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS)); if (err) { xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n", diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in index 0d1ea91..33bf908 100644 --- a/include/xorg-config.h.in +++ b/include/xorg-config.h.in @@ -118,18 +118,6 @@ /* Have execinfo.h */ #undef HAVE_EXECINFO_H -/* Have pci_system_init_dev_mem() */ -#undef HAVE_PCI_SYSTEM_INIT_DEV_MEM - -/* Define to 1 if you have the `pci_device_is_boot_vga' function. */ -#undef HAVE_PCI_DEVICE_IS_BOOT_VGA - -/* Have pci_enable_device */ -#undef HAVE_PCI_DEVICE_ENABLE - -/* Define to 1 if you have the `pci_device_vgaarb_init' function. */ -#undef HAVE_PCI_DEVICE_VGAARB_INIT - /* Path to text files containing PCI IDs */ #undef PCI_TXT_IDS_PATH commit b3ca84430d98f5338b9b1bc817c3656efb71cff1 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Sep 13 15:32:16 2011 -0500 xfree86: Work around issue where ar may be told to make an archive with no contents Automake: "Be careful when selecting library components conditionally. Because building an empty library is not portable, you should ensure that any library always contains at least one object." Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Gaetan Nadon <memsize at videotron.ca> diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am index b1ca8f9..16c1021 100644 --- a/hw/xfree86/os-support/bus/Makefile.am +++ b/hw/xfree86/os-support/bus/Makefile.am @@ -12,7 +12,7 @@ PLATFORM_SOURCES = Sbus.c sdk_HEADERS += xf86Sbus.h endif -libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES) +libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES) nobus.c INCLUDES = $(XORG_INCS) diff --git a/hw/xfree86/os-support/bus/nobus.c b/hw/xfree86/os-support/bus/nobus.c new file mode 100644 index 0000000..ad23f52 --- /dev/null +++ b/hw/xfree86/os-support/bus/nobus.c @@ -0,0 +1 @@ +static void __noop_to_appease_ar__() { return; } commit e8bafb9d8c7d7a7077e163ecfac6174356989bbf Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Sep 13 15:38:45 2011 -0500 xfree86: Add stubs for os-support to help adding new architecture support Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> Reviewed-by: Gaetan Nadon <memsize at videotron.ca> diff --git a/configure.ac b/configure.ac index 2148721..2ff247d 100644 --- a/configure.ac +++ b/configure.ac @@ -1674,8 +1674,8 @@ if test "x$XORG" = xyes; then xorg_bus_bsdpci="yes" ;; *) - XORG_OS_SUBDIR="unknown" - AC_MSG_ERROR([m4_text_wrap(m4_join([ ], + XORG_OS_SUBDIR="stub" + AC_MSG_NOTICE([m4_text_wrap(m4_join([ ], [Your OS is unknown. Xorg currently only supports Linux,], [Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.], [If you are interested in porting Xorg to your platform,], @@ -2176,6 +2176,7 @@ hw/xfree86/os-support/hurd/Makefile hw/xfree86/os-support/misc/Makefile hw/xfree86/os-support/linux/Makefile hw/xfree86/os-support/solaris/Makefile +hw/xfree86/os-support/stub/Makefile hw/xfree86/parser/Makefile hw/xfree86/ramdac/Makefile hw/xfree86/shadowfb/Makefile diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am index 094563d..a0140a1 100644 --- a/hw/xfree86/os-support/Makefile.am +++ b/hw/xfree86/os-support/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS) -DIST_SUBDIRS = bsd bus misc linux solaris hurd +DIST_SUBDIRS = bsd bus misc linux solaris stub hurd sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h diff --git a/hw/xfree86/os-support/stub/Makefile.am b/hw/xfree86/os-support/stub/Makefile.am new file mode 100644 index 0000000..a1156ef --- /dev/null +++ b/hw/xfree86/os-support/stub/Makefile.am @@ -0,0 +1,19 @@ +noinst_LTLIBRARIES = libstub.la + +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) + +INCLUDES = $(XORG_INCS) + +libstub_la_SOURCES = \ + $(srcdir)/../shared/VTsw_noop.c \ + $(srcdir)/../shared/agp_noop.c \ + $(srcdir)/../shared/ioperm_noop.c \ + $(srcdir)/../shared/kmod_noop.c \ + $(srcdir)/../shared/pm_noop.c \ + $(srcdir)/../shared/vidmem.c \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c \ + stub_bell.c \ + stub_bios.c \ + stub_init.c \ + stub_video.c diff --git a/hw/xfree86/os-support/stub/stub_bell.c b/hw/xfree86/os-support/stub/stub_bell.c new file mode 100644 index 0000000..4862592 --- /dev/null +++ b/hw/xfree86/os-support/stub/stub_bell.c @@ -0,0 +1,10 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" + +void +xf86OSRingBell(int loudness, int pitch, int duration) +{ +} diff --git a/hw/xfree86/os-support/stub/stub_bios.c b/hw/xfree86/os-support/stub/stub_bios.c new file mode 100644 index 0000000..8628316 --- /dev/null +++ b/hw/xfree86/os-support/stub/stub_bios.c @@ -0,0 +1,12 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" + +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + return -1; +} diff --git a/hw/xfree86/os-support/stub/stub_init.c b/hw/xfree86/os-support/stub/stub_init.c new file mode 100644 index 0000000..36fd2b8 --- /dev/null +++ b/hw/xfree86/os-support/stub/stub_init.c @@ -0,0 +1,26 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" + +void +xf86OpenConsole() +{ +} + +void +xf86CloseConsole() +{ +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + return 0; +} + +void +xf86UseMsg() +{ +} diff --git a/hw/xfree86/os-support/stub/stub_video.c b/hw/xfree86/os-support/stub/stub_video.c new file mode 100644 index 0000000..3274968 --- /dev/null +++ b/hw/xfree86/os-support/stub/stub_video.c @@ -0,0 +1,13 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->initialised = TRUE; + return; +} commit 342f3eac8460fc48cfad1f1d7be939d671e6e1cd Author: Adam Jackson <ajax at redhat.com> Date: Tue May 10 19:00:02 2011 -0400 int10: Port internal users off xf86MapVidMem This API is apparently semi-deprecated even by XFree86 standards, and there are only four drivers left using it. Let's start chopping it off. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c index 53cd525..fbc9b85 100644 --- a/hw/xfree86/int10/generic.c +++ b/hw/xfree86/int10/generic.c @@ -103,8 +103,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) MapVRam(pInt); #ifdef _PC if (!sysMem) - sysMem = xf86MapVidMem(screen, VIDMEM_MMIO, V_BIOS, - BIOS_SIZE + SYS_BIOS - V_BIOS); + pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS, + PCI_DEV_MAP_FLAG_WRITABLE, &sysMem); INTPriv(pInt)->sysMem = sysMem; if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) { diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c index f74da47..638f566 100644 --- a/hw/xfree86/int10/helper_exec.c +++ b/hw/xfree86/int10/helper_exec.c @@ -680,10 +680,12 @@ static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set) { int pagesize = getpagesize(); - unsigned char* base = xf86MapVidMem(pInt->scrnIndex, - VIDMEM_MMIO, 0, pagesize); + unsigned char* base; int i; + if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base)) + return; /* eek */ + if (set) { for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++) MEM_WW(pInt, i, *(base + i)); @@ -692,7 +694,7 @@ SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set) *(base + i) = MEM_RW(pInt, i); } - xf86UnMapVidMem(pInt->scrnIndex,base,pagesize); + pci_device_unmap_legacy(pInt->dev, base, pagesize); } void @@ -706,7 +708,9 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save) || (!save && !pInt->BIOSScratch)) return; - base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize); + if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base)) + return; /* eek */ + base += BIOS_SCRATCH_OFF; if (save) { if ((pInt->BIOSScratch @@ -722,7 +726,7 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save) } } - xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize); + pci_device_unmap_legacy(pInt->dev, base, pagesize); } #endif commit 7757b8092474c4f4ec04f4ebd1272236416154c3 Author: Adam Jackson <ajax at redhat.com> Date: Tue May 10 17:34:23 2011 -0400 pci: Remove xf86MapDomainMemory This is slightly draconian, but that API is just awful. In all but one case in the callers it's used to get a map of some legacy VGA memory, and it would be cleaner for the caller to just call pci_device_map_legacy. The sole exception is in the vesa driver, which uses it to avoid having to look up which device the BAR belongs to. That's similarly trivial to fix. Having done that, Linux's PCI layer is now very small indeed. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> diff --git a/configure.ac b/configure.ac index 7055df5..2148721 100644 --- a/configure.ac +++ b/configure.ac @@ -793,7 +793,7 @@ LIBXEXT="xext >= 1.0.99.4" LIBXFONT="xfont >= 1.4.2" LIBXI="xi >= 1.2.99.1" LIBXTST="xtst >= 1.0.99.2" -LIBPCIACCESS="pciaccess >= 0.8.0" +LIBPCIACCESS="pciaccess >= 0.12.901" LIBUDEV="libudev >= 143" LIBSELINUX="libselinux >= 2.0.86" LIBDBUS="dbus-1 >= 1.0" @@ -1521,7 +1521,6 @@ if test "x$XORG" = xauto; then fi AC_MSG_RESULT([$XORG]) -xorg_bus_linuxpci=no xorg_bus_bsdpci=no xorg_bus_sparc=no @@ -1592,7 +1591,6 @@ if test "x$XORG" = xyes; then XORG_CFLAGS="$XORG_CFLAGS -DXF86PM" fi XORG_OS_SUBDIR="linux" - xorg_bus_linuxpci="yes" linux_acpi="no" case $host_cpu in alpha*) @@ -1775,7 +1773,6 @@ if test "x$XORG" = xyes; then AC_SUBST([abi_extension]) fi AM_CONDITIONAL([XORG], [test "x$XORG" = xyes]) -AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes]) AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes]) AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes]) AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes]) diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c index 040d999..53cd525 100644 --- a/hw/xfree86/int10/generic.c +++ b/hw/xfree86/int10/generic.c @@ -238,9 +238,7 @@ MapVRam(xf86Int10InfoPtr pInt) int pagesize = getpagesize(); int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize; - INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO, - pInt->dev, V_RAM, size); - + pci_device_map_legacy(pInt->dev, V_RAM, size, PCI_DEV_MAP_FLAG_WRITABLE, &(INTPriv(pInt)->vRam)); pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024); } @@ -251,8 +249,7 @@ UnmapVRam(xf86Int10InfoPtr pInt) int pagesize = getpagesize(); int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize; - xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size); - + pci_device_unmap_legacy(pInt->dev, INTPriv(pInt)->vRam, size); pci_device_close_io(pInt->dev, pInt->io); pInt->io = NULL; } diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am index 643cb25..b1ca8f9 100644 --- a/hw/xfree86/os-support/bus/Makefile.am +++ b/hw/xfree86/os-support/bus/Makefile.am @@ -3,10 +3,6 @@ sdk_HEADERS = xf86Pci.h PCI_SOURCES = Pci.c Pci.h -if XORG_BUS_LINUXPCI -PCI_SOURCES += linuxPci.c -endif - if XORG_BUS_BSDPCI PCI_SOURCES += bsd_pci.c endif diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c index f51d5c0..7a5dbbb 100644 --- a/hw/xfree86/os-support/bus/bsd_pci.c +++ b/hw/xfree86/os-support/bus/bsd_pci.c @@ -48,13 +48,6 @@ #include "pciaccess.h" -pointer -xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size) -{ - return xf86MapVidMem(ScreenNum, Flags, Base, Size); -} - void osPciInit(void) { diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c deleted file mode 100644 index 8f314b5..0000000 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - * Copyright 1998 by Metro Link Incorporated - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include "xf86_OSlib.h" -#include "Pci.h" - -/** - * \bug - * The generation of the procfs file name for the domain != 0 case may not be - * correct. - */ -static int -linuxPciOpenFile(struct pci_device *dev, Bool write) -{ - static struct pci_device *last_dev = NULL; - static int fd = -1,is_write = 0; - char file[64]; - - if (dev == NULL) { - return -1; - } - - if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) { - if (fd != -1) { - close(fd); - fd = -1; - } - - sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config", - dev->domain, dev->bus, dev->dev, dev->func); - - if (write) { - fd = open(file,O_RDWR); - if (fd != -1) is_write = TRUE; - } else { - switch (is_write) { - case TRUE: - fd = open(file,O_RDWR); - if (fd > -1) - break; - default: - fd = open(file,O_RDONLY); - is_write = FALSE; - } - } - - last_dev = dev; - } - - return fd; -} - -/* - * Compiling the following simply requires the presence of <linux/pci.c>. - * Actually running this is another matter altogether... - * - * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O - * and memory spaces through its /proc/bus/pci/BUS/DFN entry. Which one is - * determined by a prior ioctl(). - * - * For the sparc64 port, this means 2.4.12 or later. For ppc, this - * functionality is almost, but not quite there yet. Alpha and other kernel - * ports to multi-domain architectures still need to implement this. - * - * TO DO: Address the deleterious reaction some host bridges have to master - * aborts. This is already done for secondary PCI buses, but not yet - * for accesses to primary buses (except for the SPARC port, where - * master aborts are avoided during PCI scans). - */ - -#include <linux/pci.h> - -#ifndef PCIIOC_BASE /* Ioctls for /proc/bus/pci/X/Y nodes. */ -#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8) - -/* Get controller for PCI device. */ -#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) -/* Set mmap state to I/O space. */ -#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) -/* Set mmap state to MEM space. */ -#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) -/* Enable/disable write-combining. */ -#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) - -#endif - -static pointer -linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size, int mmap_ioctl) -{ - /* Align to page boundary */ - const ADDRESS realBase = Base & ~(getpagesize() - 1); - const ADDRESS Offset = Base - realBase; - - do { - unsigned char *result; - int fd, mmapflags, prot; - - xf86InitVidMem(); - - /* If dev is NULL, linuxPciOpenFile will return -1, and this routine - * will fail gracefully. - */ - prot = ((Flags & VIDMEM_READONLY) == 0); - if (((fd = linuxPciOpenFile(dev, prot)) < 0) || - (ioctl(fd, mmap_ioctl, 0) < 0)) - break; - -/* Note: IA-64 doesn't compile this and doesn't need to */ -#ifdef __ia64__ - -# ifndef MAP_WRITECOMBINED -# define MAP_WRITECOMBINED 0x00010000 -# endif -# ifndef MAP_NONCACHED -# define MAP_NONCACHED 0x00020000 -# endif - - if (Flags & VIDMEM_FRAMEBUFFER) - mmapflags = MAP_SHARED | MAP_WRITECOMBINED; - else - mmapflags = MAP_SHARED | MAP_NONCACHED; - -#else /* !__ia64__ */ - - mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER; - - if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0) - break; - - mmapflags = MAP_SHARED; - -#endif /* ?__ia64__ */ - - - if (Flags & VIDMEM_READONLY) - prot = PROT_READ; - else - prot = PROT_READ | PROT_WRITE; - - result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase); - - if (!result || ((pointer)result == MAP_FAILED)) - return NULL; - - xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result); - - return result + Offset; - } while (0); - - if (mmap_ioctl == PCIIOC_MMAP_IS_MEM) - return xf86MapVidMem(ScreenNum, Flags, Base, Size); - - return NULL; -} - -static int -linuxOpenLegacy(struct pci_device *dev, char *name) -{ - static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s"; - char path[sizeof(PREFIX) + 10]; - int fd = -1; - - while (dev != NULL) { - snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name); - fd = open(path, O_RDWR); - if (fd >= 0) { - return fd; - } - - dev = pci_device_get_parent_bridge(dev); - } - - return fd; -} - -/* - * xf86MapDomainMemory - memory map PCI domain memory - * - * This routine maps the memory region in the domain specified by Tag and - * returns a pointer to it. The pointer is saved for future use if it's in - * the legacy ISA memory space (memory in a domain between 0 and 1MB). - */ -pointer -xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size) -{ - int fd = -1; - pointer addr; - - /* - * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs - * legacy_mem interface is unavailable. - */ - if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0)) - return linuxMapPci(ScreenNum, Flags, dev, Base, Size, - PCIIOC_MMAP_IS_MEM); - else - addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); - - if (fd >= 0) - close(fd); - if (addr == NULL || addr == MAP_FAILED) { - perror("mmap failure"); - FatalError("xf86MapDomainMem(): mmap() failure\n"); - } - return addr; -} diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h index 6c9a0a1..74ead20 100644 --- a/hw/xfree86/os-support/bus/xf86Pci.h +++ b/hw/xfree86/os-support/bus/xf86Pci.h @@ -254,8 +254,6 @@ typedef enum { extern _X_EXPORT Bool xf86scanpci(void); /* Domain access functions. Some of these probably shouldn't be public */ -extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size); extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev); extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *); diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c index 072c599..4036a01 100644 --- a/hw/xfree86/vgahw/vgaHW.c +++ b/hw/xfree86/vgahw/vgaHW.c @@ -1741,7 +1741,6 @@ Bool vgaHWMapMem(ScrnInfoPtr scrp) { vgaHWPtr hwp = VGAHWPTR(scrp); - int scr_index = scrp->scrnIndex; if (hwp->Base) return TRUE; @@ -1759,8 +1758,7 @@ vgaHWMapMem(ScrnInfoPtr scrp) * for now. */ DebugF("Mapping VGAMem\n"); - hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->dev, - hwp->MapPhys, hwp->MapSize); + pci_device_map_legacy(hwp->dev, hwp->MapPhys, hwp->MapSize, PCI_DEV_MAP_FLAG_WRITABLE, &hwp->Base); return hwp->Base != NULL; } @@ -1769,13 +1767,12 @@ void vgaHWUnmapMem(ScrnInfoPtr scrp) { vgaHWPtr hwp = VGAHWPTR(scrp); - int scr_index = scrp->scrnIndex; if (hwp->Base == NULL) return; DebugF("Unmapping VGAMem\n"); - xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize); + pci_device_unmap_legacy(hwp->dev, hwp->Base, hwp->MapSize); hwp->Base = NULL; } commit 6f5041d0b8e11e761d6403f1f8f8bb2ba2a9626d Author: Adam Jackson <ajax at redhat.com> Date: Tue May 10 18:04:10 2011 -0400 int10: Use pciaccess rom fetch for !PC machines ... instead of rolling our own, badly. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c index beb90b5..040d999 100644 --- a/hw/xfree86/int10/generic.c +++ b/hw/xfree86/int10/generic.c @@ -62,62 +62,6 @@ static void UnmapVRam(xf86Int10InfoPtr pInt); static void *sysMem = NULL; -/** - * Read legacy VGA video BIOS associated with specified domain. - * - * Attempts to read up to 128KiB of legacy VGA video BIOS. - * - * \return - * The number of bytes read on success or -1 on failure. - * - * \bug - * PCI ROMs can contain multiple BIOS images (e.g., OpenFirmware, x86 VGA, - * etc.). How do we know that \c pci_device_read_rom will return the - * legacy VGA BIOS image? - */ -#ifndef _PC -static int -read_legacy_video_BIOS(struct pci_device *dev, unsigned char *Buf) -{ - const ADDRESS Base = 0xC0000; - const int Len = 0x10000 * 2; - const int pagemask = getpagesize() - 1; - const ADDRESS offset = Base & ~pagemask; - const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset; - unsigned char *ptr, *src; - int len; - - - /* Try to use the civilized PCI interface first. - */ - if (pci_device_read_rom(dev, Buf) == 0) { - return dev->rom_size; - } - - ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, dev, offset, size); - - if (!ptr) - return -1; - - /* Using memcpy() here can hang the system */ - src = ptr + (Base - offset); - for (len = 0; len < (Len / 2); len++) { - Buf[len] = src[len]; - } - - if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) { - for ( /* empty */ ; len < Len; len++) { - Buf[len] = src[len]; - } - } - - xf86UnMapVidMem(-1, ptr, size); - - return Len; -} -#endif /* _PC */ - - xf86Int10InfoPtr xf86ExtendedInitInt10(int entityIndex, int Flags) { @@ -232,7 +176,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) */ vbiosMem = (char *)base + V_BIOS; memset(vbiosMem, 0, 2 * V_BIOS_SIZE); - if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) { + if (pci_device_read_rom(pInt->dev, vbiosMem) < V_BIOS_SIZE) { xf86DrvMsg(screen, X_WARNING, "Unable to retrieve all of segment 0x0C0000.\n"); } commit 492ed3e53b0ee6746bd4b597978fd866d4a89ef6 Author: Adam Jackson <ajax at redhat.com> Date: Tue May 10 16:41:08 2011 -0400 pci: Deprecate the PCITAG type It is kept around to help drivers through the API transition and will be removed at some point in the future. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c index 8b52e88..f74da47 100644 --- a/hw/xfree86/int10/helper_exec.c +++ b/hw/xfree86/int10/helper_exec.c @@ -475,7 +475,7 @@ static struct pci_device* pci_device_for_cfg_address (CARD32 addr) { struct pci_device *dev = NULL; - PCITAG tag = PCI_TAG(addr); + CARD32 tag = PCI_TAG(addr); struct pci_slot_match slot_match = { .domain = PCI_DOM_FROM_TAG(tag), .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)), diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index f1dbfc2..0362a00 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -126,12 +126,6 @@ #include "Pci.h" -PCITAG -pciTag(int busnum, int devnum, int funcnum) -{ - return(PCI_MAKE_TAG(busnum,devnum,funcnum)); -} - Bool xf86scanpci(void) { diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h index 3a17c30..6c9a0a1 100644 --- a/hw/xfree86/os-support/bus/xf86Pci.h +++ b/hw/xfree86/os-support/bus/xf86Pci.h @@ -236,7 +236,7 @@ /* Primitive Types */ typedef unsigned long ADDRESS; /* Memory/PCI address */ typedef unsigned long IOADDRESS _X_DEPRECATED; /* Must be large enough for a pointer */ -typedef unsigned long PCITAG; +typedef CARD32 PCITAG _X_DEPRECATED; typedef enum { PCI_MEM, @@ -251,7 +251,6 @@ typedef enum { /* Public PCI access functions */ -extern _X_EXPORT PCITAG pciTag(int busnum, int devnum, int funcnum); extern _X_EXPORT Bool xf86scanpci(void); /* Domain access functions. Some of these probably shouldn't be public */ commit a248fa3a33cb015942386d52b7faa8558e592a51 Author: Adam Jackson <ajax at redhat.com> Date: Fri Jan 7 17:20:15 2011 -0500 xfree86: Remove unused bios_devmem.c Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am index 348b7ff..094563d 100644 --- a/hw/xfree86/os-support/Makefile.am +++ b/hw/xfree86/os-support/Makefile.am @@ -16,6 +16,3 @@ libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib at XORG_OS_SUBDIR@.la \ AM_CFLAGS = $(DIX_CFLAGS) -# FIXME: These don't seem to be used anywhere -EXTRA_DIST += \ - shared/bios_devmem.c diff --git a/hw/xfree86/os-support/shared/bios_devmem.c b/hw/xfree86/os-support/shared/bios_devmem.c deleted file mode 100644 index b9dfb7d..0000000 --- a/hw/xfree86/os-support/shared/bios_devmem.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 1993 by David Wexelblat <dwex at goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of David Wexelblat not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. David Wexelblat makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include <string.h> - -/* - * Read BIOS via /dev/mem. - */ - -#ifndef DEV_MEM -# define DEV_MEM "/dev/mem" -#endif - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int fd; - -#ifdef __ia64__ - if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0) -#else - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) -#endif - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return -1; - } - - if (lseek(fd, (Base+Offset), SEEK_SET) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return -1; - } - if (read(fd, Buf, Len) != Len) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return -1; - } - close(fd); - return Len; -} commit aa0bfb0f133481c57762012e8e30c05ffa151423 Author: Adam Jackson <ajax at redhat.com> Date: Fri Jan 7 16:57:15 2011 -0500 linux: Remove ia64 domain I/O support code pciaccess handles this now. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/configure.ac b/configure.ac index 67a6836..7055df5 100644 --- a/configure.ac +++ b/configure.ac @@ -1595,14 +1595,10 @@ if test "x$XORG" = xyes; then xorg_bus_linuxpci="yes" linux_acpi="no" case $host_cpu in - ia64*) - linux_ia64=yes - linux_acpi="yes" - ;; alpha*) linux_alpha=yes ;; - i*86|amd64*|x86_64*) + i*86|amd64*|x86_64*|ia64*) linux_acpi="yes" ;; *) @@ -1782,7 +1778,6 @@ AM_CONDITIONAL([XORG], [test "x$XORG" = xyes]) AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes]) AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes]) AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes]) -AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes]) AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes]) AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes]) AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes]) diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am index 7a82627..36748df 100644 --- a/hw/xfree86/os-support/linux/Makefile.am +++ b/hw/xfree86/os-support/linux/Makefile.am @@ -1,9 +1,5 @@ noinst_LTLIBRARIES = liblinux.la -if LINUX_IA64 -PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c -PLATFORM_INCLUDES = -I$(srcdir)/../shared -endif if LINUX_ALPHA noinst_LTLIBRARIES += liblinuxev56.la PLATFORM_PCI_SUPPORT = \ diff --git a/hw/xfree86/os-support/shared/ia64Pci.c b/hw/xfree86/os-support/shared/ia64Pci.c deleted file mode 100644 index c93c74c..0000000 --- a/hw/xfree86/os-support/shared/ia64Pci.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, 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 - * XFREE86 PROJECT 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 XFree86 Project 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 - * XFree86 Project. - */ - -/* - * This file contains the glue needed to support various IA-64 chipsets. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <fcntl.h> -#include <unistd.h> -#include <signal.h> -#include <dirent.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <linux/pci.h> - -#include "compiler.h" -#include "Pci.h" - -/* - * We use special in/out routines here since Altix platforms require the - * use of the sysfs legacy_io interface. The legacy_io file maps to the I/O - * space of a given PCI domain; reads and writes are used to do port I/O. - * The file descriptor for the file is stored in the upper bits of the - * value passed in by the caller, and is created and populated by - * xf86MapLegacyIO. - * - * If the legacy_io interface doesn't exist, we fall back to the glibc in/out - * routines, which are prefixed by an underscore (e.g. _outb). - */ -static int ia64_port_to_fd(unsigned long port) -{ - return (port >> 24) & 0xffffffff; -} - -void outb(unsigned long port, unsigned char val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outb(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 1) != 1) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -void outw(unsigned long port, unsigned short val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outw(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 2) != 2) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -void outl(unsigned long port, unsigned int val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outl(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 4) != 4) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -unsigned int inb(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned char val; - - if (!fd) - return _inb(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 1) != 1) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - -unsigned int inw(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned short val; - - if (!fd) - return _inw(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 2) != 2) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - -unsigned int inl(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned int val; - - if (!fd) - return _inl(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 4) != 4) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - commit 95b6935637628ffa511f39004e90c75aa75141c4 Author: Adam Jackson <ajax at redhat.com> Date: Fri Oct 16 16:09:56 2009 -0400 linux: Remove pre-2.6 PCI interface support If you haven't ported 2.6 to your architecture in the intervening seven years, you can keep running older servers. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index 2778bba..8f314b5 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -63,47 +63,19 @@ linuxPciOpenFile(struct pci_device *dev, Bool write) static struct pci_device *last_dev = NULL; static int fd = -1,is_write = 0; char file[64]; - struct stat ignored; - static int is26 = -1; if (dev == NULL) { return -1; } - if (is26 == -1) { - is26 = (stat("/sys/bus/pci", &ignored) < 0) ? 0 : 1; - } - if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) { if (fd != -1) { close(fd); fd = -1; } - if (is26) { - sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config", - dev->domain, dev->bus, dev->dev, dev->func); - } else { - if (dev->domain == 0) { - sprintf(file,"/proc/bus/pci/%02x", dev->bus); - if (stat(file, &ignored) < 0) { - sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x", - dev->bus, dev->dev, dev->func); - } else { - sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", - dev->bus, dev->dev, dev->func); - } - } else { - sprintf(file,"/proc/bus/pci/%02x%02x", dev->domain, dev->bus); - if (stat(file, &ignored) < 0) { - sprintf(file, "/proc/bus/pci/%04x:%04x/%02x.%1x", - dev->domain, dev->bus, dev->dev, dev->func); - } else { - sprintf(file, "/proc/bus/pci/%02x%02x/%02x.%1x", - dev->domain, dev->bus, dev->dev, dev->func); - } - } - } + sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config", + dev->domain, dev->bus, dev->dev, dev->func); if (write) { fd = open(file,O_RDWR); commit 769f583783d17ffa3398bc8529f61e0f08b35530 Author: Adam Jackson <ajax at redhat.com> Date: Fri Oct 16 14:05:54 2009 -0400 bus: remove some dead struct fields Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c index 89db4cc..54f6c64 100644 --- a/hw/xfree86/os-support/shared/vidmem.c +++ b/hw/xfree86/os-support/shared/vidmem.c @@ -51,11 +51,9 @@ */ typedef struct { - unsigned long physBase; unsigned long size; pointer virtBase; pointer mtrrInfo; - int flags; } MappingRec, *MappingPtr; typedef struct { @@ -169,10 +167,8 @@ xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long S vp = getVidMapRec(ScreenNum); mp = newMapping(vp); - mp->physBase = Base; mp->size = Size; mp->virtBase = Vbase; - mp->flags = Flags; } void @@ -206,10 +202,8 @@ xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) vp = getVidMapRec(ScreenNum); mp = newMapping(vp); - mp->physBase = Base; mp->size = Size; mp->virtBase = vbase; - mp->flags = Flags; /* * Check the "mtrr" option even when MTRR isn't supported to avoid commit dd72b3c1f1df57215329aa5ba9e9bb9ad0a65086 Author: Adam Jackson <ajax at redhat.com> Date: Mon Sep 20 11:42:11 2010 -0400 linux: Use pci_device_get_parent_bridge instead of open-coding it Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index 28bba01..2778bba 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -160,45 +160,6 @@ linuxPciOpenFile(struct pci_device *dev, Bool write) #endif -/* This probably shouldn't be Linux-specific */ -static struct pci_device * -get_parent_bridge(struct pci_device *dev) -{ - struct pci_id_match bridge_match = { - PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, - (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8), - 0 - }; - struct pci_device *bridge; - struct pci_device_iterator *iter; - - if (dev == NULL) { - return NULL; - } - - iter = pci_id_match_iterator_create(& bridge_match); - if (iter == NULL) { - return NULL; - } - - while ((bridge = pci_device_next(iter)) != NULL) { - if (bridge->domain == dev->domain) { - const struct pci_bridge_info *info = - pci_device_get_bridge_info(bridge); - - if (info != NULL) { - if (info->secondary_bus == dev->bus) { - break; - } - } - } - } - - pci_iterator_destroy(iter); - - return bridge; -} - static pointer linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev, ADDRESS Base, unsigned long Size, int mmap_ioctl) @@ -283,7 +244,7 @@ linuxOpenLegacy(struct pci_device *dev, char *name) return fd; } - dev = get_parent_bridge(dev); + dev = pci_device_get_parent_bridge(dev); } return fd; commit 858fbbb40d7c69540cd1fb5315cebf811c6e7b3f Author: Adam Jackson <ajax at redhat.com> Date: Fri Sep 16 13:33:04 2011 -0400 pci: Port xf86MapLegacyIO to pciaccess Per-domain I/O is now something drivers must manually request, and must keep track of within their own state rather than in the ScrnInfoRec. It's not really possible to split that into two steps without an additional intermediate ABI break, so don't even try. Drivers that want source compatibility should ifdef on the presence of xf86UnmapLegacyIO. As a fringe benefit, domain-aware I/O is now OS-independent, relying only on support in pciaccess. Simplify OS PCI setup to reflect this. The IOADDRESS type is kept around to help drivers through the API transition and will be removed at some point in the future. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 3b08968..8749a29 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -308,7 +308,6 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex) pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList, pScrn->numEntities * sizeof(int)); pScrn->entityInstanceList[pScrn->numEntities - 1] = 0; - pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO; } void diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h index e161c7f..0b2ebdb 100644 --- a/hw/xfree86/common/xf86Bus.h +++ b/hw/xfree86/common/xf86Bus.h @@ -58,7 +58,6 @@ typedef struct { DevUnion * entityPrivates; int numInstances; GDevPtr * devices; - IOADDRESS domainIO; } EntityRec, *EntityPtr; #define ACCEL_IS_SHARABLE 0x100 diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 447b192..2acf486 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -235,11 +235,6 @@ xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp, xf86AddDevToEntity(num, dev); pciSlotClaimed = TRUE; - if (active) { - /* Map in this domain's I/O space */ - p->domainIO = xf86MapLegacyIO(d); - } - return num; } else return -1; @@ -1357,3 +1352,15 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo, if (*chipset < 0) *chipset = (pVideo->vendor_id << 16) | pVideo->device_id; } + +struct pci_io_handle * +xf86MapLegacyIO(struct pci_device *dev) +{ + return pci_legacy_open_io(dev, 0, 64 * 1024); +} + +void +xf86UnmapLegacyIO(struct pci_device *dev, struct pci_io_handle *handle) +{ + pci_device_close_io(dev, handle); +} diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index 0493dc5..43e9d1d 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -742,7 +742,6 @@ typedef struct _ScrnInfoRec { unsigned long biosBase; /* Base address of video BIOS */ unsigned long memPhysBase; /* Physical address of FB */ unsigned long fbOffset; /* Offset of FB in the above */ - IOADDRESS domainIOBase; /* Domain I/O base address */ int memClk; /* memory clock */ int textClockFreq; /* clock of text mode */ Bool flipPixels; /* swap default black/white */ diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index fe4850e..f1dbfc2 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -140,7 +140,7 @@ xf86scanpci(void) success = (pci_system_init() == 0); /* choose correct platform/OS specific PCI init routine */ - ARCH_PCI_INIT(); + osPciInit(); return success; } diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index 3493013..88560ec 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -137,20 +137,14 @@ #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u) -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ +#if defined(linux) +#define osPciInit(x) do {} while (0) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ defined(__OpenBSD__) || defined(__NetBSD__) || \ defined(__DragonFly__) || defined(__sun) || defined(__GNU__) -#define ARCH_PCI_INIT bsdPciInit -#endif - -#if defined(linux) -#define ARCH_PCI_INIT linuxPciInit -#endif /* defined(linux) */ - -#ifndef ARCH_PCI_INIT +extern void osPciInit(void); +#else #error No PCI support available for this architecture/OS combination #endif -extern void ARCH_PCI_INIT(void); - #endif /* _PCI_H */ diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c index 17b52db..f51d5c0 100644 --- a/hw/xfree86/os-support/bus/bsd_pci.c +++ b/hw/xfree86/os-support/bus/bsd_pci.c @@ -55,15 +55,8 @@ xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, return xf86MapVidMem(ScreenNum, Flags, Base, Size); } -IOADDRESS -xf86MapLegacyIO(struct pci_device *dev) -{ - (void)dev; - return 0; -} - void -bsdPciInit(void) +osPciInit(void) { xf86InitVidMem(); } diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index fcfdbcb..28bba01 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -52,21 +52,6 @@ #include "xf86_OSlib.h" #include "Pci.h" -static const struct pci_id_match match_host_bridge = { - PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, - (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_HOST << 8), - 0x0000ffff00, 0 -}; - -#define MAX_DOMAINS 257 -static pointer DomainMmappedIO[MAX_DOMAINS]; - -void -linuxPciInit(void) -{ - memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO)); -} - /** * \bug * The generation of the procfs file name for the domain != 0 case may not be @@ -153,15 +138,6 @@ linuxPciOpenFile(struct pci_device *dev, Bool write) * functionality is almost, but not quite there yet. Alpha and other kernel * ports to multi-domain architectures still need to implement this. * - * This scheme is also predicated on the use of an IOADDRESS compatible type to - * designate I/O addresses. Although IOADDRESS is defined as an unsigned - * integral type, it is actually the virtual address of, i.e. a pointer to, the - * I/O port to access. And so, the inX/outX macros in "compiler.h" need to be - * #define'd appropriately (as is done on SPARC's). - * - * Another requirement to port this scheme to another multi-domain architecture - * is to add the appropriate entries in the pciControllerSizes array below. - * * TO DO: Address the deleterious reaction some host bridges have to master * aborts. This is already done for secondary PCI buses, but not yet * for accesses to primary buses (except for the SPARC port, where @@ -223,67 +199,6 @@ get_parent_bridge(struct pci_device *dev) return bridge; } -/* - * This is ugly, but until I can extract this information from the kernel, - * it'll have to do. The default I/O space size is 64K, and 4G for memory. - * Anything else needs to go in this table. (PowerPC folk take note.) - * - * Note that Linux/SPARC userland is 32-bit, so 4G overflows to zero here. - * - * Please keep this table in ascending vendor/device order. - */ -static const struct pciSizes { - unsigned short vendor, device; - unsigned long io_size, mem_size; -} pciControllerSizes[] = { - { - PCI_VENDOR_SUN, PCI_CHIP_PSYCHO, - 1U << 16, 1U << 31 - }, - { - PCI_VENDOR_SUN, PCI_CHIP_SCHIZO, - 1U << 24, 1U << 31 /* ??? */ - }, - { - PCI_VENDOR_SUN, PCI_CHIP_SABRE, - 1U << 24, (unsigned long)(1ULL << 32) - }, - { - PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD, - 1U << 24, (unsigned long)(1ULL << 32) - } -}; -#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0])) - -static const struct pciSizes * -linuxGetSizesStruct(const struct pci_device *dev) -{ - static const struct pciSizes default_size = { - 0, 0, 1U << 16, (unsigned long)(1ULL << 32) - }; - int i; - - /* Look up vendor/device */ - if (dev != NULL) { - for (i = 0; i < NUM_SIZES; i++) { - if ((dev->vendor_id == pciControllerSizes[i].vendor) - && (dev->device_id == pciControllerSizes[i].device)) { - return & pciControllerSizes[i]; - } - } - } - - /* Default to 64KB I/O and 4GB memory. */ - return & default_size; -} - -static __inline__ unsigned long -linuxGetIOSize(const struct pci_device *dev) -{ - const struct pciSizes * const sizes = linuxGetSizesStruct(dev); - return sizes->io_size; -} - static pointer linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev, ADDRESS Base, unsigned long Size, int mmap_ioctl) @@ -406,45 +321,3 @@ xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, } return addr; } - -/** - * Map I/O space in this domain - * - * Each domain has a legacy ISA I/O space. This routine will try to - * map it using the Linux sysfs legacy_io interface. If that fails, - * it'll fall back to using /proc/bus/pci. - * - * If the legacy_io interface \b does exist, the file descriptor (\c fd below) - * will be saved in the \c DomainMmappedIO array in the upper bits of the - * pointer. Callers will do I/O with small port numbers (<64k values), so - * the platform I/O code can extract the port number and the \c fd, \c lseek - * to the port number in the legacy_io file, and issue the read or write. - * - * This has no means of returning failure, so all errors are fatal - */ -IOADDRESS -xf86MapLegacyIO(struct pci_device *dev) -{ - const int domain = dev->domain; - struct pci_device *bridge = get_parent_bridge(dev); - int fd; - - if (domain >= MAX_DOMAINS) - FatalError("xf86MapLegacyIO(): domain out of range\n"); - - if (DomainMmappedIO[domain] == NULL) { - /* Permanently map all of I/O space */ - fd = linuxOpenLegacy(bridge, "legacy_io"); - if (fd < 0) { - DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge, - 0, linuxGetIOSize(bridge), - PCIIOC_MMAP_IS_IO); - } - else { /* legacy_io file exists, encode fd */ - DomainMmappedIO[domain] = (pointer)(intptr_t)(fd << 24); - } - } - - return (IOADDRESS)DomainMmappedIO[domain]; -} - diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h index ce1336b..3a17c30 100644 --- a/hw/xfree86/os-support/bus/xf86Pci.h +++ b/hw/xfree86/os-support/bus/xf86Pci.h @@ -235,7 +235,7 @@ /* Primitive Types */ typedef unsigned long ADDRESS; /* Memory/PCI address */ -typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */ +typedef unsigned long IOADDRESS _X_DEPRECATED; /* Must be large enough for a pointer */ typedef unsigned long PCITAG; typedef enum { @@ -257,6 +257,7 @@ extern _X_EXPORT Bool xf86scanpci(void); /* Domain access functions. Some of these probably shouldn't be public */ extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, ADDRESS Base, unsigned long Size); -extern _X_EXPORT IOADDRESS xf86MapLegacyIO(struct pci_device *dev); +extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev); +extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *); #endif /* _XF86PCI_H */ commit 6d9efdce0d06df6b85f0681bea306c0b1e851502 Author: Adam Jackson <ajax at redhat.com> Date: Tue Sep 20 18:12:29 2011 -0400 vgahw: Port to pciaccess IO space routines Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c index 9e934f6..072c599 100644 --- a/hw/xfree86/vgahw/vgaHW.c +++ b/hw/xfree86/vgahw/vgaHW.c @@ -163,67 +163,67 @@ static CARD8 defaultDAC[768] = static void stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value) { - outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index); - outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET, value); + pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET, value); } static CARD8 stdReadCrtc(vgaHWPtr hwp, CARD8 index) { - outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index); - return inb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET); + pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + return pci_io_read8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET); } static void stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value) { - outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index); - outb(hwp->PIOOffset + VGA_GRAPH_DATA, value); + pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index); + pci_io_write8(hwp->io, VGA_GRAPH_DATA, value); } static CARD8 stdReadGr(vgaHWPtr hwp, CARD8 index) { - outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index); - return inb(hwp->PIOOffset + VGA_GRAPH_DATA); + pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index); + return pci_io_read8(hwp->io, VGA_GRAPH_DATA); } static void stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value) { - outb(hwp->PIOOffset + VGA_SEQ_INDEX, index); - outb(hwp->PIOOffset + VGA_SEQ_DATA, value); + pci_io_write8(hwp->io, VGA_SEQ_INDEX, index); + pci_io_write8(hwp->io, VGA_SEQ_DATA, value); } static CARD8 stdReadSeq(vgaHWPtr hwp, CARD8 index) { - outb(hwp->PIOOffset + VGA_SEQ_INDEX, index); - return inb(hwp->PIOOffset + VGA_SEQ_DATA); + pci_io_write8(hwp->io, VGA_SEQ_INDEX, index); + return pci_io_read8(hwp->io, VGA_SEQ_DATA); } static CARD8 stdReadST00(vgaHWPtr hwp) { - return inb(hwp->PIOOffset + VGA_IN_STAT_0); + return pci_io_read8(hwp->io, VGA_IN_STAT_0); } static CARD8 stdReadST01(vgaHWPtr hwp) { - return inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); + return pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); } static CARD8 stdReadFCR(vgaHWPtr hwp) { - return inb(hwp->PIOOffset + VGA_FEATURE_R); + return pci_io_read8(hwp->io, VGA_FEATURE_R); } static void stdWriteFCR(vgaHWPtr hwp, CARD8 value) { - outb(hwp->IOBase + hwp->PIOOffset + VGA_FEATURE_W_OFFSET,value); + pci_io_write8(hwp->io, hwp->IOBase + VGA_FEATURE_W_OFFSET,value); } static void @@ -234,9 +234,9 @@ stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value) else index |= 0x20; - (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); - outb(hwp->PIOOffset + VGA_ATTR_INDEX, index); - outb(hwp->PIOOffset + VGA_ATTR_DATA_W, value); + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, index); + pci_io_write8(hwp->io, VGA_ATTR_DATA_W, value); } static CARD8 @@ -247,85 +247,85 @@ stdReadAttr(vgaHWPtr hwp, CARD8 index) else index |= 0x20; - (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); - outb(hwp->PIOOffset + VGA_ATTR_INDEX, index); - return inb(hwp->PIOOffset + VGA_ATTR_DATA_R); + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, index); + return pci_io_read8(hwp->io, VGA_ATTR_DATA_R); } static void stdWriteMiscOut(vgaHWPtr hwp, CARD8 value) { - outb(hwp->PIOOffset + VGA_MISC_OUT_W, value); + pci_io_write8(hwp->io, VGA_MISC_OUT_W, value); } static CARD8 stdReadMiscOut(vgaHWPtr hwp) { - return inb(hwp->PIOOffset + VGA_MISC_OUT_R); + return pci_io_read8(hwp->io, VGA_MISC_OUT_R); } static void stdEnablePalette(vgaHWPtr hwp) { - (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); - outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x00); + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x00); hwp->paletteEnabled = TRUE; } static void stdDisablePalette(vgaHWPtr hwp) { - (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); - outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x20); + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x20); hwp->paletteEnabled = FALSE; } static void stdWriteDacMask(vgaHWPtr hwp, CARD8 value) { - outb(hwp->PIOOffset + VGA_DAC_MASK, value); + pci_io_write8(hwp->io, VGA_DAC_MASK, value); } static CARD8 stdReadDacMask(vgaHWPtr hwp) { - return inb(hwp->PIOOffset + VGA_DAC_MASK); + return pci_io_read8(hwp->io, VGA_DAC_MASK); } static void stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value) { - outb(hwp->PIOOffset + VGA_DAC_READ_ADDR, value); + pci_io_write8(hwp->io, VGA_DAC_READ_ADDR, value); } static void stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value) { - outb(hwp->PIOOffset + VGA_DAC_WRITE_ADDR, value); + pci_io_write8(hwp->io, VGA_DAC_WRITE_ADDR, value); } static void stdWriteDacData(vgaHWPtr hwp, CARD8 value) { - outb(hwp->PIOOffset + VGA_DAC_DATA, value); + pci_io_write8(hwp->io, VGA_DAC_DATA, value); } static CARD8 stdReadDacData(vgaHWPtr hwp) { - return inb(hwp->PIOOffset + VGA_DAC_DATA); + return pci_io_read8(hwp->io, VGA_DAC_DATA); } static CARD8 stdReadEnable(vgaHWPtr hwp) { - return inb(hwp->PIOOffset + VGA_ENABLE); + return pci_io_read8(hwp->io, VGA_ENABLE); } static void stdWriteEnable(vgaHWPtr hwp, CARD8 value) { - outb(hwp->PIOOffset + VGA_ENABLE, value); + pci_io_write8(hwp->io, VGA_ENABLE, value); } void @@ -353,9 +353,10 @@ vgaHWSetStdFuncs(vgaHWPtr hwp) hwp->writeDacReadAddr = stdWriteDacReadAddr; hwp->writeDacData = stdWriteDacData; hwp->readDacData = stdReadDacData; - hwp->PIOOffset = 0; hwp->readEnable = stdReadEnable; hwp->writeEnable = stdWriteEnable; + + hwp->io = pci_legacy_open_io(hwp->dev, 0, 64 * 1024); } /* @@ -1719,7 +1720,9 @@ vgaHWFreeHWRec(ScrnInfoPtr scrp) vgaHWPtr hwp = VGAHWPTR(scrp); if (!hwp) - return; + return; + + pci_device_close_io(hwp->dev, hwp->io); free(hwp->FontInfo1); free(hwp->FontInfo2); @@ -1789,8 +1792,7 @@ vgaHWGetIOBase(vgaHWPtr hwp) hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ? VGA_IOBASE_COLOR : VGA_IOBASE_MONO; xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3, - "vgaHWGetIOBase: hwp->IOBase is 0x%04x, hwp->PIOOffset is 0x%04lx\n", - hwp->IOBase, hwp->PIOOffset); + "vgaHWGetIOBase: hwp->IOBase is 0x%04x\n", hwp->IOBase); } @@ -1995,11 +1997,12 @@ SaveScreenProcPtr vgaHWSaveScreenWeak(void) void xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), void (*ProtectRegs)(ScrnInfoPtr, Bool), - void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg, + void (*BlankScreen)(ScrnInfoPtr, Bool), unsigned long vertsyncreg, int maskval, int knownclkindex, int knownclkvalue) { register int status = vertsyncreg; unsigned long i, cnt, rcnt, sync; + vgaHWPtr hwp = VGAHWPTR(pScrn); /* First save registers that get written on */ (*ClockFunc)(pScrn, CLK_REG_SAVE); @@ -2026,22 +2029,22 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), cnt = 0; sync = 200000; - while ((inb(status) & maskval) == 0x00) + while ((pci_io_read8(hwp->io, status) & maskval) == 0x00) if (sync-- == 0) goto finish; /* Something appears to be happening, so reset sync count */ sync = 200000; - while ((inb(status) & maskval) == maskval) + while ((pci_io_read8(hwp->io, status) & maskval) == maskval) if (sync-- == 0) goto finish; /* Something appears to be happening, so reset sync count */ sync = 200000; - while ((inb(status) & maskval) == 0x00) + while ((pci_io_read8(hwp->io, status) & maskval) == 0x00) if (sync-- == 0) goto finish; for (rcnt = 0; rcnt < 5; rcnt++) { - while (!(inb(status) & maskval)) + while (!(pci_io_read8(hwp->io, status) & maskval)) cnt++; - while ((inb(status) & maskval)) + while ((pci_io_read8(hwp->io, status) & maskval)) cnt++; } diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h index 12cfac0..e943aa3 100644 --- a/hw/xfree86/vgahw/vgaHW.h +++ b/hw/xfree86/vgahw/vgaHW.h @@ -151,17 +151,13 @@ typedef struct _vgaHWRec { vgaHWWriteProcPtr writeDacData; vgaHWReadProcPtr readDacData; pointer ddc; - IOADDRESS PIOOffset; /* offset + vgareg - = pioreg */ + struct pci_io_handle *io; vgaHWReadProcPtr readEnable; vgaHWWriteProcPtr writeEnable; struct pci_device *dev; } vgaHWRec; /* Some macros that VGA drivers can use in their ChipProbe() function */ -#define VGAHW_GET_IOBASE() ((inb(VGA_MISC_OUT_R) & 0x01) ? \ - VGA_IOBASE_COLOR : VGA_IOBASE_MONO) - #define OVERSCAN 0x11 /* Index of OverScan register */ /* Flags that define how overscan correction should take place */ @@ -174,15 +170,11 @@ typedef struct _vgaHWRec { #define BITS_PER_GUN 6 #define COLORMAP_SIZE 256 -#if defined(__powerpc__) || defined(__arm__) || defined(__s390__) || defined(__nds32__) -#define DACDelay(hw) /* No legacy VGA support */ -#else -#define DACDelay(hw) \ - do { \ - (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ - (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ +#define DACDelay(hw) \ + do { \ + pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ + pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ } while (0) -#endif /* Function Prototypes */ @@ -235,7 +227,7 @@ extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), void (*ProtectRegs)(ScrnInfoPtr, Bool), void (*BlankScreen)(ScrnInfoPtr, Bool), - IOADDRESS vertsyncreg, int maskval, + unsigned long vertsyncreg, int maskval, int knownclkindex, int knownclkvalue); #endif /* _VGAHW_H */ commit 4bd6579188e718654c35f95623fd4772f9e0ef06 Author: Adam Jackson <ajax at redhat.com> Date: Thu Sep 22 13:45:57 2011 -0400 vgahw: Don't default to standard (port space) access routines In fact, don't default to anything; drivers must explicitly say which kind they want, and they are strongly encouraged to do MMIO if possible. This is an ABI change in that drivers that don't will crash, but drivers that are explicit will work with both old and new servers. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c index 911bf07..9e934f6 100644 --- a/hw/xfree86/vgahw/vgaHW.c +++ b/hw/xfree86/vgahw/vgaHW.c @@ -1706,9 +1706,6 @@ vgaHWGetHWRec(ScrnInfoPtr scrp) hwp->MapSize = 0; hwp->pScrn = scrp; - /* Initialise the function pointers with the standard VGA versions */ - vgaHWSetStdFuncs(hwp); - hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]); return TRUE; commit 30fb334d218f8c1d809f88054b9fe8f5f556bb62 Author: Adam Jackson <ajax at redhat.com> Date: Thu Sep 22 13:44:53 2011 -0400 vgahw: Remove IO domain setup Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c index 2ecea1c..911bf07 100644 --- a/hw/xfree86/vgahw/vgaHW.c +++ b/hw/xfree86/vgahw/vgaHW.c @@ -1709,7 +1709,6 @@ vgaHWGetHWRec(ScrnInfoPtr scrp) /* Initialise the function pointers with the standard VGA versions */ vgaHWSetStdFuncs(hwp); - hwp->PIOOffset = scrp->domainIOBase; hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]); return TRUE; commit 51a5558beb71bddeff9352ef4f43269a8a22317d Author: Adam Jackson <ajax at redhat.com> Date: Sat Sep 18 08:24:19 2010 -0400 int10: Port to pciaccess' legacy IO API Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c index 9940854..beb90b5 100644 --- a/hw/xfree86/int10/generic.c +++ b/hw/xfree86/int10/generic.c @@ -297,7 +297,7 @@ MapVRam(xf86Int10InfoPtr pInt) INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO, pInt->dev, V_RAM, size); - pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase; + pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024); } static void @@ -308,6 +308,9 @@ UnmapVRam(xf86Int10InfoPtr pInt) int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize; xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size); + + pci_device_close_io(pInt->dev, pInt->io); + pInt->io = NULL; } Bool diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c index 44d8a7f..8b52e88 100644 --- a/hw/xfree86/int10/helper_exec.c +++ b/hw/xfree86/int10/helper_exec.c @@ -331,7 +331,7 @@ x_inb(CARD16 port) } #endif /* __NOT_YET__ */ } else if (!pciCfg1inb(port, &val)) { - val = inb(Int10Current->ioBase + port); + val = pci_io_read8(Int10Current->io, port); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" inb(%#x) = %2.2x\n", port, val); } @@ -353,7 +353,7 @@ x_inw(CARD16 port) X_GETTIMEOFDAY(&tv); val = (CARD16)(tv.tv_usec / 3); } else if (!pciCfg1inw(port, &val)) { - val = inw(Int10Current->ioBase + port); + val = pci_io_read16(Int10Current->io, port); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" inw(%#x) = %4.4x\n", port, val); } @@ -387,7 +387,7 @@ x_outb(CARD16 port, CARD8 val) } else if (!pciCfg1outb(port, val)) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" outb(%#x, %2.2x)\n", port, val); - outb(Int10Current->ioBase + port, val); + pci_io_write8(Int10Current->io, port, val); } } @@ -398,7 +398,7 @@ x_outw(CARD16 port, CARD16 val) if (!pciCfg1outw(port, val)) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" outw(%#x, %4.4x)\n", port, val); - outw(Int10Current->ioBase + port, val); + pci_io_write16(Int10Current->io, port, val); } } @@ -408,7 +408,7 @@ x_inl(CARD16 port) CARD32 val; if (!pciCfg1in(port, &val)) { - val = inl(Int10Current->ioBase + port); + val = pci_io_read32(Int10Current->io, port); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" inl(%#x) = %8.8" PRIx32 "\n", port, val); } @@ -421,7 +421,7 @@ x_outl(CARD16 port, CARD32 val) if (!pciCfg1out(port, val)) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" outl(%#x, %8.8" PRIx32 ")\n", port, val); - outl(Int10Current->ioBase + port, val); + pci_io_write32(Int10Current->io, port, val); } } @@ -650,29 +650,29 @@ bios_checksum(const CARD8 *start, int size) void LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) { - vga->save_msr = inb(pInt->ioBase + 0x03CC); - vga->save_vse = inb(pInt->ioBase + 0x03C3); + vga->save_msr = pci_io_read8(pInt->io, 0x03CC); + vga->save_vse = pci_io_read8(pInt->io, 0x03C3); #ifndef __ia64__ - vga->save_46e8 = inb(pInt->ioBase + 0x46E8); + vga->save_46e8 = pci_io_read8(pInt->io, 0x46E8); #endif - vga->save_pos102 = inb(pInt->ioBase + 0x0102); - outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr); - outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse); + vga->save_pos102 = pci_io_read8(pInt->io, 0x0102); + pci_io_write8(pInt->io, 0x03C2, ~(CARD8)0x03 & vga->save_msr); + pci_io_write8(pInt->io, 0x03C3, ~(CARD8)0x01 & vga->save_vse); #ifndef __ia64__ - outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8); + pci_io_write8(pInt->io, 0x46E8, ~(CARD8)0x08 & vga->save_46e8); #endif - outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102); + pci_io_write8(pInt->io, 0x0102, ~(CARD8)0x01 & vga->save_pos102); } void UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) { - outb(pInt->ioBase + 0x0102, vga->save_pos102); + pci_io_write8(pInt->io, 0x0102, vga->save_pos102); #ifndef __ia64__ - outb(pInt->ioBase + 0x46E8, vga->save_46e8); + pci_io_write8(pInt->io, 0x46E8, vga->save_46e8); #endif - outb(pInt->ioBase + 0x03C3, vga->save_vse); - outb(pInt->ioBase + 0x03C2, vga->save_msr); + pci_io_write8(pInt->io, 0x03C3, vga->save_vse); + pci_io_write8(pInt->io, 0x03C2, vga->save_msr); } #if defined (_PC) diff --git a/hw/xfree86/int10/xf86int10.c b/hw/xfree86/int10/xf86int10.c index 51eb91f..dd00e54 100644 --- a/hw/xfree86/int10/xf86int10.c +++ b/hw/xfree86/int10/xf86int10.c @@ -84,7 +84,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented (except for clearing the screen) */ { /* Localise */ - IOADDRESS ioport; + unsigned int ioport; int i; CARD16 int1d, regvals, tmp; CARD8 mode, cgamode, cgacolour; @@ -172,18 +172,15 @@ int42_handler(xf86Int10InfoPtr pInt) /* Rows */ MEM_WB(pInt, 0x0484, (25 - 1)); - /* Remap I/O port number into its domain */ - ioport += pInt->ioBase; - - /* Programme the mode */ - outb(ioport + 4, cgamode & 0x37); /* Turn off screen */ + /* Program the mode */ + pci_io_write8(pInt->io, ioport + 4, cgamode & 0x37); /* Turn off screen */ for (i = 0; i < 0x10; i++) { tmp = MEM_RB(pInt, regvals + i); - outb(ioport, i); - outb(ioport + 1, tmp); + pci_io_write8(pInt->io, ioport, i); + pci_io_write8(pInt->io, ioport + 1, tmp); } - outb(ioport + 5, cgacolour); /* Select colour mode */ - outb(ioport + 4, cgamode); /* Turn on screen */ + pci_io_write8(pInt->io, ioport + 5, cgacolour); /* Select colour mode */ + pci_io_write8(pInt->io, ioport + 4, cgamode); /* Turn on screen */ } break; @@ -194,15 +191,15 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; + unsigned int ioport = MEM_RW(pInt, 0x0463); MEM_WB(pInt, 0x0460, X86_CL); MEM_WB(pInt, 0x0461, X86_CH); - outb(ioport, 0x0A); - outb(ioport + 1, X86_CH); - outb(ioport, 0x0B); - outb(ioport + 1, X86_CL); + pci_io_write8(pInt->io, ioport, 0x0A); + pci_io_write8(pInt->io, ioport + 1, X86_CH); + pci_io_write8(pInt->io, ioport, 0x0B); + pci_io_write8(pInt->io, ioport + 1, X86_CL); } break; @@ -214,7 +211,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport; + unsigned int ioport; CARD16 offset; MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL); @@ -226,11 +223,11 @@ int42_handler(xf86Int10InfoPtr pInt) offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL; offset += MEM_RW(pInt, 0x044E) << 1; - ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; - outb(ioport, 0x0E); - outb(ioport + 1, offset >> 8); - outb(ioport, 0x0F); - outb(ioport + 1, offset & 0xFF); + ioport = MEM_RW(pInt, 0x0463); + pci_io_write8(pInt->io, ioport, 0x0E); + pci_io_write8(pInt->io, ioport + 1, offset >> 8); + pci_io_write8(pInt->io, ioport, 0x0F); + pci_io_write8(pInt->io, ioport + 1, offset & 0xFF); } break; @@ -276,7 +273,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; + unsigned int ioport = MEM_RW(pInt, 0x0463); CARD16 start; CARD8 x, y; @@ -287,10 +284,10 @@ int42_handler(xf86Int10InfoPtr pInt) start <<= 1; /* Update start address */ - outb(ioport, 0x0C); - outb(ioport + 1, start >> 8); - outb(ioport, 0x0D); - outb(ioport + 1, start & 0xFF); + pci_io_write8(pInt->io, ioport, 0x0C); + pci_io_write8(pInt->io, ioport + 1, start >> 8); + pci_io_write8(pInt->io, ioport, 0x0D); + pci_io_write8(pInt->io, ioport + 1, start & 0xFF); /* Switch cursor position */ y = MEM_RB(pInt, (X86_AL << 1) + 0x0450); @@ -298,10 +295,10 @@ int42_handler(xf86Int10InfoPtr pInt) start += (y * MEM_RW(pInt, 0x044A)) + x; /* Update cursor position */ - outb(ioport, 0x0E); - outb(ioport + 1, start >> 8); - outb(ioport, 0x0F); - outb(ioport + 1, start & 0xFF); + pci_io_write8(pInt->io, ioport, 0x0E); + pci_io_write8(pInt->io, ioport + 1, start >> 8); + pci_io_write8(pInt->io, ioport, 0x0F); + pci_io_write8(pInt->io, ioport + 1, start & 0xFF); } break; @@ -426,7 +423,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport = MEM_RW(pInt, 0x0463) + 5 + pInt->ioBase; + unsigned int ioport = MEM_RW(pInt, 0x0463) + 5; CARD8 cgacolour = MEM_RB(pInt, 0x0466); if (X86_BH) { @@ -438,7 +435,7 @@ int42_handler(xf86Int10InfoPtr pInt) } MEM_WB(pInt, 0x0466, cgacolour); - outb(ioport, cgacolour); + pci_io_write8(pInt->io, ioport, cgacolour); } break; diff --git a/hw/xfree86/int10/xf86int10.h b/hw/xfree86/int10/xf86int10.h index ba9ee52..5bf326e 100644 --- a/hw/xfree86/int10/xf86int10.h +++ b/hw/xfree86/int10/xf86int10.h @@ -41,7 +41,7 @@ typedef struct { int flags; int stackseg; struct pci_device *dev; - IOADDRESS ioBase; + struct pci_io_handle *io; } xf86Int10InfoRec, *xf86Int10InfoPtr; typedef struct _int10Mem { commit c0b63ff88a6dc20f86141aa1a1ed5a9384aa63aa Author: Adam Jackson <ajax at redhat.com> Date: Sat Sep 18 08:05:11 2010 -0400 xfree86: Move xf86GetClocks to vgahw This is really a vga-specific hack anyway. The only modern driver that uses it is trident, but it's already loaded vgahw by the time it would call xf86GetClocks. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Tested-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 1b6c998..da9287b 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -239,12 +239,6 @@ extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from); extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips); extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist); -extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, - Bool (*ClockFunc)(ScrnInfoPtr, int), - void (*ProtectRegs)(ScrnInfoPtr, Bool), - void (*BlankScreen)(ScrnInfoPtr, Bool), - IOADDRESS vertsyncreg, int maskval, - int knownclkindex, int knownclkvalue); extern _X_EXPORT const char *xf86GetVisualName(int visual); extern _X_EXPORT int xf86GetVerbosity(void); extern _X_EXPORT Pix24Flags xf86GetPix24(void); diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index a8aa316..cf57752 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -1353,96 +1353,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist) return i; } -/* - * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ... - */ -void -xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), - void (*ProtectRegs)(ScrnInfoPtr, Bool), - void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg, - int maskval, int knownclkindex, int knownclkvalue) -{ - register int status = vertsyncreg; - unsigned long i, cnt, rcnt, sync; - - /* First save registers that get written on */ - (*ClockFunc)(pScrn, CLK_REG_SAVE); - - if (num > MAXCLOCKS) - num = MAXCLOCKS; - - for (i = 0; i < num; i++) - { - if (ProtectRegs) - (*ProtectRegs)(pScrn, TRUE); - if (!(*ClockFunc)(pScrn, i)) - { - pScrn->clock[i] = -1; - continue; - } - if (ProtectRegs) - (*ProtectRegs)(pScrn, FALSE); - if (BlankScreen) - (*BlankScreen)(pScrn, FALSE); - - usleep(50000); /* let VCO stabilise */ - - cnt = 0; - sync = 200000; - - while ((inb(status) & maskval) == 0x00) - if (sync-- == 0) goto finish; - /* Something appears to be happening, so reset sync count */ - sync = 200000; - while ((inb(status) & maskval) == maskval) - if (sync-- == 0) goto finish; - /* Something appears to be happening, so reset sync count */ - sync = 200000; - while ((inb(status) & maskval) == 0x00) - if (sync-- == 0) goto finish; - - for (rcnt = 0; rcnt < 5; rcnt++) - { - while (!(inb(status) & maskval)) - cnt++; - while ((inb(status) & maskval)) - cnt++; - } - -finish: - pScrn->clock[i] = cnt ? cnt : -1; - if (BlankScreen) - (*BlankScreen)(pScrn, TRUE); - } - - for (i = 0; i < num; i++) - { - if (i != knownclkindex) - { - if (pScrn->clock[i] == -1) - { - pScrn->clock[i] = 0; - } - else - { - pScrn->clock[i] = (int)(0.5 + - (((float)knownclkvalue) * pScrn->clock[knownclkindex]) / - (pScrn->clock[i])); - /* Round to nearest 10KHz */ - pScrn->clock[i] += 5; - pScrn->clock[i] /= 10; - pScrn->clock[i] *= 10; - } - } - } - - pScrn->clock[knownclkindex] = knownclkvalue; - pScrn->numClocks = num; - - /* Restore registers that were written on */ - (*ClockFunc)(pScrn, CLK_REG_RESTORE); -} - const char * xf86GetVisualName(int visual) { diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c index ee045d1..2ecea1c 100644 --- a/hw/xfree86/vgahw/vgaHW.c +++ b/hw/xfree86/vgahw/vgaHW.c @@ -1992,3 +1992,93 @@ SaveScreenProcPtr vgaHWSaveScreenWeak(void) { return vgaHWSaveScreen; } + +/* + * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ... + */ +void +xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), + void (*ProtectRegs)(ScrnInfoPtr, Bool), + void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg, + int maskval, int knownclkindex, int knownclkvalue) +{ + register int status = vertsyncreg; + unsigned long i, cnt, rcnt, sync; + + /* First save registers that get written on */ + (*ClockFunc)(pScrn, CLK_REG_SAVE); + + if (num > MAXCLOCKS) + num = MAXCLOCKS; + + for (i = 0; i < num; i++) + { + if (ProtectRegs) + (*ProtectRegs)(pScrn, TRUE); + if (!(*ClockFunc)(pScrn, i)) + { + pScrn->clock[i] = -1; + continue; + } + if (ProtectRegs) + (*ProtectRegs)(pScrn, FALSE); + if (BlankScreen) + (*BlankScreen)(pScrn, FALSE); + + usleep(50000); /* let VCO stabilise */ + + cnt = 0; + sync = 200000; + + while ((inb(status) & maskval) == 0x00) + if (sync-- == 0) goto finish; + /* Something appears to be happening, so reset sync count */ + sync = 200000; + while ((inb(status) & maskval) == maskval) + if (sync-- == 0) goto finish; + /* Something appears to be happening, so reset sync count */ + sync = 200000; + while ((inb(status) & maskval) == 0x00) + if (sync-- == 0) goto finish; + + for (rcnt = 0; rcnt < 5; rcnt++) + { + while (!(inb(status) & maskval)) + cnt++; + while ((inb(status) & maskval)) + cnt++; + } + +finish: + pScrn->clock[i] = cnt ? cnt : -1; + if (BlankScreen) + (*BlankScreen)(pScrn, TRUE); + } + + for (i = 0; i < num; i++) + { + if (i != knownclkindex) + { + if (pScrn->clock[i] == -1) + { + pScrn->clock[i] = 0; + } + else + { + pScrn->clock[i] = (int)(0.5 + + (((float)knownclkvalue) * pScrn->clock[knownclkindex]) / + (pScrn->clock[i])); + /* Round to nearest 10KHz */ + pScrn->clock[i] += 5; + pScrn->clock[i] /= 10; + pScrn->clock[i] *= 10; + } + } + } + + pScrn->clock[knownclkindex] = knownclkvalue; + pScrn->numClocks = num; + + /* Restore registers that were written on */ + (*ClockFunc)(pScrn, CLK_REG_RESTORE); +} diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h index b31c007..12cfac0 100644 --- a/hw/xfree86/vgahw/vgaHW.h +++ b/hw/xfree86/vgahw/vgaHW.h @@ -231,5 +231,11 @@ extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp); extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void); extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void); +extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, + Bool (*ClockFunc)(ScrnInfoPtr, int), + void (*ProtectRegs)(ScrnInfoPtr, Bool), + void (*BlankScreen)(ScrnInfoPtr, Bool), + IOADDRESS vertsyncreg, int maskval, + int knownclkindex, int knownclkvalue); #endif /* _VGAHW_H */ commit 1433103a49b97e356da0f20aa65046cdb2f5ece6 Author: Dave Airlie <airlied at redhat.com> Date: Wed Oct 12 09:59:38 2011 +0100 test: fix input test The test was memsetting the wrong thing, this fixes make check in my tinderbox. Signed-off-by: Dave Airlie <airlied at redhat.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/test/input.c b/test/input.c index 64673d2..bc41c22 100644 --- a/test/input.c +++ b/test/input.c @@ -1309,17 +1309,17 @@ static void dix_get_master(void) SpriteInfoRec ptr_sprite, kbd_sprite; SpriteInfoRec floating_sprite; - memset(&vcp, 0, sizeof(DeviceIntRec)); - memset(&vck, 0, sizeof(DeviceIntRec)); - memset(&ptr, 0, sizeof(DeviceIntRec)); - memset(&kbd, 0, sizeof(DeviceIntRec)); - memset(&floating, 0, sizeof(DeviceIntRec)); - - memset(&vcp_sprite, 0, sizeof(DeviceIntRec)); - memset(&vck_sprite, 0, sizeof(DeviceIntRec)); - memset(&ptr_sprite, 0, sizeof(DeviceIntRec)); - memset(&kbd_sprite, 0, sizeof(DeviceIntRec)); - memset(&floating_sprite, 0, sizeof(DeviceIntRec)); + memset(&vcp, 0, sizeof(vcp)); + memset(&vck, 0, sizeof(vck)); + memset(&ptr, 0, sizeof(ptr)); + memset(&kbd, 0, sizeof(kbd)); + memset(&floating, 0, sizeof(floating)); + + memset(&vcp_sprite, 0, sizeof(vcp_sprite)); + memset(&vck_sprite, 0, sizeof(vck_sprite)); + memset(&ptr_sprite, 0, sizeof(ptr_sprite)); + memset(&kbd_sprite, 0, sizeof(kbd_sprite)); + memset(&floating_sprite, 0, sizeof(floating_sprite)); vcp.type = MASTER_POINTER; vck.type = MASTER_KEYBOARD; commit f9c6903d4a90b59c328f4fa05d2be9e0ce1c5189 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 5 15:02:52 2011 -0700 dix: add utility functions for double to/fro FP1616/FP3232 conversion Co-authored-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Mark Kettenis <kettenis at openbsd.org> diff --git a/dix/inpututils.c b/dix/inpututils.c index 0a3d3d8..cd45773 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -759,3 +759,66 @@ input_option_set_value(InputOption *opt, const char *value) if (value) opt->value = strdup(value); } + + +/* FP1616/FP3232 conversion functions. + * Fixed point types are encoded as signed integral and unsigned frac. So any + * negative number -n.m is encoded as floor(n) + (1 - 0.m). + */ +double +fp1616_to_double(FP1616 in) +{ + double ret; + + ret = (double)(in >> 16); + ret += (double)(in & 0xffff) * (1.0 / (1UL << 16)); /* Optimized: ldexp((double)(in & 0xffff), -16); */ + return ret; +} + +double +fp3232_to_double(FP3232 in) +{ + double ret; + ret = (double)in.integral; + ret += (double)in.frac * (1.0 / (1ULL << 32)); /* Optimized: ldexp((double)in.frac, -32); */ + return ret; +} + + +FP1616 +double_to_fp1616(double in) +{ + FP1616 ret; + int32_t integral; + double tmp; + uint32_t frac_d; + + tmp = floor(in); + integral = (int32_t)tmp; + + tmp = (in - integral) * (1UL << 16); /* Optimized: ldexp(in - integral, 16) */ + frac_d = (uint16_t)tmp; + + ret = integral << 16; + ret |= frac_d & 0xffff; + return ret; +} + +FP3232 +double_to_fp3232(double in) +{ + FP3232 ret; + int32_t integral; + double tmp; + uint32_t frac_d; + + tmp = floor(in); + integral = (int32_t)tmp; + + tmp = (in - integral) * (1ULL << 32); /* Optimized: ldexp(in - integral, 32) */ + frac_d = (uint32_t)tmp; + + ret.integral = integral; + ret.frac = frac_d; + return ret; +} diff --git a/include/inpututils.h b/include/inpututils.h index 47e242d..2832ed5 100644 --- a/include/inpututils.h +++ b/include/inpututils.h @@ -30,6 +30,7 @@ #define INPUTUTILS_H #include "input.h" +#include <X11/extensions/XI2proto.h> struct _ValuatorMask { int8_t last_bit; /* highest bit set in mask */ @@ -40,4 +41,9 @@ struct _ValuatorMask { extern void verify_internal_event(const InternalEvent *ev); extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms); +FP3232 double_to_fp3232(double in); +FP1616 double_to_fp1616(double in); +double fp1616_to_double(FP1616 in); +double fp3232_to_double(FP3232 in); + #endif diff --git a/test/input.c b/test/input.c index afc4d4d..64673d2 100644 --- a/test/input.c +++ b/test/input.c @@ -1462,9 +1462,137 @@ static void input_option_test(void) assert(list == NULL); } +static void +_test_double_fp16_values(double orig_d) +{ + FP1616 first_fp16, final_fp16; + double final_d; + char first_fp16_s[64]; + char final_fp16_s[64]; + + if (orig_d > 0x7FFF) { + printf("Test out of range\n"); + assert(0); + } + + first_fp16 = double_to_fp1616(orig_d); + final_d = fp1616_to_double(first_fp16); + final_fp16 = double_to_fp1616(final_d); + + snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff); + snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff); + + printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s); + + /* since we lose precision, we only do rough range testing */ + assert(final_d > orig_d - 0.1); + assert(final_d < orig_d + 0.1); + + assert(memcmp(&first_fp16, &final_fp16, sizeof(FP1616)) == 0); + + if (orig_d > 0) + _test_double_fp16_values(-orig_d); +} + +static void +_test_double_fp32_values(double orig_d) +{ + FP3232 first_fp32, final_fp32; + double final_d; + + if (orig_d > 0x7FFFFFFF) { + printf("Test out of range\n"); + assert(0); + } + + first_fp32 = double_to_fp3232(orig_d); + final_d = fp3232_to_double(first_fp32); + final_fp32 = double_to_fp3232(final_d); + + /* { + * char first_fp32_s[64]; + * char final_fp32_s[64]; + * snprintf(first_fp32_s, sizeof(first_fp32_s), "%d + %u * 2^-32", first_fp32.integral, first_fp32.frac); + * snprintf(final_fp32_s, sizeof(final_fp32_s), "%d + %u * 2^-32", first_fp32.integral, final_fp32.frac); + * + * printf("FP32: original double: %f first fp32: %s, re-encoded double: %f, final fp32: %s\n", orig_d, first_fp32_s, final_d, final_fp32_s); + * } + */ + + /* since we lose precision, we only do rough range testing */ + assert(final_d > orig_d - 0.1); + assert(final_d < orig_d + 0.1); + + assert(memcmp(&first_fp32, &final_fp32, sizeof(FP3232)) == 0); + + if (orig_d > 0) + _test_double_fp32_values(-orig_d); +} + +static void +dix_double_fp_conversion(void) +{ + uint32_t i; + printf("Testing double to FP1616/FP3232 conversions\n"); + + _test_double_fp16_values(0); + for (i = 1; i < 0x7FFF; i <<= 1) { + double val; + + val = i; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + /* and some pseudo-random floating points */ + val = i - 0.00382; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.00382; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.05234; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.12342; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.27583; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.50535; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.72342; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.80408; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + } + + for (i = 0x7FFFF; i < 0x7FFFFFFF; i <<= 1) { + _test_double_fp32_values(i); + /* and a few more random floating points, obtained + * by faceplanting into the numpad repeatedly */ + _test_double_fp32_values(i + 0.010177); + _test_double_fp32_values(i + 0.213841); + _test_double_fp32_values(i + 0.348720); + _test_double_fp32_values(i + 0.472020); + _test_double_fp32_values(i + 0.572020); + _test_double_fp32_values(i + 0.892929); + } +} int main(int argc, char** argv) { + dix_double_fp_conversion(); dix_input_valuator_masks(); dix_input_attributes(); dix_init_valuators(); commit 09dbfcb0ad7b6c8bac94502f2801e82f2a2ef435 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 11 17:37:44 2011 -0700 os: Remove Error() Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml index 37fd2b2..2bf4fb3 100644 --- a/doc/Xserver-spec.xml +++ b/doc/Xserver-spec.xml @@ -1324,10 +1324,6 @@ This re-enables X request processing for the specified client. void FatalError(char *f, ...) - - void - Error(str) - char *str; </programlisting></blockquote> You should write these three routines to provide for diagnostic output from the dix and ddx layers, although implementing them to produce no @@ -1335,11 +1331,7 @@ output will not affect the correctness of your server. ErrorF() and FatalError() take a printf() type of format specification in the first argument and an implementation-dependent number of arguments following that. Normally, the formats passed to ErrorF() and FatalError() -should be terminated with a newline. Error() provides an os interface -for printing out the string passed as an argument followed by a -meaningful explanation of the last system error. Normally the string -does not contain a newline, and it is only called by the ddx layer. -In the sample implementation, Error() uses the perror() function. +should be terminated with a newline. </para> <para> After printing the message arguments, FatalError() must be implemented diff --git a/hw/xfree86/utils/cvt/cvt.c b/hw/xfree86/utils/cvt/cvt.c index fff500b..0de5ffe 100644 --- a/hw/xfree86/utils/cvt/cvt.c +++ b/hw/xfree86/utils/cvt/cvt.c @@ -25,13 +25,6 @@ #include "xf86.h" -/* Error implementation used by the server code we built in */ -void -Error(const char *str) -{ - perror(str); -} - /* FatalError implementation used by the server code we built in */ void FatalError(const char *f, ...) diff --git a/include/os.h b/include/os.h index 5401ea4..b489211 100644 --- a/include/os.h +++ b/include/os.h @@ -551,7 +551,6 @@ extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X extern _X_EXPORT void VErrorF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1,0); extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); -extern _X_EXPORT void Error(const char *str); extern _X_EXPORT void LogPrintMarkers(void); extern _X_EXPORT void xorg_backtrace(void); diff --git a/os/backtrace.c b/os/backtrace.c index 7ca6dab..58b4b1f 100644 --- a/os/backtrace.c +++ b/os/backtrace.c @@ -27,6 +27,8 @@ #include "os.h" #include "misc.h" +#include <errno.h> +#include <string.h> #ifdef HAVE_BACKTRACE #ifndef _GNU_SOURCE @@ -199,9 +201,8 @@ void xorg_backtrace(void) { walkcontext(&u, xorg_backtrace_frame, &depth); else # endif - Error("Failed to get backtrace info"); + ErrorF("Failed to get backtrace info: %s\n", strerror(errno)); } - ErrorF("\n"); } # else diff --git a/os/log.c b/os/log.c index 2eddf06..9ee32c9 100644 --- a/os/log.c +++ b/os/log.c @@ -87,7 +87,6 @@ OR PERFORMANCE OF THIS SOFTWARE. #include <sys/stat.h> #include <stdarg.h> #include <stdlib.h> /* for malloc() */ -#include <errno.h> #include "input.h" #include "site.h" @@ -638,19 +637,6 @@ ErrorF(const char * f, ...) va_end(args); } -/* A perror() workalike. */ - -void -Error(const char *str) -{ - const char *err = strerror(errno); - - if (str) - LogWrite(-1, "%s: %s", str, err); - else - LogWrite(-1, "%s", err); -} - void LogPrintMarkers(void) { diff --git a/os/xprintf.c b/os/xprintf.c index 254b737..3b4bb41 100644 --- a/os/xprintf.c +++ b/os/xprintf.c @@ -64,6 +64,8 @@ #include "os.h" #include <stdarg.h> #include <stdio.h> +#include <errno.h> +#include <string.h> #ifdef asprintf # undef asprintf @@ -154,8 +156,7 @@ XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va) { int size = vasprintf(ret, format, va); if ((size == -1) || (*ret == NULL)) { - Error("XNFvasprintf"); - FatalError("XNFvasprintf failed"); + FatalError("XNFvasprintf failed: %s", strerror(errno)); } return size; } commit db30615bcb3b872475e7d40eeee8cdda5b723078 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 10 12:16:31 2011 -0700 Xephyr: Remove socket and its lock file on exit https://bugs.freedesktop.org/show_bug.cgi?id=11484 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net> diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 4caf451..47a6681 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -45,6 +45,7 @@ #include <stdio.h> #include <unistd.h> #include <string.h> /* for memset */ +#include <errno.h> #include <time.h> #include <sys/ipc.h> @@ -331,6 +332,14 @@ hostx_set_title (char *title) ephyrTitle = title; } +static int _X_NORETURN +x_io_error_handler (Display *dpy) { + ErrorF("Lost connection to X server: %s\n", strerror(errno)); + CloseWellKnownConnections(); + OsCleanup(1); + exit(1); +} + int hostx_init (void) { @@ -358,6 +367,8 @@ hostx_init (void) exit(1); } + XSetIOErrorHandler(x_io_error_handler); + HostX.screen = DefaultScreen(HostX.dpy); HostX.winroot = RootWindow(HostX.dpy, HostX.screen); HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL); commit c13a48e74ec89eafa9b529a87253a631ef02f2e2 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 10 12:09:39 2011 -0700 Xnest: Remove socket and its lock file on exit https://bugs.freedesktop.org/show_bug.cgi?id=11484 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net> diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index b78aff5..7acad75 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -17,6 +17,9 @@ is" without express or implied warranty. #include <xnest-config.h> #endif +#include <string.h> +#include <errno.h> + #include <X11/X.h> #include <X11/Xproto.h> #include "screenint.h" @@ -52,6 +55,14 @@ Pixmap xnestScreenSaverPixmap; XlibGC xnestBitmapGC; unsigned long xnestEventMask; +static int _X_NORETURN +x_io_error_handler (Display *dpy) { + ErrorF("Lost connection to X server: %s\n", strerror(errno)); + CloseWellKnownConnections(); + OsCleanup(1); + exit(1); +} + void xnestOpenDisplay(int argc, char *argv[]) { @@ -60,7 +71,9 @@ xnestOpenDisplay(int argc, char *argv[]) int i, j; if (!xnestDoFullGeneration) return; - + + XSetIOErrorHandler(x_io_error_handler); + xnestCloseDisplay(); xnestDisplay = XOpenDisplay(xnestDisplayName); diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index 619427d..2399313 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -198,6 +198,8 @@ xnestCollectEvents(void) case DestroyNotify: if (xnestParentWindow != (Window) 0 && X.xdestroywindow.window == xnestParentWindow) + CloseWellKnownConnections(); + OsCleanup(1); exit (0); break; commit 8b29addc30163bb7ba74c74351f312aac02f049a Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 9 04:00:41 2011 -0700 loader: when creating sdksyms.c only include shmint.h if MITSHM is enabled #29109 https://bugs.freedesktop.org/show_bug.cgi?id=29109 When configured with --disable-mitshm the symbols declared in shmint.h do not exist. By guarding the include with '#ifdef MITSHM' these symbols are skipped when generating sdksyms.c with --disable-mitshm. Signed-off-by: Michael Olbrich <m.olbrich at pengutronix.de> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh index 18bb735..1755f02 100755 --- a/hw/xfree86/sdksyms.sh +++ b/hw/xfree86/sdksyms.sh @@ -52,7 +52,9 @@ cat > sdksyms.c << EOF */ #include "geext.h" #include "geint.h" +#ifdef MITSHM #include "shmint.h" +#endif #include "syncsdk.h" #if XINERAMA # include "panoramiXsrv.h" commit eabd5532fb589bd0550344ebd23c9765e591aadf Author: Julien Cristau <jcristau at debian.org> Date: Sun Oct 9 17:06:14 2011 -0700 xfree86: fix build with xv disabled https://bugs.freedesktop.org/show_bug.cgi?id=29111 Signed-off-by: Julien Cristau <jcristau at debian.org> Tested-by: Cyril Brulebois <kibi at debian.org> Reviewed-by: Cyril Brulebois <kibi at debian.org> diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 3fae039..cbe0b5c 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -3090,6 +3090,7 @@ xf86_crtc_box_area(BoxPtr box) return (int) (box->x2 - box->x1) * (int) (box->y2 - box->y1); } +#ifdef XV /* * Return the crtc covering 'box'. If two crtcs cover a portion of * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc @@ -3178,6 +3179,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, return ret; } +#endif xf86_crtc_notify_proc_ptr xf86_wrap_crtc_notify (ScreenPtr screen, xf86_crtc_notify_proc_ptr new) diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index ffb2eff..716499f 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -956,6 +956,7 @@ xf86_cursors_fini (ScreenPtr screen); extern _X_EXPORT void xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y); +#ifdef XV /* * For overlay video, compute the relevant CRTC and * clip video to that. @@ -974,6 +975,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, RegionPtr reg, INT32 width, INT32 height); +#endif extern _X_EXPORT xf86_crtc_notify_proc_ptr xf86_wrap_crtc_notify (ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new); commit c53380be804852045722203c993379813d97f6d7 Author: Ville Skytt?? <ville.skytta at iki.fi> Date: Sun Mar 6 10:18:30 2011 +0200 Man page syntax and spelling fixes. Signed-off-by: Ville Skytt?? <ville.skytta at iki.fi> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/kdrive/ephyr/man/Xephyr.man b/hw/kdrive/ephyr/man/Xephyr.man index 12c9f58..ca88ab2 100644 --- a/hw/kdrive/ephyr/man/Xephyr.man +++ b/hw/kdrive/ephyr/man/Xephyr.man @@ -1,18 +1,18 @@ -." -." Copyright (c) Matthieu Herrb <matthieu at herrb.eu> -." -." Permission to use, copy, modify, and distribute this software for any -." purpose with or without fee is hereby granted, provided that the above -." copyright notice and this permission notice appear in all copies. -." -." THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -." WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -." MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -." ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -." WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -." ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -." OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -." +.\" +.\" Copyright (c) Matthieu Herrb <matthieu at herrb.eu> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" .TH Xephyr __appmansuffix__ __vendorversion__ .SH NAME Xephyr - X server outputting to a window on a pre-existing X display @@ -81,7 +81,7 @@ build flags are causing this. I haven't figured as yet how to work round it. It doesn't appear to break anything however. .IP \(bu 2 Keyboard handling is basic but works. -.TP \(bu 2 +.IP \(bu 2 Mouse button 5 probably won't work. .SH "SEE ALSO" X(__miscmansuffix__), Xserver(__appmansuffix__) diff --git a/man/Xserver.man b/man/Xserver.man index 1a36b09..02cca52 100644 --- a/man/Xserver.man +++ b/man/Xserver.man @@ -143,12 +143,12 @@ is platform and configuration specific. disables named extension. If an unknown extension name is specified, a list of accepted extension names is printed. .TP 8 -.BI \+extension extensionName +.BI +extension extensionName enables named extension. If an unknown extension name is specified, a list of accepted extension names is printed. .TP 8 .B \-f \fIvolume\fP -sets feep (bell) volume (allowable range: 0-100). +sets beep (bell) volume (allowable range: 0-100). .TP 8 .B \-fc \fIcursorFont\fP sets default cursor font. @@ -524,8 +524,8 @@ An example configuration: .fi This will add /usr/share/X11/fonts/misc as the first FPE with the attribute -'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with -the attribute unscaled etc. This is functionally equivalent to setting +\N'39'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with +the attribute 'unscaled' etc. This is functionally equivalent to setting the following font path: .nf From jeremyhu at kemper.freedesktop.org Tue Oct 18 09:25:39 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 18 Oct 2011 09:25:39 -0700 (PDT) Subject: xserver: Branch 'server-1.10-branch' - 7 commits Message-ID: <20111018162539.4AC74C0001@kemper.freedesktop.org> Xext/shm.c | 6 +----- Xi/xipassivegrab.c | 13 ++++++++++--- dix/dispatch.c | 1 - dix/events.c | 14 +++++++++++++- fb/fbblt.c | 9 +++++++-- hw/xquartz/X11Application.m | 2 +- os/utils.c | 4 ++-- 7 files changed, 34 insertions(+), 15 deletions(-) New commits: commit e4bf3807ae2fa8b4491f0ed336bc42541faf2a55 Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:27:35 2011 +0200 Fix CVE-2011-4029: File permission change vulnerability. Use fchmod() to change permissions of the lock file instead of chmod(), thus avoid the race that can be exploited to set a symbolic link to any file or directory in the system. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit b67581cf825940fdf52bf2e0af4330e695d724a4) diff --git a/os/utils.c b/os/utils.c index fad72b4..da23589 100644 --- a/os/utils.c +++ b/os/utils.c @@ -306,7 +306,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* commit e72b6653628f7aa7bf59c2d42365e967fce685be Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:26:12 2011 +0200 Fix CVE-2011-4028: File disclosure vulnerability. use O_NOFOLLOW to open the existing lock file, so symbolic links aren't followed, thus avoid revealing if it point to an existing file. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit 6ba44b91e37622ef8c146d8f2ac92d708a18ed34) diff --git a/os/utils.c b/os/utils.c index fc72787..fad72b4 100644 --- a/os/utils.c +++ b/os/utils.c @@ -327,7 +327,7 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(LockFile, O_RDONLY|O_NOFOLLOW); if (lfd < 0) { unlink(tmp); FatalError("Can't read lock file %s\n", LockFile); commit b7b27e9cc1c948bdf4eace5fee8db3667eb4a8d5 Author: Sam Spilsbury <sam.spilsbury at canonical.com> Date: Wed Sep 14 09:58:34 2011 +0800 Remove the SendEvent bit (0x80) before doing range checks on event type. Some extension libraries may set this bit before converting the event to wire protocol and as such range checking the event will cause an invalid BadValue error to result. As the documentation suggests the the bit should be "forced on", remove it before doing range checks and continue to force it on in the server. Reviewed-by: Jamey Sharp <jamey at minilop.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> (cherry picked from commit 2d2dce558d24eeea0eb011ec9ebaa6c5c2273c39) (cherry picked from commit e9ae33316012ffe9acfeeb7303ab3392c2ca2a2b) diff --git a/dix/events.c b/dix/events.c index eefcdef..effbb22 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4981,6 +4981,8 @@ CloseDownEvents(void) InputEventList = NULL; } +#define SEND_EVENT_BIT 0x80 + /** * Server-side protocol handling for SendEvent request. * @@ -4998,6 +5000,16 @@ ProcSendEvent(ClientPtr client) REQUEST_SIZE_MATCH(xSendEventReq); + /* libXext and other extension libraries may set the bit indicating + * that this event came from a SendEvent request so remove it + * since otherwise the event type may fail the range checks + * and cause an invalid BadValue error to be returned. + * + * This is safe to do since we later add the SendEvent bit (0x80) + * back in once we send the event to the client */ + + stuff->event.u.u.type &= ~(SEND_EVENT_BIT); + /* The client's event type must be a core event type or one defined by an extension. */ @@ -5055,7 +5067,7 @@ ProcSendEvent(ClientPtr client) client->errorValue = stuff->propagate; return BadValue; } - stuff->event.u.u.type |= 0x80; + stuff->event.u.u.type |= SEND_EVENT_BIT; if (stuff->propagate) { for (;pWin; pWin = pWin->parent) commit 121a4f23d27a95948ce79b18be4b557db149a9ac Author: Carlos Garnacho <carlosg at gnome.org> Date: Wed Aug 31 00:46:52 2011 +0200 Xi: Fix passive XI2 ungrabs on XIAll[Master]Devices The corresponding DeviceIntPtr wasn't being gotten properly, resulting in BadDevice from dixLookupDevice(). Signed-off-by: Carlos Garnacho <carlosg at gnome.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> (cherry picked from commit f52d5cd374563544dafe29587411f345e31bbdf8) (cherry picked from commit 347f5610ca023fb31485aa19c20607af8bf9c834) diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index 776d334..762bedb 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -264,9 +264,16 @@ ProcXIPassiveUngrabDevice(ClientPtr client) REQUEST(xXIPassiveUngrabDeviceReq); REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq); - rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); - if (rc != Success) - return rc; + if (stuff->deviceid == XIAllDevices) + dev = inputInfo.all_devices; + else if (stuff->deviceid == XIAllMasterDevices) + dev = inputInfo.all_master_devices; + else + { + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); + if (rc != Success) + return rc; + } if (stuff->grab_type != XIGrabtypeButton && stuff->grab_type != XIGrabtypeKeycode && commit d8faf80bae3becf21f6bcb1bf5b17e4ab98e1686 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Sep 20 20:39:06 2011 -0700 XQuartz: Use set_front_process rather than X11ApplicationSetFrontProcess since we're already in the AppKit thread Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 38e9e28ba2fbffee52ad9889ef6d4e94c7af3e10) (cherry picked from commit 7b74bb67528033bf2d2a1714a801c38e7822642e) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 6e9de4b..b64ca1d 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -352,7 +352,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) { */ _appFlags._active = YES; - X11ApplicationSetFrontProcess(); + [self set_front_process:nil]; /* Get the Spaces preference for SwitchOnActivate */ (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock")); commit c187638e363dca2fa0b2026473b15b01adeef1c1 Author: Jamey Sharp <jamey at minilop.net> Date: Tue Sep 14 18:35:21 2010 -0700 Fix pixmap double-frees on error paths. If AddResource fails, it will automatically free the object that was passed to it by calling the appropriate deleteFunc; and of course FreeResource also calls the deleteFunc. In both cases it's wrong to call the destroy hook manually. Commit by Jamey Sharp and Josh Triplett. Signed-off-by: Jamey Sharp <jamey at minilop.net> Signed-off-by: Josh Triplett <josh at joshtriplett.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Aaron Plattner <aplattner at nvidia.com> (cherry picked from commit 0f380a5005f800572773cd4667ce43c7459cc467) (cherry picked from commit bd6ea85209e5ab80375d4ec9994d10a89fd1374a) diff --git a/Xext/shm.c b/Xext/shm.c index 23afe6b..d9469ea 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -993,7 +993,6 @@ CreatePmap: pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = newPix->info[j].id; if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) { - (*pScreen->DestroyPixmap)(pMap); result = BadAlloc; break; } @@ -1004,10 +1003,8 @@ CreatePmap: } if(result == BadAlloc) { - while(j--) { - (*pScreen->DestroyPixmap)(pMap); + while(j--) FreeResource(newPix->info[j].id, RT_NONE); - } free(newPix); } else AddResource(stuff->pid, XRT_PIXMAP, newPix); @@ -1112,7 +1109,6 @@ CreatePmap: { return Success; } - pDraw->pScreen->DestroyPixmap(pMap); } return BadAlloc; } diff --git a/dix/dispatch.c b/dix/dispatch.c index 7b2132d..d3b280a 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1418,7 +1418,6 @@ CreatePmap: } if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) return Success; - (*pDraw->pScreen->DestroyPixmap)(pMap); } return BadAlloc; } commit ef42bc7f67aba60f59dd9d047fb00df2943e3029 Author: Adam Jackson <ajax at redhat.com> Date: Thu Apr 21 16:37:11 2011 -0400 fb: Fix memcpy abuse The memcpy fast path implicitly assumes that the copy walks left-to-right. That's not something memcpy guarantees, and newer glibc on some processors will indeed break that assumption. Since we walk a line at a time, check the source and destination against the width of the blit to determine whether we can be sloppy enough to allow memcpy. (Having done this, we can remove the check for !reverse as well.) On an Intel Core i7-2630QM with an NVIDIA GeForce GTX 460M running in NoAccel, the broken code and various fixes for -copywinwin{10,100,500} gives (edited to fit in 80 columns): 1: Disable the fastpath entirely 2: Replace memcpy with memmove 3: This fix 4: The code before this fix 1 2 3 4 Operation ------ --------------- --------------- --------------- ------------ 258000 269000 ( 1.04) 544000 ( 2.11) 552000 ( 2.14) Copy 10x10 21300 23000 ( 1.08) 43700 ( 2.05) 47100 ( 2.21) Copy 100x100 960 962 ( 1.00) 1990 ( 2.09) 1990 ( 2.07) Copy 500x500 So it's a modest performance hit, but correctness demands it, and it's probably worth keeping the 2x speedup from having the fast path in the first place. Signed-off-by: Adam Jackson <ajax at redhat.com> Signed-off-by: Keith Packard <keithp at keithp.com> (cherry picked from commit e32cc0b4c85c78cd8743a6e1680dcc79054b57ce) diff --git a/fb/fbblt.c b/fb/fbblt.c index 38271c0..23ba3ae 100644 --- a/fb/fbblt.c +++ b/fb/fbblt.c @@ -65,6 +65,7 @@ fbBlt (FbBits *srcLine, int n, nmiddle; Bool destInvarient; int startbyte, endbyte; + int careful; FbDeclareMergeRop (); #ifdef FB_24BIT @@ -76,12 +77,16 @@ fbBlt (FbBits *srcLine, } #endif - if (alu == GXcopy && pm == FB_ALLONES && !reverse && + careful = !((srcLine < dstLine && srcLine + width * (bpp>>3) > dstLine) || + (dstLine < srcLine && dstLine + width * (bpp>>3) > srcLine)) || + (bpp & 7); + + if (alu == GXcopy && pm == FB_ALLONES && !careful && !(srcX & 7) && !(dstX & 7) && !(width & 7)) { int i; CARD8 *src = (CARD8 *) srcLine; CARD8 *dst = (CARD8 *) dstLine; - + srcStride *= sizeof(FbBits); dstStride *= sizeof(FbBits); width >>= 3; From jeremyhu at kemper.freedesktop.org Tue Oct 18 09:25:42 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 18 Oct 2011 09:25:42 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' - 2 commits Message-ID: <20111018162542.7D2A1C0001@kemper.freedesktop.org> os/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 12f65819ffb04103f170ecd7e281348de618fc4c Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:27:35 2011 +0200 Fix CVE-2011-4029: File permission change vulnerability. Use fchmod() to change permissions of the lock file instead of chmod(), thus avoid the race that can be exploited to set a symbolic link to any file or directory in the system. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit b67581cf825940fdf52bf2e0af4330e695d724a4) diff --git a/os/utils.c b/os/utils.c index 9e0acb6..d9aa65e 100644 --- a/os/utils.c +++ b/os/utils.c @@ -295,7 +295,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* commit f80d23357874db19bc124dee70239fb182977883 Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:26:12 2011 +0200 Fix CVE-2011-4028: File disclosure vulnerability. use O_NOFOLLOW to open the existing lock file, so symbolic links aren't followed, thus avoid revealing if it point to an existing file. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit 6ba44b91e37622ef8c146d8f2ac92d708a18ed34) diff --git a/os/utils.c b/os/utils.c index 36cb46f..9e0acb6 100644 --- a/os/utils.c +++ b/os/utils.c @@ -316,7 +316,7 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(LockFile, O_RDONLY|O_NOFOLLOW); if (lfd < 0) { unlink(tmp); FatalError("Can't read lock file %s\n", LockFile); From alanc at kemper.freedesktop.org Tue Oct 18 22:21:32 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Tue, 18 Oct 2011 22:21:32 -0700 (PDT) Subject: mkfontscale: Changes to 'master' Message-ID: <20111019052132.8A9F7C0001@kemper.freedesktop.org> Makefile.am | 6 +-- configure.ac | 10 +++--- data.h | 9 +++-- hash.c | 8 ++-- hash.h | 2 - ident.c | 10 +++--- list.c | 10 +++--- list.h | 6 +-- mkfontscale.c | 96 +++++++++++++++++++++++++++++----------------------------- 9 files changed, 80 insertions(+), 77 deletions(-) New commits: commit cd8182e74636ffd9b140603fc61502b42a9d6f2b Author: Maxim Iorsh <iorsh at users.sourceforge.net> Date: Tue Oct 18 22:07:45 2011 -0700 Add Culmus foundry to the vendor list for TrueType & Type1 fonts Maps fonts produced by the Culmus project <http://culmus.sourceforge.net> to the XLFD foundry name "culmus" For TrueType fonts, maps the vendor code "CLM" from the TrueType vendor id field. For Type1 fonts, which use heuristics to guess mappings to XLFD foundries from words in the copyright notice, add the names of the main contributors to the Culmus product to recognize the fonts under their copyright. Signed-off-by: Maxim Iorsh <iorsh at users.sourceforge.net> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit a39deac00add15532b15827c80601f87738cb405 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Tue Oct 4 21:03:13 2011 -0700 Strip trailing whitespace Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit b2d0f04a50f1444f9d62d11636a28c89951f0f40 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Tue Oct 4 21:00:11 2011 -0700 Add const attributes to fix gcc -Wwrite-strings warnings Does not fix all of them since some lists contain constant strings and some contain dynamically allocated strings that need to be freed later. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From jeremyhu at kemper.freedesktop.org Tue Oct 18 23:51:49 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Tue, 18 Oct 2011 23:51:49 -0700 (PDT) Subject: xf86-video-chips: Changes to 'master' Message-ID: <20111019065149.80BEBC0001@kemper.freedesktop.org> configure.ac | 3 -- src/ct_driver.c | 13 ++++++++---- src/ct_driver.h | 4 +-- util/dRegs.c | 57 ----------------------------------------------------- util/iopl.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ util/mRegs.c | 57 ----------------------------------------------------- util/modClock.c | 53 +------------------------------------------------ 7 files changed, 75 insertions(+), 172 deletions(-) New commits: commit 8a5ea07f30cc71ecc413fad0713facff72f77472 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 18 23:21:33 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit c421f2477c99990d0dc712d6aece981fa6c961e5 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 18 23:09:09 2011 -0700 Fix implicit declaration of iopl warning: implicit declaration of function ???iopl??? [-Wimplicit-function-declaration] Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 94a8b34528b42a4fe6f81c8b8bd1ddb6bebaeea9 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 18 23:04:32 2011 -0700 util: Consolidate common macros Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit f5191838b70d67e991bef3491d2a60915988079c Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 18 22:37:00 2011 -0700 configure.ac: Remove AM_PROG_CC_C_O Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 7ca1840f39d0216e44fe1ca938cfc3ced048da1d Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 18 22:24:54 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 00:13:38 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 00:13:38 -0700 (PDT) Subject: xf86-video-cirrus: Changes to 'master' Message-ID: <20111019071338.720CFC0001@kemper.freedesktop.org> src/alp_driver.c | 5 +++++ src/cir.h | 2 +- src/lg_driver.c | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) New commits: commit 9fcfd1aa760023e449cbb8c1eebd0bb570a6aacb Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:12:15 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 00:24:19 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 00:24:19 -0700 (PDT) Subject: xf86-video-i128: Changes to 'master' Message-ID: <20111019072419.D1774C0001@kemper.freedesktop.org> src/i128_driver.c | 31 +++++++++++++++++-------------- src/i128dga.c | 6 +++--- src/i128reg.h | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) New commits: commit 0e357623bc3d68e6eaf9bb755f44cca2d5321f8b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:24:00 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit c3eb2c3f05902be4e4e5b929663753276cde3611 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:23:12 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit f5c6593c9309541eedd374431dbd72151b8fb3ab Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:22:09 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 00:32:31 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 00:32:31 -0700 (PDT) Subject: xf86-video-rendition: Changes to 'master' Message-ID: <20111019073231.4E6B4C0001@kemper.freedesktop.org> src/accelX.c | 14 ++++++------ src/rendition.c | 20 ++++++++++-------- src/v1krisc.c | 62 ++++++++++++++++++++++++++++---------------------------- src/vboard.c | 4 +-- src/vloaduc.c | 12 +++++----- src/vmodes.c | 7 +++--- src/vos.h | 12 +++++----- src/vramdac.c | 36 ++++++++++++++++---------------- src/vtypes.h | 2 - 9 files changed, 87 insertions(+), 82 deletions(-) New commits: commit 810c279e9106a96aa6c6d395610ade3cd1b61fba Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:31:41 2011 -0700 Include <unistd.h> for usleep Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 99d960880e3aedc35238e26841e13e12f317395d Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:31:05 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit efcd0f31433ddbcf04ca040f8474f6cb8a080271 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:29:28 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 11c189cd7b183561432736e4042f36c556de7a05 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:29:27 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 00:40:54 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 00:40:54 -0700 (PDT) Subject: xf86-video-sis: Changes to 'master' Message-ID: <20111019074054.B91D5C0001@kemper.freedesktop.org> src/osdef.h | 24 ++++++++++++------------ src/sis.h | 4 ++-- src/sis_driver.c | 2 +- src/vgatypes.h | 12 ++---------- 4 files changed, 17 insertions(+), 25 deletions(-) New commits: commit 4b0aab53a1e8500578f86178761f4c805b2a5990 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:40:32 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 69aa104ed064ca08196e7310e232ddb5c9a590bd Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:35:02 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 00:46:42 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 00:46:42 -0700 (PDT) Subject: xf86-video-tdfx: Changes to 'master' Message-ID: <20111019074642.0EC96C0001@kemper.freedesktop.org> src/tdfx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit d7be4a953859f12083c1743c73712f9f510d7fda Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:41:56 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 00:56:46 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 00:56:46 -0700 (PDT) Subject: xf86-video-trident: Changes to 'master' Message-ID: <20111019075646.DB2E3C0001@kemper.freedesktop.org> src/trident.h | 4 ++-- src/trident_driver.c | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) New commits: commit b20007d04b9198188fd214d3ed7d850dd613bc97 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:56:32 2011 -0700 Use uint32_t instead of deprecated PCITAG Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit da09f04b6d7da1ca10ce9d20a00d8ac9f2c0adb7 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:55:17 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 0bd545e1301d55c5874484f2a4a7952b6eca48c0 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 00:52:09 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 01:12:29 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 01:12:29 -0700 (PDT) Subject: xf86-video-tseng: Changes to 'master' Message-ID: <20111019081230.058D8C0001@kemper.freedesktop.org> src/tseng_cursor.c | 2 +- src/tseng_mode.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) New commits: commit 9d9895962f4078404dae06a2db5d3fe3a23e0133 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 01:11:49 2011 -0700 Fix a compiler warning tseng_cursor.c:163:1: warning: no previous prototype for 'TsengLoadCursorImage' [-Wmissing-prototypes] Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 39dd08e1b84c9aecf4eb296db51f25f4b2ff925c Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 01:09:30 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 01:41:48 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 01:41:48 -0700 (PDT) Subject: xf86-video-vesa: Changes to 'master' Message-ID: <20111019084148.158D6C0001@kemper.freedesktop.org> src/vesa.c | 49 +++++++++++++++++++++++++++++-------------------- src/vesa.h | 2 +- 2 files changed, 30 insertions(+), 21 deletions(-) New commits: commit efe1792818be463dd0367178f0233bc502b7a584 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 01:38:49 2011 -0700 Code style cleanup to make the map and unmap blocks more consistent Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 1f84310ddf49778f776a39810aa98211c812e8ab Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 01:33:07 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 1a60e9068284e1ef22d8c470a85410a54ee668e8 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 01:15:13 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 463886df688d3521afc47ec88f9aaf67e924ec7f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 01:15:03 2011 -0700 Build fix for ABI Version 12 ABI Version 12 removes support for multiple PCI domains. If you need to use this driver on a system with more than one PCI domain, you should either port this driver to using libpciaccess directly or stick with an older server. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Wed Oct 19 01:50:18 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 01:50:18 -0700 (PDT) Subject: xf86-video-vesa: Changes to 'master' Message-ID: <20111019085018.589E5C0001@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 4ba7306fd0c9533750d389829e2cbf0522e149b3 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 01:49:38 2011 -0700 configure.ac: Require a newer version of libpciaccess Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From ickle at kemper.freedesktop.org Wed Oct 19 05:54:24 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Wed, 19 Oct 2011 05:54:24 -0700 (PDT) Subject: xf86-video-intel: 6 commits - src/sna/compiler.h src/sna/kgem.h src/sna/Makefile.am src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_composite.c src/sna/sna_damage.c src/sna/sna.h src/sna/sna_reg.h src/sna/sna_render.h src/sna/sna_render_inline.h src/sna/sna_trapezoids.c Message-ID: <20111019125424.754FAC0001@kemper.freedesktop.org> src/sna/Makefile.am | 1 src/sna/compiler.h | 43 +++++ src/sna/kgem.h | 10 - src/sna/sna.h | 12 + src/sna/sna_accel.c | 374 ++++++++++++++++++++------------------------ src/sna/sna_blt.c | 114 +++++++++---- src/sna/sna_composite.c | 4 src/sna/sna_damage.c | 12 + src/sna/sna_reg.h | 2 src/sna/sna_render.h | 4 src/sna/sna_render_inline.h | 2 src/sna/sna_trapezoids.c | 4 12 files changed, 329 insertions(+), 253 deletions(-) New commits: commit 5515f75647bb148d9e720dcc4713a93b59ffbd49 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 13:49:55 2011 +0100 sna: Enlarge the minimum pixmap size to migrate for Render This is to workaround a ping-pong issue involving small icons. The horrible sequence of operations appears to use a tiled FillRect to copy from the scanout onto to a temporary pixmap, which causes us to readback from the scanout. We are destined to hit the fallback path there anyway until we implement stippling... References: https://bugs.freedesktop.org/show_bug.cgi?id=41718 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h index a2bee0c..fe6d5b8 100644 --- a/src/sna/sna_render_inline.h +++ b/src/sna/sna_render_inline.h @@ -87,7 +87,7 @@ is_dirty_gpu(DrawablePtr drawable) static inline Bool too_small(DrawablePtr drawable) { - return (drawable->width * drawable->height <= 256) && + return (drawable->width * drawable->height * drawable->bitsPerPixel <= 8*4096) && !is_dirty_gpu(drawable); } commit 87ba33bc0bcaf3c5160edfc61cff3ba0d28d3fd8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 13:09:19 2011 +0100 sna/damage: Avoid reducing the damage for simple tests Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index efb1cfe..f6ffef0 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -480,7 +480,7 @@ struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, BoxRec box; if (damage->mode == SUBTRACT) - __sna_damage_reduce(damage); + return damage; box.x1 = box.y1 = 0; box.x2 = width; @@ -658,8 +658,16 @@ static int _sna_damage_contains_box(struct sna_damage *damage, if (!sna_damage_maybe_contains_box(damage, box)) return PIXMAN_REGION_OUT; - if (damage->n) + if (damage->n) { + if (damage->mode != SUBTRACT) { + int ret = pixman_region_contains_rectangle(&damage->region, + (BoxPtr)box); + if (ret == PIXMAN_REGION_IN) + return PIXMAN_REGION_IN; + } + __sna_damage_reduce(damage); + } return pixman_region_contains_rectangle(&damage->region, (BoxPtr)box); } commit 63aa84ef57ff1e55d2df6d680d6bbf88be0619a6 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 13:08:50 2011 +0100 sna/gen6: Apply the unknown blitter death workaround Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 0148785..3b2c0b9 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -102,7 +102,21 @@ static void blt_done(struct sna *sna, const struct sna_composite_op *op) { struct kgem *kgem = &sna->kgem; - DBG(("%s: nbatch=%d\n", __FUNCTION__, kgem->nbatch)); + _kgem_set_mode(kgem, KGEM_BLT); + (void)op; +} + +static void gen6_blt_copy_done(struct sna *sna, const struct sna_composite_op *op) +{ + struct kgem *kgem = &sna->kgem; + + if (kgem_check_batch(kgem, 3)) { + uint32_t *b = kgem->batch + kgem->nbatch; + b[0] = XY_SETUP_CLIP; + b[1] = b[2] = 0; + kgem->nbatch += 3; + } + _kgem_set_mode(kgem, KGEM_BLT); (void)op; } @@ -815,7 +829,10 @@ prepare_blt_copy(struct sna *sna, op->blt = blt_copy_composite; op->box = blt_copy_composite_box; op->boxes = blt_copy_composite_boxes; - op->done = blt_done; + if (sna->kgem.gen >= 60) + op->done = gen6_blt_copy_done; + else + op->done = blt_done; return sna_blt_copy_init(sna, &op->u.blt, priv->gpu_bo, @@ -1297,6 +1314,12 @@ static void sna_blt_copy_op_done(struct sna *sna, blt_done(sna, &op->base); } +static void gen6_blt_copy_op_done(struct sna *sna, + const struct sna_copy_op *op) +{ + gen6_blt_copy_done(sna, &op->base); +} + bool sna_blt_copy(struct sna *sna, uint8_t alu, struct kgem_bo *src, struct kgem_bo *dst, @@ -1319,7 +1342,10 @@ bool sna_blt_copy(struct sna *sna, uint8_t alu, return FALSE; op->blt = sna_blt_copy_op_blt; - op->done = sna_blt_copy_op_done; + if (sna->kgem.gen >= 60) + op->done = gen6_blt_copy_op_done; + else + op->done = sna_blt_copy_op_done; return TRUE; } @@ -1539,6 +1565,13 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, _kgem_submit(kgem); } while (nbox); + if (kgem->gen >= 60 && kgem_check_batch(kgem, 3)) { + uint32_t *b = kgem->batch + kgem->nbatch; + b[0] = XY_SETUP_CLIP; + b[1] = b[2] = 0; + kgem->nbatch += 3; + } + _kgem_set_mode(kgem, KGEM_BLT); return TRUE; } diff --git a/src/sna/sna_reg.h b/src/sna/sna_reg.h index 8ca9089..75f35c4 100644 --- a/src/sna/sna_reg.h +++ b/src/sna/sna_reg.h @@ -46,7 +46,7 @@ #define XY_COLOR_BLT_WRITE_RGB (1<<20) #define XY_COLOR_BLT_TILED (1<<11) -#define XY_SETUP_CLIP_BLT_CMD ((2<<29)|(3<<22)|1) +#define XY_SETUP_CLIP ((2<<29)|(3<<22)|1) #define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6) #define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21) commit 25f2d181946738d1ac2deb724eb48453c8692ed1 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 23:03:10 2011 +0100 sna: Compute region extents in place to eliminate redundant stack space Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 201a92a..07132bf 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1177,10 +1177,10 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth, PixmapPtr pixmap = get_drawable_pixmap(drawable); struct sna_pixmap *priv = sna_pixmap(pixmap); RegionRec region, *clip; - BoxRec box; int16_t dx, dy; - DBG(("%s((%d, %d)x(%d, %d)\n", __FUNCTION__, x, y, w, h)); + DBG(("%s((%d, %d)x(%d, %d), depth=%d, format=%d)\n", + __FUNCTION__, x, y, w, h, depth, format)); if (w == 0 || h == 0) return; @@ -1194,24 +1194,16 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth, get_drawable_deltas(drawable, pixmap, &dx, &dy); - box.x1 = x + drawable->x + dx; - box.y1 = y + drawable->y + dy; - box.x2 = box.x1 + w; - box.y2 = box.y1 + h; - - if (box.x1 < 0) - box.x1 = 0; - if (box.y1 < 0) - box.y1 = 0; - if (box.x2 > pixmap->drawable.width) - box.x2 = pixmap->drawable.width; - if (box.y2 > pixmap->drawable.height) - box.y2 = pixmap->drawable.height; - if (box_empty(&box)) - return; + region.extents.x1 = x + drawable->x + dx; + region.extents.y1 = y + drawable->y + dy; + region.extents.x2 = region.extents.x1 + w; + region.extents.y2 = region.extents.y1 + h; - region_set(®ion, &box); + trim_box(®ion.extents, &pixmap->drawable); + if (box_empty(®ion.extents)) + return; + region.data = NULL; clip = fbGetCompositeClip(gc); if (clip) { RegionTranslate(clip, dx, dy); @@ -1688,7 +1680,6 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, __FUNCTION__, src_x, src_y, width, height, dst_x, dst_y)); if (wedged(sna) || !PM_IS_SOLID(dst, gc->planemask)) { - BoxRec box; RegionRec region; DBG(("%s: -- fallback, wedged=%d, solid=%d [%x]\n", @@ -1696,11 +1687,11 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, PM_IS_SOLID(dst, gc->planemask), (unsigned)gc->planemask)); - box.x1 = dst_x + dst->x; - box.y1 = dst_y + dst->y; - box.x2 = box.x1 + width; - box.y2 = box.y1 + height; - region_set(®ion, &box); + region.extents.x1 = dst_x + dst->x; + region.extents.y1 = dst_y + dst->y; + region.extents.x2 = region.extents.x1 + width; + region.extents.y2 = region.extents.y1 + height; + region.data = NULL; if (gc->pCompositeClip) RegionIntersect(®ion, ®ion, gc->pCompositeClip); @@ -2046,16 +2037,16 @@ static void sna_set_spans(DrawablePtr drawable, GCPtr gc, char *src, DDXPointPtr pt, int *width, int n, int sorted) { - BoxRec extents; RegionRec region; - if (sna_spans_extents(drawable, gc, n, pt, width, &extents)) + if (sna_spans_extents(drawable, gc, n, pt, width, ®ion.extents)) return; DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, - extents.x1, extents.y1, extents.x2, extents.y2)); + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); - region_set(®ion, &extents); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2073,18 +2064,16 @@ sna_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc, int dst_x, int dst_y, unsigned long bit) { - BoxRec box; RegionRec region; DBG(("%s: src=(%d, %d), dst=(%d, %d), size=%dx%d\n", __FUNCTION__, src_x, src_y, dst_x, dst_y, w, h)); - box.x1 = dst_x + dst->x; - box.y1 = dst_y + dst->y; - box.x2 = box.x1 + w; - box.y2 = box.y1 + h; - - region_set(®ion, &box); + region.extents.x1 = dst_x + dst->x; + region.extents.y1 = dst_y + dst->y; + region.extents.x2 = region.extents.x1 + w; + region.extents.y2 = region.extents.y1 + h; + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); sna_drawable_move_region_to_cpu(dst, ®ion, true); @@ -2182,17 +2171,17 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt) { struct sna *sna = to_sna_from_drawable(drawable); - BoxRec extents; RegionRec region; DBG(("%s(mode=%d, n=%d, pt[0]=(%d, %d)\n", __FUNCTION__, mode, n, pt[0].x, pt[0].y)); - if (sna_poly_point_extents(drawable, gc, mode, n, pt, &extents)) + if (sna_poly_point_extents(drawable, gc, mode, n, pt, ®ion.extents)) return; DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__, - extents.x1, extents.y1, extents.x2, extents.y2)); + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); if (FORCE_FALLBACK) goto fallback; @@ -2209,14 +2198,14 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc, DBG(("%s: trying solid fill [%08lx] blt paths\n", __FUNCTION__, gc->fgPixel)); - if (sna_drawable_use_gpu_bo(drawable, &extents) && + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_poly_point_blt(drawable, priv->gpu_bo, priv->gpu_only ? NULL : &priv->gpu_damage, gc, mode, n, pt)) return; - if (sna_drawable_use_cpu_bo(drawable, &extents) && + if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_point_blt(drawable, priv->cpu_bo, &priv->cpu_damage, @@ -2226,7 +2215,7 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc, fallback: DBG(("%s: fallback\n", __FUNCTION__)); - region_set(®ion, &extents); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2403,17 +2392,17 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt) { struct sna *sna = to_sna_from_drawable(drawable); - BoxRec extents; RegionRec region; DBG(("%s(mode=%d, n=%d, pt[0]=(%d, %d), lineWidth=%d\n", __FUNCTION__, mode, n, pt[0].x, pt[0].y, gc->lineWidth)); - if (sna_poly_line_extents(drawable, gc, mode, n, pt, &extents)) + if (sna_poly_line_extents(drawable, gc, mode, n, pt, ®ion.extents)) return; DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__, - extents.x1, extents.y1, extents.x2, extents.y2)); + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); if (FORCE_FALLBACK) goto fallback; @@ -2433,14 +2422,14 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, DBG(("%s: trying solid fill [%08lx]\n", __FUNCTION__, gc->fgPixel)); - if (sna_drawable_use_gpu_bo(drawable, &extents) && + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_poly_line_blt(drawable, priv->gpu_bo, priv->gpu_only ? NULL : &priv->gpu_damage, gc, mode, n, pt)) return; - if (sna_drawable_use_cpu_bo(drawable, &extents) && + if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_line_blt(drawable, priv->cpu_bo, &priv->cpu_damage, @@ -2449,7 +2438,7 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, } if (USE_SPANS && can_fill_spans(drawable, gc) && - sna_drawable_use_gpu_bo(drawable, &extents)) { + sna_drawable_use_gpu_bo(drawable, ®ion.extents)) { DBG(("%s: converting line into spans\n", __FUNCTION__)); switch (gc->lineStyle) { case LineSolid: @@ -2476,7 +2465,7 @@ fallback: return; } - region_set(®ion, &extents); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2707,7 +2696,6 @@ static void sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) { struct sna *sna = to_sna_from_drawable(drawable); - BoxRec extents; RegionRec region; DBG(("%s(n=%d, first=((%d, %d), (%d, %d)), lineWidth=%d\n", @@ -2715,11 +2703,12 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) n, seg->x1, seg->y1, seg->x2, seg->y2, gc->lineWidth)); - if (sna_poly_segment_extents(drawable, gc, n, seg, &extents)) + if (sna_poly_segment_extents(drawable, gc, n, seg, ®ion.extents)) return; DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, - extents.x1, extents.y1, extents.x2, extents.y2)); + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); if (FORCE_FALLBACK) goto fallback; @@ -2739,24 +2728,24 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) DBG(("%s: trying blt solid fill [%08lx] paths\n", __FUNCTION__, gc->fgPixel)); - if (sna_drawable_use_gpu_bo(drawable, &extents) && + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_poly_segment_blt(drawable, priv->gpu_bo, - priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, &extents), - gc, n, seg, &extents)) + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), + gc, n, seg, ®ion.extents)) return; - if (sna_drawable_use_cpu_bo(drawable, &extents) && + if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_segment_blt(drawable, priv->cpu_bo, - reduce_damage(drawable, &priv->cpu_damage, &extents), - gc, n, seg, &extents)) + reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), + gc, n, seg, ®ion.extents)) return; } /* XXX Do we really want to base this decision on the amalgam ? */ if (USE_SPANS && can_fill_spans(drawable, gc) && - sna_drawable_use_gpu_bo(drawable, &extents)) { + sna_drawable_use_gpu_bo(drawable, ®ion.extents)) { void (*line)(DrawablePtr, GCPtr, int, int, DDXPointPtr); int i; @@ -2789,7 +2778,7 @@ fallback: return; } - region_set(®ion, &extents); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2867,16 +2856,16 @@ static void sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) { struct sna *sna = to_sna_from_drawable(drawable); - BoxRec extents; RegionRec region; DBG(("%s(n=%d, lineWidth=%d\n", __FUNCTION__, n, gc->lineWidth)); - if (sna_poly_arc_extents(drawable, gc, n, arc, &extents)) + if (sna_poly_arc_extents(drawable, gc, n, arc, ®ion.extents)) return; DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, - extents.x1, extents.y1, extents.x2, extents.y2)); + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); if (FORCE_FALLBACK) goto fallback; @@ -2888,7 +2877,7 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) /* For "simple" cases use the miPolyArc to spans path */ if (USE_SPANS && arc_to_spans(gc, n) && can_fill_spans(drawable, gc) && - sna_drawable_use_gpu_bo(drawable, &extents)) { + sna_drawable_use_gpu_bo(drawable, ®ion.extents)) { DBG(("%s: converting arcs into spans\n", __FUNCTION__)); miPolyArc(drawable, gc, n, arc); return; @@ -2901,7 +2890,7 @@ fallback: return; } - region_set(®ion, &extents); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -2993,16 +2982,16 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, } else { while (n--) { RegionRec region; - BoxRec r,*box; + BoxRec *box; int nbox; - r.x1 = rect->x + drawable->x; - r.y1 = rect->y + drawable->y; - r.x2 = bound(r.x1, rect->width); - r.y2 = bound(r.y1, rect->height); + region.extents.x1 = rect->x + drawable->x; + region.extents.y1 = rect->y + drawable->y; + region.extents.x2 = bound(region.extents.x1, rect->width); + region.extents.y2 = bound(region.extents.y1, rect->height); rect++; - region_set(®ion, &r); + region.data = NULL; RegionIntersect(®ion, ®ion, clip); nbox = REGION_NUM_RECTS(®ion); @@ -3101,16 +3090,16 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, } else { while (n--) { RegionRec region; - BoxRec r,*box; + BoxRec *box; int nbox; - r.x1 = rect->x + drawable->x; - r.y1 = rect->y + drawable->y; - r.x2 = bound(r.x1, rect->width); - r.y2 = bound(r.y1, rect->height); + region.extents.x1 = rect->x + drawable->x; + region.extents.y1 = rect->y + drawable->y; + region.extents.x2 = bound(region.extents.x1, rect->width); + region.extents.y2 = bound(region.extents.y1, rect->height); rect++; - region_set(®ion, &r); + region.data = NULL; RegionIntersect(®ion, ®ion, clip); nbox = REGION_NUM_RECTS(®ion); @@ -3204,16 +3193,16 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, } else { while (n--) { RegionRec region; - BoxRec r,*box; + BoxRec *box; int nbox; - r.x1 = rect->x + drawable->x; - r.y1 = rect->y + drawable->y; - r.x2 = bound(r.x1, rect->width); - r.y2 = bound(r.y1, rect->height); + region.extents.x1 = rect->x + drawable->x; + region.extents.y1 = rect->y + drawable->y; + region.extents.x2 = bound(region.extents.x1, rect->width); + region.extents.y2 = bound(region.extents.y1, rect->height); rect++; - region_set(®ion, &r); + region.data = NULL; RegionIntersect(®ion, ®ion, clip); nbox = REGION_NUM_RECTS(®ion); @@ -3301,7 +3290,6 @@ static void sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) { struct sna *sna = to_sna_from_drawable(draw); - BoxRec extents; RegionRec region; DBG(("%s(n=%d, PlaneMask: %lx (solid %d), solid fill: %d [style=%d, tileIsPixel=%d], alu=%d)\n", __FUNCTION__, @@ -3311,7 +3299,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) gc->fillStyle, gc->tileIsPixel, gc->alu)); - if (sna_poly_fill_rect_extents(draw, gc, n, rect, &extents)) { + if (sna_poly_fill_rect_extents(draw, gc, n, rect, ®ion.extents)) { DBG(("%s, nothing to do\n", __FUNCTION__)); return; } @@ -3335,17 +3323,17 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) __FUNCTION__, gc->fillStyle == FillSolid ? gc->fgPixel : gc->tile.pixel)); - if (sna_drawable_use_gpu_bo(draw, &extents) && + if (sna_drawable_use_gpu_bo(draw, ®ion.extents) && sna_poly_fill_rect_blt(draw, priv->gpu_bo, - priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, &extents), + priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, ®ion.extents), gc, n, rect)) return; - if (sna_drawable_use_cpu_bo(draw, &extents) && + if (sna_drawable_use_cpu_bo(draw, ®ion.extents) && sna_poly_fill_rect_blt(draw, priv->cpu_bo, - reduce_damage(draw, &priv->cpu_damage, &extents), + reduce_damage(draw, &priv->cpu_damage, ®ion.extents), gc, n, rect)) return; } else if (gc->fillStyle == FillTiled) { @@ -3353,25 +3341,26 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) DBG(("%s: tiled fill, testing for blt\n", __FUNCTION__)); - if (sna_drawable_use_gpu_bo(draw, &extents) && + if (sna_drawable_use_gpu_bo(draw, ®ion.extents) && sna_poly_fill_rect_tiled(draw, priv->gpu_bo, - priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, &extents), + priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, ®ion.extents), gc, n, rect)) return; - if (sna_drawable_use_cpu_bo(draw, &extents) && + if (sna_drawable_use_cpu_bo(draw, ®ion.extents) && sna_poly_fill_rect_tiled(draw, priv->cpu_bo, - reduce_damage(draw, &priv->cpu_damage, &extents), + reduce_damage(draw, &priv->cpu_damage, ®ion.extents), gc, n, rect)) return; } fallback: DBG(("%s: fallback (%d, %d), (%d, %d)\n", __FUNCTION__, - extents.x1, extents.y1, extents.x2, extents.y2)); - region_set(®ion, &extents); + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) { DBG(("%s: nothing to do, all clipped\n", __FUNCTION__)); @@ -3590,28 +3579,26 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, { struct sna *sna = to_sna_from_drawable(drawable); ExtentInfoRec extents; - BoxRec box; RegionRec region; if (n == 0) return; QueryGlyphExtents(gc->font, info, n, &extents); - box.x1 = x + extents.overallLeft; - box.y1 = y - extents.overallAscent; - box.x2 = x + extents.overallRight; - box.y2 = y + extents.overallDescent; - - trim_box(&box, drawable); - if (box_empty(&box)) - return; - translate_box(&box, drawable); - clip_box(&box, gc); - if (box_empty(&box)) + region.extents.x1 = x + extents.overallLeft; + region.extents.y1 = y - extents.overallAscent; + region.extents.x2 = x + extents.overallRight; + region.extents.y2 = y + extents.overallDescent; + + trim_box(®ion.extents, drawable); + translate_box(®ion.extents, drawable); + clip_box(®ion.extents, gc); + if (box_empty(®ion.extents)) return; - DBG(("%s: extents(%d, %d), (%d, %d)\n", - __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); + DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); if (FORCE_FALLBACK) goto fallback; @@ -3621,12 +3608,12 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, goto fallback; } - if (sna_drawable_use_gpu_bo(drawable, &box) && - sna_glyph_blt(drawable, gc, x, y, n, info, base, false, &box)) + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && + sna_glyph_blt(drawable, gc, x, y, n, info, base, false, ®ion.extents)) return; fallback: - region_set(®ion, &box); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -3646,28 +3633,26 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, { struct sna *sna = to_sna_from_drawable(drawable); ExtentInfoRec extents; - BoxRec box; RegionRec region; if (n == 0) return; QueryGlyphExtents(gc->font, info, n, &extents); - box.x1 = x + extents.overallLeft; - box.y1 = y - extents.overallAscent; - box.x2 = x + extents.overallRight; - box.y2 = y + extents.overallDescent; - - trim_box(&box, drawable); - if (box_empty(&box)) - return; - translate_box(&box, drawable); - clip_box(&box, gc); - if (box_empty(&box)) + region.extents.x1 = x + extents.overallLeft; + region.extents.y1 = y - extents.overallAscent; + region.extents.x2 = x + extents.overallRight; + region.extents.y2 = y + extents.overallDescent; + + trim_box(®ion.extents, drawable); + translate_box(®ion.extents, drawable); + clip_box(®ion.extents, gc); + if (box_empty(®ion.extents)) return; - DBG(("%s: extents(%d, %d), (%d, %d)\n", - __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); + DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); if (FORCE_FALLBACK) goto fallback; @@ -3677,12 +3662,12 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, goto fallback; } - if (sna_drawable_use_gpu_bo(drawable, &box) && - sna_glyph_blt(drawable, gc, x, y, n, info, base, true, &box)) + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && + sna_glyph_blt(drawable, gc, x, y, n, info, base, true, ®ion.extents)) return; fallback: - region_set(®ion, &box); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -3700,7 +3685,6 @@ sna_push_pixels(GCPtr gc, PixmapPtr bitmap, DrawablePtr drawable, int w, int h, int x, int y) { - BoxRec box; RegionRec region; if (w == 0 || h == 0) @@ -3708,23 +3692,24 @@ sna_push_pixels(GCPtr gc, PixmapPtr bitmap, DrawablePtr drawable, DBG(("%s (%d, %d)x(%d, %d)\n", __FUNCTION__, x, y, w, h)); - box.x1 = x; - box.y1 = y; + region.extents.x1 = x; + region.extents.y1 = y; if (!gc->miTranslate) { - box.x1 += drawable->x; - box.y1 += drawable->y; + region.extents.x1 += drawable->x; + region.extents.y1 += drawable->y; } - box.x2 = box.x1 + w; - box.y2 = box.y1 + h; + region.extents.x2 = region.extents.x1 + w; + region.extents.y2 = region.extents.y1 + h; - clip_box(&box, gc); - if (box_empty(&box)) + clip_box(®ion.extents, gc); + if (box_empty(®ion.extents)) return; - DBG(("%s: extents(%d, %d), (%d, %d)\n", - __FUNCTION__, box.x1, box.y1, box.x2, box.y2)); + DBG(("%s: extents(%d, %d), (%d, %d)\n", __FUNCTION__, + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); - region_set(®ion, &box); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; @@ -3814,36 +3799,31 @@ sna_get_image(DrawablePtr drawable, unsigned int format, unsigned long mask, char *dst) { - BoxRec extents; RegionRec region; DBG(("%s (%d, %d, %d, %d)\n", __FUNCTION__, x, y, w, h)); - extents.x1 = x + drawable->x; - extents.y1 = y + drawable->y; - extents.x2 = extents.x1 + w; - extents.y2 = extents.y1 + h; - region_set(®ion, &extents); + region.extents.x1 = x + drawable->x; + region.extents.y1 = y + drawable->y; + region.extents.x2 = region.extents.x1 + w; + region.extents.y2 = region.extents.y1 + h; + region.data = NULL; sna_drawable_move_region_to_cpu(drawable, ®ion, false); fbGetImage(drawable, x, y, w, h, format, mask, dst); - - RegionUninit(®ion); } static void sna_get_spans(DrawablePtr drawable, int wMax, DDXPointPtr pt, int *width, int n, char *start) { - BoxRec extents; RegionRec region; - if (sna_spans_extents(drawable, NULL, n, pt, width, &extents)) + if (sna_spans_extents(drawable, NULL, n, pt, width, ®ion.extents)) return; - region_set(®ion, &extents); + region.data = NULL; sna_drawable_move_region_to_cpu(drawable, ®ion, false); - RegionUninit(®ion); fbGetSpans(drawable, wMax, pt, width, n, start); } commit 1a43b2a46a67fdea215719c4446224c9d2e26a20 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 17:52:56 2011 +0100 sna: Use the unlikely wedged() throughout Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 6101fb6..201a92a 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -842,7 +842,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap) DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL)); if (priv->gpu_bo == NULL) { - if (!sna->kgem.wedged) + if (!wedged(sna)) priv->gpu_bo = kgem_create_2d(&sna->kgem, pixmap->drawable.width, @@ -1687,7 +1687,7 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, DBG(("%s: src=(%d, %d)x(%d, %d) -> dst=(%d, %d)\n", __FUNCTION__, src_x, src_y, width, height, dst_x, dst_y)); - if (sna->kgem.wedged || !PM_IS_SOLID(dst, gc->planemask)) { + if (wedged(sna) || !PM_IS_SOLID(dst, gc->planemask)) { BoxRec box; RegionRec region; @@ -2197,7 +2197,7 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc, if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -2418,7 +2418,7 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -2724,7 +2724,7 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -2881,7 +2881,7 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -3319,7 +3319,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -3616,7 +3616,7 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc, if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -3672,7 +3672,7 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc, if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -3858,7 +3858,7 @@ sna_copy_window(WindowPtr win, DDXPointRec origin, RegionPtr src) DBG(("%s origin=(%d, %d)\n", __FUNCTION__, origin.x, origin.y)); - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); sna_pixmap_move_to_cpu(pixmap, true); fbCopyWindow(win, origin, src); diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index e0b1ca3..3962d75 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -434,7 +434,7 @@ sna_composite(CARD8 op, width, height)) return; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -641,7 +641,7 @@ sna_composite_rectangles(CARD8 op, RegionExtents(®ion)->x1, RegionExtents(®ion)->y1, RegionExtents(®ion)->x2, RegionExtents(®ion)->y2)); - if (sna->kgem.wedged) + if (wedged(sna)) goto fallback; if (dst->alphaMap) { diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index 9801121..80b4733 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -3010,7 +3010,7 @@ sna_composite_trapezoids(CARD8 op, if (NO_ACCEL) goto fallback; - if (sna->kgem.wedged || !sna->have_render) { + if (wedged(sna) || !sna->have_render) { DBG(("%s: fallback -- wedged=%d, have_render=%d\n", __FUNCTION__, sna->kgem.wedged, sna->have_render)); goto fallback; commit 7a9c76e1812d106fedf160c959e6e502998e4ce8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Tue Oct 18 15:51:33 2011 +0100 sna: Micro-optimise fill-spans Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/Makefile.am b/src/sna/Makefile.am index bacb98f..2a10801 100644 --- a/src/sna/Makefile.am +++ b/src/sna/Makefile.am @@ -32,6 +32,7 @@ NULL:=# libsna_la_SOURCES = \ blt.c \ + compiler.h \ kgem.c \ kgem.h \ sna.h \ diff --git a/src/sna/compiler.h b/src/sna/compiler.h new file mode 100644 index 0000000..0b11310 --- /dev/null +++ b/src/sna/compiler.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011 Intel Corporation + * + * 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 (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 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. + * + * Authors: + * Chris Wilson <chris at chris-wilson.co.uk> + * + */ + +#ifndef _SNA_COMPILER_H_ +#define _SNA_COMPILER_H_ + +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) +#define likely(expr) (__builtin_expect (!!(expr), 1)) +#define unlikely(expr) (__builtin_expect (!!(expr), 0)) +#define noinline __attribute__((noinline)) +#define fastcall __attribute__((regparm(3))) +#else +#define likely(expr) (expr) +#define unlikely(expr) (expr) +#define noinline +#define fastcall +#endif + +#endif /* _SNA_COMPILER_H_ */ diff --git a/src/sna/kgem.h b/src/sna/kgem.h index a43a712..43e126b 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -25,14 +25,16 @@ * */ +#ifndef KGEM_H +#define KGEM_H + #include <stdint.h> #include <stdbool.h> #include <stdarg.h> #include <i915_drm.h> -#ifndef KGEM_H -#define KGEM_H +#include "compiler.h" #if DEBUG_KGEM #define DBG_HDR(x) ErrorF x @@ -249,12 +251,12 @@ static inline void _kgem_set_mode(struct kgem *kgem, enum kgem_mode mode) static inline bool kgem_check_batch(struct kgem *kgem, int num_dwords) { - return kgem->nbatch + num_dwords + KGEM_BATCH_RESERVED <= kgem->surface; + return likely(kgem->nbatch + num_dwords + KGEM_BATCH_RESERVED <= kgem->surface); } static inline bool kgem_check_reloc(struct kgem *kgem, int num_reloc) { - return kgem->nreloc + num_reloc <= KGEM_RELOC_SIZE(kgem); + return likely(kgem->nreloc + num_reloc <= KGEM_RELOC_SIZE(kgem)); } static inline bool kgem_check_batch_with_surfaces(struct kgem *kgem, diff --git a/src/sna/sna.h b/src/sna/sna.h index ae043ed..e67e227 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -34,15 +34,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ +#ifndef _SNA_H_ +#define _SNA_H_ + #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdint.h> -#ifndef _SNA_H_ -#define _SNA_H_ - #include "xf86_OSproc.h" #include "compiler.h" #include "xf86PciInfo.h" @@ -67,6 +67,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <libudev.h> #endif +#include "compiler.h" + #define DBG(x) #define DEBUG_ALL (HAS_DEBUG_FULL || 0) @@ -474,6 +476,10 @@ Bool sna_transform_is_integer_translation(const PictTransform *t, Bool sna_transform_is_translation(const PictTransform *t, pixman_fixed_t *tx, pixman_fixed_t *ty); +static inline bool wedged(struct sna *sna) +{ + return unlikely(sna->kgem.wedged); +} static inline uint32_t pixmap_size(PixmapPtr pixmap) { diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4f5c152..6101fb6 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1772,7 +1772,6 @@ sna_fill_spans_blt(DrawablePtr drawable, struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); RegionRec clip; - int need_translation = !gc->miTranslate; int16_t dx, dy; struct sna_fill_op fill; @@ -1788,17 +1787,21 @@ sna_fill_spans_blt(DrawablePtr drawable, extents->x1, extents->y1, extents->x2, extents->y2, n, pt->x, pt->y)); - get_drawable_deltas(drawable, pixmap, &dx, &dy); - while (n--) { - int X1 = pt->x; - int y = pt->y; - int X2 = X1 + (int)*width; + if (!gc->miTranslate) { + int i; - if (need_translation) { - X1 += drawable->x; - X2 += drawable->x; - y += drawable->y; + for (i = 0; i < n; i++) { + /* XXX overflow? */ + pt->x += drawable->x; + pt->y += drawable->y; } + } + + get_drawable_deltas(drawable, pixmap, &dx, &dy); + do { + int16_t X1 = pt->x; + int16_t y = pt->y; + int16_t X2 = X1 + (int)*width; pt++; width++; @@ -1817,22 +1820,17 @@ sna_fill_spans_blt(DrawablePtr drawable, y += dy; if (clip.data == NULL) { - X1 += dx; - X2 += dx; - assert(X1 >= 0 && X2 <= pixmap->drawable.width); - if (X2 > X1) { - fill.blt(sna, &fill, X1, y, X2-X1, 1); - if (damage) { - BoxRec box; + fill.blt(sna, &fill, X1 + dx, y, X2-X1, 1); + if (damage) { + BoxRec box; - box.x1 = X1; - box.x2 = X2; - box.y1 = y; - box.y2 = box.y1 + 1; + box.x1 = X1 + dx; + box.x2 = X2 + dx; + box.y1 = y; + box.y2 = box.y1 + 1; - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - } + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); } } else { int nc = clip.data->numRects; @@ -1872,7 +1870,7 @@ sna_fill_spans_blt(DrawablePtr drawable, b++; } } - } + } while (--n); fill.done(sna, &fill); RegionUninit(&clip); return TRUE; @@ -1960,22 +1958,22 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, DDXPointPtr pt, int *width, int sorted) { struct sna *sna = to_sna_from_drawable(drawable); - BoxRec extents; RegionRec region; DBG(("%s(n=%d, pt[0]=(%d, %d)\n", __FUNCTION__, n, pt[0].x, pt[0].y)); - if (sna_spans_extents(drawable, gc, n, pt, width, &extents)) + if (sna_spans_extents(drawable, gc, n, pt, width, ®ion.extents)) return; DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__, - extents.x1, extents.y1, extents.x2, extents.y2)); + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2)); if (FORCE_FALLBACK) goto fallback; - if (sna->kgem.wedged) { + if (wedged(sna)) { DBG(("%s: fallback -- wedged\n", __FUNCTION__)); goto fallback; } @@ -1992,20 +1990,20 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, DBG(("%s: trying solid fill [alu=%d, pixel=%08lx] blt paths\n", __FUNCTION__, gc->alu, gc->fgPixel)); - if (sna_drawable_use_gpu_bo(drawable, &extents) && + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_fill_spans_blt(drawable, priv->gpu_bo, - priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, &extents), + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), gc, n, pt, width, sorted, - &extents)) + ®ion.extents)) return; - if (sna_drawable_use_cpu_bo(drawable, &extents) && + if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_fill_spans_blt(drawable, priv->cpu_bo, - reduce_damage(drawable, &priv->cpu_damage, &extents), + reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), gc, n, pt, width, sorted, - &extents)) + ®ion.extents)) return; } else if (gc->fillStyle == FillTiled) { xRectangle *rect; @@ -2032,7 +2030,7 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, fallback: DBG(("%s: fallback\n", __FUNCTION__)); - region_set(®ion, &extents); + region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); if (!RegionNotEmpty(®ion)) return; diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 1597b1f..0148785 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -141,7 +141,7 @@ static bool sna_blt_fill_init(struct sna *sna, kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_bo_fenced(kgem, bo, NULL) || - !kgem_check_batch(kgem, 9)) { + !kgem_check_batch(kgem, 12)) { _kgem_submit(kgem); _kgem_set_mode(kgem, KGEM_BLT); } @@ -151,7 +151,7 @@ static bool sna_blt_fill_init(struct sna *sna, { uint32_t *b; - if (kgem->nreloc + 1 > KGEM_RELOC_SIZE(kgem)) { + if (!kgem_check_reloc(kgem, 1)) { _kgem_submit(kgem); _kgem_set_mode(kgem, KGEM_BLT); } @@ -181,10 +181,38 @@ static bool sna_blt_fill_init(struct sna *sna, return TRUE; } +noinline static void sna_blt_fill_begin(struct sna *sna, + const struct sna_blt_state *blt) +{ + struct kgem *kgem = &sna->kgem; + uint32_t *b; + + _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + + b = kgem->batch + kgem->nbatch; + b[0] = XY_SETUP_MONO_PATTERN_SL_BLT; + if (blt->bpp == 32) + b[0] |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; + b[1] = blt->br13; + b[2] = 0; + b[3] = 0; + b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, blt->bo[0], + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = blt->pixel; + b[6] = blt->pixel; + b[7] = 0; + b[8] = 0; + kgem->nbatch += 9; +} + static void sna_blt_fill_one(struct sna *sna, const struct sna_blt_state *blt, - int x, int y, - int width, int height) + int16_t x, int16_t y, + int16_t width, int16_t height) { struct kgem *kgem = &sna->kgem; uint32_t *b; @@ -196,33 +224,13 @@ static void sna_blt_fill_one(struct sna *sna, assert(y >= 0); assert((y+height) * blt->bo[0]->pitch <= blt->bo[0]->size); - if (!kgem_check_batch(kgem, 3)) { - _kgem_submit(kgem); - _kgem_set_mode(kgem, KGEM_BLT); - - b = kgem->batch + kgem->nbatch; - b[0] = XY_SETUP_MONO_PATTERN_SL_BLT; - if (blt->bpp == 32) - b[0] |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; - b[1] = blt->br13; - b[2] = 0; - b[3] = 0; - b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, blt->bo[0], - I915_GEM_DOMAIN_RENDER << 16 | - I915_GEM_DOMAIN_RENDER | - KGEM_RELOC_FENCED, - 0); - b[5] = blt->pixel; - b[6] = blt->pixel; - b[7] = 0; - b[8] = 0; - kgem->nbatch += 9; - } + if (!kgem_check_batch(kgem, 3)) + sna_blt_fill_begin(sna, blt); b = kgem->batch + kgem->nbatch; b[0] = blt->cmd; - b[1] = (y << 16) | x; - b[2] = ((y + height) << 16) | (x + width); + b[1] = y << 16 | x; + b[2] = b[1] + (height << 16 | width); kgem->nbatch += 3; } @@ -318,8 +326,7 @@ static void sna_blt_copy_one(struct sna *sna, return; } - if (kgem->nbatch + 8 + KGEM_BATCH_RESERVED > kgem->surface || - kgem->nreloc + 2 > KGEM_RELOC_SIZE(kgem)) + if (!kgem_check_batch(kgem, 8) || !kgem_check_reloc(kgem, 2)) _kgem_submit(kgem); b = kgem->batch + kgem->nbatch; @@ -1377,8 +1384,8 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_batch(kgem, 6) || - !kgem_check_bo_fenced(kgem, bo, NULL) || - kgem->nreloc + 1 > KGEM_RELOC_SIZE(kgem)) + !kgem_check_reloc(kgem, 1) || + !kgem_check_bo_fenced(kgem, bo, NULL)) _kgem_submit(kgem); do { @@ -1478,8 +1485,8 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_batch(kgem, 8) || - !kgem_check_bo_fenced(kgem, dst_bo, src_bo, NULL) || - kgem->nreloc + 2 > KGEM_RELOC_SIZE(kgem)) + !kgem_check_reloc(kgem, 2) || + !kgem_check_bo_fenced(kgem, dst_bo, src_bo, NULL)) _kgem_submit(kgem); do { diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index b4b4085..0f174f6 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -1,9 +1,9 @@ #ifndef SNA_RENDER_H #define SNA_RENDER_H -#define GRADIENT_CACHE_SIZE 16 +#include "compiler.h" -#define fastcall __attribute__((regparm(3))) +#define GRADIENT_CACHE_SIZE 16 struct sna; struct sna_glyph; diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index 1549ef5..9801121 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -52,8 +52,6 @@ /* TODO: Emit unantialiased and MSAA triangles. */ -#define unlikely(x) x - #ifndef MAX #define MAX(x,y) ((x) >= (y) ? (x) : (y)) #endif From daenzer at kemper.freedesktop.org Wed Oct 19 09:01:25 2011 From: daenzer at kemper.freedesktop.org (Michel Dänzer) Date: Wed, 19 Oct 2011 09:01:25 -0700 (PDT) Subject: xf86-video-ati: Branch 'master' Message-ID: <20111019160125.5532BC0001@kemper.freedesktop.org> src/radeon_dri2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit f6f1b4f7789cfef763c063e671b76b60be8bdd8e Author: Maarten Lankhorst <m.b.lankhorst at gmail.com> Date: Tue Oct 18 14:30:39 2011 +0200 dri2: Add vdpau driver name entry libvdpau has a driver loading mechanism that looks for a dri2 driver first before falling back to nvidia, so lets use that. Allows use of libvdpau_rx00 without having to set things up separately, similar to the patch to xf86-video-nouveau. Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com> Reviewed-by: Christian K??nig <deathsimple at vodafone.de> Reviewed-by: Michel D??nzer <michel at daenzer.net> Tested-by: Michel D??nzer <michel at daenzer.net> diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 46573a7..88117a5 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -1299,7 +1299,7 @@ radeon_dri2_screen_init(ScreenPtr pScreen) DRI2InfoRec dri2_info = { 0 }; #ifdef USE_DRI2_SCHEDULING RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); - const char *driverNames[1]; + const char *driverNames[2]; Bool scheduling_works = TRUE; #endif @@ -1364,9 +1364,9 @@ radeon_dri2_screen_init(ScreenPtr pScreen) dri2_info.ScheduleSwap = radeon_dri2_schedule_swap; dri2_info.GetMSC = radeon_dri2_get_msc; dri2_info.ScheduleWaitMSC = radeon_dri2_schedule_wait_msc; - dri2_info.numDrivers = 1; + dri2_info.numDrivers = RADEON_ARRAY_SIZE(driverNames); dri2_info.driverNames = driverNames; - driverNames[0] = dri2_info.driverName; + driverNames[0] = driverNames[1] = dri2_info.driverName; if (pRADEONEnt->dri2_info_cnt == 0) { #if HAS_DIXREGISTERPRIVATEKEY From keithp at kemper.freedesktop.org Wed Oct 19 17:16:42 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Wed, 19 Oct 2011 17:16:42 -0700 (PDT) Subject: xrandr: Changes to 'master' Message-ID: <20111020001642.B050BC0001@kemper.freedesktop.org> xrandr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) New commits: commit e68059e9ecc4225360a522138aedcedad7fe117f Author: Keith Packard <keithp at keithp.com> Date: Sat Aug 6 19:06:42 2011 -0700 xrandr: Preserve current mode when switching crtcs When switching output crtcs, preserve any current mode in preference to selecting whatever mode is currently in use on that crtc. Signed-off-by: Keith Packard <keithp at keithp.com> From keithp at kemper.freedesktop.org Wed Oct 19 17:23:46 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Wed, 19 Oct 2011 17:23:46 -0700 (PDT) Subject: xserver: Branch 'master' - 3 commits Message-ID: <20111020002346.28422C0001@kemper.freedesktop.org> hw/xfree86/man/xorg.conf.man | 4 +++- hw/xfree86/modes/xf86Crtc.c | 25 ++++++++++++++++++++----- hw/xwin/man/XWinrc.man | 10 +++++----- 3 files changed, 28 insertions(+), 11 deletions(-) New commits: commit e4787ec20b1b9d30fe00f17b60eb0898190bf77d Author: Gaetan Nadon <memsize at videotron.ca> Date: Mon Oct 17 15:08:14 2011 -0400 XWinrc.man: fix warning: tab character in unquoted macro argument #35054 Spaces or tabs do not affect the text output layout. Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Gaetan Nadon <memsize at videotron.ca> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/xwin/man/XWinrc.man b/hw/xwin/man/XWinrc.man index e4c454f..71d8dad 100644 --- a/hw/xwin/man/XWinrc.man +++ b/hw/xwin/man/XWinrc.man @@ -88,15 +88,15 @@ this may be useful if you want no dialogs. This instruction defines a menu and asigns a \fIMenu_Name\fP to it. \fIMenu_Item_Line\fP are lines of any of the following types: .TP 8 -.B \t SEPARATOR +.B SEPARATOR .TP 8 -.B \t \fIItem_Label\fP EXEC \fICommand\fP +.B \fIItem_Label\fP EXEC \fICommand\fP .TP 8 -.B \t \fIItem_Label\fP MENU \fIpreviously-defined-menu-name\fP +.B \fIItem_Label\fP MENU \fIpreviously-defined-menu-name\fP .TP 8 -.B \t \fIItem_Label\fP ALWAYSONTOP +.B \fIItem_Label\fP ALWAYSONTOP .TP 8 -.B \t \fIItem_Label\fP RELOAD +.B \fIItem_Label\fP RELOAD .br The \fIItem_Label\fP is the string that is written in the menu item. .br commit 321873f8045139edd47b526a765f8b1c66f53cd4 Author: Gaetan Nadon <memsize at videotron.ca> Date: Mon Oct 17 15:08:13 2011 -0400 xorg.conf.man: fix 382: warning: missing `)' (got `R') #35054 http://www.gnu.org/software/groff/manual/html_node/Man-usage.html Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Gaetan Nadon <memsize at videotron.ca> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man index 7f98851..996798f 100644 --- a/hw/xfree86/man/xorg.conf.man +++ b/hw/xfree86/man/xorg.conf.man @@ -379,7 +379,9 @@ is a number used to order the fontfile FPEs. Examples: .I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc .fi .PP -.RE .RE .RE +.RE +.RE +.RE .PP .RS 7 Font server identifiers: commit 3e145d3d67b472cb5d74cb8078b614160c4722b7 Author: Jesse Barnes <jbarnes at virtuousgeek.org> Date: Thu Oct 13 12:01:10 2011 -0700 crtc: match full preferred modes if possible when choosing an initial config It's fairly common to have multiple, identical monitors plugged in. In that case, it's preferable to run the monitor's preferred mode on each output, rather than just matching the width & height and end up with different timings or refresh rates. Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org> Reviewed-by: Keith Packard <keithp at keithp.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index cbe0b5c..384d8b4 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -2060,13 +2060,28 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, if (o == p) continue; - for (mode = output->probed_modes; mode; mode = mode->next) { - Rotation r = output->initial_rotation; - if (xf86ModeWidth(mode, r) == pref_width && - xf86ModeHeight(mode, r) == pref_height) { + /* + * First see if the preferred mode matches on the next + * output as well. This catches the common case of identical + * monitors and makes sure they all have the same timings + * and refresh. If that fails, we fall back to trying to + * match just width & height. + */ + mode = xf86OutputHasPreferredMode(output, pref_width, + pref_height); + if (mode && xf86ModesEqual(mode, preferred[p])) { preferred[o] = mode; match = TRUE; - } + } else { + for (mode = output->probed_modes; mode; + mode = mode->next) { + Rotation r = output->initial_rotation; + if (xf86ModeWidth(mode, r) == pref_width && + xf86ModeHeight(mode, r) == pref_height) { + preferred[o] = mode; + match = TRUE; + } + } } all_match &= match; From keithp at kemper.freedesktop.org Wed Oct 19 17:26:02 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Wed, 19 Oct 2011 17:26:02 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111020002602.7B6DEC0001@kemper.freedesktop.org> composite/compalloc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) New commits: commit a5266dcb3a60587e1877f90c18552baf60b597a0 Author: Ville Syrjala <syrjala at sci.fi> Date: Sun Oct 9 01:11:04 2011 +0300 composite: Update borderClip in compAllocPixmap() Previously the parent constrained borderClip was copied over when compRedirectWindow() is called. That is insufficient eg. in case the window was already redirected, but not yet realized. So copy the borderClip over in compAllocPixmap() instead. Example: Window 1 is below an automatically redirect window 2. Window 2 is unmapped and moved outside the extents of window 1. Window 2 is then mapped again, and MarkOverlappedWindows() uses the up to date borderSize of window 2 to mark windows, which leaves window 1 unmarked. Then exposures are calculated using the stale borderClip of window 2, which causes the window below window 2, to be exposed through an apparent hole in window 1. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=22566 Signed-off-by: Ville Syrjala <syrjala at sci.fi> Reviewed-by: Keith Packard <keithp at keithp.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/composite/compalloc.c b/composite/compalloc.c index f00bf4e..9857a92 100644 --- a/composite/compalloc.c +++ b/composite/compalloc.c @@ -196,11 +196,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update) anyMarked = compMarkWindows (pWin, &pLayerWin); - /* Make sure our borderClip is correct for ValidateTree */ RegionNull(&cw->borderClip); - RegionCopy(&cw->borderClip, &pWin->borderClip); - cw->borderClipX = pWin->drawable.x; - cw->borderClipY = pWin->drawable.y; cw->update = CompositeRedirectAutomatic; cw->clients = 0; cw->oldx = COMP_ORIGIN_INVALID; @@ -658,6 +654,13 @@ compAllocPixmap (WindowPtr pWin) DamageRegister (&pWin->drawable, cw->damage); cw->damageRegistered = TRUE; } + + /* Make sure our borderClip is up to date */ + RegionUninit(&cw->borderClip); + RegionCopy(&cw->borderClip, &pWin->borderClip); + cw->borderClipX = pWin->drawable.x; + cw->borderClipY = pWin->drawable.y; + return TRUE; } From keithp at kemper.freedesktop.org Wed Oct 19 17:29:15 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Wed, 19 Oct 2011 17:29:15 -0700 (PDT) Subject: xserver: Branch 'master' - 4 commits Message-ID: <20111020002915.6BD2CC0001@kemper.freedesktop.org> dix/getevents.c | 32 +++++++++++++++++++++-------- dix/inpututils.c | 36 +++++++++++++++++++++++++++++++++ hw/xfree86/common/xf86Events.c | 9 +++----- hw/xfree86/os-support/linux/lnx_init.c | 14 +++++------- include/input.h | 4 +++ test/input.c | 15 ++++++++++++- 6 files changed, 87 insertions(+), 23 deletions(-) New commits: commit 15bbdc103b34b6b374815698946e6c409421a644 Merge: a5266dc... 323869f... Author: Keith Packard <keithp at keithp.com> Date: Wed Oct 19 17:26:50 2011 -0700 Merge remote-tracking branch 'whot/for-keith' commit 323869f3298cbbfe864af9404a8aed1bf7995d79 Author: Tom???? Trnka <tomastrnka at gmx.com> Date: Tue Oct 11 09:11:18 2011 +0200 Fix drain_console unregistration Bug introduced by 9dca441670d261a9a9fb6108960ed48f3d58fb7f xfree86: add a hook to replace the new console handler. console_handler was not being set, making the server eat up CPU spinning in WaitForSomething selecting consoleFd over and over again, every time trying to unregister drain_console without success due to console_handler being NULL. Let's just fix the unregistration in xf86SetConsoleHandler() and use that. But wait, there could be a catch: If some driver replaced the handler using xf86SetConsoleHandler(), the unregistration in xf86CloseConsole will unregister that one. I don't understand Xorg well enough to know whether this poses a problem (could mess up driver deinit somehow or something like that). As it is, xf86SetConsoleHandler() doesn't offer any way to prevent this (i.e. check which handler is currently registered). I had been using it for two days on my machine that previously hit 100% CPU several times a day. That has now gone away without any new problems appearing. Signed-off-by: Tomas Trnka <tomastrnka at gmx.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index c4a4db9..41ffabd 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -601,16 +601,15 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data) InputHandlerProc xf86SetConsoleHandler(InputHandlerProc proc, pointer data) { - static InputHandlerProc handler = NULL; - InputHandlerProc old_handler = handler; + static IHPtr handler = NULL; + IHPtr old_handler = handler; if (old_handler) xf86RemoveGeneralHandler(old_handler); - xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - handler = proc; + handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - return old_handler; + return (old_handler) ? old_handler->ihproc : NULL; } static void diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index 9c91740..f18271f 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -45,15 +45,12 @@ static char vtname[11]; static struct termios tty_attr; /* tty state to restore */ static int tty_mode; /* kbd mode to restore */ -static void *console_handler; - static void drain_console(int fd, void *closure) { errno = 0; if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; + xf86SetConsoleHandler(NULL, NULL); } } @@ -257,10 +254,11 @@ xf86CloseConsole(void) return; } - if (console_handler) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; - }; + /* + * unregister the drain_console handler + * - what to do if someone else changed it in the meantime? + */ + xf86SetConsoleHandler(NULL, NULL); /* Back to text mode ... */ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT)); commit 2cb63180fa9b54f763e7e92e433943e3e73741f3 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Oct 5 12:08:31 2011 +1000 dix: mark motion events as emulated if we're scrolling from button press The protocol requires that the emulated event is marked as such. So if a driver with smooth scrolling axis sends legacy button events, the motion event must be marked as emulated. Pass the real type to emulate_scroll_button_events and create the events accordingly. For real button press or relase events, only that event must be generated since a release event will follow or a press event has already occured, respectively. (This fixes a bug where we'd get two release events for each legacy button event) Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 874189f..7be39dc 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1228,6 +1228,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, * * @param events The pointer to the event list to fill the events * @param dev The device to generate the events for + * @param type The real type of the event * @param axis The axis number to generate events for * @param mask State before this event in absolute coords * @param[in,out] last Last scroll state posted in absolute coords (modified @@ -1239,6 +1240,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, static int emulate_scroll_button_events(InternalEvent *events, DeviceIntPtr dev, + int type, int axis, const ValuatorMask *mask, ValuatorMask *last, @@ -1251,6 +1253,7 @@ emulate_scroll_button_events(InternalEvent *events, int num_events = 0; double total; int b; + int flags = 0; if (dev->valuator->axes[axis].scroll.type == SCROLL_TYPE_NONE) return 0; @@ -1261,6 +1264,9 @@ emulate_scroll_button_events(InternalEvent *events, ax = &dev->valuator->axes[axis]; incr = ax->scroll.increment; + if (type != ButtonPress && type != ButtonRelease) + flags |= POINTER_EMULATED; + if (!valuator_mask_isset(last, axis)) valuator_mask_set_double(last, axis, 0); @@ -1288,14 +1294,20 @@ emulate_scroll_button_events(InternalEvent *events, */ if (num_events + 4 < max_events) { - nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms, - POINTER_EMULATED, NULL); - events += nev_tmp; - num_events += nev_tmp; - nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms, - POINTER_EMULATED, NULL); - events += nev_tmp; - num_events += nev_tmp; + if (type != ButtonRelease) + { + nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms, + flags, NULL); + events += nev_tmp; + num_events += nev_tmp; + } + if (type != ButtonPress) + { + nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms, + flags, NULL); + events += nev_tmp; + num_events += nev_tmp; + } } } @@ -1340,6 +1352,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, ValuatorMask mask; ValuatorMask scroll; int i; + int realtype = type; /* refuse events from disabled devices */ if (!pDev->enabled) @@ -1392,6 +1405,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, valuator_mask_set_double(&mask, axis, val); type = MotionNotify; buttons = 0; + flags |= POINTER_EMULATED; } } @@ -1411,7 +1425,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, valuator_mask_set_double(&scroll, i, pDev->last.valuators[i]); - nev_tmp = emulate_scroll_button_events(events, pDev, i, &scroll, + nev_tmp = emulate_scroll_button_events(events, pDev, realtype, i, &scroll, pDev->last.scroll, ms, GetMaximumEventsNum() - num_events); events += nev_tmp; commit 82c60232c07f50774ccc0198950f64c9338057a5 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Sep 30 10:59:47 2011 +1000 dix: add valuator_mask_fetch_double() Using this call simplifies callers that don't know if the mask bit is set. Before: if (valuator_mask_isset(mask, valnum)) value = valuator_mask_get_double(mask, valnum)); else value = someothervalue; Now: if (!valuator_mask_fetch_double(mask, valnum, &value)) value = someothervalue; Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Chase Douglas <chase.douglas at canonical.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/inpututils.c b/dix/inpututils.c index eeae2a7..c27894b 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -539,6 +539,42 @@ valuator_mask_get(const ValuatorMask *mask, int valuator) } /** + * Set value to the requested valuator. If the mask bit is set for this + * valuator, value contains the requested valuator value and TRUE is + * returned. + * If the mask bit is not set for this valuator, value is unchanged and + * FALSE is returned. + */ +Bool +valuator_mask_fetch_double(const ValuatorMask *mask, int valuator, double *value) +{ + if (valuator_mask_isset(mask, valuator)) + { + *value = valuator_mask_get_double(mask, valuator); + return TRUE; + } else + return FALSE; +} + +/** + * Set value to the requested valuator. If the mask bit is set for this + * valuator, value contains the requested valuator value and TRUE is + * returned. + * If the mask bit is not set for this valuator, value is unchanged and + * FALSE is returned. + */ +Bool +valuator_mask_fetch(const ValuatorMask *mask, int valuator, int *value) +{ + if (valuator_mask_isset(mask, valuator)) + { + *value = valuator_mask_get(mask, valuator); + return TRUE; + } else + return FALSE; +} + +/** * Remove the valuator from the mask. */ void diff --git a/include/input.h b/include/input.h index b7de5ca..a1930bb 100644 --- a/include/input.h +++ b/include/input.h @@ -597,6 +597,10 @@ extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest, extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum); extern _X_EXPORT double valuator_mask_get_double(const ValuatorMask *mask, int valnum); +extern _X_EXPORT Bool valuator_mask_fetch(const ValuatorMask *mask, + int valnum, int *val); +extern _X_EXPORT Bool valuator_mask_fetch_double(const ValuatorMask *mask, + int valnum, double *val); /* InputOption handling interface */ extern _X_EXPORT InputOption* input_option_new(InputOption *list, const char *key, const char *value); diff --git a/test/input.c b/test/input.c index afc4d4d..5fb9a90 100644 --- a/test/input.c +++ b/test/input.c @@ -1199,14 +1199,19 @@ static void dix_input_valuator_masks(void) assert(valuator_mask_num_valuators(mask) == num_vals); for (i = 0; i < nvaluators; i++) { + double val; if (i < first_val || i >= first_val + num_vals) + { assert(!valuator_mask_isset(mask, i)); - else + assert(!valuator_mask_fetch_double(mask, i, &val)); + } else { assert(valuator_mask_isset(mask, i)); assert(valuator_mask_get(mask, i) == val_ranged[i - first_val]); assert(valuator_mask_get_double(mask, i) == val_ranged[i - first_val]); + assert(valuator_mask_fetch_double(mask, i, &val)); + assert(val_ranged[i - first_val] == val); } } @@ -1218,10 +1223,18 @@ static void dix_input_valuator_masks(void) for (i = 0; i < nvaluators; i++) { + double a, b; assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i)); + + if (!valuator_mask_isset(mask, i)) + continue; + assert(valuator_mask_get(mask, i) == valuator_mask_get(copy, i)); assert(valuator_mask_get_double(mask, i) == valuator_mask_get_double(copy, i)); + assert(valuator_mask_fetch_double(mask, i, &a)); + assert(valuator_mask_fetch_double(copy, i, &b)); + assert(a == b); } valuator_mask_free(&mask); From keithp at kemper.freedesktop.org Wed Oct 19 17:33:54 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Wed, 19 Oct 2011 17:33:54 -0700 (PDT) Subject: xserver: Branch 'master' - 5 commits Message-ID: <20111020003354.4FF11C0001@kemper.freedesktop.org> hw/xfree86/common/xf86Helper.c | 6 ------ hw/xfree86/loader/loadmod.c | 41 +++++++++++++++-------------------------- man/Xserver.man | 6 ++++++ 3 files changed, 21 insertions(+), 32 deletions(-) New commits: commit af3f64fb77c13180e513ee99d1fd9a1b624fd8ea Merge: 15bbdc1... df0dd36... Author: Keith Packard <keithp at keithp.com> Date: Wed Oct 19 17:33:07 2011 -0700 Merge remote-tracking branch 'hramrach/pull' commit df0dd36deea0c756819825113e825059ddd19243 Author: Michal Suchanek <hramrach at centrum.cz> Date: Sat Oct 8 14:26:24 2011 +0200 Do not uselessly reload modules in DuplicateModule The function does not initialize the module so it has no business loading it. If some user of DuplicateModule expects a module actually loaded they should use LoadModule. Signed-off-by: Michal Suchanek <hramrach at centrum.cz> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 2e6c667..a21f43d 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -94,6 +94,8 @@ const ModuleVersions LoaderVersionInfo = { ABI_FONT_VERSION }; +static int ModuleDuplicated[] = {}; + static void FreeStringList(char **paths) { @@ -785,7 +787,6 @@ ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) { ModuleDescPtr ret; - int errmaj, errmin; if (!mod) return NULL; @@ -794,14 +795,11 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) if (ret == NULL) return NULL; - if (!(ret->handle = LoaderOpen(mod->path, &errmaj, &errmin))) { - free(ret); - return NULL; - } + ret->handle = mod->handle; ret->SetupProc = mod->SetupProc; ret->TearDownProc = mod->TearDownProc; - ret->TearDownData = NULL; + ret->TearDownData = ModuleDuplicated; ret->child = DuplicateModule(mod->child, ret); ret->sib = DuplicateModule(mod->sib, parent); ret->parent = parent; @@ -1077,9 +1075,11 @@ UnloadModuleOrDriver(ModuleDescPtr mod) else xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name); - if ((mod->TearDownProc) && (mod->TearDownData)) - mod->TearDownProc(mod->TearDownData); - LoaderUnload(mod->name, mod->handle); + if (mod->TearDownData != ModuleDuplicated) { + if ((mod->TearDownProc) && (mod->TearDownData)) + mod->TearDownProc(mod->TearDownData); + LoaderUnload(mod->name, mod->handle); + } if (mod->child) UnloadModuleOrDriver(mod->child); commit 24d435163eb5fbd9b73cd8ba13a9b3cdbbe8a1df Author: Michal Suchanek <hramrach at centrum.cz> Date: Sat Oct 8 14:19:34 2011 +0200 Use UnloadModuleOrDriver for UnloadSubModule. Signed-off-by: Michal Suchanek <hramrach at centrum.cz> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 9f82099..2e6c667 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -1072,7 +1072,10 @@ UnloadModuleOrDriver(ModuleDescPtr mod) if (mod == NULL || mod->name == NULL) return; - xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name); + if (mod->parent) + xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name); + else + xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name); if ((mod->TearDownProc) && (mod->TearDownData)) mod->TearDownProc(mod->TearDownData); @@ -1092,23 +1095,8 @@ UnloadSubModule(pointer _mod) { ModuleDescPtr mod = (ModuleDescPtr)_mod; - if (mod == NULL || mod->name == NULL) - return; - - xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name); - - if ((mod->TearDownProc) && (mod->TearDownData)) - mod->TearDownProc(mod->TearDownData); - LoaderUnload(mod->name, mod->handle); - RemoveChild(mod); - - if (mod->child) - UnloadModuleOrDriver(mod->child); - - free(mod->path); - free(mod->name); - free(mod); + UnloadModuleOrDriver(mod); } static void @@ -1135,6 +1123,7 @@ RemoveChild(ModuleDescPtr child) } if (mdp == child) prevsib->sib = child->sib; + child->sib = NULL; return; } commit 0d4bb5442ceb8e8e4a8de6cfc4203cae469eee72 Author: Michal Suchanek <hramrach at centrum.cz> Date: Sat Oct 8 14:13:33 2011 +0200 Unload submodules. Signed-off-by: Michal Suchanek <hramrach at centrum.cz> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index a8aa316..4e9bcad 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -1643,13 +1643,7 @@ xf86LoadOneModule(char *name, pointer opt) void xf86UnloadSubModule(pointer mod) { - /* - * This is disabled for now. The loader isn't smart enough yet to undo - * relocations. - */ -#if 0 UnloadSubModule(mod); -#endif } Bool commit b04aff76ac2eb461c71b85525a00e25efb8bf267 Author: Michal Suchanek <hramrach at centrum.cz> Date: Thu Oct 13 17:14:53 2011 +0200 Document -background none option Document option introduced in commit 8976e97. Signed-off-by: Michal Suchanek <hramrach at centrum.cz> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> diff --git a/man/Xserver.man b/man/Xserver.man index 1a36b09..fe24337 100644 --- a/man/Xserver.man +++ b/man/Xserver.man @@ -100,6 +100,12 @@ specifies a file which contains a collection of authorization records used to authenticate access. See also the \fIxdm\fP(1) and \fIXsecurity\fP(__miscmansuffix__) manual pages. .TP 8 +.BI \-background\ none +Asks the driver not to clear the background on startup, if the driver supports that. +May be useful for smooth transition with eg. fbdev driver. +For security reasons this is not the default as the screen contents might +show a previous user session. +.TP 8 .B \-br sets the default root window to solid black instead of the standard root weave pattern. This is the default unless -retro or -wr is specified. From keithp at kemper.freedesktop.org Wed Oct 19 19:22:17 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Wed, 19 Oct 2011 19:22:17 -0700 (PDT) Subject: xserver: Branch 'master' - 3 commits Message-ID: <20111020022217.83FAEC0001@kemper.freedesktop.org> randr/rrproperty.c | 19 +++++++++++++--- render/mipict.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ render/mipict.h | 20 +++++++++++++++++ render/picture.c | 44 ++++++++++--------------------------- render/picturestr.h | 21 +++++++++++++++++ 5 files changed, 130 insertions(+), 35 deletions(-) New commits: commit ff61592441916b83aeb778c74352bb5b26247f84 Merge: af3f64f... 525d417... Author: Keith Packard <keithp at keithp.com> Date: Wed Oct 19 19:14:32 2011 -0700 Merge remote-tracking branch 'aplattner/for-master' commit 525d4172b246e13b8122e059e3b22866e00561d9 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Sep 4 09:34:08 2011 -0700 render: export TriStrip and TriFan to the drivers Rather than perform an intermediate copy and expand the strip and the fan into a triangle list (thereby tripling the number of edges that the driver needs to process), allow the backend to hook directly into the appropriate Composite function. In order to extend the PictureScreen, without needlessly bumping the ABI, we move the existing copy implementations to mipict.c and assign those by default. To notify the ddx that the new entry points are available, we introduce PICTURE_SCREEN_VERSION. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> Reviewed-by: Aaron Plattner <aplattner at nvidia.com> diff --git a/render/mipict.c b/render/mipict.c index 9a44c27..0b86bee 100644 --- a/render/mipict.c +++ b/render/mipict.c @@ -569,6 +569,64 @@ miRenderPixelToColor (PictFormatPtr format, } } +void +miTriStrip (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoints, + xPointFixed *points) +{ + xTriangle *tris, *tri; + int ntri; + + ntri = npoints - 2; + tris = malloc(ntri * sizeof (xTriangle)); + if (!tris) + return; + + for (tri = tris; npoints >= 3; npoints--, points++, tri++) + { + tri->p1 = points[0]; + tri->p2 = points[1]; + tri->p3 = points[2]; + } + CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); + free(tris); +} + +void +miTriFan (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoints, + xPointFixed *points) +{ + xTriangle *tris, *tri; + xPointFixed *first; + int ntri; + + ntri = npoints - 2; + tris = malloc(ntri * sizeof (xTriangle)); + if (!tris) + return; + + first = points++; + for (tri = tris; npoints >= 3; npoints--, points++, tri++) + { + tri->p1 = *first; + tri->p2 = points[0]; + tri->p3 = points[1]; + } + CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); + free(tris); +} + Bool miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) { @@ -602,5 +660,8 @@ miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) ps->AddTraps = 0; /* requires DDX support */ ps->AddTriangles = 0; /* requires DDX support */ + ps->TriStrip = miTriStrip; /* converts call to CompositeTriangles */ + ps->TriFan = miTriFan; + return TRUE; } diff --git a/render/mipict.h b/render/mipict.h index f6d9dee..4399a6f 100644 --- a/render/mipict.h +++ b/render/mipict.h @@ -140,6 +140,26 @@ miCompositeRects (CARD8 op, xRectangle *rects); extern _X_EXPORT void +miTriStrip (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoints, + xPointFixed *points); + +extern _X_EXPORT void +miTriFan (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoints, + xPointFixed *points); + +extern _X_EXPORT void miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box); extern _X_EXPORT void diff --git a/render/picture.c b/render/picture.c index 5640c4d..f134596 100644 --- a/render/picture.c +++ b/render/picture.c @@ -1715,23 +1715,14 @@ CompositeTriStrip (CARD8 op, int npoints, xPointFixed *points) { - xTriangle *tris, *tri; - int ntri; - + PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); + if (npoints < 3) return; - ntri = npoints - 2; - tris = malloc(ntri * sizeof (xTriangle)); - if (!tris) - return; - for (tri = tris; npoints >= 3; npoints--, points++, tri++) - { - tri->p1 = points[0]; - tri->p2 = points[1]; - tri->p3 = points[2]; - } - CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); - free(tris); + + ValidatePicture (pSrc); + ValidatePicture (pDst); + (*ps->TriStrip) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); } void @@ -1744,25 +1735,14 @@ CompositeTriFan (CARD8 op, int npoints, xPointFixed *points) { - xTriangle *tris, *tri; - xPointFixed *first; - int ntri; - + PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); + if (npoints < 3) return; - ntri = npoints - 2; - tris = malloc(ntri * sizeof (xTriangle)); - if (!tris) - return; - first = points++; - for (tri = tris; npoints >= 3; npoints--, points++, tri++) - { - tri->p1 = *first; - tri->p2 = points[0]; - tri->p3 = points[1]; - } - CompositeTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); - free(tris); + + ValidatePicture (pSrc); + ValidatePicture (pDst); + (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); } void diff --git a/render/picturestr.h b/render/picturestr.h index 7b7f911..1f3f5a4 100644 --- a/render/picturestr.h +++ b/render/picturestr.h @@ -260,6 +260,24 @@ typedef void (*TrianglesProcPtr) (CARD8 op, int ntri, xTriangle *tris); +typedef void (*TriStripProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoint, + xPointFixed *points); + +typedef void (*TriFanProcPtr) (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoint, + xPointFixed *points); + typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen, PictFormatPtr pFormat); @@ -348,6 +366,9 @@ typedef struct _PictureScreen { RealizeGlyphProcPtr RealizeGlyph; UnrealizeGlyphProcPtr UnrealizeGlyph; +#define PICTURE_SCREEN_VERSION 2 + TriStripProcPtr TriStrip; + TriFanProcPtr TriFan; } PictureScreenRec, *PictureScreenPtr; extern _X_EXPORT DevPrivateKeyRec PictureScreenPrivateKeyRec; commit 9b26e6bc8d2cdf5bac3025796855ccf05972358f Author: Luc Verhaegen <libv at skynet.be> Date: Tue Aug 23 15:19:59 2011 -0700 randr: stop clients from deleting immutable output properties Immutable in randr means that clients are not able to alter the property itself, they are only allowed to alter the property value. This logically means that the property then should not be deleted by the client either. Signed-off-by: Luc Verhaegen <libv at skynet.be> Reviewed-by: Rami Ylim??ki <rami.ylimaki at vincit.fi> Reviewed-by: Aaron Plattner <aplattner at nvidia.com> Signed-off-by: Aaron Plattner <aplattner at nvidia.com> diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 6ed24d3..d0a9020 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -549,18 +549,31 @@ int ProcRRDeleteOutputProperty (ClientPtr client) { REQUEST(xRRDeleteOutputPropertyReq); - RROutputPtr output; - + RROutputPtr output; + RRPropertyPtr prop; + REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); UpdateCurrentTime(); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); - + if (!ValidAtom(stuff->property)) { client->errorValue = stuff->property; return BadAtom; } + prop = RRQueryOutputProperty(output, stuff->property); + if (!prop) + { + client->errorValue = stuff->property; + return BadName; + } + + if (prop->immutable) + { + client->errorValue = stuff->property; + return BadAccess; + } RRDeleteOutputProperty(output, stuff->property); return Success; From jeremyhu at kemper.freedesktop.org Wed Oct 19 23:10:56 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 19 Oct 2011 23:10:56 -0700 (PDT) Subject: xinit: Changes to 'master' Message-ID: <20111020061056.E110BC0001@kemper.freedesktop.org> configure.ac | 8 +++++--- launchd/user_startx/Makefile.am | 4 ++++ launchd/user_startx/startx.plist.cpp | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) New commits: commit 98b85a1ac235dbf421d1a49b41599e8bcaf490d3 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 19 23:00:56 2011 -0700 launchd: Add an option (--with-launchagent-xserver) to set the default X11 server This allows the LaunchAgent and startx to have different default servers which will be useful as the Xorg DDX becomes available on darwin. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From ickle at kemper.freedesktop.org Thu Oct 20 05:35:16 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 20 Oct 2011 05:35:16 -0700 (PDT) Subject: xf86-video-intel: 8 commits - src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_dri.c src/sna/sna_glyphs.c src/sna/sna_gradient.c src/sna/sna_io.c Message-ID: <20111020123516.372B1C0001@kemper.freedesktop.org> src/sna/kgem.c | 40 +++++---- src/sna/kgem.h | 13 --- src/sna/sna_accel.c | 32 ++++++- src/sna/sna_blt.c | 208 ++++++++++++++++++++++++++++++++++++++----------- src/sna/sna_dri.c | 19 +++- src/sna/sna_glyphs.c | 5 - src/sna/sna_gradient.c | 6 - src/sna/sna_io.c | 2 8 files changed, 238 insertions(+), 87 deletions(-) New commits: commit 3526d83e460ce6410f23f59d1315793ff9607253 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 20 00:29:52 2011 +0100 sna/dri: Perform a little dance to restore the gpu status on release of the bo As the bo is outside of our control whilst it is under the influence of an external renderer, we try to maintain it on the gpu so as to avoid unnecessary ping-pong. But once it is wholly back under our control, we want to stop paying the penalty for sharing it. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index ed0e12f..d5084f8 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -105,7 +105,6 @@ static void kgem_sna_flush(struct kgem *kgem) sna_render_flush_solid(sna); } - static int gem_set_tiling(int fd, uint32_t handle, int tiling, int stride) { struct drm_i915_gem_set_tiling set_tiling; diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c index ae4f1fa..65fec47 100644 --- a/src/sna/sna_dri.c +++ b/src/sna/sna_dri.c @@ -153,8 +153,9 @@ static struct kgem_bo *sna_pixmap_set_dri(struct sna *sna, list_add(&priv->list, &sna->dirty_pixmaps); /* The bo is outside of our control, so presume it is written to */ - priv->gpu_bo->needs_flush = 1; + priv->gpu_bo->needs_flush = true; priv->gpu_bo->reusable = false; + priv->gpu_bo->gpu = true; /* We need to submit any modifications to and reads from this * buffer before we send any reply to the Client. @@ -317,8 +318,18 @@ static void _sna_dri_destroy_buffer(struct sna *sna, DRI2Buffer2Ptr buffer) struct sna_dri_private *private = buffer->driverPrivate; if (--private->refcnt == 0) { + private->bo->gpu = private->bo->needs_flush || private->bo->rq != NULL; + private->bo->flush = 0; + if (private->pixmap) { ScreenPtr screen = private->pixmap->drawable.pScreen; + struct sna_pixmap *priv = sna_pixmap(private->pixmap); + + /* Undo the DRI markings on this pixmap */ + list_del(&priv->list); + priv->pinned = private->pixmap == sna->front; + priv->flush = 0; + screen->DestroyPixmap(private->pixmap); } else kgem_bo_destroy(&sna->kgem, private->bo); commit 50b980f12e02401cdd4bc21b970d92e7bd1e6459 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 21:09:01 2011 +0100 sna: Reuse any partial write buffer for readback Take advantage of any available temporary buffer that we reuse for readback knowing that it is the last operation in the batch. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 073fed7..ed0e12f 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1944,6 +1944,16 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, __FUNCTION__, size, flags, write, flags & KGEM_BUFFER_LAST)); list_for_each_entry(bo, &kgem->partial, base.list) { + if (flags == KGEM_BUFFER_LAST && bo->write) { + /* We can reuse any write buffer which we can fit */ + if (size < bo->alloc) { + DBG(("%s: reusing write buffer for read of %d bytes? used=%d, total=%d\n", + __FUNCTION__, size, bo->used, bo->alloc)); + offset = 0; + goto done; + } + } + if (bo->write != write) { DBG(("%s: skip write %d buffer, need %d\n", __FUNCTION__, bo->write, write)); @@ -2133,31 +2143,25 @@ cleanup_bo: return NULL; } -void kgem_buffer_sync(struct kgem *kgem, struct kgem_bo *_bo) +void kgem_buffer_read_sync(struct kgem *kgem, struct kgem_bo *_bo) { struct kgem_partial_bo *bo; + uint32_t offset = _bo->delta, length = _bo->size; if (_bo->proxy) _bo = _bo->proxy; bo = (struct kgem_partial_bo *)_bo; - DBG(("%s(need_io=%s, sync=%d)\n", __FUNCTION__, - bo->need_io ? bo->write ? "write" : "read" : "none", - bo->base.sync)); + DBG(("%s(offset=%d, length=%d, sync=%d)\n", __FUNCTION__, + offset, length, bo->base.sync)); - if (bo->need_io) { - if (bo->write) - gem_write(kgem->fd, bo->base.handle, - 0, bo->used, bo+1); - else - gem_read(kgem->fd, bo->base.handle, bo+1, bo->used); + if (!bo->base.sync) { + gem_read(kgem->fd, bo->base.handle, + (char *)(bo+1)+offset, length); bo->base.needs_flush = false; if (bo->base.gpu) kgem_retire(kgem); - bo->need_io = 0; - } - - if (bo->base.sync) - kgem_bo_sync(kgem, &bo->base, bo->write); + } else + kgem_bo_sync(kgem, &bo->base, false); } diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 60a23de..eb89c63 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -330,7 +330,7 @@ void kgem_bo_sync(struct kgem *kgem, struct kgem_bo *bo, bool for_write); struct kgem_bo *kgem_create_buffer(struct kgem *kgem, uint32_t size, uint32_t flags, void **ret); -void kgem_buffer_sync(struct kgem *kgem, struct kgem_bo *bo); +void kgem_buffer_read_sync(struct kgem *kgem, struct kgem_bo *bo); void kgem_throttle(struct kgem *kgem); bool kgem_expire_cache(struct kgem *kgem); diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c index 321247a..5a6fdd9 100644 --- a/src/sna/sna_io.c +++ b/src/sna/sna_io.c @@ -202,7 +202,7 @@ void sna_read_boxes(struct sna *sna, } while (tmp_nbox); assert(offset == dst_bo->size); - kgem_buffer_sync(kgem, dst_bo); + kgem_buffer_read_sync(kgem, dst_bo); src = ptr; do { commit 972989276dd3f84c1cedca0494d04f907875f8f3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 20:41:14 2011 +0100 sna: Add some debug to discern the nature of the Cr fallback Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 07132bf..22f5468 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2233,13 +2233,20 @@ sna_poly_line_can_blt(int mode, int n, DDXPointPtr pt) if (mode == CoordModePrevious) { for (i = 1; i < n; i++) { - if (pt[i].x != 0 && pt[i].y != 0) + if (pt[i].x != 0 && pt[i].y != 0) { + DBG(("%s: diagonal segment[%d]=(%d,%d)\n", + __FUNCTION__, i, pt[i].x, pt[i].y)); return FALSE; + } } } else { for (i = 1; i < n; i++) { - if (pt[i].x != pt[i-1].x && pt[i].y != pt[i-1].y) + if (pt[i].x != pt[i-1].x && pt[i].y != pt[i-1].y) { + DBG(("%s: diagonal segment[%d]=(%d,%d)->(%d,%d)\n", + __FUNCTION__, i, + pt[i-1].x, pt[i-1].y, pt[i].x, pt[i].y)); return FALSE; + } } } @@ -2412,6 +2419,13 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, goto fallback; } + DBG(("%s: fill=%d [%d], line=%d [%d], width=%d, mask=%lu [%d], rectlinear=%d\n", + __FUNCTION__, + gc->fillStyle, gc->fillStyle == FillSolid, + gc->lineStyle, gc->lineStyle == LineSolid, + gc->lineWidth, + gc->planemask, PM_IS_SOLID(drawable, gc->planemask), + sna_poly_line_can_blt(mode, n, pt))); if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid && (gc->lineWidth == 0 || gc->lineWidth == 1) && @@ -2482,8 +2496,11 @@ static Bool sna_poly_segment_can_blt(int n, xSegment *seg) { while (n--) { - if (seg->x1 != seg->x2 && seg->y1 != seg->y2) + if (seg->x1 != seg->x2 && seg->y1 != seg->y2) { + DBG(("%s: (%d, %d) -> (%d, %d)\n", + __FUNCTION__, seg->x1, seg->y1, seg->x2, seg->y2)); return FALSE; + } seg++; } @@ -2718,9 +2735,16 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) goto fallback; } + DBG(("%s: fill=%d [%d], line=%d [%d], width=%d, mask=%lu [%d], rectlinear=%d\n", + __FUNCTION__, + gc->fillStyle, gc->fillStyle == FillSolid, + gc->lineStyle, gc->lineStyle == LineSolid, + gc->lineWidth, + gc->planemask, PM_IS_SOLID(drawable, gc->planemask), + sna_poly_segment_can_blt(n, seg))); if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid && - gc->lineWidth == 0 && + (gc->lineWidth == 0 || gc->lineWidth == 1) && PM_IS_SOLID(drawable, gc->planemask) && sna_poly_segment_can_blt(n, seg)) { struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable); commit fc224e2f8c0200c114f8dbddfc4f5395a3ef0fad Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 20:20:55 2011 +0100 sna: Clean up some debug messages for 64bit Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c index 82cec08..ae4f1fa 100644 --- a/src/sna/sna_dri.c +++ b/src/sna/sna_dri.c @@ -630,7 +630,7 @@ sna_dri_frame_event_drawable_gone(void *data, XID id) drawable_resource); DBG(("%s: marking drawable gone [%p]: %ld\n", - __FUNCTION__, info, info->drawable_id)); + __FUNCTION__, info, (long)info->drawable_id)); list_del(&info->drawable_resource); info->drawable_id = None; @@ -696,7 +696,7 @@ sna_dri_add_frame_event(struct sna_dri_frame_event *info) list_add(&info->drawable_resource, resource); DBG(("%s: add[%p] (%p, %ld)\n", __FUNCTION__, - info, info->client, info->drawable_id)); + info, info->client, (long)info->drawable_id)); return TRUE; } @@ -705,7 +705,7 @@ static void sna_dri_frame_event_info_free(struct sna_dri_frame_event *info) { DBG(("%s: del[%p] (%p, %ld)\n", __FUNCTION__, - info, info->client, info->drawable_id)); + info, info->client, (long)info->drawable_id)); list_del(&info->client_resource); list_del(&info->drawable_resource); diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index 13b0cca..928c9fb 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -973,8 +973,9 @@ glyphs_fallback(CARD8 op, region.extents.y2 - region.extents.y1, dst->pDrawable->x, dst->pDrawable->y, x, y, - mask_format->depth, mask_format->format, - mask_format->depth << 24 | mask_format->format, + mask_format->depth, + (long)mask_format->format, + (long)(mask_format->depth << 24 | mask_format->format), NeedsComponent(mask_format->format))); mask_image = pixman_image_create_bits(mask_format->depth << 24 | mask_format->format, commit f4346e5d255f419ee6148f7d69f02560732dd4de Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 19:26:19 2011 +0100 sna/blt: Use SCANLINE_BLT for multiple fill boxes Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 43e126b..60a23de 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -237,16 +237,7 @@ static inline void kgem_set_mode(struct kgem *kgem, enum kgem_mode mode) static inline void _kgem_set_mode(struct kgem *kgem, enum kgem_mode mode) { -#if DEBUG_FLUSH_CACHE - kgem_emit_flush(kgem); -#endif - -#if DEBUG_FLUSH_BATCH - kgem_submit(kgem); -#endif - - if (kgem->nbatch) - kgem->mode = mode; + kgem->mode = mode; } static inline bool kgem_check_batch(struct kgem *kgem, int num_dwords) diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 3b2c0b9..2343838 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -290,8 +290,10 @@ static Bool sna_blt_copy_init(struct sna *sna, } kgem_set_mode(kgem, KGEM_BLT); - if (!kgem_check_bo_fenced(kgem, src, dst, NULL)) + if (!kgem_check_bo_fenced(kgem, src, dst, NULL)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } sna->blt_state.fill_bo = 0; return TRUE; @@ -340,8 +342,10 @@ static void sna_blt_copy_one(struct sna *sna, return; } - if (!kgem_check_batch(kgem, 8) || !kgem_check_reloc(kgem, 2)) + if (!kgem_check_batch(kgem, 8) || !kgem_check_reloc(kgem, 2)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } b = kgem->batch + kgem->nbatch; b[0] = blt->cmd; @@ -821,8 +825,10 @@ prepare_blt_copy(struct sna *sna, if (priv->gpu_bo->tiling == I915_TILING_Y) return FALSE; - if (!kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) + if (!kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) { _kgem_submit(&sna->kgem); + _kgem_set_mode(&sna->kgem, KGEM_BLT); + } DBG(("%s\n", __FUNCTION__)); @@ -1148,8 +1154,10 @@ sna_blt_composite(struct sna *sna, if (width && height) reduce_damage(tmp, dst_x, dst_y, width, height); - if (!kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) + if (!kgem_check_bo_fenced(&sna->kgem, priv->gpu_bo, NULL)) { _kgem_submit(&sna->kgem); + _kgem_set_mode(&sna->kgem, KGEM_BLT); + } if (op == PictOpClear) return prepare_blt_clear(sna, tmp); @@ -1349,26 +1357,20 @@ bool sna_blt_copy(struct sna *sna, uint8_t alu, return TRUE; } -Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, - struct kgem_bo *bo, int bpp, - uint32_t color, - const BoxRec *box, int nbox) +static Bool sna_blt_fill_box(struct sna *sna, uint8_t alu, + struct kgem_bo *bo, int bpp, + uint32_t color, + const BoxRec *box) { struct kgem *kgem = &sna->kgem; uint32_t br13, cmd; + uint32_t *b; -#if DEBUG_NO_BLT || NO_BLT_FILL_BOXES - return FALSE; -#endif - - DBG(("%s (%d, %08x, %d) x %d\n", - __FUNCTION__, bpp, color, alu, nbox)); + DBG(("%s: box=((%d, %d), (%d, %d))\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2)); - if (bo->tiling == I915_TILING_Y) { - DBG(("%s: fallback -- dst uses Y-tiling\n", - __FUNCTION__)); - return FALSE; - } + assert(box->x1 >= 0); + assert(box->y1 >= 0); cmd = XY_COLOR_BLT_CMD; if (bpp == 32) @@ -1403,58 +1405,171 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, DBG(("%s: replacing last fill\n", __FUNCTION__)); kgem->batch[kgem->nbatch-5] = br13; kgem->batch[kgem->nbatch-1] = color; - if (--nbox == 0) - return TRUE; - box++; + return TRUE; } kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_batch(kgem, 6) || !kgem_check_reloc(kgem, 1) || - !kgem_check_bo_fenced(kgem, bo, NULL)) + !kgem_check_bo_fenced(kgem, bo, NULL)) { + _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } + + b = kgem->batch + kgem->nbatch; + + b[0] = cmd; + b[1] = br13; + b[2] = box->y1 << 16 | box->x1; + b[3] = box->y2 << 16 | box->x2; + b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, + bo, + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = color; + kgem->nbatch += 6; + + sna->blt_state.fill_bo = 0; + return TRUE; +} + +Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, + struct kgem_bo *bo, int bpp, + uint32_t pixel, + const BoxRec *box, int nbox) +{ + struct kgem *kgem = &sna->kgem; + uint32_t br13, cmd; + +#if DEBUG_NO_BLT || NO_BLT_FILL_BOXES + return FALSE; +#endif + + DBG(("%s (%d, %08x, %d) x %d\n", + __FUNCTION__, bpp, pixel, alu, nbox)); + + if (bo->tiling == I915_TILING_Y) { + DBG(("%s: fallback -- dst uses Y-tiling\n", __FUNCTION__)); + return FALSE; + } + + if (nbox == 1) + return sna_blt_fill_box(sna, alu, bo, bpp, pixel, box); + + br13 = bo->pitch; + cmd = XY_SCANLINE_BLT; + if (kgem->gen >= 40 && bo->tiling) { + cmd |= 1 << 11; + br13 >>= 2; + } + if (br13 > MAXSHORT) + return FALSE; + + br13 |= 1<<31 | fill_ROP[alu] << 16; + switch (bpp) { + default: assert(0); + case 32: br13 |= 1 << 25; /* RGB8888 */ + case 16: br13 |= 1 << 24; /* RGB565 */ + case 8: break; + } + + kgem_set_mode(kgem, KGEM_BLT); + if (!kgem_check_bo_fenced(kgem, bo, NULL) || + !kgem_check_batch(kgem, 12)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } + + if (sna->blt_state.fill_bo != bo->handle || + sna->blt_state.fill_pixel != pixel) + { + uint32_t *b; + + if (!kgem_check_reloc(kgem, 1)) { + _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } + + b = kgem->batch + kgem->nbatch; + b[0] = XY_SETUP_MONO_PATTERN_SL_BLT; + if (bpp == 32) + b[0] |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; + b[1] = br13; + b[2] = 0; + b[3] = 0; + b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, bo, + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = pixel; + b[6] = pixel; + b[7] = 0; + b[8] = 0; + kgem->nbatch += 9; + + sna->blt_state.fill_bo = bo->handle; + sna->blt_state.fill_pixel = pixel; + } do { int nbox_this_time; nbox_this_time = nbox; - if (6*nbox_this_time > kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) - nbox_this_time = (kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) / 6; - if (nbox_this_time > KGEM_RELOC_SIZE(kgem) - kgem->nreloc) - nbox_this_time = KGEM_RELOC_SIZE(kgem) - kgem->nreloc; + if (3*nbox_this_time > kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) + nbox_this_time = (kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) / 3; assert(nbox_this_time); nbox -= nbox_this_time; do { uint32_t *b = kgem->batch + kgem->nbatch; - DBG(("%s: box=((%d, %d), (%d, %d))\n", __FUNCTION__, - box->x1, box->y1, box->x2, box->y2)); + DBG(("%s: (%d, %d), (%d, %d): %08x\n", + __FUNCTION__, + box->x1, box->y1, + box->x2, box->y2, + pixel)); assert(box->x1 >= 0); assert(box->y1 >= 0); + assert(box->y2 * bo->pitch <= bo->size); + b = kgem->batch + kgem->nbatch; + kgem->nbatch += 3; b[0] = cmd; + b[1] = box->y1 << 16 | box->x1; + b[2] = box->y2 << 16 | box->x2; + box++; + } while (--nbox_this_time); + + if (nbox) { + uint32_t *b; + + _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + + b = kgem->batch + kgem->nbatch; + b[0] = XY_SETUP_MONO_PATTERN_SL_BLT; + if (bpp == 32) + b[0] |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; b[1] = br13; - b[2] = box->y1 << 16 | box->x1; - b[3] = box->y2 << 16 | box->x2; - b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, - bo, + b[2] = 0; + b[3] = 0; + b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, bo, I915_GEM_DOMAIN_RENDER << 16 | I915_GEM_DOMAIN_RENDER | KGEM_RELOC_FENCED, 0); - b[5] = color; - kgem->nbatch += 6; - box++; - } while (--nbox_this_time); - - if (nbox) - _kgem_submit(kgem); + b[5] = pixel; + b[6] = pixel; + b[7] = 0; + b[8] = 0; + kgem->nbatch += 9; + } } while (nbox); - _kgem_set_mode(kgem, KGEM_BLT); - sna->blt_state.fill_bo = 0; return TRUE; } @@ -1512,8 +1627,10 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_batch(kgem, 8) || !kgem_check_reloc(kgem, 2) || - !kgem_check_bo_fenced(kgem, dst_bo, src_bo, NULL)) + !kgem_check_bo_fenced(kgem, dst_bo, src_bo, NULL)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } do { int nbox_this_time; @@ -1561,8 +1678,10 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, box++; } while (--nbox_this_time); - if (nbox) + if (nbox) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } } while (nbox); if (kgem->gen >= 60 && kgem_check_batch(kgem, 3)) { @@ -1572,6 +1691,5 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, kgem->nbatch += 3; } - _kgem_set_mode(kgem, KGEM_BLT); return TRUE; } commit d7fb98efdcc1bcc2cca6deb54b16d425b0350196 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 17:52:56 2011 +0100 sna: The initial aperture check for a set of bo is unlikely to fail Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 38303e3..073fed7 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1621,7 +1621,7 @@ bool kgem_check_bo_fenced(struct kgem *kgem, ...) int size = 0; int fenced_size = 0; - if (kgem->aperture > kgem->aperture_low) + if (unlikely (kgem->aperture > kgem->aperture_low)) return false; va_start(ap, kgem); commit 3c8e1c5c4cbe703781f2845926f76a9537a971ea Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 16:35:08 2011 +0100 sna: Reset the ring flag upon idling We track the last ring used when active so as to avoid stalling between batches. Once the GPU has retired all the pending requests, we can use whichever ring is preferrable for the next operation without any danger of stalling upon submission. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 4d876db..38303e3 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -670,6 +670,9 @@ void kgem_retire(struct kgem *kgem) list_del(&rq->list); free(rq); } + + if (kgem->ring && list_is_empty(&kgem->requests)) + kgem->ring = kgem->mode; } static void kgem_commit(struct kgem *kgem) commit 594c5f86bb2e1cd0390b360c926ead58ba49979f Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 19 16:25:42 2011 +0100 sna: Don't rewrite the solid colour cache if it hasn't changed Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_gradient.c b/src/sna/sna_gradient.c index 4a93143..84d57f4 100644 --- a/src/sna/sna_gradient.c +++ b/src/sna/sna_gradient.c @@ -227,9 +227,9 @@ sna_render_finish_solid(struct sna *sna, bool force) int i; DBG(("sna_render_finish_solid(force=%d, busy=%d, dirty=%d)\n", - force, cache->cache_bo->rq != NULL, cache->dirty)); + force, cache->cache_bo->gpu, cache->dirty)); - if (!force && !cache->cache_bo->rq) + if (!force && !cache->cache_bo->gpu) return; if (cache->dirty) @@ -291,13 +291,13 @@ sna_render_get_solid(struct sna *sna, uint32_t color) i = cache->size++; cache->color[i] = color; + cache->dirty = 1; DBG(("sna_render_get_solid(%d) = %x (new)\n", i, color)); create: cache->bo[i] = kgem_create_proxy(cache->cache_bo, i*sizeof(uint32_t), sizeof(uint32_t)); cache->bo[i]->pitch = 4; - cache->dirty = 1; done: cache->last = i; From sandmann at kemper.freedesktop.org Thu Oct 20 06:31:06 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Thu, 20 Oct 2011 06:31:06 -0700 (PDT) Subject: pixman: Branch 'master' - 5 commits Message-ID: <20111020133107.14220C0001@kemper.freedesktop.org> Makefile.am | 4 pixman/pixman-gradient-walker.c | 175 +++++++++------------------------------- pixman/pixman-image.c | 73 ++++++++++++++++ pixman/pixman-private.h | 16 +-- 4 files changed, 124 insertions(+), 144 deletions(-) New commits: commit 6131707e8fc39187d1d358481f7c57c57cfab206 Merge: 3d4d705... ec7c9c2... Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Thu Oct 20 09:13:12 2011 -0400 Merge branch 'gradients' commit ec7c9c2b6865b48b8bd14e4509538f8fcbe93463 Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Fri Oct 14 09:04:48 2011 -0400 Simplify gradient_walker_reset() The code that searches for the closest color stop to the given position is duplicated across the various repeat modes. Replace the switch with two if/else constructions, and put the search code between them. diff --git a/pixman/pixman-gradient-walker.c b/pixman/pixman-gradient-walker.c index 3848247..048039e 100644 --- a/pixman/pixman-gradient-walker.c +++ b/pixman/pixman-gradient-walker.c @@ -56,57 +56,40 @@ gradient_walker_reset (pixman_gradient_walker_t *walker, int n, count = walker->num_stops; pixman_gradient_stop_t *stops = walker->stops; - switch (walker->repeat) + if (walker->repeat == PIXMAN_REPEAT_NORMAL) { - case PIXMAN_REPEAT_NORMAL: - x = (int32_t)pos & 0xFFFF; - for (n = 0; n < count; n++) - { - if (x < stops[n].x) - break; - } - - left_x = stops[n - 1].x; - left_c = &stops[n - 1].color; - - right_x = stops[n].x; - right_c = &stops[n].color; - - left_x += (pos - x); - right_x += (pos - x); - break; - - case PIXMAN_REPEAT_PAD: - for (n = 0; n < count; n++) - { - if (pos < stops[n].x) - break; - } - - left_x = stops[n - 1].x; - left_c = &stops[n - 1].color; - - right_x = stops[n].x; - right_c = &stops[n].color; - break; - - case PIXMAN_REPEAT_REFLECT: - x = (int32_t)pos & 0xFFFF; + x = (int32_t)pos & 0xffff; + } + else if (walker->repeat == PIXMAN_REPEAT_REFLECT) + { + x = (int32_t)pos & 0xffff; if ((int32_t)pos & 0x10000) x = 0x10000 - x; - - for (n = 0; n < count; n++) - { - if (x < stops[n].x) - break; - } - - left_x = stops[n - 1].x; - left_c = &stops[n - 1].color; - - right_x = stops[n].x; - right_c = &stops[n].color; - + } + else + { + x = pos; + } + + for (n = 0; n < count; n++) + { + if (x < stops[n].x) + break; + } + + left_x = stops[n - 1].x; + left_c = &stops[n - 1].color; + + right_x = stops[n].x; + right_c = &stops[n].color; + + if (walker->repeat == PIXMAN_REPEAT_NORMAL) + { + left_x += (pos - x); + right_x += (pos - x); + } + else if (walker->repeat == PIXMAN_REPEAT_REFLECT) + { if ((int32_t)pos & 0x10000) { pixman_color_t *tmp_c; @@ -124,20 +107,6 @@ gradient_walker_reset (pixman_gradient_walker_t *walker, } left_x += (pos - x); right_x += (pos - x); - break; - - default: /* REPEAT_NONE */ - for (n = 0; n < count; n++) - { - if (pos < stops[n].x) - break; - } - - left_x = stops[n - 1].x; - left_c = &stops[n - 1].color; - - right_x = stops[n].x; - right_c = &stops[n].color; } walker->left_x = left_x; commit 2d0da8ab8d8fef60ed1bbb9d6b75f66577c3f85d Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Fri Oct 14 09:02:14 2011 -0400 Use sentinels instead of special casing first and last stops When storing the gradient stops internally, allocate two more stops, one before the beginning of the stop list and one after the end. Initialize those stops based on the repeat property of the gradient. This allows gradient_walker_reset() to be simplified because it can now simply pick the two closest stops to the position without special casing the first and last stops. diff --git a/pixman/pixman-gradient-walker.c b/pixman/pixman-gradient-walker.c index 53d0b30..3848247 100644 --- a/pixman/pixman-gradient-walker.c +++ b/pixman/pixman-gradient-walker.c @@ -56,8 +56,6 @@ gradient_walker_reset (pixman_gradient_walker_t *walker, int n, count = walker->num_stops; pixman_gradient_stop_t *stops = walker->stops; - static const pixman_color_t transparent_black = { 0, 0, 0, 0 }; - switch (walker->repeat) { case PIXMAN_REPEAT_NORMAL: @@ -68,27 +66,12 @@ gradient_walker_reset (pixman_gradient_walker_t *walker, break; } - if (n == 0) - { - left_x = stops[count - 1].x - 0x10000; - left_c = &stops[count - 1].color; - } - else - { - left_x = stops[n - 1].x; - left_c = &stops[n - 1].color; - } + left_x = stops[n - 1].x; + left_c = &stops[n - 1].color; + + right_x = stops[n].x; + right_c = &stops[n].color; - if (n == count) - { - right_x = stops[0].x + 0x10000; - right_c = &stops[0].color; - } - else - { - right_x = stops[n].x; - right_c = &stops[n].color; - } left_x += (pos - x); right_x += (pos - x); break; @@ -100,27 +83,11 @@ gradient_walker_reset (pixman_gradient_walker_t *walker, break; } - if (n == 0) - { - left_x = INT32_MIN; - left_c = &stops[0].color; - } - else - { - left_x = stops[n - 1].x; - left_c = &stops[n - 1].color; - } + left_x = stops[n - 1].x; + left_c = &stops[n - 1].color; - if (n == count) - { - right_x = INT32_MAX; - right_c = &stops[n - 1].color; - } - else - { - right_x = stops[n].x; - right_c = &stops[n].color; - } + right_x = stops[n].x; + right_c = &stops[n].color; break; case PIXMAN_REPEAT_REFLECT: @@ -134,27 +101,11 @@ gradient_walker_reset (pixman_gradient_walker_t *walker, break; } - if (n == 0) - { - left_x = -stops[0].x; - left_c = &stops[0].color; - } - else - { - left_x = stops[n - 1].x; - left_c = &stops[n - 1].color; - } + left_x = stops[n - 1].x; + left_c = &stops[n - 1].color; - if (n == count) - { - right_x = 0x20000 - stops[n - 1].x; - right_c = &stops[n - 1].color; - } - else - { - right_x = stops[n].x; - right_c = &stops[n].color; - } + right_x = stops[n].x; + right_c = &stops[n].color; if ((int32_t)pos & 0x10000) { @@ -182,25 +133,11 @@ gradient_walker_reset (pixman_gradient_walker_t *walker, break; } - if (n == 0) - { - left_x = INT32_MIN; - right_x = stops[0].x; - left_c = right_c = (pixman_color_t*) &transparent_black; - } - else if (n == count) - { - left_x = stops[n - 1].x; - right_x = INT32_MAX; - left_c = right_c = (pixman_color_t*) &transparent_black; - } - else - { - left_x = stops[n - 1].x; - right_x = stops[n].x; - left_c = &stops[n - 1].color; - right_c = &stops[n].color; - } + left_x = stops[n - 1].x; + left_c = &stops[n - 1].color; + + right_x = stops[n].x; + right_c = &stops[n].color; } walker->left_x = left_x; diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index afe587f..09d7cbc 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -31,6 +31,50 @@ #include "pixman-private.h" +static const pixman_color_t transparent_black = { 0, 0, 0, 0 }; + +static void +gradient_property_changed (pixman_image_t *image) +{ + gradient_t *gradient = &image->gradient; + int n = gradient->n_stops; + pixman_gradient_stop_t *stops = gradient->stops; + pixman_gradient_stop_t *begin = &(gradient->stops[-1]); + pixman_gradient_stop_t *end = &(gradient->stops[n]); + + switch (gradient->common.repeat) + { + default: + case PIXMAN_REPEAT_NONE: + begin->x = INT32_MIN; + begin->color = transparent_black; + end->x = INT32_MAX; + end->color = transparent_black; + break; + + case PIXMAN_REPEAT_NORMAL: + begin->x = stops[n - 1].x - pixman_fixed_1; + begin->color = stops[n - 1].color; + end->x = stops[0].x + pixman_fixed_1; + end->color = stops[0].color; + break; + + case PIXMAN_REPEAT_REFLECT: + begin->x = - stops[0].x; + begin->color = stops[0].color; + end->x = pixman_int_to_fixed (2) - stops[n - 1].x; + end->color = stops[n - 1].color; + break; + + case PIXMAN_REPEAT_PAD: + begin->x = INT32_MIN; + begin->color = stops[0].color; + end->x = INT32_MAX; + end->color = stops[n - 1].color; + break; + } +} + pixman_bool_t _pixman_init_gradient (gradient_t * gradient, const pixman_gradient_stop_t *stops, @@ -38,14 +82,27 @@ _pixman_init_gradient (gradient_t * gradient, { return_val_if_fail (n_stops > 0, FALSE); - gradient->stops = pixman_malloc_ab (n_stops, sizeof (pixman_gradient_stop_t)); + /* We allocate two extra stops, one before the beginning of the stop list, + * and one after the end. These stops are initialized to whatever color + * would be used for positions outside the range of the stop list. + * + * This saves a bit of computation in the gradient walker. + * + * The pointer we store in the gradient_t struct still points to the + * first user-supplied struct, so when freeing, we will have to + * subtract one. + */ + gradient->stops = + pixman_malloc_ab (n_stops + 2, sizeof (pixman_gradient_stop_t)); if (!gradient->stops) return FALSE; + gradient->stops += 1; memcpy (gradient->stops, stops, n_stops * sizeof (pixman_gradient_stop_t)); - gradient->n_stops = n_stops; + gradient->common.property_changed = gradient_property_changed; + return TRUE; } @@ -102,7 +159,17 @@ _pixman_image_fini (pixman_image_t *image) image->type == CONICAL) { if (image->gradient.stops) - free (image->gradient.stops); + { + /* See _pixman_init_gradient() for an explanation of the - 1 */ + free (image->gradient.stops - 1); + } + + /* This will trigger if someone adds a property_changed + * method to the linear/radial/conical gradient overwriting + * the general one. + */ + assert ( + image->common.property_changed == gradient_property_changed); } if (image->type == BITS && image->bits.free_me) commit 84d6ca7c891601b019d4862a556ed98b7e6fe525 Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Fri Oct 14 07:42:00 2011 -0400 gradient walker: Correct types and fix formatting The type of pos in gradient_walker_reset() and gradient_walker_pixel() is pixman_fixed_48_16_t and not pixman_fixed_32_32. The types of the positions in the walker struct are pixman_fixed_t and not int32_t, and need_reset is a boolean, not an integer. The spread field should be called repeat and have the type pixman_repeat_t. Also fix some formatting issues, make gradient_walker_reset() static, and delete the pointless PIXMAN_GRADIENT_WALKER_NEED_RESET() macro. diff --git a/pixman/pixman-gradient-walker.c b/pixman/pixman-gradient-walker.c index dd666b4..53d0b30 100644 --- a/pixman/pixman-gradient-walker.c +++ b/pixman/pixman-gradient-walker.c @@ -31,7 +31,7 @@ void _pixman_gradient_walker_init (pixman_gradient_walker_t *walker, gradient_t * gradient, - unsigned int spread) + pixman_repeat_t repeat) { walker->num_stops = gradient->n_stops; walker->stops = gradient->stops; @@ -42,29 +42,32 @@ _pixman_gradient_walker_init (pixman_gradient_walker_t *walker, walker->left_rb = 0; walker->right_ag = 0; walker->right_rb = 0; - walker->spread = spread; + walker->repeat = repeat; walker->need_reset = TRUE; } -void -_pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, - pixman_fixed_32_32_t pos) +static void +gradient_walker_reset (pixman_gradient_walker_t *walker, + pixman_fixed_48_16_t pos) { int32_t x, left_x, right_x; - pixman_color_t *left_c, *right_c; + pixman_color_t *left_c, *right_c; int n, count = walker->num_stops; - pixman_gradient_stop_t * stops = walker->stops; + pixman_gradient_stop_t *stops = walker->stops; static const pixman_color_t transparent_black = { 0, 0, 0, 0 }; - switch (walker->spread) + switch (walker->repeat) { case PIXMAN_REPEAT_NORMAL: x = (int32_t)pos & 0xFFFF; for (n = 0; n < count; n++) + { if (x < stops[n].x) break; + } + if (n == 0) { left_x = stops[count - 1].x - 0x10000; @@ -92,8 +95,10 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, case PIXMAN_REPEAT_PAD: for (n = 0; n < count; n++) + { if (pos < stops[n].x) break; + } if (n == 0) { @@ -122,9 +127,12 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, x = (int32_t)pos & 0xFFFF; if ((int32_t)pos & 0x10000) x = 0x10000 - x; + for (n = 0; n < count; n++) + { if (x < stops[n].x) break; + } if (n == 0) { @@ -169,8 +177,10 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, default: /* REPEAT_NONE */ for (n = 0; n < count; n++) + { if (pos < stops[n].x) break; + } if (n == 0) { @@ -201,8 +211,8 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, walker->right_rb = ((right_c->red & 0xff00) << 8) | (right_c->blue >> 8); if (walker->left_x == walker->right_x || - ( walker->left_ag == walker->right_ag && - walker->left_rb == walker->right_rb ) ) + (walker->left_ag == walker->right_ag && + walker->left_rb == walker->right_rb)) { walker->stepper = 0; } @@ -215,20 +225,15 @@ _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, walker->need_reset = FALSE; } -#define PIXMAN_GRADIENT_WALKER_NEED_RESET(w, x) \ - ( (w)->need_reset || (x) < (w)->left_x || (x) >= (w)->right_x) - - -/* the following assumes that PIXMAN_GRADIENT_WALKER_NEED_RESET(w,x) is FALSE */ uint32_t _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker, - pixman_fixed_32_32_t x) + pixman_fixed_48_16_t x) { int dist, idist; uint32_t t1, t2, a, color; - if (PIXMAN_GRADIENT_WALKER_NEED_RESET (walker, x)) - _pixman_gradient_walker_reset (walker, x); + if (walker->need_reset || x < walker->left_x || x >= walker->right_x) + gradient_walker_reset (walker, x); dist = ((int)(x - walker->left_x) * walker->stepper) >> 16; idist = 256 - dist; diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index cbd48f3..1443bfb 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -299,29 +299,29 @@ typedef struct uint32_t left_rb; uint32_t right_ag; uint32_t right_rb; - int32_t left_x; - int32_t right_x; - int32_t stepper; + pixman_fixed_t left_x; + pixman_fixed_t right_x; + pixman_fixed_t stepper; pixman_gradient_stop_t *stops; int num_stops; - unsigned int spread; + pixman_repeat_t repeat; - int need_reset; + pixman_bool_t need_reset; } pixman_gradient_walker_t; void _pixman_gradient_walker_init (pixman_gradient_walker_t *walker, gradient_t * gradient, - unsigned int spread); + pixman_repeat_t repeat); void _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, - pixman_fixed_32_32_t pos); + pixman_fixed_48_16_t pos); uint32_t _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker, - pixman_fixed_32_32_t x); + pixman_fixed_48_16_t x); /* * Edges commit ace225b53dee88d134753ac901f26ba3db6781da Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Tue Oct 11 16:12:24 2011 -0400 Add stable release / development snapshot to draft release notes This will hopefully serve as a reminder to me that I should put this information in the release notes. diff --git a/Makefile.am b/Makefile.am index ff87e26..df8677a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,6 +87,8 @@ release-upload: release-check $(tar_gz) $(tar_bz2) $(sha1_tgz) $(sha1_tbz2) $(md scp $(tar_gz) $(tar_bz2) $(RELEASE_XORG_HOST):$(RELEASE_XORG_DIR) ssh $(RELEASE_CAIRO_HOST) "rm -f $(RELEASE_CAIRO_DIR)/LATEST-$(PACKAGE)-[0-9]* && ln -s $(tar_gz) $(RELEASE_CAIRO_DIR)/LATEST-$(PACKAGE)-$(VERSION)" +RELEASE_TYPE = $$(if test "x$(PIXMAN_VERSION_MINOR)" = "x$$(echo "$(PIXMAN_VERSION_MINOR)/2*2" | bc)" ; then echo "stable release in the" ; else echo "development snapshot leading up to a stable"; fi) + release-publish-message: $(HASHFILES) ensure-prev @echo "Please follow the instructions in RELEASING to push stuff out and" @echo "send out the announcement mails. Here is the excerpt you need:" @@ -94,7 +96,7 @@ release-publish-message: $(HASHFILES) ensure-prev @echo "Lists: $(RELEASE_ANNOUNCE_LIST)" @echo "Subject: [ANNOUNCE] $(PACKAGE) release $(VERSION) now available" @echo "============================== CUT HERE ==============================" - @echo "A new $(PACKAGE) release $(VERSION) is now available" + @echo "A new $(PACKAGE) release $(VERSION) is now available. This is a $(RELEASE_TYPE)" @echo "" @echo "tar.gz:" @echo " $(RELEASE_CAIRO_URL)/$(tar_gz)" From ickle at kemper.freedesktop.org Thu Oct 20 10:00:38 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 20 Oct 2011 10:00:38 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c src/sna/sna_damage.c src/sna/sna_damage.h Message-ID: <20111020170038.F281CC0001@kemper.freedesktop.org> src/sna/sna_accel.c | 23 ++++--- src/sna/sna_damage.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/sna/sna_damage.h | 10 +++ 3 files changed, 175 insertions(+), 11 deletions(-) New commits: commit 1229bf6a690e7f315ab22957da23481f58515ff9 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 20 17:37:41 2011 +0100 sna: Actually apply the composite offset for the self-copy I translated the region to copy by the composite pixmap offset, only failed to use the translated region for the actual copy command (using instead the original boxes). Fix that mistake by avoiding the temporary region entirely and applying the translation inplace. We also have to be careful in the case of copying between two composited windows that have different offsets into the same screen pixmap. This fixes the regression introduced with a3466c8b69af (sna/accel: Implement a simpler path for CopyArea between the same pixmaps). Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 22f5468..8153d34 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1254,7 +1254,6 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, PixmapPtr pixmap = get_drawable_pixmap(src); struct sna_pixmap *priv = sna_pixmap(pixmap); int alu = gc ? gc->alu : GXcopy; - RegionRec region; int16_t tx, ty; if (n == 0 || (dx | dy) == 0) @@ -1266,10 +1265,11 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, dx, dy, alu, pixmap->drawable.width, pixmap->drawable.height)); - pixman_region_init_rects(®ion, box, n); - get_drawable_deltas(dst, pixmap, &tx, &ty); - RegionTranslate(®ion, tx, ty); - assert_pixmap_contains_box(pixmap, RegionExtents(®ion)); + get_drawable_deltas(src, pixmap, &tx, &ty); + dx += tx; + dy += ty; + if (dst != src) + get_drawable_deltas(dst, pixmap, &tx, &ty); if (priv && priv->gpu_bo) { if (!sna_pixmap_move_to_gpu(pixmap)) { @@ -1280,14 +1280,14 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, if (!sna->render.copy_boxes(sna, alu, pixmap, priv->gpu_bo, dx, dy, - pixmap, priv->gpu_bo, 0, 0, + pixmap, priv->gpu_bo, tx, ty, box, n)) { DBG(("%s: fallback - accelerated copy boxes failed\n", __FUNCTION__)); goto fallback; } - sna_damage_add(&priv->gpu_damage, ®ion); + sna_damage_add_boxes(&priv->gpu_damage, box, n, tx, ty); } else { FbBits *dst_bits, *src_bits; int stride, bpp; @@ -1299,7 +1299,9 @@ fallback: stride = pixmap->devKind; bpp = pixmap->drawable.bitsPerPixel; if (alu == GXcopy && !reverse && !upsidedown && bpp >= 8) { - dst_bits = pixmap->devPrivate.ptr; + dst_bits = (FbBits *) + ((char *)pixmap->devPrivate.ptr + + ty * stride + tx * bpp / 8); src_bits = (FbBits *) ((char *)pixmap->devPrivate.ptr + dy * stride + dx * bpp / 8); @@ -1323,9 +1325,9 @@ fallback: stride, (box->x1 + dx) * bpp, - dst_bits + box->y1 * stride, + dst_bits + (box->y1 + ty) * stride, stride, - box->x1 * bpp, + (box->x1 + tx) * bpp, (box->x2 - box->x1) * bpp, (box->y2 - box->y1), @@ -1336,7 +1338,6 @@ fallback: }while (--n); } } - RegionUninit(®ion); } static void diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index f6ffef0..b5d0084 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -231,6 +231,73 @@ _sna_damage_create_elt(struct sna_damage *damage, boxes, count * sizeof(BoxRec)); } +static void +_sna_damage_create_elt_with_translation(struct sna_damage *damage, + enum mode mode, + const BoxRec *boxes, int count, + int16_t dx, int16_t dy) +{ + struct sna_damage_elt *elt; + int i; + + DBG((" %s(%s): n=%d, prev=(%s, remain %d)\n", __FUNCTION__, + mode == ADD ? "add" : "subtract", + damage->n, + damage->n ? damage->elts[damage->n-1].mode == ADD ? "add" : "subtract" : "none", + damage->last_box ? damage->last_box->remain : 0)); + + if (damage->last_box && damage->elts[damage->n-1].mode == mode) { + int n; + BoxRec *b; + + n = count; + if (n > damage->last_box->remain) + n = damage->last_box->remain; + + elt = damage->elts + damage->n-1; + b = elt->box + elt->n; + for (i = 0; i < n; i++) { + b[i].x1 = boxes[i].x1 + dx; + b[i].x2 = boxes[i].x2 + dx; + b[i].y1 = boxes[i].y1 + dy; + b[i].y2 = boxes[i].y2 + dy; + } + elt->n += n; + damage->last_box->remain -= n; + if (damage->last_box->remain == 0) + damage->last_box = NULL; + + count -=n; + boxes += n; + if (count == 0) + return; + } + + if (damage->n == damage->size) { + int newsize = damage->size * 2; + struct sna_damage_elt *newelts = realloc(damage->elts, + newsize*sizeof(*elt)); + if (newelts == NULL) + return; + + damage->elts = newelts; + damage->size = newsize; + } + + DBG((" %s(): new elt\n", __FUNCTION__)); + + elt = damage->elts + damage->n++; + elt->mode = mode; + elt->n = count; + elt->box = _sna_damage_create_boxes(damage, count); + for (i = 0; i < count; i++) { + elt->box[i].x1 = boxes[i].x1 + dx; + elt->box[i].x2 = boxes[i].x2 + dx; + elt->box[i].y1 = boxes[i].y1 + dy; + elt->box[i].y2 = boxes[i].y2 + dy; + } +} + static void free_list(struct list *head) { while (!list_is_empty(head)) { @@ -387,6 +454,92 @@ fastcall struct sna_damage *_sna_damage_add(struct sna_damage *damage, } #endif +inline static struct sna_damage * +__sna_damage_add_boxes(struct sna_damage *damage, + const BoxRec *box, int n, + int16_t dx, int16_t dy) +{ + BoxRec extents; + int i; + + assert(n); + + extents = box[0]; + for (i = 1; i < n; i++) { + if (extents.x1 > box[i].x1) + extents.x1 = box[i].x1; + if (extents.x2 < box[i].x2) + extents.x2 = box[i].x2; + if (extents.y1 > box[i].y1) + extents.y1 = box[i].y1; + if (extents.y2 < box[i].y2) + extents.y2 = box[i].y2; + } + + if (extents.y2 <= extents.y1 || extents.x2 <= extents.x1) + return damage; + + extents.x1 += dx; + extents.x2 += dx; + extents.y1 += dy; + extents.y2 += dy; + + if (!damage) + damage = _sna_damage_create(); + + if (damage->all) + return damage; + + if (damage->mode == SUBTRACT) + __sna_damage_reduce(damage); + damage->mode = ADD; + + if (pixman_region_contains_rectangle(&damage->region, + &extents) == PIXMAN_REGION_IN) + return damage; + + _sna_damage_create_elt_with_translation(damage, ADD, box, n, dx, dy); + + if (damage->extents.x1 > extents.x1) + damage->extents.x1 = extents.x1; + if (damage->extents.x2 < extents.x2) + damage->extents.x2 = extents.x2; + + if (damage->extents.y1 > extents.y1) + damage->extents.y1 = extents.y1; + if (damage->extents.y2 < extents.y2) + damage->extents.y2 = extents.y2; + + return damage; +} + +#if DEBUG_DAMAGE +struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, + const BoxRec *box, int n, + int16_t dx, int16_t dy) +{ + char damage_buf[1000]; + + DBG(("%s(%s + [(%d, %d), (%d, %d) ... x %d])\n", __FUNCTION__, + _debug_describe_damage(damage_buf, sizeof(damage_buf), damage), + box->x1, box->y1, box->x2, box->y2, n)); + + damage = __sna_damage_add_box(damage, boxes, n, dx, dy); + + ErrorF(" = %s\n", + _debug_describe_damage(damage_buf, sizeof(damage_buf), damage)); + + return damage; +} +#else +struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, + const BoxRec *box, int n, + int16_t dx, int16_t dy) +{ + return __sna_damage_add_boxes(damage, box, n, dx, dy); +} +#endif + inline static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, const BoxRec *box) { diff --git a/src/sna/sna_damage.h b/src/sna/sna_damage.h index 5fb9aef..454ad84 100644 --- a/src/sna/sna_damage.h +++ b/src/sna/sna_damage.h @@ -34,6 +34,16 @@ static inline void sna_damage_add_box(struct sna_damage **damage, *damage = _sna_damage_add_box(*damage, box); } +struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, + const BoxRec *box, int n, + int16_t dx, int16_t dy); +static inline void sna_damage_add_boxes(struct sna_damage **damage, + const BoxRec *box, int n, + int16_t dx, int16_t dy) +{ + *damage = _sna_damage_add_boxes(*damage, box, n, dx, dy); +} + struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, int width, int height); static inline bool sna_damage_is_all(struct sna_damage **damage, From glisse at kemper.freedesktop.org Thu Oct 20 12:05:03 2011 From: glisse at kemper.freedesktop.org (Jerome Glisse) Date: Thu, 20 Oct 2011 12:05:03 -0700 (PDT) Subject: xf86-video-ati: Branch 'master' Message-ID: <20111020190503.D937BC0001@kemper.freedesktop.org> src/radeon.h | 66 ----------------------------------------------------- src/radeon_probe.c | 29 ++++++++++++++++++++++- src/radeon_probe.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 67 deletions(-) New commits: commit 856583dbca9319c77fed40daa9956e81a0068f9e Author: Jerome Glisse <jglisse at redhat.com> Date: Thu Oct 20 14:17:14 2011 -0400 radeon/kms: fallback to vesa if GPU is not supported by UMS For GPU not supported by UMS, test in probe so that we properly fallback to vesa. Signed-off-by: Jerome Glisse <jglisse at redhat.com> Reviewed-by: Alex Deucher <alexander.deucher at amd.com> diff --git a/src/radeon.h b/src/radeon.h index f66ffd0..50ce62f 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -313,62 +313,6 @@ typedef struct { DisplayModePtr mode; } RADEONFBLayout; -typedef enum { - CHIP_FAMILY_UNKNOW, - CHIP_FAMILY_LEGACY, - CHIP_FAMILY_RADEON, - CHIP_FAMILY_RV100, - CHIP_FAMILY_RS100, /* U1 (IGP320M) or A3 (IGP320)*/ - CHIP_FAMILY_RV200, - CHIP_FAMILY_RS200, /* U2 (IGP330M/340M/350M) or A4 (IGP330/340/345/350), RS250 (IGP 7000) */ - CHIP_FAMILY_R200, - CHIP_FAMILY_RV250, - CHIP_FAMILY_RS300, /* RS300/RS350 */ - CHIP_FAMILY_RV280, - CHIP_FAMILY_R300, - CHIP_FAMILY_R350, - CHIP_FAMILY_RV350, - CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */ - CHIP_FAMILY_R420, /* R420/R423/M18 */ - CHIP_FAMILY_RV410, /* RV410, M26 */ - CHIP_FAMILY_RS400, /* xpress 200, 200m (RS400) Intel */ - CHIP_FAMILY_RS480, /* xpress 200, 200m (RS410/480/482/485) AMD */ - CHIP_FAMILY_RV515, /* rv515 */ - CHIP_FAMILY_R520, /* r520 */ - CHIP_FAMILY_RV530, /* rv530 */ - CHIP_FAMILY_R580, /* r580 */ - CHIP_FAMILY_RV560, /* rv560 */ - CHIP_FAMILY_RV570, /* rv570 */ - CHIP_FAMILY_RS600, - CHIP_FAMILY_RS690, - CHIP_FAMILY_RS740, - CHIP_FAMILY_R600, /* r600 */ - CHIP_FAMILY_RV610, - CHIP_FAMILY_RV630, - CHIP_FAMILY_RV670, - CHIP_FAMILY_RV620, - CHIP_FAMILY_RV635, - CHIP_FAMILY_RS780, - CHIP_FAMILY_RS880, - CHIP_FAMILY_RV770, /* r700 */ - CHIP_FAMILY_RV730, - CHIP_FAMILY_RV710, - CHIP_FAMILY_RV740, - CHIP_FAMILY_CEDAR, /* evergreen */ - CHIP_FAMILY_REDWOOD, - CHIP_FAMILY_JUNIPER, - CHIP_FAMILY_CYPRESS, - CHIP_FAMILY_HEMLOCK, - CHIP_FAMILY_PALM, - CHIP_FAMILY_SUMO, - CHIP_FAMILY_SUMO2, - CHIP_FAMILY_BARTS, - CHIP_FAMILY_TURKS, - CHIP_FAMILY_CAICOS, - CHIP_FAMILY_CAYMAN, - CHIP_FAMILY_LAST -} RADEONChipFamily; - #define IS_RV100_VARIANT ((info->ChipFamily == CHIP_FAMILY_RV100) || \ (info->ChipFamily == CHIP_FAMILY_RV200) || \ (info->ChipFamily == CHIP_FAMILY_RS100) || \ @@ -501,16 +445,6 @@ struct radeon_exa_pixmap_priv { Bool bo_mapped; }; -typedef struct { - uint32_t pci_device_id; - RADEONChipFamily chip_family; - int mobility; - int igp; - int nocrtc2; - int nointtvout; - int singledac; -} RADEONCardInfo; - #define RADEON_2D_EXA_COPY 1 #define RADEON_2D_EXA_SOLID 2 diff --git a/src/radeon_probe.c b/src/radeon_probe.c index 7819027..26dec28 100644 --- a/src/radeon_probe.c +++ b/src/radeon_probe.c @@ -59,9 +59,31 @@ #include "radeon_pci_chipset_gen.h" +#include "radeon_chipinfo_gen.h" #ifdef XSERVER_LIBPCIACCESS #include "radeon_pci_device_match_gen.h" + +static Bool radeon_ums_supported(ScrnInfoPtr pScrn, struct pci_device *pci_dev) +{ + unsigned family = 0, i; + + for (i = 0; i < sizeof(RADEONCards) / sizeof(RADEONCardInfo); i++) { + if (pci_dev->device_id == RADEONCards[i].pci_device_id) { + family = RADEONCards[i].chip_family; + break; + } + } + + if (family >= CHIP_FAMILY_SUMO) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, + "GPU only supported with KMS, using vesa instead.\n"); + return FALSE; + } + return TRUE; +} +#else +#define radeon_ums_supported(x, y) TRUE #endif #ifndef XSERVER_LIBPCIACCESS @@ -131,8 +153,13 @@ radeon_get_scrninfo(int entity_num, void *pci_dev) return FALSE; if (pci_dev) { - if (radeon_kernel_mode_enabled(pScrn, pci_dev)) + if (radeon_kernel_mode_enabled(pScrn, pci_dev)) { kms = 1; + } else { + if (!radeon_ums_supported(pScrn, pci_dev)) { + return FALSE; + } + } } pScrn->driverVersion = RADEON_VERSION_CURRENT; diff --git a/src/radeon_probe.h b/src/radeon_probe.h index d97bb06..94f6d7d 100644 --- a/src/radeon_probe.h +++ b/src/radeon_probe.h @@ -55,6 +55,72 @@ extern DriverRec RADEON; #define RADEON_MAX_CRTC 6 #define RADEON_MAX_BIOS_CONNECTOR 16 +typedef enum { + CHIP_FAMILY_UNKNOW, + CHIP_FAMILY_LEGACY, + CHIP_FAMILY_RADEON, + CHIP_FAMILY_RV100, + CHIP_FAMILY_RS100, /* U1 (IGP320M) or A3 (IGP320)*/ + CHIP_FAMILY_RV200, + CHIP_FAMILY_RS200, /* U2 (IGP330M/340M/350M) or A4 (IGP330/340/345/350), RS250 (IGP 7000) */ + CHIP_FAMILY_R200, + CHIP_FAMILY_RV250, + CHIP_FAMILY_RS300, /* RS300/RS350 */ + CHIP_FAMILY_RV280, + CHIP_FAMILY_R300, + CHIP_FAMILY_R350, + CHIP_FAMILY_RV350, + CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */ + CHIP_FAMILY_R420, /* R420/R423/M18 */ + CHIP_FAMILY_RV410, /* RV410, M26 */ + CHIP_FAMILY_RS400, /* xpress 200, 200m (RS400) Intel */ + CHIP_FAMILY_RS480, /* xpress 200, 200m (RS410/480/482/485) AMD */ + CHIP_FAMILY_RV515, /* rv515 */ + CHIP_FAMILY_R520, /* r520 */ + CHIP_FAMILY_RV530, /* rv530 */ + CHIP_FAMILY_R580, /* r580 */ + CHIP_FAMILY_RV560, /* rv560 */ + CHIP_FAMILY_RV570, /* rv570 */ + CHIP_FAMILY_RS600, + CHIP_FAMILY_RS690, + CHIP_FAMILY_RS740, + CHIP_FAMILY_R600, /* r600 */ + CHIP_FAMILY_RV610, + CHIP_FAMILY_RV630, + CHIP_FAMILY_RV670, + CHIP_FAMILY_RV620, + CHIP_FAMILY_RV635, + CHIP_FAMILY_RS780, + CHIP_FAMILY_RS880, + CHIP_FAMILY_RV770, /* r700 */ + CHIP_FAMILY_RV730, + CHIP_FAMILY_RV710, + CHIP_FAMILY_RV740, + CHIP_FAMILY_CEDAR, /* evergreen */ + CHIP_FAMILY_REDWOOD, + CHIP_FAMILY_JUNIPER, + CHIP_FAMILY_CYPRESS, + CHIP_FAMILY_HEMLOCK, + CHIP_FAMILY_PALM, + CHIP_FAMILY_SUMO, + CHIP_FAMILY_SUMO2, + CHIP_FAMILY_BARTS, + CHIP_FAMILY_TURKS, + CHIP_FAMILY_CAICOS, + CHIP_FAMILY_CAYMAN, + CHIP_FAMILY_LAST +} RADEONChipFamily; + +typedef struct { + uint32_t pci_device_id; + RADEONChipFamily chip_family; + int mobility; + int igp; + int nocrtc2; + int nointtvout; + int singledac; +} RADEONCardInfo; + typedef enum { MT_UNKNOWN = -1, From jeremyhu at kemper.freedesktop.org Thu Oct 20 14:45:59 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Thu, 20 Oct 2011 14:45:59 -0700 (PDT) Subject: xf86-video-cirrus: Changes to 'master' Message-ID: <20111020214559.A5189C0001@kemper.freedesktop.org> src/alp_driver.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) New commits: commit 65662c012069f2591ab10ac5b92432e58e878ca5 Author: Stefan Potyra <sistpoty at ubuntu.com> Date: Thu Oct 20 14:44:44 2011 -0700 Limit the maximul pitch of GD5436 and GD5446 Limit the maximum supported pitch of the GD5446 to 4088, since the internal pitch register is only 9 bit (and contains the pitch left shifted by 3). See https://bugs.freedesktop.org/attachment.cgi?id=52605 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Thu Oct 20 14:50:18 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Thu, 20 Oct 2011 14:50:18 -0700 (PDT) Subject: xf86-video-cirrus: Changes to 'master' Message-ID: <20111020215018.40213C0001@kemper.freedesktop.org> Rebased ref, commits from common ancestor: commit f5a8080f149a2f2658b7773ae7db7c67c52c4199 Author: Stefan Potyra <sistpoty at ubuntu.com> Date: Thu Oct 20 14:44:44 2011 -0700 Limit the maximul pitch of GD5436 and GD5446 Limit the maximum supported pitch of the GD5446 to 4088, since the internal pitch register is only 9 bit (and contains the pitch left shifted by 3). See https://bugs.freedesktop.org/show_bug.cgi?id=23775 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From whot at kemper.freedesktop.org Thu Oct 20 15:09:47 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Thu, 20 Oct 2011 15:09:47 -0700 (PDT) Subject: libXi: Changes to 'master' Message-ID: <20111020220947.8BD9BC0001@kemper.freedesktop.org> man/XIGrabButton.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 05aaf65b3b6b7dc7268137ce4ee516f08eefb62f Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Oct 21 08:07:45 2011 +1000 man: fix #include for XIGrabButton Reported-by: Matthias Clasen <mclasen at redhat.com> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> From alanc at kemper.freedesktop.org Thu Oct 20 16:31:02 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Thu, 20 Oct 2011 16:31:02 -0700 (PDT) Subject: mkfontscale: Changes to 'master' Message-ID: <20111020233103.0629CC0001@kemper.freedesktop.org> data.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) New commits: commit bf7d4fd83c896b70f68d59de756a3847417d9add Author: Maxim Iorsh <iorsh at users.sourceforge.net> Date: Thu Oct 20 08:08:47 2011 +0200 mkfontscale: fix Culmus entries to precede URW Culmus must precede URW and Bitstream in notice list, since its fonts are based on URW/Bitstream sometimes. Signed-off-by: Maxim Iorsh <iorsh at users.sourceforge.net> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From ickle at kemper.freedesktop.org Fri Oct 21 09:16:37 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Fri, 21 Oct 2011 09:16:37 -0700 (PDT) Subject: xf86-video-intel: 14 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_damage.c src/sna/sna_damage.h src/sna/sna.h src/sna/sna_render.h Message-ID: <20111021161637.89DC9C0001@kemper.freedesktop.org> src/sna/gen2_render.c | 20 + src/sna/gen3_render.c | 19 + src/sna/gen4_render.c | 16 + src/sna/gen5_render.c | 37 +++ src/sna/gen6_render.c | 32 ++ src/sna/gen7_render.c | 32 ++ src/sna/kgem.c | 3 src/sna/sna.h | 15 + src/sna/sna_accel.c | 471 +++++++++++++++++++++++++++-------------- src/sna/sna_blt.c | 49 +++- src/sna/sna_damage.c | 570 +++++++++++++++++++++++++++++++++++++++----------- src/sna/sna_damage.h | 47 +++- src/sna/sna_render.h | 3 13 files changed, 1002 insertions(+), 312 deletions(-) New commits: commit a18f559961135fa288dda3b94207abb0b6d4d302 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 16:37:09 2011 +0100 sna: Fix debug compilation Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 6fd8fe8..6492205 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -628,16 +628,16 @@ __sna_damage_add_boxes(struct sna_damage *damage, #if DEBUG_DAMAGE struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, - const BoxRec *box, int n, + const BoxRec *b, int n, int16_t dx, int16_t dy) { char damage_buf[1000]; DBG(("%s(%s + [(%d, %d), (%d, %d) ... x %d])\n", __FUNCTION__, _debug_describe_damage(damage_buf, sizeof(damage_buf), damage), - box->x1, box->y1, box->x2, box->y2, n)); + b->x1, b->y1, b->x2, b->y2, n)); - damage = __sna_damage_add_boxes(damage, boxes, n, dx, dy); + damage = __sna_damage_add_boxes(damage, b, n, dx, dy); ErrorF(" = %s\n", _debug_describe_damage(damage_buf, sizeof(damage_buf), damage)); @@ -646,10 +646,10 @@ struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, } #else struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, - const BoxRec *box, int n, + const BoxRec *b, int n, int16_t dx, int16_t dy) { - return __sna_damage_add_boxes(damage, box, n, dx, dy); + return __sna_damage_add_boxes(damage, b, n, dx, dy); } #endif @@ -734,9 +734,9 @@ struct sna_damage *_sna_damage_add_rectangles(struct sna_damage *damage, { char damage_buf[1000]; - DBG(("%s(%s + [(%d, %d), (%d, %d) ... x %d])\n", __FUNCTION__, + DBG(("%s(%s + [(%d, %d)x(%d, %d) ... x %d])\n", __FUNCTION__, _debug_describe_damage(damage_buf, sizeof(damage_buf), damage), - box->x1, box->y1, box->x2, box->y2, n)); + r->x, r->y, r->width, r->height, n)); damage = __sna_damage_add_rectangles(damage, r, n, dx, dy); @@ -826,9 +826,9 @@ struct sna_damage *_sna_damage_add_points(struct sna_damage *damage, { char damage_buf[1000]; - DBG(("%s(%s + [(%d, %d), (%d, %d) ... x %d])\n", __FUNCTION__, + DBG(("%s(%s + [(%d, %d) ... x %d])\n", __FUNCTION__, _debug_describe_damage(damage_buf, sizeof(damage_buf), damage), - box->x1, box->y1, box->x2, box->y2, n)); + p->x, p->y, n)); damage = __sna_damage_add_points(damage, p, n, dx, dy); commit a3a075201c8e47cfad6ec296b7baf549deb44cb3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 15:30:52 2011 +0100 sna: Treat a bo marked as being last seen on the GPU as requiring a flush We are hitting this path upon retiring the old scanout buffer following a page-flip. We want to treat this as being hot and available for reuse, so mark it as such until the next retirement pass. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index d5084f8..6f98f27 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -564,12 +564,11 @@ static void __kgem_bo_destroy(struct kgem *kgem, struct kgem_bo *bo) kgem->need_expire = true; if (bo->rq) { list_move(&bo->list, active(kgem, bo->size)); - } else if (bo->needs_flush) { + } else if (bo->needs_flush | bo->gpu) { assert(list_is_empty(&bo->request)); list_add(&bo->request, &kgem->flushing); list_move(&bo->list, active(kgem, bo->size)); } else { - assert(bo->gpu == 0); list_move(&bo->list, inactive(kgem, bo->size)); } commit 999d13f32162ce11fe4042825b5b849073944ca8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 12:43:02 2011 +0100 sna: Fast path unclipped points Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index f78bd5c..636544e 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2140,7 +2140,8 @@ static Bool sna_poly_point_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, - GCPtr gc, int mode, int n, DDXPointPtr pt) + GCPtr gc, int mode, int n, DDXPointPtr pt, + bool clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); @@ -2149,7 +2150,8 @@ sna_poly_point_blt(DrawablePtr drawable, DDXPointRec last; int16_t dx, dy; - DBG(("%s: alu=%d, pixel=%08lx\n", __FUNCTION__, gc->alu, gc->fgPixel)); + DBG(("%s: alu=%d, pixel=%08lx, clipped?=%d\n", + __FUNCTION__, gc->alu, gc->fgPixel, clipped)); if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return FALSE; @@ -2159,7 +2161,30 @@ sna_poly_point_blt(DrawablePtr drawable, last.x = drawable->x; last.y = drawable->y; - while (n--) { + if (!clipped) { + last.x += dx; + last.y += dy; + + sna_damage_add_points(damage, pt, n, last.x, last.y); + do { + BoxRec r; + + r.x1 = pt->x; + r.y1 = pt->y; + pt++; + + r.x1 += last.x; + r.y1 += last.y; + if (mode == CoordModePrevious) { + last.x = r.x1; + last.y = r.y1; + } + + r.x2 = r.x1 + 1; + r.y2 = r.y1 + 1; + fill.box(sna, &fill, &r); + } while (--n); + } else while (n--) { int x, y; x = pt->x; @@ -2194,14 +2219,15 @@ sna_poly_point_blt(DrawablePtr drawable, return TRUE; } -static Bool +static unsigned sna_poly_point_extents(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt, BoxPtr out) { BoxRec box; + bool clipped; if (n == 0) - return true; + return 0; box.x2 = box.x1 = pt->x; box.y2 = box.y1 = pt->y; @@ -2212,9 +2238,12 @@ sna_poly_point_extents(DrawablePtr drawable, GCPtr gc, box.x2++; box.y2++; - trim_and_translate_box(&box, drawable, gc); + clipped = trim_and_translate_box(&box, drawable, gc); + if (box_empty(&box)) + return 0; + *out = box; - return box_empty(&box); + return 1 | clipped << 1; } static void @@ -2223,16 +2252,19 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc, { struct sna *sna = to_sna_from_drawable(drawable); RegionRec region; + unsigned flags; DBG(("%s(mode=%d, n=%d, pt[0]=(%d, %d)\n", __FUNCTION__, mode, n, pt[0].x, pt[0].y)); - if (sna_poly_point_extents(drawable, gc, mode, n, pt, ®ion.extents)) + flags = sna_poly_point_extents(drawable, gc, mode, n, pt, ®ion.extents); + if (flags == 0) return; - DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__, + DBG(("%s: extents (%d, %d), (%d, %d), flags=%x\n", __FUNCTION__, region.extents.x1, region.extents.y1, - region.extents.x2, region.extents.y2)); + region.extents.x2, region.extents.y2, + flags)); if (FORCE_FALLBACK) goto fallback; @@ -2252,15 +2284,15 @@ sna_poly_point(DrawablePtr drawable, GCPtr gc, if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_poly_point_blt(drawable, priv->gpu_bo, - priv->gpu_only ? NULL : &priv->gpu_damage, - gc, mode, n, pt)) + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), + gc, mode, n, pt, flags & 2)) return; if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_point_blt(drawable, priv->cpu_bo, - &priv->cpu_damage, - gc, mode, n, pt)) + reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), + gc, mode, n, pt, flags & 2)) return; } diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index e33fc34..6fd8fe8 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -371,6 +371,69 @@ _sna_damage_create_elt_from_rectangles(struct sna_damage *damage, } } +static void +_sna_damage_create_elt_from_points(struct sna_damage *damage, + const DDXPointRec *p, int count, + int16_t dx, int16_t dy) +{ + struct sna_damage_elt *elt; + int i; + + DBG((" %s: n=%d, prev=(remain %d)\n", __FUNCTION__, + damage->n, + damage->last_box ? damage->last_box->remain : 0)); + + if (damage->last_box) { + int n; + BoxRec *b; + + n = count; + if (n > damage->last_box->remain) + n = damage->last_box->remain; + + elt = damage->elts + damage->n-1; + b = elt->box + elt->n; + for (i = 0; i < n; i++) { + b[i].x1 = p[i].x + dx; + b[i].x2 = b[i].x1 + 1; + b[i].y1 = p[i].y + dy; + b[i].y2 = b[i].y1 + 1; + } + elt->n += n; + damage->last_box->remain -= n; + if (damage->last_box->remain == 0) + damage->last_box = NULL; + + count -=n; + p += n; + if (count == 0) + return; + } + + if (damage->n == damage->size) { + int newsize = damage->size * 2; + struct sna_damage_elt *newelts = realloc(damage->elts, + newsize*sizeof(*elt)); + if (newelts == NULL) + return; + + damage->elts = newelts; + damage->size = newsize; + } + + DBG((" %s(): new elt\n", __FUNCTION__)); + + elt = damage->elts + damage->n++; + elt->n = count; + elt->box = _sna_damage_create_boxes(damage, count); + for (i = 0; i < count; i++) { + elt->box[i].x1 = p[i].x + dx; + elt->box[i].x2 = elt->box[i].x1 + 1; + elt->box[i].y1 = p[i].y + dy; + elt->box[i].y2 = elt->box[i].y1 + 1; + } +} + static void free_list(struct list *head) { while (!list_is_empty(head)) { @@ -621,8 +684,7 @@ __sna_damage_add_rectangles(struct sna_damage *damage, extents.y2 = r[i].y + r[i].height; } - if (extents.y2 <= extents.y1 || extents.x2 <= extents.x1) - return damage; + assert(extents.y2 > extents.y1 && extents.x2 > extents.x1); extents.x1 += dx; extents.x2 += dx; @@ -692,6 +754,98 @@ struct sna_damage *_sna_damage_add_rectangles(struct sna_damage *damage, } #endif +/* XXX pass in extents? */ +inline static struct sna_damage * +__sna_damage_add_points(struct sna_damage *damage, + const DDXPointRec *p, int n, + int16_t dx, int16_t dy) +{ + BoxRec extents; + int i; + + assert(n); + + extents.x2 = extents.x1 = p[0].x; + extents.y2 = extents.y1 = p[0].y; + for (i = 1; i < n; i++) { + if (extents.x1 > p[i].x) + extents.x1 = p[i].x; + else if (extents.x2 < p[i].x) + extents.x2 = p[i].x; + if (extents.y1 > p[i].y) + extents.y1 = p[i].y; + else if (extents.y2 < p[i].y) + extents.y2 = p[i].y; + } + + extents.x1 += dx; + extents.x2 += dx + 1; + extents.y1 += dy; + extents.y2 += dy + 1; + + if (!damage) + damage = _sna_damage_create(); + else switch (damage->mode) { + case DAMAGE_ALL: + return damage; + case DAMAGE_SUBTRACT: + __sna_damage_reduce(damage); + case DAMAGE_ADD: + break; + } + + if (pixman_region_contains_rectangle(&damage->region, + &extents) == PIXMAN_REGION_IN) + return damage; + + _sna_damage_create_elt_from_points(damage, p, n, dx, dy); + + if (REGION_NUM_RECTS(&damage->region) == 0) { + damage->region.extents = *damage->elts[0].box; + damage->region.data = NULL; + damage->extents = extents; + } else { + if (damage->extents.x1 > extents.x1) + damage->extents.x1 = extents.x1; + if (damage->extents.x2 < extents.x2) + damage->extents.x2 = extents.x2; + + if (damage->extents.y1 > extents.y1) + damage->extents.y1 = extents.y1; + if (damage->extents.y2 < extents.y2) + damage->extents.y2 = extents.y2; + } + + return damage; +} + +#if DEBUG_DAMAGE +struct sna_damage *_sna_damage_add_points(struct sna_damage *damage, + const DDXPointRec *p, int n, + int16_t dx, int16_t dy) +{ + char damage_buf[1000]; + + DBG(("%s(%s + [(%d, %d), (%d, %d) ... x %d])\n", __FUNCTION__, + _debug_describe_damage(damage_buf, sizeof(damage_buf), damage), + box->x1, box->y1, box->x2, box->y2, n)); + + damage = __sna_damage_add_points(damage, p, n, dx, dy); + + ErrorF(" = %s\n", + _debug_describe_damage(damage_buf, sizeof(damage_buf), damage)); + + return damage; +} +#else +struct sna_damage *_sna_damage_add_points(struct sna_damage *damage, + const DDXPointRec *p, int n, + int16_t dx, int16_t dy) +{ + return __sna_damage_add_points(damage, p, n, dx, dy); +} +#endif + inline static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, const BoxRec *box) { diff --git a/src/sna/sna_damage.h b/src/sna/sna_damage.h index 30058db..2dc2737 100644 --- a/src/sna/sna_damage.h +++ b/src/sna/sna_damage.h @@ -60,6 +60,17 @@ static inline void sna_damage_add_rectangles(struct sna_damage **damage, *damage = _sna_damage_add_rectangles(*damage, r, n, dx, dy); } +struct sna_damage *_sna_damage_add_points(struct sna_damage *damage, + const DDXPointRec *p, int n, + int16_t dx, int16_t dy); +static inline void sna_damage_add_points(struct sna_damage **damage, + const DDXPointRec *p, int n, + int16_t dx, int16_t dy) +{ + if (damage) + *damage = _sna_damage_add_points(*damage, p, n, dx, dy); +} + struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, int width, int height); static inline bool sna_damage_is_all(struct sna_damage **damage, @@ -68,6 +79,9 @@ static inline bool sna_damage_is_all(struct sna_damage **damage, if (*damage == NULL) return false; + if ((*damage)->n) + return false; + switch ((*damage)->mode) { case DAMAGE_ALL: return true; commit eb80013f4ea50ad4f54b4d1d90c5e9da27e1c34c Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 11:49:55 2011 +0100 sna: Fast path for unclipped rectangles Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index c420f0a..f78bd5c 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2395,7 +2395,7 @@ sna_poly_line_blt(DrawablePtr drawable, } DBG(("%s: (%d, %d) -> (%d, %d) clipping line (%d, %d), (%d, %d) against box (%d, %d), (%d, %d)\n", __FUNCTION__, - last.x, last.y, x, y, + last.x, last.y, p.x, p.y, r.x1, r.y1, r.x2, r.y2, box->x1, box->y1, box->x2, box->y2)); if (box_intersect(&r, box)) { @@ -3026,7 +3026,8 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, GCPtr gc, int n, - xRectangle *rect) + xRectangle *rect, + bool clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); @@ -3035,8 +3036,10 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, uint32_t pixel = gc->fillStyle == FillSolid ? gc->fgPixel : gc->tile.pixel; int16_t dx, dy; - DBG(("%s x %d [(%d, %d)+(%d, %d)...]\n", - __FUNCTION__, n, rect->x, rect->y, rect->width, rect->height)); + DBG(("%s x %d [(%d, %d)+(%d, %d)...], clipped?=%d\n", + __FUNCTION__, + n, rect->x, rect->y, rect->width, rect->height, + clipped)); if (n == 1 && clip->data == NULL) { BoxPtr box = &clip->extents; @@ -3071,7 +3074,23 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, } get_drawable_deltas(drawable, pixmap, &dx, &dy); - if (clip->data == NULL) { + if (!clipped) { + dx += drawable->x; + dy += drawable->y; + + sna_damage_add_rectangles(damage, rect, n, dx, dy); + do { + BoxRec r; + + r.x1 = rect->x + dx; + r.y1 = rect->y + dy; + r.x2 = bound(r.x1, rect->width); + r.y2 = bound(r.y1, rect->height); + rect++; + + fill.box(sna, &fill, &r); + } while (--n); + } else if (clip->data == NULL) { BoxPtr box = &clip->extents; while (n--) { BoxRec r; @@ -3367,15 +3386,16 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, return TRUE; } -static Bool +static unsigned sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc, int n, xRectangle *rect, BoxPtr out) { BoxRec box; + bool clipped; if (n == 0) - return true; + return 0; DBG(("%s: [0] = (%d, %d)x(%d, %d)\n", __FUNCTION__, rect->x, rect->y, rect->width, rect->height)); @@ -3389,9 +3409,12 @@ sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc, box_add_rect(&box, rect); } - trim_and_translate_box(&box, drawable, gc); + clipped = trim_and_translate_box(&box, drawable, gc); + if (box_empty(&box)) + return 0; + *out = box; - return box_empty(&box); + return 1 | clipped << 1; } static void @@ -3399,6 +3422,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) { struct sna *sna = to_sna_from_drawable(draw); RegionRec region; + unsigned flags; DBG(("%s(n=%d, PlaneMask: %lx (solid %d), solid fill: %d [style=%d, tileIsPixel=%d], alu=%d)\n", __FUNCTION__, n, gc->planemask, !!PM_IS_SOLID(draw, gc->planemask), @@ -3407,11 +3431,17 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) gc->fillStyle, gc->tileIsPixel, gc->alu)); - if (sna_poly_fill_rect_extents(draw, gc, n, rect, ®ion.extents)) { + flags = sna_poly_fill_rect_extents(draw, gc, n, rect, ®ion.extents); + if (flags == 0) { DBG(("%s, nothing to do\n", __FUNCTION__)); return; } + DBG(("%s: extents(%d, %d), (%d, %d), flags=%x\n", __FUNCTION__, + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2, + flags)); + if (FORCE_FALLBACK) goto fallback; @@ -3435,14 +3465,14 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) sna_poly_fill_rect_blt(draw, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, ®ion.extents), - gc, n, rect)) + gc, n, rect, flags & 2)) return; if (sna_drawable_use_cpu_bo(draw, ®ion.extents) && sna_poly_fill_rect_blt(draw, priv->cpu_bo, reduce_damage(draw, &priv->cpu_damage, ®ion.extents), - gc, n, rect)) + gc, n, rect, flags & 2)) return; } else if (gc->fillStyle == FillTiled) { struct sna_pixmap *priv = sna_pixmap_from_drawable(draw); diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index b317e9e..9ab7d8e 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1617,10 +1617,7 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, src_bo->tiling, dst_bo->tiling, src_bo->pitch, dst_bo->pitch)); - if (src_bo->tiling == I915_TILING_Y) - return FALSE; - - if (dst_bo->tiling == I915_TILING_Y) + if (src_bo->tiling == I915_TILING_Y || dst_bo->tiling == I915_TILING_Y) return FALSE; cmd = XY_SRC_COPY_BLT_CMD; @@ -1688,16 +1685,14 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, b[1] = br13; b[2] = ((box->y1 + dst_dy) << 16) | (box->x1 + dst_dx); b[3] = ((box->y2 + dst_dy) << 16) | (box->x2 + dst_dx); - b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, - dst_bo, + b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, dst_bo, I915_GEM_DOMAIN_RENDER << 16 | I915_GEM_DOMAIN_RENDER | KGEM_RELOC_FENCED, 0); b[5] = ((box->y1 + src_dy) << 16) | (box->x1 + src_dx); b[6] = src_pitch; - b[7] = kgem_add_reloc(kgem, kgem->nbatch + 7, - src_bo, + b[7] = kgem_add_reloc(kgem, kgem->nbatch + 7, src_bo, I915_GEM_DOMAIN_RENDER << 16 | KGEM_RELOC_FENCED, 0); @@ -1705,11 +1700,12 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, box++; } while (--nbox_this_time); - if (nbox) { - _kgem_submit(kgem); - _kgem_set_mode(kgem, KGEM_BLT); - } - } while (nbox); + if (!nbox) + break; + + _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } while (1); if (kgem->gen >= 60 && kgem_check_batch(kgem, 3)) { uint32_t *b = kgem->batch + kgem->nbatch; diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 7a97c37..e33fc34 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -246,9 +246,9 @@ _sna_damage_create_elt(struct sna_damage *damage, } static void -_sna_damage_create_elt_with_translation(struct sna_damage *damage, - const BoxRec *boxes, int count, - int16_t dx, int16_t dy) +_sna_damage_create_elt_from_boxes(struct sna_damage *damage, + const BoxRec *boxes, int count, + int16_t dx, int16_t dy) { struct sna_damage_elt *elt; int i; @@ -308,6 +308,69 @@ _sna_damage_create_elt_with_translation(struct sna_damage *damage, } } +static void +_sna_damage_create_elt_from_rectangles(struct sna_damage *damage, + const xRectangle *r, int count, + int16_t dx, int16_t dy) +{ + struct sna_damage_elt *elt; + int i; + + DBG((" %s: n=%d, prev=(remain %d)\n", __FUNCTION__, + damage->n, + damage->last_box ? damage->last_box->remain : 0)); + + if (damage->last_box) { + int n; + BoxRec *b; + + n = count; + if (n > damage->last_box->remain) + n = damage->last_box->remain; + + elt = damage->elts + damage->n-1; + b = elt->box + elt->n; + for (i = 0; i < n; i++) { + b[i].x1 = r[i].x + dx; + b[i].x2 = b[i].x1 + r[i].width; + b[i].y1 = r[i].y + dy; + b[i].y2 = b[i].y1 + r[i].height; + } + elt->n += n; + damage->last_box->remain -= n; + if (damage->last_box->remain == 0) + damage->last_box = NULL; + + count -=n; + r += n; + if (count == 0) + return; + } + + if (damage->n == damage->size) { + int newsize = damage->size * 2; + struct sna_damage_elt *newelts = realloc(damage->elts, + newsize*sizeof(*elt)); + if (newelts == NULL) + return; + + damage->elts = newelts; + damage->size = newsize; + } + + DBG((" %s(): new elt\n", __FUNCTION__)); + + elt = damage->elts + damage->n++; + elt->n = count; + elt->box = _sna_damage_create_boxes(damage, count); + for (i = 0; i < count; i++) { + elt->box[i].x1 = r[i].x + dx; + elt->box[i].x2 = elt->box[i].x1 + r[i].width; + elt->box[i].y1 = r[i].y + dy; + elt->box[i].y2 = elt->box[i].y1 + r[i].height; + } +} + static void free_list(struct list *head) { while (!list_is_empty(head)) { @@ -445,6 +508,17 @@ __sna_damage_add_boxes(struct sna_damage *damage, assert(n); + if (!damage) + damage = _sna_damage_create(); + else switch (damage->mode) { + case DAMAGE_ALL: + return damage; + case DAMAGE_SUBTRACT: + __sna_damage_reduce(damage); + case DAMAGE_ADD: + break; + } + extents = box[0]; for (i = 1; i < n; i++) { if (extents.x1 > box[i].x1) @@ -457,33 +531,23 @@ __sna_damage_add_boxes(struct sna_damage *damage, extents.y2 = box[i].y2; } - if (extents.y2 <= extents.y1 || extents.x2 <= extents.x1) - return damage; + assert(extents.y2 > extents.y1 && extents.x2 > extents.x1); extents.x1 += dx; extents.x2 += dx; extents.y1 += dy; extents.y2 += dy; - if (!damage) - damage = _sna_damage_create(); - else switch (damage->mode) { - case DAMAGE_ALL: - return damage; - case DAMAGE_SUBTRACT: - __sna_damage_reduce(damage); - case DAMAGE_ADD: - break; - } - if (pixman_region_contains_rectangle(&damage->region, &extents) == PIXMAN_REGION_IN) return damage; - _sna_damage_create_elt_with_translation(damage, box, n, dx, dy); + _sna_damage_create_elt_from_boxes(damage, box, n, dx, dy); - if (REGION_NUM_RECTS(&damage->region) <= 1) { - __sna_damage_reduce(damage); + if (REGION_NUM_RECTS(&damage->region) == 0) { + damage->region.extents = *damage->elts[0].box; + damage->region.data = NULL; + damage->extents = extents; } else { if (damage->extents.x1 > extents.x1) damage->extents.x1 = extents.x1; @@ -532,6 +596,102 @@ static void _pixman_region_union_box(RegionRec *region, const BoxRec *box) pixman_region_union(region, region, &u); } +inline static struct sna_damage * +__sna_damage_add_rectangles(struct sna_damage *damage, + const xRectangle *r, int n, + int16_t dx, int16_t dy) +{ + BoxRec extents; + int i; + + assert(n); + + extents.x1 = r[0].x; + extents.x2 = r[0].x + r[0].width; + extents.y1 = r[0].y; + extents.y2 = r[0].y + r[0].height; + for (i = 1; i < n; i++) { + if (extents.x1 > r[i].x) + extents.x1 = r[i].x; + if (extents.x2 < r[i].x + r[i].width) + extents.x2 = r[i].x + r[i].width; + if (extents.y1 > r[i].y) + extents.y1 = r[i].y; + if (extents.y2 < r[i].y + r[i].height) + extents.y2 = r[i].y + r[i].height; + } + + if (extents.y2 <= extents.y1 || extents.x2 <= extents.x1) + return damage; + + extents.x1 += dx; + extents.x2 += dx; + extents.y1 += dy; + extents.y2 += dy; + + if (!damage) + damage = _sna_damage_create(); + else switch (damage->mode) { + case DAMAGE_ALL: + return damage; + case DAMAGE_SUBTRACT: + __sna_damage_reduce(damage); + case DAMAGE_ADD: + break; + } + + if (pixman_region_contains_rectangle(&damage->region, + &extents) == PIXMAN_REGION_IN) + return damage; + + _sna_damage_create_elt_from_rectangles(damage, r, n, dx, dy); + + if (REGION_NUM_RECTS(&damage->region) == 0) { + damage->region.extents = *damage->elts[0].box; + damage->region.data = NULL; + damage->extents = extents; + } else { + if (damage->extents.x1 > extents.x1) + damage->extents.x1 = extents.x1; + if (damage->extents.x2 < extents.x2) + damage->extents.x2 = extents.x2; + + if (damage->extents.y1 > extents.y1) + damage->extents.y1 = extents.y1; + if (damage->extents.y2 < extents.y2) + damage->extents.y2 = extents.y2; + } + + return damage; +} + +#if DEBUG_DAMAGE +struct sna_damage *_sna_damage_add_rectangles(struct sna_damage *damage, + const xRectangle *r, int n, + int16_t dx, int16_t dy) +{ + char damage_buf[1000]; + + DBG(("%s(%s + [(%d, %d), (%d, %d) ... x %d])\n", __FUNCTION__, + _debug_describe_damage(damage_buf, sizeof(damage_buf), damage), + box->x1, box->y1, box->x2, box->y2, n)); + + damage = __sna_damage_add_rectangles(damage, r, n, dx, dy); + + ErrorF(" = %s\n", + _debug_describe_damage(damage_buf, sizeof(damage_buf), damage)); + + return damage; +} +#else +struct sna_damage *_sna_damage_add_rectangles(struct sna_damage *damage, + const xRectangle *r, int n, + int16_t dx, int16_t dy) +{ + return __sna_damage_add_rectangles(damage, r, n, dx, dy); +} +#endif + inline static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, const BoxRec *box) { diff --git a/src/sna/sna_damage.h b/src/sna/sna_damage.h index c402304..30058db 100644 --- a/src/sna/sna_damage.h +++ b/src/sna/sna_damage.h @@ -49,6 +49,17 @@ static inline void sna_damage_add_boxes(struct sna_damage **damage, *damage = _sna_damage_add_boxes(*damage, box, n, dx, dy); } +struct sna_damage *_sna_damage_add_rectangles(struct sna_damage *damage, + const xRectangle *r, int n, + int16_t dx, int16_t dy); +static inline void sna_damage_add_rectangles(struct sna_damage **damage, + const xRectangle *r, int n, + int16_t dx, int16_t dy) +{ + if (damage) + *damage = _sna_damage_add_rectangles(*damage, r, n, dx, dy); +} + struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, int width, int height); static inline bool sna_damage_is_all(struct sna_damage **damage, commit d6ae86a51cc49dbba579838edd24a94e8f68294c Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 03:06:20 2011 +0100 sna: Optimise reduce_damage() to handle all-damaged pixmaps Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 83106a2..c420f0a 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1960,6 +1960,11 @@ reduce_damage(DrawablePtr drawable, if (*damage == NULL) return damage; + if (sna_damage_is_all(damage, + pixmap->drawable.width, + pixmap->drawable.height)) + return NULL; + get_drawable_deltas(drawable, pixmap, &dx, &dy); r = *box; commit 5b945b85ee938688412df6adfea488766f4656af Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 02:45:50 2011 +0100 sna: Fast-path unclipped fill spans Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index e3d2779..83106a2 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1768,7 +1768,7 @@ sna_fill_spans_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, GCPtr gc, int n, DDXPointPtr pt, int *width, int sorted, - const BoxRec *extents) + const BoxRec *extents, bool clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); @@ -1799,7 +1799,36 @@ sna_fill_spans_blt(DrawablePtr drawable, } get_drawable_deltas(drawable, pixmap, &dx, &dy); - do { + if (!clipped) { + if (damage) { + do { + BoxRec box; + + box.x1 = pt->x + dx; + box.x2 = box.x1 + *width++; + box.y1 = pt->y + dy; + box.y2 = box.y1 + 1; + pt++; + + fill.box(sna, &fill, &box); + + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + } while (--n); + } else { + do { + BoxRec box; + + box.x1 = pt->x + dx; + box.x2 = box.x1 + *width++; + box.y1 = pt->y + dy; + box.y2 = box.y1 + 1; + pt++; + + fill.box(sna, &fill, &box); + } while (--n); + } + } else do { int16_t X1 = pt->x; int16_t y = pt->y; int16_t X2 = X1 + (int)*width; @@ -1877,15 +1906,16 @@ sna_fill_spans_blt(DrawablePtr drawable, return TRUE; } -static Bool +static unsigned sna_spans_extents(DrawablePtr drawable, GCPtr gc, int n, DDXPointPtr pt, int *width, BoxPtr out) { BoxRec box; + bool clipped = false; if (n == 0) - return true; + return 0; box.x1 = pt->x; box.x2 = box.x1 + *width; @@ -1909,10 +1939,13 @@ sna_spans_extents(DrawablePtr drawable, GCPtr gc, if (gc) { if (!gc->miTranslate) translate_box(&box, drawable); - clip_box(&box, gc); + clipped = clip_box(&box, gc); } + if (box_empty(&box)) + return 0; + *out = box; - return box_empty(&box); + return 1 | clipped << 1; } static struct sna_damage ** @@ -1960,11 +1993,14 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, { struct sna *sna = to_sna_from_drawable(drawable); RegionRec region; + unsigned flags; DBG(("%s(n=%d, pt[0]=(%d, %d)\n", __FUNCTION__, n, pt[0].x, pt[0].y)); - if (sna_spans_extents(drawable, gc, n, pt, width, ®ion.extents)) + + flags = sna_spans_extents(drawable, gc, n, pt, width, ®ion.extents); + if (flags == 0) return; DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__, @@ -1996,7 +2032,7 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), gc, n, pt, width, sorted, - ®ion.extents)) + ®ion.extents, flags & 2)) return; if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && @@ -2004,7 +2040,7 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, priv->cpu_bo, reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), gc, n, pt, width, sorted, - ®ion.extents)) + ®ion.extents, flags & 2)) return; } else if (gc->fillStyle == FillTiled) { xRectangle *rect; @@ -2049,7 +2085,7 @@ sna_set_spans(DrawablePtr drawable, GCPtr gc, char *src, { RegionRec region; - if (sna_spans_extents(drawable, gc, n, pt, width, ®ion.extents)) + if (sna_spans_extents(drawable, gc, n, pt, width, ®ion.extents) == 0) return; DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, @@ -3886,7 +3922,7 @@ sna_get_spans(DrawablePtr drawable, int wMax, { RegionRec region; - if (sna_spans_extents(drawable, NULL, n, pt, width, ®ion.extents)) + if (sna_spans_extents(drawable, NULL, n, pt, width, ®ion.extents) == 0) return; region.data = NULL; commit e9a193e9803bb69fc4a7e712f33a36ba395b3c89 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 02:20:22 2011 +0100 sna: Short-circuit GetWindowPixmap() to speed-up pixmap retrieval Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna.h b/src/sna/sna.h index e67e227..ec4429d 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -145,14 +145,23 @@ struct sna_pixmap { uint8_t gpu :1; }; -static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable) +extern DevPrivateKey sna_window_key; + +static inline PixmapPtr get_window_pixmap(WindowPtr window) { - ScreenPtr screen = drawable->pScreen; +#if 0 + return window->drawable.pScreen->GetWindowPixmap(window) +#else + return dixGetPrivate(&window->devPrivates, sna_window_key); +#endif +} +static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable) +{ if (drawable->type == DRAWABLE_PIXMAP) return (PixmapPtr)drawable; else - return screen->GetWindowPixmap((WindowPtr)drawable); + return get_window_pixmap((WindowPtr)drawable); } extern DevPrivateKeyRec sna_pixmap_index; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index d818d2c..e3d2779 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -62,6 +62,7 @@ #define USE_SPANS 0 DevPrivateKeyRec sna_pixmap_index; +DevPrivateKey sna_window_key; static inline void region_set(RegionRec *r, const BoxRec *b) { @@ -4157,6 +4158,8 @@ Bool sna_accel_init(ScreenPtr screen, struct sna *sna) if (!sna_glyphs_init(screen)) return FALSE; + sna_window_key = fbGetWinPrivateKey(); + list_init(&sna->dirty_pixmaps); list_init(&sna->deferred_free); commit 662402e41e5c7976002a71a7f961ca97c771b1f3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 02:11:19 2011 +0100 sna: Micro-optimise PolyLine blt Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 5de1b57..d818d2c 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2258,8 +2258,6 @@ sna_poly_line_blt(DrawablePtr drawable, get_drawable_deltas(drawable, pixmap, &dx, &dy); if (!clipped) { - int x, y; - dx += drawable->x; dy += drawable->y; @@ -2269,30 +2267,35 @@ sna_poly_line_blt(DrawablePtr drawable, while (--n) { BoxRec r; + DDXPointRec p; - x = pt->x; - y = pt->y; - pt++; + p = *pt++; if (mode == CoordModePrevious) { - x += last.x; - y += last.y; + p.x += last.x; + p.y += last.y; } else { - x += dx; - y += dy; + p.x += dx; + p.y += dy; } - if (last.x == x) { + if (last.x == p.x) { r.x1 = last.x; r.x2 = last.x + 1; + } else if (last.x < p.x) { + r.x1 = last.x; + r.x2 = p.x; } else { - r.x1 = last.x < x ? last.x : x; - r.x2 = last.x > x ? last.x : x; + r.x1 = p.x; + r.x2 = last.x; } - if (last.y == y) { + if (last.y == p.y) { r.y1 = last.y; r.y2 = last.y + 1; + } else if (last.y < p.y) { + r.y1 = last.y; + r.y2 = p.y; } else { - r.y1 = last.y < y ? last.y : y; - r.y2 = last.y > y ? last.y : y; + r.y1 = p.y; + r.y2 = last.y; } DBG(("%s: blt (%d, %d), (%d, %d)\n", __FUNCTION__, @@ -2303,8 +2306,7 @@ sna_poly_line_blt(DrawablePtr drawable, sna_damage_add_box(damage, &r); } - last.x = x; - last.y = y; + last = p; } } else { last.x = drawable->x; @@ -2314,36 +2316,40 @@ sna_poly_line_blt(DrawablePtr drawable, while (n--) { int nclip; BoxPtr box; - int x, y; + DDXPointRec p; - x = pt->x; - y = pt->y; - pt++; + p = *pt++; if (mode == CoordModePrevious) { - x += last.x; - y += last.y; + p.x += last.x; + p.y += last.y; } else { - x += drawable->x; - y += drawable->y; + p.x += drawable->x; + p.y += drawable->y; } if (!first) { for (nclip = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nclip--; box++) { BoxRec r; - if (last.x == x) { + if (last.x == p.x) { r.x1 = last.x; r.x2 = last.x + 1; + } else if (last.x < p.x) { + r.x1 = last.x; + r.x2 = p.x; } else { - r.x1 = last.x < x ? last.x : x; - r.x2 = last.x > x ? last.x : x; + r.x1 = p.x; + r.x2 = last.x; } - if (last.y == y) { + if (last.y == p.y) { r.y1 = last.y; r.y2 = last.y + 1; + } else if (last.y < p.y) { + r.y1 = last.y; + r.y2 = p.y; } else { - r.y1 = last.y < y ? last.y : y; - r.y2 = last.y > y ? last.y : y; + r.y1 = p.y; + r.y2 = last.y; } DBG(("%s: (%d, %d) -> (%d, %d) clipping line (%d, %d), (%d, %d) against box (%d, %d), (%d, %d)\n", __FUNCTION__, @@ -2367,8 +2373,7 @@ sna_poly_line_blt(DrawablePtr drawable, } } - last.x = x; - last.y = y; + last = p; first = 0; } } commit c2040fb8e62076d87f7a5b407505ee3f3482945e Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 02:00:44 2011 +0100 sna: Remove the memset(0) of the fill op The backends are all expected to initialise the state required. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 98360b8..7c72f41 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -2099,6 +2099,7 @@ gen2_render_fill(struct sna *sna, uint8_t alu, tmp->base.dst.height = dst->drawable.height; tmp->base.dst.format = sna_format_for_depth(dst->drawable.depth); tmp->base.dst.bo = dst_bo; + tmp->base.dst.x = tmp->base.dst.y = 0; tmp->base.floats_per_vertex = 2; tmp->base.floats_per_rect = 6; diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index f099fbf..0092f60 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2558,6 +2558,7 @@ gen4_render_fill(struct sna *sna, uint8_t alu, op->base.dst.height = dst->drawable.height; op->base.dst.format = sna_format_for_depth(dst->drawable.depth); op->base.dst.bo = dst_bo; + op->base.dst.x = op->base.dst.y = 0; op->base.src.bo = sna_render_get_solid(sna, @@ -2566,6 +2567,10 @@ gen4_render_fill(struct sna *sna, uint8_t alu, op->base.src.filter = SAMPLER_FILTER_NEAREST; op->base.src.repeat = SAMPLER_EXTEND_REPEAT; + op->base.mask.bo = NULL; + op->base.mask.filter = SAMPLER_FILTER_NEAREST; + op->base.mask.repeat = SAMPLER_EXTEND_NONE; + op->base.is_affine = TRUE; op->base.floats_per_vertex = 3; op->base.u.gen4.wm_kernel = WM_KERNEL; diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index db69f06..041e918 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -1219,8 +1219,11 @@ gen5_emit_invariant(struct sna *sna) { /* Ironlake errata workaround: Before disabling the clipper, * you have to MI_FLUSH to get the pipeline idle. + * + * However, the kernel flushes the pipeline between batches, + * so we should be safe.... + * OUT_BATCH(MI_FLUSH | MI_INHIBIT_RENDER_CACHE_FLUSH); */ - OUT_BATCH(MI_FLUSH | MI_INHIBIT_RENDER_CACHE_FLUSH); OUT_BATCH(GEN5_PIPELINE_SELECT | PIPELINE_SELECT_3D); gen5_emit_sip(sna); @@ -2573,6 +2576,7 @@ gen5_render_fill(struct sna *sna, uint8_t alu, op->base.dst.height = dst->drawable.height; op->base.dst.format = sna_format_for_depth(dst->drawable.depth); op->base.dst.bo = dst_bo; + op->base.dst.x = op->base.dst.y = 0; op->base.src.bo = sna_render_get_solid(sna, @@ -2581,6 +2585,10 @@ gen5_render_fill(struct sna *sna, uint8_t alu, op->base.src.filter = SAMPLER_FILTER_NEAREST; op->base.src.repeat = SAMPLER_EXTEND_REPEAT; + op->base.mask.bo = NULL; + op->base.mask.filter = SAMPLER_FILTER_NEAREST; + op->base.mask.repeat = SAMPLER_EXTEND_NONE; + op->base.is_affine = TRUE; op->base.floats_per_vertex = 3; op->base.u.gen5.wm_kernel = WM_KERNEL; diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index fc2fc47..838819d 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2793,6 +2793,7 @@ gen6_render_fill(struct sna *sna, uint8_t alu, op->base.dst.height = dst->drawable.height; op->base.dst.format = sna_format_for_depth(dst->drawable.depth); op->base.dst.bo = dst_bo; + op->base.dst.x = op->base.dst.y = 0; op->base.src.bo = sna_render_get_solid(sna, @@ -2801,6 +2802,10 @@ gen6_render_fill(struct sna *sna, uint8_t alu, op->base.src.filter = SAMPLER_FILTER_NEAREST; op->base.src.repeat = SAMPLER_EXTEND_REPEAT; + op->base.mask.bo = NULL; + op->base.mask.filter = SAMPLER_FILTER_NEAREST; + op->base.mask.repeat = SAMPLER_EXTEND_NONE; + op->base.is_affine = TRUE; op->base.floats_per_vertex = 3; op->base.floats_per_rect = 9; diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index ae77320..ccc0037 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2944,6 +2944,7 @@ gen7_render_fill(struct sna *sna, uint8_t alu, op->base.dst.height = dst->drawable.height; op->base.dst.format = sna_format_for_depth(dst->drawable.depth); op->base.dst.bo = dst_bo; + op->base.dst.x = op->base.dst.y = 0; op->base.src.bo = sna_render_get_solid(sna, @@ -2952,6 +2953,10 @@ gen7_render_fill(struct sna *sna, uint8_t alu, op->base.src.filter = SAMPLER_FILTER_NEAREST; op->base.src.repeat = SAMPLER_EXTEND_REPEAT; + op->base.mask.bo = NULL; + op->base.mask.filter = SAMPLER_FILTER_NEAREST; + op->base.mask.repeat = SAMPLER_EXTEND_NONE; + op->base.is_affine = TRUE; op->base.floats_per_vertex = 3; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4b59b55..5de1b57 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1740,7 +1740,7 @@ box_intersect(BoxPtr a, const BoxRec *b) return a->x1 < a->x2 && a->y1 < a->y2; } -static Bool +inline static bool sna_fill_init_blt(struct sna_fill_op *fill, struct sna *sna, PixmapPtr pixmap, @@ -1748,7 +1748,6 @@ sna_fill_init_blt(struct sna_fill_op *fill, uint8_t alu, uint32_t pixel) { - memset(fill, 0, sizeof(*fill)); return sna->render.fill(sna, alu, pixmap, bo, pixel, fill); } commit 7e7759db4c1dbf8b782fab9b9ca95cfa1db6cf59 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 01:41:56 2011 +0100 sna: Pass a BoxRec to the fill op For many of the core drawing routines, passing a BoxRec for the fill is more convenient since they already have one generated by the clip intersection. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 6b30069..98360b8 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -2038,6 +2038,24 @@ gen2_render_fill_blt(struct sna *sna, VERTEX(y); } +fastcall static void +gen2_render_fill_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) +{ + if (!gen2_get_rectangles(sna, &op->base, 1)) { + gen2_emit_fill_state(sna, &op->base); + gen2_get_rectangles(sna, &op->base, 1); + } + + VERTEX(box->x2); + VERTEX(box->y2); + VERTEX(box->x1); + VERTEX(box->y2); + VERTEX(box->x1); + VERTEX(box->y1); +} + static void gen2_render_fill_done(struct sna *sna, const struct sna_fill_op *op) { @@ -2096,6 +2114,7 @@ gen2_render_fill(struct sna *sna, uint8_t alu, } tmp->blt = gen2_render_fill_blt; + tmp->box = gen2_render_fill_box; tmp->done = gen2_render_fill_done; gen2_emit_fill_state(sna, &tmp->base); diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 90797d7..6d91f32 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3793,6 +3793,24 @@ gen3_render_fill_blt(struct sna *sna, OUT_VERTEX(y); } +fastcall static void +gen3_render_fill_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) +{ + if (!gen3_get_rectangles(sna, &op->base, 1)) { + gen3_emit_composite_state(sna, &op->base); + gen3_get_rectangles(sna, &op->base, 1); + } + + OUT_VERTEX(box->x2); + OUT_VERTEX(box->y2); + OUT_VERTEX(box->x1); + OUT_VERTEX(box->y2); + OUT_VERTEX(box->x1); + OUT_VERTEX(box->y1); +} + static void gen3_render_fill_done(struct sna *sna, const struct sna_fill_op *op) { @@ -3852,6 +3870,7 @@ gen3_render_fill(struct sna *sna, uint8_t alu, kgem_submit(&sna->kgem); tmp->blt = gen3_render_fill_blt; + tmp->box = gen3_render_fill_box; tmp->done = gen3_render_fill_done; gen3_emit_composite_state(sna, &tmp->base); diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 2c988ff..f099fbf 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2503,6 +2503,16 @@ gen4_render_fill_blt(struct sna *sna, const struct sna_fill_op *op, gen4_render_fill_rectangle(sna, &op->base, x, y, w, h); } +fastcall static void +gen4_render_fill_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) +{ + gen4_render_fill_rectangle(sna, &op->base, + box->x1, box->y1, + box->x2-box->x1, box->y2-box->y1); +} + static void gen4_render_fill_done(struct sna *sna, const struct sna_fill_op *op) { @@ -2568,6 +2578,7 @@ gen4_render_fill(struct sna *sna, uint8_t alu, gen4_align_vertex(sna, &op->base); op->blt = gen4_render_fill_blt; + op->box = gen4_render_fill_box; op->done = gen4_render_fill_done; return TRUE; } diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index d246d01..db69f06 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2504,6 +2504,32 @@ gen5_render_fill_blt(struct sna *sna, OUT_VERTEX_F(0); } +fastcall static void +gen5_render_fill_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) +{ + DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2)); + + if (!gen5_get_rectangles(sna, &op->base, 1)) { + gen5_fill_bind_surfaces(sna, &op->base); + gen5_get_rectangles(sna, &op->base, 1); + } + + OUT_VERTEX(box->x2, box->y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); +} + static void gen5_render_fill_done(struct sna *sna, const struct sna_fill_op *op) @@ -2567,6 +2593,7 @@ gen5_render_fill(struct sna *sna, uint8_t alu, gen5_align_vertex(sna, &op->base); op->blt = gen5_render_fill_blt; + op->box = gen5_render_fill_box; op->done = gen5_render_fill_done; return TRUE; } diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index badade0..fc2fc47 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2720,6 +2720,32 @@ gen6_render_fill_blt(struct sna *sna, OUT_VERTEX_F(0); } +fastcall static void +gen6_render_fill_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) +{ + DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2)); + + if (!gen6_get_rectangles(sna, &op->base, 1)) { + gen6_emit_fill_state(sna, &op->base); + gen6_get_rectangles(sna, &op->base, 1); + } + + OUT_VERTEX(box->x2, box->y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); +} + static void gen6_render_fill_done(struct sna *sna, const struct sna_fill_op *op) { @@ -2791,6 +2817,7 @@ gen6_render_fill(struct sna *sna, uint8_t alu, gen6_align_vertex(sna, &op->base); op->blt = gen6_render_fill_blt; + op->box = gen6_render_fill_box; op->done = gen6_render_fill_done; return TRUE; } diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 16c1462..ae77320 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2870,6 +2870,32 @@ gen7_render_fill_blt(struct sna *sna, OUT_VERTEX_F(0); } +fastcall static void +gen7_render_fill_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) +{ + DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2)); + + if (!gen7_get_rectangles(sna, &op->base, 1)) { + gen7_emit_fill_state(sna, &op->base); + gen7_get_rectangles(sna, &op->base, 1); + } + + OUT_VERTEX(box->x2, box->y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); +} + static void gen7_render_fill_done(struct sna *sna, const struct sna_fill_op *op) { @@ -2941,6 +2967,7 @@ gen7_render_fill(struct sna *sna, uint8_t alu, gen7_align_vertex(sna, &op->base); op->blt = gen7_render_fill_blt; + op->box = gen7_render_fill_box; op->done = gen7_render_fill_done; return TRUE; } diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 648f928..4b59b55 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2298,9 +2298,7 @@ sna_poly_line_blt(DrawablePtr drawable, DBG(("%s: blt (%d, %d), (%d, %d)\n", __FUNCTION__, r.x1, r.y1, r.x2, r.y2)); - fill.blt(sna, &fill, - r.x1, r.y1, - r.x2-r.x1, r.y2-r.y1); + fill.box(sna, &fill, &r); if (damage) { assert_pixmap_contains_box(pixmap, &r); sna_damage_add_box(damage, &r); @@ -2361,9 +2359,7 @@ sna_poly_line_blt(DrawablePtr drawable, DBG(("%s: blt (%d, %d), (%d, %d)\n", __FUNCTION__, r.x1, r.y1, r.x2, r.y2)); - fill.blt(sna, &fill, - r.x1, r.y1, - r.x2-r.x1, r.y2-r.y1); + fill.box(sna, &fill, &r); if (damage) { assert_pixmap_contains_box(pixmap, &r); sna_damage_add_box(damage, &r); @@ -2681,9 +2677,7 @@ sna_poly_segment_blt(DrawablePtr drawable, r.x2 += dx; r.y1 += dy; r.y2 += dy; - fill.blt(sna, &fill, - r.x1, r.y1, - r.x2-r.x1, r.y2-r.y1); + fill.box(sna, &fill, &r); if (damage) { assert_pixmap_contains_box(pixmap, &r); sna_damage_add_box(damage, &r); @@ -3047,9 +3041,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, r.x2 += dx; r.y1 += dy; r.y2 += dy; - fill.blt(sna, &fill, - r.x1, r.y1, - r.x2-r.x1, r.y2-r.y1); + fill.box(sna, &fill, &r); if (damage) { assert_pixmap_contains_box(pixmap, &r); sna_damage_add_box(damage, &r); @@ -3078,9 +3070,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, box->x2 += dx; box->y1 += dy; box->y2 += dy; - fill.blt(sna, &fill, - box->x1, box->y1, - box->x2-box->x1, box->y2-box->y1); + fill.box(sna, &fill, box); if (damage) { assert_pixmap_contains_box(pixmap, box); sna_damage_add_box(damage, box); @@ -3155,9 +3145,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, r.x2 += dx; r.y1 += dy; r.y2 += dy; - fill.blt(sna, &fill, - r.x1, r.y1, - r.x2-r.x1, r.y2-r.y1); + fill.box(sna, &fill, &r); if (damage) { assert_pixmap_contains_box(pixmap, &r); sna_damage_add_box(damage, &r); @@ -3186,10 +3174,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, box->x2 += dx; box->y1 += dy; box->y2 += dy; - fill.blt(sna, &fill, - box->x1, box->y1, - box->x2-box->x1, - box->y2-box->y1); + fill.box(sna, &fill, box); if (damage) { assert_pixmap_contains_box(pixmap, box); sna_damage_add_box(damage, box); diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 2343838..b317e9e 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1272,6 +1272,32 @@ static void sna_blt_fill_op_blt(struct sna *sna, sna_blt_fill_one(sna, &op->base.u.blt, x, y, width, height); } +fastcall static void sna_blt_fill_op_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) +{ + struct kgem *kgem = &sna->kgem; + uint32_t *b; + + DBG(("%s: (%d, %d), (%d, %d): %08x\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, + op->base.u.blt.pixel)); + + assert(box->x1 >= 0); + assert(box->y1 >= 0); + assert(box->y2 * op->base.u.blt.bo[0]->pitch <= op->base.u.blt.bo[0]->size); + + if (!kgem_check_batch(kgem, 3)) + sna_blt_fill_begin(sna, &op->base.u.blt); + + b = kgem->batch + kgem->nbatch; + kgem->nbatch += 3; + + b[0] = op->base.u.blt.cmd; + b[1] = box->y1 << 16 | box->x1; + b[2] = box->y2 << 16 | box->x2; +} + static void sna_blt_fill_op_done(struct sna *sna, const struct sna_fill_op *fill) { @@ -1300,6 +1326,7 @@ bool sna_blt_fill(struct sna *sna, uint8_t alu, return FALSE; fill->blt = sna_blt_fill_op_blt; + fill->box = sna_blt_fill_op_box; fill->done = sna_blt_fill_op_done; return TRUE; } diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 0f174f6..d30c0b6 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -157,6 +157,9 @@ struct sna_fill_op { void (*blt)(struct sna *sna, const struct sna_fill_op *op, int16_t x, int16_t y, int16_t w, int16_t h); + fastcall void (*box)(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box); void (*done)(struct sna *sna, const struct sna_fill_op *op); }; commit 98bca2dbb9c33c548b1d9789ddb633ae0389c8f1 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 01:07:52 2011 +0100 sna: Check whether we can blt whilst determining the PolyLine extents Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 33b079c..648f928 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2237,33 +2237,6 @@ fallback: } static Bool -sna_poly_line_can_blt(int mode, int n, DDXPointPtr pt) -{ - int i; - - if (mode == CoordModePrevious) { - for (i = 1; i < n; i++) { - if (pt[i].x != 0 && pt[i].y != 0) { - DBG(("%s: diagonal segment[%d]=(%d,%d)\n", - __FUNCTION__, i, pt[i].x, pt[i].y)); - return FALSE; - } - } - } else { - for (i = 1; i < n; i++) { - if (pt[i].x != pt[i-1].x && pt[i].y != pt[i-1].y) { - DBG(("%s: diagonal segment[%d]=(%d,%d)->(%d,%d)\n", - __FUNCTION__, i, - pt[i-1].x, pt[i-1].y, pt[i].x, pt[i].y)); - return FALSE; - } - } - } - - return TRUE; -} - -static Bool sna_poly_line_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, @@ -2408,16 +2381,17 @@ sna_poly_line_blt(DrawablePtr drawable, return TRUE; } -static Bool +static unsigned sna_poly_line_extents(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt, - BoxPtr out, bool *clipped) + BoxPtr out) { BoxRec box; int extra = gc->lineWidth >> 1; + bool clip, blt = true; if (n == 0) - return true; + return 0; if (n > 1) { if (gc->joinStyle == JoinMiter) @@ -2435,11 +2409,20 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc, pt++; x += pt->x; y += pt->y; + if (blt) + blt &= pt->x == 0 || pt->y == 0; box_add_pt(&box, x, y); } } else { + int x = box.x1; + int y = box.y1; while (--n) { pt++; + if (blt) { + blt &= pt->x == x || pt->y == y; + x = pt->x; + y = pt->y; + } box_add_pt(&box, pt->x, pt->y); } } @@ -2453,9 +2436,12 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc, box.y2 += extra; } - *clipped = trim_and_translate_box(&box, drawable, gc); + clip = trim_and_translate_box(&box, drawable, gc); + if (box_empty(&box)) + return 0; + *out = box; - return box_empty(&box); + return 1 | blt << 1 | clip << 2; } static void @@ -2464,13 +2450,14 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, { struct sna *sna = to_sna_from_drawable(drawable); RegionRec region; - bool clipped; + unsigned flags; DBG(("%s(mode=%d, n=%d, pt[0]=(%d, %d), lineWidth=%d\n", __FUNCTION__, mode, n, pt[0].x, pt[0].y, gc->lineWidth)); - if (sna_poly_line_extents(drawable, gc, mode, n, pt, - ®ion.extents, &clipped)) + flags = sna_poly_line_extents(drawable, gc, mode, n, pt, + ®ion.extents); + if (flags == 0) return; DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__, @@ -2491,12 +2478,12 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, gc->lineStyle, gc->lineStyle == LineSolid, gc->lineWidth, gc->planemask, PM_IS_SOLID(drawable, gc->planemask), - sna_poly_line_can_blt(mode, n, pt))); + flags & 2)); if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid && (gc->lineWidth == 0 || gc->lineWidth == 1) && PM_IS_SOLID(drawable, gc->planemask) && - sna_poly_line_can_blt(mode, n, pt)) { + flags & 2) { struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable); DBG(("%s: trying solid fill [%08lx]\n", @@ -2506,14 +2493,14 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, sna_poly_line_blt(drawable, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), - gc, mode, n, pt, clipped)) + gc, mode, n, pt, flags & 4)) return; if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_line_blt(drawable, priv->cpu_bo, reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), - gc, mode, n, pt, clipped)) + gc, mode, n, pt, flags & 4)) return; } commit 91f49549750aac99d38ae8f3a132c955a2c8d8f5 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 00:42:43 2011 +0100 sna: Speed-up blitting of unclipped lines Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 8153d34..33b079c 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -916,37 +916,45 @@ static void sna_gc_move_to_cpu(GCPtr gc) sna_drawable_move_to_cpu(&gc->tile.pixmap->drawable, false); } -static inline void trim_box(BoxPtr box, DrawablePtr d) +static inline bool trim_box(BoxPtr box, DrawablePtr d) { + bool clipped = false; + if (box->x1 < 0) - box->x1 = 0; + box->x1 = 0, clipped = true; if (box->x2 > d->width) - box->x2 = d->width; + box->x2 = d->width, clipped = true; if (box->y1 < 0) - box->y1 = 0; + box->y1 = 0, clipped = true; if (box->y2 > d->height) - box->y2 = d->height; + box->y2 = d->height, clipped = true; + + return clipped; } -static inline void clip_box(BoxPtr box, GCPtr gc) +static inline bool clip_box(BoxPtr box, GCPtr gc) { const BoxRec *clip; + bool clipped; if (!gc->pCompositeClip) - return; + return false; clip = &gc->pCompositeClip->extents; + clipped = gc->pCompositeClip->data != NULL; if (box->x1 < clip->x1) - box->x1 = clip->x1; + box->x1 = clip->x1, clipped = true; if (box->x2 > clip->x2) - box->x2 = clip->x2; + box->x2 = clip->x2, clipped = true; if (box->y1 < clip->y1) - box->y1 = clip->y1; + box->y1 = clip->y1, clipped = true; if (box->y2 > clip->y2) - box->y2 = clip->y2; + box->y2 = clip->y2, clipped = true; + + return clipped; } static inline void translate_box(BoxPtr box, DrawablePtr d) @@ -958,11 +966,12 @@ static inline void translate_box(BoxPtr box, DrawablePtr d) box->y2 += d->y; } -static inline void trim_and_translate_box(BoxPtr box, DrawablePtr d, GCPtr gc) +static inline bool trim_and_translate_box(BoxPtr box, DrawablePtr d, GCPtr gc) { - trim_box(box, d); + bool clipped = trim_box(box, d); translate_box(box, d); - clip_box(box, gc); + clipped |= clip_box(box, gc); + return clipped; } static inline void box_add_pt(BoxPtr box, int16_t x, int16_t y) @@ -2258,7 +2267,8 @@ static Bool sna_poly_line_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, - GCPtr gc, int mode, int n, DDXPointPtr pt) + GCPtr gc, int mode, int n, DDXPointPtr pt, + bool clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); @@ -2275,71 +2285,124 @@ sna_poly_line_blt(DrawablePtr drawable, get_drawable_deltas(drawable, pixmap, &dx, &dy); - last.x = drawable->x; - last.y = drawable->y; - first = 1; - - while (n--) { - int nclip; - BoxPtr box; + if (!clipped) { int x, y; - x = pt->x; - y = pt->y; + dx += drawable->x; + dy += drawable->y; + + last.x = pt->x + dx; + last.y = pt->y + dy; pt++; - if (mode == CoordModePrevious) { - x += last.x; - y += last.y; - } else { - x += drawable->x; - y += drawable->y; + + while (--n) { + BoxRec r; + + x = pt->x; + y = pt->y; + pt++; + if (mode == CoordModePrevious) { + x += last.x; + y += last.y; + } else { + x += dx; + y += dy; + } + if (last.x == x) { + r.x1 = last.x; + r.x2 = last.x + 1; + } else { + r.x1 = last.x < x ? last.x : x; + r.x2 = last.x > x ? last.x : x; + } + if (last.y == y) { + r.y1 = last.y; + r.y2 = last.y + 1; + } else { + r.y1 = last.y < y ? last.y : y; + r.y2 = last.y > y ? last.y : y; + } + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + r.x1, r.y1, r.x2, r.y2)); + fill.blt(sna, &fill, + r.x1, r.y1, + r.x2-r.x1, r.y2-r.y1); + if (damage) { + assert_pixmap_contains_box(pixmap, &r); + sna_damage_add_box(damage, &r); + } + + last.x = x; + last.y = y; } + } else { + last.x = drawable->x; + last.y = drawable->y; + first = 1; - if (!first) { - for (nclip = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nclip--; box++) { - BoxRec r; + while (n--) { + int nclip; + BoxPtr box; + int x, y; - if (last.x == x) { - r.x1 = last.x; - r.x2 = last.x + 1; - } else { - r.x1 = last.x < x ? last.x : x; - r.x2 = last.x > x ? last.x : x; - } - if (last.y == y) { - r.y1 = last.y; - r.y2 = last.y + 1; - } else { - r.y1 = last.y < y ? last.y : y; - r.y2 = last.y > y ? last.y : y; - } - DBG(("%s: (%d, %d) -> (%d, %d) clipping line (%d, %d), (%d, %d) against box (%d, %d), (%d, %d)\n", - __FUNCTION__, - last.x, last.y, x, y, - r.x1, r.y1, r.x2, r.y2, - box->x1, box->y1, box->x2, box->y2)); - if (box_intersect(&r, box)) { - r.x1 += dx; - r.x2 += dx; - r.y1 += dy; - r.y2 += dy; - DBG(("%s: blt (%d, %d), (%d, %d)\n", + x = pt->x; + y = pt->y; + pt++; + if (mode == CoordModePrevious) { + x += last.x; + y += last.y; + } else { + x += drawable->x; + y += drawable->y; + } + + if (!first) { + for (nclip = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nclip--; box++) { + BoxRec r; + + if (last.x == x) { + r.x1 = last.x; + r.x2 = last.x + 1; + } else { + r.x1 = last.x < x ? last.x : x; + r.x2 = last.x > x ? last.x : x; + } + if (last.y == y) { + r.y1 = last.y; + r.y2 = last.y + 1; + } else { + r.y1 = last.y < y ? last.y : y; + r.y2 = last.y > y ? last.y : y; + } + DBG(("%s: (%d, %d) -> (%d, %d) clipping line (%d, %d), (%d, %d) against box (%d, %d), (%d, %d)\n", __FUNCTION__, - r.x1, r.y1, r.x2, r.y2)); - fill.blt(sna, &fill, - r.x1, r.y1, - r.x2-r.x1, r.y2-r.y1); - if (damage) { - assert_pixmap_contains_box(pixmap, &r); - sna_damage_add_box(damage, &r); + last.x, last.y, x, y, + r.x1, r.y1, r.x2, r.y2, + box->x1, box->y1, box->x2, box->y2)); + if (box_intersect(&r, box)) { + r.x1 += dx; + r.x2 += dx; + r.y1 += dy; + r.y2 += dy; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + r.x1, r.y1, r.x2, r.y2)); + fill.blt(sna, &fill, + r.x1, r.y1, + r.x2-r.x1, r.y2-r.y1); + if (damage) { + assert_pixmap_contains_box(pixmap, &r); + sna_damage_add_box(damage, &r); + } } } } - } - last.x = x; - last.y = y; - first = 0; + last.x = x; + last.y = y; + first = 0; + } } fill.done(sna, &fill); return TRUE; @@ -2348,7 +2411,7 @@ sna_poly_line_blt(DrawablePtr drawable, static Bool sna_poly_line_extents(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt, - BoxPtr out) + BoxPtr out, bool *clipped) { BoxRec box; int extra = gc->lineWidth >> 1; @@ -2390,7 +2453,7 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc, box.y2 += extra; } - trim_and_translate_box(&box, drawable, gc); + *clipped = trim_and_translate_box(&box, drawable, gc); *out = box; return box_empty(&box); } @@ -2401,11 +2464,13 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, { struct sna *sna = to_sna_from_drawable(drawable); RegionRec region; + bool clipped; DBG(("%s(mode=%d, n=%d, pt[0]=(%d, %d), lineWidth=%d\n", __FUNCTION__, mode, n, pt[0].x, pt[0].y, gc->lineWidth)); - if (sna_poly_line_extents(drawable, gc, mode, n, pt, ®ion.extents)) + if (sna_poly_line_extents(drawable, gc, mode, n, pt, + ®ion.extents, &clipped)) return; DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__, @@ -2440,15 +2505,15 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_poly_line_blt(drawable, priv->gpu_bo, - priv->gpu_only ? NULL : &priv->gpu_damage, - gc, mode, n, pt)) + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), + gc, mode, n, pt, clipped)) return; if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_line_blt(drawable, priv->cpu_bo, - &priv->cpu_damage, - gc, mode, n, pt)) + reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), + gc, mode, n, pt, clipped)) return; } commit 06d7574d7da047a6314be5af27f4ac47ccd5a350 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 20 21:38:30 2011 +0100 sna/damage: Stash the last freed damage for quick reallocation Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index 0194f5c..7a97c37 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -48,6 +48,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * cheapy discard no-ops. */ +static struct sna_damage *__freed_damage; + #if DEBUG_DAMAGE #undef DBG #define DBG(x) ErrorF x @@ -146,7 +148,11 @@ static struct sna_damage *_sna_damage_create(void) { struct sna_damage *damage; - damage = malloc(sizeof(*damage)); + if (__freed_damage) { + damage = __freed_damage; + __freed_damage = NULL; + } else + damage = malloc(sizeof(*damage)); damage->n = 0; damage->size = 16; damage->elts = malloc(sizeof(*damage->elts) * damage->size); @@ -958,7 +964,10 @@ void __sna_damage_destroy(struct sna_damage *damage) free_list(&damage->boxes); pixman_region_fini(&damage->region); - free(damage); + if (__freed_damage == NULL) + __freed_damage = damage; + else + free(damage); } #if DEBUG_DAMAGE && TEST_DAMAGE commit 1471ef82b595a207dc8873c45176ec31f277a43f Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 20 21:32:14 2011 +0100 sna/damage: Only track the mode globally As damage accumulation is handled modally, we do not need to track the mode per elt and so attempt to simplify the code. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c index b5d0084..0194f5c 100644 --- a/src/sna/sna_damage.c +++ b/src/sna/sna_damage.c @@ -31,6 +31,23 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sna.h" #include "sna_damage.h" +/* + * sna_damage is a batching layer on top of the regular pixman_region_t. + * It is required as the ever-growing accumulation of invidual small + * damage regions is an O(n^2) operation. Instead the accumulation of a + * batch can be done in closer to O(n.lgn), and so prevents abysmal + * performance in x11perf -copywinwin10. + * + * As with the core of SNA, damage is handled modally. That is, it + * accumulates whilst rendering and then subtracts during migration of the + * pixmap from GPU to CPU or vice versa. As such we can track the current + * mode globally and when that mode switches perform the update of the region + * in a single operation. + * + * Furthermore, we can track whether the whole pixmap is damaged and so + * cheapy discard no-ops. + */ + #if DEBUG_DAMAGE #undef DBG #define DBG(x) ErrorF x @@ -121,10 +138,6 @@ struct sna_damage_box { }; struct sna_damage_elt { - enum mode { - ADD, - SUBTRACT, - } mode; BoxPtr box; uint16_t n; }; @@ -134,13 +147,12 @@ static struct sna_damage *_sna_damage_create(void) struct sna_damage *damage; damage = malloc(sizeof(*damage)); - damage->all = 0; damage->n = 0; damage->size = 16; damage->elts = malloc(sizeof(*damage->elts) * damage->size); list_init(&damage->boxes); damage->last_box = NULL; - damage->mode = ADD; + damage->mode = DAMAGE_ADD; pixman_region_init(&damage->region); damage->extents.x1 = damage->extents.y1 = MAXSHORT; damage->extents.x2 = damage->extents.y2 = MINSHORT; @@ -180,18 +192,15 @@ static BoxPtr _sna_damage_create_boxes(struct sna_damage *damage, static void _sna_damage_create_elt(struct sna_damage *damage, - enum mode mode, const BoxRec *boxes, int count) { struct sna_damage_elt *elt; - DBG((" %s(%s): n=%d, prev=(%s, remain %d)\n", __FUNCTION__, - mode == ADD ? "add" : "subtract", + DBG((" %s: n=%d, prev=(remain %d)\n", __FUNCTION__, damage->n, - damage->n ? damage->elts[damage->n-1].mode == ADD ? "add" : "subtract" : "none", damage->last_box ? damage->last_box->remain : 0)); - if (damage->last_box && damage->elts[damage->n-1].mode == mode) { + if (damage->last_box) { int n; n = count; @@ -225,7 +234,6 @@ _sna_damage_create_elt(struct sna_damage *damage, DBG((" %s(): new elt\n", __FUNCTION__)); elt = damage->elts + damage->n++; - elt->mode = mode; elt->n = count; elt->box = memcpy(_sna_damage_create_boxes(damage, count), boxes, count * sizeof(BoxRec)); @@ -233,20 +241,17 @@ _sna_damage_create_elt(struct sna_damage *damage, static void _sna_damage_create_elt_with_translation(struct sna_damage *damage, - enum mode mode, const BoxRec *boxes, int count, int16_t dx, int16_t dy) { struct sna_damage_elt *elt; int i; - DBG((" %s(%s): n=%d, prev=(%s, remain %d)\n", __FUNCTION__, - mode == ADD ? "add" : "subtract", + DBG((" %s: n=%d, prev=(remain %d)\n", __FUNCTION__, damage->n, - damage->n ? damage->elts[damage->n-1].mode == ADD ? "add" : "subtract" : "none", damage->last_box ? damage->last_box->remain : 0)); - if (damage->last_box && damage->elts[damage->n-1].mode == mode) { + if (damage->last_box) { int n; BoxRec *b; @@ -287,7 +292,6 @@ _sna_damage_create_elt_with_translation(struct sna_damage *damage, DBG((" %s(): new elt\n", __FUNCTION__)); elt = damage->elts + damage->n++; - elt->mode = mode; elt->n = count; elt->box = _sna_damage_create_boxes(damage, count); for (i = 0; i < count; i++) { @@ -309,64 +313,35 @@ static void free_list(struct list *head) static void __sna_damage_reduce(struct sna_damage *damage) { - int n, m, j; - int nboxes; + int n, nboxes; BoxPtr boxes; pixman_region16_t tmp, *region = &damage->region; - assert(!damage->all); + assert(damage->mode != DAMAGE_ALL); + assert(damage->n); DBG((" reduce: before damage.n=%d region.n=%d\n", damage->n, REGION_NUM_RECTS(region))); - m = 0; nboxes = damage->elts[0].n; - boxes = damage->elts[0].box; - for (n = 1; n < damage->n; n++) { - if (damage->elts[n].mode != damage->elts[m].mode) { - if (!boxes) { - boxes = malloc(sizeof(BoxRec)*nboxes); - nboxes = 0; - for (j = m; j < n; j++) { - memcpy(boxes+nboxes, - damage->elts[j].box, - damage->elts[j].n*sizeof(BoxRec)); - nboxes += damage->elts[j].n; - } - } - - pixman_region_init_rects(&tmp, boxes, nboxes); - if (damage->elts[m].mode == ADD) - pixman_region_union(region, region, &tmp); - else - pixman_region_subtract(region, region, &tmp); - pixman_region_fini(&tmp); - - if (boxes != damage->elts[m].box) - free(boxes); - - m = n; - boxes = damage->elts[n].box; - nboxes = damage->elts[n].n; - } else { - boxes = NULL; + if (damage->n == 1) { + boxes = damage->elts[0].box; + } else { + for (n = 1; n < damage->n; n++) nboxes += damage->elts[n].n; - } - } - if (!boxes) { boxes = malloc(sizeof(BoxRec)*nboxes); nboxes = 0; - for (j = m; j < n; j++) { + for (n = 0; n < damage->n; n++) { memcpy(boxes+nboxes, - damage->elts[j].box, - damage->elts[j].n*sizeof(BoxRec)); - nboxes += damage->elts[j].n; + damage->elts[n].box, + damage->elts[n].n*sizeof(BoxRec)); + nboxes += damage->elts[n].n; } } pixman_region_init_rects(&tmp, boxes, nboxes); - if (damage->elts[m].mode == ADD) + if (damage->mode == DAMAGE_ADD) pixman_region_union(region, region, &tmp); else pixman_region_subtract(region, region, &tmp); @@ -374,13 +349,13 @@ static void __sna_damage_reduce(struct sna_damage *damage) damage->extents = region->extents; - if (boxes != damage->elts[m].box) + if (boxes != damage->elts[0].box) free(boxes); damage->n = 0; + damage->mode = DAMAGE_ADD; free_list(&damage->boxes); damage->last_box = NULL; - damage->mode = ADD; DBG((" reduce: after region.n=%d\n", REGION_NUM_RECTS(region))); } @@ -393,13 +368,14 @@ inline static struct sna_damage *__sna_damage_add(struct sna_damage *damage, if (!damage) damage = _sna_damage_create(); - - if (damage->all) + else switch (damage->mode) { + case DAMAGE_ALL: return damage; - - if (damage->mode == SUBTRACT) + case DAMAGE_SUBTRACT: __sna_damage_reduce(damage); - damage->mode = ADD; + case DAMAGE_ADD: + break; + } if (REGION_NUM_RECTS(&damage->region) <= 1) { pixman_region_union(&damage->region, &damage->region, region); @@ -411,9 +387,8 @@ inline static struct sna_damage *__sna_damage_add(struct sna_damage *damage, ®ion->extents) == PIXMAN_REGION_IN) return damage; - _sna_damage_create_elt(damage, ADD, - REGION_RECTS(region), - REGION_NUM_RECTS(region)); + _sna_damage_create_elt(damage, + REGION_RECTS(region), REGION_NUM_RECTS(region)); if (damage->extents.x1 > region->extents.x1) damage->extents.x1 = region->extents.x1; @@ -486,29 +461,34 @@ __sna_damage_add_boxes(struct sna_damage *damage, if (!damage) damage = _sna_damage_create(); - - if (damage->all) + else switch (damage->mode) { + case DAMAGE_ALL: return damage; - - if (damage->mode == SUBTRACT) + case DAMAGE_SUBTRACT: __sna_damage_reduce(damage); - damage->mode = ADD; + case DAMAGE_ADD: + break; + } if (pixman_region_contains_rectangle(&damage->region, &extents) == PIXMAN_REGION_IN) return damage; - _sna_damage_create_elt_with_translation(damage, ADD, box, n, dx, dy); + _sna_damage_create_elt_with_translation(damage, box, n, dx, dy); - if (damage->extents.x1 > extents.x1) - damage->extents.x1 = extents.x1; - if (damage->extents.x2 < extents.x2) - damage->extents.x2 = extents.x2; - - if (damage->extents.y1 > extents.y1) - damage->extents.y1 = extents.y1; - if (damage->extents.y2 < extents.y2) - damage->extents.y2 = extents.y2; + if (REGION_NUM_RECTS(&damage->region) <= 1) { + __sna_damage_reduce(damage); + } else { + if (damage->extents.x1 > extents.x1) + damage->extents.x1 = extents.x1; + if (damage->extents.x2 < extents.x2) + damage->extents.x2 = extents.x2; + + if (damage->extents.y1 > extents.y1) + damage->extents.y1 = extents.y1; + if (damage->extents.y2 < extents.y2) + damage->extents.y2 = extents.y2; + } return damage; } @@ -524,7 +504,7 @@ struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, _debug_describe_damage(damage_buf, sizeof(damage_buf), damage), box->x1, box->y1, box->x2, box->y2, n)); - damage = __sna_damage_add_box(damage, boxes, n, dx, dy); + damage = __sna_damage_add_boxes(damage, boxes, n, dx, dy); ErrorF(" = %s\n", _debug_describe_damage(damage_buf, sizeof(damage_buf), damage)); @@ -540,6 +520,12 @@ struct sna_damage *_sna_damage_add_boxes(struct sna_damage *damage, } #endif +static void _pixman_region_union_box(RegionRec *region, const BoxRec *box) +{ + RegionRec u = { *box, NULL }; + pixman_region_union(region, region, &u); +} + inline static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, const BoxRec *box) { @@ -548,25 +534,31 @@ inline static struct sna_damage *__sna_damage_add_box(struct sna_damage *damage, if (!damage) damage = _sna_damage_create(); - - if (damage->all) + else switch (damage->mode) { + case DAMAGE_ALL: return damage; - - if (damage->mode == SUBTRACT) + case DAMAGE_SUBTRACT: __sna_damage_reduce(damage); - damage->mode = ADD; + case DAMAGE_ADD: + break; + } - if (REGION_NUM_RECTS(&damage->region) == 0) { + switch (REGION_NUM_RECTS(&damage->region)) { + case 0: pixman_region_init_rects(&damage->region, box, 1); damage->extents = *box; return damage; + case 1: + _pixman_region_union_box(&damage->region, box); + damage->extents = damage->region.extents; + return damage; } if (pixman_region_contains_rectangle(&damage->region, (BoxPtr)box) == PIXMAN_REGION_IN) return damage; - _sna_damage_create_elt(damage, ADD, box, 1); + _sna_damage_create_elt(damage, box, 1); if (damage->extents.x1 > box->x1) damage->extents.x1 = box->x1; @@ -621,8 +613,7 @@ struct sna_damage *_sna_damage_all(struct sna_damage *damage, pixman_region_init_rect(&damage->region, 0, 0, width, height); damage->extents = damage->region.extents; - damage->mode = ADD; - damage->all = 1; + damage->mode = DAMAGE_ALL; return damage; } @@ -632,9 +623,6 @@ struct sna_damage *_sna_damage_is_all(struct sna_damage *damage, { BoxRec box; - if (damage->mode == SUBTRACT) - return damage; - box.x1 = box.y1 = 0; box.x2 = width; box.y2 = height; @@ -677,7 +665,10 @@ static struct sna_damage *__sna_damage_subtract(struct sna_damage *damage, if (!sna_damage_maybe_contains_box(damage, ®ion->extents)) return damage; - if (damage->n == 0) { + if (damage->mode != DAMAGE_SUBTRACT) { + if (damage->n) + __sna_damage_reduce(damage); + if (pixman_region_equal(region, &damage->region)) { __sna_damage_destroy(damage); return NULL; @@ -694,16 +685,15 @@ static struct sna_damage *__sna_damage_subtract(struct sna_damage *damage, &damage->region, region); damage->extents = damage->region.extents; - damage->all = 0; + damage->mode = DAMAGE_ADD; /* reduce from ALL */ return damage; } + + damage->mode = DAMAGE_SUBTRACT; } - damage->all = 0; - damage->mode = SUBTRACT; - _sna_damage_create_elt(damage, SUBTRACT, - REGION_RECTS(region), - REGION_NUM_RECTS(region)); + _sna_damage_create_elt(damage, + REGION_RECTS(region), REGION_NUM_RECTS(region)); return damage; } @@ -748,7 +738,10 @@ inline static struct sna_damage *__sna_damage_subtract_box(struct sna_damage *da if (!sna_damage_maybe_contains_box(damage, box)) return damage; - if (damage->n == 0) { + if (damage->mode != DAMAGE_SUBTRACT) { + if (damage->n) + __sna_damage_reduce(damage); + if (!pixman_region_not_empty(&damage->region)) { __sna_damage_destroy(damage); return NULL; @@ -762,15 +755,14 @@ inline static struct sna_damage *__sna_damage_subtract_box(struct sna_damage *da &damage->region, ®ion); damage->extents = damage->region.extents; - damage->all = 0; + damage->mode = DAMAGE_ADD; return damage; } - } - damage->all = 0; - damage->mode = SUBTRACT; - _sna_damage_create_elt(damage, SUBTRACT, box, 1); + damage->mode = DAMAGE_SUBTRACT; + } + _sna_damage_create_elt(damage, box, 1); return damage; } @@ -805,14 +797,14 @@ static int _sna_damage_contains_box(struct sna_damage *damage, if (!damage) return PIXMAN_REGION_OUT; - if (damage->all) + if (damage->mode == DAMAGE_ALL) return PIXMAN_REGION_IN; if (!sna_damage_maybe_contains_box(damage, box)) return PIXMAN_REGION_OUT; if (damage->n) { - if (damage->mode != SUBTRACT) { + if (damage->mode != DAMAGE_SUBTRACT) { int ret = pixman_region_contains_rectangle(&damage->region, (BoxPtr)box); if (ret == PIXMAN_REGION_IN) @@ -859,6 +851,11 @@ static Bool _sna_damage_intersect(struct sna_damage *damage, if (!damage) return FALSE; + if (damage->mode == DAMAGE_ALL) { + RegionCopy(result, region); + return TRUE; + } + if (region->extents.x2 <= damage->extents.x1 || region->extents.x1 >= damage->extents.x2) return FALSE; diff --git a/src/sna/sna_damage.h b/src/sna/sna_damage.h index 454ad84..c402304 100644 --- a/src/sna/sna_damage.h +++ b/src/sna/sna_damage.h @@ -4,15 +4,20 @@ #include <regionstr.h> #include <list.h> -#define fastcall __attribute__((regparm(3))) +#include "compiler.h" struct sna_damage_elt; struct sna_damage_box; struct sna_damage { BoxRec extents; - int n, size, mode, all; pixman_region16_t region; + enum sna_damage_mode { + DAMAGE_ADD = 0, + DAMAGE_SUBTRACT, + DAMAGE_ALL, + } mode; + int n, size; struct sna_damage_elt *elts; struct sna_damage_box *last_box; struct list boxes; @@ -52,11 +57,16 @@ static inline bool sna_damage_is_all(struct sna_damage **damage, if (*damage == NULL) return false; - if ((*damage)->all) + switch ((*damage)->mode) { + case DAMAGE_ALL: return true; - - *damage = _sna_damage_is_all(*damage, width, height); - return (*damage)->all; + case DAMAGE_SUBTRACT: + return false; + default: + case DAMAGE_ADD: + *damage = _sna_damage_is_all(*damage, width, height); + return (*damage)->mode == DAMAGE_ALL; + } } struct sna_damage *_sna_damage_all(struct sna_damage *damage, From jeremyhu at kemper.freedesktop.org Fri Oct 21 15:36:27 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 21 Oct 2011 15:36:27 -0700 (PDT) Subject: xf86-video-cirrus: Changes to 'master' Message-ID: <20111021223628.02E4BC0001@kemper.freedesktop.org> src/alp_driver.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/cir_driver.c | 8 ++++ 2 files changed, 97 insertions(+), 1 deletion(-) New commits: commit 28aef0c4a45288751b2d5b7d5d0c452a116a5b38 Author: Satoshi KImura <satosi.kimura at nifty.ne.jp> Date: Fri Oct 21 15:34:41 2011 -0700 Add support for the NEC PC-9821 https://bugs.freedesktop.org/show_bug.cgi?id=1837 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From alanc at kemper.freedesktop.org Fri Oct 21 20:08:41 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 21 Oct 2011 20:08:41 -0700 (PDT) Subject: libX11: Changes to 'master' Message-ID: <20111022030841.ABAD8C0001@kemper.freedesktop.org> modules/lc/gen/lcGenConv.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) New commits: commit d8956520deb79c1cbb5e974c175bf8493859b22b Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 17:53:00 2011 -0700 Fix "nomal" -> "normal" typo in several comments Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 002b36e308a26a152504f9b40aa08a0dce9a7991 Author: Xue Wei <Wei.Xue at Sun.COM> Date: Fri Oct 14 17:39:21 2011 -0700 mbtocs should not truncate input Fixes pasting more than 1024 bytes into xterm, as described in https://bugs.freedesktop.org/show_bug.cgi?id=25209 Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Fri Oct 21 20:58:25 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 21 Oct 2011 20:58:25 -0700 (PDT) Subject: oclock: Changes to 'master' Message-ID: <20111022035825.D4C08C0001@kemper.freedesktop.org> Clock.c | 4 ++++ configure.ac | 12 +++++++++++- oclock.c | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) New commits: commit 027f85a81df383155e365f160d7760fa50e48ebe Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 14 23:12:05 2011 -0700 Enable the latent XKBStdBell code in oclock This code has been unreachable since the switch from Imake lost -DXKB, might as well hook it back up. Sadly it relies on the nonsensical use of libxkbfile for the Bell calls, but such is the state of our XKB Bell API. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Fri Oct 21 21:15:38 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 21 Oct 2011 21:15:38 -0700 (PDT) Subject: sessreg: Changes to 'master' Message-ID: <20111022041538.276FBC0001@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 7ac51a652bfb8423604bb1a120568d44516c9de9 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 21 21:09:43 2011 -0700 sessreg 1.0.7 Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Fri Oct 21 21:15:45 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 21 Oct 2011 21:15:45 -0700 (PDT) Subject: sessreg: Changes to 'refs/tags/sessreg-1.0.7' Message-ID: <20111022041545.7D345C0001@kemper.freedesktop.org> Tag 'sessreg-1.0.7' created by Alan Coopersmith <alan.coopersmith at oracle.com> at 2011-10-22 05:09 -0700 sessreg 1.0.7 Changes since sessreg-1.0.6: Alan Coopersmith (5): Sun's copyrights belong to Oracle now config: upgrade to util-macros 1.8 for additional man page support config: Remove unnecessary calls from configure.ac Add const attributes to fix gcc -Wwrite-strings warnings sessreg 1.0.7 Ed Schouten (12): Correct whitespace and indentation. Fix typo in function name check. Only split off /dev/ instead trimming to last /. Use Autoconf to check for utmp field existence. Get rid of bzero() calls. Replace them by memset(). Don't forget to include <sys/types.h> before <utmp.h>. Get rid of SYSV definition. Just check for pututline(). Only expose the sflag variable when needed. Just use time_t directly. Fix whitespace inconsistencies. Simply define LLOG_FILE and TTYS_FILE unconditionally. Make lastlog work on BSD systems without <lastlog.h>. Gaetan Nadon (5): man: remove trailing spaces and tabs man: replace hard coded man page section with substitution strings config: move man pages into their own directory config: remove AC_CANONICAL_HOST already included by XORG_DEFAULT_OPTIONS config: use AC_CHECK_MEMBERS rather than AC_CHECK_MEMBER Jon TURNEY (1): Fix non-srcdir builds --- COPYING | 2 Makefile.am | 43 ------- configure.ac | 56 +++++---- filenames.sed.c | 29 ---- man/Makefile.am | 22 +++ man/filenames.sed.c | 29 ++++ man/sessreg.man | 135 +++++++++++++++++++++++ sessreg.c | 302 +++++++++++++++++++++++++--------------------------- sessreg.h | 45 ++----- sessreg.man | 135 ----------------------- 10 files changed, 389 insertions(+), 409 deletions(-) --- From alanc at kemper.freedesktop.org Fri Oct 21 21:35:45 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 21 Oct 2011 21:35:45 -0700 (PDT) Subject: xdpyinfo: Changes to 'master' Message-ID: <20111022043545.BB95EC0001@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 02376118fb58c05067054be3f2e469f461f81757 Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Fri Oct 21 21:34:32 2011 -0700 xdpyinfo 1.3.0 Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> From alanc at kemper.freedesktop.org Fri Oct 21 21:35:46 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 21 Oct 2011 21:35:46 -0700 (PDT) Subject: xdpyinfo: Changes to 'refs/tags/xdpyinfo-1.3.0' Message-ID: <20111022043546.A8498C0001@kemper.freedesktop.org> Tag 'xdpyinfo-1.3.0' created by Alan Coopersmith <alan.coopersmith at oracle.com> at 2011-10-22 05:34 -0700 xdpyinfo 1.3.0 Changes since xdpyinfo-1.2.0: Alan Coopersmith (6): Use xcb for -queryExt instead of a round-trip per extension Strip trailing whitespace Add const attributes to fix gcc -Wwrite-strings warnings Remove unused function hasExtension Silence gcc complaint about being unable to check printf format string xdpyinfo 1.3.0 Gaetan Nadon (4): config: replace deprecated AC_HELP_STRING with AS_HELP_STRING config: replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS man: remove trailing spaces and tabs config: move man pages into their own directory Jesse Adkins (1): Purge cvs tags. --- Makefile.am | 23 +----- configure.ac | 41 ++++++----- man/Makefile.am | 12 +++ man/xdpyinfo.man | 69 +++++++++++++++++++ xdpyinfo.c | 196 +++++++++++++++++++++++++++++-------------------------- xdpyinfo.man | 72 -------------------- 6 files changed, 212 insertions(+), 201 deletions(-) --- From alanc at kemper.freedesktop.org Fri Oct 21 21:42:38 2011 From: alanc at kemper.freedesktop.org (Alan Coopersmith) Date: Fri, 21 Oct 2011 21:42:38 -0700 (PDT) Subject: modular: Changes to 'master' Message-ID: <20111022044238.E8DDDC0001@kemper.freedesktop.org> release.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 14 deletions(-) New commits: commit f509b989f0bf7171ea3ff950d1cf1fafa8e23a1b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Sep 21 13:01:22 2011 -0700 release.sh: Add user verification of auto-detected values Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> commit 920c2e71a2ddfcefdc52e1f57606d5fc077b844c Author: Alan Coopersmith <alan.coopersmith at oracle.com> Date: Thu Sep 15 23:00:23 2011 -0700 release.sh: Attempt to autodetect section and current/previous tags Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From jcristau at kemper.freedesktop.org Sat Oct 22 12:13:07 2011 From: jcristau at kemper.freedesktop.org (Julien Cristau) Date: Sat, 22 Oct 2011 12:13:07 -0700 (PDT) Subject: xdm: Changes to 'master' Message-ID: <20111022191307.F3201C0001@kemper.freedesktop.org> configure.ac | 4 ++-- greeter/Login.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) New commits: commit 284532c0884893728b75ca37f5d2a9a33f7bc8db Author: Julien Cristau <jcristau at debian.org> Date: Sat Oct 22 17:14:46 2011 +0200 greeter: link against -lXrender if xft is enabled XmuCvtStringToXftColor uses XRenderParseColor, so require xrender for the xft option, and link against it. Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> From whot at kemper.freedesktop.org Sun Oct 23 23:24:53 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Sun, 23 Oct 2011 23:24:53 -0700 (PDT) Subject: xf86-input-evdev: Changes to 'master' Message-ID: <20111024062453.EF6611000F@kemper.freedesktop.org> src/evdev.c | 76 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 34 deletions(-) New commits: commit 49693892ce35e95674fbb3d2a067c8fa0227da87 Author: Max Schwarz <Max at x-quadraht.de> Date: Mon Oct 17 21:01:22 2011 +0200 type-safe inline functions for bitmask manipulation We can't use BitIsSet/SetBit from the server (inputstr.h) since they operate on byte arrays. EvdevSetBit is added in preparation for the "smooth-scrolling on wheel emulation" patch. Signed-off-by: Max Schwarz <Max at x-quadraht.de> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> From jeremyhu at kemper.freedesktop.org Mon Oct 24 10:06:28 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 24 Oct 2011 10:06:28 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' Message-ID: <20111024170628.D27A9C0001@kemper.freedesktop.org> composite/compalloc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) New commits: commit d780c6f6301ed2263b21ac7d327a1b2e8d3e76df Author: Ville Syrjala <syrjala at sci.fi> Date: Sun Oct 9 01:11:04 2011 +0300 composite: Update borderClip in compAllocPixmap() Previously the parent constrained borderClip was copied over when compRedirectWindow() is called. That is insufficient eg. in case the window was already redirected, but not yet realized. So copy the borderClip over in compAllocPixmap() instead. Example: Window 1 is below an automatically redirect window 2. Window 2 is unmapped and moved outside the extents of window 1. Window 2 is then mapped again, and MarkOverlappedWindows() uses the up to date borderSize of window 2 to mark windows, which leaves window 1 unmarked. Then exposures are calculated using the stale borderClip of window 2, which causes the window below window 2, to be exposed through an apparent hole in window 1. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=22566 Signed-off-by: Ville Syrjala <syrjala at sci.fi> Reviewed-by: Keith Packard <keithp at keithp.com> Signed-off-by: Keith Packard <keithp at keithp.com> (cherry picked from commit a5266dcb3a60587e1877f90c18552baf60b597a0) diff --git a/composite/compalloc.c b/composite/compalloc.c index f00bf4e..9857a92 100644 --- a/composite/compalloc.c +++ b/composite/compalloc.c @@ -196,11 +196,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update) anyMarked = compMarkWindows (pWin, &pLayerWin); - /* Make sure our borderClip is correct for ValidateTree */ RegionNull(&cw->borderClip); - RegionCopy(&cw->borderClip, &pWin->borderClip); - cw->borderClipX = pWin->drawable.x; - cw->borderClipY = pWin->drawable.y; cw->update = CompositeRedirectAutomatic; cw->clients = 0; cw->oldx = COMP_ORIGIN_INVALID; @@ -658,6 +654,13 @@ compAllocPixmap (WindowPtr pWin) DamageRegister (&pWin->drawable, cw->damage); cw->damageRegistered = TRUE; } + + /* Make sure our borderClip is up to date */ + RegionUninit(&cw->borderClip); + RegionCopy(&cw->borderClip, &pWin->borderClip); + cw->borderClipX = pWin->drawable.x; + cw->borderClipY = pWin->drawable.y; + return TRUE; } From jeremyhu at kemper.freedesktop.org Mon Oct 24 10:19:32 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 24 Oct 2011 10:19:32 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' Message-ID: <20111024171933.01C79C0001@kemper.freedesktop.org> hw/xfree86/modes/xf86Crtc.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) New commits: commit c8c5ed998aac2c91dbec1f86af3395e08ddab373 Author: Jesse Barnes <jbarnes at virtuousgeek.org> Date: Thu Oct 13 12:01:10 2011 -0700 crtc: match full preferred modes if possible when choosing an initial config It's fairly common to have multiple, identical monitors plugged in. In that case, it's preferable to run the monitor's preferred mode on each output, rather than just matching the width & height and end up with different timings or refresh rates. Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org> Reviewed-by: Keith Packard <keithp at keithp.com> Signed-off-by: Keith Packard <keithp at keithp.com> (cherry picked from commit 3e145d3d67b472cb5d74cb8078b614160c4722b7) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 3fae039..d75cd77 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -2060,13 +2060,28 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, if (o == p) continue; - for (mode = output->probed_modes; mode; mode = mode->next) { - Rotation r = output->initial_rotation; - if (xf86ModeWidth(mode, r) == pref_width && - xf86ModeHeight(mode, r) == pref_height) { + /* + * First see if the preferred mode matches on the next + * output as well. This catches the common case of identical + * monitors and makes sure they all have the same timings + * and refresh. If that fails, we fall back to trying to + * match just width & height. + */ + mode = xf86OutputHasPreferredMode(output, pref_width, + pref_height); + if (mode && xf86ModesEqual(mode, preferred[p])) { preferred[o] = mode; match = TRUE; - } + } else { + for (mode = output->probed_modes; mode; + mode = mode->next) { + Rotation r = output->initial_rotation; + if (xf86ModeWidth(mode, r) == pref_width && + xf86ModeHeight(mode, r) == pref_height) { + preferred[o] = mode; + match = TRUE; + } + } } all_match &= match; From jeremyhu at kemper.freedesktop.org Mon Oct 24 16:36:07 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 24 Oct 2011 16:36:07 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' Message-ID: <20111024233607.E6C77C0001@kemper.freedesktop.org> hw/xfree86/common/xf86Events.c | 9 ++++----- hw/xfree86/os-support/linux/lnx_init.c | 14 ++++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) New commits: commit 82445286d56fdac36f21ec5eed436646bda768dd Author: Tom???? Trnka <tomastrnka at gmx.com> Date: Tue Oct 11 09:11:18 2011 +0200 Fix drain_console unregistration Bug introduced by 9dca441670d261a9a9fb6108960ed48f3d58fb7f xfree86: add a hook to replace the new console handler. console_handler was not being set, making the server eat up CPU spinning in WaitForSomething selecting consoleFd over and over again, every time trying to unregister drain_console without success due to console_handler being NULL. Let's just fix the unregistration in xf86SetConsoleHandler() and use that. But wait, there could be a catch: If some driver replaced the handler using xf86SetConsoleHandler(), the unregistration in xf86CloseConsole will unregister that one. I don't understand Xorg well enough to know whether this poses a problem (could mess up driver deinit somehow or something like that). As it is, xf86SetConsoleHandler() doesn't offer any way to prevent this (i.e. check which handler is currently registered). I had been using it for two days on my machine that previously hit 100% CPU several times a day. That has now gone away without any new problems appearing. Signed-off-by: Tomas Trnka <tomastrnka at gmx.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> (cherry picked from commit 323869f3298cbbfe864af9404a8aed1bf7995d79) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index c4a4db9..41ffabd 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -601,16 +601,15 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data) InputHandlerProc xf86SetConsoleHandler(InputHandlerProc proc, pointer data) { - static InputHandlerProc handler = NULL; - InputHandlerProc old_handler = handler; + static IHPtr handler = NULL; + IHPtr old_handler = handler; if (old_handler) xf86RemoveGeneralHandler(old_handler); - xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - handler = proc; + handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - return old_handler; + return (old_handler) ? old_handler->ihproc : NULL; } static void diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index 77dfb2f..e098e14 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -47,15 +47,12 @@ static char vtname[11]; static struct termios tty_attr; /* tty state to restore */ static int tty_mode; /* kbd mode to restore */ -static void *console_handler; - static void drain_console(int fd, void *closure) { errno = 0; if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; + xf86SetConsoleHandler(NULL, NULL); } } @@ -259,10 +256,11 @@ xf86CloseConsole(void) return; } - if (console_handler) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; - }; + /* + * unregister the drain_console handler + * - what to do if someone else changed it in the meantime? + */ + xf86SetConsoleHandler(NULL, NULL); /* Back to text mode ... */ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT)); From keithp at kemper.freedesktop.org Mon Oct 24 18:11:09 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 24 Oct 2011 18:11:09 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111025011109.C43E0C0001@kemper.freedesktop.org> hw/xfree86/modes/xf86Crtc.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) New commits: commit 17416e88dcfcc584fe5f87580d5d2b719b3521c3 Author: Dave Airlie <airlied at redhat.com> Date: Thu Oct 20 14:43:01 2011 +0100 xf86Crtc: handle no outputs with no modes harder. If you started an X server with no connected outputs, we pick a default 1024x768 mode, however if you then ran an xvidmode using app against that server it would segfault the server due to not finding any valid modes. This was due to the no output mode set code, only adding the modes to the scrn->modes once, when something called randr 1.2 xf86SetScrnInfoModes would get called and remove all the modes and we'd end up with 0. This change fixes xf86SetScrnInfoModes to always report a scrn mode of at least 1024x768, and pushes the initial configuration to just call it instead of setting up the mode itself. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=746926 I've seen other bugs like this on other distros so it might also actually fix them. Signed-off-by: Dave Airlie <airlied at redhat.com> Reviewed-by: Keith Packard <keithp at keithp.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 384d8b4..aac33d3 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1915,19 +1915,25 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn) break; } - if (scrn->modes != NULL) { - /* For some reason, scrn->modes is circular, unlike the other mode - * lists. How great is that? - */ - for (last = scrn->modes; last && last->next; last = last->next) - ; - last->next = scrn->modes; - scrn->modes->prev = last; - if (mode) { - while (scrn->modes != mode) - scrn->modes = scrn->modes->next; - } + if (!scrn->modes) { + scrn->modes = xf86ModesAdd(scrn->modes, + xf86CVTMode(scrn->display->virtualX, + scrn->display->virtualY, + 60, 0, 0)); + } + + /* For some reason, scrn->modes is circular, unlike the other mode + * lists. How great is that? + */ + for (last = scrn->modes; last && last->next; last = last->next) + ; + last->next = scrn->modes; + scrn->modes->prev = last; + if (mode) { + while (scrn->modes != mode) + scrn->modes = scrn->modes->next; } + scrn->currentMode = scrn->modes; #ifdef XFreeXDGA if (scrn->pScreen) @@ -2529,16 +2535,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) width, height); } - if (have_outputs) { - /* Mirror output modes to scrn mode list */ - xf86SetScrnInfoModes (scrn); - } else { - /* Clear any existing modes from scrn->modes */ - while (scrn->modes != NULL) - xf86DeleteMode(&scrn->modes, scrn->modes); - scrn->modes = xf86ModesAdd(scrn->modes, - xf86CVTMode(width, height, 60, 0, 0)); - } + xf86SetScrnInfoModes (scrn); success = TRUE; bailout: From keithp at kemper.freedesktop.org Mon Oct 24 18:16:05 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 24 Oct 2011 18:16:05 -0700 (PDT) Subject: xserver: Branch 'master' - 13 commits Message-ID: <20111025011605.6B1D3C0001@kemper.freedesktop.org> configure.ac | 6 hw/xnest/Events.c | 2 hw/xnest/Keyboard.c | 25 +++ hw/xquartz/darwin.c | 2 hw/xquartz/xpr/appledri.c | 137 ++++++++++++++++++- hw/xquartz/xpr/appledristr.h | 298 ++++++++++++++++++++++--------------------- mi/mieq.c | 188 +++++++++++++++++++++------ test/input.c | 84 +++++++++++- 8 files changed, 543 insertions(+), 199 deletions(-) New commits: commit d9d3a01ffca5e2de650d098231e16205781804c5 Merge: 17416e8... fb55f8f... Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 24 18:12:23 2011 -0700 Merge remote-tracking branch 'jeremyhu/master' commit fb55f8f790f69f30b0ab18648c337bde9d41f5ff Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 24 16:45:36 2011 -0700 XQuartz: Fix the filename of our log file Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c index b483000..465a96d 100644 --- a/hw/xquartz/darwin.c +++ b/hw/xquartz/darwin.c @@ -621,7 +621,7 @@ void OsVendorInit(void) char *lf; char *home = getenv("HOME"); assert(home); - assert(0 < asprintf(&lf, "%s/Library/Logs/X11.%s.log", home, bundle_id_prefix)); + assert(0 < asprintf(&lf, "%s/Library/Logs/%s.X11.log", home, bundle_id_prefix)); LogInit(lf, ".old"); free(lf); commit 1c8bda798b4480bab0f0da6f531e4770c7a1f771 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 21 10:27:16 2011 -0700 XQuartz: appledri: Allow byte swapped requests Even though it's only valid when local, it is possible for a local client and the server to not match endianness, such as when running a ppc application under Rosetta. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 46c72a7..6b4a8a3 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -2,7 +2,7 @@ Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 2000 VA Linux Systems, Inc. -Copyright (c) 2002, 2009 Apple Computer, Inc. +Copyright (c) 2002, 2009-2011 Apple Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -410,21 +410,107 @@ SProcAppleDRIQueryVersion( } static int +SProcAppleDRIQueryDirectRenderingCapable( + register ClientPtr client +) +{ + REQUEST(xAppleDRIQueryDirectRenderingCapableReq); + swaps(&stuff->length); + swapl(&stuff->screen); + return ProcAppleDRIQueryDirectRenderingCapable(client); +} + +static int +SProcAppleDRIAuthConnection( + register ClientPtr client +) +{ + REQUEST(xAppleDRIAuthConnectionReq); + swaps(&stuff->length); + swapl(&stuff->screen); + swapl(&stuff->magic); + return ProcAppleDRIAuthConnection(client); +} + +static int +SProcAppleDRICreateSurface( + register ClientPtr client +) +{ + REQUEST(xAppleDRICreateSurfaceReq); + swaps(&stuff->length); + swapl(&stuff->screen); + swapl(&stuff->drawable); + swapl(&stuff->client_id); + return ProcAppleDRICreateSurface(client); +} + +static int +SProcAppleDRIDestroySurface( + register ClientPtr client +) +{ + REQUEST(xAppleDRIDestroySurfaceReq); + swaps(&stuff->length); + swapl(&stuff->screen); + swapl(&stuff->drawable); + return ProcAppleDRIDestroySurface(client); +} + +static int +SProcAppleDRICreatePixmap( + register ClientPtr client +) +{ + REQUEST(xAppleDRICreatePixmapReq); + swaps(&stuff->length); + swapl(&stuff->screen); + swapl(&stuff->drawable); + return ProcAppleDRICreatePixmap(client); +} + +static int +SProcAppleDRIDestroyPixmap( + register ClientPtr client +) +{ + REQUEST(xAppleDRIDestroyPixmapReq); + swaps(&stuff->length); + swapl(&stuff->drawable); + return ProcAppleDRIDestroyPixmap(client); +} + +static int SProcAppleDRIDispatch ( register ClientPtr client ) { REQUEST(xReq); - /* It is bound to be non-local when there is byte swapping */ + switch (stuff->data) + { + case X_AppleDRIQueryVersion: + return SProcAppleDRIQueryVersion(client); + case X_AppleDRIQueryDirectRenderingCapable: + return SProcAppleDRIQueryDirectRenderingCapable(client); + } + if (!LocalClient(client)) return DRIErrorBase + AppleDRIClientNotLocal; - /* only local clients are allowed DRI access */ switch (stuff->data) { - case X_AppleDRIQueryVersion: - return SProcAppleDRIQueryVersion(client); + case X_AppleDRIAuthConnection: + return SProcAppleDRIAuthConnection(client); + case X_AppleDRICreateSurface: + return SProcAppleDRICreateSurface(client); + case X_AppleDRIDestroySurface: + return SProcAppleDRIDestroySurface(client); + case X_AppleDRICreatePixmap: + return SProcAppleDRICreatePixmap(client); + case X_AppleDRIDestroyPixmap: + return SProcAppleDRIDestroyPixmap(client); + default: return BadRequest; } commit 14205ade0c750191bf43fba8bd55c65dba912cf4 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 22:34:44 2011 -0700 XQuartz: appledri: Fix byte swapping in replies Even though it's only valid when local, it is possible for a local client and the server to not match endianness, such as when running a ppc application under Rosetta. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index f6bc32b..46c72a7 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -102,6 +102,9 @@ ProcAppleDRIQueryVersion( if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); + swaps(&rep.majorVersion); + swaps(&rep.minorVersion); + swapl(&rep.patchVersion); } WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep); return Success; @@ -133,6 +136,11 @@ ProcAppleDRIQueryDirectRenderingCapable( if (!LocalClient(client)) rep.isCapable = 0; + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + } + WriteToClient(client, sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep); return Success; @@ -157,6 +165,13 @@ ProcAppleDRIAuthConnection( ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic); rep.authenticated = 0; } + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.authenticated); /* Yes, this is a CARD32 ... sigh */ + } + WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep); return Success; } @@ -216,6 +231,14 @@ ProcAppleDRICreateSurface( rep.key_1 = key[1]; rep.uid = sid; + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.key_0); + swapl(&rep.key_1); + swapl(&rep.uid); + } + WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep); return Success; } @@ -277,7 +300,6 @@ ProcAppleDRICreatePixmap(ClientPtr client) rep.stringLength = strlen(path) + 1; - /* No need for swapping, because this only runs if LocalClient is true. */ rep.type = X_Reply; rep.length = bytes_to_int32(rep.stringLength); rep.sequenceNumber = client->sequence; @@ -290,8 +312,19 @@ ProcAppleDRICreatePixmap(ClientPtr client) if(sizeof(rep) != sz_xAppleDRICreatePixmapReply) ErrorF("error sizeof(rep) is %zu\n", sizeof(rep)); - WriteReplyToClient(client, sizeof(rep), &rep); - (void)WriteToClient(client, rep.stringLength, path); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.stringLength); + swapl(&rep.width); + swapl(&rep.height); + swapl(&rep.pitch); + swapl(&rep.bpp); + swapl(&rep.size); + } + + WriteToClient(client, sizeof(rep), &rep); + WriteToClient(client, rep.stringLength, path); return Success; } commit 2ba0ac202ad64eb4a555715980ba538de19c9fd7 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 22:23:07 2011 -0700 XQuartz: appledri: Set the correct reply length for XAppleDRICreatePixmap http://xquartz.macosforge.org/trac/ticket/508 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 1304d5a..f6bc32b 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -279,7 +279,7 @@ ProcAppleDRICreatePixmap(ClientPtr client) /* No need for swapping, because this only runs if LocalClient is true. */ rep.type = X_Reply; - rep.length = sizeof(rep) + rep.stringLength; + rep.length = bytes_to_int32(rep.stringLength); rep.sequenceNumber = client->sequence; rep.width = width; rep.height = height; commit e4f257748b51d041275a64b8be408729ea05fbb5 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 11:35:54 2011 -0700 XQuartz: appledri: Change whitespace in appledristr.h to match mesa Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xquartz/xpr/appledristr.h b/hw/xquartz/xpr/appledristr.h index c569719..b5ffe5b 100644 --- a/hw/xquartz/xpr/appledristr.h +++ b/hw/xquartz/xpr/appledristr.h @@ -42,209 +42,225 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define APPLEDRINAME "Apple-DRI" -#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */ +#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */ #define APPLE_DRI_MINOR_VERSION 0 #define APPLE_DRI_PATCH_VERSION 0 -typedef struct _AppleDRIQueryVersion { - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIQueryVersion */ - CARD16 length B16; +typedef struct _AppleDRIQueryVersion +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIQueryVersion */ + CARD16 length B16; } xAppleDRIQueryVersionReq; #define sz_xAppleDRIQueryVersionReq 4 -typedef struct { - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DRI protocol */ - CARD16 minorVersion B16; /* minor version of DRI protocol */ - CARD32 patchVersion B32; /* patch version of DRI protocol */ - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD16 majorVersion B16; /* major version of DRI protocol */ + CARD16 minorVersion B16; /* minor version of DRI protocol */ + CARD32 patchVersion B32; /* patch version of DRI protocol */ + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRIQueryVersionReply; #define sz_xAppleDRIQueryVersionReply 32 -typedef struct _AppleDRIQueryDirectRenderingCapable { - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ - CARD16 length B16; - CARD32 screen B32; +typedef struct _AppleDRIQueryDirectRenderingCapable +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ + CARD16 length B16; + CARD32 screen B32; } xAppleDRIQueryDirectRenderingCapableReq; #define sz_xAppleDRIQueryDirectRenderingCapableReq 8 -typedef struct { - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - BOOL isCapable; - BOOL pad2; - BOOL pad3; - BOOL pad4; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; - CARD32 pad9 B32; +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + BOOL isCapable; + BOOL pad2; + BOOL pad3; + BOOL pad4; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; + CARD32 pad8 B32; + CARD32 pad9 B32; } xAppleDRIQueryDirectRenderingCapableReply; #define sz_xAppleDRIQueryDirectRenderingCapableReply 32 -typedef struct _AppleDRIAuthConnection { - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; - CARD32 magic B32; +typedef struct _AppleDRIAuthConnection +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICloseConnection */ + CARD16 length B16; + CARD32 screen B32; + CARD32 magic B32; } xAppleDRIAuthConnectionReq; #define sz_xAppleDRIAuthConnectionReq 12 -typedef struct { - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 authenticated B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct +{ + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 authenticated B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRIAuthConnectionReply; #define zx_xAppleDRIAuthConnectionReply 32 -typedef struct _AppleDRICreateSurface { - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateSurface */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; - CARD32 client_id B32; +typedef struct _AppleDRICreateSurface +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRICreateSurface */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; + CARD32 client_id B32; } xAppleDRICreateSurfaceReq; #define sz_xAppleDRICreateSurfaceReq 16 -typedef struct { - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 key_0 B32; - CARD32 key_1 B32; - CARD32 uid B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 key_0 B32; + CARD32 key_1 B32; + CARD32 uid B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRICreateSurfaceReply; #define sz_xAppleDRICreateSurfaceReply 32 -typedef struct _AppleDRIDestroySurface { - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroySurface */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; +typedef struct _AppleDRIDestroySurface +{ + CARD8 reqType; /* always DRIReqCode */ + CARD8 driReqType; /* always X_DRIDestroySurface */ + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; } xAppleDRIDestroySurfaceReq; #define sz_xAppleDRIDestroySurfaceReq 12 -typedef struct _AppleDRINotify { - BYTE type; /* always eventBase + event type */ - BYTE kind; - CARD16 sequenceNumber B16; - CARD32 time B32; /* time of change */ - CARD32 pad1 B32; - CARD32 arg B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; +typedef struct _AppleDRINotify +{ + BYTE type; /* always eventBase + event type */ + BYTE kind; + CARD16 sequenceNumber B16; + CARD32 time B32; /* time of change */ + CARD32 pad1 B32; + CARD32 arg B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; } xAppleDRINotifyEvent; #define sz_xAppleDRINotifyEvent 32 -typedef struct { - CARD8 reqType; - CARD8 driReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; - BOOL doubleSwap; - CARD8 pad1, pad2, pad3; +typedef struct +{ + CARD8 reqType; + CARD8 driReqType; + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; + BOOL doubleSwap; + CARD8 pad1, pad2, pad3; } xAppleDRICreateSharedBufferReq; #define sz_xAppleDRICreateSharedBufferReq 16 -typedef struct { - BYTE type; - BYTE data1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 stringLength B32; /* 0 on error */ - CARD32 width B32; - CARD32 height B32; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; +typedef struct +{ + BYTE type; + BYTE data1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 stringLength B32; /* 0 on error */ + CARD32 width B32; + CARD32 height B32; + CARD32 pad1 B32; + CARD32 pad2 B32; + CARD32 pad3 B32; } xAppleDRICreateSharedBufferReply; #define sz_xAppleDRICreateSharedBufferReply 32 -typedef struct { - CARD8 reqType; - CARD8 driReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; +typedef struct +{ + CARD8 reqType; + CARD8 driReqType; + CARD16 length B16; + CARD32 screen B32; + CARD32 drawable B32; } xAppleDRISwapBuffersReq; #define sz_xAppleDRISwapBuffersReq 12 -typedef struct { - CARD8 reqType; /*1*/ - CARD8 driReqType; /*2*/ - CARD16 length B16; /*4*/ - CARD32 screen B32; /*8*/ - CARD32 drawable B32; /*12*/ +typedef struct +{ + CARD8 reqType; /*1 */ + CARD8 driReqType; /*2 */ + CARD16 length B16; /*4 */ + CARD32 screen B32; /*8 */ + CARD32 drawable B32; /*12 */ } xAppleDRICreatePixmapReq; #define sz_xAppleDRICreatePixmapReq 12 -typedef struct { - BYTE type; /*1*/ - BOOL pad1; /*2*/ - CARD16 sequenceNumber B16; /*4*/ - CARD32 length B32; /*8*/ - CARD32 width B32; /*12*/ - CARD32 height B32; /*16*/ - CARD32 pitch B32; /*20*/ - CARD32 bpp B32; /*24*/ - CARD32 size B32; /*28*/ - CARD32 stringLength B32; /*32*/ +typedef struct +{ + BYTE type; /*1 */ + BOOL pad1; /*2 */ + CARD16 sequenceNumber B16; /*4 */ + CARD32 length B32; /*8 */ + CARD32 width B32; /*12 */ + CARD32 height B32; /*16 */ + CARD32 pitch B32; /*20 */ + CARD32 bpp B32; /*24 */ + CARD32 size B32; /*28 */ + CARD32 stringLength B32; /*32 */ } xAppleDRICreatePixmapReply; #define sz_xAppleDRICreatePixmapReply 32 -typedef struct { - CARD8 reqType; /*1*/ - CARD8 driReqType; /*2*/ - CARD16 length B16; /*4*/ - CARD32 drawable B32; /*8*/ +typedef struct +{ + CARD8 reqType; /*1 */ + CARD8 driReqType; /*2 */ + CARD16 length B16; /*4 */ + CARD32 drawable B32; /*8 */ } xAppleDRIDestroyPixmapReq; #define sz_xAppleDRIDestroyPixmapReq 8 #ifdef _APPLEDRI_SERVER_ -void AppleDRISendEvent ( +void AppleDRISendEvent( #if NeedFunctionPrototypes - int /* type */, - unsigned int /* mask */, - int /* which */, - int /* arg */ + int /* type */ , + unsigned int /* mask */ , + int /* which */ , + int /* arg */ #endif -); + ); #endif /* _APPLEDRI_SERVER_ */ #endif /* _APPLEDRISTR_H_ */ commit 83fef4235db86343477b4ec9858c6ba35e1aa7d9 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 16 02:12:38 2011 -0700 Xnest: Match the host's keymap This was a regression. Introduced by: 08363c5830bdea34012dcd954b45ccfdc79a3a7e and 32db27a7f867b503c2840ca7b815e96d10be9210 Masked by: 1e69fd4a60147287b31e53bfc61543fb17bb82c8 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index ec629dc..5ef376b 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -114,11 +114,13 @@ xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) int xnestKeyboardProc(DeviceIntPtr pDev, int onoff) { + XModifierKeymap *modifier_keymap; KeySym *keymap; int mapWidth; int min_keycode, max_keycode; KeySymsRec keySyms; - int i; + CARD8 modmap[MAP_LENGTH]; + int i, j; XKeyboardState values; XkbDescPtr xkb; int op, event, error, major, minor; @@ -130,7 +132,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) #ifdef _XSERVER64 { KeySym64 *keymap64; - int i, len; + int len; keymap64 = XGetKeyboardMapping(xnestDisplay, min_keycode, max_keycode - min_keycode + 1, @@ -147,7 +149,17 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) max_keycode - min_keycode + 1, &mapWidth); #endif - + + memset(modmap, 0, sizeof(modmap)); + modifier_keymap = XGetModifierMapping(xnestDisplay); + for (j = 0; j < 8; j++) + for(i = 0; i < modifier_keymap->max_keypermod; i++) { + CARD8 keycode; + if ((keycode = modifier_keymap->modifiermap[j * modifier_keymap->max_keypermod + i])) + modmap[keycode] |= 1<<j; + } + XFreeModifiermap(modifier_keymap); + keySyms.minKeyCode = min_keycode; keySyms.maxKeyCode = max_keycode; keySyms.mapWidth = mapWidth; @@ -165,7 +177,12 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb); InitKeyboardDeviceStruct(pDev, NULL, - xnestBell, xnestChangeKeyboardControl); + xnestBell, xnestChangeKeyboardControl); + + XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); + XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); XkbFreeKeyboard(xkb, 0, False); free(keymap); commit 4597ac6fe0580323860080dae2576733acc49757 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 17 23:45:32 2011 -0700 test: Add unit test for mieq Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/test/input.c b/test/input.c index 52bc2f5..5b4c8c1 100644 --- a/test/input.c +++ b/test/input.c @@ -40,6 +40,7 @@ #include "dixgrabs.h" #include "eventstr.h" #include "inpututils.h" +#include "mi.h" #include "assert.h" /** @@ -1606,6 +1607,73 @@ dix_double_fp_conversion(void) } } +/* The mieq test verifies that events added to the queue come out in the same + * order that they went in. + */ +static uint32_t mieq_test_event_last_processed; + +static void +mieq_test_event_handler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) { + RawDeviceEvent *e = (RawDeviceEvent *)ie; + + assert(e->type == ET_RawMotion); + assert(e->flags > mieq_test_event_last_processed); + mieq_test_event_last_processed = e->flags; +} + +static void _mieq_test_generate_events(uint32_t start, uint32_t count) { + count += start; + while (start < count) { + RawDeviceEvent e = {0}; + e.header = ET_Internal; + e.type = ET_RawMotion; + e.length = sizeof(e); + e.time = GetTimeInMillis(); + e.flags = start; + + mieqEnqueue(NULL, (InternalEvent*)&e); + + start++; + } +} + +#define mieq_test_generate_events(c) { _mieq_test_generate_events(next, c); next += c; } + +static void +mieq_test(void) { + uint32_t next = 1; + + mieq_test_event_last_processed = 0; + mieqInit(); + mieqSetHandler(ET_RawMotion, mieq_test_event_handler); + + /* Enough to fit the buffer but trigger a grow */ + mieq_test_generate_events(180); + + /* We should resize to 512 now */ + mieqProcessInputEvents(); + + /* Some should now get dropped */ + mieq_test_generate_events(500); + + /* Tell us how many got dropped, 1024 now */ + mieqProcessInputEvents(); + + /* Now make it 2048 */ + mieq_test_generate_events(900); + mieqProcessInputEvents(); + + /* Now make it 4096 (max) */ + mieq_test_generate_events(1950); + mieqProcessInputEvents(); + + /* Now overflow one last time with the maximal queue and reach the verbosity limit */ + mieq_test_generate_events(10000); + mieqProcessInputEvents(); + + mieqFini(); +} + int main(int argc, char** argv) { dix_double_fp_conversion(); @@ -1624,6 +1692,7 @@ int main(int argc, char** argv) dix_valuator_alloc(); dix_get_master(); input_option_test(); + mieq_test(); return 0; } commit ad450d76e468cd62406c4f09e71e131f7ff4555c Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 17 21:16:37 2011 -0700 mieq: Reserve some space in EQ for release and other special events The last 64 events in the event queue will be reserved for release events in order to help return the system to a cleaner state when it comes back from a soft wedge. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/mi/mieq.c b/mi/mieq.c index f644658..093dba2 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -60,7 +60,8 @@ in this Software without prior written authorization from The Open Group. #endif /* Maximum size should be initial size multiplied by a power of 2 */ -#define QUEUE_INITIAL_SIZE 128 +#define QUEUE_INITIAL_SIZE 256 +#define QUEUE_RESERVED_SIZE 64 #define QUEUE_MAXIMUM_SIZE 4096 #define QUEUE_DROP_BACKTRACE_FREQUENCY 100 #define QUEUE_DROP_BACKTRACE_MAX 10 @@ -205,6 +206,26 @@ mieqFini(void) free(miEventQueue.events); } +/* This function will determine if the given event is allowed to used the reserved + * queue space. + */ +static Bool +mieqReservedCandidate(InternalEvent *e) { + switch(e->any.type) { + case ET_KeyRelease: + case ET_ButtonRelease: +#if XFreeXDGA + case ET_DGAEvent: +#endif + case ET_RawKeyRelease: + case ET_RawButtonRelease: + case ET_XQuartz: + return TRUE; + default: + return FALSE; + } +} + /* * Must be reentrant with ProcessInputEvents. Assumption: mieqEnqueue * will never be interrupted. If this is called from both signal @@ -220,6 +241,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) int isMotion = 0; int evlen; Time time; + size_t n_enqueued; #ifdef XQUARTZ wait_for_server_init(); @@ -228,6 +250,8 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) verify_internal_event(e); + n_enqueued = mieqNumEnqueued(&miEventQueue); + /* avoid merging events from different devices */ if (e->any.type == ET_Motion) isMotion = pDev->id; @@ -235,7 +259,8 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) if (isMotion && isMotion == miEventQueue.lastMotion && oldtail != miEventQueue.head) { oldtail = (oldtail - 1) % miEventQueue.nevents; - } else if (((oldtail + 1) % miEventQueue.nevents) == miEventQueue.head) { + } else if ((n_enqueued + 1 == miEventQueue.nevents) || + ((n_enqueued + 1 >= miEventQueue.nevents - QUEUE_RESERVED_SIZE) && !mieqReservedCandidate(e))) { /* Toss events which come in late. Usually this means your server's * stuck in an infinite loop somewhere, but SIGIO is still getting * handled. @@ -517,9 +542,9 @@ mieqProcessInputEvents(void) pthread_mutex_lock(&miEventQueueMutex); #endif - /* Grow our queue if we are reaching capacity: > 50% full */ + /* Grow our queue if we are reaching capacity: < 2 * QUEUE_RESERVED_SIZE remaining */ n_enqueued = mieqNumEnqueued(&miEventQueue); - if (n_enqueued >= (miEventQueue.nevents >> 1) && + if (n_enqueued >= (miEventQueue.nevents - (2 * QUEUE_RESERVED_SIZE)) && miEventQueue.nevents < QUEUE_MAXIMUM_SIZE) { ErrorF("[mi] Increasing EQ size to %lu to prevent dropped events.\n", miEventQueue.nevents << 1); if (!mieqGrowQueue(&miEventQueue, miEventQueue.nevents << 1)) { commit 7d153f25be678acf500236ae422b33d17e6cb7a6 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 15 22:51:30 2011 -0700 mieq: Provide better adaptability and diagnostics during mieq overflow This patch changes from a static length event queue (512) to one that starts at 128 and grows to 4096 as it overflows, logging each time it grows. This change also allows for multiple backtraces to be printed when the server is wedged rather than just one. This increased sampling should help identify the true hog in cases where one backtrace might be insufficient. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/mi/mieq.c b/mi/mieq.c index b75bde9..f644658 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -59,7 +59,11 @@ in this Software without prior written authorization from The Open Group. # include <X11/extensions/dpmsconst.h> #endif -#define QUEUE_SIZE 512 +/* Maximum size should be initial size multiplied by a power of 2 */ +#define QUEUE_INITIAL_SIZE 128 +#define QUEUE_MAXIMUM_SIZE 4096 +#define QUEUE_DROP_BACKTRACE_FREQUENCY 100 +#define QUEUE_DROP_BACKTRACE_MAX 10 #define EnqueueScreen(dev) dev->spriteInfo->sprite->pEnqueueScreen #define DequeueScreen(dev) dev->spriteInfo->sprite->pDequeueScreen @@ -74,7 +78,9 @@ typedef struct _EventQueue { HWEventQueueType head, tail; /* long for SetInputCheck */ CARD32 lastEventTime; /* to avoid time running backwards */ int lastMotion; /* device ID if last event motion? */ - EventRec events[QUEUE_SIZE]; /* static allocation for signals */ + EventRec *events; /* our queue as an array */ + size_t nevents; /* the number of buckets in our queue */ + size_t dropped; /* counter for number of consecutive dropped events */ mieqHandler handlers[128]; /* custom event handler */ } EventQueueRec, *EventQueuePtr; @@ -99,25 +105,87 @@ static inline void wait_for_server_init(void) { } #endif +static size_t +mieqNumEnqueued(EventQueuePtr eventQueue) { + size_t n_enqueued = 0; + if (eventQueue->nevents) { + /* % is not well-defined with negative numbers... sigh */ + n_enqueued = eventQueue->tail - eventQueue->head + eventQueue->nevents; + if (n_enqueued >= eventQueue->nevents) + n_enqueued -= eventQueue->nevents; + } + return n_enqueued; +} + +/* Pre-condition: Called with miEventQueueMutex held */ +static Bool +mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents) { + size_t i, n_enqueued, first_hunk; + EventRec *new_events; + + if (!eventQueue) { + ErrorF("[mi] mieqGrowQueue called with a NULL eventQueue\n"); + return FALSE; + } + + if (new_nevents <= eventQueue->nevents) + return FALSE; + + new_events = calloc(new_nevents, sizeof(EventRec)); + if (new_events == NULL) { + ErrorF("[mi] mieqGrowQueue memory allocation error.\n"); + return FALSE; + } + + n_enqueued = mieqNumEnqueued(eventQueue); + + /* We block signals, so an mieqEnqueue triggered by SIGIO does not + * write to our queue as we are modifying it. + */ + OsBlockSignals(); + + /* First copy the existing events */ + first_hunk = eventQueue->nevents - eventQueue->head; + memcpy(new_events, + &eventQueue->events[eventQueue->head], + first_hunk * sizeof(EventRec)); + memcpy(&new_events[first_hunk], + eventQueue->events, + eventQueue->head * sizeof(EventRec)); + + /* Initialize the new portion */ + for (i = eventQueue->nevents; i < new_nevents; i++) { + InternalEvent* evlist = InitEventList(1); + if (!evlist) { + size_t j; + for (j = 0; j < i; j++) + FreeEventList(new_events[j].events, 1); + free(new_events); + OsReleaseSignals(); + return FALSE; + } + new_events[i].events = evlist; + } + + /* And update our record */ + eventQueue->tail = n_enqueued; + eventQueue->head = 0; + eventQueue->nevents = new_nevents; + free(eventQueue->events); + eventQueue->events = new_events; + + OsReleaseSignals(); + return TRUE; +} + Bool mieqInit(void) { - int i; - - miEventQueue.head = miEventQueue.tail = 0; + memset(&miEventQueue, 0, sizeof(miEventQueue)); miEventQueue.lastEventTime = GetTimeInMillis (); - miEventQueue.lastMotion = FALSE; - for (i = 0; i < 128; i++) - miEventQueue.handlers[i] = NULL; - for (i = 0; i < QUEUE_SIZE; i++) - { - if (miEventQueue.events[i].events == NULL) { - InternalEvent* evlist = InitEventList(1); - if (!evlist) - FatalError("Could not allocate event queue.\n"); - miEventQueue.events[i].events = evlist; - } - } + + if(!mieqGrowQueue(&miEventQueue, QUEUE_INITIAL_SIZE)) + FatalError("Could not allocate event queue.\n"); SetInputCheck(&miEventQueue.head, &miEventQueue.tail); return TRUE; @@ -127,13 +195,14 @@ void mieqFini(void) { int i; - for (i = 0; i < QUEUE_SIZE; i++) + for (i = 0; i < miEventQueue.nevents; i++) { if (miEventQueue.events[i].events != NULL) { FreeEventList(miEventQueue.events[i].events, 1); miEventQueue.events[i].events = NULL; } } + free(miEventQueue.events); } /* @@ -165,26 +234,31 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) if (isMotion && isMotion == miEventQueue.lastMotion && oldtail != miEventQueue.head) { - oldtail = (oldtail - 1) % QUEUE_SIZE; - } - else { - static int stuck = 0; + oldtail = (oldtail - 1) % miEventQueue.nevents; + } else if (((oldtail + 1) % miEventQueue.nevents) == miEventQueue.head) { /* Toss events which come in late. Usually this means your server's * stuck in an infinite loop somewhere, but SIGIO is still getting - * handled. */ - if (((oldtail + 1) % QUEUE_SIZE) == miEventQueue.head) { - if (!stuck) { - ErrorF("[mi] EQ overflowing. The server is probably stuck " - "in an infinite loop.\n"); - xorg_backtrace(); - stuck = 1; + * handled. + */ + miEventQueue.dropped++; + if (miEventQueue.dropped == 1) { + ErrorF("[mi] EQ overflowing. Additional events will be discarded until existing events are processed.\n"); + xorg_backtrace(); + ErrorF("[mi] These backtraces from mieqEnqueue may point to a culprit higher up the stack.\n"); + ErrorF("[mi] mieq is *NOT* the cause. It is a victim.\n"); + } else if (miEventQueue.dropped % QUEUE_DROP_BACKTRACE_FREQUENCY == 0 && + miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY <= QUEUE_DROP_BACKTRACE_MAX) { + ErrorF("[mi] EQ overflow continuing. %lu events have been dropped.\n", miEventQueue.dropped); + if (miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY == QUEUE_DROP_BACKTRACE_MAX) { + ErrorF("[mi] No further overflow reports will be reported until the clog is cleared.\n"); } + xorg_backtrace(); + } + #ifdef XQUARTZ - pthread_mutex_unlock(&miEventQueueMutex); + pthread_mutex_unlock(&miEventQueueMutex); #endif - return; - } - stuck = 0; + return; } evlen = e->any.length; @@ -203,7 +277,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) miEventQueue.events[oldtail].pDev = pDev; miEventQueue.lastMotion = isMotion; - miEventQueue.tail = (oldtail + 1) % QUEUE_SIZE; + miEventQueue.tail = (oldtail + 1) % miEventQueue.nevents; #ifdef XQUARTZ pthread_mutex_unlock(&miEventQueueMutex); #endif @@ -437,11 +511,28 @@ mieqProcessInputEvents(void) static InternalEvent event; DeviceIntPtr dev = NULL, master = NULL; + size_t n_enqueued; #ifdef XQUARTZ pthread_mutex_lock(&miEventQueueMutex); #endif - + + /* Grow our queue if we are reaching capacity: > 50% full */ + n_enqueued = mieqNumEnqueued(&miEventQueue); + if (n_enqueued >= (miEventQueue.nevents >> 1) && + miEventQueue.nevents < QUEUE_MAXIMUM_SIZE) { + ErrorF("[mi] Increasing EQ size to %lu to prevent dropped events.\n", miEventQueue.nevents << 1); + if (!mieqGrowQueue(&miEventQueue, miEventQueue.nevents << 1)) { + ErrorF("[mi] Increasing the size of EQ failed.\n"); + } + } + + if (miEventQueue.dropped) { + ErrorF("[mi] EQ processing has resumed after %lu dropped events.\n", miEventQueue.dropped); + ErrorF("[mi] This may be caused my a misbehaving driver monopolizing the server's resources.\n"); + miEventQueue.dropped = 0; + } + while (miEventQueue.head != miEventQueue.tail) { e = &miEventQueue.events[miEventQueue.head]; @@ -449,7 +540,7 @@ mieqProcessInputEvents(void) dev = e->pDev; screen = e->pScreen; - miEventQueue.head = (miEventQueue.head + 1) % QUEUE_SIZE; + miEventQueue.head = (miEventQueue.head + 1) % miEventQueue.nevents; #ifdef XQUARTZ pthread_mutex_unlock(&miEventQueueMutex); commit 09eaa1f6f19f9a85a3cb74a18ac898162db451df Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 30 14:55:06 2010 -0700 configure.ac: Add -fno-strict-aliasing to CFLAGS This should force the server to have -fno-strict-aliasing even once it is removed from the warning flags. See: https://bugs.freedesktop.org/show_bug.cgi?id=31238 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Gaetan Nadon <memsize at videotron.ca> diff --git a/configure.ac b/configure.ac index 4bfa82c..63d59f9 100644 --- a/configure.ac +++ b/configure.ac @@ -87,6 +87,12 @@ XORG_PROG_RAWCPP # easier overrides at build time. XSERVER_CFLAGS='$(CWARNFLAGS)' +dnl Explicitly add -fno-strict-aliasing since this option should disappear +dnl from util-macros CWARNFLAGS +if test "x$GCC" = xyes ; then + XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing" +fi + dnl Check for dtrace program (needed to build Xserver dtrace probes) dnl Also checks for <sys/sdt.h>, since some Linux distros have an dnl ISDN trace program named dtrace commit a046d649e4c7e4d28f350382dcdd293e92a59aad Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Wed Oct 5 15:02:52 2011 -0700 test: Silence some debug lines from the input unit tests Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/test/input.c b/test/input.c index 3475197..52bc2f5 100644 --- a/test/input.c +++ b/test/input.c @@ -1480,8 +1480,6 @@ _test_double_fp16_values(double orig_d) { FP1616 first_fp16, final_fp16; double final_d; - char first_fp16_s[64]; - char final_fp16_s[64]; if (orig_d > 0x7FFF) { printf("Test out of range\n"); @@ -1492,10 +1490,15 @@ _test_double_fp16_values(double orig_d) final_d = fp1616_to_double(first_fp16); final_fp16 = double_to_fp1616(final_d); - snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff); - snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff); - - printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s); + /* { + * char first_fp16_s[64]; + * char final_fp16_s[64]; + * snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff); + * snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff); + * + * printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s); + * } + */ /* since we lose precision, we only do rough range testing */ assert(final_d > orig_d - 0.1); commit 8db554d2d830953de3c6d0cbf58e23d53d89009f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 14:28:56 2011 -0700 Xnest: Fix DestroyNotify handler This partially reverts the unwanted changes that crept into c13a48e74ec89eafa9b529a87253a631ef02f2e2 Reported-by: Julien Cristau <jcristau at debian.org> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Julien Cristau <jcristau at debian.org> diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index 2399313..619427d 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -198,8 +198,6 @@ xnestCollectEvents(void) case DestroyNotify: if (xnestParentWindow != (Window) 0 && X.xdestroywindow.window == xnestParentWindow) - CloseWellKnownConnections(); - OsCleanup(1); exit (0); break; From jeremyhu at kemper.freedesktop.org Mon Oct 24 18:32:41 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 24 Oct 2011 18:32:41 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' - 4 commits Message-ID: <20111025013241.A903AC0001@kemper.freedesktop.org> hw/xnest/Keyboard.c | 25 ++++++- hw/xquartz/xpr/appledri.c | 149 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 160 insertions(+), 14 deletions(-) New commits: commit 7be5492bcfab540676d6f849b85ad3db64a5ada0 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 21 10:27:16 2011 -0700 XQuartz: appledri: Allow byte swapped requests Even though it's only valid when local, it is possible for a local client and the server to not match endianness, such as when running a ppc application under Rosetta. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 1c8bda798b4480bab0f0da6f531e4770c7a1f771) diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 1d37de2..129fc78 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -2,7 +2,7 @@ Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 2000 VA Linux Systems, Inc. -Copyright (c) 2002, 2009 Apple Computer, Inc. +Copyright (c) 2002, 2009-2011 Apple Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -416,21 +416,113 @@ SProcAppleDRIQueryVersion( } static int +SProcAppleDRIQueryDirectRenderingCapable( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIQueryDirectRenderingCapableReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + return ProcAppleDRIQueryDirectRenderingCapable(client); +} + +static int +SProcAppleDRIAuthConnection( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIAuthConnectionReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->magic, n); + return ProcAppleDRIAuthConnection(client); +} + +static int +SProcAppleDRICreateSurface( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRICreateSurfaceReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->drawable, n); + swapl(&stuff->client_id, n); + return ProcAppleDRICreateSurface(client); +} + +static int +SProcAppleDRIDestroySurface( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIDestroySurfaceReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->drawable, n); + return ProcAppleDRIDestroySurface(client); +} + +static int +SProcAppleDRICreatePixmap( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRICreatePixmapReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->drawable, n); + return ProcAppleDRICreatePixmap(client); +} + +static int +SProcAppleDRIDestroyPixmap( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIDestroyPixmapReq); + swaps(&stuff->length, n); + swapl(&stuff->drawable, n); + return ProcAppleDRIDestroyPixmap(client); +} + +static int SProcAppleDRIDispatch ( register ClientPtr client ) { REQUEST(xReq); - /* It is bound to be non-local when there is byte swapping */ + switch (stuff->data) + { + case X_AppleDRIQueryVersion: + return SProcAppleDRIQueryVersion(client); + case X_AppleDRIQueryDirectRenderingCapable: + return SProcAppleDRIQueryDirectRenderingCapable(client); + } + if (!LocalClient(client)) return DRIErrorBase + AppleDRIClientNotLocal; - /* only local clients are allowed DRI access */ switch (stuff->data) { - case X_AppleDRIQueryVersion: - return SProcAppleDRIQueryVersion(client); + case X_AppleDRIAuthConnection: + return SProcAppleDRIAuthConnection(client); + case X_AppleDRICreateSurface: + return SProcAppleDRICreateSurface(client); + case X_AppleDRIDestroySurface: + return SProcAppleDRIDestroySurface(client); + case X_AppleDRICreatePixmap: + return SProcAppleDRICreatePixmap(client); + case X_AppleDRIDestroyPixmap: + return SProcAppleDRIDestroyPixmap(client); + default: return BadRequest; } commit 0ad049706d2fa8ff2758c42bdd412fb62bb1e86a Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 22:34:44 2011 -0700 XQuartz: appledri: Fix byte swapping in replies Even though it's only valid when local, it is possible for a local client and the server to not match endianness, such as when running a ppc application under Rosetta. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> (cherry picked from commit 14205ade0c750191bf43fba8bd55c65dba912cf4) Conflicts: hw/xquartz/xpr/appledri.c Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index e1b4134..1d37de2 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -91,7 +91,6 @@ ProcAppleDRIQueryVersion( ) { xAppleDRIQueryVersionReply rep; - register int n; REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq); rep.type = X_Reply; @@ -101,8 +100,12 @@ ProcAppleDRIQueryVersion( rep.minorVersion = SERVER_APPLEDRI_MINOR_VERSION; rep.patchVersion = SERVER_APPLEDRI_PATCH_VERSION; if (client->swapped) { + register int n; swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + swapl(&rep.patchVersion, n); } WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep); return Success; @@ -134,6 +137,12 @@ ProcAppleDRIQueryDirectRenderingCapable( if (!LocalClient(client)) rep.isCapable = 0; + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + } + WriteToClient(client, sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep); return Success; @@ -158,6 +167,14 @@ ProcAppleDRIAuthConnection( ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic); rep.authenticated = 0; } + + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.authenticated, n); /* Yes, this is a CARD32 ... sigh */ + } + WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep); return Success; } @@ -217,6 +234,15 @@ ProcAppleDRICreateSurface( rep.key_1 = key[1]; rep.uid = sid; + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.key_0, n); + swapl(&rep.key_1, n); + swapl(&rep.uid, n); + } + WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep); return Success; } @@ -278,7 +304,6 @@ ProcAppleDRICreatePixmap(ClientPtr client) rep.stringLength = strlen(path) + 1; - /* No need for swapping, because this only runs if LocalClient is true. */ rep.type = X_Reply; rep.length = bytes_to_int32(rep.stringLength); rep.sequenceNumber = client->sequence; @@ -291,8 +316,20 @@ ProcAppleDRICreatePixmap(ClientPtr client) if(sizeof(rep) != sz_xAppleDRICreatePixmapReply) ErrorF("error sizeof(rep) is %zu\n", sizeof(rep)); - WriteReplyToClient(client, sizeof(rep), &rep); - (void)WriteToClient(client, rep.stringLength, path); + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.stringLength, n); + swapl(&rep.width, n); + swapl(&rep.height, n); + swapl(&rep.pitch, n); + swapl(&rep.bpp, n); + swapl(&rep.size, n); + } + + WriteToClient(client, sizeof(rep), &rep); + WriteToClient(client, rep.stringLength, path); return Success; } commit 3b931c92764fc4e6417f1f38a67114b8c7442fc2 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 22:23:07 2011 -0700 XQuartz: appledri: Set the correct reply length for XAppleDRICreatePixmap http://xquartz.macosforge.org/trac/ticket/508 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> (cherry picked from commit 2ba0ac202ad64eb4a555715980ba538de19c9fd7) diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index ff70a38..e1b4134 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -280,7 +280,7 @@ ProcAppleDRICreatePixmap(ClientPtr client) /* No need for swapping, because this only runs if LocalClient is true. */ rep.type = X_Reply; - rep.length = sizeof(rep) + rep.stringLength; + rep.length = bytes_to_int32(rep.stringLength); rep.sequenceNumber = client->sequence; rep.width = width; rep.height = height; commit f22a41416b9795c778deeae6406cd33d18f13fa3 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 16 02:12:38 2011 -0700 Xnest: Match the host's keymap This was a regression. Introduced by: 08363c5830bdea34012dcd954b45ccfdc79a3a7e and 32db27a7f867b503c2840ca7b815e96d10be9210 Masked by: 1e69fd4a60147287b31e53bfc61543fb17bb82c8 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> (cherry picked from commit 83fef4235db86343477b4ec9858c6ba35e1aa7d9) diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index ec629dc..5ef376b 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -114,11 +114,13 @@ xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) int xnestKeyboardProc(DeviceIntPtr pDev, int onoff) { + XModifierKeymap *modifier_keymap; KeySym *keymap; int mapWidth; int min_keycode, max_keycode; KeySymsRec keySyms; - int i; + CARD8 modmap[MAP_LENGTH]; + int i, j; XKeyboardState values; XkbDescPtr xkb; int op, event, error, major, minor; @@ -130,7 +132,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) #ifdef _XSERVER64 { KeySym64 *keymap64; - int i, len; + int len; keymap64 = XGetKeyboardMapping(xnestDisplay, min_keycode, max_keycode - min_keycode + 1, @@ -147,7 +149,17 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) max_keycode - min_keycode + 1, &mapWidth); #endif - + + memset(modmap, 0, sizeof(modmap)); + modifier_keymap = XGetModifierMapping(xnestDisplay); + for (j = 0; j < 8; j++) + for(i = 0; i < modifier_keymap->max_keypermod; i++) { + CARD8 keycode; + if ((keycode = modifier_keymap->modifiermap[j * modifier_keymap->max_keypermod + i])) + modmap[keycode] |= 1<<j; + } + XFreeModifiermap(modifier_keymap); + keySyms.minKeyCode = min_keycode; keySyms.maxKeyCode = max_keycode; keySyms.mapWidth = mapWidth; @@ -165,7 +177,12 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb); InitKeyboardDeviceStruct(pDev, NULL, - xnestBell, xnestChangeKeyboardControl); + xnestBell, xnestChangeKeyboardControl); + + XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); + XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); XkbFreeKeyboard(xkb, 0, False); free(keymap); From keithp at kemper.freedesktop.org Mon Oct 24 19:00:22 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 24 Oct 2011 19:00:22 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111025020023.AE7D0C0001@kemper.freedesktop.org> hw/vfb/InitOutput.c | 2 ++ 1 file changed, 2 insertions(+) New commits: commit 7d50211ab57a35910d79fc3f67ae89aff91fa995 Author: Christopher Yeleighton <giecrilj at stegny.2a.pl> Date: Mon Oct 24 18:47:06 2011 -0700 Bug 38420: Xvfb crashes in miInitVisuals() when started with depth=2 https://bugs.freedesktop.org/show_bug.cgi?id=38420 Exit with fatal error message, not segfault. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index 0e701e5..1218547 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -863,6 +863,8 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) (1 << DirectColor)), 10, TrueColor, 0x3ff00000, 0x000ffc00, 0x000003ff); break; + default: + return FALSE; } miSetPixmapDepths (); From keithp at kemper.freedesktop.org Mon Oct 24 22:19:34 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 24 Oct 2011 22:19:34 -0700 (PDT) Subject: xserver: Branch 'master' - 18 commits Message-ID: <20111025051935.21770C0001@kemper.freedesktop.org> Xi/exevents.c | 20 ++++- Xi/xiquerydevice.c | 7 - dix/devices.c | 2 dix/eventconvert.c | 67 +++++++++++++++--- dix/getevents.c | 10 +- dix/inpututils.c | 34 ++++----- dix/ptrveloc.c | 4 - hw/kdrive/src/kinput.c | 139 +++++++++++++++++++++----------------- hw/xfree86/common/xf86Config.c | 16 +++- hw/xfree86/common/xf86Init.c | 29 ------- hw/xfree86/common/xf86Option.c | 3 hw/xfree86/common/xf86Optionstr.h | 13 --- hw/xfree86/common/xf86Xinput.c | 5 - hw/xfree86/doc/ddxDesign.xml | 4 - hw/xfree86/parser/Flags.c | 5 - hw/xfree86/parser/Layout.c | 2 include/eventstr.h | 1 include/exevents.h | 3 include/input.h | 3 include/inputstr.h | 7 - include/list.h | 12 +++ include/optionstr.h | 14 +++ test/xi2/protocol-eventconvert.c | 27 ++++++- xkb/xkbActions.c | 7 + 24 files changed, 265 insertions(+), 169 deletions(-) New commits: commit 5701ab4a441eb113abd0851b0d71b82d12112854 Merge: 7d50211... a41214b... Author: Keith Packard <keithp at keithp.com> Date: Mon Oct 24 22:09:00 2011 -0700 Merge remote-tracking branch 'whot/for-keith' commit a41214bc9a0f326c6dc129e4a6382efb8b826862 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 25 12:57:07 2011 +1000 kdrive: check for null memory, fix OOB If key/value allocation failed, don't bother adding another InputOption. And make sure the memory allocated is large enough for the trailing \0 Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index a1bbcaa..6a1ce49 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -1049,10 +1049,15 @@ KdGetOptions (InputOption **options, char *string) if (strchr(string, '=')) { tam_key = (strchr(string, '=') - string); - key = malloc(tam_key); + key = malloc(tam_key + 1); + if (!key) + goto out; + strncpy(key, string, tam_key); key[tam_key] = '\0'; value = strdup(strchr(string, '=') + 1); + if (!value) + goto out; } else { @@ -1064,6 +1069,7 @@ KdGetOptions (InputOption **options, char *string) if (newopt) *options = newopt; +out: free(key); free(value); commit ffe20acedb3cdc4811eb52f8fc540ba6af7339fa Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Thu Oct 20 16:42:20 2011 +1000 Use new FP1616/FP3232 conversion functions Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 9961d1b..5f543f6 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -41,6 +41,7 @@ #include "xserver-properties.h" #include "exevents.h" #include "xace.h" +#include "inpututils.h" #include "xiquerydevice.h" @@ -351,8 +352,7 @@ ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber, info->min.frac = 0; info->max.integral = v->axes[axisnumber].max_value; info->max.frac = 0; - info->value.integral = (int)v->axisVal[axisnumber]; - info->value.frac = (int)(v->axisVal[axisnumber] * (1 << 16) * (1 << 16)); + info->value = double_to_fp3232(v->axisVal[axisnumber]); info->resolution = v->axes[axisnumber].resolution; info->number = axisnumber; info->mode = valuator_get_mode(dev, axisnumber); @@ -402,8 +402,7 @@ ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo *info, int axisnumber) ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", axis->scroll.type); break; } - info->increment.integral = (int)axis->scroll.increment; - info->increment.frac = (unsigned int)(axis->scroll.increment * (1UL << 16) * (1UL << 16)); + info->increment = double_to_fp3232(axis->scroll.increment); info->sourceid = v->sourceid; info->flags = 0; diff --git a/dix/eventconvert.c b/dix/eventconvert.c index ff42b03..c9da396 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -49,6 +49,7 @@ #include "inpututils.h" #include "xiquerydevice.h" #include "xkbsrv.h" +#include "inpututils.h" static int countValuators(DeviceEvent *ev, int *first); @@ -686,9 +687,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); - axisval->integral = trunc(ev->valuators.data[i]); - axisval->frac = (ev->valuators.data[i] - axisval->integral) * - (1 << 16) * (1 << 16); + *axisval = double_to_fp3232(ev->valuators.data[i]); axisval++; } } @@ -732,13 +731,8 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) if (BitIsOn(ev->valuators.mask, i)) { SetBit(ptr, i); - axisval->integral = trunc(ev->valuators.data[i]); - axisval->frac = (ev->valuators.data[i] - axisval->integral) * - (1 << 16) * (1 << 16); - axisval_raw->integral = trunc(ev->valuators.data_raw[i]); - axisval_raw->frac = - (ev->valuators.data_raw[i] - axisval_raw->integral) * - (1 << 16) * (1 << 16); + *axisval = double_to_fp3232(ev->valuators.data[i]); + *axisval_raw = double_to_fp3232(ev->valuators.data_raw[i]); axisval++; axisval_raw++; } commit 7500d841f4c709ae0edc6420332096d3b9ef9fcc Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Thu Oct 20 16:49:28 2011 +1000 test: fix test with new double -> fp3232 conversion functions Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Tested-by: Dave Airlie <airlied at redhat.com> Reviewed-by: Dave Airlie <airlied at redhat.com> diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index 41a3001..ba2d96a 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -30,6 +30,7 @@ #include "eventstr.h" #include "eventconvert.h" #include "exevents.h" +#include "inpututils.h" #include <X11/extensions/XI2proto.h> static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, @@ -104,8 +105,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4); value += nvals; - vi.integral = trunc(in->valuators.data[i]); - vi.frac = in->valuators.data[i] - vi.integral; + vi = double_to_fp3232(in->valuators.data[i]); vo.integral = value->integral; vo.frac = value->frac; @@ -120,8 +120,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, raw_value = value + bits_set; - vi.integral = trunc(in->valuators.data_raw[i]); - vi.frac = in->valuators.data_raw[i] - vi.integral; + vi = double_to_fp3232(in->valuators.data_raw[i]); vo.integral = raw_value->integral; vo.frac = raw_value->frac; commit 4bb5d8fae4f9a70f12591315f0b267a2ea826a0c Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Oct 19 13:17:51 2011 +1000 Xi: send DeviceChangedEvents when the scroll valuators change value Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index 7afb69e..053c76f 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1103,6 +1103,8 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr { AxisInfoPtr ax; int *current_ax; + InternalEvent dce; + DeviceIntPtr master; if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes) return FALSE; @@ -1139,7 +1141,16 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr ax->scroll.type = type; ax->scroll.increment = increment; ax->scroll.flags = flags; - /* FIXME: generate DeviceChanged Events */ + + master = GetMaster(dev, MASTER_ATTACHED); + CreateClassesChangedEvent(&dce, master, dev, DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE); + XISendDeviceChangedEvent(dev, &dce.changed_event); + + /* if the current slave is us, update the master. If not, we'll update + * whenever the next slave switch happens anyway. CMDC sends the event + * for us */ + if (master && master->lastSlave == dev) + ChangeMasterDeviceClasses(master, &dce.changed_event); return TRUE; } commit 1f4af6c12fb5d4c19f4eac3df768517c9132cc88 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Oct 19 12:28:37 2011 +1000 dix: accept a NULL master for CreateClassesChangedEvent If a floating device changes, the master is NULL but we must still create a DCE for it. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 8057e62..4845a10 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -218,7 +218,7 @@ CreateClassesChangedEvent(InternalEvent* event, dce = &event->changed_event; memset(dce, 0, sizeof(DeviceChangedEvent)); dce->deviceid = slave->id; - dce->masterid = master->id; + dce->masterid = master ? master->id : 0; dce->header = ET_Internal; dce->length = sizeof(DeviceChangedEvent); dce->type = ET_DeviceChanged; commit d77dec6971e4a0b306c8dbd5adf627908d7972cb Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Oct 19 12:11:16 2011 +1000 Xi: ensure the deviceid for DeviceChangedEvents is always the right one If we're sending the event for a given device, make sure the deviceid is that of the device. This allows callers to use the same DCE for slave and master without having to fiddle the DCE's internal fields. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index 2ae5a62..7afb69e 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -699,6 +699,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) /* FIXME: the classes may have changed since we generated the event. */ DeepCopyDeviceClasses(slave, device, dce); + dce->deviceid = device->id; XISendDeviceChangedEvent(device, dce); } commit e9dee21fa3213bfe87b2b728a38eb41d3ba0e664 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 18 17:47:59 2011 +1000 dix: pass the flags into the CreateClassesChangedEvent No effective functional changes, prep work for future patches. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/getevents.c b/dix/getevents.c index 31c69bf..8057e62 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -209,7 +209,7 @@ void CreateClassesChangedEvent(InternalEvent* event, DeviceIntPtr master, DeviceIntPtr slave, - int type) + int flags) { int i; DeviceChangedEvent *dce; @@ -223,8 +223,7 @@ CreateClassesChangedEvent(InternalEvent* event, dce->length = sizeof(DeviceChangedEvent); dce->type = ET_DeviceChanged; dce->time = ms; - dce->flags = type; - dce->flags |= DEVCHANGE_SLAVE_SWITCH; + dce->flags = flags; dce->sourceid = slave->id; if (slave->button) @@ -674,7 +673,7 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve if (master && master->last.slave != dev) { - CreateClassesChangedEvent(events, master, dev, type); + CreateClassesChangedEvent(events, master, dev, type | DEVCHANGE_SLAVE_SWITCH); if (IsPointerDevice(master)) { updateSlaveDeviceCoords(master, dev); diff --git a/include/input.h b/include/input.h index a1930bb..4eee47c 100644 --- a/include/input.h +++ b/include/input.h @@ -427,7 +427,8 @@ extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events); extern void CreateClassesChangedEvent(InternalEvent *event, DeviceIntPtr master, DeviceIntPtr slave, - int type); + int flags); + extern InternalEvent * UpdateFromMaster( InternalEvent *events, DeviceIntPtr pDev, commit fcdd2587a17437b643b4592aa7f65d11c05a4cd8 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 18 17:41:29 2011 +1000 dix: drop unused argument from XISendDeviceChangedEvent Instead of device and master (and just using master), drop the master argument and let the callers pass in the device the event is to be sent for. No effective functional changes. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/Xi/exevents.c b/Xi/exevents.c index 74a78ec..2ae5a62 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -651,7 +651,7 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dc * Send an XI2 DeviceChangedEvent to all interested clients. */ void -XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChangedEvent *dce) +XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce) { xXIDeviceChangedEvent *dcce; int rc; @@ -665,7 +665,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged /* we don't actually swap if there's a NullClient, swapping is done * later when event is delivered. */ - SendEventToAllWindows(master, XI_DeviceChangedMask, (xEvent*)dcce, 1); + SendEventToAllWindows(device, XI_DeviceChangedMask, (xEvent*)dcce, 1); free(dcce); } @@ -699,7 +699,7 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) /* FIXME: the classes may have changed since we generated the event. */ DeepCopyDeviceClasses(slave, device, dce); - XISendDeviceChangedEvent(slave, device, dce); + XISendDeviceChangedEvent(device, dce); } /** diff --git a/dix/devices.c b/dix/devices.c index 64557aa..7c196e0 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2360,7 +2360,7 @@ RecalculateMasterButtons(DeviceIntPtr slave) event.keys.max_keycode = master->key->xkbInfo->desc->max_key_code; } - XISendDeviceChangedEvent(master, master, &event); + XISendDeviceChangedEvent(master, &event); } } diff --git a/include/exevents.h b/include/exevents.h index 4fe6c61..720fb2e 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -322,8 +322,7 @@ extern int XIShouldNotify(ClientPtr client, DeviceIntPtr dev); extern void -XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, - DeviceChangedEvent *dce); +XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce); extern int XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, commit 8473e441b0f832775153281bc3df5e2d4feb2b36 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 18 17:11:27 2011 +1000 dix: add ScrollInfo to DeviceChangedEvents 3304bbff9b4ed63f1a47410a5320a136420ba2c6 added smooth scrolling support for pointer events and for XIQueryDevice but didn't add the matching parts to XIDeviceChangedEvents. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 189cb85..ff42b03 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -43,8 +43,10 @@ #include "inputstr.h" #include "misc.h" #include "eventstr.h" +#include "exevents.h" #include "exglobals.h" #include "eventconvert.h" +#include "inpututils.h" #include "xiquerydevice.h" #include "xkbsrv.h" @@ -482,6 +484,40 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo *info, int axisnumbe } static int +appendScrollInfo(DeviceChangedEvent *dce, xXIScrollInfo *info, int axisnumber) +{ + if (dce->valuators[axisnumber].scroll.type == SCROLL_TYPE_NONE) + return 0; + + info->type = XIScrollClass; + info->length = sizeof(xXIScrollInfo)/4; + info->number = axisnumber; + switch(dce->valuators[axisnumber].scroll.type) + { + case SCROLL_TYPE_VERTICAL: + info->scroll_type = XIScrollTypeVertical; + break; + case SCROLL_TYPE_HORIZONTAL: + info->scroll_type = XIScrollTypeHorizontal; + break; + default: + ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", dce->valuators[axisnumber].scroll.type); + break; + } + info->increment = double_to_fp3232(dce->valuators[axisnumber].scroll.increment); + info->sourceid = dce->sourceid; + + info->flags = 0; + + if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_DONT_EMULATE) + info->flags |= XIScrollFlagNoEmulation; + if (dce->valuators[axisnumber].scroll.flags & SCROLL_FLAG_PREFERRED) + info->flags |= XIScrollFlagPreferred; + + return info->length * 4; +} + +static int eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi) { xXIDeviceChangedEvent *dcce; @@ -496,8 +532,16 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi) len += pad_to_int32(bits_to_bytes(dce->buttons.num_buttons)); } if (dce->num_valuators) + { + int i; + len += sizeof(xXIValuatorInfo) * dce->num_valuators; + for (i = 0; i < dce->num_valuators; i++) + if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE) + len += sizeof(xXIScrollInfo); + } + nkeys = (dce->keys.max_keycode > 0) ? dce->keys.max_keycode - dce->keys.min_keycode + 1 : 0; if (nkeys > 0) @@ -543,6 +587,15 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi) dcce->num_classes += dce->num_valuators; for (i = 0; i < dce->num_valuators; i++) ptr += appendValuatorInfo(dce, (xXIValuatorInfo*)ptr, i); + + for (i = 0; i < dce->num_valuators; i++) + { + if (dce->valuators[i].scroll.type != SCROLL_TYPE_NONE) + { + dcce->num_classes++; + ptr += appendScrollInfo(dce, (xXIScrollInfo*)ptr, i); + } + } } *xi = (xEvent*)dcce; diff --git a/dix/getevents.c b/dix/getevents.c index 7be39dc..31c69bf 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -243,6 +243,7 @@ CreateClassesChangedEvent(InternalEvent* event, dce->valuators[i].resolution = slave->valuator->axes[i].resolution; dce->valuators[i].mode = slave->valuator->axes[i].mode; dce->valuators[i].name = slave->valuator->axes[i].label; + dce->valuators[i].scroll = slave->valuator->axes[i].scroll; } } if (slave->key) diff --git a/include/eventstr.h b/include/eventstr.h index 2de077f..4d836fb 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -153,6 +153,7 @@ struct _DeviceChangedEvent uint32_t resolution; /**< Resolution counts/m */ uint8_t mode; /**< Relative or Absolute */ Atom name; /**< Axis name */ + ScrollInfo scroll; /**< Smooth scrolling info */ } valuators[MAX_VALUATORS]; struct { diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index bfa23b5..41a3001 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -748,6 +748,26 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, } break; + case XIScrollClass: + { + xXIScrollInfo *s = (xXIScrollInfo*)any; + assert(s->length == + bytes_to_int32(sizeof(xXIScrollInfo))); + + assert(s->sourceid == in->sourceid); + assert(s->number < in->num_valuators); + switch(s->type) + { + case XIScrollTypeVertical: + assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_VERTICAL); + break; + case XIScrollTypeHorizontal: + assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_HORIZONTAL); + break; + } + if (s->flags & XIScrollFlagPreferred) + assert(in->valuators[s->number].scroll.flags & SCROLL_FLAG_PREFERRED); + } default: printf("Invalid class type.\n\n"); assert(1); commit e3f6a76dd480717eae4b17ad8e2ff707de2ffe4c Author: Andreas Wettstein <wettstein509 at solnet.ch> Date: Thu Aug 11 16:33:33 2011 +1000 xkb: Support noLock and noUnlock flags for LockMods These flags are required by the XKB spec section 6.3. Signed-off-by: Andreas Wettstein <wettstein509 at solnet.ch> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 4b5405a..000002a 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -344,15 +344,18 @@ _XkbFilterLockState( XkbSrvInfoPtr xkbi, filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; - filter->priv = 0; + filter->priv = xkbi->state.locked_mods&pAction->mods.mask; filter->filter = _XkbFilterLockState; filter->upAction = *pAction; - xkbi->state.locked_mods^= pAction->mods.mask; + if (!(filter->upAction.mods.flags&XkbSA_LockNoLock)) + xkbi->state.locked_mods|= pAction->mods.mask; xkbi->setMods = pAction->mods.mask; } else if (filter->keycode==keycode) { filter->active = 0; xkbi->clearMods = filter->upAction.mods.mask; + if (!(filter->upAction.mods.flags&XkbSA_LockNoUnlock)) + xkbi->state.locked_mods&= ~filter->priv; } return 1; } commit 6f33593dc087d367d899d1cb6e6e30b282d922e2 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Oct 21 09:09:55 2011 +1000 xfree86 doc: replace driver "keyboard" with "kbd" We've deprecated keyboard a long time ago Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml index a4baad5..0d5e952 100644 --- a/hw/xfree86/doc/ddxDesign.xml +++ b/hw/xfree86/doc/ddxDesign.xml @@ -189,7 +189,7 @@ following changes: <varlistentry><term><emphasis>Keyboard</emphasis></term> <listitem><literallayout> &k.identifier; "Implicit Core Keyboard" - &k.driver; "keyboard" + &k.driver; "kbd" </literallayout></listitem></varlistentry> <varlistentry><term><emphasis>Pointer</emphasis></term> <listitem><literallayout> @@ -206,7 +206,7 @@ following changes: is no &k.serverlayout; section, if the <option>-screen</option> command line options is used, or if the &k.serverlayout; section doesn't reference any &k.inputdevice; sections. In this case, the first - sections with drivers "keyboard" and "mouse" are used as the core + sections with drivers "kbd" and "mouse" are used as the core keyboard and pointer respectively. </para> </sect2> commit e4cd24e717ef1059804b3f6bb483810b708cd56a Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Aug 5 14:48:02 2011 +1000 xfree86: use NewInputDeviceRequest for xorg.conf devices too Only use one init path for input devices - through NIDR. This requires that inp_driver and inp_identifier from the XF86ConfInputRec are copied over into the options for NIDR to see them. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 96e98c1..cb4be42 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1196,6 +1196,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (foundPointer) { Pointer->options = xf86AddNewOption(Pointer->options, "CorePointer", "on"); + Pointer->options = xf86AddNewOption(Pointer->options, + "driver", confInput->inp_driver); + Pointer->options = xf86AddNewOption(Pointer->options, + "identifier", confInput->inp_identifier); servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer); } } @@ -1286,6 +1290,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (foundKeyboard) { Keyboard->options = xf86AddNewOption(Keyboard->options, "CoreKeyboard", "on"); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "driver", confInput->inp_driver); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "identifier", confInput->inp_identifier); servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard); } } diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 74e0bc2..a0fdf29 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -811,21 +811,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) NULL); } -static InputInfoPtr -duplicateDevice(InputInfoPtr pInfo) -{ - InputInfoPtr dup = calloc(1, sizeof(InputInfoRec)); - if (dup) { - dup->name = strdup(pInfo->name); - dup->driver = strdup(pInfo->driver); - dup->options = xf86OptionListDuplicate(pInfo->options); - /* type_name is a const string */ - dup->type_name = pInfo->type_name; - dup->fd = -1; - } - return dup; -} - /** * Initialize all supported input devices present and referenced in the * xorg.conf. @@ -842,20 +827,8 @@ InitInput(int argc, char **argv) /* Initialize all configured input devices */ for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) { - InputInfoPtr dup; - /* Replace obsolete keyboard driver with kbd */ - if (!xf86NameCmp((*pInfo)->driver, "keyboard")) { - strcpy((*pInfo)->driver, "kbd"); - } - - /* Data passed into xf86NewInputDevice will be freed on shutdown. - * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any - * xorg.conf input devices in the second generation - */ - dup = duplicateDevice(*pInfo); - /* If one fails, the others will too */ - if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc) + if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc) break; } commit 1ecc427a39d41e723912492b846512fd0ad9af2d Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Aug 10 14:37:41 2011 +1000 dix: move #if statement to stop compiler warning ptrveloc.c: In function 'QueryTrackers': ptrveloc.c:598:34: warning: variable 'used_offset' set but not used [-Wunused-but-set-variable] used_offset is used, but only in the debugging code. Move the #if statement to ignore that warning. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 53a0d03..7b6f560 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -649,13 +649,13 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){ DebugAccelF("(dix prtacc) query: last tracker in effect\n"); used_offset = vel->num_tracker-1; } -#ifdef PTRACCEL_DEBUGGING if(used_offset >= 0){ +#ifdef PTRACCEL_DEBUGGING MotionTracker *tracker = TRACKER(vel, used_offset); DebugAccelF("(dix prtacc) result: offset %i [dx: %i dy: %i diff: %i]\n", used_offset, tracker->dx, tracker->dy, cur_t - tracker->time); - } #endif + } return result; } commit f9067c1dd8ce9058eb48a20dfae52bc8cf3a1e55 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Fri Aug 5 14:05:58 2011 +1000 xfree86: Fix a comment, the old function doesn't exist anymore Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index 1a1f42a..9c52878 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -299,7 +299,7 @@ xf86CheckPercentOption(XF86OptionPtr optlist, const char *name, double deflt) return LookupPercentOption(optlist, name, deflt, FALSE); } /* - * addNewOption() has the required property of replacing the option value + * xf86AddNewOption() has the required property of replacing the option value * if the option is already present. */ XF86OptionPtr commit aeab26e9e1751e1e3514798fa53e9bd604b0d254 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Aug 10 15:58:34 2011 +1000 xfree86: use xf86AddNewOption instead of xf86addNewOption The former strdups for us. If the strdup fails we miss out on the CorePointer option (default on anyway) and we're likely to fall over soon anyway, so let's pretend this is the same behaviour. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 5c46152..96e98c1 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1194,8 +1194,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (Pointer) foundPointer = configInput(Pointer, confInput, from); if (foundPointer) { - Pointer->options = xf86addNewOption(Pointer->options, - xnfstrdup("CorePointer"), "on"); + Pointer->options = xf86AddNewOption(Pointer->options, + "CorePointer", "on"); servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer); } } @@ -1284,8 +1284,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (Keyboard) foundKeyboard = configInput(Keyboard, confInput, from); if (foundKeyboard) { - Keyboard->options = xf86addNewOption(Keyboard->options, - xnfstrdup("CoreKeyboard"), "on"); + Keyboard->options = xf86AddNewOption(Keyboard->options, + "CoreKeyboard", "on"); servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard); } } commit c39c8d34282b82d73c3c69a16cf0c2816256d85b Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Wed Aug 10 14:38:58 2011 +1000 input: switch InputOption to use XF86OptionRec storage. Use the same struct for both InputOption and XF86OptionRec so we don't need to convert to and fro the two in the config backends. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Dan Nicholson <dbn.lists at gmail.com> Reviewed-by: Daniel Stone <daniel at fooishbar.org> diff --git a/dix/inpututils.c b/dix/inpututils.c index 2915e67..5797f92 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -38,6 +38,7 @@ #include "inpututils.h" #include "eventstr.h" #include "scrnintstr.h" +#include "optionstr.h" /* Check if a button map change is okay with the device. * Returns -1 for BadValue, as it collides with MappingBusy. */ @@ -670,8 +671,9 @@ point_on_screen(ScreenPtr pScreen, int x, int y) static void input_option_free(InputOption *o) { - free(o->key); - free(o->value); + free(o->opt_name); + free(o->opt_val); + free(o->opt_comment); free(o); } @@ -701,7 +703,7 @@ input_option_new(InputOption* list, const char *key, const char *value) if (list) { - nt_list_for_each_entry(opt, list, next) + nt_list_for_each_entry(opt, list, list.next) { if (strcmp(input_option_get_key(opt), key) == 0) { @@ -715,13 +717,13 @@ input_option_new(InputOption* list, const char *key, const char *value) if (!opt) return NULL; - nt_list_init(opt, next); + nt_list_init(opt, list.next); input_option_set_key(opt, key); input_option_set_value(opt, value); if (list) { - nt_list_append(opt, list, InputOption, next); + nt_list_append(opt, list, InputOption, list.next); return list; } else return opt; @@ -732,9 +734,9 @@ input_option_free_element(InputOption *list, const char *key) { InputOption *element; - nt_list_for_each_entry(element, list, next) { + nt_list_for_each_entry(element, list, list.next) { if (strcmp(input_option_get_key(element), key) == 0) { - nt_list_del(element, list, InputOption, next); + nt_list_del(element, list, InputOption, list.next); input_option_free(element); break; } @@ -750,8 +752,8 @@ input_option_free_list(InputOption **opt) { InputOption *element, *tmp; - nt_list_for_each_entry_safe(element, tmp, *opt, next) { - nt_list_del(element, *opt, InputOption, next); + nt_list_for_each_entry_safe(element, tmp, *opt, list.next) { + nt_list_del(element, *opt, InputOption, list.next); input_option_free(element); } *opt = NULL; @@ -768,7 +770,7 @@ input_option_find(InputOption *list, const char *key) { InputOption *element; - nt_list_for_each_entry(element, list, next) { + nt_list_for_each_entry(element, list, list.next) { if (strcmp(input_option_get_key(element), key) == 0) return element; } @@ -779,29 +781,29 @@ input_option_find(InputOption *list, const char *key) const char* input_option_get_key(const InputOption *opt) { - return opt->key; + return opt->opt_name; } const char* input_option_get_value(const InputOption *opt) { - return opt->value; + return opt->opt_val; } void input_option_set_key(InputOption *opt, const char *key) { - free(opt->key); + free(opt->opt_name); if (key) - opt->key = strdup(key); + opt->opt_name = strdup(key); } void input_option_set_value(InputOption *opt, const char *value) { - free(opt->value); + free(opt->opt_val); if (value) - opt->value = strdup(value); + opt->opt_val = strdup(value); } diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 15c9ae2..a1bbcaa 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -49,6 +49,7 @@ #include "eventstr.h" #include "xserver-properties.h" #include "inpututils.h" +#include "optionstr.h" #define AtomFromName(x) MakeAtom(x, strlen(x), 1) @@ -1074,7 +1075,7 @@ KdParseKbdOptions (KdKeyboardInfo *ki) { InputOption *option = NULL; - nt_list_for_each_entry(option, ki->options, next) + nt_list_for_each_entry(option, ki->options, list.next) { const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); @@ -1174,7 +1175,7 @@ KdParsePointerOptions (KdPointerInfo *pi) { InputOption *option = NULL; - nt_list_for_each_entry(option, pi->options, next) + nt_list_for_each_entry(option, pi->options, list.next) { const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); @@ -2222,7 +2223,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, KdPointerInfo *pi = NULL; KdKeyboardInfo *ki = NULL; - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); @@ -2267,7 +2268,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, /* FIXME: change this code below to use KdParseKbdOptions and * KdParsePointerOptions */ - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index 73b6573..1a1f42a 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -44,6 +44,7 @@ #include "xf86Xinput.h" #include "xf86Optrec.h" #include "xf86Parser.h" +#include "optionstr.h" static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, OptionInfoPtr p, Bool markUsed); diff --git a/hw/xfree86/common/xf86Optionstr.h b/hw/xfree86/common/xf86Optionstr.h index 8cc82d3..fc93856 100644 --- a/hw/xfree86/common/xf86Optionstr.h +++ b/hw/xfree86/common/xf86Optionstr.h @@ -24,16 +24,7 @@ #ifndef XF86OPTIONSTR_H #define XF86OPTIONSTR_H - -/* - * all records that need to be linked lists should contain a GenericList as - * their first field. - */ -typedef struct generic_list_rec -{ - void *next; -} -GenericListRec, *GenericListPtr, *glp; +#include "list.h" /* * All options are stored using this data type. @@ -48,6 +39,6 @@ typedef struct _XF86OptionRec } XF86OptionRec; -typedef struct _XF86OptionRec *XF86OptionPtr; +typedef struct _InputOption *XF86OptionPtr; #endif diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index ea1f927..425b359 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -68,6 +68,7 @@ #include "exglobals.h" #include "eventstr.h" #include "inpututils.h" +#include "optionstr.h" #include <string.h> /* InputClassMatches */ #ifdef HAVE_FNMATCH_H @@ -908,7 +909,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, if (!pInfo) return BadAlloc; - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { if (strcasecmp(input_option_get_key(option), "driver") == 0) { if (pInfo->driver) { rval = BadRequest; @@ -946,7 +947,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, } } - nt_list_for_each_entry(option, options, next) { + nt_list_for_each_entry(option, options, list.next) { /* Copy option key/value strings from the provided list */ pInfo->options = xf86AddNewOption(pInfo->options, input_option_get_key(option), diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c index 7a0794b..f0a6170 100644 --- a/hw/xfree86/parser/Flags.c +++ b/hw/xfree86/parser/Flags.c @@ -63,6 +63,7 @@ #include "Configint.h" #include <X11/Xfuncproto.h> #include "Xprintf.h" +#include "optionstr.h" extern LexRec val; @@ -203,7 +204,7 @@ addNewOption2 (XF86OptionPtr head, char *name, char *val, int used) free(new->opt_val); } else - new = calloc (1, sizeof (XF86OptionRec)); + new = calloc (1, sizeof (*new)); new->opt_name = name; new->opt_val = val; new->opt_used = used; @@ -284,7 +285,7 @@ xf86newOption(char *name, char *value) { XF86OptionPtr opt; - opt = calloc(1, sizeof (XF86OptionRec)); + opt = calloc(1, sizeof (*opt)); if (!opt) return NULL; diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c index e1f770b..4487b0d 100644 --- a/hw/xfree86/parser/Layout.c +++ b/hw/xfree86/parser/Layout.c @@ -63,7 +63,7 @@ #include "xf86tokens.h" #include "Configint.h" #include <string.h> - +#include "optionstr.h" /* Needed for auto server layout */ extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt); diff --git a/include/inputstr.h b/include/inputstr.h index 9d4108e..7a15540 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -621,11 +621,4 @@ static inline WindowPtr DeepestSpriteWin(SpritePtr sprite) return sprite->spriteTrace[sprite->spriteTraceGood - 1]; } -struct _InputOption { - char *key; - char *value; - struct _InputOption *next; -}; - - #endif /* INPUTSTRUCT_H */ diff --git a/include/list.h b/include/list.h index 7825dce..4706e17 100644 --- a/include/list.h +++ b/include/list.h @@ -438,4 +438,16 @@ list_is_empty(struct list *head) nt_list_init(__e, _member); \ } while(0) +/** + * DO NOT USE THIS. + * This is a remainder of the xfree86 DDX attempt of having a set of generic + * list functions. Unfortunately, the xf86OptionRec uses it and we can't + * easily get rid of it. Do not use for new code. + */ +typedef struct generic_list_rec +{ + void *next; +} +GenericListRec, *GenericListPtr, *glp; + #endif diff --git a/include/optionstr.h b/include/optionstr.h new file mode 100644 index 0000000..a71d245 --- /dev/null +++ b/include/optionstr.h @@ -0,0 +1,14 @@ +#ifndef OPTIONSTR_H_ +#define OPTIONSTR_H_ +#include "list.h" + + +struct _InputOption { + GenericListRec list; + char *opt_name; + char *opt_val; + int opt_used; + char *opt_comment; +}; + +#endif /* INPUTSTRUCT_H */ commit 16ac78a53c1edeae183db8672104587b306cfe13 Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 25 11:40:58 2011 +1000 kdrive: switch to new InputOption API. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Keith Packard <keithp at keithp.com> diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index c14dd82..15c9ae2 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -344,7 +344,7 @@ KdEnableInput (void) } static KdKeyboardDriver * -KdFindKeyboardDriver (char *name) +KdFindKeyboardDriver (const char *name) { KdKeyboardDriver *ret; @@ -361,7 +361,7 @@ KdFindKeyboardDriver (char *name) } static KdPointerDriver * -KdFindPointerDriver (char *name) +KdFindPointerDriver (const char *name) { KdPointerDriver *ret; @@ -1040,33 +1040,33 @@ KdRemovePointer (KdPointerInfo *pi) static Bool KdGetOptions (InputOption **options, char *string) { - InputOption *newopt = NULL, **tmpo = NULL; + InputOption *newopt = NULL; + char *key = NULL, + *value = NULL; int tam_key = 0; - newopt = calloc(1, sizeof (InputOption)); - if (!newopt) - return FALSE; - - for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next) - ; /* Hello, I'm here */ - *tmpo = newopt; - if (strchr(string, '=')) { tam_key = (strchr(string, '=') - string); - newopt->key = (char *)malloc(tam_key); - strncpy(newopt->key, string, tam_key); - newopt->key[tam_key] = '\0'; - newopt->value = strdup(strchr(string, '=') + 1); + key = malloc(tam_key); + strncpy(key, string, tam_key); + key[tam_key] = '\0'; + value = strdup(strchr(string, '=') + 1); } else { - newopt->key = strdup(string); - newopt->value = NULL; + key = strdup(string); + value = NULL; } - newopt->next = NULL; - return TRUE; + newopt = input_option_new(*options, key, value); + if (newopt) + *options = newopt; + + free(key); + free(value); + + return (newopt != NULL); } static void @@ -1074,23 +1074,26 @@ KdParseKbdOptions (KdKeyboardInfo *ki) { InputOption *option = NULL; - for (option = ki->options; option; option = option->next) + nt_list_for_each_entry(option, ki->options, next) { - if (strcasecmp(option->key, "XkbRules") == 0) - ki->xkbRules = option->value; - else if (strcasecmp(option->key, "XkbModel") == 0) - ki->xkbModel = option->value; - else if (strcasecmp(option->key, "XkbLayout") == 0) - ki->xkbLayout = option->value; - else if (strcasecmp(option->key, "XkbVariant") == 0) - ki->xkbVariant = option->value; - else if (strcasecmp(option->key, "XkbOptions") == 0) - ki->xkbOptions = option->value; - else if (!strcasecmp (option->key, "device")) - ki->path = strdup(option->value); + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (strcasecmp(key, "XkbRules") == 0) + ki->xkbRules = strdup(value); + else if (strcasecmp(key, "XkbModel") == 0) + ki->xkbModel = strdup(value); + else if (strcasecmp(key, "XkbLayout") == 0) + ki->xkbLayout = strdup(value); + else if (strcasecmp(key, "XkbVariant") == 0) + ki->xkbVariant = strdup(value); + else if (strcasecmp(key, "XkbOptions") == 0) + ki->xkbOptions = strdup(value); + else if (!strcasecmp (key, "device")) + ki->path = strdup(value); else ErrorF("Kbd option key (%s) of value (%s) not assigned!\n", - option->key, option->value); + key, value); } } @@ -1171,23 +1174,26 @@ KdParsePointerOptions (KdPointerInfo *pi) { InputOption *option = NULL; - for (option = pi->options; option; option = option->next) + nt_list_for_each_entry(option, pi->options, next) { - if (!strcmp (option->key, "emulatemiddle")) + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (!strcmp (key, "emulatemiddle")) pi->emulateMiddleButton = TRUE; - else if (!strcmp (option->key, "noemulatemiddle")) + else if (!strcmp (key, "noemulatemiddle")) pi->emulateMiddleButton = FALSE; - else if (!strcmp (option->key, "transformcoord")) + else if (!strcmp (key, "transformcoord")) pi->transformCoordinates = TRUE; - else if (!strcmp (option->key, "rawcoord")) + else if (!strcmp (key, "rawcoord")) pi->transformCoordinates = FALSE; - else if (!strcasecmp (option->key, "device")) - pi->path = strdup(option->value); - else if (!strcasecmp (option->key, "protocol")) - pi->protocol = strdup(option->value); + else if (!strcasecmp (key, "device")) + pi->path = strdup(value); + else if (!strcasecmp (key, "protocol")) + pi->protocol = strdup(value); else ErrorF("Pointer option key (%s) of value (%s) not assigned!\n", - option->key, option->value); + key, value); } } @@ -2216,14 +2222,17 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, KdPointerInfo *pi = NULL; KdKeyboardInfo *ki = NULL; - for (option = options; option; option = option->next) { - if (strcmp(option->key, "type") == 0) { - if (strcmp(option->value, "pointer") == 0) { + nt_list_for_each_entry(option, options, next) { + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (strcmp(key, "type") == 0) { + if (strcmp(value, "pointer") == 0) { pi = KdNewPointer(); if (!pi) return BadAlloc; } - else if (strcmp(option->value, "keyboard") == 0) { + else if (strcmp(value, "keyboard") == 0) { ki = KdNewKeyboard(); if (!ki) return BadAlloc; @@ -2234,16 +2243,16 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, } } #ifdef CONFIG_HAL - else if (strcmp(option->key, "_source") == 0 && - strcmp(option->value, "server/hal") == 0) + else if (strcmp(key, "_source") == 0 && + strcmp(value, "server/hal") == 0) { ErrorF("Ignoring device from HAL.\n"); return BadValue; } #endif #ifdef CONFIG_UDEV - else if (strcmp(option->key, "_source") == 0 && - strcmp(option->value, "server/udev") == 0) + else if (strcmp(key, "_source") == 0 && + strcmp(value, "server/udev") == 0) { ErrorF("Ignoring device from udev.\n"); return BadValue; @@ -2258,16 +2267,19 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, /* FIXME: change this code below to use KdParseKbdOptions and * KdParsePointerOptions */ - for (option = options; option; option = option->next) { - if (strcmp(option->key, "device") == 0) { - if (pi && option->value) - pi->path = strdup(option->value); - else if (ki && option->value) - ki->path = strdup(option->value); + nt_list_for_each_entry(option, options, next) { + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (strcmp(key, "device") == 0) { + if (pi && value) + pi->path = strdup(value); + else if (ki && value) + ki->path = strdup(value); } - else if (strcmp(option->key, "driver") == 0) { + else if (strcmp(key, "driver") == 0) { if (pi) { - pi->driver = KdFindPointerDriver(option->value); + pi->driver = KdFindPointerDriver(value); if (!pi->driver) { ErrorF("couldn't find driver!\n"); KdFreePointer(pi); @@ -2276,7 +2288,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, pi->options = options; } else if (ki) { - ki->driver = KdFindKeyboardDriver(option->value); + ki->driver = KdFindKeyboardDriver(value); if (!ki->driver) { ErrorF("couldn't find driver!\n"); KdFreeKeyboard(ki); From jeremyhu at kemper.freedesktop.org Mon Oct 24 22:40:49 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 24 Oct 2011 22:40:49 -0700 (PDT) Subject: libpciaccess: Changes to 'master' Message-ID: <20111025054049.C48C9C0001@kemper.freedesktop.org> src/linux_sysfs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) New commits: commit a0a53a67c91c698007dcac3e7aba27c999c4f6ed Author: Nithin Nayak Sujir <nsujir at broadcom.com> Date: Mon Oct 24 12:15:15 2011 -0700 libpciaccess: close mtrr fd on pci_cleanup Since the fd is not closed, calling pci_system_init and pci_system_cleanup more than 1024 times results in "too many files open" error. Signed-off-by: Nithin Nayak Sujir <nsujir at broadcom.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 24 23:41:41 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 24 Oct 2011 23:41:41 -0700 (PDT) Subject: libXft: Changes to 'master' Message-ID: <20111025064141.B61FBC0001@kemper.freedesktop.org> src/xftglyphs.c | 3 +++ 1 file changed, 3 insertions(+) New commits: commit 301029c9a1d9429009eaf08bb726357d4e94780d Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 24 23:39:25 2011 -0700 Fix undefined ftbit in XftFontLoadGlyphs https://bugs.freedesktop.org/show_bug.cgi?id=42173 Fixes regression from: 6f1d7bcdd461b1f6cc64370793f52d7c170187d0 Fixed by examining original patch before rebase from: https://bugs.freedesktop.org/show_bug.cgi?id=29151 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From daenzer at kemper.freedesktop.org Tue Oct 25 08:54:11 2011 From: daenzer at kemper.freedesktop.org (Michel Dänzer) Date: Tue, 25 Oct 2011 08:54:11 -0700 (PDT) Subject: xf86-video-ati: Branch 'master' Message-ID: <20111025155411.DD3271000F@kemper.freedesktop.org> src/radeon_dri2.c | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) New commits: commit 6e0e1a821accc6ca95f4134e49b66a6b168c1934 Author: Michel D??nzer <michel.daenzer at amd.com> Date: Tue Oct 25 17:39:57 2011 +0200 Make radeon_dri2_create_buffer(s) more robust. (Bug #30047) In particular, handle and propagate failure to allocate GPU accessible memory, instead of crashing. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=30047 . Also take care not to leak resources in error paths. Signed-off-by: Michel D??nzer <michel.daenzer at amd.com> diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 88117a5..8789d73 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -205,9 +205,17 @@ radeon_dri2_create_buffers(DrawablePtr drawable, exaMoveInPixmap(pixmap); info->exa_force_create = FALSE; driver_priv = exaGetPixmapDriverPrivate(pixmap); - r = radeon_gem_get_kernel_name(driver_priv->bo, &buffers[i].name); - if (r) - return r; + if (!driver_priv || + radeon_gem_get_kernel_name(driver_priv->bo, &buffers[i].name) != 0) { + int j; + + for (j = 0; j < i; j++) + (*pScreen->DestroyPixmap)(privates[j].pixmap); + (*pScreen->DestroyPixmap)(pixmap); + free(privates); + free(buffers); + return NULL; + } buffers[i].attachment = attachments[i]; buffers[i].pitch = pixmap->devKind; @@ -232,7 +240,7 @@ radeon_dri2_create_buffer(DrawablePtr drawable, struct dri2_buffer_priv *privates; PixmapPtr pixmap, depth_pixmap; struct radeon_exa_pixmap_priv *driver_priv; - int r, need_enlarge = 0; + int need_enlarge = 0; int flags; unsigned front_width; uint32_t tiling = 0; @@ -240,17 +248,7 @@ radeon_dri2_create_buffer(DrawablePtr drawable, pixmap = pScreen->GetScreenPixmap(pScreen); front_width = pixmap->drawable.width; - buffers = calloc(1, sizeof *buffers); - if (buffers == NULL) { - return NULL; - } - privates = calloc(1, sizeof(struct dri2_buffer_priv)); - if (privates == NULL) { - free(buffers); - return NULL; - } - - depth_pixmap = NULL; + pixmap = depth_pixmap = NULL; if (attachment == DRI2BufferFrontLeft) { if (drawable->type == DRAWABLE_PIXMAP) { @@ -351,6 +349,13 @@ radeon_dri2_create_buffer(DrawablePtr drawable, } } + if (!pixmap) + return NULL; + + buffers = calloc(1, sizeof *buffers); + if (buffers == NULL) + goto error; + if (attachment == DRI2BufferDepth) { depth_pixmap = pixmap; } @@ -358,9 +363,13 @@ radeon_dri2_create_buffer(DrawablePtr drawable, exaMoveInPixmap(pixmap); info->exa_force_create = FALSE; driver_priv = exaGetPixmapDriverPrivate(pixmap); - r = radeon_gem_get_kernel_name(driver_priv->bo, &buffers->name); - if (r) - return NULL; + if (!driver_priv || + (radeon_gem_get_kernel_name(driver_priv->bo, &buffers->name) != 0)) + goto error; + + privates = calloc(1, sizeof(struct dri2_buffer_priv)); + if (privates == NULL) + goto error; buffers->attachment = attachment; buffers->pitch = pixmap->devKind; @@ -373,6 +382,12 @@ radeon_dri2_create_buffer(DrawablePtr drawable, privates->refcnt = 1; return buffers; + +error: + free(buffers); + if (pixmap) + (*pScreen->DestroyPixmap)(pixmap); + return NULL; } #endif From thomash at kemper.freedesktop.org Wed Oct 26 04:21:01 2011 From: thomash at kemper.freedesktop.org (Thomas Hellstrom) Date: Wed, 26 Oct 2011 04:21:01 -0700 (PDT) Subject: xf86-video-vmware: Changes to 'vmwgfx_branch' Message-ID: <20111026112101.865AC1000F@kemper.freedesktop.org> vmwgfx/vmwgfx_dri2.c | 14 ++++++++++++-- vmwgfx/vmwgfx_output.c | 9 ++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) New commits: commit c73a7f3d991dd95d332829f2ca8a88aabfea5a46 Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Wed Oct 26 07:28:31 2011 +0200 vmwgfx: Update the connector type name array Also map connector types that are not in the array to "Unknown". Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> commit a33710b0d16c9c01a1995b60f0b0d4d482f459d3 Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Fri Oct 21 11:19:36 2011 +0200 vmwgfx: Save the dri2 requested depth since it may differ from the drawable depth. Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> From jeremyhu at kemper.freedesktop.org Wed Oct 26 10:53:37 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Wed, 26 Oct 2011 10:53:37 -0700 (PDT) Subject: xserver: Branch 'server-1.10-branch' - 6 commits Message-ID: <20111026175337.AECED1000F@kemper.freedesktop.org> hw/xfree86/common/xf86Events.c | 9 - hw/xfree86/os-support/linux/lnx_init.c | 14 +-- hw/xnest/Keyboard.c | 25 ++++- hw/xquartz/xpr/appledri.c | 149 ++++++++++++++++++++++++++++++--- xkb/xkb.c | 3 5 files changed, 173 insertions(+), 27 deletions(-) New commits: commit 491bdaa83628fa0631422b5403fe671f205cc2e9 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 21 10:27:16 2011 -0700 XQuartz: appledri: Allow byte swapped requests Even though it's only valid when local, it is possible for a local client and the server to not match endianness, such as when running a ppc application under Rosetta. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 1c8bda798b4480bab0f0da6f531e4770c7a1f771) (cherry picked from commit 7be5492bcfab540676d6f849b85ad3db64a5ada0) diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 1d37de2..129fc78 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -2,7 +2,7 @@ Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 2000 VA Linux Systems, Inc. -Copyright (c) 2002, 2009 Apple Computer, Inc. +Copyright (c) 2002, 2009-2011 Apple Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -416,21 +416,113 @@ SProcAppleDRIQueryVersion( } static int +SProcAppleDRIQueryDirectRenderingCapable( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIQueryDirectRenderingCapableReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + return ProcAppleDRIQueryDirectRenderingCapable(client); +} + +static int +SProcAppleDRIAuthConnection( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIAuthConnectionReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->magic, n); + return ProcAppleDRIAuthConnection(client); +} + +static int +SProcAppleDRICreateSurface( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRICreateSurfaceReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->drawable, n); + swapl(&stuff->client_id, n); + return ProcAppleDRICreateSurface(client); +} + +static int +SProcAppleDRIDestroySurface( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIDestroySurfaceReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->drawable, n); + return ProcAppleDRIDestroySurface(client); +} + +static int +SProcAppleDRICreatePixmap( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRICreatePixmapReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->drawable, n); + return ProcAppleDRICreatePixmap(client); +} + +static int +SProcAppleDRIDestroyPixmap( + register ClientPtr client +) +{ + register int n; + REQUEST(xAppleDRIDestroyPixmapReq); + swaps(&stuff->length, n); + swapl(&stuff->drawable, n); + return ProcAppleDRIDestroyPixmap(client); +} + +static int SProcAppleDRIDispatch ( register ClientPtr client ) { REQUEST(xReq); - /* It is bound to be non-local when there is byte swapping */ + switch (stuff->data) + { + case X_AppleDRIQueryVersion: + return SProcAppleDRIQueryVersion(client); + case X_AppleDRIQueryDirectRenderingCapable: + return SProcAppleDRIQueryDirectRenderingCapable(client); + } + if (!LocalClient(client)) return DRIErrorBase + AppleDRIClientNotLocal; - /* only local clients are allowed DRI access */ switch (stuff->data) { - case X_AppleDRIQueryVersion: - return SProcAppleDRIQueryVersion(client); + case X_AppleDRIAuthConnection: + return SProcAppleDRIAuthConnection(client); + case X_AppleDRICreateSurface: + return SProcAppleDRICreateSurface(client); + case X_AppleDRIDestroySurface: + return SProcAppleDRIDestroySurface(client); + case X_AppleDRICreatePixmap: + return SProcAppleDRICreatePixmap(client); + case X_AppleDRIDestroyPixmap: + return SProcAppleDRIDestroyPixmap(client); + default: return BadRequest; } commit d9e271822012db95bc2604b59a9f2595efe0a5d7 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 22:34:44 2011 -0700 XQuartz: appledri: Fix byte swapping in replies Even though it's only valid when local, it is possible for a local client and the server to not match endianness, such as when running a ppc application under Rosetta. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> (cherry picked from commit 14205ade0c750191bf43fba8bd55c65dba912cf4) Conflicts: hw/xquartz/xpr/appledri.c Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit 0ad049706d2fa8ff2758c42bdd412fb62bb1e86a) diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index e1b4134..1d37de2 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -91,7 +91,6 @@ ProcAppleDRIQueryVersion( ) { xAppleDRIQueryVersionReply rep; - register int n; REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq); rep.type = X_Reply; @@ -101,8 +100,12 @@ ProcAppleDRIQueryVersion( rep.minorVersion = SERVER_APPLEDRI_MINOR_VERSION; rep.patchVersion = SERVER_APPLEDRI_PATCH_VERSION; if (client->swapped) { + register int n; swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + swapl(&rep.patchVersion, n); } WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep); return Success; @@ -134,6 +137,12 @@ ProcAppleDRIQueryDirectRenderingCapable( if (!LocalClient(client)) rep.isCapable = 0; + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + } + WriteToClient(client, sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep); return Success; @@ -158,6 +167,14 @@ ProcAppleDRIAuthConnection( ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic); rep.authenticated = 0; } + + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.authenticated, n); /* Yes, this is a CARD32 ... sigh */ + } + WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep); return Success; } @@ -217,6 +234,15 @@ ProcAppleDRICreateSurface( rep.key_1 = key[1]; rep.uid = sid; + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.key_0, n); + swapl(&rep.key_1, n); + swapl(&rep.uid, n); + } + WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep); return Success; } @@ -278,7 +304,6 @@ ProcAppleDRICreatePixmap(ClientPtr client) rep.stringLength = strlen(path) + 1; - /* No need for swapping, because this only runs if LocalClient is true. */ rep.type = X_Reply; rep.length = bytes_to_int32(rep.stringLength); rep.sequenceNumber = client->sequence; @@ -291,8 +316,20 @@ ProcAppleDRICreatePixmap(ClientPtr client) if(sizeof(rep) != sz_xAppleDRICreatePixmapReply) ErrorF("error sizeof(rep) is %zu\n", sizeof(rep)); - WriteReplyToClient(client, sizeof(rep), &rep); - (void)WriteToClient(client, rep.stringLength, path); + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.stringLength, n); + swapl(&rep.width, n); + swapl(&rep.height, n); + swapl(&rep.pitch, n); + swapl(&rep.bpp, n); + swapl(&rep.size, n); + } + + WriteToClient(client, sizeof(rep), &rep); + WriteToClient(client, rep.stringLength, path); return Success; } commit 1987c90aa4420269572ef668c4c56cf97480f5f5 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Thu Oct 20 22:23:07 2011 -0700 XQuartz: appledri: Set the correct reply length for XAppleDRICreatePixmap http://xquartz.macosforge.org/trac/ticket/508 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> (cherry picked from commit 2ba0ac202ad64eb4a555715980ba538de19c9fd7) diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index ff70a38..e1b4134 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -280,7 +280,7 @@ ProcAppleDRICreatePixmap(ClientPtr client) /* No need for swapping, because this only runs if LocalClient is true. */ rep.type = X_Reply; - rep.length = sizeof(rep) + rep.stringLength; + rep.length = bytes_to_int32(rep.stringLength); rep.sequenceNumber = client->sequence; rep.width = width; rep.height = height; commit 6a8263737464bf07d0dd0de202afa8a78dd032e4 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 16 02:12:38 2011 -0700 Xnest: Match the host's keymap This was a regression. Introduced by: 08363c5830bdea34012dcd954b45ccfdc79a3a7e and 32db27a7f867b503c2840ca7b815e96d10be9210 Masked by: 1e69fd4a60147287b31e53bfc61543fb17bb82c8 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jamey Sharp <jamey at minilop.net> (cherry picked from commit 83fef4235db86343477b4ec9858c6ba35e1aa7d9) diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index ec629dc..5ef376b 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -114,11 +114,13 @@ xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) int xnestKeyboardProc(DeviceIntPtr pDev, int onoff) { + XModifierKeymap *modifier_keymap; KeySym *keymap; int mapWidth; int min_keycode, max_keycode; KeySymsRec keySyms; - int i; + CARD8 modmap[MAP_LENGTH]; + int i, j; XKeyboardState values; XkbDescPtr xkb; int op, event, error, major, minor; @@ -130,7 +132,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) #ifdef _XSERVER64 { KeySym64 *keymap64; - int i, len; + int len; keymap64 = XGetKeyboardMapping(xnestDisplay, min_keycode, max_keycode - min_keycode + 1, @@ -147,7 +149,17 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) max_keycode - min_keycode + 1, &mapWidth); #endif - + + memset(modmap, 0, sizeof(modmap)); + modifier_keymap = XGetModifierMapping(xnestDisplay); + for (j = 0; j < 8; j++) + for(i = 0; i < modifier_keymap->max_keypermod; i++) { + CARD8 keycode; + if ((keycode = modifier_keymap->modifiermap[j * modifier_keymap->max_keypermod + i])) + modmap[keycode] |= 1<<j; + } + XFreeModifiermap(modifier_keymap); + keySyms.minKeyCode = min_keycode; keySyms.maxKeyCode = max_keycode; keySyms.mapWidth = mapWidth; @@ -165,7 +177,12 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb); InitKeyboardDeviceStruct(pDev, NULL, - xnestBell, xnestChangeKeyboardControl); + xnestBell, xnestChangeKeyboardControl); + + XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode, + keySyms.maxKeyCode - keySyms.minKeyCode + 1, + modmap, serverClient); + XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); XkbFreeKeyboard(xkb, 0, False); free(keymap); commit a3dfc9c9131cc3d41f04f4d3ad194278fcb5bb25 Author: Tom???? Trnka <tomastrnka at gmx.com> Date: Tue Oct 11 09:11:18 2011 +0200 Fix drain_console unregistration Bug introduced by 9dca441670d261a9a9fb6108960ed48f3d58fb7f xfree86: add a hook to replace the new console handler. console_handler was not being set, making the server eat up CPU spinning in WaitForSomething selecting consoleFd over and over again, every time trying to unregister drain_console without success due to console_handler being NULL. Let's just fix the unregistration in xf86SetConsoleHandler() and use that. But wait, there could be a catch: If some driver replaced the handler using xf86SetConsoleHandler(), the unregistration in xf86CloseConsole will unregister that one. I don't understand Xorg well enough to know whether this poses a problem (could mess up driver deinit somehow or something like that). As it is, xf86SetConsoleHandler() doesn't offer any way to prevent this (i.e. check which handler is currently registered). I had been using it for two days on my machine that previously hit 100% CPU several times a day. That has now gone away without any new problems appearing. Signed-off-by: Tomas Trnka <tomastrnka at gmx.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> (cherry picked from commit 323869f3298cbbfe864af9404a8aed1bf7995d79) (cherry picked from commit 82445286d56fdac36f21ec5eed436646bda768dd) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 84c0d18..8511ea1 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -603,16 +603,15 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data) InputHandlerProc xf86SetConsoleHandler(InputHandlerProc proc, pointer data) { - static InputHandlerProc handler = NULL; - InputHandlerProc old_handler = handler; + static IHPtr handler = NULL; + IHPtr old_handler = handler; if (old_handler) xf86RemoveGeneralHandler(old_handler); - xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - handler = proc; + handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - return old_handler; + return (old_handler) ? old_handler->ihproc : NULL; } static void diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index 77dfb2f..e098e14 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -47,15 +47,12 @@ static char vtname[11]; static struct termios tty_attr; /* tty state to restore */ static int tty_mode; /* kbd mode to restore */ -static void *console_handler; - static void drain_console(int fd, void *closure) { errno = 0; if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; + xf86SetConsoleHandler(NULL, NULL); } } @@ -259,10 +256,11 @@ xf86CloseConsole(void) return; } - if (console_handler) { - xf86RemoveGeneralHandler(console_handler); - console_handler = NULL; - }; + /* + * unregister the drain_console handler + * - what to do if someone else changed it in the meantime? + */ + xf86SetConsoleHandler(NULL, NULL); /* Back to text mode ... */ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT)); commit 8011c9f160ea41120e89b55a146dc58dcb1fb716 Author: Peter Harris <pharris at opentext.com> Date: Fri Sep 2 18:45:16 2011 -0400 xkb: add missing swaps for xkbGetDeviceInfoReply Caught during review of e095369bf. Signed-off-by: Peter Harris <pharris at opentext.com> Reviewed-by-by: Matt Turner <mattst88 at gmail.com> Signed-off-by: Matt Turner <mattst88 at gmail.com> (cherry picked from commit c90903b4f7a826ae6826a8dd0a901c8362500e46) Conflicts: xkb/xkb.c Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> (cherry picked from commit ec8ee3a9f76cc94d6fa4e7245c1a8fb68a42783c) diff --git a/xkb/xkb.c b/xkb/xkb.c index a8d0e80..77a9862 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -6215,6 +6215,9 @@ char * str; swaps(&rep.unsupported,n); swaps(&rep.nDeviceLedFBs,n); swapl(&rep.type,n); + swaps(&rep.dfltKbdFB, n); + swaps(&rep.dfltLedFB, n); + swapl(&rep.devType, n); } WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep); From ickle at kemper.freedesktop.org Thu Oct 27 02:35:15 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 27 Oct 2011 02:35:15 -0700 (PDT) Subject: xf86-video-intel: 20 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_composite.c src/sna/sna_io.c src/sna/sna_render.h Message-ID: <20111027093515.7C1C21000F@kemper.freedesktop.org> src/sna/gen2_render.c | 58 + src/sna/gen3_render.c | 52 + src/sna/gen4_render.c | 35 - src/sna/gen5_render.c | 60 + src/sna/gen6_render.c | 57 + src/sna/gen7_render.c | 55 + src/sna/kgem.c | 6 src/sna/sna_accel.c | 1638 +++++++++++++++++++++++++++++++++++++++++++----- src/sna/sna_blt.c | 232 +++++- src/sna/sna_composite.c | 3 src/sna/sna_io.c | 21 src/sna/sna_render.h | 10 12 files changed, 1941 insertions(+), 286 deletions(-) New commits: commit 991582f6678581e3d92c0497e10ecee67536efc2 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 09:27:41 2011 +0100 sna/io: Update batch mode after submitting partial requests Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c index 5a6fdd9..f97b88a 100644 --- a/src/sna/sna_io.c +++ b/src/sna/sna_io.c @@ -143,8 +143,10 @@ void sna_read_boxes(struct sna *sna, if (kgem->nexec + 2 > KGEM_EXEC_SIZE(kgem) || kgem->nreloc + 2 > KGEM_RELOC_SIZE(kgem) || !kgem_check_batch(kgem, 8) || - !kgem_check_bo_fenced(kgem, dst_bo, src_bo, NULL)) + !kgem_check_bo_fenced(kgem, dst_bo, src_bo, NULL)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } tmp_nbox = nbox; tmp_box = box; @@ -196,10 +198,14 @@ void sna_read_boxes(struct sna *sna, offset += pitch * height; } - tmp_box += nbox_this_time; _kgem_submit(kgem); - } while (tmp_nbox); + if (!tmp_nbox) + break; + + _kgem_set_mode(kgem, KGEM_BLT); + tmp_box += nbox_this_time; + } while (1); assert(offset == dst_bo->size); kgem_buffer_read_sync(kgem, dst_bo); @@ -315,8 +321,10 @@ void sna_write_boxes(struct sna *sna, if (kgem->nexec + 2 > KGEM_EXEC_SIZE(kgem) || kgem->nreloc + 2 > KGEM_RELOC_SIZE(kgem) || !kgem_check_batch(kgem, 8) || - !kgem_check_bo_fenced(kgem, dst_bo, NULL)) + !kgem_check_bo_fenced(kgem, dst_bo, NULL)) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } do { int nbox_this_time; @@ -395,13 +403,14 @@ void sna_write_boxes(struct sna *sna, } while (--nbox_this_time); assert(offset == src_bo->size); - if (nbox) + if (nbox) { _kgem_submit(kgem); + _kgem_set_mode(kgem, KGEM_BLT); + } kgem_bo_destroy(kgem, src_bo); } while (nbox); - _kgem_set_mode(kgem, KGEM_BLT); sna->blt_state.fill_bo = 0; } commit 91745de113340c8a281e8cb724b4a7e0b7a0711a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 09:17:50 2011 +0100 sna: Further improve use of fill->boxes for PolyRectangle Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index c8936fa..efa2013 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3869,17 +3869,13 @@ sna_poly_rectangle_blt(DrawablePtr drawable, struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); struct sna_fill_op fill; + BoxRec boxes[512], *b = boxes, *const last_box = boxes+ARRAY_SIZE(boxes); int16_t dx, dy; static void * const jump[] = { - &&no_damage_zero, - &&maybe_damage_zero_clipped, - &&no_damage_wide, - &&maybe_damage_wide_clipped, - - &&damage_zero, - &&maybe_damage_zero_clipped, - &&damage_wide, - &&maybe_damage_wide_clipped, + &&zero, + &&zero_clipped, + &&wide, + &&wide_clipped, }; unsigned v; @@ -3893,167 +3889,125 @@ sna_poly_rectangle_blt(DrawablePtr drawable, v = !!clipped; v |= (gc->lineWidth != 0) << 1; - v |= (damage != NULL) << 2; goto *jump[v]; -damage_zero: +zero: dx += drawable->x; dy += drawable->y; do { - BoxRec box; + xRectangle rr = *r++; + rr.x += dx; + rr.y += dy; - if (r->width <= 1 || r->height <= 1) { - box.x1 = r->x + dx; - box.y1 = r->y + dy; - box.x2 = box.x1 + r->width + 1; - box.y2 = box.y1 + r->height + 1; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - } else { - box.x1 = r->x + dx; - box.y1 = r->y + dy; - box.x2 = box.x1 + r->width + 1; - box.y2 = box.y1 + 1; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - - box.y1 += r->height; - box.y2 += r->height; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - - box.y1 = r->y + dy + 1; - box.y2 = box.y1 + r->height - 1; - box.x1 = r->x + dx; - box.x2 = box.x1 + 1; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - - box.x1 += r->width; - box.x2 += r->width; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); + if (b+4 > last_box) { + fill.boxes(sna, &fill, boxes, b-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; } - r++; - } while (--n); - goto done; - -no_damage_zero: - dx += drawable->x; - dy += drawable->y; - do { - BoxRec box[4]; - - if (r->width <= 1 || r->height <= 1) { - box[0].x1 = r->x + dx; - box[0].y1 = r->y + dy; - box[0].x2 = box[0].x1 + r->width + 1; - box[0].y2 = box[0].y1 + r->height + 1; + if (rr.width <= 1 || rr.height <= 1) { + b->x1 = rr.x; + b->y1 = rr.y; + b->x2 = rr.x + rr.width + 1; + b->y2 = rr.y + rr.height + 1; DBG(("%s: blt (%d, %d), (%d, %d)\n", __FUNCTION__, - box[0].x1, box[0].y1, box[0].x2, box[0].y2)); - fill.box(sna, &fill, &box[0]); + b->x1, b->y1, b->x2,b->y2)); + b++; } else { - box[0].x1 = r->x + dx; - box[0].y1 = r->y + dy; - box[0].x2 = box[0].x1 + r->width + 1; - box[0].y2 = box[0].y1 + 1; + b[0].x1 = rr.x; + b[0].y1 = rr.y; + b[0].x2 = rr.x + rr.width + 1; + b[0].y2 = rr.y + 1; - box[1] = box[0]; - box[1].y1 += r->height; - box[1].y2 += r->height; + b[1] = b[0]; + b[1].y1 += rr.height; + b[1].y2 += rr.height; - box[2].y1 = r->y + dy + 1; - box[2].y2 = box[2].y1 + r->height - 1; - box[2].x1 = r->x + dx; - box[2].x2 = box[2].x1 + 1; + b[2].y1 = rr.y + 1; + b[2].y2 = rr.y + rr.height - 1; + b[2].x1 = rr.x; + b[2].x2 = rr.x + 1; - box[3] = box[2]; - box[3].x1 += r->width; - box[3].x2 += r->width; + b[3] = b[2]; + b[3].x1 += rr.width; + b[3].x2 += rr.width; - fill.boxes(sna, &fill, box, 4); + b += 4; } - r++; } while (--n); goto done; -maybe_damage_zero_clipped: +zero_clipped: { RegionRec clip; - BoxRec box[4], *b, *c; - int count = 0, i, j; + const BoxRec *clip_start, *clip_end, *c; + BoxRec box[4]; + int count, i; region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + return true; + clip_start = RegionBoxptr(&clip); + clip_end = clip_start + clip.data->numRects; do { - if (r->width <= 1 || r->height <= 1) { - box[0].x1 = r->x + drawable->x; - box[0].y1 = r->y + drawable->y; - box[0].x2 = box[0].x1 + r->width + 1; - box[0].y2 = box[0].y1 + r->height + 1; + xRectangle rr = *r++; + rr.x += drawable->x; + rr.y += drawable->y; + + if (rr.width <= 1 || rr.height <= 1) { + box[0].x1 = rr.x; + box[0].y1 = rr.y; + box[0].x2 = rr.x + rr.width + 1; + box[0].y2 = rr.y + r->height + 1; count = 1; } else { - box[0].x1 = r->x + drawable->x; - box[0].y1 = r->y + drawable->y; - box[0].x2 = box[0].x1 + r->width + 1; - box[0].y2 = box[0].y1 + 1; + box[0].x1 = rr.x; + box[0].y1 = rr.y; + box[0].x2 = rr.x + rr.width + 1; + box[0].y2 = rr.y + 1; box[1] = box[0]; - box[1].y1 += r->height; - box[1].y2 += r->height; + box[1].y1 += rr.height; + box[1].y2 += rr.height; - box[2].y1 = r->y + drawable->y + 1; - box[2].y2 = box[2].y1 + r->height - 1; - box[2].x1 = r->x + drawable->x; - box[2].x2 = box[2].x1 + 1; + box[2].y1 = rr.y + 1; + box[2].y2 = box[2].y1 + rr.height - 1; + box[2].x1 = rr.x; + box[2].x2 = rr.x + 1; box[3] = box[2]; - box[3].x1 += r->width; - box[3].x2 += r->width; + box[3].x1 += rr.width; + box[3].x2 += rr.width; count = 4; } - for (i = REGION_NUM_RECTS(&clip), c = REGION_RECTS(&clip); i--; c++) { - for (j = count, b = box; j--; b++) { - BoxRec clipped = *b; - if (box_intersect(&clipped, c)) { - clipped.x1 += dx; - clipped.x2 += dx; - clipped.y1 += dy; - clipped.y2 += dy; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - clipped.x1, clipped.y1, clipped.x2, clipped.y2)); - fill.box(sna, &fill, &clipped); - if (damage) { - assert_pixmap_contains_box(pixmap, &clipped); - sna_damage_add_box(damage, &clipped); + for (i = 0; i < count; i++) { + c = find_clip_box_for_y(clip_start, + clip_end, + box[i].y1); + while (c != clip_end) { + if (box[i].y2 <= c->y1) + break; + + *b = box[i]; + if (box_intersect(b, c)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; } } + } } r++; @@ -4061,78 +4015,85 @@ maybe_damage_zero_clipped: } goto done; -maybe_damage_wide_clipped: +wide_clipped: { RegionRec clip; + BoxRec box[4]; + const BoxRec *clip_start, *clip_end, *c; int16_t offset2 = gc->lineWidth; int16_t offset1 = offset2 >> 1; int16_t offset3 = offset2 - offset1; region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + return true; + clip_start = RegionBoxptr(&clip); + clip_end = clip_start + clip.data->numRects; do { - BoxRec box[4], *c, *b; - int16_t x = r->x + drawable->x; - int16_t y = r->y + drawable->y; - int16_t width = r->width; - int16_t height = r->height; - int count, i, j; - r++; - - if (height < offset2 || width < offset1) { - if (height == 0) { - box[0].x1 = x; - box[0].x2 = x + width + 1; + xRectangle rr = *r++; + int count; + rr.x += drawable->x; + rr.y += drawable->y; + + if (rr.height < offset2 || rr.width < offset1) { + if (rr.height == 0) { + box[0].x1 = rr.x; + box[0].x2 = rr.x + rr.width + 1; } else { - box[0].x1 = x - offset1; - box[0].x2 = box[0].x1 + width + offset2; + box[0].x1 = rr.x - offset1; + box[0].x2 = box[0].x1 + rr.width + offset2; } - if (width == 0) { - box[0].y1 = y; - box[0].y2 = y + height + 1; + if (rr.width == 0) { + box[0].y1 = rr.y; + box[0].y2 = rr.y + rr.height + 1; } else { - box[0].y1 = y - offset1; - box[0].y2 = box[0].y1 + height + offset2; + box[0].y1 = rr.y - offset1; + box[0].y2 = box[0].y1 + rr.height + offset2; } count = 1; } else { - box[0].x1 = x - offset1; - box[0].x2 = box[0].x1 + width + offset2; - box[0].y1 = y - offset1; + box[0].x1 = rr.x - offset1; + box[0].x2 = box[0].x1 + rr.width + offset2; + box[0].y1 = rr.y - offset1; box[0].y2 = box[0].y1 + offset2; - box[1].x1 = x - offset1; + box[1].x1 = rr.x - offset1; box[1].x2 = box[1].x1 + offset2; - box[1].y1 = y + offset3; - box[1].y2 = y + height - offset1; + box[1].y1 = rr.y + offset3; + box[1].y2 = rr.y + rr.height - offset1; - box[2].x1 = x + width - offset1; + box[2].x1 = rr.x + rr.width - offset1; box[2].x2 = box[2].x1 + offset2; - box[2].y1 = y + offset3; - box[2].y2 = y + height - offset1; + box[2].y1 = rr.y + offset3; + box[2].y2 = rr.y + rr.height - offset1; box[3] = box[1]; - box[3].y1 += height; - box[3].y2 += height; + box[3].y1 += rr.height; + box[3].y2 += rr.height; count = 4; } - for (i = REGION_NUM_RECTS(&clip), c = REGION_RECTS(&clip); i--; c++) { - for (j = count, b = box; j--; b++) { - BoxRec clipped = *b; - if (box_intersect(&clipped, c)) { - clipped.x1 += dx; - clipped.x2 += dx; - clipped.y1 += dy; - clipped.y2 += dy; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - clipped.x1, clipped.y1, clipped.x2, clipped.y2)); - fill.box(sna, &fill, &clipped); - if (damage) { - assert_pixmap_contains_box(pixmap, &clipped); - sna_damage_add_box(damage, &clipped); + while (count--) { + c = find_clip_box_for_y(clip_start, + clip_end, + box[count].y1); + while (c != clip_end) { + if (box[count].y2 <= c->y1) + break; + + *b = box[count]; + if (box_intersect(b, c)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; } } } @@ -4141,7 +4102,7 @@ maybe_damage_wide_clipped: } goto done; -no_damage_wide: +wide: { int offset2 = gc->lineWidth; int offset1 = offset2 >> 1; @@ -4151,126 +4112,63 @@ no_damage_wide: dy += drawable->y; do { - BoxRec box[4]; - int16_t x = r->x + dx; - int16_t y = r->y + dy; - int16_t width = r->width; - int16_t height = r->height; - r++; - - if (height < offset2 || width < offset1) { - if (height == 0) { - box[0].x1 = x; - box[0].x2 = x + width + 1; - } else { - box[0].x1 = x - offset1; - box[0].x2 = box[0].x1 + width + offset2; - } - if (width == 0) { - box[0].y1 = y; - box[0].y2 = y + height + 1; - } else { - box[0].y1 = y - offset1; - box[0].y2 = box[0].y1 + height + offset2; - } - fill.box(sna, &fill, &box[0]); - } else { - box[0].x1 = x - offset1; - box[0].x2 = box[0].x1 + width + offset2; - box[0].y1 = y - offset1; - box[0].y2 = box[0].y1 + offset2; - - box[1] = box[0]; - box[1].y1 = y + height - offset1; - box[1].y2 = box[1].y1 + offset2; - - box[2].x1 = x - offset1; - box[2].x2 = box[2].x1 + offset2; - box[2].y1 = y + offset3; - box[2].y2 = y + height - offset1; - - box[3] = box[2]; - box[3].x1 = x + width - offset1; - box[3].x2 = box[3].x1 + offset2; - - fill.boxes(sna, &fill, box, 4); + xRectangle rr = *r++; + rr.x += dx; + rr.y += dy; + + if (b+4 > last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; } - } while (--n); - } - goto done; - -damage_wide: - { - int offset2 = gc->lineWidth; - int offset1 = offset2 >> 1; - int offset3 = offset2 - offset1; - - dx += drawable->x; - dy += drawable->y; - - do { - BoxRec box; - int16_t x = r->x + dx; - int16_t y = r->y + dy; - int16_t width = r->width; - int16_t height = r->height; - r++; - - if (height < offset2 || width < offset1) { - if (height == 0) { - box.x1 = x; - box.x2 = x + width + 1; + if (rr.height < offset2 || rr.width < offset1) { + if (rr.height == 0) { + b->x1 = rr.x; + b->x2 = rr.x + rr.width + 1; } else { - box.x1 = x - offset1; - box.x2 = box.x1 + width + offset2; + b->x1 = rr.x - offset1; + b->x2 = rr.x + rr.width + offset2; } - if (width == 0) { - box.y1 = y; - box.y2 = y + height + 1; + if (rr.width == 0) { + b->y1 = rr.y; + b->y2 = rr.y + rr.height + 1; } else { - box.y1 = y - offset1; - box.y2 = box.y1 + height + offset2; + b->y1 = rr.y - offset1; + b->y2 = rr.y + rr.height + offset2; } - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); + b++; } else { - box.x1 = x - offset1; - box.x2 = box.x1 + width + offset2; - box.y1 = y - offset1; - box.y2 = box.y1 + offset2; - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - - box.x1 = x - offset1; - box.x2 = box.x1 + offset2; - box.y1 = y + offset3; - box.y2 = y + height - offset1; - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - - box.x1 = x + width - offset1; - box.x2 = box.x1 + offset2; - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - - box.x1 = x - offset1; - box.x2 = box.x1 + width + offset2; - box.y1 = y + height - offset1; - box.y2 = box.y1 + offset2; - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); + b[0].x1 = rr.x - offset1; + b[0].x2 = b[0].x1 + rr.width + offset2; + b[0].y1 = rr.y - offset1; + b[0].y2 = b[0].y1 + offset2; + + b[1] = b[0]; + b[1].y1 = rr.y + rr.height - offset1; + b[1].y2 = b[1].y1 + offset2; + + b[2].x1 = rr.x - offset1; + b[2].x2 = b[2].x1 + offset2; + b[2].y1 = rr.y + offset3; + b[2].y2 = rr.y + rr.height - offset1; + + b[3] = b[2]; + b[3].x1 = rr.x + rr.width - offset1; + b[3].x2 = b[3].x1 + offset2; + b += 4; } } while (--n); } goto done; done: + if (b != boxes) { + fill.boxes(sna, &fill, boxes, b-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + } fill.done(sna, &fill); return TRUE; } commit ffe1bdea82c07a2738743855dfa83494531b41aa Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 18:37:29 2011 +0100 sna/blt: After submitting the batch, it will be empty Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 2aa5bc1..ffe81df 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -207,7 +207,8 @@ noinline static void sna_blt_fill_begin(struct sna *sna, _kgem_submit(kgem); _kgem_set_mode(kgem, KGEM_BLT); - b = kgem->batch + kgem->nbatch; + assert(kgem->nbatch == 0); + b = kgem->batch; b[0] = XY_SETUP_MONO_PATTERN_SL_BLT; if (blt->bpp == 32) b[0] |= BLT_WRITE_ALPHA | BLT_WRITE_RGB; @@ -223,7 +224,7 @@ noinline static void sna_blt_fill_begin(struct sna *sna, b[6] = blt->pixel; b[7] = 0; b[8] = 0; - kgem->nbatch += 9; + kgem->nbatch = 9; } inline static void sna_blt_fill_one(struct sna *sna, commit b34e7454574f36796560955fb9d3d33ca00924d6 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 18:11:25 2011 +0100 sna/blt: Convert Copy with color 0 into a Clear Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 8d07035..2aa5bc1 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -142,6 +142,9 @@ static bool sna_blt_fill_init(struct sna *sna, if (pitch > MAXSHORT) return FALSE; + if (pixel == 0) + alu = GXclear; + blt->br13 = 1<<31 | (fill_ROP[alu] << 16) | pitch; switch (bpp) { default: assert(0); @@ -1524,6 +1527,9 @@ static Bool sna_blt_fill_box(struct sna *sna, uint8_t alu, return FALSE; } + if (color == 0) + alu = GXclear; + br13 |= fill_ROP[alu] << 16; switch (bpp) { default: assert(0); @@ -1603,6 +1609,9 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, if (br13 > MAXSHORT) return FALSE; + if (pixel == 0) + alu = GXclear; + br13 |= 1<<31 | fill_ROP[alu] << 16; switch (bpp) { default: assert(0); commit 389241aa6469b2e64a58cc0527e3310fdc69ffb7 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 17:50:38 2011 +0100 sna: Suppress an overwritten fill Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index bbe9dda..8d07035 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1756,6 +1756,18 @@ Bool sna_blt_copy_boxes(struct sna *sna, uint8_t alu, case 8: break; } + /* Compare first box against a previous fill */ + if (kgem->nbatch >= 6 && + (alu == GXcopy || alu == GXclear) && + kgem->reloc[kgem->nreloc-1].target_handle == dst_bo->handle && + kgem->batch[kgem->nbatch-6] == ((cmd & ~XY_SRC_COPY_BLT_CMD) | XY_COLOR_BLT_CMD) && + kgem->batch[kgem->nbatch-4] == ((uint32_t)(box->y1 + dst_dy) << 16 | (uint16_t)(box->x1 + dst_dx)) && + kgem->batch[kgem->nbatch-3] == ((uint32_t)(box->y2 + dst_dy) << 16 | (uint16_t)(box->x2 + dst_dx))) { + DBG(("%s: deleting last fill\n", __FUNCTION__)); + kgem->nbatch -= 6; + kgem->nreloc--; + } + kgem_set_mode(kgem, KGEM_BLT); if (!kgem_check_batch(kgem, 8) || !kgem_check_reloc(kgem, 2) || commit baf78fcddb87eba987163485ad8fd227fb244f29 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 12:54:13 2011 +0100 sna/gen2: Cache the last solid colour for spans Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 440a343..aa315e6 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -1593,8 +1593,11 @@ static void gen2_emit_composite_spans_state(struct sna *sna, gen2_emit_spans_pipeline(sna, op); if (op->base.src.is_solid) { - BATCH(_3DSTATE_DFLT_SPECULAR_CMD); - BATCH(op->base.src.u.gen2.pixel); + if (op->base.src.u.gen2.pixel != sna->render_state.gen2.specular) { + BATCH(_3DSTATE_DFLT_SPECULAR_CMD); + BATCH(op->base.src.u.gen2.pixel); + sna->render_state.gen2.specular = op->base.src.u.gen2.pixel; + } } else { uint32_t v =_3DSTATE_VERTEX_FORMAT_2_CMD | (op->base.src.is_affine ? TEXCOORDFMT_2D : TEXCOORDFMT_3D); @@ -2534,6 +2537,7 @@ gen2_render_reset(struct sna *sna) sna->render_state.gen2.vft = 0; sna->render_state.gen2.diffuse = 0x0c0ffee0; + sna->render_state.gen2.specular = 0x0c0ffee0; } static void diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index d31b55c..774c576 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -275,8 +275,9 @@ struct gen2_render_state { Bool need_invariant; Bool logic_op_enabled; uint32_t ls1, ls2, vft; - uint16_t vertex_offset; uint32_t diffuse; + uint32_t specular; + uint16_t vertex_offset; }; struct gen3_render_state { commit ff4715a36999a43cee20cf3474b4ae0af646342c Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 12:40:46 2011 +0100 sna/composite: Discard opaque masks Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 80ccf9c..bbe9dda 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -652,6 +652,17 @@ is_white(PicturePtr picture) return pixel_is_white(get_pixel(picture), picture->format); } +bool +sna_composite_mask_is_opaque(PicturePtr mask) +{ + if (mask->componentAlpha && PICT_FORMAT_RGB(mask->format)) + return is_solid(mask) && is_white(mask); + else if (!PICT_FORMAT_A(mask->format)) + return TRUE; + else + return is_solid(mask) && is_opaque_solid(mask); +} + fastcall static void blt_composite_fill(struct sna *sna, const struct sna_composite_op *op, diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index 3962d75..e9dc965 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -426,6 +426,9 @@ sna_composite(CARD8 op, dst_x, dst_y, dst->pDrawable->x, dst->pDrawable->y, width, height)); + if (mask && sna_composite_mask_is_opaque(mask)) + mask = NULL; + if (!sna_compute_composite_region(®ion, src, mask, dst, src_x, src_y, diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index 6c18791..d31b55c 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -569,4 +569,7 @@ void sna_render_composite_redirect_done(struct sna *sna, const struct sna_composite_op *op); +bool +sna_composite_mask_is_opaque(PicturePtr mask); + #endif /* SNA_RENDER_H */ commit 0079579ebd548fc1b490a42928373507a93229bd Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 11:49:53 2011 +0100 sna: Fix debug compilation, again. diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 3ec2e08..440a343 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -2063,7 +2063,7 @@ gen2_render_fill_op_boxes(struct sna *sna, int nbox) { DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, - box->x1, box->y1, box->x2, box->y2, n)); + box->x1, box->y1, box->x2, box->y2, nbox)); do { int nbox_this_time = gen2_get_rectangles(sna, &op->base, nbox); diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index b9ce45f..2b70b85 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3818,7 +3818,7 @@ gen3_render_fill_op_boxes(struct sna *sna, int nbox) { DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, - box->x1, box->y1, box->x2, box->y2, n)); + box->x1, box->y1, box->x2, box->y2, nbox)); do { int nbox_this_time = gen3_get_rectangles(sna, &op->base, nbox); diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index e72283e..a177d32 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2540,7 +2540,7 @@ gen5_render_fill_op_boxes(struct sna *sna, int nbox) { DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, - box->x1, box->y1, box->x2, box->y2, n)); + box->x1, box->y1, box->x2, box->y2, nbox)); do { int nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox); diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 05e6d63..0dde625 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2753,7 +2753,7 @@ gen6_render_op_fill_boxes(struct sna *sna, int nbox) { DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, - box->x1, box->y1, box->x2, box->y2, n)); + box->x1, box->y1, box->x2, box->y2, nbox)); do { int nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox); diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 05b65f3..b9f23ee 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2903,7 +2903,7 @@ gen7_render_fill_op_boxes(struct sna *sna, int nbox) { DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, - box->x1, box->y1, box->x2, box->y2, n)); + box->x1, box->y1, box->x2, box->y2, nbox)); do { int nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox); diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 6f98f27..e8df7d9 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -998,10 +998,10 @@ void _kgem_submit(struct kgem *kgem) i, kgem->exec[i].handle, (int)kgem->exec[i].offset, - found ? found->size : 0, - found ? found->tiling : 0, + found ? found->size : -1, + found ? found->tiling : -1, (int)(kgem->exec[i].flags & EXEC_OBJECT_NEEDS_FENCE), - found ? found->deleted : 1); + found ? found->deleted : -1); } for (i = 0; i < kgem->nreloc; i++) { ErrorF("reloc[%d] = pos:%d, target:%d, delta:%d, read:%x, write:%x, offset:%x\n", diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 153ec21..c8936fa 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2537,7 +2537,7 @@ sna_poly_zero_line_blt(DrawablePtr drawable, void *jump, *ret; DBG(("%s: alu=%d, pixel=%lx, n=%d, clipped=%d, damage=%p\n", - __FUNCTION__, gc->alu, gc->fgPixel, n, clipped, damage)); + __FUNCTION__, gc->alu, gc->fgPixel, _n, clipped, damage)); if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return FALSE; @@ -3348,7 +3348,7 @@ sna_poly_zero_segment_blt(DrawablePtr drawable, void *jump, *ret; DBG(("%s: alu=%d, pixel=%lx, n=%d, clipped=%d, damage=%p\n", - __FUNCTION__, gc->alu, gc->fgPixel, n, clipped, damage)); + __FUNCTION__, gc->alu, gc->fgPixel, _n, clipped, damage)); if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return FALSE; commit 5988422455ebb2a3b1cafadc1ff302c35a7a5039 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 11:47:45 2011 +0100 sna: Handle degenerate copy area whilst wedged We want to return early to avoid handing the empty box as the lower code makes the assumption that it has work to do. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 8df94eb..153ec21 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1708,6 +1708,8 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, region.data = NULL; if (gc->pCompositeClip) RegionIntersect(®ion, ®ion, gc->pCompositeClip); + if (!RegionNotEmpty(®ion)) + return NULL; sna_drawable_move_region_to_cpu(dst, ®ion, true); RegionTranslate(®ion, @@ -1891,6 +1893,10 @@ no_damage_clipped_translate: no_damage_clipped: region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + assert(clip.extents.x1 >= 0); + assert(clip.extents.y1 >= 0); + assert(clip.extents.x2 <= pixmap->drawable.width); + assert(clip.extents.y2 <= pixmap->drawable.height); DBG(("%s: clip %d x [(%d, %d), (%d, %d)] x %d [(%d, %d)...]\n", __FUNCTION__, @@ -1991,6 +1997,10 @@ damage_clipped_translate: damage_clipped: region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + assert(clip.extents.x1 >= 0); + assert(clip.extents.y1 >= 0); + assert(clip.extents.x2 <= pixmap->drawable.width); + assert(clip.extents.y2 <= pixmap->drawable.height); DBG(("%s: clip %d x [(%d, %d), (%d, %d)] x %d [(%d, %d)...]\n", __FUNCTION__, commit 3fc7cd2dc8e2b9c0d4143a9f6657f84050ae249a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 23 20:59:50 2011 +0100 sna/blt: Rename the composite paths Whilst re-reading, I found the old naming scheme slightly muddled and not nearly as descriptive as it should be. Hopefully this slight tweak reads better in 6 months time. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 90b9b1c..80ccf9c 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -653,7 +653,7 @@ is_white(PicturePtr picture) } fastcall -static void blt_fill_composite(struct sna *sna, +static void blt_composite_fill(struct sna *sna, const struct sna_composite_op *op, const struct sna_composite_rectangles *r) { @@ -764,21 +764,21 @@ inline static void _sna_blt_fill_boxes(struct sna *sna, } while (1); } -fastcall static void blt_fill_composite_box_no_offset(struct sna *sna, +fastcall static void blt_composite_fill_box_no_offset(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box) { _sna_blt_fill_box(sna, &op->u.blt, box); } -static void blt_fill_composite_boxes_no_offset(struct sna *sna, +static void blt_composite_fill_boxes_no_offset(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box, int n) { _sna_blt_fill_boxes(sna, &op->u.blt, box, n); } -fastcall static void blt_fill_composite_box(struct sna *sna, +fastcall static void blt_composite_fill_box(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box) { @@ -789,7 +789,7 @@ fastcall static void blt_fill_composite_box(struct sna *sna, box->y2 - box->y1); } -static void blt_fill_composite_boxes(struct sna *sna, +static void blt_composite_fill_boxes(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box, int n) { @@ -807,13 +807,13 @@ prepare_blt_clear(struct sna *sna, { DBG(("%s\n", __FUNCTION__)); - op->blt = blt_fill_composite; + op->blt = blt_composite_fill; if (op->dst.x|op->dst.y) { - op->box = blt_fill_composite_box; - op->boxes = blt_fill_composite_boxes; + op->box = blt_composite_fill_box; + op->boxes = blt_composite_fill_boxes; } else { - op->box = blt_fill_composite_box_no_offset; - op->boxes = blt_fill_composite_boxes_no_offset; + op->box = blt_composite_fill_box_no_offset; + op->boxes = blt_composite_fill_boxes_no_offset; } op->done = blt_done; @@ -830,13 +830,13 @@ prepare_blt_fill(struct sna *sna, { DBG(("%s\n", __FUNCTION__)); - op->blt = blt_fill_composite; + op->blt = blt_composite_fill; if (op->dst.x|op->dst.y) { - op->box = blt_fill_composite_box; - op->boxes = blt_fill_composite_boxes; + op->box = blt_composite_fill_box; + op->boxes = blt_composite_fill_boxes; } else { - op->box = blt_fill_composite_box_no_offset; - op->boxes = blt_fill_composite_boxes_no_offset; + op->box = blt_composite_fill_box_no_offset; + op->boxes = blt_composite_fill_boxes_no_offset; } op->done = blt_done; @@ -847,7 +847,7 @@ prepare_blt_fill(struct sna *sna, } fastcall static void -blt_copy_composite(struct sna *sna, +blt_composite_copy(struct sna *sna, const struct sna_composite_op *op, const struct sna_composite_rectangles *r) { @@ -893,7 +893,7 @@ blt_copy_composite(struct sna *sna, x1, y1); } -fastcall static void blt_copy_composite_box(struct sna *sna, +fastcall static void blt_composite_copy_box(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box) { @@ -908,7 +908,7 @@ fastcall static void blt_copy_composite_box(struct sna *sna, box->y1 + op->dst.y); } -static void blt_copy_composite_boxes(struct sna *sna, +static void blt_composite_copy_boxes(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box, int nbox) { @@ -941,9 +941,9 @@ prepare_blt_copy(struct sna *sna, DBG(("%s\n", __FUNCTION__)); - op->blt = blt_copy_composite; - op->box = blt_copy_composite_box; - op->boxes = blt_copy_composite_boxes; + op->blt = blt_composite_copy; + op->box = blt_composite_copy_box; + op->boxes = blt_composite_copy_boxes; if (sna->kgem.gen >= 60) op->done = gen6_blt_copy_done; else @@ -1119,9 +1119,9 @@ prepare_blt_put(struct sna *sna, free_bo = src_bo; } if (src_bo) { - op->blt = blt_copy_composite; - op->box = blt_copy_composite_box; - op->boxes = blt_copy_composite_boxes; + op->blt = blt_composite_copy; + op->box = blt_composite_copy_box; + op->boxes = blt_composite_copy_boxes; op->u.blt.src_pixmap = (void *)free_bo; op->done = blt_vmap_done; commit 280325900bf3c17c3177f6e3f52236d6b452e0f3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 23 20:58:48 2011 +0100 sna/blt: Share the common fill->boxes between blt and render paths Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 9b598c9..90b9b1c 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -223,10 +223,10 @@ noinline static void sna_blt_fill_begin(struct sna *sna, kgem->nbatch += 9; } -static void sna_blt_fill_one(struct sna *sna, - const struct sna_blt_state *blt, - int16_t x, int16_t y, - int16_t width, int16_t height) +inline static void sna_blt_fill_one(struct sna *sna, + const struct sna_blt_state *blt, + int16_t x, int16_t y, + int16_t width, int16_t height) { struct kgem *kgem = &sna->kgem; uint32_t *b; @@ -242,10 +242,11 @@ static void sna_blt_fill_one(struct sna *sna, sna_blt_fill_begin(sna, blt); b = kgem->batch + kgem->nbatch; + kgem->nbatch += 3; + b[0] = blt->cmd; b[1] = y << 16 | x; b[2] = b[1] + (height << 16 | width); - kgem->nbatch += 3; } static Bool sna_blt_copy_init(struct sna *sna, @@ -679,6 +680,104 @@ static void blt_fill_composite(struct sna *sna, sna_blt_fill_one(sna, &op->u.blt, x1, y1, x2-x1, y2-y1); } +inline static void _sna_blt_fill_box(struct sna *sna, + const struct sna_blt_state *blt, + const BoxRec *box) +{ + struct kgem *kgem = &sna->kgem; + uint32_t *b; + + DBG(("%s: (%d, %d), (%d, %d): %08x\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, + blt->pixel)); + + assert(box->x1 >= 0); + assert(box->y1 >= 0); + assert(box->y2 * blt->bo[0]->pitch <= blt->bo[0]->size); + + if (!kgem_check_batch(kgem, 3)) + sna_blt_fill_begin(sna, blt); + + b = kgem->batch + kgem->nbatch; + kgem->nbatch += 3; + + b[0] = blt->cmd; + *(uint64_t *)(b+1) = *(uint64_t *)box; +} + +inline static void _sna_blt_fill_boxes(struct sna *sna, + const struct sna_blt_state *blt, + const BoxRec *box, + int nbox) +{ + struct kgem *kgem = &sna->kgem; + uint32_t cmd = blt->cmd; + + DBG(("%s: %08x x %d\n", __FUNCTION__, blt->pixel, nbox)); + + if (!kgem_check_batch(kgem, 3)) + sna_blt_fill_begin(sna, blt); + + do { + uint32_t *b = kgem->batch + kgem->nbatch; + int nbox_this_time; + + nbox_this_time = nbox; + if (3*nbox_this_time > kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) + nbox_this_time = (kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) / 3; + assert(nbox_this_time); + nbox -= nbox_this_time; + + kgem->nbatch += 3 * nbox_this_time; + while (nbox_this_time >= 8) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; + b[6] = cmd; *(uint64_t *)(b+7) = *(uint64_t *)box++; + b[9] = cmd; *(uint64_t *)(b+10) = *(uint64_t *)box++; + b[12] = cmd; *(uint64_t *)(b+13) = *(uint64_t *)box++; + b[15] = cmd; *(uint64_t *)(b+16) = *(uint64_t *)box++; + b[18] = cmd; *(uint64_t *)(b+19) = *(uint64_t *)box++; + b[21] = cmd; *(uint64_t *)(b+22) = *(uint64_t *)box++; + b += 24; + nbox_this_time -= 8; + } + if (nbox_this_time & 4) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; + b[6] = cmd; *(uint64_t *)(b+7) = *(uint64_t *)box++; + b[9] = cmd; *(uint64_t *)(b+10) = *(uint64_t *)box++; + b += 12; + } + if (nbox_this_time & 2) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; + b += 6; + } + if (nbox_this_time & 1) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + } + + if (!nbox) + return; + + sna_blt_fill_begin(sna, blt); + } while (1); +} + +fastcall static void blt_fill_composite_box_no_offset(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + _sna_blt_fill_box(sna, &op->u.blt, box); +} + +static void blt_fill_composite_boxes_no_offset(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box, int n) +{ + _sna_blt_fill_boxes(sna, &op->u.blt, box, n); +} + fastcall static void blt_fill_composite_box(struct sna *sna, const struct sna_composite_op *op, const BoxRec *box) @@ -709,8 +808,13 @@ prepare_blt_clear(struct sna *sna, DBG(("%s\n", __FUNCTION__)); op->blt = blt_fill_composite; - op->box = blt_fill_composite_box; - op->boxes = blt_fill_composite_boxes; + if (op->dst.x|op->dst.y) { + op->box = blt_fill_composite_box; + op->boxes = blt_fill_composite_boxes; + } else { + op->box = blt_fill_composite_box_no_offset; + op->boxes = blt_fill_composite_boxes_no_offset; + } op->done = blt_done; return sna_blt_fill_init(sna, &op->u.blt, @@ -727,8 +831,13 @@ prepare_blt_fill(struct sna *sna, DBG(("%s\n", __FUNCTION__)); op->blt = blt_fill_composite; - op->box = blt_fill_composite_box; - op->boxes = blt_fill_composite_boxes; + if (op->dst.x|op->dst.y) { + op->box = blt_fill_composite_box; + op->boxes = blt_fill_composite_boxes; + } else { + op->box = blt_fill_composite_box_no_offset; + op->boxes = blt_fill_composite_boxes_no_offset; + } op->done = blt_done; return sna_blt_fill_init(sna, &op->u.blt, op->dst.bo, @@ -1276,25 +1385,7 @@ fastcall static void sna_blt_fill_op_box(struct sna *sna, const struct sna_fill_op *op, const BoxRec *box) { - struct kgem *kgem = &sna->kgem; - uint32_t *b; - - DBG(("%s: (%d, %d), (%d, %d): %08x\n", __FUNCTION__, - box->x1, box->y1, box->x2, box->y2, - op->base.u.blt.pixel)); - - assert(box->x1 >= 0); - assert(box->y1 >= 0); - assert(box->y2 * op->base.u.blt.bo[0]->pitch <= op->base.u.blt.bo[0]->size); - - if (!kgem_check_batch(kgem, 3)) - sna_blt_fill_begin(sna, &op->base.u.blt); - - b = kgem->batch + kgem->nbatch; - kgem->nbatch += 3; - - b[0] = op->base.u.blt.cmd; - *(uint64_t *)(b+1) = *(uint64_t *)box; + _sna_blt_fill_box(sna, &op->base.u.blt, box); } fastcall static void sna_blt_fill_op_boxes(struct sna *sna, @@ -1302,59 +1393,7 @@ fastcall static void sna_blt_fill_op_boxes(struct sna *sna, const BoxRec *box, int nbox) { - struct kgem *kgem = &sna->kgem; - uint32_t cmd = op->base.u.blt.cmd; - - DBG(("%s: %08x x %d\n", __FUNCTION__, - op->base.u.blt.pixel, nbox)); - - if (!kgem_check_batch(kgem, 3)) - sna_blt_fill_begin(sna, &op->base.u.blt); - - do { - uint32_t *b = kgem->batch + kgem->nbatch; - int nbox_this_time; - - nbox_this_time = nbox; - if (3*nbox_this_time > kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) - nbox_this_time = (kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) / 3; - assert(nbox_this_time); - nbox -= nbox_this_time; - - kgem->nbatch += 3 * nbox_this_time; - while (nbox_this_time >= 8) { - b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; - b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; - b[6] = cmd; *(uint64_t *)(b+7) = *(uint64_t *)box++; - b[9] = cmd; *(uint64_t *)(b+10) = *(uint64_t *)box++; - b[12] = cmd; *(uint64_t *)(b+13) = *(uint64_t *)box++; - b[15] = cmd; *(uint64_t *)(b+16) = *(uint64_t *)box++; - b[18] = cmd; *(uint64_t *)(b+19) = *(uint64_t *)box++; - b[21] = cmd; *(uint64_t *)(b+22) = *(uint64_t *)box++; - b += 24; - nbox_this_time -= 8; - } - if (nbox_this_time & 4) { - b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; - b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; - b[6] = cmd; *(uint64_t *)(b+7) = *(uint64_t *)box++; - b[9] = cmd; *(uint64_t *)(b+10) = *(uint64_t *)box++; - b += 12; - } - if (nbox_this_time & 2) { - b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; - b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; - b += 6; - } - if (nbox_this_time & 1) { - b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; - } - - if (!nbox) - return; - - sna_blt_fill_begin(sna, &op->base.u.blt); - } while (1); + _sna_blt_fill_boxes(sna, &op->base.u.blt, box, nbox); } static void sna_blt_fill_op_done(struct sna *sna, commit 56f65e65204f1ecbad598419e525e69f6179f9c7 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 23 20:40:21 2011 +0100 sna: Inline box_intersect() Most of this branchy function is spent in manipulating the stack for the function call, so inline it. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 9b6b2c7..8df94eb 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1729,7 +1729,7 @@ sna_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, 0, NULL); } -static Bool +inline static Bool box_intersect(BoxPtr a, const BoxRec *b) { if (a->x1 < b->x1) commit f65e73f8a3a013e79b753d625f79994408e717f7 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 23 19:55:40 2011 +0100 sna: Use fill->boxes to unroll FillSpans Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index d5605be..9b6b2c7 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1766,6 +1766,33 @@ sna_copy_init_blt(struct sna_copy_op *copy, return sna->render.copy(sna, alu, src, src_bo, dst, dst_bo, copy); } +static const BoxRec * +find_clip_box_for_y(const BoxRec *begin, const BoxRec *end, int16_t y) +{ + const BoxRec *mid; + + if (end == begin) + return end; + + if (end - begin == 1) { + if (begin->y2 > y) + return begin; + else + return end; + } + + mid = begin + (end - begin) / 2; + if (mid->y2 > y) + /* If no box is found in [begin, mid], the function + * will return @mid, which is then known to be the + * correct answer. + */ + return find_clip_box_for_y(begin, mid, y); + else + return find_clip_box_for_y(mid, end, y); +} + + static Bool sna_fill_spans_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, @@ -1777,6 +1804,7 @@ sna_fill_spans_blt(DrawablePtr drawable, PixmapPtr pixmap = get_drawable_pixmap(drawable); int16_t dx, dy; struct sna_fill_op fill; + BoxRec box[512], *b = box, *const last_box = box + ARRAY_SIZE(box); static void * const jump[] = { &&no_damage_translate, &&damage_translate, @@ -1805,17 +1833,25 @@ no_damage_translate: dx += drawable->x; dy += drawable->y; no_damage: - do { - BoxRec box; - - box.x1 = pt->x + dx; - box.x2 = box.x1 + *width++; - box.y1 = pt->y + dy; - box.y2 = box.y1 + 1; - pt++; + { + unsigned offset = dx|dy; + do { + *(DDXPointRec *)b = *pt++; + if (offset) { + b->x1 += dx; + b->y1 += dy; + } + b->x2 = b->x1 + (int)*width++; + b->y2 = b->y1 + 1; - fill.box(sna, &fill, &box); - } while (--n); + if (++b == last_box) { + fill.boxes(sna, &fill, box, last_box - box); + b = box; + } + } while (--n); + if (b != box) + fill.boxes(sna, &fill, box, b - box); + } goto done; damage_translate: @@ -1823,18 +1859,22 @@ damage_translate: dy += drawable->y; damage: do { - BoxRec box; - - box.x1 = pt->x + dx; - box.x2 = box.x1 + *width++; - box.y1 = pt->y + dy; - box.y2 = box.y1 + 1; - pt++; + *(DDXPointRec *)b = *pt++; + b->x1 += dx; + b->y1 += dy; + b->x2 = b->x1 + (int)*width++; + b->y2 = b->y1 + 1; - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); + if (++b == last_box) { + fill.boxes(sna, &fill, box, last_box - box); + sna_damage_add_boxes(damage, box, last_box - box, 0, 0); + b = box; + } } while (--n); + if (b != box) { + fill.boxes(sna, &fill, box, b - box); + sna_damage_add_boxes(damage, box, b - box, 0, 0); + } goto done; { @@ -1860,29 +1900,29 @@ no_damage_clipped: if (clip.data == NULL) { do { - BoxRec box; - - box.x1 = pt->x; - box.y1 = pt->y; - box.x2 = box.x1 + (int)*width++; - box.y2 = box.y1 + 1; - pt++; + *(DDXPointRec *)b = *pt++; + b->x2 = b->x1 + (int)*width++; + b->y2 = b->y1 + 1; - if (box_intersect(&box, &clip.extents)) { - box.x1 += dx; - box.x2 += dx; - box.y1 += dy; - box.y2 += dy; - fill.box(sna, &fill, &box); + if (box_intersect(b, &clip.extents)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, box, last_box - box); + b = box; + } } } while (--n); } else { + const BoxRec * const clip_start = RegionBoxptr(&clip); + const BoxRec * const clip_end = clip_start + clip.data->numRects; do { - int nc = clip.data->numRects; - const BoxRec *b = RegionBoxptr(&clip); int16_t X1 = pt->x; int16_t y = pt->y; int16_t X2 = X1 + (int)*width; + const BoxRec *c; pt++; width++; @@ -1899,31 +1939,41 @@ no_damage_clipped: if (X1 >= X2) continue; - y += dy; - do { - if (b->y1 <= y && y < b->y2) { - int x1 = b->x1; - int x2 = b->x2; - - if (x1 < X1) - x1 = X1; - x1 += dx; - if (x1 < 0) - x1 = 0; - if (x2 > X2) - x2 = X2; - x2 += dx; - if (x2 > pixmap->drawable.width) - x2 = pixmap->drawable.width; - - if (x2 > x1) - fill.blt(sna, &fill, x1, y, x2-x1, 1); + c = find_clip_box_for_y(clip_start, + clip_end, + y); + while (c != clip_end) { + if (y + 1 <= c->y1) + break; + + if (X2 <= c->x1) + continue; + if (X1 >= c->x2) + break; + + b->x1 = c->x1; + b->x2 = c->x2; + c++; + + if (b->x1 < X1) + b->x1 = X1; + if (b->x2 > X2) + b->x2 = X2; + + b->x1 += dx; + b->x2 += dx; + b->y1 = y + dy; + b->y2 = b->y1 + 1; + if (++b == last_box) { + fill.boxes(sna, &fill, box, last_box - box); + b = box; } - b++; - } while (--nc); + } } while (--n); RegionUninit(&clip); } + if (b != box) + fill.boxes(sna, &fill, box, b - box); goto done; } @@ -1950,31 +2000,30 @@ damage_clipped: if (clip.data == NULL) { do { - BoxRec box; - - box.x1 = pt->x; - box.y1 = pt->y; - box.x2 = box.x1 + (int)*width++; - box.y2 = box.y1 + 1; - pt++; + *(DDXPointRec *)b = *pt++; + b->x2 = b->x1 + (int)*width++; + b->y2 = b->y1 + 1; - if (box_intersect(&box, &clip.extents)) { - box.x1 += dx; - box.x2 += dx; - box.y1 += dy; - box.y2 += dy; - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); + if (box_intersect(b, &clip.extents)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, box, last_box - box); + sna_damage_add_boxes(damage, box, b - box, 0, 0); + b = box; + } } } while (--n); } else { + const BoxRec * const clip_start = RegionBoxptr(&clip); + const BoxRec * const clip_end = clip_start + clip.data->numRects; do { - int nc = clip.data->numRects; - const BoxRec *b = RegionBoxptr(&clip); int16_t X1 = pt->x; int16_t y = pt->y; int16_t X2 = X1 + (int)*width; + const BoxRec *c; pt++; width++; @@ -1991,41 +2040,44 @@ damage_clipped: if (X1 >= X2) continue; - y += dy; - do { - if (b->y1 <= y && y < b->y2) { - int x1 = b->x1; - int x2 = b->x2; - - if (x1 < X1) - x1 = X1; - x1 += dx; - if (x1 < 0) - x1 = 0; - if (x2 > X2) - x2 = X2; - x2 += dx; - if (x2 > pixmap->drawable.width) - x2 = pixmap->drawable.width; - - if (x2 > x1) { - BoxRec box; - - box.x1 = x1; - box.y1 = y; - box.x2 = x2; - box.y2 = box.y1 + 1; - - fill.box(sna, &fill, &box); - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - } + c = find_clip_box_for_y(clip_start, + clip_end, + y); + while (c != clip_end) { + if (y + 1 <= c->y1) + break; + + if (X2 <= c->x1) + continue; + if (X1 >= c->x2) + break; + + b->x1 = c->x1; + b->x2 = c->x2; + c++; + + if (b->x1 < X1) + b->x1 = X1; + if (b->x2 > X2) + b->x2 = X2; + + b->x1 += dx; + b->x2 += dx; + b->y1 = y + dy; + b->y2 = b->y1 + 1; + if (++b == last_box) { + fill.boxes(sna, &fill, box, last_box - box); + sna_damage_add_boxes(damage, box, last_box - box, 0, 0); + b = box; } - b++; - } while (--nc); + } } while (--n); RegionUninit(&clip); } + if (b != box) { + fill.boxes(sna, &fill, box, b - box); + sna_damage_add_boxes(damage, box, b - box, 0, 0); + } goto done; } commit 94f9cd40dcdd444d3b5a5598deb0f3d04026df3a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 23 19:11:35 2011 +0100 sna: Use fill->boxes to unroll PolyPoint Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 81459b2..d5605be 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2274,6 +2274,7 @@ sna_poly_point_blt(DrawablePtr drawable, struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); RegionPtr clip = fbGetCompositeClip(gc); + BoxRec box[512], *b = box, * const last_box = box + ARRAY_SIZE(box); struct sna_fill_op fill; DDXPointRec last; int16_t dx, dy; @@ -2295,53 +2296,61 @@ sna_poly_point_blt(DrawablePtr drawable, sna_damage_add_points(damage, pt, n, last.x, last.y); do { - BoxRec r; - - r.x1 = pt->x; - r.y1 = pt->y; + b->x1 = pt->x; + b->y1 = pt->y; pt++; - r.x1 += last.x; - r.y1 += last.y; + b->x1 += last.x; + b->y1 += last.y; if (mode == CoordModePrevious) { - last.x = r.x1; - last.y = r.y1; + last.x = b->x1; + last.y = b->y1; } - r.x2 = r.x1 + 1; - r.y2 = r.y1 + 1; - fill.box(sna, &fill, &r); + b->x2 = b->x1 + 1; + b->y2 = b->y1 + 1; + if (++b == last_box) { + fill.boxes(sna, &fill, box, last_box - box); + b = box; + } } while (--n); - } else while (n--) { - int x, y; - - x = pt->x; - y = pt->y; - pt++; - if (mode == CoordModePrevious) { - x += last.x; - y += last.y; - last.x = x; - last.y = y; - } else { - x += drawable->x; - y += drawable->y; - } - - if (RegionContainsPoint(clip, x, y, NULL)) { - fill.blt(sna, &fill, x + dx, y + dy, 1, 1); - if (damage) { - BoxRec box; + if (b != box) + fill.boxes(sna, &fill, box, last_box - box); + } else { + while (n--) { + int x, y; - box.x1 = x + dx; - box.y1 = y + dy; - box.x2 = box.x1 + 1; - box.y2 = box.y1 + 1; + x = pt->x; + y = pt->y; + pt++; + if (mode == CoordModePrevious) { + x += last.x; + y += last.y; + last.x = x; + last.y = y; + } else { + x += drawable->x; + y += drawable->y; + } - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); + if (RegionContainsPoint(clip, x, y, NULL)) { + b->x1 = x + dx; + b->y1 = y + dy; + b->x2 = b->x1 + 1; + b->y2 = b->y1 + 1; + if (++b == last_box){ + fill.boxes(sna, &fill, box, last_box - box); + if (damage) + sna_damage_add_boxes(damage, box, last_box-box, 0, 0); + b = box; + } } } + if (b != box){ + fill.boxes(sna, &fill, box, b - box); + if (damage) + sna_damage_add_boxes(damage, box, b-box, 0, 0); + } } fill.done(sna, &fill); return TRUE; commit 5e08ca75a5eb852c09b9acf6004668bc63f1fe6c Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 23 17:53:54 2011 +0100 sna: Use the new fill->boxes for PolyRectangle Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 82ca094..81459b2 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3893,49 +3893,37 @@ no_damage_zero: dy += drawable->y; do { - BoxRec box; + BoxRec box[4]; if (r->width <= 1 || r->height <= 1) { - box.x1 = r->x + dx; - box.y1 = r->y + dy; - box.x2 = box.x1 + r->width + 1; - box.y2 = box.y1 + r->height + 1; + box[0].x1 = r->x + dx; + box[0].y1 = r->y + dy; + box[0].x2 = box[0].x1 + r->width + 1; + box[0].y2 = box[0].y1 + r->height + 1; DBG(("%s: blt (%d, %d), (%d, %d)\n", __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); + box[0].x1, box[0].y1, box[0].x2, box[0].y2)); + fill.box(sna, &fill, &box[0]); } else { - box.x1 = r->x + dx; - box.y1 = r->y + dy; - box.x2 = box.x1 + r->width + 1; - box.y2 = box.y1 + 1; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); + box[0].x1 = r->x + dx; + box[0].y1 = r->y + dy; + box[0].x2 = box[0].x1 + r->width + 1; + box[0].y2 = box[0].y1 + 1; - box.y1 += r->height; - box.y2 += r->height; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); + box[1] = box[0]; + box[1].y1 += r->height; + box[1].y2 += r->height; - box.y1 = r->y + dy + 1; - box.y2 = box.y1 + r->height - 1; - box.x1 = r->x + dx; - box.x2 = box.x1 + 1; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); + box[2].y1 = r->y + dy + 1; + box[2].y2 = box[2].y1 + r->height - 1; + box[2].x1 = r->x + dx; + box[2].x2 = box[2].x1 + 1; - box.x1 += r->width; - box.x2 += r->width; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - box.x1, box.y1, box.x2, box.y2)); - fill.box(sna, &fill, &box); + box[3] = box[2]; + box[3].x1 += r->width; + box[3].x2 += r->width; + + fill.boxes(sna, &fill, box, 4); } r++; } while (--n); @@ -4092,7 +4080,7 @@ no_damage_wide: dy += drawable->y; do { - BoxRec box; + BoxRec box[4]; int16_t x = r->x + dx; int16_t y = r->y + dy; int16_t width = r->width; @@ -4101,42 +4089,40 @@ no_damage_wide: if (height < offset2 || width < offset1) { if (height == 0) { - box.x1 = x; - box.x2 = x + width + 1; + box[0].x1 = x; + box[0].x2 = x + width + 1; } else { - box.x1 = x - offset1; - box.x2 = box.x1 + width + offset2; + box[0].x1 = x - offset1; + box[0].x2 = box[0].x1 + width + offset2; } if (width == 0) { - box.y1 = y; - box.y2 = y + height + 1; + box[0].y1 = y; + box[0].y2 = y + height + 1; } else { - box.y1 = y - offset1; - box.y2 = box.y1 + height + offset2; + box[0].y1 = y - offset1; + box[0].y2 = box[0].y1 + height + offset2; } - fill.box(sna, &fill, &box); + fill.box(sna, &fill, &box[0]); } else { - box.x1 = x - offset1; - box.x2 = box.x1 + width + offset2; - box.y1 = y - offset1; - box.y2 = box.y1 + offset2; - fill.box(sna, &fill, &box); + box[0].x1 = x - offset1; + box[0].x2 = box[0].x1 + width + offset2; + box[0].y1 = y - offset1; + box[0].y2 = box[0].y1 + offset2; - box.x1 = x - offset1; - box.x2 = box.x1 + offset2; - box.y1 = y + offset3; - box.y2 = y + height - offset1; - fill.box(sna, &fill, &box); + box[1] = box[0]; + box[1].y1 = y + height - offset1; + box[1].y2 = box[1].y1 + offset2; - box.x1 = x + width - offset1; - box.x2 = box.x1 + offset2; - fill.box(sna, &fill, &box); + box[2].x1 = x - offset1; + box[2].x2 = box[2].x1 + offset2; + box[2].y1 = y + offset3; + box[2].y2 = y + height - offset1; - box.x1 = x - offset1; - box.x2 = box.x1 + width + offset2; - box.y1 = y + height - offset1; - box.y2 = box.y1 + offset2; - fill.box(sna, &fill, &box); + box[3] = box[2]; + box[3].x1 = x + width - offset1; + box[3].x2 = box[3].x1 + offset2; + + fill.boxes(sna, &fill, box, 4); } } while (--n); commit efdc7985e2f619ca94cf6ad77ead4f6867ceedc5 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Wed Oct 26 14:57:28 2011 +0100 self-copy-damage diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index e73804d..82ca094 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1299,7 +1299,8 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, goto fallback; } - sna_damage_add_boxes(&priv->gpu_damage, box, n, tx, ty); + if (!priv->gpu_only) + sna_damage_add_boxes(&priv->gpu_damage, box, n, tx, ty); } else { FbBits *dst_bits, *src_bits; int stride, bpp; commit 0ed3426a810336b666604d34c10f996f318ebf82 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 23:45:28 2011 +0100 sna: Convert diagonal zero-width lines into blits This is slower than falling back to swrast for x11perf (up to 4x slower on SNB), it is still faster than doing that rasterisation through a WC-mapping and much faster in ordinary usage due to avoiding the readback hit. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 7c72f41..3ec2e08 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -2021,9 +2021,9 @@ static void gen2_emit_fill_state(struct sna *sna, } static void -gen2_render_fill_blt(struct sna *sna, - const struct sna_fill_op *op, - int16_t x, int16_t y, int16_t w, int16_t h) +gen2_render_fill_op_blt(struct sna *sna, + const struct sna_fill_op *op, + int16_t x, int16_t y, int16_t w, int16_t h) { if (!gen2_get_rectangles(sna, &op->base, 1)) { gen2_emit_fill_state(sna, &op->base); @@ -2039,9 +2039,9 @@ gen2_render_fill_blt(struct sna *sna, } fastcall static void -gen2_render_fill_box(struct sna *sna, - const struct sna_fill_op *op, - const BoxRec *box) +gen2_render_fill_op_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) { if (!gen2_get_rectangles(sna, &op->base, 1)) { gen2_emit_fill_state(sna, &op->base); @@ -2056,8 +2056,37 @@ gen2_render_fill_box(struct sna *sna, VERTEX(box->y1); } +fastcall static void +gen2_render_fill_op_boxes(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int nbox) +{ + DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, n)); + + do { + int nbox_this_time = gen2_get_rectangles(sna, &op->base, nbox); + if (nbox_this_time == 0) { + gen2_emit_fill_state(sna, &op->base); + nbox_this_time = gen2_get_rectangles(sna, &op->base, nbox); + } + nbox -= nbox_this_time; + + do { + VERTEX(box->x2); + VERTEX(box->y2); + VERTEX(box->x1); + VERTEX(box->y2); + VERTEX(box->x1); + VERTEX(box->y1); + box++; + } while (--nbox_this_time); + } while (nbox); +} + static void -gen2_render_fill_done(struct sna *sna, const struct sna_fill_op *op) +gen2_render_fill_op_done(struct sna *sna, const struct sna_fill_op *op) { gen2_vertex_flush(sna); _kgem_set_mode(&sna->kgem, KGEM_RENDER); @@ -2114,9 +2143,10 @@ gen2_render_fill(struct sna *sna, uint8_t alu, tmp); } - tmp->blt = gen2_render_fill_blt; - tmp->box = gen2_render_fill_box; - tmp->done = gen2_render_fill_done; + tmp->blt = gen2_render_fill_op_blt; + tmp->box = gen2_render_fill_op_box; + tmp->boxes = gen2_render_fill_op_boxes; + tmp->done = gen2_render_fill_op_done; gen2_emit_fill_state(sna, &tmp->base); return TRUE; diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 6d91f32..b9ce45f 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3776,9 +3776,9 @@ gen3_render_fill_boxes(struct sna *sna, } static void -gen3_render_fill_blt(struct sna *sna, - const struct sna_fill_op *op, - int16_t x, int16_t y, int16_t w, int16_t h) +gen3_render_fill_op_blt(struct sna *sna, + const struct sna_fill_op *op, + int16_t x, int16_t y, int16_t w, int16_t h) { if (!gen3_get_rectangles(sna, &op->base, 1)) { gen3_emit_composite_state(sna, &op->base); @@ -3794,9 +3794,9 @@ gen3_render_fill_blt(struct sna *sna, } fastcall static void -gen3_render_fill_box(struct sna *sna, - const struct sna_fill_op *op, - const BoxRec *box) +gen3_render_fill_op_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) { if (!gen3_get_rectangles(sna, &op->base, 1)) { gen3_emit_composite_state(sna, &op->base); @@ -3811,8 +3811,37 @@ gen3_render_fill_box(struct sna *sna, OUT_VERTEX(box->y1); } +fastcall static void +gen3_render_fill_op_boxes(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int nbox) +{ + DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, n)); + + do { + int nbox_this_time = gen3_get_rectangles(sna, &op->base, nbox); + if (nbox_this_time == 0) { + gen3_emit_composite_state(sna, &op->base); + nbox_this_time = gen3_get_rectangles(sna, &op->base, nbox); + } + nbox -= nbox_this_time; + + do { + OUT_VERTEX(box->x2); + OUT_VERTEX(box->y2); + OUT_VERTEX(box->x1); + OUT_VERTEX(box->y2); + OUT_VERTEX(box->x1); + OUT_VERTEX(box->y1); + box++; + } while (--nbox_this_time); + } while (nbox); +} + static void -gen3_render_fill_done(struct sna *sna, const struct sna_fill_op *op) +gen3_render_fill_op_done(struct sna *sna, const struct sna_fill_op *op) { gen3_vertex_flush(sna); _kgem_set_mode(&sna->kgem, KGEM_RENDER); @@ -3859,6 +3888,8 @@ gen3_render_fill(struct sna *sna, uint8_t alu, tmp->base.dst.bo = dst_bo; tmp->base.floats_per_vertex = 2; tmp->base.floats_per_rect = 6; + tmp->base.need_magic_ca_pass = 0; + tmp->base.has_component_alpha = 0; tmp->base.src.u.gen3.type = SHADER_CONSTANT; tmp->base.src.u.gen3.mode = @@ -3869,9 +3900,10 @@ gen3_render_fill(struct sna *sna, uint8_t alu, if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) kgem_submit(&sna->kgem); - tmp->blt = gen3_render_fill_blt; - tmp->box = gen3_render_fill_box; - tmp->done = gen3_render_fill_done; + tmp->blt = gen3_render_fill_op_blt; + tmp->box = gen3_render_fill_op_box; + tmp->boxes = gen3_render_fill_op_boxes; + tmp->done = gen3_render_fill_op_done; gen3_emit_composite_state(sna, &tmp->base); gen3_align_vertex(sna, &tmp->base); diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 0092f60..e4a40fc 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2497,24 +2497,38 @@ gen4_render_fill_boxes(struct sna *sna, } static void -gen4_render_fill_blt(struct sna *sna, const struct sna_fill_op *op, - int16_t x, int16_t y, int16_t w, int16_t h) +gen4_render_fill_op_blt(struct sna *sna, const struct sna_fill_op *op, + int16_t x, int16_t y, int16_t w, int16_t h) { gen4_render_fill_rectangle(sna, &op->base, x, y, w, h); } fastcall static void -gen4_render_fill_box(struct sna *sna, - const struct sna_fill_op *op, - const BoxRec *box) +gen4_render_fill_op_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) { gen4_render_fill_rectangle(sna, &op->base, box->x1, box->y1, box->x2-box->x1, box->y2-box->y1); } +fastcall static void +gen4_render_fill_op_boxes(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int nbox) +{ + do { + gen4_render_fill_rectangle(sna, &op->base, + box->x1, box->y1, + box->x2-box->x1, box->y2-box->y1); + box++; + } while (--nbox); +} + static void -gen4_render_fill_done(struct sna *sna, const struct sna_fill_op *op) +gen4_render_fill_op_done(struct sna *sna, const struct sna_fill_op *op) { gen4_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, op->base.src.bo); @@ -2573,6 +2587,8 @@ gen4_render_fill(struct sna *sna, uint8_t alu, op->base.is_affine = TRUE; op->base.floats_per_vertex = 3; + op->base.need_magic_ca_pass = 0; + op->base.has_component_alpha = 0; op->base.u.gen4.wm_kernel = WM_KERNEL; op->base.u.gen4.ve_id = 1; @@ -2582,9 +2598,10 @@ gen4_render_fill(struct sna *sna, uint8_t alu, gen4_fill_bind_surfaces(sna, &op->base); gen4_align_vertex(sna, &op->base); - op->blt = gen4_render_fill_blt; - op->box = gen4_render_fill_box; - op->done = gen4_render_fill_done; + op->blt = gen4_render_fill_op_blt; + op->box = gen4_render_fill_op_box; + op->boxes = gen4_render_fill_op_boxes; + op->done = gen4_render_fill_op_done; return TRUE; } diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index 041e918..e72283e 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2483,9 +2483,9 @@ gen5_render_fill_boxes(struct sna *sna, } static void -gen5_render_fill_blt(struct sna *sna, - const struct sna_fill_op *op, - int16_t x, int16_t y, int16_t w, int16_t h) +gen5_render_fill_op_blt(struct sna *sna, + const struct sna_fill_op *op, + int16_t x, int16_t y, int16_t w, int16_t h) { DBG(("%s (%d, %d)x(%d, %d)\n", __FUNCTION__, x,y,w,h)); @@ -2508,9 +2508,9 @@ gen5_render_fill_blt(struct sna *sna, } fastcall static void -gen5_render_fill_box(struct sna *sna, - const struct sna_fill_op *op, - const BoxRec *box) +gen5_render_fill_op_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) { DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__, box->x1, box->y1, box->x2, box->y2)); @@ -2533,9 +2533,43 @@ gen5_render_fill_box(struct sna *sna, OUT_VERTEX_F(0); } +fastcall static void +gen5_render_fill_op_boxes(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int nbox) +{ + DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, n)); + + do { + int nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox); + if (nbox_this_time == 0) { + gen5_fill_bind_surfaces(sna, &op->base); + nbox_this_time = gen5_get_rectangles(sna, &op->base, nbox); + } + nbox -= nbox_this_time; + + do { + OUT_VERTEX(box->x2, box->y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + box++; + } while (--nbox_this_time); + } while (nbox); +} + static void -gen5_render_fill_done(struct sna *sna, - const struct sna_fill_op *op) +gen5_render_fill_op_done(struct sna *sna, + const struct sna_fill_op *op) { gen5_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, op->base.src.bo); @@ -2578,6 +2612,9 @@ gen5_render_fill(struct sna *sna, uint8_t alu, op->base.dst.bo = dst_bo; op->base.dst.x = op->base.dst.y = 0; + op->base.need_magic_ca_pass = 0; + op->base.has_component_alpha = 0; + op->base.src.bo = sna_render_get_solid(sna, sna_rgba_for_color(color, @@ -2600,9 +2637,10 @@ gen5_render_fill(struct sna *sna, uint8_t alu, gen5_fill_bind_surfaces(sna, &op->base); gen5_align_vertex(sna, &op->base); - op->blt = gen5_render_fill_blt; - op->box = gen5_render_fill_box; - op->done = gen5_render_fill_done; + op->blt = gen5_render_fill_op_blt; + op->box = gen5_render_fill_op_box; + op->boxes = gen5_render_fill_op_boxes; + op->done = gen5_render_fill_op_done; return TRUE; } diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 838819d..05e6d63 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2696,9 +2696,9 @@ gen6_render_fill_boxes(struct sna *sna, } static void -gen6_render_fill_blt(struct sna *sna, - const struct sna_fill_op *op, - int16_t x, int16_t y, int16_t w, int16_t h) +gen6_render_op_fill_blt(struct sna *sna, + const struct sna_fill_op *op, + int16_t x, int16_t y, int16_t w, int16_t h) { DBG(("%s: (%d, %d)x(%d, %d)\n", __FUNCTION__, x, y, w, h)); @@ -2721,9 +2721,9 @@ gen6_render_fill_blt(struct sna *sna, } fastcall static void -gen6_render_fill_box(struct sna *sna, - const struct sna_fill_op *op, - const BoxRec *box) +gen6_render_op_fill_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) { DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__, box->x1, box->y1, box->x2, box->y2)); @@ -2746,8 +2746,42 @@ gen6_render_fill_box(struct sna *sna, OUT_VERTEX_F(0); } +fastcall static void +gen6_render_op_fill_boxes(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int nbox) +{ + DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, n)); + + do { + int nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox); + if (nbox_this_time == 0) { + gen6_emit_fill_state(sna, &op->base); + nbox_this_time = gen6_get_rectangles(sna, &op->base, nbox); + } + nbox -= nbox_this_time; + + do { + OUT_VERTEX(box->x2, box->y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + box++; + } while (--nbox_this_time); + } while (nbox); +} + static void -gen6_render_fill_done(struct sna *sna, const struct sna_fill_op *op) +gen6_render_op_fill_done(struct sna *sna, const struct sna_fill_op *op) { gen6_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, op->base.src.bo); @@ -2807,6 +2841,8 @@ gen6_render_fill(struct sna *sna, uint8_t alu, op->base.mask.repeat = SAMPLER_EXTEND_NONE; op->base.is_affine = TRUE; + op->base.has_component_alpha = FALSE; + op->base.need_magic_ca_pass = FALSE; op->base.floats_per_vertex = 3; op->base.floats_per_rect = 9; @@ -2821,9 +2857,10 @@ gen6_render_fill(struct sna *sna, uint8_t alu, gen6_emit_fill_state(sna, &op->base); gen6_align_vertex(sna, &op->base); - op->blt = gen6_render_fill_blt; - op->box = gen6_render_fill_box; - op->done = gen6_render_fill_done; + op->blt = gen6_render_op_fill_blt; + op->box = gen6_render_op_fill_box; + op->boxes = gen6_render_op_fill_boxes; + op->done = gen6_render_op_fill_done; return TRUE; } diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index ccc0037..05b65f3 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2846,9 +2846,9 @@ gen7_render_fill_boxes(struct sna *sna, } static void -gen7_render_fill_blt(struct sna *sna, - const struct sna_fill_op *op, - int16_t x, int16_t y, int16_t w, int16_t h) +gen7_render_fill_op_blt(struct sna *sna, + const struct sna_fill_op *op, + int16_t x, int16_t y, int16_t w, int16_t h) { DBG(("%s: (%d, %d)x(%d, %d)\n", __FUNCTION__, x, y, w, h)); @@ -2871,9 +2871,9 @@ gen7_render_fill_blt(struct sna *sna, } fastcall static void -gen7_render_fill_box(struct sna *sna, - const struct sna_fill_op *op, - const BoxRec *box) +gen7_render_fill_op_box(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box) { DBG(("%s: (%d, %d),(%d, %d)\n", __FUNCTION__, box->x1, box->y1, box->x2, box->y2)); @@ -2896,8 +2896,42 @@ gen7_render_fill_box(struct sna *sna, OUT_VERTEX_F(0); } +fastcall static void +gen7_render_fill_op_boxes(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int nbox) +{ + DBG(("%s: (%d, %d),(%d, %d)... x %d\n", __FUNCTION__, + box->x1, box->y1, box->x2, box->y2, n)); + + do { + int nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox); + if (nbox_this_time == 0) { + gen7_emit_fill_state(sna, &op->base); + nbox_this_time = gen7_get_rectangles(sna, &op->base, nbox); + } + nbox -= nbox_this_time; + + do { + OUT_VERTEX(box->x2, box->y2); + OUT_VERTEX_F(1); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y2); + OUT_VERTEX_F(0); + OUT_VERTEX_F(1); + + OUT_VERTEX(box->x1, box->y1); + OUT_VERTEX_F(0); + OUT_VERTEX_F(0); + box++; + } while (--nbox_this_time); + } while (nbox); +} + static void -gen7_render_fill_done(struct sna *sna, const struct sna_fill_op *op) +gen7_render_fill_op_done(struct sna *sna, const struct sna_fill_op *op) { gen7_vertex_flush(sna); kgem_bo_destroy(&sna->kgem, op->base.src.bo); @@ -2971,9 +3005,10 @@ gen7_render_fill(struct sna *sna, uint8_t alu, gen7_emit_fill_state(sna, &op->base); gen7_align_vertex(sna, &op->base); - op->blt = gen7_render_fill_blt; - op->box = gen7_render_fill_box; - op->done = gen7_render_fill_done; + op->blt = gen7_render_fill_op_blt; + op->box = gen7_render_fill_op_box; + op->boxes = gen7_render_fill_op_boxes; + op->done = gen7_render_fill_op_done; return TRUE; } diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 6c45b68..e73804d 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -43,6 +43,7 @@ #include <mipict.h> #include <fbpict.h> #endif +#include <miline.h> #include <sys/time.h> #include <sys/mman.h> @@ -60,6 +61,7 @@ #define FORCE_FLUSH 0 #define USE_SPANS 0 +#define USE_ZERO_SPANS 1 DevPrivateKeyRec sna_pixmap_index; DevPrivateKey sna_window_key; @@ -2434,6 +2436,363 @@ fallback: fbPolyPoint(drawable, gc, mode, n, pt); } +static bool +sna_poly_zero_line_blt(DrawablePtr drawable, + struct kgem_bo *bo, + struct sna_damage **damage, + GCPtr gc, int mode, const int _n, const DDXPointRec * const _pt, + const BoxRec *extents, unsigned clipped) +{ + static void * const _jump[] = { + &&no_damage, + &&damage, + + &&no_damage_offset, + &&damage_offset, + }; + + struct sna *sna = to_sna_from_drawable(drawable); + PixmapPtr pixmap = get_drawable_pixmap(drawable); + int x2, y2, xstart, ystart; + int oc2, pt2_clipped = 0; + unsigned int bias = miGetZeroLineBias(drawable->pScreen); + bool degenerate = true; + struct sna_fill_op fill; + RegionRec clip; + BoxRec box[512], *b, * const last_box = box + ARRAY_SIZE(box); + const BoxRec *last_extents; + int16_t dx, dy; + void *jump, *ret; + + DBG(("%s: alu=%d, pixel=%lx, n=%d, clipped=%d, damage=%p\n", + __FUNCTION__, gc->alu, gc->fgPixel, n, clipped, damage)); + if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) + return FALSE; + + get_drawable_deltas(drawable, pixmap, &dx, &dy); + + region_set(&clip, extents); + if (clipped) + region_maybe_clip(&clip, gc->pCompositeClip); + + jump = _jump[(damage != NULL) | !!(dx|dy) << 1]; + DBG(("%s: [clipped] extents=(%d, %d), (%d, %d), delta=(%d, %d)\n", + __FUNCTION__, + clip.extents.x1, clip.extents.y1, + clip.extents.x2, clip.extents.y2, + dx, dy)); + + extents = REGION_RECTS(&clip); + last_extents = extents + REGION_NUM_RECTS(&clip); + + b = box; + do { + int n = _n; + const DDXPointRec *pt = _pt; + + xstart = pt->x + drawable->x; + ystart = pt->y + drawable->y; + + /* x2, y2, oc2 copied to x1, y1, oc1 at top of loop to simplify + * iteration logic + */ + x2 = xstart; + y2 = ystart; + oc2 = 0; + MIOUTCODES(oc2, x2, y2, + clip.extents.x1, + clip.extents.y1, + clip.extents.x2, + clip.extents.y2); + + while (--n) { + int16_t sdx, sdy; + int16_t adx, ady; + int16_t e, e1, e2, e3; + int16_t length; + int x1 = x2, x; + int y1 = y2, y; + int oc1 = oc2; + int octant; + + ++pt; + + x2 = pt->x; + y2 = pt->y; + if (mode == CoordModePrevious) { + x2 += x1; + y2 += y1; + } else { + x2 += drawable->x; + y2 += drawable->y; + } + DBG(("%s: segment (%d, %d) to (%d, %d)\n", + __FUNCTION__, x1, y1, x2, y2)); + if (x2 == x1 && y2 == y1) + continue; + + degenerate = false; + + oc2 = 0; + MIOUTCODES(oc2, x2, y2, + clip.extents.x1, + clip.extents.y1, + clip.extents.x2, + clip.extents.y2); + if (oc1 & oc2) + continue; + + CalcLineDeltas(x1, y1, x2, y2, + adx, ady, sdx, sdy, + 1, 1, octant); + + DBG(("%s: adx=(%d, %d), sdx=(%d, %d)\n", + __FUNCTION__, adx, ady, sdx, sdy)); + if (adx == 0 || ady == 0) { + if (x1 <= x2) { + b->x1 = x1; + b->x2 = x2; + } else { + b->x1 = x2; + b->x2 = x1; + } + if (y1 <= y2) { + b->y1 = y1; + b->y2 = y2; + } else { + b->y1 = y2; + b->y2 = y1; + } + b->x2++; + b->y2++; + if (oc1 | oc2) + box_intersect(b, &clip.extents); + if (++b == last_box) { + ret = &&rectangle_continue; + goto *jump; +rectangle_continue: + b = box; + } + } else if (adx >= ady) { + /* X-major segment */ + e1 = ady << 1; + e2 = e1 - (adx << 1); + e = e1 - adx; + length = adx; /* don't draw endpoint in main loop */ + + FIXUP_ERROR(e, octant, bias); + + x = x1; + y = y1; + pt2_clipped = 0; + + if (oc1 | oc2) { + int x2_clipped = x2, y2_clipped = y2; + int pt1_clipped; + + if (miZeroClipLine(clip.extents.x1, clip.extents.y1, + clip.extents.x2, clip.extents.y2, + &x, &y, &x2_clipped, &y2_clipped, + adx, ady, + &pt1_clipped, &pt2_clipped, + octant, bias, oc1, oc2) == -1) + continue; + + length = abs(x2_clipped - x); + + /* if we've clipped the endpoint, always draw the full length + * of the segment, because then the capstyle doesn't matter + */ + if (pt2_clipped) + length++; + + if (pt1_clipped) { + int clipdx = abs(x - x1); + int clipdy = abs(y - y1); + e += clipdy * e2 + (clipdx - clipdy) * e1; + } + } + if (length == 0) + continue; + + e3 = e2 - e1; + e = e - e1; + + b->x1 = x; + b->y2 = b->y1 = y; + while (length--) { + e += e1; + if (e >= 0) { + b->x2 = x; + if (b->x2 < b->x1) { + int16_t t = b->x1; + b->x1 = b->x2; + b->x2 = t; + } + b->x2++; + b->y2++; + if (++b == last_box) { + ret = &&X_continue; + goto *jump; +X_continue: + b = box; + } + y += sdy; + e += e3; + b->y2 = b->y1 = y; + b->x1 = x; + } + x += sdx; + } + } else { + /* Y-major segment */ + e1 = adx << 1; + e2 = e1 - (ady << 1); + e = e1 - ady; + length = ady; /* don't draw endpoint in main loop */ + + SetYMajorOctant(octant); + FIXUP_ERROR(e, octant, bias); + + x = x1; + y = y1; + pt2_clipped = 0; + + if (oc1 | oc2) { + int x2_clipped = x2, y2_clipped = y2; + int pt1_clipped; + + if (miZeroClipLine(clip.extents.x1, + clip.extents.y1, + clip.extents.x2, + clip.extents.y2, + &x, &y, &x2_clipped, &y2_clipped, + adx, ady, + &pt1_clipped, &pt2_clipped, + octant, bias, oc1, oc2) == -1) + continue; + + length = abs(y2 - y); + + /* if we've clipped the endpoint, always draw the full length + * of the segment, because then the capstyle doesn't matter + */ + if (pt2_clipped) + length++; + + if (pt1_clipped) { + int clipdx = abs(x - x1); + int clipdy = abs(y - y1); + e += clipdx * e2 + (clipdy - clipdx) * e1; + } + } + if (length == 0) + continue; + + e3 = e2 - e1; + e = e - e1; + + b->x2 = b->x1 = x; + b->y1 = y; + while (length--) { + e += e1; + if (e >= 0) { + b->y2 = y; + if (b->y2 < b->y1) { + int16_t t = b->y1; + b->y1 = b->y2; + b->y2 = t; + } + b->x2++; + b->y2++; + if (++b == last_box) { + ret = &&Y_continue; + goto *jump; +Y_continue: + b = box; + } + x += sdx; + e += e3; + b->x2 = b->x1 = x; + b->y1 = y; + } + y += sdy; + } + } + } + +#if 0 + /* Only do the CapNotLast check on the last segment + * and only if the endpoint wasn't clipped. And then, if the last + * point is the same as the first point, do not draw it, unless the + * line is degenerate + */ + if (!pt2_clipped && + gc->capStyle != CapNotLast && + !(xstart == x2 && ystart == y2 && !degenerate)) + { + b->x2 = x2; + b->y2 = y2; + if (b->x2 < b->x1) { + int16_t t = b->x1; + b->x1 = b->x2; + b->x2 = t; + } + if (b->y2 < b->y1) { + int16_t t = b->y1; + b->y1 = b->y2; + b->y2 = t; + } + b->x2++; + b->y2++; + b++; + } +#endif + } while (++extents != last_extents); + + if (b != box) { + ret = &&done; + goto *jump; + } + +done: + fill.done(sna, &fill); + return true; + +damage: + sna_damage_add_boxes(damage, box, b-box, 0, 0); +no_damage: + fill.boxes(sna, &fill, box, b-box); + goto *ret; + +no_damage_offset: + { + BoxRec *bb = box; + do { + bb->x1 += dx; + bb->x2 += dx; + bb->y1 += dy; + bb->y2 += dy; + } while (++bb != b); + fill.boxes(sna, &fill, box, b - box); + } + goto *ret; + +damage_offset: + { + BoxRec *bb = box; + do { + bb->x1 += dx; + bb->x2 += dx; + bb->y1 += dy; + bb->y2 += dy; + } while (++bb != b); + fill.boxes(sna, &fill, box, b - box); + sna_damage_add_boxes(damage, box, b - box, 0, 0); + } + goto *ret; +} + static Bool sna_poly_line_blt(DrawablePtr drawable, struct kgem_bo *bo, @@ -2680,14 +3039,14 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, flags & 2)); if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid && - (gc->lineWidth == 0 || gc->lineWidth == 1) && - PM_IS_SOLID(drawable, gc->planemask) && - flags & 2) { + gc->lineWidth <= 1 && + PM_IS_SOLID(drawable, gc->planemask)) { struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable); DBG(("%s: trying solid fill [%08lx]\n", __FUNCTION__, gc->fgPixel)); + if (flags & 2) { if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_poly_line_blt(drawable, priv->gpu_bo, @@ -2701,6 +3060,17 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), gc, mode, n, pt, flags & 4)) return; + } else { /* !rectilinear */ + if (USE_ZERO_SPANS && + sna_drawable_use_gpu_bo(drawable, ®ion.extents) && + sna_poly_zero_line_blt(drawable, + priv->gpu_bo, + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), + gc, mode, n, pt, + ®ion.extents, flags & 4)) + return; + + } } if (USE_SPANS && can_fill_spans(drawable, gc) && @@ -2745,22 +3115,6 @@ fallback: } static Bool -sna_poly_segment_can_blt(int n, xSegment *seg) -{ - while (n--) { - if (seg->x1 != seg->x2 && seg->y1 != seg->y2) { - DBG(("%s: (%d, %d) -> (%d, %d)\n", - __FUNCTION__, seg->x1, seg->y1, seg->x2, seg->y2)); - return FALSE; - } - - seg++; - } - - return TRUE; -} - -static Bool sna_poly_segment_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, @@ -2895,16 +3249,320 @@ sna_poly_segment_blt(DrawablePtr drawable, return TRUE; } -static Bool +static bool +sna_poly_zero_segment_blt(DrawablePtr drawable, + struct kgem_bo *bo, + struct sna_damage **damage, + GCPtr gc, const int _n, const xSegment *_s, + const BoxRec *extents, unsigned clipped) +{ + static void * const _jump[] = { + &&no_damage, + &&damage, + + &&no_damage_offset, + &&damage_offset, + }; + + struct sna *sna = to_sna_from_drawable(drawable); + PixmapPtr pixmap = get_drawable_pixmap(drawable); + unsigned int bias = miGetZeroLineBias(drawable->pScreen); + struct sna_fill_op fill; + RegionRec clip; + const BoxRec *last_extents; + BoxRec box[512], *b; + BoxRec *const last_box = box + ARRAY_SIZE(box); + int16_t dx, dy; + void *jump, *ret; + + DBG(("%s: alu=%d, pixel=%lx, n=%d, clipped=%d, damage=%p\n", + __FUNCTION__, gc->alu, gc->fgPixel, n, clipped, damage)); + if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) + return FALSE; + + get_drawable_deltas(drawable, pixmap, &dx, &dy); + + region_set(&clip, extents); + if (clipped) + region_maybe_clip(&clip, gc->pCompositeClip); + DBG(("%s: [clipped] extents=(%d, %d), (%d, %d), delta=(%d, %d)\n", + __FUNCTION__, + clip.extents.x1, clip.extents.y1, + clip.extents.x2, clip.extents.y2, + dx, dy)); + + jump = _jump[(damage != NULL) | !!(dx|dy) << 1]; + + b = box; + extents = REGION_RECTS(&clip); + last_extents = extents + REGION_NUM_RECTS(&clip); + do { + int n = _n; + const xSegment *s = _s; + do { + int16_t sdx, sdy; + int16_t adx, ady; + int16_t e, e1, e2, e3; + int16_t length; + int x1, x2; + int y1, y2; + int oc1, oc2; + int octant; + + x1 = s->x1 + drawable->x; + y1 = s->y1 + drawable->y; + x2 = s->x2 + drawable->x; + y2 = s->y2 + drawable->y; + s++; + + DBG(("%s: segment (%d, %d) to (%d, %d)\n", + __FUNCTION__, x1, y1, x2, y2)); + if (x2 == x1 && y2 == y1) + continue; + + oc1 = 0; + MIOUTCODES(oc1, x1, y1, + extents->x1, + extents->y1, + extents->x2, + extents->y2); + oc2 = 0; + MIOUTCODES(oc2, x2, y2, + extents->x1, + extents->y1, + extents->x2, + extents->y2); + if (oc1 & oc2) + continue; + + CalcLineDeltas(x1, y1, x2, y2, + adx, ady, sdx, sdy, + 1, 1, octant); + + DBG(("%s: adx=(%d, %d), sdx=(%d, %d)\n", + __FUNCTION__, adx, ady, sdx, sdy)); + if (adx == 0 || ady == 0) { + if (x1 <= x2) { + b->x1 = x1; + b->x2 = x2; + } else { + b->x1 = x2; + b->x2 = x1; + } + if (y1 <= y2) { + b->y1 = y1; + b->y2 = y2; + } else { + b->y1 = y2; + b->y2 = y1; + } + b->x2++; + b->y2++; + if (box_intersect(b, extents)) { + if (++b == last_box) { + ret = &&rectangle_continue; + goto *jump; +rectangle_continue: + b = box; + } + } + } else if (adx >= ady) { + /* X-major segment */ + e1 = ady << 1; + e2 = e1 - (adx << 1); + e = e1 - adx; + length = adx; /* don't draw endpoint in main loop */ + + FIXUP_ERROR(e, octant, bias); + + if (oc1 | oc2) { + int pt1_clipped, pt2_clipped; + int x = x1, y = y1; + + if (miZeroClipLine(extents->x1, + extents->y1, + extents->x2, + extents->y2, + &x1, &y1, &x2, &y2, + adx, ady, + &pt1_clipped, &pt2_clipped, + octant, bias, oc1, oc2) == -1) + continue; + + length = abs(x2 - x1); + + /* if we've clipped the endpoint, always draw the full length + * of the segment, because then the capstyle doesn't matter + */ + if (pt2_clipped) + length++; + + if (pt1_clipped) { + int clipdx = abs(x1 - x); + int clipdy = abs(y1 - y); + e += clipdy * e2 + (clipdx - clipdy) * e1; + } + } + if (length == 0) + continue; + + e3 = e2 - e1; + e = e - e1; + + b->x1 = x1; + b->y2 = b->y1 = y1; + while (length--) { + e += e1; + if (e >= 0) { + b->x2 = x1; + if (b->x2 < b->x1) { + int16_t t = b->x1; + b->x1 = b->x2; + b->x2 = t; + } + b->x2++; + b->y2++; + if (++b == last_box) { + ret = &&X_continue; + goto *jump; +X_continue: + b = box; + } + y1 += sdy; + e += e3; + b->y2 = b->y1 = y1; + b->x1 = x1; + } + x1 += sdx; + } + } else { + /* Y-major segment */ + e1 = adx << 1; + e2 = e1 - (ady << 1); + e = e1 - ady; + length = ady; /* don't draw endpoint in main loop */ + + SetYMajorOctant(octant); + FIXUP_ERROR(e, octant, bias); + + if (oc1 | oc2) { + int pt1_clipped, pt2_clipped; + int x = x1, y = y1; + + if (miZeroClipLine(extents->x1, + extents->y1, + extents->x2, + extents->y2, + &x1, &y1, &x2, &y2, + adx, ady, + &pt1_clipped, &pt2_clipped, + octant, bias, oc1, oc2) == -1) + continue; + + length = abs(y2 - y1); + + /* if we've clipped the endpoint, always draw the full length + * of the segment, because then the capstyle doesn't matter + */ + if (pt2_clipped) + length++; + + if (pt1_clipped) { + int clipdx = abs(x1 - x); + int clipdy = abs(y1 - y); + e += clipdx * e2 + (clipdy - clipdx) * e1; + } + } + if (length == 0) + continue; + + e3 = e2 - e1; + e = e - e1; + + b->x2 = b->x1 = x1; + b->y1 = y1; + while (length--) { + e += e1; + if (e >= 0) { + b->y2 = y1; + if (b->y2 < b->y1) { + int16_t t = b->y1; + b->y1 = b->y2; + b->y2 = t; + } + b->x2++; + b->y2++; + if (++b == last_box) { + ret = &&Y_continue; + goto *jump; +Y_continue: + b = box; + } + x1 += sdx; + e += e3; + b->x2 = b->x1 = x1; + b->y1 = y1; + } + y1 += sdy; + } + } + } while (--n); + } while (++extents != last_extents); + + if (b != box) { + ret = &&done; + goto *jump; + } + +done: + fill.done(sna, &fill); + return true; + +damage: + sna_damage_add_boxes(damage, box, b-box, 0, 0); +no_damage: + fill.boxes(sna, &fill, box, b-box); + goto *ret; + +no_damage_offset: + { + BoxRec *bb = box; + do { + bb->x1 += dx; + bb->x2 += dx; + bb->y1 += dy; + bb->y2 += dy; + } while (++bb != b); + fill.boxes(sna, &fill, box, b - box); + } + goto *ret; + +damage_offset: + { + BoxRec *bb = box; + do { + bb->x1 += dx; + bb->x2 += dx; + bb->y1 += dy; + bb->y2 += dy; + } while (++bb != b); + fill.boxes(sna, &fill, box, b - box); + sna_damage_add_boxes(damage, box, b - box, 0, 0); + } + goto *ret; +} + +static unsigned sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg, BoxPtr out) { BoxRec box; int extra = gc->lineWidth; + bool clipped, can_blit; if (n == 0) - return true; + return 0; if (gc->capStyle != CapProjecting) extra >>= 1; @@ -2925,6 +3583,7 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc, box.y1 = seg->y2; } + can_blit = seg->x1 == seg->x2 || seg->y1 == seg->y2; while (--n) { seg++; if (seg->x2 > seg->x1) { @@ -2942,6 +3601,9 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc, if (seg->y2 < box.y1) box.y1 = seg->y2; if (seg->y1 > box.y2) box.y2 = seg->y1; } + + if (can_blit && !(seg->x1 == seg->x2 || seg->y1 == seg->y2)) + can_blit = false; } box.x2++; @@ -2954,9 +3616,11 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc, box.y2 += extra; } - trim_and_translate_box(&box, drawable, gc); + clipped = trim_and_translate_box(&box, drawable, gc); + if (box_empty(&box)) + return 0; *out = box; - return box_empty(&box); + return 1 | clipped << 1 | can_blit << 2; } static void @@ -2964,13 +3628,15 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) { struct sna *sna = to_sna_from_drawable(drawable); RegionRec region; + unsigned flags; DBG(("%s(n=%d, first=((%d, %d), (%d, %d)), lineWidth=%d\n", __FUNCTION__, n, seg->x1, seg->y1, seg->x2, seg->y2, gc->lineWidth)); - if (sna_poly_segment_extents(drawable, gc, n, seg, ®ion.extents)) + flags = sna_poly_segment_extents(drawable, gc, n, seg, ®ion.extents); + if (flags == 0) return; DBG(("%s: extents=(%d, %d), (%d, %d)\n", __FUNCTION__, @@ -2991,17 +3657,17 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) gc->lineStyle, gc->lineStyle == LineSolid, gc->lineWidth, gc->planemask, PM_IS_SOLID(drawable, gc->planemask), - sna_poly_segment_can_blt(n, seg))); + flags & 4)); if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid && - (gc->lineWidth == 0 || gc->lineWidth == 1) && - PM_IS_SOLID(drawable, gc->planemask) && - sna_poly_segment_can_blt(n, seg)) { + gc->lineWidth <= 1 && + PM_IS_SOLID(drawable, gc->planemask)) { struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable); DBG(("%s: trying blt solid fill [%08lx] paths\n", __FUNCTION__, gc->fgPixel)); + if (flags & 4) { if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && sna_poly_segment_blt(drawable, priv->gpu_bo, @@ -3015,6 +3681,15 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), gc, n, seg, ®ion.extents)) return; + } else { + if (USE_ZERO_SPANS && + sna_drawable_use_gpu_bo(drawable, ®ion.extents) && + sna_poly_zero_segment_blt(drawable, + priv->gpu_bo, + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), + gc, n, seg, ®ion.extents, flags & 2)) + return; + } } /* XXX Do we really want to base this decision on the amalgam ? */ diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 62f8cdf..9b598c9 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1297,6 +1297,66 @@ fastcall static void sna_blt_fill_op_box(struct sna *sna, *(uint64_t *)(b+1) = *(uint64_t *)box; } +fastcall static void sna_blt_fill_op_boxes(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int nbox) +{ + struct kgem *kgem = &sna->kgem; + uint32_t cmd = op->base.u.blt.cmd; + + DBG(("%s: %08x x %d\n", __FUNCTION__, + op->base.u.blt.pixel, nbox)); + + if (!kgem_check_batch(kgem, 3)) + sna_blt_fill_begin(sna, &op->base.u.blt); + + do { + uint32_t *b = kgem->batch + kgem->nbatch; + int nbox_this_time; + + nbox_this_time = nbox; + if (3*nbox_this_time > kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) + nbox_this_time = (kgem->surface - kgem->nbatch - KGEM_BATCH_RESERVED) / 3; + assert(nbox_this_time); + nbox -= nbox_this_time; + + kgem->nbatch += 3 * nbox_this_time; + while (nbox_this_time >= 8) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; + b[6] = cmd; *(uint64_t *)(b+7) = *(uint64_t *)box++; + b[9] = cmd; *(uint64_t *)(b+10) = *(uint64_t *)box++; + b[12] = cmd; *(uint64_t *)(b+13) = *(uint64_t *)box++; + b[15] = cmd; *(uint64_t *)(b+16) = *(uint64_t *)box++; + b[18] = cmd; *(uint64_t *)(b+19) = *(uint64_t *)box++; + b[21] = cmd; *(uint64_t *)(b+22) = *(uint64_t *)box++; + b += 24; + nbox_this_time -= 8; + } + if (nbox_this_time & 4) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; + b[6] = cmd; *(uint64_t *)(b+7) = *(uint64_t *)box++; + b[9] = cmd; *(uint64_t *)(b+10) = *(uint64_t *)box++; + b += 12; + } + if (nbox_this_time & 2) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + b[3] = cmd; *(uint64_t *)(b+4) = *(uint64_t *)box++; + b += 6; + } + if (nbox_this_time & 1) { + b[0] = cmd; *(uint64_t *)(b+1) = *(uint64_t *)box++; + } + + if (!nbox) + return; + + sna_blt_fill_begin(sna, &op->base.u.blt); + } while (1); +} + static void sna_blt_fill_op_done(struct sna *sna, const struct sna_fill_op *fill) { @@ -1324,9 +1384,10 @@ bool sna_blt_fill(struct sna *sna, uint8_t alu, bo, bpp, alu, pixel)) return FALSE; - fill->blt = sna_blt_fill_op_blt; - fill->box = sna_blt_fill_op_box; - fill->done = sna_blt_fill_op_done; + fill->blt = sna_blt_fill_op_blt; + fill->box = sna_blt_fill_op_box; + fill->boxes = sna_blt_fill_op_boxes; + fill->done = sna_blt_fill_op_done; return TRUE; } diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index d30c0b6..6c18791 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -160,6 +160,10 @@ struct sna_fill_op { fastcall void (*box)(struct sna *sna, const struct sna_fill_op *op, const BoxRec *box); + fastcall void (*boxes)(struct sna *sna, + const struct sna_fill_op *op, + const BoxRec *box, + int count); void (*done)(struct sna *sna, const struct sna_fill_op *op); }; commit c12371d9e7b3bbff7f318186a0933d6108db0bc8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 22:28:56 2011 +0100 sna: Flatten the branching for fill-spans Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 11f5c21..6c45b68 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1768,123 +1768,244 @@ sna_fill_spans_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, GCPtr gc, int n, DDXPointPtr pt, int *width, int sorted, - const BoxRec *extents, bool clipped) + const BoxRec *extents, unsigned clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); - RegionRec clip; int16_t dx, dy; struct sna_fill_op fill; + static void * const jump[] = { + &&no_damage_translate, + &&damage_translate, + &&no_damage_clipped_translate, + &&damage_clipped_translate, + + &&no_damage, + &&damage, + &&no_damage_clipped, + &&damage_clipped, + }; + unsigned v; + + DBG(("%s: alu=%d, fg=%08lx, damge=%p, clipped?=%d\n", + __FUNCTION__, gc->alu, gc->fgPixel, damage, clipped)); if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return false; - region_set(&clip, extents); - region_maybe_clip(&clip, gc->pCompositeClip); + get_drawable_deltas(drawable, pixmap, &dx, &dy); - DBG(("%s: clip %d x [(%d, %d), (%d, %d)] x %d [(%d, %d)...]\n", - __FUNCTION__, - REGION_NUM_RECTS(&clip), - extents->x1, extents->y1, extents->x2, extents->y2, - n, pt->x, pt->y)); + v = (damage != NULL) | clipped | gc->miTranslate << 2; + goto *jump[v]; - if (!gc->miTranslate) { +no_damage_translate: + dx += drawable->x; + dy += drawable->y; +no_damage: + do { + BoxRec box; + + box.x1 = pt->x + dx; + box.x2 = box.x1 + *width++; + box.y1 = pt->y + dy; + box.y2 = box.y1 + 1; + pt++; + + fill.box(sna, &fill, &box); + } while (--n); + goto done; + +damage_translate: + dx += drawable->x; + dy += drawable->y; +damage: + do { + BoxRec box; + + box.x1 = pt->x + dx; + box.x2 = box.x1 + *width++; + box.y1 = pt->y + dy; + box.y2 = box.y1 + 1; + pt++; + + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + } while (--n); + goto done; + + { + RegionRec clip; int i; +no_damage_clipped_translate: for (i = 0; i < n; i++) { /* XXX overflow? */ pt->x += drawable->x; pt->y += drawable->y; } - } - get_drawable_deltas(drawable, pixmap, &dx, &dy); - if (!clipped) { - if (damage) { +no_damage_clipped: + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); + + DBG(("%s: clip %d x [(%d, %d), (%d, %d)] x %d [(%d, %d)...]\n", + __FUNCTION__, + REGION_NUM_RECTS(&clip), + clip.extents.x1, clip.extents.y1, clip.extents.x2, clip.extents.y2, + n, pt->x, pt->y)); + + if (clip.data == NULL) { do { BoxRec box; - box.x1 = pt->x + dx; - box.x2 = box.x1 + *width++; - box.y1 = pt->y + dy; + box.x1 = pt->x; + box.y1 = pt->y; + box.x2 = box.x1 + (int)*width++; box.y2 = box.y1 + 1; pt++; - fill.box(sna, &fill, &box); - - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); + if (box_intersect(&box, &clip.extents)) { + box.x1 += dx; + box.x2 += dx; + box.y1 += dy; + box.y2 += dy; + fill.box(sna, &fill, &box); + } } while (--n); } else { do { - BoxRec box; + int nc = clip.data->numRects; + const BoxRec *b = RegionBoxptr(&clip); + int16_t X1 = pt->x; + int16_t y = pt->y; + int16_t X2 = X1 + (int)*width; - box.x1 = pt->x + dx; - box.x2 = box.x1 + *width++; - box.y1 = pt->y + dy; - box.y2 = box.y1 + 1; pt++; - - fill.box(sna, &fill, &box); + width++; + + if (y < extents->y1 || extents->y2 <= y) + continue; + + if (X1 < extents->x1) + X1 = extents->x1; + + if (X2 > extents->x2) + X2 = extents->x2; + + if (X1 >= X2) + continue; + + y += dy; + do { + if (b->y1 <= y && y < b->y2) { + int x1 = b->x1; + int x2 = b->x2; + + if (x1 < X1) + x1 = X1; + x1 += dx; + if (x1 < 0) + x1 = 0; + if (x2 > X2) + x2 = X2; + x2 += dx; + if (x2 > pixmap->drawable.width) + x2 = pixmap->drawable.width; + + if (x2 > x1) + fill.blt(sna, &fill, x1, y, x2-x1, 1); + } + b++; + } while (--nc); } while (--n); + RegionUninit(&clip); } - } else do { - int16_t X1 = pt->x; - int16_t y = pt->y; - int16_t X2 = X1 + (int)*width; - - pt++; - width++; + goto done; + } - if (y < extents->y1 || extents->y2 <= y) - continue; + { + RegionRec clip; + int i; - if (X1 < extents->x1) - X1 = extents->x1; +damage_clipped_translate: + for (i = 0; i < n; i++) { + /* XXX overflow? */ + pt->x += drawable->x; + pt->y += drawable->y; + } - if (X2 > extents->x2) - X2 = extents->x2; +damage_clipped: + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); - if (X1 >= X2) - continue; + DBG(("%s: clip %d x [(%d, %d), (%d, %d)] x %d [(%d, %d)...]\n", + __FUNCTION__, + REGION_NUM_RECTS(&clip), + clip.extents.x1, clip.extents.y1, clip.extents.x2, clip.extents.y2, + n, pt->x, pt->y)); - y += dy; if (clip.data == NULL) { - fill.blt(sna, &fill, X1 + dx, y, X2-X1, 1); - if (damage) { + do { BoxRec box; - box.x1 = X1 + dx; - box.x2 = X2 + dx; - box.y1 = y; + box.x1 = pt->x; + box.y1 = pt->y; + box.x2 = box.x1 + (int)*width++; box.y2 = box.y1 + 1; + pt++; - assert_pixmap_contains_box(pixmap, &box); - sna_damage_add_box(damage, &box); - } + if (box_intersect(&box, &clip.extents)) { + box.x1 += dx; + box.x2 += dx; + box.y1 += dy; + box.y2 += dy; + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + } + } while (--n); } else { - int nc = clip.data->numRects; - const BoxRec *b = RegionBoxptr(&clip); - while (nc--) { - if (b->y1 <= y && y < b->y2) { - int x1 = b->x1; - int x2 = b->x2; - - if (x1 < X1) - x1 = X1; - x1 += dx; - if (x1 < 0) - x1 = 0; - if (x2 > X2) - x2 = X2; - x2 += dx; - if (x2 > pixmap->drawable.width) - x2 = pixmap->drawable.width; - - if (x2 > x1) { - fill.blt(sna, &fill, - x1, y, x2-x1, 1); - if (damage) { + do { + int nc = clip.data->numRects; + const BoxRec *b = RegionBoxptr(&clip); + int16_t X1 = pt->x; + int16_t y = pt->y; + int16_t X2 = X1 + (int)*width; + + pt++; + width++; + + if (y < extents->y1 || extents->y2 <= y) + continue; + + if (X1 < extents->x1) + X1 = extents->x1; + + if (X2 > extents->x2) + X2 = extents->x2; + + if (X1 >= X2) + continue; + + y += dy; + do { + if (b->y1 <= y && y < b->y2) { + int x1 = b->x1; + int x2 = b->x2; + + if (x1 < X1) + x1 = X1; + x1 += dx; + if (x1 < 0) + x1 = 0; + if (x2 > X2) + x2 = X2; + x2 += dx; + if (x2 > pixmap->drawable.width) + x2 = pixmap->drawable.width; + + if (x2 > x1) { BoxRec box; box.x1 = x1; @@ -1892,17 +2013,21 @@ sna_fill_spans_blt(DrawablePtr drawable, box.x2 = x2; box.y2 = box.y1 + 1; + fill.box(sna, &fill, &box); assert_pixmap_contains_box(pixmap, &box); sna_damage_add_box(damage, &box); } } - } - b++; - } + b++; + } while (--nc); + } while (--n); + RegionUninit(&clip); } - } while (--n); + goto done; + } + +done: fill.done(sna, &fill); - RegionUninit(&clip); return TRUE; } commit e7f19d85fead62df21eedc87409b5abacfec4a17 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 22:15:09 2011 +0100 sna/blt: Upload the box using a single 64-bit instruction So long as we have 64-bit instructions of course! Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 9ab7d8e..62f8cdf 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1294,8 +1294,7 @@ fastcall static void sna_blt_fill_op_box(struct sna *sna, kgem->nbatch += 3; b[0] = op->base.u.blt.cmd; - b[1] = box->y1 << 16 | box->x1; - b[2] = box->y2 << 16 | box->x2; + *(uint64_t *)(b+1) = *(uint64_t *)box; } static void sna_blt_fill_op_done(struct sna *sna, @@ -1447,8 +1446,7 @@ static Bool sna_blt_fill_box(struct sna *sna, uint8_t alu, b[0] = cmd; b[1] = br13; - b[2] = box->y1 << 16 | box->x1; - b[3] = box->y2 << 16 | box->x2; + *(uint64_t *)(b+2) = *(uint64_t *)box; b[4] = kgem_add_reloc(kgem, kgem->nbatch + 4, bo, I915_GEM_DOMAIN_RENDER << 16 | @@ -1566,8 +1564,7 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, b = kgem->batch + kgem->nbatch; kgem->nbatch += 3; b[0] = cmd; - b[1] = box->y1 << 16 | box->x1; - b[2] = box->y2 << 16 | box->x2; + *(uint64_t *)(b+1) = *(uint64_t *)box; box++; } while (--nbox_this_time); commit 40af32a0e9ed971a1f2c2a45266f32016bda7ed3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 21 20:10:02 2011 +0100 sna: Execute blits directly for PolyRectangle By constructing the batch buffer directly for PolyRectangle, rather than via miPolyRectangle->(PolyFillRectangle/PolyLine), we dramatically reduce the CPU overhead and can saturate the GPU. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 636544e..11f5c21 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2940,6 +2940,562 @@ fallback: fbPolySegment(drawable, gc, n, seg); } +static unsigned +sna_poly_rectangle_extents(DrawablePtr drawable, GCPtr gc, + int n, xRectangle *r, + BoxPtr out) +{ + BoxRec box; + int extra = gc->lineWidth >> 1; + bool clipped; + + if (n == 0) + return 0; + + box.x1 = r->x; + box.y1 = r->y; + box.x2 = r->x + r->width; + box.y2 = r->y + r->height; + + while (--n) { + r++; + if (r->x < box.x1) + box.x1 = r->x; + if (r->x + r->width > box.x2) + box.x2 = r->x + r->width; + if (r->y < box.y1) + box.y1 = r->y; + if (r->y + r->width > box.y2) + box.y2 = r->y + r->height; + } + + box.x2++; + box.y2++; + + if (extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + if (box_empty(&box)) + return 0; + + clipped = trim_and_translate_box(&box, drawable, gc); + *out = box; + return 1 | clipped << 1; +} + +static Bool +sna_poly_rectangle_blt(DrawablePtr drawable, + struct kgem_bo *bo, + struct sna_damage **damage, + GCPtr gc, int n, xRectangle *r, + const BoxRec *extents, bool clipped) +{ + struct sna *sna = to_sna_from_drawable(drawable); + PixmapPtr pixmap = get_drawable_pixmap(drawable); + struct sna_fill_op fill; + int16_t dx, dy; + static void * const jump[] = { + &&no_damage_zero, + &&maybe_damage_zero_clipped, + &&no_damage_wide, + &&maybe_damage_wide_clipped, + + &&damage_zero, + &&maybe_damage_zero_clipped, + &&damage_wide, + &&maybe_damage_wide_clipped, + }; + unsigned v; + + DBG(("%s: alu=%d, width=%d, fg=%08lx, damge=%p, clipped?=%d\n", + __FUNCTION__, gc->alu, gc->lineWidth, gc->fgPixel, damage, clipped)); + + if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) + return FALSE; + + get_drawable_deltas(drawable, pixmap, &dx, &dy); + + v = !!clipped; + v |= (gc->lineWidth != 0) << 1; + v |= (damage != NULL) << 2; + goto *jump[v]; + +damage_zero: + dx += drawable->x; + dy += drawable->y; + + do { + BoxRec box; + + if (r->width <= 1 || r->height <= 1) { + box.x1 = r->x + dx; + box.y1 = r->y + dy; + box.x2 = box.x1 + r->width + 1; + box.y2 = box.y1 + r->height + 1; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + } else { + box.x1 = r->x + dx; + box.y1 = r->y + dy; + box.x2 = box.x1 + r->width + 1; + box.y2 = box.y1 + 1; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + + box.y1 += r->height; + box.y2 += r->height; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + + box.y1 = r->y + dy + 1; + box.y2 = box.y1 + r->height - 1; + box.x1 = r->x + dx; + box.x2 = box.x1 + 1; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + + box.x1 += r->width; + box.x2 += r->width; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + } + r++; + } while (--n); + goto done; + +no_damage_zero: + dx += drawable->x; + dy += drawable->y; + + do { + BoxRec box; + + if (r->width <= 1 || r->height <= 1) { + box.x1 = r->x + dx; + box.y1 = r->y + dy; + box.x2 = box.x1 + r->width + 1; + box.y2 = box.y1 + r->height + 1; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + } else { + box.x1 = r->x + dx; + box.y1 = r->y + dy; + box.x2 = box.x1 + r->width + 1; + box.y2 = box.y1 + 1; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + + box.y1 += r->height; + box.y2 += r->height; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + + box.y1 = r->y + dy + 1; + box.y2 = box.y1 + r->height - 1; + box.x1 = r->x + dx; + box.x2 = box.x1 + 1; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + + box.x1 += r->width; + box.x2 += r->width; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + fill.box(sna, &fill, &box); + } + r++; + } while (--n); + goto done; + +maybe_damage_zero_clipped: + { + RegionRec clip; + BoxRec box[4], *b, *c; + int count = 0, i, j; + + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); + + do { + if (r->width <= 1 || r->height <= 1) { + box[0].x1 = r->x + drawable->x; + box[0].y1 = r->y + drawable->y; + box[0].x2 = box[0].x1 + r->width + 1; + box[0].y2 = box[0].y1 + r->height + 1; + count = 1; + } else { + box[0].x1 = r->x + drawable->x; + box[0].y1 = r->y + drawable->y; + box[0].x2 = box[0].x1 + r->width + 1; + box[0].y2 = box[0].y1 + 1; + + box[1] = box[0]; + box[1].y1 += r->height; + box[1].y2 += r->height; + + box[2].y1 = r->y + drawable->y + 1; + box[2].y2 = box[2].y1 + r->height - 1; + box[2].x1 = r->x + drawable->x; + box[2].x2 = box[2].x1 + 1; + + box[3] = box[2]; + box[3].x1 += r->width; + box[3].x2 += r->width; + count = 4; + } + + for (i = REGION_NUM_RECTS(&clip), c = REGION_RECTS(&clip); i--; c++) { + for (j = count, b = box; j--; b++) { + BoxRec clipped = *b; + if (box_intersect(&clipped, c)) { + clipped.x1 += dx; + clipped.x2 += dx; + clipped.y1 += dy; + clipped.y2 += dy; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + clipped.x1, clipped.y1, clipped.x2, clipped.y2)); + fill.box(sna, &fill, &clipped); + if (damage) { + assert_pixmap_contains_box(pixmap, &clipped); + sna_damage_add_box(damage, &clipped); + } + } + } + } + r++; + } while (--n); + } + goto done; + +maybe_damage_wide_clipped: + { + RegionRec clip; + int16_t offset2 = gc->lineWidth; + int16_t offset1 = offset2 >> 1; + int16_t offset3 = offset2 - offset1; + + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); + + do { + BoxRec box[4], *c, *b; + int16_t x = r->x + drawable->x; + int16_t y = r->y + drawable->y; + int16_t width = r->width; + int16_t height = r->height; + int count, i, j; + r++; + + if (height < offset2 || width < offset1) { + if (height == 0) { + box[0].x1 = x; + box[0].x2 = x + width + 1; + } else { + box[0].x1 = x - offset1; + box[0].x2 = box[0].x1 + width + offset2; + } + if (width == 0) { + box[0].y1 = y; + box[0].y2 = y + height + 1; + } else { + box[0].y1 = y - offset1; + box[0].y2 = box[0].y1 + height + offset2; + } + count = 1; + } else { + box[0].x1 = x - offset1; + box[0].x2 = box[0].x1 + width + offset2; + box[0].y1 = y - offset1; + box[0].y2 = box[0].y1 + offset2; + + box[1].x1 = x - offset1; + box[1].x2 = box[1].x1 + offset2; + box[1].y1 = y + offset3; + box[1].y2 = y + height - offset1; + + box[2].x1 = x + width - offset1; + box[2].x2 = box[2].x1 + offset2; + box[2].y1 = y + offset3; + box[2].y2 = y + height - offset1; + + box[3] = box[1]; + box[3].y1 += height; + box[3].y2 += height; + count = 4; + } + + for (i = REGION_NUM_RECTS(&clip), c = REGION_RECTS(&clip); i--; c++) { + for (j = count, b = box; j--; b++) { + BoxRec clipped = *b; + if (box_intersect(&clipped, c)) { + clipped.x1 += dx; + clipped.x2 += dx; + clipped.y1 += dy; + clipped.y2 += dy; + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + clipped.x1, clipped.y1, clipped.x2, clipped.y2)); + fill.box(sna, &fill, &clipped); + if (damage) { + assert_pixmap_contains_box(pixmap, &clipped); + sna_damage_add_box(damage, &clipped); + } + } + } + } + } while (--n); + } + goto done; + +no_damage_wide: + { + int offset2 = gc->lineWidth; + int offset1 = offset2 >> 1; + int offset3 = offset2 - offset1; + + dx += drawable->x; + dy += drawable->y; + + do { + BoxRec box; + int16_t x = r->x + dx; + int16_t y = r->y + dy; + int16_t width = r->width; + int16_t height = r->height; + r++; + + if (height < offset2 || width < offset1) { + if (height == 0) { + box.x1 = x; + box.x2 = x + width + 1; + } else { + box.x1 = x - offset1; + box.x2 = box.x1 + width + offset2; + } + if (width == 0) { + box.y1 = y; + box.y2 = y + height + 1; + } else { + box.y1 = y - offset1; + box.y2 = box.y1 + height + offset2; + } + fill.box(sna, &fill, &box); + } else { + box.x1 = x - offset1; + box.x2 = box.x1 + width + offset2; + box.y1 = y - offset1; + box.y2 = box.y1 + offset2; + fill.box(sna, &fill, &box); + + box.x1 = x - offset1; + box.x2 = box.x1 + offset2; + box.y1 = y + offset3; + box.y2 = y + height - offset1; + fill.box(sna, &fill, &box); + + box.x1 = x + width - offset1; + box.x2 = box.x1 + offset2; + fill.box(sna, &fill, &box); + + box.x1 = x - offset1; + box.x2 = box.x1 + width + offset2; + box.y1 = y + height - offset1; + box.y2 = box.y1 + offset2; + fill.box(sna, &fill, &box); + } + + } while (--n); + } + goto done; + +damage_wide: + { + int offset2 = gc->lineWidth; + int offset1 = offset2 >> 1; + int offset3 = offset2 - offset1; + + dx += drawable->x; + dy += drawable->y; + + do { + BoxRec box; + int16_t x = r->x + dx; + int16_t y = r->y + dy; + int16_t width = r->width; + int16_t height = r->height; + r++; + + if (height < offset2 || width < offset1) { + if (height == 0) { + box.x1 = x; + box.x2 = x + width + 1; + } else { + box.x1 = x - offset1; + box.x2 = box.x1 + width + offset2; + } + if (width == 0) { + box.y1 = y; + box.y2 = y + height + 1; + } else { + box.y1 = y - offset1; + box.y2 = box.y1 + height + offset2; + } + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + } else { + box.x1 = x - offset1; + box.x2 = box.x1 + width + offset2; + box.y1 = y - offset1; + box.y2 = box.y1 + offset2; + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + + box.x1 = x - offset1; + box.x2 = box.x1 + offset2; + box.y1 = y + offset3; + box.y2 = y + height - offset1; + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + + box.x1 = x + width - offset1; + box.x2 = box.x1 + offset2; + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + + box.x1 = x - offset1; + box.x2 = box.x1 + width + offset2; + box.y1 = y + height - offset1; + box.y2 = box.y1 + offset2; + fill.box(sna, &fill, &box); + assert_pixmap_contains_box(pixmap, &box); + sna_damage_add_box(damage, &box); + } + } while (--n); + } + goto done; + +done: + fill.done(sna, &fill); + return TRUE; +} + +static void +sna_poly_rectangle(DrawablePtr drawable, GCPtr gc, int n, xRectangle *r) +{ + struct sna *sna = to_sna_from_drawable(drawable); + RegionRec region; + unsigned flags; + + DBG(("%s(n=%d, first=((%d, %d)x(%d, %d)), lineWidth=%d\n", + __FUNCTION__, + n, r->x, r->y, r->width, r->height, + gc->lineWidth)); + + flags = sna_poly_rectangle_extents(drawable, gc, n, r, ®ion.extents); + if (flags == 0) + return; + + DBG(("%s: extents=(%d, %d), (%d, %d), flags=%x\n", __FUNCTION__, + region.extents.x1, region.extents.y1, + region.extents.x2, region.extents.y2, + flags)); + + if (FORCE_FALLBACK) + goto fallback; + + if (wedged(sna)) { + DBG(("%s: fallback -- wedged\n", __FUNCTION__)); + goto fallback; + } + + DBG(("%s: line=%d [%d], join=%d [%d], mask=%lu [%d]\n", + __FUNCTION__, + gc->lineStyle, gc->lineStyle == LineSolid, + gc->joinStyle, gc->joinStyle == JoinMiter, + gc->planemask, PM_IS_SOLID(drawable, gc->planemask))); + if (gc->lineStyle == LineSolid && + gc->joinStyle == JoinMiter && + PM_IS_SOLID(drawable, gc->planemask)) { + struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable); + + DBG(("%s: trying blt solid fill [%08lx] paths\n", + __FUNCTION__, gc->fgPixel)); + + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents) && + sna_poly_rectangle_blt(drawable, priv->gpu_bo, + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), + gc, n, r, ®ion.extents, flags&2)) + return; + + if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && + sna_poly_rectangle_blt(drawable, priv->cpu_bo, + reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), + gc, n, r, ®ion.extents, flags&2)) + return; + } + + /* Not a trivial outline, but we still maybe able to break it + * down into simpler operations that we can accelerate. + */ + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents)) { + miPolyRectangle(drawable, gc, n, r); + return; + } + +fallback: + DBG(("%s: fallback\n", __FUNCTION__)); + + region.data = NULL; + region_maybe_clip(®ion, gc->pCompositeClip); + if (!RegionNotEmpty(®ion)) + return; + + sna_gc_move_to_cpu(gc); + sna_drawable_move_region_to_cpu(drawable, ®ion, true); + RegionUninit(®ion); + + DBG(("%s: fbPolyRectangle\n", __FUNCTION__)); + fbPolyRectangle(drawable, gc, n, r); +} + static Bool sna_poly_arc_extents(DrawablePtr drawable, GCPtr gc, int n, xArc *arc, @@ -3901,7 +4457,7 @@ static const GCOps sna_gc_ops = { sna_poly_point, sna_poly_line, sna_poly_segment, - miPolyRectangle, + sna_poly_rectangle, sna_poly_arc, miFillPolygon, sna_poly_fill_rect, From ickle at kemper.freedesktop.org Thu Oct 27 04:49:30 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 27 Oct 2011 04:49:30 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111027114930.4A7331000F@kemper.freedesktop.org> src/sna/sna_accel.c | 324 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 219 insertions(+), 105 deletions(-) New commits: commit 990043f6b8cf8e580aad2e52f8d236a6aec838b5 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 12:33:55 2011 +0100 sna: Handle singular clip regions for PolyRectangles Otherwise X will crash! Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index efa2013..7b8f761 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3430,13 +3430,13 @@ sna_poly_zero_segment_blt(DrawablePtr drawable, } b->x2++; b->y2++; - if (box_intersect(b, extents)) { - if (++b == last_box) { - ret = &&rectangle_continue; - goto *jump; + if (oc1 | oc2) + box_intersect(b, &clip.extents); + if (++b == last_box) { + ret = &&rectangle_continue; + goto *jump; rectangle_continue: - b = box; - } + b = box; } } else if (adx >= ady) { /* X-major segment */ @@ -3943,59 +3943,111 @@ zero: zero_clipped: { RegionRec clip; - const BoxRec *clip_start, *clip_end, *c; BoxRec box[4]; - int count, i; + int count; region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); if (!RegionNotEmpty(&clip)) - return true; + goto done; - clip_start = RegionBoxptr(&clip); - clip_end = clip_start + clip.data->numRects; - do { - xRectangle rr = *r++; - rr.x += drawable->x; - rr.y += drawable->y; - - if (rr.width <= 1 || rr.height <= 1) { - box[0].x1 = rr.x; - box[0].y1 = rr.y; - box[0].x2 = rr.x + rr.width + 1; - box[0].y2 = rr.y + r->height + 1; - count = 1; - } else { - box[0].x1 = rr.x; - box[0].y1 = rr.y; - box[0].x2 = rr.x + rr.width + 1; - box[0].y2 = rr.y + 1; - - box[1] = box[0]; - box[1].y1 += rr.height; - box[1].y2 += rr.height; - - box[2].y1 = rr.y + 1; - box[2].y2 = box[2].y1 + rr.height - 1; - box[2].x1 = rr.x; - box[2].x2 = rr.x + 1; - - box[3] = box[2]; - box[3].x1 += rr.width; - box[3].x2 += rr.width; - count = 4; - } + if (clip.data) { + const BoxRec * const clip_start = RegionBoxptr(&clip); + const BoxRec * const clip_end = clip_start + clip.data->numRects; + const BoxRec *c; + do { + xRectangle rr = *r++; + rr.x += drawable->x; + rr.y += drawable->y; - for (i = 0; i < count; i++) { - c = find_clip_box_for_y(clip_start, - clip_end, - box[i].y1); - while (c != clip_end) { - if (box[i].y2 <= c->y1) - break; + if (rr.width <= 1 || rr.height <= 1) { + box[0].x1 = rr.x; + box[0].y1 = rr.y; + box[0].x2 = rr.x + rr.width + 1; + box[0].y2 = rr.y + r->height + 1; + count = 1; + } else { + box[0].x1 = rr.x; + box[0].y1 = rr.y; + box[0].x2 = rr.x + rr.width + 1; + box[0].y2 = rr.y + 1; + + box[1] = box[0]; + box[1].y1 += rr.height; + box[1].y2 += rr.height; + + box[2].y1 = rr.y + 1; + box[2].y2 = box[2].y1 + rr.height - 1; + box[2].x1 = rr.x; + box[2].x2 = rr.x + 1; + + box[3] = box[2]; + box[3].x1 += rr.width; + box[3].x2 += rr.width; + count = 4; + } + + while (count--) { + c = find_clip_box_for_y(clip_start, + clip_end, + box[count].y1); + while (c != clip_end) { + if (box[count].y2 <= c->y1) + break; + + *b = box[count]; + if (box_intersect(b, c)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; + } + } + + } + } + } while (--n); + } else { + do { + xRectangle rr = *r++; + rr.x += drawable->x; + rr.y += drawable->y; + + if (rr.width <= 1 || rr.height <= 1) { + box[0].x1 = rr.x; + box[0].y1 = rr.y; + box[0].x2 = rr.x + rr.width + 1; + box[0].y2 = rr.y + r->height + 1; + count = 1; + } else { + box[0].x1 = rr.x; + box[0].y1 = rr.y; + box[0].x2 = rr.x + rr.width + 1; + box[0].y2 = rr.y + 1; + + box[1] = box[0]; + box[1].y1 += rr.height; + box[1].y2 += rr.height; + + box[2].y1 = rr.y + 1; + box[2].y2 = box[2].y1 + rr.height - 1; + box[2].x1 = rr.x; + box[2].x2 = rr.x + 1; - *b = box[i]; - if (box_intersect(b, c)) { + box[3] = box[2]; + box[3].x1 += rr.width; + box[3].x2 += rr.width; + count = 4; + } + + while (count--) { + *b = box[count]; + if (box_intersect(b, &clip.extents)) { b->x1 += dx; b->x2 += dx; b->y1 += dy; @@ -4009,9 +4061,8 @@ zero_clipped: } } - } - r++; - } while (--n); + } while (--n); + } } goto done; @@ -4019,7 +4070,6 @@ wide_clipped: { RegionRec clip; BoxRec box[4]; - const BoxRec *clip_start, *clip_end, *c; int16_t offset2 = gc->lineWidth; int16_t offset1 = offset2 >> 1; int16_t offset3 = offset2 - offset1; @@ -4027,64 +4077,128 @@ wide_clipped: region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); if (!RegionNotEmpty(&clip)) - return true; + goto done; - clip_start = RegionBoxptr(&clip); - clip_end = clip_start + clip.data->numRects; - do { - xRectangle rr = *r++; - int count; - rr.x += drawable->x; - rr.y += drawable->y; - - if (rr.height < offset2 || rr.width < offset1) { - if (rr.height == 0) { - box[0].x1 = rr.x; - box[0].x2 = rr.x + rr.width + 1; + if (clip.data) { + const BoxRec * const clip_start = RegionBoxptr(&clip); + const BoxRec * const clip_end = clip_start + clip.data->numRects; + const BoxRec *c; + do { + xRectangle rr = *r++; + int count; + rr.x += drawable->x; + rr.y += drawable->y; + + if (rr.height < offset2 || rr.width < offset1) { + if (rr.height == 0) { + box[0].x1 = rr.x; + box[0].x2 = rr.x + rr.width + 1; + } else { + box[0].x1 = rr.x - offset1; + box[0].x2 = box[0].x1 + rr.width + offset2; + } + if (rr.width == 0) { + box[0].y1 = rr.y; + box[0].y2 = rr.y + rr.height + 1; + } else { + box[0].y1 = rr.y - offset1; + box[0].y2 = box[0].y1 + rr.height + offset2; + } + count = 1; } else { box[0].x1 = rr.x - offset1; box[0].x2 = box[0].x1 + rr.width + offset2; + box[0].y1 = rr.y - offset1; + box[0].y2 = box[0].y1 + offset2; + + box[1].x1 = rr.x - offset1; + box[1].x2 = box[1].x1 + offset2; + box[1].y1 = rr.y + offset3; + box[1].y2 = rr.y + rr.height - offset1; + + box[2].x1 = rr.x + rr.width - offset1; + box[2].x2 = box[2].x1 + offset2; + box[2].y1 = rr.y + offset3; + box[2].y2 = rr.y + rr.height - offset1; + + box[3] = box[1]; + box[3].y1 += rr.height; + box[3].y2 += rr.height; + count = 4; } - if (rr.width == 0) { - box[0].y1 = rr.y; - box[0].y2 = rr.y + rr.height + 1; + + while (count--) { + c = find_clip_box_for_y(clip_start, + clip_end, + box[count].y1); + while (c != clip_end) { + if (box[count].y2 <= c->y1) + break; + + *b = box[count]; + if (box_intersect(b, c)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; + } + } + } + } + } while (--n); + } else { + do { + xRectangle rr = *r++; + int count; + rr.x += drawable->x; + rr.y += drawable->y; + + if (rr.height < offset2 || rr.width < offset1) { + if (rr.height == 0) { + box[0].x1 = rr.x; + box[0].x2 = rr.x + rr.width + 1; + } else { + box[0].x1 = rr.x - offset1; + box[0].x2 = box[0].x1 + rr.width + offset2; + } + if (rr.width == 0) { + box[0].y1 = rr.y; + box[0].y2 = rr.y + rr.height + 1; + } else { + box[0].y1 = rr.y - offset1; + box[0].y2 = box[0].y1 + rr.height + offset2; + } + count = 1; } else { + box[0].x1 = rr.x - offset1; + box[0].x2 = box[0].x1 + rr.width + offset2; box[0].y1 = rr.y - offset1; - box[0].y2 = box[0].y1 + rr.height + offset2; + box[0].y2 = box[0].y1 + offset2; + + box[1].x1 = rr.x - offset1; + box[1].x2 = box[1].x1 + offset2; + box[1].y1 = rr.y + offset3; + box[1].y2 = rr.y + rr.height - offset1; + + box[2].x1 = rr.x + rr.width - offset1; + box[2].x2 = box[2].x1 + offset2; + box[2].y1 = rr.y + offset3; + box[2].y2 = rr.y + rr.height - offset1; + + box[3] = box[1]; + box[3].y1 += rr.height; + box[3].y2 += rr.height; + count = 4; } - count = 1; - } else { - box[0].x1 = rr.x - offset1; - box[0].x2 = box[0].x1 + rr.width + offset2; - box[0].y1 = rr.y - offset1; - box[0].y2 = box[0].y1 + offset2; - - box[1].x1 = rr.x - offset1; - box[1].x2 = box[1].x1 + offset2; - box[1].y1 = rr.y + offset3; - box[1].y2 = rr.y + rr.height - offset1; - - box[2].x1 = rr.x + rr.width - offset1; - box[2].x2 = box[2].x1 + offset2; - box[2].y1 = rr.y + offset3; - box[2].y2 = rr.y + rr.height - offset1; - - box[3] = box[1]; - box[3].y1 += rr.height; - box[3].y2 += rr.height; - count = 4; - } - - while (count--) { - c = find_clip_box_for_y(clip_start, - clip_end, - box[count].y1); - while (c != clip_end) { - if (box[count].y2 <= c->y1) - break; + while (count--) { *b = box[count]; - if (box_intersect(b, c)) { + if (box_intersect(b, &clip.extents)) { b->x1 += dx; b->x2 += dx; b->y1 += dy; @@ -4097,8 +4211,8 @@ wide_clipped: } } } - } - } while (--n); + } while (--n); + } } goto done; From ickle at kemper.freedesktop.org Thu Oct 27 08:30:24 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 27 Oct 2011 08:30:24 -0700 (PDT) Subject: xf86-video-intel: 4 commits - src/sna/sna_accel.c Message-ID: <20111027153024.DBB751000F@kemper.freedesktop.org> src/sna/sna_accel.c | 663 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 409 insertions(+), 254 deletions(-) New commits: commit c7bd89fb54686c14b687c007e42c34c23423b0fd Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 16:23:35 2011 +0100 sna: Fix PolyPoint not to always send 512 boxes Just emit the remaining boxes! Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 76e412f..58ef208 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2377,7 +2377,7 @@ sna_poly_point_blt(DrawablePtr drawable, } } while (--n); if (b != box) - fill.boxes(sna, &fill, box, last_box - box); + fill.boxes(sna, &fill, box, b - box); } else { while (n--) { int x, y; @@ -4372,7 +4372,7 @@ wide: if (b+4 > last_box) { fill.boxes(sna, &fill, boxes, last_box-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); b = boxes; } @@ -4711,7 +4711,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, if (++b == last_box) { fill.boxes(sna, &fill, boxes, last_box-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); b = boxes; } } commit cfd5b7f6ce80af911bfc8b71bba776ea814e307a Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 15:28:11 2011 +0100 sna: Use fill->boxes to pack PolyFillRectangle Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 3df889a..76e412f 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4624,12 +4624,13 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, struct sna_damage **damage, GCPtr gc, int n, xRectangle *rect, + const BoxRec *extents, bool clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); - RegionPtr clip = fbGetCompositeClip(gc); struct sna_fill_op fill; + BoxRec boxes[512], *b = boxes, *const last_box = boxes+ARRAY_SIZE(boxes); uint32_t pixel = gc->fillStyle == FillSolid ? gc->fgPixel : gc->tile.pixel; int16_t dx, dy; @@ -4638,8 +4639,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, n, rect->x, rect->y, rect->width, rect->height, clipped)); - if (n == 1 && clip->data == NULL) { - BoxPtr box = &clip->extents; + if (n == 1 && gc->pCompositeClip->data == NULL) { BoxRec r; bool success = true; @@ -4647,7 +4647,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, r.y1 = rect->y + drawable->y; r.x2 = bound(r.x1, rect->width); r.y2 = bound(r.y1, rect->height); - if (box_intersect(&r, box)) { + if (box_intersect(&r, &gc->pCompositeClip->extents)) { get_drawable_deltas(drawable, pixmap, &dx, &dy); r.x1 += dx; r.y1 += dy; r.x2 += dx; r.y2 += dy; @@ -4677,72 +4677,89 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, sna_damage_add_rectangles(damage, rect, n, dx, dy); do { - BoxRec r; - - r.x1 = rect->x + dx; - r.y1 = rect->y + dy; - r.x2 = bound(r.x1, rect->width); - r.y2 = bound(r.y1, rect->height); + b->x1 = rect->x + dx; + b->y1 = rect->y + dy; + b->x2 = b->x1 + rect->width; + b->y2 = b->y1 + rect->height; rect++; - - fill.box(sna, &fill, &r); + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + b = boxes; + } } while (--n); - } else if (clip->data == NULL) { - BoxPtr box = &clip->extents; - while (n--) { - BoxRec r; + } else { + RegionRec clip; - r.x1 = rect->x + drawable->x; - r.y1 = rect->y + drawable->y; - r.x2 = bound(r.x1, rect->width); - r.y2 = bound(r.y1, rect->height); - rect++; + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + goto done; - if (box_intersect(&r, box)) { - r.x1 += dx; - r.x2 += dx; - r.y1 += dy; - r.y2 += dy; - fill.box(sna, &fill, &r); - if (damage) { - assert_pixmap_contains_box(pixmap, &r); - sna_damage_add_box(damage, &r); - } - } - } - } else { - while (n--) { - RegionRec region; - BoxRec *box; - int nbox; - - region.extents.x1 = rect->x + drawable->x; - region.extents.y1 = rect->y + drawable->y; - region.extents.x2 = bound(region.extents.x1, rect->width); - region.extents.y2 = bound(region.extents.y1, rect->height); - rect++; + if (clip.data == NULL) { + do { + b->x1 = rect->x + drawable->x; + b->y1 = rect->y + drawable->y; + b->x2 = bound(b->x1, rect->width); + b->y2 = bound(b->y1, rect->height); + rect++; - region.data = NULL; - RegionIntersect(®ion, ®ion, clip); - - nbox = REGION_NUM_RECTS(®ion); - box = REGION_RECTS(®ion); - while (nbox--) { - box->x1 += dx; - box->x2 += dx; - box->y1 += dy; - box->y2 += dy; - fill.box(sna, &fill, box); - if (damage) { - assert_pixmap_contains_box(pixmap, box); - sna_damage_add_box(damage, box); + if (box_intersect(b, &clip.extents)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; + } } - box++; - } + } while (--n); + } else { + const BoxRec * const clip_start = RegionBoxptr(&clip); + const BoxRec * const clip_end = clip_start + clip.data->numRects; + const BoxRec *c; + + do { + BoxRec box; + + box.x1 = rect->x + drawable->x; + box.y1 = rect->y + drawable->y; + box.x2 = bound(box.x1, rect->width); + box.y2 = bound(box.y1, rect->height); + rect++; - RegionUninit(®ion); + c = find_clip_box_for_y(clip_start, + clip_end, + box.y1); + while (c != clip_end) { + if (box.y2 <= c->y1) + break; + + *b = box; + if (box_intersect(b, c)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + b = boxes; + } + } + + } + } while (--n); } + + RegionUninit(&clip); } + if (b != boxes) + fill.boxes(sna, &fill, boxes, b-boxes); +done: fill.done(sna, &fill); return TRUE; } @@ -5000,11 +5017,8 @@ sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc, box.x2 = bound(box.x1, rect->width); box.y1 = rect->y; box.y2 = bound(box.y1, rect->height); - - while (--n) { - rect++; - box_add_rect(&box, rect); - } + while (--n) + box_add_rect(&box, ++rect); clipped = trim_and_translate_box(&box, drawable, gc); if (box_empty(&box)) @@ -5062,14 +5076,16 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) sna_poly_fill_rect_blt(draw, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, ®ion.extents), - gc, n, rect, flags & 2)) + gc, n, rect, + ®ion.extents, flags & 2)) return; if (sna_drawable_use_cpu_bo(draw, ®ion.extents) && sna_poly_fill_rect_blt(draw, priv->cpu_bo, reduce_damage(draw, &priv->cpu_damage, ®ion.extents), - gc, n, rect, flags & 2)) + gc, n, rect, + ®ion.extents, flags & 2)) return; } else if (gc->fillStyle == FillTiled) { struct sna_pixmap *priv = sna_pixmap_from_drawable(draw); commit 8d304f47e35be344550f389158eac3d4c21d9440 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 14:43:46 2011 +0100 sna: Use fill->boxes for rectilinear blits Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index d776103..3df889a 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2870,15 +2870,14 @@ sna_poly_line_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, GCPtr gc, int mode, int n, DDXPointPtr pt, - bool clipped) + const BoxRec *extents, bool clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); - RegionPtr clip = fbGetCompositeClip(gc); + BoxRec boxes[512], *b = boxes, * const last_box = boxes + ARRAY_SIZE(boxes); struct sna_fill_op fill; DDXPointRec last; int16_t dx, dy; - int first; DBG(("%s: alu=%d, fg=%08lx\n", __FUNCTION__, gc->alu, gc->fgPixel)); @@ -2896,7 +2895,6 @@ sna_poly_line_blt(DrawablePtr drawable, pt++; while (--n) { - BoxRec r; DDXPointRec p; p = *pt++; @@ -2908,104 +2906,169 @@ sna_poly_line_blt(DrawablePtr drawable, p.y += dy; } if (last.x == p.x) { - r.x1 = last.x; - r.x2 = last.x + 1; + b->x1 = last.x; + b->x2 = last.x + 1; } else if (last.x < p.x) { - r.x1 = last.x; - r.x2 = p.x; + b->x1 = last.x; + b->x2 = p.x; } else { - r.x1 = p.x; - r.x2 = last.x; + b->x1 = p.x; + b->x2 = last.x; } if (last.y == p.y) { - r.y1 = last.y; - r.y2 = last.y + 1; + b->y1 = last.y; + b->y2 = last.y + 1; } else if (last.y < p.y) { - r.y1 = last.y; - r.y2 = p.y; + b->y1 = last.y; + b->y2 = p.y; } else { - r.y1 = p.y; - r.y2 = last.y; + b->y1 = p.y; + b->y2 = last.y; } DBG(("%s: blt (%d, %d), (%d, %d)\n", __FUNCTION__, - r.x1, r.y1, r.x2, r.y2)); - fill.box(sna, &fill, &r); - if (damage) { - assert_pixmap_contains_box(pixmap, &r); - sna_damage_add_box(damage, &r); + b->x1, b->y1, b->x2, b->y2)); + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box - boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box - boxes, 0, 0); + b = boxes; } last = p; } } else { - last.x = drawable->x; - last.y = drawable->y; - first = 1; + RegionRec clip; - while (n--) { - int nclip; - BoxPtr box; - DDXPointRec p; + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); - p = *pt++; - if (mode == CoordModePrevious) { - p.x += last.x; - p.y += last.y; - } else { - p.x += drawable->x; - p.y += drawable->y; - } + last.x = pt->x + drawable->x; + last.y = pt->y + drawable->y; + pt++; - if (!first) { - for (nclip = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nclip--; box++) { - BoxRec r; + if (clip.data == NULL) { + while (--n) { + DDXPointRec p; - if (last.x == p.x) { - r.x1 = last.x; - r.x2 = last.x + 1; - } else if (last.x < p.x) { - r.x1 = last.x; - r.x2 = p.x; - } else { - r.x1 = p.x; - r.x2 = last.x; - } - if (last.y == p.y) { - r.y1 = last.y; - r.y2 = last.y + 1; - } else if (last.y < p.y) { - r.y1 = last.y; - r.y2 = p.y; - } else { - r.y1 = p.y; - r.y2 = last.y; + p = *pt++; + if (mode == CoordModePrevious) { + p.x += last.x; + p.y += last.y; + } else { + p.x += drawable->x; + p.y += drawable->y; + } + if (last.x == p.x) { + b->x1 = last.x; + b->x2 = last.x + 1; + } else if (last.x < p.x) { + b->x1 = last.x; + b->x2 = p.x; + } else { + b->x1 = p.x; + b->x2 = last.x; + } + if (last.y == p.y) { + b->y1 = last.y; + b->y2 = last.y + 1; + } else if (last.y < p.y) { + b->y1 = last.y; + b->y2 = p.y; + } else { + b->y1 = p.y; + b->y2 = last.y; + } + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + b->x1, b->y1, b->x2, b->y2)); + if (box_intersect(b, &clip.extents)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box - boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box - boxes, 0, 0); + b = boxes; } - DBG(("%s: (%d, %d) -> (%d, %d) clipping line (%d, %d), (%d, %d) against box (%d, %d), (%d, %d)\n", - __FUNCTION__, - last.x, last.y, p.x, p.y, - r.x1, r.y1, r.x2, r.y2, - box->x1, box->y1, box->x2, box->y2)); - if (box_intersect(&r, box)) { - r.x1 += dx; - r.x2 += dx; - r.y1 += dy; - r.y2 += dy; - DBG(("%s: blt (%d, %d), (%d, %d)\n", - __FUNCTION__, - r.x1, r.y1, r.x2, r.y2)); - fill.box(sna, &fill, &r); - if (damage) { - assert_pixmap_contains_box(pixmap, &r); - sna_damage_add_box(damage, &r); + } + + last = p; + } + } else { + const BoxRec * const clip_start = RegionBoxptr(&clip); + const BoxRec * const clip_end = clip_start + clip.data->numRects; + const BoxRec *c; + + while (--n) { + DDXPointRec p; + BoxRec box; + + p = *pt++; + if (mode == CoordModePrevious) { + p.x += last.x; + p.y += last.y; + } else { + p.x += drawable->x; + p.y += drawable->y; + } + if (last.x == p.x) { + box.x1 = last.x; + box.x2 = last.x + 1; + } else if (last.x < p.x) { + box.x1 = last.x; + box.x2 = p.x; + } else { + box.x1 = p.x; + box.x2 = last.x; + } + if (last.y == p.y) { + box.y1 = last.y; + box.y2 = last.y + 1; + } else if (last.y < p.y) { + box.y1 = last.y; + box.y2 = p.y; + } else { + box.y1 = p.y; + box.y2 = last.y; + } + DBG(("%s: blt (%d, %d), (%d, %d)\n", + __FUNCTION__, + box.x1, box.y1, box.x2, box.y2)); + + c = find_clip_box_for_y(clip_start, + clip_end, + box.y1); + while (c != clip_end) { + if (box.y2 <= c->y1) + break; + + *b = box; + if (box_intersect(b, c)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + b = boxes; } } } - } - last = p; - first = 0; + last = p; + } } + RegionUninit(&clip); + } + if (b != boxes) { + fill.boxes(sna, &fill, boxes, b - boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b - boxes, 0, 0); } fill.done(sna, &fill); return TRUE; @@ -3123,14 +3186,16 @@ sna_poly_line(DrawablePtr drawable, GCPtr gc, sna_poly_line_blt(drawable, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), - gc, mode, n, pt, flags & 4)) + gc, mode, n, pt, + ®ion.extents, flags & 4)) return; if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_line_blt(drawable, priv->cpu_bo, reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), - gc, mode, n, pt, flags & 4)) + gc, mode, n, pt, + ®ion.extents, flags & 4)) return; } else { /* !rectilinear */ if (USE_ZERO_SPANS && @@ -3191,133 +3256,205 @@ sna_poly_segment_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, GCPtr gc, int n, xSegment *seg, - const BoxRec *extents) + const BoxRec *extents, unsigned clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); - RegionRec clip; + BoxRec boxes[512], *b = boxes, * const last_box = boxes + ARRAY_SIZE(boxes); struct sna_fill_op fill; int16_t dx, dy; DBG(("%s: alu=%d, fg=%08lx\n", __FUNCTION__, gc->alu, gc->fgPixel)); - region_set(&clip, extents); - region_maybe_clip(&clip, gc->pCompositeClip); + if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) + return FALSE; - if (n == 1 && clip.data == NULL) { - BoxRec r; - int width, height; - bool success = true; + get_drawable_deltas(drawable, pixmap, &dx, &dy); - DBG(("%s: trying single fill fast-path\n", __FUNCTION__)); + if (!clipped) { + dx += drawable->x; + dy += drawable->y; + do { + int x, y, width, height; - if (seg->x1 < seg->x2) { - r.x1 = seg->x1; - width = seg->x2; - } else { - r.x1 = seg->x2; - width = seg->x1; - } - width -= r.x1 - 1; - r.x1 += drawable->x; + if (seg->x1 < seg->x2) { + x = seg->x1; + width = seg->x2; + } else { + x = seg->x2; + width = seg->x1; + } + width -= x - 1; - if (seg->y1 < seg->y2) { - r.y1 = seg->y1; - height = seg->y2; - } else { - r.y1 = seg->y2; - height = seg->y1; - } - height -= r.y1- 1; - r.y1 += drawable->y; + if (seg->y1 < seg->y2) { + y = seg->y1; + height = seg->y2; + } else { + y = seg->y2; + height = seg->y1; + } + height -= y - 1; + + /* don't paint last pixel */ + if (gc->capStyle == CapNotLast) { + if (width == 1) + height--; + else + width--; + } - /* don't paint last pixel */ - if (gc->capStyle == CapNotLast) { - if (width == 1) - height--; - else - width--; - } - r.x2 = r.x1 + width; - r.y2 = r.y1 + height; + DBG(("%s: [%d] (%d, %d)x(%d, %d) + (%d, %d)\n", __FUNCTION__, n, + x, y, width, height, dx, dy)); - if (box_intersect(&r, &clip.extents)) { - get_drawable_deltas(drawable, pixmap, &dx, &dy); - r.x1 += dx; r.y1 += dy; - r.x2 += dx; r.y2 += dy; - if (sna->render.fill_one(sna, pixmap, bo, gc->fgPixel, - r.x1, r.y1, r.x2, r.y2, - gc->alu)) { - if (damage) { - assert_pixmap_contains_box(pixmap, &r); - sna_damage_add_box(damage, &r); + b->x1 = x + dx; + b->x2 = b->x1 + width; + b->y1 = y + dy; + b->y2 = b->y1 + height; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + b = boxes; + } + + seg++; + } while (--n); + } else { + RegionRec clip; + + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); + + if (!RegionNotEmpty(&clip)) + goto done; + + if (clip.data) { + const BoxRec * const clip_start = RegionBoxptr(&clip); + const BoxRec * const clip_end = clip_start + clip.data->numRects; + const BoxRec *c; + do { + int x, y, width, height; + BoxRec box; + + if (seg->x1 < seg->x2) { + x = seg->x1; + width = seg->x2; + } else { + x = seg->x2; + width = seg->x1; } - } else - success = false; - } + width -= x - 1; - return success; - } + if (seg->y1 < seg->y2) { + y = seg->y1; + height = seg->y2; + } else { + y = seg->y2; + height = seg->y1; + } + height -= y - 1; + + /* don't paint last pixel */ + if (gc->capStyle == CapNotLast) { + if (width == 1) + height--; + else + width--; + } - if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) { - RegionUninit(&clip); - return FALSE; - } + DBG(("%s: [%d] (%d, %d)x(%d, %d) + (%d, %d)\n", __FUNCTION__, n, + x, y, width, height, dx+drawable->x, dy+drawable->y)); + box.x1 = x + drawable->x; + box.x2 = box.x1 + width; + box.y1 = y + drawable->y; + box.y2 = box.y1 + height; + c = find_clip_box_for_y(clip_start, + clip_end, + box.y1); + while (c != clip_end) { + if (box.y2 <= c->y1) + break; - get_drawable_deltas(drawable, pixmap, &dx, &dy); - while (n--) { - int x, y, width, height, nclip; - BoxPtr box; + *b = box; + if (box_intersect(b, c)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + b = boxes; + } + } + } - if (seg->x1 < seg->x2) { - x = seg->x1; - width = seg->x2; + seg++; + } while (--n); } else { - x = seg->x2; - width = seg->x1; - } - width -= x - 1; - x += drawable->x; + do { + int x, y, width, height; - if (seg->y1 < seg->y2) { - y = seg->y1; - height = seg->y2; - } else { - y = seg->y2; - height = seg->y1; - } - height -= y - 1; - y += drawable->y; + if (seg->x1 < seg->x2) { + x = seg->x1; + width = seg->x2; + } else { + x = seg->x2; + width = seg->x1; + } + width -= x - 1; - /* don't paint last pixel */ - if (gc->capStyle == CapNotLast) { - if (width == 1) - height--; - else - width--; - } + if (seg->y1 < seg->y2) { + y = seg->y1; + height = seg->y2; + } else { + y = seg->y2; + height = seg->y1; + } + height -= y - 1; + + /* don't paint last pixel */ + if (gc->capStyle == CapNotLast) { + if (width == 1) + height--; + else + width--; + } - DBG(("%s: [%d] (%d, %d)x(%d, %d) + (%d, %d)\n", __FUNCTION__, n, - x, y, width, height, dx, dy)); - for (nclip = REGION_NUM_RECTS(&clip), box = REGION_RECTS(&clip); nclip--; box++) { - BoxRec r = { x, y, x + width, y + height }; - if (box_intersect(&r, box)) { - r.x1 += dx; - r.x2 += dx; - r.y1 += dy; - r.y2 += dy; - fill.box(sna, &fill, &r); - if (damage) { - assert_pixmap_contains_box(pixmap, &r); - sna_damage_add_box(damage, &r); + DBG(("%s: [%d] (%d, %d)x(%d, %d) + (%d, %d)\n", __FUNCTION__, n, + x, y, width, height, dx+drawable->x, dy+drawable->y)); + + b->x1 = x + drawable->x; + b->x2 = b->x1 + width; + b->y1 = y + drawable->y; + b->y2 = b->y1 + height; + + if (box_intersect(b, &clip.extents)) { + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + if (++b == last_box) { + fill.boxes(sna, &fill, boxes, last_box-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + b = boxes; + } } - } - } - seg++; + seg++; + } while (--n); + } + RegionUninit(&clip); + } + if (b != boxes) { + fill.boxes(sna, &fill, boxes, b - boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b - boxes, 0, 0); } +done: fill.done(sna, &fill); - RegionUninit(&clip); return TRUE; } @@ -3744,14 +3881,16 @@ sna_poly_segment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg) sna_poly_segment_blt(drawable, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), - gc, n, seg, ®ion.extents)) + gc, n, seg, + ®ion.extents, flags & 2)) return; if (sna_drawable_use_cpu_bo(drawable, ®ion.extents) && sna_poly_segment_blt(drawable, priv->cpu_bo, reduce_damage(drawable, &priv->cpu_damage, ®ion.extents), - gc, n, seg, ®ion.extents)) + gc, n, seg, + ®ion.extents, flags & 2)) return; } else { if (USE_ZERO_SPANS && commit 5d51ff0cf901b808c3cd5aea761d51e6d15b73bf Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 13:57:59 2011 +0100 sna: Clip PolyLines to the current clip box Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 7b8f761..d776103 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2638,7 +2638,7 @@ sna_poly_zero_line_blt(DrawablePtr drawable, b->x2++; b->y2++; if (oc1 | oc2) - box_intersect(b, &clip.extents); + box_intersect(b, extents); if (++b == last_box) { ret = &&rectangle_continue; goto *jump; @@ -3431,7 +3431,7 @@ sna_poly_zero_segment_blt(DrawablePtr drawable, b->x2++; b->y2++; if (oc1 | oc2) - box_intersect(b, &clip.extents); + box_intersect(b, extents); if (++b == last_box) { ret = &&rectangle_continue; goto *jump; From ickle at kemper.freedesktop.org Thu Oct 27 09:09:07 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 27 Oct 2011 09:09:07 -0700 (PDT) Subject: xf86-video-intel: 2 commits - src/sna/sna_accel.c Message-ID: <20111027160907.AAAAA1000F@kemper.freedesktop.org> src/sna/sna_accel.c | 88 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 13 deletions(-) New commits: commit 5d52d5009375618bb703909fa0fad04e6d54a2ba Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 17:06:51 2011 +0100 sna: Tweak zero line spans to include missing last segment Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 950eba1..c0f9572 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2692,7 +2692,7 @@ rectangle_continue: b->x1 = x; b->y2 = b->y1 = y; - while (length--) { + while (--length) { e += e1; if (e >= 0) { b->x2 = x; @@ -2712,10 +2712,25 @@ X_continue: y += sdy; e += e3; b->y2 = b->y1 = y; - b->x1 = x; + b->x1 = x + dx; } x += sdx; } + + b->x2 = x; + if (b->x2 < b->x1) { + int16_t t = b->x1; + b->x1 = b->x2; + b->x2 = t; + } + b->x2++; + b->y2++; + if (++b == last_box) { + ret = &&X_continue2; + goto *jump; +X_continue2: + b = box; + } } else { /* Y-major segment */ e1 = adx << 1; @@ -2766,7 +2781,7 @@ X_continue: b->x2 = b->x1 = x; b->y1 = y; - while (length--) { + while (--length) { e += e1; if (e >= 0) { b->y2 = y; @@ -2786,10 +2801,25 @@ Y_continue: x += sdx; e += e3; b->x2 = b->x1 = x; - b->y1 = y; + b->y1 = y + sdy; } y += sdy; } + + b->y2 = y; + if (b->y2 < b->y1) { + int16_t t = b->y1; + b->y1 = b->y2; + b->y2 = t; + } + b->x2++; + b->y2++; + if (++b == last_box) { + ret = &&Y_continue2; + goto *jump; +Y_continue2: + b = box; + } } } @@ -3620,7 +3650,7 @@ rectangle_continue: b->x1 = x1; b->y2 = b->y1 = y1; - while (length--) { + while (--length) { e += e1; if (e >= 0) { b->x2 = x1; @@ -3640,10 +3670,26 @@ X_continue: y1 += sdy; e += e3; b->y2 = b->y1 = y1; - b->x1 = x1; + b->x1 = x1 + sdx; } x1 += sdx; } + + b->x2 = x1; + if (b->x2 < b->x1) { + int16_t t = b->x1; + b->x1 = b->x2; + b->x2 = t; + } + if (gc->capStyle != CapNotLast) + b->x2++; + b->y2++; + if (++b == last_box) { + ret = &&X_continue2; + goto *jump; +X_continue2: + b = box; + } } else { /* Y-major segment */ e1 = adx << 1; @@ -3690,7 +3736,7 @@ X_continue: b->x2 = b->x1 = x1; b->y1 = y1; - while (length--) { + while (--length) { e += e1; if (e >= 0) { b->y2 = y1; @@ -3710,10 +3756,26 @@ Y_continue: x1 += sdx; e += e3; b->x2 = b->x1 = x1; - b->y1 = y1; + b->y1 = y1 + sdy; } y1 += sdy; } + + b->y2 = y1; + if (b->y2 < b->y1) { + int16_t t = b->y1; + b->y1 = b->y2; + b->y2 = t; + } + b->x2++; + if (gc->capStyle != CapNotLast) + b->y2++; + if (++b == last_box) { + ret = &&Y_continue2; + goto *jump; +Y_continue2: + b = box; + } } } while (--n); } while (++extents != last_extents); commit 72e00096351137bd7eb0ae91474657a597836252 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 16:36:39 2011 +0100 sna: Fix advance through clip boxes for fill->boxes Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 58ef208..950eba1 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3046,7 +3046,7 @@ sna_poly_line_blt(DrawablePtr drawable, break; *b = box; - if (box_intersect(b, c)) { + if (box_intersect(b, c++)) { b->x1 += dx; b->x2 += dx; b->y1 += dy; @@ -3376,7 +3376,7 @@ sna_poly_segment_blt(DrawablePtr drawable, break; *b = box; - if (box_intersect(b, c)) { + if (box_intersect(b, c++)) { b->x1 += dx; b->x2 += dx; b->y1 += dy; @@ -4135,7 +4135,7 @@ zero_clipped: break; *b = box[count]; - if (box_intersect(b, c)) { + if (box_intersect(b, c++)) { b->x1 += dx; b->x2 += dx; b->y1 += dy; @@ -4275,7 +4275,7 @@ wide_clipped: break; *b = box[count]; - if (box_intersect(b, c)) { + if (box_intersect(b, c++)) { b->x1 += dx; b->x2 += dx; b->y1 += dy; @@ -4738,7 +4738,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, break; *b = box; - if (box_intersect(b, c)) { + if (box_intersect(b, c++)) { b->x1 += dx; b->x2 += dx; b->y1 += dy; From ickle at kemper.freedesktop.org Thu Oct 27 10:09:41 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 27 Oct 2011 10:09:41 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111027170941.E7D0A1000F@kemper.freedesktop.org> src/sna/sna_accel.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) New commits: commit 14a065a267523f9a31be07daaab19b67e9f02290 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 18:07:53 2011 +0100 sna: Create scratch pixmap on the CPU Contrary to earlier belief, the only usage of CREATE_PIXMAP_USAGE_SCRATCH in the dix/mi are either along paths unused by us or more importantly for operations which are detrimental to create GPU-only buffers. So create CPU pixmaps instead. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index c0f9572..f3a9251 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -265,11 +265,8 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, DBG(("%s(%d, %d, %d, usage=%x)\n", __FUNCTION__, width, height, depth, usage)); - if (usage == CREATE_PIXMAP_USAGE_SCRATCH && - to_sna_from_screen(screen)->have_render) - return sna_pixmap_create_scratch(screen, - width, height, depth, - I915_TILING_Y); + if (usage == CREATE_PIXMAP_USAGE_SCRATCH) + return fbCreatePixmap(screen, width, height, depth, usage); if (FORCE_GPU_ONLY && width && height) return sna_pixmap_create_scratch(screen, From daenzer at kemper.freedesktop.org Thu Oct 27 10:42:33 2011 From: daenzer at kemper.freedesktop.org (Michel Dänzer) Date: Thu, 27 Oct 2011 10:42:33 -0700 (PDT) Subject: xf86-video-ati: Branch 'master' Message-ID: <20111027174233.B70CB1000F@kemper.freedesktop.org> src/radeon_exa_funcs.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) New commits: commit 23788c4a5e3b6affb9b183e1393edd0e5ca4550e Author: Michel D??nzer <michel.daenzer at amd.com> Date: Thu Oct 27 19:12:22 2011 +0200 EXA < R6xx: Make sure 2D state is re-emitted after running out of CS space. Otherwise it's basically luck what the 2D state ends up being at the beginning of the next CS. Signed-off-by: Michel D??nzer <michel.daenzer at amd.com> diff --git a/src/radeon_exa_funcs.c b/src/radeon_exa_funcs.c index 52adcea..058a547 100644 --- a/src/radeon_exa_funcs.c +++ b/src/radeon_exa_funcs.c @@ -132,14 +132,13 @@ static void FUNC_NAME(Emit2DState)(ScrnInfoPtr pScrn, int op) } static void -FUNC_NAME(RADEONDone2D)(PixmapPtr pPix) +FUNC_NAME(RADEONFlush2D)(PixmapPtr pPix) { RINFO_FROM_SCREEN(pPix->drawable.pScreen); ACCEL_PREAMBLE(); TRACE; - info->state_2d.op = 0; BEGIN_ACCEL(2); OUT_ACCEL_REG(RADEON_DSTCACHE_CTLSTAT, RADEON_RB2D_DC_FLUSH_ALL); OUT_ACCEL_REG(RADEON_WAIT_UNTIL, @@ -147,6 +146,15 @@ FUNC_NAME(RADEONDone2D)(PixmapPtr pPix) FINISH_ACCEL(); } +static void +FUNC_NAME(RADEONDone2D)(PixmapPtr pPix) +{ + RINFO_FROM_SCREEN(pPix->drawable.pScreen); + info->state_2d.op = 0; + + FUNC_NAME(RADEONFlush2D)(pPix); +} + static Bool FUNC_NAME(RADEONPrepareSolid)(PixmapPtr pPix, int alu, Pixel pm, Pixel fg) { @@ -220,7 +228,7 @@ FUNC_NAME(RADEONSolid)(PixmapPtr pPix, int x1, int y1, int x2, int y2) #if defined(ACCEL_CP) && defined(XF86DRM_MODE) if (info->cs && CS_FULL(info->cs)) { - FUNC_NAME(RADEONDone2D)(info->accel_state->dst_pix); + FUNC_NAME(RADEONFlush2D)(info->accel_state->dst_pix); radeon_cs_flush_indirect(pScrn); } #endif @@ -332,7 +340,7 @@ FUNC_NAME(RADEONCopy)(PixmapPtr pDst, #if defined(ACCEL_CP) && defined(XF86DRM_MODE) if (info->cs && CS_FULL(info->cs)) { - FUNC_NAME(RADEONDone2D)(info->accel_state->dst_pix); + FUNC_NAME(RADEONFlush2D)(info->accel_state->dst_pix); radeon_cs_flush_indirect(pScrn); } #endif From ickle at kemper.freedesktop.org Thu Oct 27 12:15:36 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 27 Oct 2011 12:15:36 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c src/sna/sna_dri.c src/sna/sna_glyphs.c src/sna/sna.h src/sna/sna_render.c Message-ID: <20111027191536.86C0E1000F@kemper.freedesktop.org> src/sna/sna.h | 1 + src/sna/sna_accel.c | 5 +++++ src/sna/sna_dri.c | 2 +- src/sna/sna_glyphs.c | 4 ++-- src/sna/sna_render.c | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) New commits: commit d6f543011bf3d03b9298b5ceeddfc1fc20fc534b Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 20:16:35 2011 +0100 sna: Use private identifier for internal scratch pixmaps This was meant to be a part of the previous commit. These are the scratch pixmaps for which we truly do want to allocate GPU-only. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna.h b/src/sna/sna.h index ec4429d..1bb81d0 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -624,5 +624,6 @@ memcpy_blt(const void *src, void *dst, int bpp, uint16_t width, uint16_t height); #define SNA_CREATE_FB 0x10 +#define SNA_CREATE_SCRATCH 0x11 #endif /* _SNA_H */ diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index f3a9251..70bbad6 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -268,6 +268,11 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, if (usage == CREATE_PIXMAP_USAGE_SCRATCH) return fbCreatePixmap(screen, width, height, depth, usage); + if (usage == SNA_CREATE_SCRATCH) + return sna_pixmap_create_scratch(screen, + width, height, depth, + I915_TILING_Y); + if (FORCE_GPU_ONLY && width && height) return sna_pixmap_create_scratch(screen, width, height, depth, diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c index 65fec47..2fcc060 100644 --- a/src/sna/sna_dri.c +++ b/src/sna/sna_dri.c @@ -198,7 +198,7 @@ sna_dri_create_buffer(DrawablePtr drawable, pixmap = NULL; bo = NULL; - usage = CREATE_PIXMAP_USAGE_SCRATCH; + usage = SNA_CREATE_SCRATCH; switch (attachment) { case DRI2BufferFrontLeft: pixmap = get_drawable_pixmap(drawable); diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index 928c9fb..7b98b0c 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -177,7 +177,7 @@ static Bool realize_glyph_caches(struct sna *sna) CACHE_PICTURE_SIZE, CACHE_PICTURE_SIZE, depth, - CREATE_PIXMAP_USAGE_SCRATCH); + SNA_CREATE_SCRATCH); if (!pixmap) goto bail; @@ -726,7 +726,7 @@ glyphs_via_mask(struct sna *sna, pixmap = screen->CreatePixmap(screen, width, height, format->depth, - CREATE_PIXMAP_USAGE_SCRATCH); + SNA_CREATE_SCRATCH); if (!pixmap) return FALSE; diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index 7ab0de1..4017f91 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -559,7 +559,7 @@ static int sna_render_picture_downsample(struct sna *sna, tmp = screen->CreatePixmap(screen, w/2, h/2, pixmap->drawable.depth, - CREATE_PIXMAP_USAGE_SCRATCH); + SNA_CREATE_SCRATCH); if (!tmp) goto fixup; From ickle at kemper.freedesktop.org Thu Oct 27 16:29:42 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Thu, 27 Oct 2011 16:29:42 -0700 (PDT) Subject: xf86-video-intel: 2 commits - src/sna/gen2_render.c src/sna/sna_accel.c Message-ID: <20111027232942.770AF1000F@kemper.freedesktop.org> src/sna/gen2_render.c | 12 +++ src/sna/sna_accel.c | 164 ++++++++++++++++++++++---------------------------- 2 files changed, 87 insertions(+), 89 deletions(-) New commits: commit 48eff1676c4066c8b8e069fd579a1b6fc2329960 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 23:30:06 2011 +0100 sna/gen2: Reset BLT registers across 2D/3D context switches It appears the hardware trashes the BLT registers after a 3D context switch, so we need to reload. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index aa315e6..9e85176 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -2546,10 +2546,22 @@ gen2_render_flush(struct sna *sna) gen2_vertex_flush(sna); } +static void +gen2_render_context_switch(struct kgem *kgem, + int new_mode) +{ + struct sna *sna = container_of(kgem, struct sna, kgem); + + /* Reload BLT registers following a lost context */ + sna->blt_state.fill_bo = 0; +} + Bool gen2_render_init(struct sna *sna) { struct sna_render *render = &sna->render; + sna->kgem.context_switch = gen2_render_context_switch; + /* Use the BLT (and overlay) for everything except when forced to * use the texture combiners. */ commit f006fac72a733e047b9468704e9c9206f62f96f5 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Thu Oct 27 21:50:25 2011 +0100 sna: Fast path typically unclipped tiled rects Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 70bbad6..31f4013 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4686,8 +4686,8 @@ static Bool sna_poly_fill_rect_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, - GCPtr gc, int n, - xRectangle *rect, + GCPtr gc, uint32_t pixel, + int n, xRectangle *rect, const BoxRec *extents, bool clipped) { @@ -4695,7 +4695,6 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, PixmapPtr pixmap = get_drawable_pixmap(drawable); struct sna_fill_op fill; BoxRec boxes[512], *b = boxes, *const last_box = boxes+ARRAY_SIZE(boxes); - uint32_t pixel = gc->fillStyle == FillSolid ? gc->fgPixel : gc->tile.pixel; int16_t dx, dy; DBG(("%s x %d [(%d, %d)+(%d, %d)...], clipped?=%d\n", @@ -4844,14 +4843,14 @@ static Bool sna_poly_fill_rect_tiled(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, - GCPtr gc, int n, - xRectangle *rect) + GCPtr gc, int n, xRectangle *rect, + const BoxRec *extents, unsigned clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); PixmapPtr tile = gc->tile.pixmap; - RegionPtr clip = fbGetCompositeClip(gc); - DDXPointPtr origin = &gc->patOrg; + const DDXPointRec * const origin = &gc->patOrg; + struct sna_copy_op copy; CARD32 alu = gc->alu; int tile_width, tile_height; int16_t dx, dy; @@ -4861,90 +4860,71 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, tile_width = tile->drawable.width; tile_height = tile->drawable.height; + if (tile_width == 1 && tile_height == 1) + return sna_poly_fill_rect_blt(drawable, bo, damage, + gc, get_pixel(tile), + n, rect, + extents, clipped); - get_drawable_deltas(drawable, pixmap, &dx, &dy); - - if (tile_width == 1 && tile_height == 1) { - struct sna_fill_op fill; - - if (!sna_fill_init_blt(&fill, sna, pixmap, bo, alu, get_pixel(tile))) { - DBG(("%s: unsupported blt\n", __FUNCTION__)); - return FALSE; - } - - if (clip->data == NULL) { - BoxPtr box = &clip->extents; - while (n--) { - BoxRec r; - - r.x1 = rect->x + drawable->x; - r.y1 = rect->y + drawable->y; - r.x2 = bound(r.x1, rect->width); - r.y2 = bound(r.y1, rect->height); - rect++; - - if (box_intersect(&r, box)) { - r.x1 += dx; - r.x2 += dx; - r.y1 += dy; - r.y2 += dy; - fill.box(sna, &fill, &r); - if (damage) { - assert_pixmap_contains_box(pixmap, &r); - sna_damage_add_box(damage, &r); - } - } - } - } else { - while (n--) { - RegionRec region; - BoxRec *box; - int nbox; + if (!sna_pixmap_move_to_gpu(tile)) + return FALSE; - region.extents.x1 = rect->x + drawable->x; - region.extents.y1 = rect->y + drawable->y; - region.extents.x2 = bound(region.extents.x1, rect->width); - region.extents.y2 = bound(region.extents.y1, rect->height); - rect++; + if (!sna_copy_init_blt(©, sna, + tile, sna_pixmap_get_bo(tile), + pixmap, bo, + alu)) { + DBG(("%s: unsupported blt\n", __FUNCTION__)); + return FALSE; + } - region.data = NULL; - RegionIntersect(®ion, ®ion, clip); + get_drawable_deltas(drawable, pixmap, &dx, &dy); + if (!clipped) { + dx += drawable->x; + dy += drawable->y; - nbox = REGION_NUM_RECTS(®ion); - box = REGION_RECTS(®ion); - while (nbox--) { - box->x1 += dx; - box->x2 += dx; - box->y1 += dy; - box->y2 += dy; - fill.box(sna, &fill, box); - if (damage) { - assert_pixmap_contains_box(pixmap, box); - sna_damage_add_box(damage, box); - } - box++; - } + sna_damage_add_rectangles(damage, rect, n, dx, dy); + do { + xRectangle r = *rect++; + int16_t tile_y = (r.y - origin->y) % tile_height; - RegionUninit(®ion); - } - } - fill.done(sna, &fill); + r.y += dy; + do { + int16_t width = r.width; + int16_t x = r.x + dx; + int16_t tile_x = (r.x - origin->x) % tile_width; + int16_t h = tile_height - tile_y; + if (h > r.height) + h = r.height; + r.height -= h; + + do { + int16_t w = tile_width - tile_x; + if (w > width) + w = width; + width -= w; + + copy.blt(sna, ©, + tile_x, tile_y, + w, h, + x, r.y); + + x += w; + tile_x = 0; + } while (width); + r.y += h; + tile_y = 0; + } while (r.height); + } while (--n); } else { - struct sna_copy_op copy; - - if (!sna_pixmap_move_to_gpu(tile)) - return FALSE; + RegionRec clip; - if (!sna_copy_init_blt(©, sna, - tile, sna_pixmap_get_bo(tile), - pixmap, bo, - alu)) { - DBG(("%s: unsupported blt\n", __FUNCTION__)); - return FALSE; - } + region_set(&clip, extents); + region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + goto done; - if (clip->data == NULL) { - const BoxRec *box = &clip->extents; + if (clip.data == NULL) { + const BoxRec *box = &clip.extents; while (n--) { BoxRec r; @@ -5008,7 +4988,7 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, rect++; region.data = NULL; - RegionIntersect(®ion, ®ion, clip); + RegionIntersect(®ion, ®ion, &clip); nbox = REGION_NUM_RECTS(®ion); box = REGION_RECTS(®ion); @@ -5059,8 +5039,11 @@ sna_poly_fill_rect_tiled(DrawablePtr drawable, RegionUninit(®ion); } } - copy.done(sna, ©); + + RegionUninit(&clip); } +done: + copy.done(sna, ©); return TRUE; } @@ -5131,6 +5114,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) if (gc->fillStyle == FillSolid || (gc->fillStyle == FillTiled && gc->tileIsPixel)) { struct sna_pixmap *priv = sna_pixmap_from_drawable(draw); + uint32_t color = gc->fillStyle == FillSolid ? gc->fgPixel : gc->tile.pixel; DBG(("%s: solid fill [%08lx], testing for blt\n", __FUNCTION__, @@ -5140,7 +5124,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) sna_poly_fill_rect_blt(draw, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, ®ion.extents), - gc, n, rect, + gc, color, n, rect, ®ion.extents, flags & 2)) return; @@ -5148,7 +5132,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) sna_poly_fill_rect_blt(draw, priv->cpu_bo, reduce_damage(draw, &priv->cpu_damage, ®ion.extents), - gc, n, rect, + gc, color, n, rect, ®ion.extents, flags & 2)) return; } else if (gc->fillStyle == FillTiled) { @@ -5160,14 +5144,16 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) sna_poly_fill_rect_tiled(draw, priv->gpu_bo, priv->gpu_only ? NULL : reduce_damage(draw, &priv->gpu_damage, ®ion.extents), - gc, n, rect)) + gc, n, rect, + ®ion.extents, flags & 2)) return; if (sna_drawable_use_cpu_bo(draw, ®ion.extents) && sna_poly_fill_rect_tiled(draw, priv->cpu_bo, reduce_damage(draw, &priv->cpu_damage, ®ion.extents), - gc, n, rect)) + gc, n, rect, + ®ion.extents, flags & 2)) return; } From daenzer at kemper.freedesktop.org Fri Oct 28 01:43:20 2011 From: daenzer at kemper.freedesktop.org (Michel Dänzer) Date: Fri, 28 Oct 2011 01:43:20 -0700 (PDT) Subject: xf86-video-ati: Branch 'master' Message-ID: <20111028084321.028291000F@kemper.freedesktop.org> src/evergreen_exa.c | 147 ++++++++++++++++++++++++++++++---------------- src/r600_exa.c | 164 ++++++++++++++++++++++++++++++++++------------------ src/radeon.h | 3 3 files changed, 206 insertions(+), 108 deletions(-) New commits: commit a3bb07efb1757c33d70e2e1928219d12a4dd6498 Author: Michel D??nzer <michel.daenzer at amd.com> Date: Tue Oct 25 17:43:58 2011 +0200 EXA >= R6xx / KMS: Avoid running out of CS space at inconvenient times. Otherwise we may end up with things not properly set up at the beginning of the next CS. Fixes http://bugs.debian.org/645007 . In contrast to the Composite code for < R6xx, this isn't necessary with UMS, as the draw packet only uses constant space in the indirect buffer, and nothing else can mess with the 3D state between indirect buffers. Signed-off-by: Michel D??nzer <michel.daenzer at amd.com> Reviewed-by: Alex Deucher <alexander.deucher at amd.com> diff --git a/src/evergreen_exa.c b/src/evergreen_exa.c index 306e90f..6becbb3 100644 --- a/src/evergreen_exa.c +++ b/src/evergreen_exa.c @@ -55,9 +55,6 @@ extern int cayman_xv_ps(RADEONChipFamily ChipSet, uint32_t* shader); extern int cayman_comp_vs(RADEONChipFamily ChipSet, uint32_t* vs); extern int cayman_comp_ps(RADEONChipFamily ChipSet, uint32_t* ps); -static void -EVERGREENDoneSolid(PixmapPtr pPix); - static Bool EVERGREENPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg) { @@ -205,9 +202,27 @@ EVERGREENPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg) if (accel_state->vsync) RADEONVlineHelperClear(pScrn); + accel_state->dst_pix = pPix; + accel_state->fg = fg; + return TRUE; } +static void +EVERGREENDoneSolid(PixmapPtr pPix) +{ + ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + struct radeon_accel_state *accel_state = info->accel_state; + + if (accel_state->vsync) + evergreen_cp_wait_vline_sync(pScrn, pPix, + accel_state->vline_crtc, + accel_state->vline_y1, + accel_state->vline_y2); + + evergreen_finish_op(pScrn, 8); +} static void EVERGREENSolid(PixmapPtr pPix, int x1, int y1, int x2, int y2) @@ -217,6 +232,15 @@ EVERGREENSolid(PixmapPtr pPix, int x1, int y1, int x2, int y2) struct radeon_accel_state *accel_state = info->accel_state; float *vb; + if (CS_FULL(info->cs)) { + EVERGREENDoneSolid(info->accel_state->dst_pix); + radeon_cs_flush_indirect(pScrn); + EVERGREENPrepareSolid(accel_state->dst_pix, + accel_state->rop, + accel_state->planemask, + accel_state->fg); + } + if (accel_state->vsync) RADEONVlineHelperSet(pScrn, x1, y1, x2, y2); @@ -235,22 +259,6 @@ EVERGREENSolid(PixmapPtr pPix, int x1, int y1, int x2, int y2) } static void -EVERGREENDoneSolid(PixmapPtr pPix) -{ - ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum]; - RADEONInfoPtr info = RADEONPTR(pScrn); - struct radeon_accel_state *accel_state = info->accel_state; - - if (accel_state->vsync) - evergreen_cp_wait_vline_sync(pScrn, pPix, - accel_state->vline_crtc, - accel_state->vline_y1, - accel_state->vline_y2); - - evergreen_finish_op(pScrn, 8); -} - -static void EVERGREENDoPrepareCopy(ScrnInfoPtr pScrn) { RADEONInfoPtr info = RADEONPTR(pScrn); @@ -510,10 +518,30 @@ EVERGREENPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, if (accel_state->vsync) RADEONVlineHelperClear(pScrn); + accel_state->dst_pix = pDst; + accel_state->src_pix = pSrc; + accel_state->xdir = xdir; + accel_state->ydir = ydir; + return TRUE; } static void +EVERGREENDoneCopy(PixmapPtr pDst) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + struct radeon_accel_state *accel_state = info->accel_state; + + if (!accel_state->same_surface) + EVERGREENDoCopyVline(pDst); + + if (accel_state->copy_area) + accel_state->copy_area = NULL; + +} + +static void EVERGREENCopy(PixmapPtr pDst, int srcX, int srcY, int dstX, int dstY, @@ -526,6 +554,17 @@ EVERGREENCopy(PixmapPtr pDst, if (accel_state->same_surface && (srcX == dstX) && (srcY == dstY)) return; + if (CS_FULL(info->cs)) { + EVERGREENDoneCopy(info->accel_state->dst_pix); + radeon_cs_flush_indirect(pScrn); + EVERGREENPrepareCopy(accel_state->src_pix, + accel_state->dst_pix, + accel_state->xdir, + accel_state->ydir, + accel_state->rop, + accel_state->planemask); + } + if (accel_state->vsync) RADEONVlineHelperSet(pScrn, dstX, dstY, dstX + w, dstY + h); @@ -568,21 +607,6 @@ EVERGREENCopy(PixmapPtr pDst, } -static void -EVERGREENDoneCopy(PixmapPtr pDst) -{ - ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; - RADEONInfoPtr info = RADEONPTR(pScrn); - struct radeon_accel_state *accel_state = info->accel_state; - - if (!accel_state->same_surface) - EVERGREENDoCopyVline(pDst); - - if (accel_state->copy_area) - accel_state->copy_area = NULL; - -} - struct blendinfo { Bool dst_alpha; Bool src_alpha; @@ -1306,9 +1330,34 @@ static Bool EVERGREENPrepareComposite(int op, PicturePtr pSrcPicture, if (accel_state->vsync) RADEONVlineHelperClear(pScrn); + accel_state->composite_op = op; + accel_state->dst_pic = pDstPicture; + accel_state->src_pic = pSrcPicture; + accel_state->dst_pix = pDst; + accel_state->msk_pix = pMask; + accel_state->src_pix = pSrc; + return TRUE; } +static void EVERGREENDoneComposite(PixmapPtr pDst) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + struct radeon_accel_state *accel_state = info->accel_state; + int vtx_size; + + if (accel_state->vsync) + evergreen_cp_wait_vline_sync(pScrn, pDst, + accel_state->vline_crtc, + accel_state->vline_y1, + accel_state->vline_y2); + + vtx_size = accel_state->msk_pic ? 24 : 16; + + evergreen_finish_op(pScrn, vtx_size); +} + static void EVERGREENComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, @@ -1320,6 +1369,18 @@ static void EVERGREENComposite(PixmapPtr pDst, struct radeon_accel_state *accel_state = info->accel_state; float *vb; + if (CS_FULL(info->cs)) { + EVERGREENDoneComposite(info->accel_state->dst_pix); + radeon_cs_flush_indirect(pScrn); + EVERGREENPrepareComposite(info->accel_state->composite_op, + info->accel_state->src_pic, + info->accel_state->msk_pic, + info->accel_state->dst_pic, + info->accel_state->src_pix, + info->accel_state->msk_pix, + info->accel_state->dst_pix); + } + if (accel_state->vsync) RADEONVlineHelperSet(pScrn, dstX, dstY, dstX + w, dstY + h); @@ -1375,24 +1436,6 @@ static void EVERGREENComposite(PixmapPtr pDst, } -static void EVERGREENDoneComposite(PixmapPtr pDst) -{ - ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; - RADEONInfoPtr info = RADEONPTR(pScrn); - struct radeon_accel_state *accel_state = info->accel_state; - int vtx_size; - - if (accel_state->vsync) - evergreen_cp_wait_vline_sync(pScrn, pDst, - accel_state->vline_crtc, - accel_state->vline_y1, - accel_state->vline_y2); - - vtx_size = accel_state->msk_pic ? 24 : 16; - - evergreen_finish_op(pScrn, vtx_size); -} - static Bool EVERGREENUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, int src_pitch) diff --git a/src/r600_exa.c b/src/r600_exa.c index 2673599..71e1393 100644 --- a/src/r600_exa.c +++ b/src/r600_exa.c @@ -132,6 +132,11 @@ R600SetAccelState(ScrnInfoPtr pScrn, accel_state->dst_size = 0; } +#ifdef XF86DRM_MODE + if (info->cs && CS_FULL(info->cs)) + radeon_cs_flush_indirect(pScrn); +#endif + accel_state->rop = rop; accel_state->planemask = planemask; @@ -170,9 +175,6 @@ R600SetAccelState(ScrnInfoPtr pScrn, return TRUE; } -static void -R600DoneSolid(PixmapPtr pPix); - static Bool R600PrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg) { @@ -318,9 +320,27 @@ R600PrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg) if (accel_state->vsync) RADEONVlineHelperClear(pScrn); + accel_state->dst_pix = pPix; + accel_state->fg = fg; + return TRUE; } +static void +R600DoneSolid(PixmapPtr pPix) +{ + ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + struct radeon_accel_state *accel_state = info->accel_state; + + if (accel_state->vsync) + r600_cp_wait_vline_sync(pScrn, accel_state->ib, pPix, + accel_state->vline_crtc, + accel_state->vline_y1, + accel_state->vline_y2); + + r600_finish_op(pScrn, 8); +} static void R600Solid(PixmapPtr pPix, int x1, int y1, int x2, int y2) @@ -330,6 +350,17 @@ R600Solid(PixmapPtr pPix, int x1, int y1, int x2, int y2) struct radeon_accel_state *accel_state = info->accel_state; float *vb; +#ifdef XF86DRM_MODE + if (info->cs && CS_FULL(info->cs)) { + R600DoneSolid(info->accel_state->dst_pix); + radeon_cs_flush_indirect(pScrn); + R600PrepareSolid(accel_state->dst_pix, + accel_state->rop, + accel_state->planemask, + accel_state->fg); + } +#endif + if (accel_state->vsync) RADEONVlineHelperSet(pScrn, x1, y1, x2, y2); @@ -348,22 +379,6 @@ R600Solid(PixmapPtr pPix, int x1, int y1, int x2, int y2) } static void -R600DoneSolid(PixmapPtr pPix) -{ - ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum]; - RADEONInfoPtr info = RADEONPTR(pScrn); - struct radeon_accel_state *accel_state = info->accel_state; - - if (accel_state->vsync) - r600_cp_wait_vline_sync(pScrn, accel_state->ib, pPix, - accel_state->vline_crtc, - accel_state->vline_y1, - accel_state->vline_y2); - - r600_finish_op(pScrn, 8); -} - -static void R600DoPrepareCopy(ScrnInfoPtr pScrn) { RADEONInfoPtr info = RADEONPTR(pScrn); @@ -653,10 +668,33 @@ R600PrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, if (accel_state->vsync) RADEONVlineHelperClear(pScrn); + accel_state->dst_pix = pDst; + accel_state->src_pix = pSrc; + accel_state->xdir = xdir; + accel_state->ydir = ydir; + return TRUE; } static void +R600DoneCopy(PixmapPtr pDst) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + struct radeon_accel_state *accel_state = info->accel_state; + + if (!accel_state->same_surface) + R600DoCopyVline(pDst); + + if (accel_state->copy_area) { + if (!info->cs) + exaOffscreenFree(pDst->drawable.pScreen, accel_state->copy_area); + accel_state->copy_area = NULL; + } + +} + +static void R600Copy(PixmapPtr pDst, int srcX, int srcY, int dstX, int dstY, @@ -669,6 +707,19 @@ R600Copy(PixmapPtr pDst, if (accel_state->same_surface && (srcX == dstX) && (srcY == dstY)) return; +#ifdef XF86DRM_MODE + if (info->cs && CS_FULL(info->cs)) { + R600DoneCopy(info->accel_state->dst_pix); + radeon_cs_flush_indirect(pScrn); + R600PrepareCopy(accel_state->src_pix, + accel_state->dst_pix, + accel_state->xdir, + accel_state->ydir, + accel_state->rop, + accel_state->planemask); + } +#endif + if (accel_state->vsync) RADEONVlineHelperSet(pScrn, dstX, dstY, dstX + w, dstY + h); @@ -723,24 +774,6 @@ R600Copy(PixmapPtr pDst, } -static void -R600DoneCopy(PixmapPtr pDst) -{ - ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; - RADEONInfoPtr info = RADEONPTR(pScrn); - struct radeon_accel_state *accel_state = info->accel_state; - - if (!accel_state->same_surface) - R600DoCopyVline(pDst); - - if (accel_state->copy_area) { - if (!info->cs) - exaOffscreenFree(pDst->drawable.pScreen, accel_state->copy_area); - accel_state->copy_area = NULL; - } - -} - struct blendinfo { Bool dst_alpha; Bool src_alpha; @@ -1452,9 +1485,34 @@ static Bool R600PrepareComposite(int op, PicturePtr pSrcPicture, if (accel_state->vsync) RADEONVlineHelperClear(pScrn); + accel_state->composite_op = op; + accel_state->dst_pic = pDstPicture; + accel_state->src_pic = pSrcPicture; + accel_state->dst_pix = pDst; + accel_state->msk_pix = pMask; + accel_state->src_pix = pSrc; + return TRUE; } +static void R600DoneComposite(PixmapPtr pDst) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + struct radeon_accel_state *accel_state = info->accel_state; + int vtx_size; + + if (accel_state->vsync) + r600_cp_wait_vline_sync(pScrn, accel_state->ib, pDst, + accel_state->vline_crtc, + accel_state->vline_y1, + accel_state->vline_y2); + + vtx_size = accel_state->msk_pic ? 24 : 16; + + r600_finish_op(pScrn, vtx_size); +} + static void R600Composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, @@ -1469,6 +1527,20 @@ static void R600Composite(PixmapPtr pDst, /* ErrorF("R600Composite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n", srcX, srcY, maskX, maskY,dstX, dstY, w, h); */ +#ifdef XF86DRM_MODE + if (info->cs && CS_FULL(info->cs)) { + R600DoneComposite(info->accel_state->dst_pix); + radeon_cs_flush_indirect(pScrn); + R600PrepareComposite(info->accel_state->composite_op, + info->accel_state->src_pic, + info->accel_state->msk_pic, + info->accel_state->dst_pic, + info->accel_state->src_pix, + info->accel_state->msk_pix, + info->accel_state->dst_pix); + } +#endif + if (accel_state->vsync) RADEONVlineHelperSet(pScrn, dstX, dstY, dstX + w, dstY + h); @@ -1524,24 +1596,6 @@ static void R600Composite(PixmapPtr pDst, } -static void R600DoneComposite(PixmapPtr pDst) -{ - ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; - RADEONInfoPtr info = RADEONPTR(pScrn); - struct radeon_accel_state *accel_state = info->accel_state; - int vtx_size; - - if (accel_state->vsync) - r600_cp_wait_vline_sync(pScrn, accel_state->ib, pDst, - accel_state->vline_crtc, - accel_state->vline_y1, - accel_state->vline_y2); - - vtx_size = accel_state->msk_pic ? 24 : 16; - - r600_finish_op(pScrn, vtx_size); -} - Bool R600CopyToVRAM(ScrnInfoPtr pScrn, char *src, int src_pitch, diff --git a/src/radeon.h b/src/radeon.h index 50ce62f..73d6db1 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -735,12 +735,13 @@ struct radeon_accel_state { // UTS/DFS drmBufPtr scratch; - // copy + // solid/copy ExaOffscreenArea *copy_area; struct radeon_bo *copy_area_bo; Bool same_surface; int rop; uint32_t planemask; + uint32_t fg; // composite Bool component_alpha; From keithp at kemper.freedesktop.org Fri Oct 28 10:20:40 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Fri, 28 Oct 2011 10:20:40 -0700 (PDT) Subject: xserver: Branch 'master' - 3 commits Message-ID: <20111028172040.86C671000F@kemper.freedesktop.org> hw/xquartz/applewm.c | 4 +++- hw/xquartz/xpr/appledri.c | 4 +++- hw/xwin/winwindowswm.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) New commits: commit 286fa9bf9b4ffb0f9dbd3f1cae46ddcb27ee9318 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:53:43 2011 -0700 XWin: windowswm: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk> diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c index 403c859..577614d 100644 --- a/hw/xwin/winwindowswm.c +++ b/hw/xwin/winwindowswm.c @@ -629,9 +629,11 @@ winWindowsWMExtensionInit (void) NULL, StandardMinorOpcode))) { + size_t i; WMReqCode = (unsigned char)extEntry->base; WMErrorBase = extEntry->errorBase; WMEventBase = extEntry->eventBase; - EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < WindowsWMNumberEvents; i++) + EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent; } } commit dc054fefc586c5b404fe0f949dbd456e5267c647 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:49:33 2011 -0700 XQuartz: appledri: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 6b4a8a3..44c132a 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -529,9 +529,11 @@ AppleDRIExtensionInit(void) SProcAppleDRIDispatch, AppleDRIResetProc, StandardMinorOpcode))) { + size_t i; DRIReqCode = (unsigned char)extEntry->base; DRIErrorBase = extEntry->errorBase; DRIEventBase = extEntry->eventBase; - EventSwapVector[DRIEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < AppleDRINumberEvents; i++) + EventSwapVector[DRIEventBase + i] = (EventSwapPtr) SNotifyEvent; } } commit d5fee2b638fabeb8bec31a24e57d5c2a232d0893 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:48:16 2011 -0700 XQuartz: applewm: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index 27fb125..55976c4 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -725,10 +725,12 @@ AppleWMExtensionInit( NULL, StandardMinorOpcode))) { + size_t i; WMReqCode = (unsigned char)extEntry->base; WMErrorBase = extEntry->errorBase; WMEventBase = extEntry->eventBase; - EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < AppleWMNumberEvents; i++) + EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent; appleWMProcs = procsPtr; } } From keithp at kemper.freedesktop.org Fri Oct 28 13:12:23 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Fri, 28 Oct 2011 13:12:23 -0700 (PDT) Subject: xserver: Branch 'master' - 2 commits Message-ID: <20111028201223.0F2561000F@kemper.freedesktop.org> hw/xfree86/os-support/bsd/bsd_init.c | 1 - include/dix.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) New commits: commit 91131037a2d2e07079de5d222d8a8c95300750cc Author: Alexandr Shadchin <alexandr.shadchin at gmail.com> Date: Sat Oct 29 00:14:32 2011 +0600 Fix position _X_EXPORT Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/include/dix.h b/include/dix.h index b1bf9ed..34661f3 100644 --- a/include/dix.h +++ b/include/dix.h @@ -571,8 +571,8 @@ typedef struct { extern int XItoCoreType(int xi_type); extern Bool DevHasCursor(DeviceIntPtr pDev); -extern Bool _X_EXPORT IsPointerDevice( DeviceIntPtr dev); -extern Bool _X_EXPORT IsKeyboardDevice(DeviceIntPtr dev); +extern _X_EXPORT Bool IsPointerDevice(DeviceIntPtr dev); +extern _X_EXPORT Bool IsKeyboardDevice(DeviceIntPtr dev); extern Bool IsPointerEvent(InternalEvent *event); extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev); extern _X_EXPORT Bool IsFloating(DeviceIntPtr dev); commit 219bcec73d3554c57b87f28812ab06a66b739b19 Author: Alexandr Shadchin <alexandr.shadchin at gmail.com> Date: Sat Oct 29 00:14:31 2011 +0600 bsd: Remove odd message about -sharevts This is missing in commit 'xfree86: move -novtswitch & -sharevts argument handling up to common layer' Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index 8446179..b58d6a7 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -710,7 +710,6 @@ xf86UseMsg() { #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) ErrorF("vtXX use the specified VT number (1-12)\n"); - ErrorF("-sharevts share VTs with another X server\n"); #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ ErrorF("-keeptty "); ErrorF("don't detach controlling tty (for debugging only)\n"); From jeremyhu at kemper.freedesktop.org Fri Oct 28 18:43:27 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 28 Oct 2011 18:43:27 -0700 (PDT) Subject: xserver: Branch 'server-1.11-branch' - 4 commits Message-ID: <20111029014327.544481000F@kemper.freedesktop.org> configure.ac | 4 ++-- hw/xquartz/applewm.c | 4 +++- hw/xquartz/xpr/appledri.c | 4 +++- hw/xwin/winwindowswm.c | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) New commits: commit 0bffe6b38cdf6b21d9ec9b0abf0092d4d4eaef86 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 28 18:32:28 2011 -0700 configure.ac: Bump to 1.11.1.902 (1.11.2 RC2) Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/configure.ac b/configure.ac index cc4292b..5b6e39c 100644 --- a/configure.ac +++ b/configure.ac @@ -26,8 +26,8 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([xorg-server], 1.11.1.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) -RELEASE_DATE="2011-10-14" +AC_INIT([xorg-server], 1.11.1.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +RELEASE_DATE="2011-10-28" AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE commit a1d638da0d12c82c944bfecb996903210879f426 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:53:43 2011 -0700 XWin: windowswm: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk> (cherry picked from commit 286fa9bf9b4ffb0f9dbd3f1cae46ddcb27ee9318) diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c index 7138409..f5d27e5 100644 --- a/hw/xwin/winwindowswm.c +++ b/hw/xwin/winwindowswm.c @@ -629,9 +629,11 @@ winWindowsWMExtensionInit (void) NULL, StandardMinorOpcode))) { + size_t i; WMReqCode = (unsigned char)extEntry->base; WMErrorBase = extEntry->errorBase; WMEventBase = extEntry->eventBase; - EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < WindowsWMNumberEvents; i++) + EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent; } } commit 0715469f1cb150261b51867df75892d26916ea05 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:49:33 2011 -0700 XQuartz: appledri: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit dc054fefc586c5b404fe0f949dbd456e5267c647) diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 129fc78..80955fe 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -541,9 +541,11 @@ AppleDRIExtensionInit(void) SProcAppleDRIDispatch, AppleDRIResetProc, StandardMinorOpcode))) { + size_t i; DRIReqCode = (unsigned char)extEntry->base; DRIErrorBase = extEntry->errorBase; DRIEventBase = extEntry->eventBase; - EventSwapVector[DRIEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < AppleDRINumberEvents; i++) + EventSwapVector[DRIEventBase + i] = (EventSwapPtr) SNotifyEvent; } } commit bc2600466eea2af2d6a81fe1592d908565995cb2 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:48:16 2011 -0700 XQuartz: applewm: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit d5fee2b638fabeb8bec31a24e57d5c2a232d0893) diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index 2f26e61..2dfc35a 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -727,10 +727,12 @@ AppleWMExtensionInit( NULL, StandardMinorOpcode))) { + size_t i; WMReqCode = (unsigned char)extEntry->base; WMErrorBase = extEntry->errorBase; WMEventBase = extEntry->eventBase; - EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < AppleWMNumberEvents; i++) + EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent; appleWMProcs = procsPtr; } } From jeremyhu at kemper.freedesktop.org Fri Oct 28 18:44:54 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Fri, 28 Oct 2011 18:44:54 -0700 (PDT) Subject: xserver: Changes to 'refs/tags/xorg-server-1.11.1.902' Message-ID: <20111029014454.62CE110010@kemper.freedesktop.org> Tag 'xorg-server-1.11.1.902' created by Jeremy Huddleston <jeremyhu at apple.com> at 2011-10-29 02:44 -0700 xorg-server-1.11.1.902 (1.11.2 RC2) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iD8DBQBOq1pujC1Anjf1NmMRAi4LAJ41+Cdp827SOAzURbCp0enDvPAmywCZAX9/ fBqMoZyz8ln380YI8nsvFdo= =6e+9 -----END PGP SIGNATURE----- Changes since xorg-server-1.11.1.901: Jeremy Huddleston (8): Xnest: Match the host's keymap XQuartz: appledri: Set the correct reply length for XAppleDRICreatePixmap XQuartz: appledri: Fix byte swapping in replies XQuartz: appledri: Allow byte swapped requests XQuartz: applewm: Correct byte swapping in event notifications XQuartz: appledri: Correct byte swapping in event notifications XWin: windowswm: Correct byte swapping in event notifications configure.ac: Bump to 1.11.1.902 (1.11.2 RC2) Jesse Barnes (1): crtc: match full preferred modes if possible when choosing an initial config Matthieu Herrb (2): Fix CVE-2011-4028: File disclosure vulnerability. Fix CVE-2011-4029: File permission change vulnerability. Tom???? Trnka (1): Fix drain_console unregistration Ville Syrjala (1): composite: Update borderClip in compAllocPixmap() --- composite/compalloc.c | 11 +- configure.ac | 4 hw/xfree86/common/xf86Events.c | 9 - hw/xfree86/modes/xf86Crtc.c | 25 ++++- hw/xfree86/os-support/linux/lnx_init.c | 14 +-- hw/xnest/Keyboard.c | 25 ++++- hw/xquartz/applewm.c | 4 hw/xquartz/xpr/appledri.c | 153 ++++++++++++++++++++++++++++++--- hw/xwin/winwindowswm.c | 4 os/utils.c | 4 10 files changed, 210 insertions(+), 43 deletions(-) --- From jeremyhu at kemper.freedesktop.org Sat Oct 29 00:09:04 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 00:09:04 -0700 (PDT) Subject: xserver: Branch 'server-1.10-branch' - 3 commits Message-ID: <20111029070904.280471000F@kemper.freedesktop.org> hw/xquartz/applewm.c | 4 +++- hw/xquartz/xpr/appledri.c | 4 +++- hw/xwin/winwindowswm.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) New commits: commit e3a24febc4bb84b77aea14f8d7a174e5a8614d6c Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:53:43 2011 -0700 XWin: windowswm: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk> (cherry picked from commit 286fa9bf9b4ffb0f9dbd3f1cae46ddcb27ee9318) diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c index 7138409..f5d27e5 100644 --- a/hw/xwin/winwindowswm.c +++ b/hw/xwin/winwindowswm.c @@ -629,9 +629,11 @@ winWindowsWMExtensionInit (void) NULL, StandardMinorOpcode))) { + size_t i; WMReqCode = (unsigned char)extEntry->base; WMErrorBase = extEntry->errorBase; WMEventBase = extEntry->eventBase; - EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < WindowsWMNumberEvents; i++) + EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent; } } commit fa85f7811e8bd121eb91caa5cc4fcb7d38e93c16 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:49:33 2011 -0700 XQuartz: appledri: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit dc054fefc586c5b404fe0f949dbd456e5267c647) diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c index 129fc78..80955fe 100644 --- a/hw/xquartz/xpr/appledri.c +++ b/hw/xquartz/xpr/appledri.c @@ -541,9 +541,11 @@ AppleDRIExtensionInit(void) SProcAppleDRIDispatch, AppleDRIResetProc, StandardMinorOpcode))) { + size_t i; DRIReqCode = (unsigned char)extEntry->base; DRIErrorBase = extEntry->errorBase; DRIEventBase = extEntry->eventBase; - EventSwapVector[DRIEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < AppleDRINumberEvents; i++) + EventSwapVector[DRIEventBase + i] = (EventSwapPtr) SNotifyEvent; } } commit 1a9346f62ca5c6af81bb32aadefd3c97125ae1da Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Tue Oct 25 23:48:16 2011 -0700 XQuartz: applewm: Correct byte swapping in event notifications Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> (cherry picked from commit d5fee2b638fabeb8bec31a24e57d5c2a232d0893) diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index ec20534..e52094b 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -727,10 +727,12 @@ AppleWMExtensionInit( NULL, StandardMinorOpcode))) { + size_t i; WMReqCode = (unsigned char)extEntry->base; WMErrorBase = extEntry->errorBase; WMEventBase = extEntry->eventBase; - EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent; + for (i=0; i < AppleWMNumberEvents; i++) + EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent; appleWMProcs = procsPtr; } } From sandmann at kemper.freedesktop.org Sat Oct 29 02:30:23 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Sat, 29 Oct 2011 02:30:23 -0700 (PDT) Subject: pixman: Branch 'master' Message-ID: <20111029093023.7DD7C1000F@kemper.freedesktop.org> pixman/pixman-noop.c | 6 +++--- pixman/pixman-sse2.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit 498138c293a2abce44ce122114852f4e6c5b87fe Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Tue Oct 25 08:45:34 2011 -0400 Fix use of uninitialized fields reported by valgrind In pixman-noop.c and pixman-sse2.c, we are accessing image->bits.width/height without first making sure the image is a bits image. The warning is harmless because we never act on this information without checking that the image is a8r8g8b8, but valgrind does warn about it. In pixman-noop.c, just reorder the clauses in the if statement; in pixman-sse2.c require images to have the FAST_PATH_BITS_IMAGE flag set. diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c index 906a491..f4012d8 100644 --- a/pixman/pixman-noop.c +++ b/pixman/pixman-noop.c @@ -76,12 +76,12 @@ noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) { iter->get_scanline = _pixman_iter_get_scanline_noop; } - else if ((iter->flags & ITER_NARROW) && + else if (image->common.extended_format_code == PIXMAN_a8r8g8b8 && + (iter->flags & ITER_NARROW) && (image->common.flags & FLAGS) == FLAGS && iter->x >= 0 && iter->y >= 0 && iter->x + iter->width <= image->bits.width && - iter->y + iter->height <= image->bits.height && - image->common.extended_format_code == PIXMAN_a8r8g8b8) + iter->y + iter->height <= image->bits.height) { iter->buffer = image->bits.bits + iter->y * image->bits.rowstride + iter->x; diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c index c419511..8adf541 100644 --- a/pixman/pixman-sse2.c +++ b/pixman/pixman-sse2.c @@ -5982,7 +5982,7 @@ sse2_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) int height = iter->height; #define FLAGS \ - (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM) + (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE) if ((iter->flags & ITER_NARROW) && (image->common.flags & FLAGS) == FLAGS && From ickle at kemper.freedesktop.org Sat Oct 29 02:34:42 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sat, 29 Oct 2011 02:34:42 -0700 (PDT) Subject: xf86-video-intel: 9 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/kgem.c src/sna/sna_accel.c Message-ID: <20111029093442.8F8B81000F@kemper.freedesktop.org> src/sna/gen2_render.c | 3 src/sna/gen3_render.c | 3 src/sna/gen4_render.c | 3 src/sna/gen5_render.c | 3 src/sna/gen6_render.c | 3 src/sna/gen7_render.c | 3 src/sna/kgem.c | 13 ++ src/sna/sna_accel.c | 321 +++++++++++++++++++++++++++++++++----------------- 8 files changed, 239 insertions(+), 113 deletions(-) New commits: commit 719626ef7918d5cd69d13f983b8b615aefe215d6 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 29 10:26:08 2011 +0100 sna: Increment clip box when short-circuiting the iteration Reported-by: nkalkhof at web.de Bugzilla: https://bugs.freedesktop.org/show_bug.cgi Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index fead5a1..3c1a65e 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1968,10 +1968,12 @@ no_damage_clipped: if (y + 1 <= c->y1) break; - if (X2 <= c->x1) - continue; if (X1 >= c->x2) break; + if (X2 <= c->x1) { + c++; + continue; + } b->x1 = c->x1; b->x2 = c->x2; @@ -1981,6 +1983,8 @@ no_damage_clipped: b->x1 = X1; if (b->x2 > X2) b->x2 = X2; + if (b->x2 <= b->x1) + continue; b->x1 += dx; b->x2 += dx; @@ -2073,10 +2077,12 @@ damage_clipped: if (y + 1 <= c->y1) break; - if (X2 <= c->x1) - continue; if (X1 >= c->x2) break; + if (X2 <= c->x1) { + c++; + continue; + } b->x1 = c->x1; b->x2 = c->x2; @@ -2086,6 +2092,8 @@ damage_clipped: b->x1 = X1; if (b->x2 > X2) b->x2 = X2; + if (b->x2 <= b->x1) + continue; b->x1 += dx; b->x2 += dx; commit 32a9e0352a1e28509580d84bfc5377d8fae913c4 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 23:14:24 2011 +0100 sna: Retire and search inactive again before creating new buffer Attempt to retire an active buffer into the inactive cache before giving up and creating a new buffer. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index e8df7d9..4827fb8 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1270,6 +1270,13 @@ struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size) if (bo) return kgem_bo_reference(bo); + if (!list_is_empty(&kgem->requests)) { + kgem_retire(kgem); + bo = search_linear_cache(kgem, size, false); + if (bo) + return kgem_bo_reference(bo); + } + handle = gem_create(kgem->fd, size); if (handle == 0) return NULL; @@ -1541,6 +1548,12 @@ next_bo: continue; } + if (flags & CREATE_INACTIVE && !list_is_empty(&kgem->requests)) { + kgem_retire(kgem); + flags &= ~CREATE_INACTIVE; + goto skip_active_search; + } + handle = gem_create(kgem->fd, size); if (handle == 0) return NULL; commit 15266e1b9500f6b348661c60d1982bde911f2d0e Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 18:00:56 2011 +0100 sna: Don't flush the render caches if in the process of writing again Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index 9e85176..e76876c 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -1375,7 +1375,8 @@ gen2_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) { + if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || + (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) { if (tmp->src.bo == tmp->dst.bo || tmp->mask.bo == tmp->dst.bo) { kgem_emit_flush(&sna->kgem); } else { diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 2b70b85..118b906 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -2479,7 +2479,8 @@ gen3_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) { + if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || + (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) { if (tmp->src.bo == tmp->dst.bo || tmp->mask.bo == tmp->dst.bo) { kgem_emit_flush(&sna->kgem); } else { diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index e4a40fc..425967b 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2058,7 +2058,8 @@ gen4_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) + if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || + (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) kgem_emit_flush(&sna->kgem); gen4_bind_surfaces(sna, tmp); diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index a177d32..6d4fbd9 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2078,7 +2078,8 @@ gen5_render_composite(struct sna *sna, tmp->dst.bo, tmp->src.bo, tmp->mask.bo, NULL)) kgem_submit(&sna->kgem); - if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) + if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || + (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) kgem_emit_flush(&sna->kgem); gen5_bind_surfaces(sna, tmp); diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 0dde625..1abb54f 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2248,7 +2248,8 @@ gen6_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) + if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || + (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) kgem_emit_flush(&sna->kgem); gen6_emit_composite_state(sna, tmp); diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index b9f23ee..7eb323f 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2388,7 +2388,8 @@ gen7_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) + if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || + (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) kgem_emit_flush(&sna->kgem); gen7_emit_composite_state(sna, tmp); commit d3c7ee921172d4898ebdc6e944812a02426008e9 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 16:44:16 2011 +0100 sna: Faster unclipped rectilinear segments Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4b1e536..fead5a1 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3332,51 +3332,95 @@ sna_poly_segment_blt(DrawablePtr drawable, if (!clipped) { dx += drawable->x; dy += drawable->y; - do { - int x, y, width, height; + if (dx|dy) { + do { + int nbox = n; + if (nbox > ARRAY_SIZE(boxes)) + nbox = ARRAY_SIZE(boxes); + n -= nbox; + do { + if (seg->x1 < seg->x2) { + b->x1 = seg->x1; + b->x2 = seg->x2; + } else { + b->x1 = seg->x2; + b->x2 = seg->x1; + } + b->x2++; - if (seg->x1 < seg->x2) { - x = seg->x1; - width = seg->x2; - } else { - x = seg->x2; - width = seg->x1; - } - width -= x - 1; + if (seg->y1 < seg->y2) { + b->y1 = seg->y1; + b->y2 = seg->y2; + } else { + b->y1 = seg->y2; + b->y2 = seg->y1; + } + b->y2++; - if (seg->y1 < seg->y2) { - y = seg->y1; - height = seg->y2; - } else { - y = seg->y2; - height = seg->y1; - } - height -= y - 1; - - /* don't paint last pixel */ - if (gc->capStyle == CapNotLast) { - if (width == 1) - height--; - else - width--; - } + /* don't paint last pixel */ + if (gc->capStyle == CapNotLast) { + if (seg->x1 == seg->x2) + b->y2--; + else + b->x2--; + } - DBG(("%s: [%d] (%d, %d)x(%d, %d) + (%d, %d)\n", __FUNCTION__, n, - x, y, width, height, dx, dy)); + b->x1 += dx; + b->x2 += dx; + b->y1 += dy; + b->y2 += dy; + b++; + seg++; + } while (--nbox); - b->x1 = x + dx; - b->x2 = b->x1 + width; - b->y1 = y + dy; - b->y2 = b->y1 + height; - if (++b == last_box) { - fill.boxes(sna, &fill, boxes, last_box-boxes); + fill.boxes(sna, &fill, boxes, b-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); b = boxes; - } + } while (n); + } else { + do { + int nbox = n; + if (nbox > ARRAY_SIZE(boxes)) + nbox = ARRAY_SIZE(boxes); + n -= nbox; + do { + if (seg->x1 < seg->x2) { + b->x1 = seg->x1; + b->x2 = seg->x2; + } else { + b->x1 = seg->x2; + b->x2 = seg->x1; + } + b->x2++; - seg++; - } while (--n); + if (seg->y1 < seg->y2) { + b->y1 = seg->y1; + b->y2 = seg->y2; + } else { + b->y1 = seg->y2; + b->y2 = seg->y1; + } + b->y2++; + + /* don't paint last pixel */ + if (gc->capStyle == CapNotLast) { + if (seg->x1 == seg->x2) + b->y2--; + else + b->x2--; + } + + b++; + seg++; + } while (--nbox); + + fill.boxes(sna, &fill, boxes, b-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + b = boxes; + } while (n); + } } else { RegionRec clip; commit 3cd909cfe9e7d7e97a1d51513a049e312fd9ddae Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 15:48:49 2011 +0100 sna: Call miZeroArcLine where appropriate for GPU paths Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 96f0e05..4b1e536 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4683,13 +4683,18 @@ sna_poly_arc(DrawablePtr drawable, GCPtr gc, int n, xArc *arc) if (USE_SPANS && arc_to_spans(gc, n) && can_fill_spans(drawable, gc) && sna_drawable_use_gpu_bo(drawable, ®ion.extents)) { DBG(("%s: converting arcs into spans\n", __FUNCTION__)); - miPolyArc(drawable, gc, n, arc); + /* XXX still around 10x slower for x11perf -ellipse */ + if (gc->lineWidth == 0) + miZeroPolyArc(drawable, gc, n, arc); + else + miPolyArc(drawable, gc, n, arc); return; } fallback: DBG(("%s -- fallback\n", __FUNCTION__)); if (gc->lineWidth) { + DBG(("%s -- miPolyArc\n", __FUNCTION__)); miPolyArc(drawable, gc, n, arc); return; } commit 9921c98df070032e082570f0663f6d3ad0cccd56 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 14:09:11 2011 +0100 sna: Faster unclipped PolyFillRect Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 9f00fd6..96f0e05 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4765,17 +4765,41 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, dy += drawable->y; sna_damage_add_rectangles(damage, rect, n, dx, dy); - do { - b->x1 = rect->x + dx; - b->y1 = rect->y + dy; - b->x2 = b->x1 + rect->width; - b->y2 = b->y1 + rect->height; - rect++; - if (++b == last_box) { - fill.boxes(sna, &fill, boxes, last_box-boxes); + if (dx|dy) { + do { + int nbox = n; + if (nbox > ARRAY_SIZE(boxes)) + nbox = ARRAY_SIZE(boxes); + n -= nbox; + do { + b->x1 = rect->x + dx; + b->y1 = rect->y + dy; + b->x2 = b->x1 + rect->width; + b->y2 = b->y1 + rect->height; + b++; + rect++; + } while (--nbox); + fill.boxes(sna, &fill, boxes, b-boxes); b = boxes; - } - } while (--n); + } while (n); + } else { + do { + int nbox = n; + if (nbox > ARRAY_SIZE(boxes)) + nbox = ARRAY_SIZE(boxes); + n -= nbox; + do { + b->x1 = rect->x; + b->y1 = rect->y; + b->x2 = b->x1 + rect->width; + b->y2 = b->y1 + rect->height; + b++; + rect++; + } while (--nbox); + fill.boxes(sna, &fill, boxes, b-boxes); + b = boxes; + } while (n); + } } else { RegionRec clip; commit c1718f96f520874c1fb2af0eb975c7f548762d34 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 14:01:24 2011 +0100 sna: Faster unclipped PolyPoint Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 61fe190..9f00fd6 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2387,26 +2387,25 @@ sna_poly_point_blt(DrawablePtr drawable, sna_damage_add_points(damage, pt, n, last.x, last.y); do { - b->x1 = pt->x; - b->y1 = pt->y; - pt++; + int nbox = n; + if (nbox > ARRAY_SIZE(box)) + nbox = ARRAY_SIZE(box); + n -= nbox; + do { + *(DDXPointRec *)b = *pt++; - b->x1 += last.x; - b->y1 += last.y; - if (mode == CoordModePrevious) { - last.x = b->x1; - last.y = b->y1; - } + b->x1 += last.x; + b->y1 += last.y; + if (mode == CoordModePrevious) + last = *(DDXPointRec *)b; - b->x2 = b->x1 + 1; - b->y2 = b->y1 + 1; - if (++b == last_box) { - fill.boxes(sna, &fill, box, last_box - box); - b = box; - } - } while (--n); - if (b != box) + b->x2 = b->x1 + 1; + b->y2 = b->y1 + 1; + b++; + } while (--nbox); fill.boxes(sna, &fill, box, b - box); + b = box; + } while (n); } else { while (n--) { int x, y; @@ -4846,9 +4845,9 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, } RegionUninit(&clip); + if (b != boxes) + fill.boxes(sna, &fill, boxes, b-boxes); } - if (b != boxes) - fill.boxes(sna, &fill, boxes, b-boxes); done: fill.done(sna, &fill); return TRUE; commit a4762ed891a50238abddf6c762a053db5c34b87f Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 13:39:17 2011 +0100 sna: Call directly into tiled rects for tiled spans. As we already know the extents and that this is a candidate for GPU-acceleration, we can skip over those steps and emit the tiled rects. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 2a9f2a4..61fe190 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2182,8 +2182,12 @@ reduce_damage(DrawablePtr drawable, return damage; } -static void -sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect); +static Bool +sna_poly_fill_rect_tiled(DrawablePtr drawable, + struct kgem_bo *bo, + struct sna_damage **damage, + GCPtr gc, int n, xRectangle *rect, + const BoxRec *extents, unsigned clipped); static bool can_fill_spans(DrawablePtr drawable, GCPtr gc) @@ -2253,26 +2257,36 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, ®ion.extents, flags & 2)) return; } else if (gc->fillStyle == FillTiled) { - xRectangle *rect; - int i; - /* Try converting these to a set of rectangles instead */ - DBG(("%s: converting to rectagnles\n", __FUNCTION__)); - rect = malloc (n * sizeof (xRectangle)); - if (rect == NULL) - return; + if (sna_drawable_use_gpu_bo(drawable, ®ion.extents)) { + struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable); + xRectangle *rect; + int i; - for (i = 0; i < n; i++) { - rect[i].x = pt[i].x; - rect[i].width = width[i]; - rect[i].y = pt[i].y; - rect[i].height = 1; - } + DBG(("%s: converting to rectagnles\n", __FUNCTION__)); - sna_poly_fill_rect(drawable, gc, n, rect); - free (rect); - return; + rect = malloc (n * sizeof (xRectangle)); + if (rect == NULL) + return; + + for (i = 0; i < n; i++) { + rect[i].x = pt[i].x; + rect[i].width = width[i]; + rect[i].y = pt[i].y; + rect[i].height = 1; + } + + i = sna_poly_fill_rect_tiled(drawable, + priv->gpu_bo, + priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, ®ion.extents), + gc, n, rect, + ®ion.extents, flags & 2); + free (rect); + + if (i) + return; + } } fallback: commit a02069df2ddc259d65ad468834f7968d283b713f Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Fri Oct 28 11:30:37 2011 +0100 sna: Faster unclipped spans Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 31f4013..2a9f2a4 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1837,24 +1837,38 @@ no_damage_translate: dx += drawable->x; dy += drawable->y; no_damage: - { - unsigned offset = dx|dy; + if (dx|dy) { do { - *(DDXPointRec *)b = *pt++; - if (offset) { + int nbox = n; + if (nbox > last_box - box) + nbox = last_box - box; + n -= nbox; + do { + *(DDXPointRec *)b = *pt++; b->x1 += dx; b->y1 += dy; - } - b->x2 = b->x1 + (int)*width++; - b->y2 = b->y1 + 1; - - if (++b == last_box) { - fill.boxes(sna, &fill, box, last_box - box); - b = box; - } - } while (--n); - if (b != box) + b->x2 = b->x1 + (int)*width++; + b->y2 = b->y1 + 1; + b++; + } while (--nbox); fill.boxes(sna, &fill, box, b - box); + b = box; + } while (n); + } else { + do { + int nbox = n; + if (nbox > last_box - box) + nbox = last_box - box; + n -= nbox; + do { + *(DDXPointRec *)b = *pt++; + b->x2 = b->x1 + (int)*width++; + b->y2 = b->y1 + 1; + b++; + } while (--nbox); + fill.boxes(sna, &fill, box, b - box); + b = box; + } while (n); } goto done; @@ -2192,9 +2206,8 @@ sna_fill_spans(DrawablePtr drawable, GCPtr gc, int n, RegionRec region; unsigned flags; - DBG(("%s(n=%d, pt[0]=(%d, %d)\n", - __FUNCTION__, n, pt[0].x, pt[0].y)); - + DBG(("%s(n=%d, pt[0]=(%d, %d)+%d, sorted=%d\n", + __FUNCTION__, n, pt[0].x, pt[0].y, width[0], sorted)); flags = sna_spans_extents(drawable, gc, n, pt, width, ®ion.extents); if (flags == 0) From sandmann at kemper.freedesktop.org Sat Oct 29 02:48:50 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Sat, 29 Oct 2011 02:48:50 -0700 (PDT) Subject: pixman: Branch 'master' Message-ID: <20111029094850.5B5F91000F@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit a0f1b565811388b0567c845b9b7063d5b93d325e Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Sat Oct 29 05:33:44 2011 -0400 Pre-release version bump to 0.23.8 diff --git a/configure.ac b/configure.ac index 6c88c84..0552563 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ AC_PREREQ([2.57]) m4_define([pixman_major], 0) m4_define([pixman_minor], 23) -m4_define([pixman_micro], 7) +m4_define([pixman_micro], 8) m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro]) From sandmann at kemper.freedesktop.org Sat Oct 29 02:49:00 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Sat, 29 Oct 2011 02:49:00 -0700 (PDT) Subject: pixman: Changes to 'refs/tags/pixman-0.23.8' Message-ID: <20111029094900.0A13D1000F@kemper.freedesktop.org> Tag 'pixman-0.23.8' created by S??ren Sandmann Pedersen <ssp at redhat.com> at 2011-10-29 10:41 -0700 pixman 0.23.8 release -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEABECAAYFAk6ryk4ACgkQmxfmIW/3waiVUACgms9zzrMQmwQNNPVkewOh9V4E 570An1hGPpTUWGIDw840/sbwcWZKfxTV =zEet -----END PGP SIGNATURE----- Changes since pixman-0.23.6-15: --- 0 files changed --- From sandmann at kemper.freedesktop.org Sat Oct 29 02:50:05 2011 From: sandmann at kemper.freedesktop.org (Søren Sandmann Pedersen) Date: Sat, 29 Oct 2011 02:50:05 -0700 (PDT) Subject: pixman: Branch 'master' Message-ID: <20111029095005.AB04D1000F@kemper.freedesktop.org> configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 697cfe15377a8c420764ff824c0a8c2c8ff2148c Author: S??ren Sandmann Pedersen <ssp at redhat.com> Date: Sat Oct 29 05:51:44 2011 -0400 Post-release version bump to 0.23.9 diff --git a/configure.ac b/configure.ac index 0552563..eb783ac 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ AC_PREREQ([2.57]) m4_define([pixman_major], 0) m4_define([pixman_minor], 23) -m4_define([pixman_micro], 8) +m4_define([pixman_micro], 9) m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro]) From ickle at kemper.freedesktop.org Sat Oct 29 03:05:12 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sat, 29 Oct 2011 03:05:12 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111029100512.41F491000F@kemper.freedesktop.org> src/sna/sna_accel.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) New commits: commit 64a57c8dbec81f6420ff032985237eb16cebfb87 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 29 11:01:51 2011 +0100 sna: Further clipping bugs Make sure the line is clipped to the current clip box and discard if the clip is reduced to nothing. References: https://bugs.freedesktop.org/show_bug.cgi?id=42361 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 3c1a65e..096e458 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1909,6 +1909,9 @@ no_damage_clipped_translate: no_damage_clipped: region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + return TRUE; + assert(clip.extents.x1 >= 0); assert(clip.extents.y1 >= 0); assert(clip.extents.x2 <= pixmap->drawable.width); @@ -2017,6 +2020,9 @@ damage_clipped_translate: damage_clipped: region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + return TRUE; + assert(clip.extents.x1 >= 0); assert(clip.extents.y1 >= 0); assert(clip.extents.x2 <= pixmap->drawable.width); @@ -2353,6 +2359,8 @@ sna_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc, region.extents.y2 = region.extents.y1 + h; region.data = NULL; region_maybe_clip(®ion, gc->pCompositeClip); + if (!RegionNotEmpty(®ion)) + return NULL; sna_drawable_move_region_to_cpu(dst, ®ion, true); RegionTranslate(®ion, @@ -2580,8 +2588,11 @@ sna_poly_zero_line_blt(DrawablePtr drawable, get_drawable_deltas(drawable, pixmap, &dx, &dy); region_set(&clip, extents); - if (clipped) + if (clipped) { region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + return TRUE; + } jump = _jump[(damage != NULL) | !!(dx|dy) << 1]; DBG(("%s: [clipped] extents=(%d, %d), (%d, %d), delta=(%d, %d)\n", @@ -2608,10 +2619,10 @@ sna_poly_zero_line_blt(DrawablePtr drawable, y2 = ystart; oc2 = 0; MIOUTCODES(oc2, x2, y2, - clip.extents.x1, - clip.extents.y1, - clip.extents.x2, - clip.extents.y2); + extents->x1, + extents->y1, + extents->x2, + extents->y2); while (--n) { int16_t sdx, sdy; @@ -2643,10 +2654,10 @@ sna_poly_zero_line_blt(DrawablePtr drawable, oc2 = 0; MIOUTCODES(oc2, x2, y2, - clip.extents.x1, - clip.extents.y1, - clip.extents.x2, - clip.extents.y2); + extents->x1, + extents->y1, + extents->x2, + extents->y2); if (oc1 & oc2) continue; @@ -2698,8 +2709,8 @@ rectangle_continue: int x2_clipped = x2, y2_clipped = y2; int pt1_clipped; - if (miZeroClipLine(clip.extents.x1, clip.extents.y1, - clip.extents.x2, clip.extents.y2, + if (miZeroClipLine(extents->x1, extents->y1, + extents->x2, extents->y2, &x, &y, &x2_clipped, &y2_clipped, adx, ady, &pt1_clipped, &pt2_clipped, @@ -2785,10 +2796,8 @@ X_continue2: int x2_clipped = x2, y2_clipped = y2; int pt1_clipped; - if (miZeroClipLine(clip.extents.x1, - clip.extents.y1, - clip.extents.x2, - clip.extents.y2, + if (miZeroClipLine(extents->x1, extents->y1, + extents->x2, extents->y2, &x, &y, &x2_clipped, &y2_clipped, adx, ady, &pt1_clipped, &pt2_clipped, @@ -3008,6 +3017,8 @@ sna_poly_line_blt(DrawablePtr drawable, region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + return TRUE; last.x = pt->x + drawable->x; last.y = pt->y + drawable->y; @@ -3434,7 +3445,6 @@ sna_poly_segment_blt(DrawablePtr drawable, region_set(&clip, extents); region_maybe_clip(&clip, gc->pCompositeClip); - if (!RegionNotEmpty(&clip)) goto done; @@ -3602,8 +3612,11 @@ sna_poly_zero_segment_blt(DrawablePtr drawable, get_drawable_deltas(drawable, pixmap, &dx, &dy); region_set(&clip, extents); - if (clipped) + if (clipped) { region_maybe_clip(&clip, gc->pCompositeClip); + if (!RegionNotEmpty(&clip)) + return TRUE; + } DBG(("%s: [clipped] extents=(%d, %d), (%d, %d), delta=(%d, %d)\n", __FUNCTION__, clip.extents.x1, clip.extents.y1, From ickle at kemper.freedesktop.org Sat Oct 29 05:44:04 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sat, 29 Oct 2011 05:44:04 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111029124405.707351000F@kemper.freedesktop.org> src/sna/sna_accel.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) New commits: commit 33383fde55609fb4bd372d2d41a6254799499225 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 29 12:53:15 2011 +0100 sna: Tweak PolyRectangle blitting A box of height/width 1 and lineWidth 0 can also be drawn with a single box as the far edge is contiguous with far side of the near edge. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 096e458..3eb0d85 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4182,7 +4182,7 @@ sna_poly_rectangle_blt(DrawablePtr drawable, get_drawable_deltas(drawable, pixmap, &dx, &dy); v = !!clipped; - v |= (gc->lineWidth != 0) << 1; + v |= (gc->lineWidth <= 1) << 1; goto *jump[v]; zero: @@ -4201,7 +4201,7 @@ zero: b = boxes; } - if (rr.width <= 1 || rr.height <= 1) { + if (rr.width <= 2 || rr.height <= 2) { b->x1 = rr.x; b->y1 = rr.y; b->x2 = rr.x + rr.width + 1; @@ -4254,11 +4254,11 @@ zero_clipped: rr.x += drawable->x; rr.y += drawable->y; - if (rr.width <= 1 || rr.height <= 1) { + if (rr.width <= 2 || rr.height <= 2) { box[0].x1 = rr.x; box[0].y1 = rr.y; box[0].x2 = rr.x + rr.width + 1; - box[0].y2 = rr.y + r->height + 1; + box[0].y2 = rr.y + rr.height + 1; count = 1; } else { box[0].x1 = rr.x; @@ -4312,11 +4312,11 @@ zero_clipped: rr.x += drawable->x; rr.y += drawable->y; - if (rr.width <= 1 || rr.height <= 1) { + if (rr.width <= 2 || rr.height <= 2) { box[0].x1 = rr.x; box[0].y1 = rr.y; box[0].x2 = rr.x + rr.width + 1; - box[0].y2 = rr.y + r->height + 1; + box[0].y2 = rr.y + rr.height + 1; count = 1; } else { box[0].x1 = rr.x; @@ -4383,7 +4383,7 @@ wide_clipped: rr.x += drawable->x; rr.y += drawable->y; - if (rr.height < offset2 || rr.width < offset1) { + if (rr.height <= offset2 || rr.width <= offset2) { if (rr.height == 0) { box[0].x1 = rr.x; box[0].x2 = rr.x + rr.width + 1; @@ -4452,7 +4452,7 @@ wide_clipped: rr.x += drawable->x; rr.y += drawable->y; - if (rr.height < offset2 || rr.width < offset1) { + if (rr.height <= offset2 || rr.width <= offset2) { if (rr.height == 0) { box[0].x1 = rr.x; box[0].x2 = rr.x + rr.width + 1; @@ -4531,7 +4531,7 @@ wide: b = boxes; } - if (rr.height < offset2 || rr.width < offset1) { + if (rr.height <= offset2 || rr.width <= offset2) { if (rr.height == 0) { b->x1 = rr.x; b->x2 = rr.x + rr.width + 1; From ickle at kemper.freedesktop.org Sat Oct 29 10:59:22 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sat, 29 Oct 2011 10:59:22 -0700 (PDT) Subject: xf86-video-intel: src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c Message-ID: <20111029175922.20FA61000F@kemper.freedesktop.org> src/sna/gen3_render.c | 26 +++++++++++++------------- src/sna/gen4_render.c | 30 ++++++++++++++++-------------- src/sna/gen5_render.c | 30 ++++++++++++++++-------------- src/sna/gen6_render.c | 21 +++++++++++++-------- src/sna/gen7_render.c | 30 ++++++++++++++++-------------- 5 files changed, 74 insertions(+), 63 deletions(-) New commits: commit 4835fe5b2e19ac456773565399f334845f7442c0 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 29 18:56:29 2011 +0100 sna/genX: Improve reduction of Render operator to BLT alu This appeared to introduce a visual gitch into the xfce4 selection box on gen6 at least. References: https://bugs.freedesktop.org/show_bug.cgi?id=42367 Reported-by: Paul Neumann <paul104x at yahoo.de> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index 118b906..a581c8a 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3634,14 +3634,6 @@ gen3_render_fill_boxes_try_blt(struct sna *sna, if (dst_bo->tiling == I915_TILING_Y) return FALSE; - if (!sna_get_pixel_from_rgba(&pixel, - color->red, - color->green, - color->blue, - color->alpha, - format)) - return FALSE; - if (color->alpha >= 0xff00) { if (op == PictOpOver) op = PictOpSrc; @@ -3652,15 +3644,23 @@ gen3_render_fill_boxes_try_blt(struct sna *sna, op = PictOpSrc; } + pixel = 0; if (op == PictOpClear) { alu = GXclear; - pixel = 0; - op = PictOpSrc; - } - - if (op != PictOpSrc) + } else if (op == PictOpSrc) { + if (color->alpha <= 0x00ff) + alu = GXclear; + else if (!sna_get_pixel_from_rgba(&pixel, + color->red, + color->green, + color->blue, + color->alpha, + format)) + return FALSE; + } else return FALSE; + return sna_blt_fill_boxes(sna, alu, dst_bo, dst->drawable.bitsPerPixel, pixel, box, n); diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 425967b..18171c4 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2416,24 +2416,26 @@ gen4_render_fill_boxes(struct sna *sna, dst->drawable.width > 8192 || dst->drawable.height > 8192 || !gen4_check_dst_format(format)) { - uint8_t alu = GXcopy; + uint8_t alu = -1; - if (op == PictOpClear) { + if (op == PictOpClear || (op == PictOpOutReverse && color->alpha >= 0xff00)) alu = GXclear; - pixel = 0; - op = PictOpSrc; - } - if (op == PictOpOver && color->alpha >= 0xff00) - op = PictOpSrc; + if (op == PictOpSrc || (op == PictOpOver && color->alpha >= 0xff00)) { + alu = GXcopy; + if (color->alpha <= 0x00ff) + alu = GXclear; + } - if (op == PictOpSrc && - sna_get_pixel_from_rgba(&pixel, - color->red, - color->green, - color->blue, - color->alpha, - format) && + pixel = 0; + if ((alu == GXclear || + (alu == GXcopy && + sna_get_pixel_from_rgba(&pixel, + color->red, + color->green, + color->blue, + color->alpha, + format))) && sna_blt_fill_boxes(sna, alu, dst_bo, dst->drawable.bitsPerPixel, pixel, box, n)) diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index 6d4fbd9..b9512c7 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2389,24 +2389,26 @@ gen5_render_fill_boxes(struct sna *sna, dst->drawable.width > 8192 || dst->drawable.height > 8192 || !gen5_check_dst_format(format)) { - uint8_t alu = GXcopy; - uint8_t _op = op; + uint8_t alu = -1; - if (_op == PictOpClear) { + if (op == PictOpClear || (op == PictOpOutReverse && color->alpha >= 0xff00)) alu = GXclear; - _op = PictOpSrc; - } - if (_op == PictOpOver && color->alpha >= 0xff00) - _op = PictOpSrc; + if (op == PictOpSrc || (op == PictOpOver && color->alpha >= 0xff00)) { + alu = GXcopy; + if (color->alpha <= 0x00ff) + alu = GXclear; + } - if (_op == PictOpSrc && - sna_get_pixel_from_rgba(&pixel, - color->red, - color->green, - color->blue, - color->alpha, - format) && + pixel = 0; + if ((alu == GXclear || + (alu == GXcopy && + sna_get_pixel_from_rgba(&pixel, + color->red, + color->green, + color->blue, + color->alpha, + format))) && sna_blt_fill_boxes(sna, alu, dst_bo, dst->drawable.bitsPerPixel, pixel, box, n)) diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 1abb54f..1fc971f 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2598,16 +2598,21 @@ gen6_render_fill_boxes(struct sna *sna, if (op == PictOpClear || (op == PictOpOutReverse && color->alpha >= 0xff00)) alu = GXclear; - if (op == PictOpSrc || (op == PictOpOver && color->alpha >= 0xff00)) + if (op == PictOpSrc || (op == PictOpOver && color->alpha >= 0xff00)) { alu = GXcopy; + if (color->alpha <= 0x00ff) + alu = GXclear; + } - if (alu != -1 && - sna_get_pixel_from_rgba(&pixel, - color->red, - color->green, - color->blue, - color->alpha, - format) && + pixel = 0; + if ((alu == GXclear || + (alu == GXcopy && + sna_get_pixel_from_rgba(&pixel, + color->red, + color->green, + color->blue, + color->alpha, + format))) && sna_blt_fill_boxes(sna, alu, dst_bo, dst->drawable.bitsPerPixel, pixel, box, n)) diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 7eb323f..ecdab6e 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2741,24 +2741,26 @@ gen7_render_fill_boxes(struct sna *sna, dst->drawable.width > GEN7_MAX_SIZE || dst->drawable.height > GEN7_MAX_SIZE || !gen7_check_dst_format(format)) { - uint8_t alu = GXcopy; + uint8_t alu = -1; - if (op == PictOpClear) { + if (op == PictOpClear || (op == PictOpOutReverse && color->alpha >= 0xff00)) alu = GXclear; - pixel = 0; - op = PictOpSrc; - } - if (op == PictOpOver && color->alpha >= 0xff00) - op = PictOpSrc; + if (op == PictOpSrc || (op == PictOpOver && color->alpha >= 0xff00)) { + alu = GXcopy; + if (color->alpha <= 0x00ff) + alu = GXclear; + } - if (op == PictOpSrc && - sna_get_pixel_from_rgba(&pixel, - color->red, - color->green, - color->blue, - color->alpha, - format) && + pixel = 0; + if ((alu == GXclear || + (alu == GXcopy && + sna_get_pixel_from_rgba(&pixel, + color->red, + color->green, + color->blue, + color->alpha, + format))) && sna_blt_fill_boxes(sna, alu, dst_bo, dst->drawable.bitsPerPixel, pixel, box, n)) From jcristau at kemper.freedesktop.org Sat Oct 29 11:54:04 2011 From: jcristau at kemper.freedesktop.org (Julien Cristau) Date: Sat, 29 Oct 2011 11:54:04 -0700 (PDT) Subject: xserver: Branch 'server-1.7-branch' - 9 commits Message-ID: <20111029185404.7C2361000F@kemper.freedesktop.org> glx/glxcmds.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++--- glx/glxcmdsswap.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++--- glx/xfont.c | 2 os/utils.c | 4 - 4 files changed, 342 insertions(+), 21 deletions(-) New commits: commit 03ff880e8bf20cdecaf27f03391ea31545ecc22c Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:27:35 2011 +0200 Fix CVE-2011-4029: File permission change vulnerability. Use fchmod() to change permissions of the lock file instead of chmod(), thus avoid the race that can be exploited to set a symbolic link to any file or directory in the system. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit b67581cf825940fdf52bf2e0af4330e695d724a4) (cherry picked from commit 12f65819ffb04103f170ecd7e281348de618fc4c) diff --git a/os/utils.c b/os/utils.c index 7032227..adc75bc 100644 --- a/os/utils.c +++ b/os/utils.c @@ -315,7 +315,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* commit 3394ae378da567025ac94a2c2ff04f2a0b113962 Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:26:12 2011 +0200 Fix CVE-2011-4028: File disclosure vulnerability. use O_NOFOLLOW to open the existing lock file, so symbolic links aren't followed, thus avoid revealing if it point to an existing file. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit 6ba44b91e37622ef8c146d8f2ac92d708a18ed34) (cherry picked from commit f80d23357874db19bc124dee70239fb182977883) diff --git a/os/utils.c b/os/utils.c index d7c8388..7032227 100644 --- a/os/utils.c +++ b/os/utils.c @@ -336,7 +336,7 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(LockFile, O_RDONLY|O_NOFOLLOW); if (lfd < 0) { unlink(tmp); FatalError("Can't read lock file %s\n", LockFile); commit 656307e93a7c72b147805e3741ebb02baf876150 Author: Julien Cristau <jcristau at debian.org> Date: Sun Jan 23 13:35:54 2011 +0100 glx: Work around wrong request lengths sent by mesa mesa used to send too long requests for GLXDestroyPixmap, GLXDestroyWindow, GLXChangeDrawableAttributes, GLXGetDrawableAttributes and GLXGetFBConfigsSGIX. Fixes a regression introduced in ec9c97c6bf70b523bc500bd3adf62176f1bb33a4 X.Org bug#33324 <https://bugs.freedesktop.org/show_bug.cgi?id=33324> Reported-by: xunx.fang at intel.com Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit 402b329c3aa8ddbebaa1f593306a02d4cd6fed26) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index f42cce8..ce6aeb3 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1122,7 +1122,8 @@ int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + /* work around mesa bug, don't use REQUEST_SIZE_MATCH */ + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); return DoGetFBConfigs(cl, req->screen); } @@ -1346,7 +1347,9 @@ int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq); + /* should be REQUEST_SIZE_MATCH, but mesa's glXDestroyPixmap used to set + * length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyPixmapReq); return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } @@ -1478,7 +1481,13 @@ int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } +#if 0 + /* mesa sends an additional 8 bytes */ REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); +#else + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; +#endif return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); @@ -1540,7 +1549,8 @@ int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + /* mesa's glXDestroyWindow used to set length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW); } @@ -1849,7 +1859,8 @@ int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + /* this should be REQUEST_SIZE_MATCH, but mesa sends an additional 4 bytes */ + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); return DoGetDrawableAttributes(cl, req->drawable); } diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index c200244..5947e64 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -280,7 +280,7 @@ int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigsSGIX(cl, pc); @@ -369,7 +369,7 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyGLXPixmapReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -477,7 +477,9 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } - REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; + attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -543,7 +545,7 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); __GLX_SWAP_INT(&req->glxwindow); @@ -743,7 +745,7 @@ int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); commit c821bd84e594e86d5dd766f680064e88a29a10d1 Author: Julien Cristau <jcristau at debian.org> Date: Wed Jan 26 13:06:53 2011 +0100 glx: fix BindTexImageEXT length check The request is followed by a list of attributes. X.Org bug#33449 Reported-and-tested-by: meng <mengmeng.meng at intel.com> Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit 1137c11be0f82049d28024eaf963c6f76e0d4334) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index ff1249f..f42cce8 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1674,13 +1674,21 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) GLXDrawable drawId; int buffer; int error; + CARD32 num_attribs; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); buffer = *((INT32 *) (pc + 4)); + num_attribs = *((CARD32 *) (pc + 8)); + if (num_attribs > (UINT32_MAX >> 3)) { + client->errorValue = num_attribs; + return BadValue; + } + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 12 + (num_attribs << 3)); if (buffer != GLX_FRONT_LEFT_EXT) return __glXError(GLXBadPixmap); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index 1155b23..c200244 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -649,19 +649,23 @@ int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; + CARD32 *num_attribs; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); buffer = ((int *) (pc + 4)); + num_attribs = ((CARD32 *) (pc + 8)); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(drawId); __GLX_SWAP_INT(buffer); + __GLX_SWAP_INT(num_attribs); return __glXDisp_BindTexImageEXT(cl, (GLbyte *)pc); } commit 5b76d710d3cebbfb8a5f02eaa7920f73deadff21 Author: Julien Cristau <jcristau at debian.org> Date: Sun Jan 23 17:05:26 2011 +0100 glx: fix request length check for CreateGLXPbufferSGIX The request is followed by an attribute list. Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit a883cf1545abd89bb2cadfa659718884b56fd234) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 83469a5..ff1249f 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1416,7 +1416,7 @@ int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); return DoCreatePbuffer(cl->client, req->screen, req->fbconfig, req->width, req->height, req->pbuffer); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index a0e0882..1155b23 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -422,7 +422,7 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); commit 7ed56f793fe9bfe1fd2b70157523952cf6070fd8 Author: Julien Cristau <jcristau at debian.org> Date: Wed Nov 10 22:39:54 2010 +0100 glx: validate numAttribs field before using it Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit d9225b9602c85603ae616a7381c784f5cf5e811c) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index b8ee546..83469a5 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1273,6 +1273,11 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) __GLXscreen *pGlxScreen; int err; + REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) @@ -1376,6 +1381,11 @@ int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) CARD32 *attrs; int width, height, i; + REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attrs = (CARD32 *) (req + 1); @@ -1463,6 +1473,11 @@ int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); return DoChangeDrawableAttributes(cl->client, req->drawable, @@ -1475,6 +1490,11 @@ int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *)pc; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); return DoChangeDrawableAttributes(cl->client, req->drawable, @@ -1490,6 +1510,11 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw; int err; + REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index cbd9b88..a0e0882 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -320,6 +320,10 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->glxpixmap); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -401,6 +405,10 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->pbuffer); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -465,6 +473,10 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -487,6 +499,10 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -510,6 +526,10 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->glxwindow); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); commit 4f6ee6177c76d480fe2c477b0ca19ad337928373 Author: Julien Cristau <jcristau at debian.org> Date: Sun Aug 22 16:20:45 2010 +0100 glx: swap the request arrays entirely, not just half of them Various glx requests include a list of pairs of attributes. We were only swapping the first half. Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit 62319e8381ebd645ae36b25e5fc3c0e9b098387b) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index cca9843..cbd9b88 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -322,7 +322,7 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreatePixmap(cl, pc); } @@ -403,7 +403,7 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreatePbuffer(cl, pc); } @@ -467,7 +467,7 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_ChangeDrawableAttributes(cl, pc); } @@ -489,7 +489,7 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_ChangeDrawableAttributesSGIX(cl, pc); } @@ -512,7 +512,7 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreateWindow(cl, pc); } commit 00130263a222de904a4500c5410706aa5ec693dc Author: Julien Cristau <jcristau at debian.org> Date: Sun Aug 22 00:50:05 2010 +0100 glx: check request length before swapping Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit 6c69235a9dfc52e4b4e47630ff4bab1a820eb543) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index c414dc8..cca9843 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -61,9 +61,12 @@ int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->visual); @@ -75,9 +78,12 @@ int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateNewContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->fbconfig); @@ -90,10 +96,13 @@ int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->fbconfig); @@ -106,9 +115,12 @@ int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -117,9 +129,12 @@ int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->context); @@ -130,9 +145,12 @@ int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->readdrawable); @@ -144,9 +162,12 @@ int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->readable); @@ -158,9 +179,12 @@ int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXIsDirectReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -169,9 +193,12 @@ int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryVersionReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->majorVersion); __GLX_SWAP_INT(&req->minorVersion); @@ -181,9 +208,12 @@ int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXWaitGLReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -192,9 +222,12 @@ int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitXReq *req = (xGLXWaitXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXWaitXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -203,9 +236,12 @@ int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCopyContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->source); __GLX_SWAP_INT(&req->dest); @@ -216,36 +252,48 @@ int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetVisualConfigs(cl, pc); } int __glXDispSwap_GetFBConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigs(cl, pc); } int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigsSGIX(cl, pc); } int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->visual); @@ -257,17 +305,22 @@ int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; CARD32 *attribs; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pixmap); __GLX_SWAP_INT(&req->glxpixmap); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -276,10 +329,13 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapWithConfigSGIXReq *req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); @@ -291,9 +347,12 @@ int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -302,9 +361,12 @@ int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -313,9 +375,12 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryContextReq); + __GLX_SWAP_INT(&req->context); return __glXDisp_QueryContext(cl, pc); @@ -323,15 +388,20 @@ int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pbuffer); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -340,9 +410,12 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pbuffer); @@ -354,9 +427,12 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq); + __GLX_SWAP_INT(&req->pbuffer); return __glXDisp_DestroyPbuffer(cl, pc); @@ -364,9 +440,12 @@ int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq); + __GLX_SWAP_INT(&req->pbuffer); return __glXDisp_DestroyGLXPbufferSGIX(cl, pc); @@ -374,14 +453,19 @@ int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq); + __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -391,14 +475,19 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq); + __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -407,16 +496,21 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->window); __GLX_SWAP_INT(&req->glxwindow); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -425,9 +519,12 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + __GLX_SWAP_INT(&req->glxwindow); return __glXDisp_DestroyWindow(cl, pc); @@ -435,9 +532,12 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXSwapBuffersReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(&req->drawable); @@ -447,9 +547,12 @@ int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXUseXFontReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(&req->font); @@ -463,9 +566,12 @@ int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); @@ -474,9 +580,12 @@ int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryServerStringReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->name); @@ -486,9 +595,12 @@ int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->major); __GLX_SWAP_INT(&req->minor); @@ -499,9 +611,12 @@ int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -510,12 +625,14 @@ int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); @@ -531,12 +648,14 @@ int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); @@ -552,12 +671,14 @@ int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20); + (void) drawId; (void) buffer; @@ -577,11 +698,13 @@ int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc; CARD32 *data; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq); + data = (CARD32 *) (req + 1); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -592,10 +715,12 @@ int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); commit 6ff0bcfcc0eb02640456beacaaa93ee762c84507 Author: Julien Cristau <jcristau at debian.org> Date: Sat Jul 3 19:47:55 2010 +0100 glx: validate request lengths Reviewed-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry-picked from commit ec9c97c6bf70b523bc500bd3adf62176f1bb33a4) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 3eae1aa..b8ee546 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -312,11 +312,14 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId, int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateContextReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err)) @@ -328,11 +331,14 @@ int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateNewContextReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -344,12 +350,15 @@ int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -360,10 +369,13 @@ int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) } int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; __GLXcontext *glxc; int err; + REQUEST_SIZE_MATCH(xGLXDestroyContextReq); + if (!validGlxContext(cl->client, req->context, DixDestroyAccess, &glxc, &err)) return err; @@ -675,24 +687,33 @@ DoMakeCurrent(__GLXclientState *cl, int __glXDisp_MakeCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReq); + return DoMakeCurrent( cl, req->drawable, req->drawable, req->context, req->oldContextTag ); } int __glXDisp_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq); + return DoMakeCurrent( cl, req->drawable, req->readdrawable, req->context, req->oldContextTag ); } int __glXDisp_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq); + return DoMakeCurrent( cl, req->drawable, req->readable, req->context, req->oldContextTag ); } @@ -705,6 +726,8 @@ int __glXDisp_IsDirect(__GLXclientState *cl, GLbyte *pc) __GLXcontext *glxc; int err; + REQUEST_SIZE_MATCH(xGLXIsDirectReq); + if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err)) return err; @@ -729,6 +752,8 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc) xGLXQueryVersionReply reply; GLuint major, minor; + REQUEST_SIZE_MATCH(xGLXQueryVersionReq); + major = req->majorVersion; minor = req->minorVersion; (void)major; @@ -755,11 +780,15 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc; - GLXContextTag tag = req->contextTag; + GLXContextTag tag; __GLXcontext *glxc = NULL; int error; + REQUEST_SIZE_MATCH(xGLXWaitGLReq); + + tag = req->contextTag; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) @@ -779,11 +808,15 @@ int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitXReq *req = (xGLXWaitXReq *)pc; - GLXContextTag tag = req->contextTag; + GLXContextTag tag; __GLXcontext *glxc = NULL; int error; + REQUEST_SIZE_MATCH(xGLXWaitXReq); + + tag = req->contextTag; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) @@ -803,13 +836,19 @@ int __glXDisp_CopyContext(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc; - GLXContextID source = req->source; - GLXContextID dest = req->dest; - GLXContextTag tag = req->contextTag; - unsigned long mask = req->mask; + GLXContextID source; + GLXContextID dest; + GLXContextTag tag; + unsigned long mask; __GLXcontext *src, *dst; int error; + REQUEST_SIZE_MATCH(xGLXCopyContextReq); + + source = req->source; + dest = req->dest; + tag = req->contextTag; + mask = req->mask; if (!validGlxContext(cl->client, source, DixReadAccess, &src, &error)) return error; if (!validGlxContext(cl->client, dest, DixWriteAccess, &dst, &error)) @@ -892,6 +931,8 @@ int __glXDisp_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc) __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; @@ -1071,13 +1112,17 @@ DoGetFBConfigs(__GLXclientState *cl, unsigned screen) int __glXDisp_GetFBConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq); return DoGetFBConfigs(cl, req->screen); } int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); return DoGetFBConfigs(cl, req->screen); } @@ -1203,11 +1248,14 @@ determineTextureTarget(ClientPtr client, XID glxDrawableID, int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err)) @@ -1219,11 +1267,14 @@ int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -1242,12 +1293,15 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapWithConfigSGIXReq *req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -1274,15 +1328,21 @@ static int DoDestroyDrawable(__GLXclientState *cl, XID glxdrawable, int type) int __glXDisp_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq); + return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } @@ -1311,10 +1371,13 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId, int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; CARD32 *attrs; int width, height, i; + REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); + attrs = (CARD32 *) (req + 1); width = 0; height = 0; @@ -1340,23 +1403,32 @@ int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + return DoCreatePbuffer(cl->client, req->screen, req->fbconfig, req->width, req->height, req->pbuffer); } int __glXDisp_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq); + return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER); } int __glXDisp_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq); + return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER); } @@ -1387,18 +1459,24 @@ DoChangeDrawableAttributes(ClientPtr client, XID glxdrawable, int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); + return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); } int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *)pc; + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); + return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); } @@ -1412,6 +1490,8 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw; int err; + REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); + if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(client, pGlxScreen, req->fbconfig, &config, &err)) @@ -1432,8 +1512,11 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW); } @@ -1449,12 +1532,16 @@ int __glXDisp_SwapBuffers(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; - GLXContextTag tag = req->contextTag; - XID drawId = req->drawable; + GLXContextTag tag; + XID drawId; __GLXcontext *glxc = NULL; __GLXdrawable *pGlxDraw; int error; + REQUEST_SIZE_MATCH(xGLXSwapBuffersReq); + + tag = req->contextTag; + drawId = req->drawable; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) { @@ -1535,15 +1622,21 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId) int __glXDisp_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; + REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq); + return DoQueryContext(cl, req->context); } int __glXDisp_QueryContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; + REQUEST_SIZE_MATCH(xGLXQueryContextReq); + return DoQueryContext(cl, req->context); } @@ -1557,6 +1650,8 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) int buffer; int error; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1591,6 +1686,8 @@ int __glXDisp_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) int buffer; int error; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1626,6 +1723,8 @@ int __glXDisp_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) (void) client; (void) req; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1714,16 +1813,22 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId) int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + return DoGetDrawableAttributes(cl, req->drawable); } int __glXDisp_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesSGIXReq *req = (xGLXGetDrawableAttributesSGIXReq *)pc; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq); + return DoGetDrawableAttributes(cl, req->drawable); } @@ -1748,6 +1853,8 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) __GLXcontext *glxc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXRenderReq); + req = (xGLXRenderReq *) pc; if (client->swapped) { __GLX_SWAP_SHORT(&req->length); @@ -1768,6 +1875,9 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) __GLXdispatchRenderProcPtr proc; int err; + if (left < sizeof(__GLXrenderHeader)) + return BadLength; + /* ** Verify that the header length and the overall length agree. ** Also, each command must be word aligned. @@ -2278,10 +2388,12 @@ int __glXDisp_HyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLint vendorcode = req->vendorCode; __GLXdispatchVendorPrivProcPtr proc; + REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq); proc = (__GLXdispatchVendorPrivProcPtr) __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info, @@ -2297,10 +2409,12 @@ int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc) int __glXDisp_VendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLint vendorcode = req->vendorCode; __GLXdispatchVendorPrivProcPtr proc; + REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq); proc = (__GLXdispatchVendorPrivProcPtr) __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info, @@ -2323,6 +2437,8 @@ int __glXDisp_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) char *buf; int err; + REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq); + if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; @@ -2361,6 +2477,8 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc) __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXQueryServerStringReq); + if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; @@ -2404,14 +2522,20 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc) int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc; const char *buf; + REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq); + + buf = (const char *)(req+1); + if (!memchr(buf, 0, (client->req_len << 2) - sizeof(xGLXClientInfoReq))) + return BadLength; + cl->GLClientmajorVersion = req->major; cl->GLClientminorVersion = req->minor; if (cl->GLClientextensions) xfree(cl->GLClientextensions); - buf = (const char *)(req+1); cl->GLClientextensions = xstrdup(buf); return Success; diff --git a/glx/xfont.c b/glx/xfont.c index b8b466d..5d5b4c3 100644 --- a/glx/xfont.c +++ b/glx/xfont.c @@ -160,6 +160,8 @@ int __glXDisp_UseXFont(__GLXclientState *cl, GLbyte *pc) __GLXcontext *cx; int error; + REQUEST_SIZE_MATCH(xGLXUseXFontReq); + req = (xGLXUseXFontReq *) pc; cx = __glXForceCurrent(cl, req->contextTag, &error); if (!cx) { From jcristau at kemper.freedesktop.org Sat Oct 29 11:54:04 2011 From: jcristau at kemper.freedesktop.org (Julien Cristau) Date: Sat, 29 Oct 2011 11:54:04 -0700 (PDT) Subject: xserver: Branch 'server-1.8-branch' - 9 commits Message-ID: <20111029185404.CC8E61000F@kemper.freedesktop.org> glx/glxcmds.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++--- glx/glxcmdsswap.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++--- glx/xfont.c | 2 os/utils.c | 4 - 4 files changed, 341 insertions(+), 22 deletions(-) New commits: commit 630e4c93865ab892eec09d475d22596bbd8bd6fc Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:27:35 2011 +0200 Fix CVE-2011-4029: File permission change vulnerability. Use fchmod() to change permissions of the lock file instead of chmod(), thus avoid the race that can be exploited to set a symbolic link to any file or directory in the system. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit b67581cf825940fdf52bf2e0af4330e695d724a4) diff --git a/os/utils.c b/os/utils.c index 3b6c7cd..917b34f 100644 --- a/os/utils.c +++ b/os/utils.c @@ -315,7 +315,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* commit 4185af737d7ae9aeb90893ef93343f4672f3222c Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:26:12 2011 +0200 Fix CVE-2011-4028: File disclosure vulnerability. use O_NOFOLLOW to open the existing lock file, so symbolic links aren't followed, thus avoid revealing if it point to an existing file. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit 6ba44b91e37622ef8c146d8f2ac92d708a18ed34) diff --git a/os/utils.c b/os/utils.c index 13d3b3f..3b6c7cd 100644 --- a/os/utils.c +++ b/os/utils.c @@ -336,7 +336,7 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(LockFile, O_RDONLY|O_NOFOLLOW); if (lfd < 0) { unlink(tmp); FatalError("Can't read lock file %s\n", LockFile); commit d7ca4b7139ef05bf6562341bea75c58249b8586d Author: Julien Cristau <jcristau at debian.org> Date: Sun Jan 23 13:35:54 2011 +0100 glx: Work around wrong request lengths sent by mesa mesa used to send too long requests for GLXDestroyPixmap, GLXDestroyWindow, GLXChangeDrawableAttributes, GLXGetDrawableAttributes and GLXGetFBConfigsSGIX. Fixes a regression introduced in ec9c97c6bf70b523bc500bd3adf62176f1bb33a4 X.Org bug#33324 <https://bugs.freedesktop.org/show_bug.cgi?id=33324> Reported-by: xunx.fang at intel.com Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit 402b329c3aa8ddbebaa1f593306a02d4cd6fed26) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index f05e14d..2b5f0df 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1126,7 +1126,8 @@ int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + /* work around mesa bug, don't use REQUEST_SIZE_MATCH */ + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); return DoGetFBConfigs(cl, req->screen); } @@ -1350,7 +1351,9 @@ int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq); + /* should be REQUEST_SIZE_MATCH, but mesa's glXDestroyPixmap used to set + * length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyPixmapReq); return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } @@ -1492,7 +1495,13 @@ int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } +#if 0 + /* mesa sends an additional 8 bytes */ REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); +#else + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; +#endif return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); @@ -1555,7 +1564,8 @@ int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + /* mesa's glXDestroyWindow used to set length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW); } @@ -1864,7 +1874,8 @@ int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + /* this should be REQUEST_SIZE_MATCH, but mesa sends an additional 4 bytes */ + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); return DoGetDrawableAttributes(cl, req->drawable); } diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index c200244..5947e64 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -280,7 +280,7 @@ int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigsSGIX(cl, pc); @@ -369,7 +369,7 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyGLXPixmapReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -477,7 +477,9 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } - REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; + attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -543,7 +545,7 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); __GLX_SWAP_INT(&req->glxwindow); @@ -743,7 +745,7 @@ int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); commit e79160d403b7dd84be97ce1e851216cecb7efdac Author: Julien Cristau <jcristau at debian.org> Date: Wed Jan 26 13:06:53 2011 +0100 glx: fix BindTexImageEXT length check The request is followed by a list of attributes. X.Org bug#33449 Reported-and-tested-by: meng <mengmeng.meng at intel.com> Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit 1137c11be0f82049d28024eaf963c6f76e0d4334) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 46a77a9..f05e14d 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1689,13 +1689,21 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) GLXDrawable drawId; int buffer; int error; + CARD32 num_attribs; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); buffer = *((INT32 *) (pc + 4)); + num_attribs = *((CARD32 *) (pc + 8)); + if (num_attribs > (UINT32_MAX >> 3)) { + client->errorValue = num_attribs; + return BadValue; + } + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 12 + (num_attribs << 3)); if (buffer != GLX_FRONT_LEFT_EXT) return __glXError(GLXBadPixmap); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index 1155b23..c200244 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -649,19 +649,23 @@ int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; + CARD32 *num_attribs; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); buffer = ((int *) (pc + 4)); + num_attribs = ((CARD32 *) (pc + 8)); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(drawId); __GLX_SWAP_INT(buffer); + __GLX_SWAP_INT(num_attribs); return __glXDisp_BindTexImageEXT(cl, (GLbyte *)pc); } commit a1074ca98d6e8e1959614b2d10af98b296669381 Author: Julien Cristau <jcristau at debian.org> Date: Sun Jan 23 17:05:26 2011 +0100 glx: fix request length check for CreateGLXPbufferSGIX The request is followed by an attribute list. Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit a883cf1545abd89bb2cadfa659718884b56fd234) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 25f1060..46a77a9 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1430,7 +1430,7 @@ int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); return DoCreatePbuffer(cl->client, req->screen, req->fbconfig, req->width, req->height, req->pbuffer); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index a0e0882..1155b23 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -422,7 +422,7 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); commit 835c09ce5f612ad003953e88939458abf5d93ee6 Author: Julien Cristau <jcristau at debian.org> Date: Wed Nov 10 22:39:54 2010 +0100 glx: validate numAttribs field before using it Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit d9225b9602c85603ae616a7381c784f5cf5e811c) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 9725a15..25f1060 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1277,6 +1277,11 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) __GLXscreen *pGlxScreen; int err; + REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) @@ -1390,6 +1395,11 @@ int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) CARD32 *attrs; int width, height, i; + REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attrs = (CARD32 *) (req + 1); @@ -1477,6 +1487,11 @@ int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); return DoChangeDrawableAttributes(cl->client, req->drawable, @@ -1489,6 +1504,11 @@ int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *)pc; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); return DoChangeDrawableAttributes(cl->client, req->drawable, @@ -1504,6 +1524,11 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw; int err; + REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index cbd9b88..a0e0882 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -320,6 +320,10 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->glxpixmap); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -401,6 +405,10 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->pbuffer); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -465,6 +473,10 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -487,6 +499,10 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -510,6 +526,10 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->glxwindow); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); commit a02149cbad8f65a7bdd697213176732f105eaace Author: Julien Cristau <jcristau at debian.org> Date: Sun Aug 22 16:20:45 2010 +0100 glx: swap the request arrays entirely, not just half of them Various glx requests include a list of pairs of attributes. We were only swapping the first half. Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit 62319e8381ebd645ae36b25e5fc3c0e9b098387b) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index cca9843..cbd9b88 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -322,7 +322,7 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreatePixmap(cl, pc); } @@ -403,7 +403,7 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreatePbuffer(cl, pc); } @@ -467,7 +467,7 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_ChangeDrawableAttributes(cl, pc); } @@ -489,7 +489,7 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_ChangeDrawableAttributesSGIX(cl, pc); } @@ -512,7 +512,7 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreateWindow(cl, pc); } commit 541f459a9e760f811ce896d098815f9a8157daa2 Author: Julien Cristau <jcristau at debian.org> Date: Sun Aug 22 00:50:05 2010 +0100 glx: check request length before swapping Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit 6c69235a9dfc52e4b4e47630ff4bab1a820eb543) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index c414dc8..cca9843 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -61,9 +61,12 @@ int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->visual); @@ -75,9 +78,12 @@ int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateNewContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->fbconfig); @@ -90,10 +96,13 @@ int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->fbconfig); @@ -106,9 +115,12 @@ int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -117,9 +129,12 @@ int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->context); @@ -130,9 +145,12 @@ int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->readdrawable); @@ -144,9 +162,12 @@ int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->readable); @@ -158,9 +179,12 @@ int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXIsDirectReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -169,9 +193,12 @@ int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryVersionReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->majorVersion); __GLX_SWAP_INT(&req->minorVersion); @@ -181,9 +208,12 @@ int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXWaitGLReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -192,9 +222,12 @@ int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitXReq *req = (xGLXWaitXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXWaitXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -203,9 +236,12 @@ int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCopyContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->source); __GLX_SWAP_INT(&req->dest); @@ -216,36 +252,48 @@ int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetVisualConfigs(cl, pc); } int __glXDispSwap_GetFBConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigs(cl, pc); } int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigsSGIX(cl, pc); } int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->visual); @@ -257,17 +305,22 @@ int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; CARD32 *attribs; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pixmap); __GLX_SWAP_INT(&req->glxpixmap); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -276,10 +329,13 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapWithConfigSGIXReq *req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); @@ -291,9 +347,12 @@ int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -302,9 +361,12 @@ int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -313,9 +375,12 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryContextReq); + __GLX_SWAP_INT(&req->context); return __glXDisp_QueryContext(cl, pc); @@ -323,15 +388,20 @@ int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pbuffer); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -340,9 +410,12 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pbuffer); @@ -354,9 +427,12 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq); + __GLX_SWAP_INT(&req->pbuffer); return __glXDisp_DestroyPbuffer(cl, pc); @@ -364,9 +440,12 @@ int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq); + __GLX_SWAP_INT(&req->pbuffer); return __glXDisp_DestroyGLXPbufferSGIX(cl, pc); @@ -374,14 +453,19 @@ int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq); + __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -391,14 +475,19 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq); + __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -407,16 +496,21 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->window); __GLX_SWAP_INT(&req->glxwindow); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -425,9 +519,12 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + __GLX_SWAP_INT(&req->glxwindow); return __glXDisp_DestroyWindow(cl, pc); @@ -435,9 +532,12 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXSwapBuffersReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(&req->drawable); @@ -447,9 +547,12 @@ int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXUseXFontReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(&req->font); @@ -463,9 +566,12 @@ int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); @@ -474,9 +580,12 @@ int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryServerStringReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->name); @@ -486,9 +595,12 @@ int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->major); __GLX_SWAP_INT(&req->minor); @@ -499,9 +611,12 @@ int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -510,12 +625,14 @@ int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); @@ -531,12 +648,14 @@ int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); @@ -552,12 +671,14 @@ int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20); + (void) drawId; (void) buffer; @@ -577,11 +698,13 @@ int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc; CARD32 *data; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq); + data = (CARD32 *) (req + 1); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -592,10 +715,12 @@ int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); commit 036b157f9fd6edefd5eb38deda8363667c443e22 Author: Julien Cristau <jcristau at debian.org> Date: Sat Jul 3 19:47:55 2010 +0100 glx: validate request lengths Reviewed-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry-picked from commit ec9c97c6bf70b523bc500bd3adf62176f1bb33a4) Conflicts: glx/glxcmds.c diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 34829dd..9725a15 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -315,11 +315,14 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId, int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateContextReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err)) @@ -331,11 +334,14 @@ int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateNewContextReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -347,12 +353,15 @@ int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -363,10 +372,13 @@ int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) } int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; __GLXcontext *glxc; int err; + REQUEST_SIZE_MATCH(xGLXDestroyContextReq); + if (!validGlxContext(cl->client, req->context, DixDestroyAccess, &glxc, &err)) return err; @@ -679,24 +691,33 @@ DoMakeCurrent(__GLXclientState *cl, int __glXDisp_MakeCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReq); + return DoMakeCurrent( cl, req->drawable, req->drawable, req->context, req->oldContextTag ); } int __glXDisp_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq); + return DoMakeCurrent( cl, req->drawable, req->readdrawable, req->context, req->oldContextTag ); } int __glXDisp_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq); + return DoMakeCurrent( cl, req->drawable, req->readable, req->context, req->oldContextTag ); } @@ -709,6 +730,8 @@ int __glXDisp_IsDirect(__GLXclientState *cl, GLbyte *pc) __GLXcontext *glxc; int err; + REQUEST_SIZE_MATCH(xGLXIsDirectReq); + if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err)) return err; @@ -733,6 +756,8 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc) xGLXQueryVersionReply reply; GLuint major, minor; + REQUEST_SIZE_MATCH(xGLXQueryVersionReq); + major = req->majorVersion; minor = req->minorVersion; (void)major; @@ -759,11 +784,15 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc; - GLXContextTag tag = req->contextTag; + GLXContextTag tag; __GLXcontext *glxc = NULL; int error; + REQUEST_SIZE_MATCH(xGLXWaitGLReq); + + tag = req->contextTag; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) @@ -783,11 +812,15 @@ int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitXReq *req = (xGLXWaitXReq *)pc; - GLXContextTag tag = req->contextTag; + GLXContextTag tag; __GLXcontext *glxc = NULL; int error; + REQUEST_SIZE_MATCH(xGLXWaitXReq); + + tag = req->contextTag; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) @@ -807,13 +840,19 @@ int __glXDisp_CopyContext(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc; - GLXContextID source = req->source; - GLXContextID dest = req->dest; - GLXContextTag tag = req->contextTag; - unsigned long mask = req->mask; + GLXContextID source; + GLXContextID dest; + GLXContextTag tag; + unsigned long mask; __GLXcontext *src, *dst; int error; + REQUEST_SIZE_MATCH(xGLXCopyContextReq); + + source = req->source; + dest = req->dest; + tag = req->contextTag; + mask = req->mask; if (!validGlxContext(cl->client, source, DixReadAccess, &src, &error)) return error; if (!validGlxContext(cl->client, dest, DixWriteAccess, &dst, &error)) @@ -896,6 +935,8 @@ int __glXDisp_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc) __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; @@ -1075,13 +1116,17 @@ DoGetFBConfigs(__GLXclientState *cl, unsigned screen) int __glXDisp_GetFBConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq); return DoGetFBConfigs(cl, req->screen); } int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); return DoGetFBConfigs(cl, req->screen); } @@ -1207,11 +1252,14 @@ determineTextureTarget(ClientPtr client, XID glxDrawableID, int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err)) @@ -1223,11 +1271,14 @@ int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -1246,12 +1297,15 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapWithConfigSGIXReq *req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -1278,15 +1332,21 @@ static int DoDestroyDrawable(__GLXclientState *cl, XID glxdrawable, int type) int __glXDisp_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq); + return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } @@ -1325,10 +1385,13 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId, int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; CARD32 *attrs; int width, height, i; + REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); + attrs = (CARD32 *) (req + 1); width = 0; height = 0; @@ -1354,23 +1417,32 @@ int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + return DoCreatePbuffer(cl->client, req->screen, req->fbconfig, req->width, req->height, req->pbuffer); } int __glXDisp_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq); + return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER); } int __glXDisp_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq); + return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER); } @@ -1401,18 +1473,24 @@ DoChangeDrawableAttributes(ClientPtr client, XID glxdrawable, int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); + return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); } int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *)pc; + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); + return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); } @@ -1426,7 +1504,7 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw; int err; - LEGAL_NEW_RESOURCE(req->glxwindow, client); + REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; @@ -1449,8 +1527,11 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW); } @@ -1466,12 +1547,16 @@ int __glXDisp_SwapBuffers(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; - GLXContextTag tag = req->contextTag; - XID drawId = req->drawable; + GLXContextTag tag; + XID drawId; __GLXcontext *glxc = NULL; __GLXdrawable *pGlxDraw; int error; + REQUEST_SIZE_MATCH(xGLXSwapBuffersReq); + + tag = req->contextTag; + drawId = req->drawable; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) { @@ -1552,15 +1637,21 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId) int __glXDisp_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; + REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq); + return DoQueryContext(cl, req->context); } int __glXDisp_QueryContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; + REQUEST_SIZE_MATCH(xGLXQueryContextReq); + return DoQueryContext(cl, req->context); } @@ -1574,6 +1665,8 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) int buffer; int error; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1608,6 +1701,8 @@ int __glXDisp_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) int buffer; int error; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1643,6 +1738,8 @@ int __glXDisp_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) (void) client; (void) req; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1731,16 +1828,22 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId) int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + return DoGetDrawableAttributes(cl, req->drawable); } int __glXDisp_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesSGIXReq *req = (xGLXGetDrawableAttributesSGIXReq *)pc; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq); + return DoGetDrawableAttributes(cl, req->drawable); } @@ -1765,6 +1868,8 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) __GLXcontext *glxc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXRenderReq); + req = (xGLXRenderReq *) pc; if (client->swapped) { __GLX_SWAP_SHORT(&req->length); @@ -1785,6 +1890,9 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) __GLXdispatchRenderProcPtr proc; int err; + if (left < sizeof(__GLXrenderHeader)) + return BadLength; + /* ** Verify that the header length and the overall length agree. ** Also, each command must be word aligned. @@ -2295,10 +2403,12 @@ int __glXDisp_HyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLint vendorcode = req->vendorCode; __GLXdispatchVendorPrivProcPtr proc; + REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq); proc = (__GLXdispatchVendorPrivProcPtr) __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info, @@ -2314,10 +2424,12 @@ int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc) int __glXDisp_VendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLint vendorcode = req->vendorCode; __GLXdispatchVendorPrivProcPtr proc; + REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq); proc = (__GLXdispatchVendorPrivProcPtr) __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info, @@ -2340,6 +2452,8 @@ int __glXDisp_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) char *buf; int err; + REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq); + if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; @@ -2379,6 +2493,8 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc) int err; char ver_str[16]; + REQUEST_SIZE_MATCH(xGLXQueryServerStringReq); + if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; @@ -2426,14 +2542,20 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc) int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc; const char *buf; + REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq); + + buf = (const char *)(req+1); + if (!memchr(buf, 0, (client->req_len << 2) - sizeof(xGLXClientInfoReq))) + return BadLength; + cl->GLClientmajorVersion = req->major; cl->GLClientminorVersion = req->minor; if (cl->GLClientextensions) xfree(cl->GLClientextensions); - buf = (const char *)(req+1); cl->GLClientextensions = xstrdup(buf); return Success; diff --git a/glx/xfont.c b/glx/xfont.c index b8b466d..5d5b4c3 100644 --- a/glx/xfont.c +++ b/glx/xfont.c @@ -160,6 +160,8 @@ int __glXDisp_UseXFont(__GLXclientState *cl, GLbyte *pc) __GLXcontext *cx; int error; + REQUEST_SIZE_MATCH(xGLXUseXFontReq); + req = (xGLXUseXFontReq *) pc; cx = __glXForceCurrent(cl, req->contextTag, &error); if (!cx) { From jcristau at kemper.freedesktop.org Sat Oct 29 11:54:05 2011 From: jcristau at kemper.freedesktop.org (Julien Cristau) Date: Sat, 29 Oct 2011 11:54:05 -0700 (PDT) Subject: xserver: Branch 'server-1.9-branch' - 9 commits Message-ID: <20111029185405.189BC10010@kemper.freedesktop.org> glx/glxcmds.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++--- glx/glxcmdsswap.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++--- glx/xfont.c | 2 os/utils.c | 4 - 4 files changed, 342 insertions(+), 21 deletions(-) New commits: commit e9ffc3a5f9414cdc4c3e5b8bf25fefe4f01cf725 Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:27:35 2011 +0200 Fix CVE-2011-4029: File permission change vulnerability. Use fchmod() to change permissions of the lock file instead of chmod(), thus avoid the race that can be exploited to set a symbolic link to any file or directory in the system. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit b67581cf825940fdf52bf2e0af4330e695d724a4) diff --git a/os/utils.c b/os/utils.c index 575998f..de6476a 100644 --- a/os/utils.c +++ b/os/utils.c @@ -306,7 +306,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* commit 1fec281b0daa21f39e98855872e35fbaeb5ec0bb Author: Matthieu Herrb <matthieu.herrb at laas.fr> Date: Mon Oct 17 22:26:12 2011 +0200 Fix CVE-2011-4028: File disclosure vulnerability. use O_NOFOLLOW to open the existing lock file, so symbolic links aren't followed, thus avoid revealing if it point to an existing file. Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com> (cherry picked from commit 6ba44b91e37622ef8c146d8f2ac92d708a18ed34) diff --git a/os/utils.c b/os/utils.c index 193992d..575998f 100644 --- a/os/utils.c +++ b/os/utils.c @@ -327,7 +327,7 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(LockFile, O_RDONLY|O_NOFOLLOW); if (lfd < 0) { unlink(tmp); FatalError("Can't read lock file %s\n", LockFile); commit 99520ddbb1a46e144fd35768ba1ba45067d784ff Author: Julien Cristau <jcristau at debian.org> Date: Sun Jan 23 13:35:54 2011 +0100 glx: Work around wrong request lengths sent by mesa mesa used to send too long requests for GLXDestroyPixmap, GLXDestroyWindow, GLXChangeDrawableAttributes, GLXGetDrawableAttributes and GLXGetFBConfigsSGIX. Fixes a regression introduced in ec9c97c6bf70b523bc500bd3adf62176f1bb33a4 X.Org bug#33324 <https://bugs.freedesktop.org/show_bug.cgi?id=33324> Reported-by: xunx.fang at intel.com Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit 402b329c3aa8ddbebaa1f593306a02d4cd6fed26) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index e513916..06e7755 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1133,7 +1133,8 @@ int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + /* work around mesa bug, don't use REQUEST_SIZE_MATCH */ + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); return DoGetFBConfigs(cl, req->screen); } @@ -1357,7 +1358,9 @@ int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq); + /* should be REQUEST_SIZE_MATCH, but mesa's glXDestroyPixmap used to set + * length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyPixmapReq); return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } @@ -1499,7 +1502,13 @@ int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } +#if 0 + /* mesa sends an additional 8 bytes */ REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); +#else + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; +#endif return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); @@ -1564,7 +1573,8 @@ int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + /* mesa's glXDestroyWindow used to set length to 3 instead of 2 */ + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW); } @@ -1873,7 +1883,8 @@ int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + /* this should be REQUEST_SIZE_MATCH, but mesa sends an additional 4 bytes */ + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); return DoGetDrawableAttributes(cl, req->drawable); } diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index c200244..5947e64 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -280,7 +280,7 @@ int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq); __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigsSGIX(cl, pc); @@ -369,7 +369,7 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyGLXPixmapReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -477,7 +477,9 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) client->errorValue = req->numAttribs; return BadValue; } - REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); + if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len) + return BadLength; + attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -543,7 +545,7 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq); __GLX_SWAP_INT(&req->glxwindow); @@ -743,7 +745,7 @@ int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); commit d6831f5aa16bc9ceca6684bd624bb75bcc31c4f5 Author: Julien Cristau <jcristau at debian.org> Date: Wed Jan 26 13:06:53 2011 +0100 glx: fix BindTexImageEXT length check The request is followed by a list of attributes. X.Org bug#33449 Reported-and-tested-by: meng <mengmeng.meng at intel.com> Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit 1137c11be0f82049d28024eaf963c6f76e0d4334) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 5746a23..e513916 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1698,13 +1698,21 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) GLXDrawable drawId; int buffer; int error; + CARD32 num_attribs; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); buffer = *((INT32 *) (pc + 4)); + num_attribs = *((CARD32 *) (pc + 8)); + if (num_attribs > (UINT32_MAX >> 3)) { + client->errorValue = num_attribs; + return BadValue; + } + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 12 + (num_attribs << 3)); if (buffer != GLX_FRONT_LEFT_EXT) return __glXError(GLXBadPixmap); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index 1155b23..c200244 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -649,19 +649,23 @@ int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; + CARD32 *num_attribs; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len) + return BadLength; pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); buffer = ((int *) (pc + 4)); + num_attribs = ((CARD32 *) (pc + 8)); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(drawId); __GLX_SWAP_INT(buffer); + __GLX_SWAP_INT(num_attribs); return __glXDisp_BindTexImageEXT(cl, (GLbyte *)pc); } commit 5f3e015ae0f09fda242485df282ef2b546305b12 Author: Julien Cristau <jcristau at debian.org> Date: Sun Jan 23 17:05:26 2011 +0100 glx: fix request length check for CreateGLXPbufferSGIX The request is followed by an attribute list. Signed-off-by: Julien Cristau <jcristau at debian.org> Reviewed-by: Adam Jackson <ajax at redhat.com> (cherry picked from commit a883cf1545abd89bb2cadfa659718884b56fd234) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 40934de..5746a23 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1437,7 +1437,7 @@ int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); return DoCreatePbuffer(cl->client, req->screen, req->fbconfig, req->width, req->height, req->pbuffer); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index a0e0882..1155b23 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -422,7 +422,7 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; - REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); commit d22de252621e09ead235001af4e09c4c83c2626f Author: Julien Cristau <jcristau at debian.org> Date: Wed Nov 10 22:39:54 2010 +0100 glx: validate numAttribs field before using it Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit d9225b9602c85603ae616a7381c784f5cf5e811c) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 1973ada..40934de 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1284,6 +1284,11 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) __GLXscreen *pGlxScreen; int err; + REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) @@ -1397,6 +1402,11 @@ int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) CARD32 *attrs; int width, height, i; + REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attrs = (CARD32 *) (req + 1); @@ -1484,6 +1494,11 @@ int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); return DoChangeDrawableAttributes(cl->client, req->drawable, @@ -1496,6 +1511,11 @@ int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *)pc; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); return DoChangeDrawableAttributes(cl->client, req->drawable, @@ -1511,6 +1531,11 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw; int err; + REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); LEGAL_NEW_RESOURCE(req->glxwindow, client); diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index cbd9b88..a0e0882 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -320,6 +320,10 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->glxpixmap); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -401,6 +405,10 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->pbuffer); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -465,6 +473,10 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -487,6 +499,10 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); @@ -510,6 +526,10 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->glxwindow); __GLX_SWAP_INT(&req->numAttribs); + if (req->numAttribs > (UINT32_MAX >> 3)) { + client->errorValue = req->numAttribs; + return BadValue; + } REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); commit 83f5faba544257193e4c4c2457429115d7264a37 Author: Julien Cristau <jcristau at debian.org> Date: Sun Aug 22 16:20:45 2010 +0100 glx: swap the request arrays entirely, not just half of them Various glx requests include a list of pairs of attributes. We were only swapping the first half. Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit 62319e8381ebd645ae36b25e5fc3c0e9b098387b) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index cca9843..cbd9b88 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -322,7 +322,7 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreatePixmap(cl, pc); } @@ -403,7 +403,7 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreatePbuffer(cl, pc); } @@ -467,7 +467,7 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_ChangeDrawableAttributes(cl, pc); } @@ -489,7 +489,7 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_ChangeDrawableAttributesSGIX(cl, pc); } @@ -512,7 +512,7 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); - __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); + __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1); return __glXDisp_CreateWindow(cl, pc); } commit 4ecf6e2ca9d331cc6fd803a17f0d2e55ecc38f01 Author: Julien Cristau <jcristau at debian.org> Date: Sun Aug 22 00:50:05 2010 +0100 glx: check request length before swapping Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit 6c69235a9dfc52e4b4e47630ff4bab1a820eb543) diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c index c414dc8..cca9843 100644 --- a/glx/glxcmdsswap.c +++ b/glx/glxcmdsswap.c @@ -61,9 +61,12 @@ int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->visual); @@ -75,9 +78,12 @@ int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateNewContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->fbconfig); @@ -90,10 +96,13 @@ int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->fbconfig); @@ -106,9 +115,12 @@ int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -117,9 +129,12 @@ int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->context); @@ -130,9 +145,12 @@ int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->readdrawable); @@ -144,9 +162,12 @@ int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->readable); @@ -158,9 +179,12 @@ int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXIsDirectReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -169,9 +193,12 @@ int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryVersionReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->majorVersion); __GLX_SWAP_INT(&req->minorVersion); @@ -181,9 +208,12 @@ int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXWaitGLReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -192,9 +222,12 @@ int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitXReq *req = (xGLXWaitXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXWaitXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -203,9 +236,12 @@ int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCopyContextReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->source); __GLX_SWAP_INT(&req->dest); @@ -216,36 +252,48 @@ int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetVisualConfigs(cl, pc); } int __glXDispSwap_GetFBConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigs(cl, pc); } int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); + __GLX_SWAP_INT(&req->screen); return __glXDisp_GetFBConfigsSGIX(cl, pc); } int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->visual); @@ -257,17 +305,22 @@ int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; CARD32 *attribs; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pixmap); __GLX_SWAP_INT(&req->glxpixmap); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -276,10 +329,13 @@ int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapWithConfigSGIXReq *req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); @@ -291,9 +347,12 @@ int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -302,9 +361,12 @@ int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->glxpixmap); @@ -313,9 +375,12 @@ int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryContextReq); + __GLX_SWAP_INT(&req->context); return __glXDisp_QueryContext(cl, pc); @@ -323,15 +388,20 @@ int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pbuffer); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -340,9 +410,12 @@ int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->pbuffer); @@ -354,9 +427,12 @@ int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq); + __GLX_SWAP_INT(&req->pbuffer); return __glXDisp_DestroyPbuffer(cl, pc); @@ -364,9 +440,12 @@ int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq); + __GLX_SWAP_INT(&req->pbuffer); return __glXDisp_DestroyGLXPbufferSGIX(cl, pc); @@ -374,14 +453,19 @@ int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq); + __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -391,14 +475,19 @@ int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq); + __GLX_SWAP_INT(&req->drawable); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -407,16 +496,21 @@ int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl, int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; CARD32 *attribs; + REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq); + __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->fbconfig); __GLX_SWAP_INT(&req->window); __GLX_SWAP_INT(&req->glxwindow); __GLX_SWAP_INT(&req->numAttribs); + + REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); attribs = (CARD32*)(req + 1); __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs); @@ -425,9 +519,12 @@ int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + __GLX_SWAP_INT(&req->glxwindow); return __glXDisp_DestroyWindow(cl, pc); @@ -435,9 +532,12 @@ int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXSwapBuffersReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(&req->drawable); @@ -447,9 +547,12 @@ int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXUseXFontReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(&req->font); @@ -463,9 +566,12 @@ int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); @@ -474,9 +580,12 @@ int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryServerStringReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->name); @@ -486,9 +595,12 @@ int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->major); __GLX_SWAP_INT(&req->minor); @@ -499,9 +611,12 @@ int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); @@ -510,12 +625,14 @@ int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); @@ -531,12 +648,14 @@ int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = ((GLXDrawable *) (pc)); @@ -552,12 +671,14 @@ int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLXDrawable *drawId; int *buffer; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20); + (void) drawId; (void) buffer; @@ -577,11 +698,13 @@ int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc; CARD32 *data; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq); + data = (CARD32 *) (req + 1); __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->contextTag); @@ -592,10 +715,12 @@ int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; - __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->drawable); commit 6255419c3c8d6ae0f3f9c4a7f65a458be59b6982 Author: Julien Cristau <jcristau at debian.org> Date: Sat Jul 3 19:47:55 2010 +0100 glx: validate request lengths Reviewed-by: Adam Jackson <ajax at redhat.com> Reviewed-by: Kristian H??gsberg <krh at bitplanet.net> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Signed-off-by: Julien Cristau <jcristau at debian.org> (cherry picked from commit ec9c97c6bf70b523bc500bd3adf62176f1bb33a4) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 9e32d6c..1973ada 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -315,11 +315,14 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId, int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateContextReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err)) @@ -331,11 +334,14 @@ int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateNewContextReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -347,12 +353,15 @@ int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -363,10 +372,13 @@ int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) } int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; __GLXcontext *glxc; int err; + REQUEST_SIZE_MATCH(xGLXDestroyContextReq); + if (!validGlxContext(cl->client, req->context, DixDestroyAccess, &glxc, &err)) return err; @@ -686,24 +698,33 @@ DoMakeCurrent(__GLXclientState *cl, int __glXDisp_MakeCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReq); + return DoMakeCurrent( cl, req->drawable, req->drawable, req->context, req->oldContextTag ); } int __glXDisp_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq); + return DoMakeCurrent( cl, req->drawable, req->readdrawable, req->context, req->oldContextTag ); } int __glXDisp_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; + REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq); + return DoMakeCurrent( cl, req->drawable, req->readable, req->context, req->oldContextTag ); } @@ -716,6 +737,8 @@ int __glXDisp_IsDirect(__GLXclientState *cl, GLbyte *pc) __GLXcontext *glxc; int err; + REQUEST_SIZE_MATCH(xGLXIsDirectReq); + if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err)) return err; @@ -740,6 +763,8 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc) xGLXQueryVersionReply reply; GLuint major, minor; + REQUEST_SIZE_MATCH(xGLXQueryVersionReq); + major = req->majorVersion; minor = req->minorVersion; (void)major; @@ -766,11 +791,15 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc; - GLXContextTag tag = req->contextTag; + GLXContextTag tag; __GLXcontext *glxc = NULL; int error; + REQUEST_SIZE_MATCH(xGLXWaitGLReq); + + tag = req->contextTag; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) @@ -790,11 +819,15 @@ int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXWaitXReq *req = (xGLXWaitXReq *)pc; - GLXContextTag tag = req->contextTag; + GLXContextTag tag; __GLXcontext *glxc = NULL; int error; + REQUEST_SIZE_MATCH(xGLXWaitXReq); + + tag = req->contextTag; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) @@ -814,13 +847,19 @@ int __glXDisp_CopyContext(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc; - GLXContextID source = req->source; - GLXContextID dest = req->dest; - GLXContextTag tag = req->contextTag; - unsigned long mask = req->mask; + GLXContextID source; + GLXContextID dest; + GLXContextTag tag; + unsigned long mask; __GLXcontext *src, *dst; int error; + REQUEST_SIZE_MATCH(xGLXCopyContextReq); + + source = req->source; + dest = req->dest; + tag = req->contextTag; + mask = req->mask; if (!validGlxContext(cl->client, source, DixReadAccess, &src, &error)) return error; if (!validGlxContext(cl->client, dest, DixWriteAccess, &dst, &error)) @@ -903,6 +942,8 @@ int __glXDisp_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc) __GLX_DECLARE_SWAP_VARIABLES; __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; @@ -1082,13 +1123,17 @@ DoGetFBConfigs(__GLXclientState *cl, unsigned screen) int __glXDisp_GetFBConfigs(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq); return DoGetFBConfigs(cl, req->screen); } int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq); return DoGetFBConfigs(cl, req->screen); } @@ -1214,11 +1259,14 @@ determineTextureTarget(ClientPtr client, XID glxDrawableID, int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err)) @@ -1230,11 +1278,14 @@ int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -1253,12 +1304,15 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPixmapWithConfigSGIXReq *req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; __GLXconfig *config; __GLXscreen *pGlxScreen; int err; + REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq); + if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err)) return err; if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err)) @@ -1285,15 +1339,21 @@ static int DoDestroyDrawable(__GLXclientState *cl, XID glxdrawable, int type) int __glXDisp_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq); + return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq); + return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP); } @@ -1332,10 +1392,13 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId, int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; CARD32 *attrs; int width, height, i; + REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3); + attrs = (CARD32 *) (req + 1); width = 0; height = 0; @@ -1361,23 +1424,32 @@ int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc) int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq); + return DoCreatePbuffer(cl->client, req->screen, req->fbconfig, req->width, req->height, req->pbuffer); } int __glXDisp_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq); + return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER); } int __glXDisp_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq); + return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER); } @@ -1408,18 +1480,24 @@ DoChangeDrawableAttributes(ClientPtr client, XID glxdrawable, int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *) pc; + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3); + return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); } int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXChangeDrawableAttributesSGIXReq *req = (xGLXChangeDrawableAttributesSGIXReq *)pc; + REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3); + return DoChangeDrawableAttributes(cl->client, req->drawable, req->numAttribs, (CARD32 *) (req + 1)); } @@ -1433,6 +1511,8 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) DrawablePtr pDraw; int err; + REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3); + LEGAL_NEW_RESOURCE(req->glxwindow, client); if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) @@ -1456,8 +1536,11 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc) int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; + REQUEST_SIZE_MATCH(xGLXDestroyWindowReq); + return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW); } @@ -1473,12 +1556,16 @@ int __glXDisp_SwapBuffers(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; - GLXContextTag tag = req->contextTag; - XID drawId = req->drawable; + GLXContextTag tag; + XID drawId; __GLXcontext *glxc = NULL; __GLXdrawable *pGlxDraw; int error; + REQUEST_SIZE_MATCH(xGLXSwapBuffersReq); + + tag = req->contextTag; + drawId = req->drawable; if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) { @@ -1559,15 +1646,21 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId) int __glXDisp_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; + REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq); + return DoQueryContext(cl, req->context); } int __glXDisp_QueryContext(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; + REQUEST_SIZE_MATCH(xGLXQueryContextReq); + return DoQueryContext(cl, req->context); } @@ -1581,6 +1674,8 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) int buffer; int error; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1615,6 +1710,8 @@ int __glXDisp_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) int buffer; int error; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1650,6 +1747,8 @@ int __glXDisp_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc) (void) client; (void) req; + REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20); + pc += __GLX_VENDPRIV_HDR_SIZE; drawId = *((CARD32 *) (pc)); @@ -1738,16 +1837,22 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId) int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq); + return DoGetDrawableAttributes(cl, req->drawable); } int __glXDisp_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXGetDrawableAttributesSGIXReq *req = (xGLXGetDrawableAttributesSGIXReq *)pc; + REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq); + return DoGetDrawableAttributes(cl, req->drawable); } @@ -1772,6 +1877,8 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) __GLXcontext *glxc; __GLX_DECLARE_SWAP_VARIABLES; + REQUEST_AT_LEAST_SIZE(xGLXRenderReq); + req = (xGLXRenderReq *) pc; if (client->swapped) { __GLX_SWAP_SHORT(&req->length); @@ -1792,6 +1899,9 @@ int __glXDisp_Render(__GLXclientState *cl, GLbyte *pc) __GLXdispatchRenderProcPtr proc; int err; + if (left < sizeof(__GLXrenderHeader)) + return BadLength; + /* ** Verify that the header length and the overall length agree. ** Also, each command must be word aligned. @@ -2302,10 +2412,12 @@ int __glXDisp_HyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc) int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLint vendorcode = req->vendorCode; __GLXdispatchVendorPrivProcPtr proc; + REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq); proc = (__GLXdispatchVendorPrivProcPtr) __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info, @@ -2321,10 +2433,12 @@ int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc) int __glXDisp_VendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; GLint vendorcode = req->vendorCode; __GLXdispatchVendorPrivProcPtr proc; + REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq); proc = (__GLXdispatchVendorPrivProcPtr) __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info, @@ -2347,6 +2461,8 @@ int __glXDisp_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc) char *buf; int err; + REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq); + if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; @@ -2386,6 +2502,8 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc) int err; char ver_str[16]; + REQUEST_SIZE_MATCH(xGLXQueryServerStringReq); + if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; @@ -2433,13 +2551,19 @@ int __glXDisp_QueryServerString(__GLXclientState *cl, GLbyte *pc) int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc) { + ClientPtr client = cl->client; xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc; const char *buf; + REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq); + + buf = (const char *)(req+1); + if (!memchr(buf, 0, (client->req_len << 2) - sizeof(xGLXClientInfoReq))) + return BadLength; + cl->GLClientmajorVersion = req->major; cl->GLClientminorVersion = req->minor; free(cl->GLClientextensions); - buf = (const char *)(req+1); cl->GLClientextensions = strdup(buf); return Success; diff --git a/glx/xfont.c b/glx/xfont.c index b4081cf..eafac01 100644 --- a/glx/xfont.c +++ b/glx/xfont.c @@ -155,6 +155,8 @@ int __glXDisp_UseXFont(__GLXclientState *cl, GLbyte *pc) __GLXcontext *cx; int error; + REQUEST_SIZE_MATCH(xGLXUseXFontReq); + req = (xGLXUseXFontReq *) pc; cx = __glXForceCurrent(cl, req->contextTag, &error); if (!cx) { From ickle at kemper.freedesktop.org Sat Oct 29 12:08:48 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sat, 29 Oct 2011 12:08:48 -0700 (PDT) Subject: xf86-video-intel: src/sna/gen3_render.c Message-ID: <20111029190849.6A60C1000F@kemper.freedesktop.org> src/sna/gen3_render.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) New commits: commit 17ba07a7befc7f442ae1c917a087ac026516d886 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sat Oct 29 20:03:37 2011 +0100 sna/gen3: Set the src flags for fill A regression from c2040fb8e62076d87f7a5b407505ee3f3482945e (sna: Remove the memset(0) of the fill op) left the flags for the source channel uninitalised leaving the shader construction undefined and causing visual glitches. Reported-by: Paul Neumann <paul104x at yahoo.de> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42367 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index a581c8a..efd5d7a 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3738,9 +3738,13 @@ gen3_render_fill_boxes(struct sna *sna, tmp.dst.bo = dst_bo; tmp.floats_per_vertex = 2; tmp.floats_per_rect = 6; + tmp.rb_reversed = 0; tmp.src.u.gen3.type = op == PictOpClear ? SHADER_ZERO : SHADER_CONSTANT; tmp.src.u.gen3.mode = pixel; + tmp.src.is_affine = 0; + tmp.src.alpha_fixup = 0; + tmp.src.rb_reversed = 0; tmp.mask.u.gen3.type = SHADER_NONE; tmp.u.gen3.num_constants = 0; @@ -3891,10 +3895,14 @@ gen3_render_fill(struct sna *sna, uint8_t alu, tmp->base.floats_per_rect = 6; tmp->base.need_magic_ca_pass = 0; tmp->base.has_component_alpha = 0; + tmp->base.rb_reversed = 0; tmp->base.src.u.gen3.type = SHADER_CONSTANT; tmp->base.src.u.gen3.mode = sna_rgba_for_color(color, dst->drawable.depth); + tmp->base.src.is_affine = 0; + tmp->base.src.alpha_fixup = 0; + tmp->base.src.rb_reversed = 0; tmp->base.mask.u.gen3.type = SHADER_NONE; tmp->base.u.gen3.num_constants = 0; @@ -3967,6 +3975,9 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, tmp.dst.bo = bo; tmp.floats_per_vertex = 2; tmp.floats_per_rect = 6; + tmp.need_magic_ca_pass = 0; + tmp.has_component_alpha = 0; + tmp.rb_reversed = 0; color = sna_rgba_for_color(color, dst->drawable.depth); if (color == 0) @@ -3978,6 +3989,9 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, else tmp.src.u.gen3.type = SHADER_CONSTANT; tmp.src.u.gen3.mode = color; + tmp.src.is_affine = 0; + tmp.src.alpha_fixup = 0; + tmp.src.rb_reversed = 0; tmp.mask.u.gen3.type = SHADER_NONE; tmp.u.gen3.num_constants = 0; From anholt at kemper.freedesktop.org Sat Oct 29 13:55:10 2011 From: anholt at kemper.freedesktop.org (Eric Anholt) Date: Sat, 29 Oct 2011 13:55:10 -0700 (PDT) Subject: modular: Changes to 'master' Message-ID: <20111029205510.C77451000F@kemper.freedesktop.org> release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 20ab0ade3aba602125268d67993b33083283e660 Author: Eric Anholt <eric at anholt.net> Date: Sat Oct 29 13:54:53 2011 -0700 Fix mailing list for libdrm releases. From jeremyhu at kemper.freedesktop.org Sat Oct 29 16:35:11 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 16:35:11 -0700 (PDT) Subject: xf86-video-mga: Changes to 'master' Message-ID: <20111029233511.9E3A21000F@kemper.freedesktop.org> src/mga_driver.c | 4 ++++ src/mga_vga.c | 2 ++ 2 files changed, 6 insertions(+) New commits: commit d9cf07a4f424b2beb844ea1b3ec5d468e79a747c Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 16:34:41 2011 -0700 Include "xf86Modes.h" for xf86ModeBandwidth Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit f9acf37be49844bea8165be9786afe37fd999229 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 16:31:08 2011 -0700 Include <unistd.h> for usleep Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 16:59:38 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 16:59:38 -0700 (PDT) Subject: xf86-video-cirrus: Changes to 'master' Message-ID: <20111029235938.281281000F@kemper.freedesktop.org> src/alp_driver.c | 14 ++++++++++++-- src/cir_pcirename.h | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) New commits: commit 05fd00f46eb3be46d669921d11dff6fe8a5bb60b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 16:58:41 2011 -0700 pciTag was removed from xorg-server, so provide it in-driver until this is updated to use libpciaccess Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 1a4dc3fb35223b708f27746b9d30a068a046cf3a Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 16:47:43 2011 -0700 Disable PC98 code on newer servers. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 17:15:10 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 17:15:10 -0700 (PDT) Subject: xf86-video-glint: Changes to 'master' Message-ID: <20111030001510.C52BC1000F@kemper.freedesktop.org> src/glint_driver.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) New commits: commit c539e59ba332fba669e025f8d0d680d2a2b1c9ff Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 17:12:58 2011 -0700 Disable PC98 code on newer servers. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From keithp at kemper.freedesktop.org Sat Oct 29 17:21:00 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Sat, 29 Oct 2011 17:21:00 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111030002101.033101000F@kemper.freedesktop.org> hw/xfree86/common/xf86pciBus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) New commits: commit d0c6732a99c9a7e40752b9ba7898a01c325103fa Author: Anssi Hannula <anssi.hannula at iki.fi> Date: Wed Apr 20 14:34:52 2011 +0300 xfree86: add nouveau as the first automatic driver for NVIDIA hardware Add nouveau as the first driver on linux for NVIDIA hardware when driver autoconfiguration is done, as it is more capable than nv. nv is also kept in the list as it is more widely supported and because some old cards are not supported by nouveau. Signed-off-by: Anssi Hannula <anssi.hannula at iki.fi> Reviewed-by: Daniel Stone <daniel at fooishbar.org> Reviewed-by: Cyril Brulebois <kibi at debian.org> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index eb5323c..bc09bd2 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -1116,7 +1116,15 @@ videoPtrToDriverList(struct pci_device *dev, break; case 0x102b: driverList[0] = "mga"; break; case 0x10c8: driverList[0] = "neomagic"; break; - case 0x10de: case 0x12d2: driverList[0] = "nv"; break; + case 0x10de: case 0x12d2: + { + int idx = 0; +#ifdef __linux__ + driverList[idx++] = "nouveau"; +#endif + driverList[idx++] = "nv"; + break; + } case 0x1106: driverList[0] = "openchrome"; break; case 0x1b36: driverList[0] = "qxl"; break; case 0x1163: driverList[0] = "rendition"; break; From jeremyhu at kemper.freedesktop.org Sat Oct 29 17:37:55 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 17:37:55 -0700 (PDT) Subject: xf86-video-sis: Changes to 'master' Message-ID: <20111030003755.4F78A1000F@kemper.freedesktop.org> configure.ac | 2 +- src/sis_driver.c | 4 ++-- src/sispcirename.h | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) New commits: commit b0e2f50d65ea6b5eac093440b9c6fec0051051a6 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 17:32:21 2011 -0700 pciTag was removed from xorg-server, so provide it in-driver until this is updated to use libpciaccess Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 722df08bbc82f35b8b9b54e39f14868a009c4892 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 17:28:21 2011 -0700 Include "dix.h" for LookupWindow Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 03644653d051e4f5b8498c790626a9bed2756a89 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 17:25:18 2011 -0700 Silence warnings by using newer xf86dgaproto Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 17:38:25 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 17:38:25 -0700 (PDT) Subject: xf86-video-sis: Changes to 'master' Message-ID: <20111030003825.363741000F@kemper.freedesktop.org> Rebased ref, commits from common ancestor: commit 06f8213bffd27360d5cc3df0cad19b102cc928e2 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 17:32:21 2011 -0700 pciTag was removed from xorg-server, so provide it in-driver until this is updated to use libpciaccess Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 18:59:27 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 18:59:27 -0700 (PDT) Subject: xf86-video-mach64: Branch 'master' - 2 commits Message-ID: <20111030015927.D070F1000F@kemper.freedesktop.org> configure.ac | 2 +- src/atiprint.c | 4 ++-- src/atiprobe.c | 2 +- src/atistruct.h | 8 ++++---- src/atividmem.c | 14 ++++++++++++-- 5 files changed, 20 insertions(+), 10 deletions(-) New commits: commit 0de234329fa1c3365954498819da93d64a978911 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 18:53:48 2011 -0700 Use pci_device_map_legacy rather than xf86MapDomainMemory Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/configure.ac b/configure.ac index e4ab861..087ef11 100644 --- a/configure.ac +++ b/configure.ac @@ -206,7 +206,7 @@ CPPFLAGS="$SAVE_CPPFLAGS" AM_CONDITIONAL(USE_EXA, test "x$USE_EXA" = xyes) if test "x$XSERVER_LIBPCIACCESS" = xyes; then - PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) + PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.12.901]) XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" fi AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes) diff --git a/src/atividmem.c b/src/atividmem.c index 8950f84..0104a0a 100644 --- a/src/atividmem.c +++ b/src/atividmem.c @@ -84,7 +84,11 @@ ATIUnmapVGA if (!pATI->pBank) return; +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(iScreen, pATI->pBank, 0x00010000U); +#else + (void) pci_device_unmap_legacy(pATI->PCIInfo, pATI->pBank, 0x00010000U); +#endif pATI->pBank = NULL; } @@ -219,8 +223,14 @@ ATIMapApertures * No relocation, resizing, caching or write-combining of this * aperture is supported. Hence, the hard-coded values here... */ - pATI->pBank = xf86MapDomainMemory(iScreen, VIDMEM_MMIO_32BIT, - Tag, 0x000A0000U, 0x00010000U); +#ifndef XSERVER_LIBPCIACCESS + pATI->pBank = xf86MapDomainMemory(iScreen, VIDMEM_MMIO_32BIT, + Tag, 0x000A0000U, 0x00010000U); +#else + (void) pci_device_map_legacy(Tag, 0x000A0000U, 0x00010000U, + PCI_DEV_MAP_FLAG_WRITABLE, + &pATI->pBank); +#endif if (!pATI->pBank) return FALSE; commit 75166a0fc92220b496eb67451ec1b11cb8b72091 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 18:54:10 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/src/atiprint.c b/src/atiprint.c index 3a1debb..f050d52 100644 --- a/src/atiprint.c +++ b/src/atiprint.c @@ -92,11 +92,11 @@ ATIPrintBIOS static void ATIPrintIndexedRegisters ( - const IOADDRESS Port, + const unsigned long Port, const CARD8 StartIndex, const CARD8 EndIndex, const char *Name, - const IOADDRESS GenS1 + const unsigned long GenS1 ) { int Index; diff --git a/src/atiprobe.c b/src/atiprobe.c index 5092073..b065915 100644 --- a/src/atiprobe.c +++ b/src/atiprobe.c @@ -373,7 +373,7 @@ ATIMach64ProbeIO #ifndef AVOID_CPIO - static const IOADDRESS Mach64SparseIOBases[] = { + static const unsigned long Mach64SparseIOBases[] = { 0x02ECU, 0x01CCU, 0x01C8U diff --git a/src/atistruct.h b/src/atistruct.h index 5225256..87f2a5d 100644 --- a/src/atistruct.h +++ b/src/atistruct.h @@ -234,19 +234,19 @@ typedef struct _ATIRec * Processor I/O decoding definitions. */ CARD8 CPIODecoding; - IOADDRESS CPIOBase; + unsigned long CPIOBase; #ifndef AVOID_CPIO /* * Processor I/O port definition for VGA. */ - IOADDRESS CPIO_VGABase; + unsigned long CPIO_VGABase; /* * Processor I/O port definitions for VGA Wonder. */ - IOADDRESS CPIO_VGAWonder; + unsigned long CPIO_VGAWonder; #endif /* AVOID_CPIO */ @@ -256,7 +256,7 @@ typedef struct _ATIRec #ifndef AVOID_CPIO - IOADDRESS CPIO_DAC_MASK, CPIO_DAC_DATA, CPIO_DAC_READ, CPIO_DAC_WRITE, + unsigned long CPIO_DAC_MASK, CPIO_DAC_DATA, CPIO_DAC_READ, CPIO_DAC_WRITE, CPIO_DAC_WAIT; #endif /* AVOID_CPIO */ From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:03:06 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:03:06 -0700 (PDT) Subject: xf86-video-voodoo: Changes to 'master' Message-ID: <20111030020306.AC8F71000F@kemper.freedesktop.org> src/voodoo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit d2f109c4179c13c3367b08f1ee4f4baa3a2a68ad Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:02:46 2011 -0700 Fix implicit declaration warning voodoo_driver.c:898:7: warning: implicit declaration of function 'VoodooRestorePassThrough' [-Wimplicit-function-declaration] Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:29:13 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:29:13 -0700 (PDT) Subject: xf86-video-xgixp: Changes to 'master' Message-ID: <20111030022913.737AA1000F@kemper.freedesktop.org> src/xg47_cmdlist.c | 2 +- src/xg47_display.c | 10 +++++----- src/xg47_misc.h | 3 +++ src/xg47_mode.h | 3 +++ src/xg47_outputs.c | 1 + src/xg47_video.c | 26 +++++++++++++------------- src/xgi_dga.c | 6 +++--- src/xgi_dri.c | 4 ++-- src/xgi_driver.c | 32 +++++++------------------------- src/xgi_hwmc.c | 14 +++++++------- src/xgi_misc.c | 4 ++-- src/xgi_option.c | 2 +- 12 files changed, 48 insertions(+), 59 deletions(-) New commits: commit 6de4e59b48cd1229a4c91b190d239976f7bb3e30 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:22:09 2011 -0700 Add missing prototypes to headers to silence warnings Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit d5fe4c4aa83db6e5f9c37eaecad006b6cfc466e8 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:25:23 2011 -0700 Silence warning about xg47_CrtcInit returning a value when it should return void Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 447f63b6d49de6b4678a0ea54d0152fc808c5e04 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:23:55 2011 -0700 Include "fbdevhw.h" for fbdevHWDPMSSet Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit c97f4b0a5450eb1abdd45f3c884a829efbb52d02 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:17:18 2011 -0700 Remove calls to loader symbol list API These were removed a while ago and were noops before then. cf xserver commit 71a83d68ab07536c0778d13cd7da974c40e77457 Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 881ac08b1dfed4822b1239ab8a0da4dc7aa2ee43 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:13:28 2011 -0700 Silence printf format warnings Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 4b4a2dcd75b329311b21e6203e9b12df7fa06a8b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:09:26 2011 -0700 Silence compiler warnings by including header Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 1ccae1f9d9b1f62a86c58837c6a737f2aea9c119 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:07:38 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:32:59 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:32:59 -0700 (PDT) Subject: xf86-video-r128: Branch 'master' - 2 commits Message-ID: <20111030023259.E35191000F@kemper.freedesktop.org> src/atipcirename.h | 22 ++++++++++++++++++++++ src/r128_accel.c | 2 +- src/r128_dga.c | 2 +- src/r128_dri.c | 36 ++++++++++++++++++------------------ src/r128_driver.c | 22 +++++++++++----------- src/r128_probe.c | 6 +++--- src/r128_video.c | 8 ++++---- 7 files changed, 60 insertions(+), 38 deletions(-) New commits: commit ea9e6b548633df5b6ffeac8071f27a5c04ac817e Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:31:19 2011 -0700 pciTag was removed from xorg-server, so provide it in-driver until this is updated to use libpciaccess Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/src/atipcirename.h b/src/atipcirename.h index de8f0a3..7d9d3a8 100644 --- a/src/atipcirename.h +++ b/src/atipcirename.h @@ -34,6 +34,28 @@ enum region_type { REGION_IO }; +#if (defined(__alpha__) || defined(__ia64__)) && defined (linux) +#define PCI_DOM_MASK 0x01fful +#else +#define PCI_DOM_MASK 0x0ffu +#endif + +#ifndef PCI_DOM_MASK +# define PCI_DOM_MASK 0x0ffu +#endif +#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) + +static inline uint32_t +pciTag(int busnum, int devnum, int funcnum) +{ + uint32_t tag; + tag = (busnum & (PCI_DOMBUS_MASK)) << 16; + tag |= (devnum & 0x00001fu) << 11; + tag |= (funcnum & 0x000007u) << 8; + + return tag; +} + #ifndef XSERVER_LIBPCIACCESS /* pciVideoPtr */ commit cfcaac0d7861c00af23c683487dcad2fcb51a908 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:29:35 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/src/r128_accel.c b/src/r128_accel.c index 8870682..eeb2bfc 100644 --- a/src/r128_accel.c +++ b/src/r128_accel.c @@ -1804,7 +1804,7 @@ static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) | LEFT_EDGE_CLIPPING_NEGATIVE_X; a->NumScanlineColorExpandBuffers = 1; a->ScanlineColorExpandBuffers = info->scratch_buffer; - info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4) + info->scratch_save = malloc(((pScrn->virtualX+31)/32*4) + (pScrn->virtualX * info->CurrentLayout.pixel_bytes)); info->scratch_buffer[0] = info->scratch_save; diff --git a/src/r128_dga.c b/src/r128_dga.c index 7dd03aa..1e493ee 100644 --- a/src/r128_dga.c +++ b/src/r128_dga.c @@ -69,7 +69,7 @@ SECOND_PASS: if (secondPitch) pitch = secondPitch; - if (!(newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec)))) + if (!(newmodes = realloc(modes, (*num + 1) * sizeof(DGAModeRec)))) break; modes = newmodes; diff --git a/src/r128_dri.c b/src/r128_dri.c index 2927718..624e3a5 100644 --- a/src/r128_dri.c +++ b/src/r128_dri.c @@ -105,21 +105,21 @@ static Bool R128InitVisualConfigs(ScreenPtr pScreen) if (R128_USE_DB) numConfigs *= 2; if (!(pConfigs - = (__GLXvisualConfig*)xcalloc(sizeof(__GLXvisualConfig), + = (__GLXvisualConfig*)calloc(sizeof(__GLXvisualConfig), numConfigs))) { return FALSE; } if (!(pR128Configs - = (R128ConfigPrivPtr)xcalloc(sizeof(R128ConfigPrivRec), + = (R128ConfigPrivPtr)calloc(sizeof(R128ConfigPrivRec), numConfigs))) { - xfree(pConfigs); + free(pConfigs); return FALSE; } if (!(pR128ConfigPtrs - = (R128ConfigPrivPtr*)xcalloc(sizeof(R128ConfigPrivPtr), + = (R128ConfigPrivPtr*)calloc(sizeof(R128ConfigPrivPtr), numConfigs))) { - xfree(pConfigs); - xfree(pR128Configs); + free(pConfigs); + free(pR128Configs); return FALSE; } @@ -188,21 +188,21 @@ static Bool R128InitVisualConfigs(ScreenPtr pScreen) if (R128_USE_DB) numConfigs *= 2; if (!(pConfigs - = (__GLXvisualConfig*)xcalloc(sizeof(__GLXvisualConfig), + = (__GLXvisualConfig*)calloc(sizeof(__GLXvisualConfig), numConfigs))) { return FALSE; } if (!(pR128Configs - = (R128ConfigPrivPtr)xcalloc(sizeof(R128ConfigPrivRec), + = (R128ConfigPrivPtr)calloc(sizeof(R128ConfigPrivRec), numConfigs))) { - xfree(pConfigs); + free(pConfigs); return FALSE; } if (!(pR128ConfigPtrs - = (R128ConfigPrivPtr*)xcalloc(sizeof(R128ConfigPrivPtr), + = (R128ConfigPrivPtr*)calloc(sizeof(R128ConfigPrivPtr), numConfigs))) { - xfree(pConfigs); - xfree(pR128Configs); + free(pConfigs); + free(pR128Configs); return FALSE; } @@ -1026,7 +1026,7 @@ Bool R128DRIScreenInit(ScreenPtr pScreen) if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) { pDRIInfo->busIdString = DRICreatePCIBusID(info->PciInfo); } else { - pDRIInfo->busIdString = xalloc(64); + pDRIInfo->busIdString = malloc(64); sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", PCI_DEV_BUS(info->PciInfo), @@ -1065,7 +1065,7 @@ Bool R128DRIScreenInit(ScreenPtr pScreen) pDRIInfo->SAREASize = SAREA_MAX; #endif - if (!(pR128DRI = (R128DRIPtr)xcalloc(sizeof(R128DRIRec),1))) { + if (!(pR128DRI = (R128DRIPtr)calloc(sizeof(R128DRIRec),1))) { DRIDestroyInfoRec(info->pDRIInfo); info->pDRIInfo = NULL; return FALSE; @@ -1091,7 +1091,7 @@ Bool R128DRIScreenInit(ScreenPtr pScreen) if (!DRIScreenInit(pScreen, pDRIInfo, &info->drmFD)) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] DRIScreenInit failed. Disabling DRI.\n"); - xfree(pDRIInfo->devPrivate); + free(pDRIInfo->devPrivate); pDRIInfo->devPrivate = NULL; DRIDestroyInfoRec(pDRIInfo); pDRIInfo = NULL; @@ -1352,18 +1352,18 @@ void R128DRICloseScreen(ScreenPtr pScreen) /* De-allocate all DRI data structures */ if (info->pDRIInfo) { if (info->pDRIInfo->devPrivate) { - xfree(info->pDRIInfo->devPrivate); + free(info->pDRIInfo->devPrivate); info->pDRIInfo->devPrivate = NULL; } DRIDestroyInfoRec(info->pDRIInfo); info->pDRIInfo = NULL; } if (info->pVisualConfigs) { - xfree(info->pVisualConfigs); + free(info->pVisualConfigs); info->pVisualConfigs = NULL; } if (info->pVisualConfigsPriv) { - xfree(info->pVisualConfigsPriv); + free(info->pVisualConfigsPriv); info->pVisualConfigsPriv = NULL; } } diff --git a/src/r128_driver.c b/src/r128_driver.c index 9d08d77..eb1d978 100644 --- a/src/r128_driver.c +++ b/src/r128_driver.c @@ -228,7 +228,7 @@ static Bool R128GetRec(ScrnInfoPtr pScrn) static void R128FreeRec(ScrnInfoPtr pScrn) { if (!pScrn || !pScrn->driverPrivate) return; - xfree(pScrn->driverPrivate); + free(pScrn->driverPrivate); pScrn->driverPrivate = NULL; } @@ -506,9 +506,9 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) #ifdef XSERVER_LIBPCIACCESS int size = info->PciInfo->rom_size > R128_VBIOS_SIZE ? info->PciInfo->rom_size : R128_VBIOS_SIZE; - info->VBIOS = xalloc(size); + info->VBIOS = malloc(size); #else - info->VBIOS = xalloc(R128_VBIOS_SIZE); + info->VBIOS = malloc(R128_VBIOS_SIZE); #endif if (!info->VBIOS) { @@ -541,7 +541,7 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) } if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { info->BIOSAddr = 0x00000000; - xfree(info->VBIOS); + free(info->VBIOS); info->VBIOS = NULL; xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Video BIOS not found!\n"); @@ -1519,7 +1519,7 @@ static void R128SetSyncRangeFromEdid(ScrnInfoPtr pScrn, int flag) } /*********** - xfree's xf86ValidateModes routine deosn't work well with DFPs + free's xf86ValidateModes routine deosn't work well with DFPs here is our own validation routine. All modes between 640<=XRes<=MaxRes and 480<=YRes<=MaxYRes will be permitted. NOTE: RageProII doesn't support rmx, can only work with the @@ -1987,7 +1987,7 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int flags) /* We can't do this until we have a pScrn->display. */ xf86CollectOptions(pScrn, NULL); - if (!(info->Options = xalloc(sizeof(R128Options)))) goto fail; + if (!(info->Options = malloc(sizeof(R128Options)))) goto fail; memcpy(info->Options, R128Options, sizeof(R128Options)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, info->Options); @@ -2082,7 +2082,7 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int flags) /* Free the video bios (if applicable) */ if (info->VBIOS) { - xfree(info->VBIOS); + free(info->VBIOS); info->VBIOS = NULL; } @@ -2101,7 +2101,7 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int flags) /* Free the video bios (if applicable) */ if (info->VBIOS) { - xfree(info->VBIOS); + free(info->VBIOS); info->VBIOS = NULL; } @@ -4310,17 +4310,17 @@ static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen) if (info->accel) XAADestroyInfoRec(info->accel); info->accel = NULL; - if (info->scratch_save) xfree(info->scratch_save); + if (info->scratch_save) free(info->scratch_save); info->scratch_save = NULL; if (info->cursor) xf86DestroyCursorInfoRec(info->cursor); info->cursor = NULL; - if (info->DGAModes) xfree(info->DGAModes); + if (info->DGAModes) free(info->DGAModes); info->DGAModes = NULL; if (info->adaptor) { - xfree(info->adaptor->pPortPrivates[0].ptr); + free(info->adaptor->pPortPrivates[0].ptr); xf86XVFreeVideoAdaptorRec(info->adaptor); info->adaptor = NULL; } diff --git a/src/r128_probe.c b/src/r128_probe.c index 412da92..0477617 100644 --- a/src/r128_probe.c +++ b/src/r128_probe.c @@ -298,7 +298,7 @@ r128_get_scrninfo(int entity_num) instance++; } - xfree(pEnt); + free(pEnt); return TRUE; } @@ -340,8 +340,8 @@ R128Probe(DriverPtr drv, int flags) foundScreen = TRUE; } - xfree(usedChips); - xfree(devSections); + free(usedChips); + free(devSections); return foundScreen; } diff --git a/src/r128_video.c b/src/r128_video.c index 8e83323..ec22ee1 100644 --- a/src/r128_video.c +++ b/src/r128_video.c @@ -95,7 +95,7 @@ void R128InitVideo(ScreenPtr pScreen) adaptors = &newAdaptor; } else { newAdaptors = /* need to free this someplace */ - xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); if(newAdaptors) { memcpy(newAdaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr)); @@ -110,7 +110,7 @@ void R128InitVideo(ScreenPtr pScreen) xf86XVScreenInit(pScreen, adaptors, num_adaptors); if(newAdaptors) - xfree(newAdaptors); + free(newAdaptors); } #define MAXWIDTH 2048 @@ -188,9 +188,9 @@ R128AllocAdaptor(ScrnInfoPtr pScrn) if(!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn))) return NULL; - if(!(pPriv = xcalloc(1, sizeof(R128PortPrivRec) + sizeof(DevUnion)))) + if(!(pPriv = calloc(1, sizeof(R128PortPrivRec) + sizeof(DevUnion)))) { - xfree(adapt); + free(adapt); return NULL; } From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:51:38 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:51:38 -0700 (PDT) Subject: xf86-video-suncg14: Changes to 'master' Message-ID: <20111030025138.288161000F@kemper.freedesktop.org> src/cg14_driver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) New commits: commit 871f39d28f98a3a3c15832008c4d6e96a2790b24 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:51:21 2011 -0700 Include <sys/ioctl.h> for ioctl() Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 6d87bfa5949dc923a7cd869b748aa5323b3e17d0 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:50:27 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:53:55 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:53:55 -0700 (PDT) Subject: xf86-video-suncg3: Changes to 'master' Message-ID: <20111030025355.3B0651000F@kemper.freedesktop.org> src/cg3_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) New commits: commit 68a92f10b260d2653b3469a879a0ee3602c62a03 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:52:11 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:54:00 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:54:00 -0700 (PDT) Subject: xf86-video-suncg6: Changes to 'master' Message-ID: <20111030025400.0FB331000F@kemper.freedesktop.org> src/cg6_driver.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) New commits: commit 9d6d59f7a37f1290237721918583becb66516ec0 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:52:38 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:56:40 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:56:40 -0700 (PDT) Subject: xf86-video-sunffb: Changes to 'master' Message-ID: <20111030025640.880861000F@kemper.freedesktop.org> src/ffb_accel.c | 14 +++++++++----- src/ffb_driver.c | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) New commits: commit 20e5b57ca3186dd58f88bc663e410aeea638100f Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:56:26 2011 -0700 Add missing prototypes to silence warnings Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit d76eda9d1c6456ece6b5e2a6b8a772293e10beb6 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:52:52 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 19:59:06 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 19:59:06 -0700 (PDT) Subject: xf86-video-sunleo: Changes to 'master' Message-ID: <20111030025907.1A5F21000F@kemper.freedesktop.org> src/leo_checks.c | 8 ++++---- src/leo_driver.c | 10 +++++----- src/leo_fspans.c | 12 ++++++------ src/leo_fspanssp.c | 12 ++++++------ 4 files changed, 21 insertions(+), 21 deletions(-) New commits: commit 9d552e5d9edfdda14cb1f4cfcf4197307d4e4a54 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 19:53:16 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 20:00:17 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 20:00:17 -0700 (PDT) Subject: xf86-video-suntcx: Changes to 'master' Message-ID: <20111030030017.A109D1000F@kemper.freedesktop.org> src/tcx_driver.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) New commits: commit 431e56e06b456ad9bd95dc2b5416708625d91b0a Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 20:00:00 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 20:03:31 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 20:03:31 -0700 (PDT) Subject: xf86-video-tga: Changes to 'master' Message-ID: <20111030030332.349EB1000F@kemper.freedesktop.org> configure.ac | 2 +- src/tga_driver.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) New commits: commit 8c56d6cb99da1e2439c5f6aa09a72b6e0dc9af04 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 20:03:28 2011 -0700 Silence warnings by using newer xf86dgaproto Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit a7f58500fba5a75c41130b6e1a13739c999d5864 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 20:00:30 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 20:12:40 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 20:12:40 -0700 (PDT) Subject: xf86-video-trident: Changes to 'master' Message-ID: <20111030031240.57B3A1000F@kemper.freedesktop.org> src/trident_driver.c | 33 +++++++++++++++++++++++++++------ src/trident_video.c | 5 ++++- 2 files changed, 31 insertions(+), 7 deletions(-) New commits: commit 343fc2a2b98ca9e93c031b7f7c3378563699b394 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 20:07:56 2011 -0700 Disable PC98 code on newer servers Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sat Oct 29 20:16:04 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 20:16:04 -0700 (PDT) Subject: xf86-video-ati: Branch 'master' Message-ID: <20111030031604.BABDE1000F@kemper.freedesktop.org> src/theatre.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 70da7001e81363ed6ef2c4727c512daf53ae29fe Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 20:15:09 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/src/theatre.c b/src/theatre.c index ad055c5..fc68f27 100644 --- a/src/theatre.c +++ b/src/theatre.c @@ -46,7 +46,7 @@ TheatrePtr DetectTheatre(GENERIC_BUS_Ptr b) return NULL; } - t = xcalloc(1,sizeof(TheatreRec)); + t = calloc(1,sizeof(TheatreRec)); t->VIP = b; t->theatre_num = -1; t->mode=MODE_UNINITIALIZED; @@ -81,7 +81,7 @@ TheatrePtr DetectTheatre(GENERIC_BUS_Ptr b) if(t->theatre_num < 0) { - xfree(t); + free(t); return NULL; } From jeremyhu at kemper.freedesktop.org Sat Oct 29 20:16:28 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 20:16:28 -0700 (PDT) Subject: xf86-video-intel: src/legacy/i810 src/xvmc/i965_xvmc.c src/xvmc/intel_xvmc.c src/xvmc/xvmc_vld.c Message-ID: <20111030031628.5DDE01000F@kemper.freedesktop.org> src/legacy/i810/xvmc/I810XvMC.c | 2 +- src/xvmc/i965_xvmc.c | 2 +- src/xvmc/intel_xvmc.c | 2 +- src/xvmc/xvmc_vld.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) New commits: commit da3f8656744f7c801608c7c89a859c0f7dc9e6e0 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 20:15:11 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/src/legacy/i810/xvmc/I810XvMC.c b/src/legacy/i810/xvmc/I810XvMC.c index 0754ff4..e6b63d3 100644 --- a/src/legacy/i810/xvmc/I810XvMC.c +++ b/src/legacy/i810/xvmc/I810XvMC.c @@ -4323,7 +4323,7 @@ static XvAttribute I810_XVMC_ATTRIBUTES[] = { // Function: XvMCQueryAttributes // Description: An array of XvAttributes of size "number" is returned by // this function. If there are no attributes, NULL is returned and number -// is set to 0. The array may be freed with xfree(). +// is set to 0. The array may be freed with free(). // // Arguments: // display - Connection to the X server. diff --git a/src/xvmc/i965_xvmc.c b/src/xvmc/i965_xvmc.c index 210cf73..261cf35 100644 --- a/src/xvmc/i965_xvmc.c +++ b/src/xvmc/i965_xvmc.c @@ -244,7 +244,7 @@ static Status destroy_context(Display * display, XvMCContext * context) { struct intel_xvmc_context *intel_ctx; intel_ctx = context->privData; - Xfree(intel_ctx->hw); + free(intel_ctx->hw); free(intel_ctx); return Success; } diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c index 1b96945..883dada 100644 --- a/src/xvmc/intel_xvmc.c +++ b/src/xvmc/intel_xvmc.c @@ -972,7 +972,7 @@ _X_EXPORT Status XvMCGetSubpictureStatus(Display * display, * Function: XvMCQueryAttributes * Description: An array of XvAttributes of size "number" is returned by * this function. If there are no attributes, NULL is returned and number - * is set to 0. The array may be freed with xfree(). + * is set to 0. The array may be freed with free(). * * Arguments: * display - Connection to the X server. diff --git a/src/xvmc/xvmc_vld.c b/src/xvmc/xvmc_vld.c index 570e9b6..3f5fa5e 100644 --- a/src/xvmc/xvmc_vld.c +++ b/src/xvmc/xvmc_vld.c @@ -622,7 +622,7 @@ static Status destroy_context(Display * display, XvMCContext * context) { struct intel_xvmc_context *intel_ctx; intel_ctx = context->privData; - Xfree(intel_ctx->hw); + free(intel_ctx->hw); free(intel_ctx); return Success; } From jeremyhu at kemper.freedesktop.org Sat Oct 29 20:17:51 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sat, 29 Oct 2011 20:17:51 -0700 (PDT) Subject: xf86-video-xgi: Changes to 'master' Message-ID: <20111030031751.3F3631000F@kemper.freedesktop.org> src/xgi_memcpy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) New commits: commit 2fe26848181e50e451dde7c65a8d780ec52dc26a Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 20:15:13 2011 -0700 Use malloc/calloc/realloc/free directly Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From ickle at kemper.freedesktop.org Sun Oct 30 03:46:00 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 03:46:00 -0700 (PDT) Subject: xf86-video-intel: src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/sna_composite.c Message-ID: <20111030104600.BA2DA1000F@kemper.freedesktop.org> src/sna/gen2_render.c | 17 +++++------- src/sna/gen3_render.c | 68 +++++++++++++++++++++++------------------------- src/sna/gen4_render.c | 4 ++ src/sna/gen5_render.c | 4 ++ src/sna/gen6_render.c | 4 ++ src/sna/gen7_render.c | 4 ++ src/sna/sna_composite.c | 36 +++++++++++++++++++++++++ 7 files changed, 89 insertions(+), 48 deletions(-) New commits: commit d4062705178856cffc83030fa40f758e9d884566 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 10:40:32 2011 +0000 sna/composite: Fix incorrect operator reduction for RenderFillRectangles As exemplified by KDE (using Kate) on gen3, it would attempt to render a large set of boxes using OVER and a transparent colour. As gen3 copied across some of the BLT assumptions, it was incorrectly reducing that to a CLEAR and thus rendering incorrectly. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index e76876c..f8e71e7 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -1938,20 +1938,19 @@ gen2_render_fill_boxes(struct sna *sna, box, n)) return TRUE; - if (!sna_get_pixel_from_rgba(&pixel, - color->red, - color->green, - color->blue, - color->alpha, - PICT_a8r8g8b8)) + if (op == PictOpClear) + pixel = 0; + else if (!sna_get_pixel_from_rgba(&pixel, + color->red, + color->green, + color->blue, + color->alpha, + PICT_a8r8g8b8)) return FALSE; DBG(("%s: using shader for op=%d, format=%x, pixel=%x\n", __FUNCTION__, op, (int)format, pixel)); - if (pixel == 0) - op = PictOpClear; - memset(&tmp, 0, sizeof(tmp)); tmp.op = op; tmp.dst.pixmap = dst; diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index efd5d7a..e21ea6c 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -3675,6 +3675,23 @@ static inline Bool prefer_fill_blt(struct sna *sna) #endif } +static inline void set_fill_shader(struct sna_composite_channel *c, + uint32_t pixel) +{ + if (pixel == 0) + c->u.gen3.type = SHADER_ZERO; + else if (pixel == 0xff000000) + c->u.gen3.type = SHADER_BLACK; + else if (pixel == 0xffffffff) + c->u.gen3.type = SHADER_WHITE; + else + c->u.gen3.type = SHADER_CONSTANT; + c->u.gen3.mode = pixel; + c->is_affine = 1; + c->alpha_fixup = 0; + c->rb_reversed = 0; +} + static Bool gen3_render_fill_boxes(struct sna *sna, CARD8 op, @@ -3716,20 +3733,20 @@ gen3_render_fill_boxes(struct sna *sna, box, n)) return TRUE; - if (!sna_get_pixel_from_rgba(&pixel, - color->red, - color->green, - color->blue, - color->alpha, - PICT_a8r8g8b8)) - return FALSE; - + if (op == PictOpClear) { + pixel = 0; + } else { + if (!sna_get_pixel_from_rgba(&pixel, + color->red, + color->green, + color->blue, + color->alpha, + PICT_a8r8g8b8)) + return FALSE; + } DBG(("%s: using shader for op=%d, format=%x, pixel=%x\n", __FUNCTION__, op, (int)format, pixel)); - if (pixel == 0) - op = PictOpClear; - tmp.op = op; tmp.dst.pixmap = dst; tmp.dst.width = dst->drawable.width; @@ -3740,11 +3757,7 @@ gen3_render_fill_boxes(struct sna *sna, tmp.floats_per_rect = 6; tmp.rb_reversed = 0; - tmp.src.u.gen3.type = op == PictOpClear ? SHADER_ZERO : SHADER_CONSTANT; - tmp.src.u.gen3.mode = pixel; - tmp.src.is_affine = 0; - tmp.src.alpha_fixup = 0; - tmp.src.rb_reversed = 0; + set_fill_shader(&tmp.src, pixel); tmp.mask.u.gen3.type = SHADER_NONE; tmp.u.gen3.num_constants = 0; @@ -3897,12 +3910,8 @@ gen3_render_fill(struct sna *sna, uint8_t alu, tmp->base.has_component_alpha = 0; tmp->base.rb_reversed = 0; - tmp->base.src.u.gen3.type = SHADER_CONSTANT; - tmp->base.src.u.gen3.mode = - sna_rgba_for_color(color, dst->drawable.depth); - tmp->base.src.is_affine = 0; - tmp->base.src.alpha_fixup = 0; - tmp->base.src.rb_reversed = 0; + set_fill_shader(&tmp->base.src, + sna_rgba_for_color(color, dst->drawable.depth)); tmp->base.mask.u.gen3.type = SHADER_NONE; tmp->base.u.gen3.num_constants = 0; @@ -3979,19 +3988,8 @@ gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, tmp.has_component_alpha = 0; tmp.rb_reversed = 0; - color = sna_rgba_for_color(color, dst->drawable.depth); - if (color == 0) - tmp.src.u.gen3.type = SHADER_ZERO; - else if (color == 0xff000000) - tmp.src.u.gen3.type = SHADER_BLACK; - else if (color == 0xffffffff) - tmp.src.u.gen3.type = SHADER_WHITE; - else - tmp.src.u.gen3.type = SHADER_CONSTANT; - tmp.src.u.gen3.mode = color; - tmp.src.is_affine = 0; - tmp.src.alpha_fixup = 0; - tmp.src.rb_reversed = 0; + set_fill_shader(&tmp.src, + sna_rgba_for_color(color, dst->drawable.depth)); tmp.mask.u.gen3.type = SHADER_NONE; tmp.u.gen3.num_constants = 0; diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 18171c4..9fa2278 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2451,7 +2451,9 @@ gen4_render_fill_boxes(struct sna *sna, return FALSE; #endif - if (!sna_get_pixel_from_rgba(&pixel, + if (op == PictOpClear) + pixel = 0; + else if (!sna_get_pixel_from_rgba(&pixel, color->red, color->green, color->blue, diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index b9512c7..b33125c 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2420,7 +2420,9 @@ gen5_render_fill_boxes(struct sna *sna, return FALSE; } - if (!sna_get_pixel_from_rgba(&pixel, + if (op == PictOpClear) + pixel = 0; + else if (!sna_get_pixel_from_rgba(&pixel, color->red, color->green, color->blue, diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 1fc971f..6a132ad 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2628,7 +2628,9 @@ gen6_render_fill_boxes(struct sna *sna, return FALSE; #endif - if (!sna_get_pixel_from_rgba(&pixel, + if (op == PictOpClear) + pixel = 0; + else if (!sna_get_pixel_from_rgba(&pixel, color->red, color->green, color->blue, diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index ecdab6e..3f9e59a 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2776,7 +2776,9 @@ gen7_render_fill_boxes(struct sna *sna, return FALSE; #endif - if (!sna_get_pixel_from_rgba(&pixel, + if (op ==PictOpClear) + pixel = 0; + else if (!sna_get_pixel_from_rgba(&pixel, color->red, color->green, color->blue, diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index e9dc965..0373bad 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -601,6 +601,42 @@ sna_composite_rectangles(CARD8 op, if (!num_rects) return; + if (color->alpha <= 0x00ff) { + switch (op) { + case PictOpOver: + case PictOpOutReverse: + case PictOpAdd: + return; + case PictOpInReverse: + case PictOpSrc: + op = PictOpClear; + break; + case PictOpAtopReverse: + op = PictOpOut; + break; + case PictOpXor: + op = PictOpOverReverse; + break; + } + } else if (color->alpha >= 0xff00) { + switch (op) { + case PictOpOver: + op = PictOpSrc; + break; + case PictOpInReverse: + return; + case PictOpOutReverse: + op = PictOpClear; + break; + case PictOpAtopReverse: + op = PictOpOverReverse; + break; + case PictOpXor: + op = PictOpOut; + break; + } + } + if (!pixman_region_not_empty(dst->pCompositeClip)) { DBG(("%s: empty clip, skipping\n", __FUNCTION__)); return; From ickle at kemper.freedesktop.org Sun Oct 30 04:24:49 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 04:24:49 -0700 (PDT) Subject: xf86-video-intel: src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c Message-ID: <20111030112449.5BD711000F@kemper.freedesktop.org> src/sna/gen2_render.c | 3 +-- src/sna/gen3_render.c | 3 +-- src/sna/gen4_render.c | 3 +-- src/sna/gen5_render.c | 3 +-- src/sna/gen6_render.c | 3 +-- src/sna/gen7_render.c | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) New commits: commit 2d3aba8518ae790325c6123dacc3ce73b6e91cbd Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 11:22:26 2011 +0000 Revert "sna: Don't flush the render caches if in the process of writing again" This reverts commit 15266e1b9500f6b348661c60d1982bde911f2d0e. KDE relies upon the ability to render into a sampler and then render upon itself. Not the first sign of madness... Will have to find another way of winning back the compwinwin performance. diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index f8e71e7..d2a296c 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -1375,8 +1375,7 @@ gen2_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || - (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) { + if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) { if (tmp->src.bo == tmp->dst.bo || tmp->mask.bo == tmp->dst.bo) { kgem_emit_flush(&sna->kgem); } else { diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index e21ea6c..eca841e 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -2479,8 +2479,7 @@ gen3_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || - (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) { + if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) { if (tmp->src.bo == tmp->dst.bo || tmp->mask.bo == tmp->dst.bo) { kgem_emit_flush(&sna->kgem); } else { diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index 9fa2278..c603e67 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -2058,8 +2058,7 @@ gen4_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || - (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) + if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) kgem_emit_flush(&sna->kgem); gen4_bind_surfaces(sna, tmp); diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index b33125c..3006bd1 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -2078,8 +2078,7 @@ gen5_render_composite(struct sna *sna, tmp->dst.bo, tmp->src.bo, tmp->mask.bo, NULL)) kgem_submit(&sna->kgem); - if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || - (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) + if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) kgem_emit_flush(&sna->kgem); gen5_bind_surfaces(sna, tmp); diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index 6a132ad..b7f0ed0 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -2248,8 +2248,7 @@ gen6_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || - (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) + if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) kgem_emit_flush(&sna->kgem); gen6_emit_composite_state(sna, tmp); diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 3f9e59a..4667bad 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -2388,8 +2388,7 @@ gen7_render_composite(struct sna *sna, NULL)) kgem_submit(&sna->kgem); - if ((tmp->src.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->src.bo)) || - (tmp->mask.bo && tmp->mask.bo != tmp->dst.bo && kgem_bo_is_dirty(tmp->mask.bo))) + if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) kgem_emit_flush(&sna->kgem); gen7_emit_composite_state(sna, tmp); From ickle at kemper.freedesktop.org Sun Oct 30 05:10:37 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 05:10:37 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111030121037.A44E91000F@kemper.freedesktop.org> src/sna/sna_accel.c | 94 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 11 deletions(-) New commits: commit 427622aca31b7463eb2dcd52e352dc8997e84baa Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 12:02:42 2011 +0000 sna: Push overflow detection to the end of extents Removes a couple of conditionals from the middle of the hotpath and on Intel we are not realising the benefit of only utilising 16-bit values. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 3eb0d85..d227184 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -78,6 +78,10 @@ static inline void region_maybe_clip(RegionRec *r, RegionRec *clip) RegionIntersect(r, r, clip); } +typedef struct box32 { + int32_t x1, y1, x2, y2; +} Box32Rec; + #define PM_IS_SOLID(_draw, _pm) \ (((_pm) & FbFullMask((_draw)->depth)) == FbFullMask((_draw)->depth)) @@ -979,6 +983,65 @@ static inline bool trim_and_translate_box(BoxPtr box, DrawablePtr d, GCPtr gc) return clipped; } +static inline bool box32_trim(Box32Rec *box, DrawablePtr d) +{ + bool clipped = false; + + if (box->x1 < 0) + box->x1 = 0, clipped = true; + if (box->x2 > d->width) + box->x2 = d->width, clipped = true; + + if (box->y1 < 0) + box->y1 = 0, clipped = true; + if (box->y2 > d->height) + box->y2 = d->height, clipped = true; + + return clipped; +} + +static inline bool box32_clip(Box32Rec *box, GCPtr gc) +{ + bool clipped = gc->pCompositeClip->data != NULL; + const BoxRec *clip = &gc->pCompositeClip->extents; + + if (box->x1 < clip->x1) + box->x1 = clip->x1, clipped = true; + if (box->x2 > clip->x2) + box->x2 = clip->x2, clipped = true; + + if (box->y1 < clip->y1) + box->y1 = clip->y1, clipped = true; + if (box->y2 > clip->y2) + box->y2 = clip->y2, clipped = true; + + return clipped; +} + +static inline void box32_translate(Box32Rec *box, DrawablePtr d) +{ + box->x1 += d->x; + box->x2 += d->x; + + box->y1 += d->y; + box->y2 += d->y; +} + +static inline bool box32_trim_and_translate(Box32Rec *box, DrawablePtr d, GCPtr gc) +{ + bool clipped; + + if (likely (gc->pCompositeClip)) { + box32_translate(box, d); + clipped = box32_clip(box, gc); + } else { + clipped = box32_trim(box, d); + box32_translate(box, d); + } + + return clipped; +} + static inline void box_add_pt(BoxPtr box, int16_t x, int16_t y) { if (box->x1 > x) @@ -1000,19 +1063,29 @@ static int16_t bound(int16_t a, uint16_t b) return v; } -static inline void box_add_rect(BoxPtr box, const xRectangle *r) +static inline bool box32_to_box16(const Box32Rec *b32, BoxRec *b16) { - int v; + b16->x1 = b32->x1; + b16->y1 = b32->y1; + b16->x2 = b32->x2; + b16->y2 = b32->y2; + + return b16->x2 > b16->x1 && b16->y2 > b16->y1; +} + +static inline void box32_add_rect(Box32Rec *box, const xRectangle *r) +{ + int32_t v; if (box->x1 > r->x) box->x1 = r->x; - v = bound(r->x, r->width); + v = r->x + r->width; if (box->x2 < v) box->x2 = v; if (box->y1 > r->y) box->y1 = r->y; - v =bound(r->y, r->height); + v = r->y + r->height; if (box->y2 < v) box->y2 = v; } @@ -5172,7 +5245,7 @@ sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc, int n, xRectangle *rect, BoxPtr out) { - BoxRec box; + Box32Rec box; bool clipped; if (n == 0) @@ -5181,17 +5254,16 @@ sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc, DBG(("%s: [0] = (%d, %d)x(%d, %d)\n", __FUNCTION__, rect->x, rect->y, rect->width, rect->height)); box.x1 = rect->x; - box.x2 = bound(box.x1, rect->width); + box.x2 = box.x1 + rect->width; box.y1 = rect->y; - box.y2 = bound(box.y1, rect->height); + box.y2 = box.y1 + rect->height; while (--n) - box_add_rect(&box, ++rect); + box32_add_rect(&box, ++rect); - clipped = trim_and_translate_box(&box, drawable, gc); - if (box_empty(&box)) + clipped = box32_trim_and_translate(&box, drawable, gc); + if (!box32_to_box16(&box, out)) return 0; - *out = box; return 1 | clipped << 1; } From ickle at kemper.freedesktop.org Sun Oct 30 08:25:05 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 08:25:05 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111030152505.D06C11000F@kemper.freedesktop.org> src/sna/sna_accel.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) New commits: commit 23b314729c43101e515e2625db2a2401c72c2596 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 15:24:21 2011 +0000 sna: Rewrite box32_add_rect() to enable int32_t promotion Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index d227184..3666544 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1077,15 +1077,17 @@ static inline void box32_add_rect(Box32Rec *box, const xRectangle *r) { int32_t v; - if (box->x1 > r->x) - box->x1 = r->x; - v = r->x + r->width; + v = r->x; + if (box->x1 > v) + box->x1 = v; + v += r->width; if (box->x2 < v) box->x2 = v; - if (box->y1 > r->y) - box->y1 = r->y; - v = r->y + r->height; + v = r->y; + if (box->y1 > v) + box->y1 = ; + v += r->height; if (box->y2 < v) box->y2 = v; } From ickle at kemper.freedesktop.org Sun Oct 30 08:35:16 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 08:35:16 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111030153516.CA05E1000F@kemper.freedesktop.org> src/sna/sna_accel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit af52e234a78bbde964a93ef8cce21f41a5c959f3 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 15:34:34 2011 +0000 sna: Fix compilation Remember to drink coffee and compile "obvious" fixes before pushing. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 3666544..47b8698 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1086,7 +1086,7 @@ static inline void box32_add_rect(Box32Rec *box, const xRectangle *r) v = r->y; if (box->y1 > v) - box->y1 = ; + box->y1 = v; v += r->height; if (box->y2 < v) box->y2 = v; From ickle at kemper.freedesktop.org Sun Oct 30 09:14:37 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 09:14:37 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111030161437.D4C411000F@kemper.freedesktop.org> src/sna/sna_accel.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) New commits: commit bb840ee09fa620648065884306fbe3e0da37ad77 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 16:13:04 2011 +0000 sna: Convert PolyRectangles to use Box32 For the same overflow protection. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 47b8698..c285c97 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4186,7 +4186,7 @@ sna_poly_rectangle_extents(DrawablePtr drawable, GCPtr gc, int n, xRectangle *r, BoxPtr out) { - BoxRec box; + Box32Rec box; int extra = gc->lineWidth >> 1; bool clipped; @@ -4195,20 +4195,11 @@ sna_poly_rectangle_extents(DrawablePtr drawable, GCPtr gc, box.x1 = r->x; box.y1 = r->y; - box.x2 = r->x + r->width; - box.y2 = r->y + r->height; + box.x2 = box.x1 + r->width; + box.y2 = box.y1 + r->height; - while (--n) { - r++; - if (r->x < box.x1) - box.x1 = r->x; - if (r->x + r->width > box.x2) - box.x2 = r->x + r->width; - if (r->y < box.y1) - box.y1 = r->y; - if (r->y + r->width > box.y2) - box.y2 = r->y + r->height; - } + while (--n) + box32_add_rect(&box, r++); box.x2++; box.y2++; @@ -4220,11 +4211,10 @@ sna_poly_rectangle_extents(DrawablePtr drawable, GCPtr gc, box.y2 += extra; } - if (box_empty(&box)) + clipped = box32_trim_and_translate(&box, drawable, gc); + if (!box32_to_box16(&box, out)) return 0; - clipped = trim_and_translate_box(&box, drawable, gc); - *out = box; return 1 | clipped << 1; } From danvet at kemper.freedesktop.org Sun Oct 30 09:34:40 2011 From: danvet at kemper.freedesktop.org (Daniel Vetter) Date: Sun, 30 Oct 2011 09:34:40 -0700 (PDT) Subject: xf86-video-intel: 4 commits - src/legacy/i810 Message-ID: <20111030163440.5523F1000F@kemper.freedesktop.org> src/legacy/i810/Makefile.am | 1 src/legacy/i810/i810.h | 14 ---- src/legacy/i810/i810_cursor.c | 19 +++--- src/legacy/i810/i810_driver.c | 21 ++---- src/legacy/i810/i810_io.c | 133 ------------------------------------------ 5 files changed, 19 insertions(+), 169 deletions(-) New commits: commit c7552cb819ae8c90975193c159236e0070628dd9 Author: Daniel Vetter <daniel.vetter at ffwll.ch> Date: Sun Oct 30 16:35:14 2011 +0100 i810: kill mmio vga access helpers Signed-Off-by: Daniel Vetter <daniel.vetter at ffwll.ch> diff --git a/src/legacy/i810/Makefile.am b/src/legacy/i810/Makefile.am index 3676da6..a1bdd85 100644 --- a/src/legacy/i810/Makefile.am +++ b/src/legacy/i810/Makefile.am @@ -14,7 +14,6 @@ liblegacy_i810_la_SOURCES = \ i810_dga.c \ i810_driver.c \ i810.h \ - i810_io.c \ i810_memory.c \ i810_reg.h \ i810_ring.h \ diff --git a/src/legacy/i810/i810.h b/src/legacy/i810/i810.h index c3a6255..3a355a3 100644 --- a/src/legacy/i810/i810.h +++ b/src/legacy/i810/i810.h @@ -74,14 +74,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. typedef struct _I810Rec *I810Ptr; -typedef void (*I810WriteIndexedByteFunc)(I810Ptr pI810, IOADDRESS addr, - uint8_t index, uint8_t value); -typedef uint8_t(*I810ReadIndexedByteFunc)(I810Ptr pI810, IOADDRESS addr, - uint8_t index); -typedef void (*I810WriteByteFunc)(I810Ptr pI810, IOADDRESS addr, - uint8_t value); -typedef uint8_t(*I810ReadByteFunc)(I810Ptr pI810, IOADDRESS addr); - extern void I810SetTiledMemory(ScrnInfoPtr pScrn, int nr, unsigned start, unsigned pitch, unsigned size); @@ -215,11 +207,6 @@ typedef struct _I810Rec { CloseScreenProcPtr CloseScreen; ScreenBlockHandlerProcPtr BlockHandler; - I810WriteIndexedByteFunc writeControl; - I810ReadIndexedByteFunc readControl; - I810WriteByteFunc writeStandard; - I810ReadByteFunc readStandard; - Bool directRenderingDisabled; /* DRI disabled in PreInit */ Bool directRenderingEnabled; /* false if XF86DRI not defined. */ diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c index 9509ae2..d8f7c45 100644 --- a/src/legacy/i810/i810_driver.c +++ b/src/legacy/i810/i810_driver.c @@ -652,8 +652,6 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) } #endif - /* We won't be using the VGA access after the probe */ - I810SetMMIOAccess(pI810); return TRUE; } diff --git a/src/legacy/i810/i810_io.c b/src/legacy/i810/i810_io.c deleted file mode 100644 index 954ed6e..0000000 --- a/src/legacy/i810/i810_io.c +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -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, 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. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. - -**************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* - * Authors: - * Daryll Strauss <daryll at precisioninsight.com> - * - */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "compiler.h" - -#include "i810.h" - -#define minb(p) *(volatile uint8_t *)(pI810->MMIOBase + (p)) -#define moutb(p,v) *(volatile uint8_t *)(pI810->MMIOBase + (p)) = (v) - -static void -I810WriteControlMMIO(I810Ptr pI810, IOADDRESS addr, uint8_t index, uint8_t val) -{ - moutb(addr, index); - moutb(addr + 1, val); -} - -static uint8_t -I810ReadControlMMIO(I810Ptr pI810, IOADDRESS addr, uint8_t index) -{ - moutb(addr, index); - return minb(addr + 1); -} - -static void -I810WriteStandardMMIO(I810Ptr pI810, IOADDRESS addr, uint8_t val) -{ - moutb(addr, val); -} - -static uint8_t -I810ReadStandardMMIO(I810Ptr pI810, IOADDRESS addr) -{ - return minb(addr); -} - -void -I810SetMMIOAccess(I810Ptr pI810) -{ - pI810->writeControl = I810WriteControlMMIO; - pI810->readControl = I810ReadControlMMIO; - pI810->writeStandard = I810WriteStandardMMIO; - pI810->readStandard = I810ReadStandardMMIO; -} commit e8b8adeab3b2e69a8684217271604a5f658f617d Author: Daniel Vetter <daniel.vetter at ffwll.ch> Date: Sun Oct 30 16:34:05 2011 +0100 i810: use vgahw functions instead of roll-your-own Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch> diff --git a/src/legacy/i810/i810_cursor.c b/src/legacy/i810/i810_cursor.c index 898a136..88829cb 100644 --- a/src/legacy/i810/i810_cursor.c +++ b/src/legacy/i810/i810_cursor.c @@ -239,26 +239,29 @@ I810SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) { int tmp; I810Ptr pI810 = I810PTR(pScrn); + vgaHWPtr hwp; #ifdef ARGB_CURSOR if (pI810->CursorIsARGB) return; #endif + hwp = VGAHWPTR(pScrn); + tmp = INREG8(PIXPIPE_CONFIG_0); tmp |= EXTENDED_PALETTE; OUTREG8(PIXPIPE_CONFIG_0, tmp); - pI810->writeStandard(pI810, DACMASK, 0xFF); - pI810->writeStandard(pI810, DACWX, 0x04); + hwp->writeDacMask(hwp, 0xFF); + hwp->writeDacWriteAddr(hwp, 0x04); - pI810->writeStandard(pI810, DACDATA, (bg & 0x00FF0000) >> 16); - pI810->writeStandard(pI810, DACDATA, (bg & 0x0000FF00) >> 8); - pI810->writeStandard(pI810, DACDATA, (bg & 0x000000FF)); + hwp->writeDacData(hwp, (bg & 0x00FF0000) >> 16); + hwp->writeDacData(hwp, (bg & 0x0000FF00) >> 8); + hwp->writeDacData(hwp, (bg & 0x000000FF)); - pI810->writeStandard(pI810, DACDATA, (fg & 0x00FF0000) >> 16); - pI810->writeStandard(pI810, DACDATA, (fg & 0x0000FF00) >> 8); - pI810->writeStandard(pI810, DACDATA, (fg & 0x000000FF)); + hwp->writeDacData(hwp, (fg & 0x00FF0000) >> 16); + hwp->writeDacData(hwp, (fg & 0x0000FF00) >> 8); + hwp->writeDacData(hwp, (fg & 0x000000FF)); tmp = INREG8(PIXPIPE_CONFIG_0); tmp &= ~EXTENDED_PALETTE; diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c index 83c999f..9509ae2 100644 --- a/src/legacy/i810/i810_driver.c +++ b/src/legacy/i810/i810_driver.c @@ -790,7 +790,7 @@ DoSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, I810RegPtr i810Reg, * into the fields of the vgaI810Rec structure goes here. */ i810Reg->IOControl = hwp->readCrtc(hwp, IO_CTNL); - i810Reg->AddressMapping = pI810->readControl(pI810, GRX, ADDRESS_MAPPING); + i810Reg->AddressMapping = hwp->readGr(hwp, ADDRESS_MAPPING); i810Reg->BitBLTControl = INREG8(BITBLT_CNTL); i810Reg->VideoClk2_M = INREG16(VCLK2_VCO_M); i810Reg->VideoClk2_N = INREG16(VCLK2_VCO_N); @@ -985,10 +985,10 @@ DoRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, I810RegPtr i810Reg, temp |= i810Reg->InterlaceControl; hwp->writeCrtc(hwp, INTERLACE_CNTL, temp); - temp = pI810->readControl(pI810, GRX, ADDRESS_MAPPING); + temp = hwp->readGr(hwp, ADDRESS_MAPPING); temp &= 0xE0; /* Save reserved bits 7:5 */ temp |= i810Reg->AddressMapping; - pI810->writeControl(pI810, GRX, ADDRESS_MAPPING, temp); + hwp->writeGr(hwp, ADDRESS_MAPPING, temp); /* Setting the OVRACT Register for video overlay */ { @@ -2061,6 +2061,7 @@ I810DisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, I810Ptr pI810; unsigned char SEQ01 = 0; int DPMSSyncSelect = 0; + vgaHWPtr hwp; pI810 = I810PTR(pScrn); switch (PowerManagementMode) { @@ -2086,9 +2087,11 @@ I810DisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, break; } + hwp = VGAHWPTR(pScrn); + /* Turn the screen on/off */ - SEQ01 |= pI810->readControl(pI810, SRX, 0x01) & ~0x20; - pI810->writeControl(pI810, SRX, 0x01, SEQ01); + SEQ01 |= hwp->readSeq(hwp, 0x01) & ~0x20; + hwp->writeSeq(hwp, 0x01, SEQ01); /* Set the DPMS mode */ OUTREG8(DPMS_SYNC_SELECT, DPMSSyncSelect); commit 4aeea489ed3189d7ebcae4199153c1ae736ebf68 Author: Daniel Vetter <daniel.vetter at ffwll.ch> Date: Sun Oct 30 16:07:45 2011 +0100 i810: rip out PIO access functions All the io done at init time is already converted to libpciaccess Signed-Off-by: Daniel Vetter <daniel.vetter at ffwll.ch> diff --git a/src/legacy/i810/i810.h b/src/legacy/i810/i810.h index 6620695..c3a6255 100644 --- a/src/legacy/i810/i810.h +++ b/src/legacy/i810/i810.h @@ -178,7 +178,6 @@ typedef struct _I810Rec { int Chipset; unsigned long LinearAddr; unsigned long MMIOAddr; - IOADDRESS ioBase; EntityInfoPtr pEnt; struct pci_device *PciInfo; diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c index 3637e25..83c999f 100644 --- a/src/legacy/i810/i810_driver.c +++ b/src/legacy/i810/i810_driver.c @@ -234,7 +234,6 @@ I810DoDDC(ScrnInfoPtr pScrn, int index) static Bool I810PreInit(ScrnInfoPtr pScrn, int flags) { - vgaHWPtr hwp; I810Ptr pI810; ClockRangePtr clockRanges; int i; @@ -270,8 +269,6 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) /* Allocate a vgaHWRec */ if (!vgaHWGetHWRec(pScrn)) return FALSE; - hwp = VGAHWPTR(pScrn); - pI810->ioBase = hwp->PIOOffset; pI810->PciInfo = xf86GetPciInfoForEntity(pI810->pEnt->index); @@ -378,9 +375,6 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) */ I810DoDDC(pScrn, pI810->pEnt->index); - /* We have to use PIO to probe, because we haven't mapped yet */ - I810SetPIOAccess(pI810); - intel_detect_chipset(pScrn, pI810->PciInfo, &chipset); /* diff --git a/src/legacy/i810/i810_io.c b/src/legacy/i810/i810_io.c index b485cef..954ed6e 100644 --- a/src/legacy/i810/i810_io.c +++ b/src/legacy/i810/i810_io.c @@ -45,43 +45,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define moutb(p,v) *(volatile uint8_t *)(pI810->MMIOBase + (p)) = (v) static void -I810WriteControlPIO(I810Ptr pI810, IOADDRESS addr, uint8_t index, uint8_t val) -{ - addr += pI810->ioBase; - outb(addr, index); - outb(addr + 1, val); -} - -static uint8_t -I810ReadControlPIO(I810Ptr pI810, IOADDRESS addr, uint8_t index) -{ - addr += pI810->ioBase; - outb(addr, index); - return inb(addr + 1); -} - -static void -I810WriteStandardPIO(I810Ptr pI810, IOADDRESS addr, uint8_t val) -{ - outb(pI810->ioBase + addr, val); -} - -static uint8_t -I810ReadStandardPIO(I810Ptr pI810, IOADDRESS addr) -{ - return inb(pI810->ioBase + addr); -} - -void -I810SetPIOAccess(I810Ptr pI810) -{ - pI810->writeControl = I810WriteControlPIO; - pI810->readControl = I810ReadControlPIO; - pI810->writeStandard = I810WriteStandardPIO; - pI810->readStandard = I810ReadStandardPIO; -} - -static void I810WriteControlMMIO(I810Ptr pI810, IOADDRESS addr, uint8_t index, uint8_t val) { moutb(addr, index); commit e735636194671e221eca3e86b9bd06fd0d4b6c5a Author: Daniel Vetter <daniel.vetter at ffwll.ch> Date: Sun Oct 30 15:51:49 2011 +0100 i810: kill dead i830 defines Signed-Off-by: Daniel Vetter <daniel.vetter at ffwll.ch> diff --git a/src/legacy/i810/i810_io.c b/src/legacy/i810/i810_io.c index a6cf305..b485cef 100644 --- a/src/legacy/i810/i810_io.c +++ b/src/legacy/i810/i810_io.c @@ -39,23 +39,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86_OSproc.h" #include "compiler.h" -#ifdef BUILD_FOR_I830 -#include "i830.h" -#define pI810 pI830 -#define I810Ptr I830Ptr -#define I810WriteControlPIO I830WriteControlPIO -#define I810ReadControlPIO I830ReadControlPIO -#define I810WriteStandardPIO I830WriteStandardPIO -#define I810ReadStandardPIO I830ReadStandardPIO -#define I810SetPIOAccess I830SetPIOAccess -#define I810WriteControlMMIO I830WriteControlMMIO -#define I810ReadControlMMIO I830ReadControlMMIO -#define I810WriteStandardMMIO I830WriteStandardMMIO -#define I810ReadStandardMMIO I830ReadStandardMMIO -#define I810SetMMIOAccess I830SetMMIOAccess -#else #include "i810.h" -#endif #define minb(p) *(volatile uint8_t *)(pI810->MMIOBase + (p)) #define moutb(p,v) *(volatile uint8_t *)(pI810->MMIOBase + (p)) = (v) From ickle at kemper.freedesktop.org Sun Oct 30 09:49:48 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 09:49:48 -0700 (PDT) Subject: xf86-video-intel: 2 commits - configure.ac NEWS Message-ID: <20111030164948.947701000F@kemper.freedesktop.org> NEWS | 24 ++++++++++++++++++++++++ configure.ac | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) New commits: commit 7237374a03d1e0c2e6c0b2d0eb42afc8df25df0d Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 16:46:10 2011 +0000 configure: Bump version to 2.16.901 diff --git a/configure.ac b/configure.ac index 0a60bd7..102a25a 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ # Initialize Autoconf AC_PREREQ([2.63]) AC_INIT([xf86-video-intel], - [2.16.0], + [2.16.901], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xf86-video-intel]) AC_CONFIG_SRCDIR([Makefile.am]) commit 0a78a75e75225d89e465804c482a667840a2c8de Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 16:45:46 2011 +0000 NEWS: Add release notes for 2.16.901 diff --git a/NEWS b/NEWS index 46d0d24..c736d63 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,27 @@ +Snapshot 2.16.901 (2011-10-30) +============================== +This is the first release candidate in preparation for the upcoming +2.17.0 release. We will appreciate any feedback we can get from +testing of this snapshot. + +The basis of this release are to push out a couple of critical stability +fixes for SandyBridge and IvyBridge. There is very little else to see +here. Those 200+ other commits do not exist... + +Bugs fixed in this snapshot (compared to 2.16.0) +-------------------------------------------------- + + * Workaround blitter hang on SandyBridge and IvyBridge + https://bugzilla.kernel.org/show_bug.cgi?id=27892 + https://bugs.freedesktop.org/show_bug.cgi + + * Workaround pipe control issues on SandyBridge + + * Use correct maximum PS thread count on IvyBridge + + * Protect against failed pixmap allocation for XV + https://bugs.freedesktop.org/show_bug.cgi?id=40439 + Release 2.16.0 (2011-08-09) ============================== A new quarter, a new release! The key feature of this release, looking past From ickle at kemper.freedesktop.org Sun Oct 30 09:50:00 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 09:50:00 -0700 (PDT) Subject: xf86-video-intel: Changes to 'refs/tags/2.16.901' Message-ID: <20111030165000.F423B1000F@kemper.freedesktop.org> Tag '2.16.901' created by Chris Wilson <chris at chris-wilson.co.uk> at 2011-10-30 17:49 -0700 Intel 2.16.901 snapshot Changes since 2.16.0: Chris Wilson (252): sna/damage: Take advantage of marking all-damaged sna/gradient: Use a high-precision ramp for a color step rather than fallback sna/trapezoids: Speedup tor rasteriser sna/render: allow CLAMP_TO_EDGE for outside samples of extract regions as well sna/gen3: reset blend state after applying CA pass sna/display: Destroy shadow data sna/dri2: Add some debug around the use of the Resource database sna: Clear structures across server reset sna/video: Flush the video state at the end of the operation sna/accel: Simplify single pixel read-back sna/trapezoids: Reduce imprecise sampling to 4x4 sna/trapezoids: Use the tor scan converter to compute the low precision mask video: check that the pixmap exists before use sna/video: Defend against PutImage to a broken screen sna: Cleanup up the cache upon close sna: Free the buffers immediately upon release sna: Retain the GTT space used for an upload buffer sna/trapezoids: Allocate sufficient space for a8 mask for mono traps sna/trapezoids: Reject invalid traps after projecting onto the sample grid sna/trapezoids: Refactor to project the trapezoid only once sna/gen6: Prefer the BLT ring, except for copies on behalf of DRI sna: Use the shadow buffer for PutImage sna/trapezoids: Edges may lie out of bounds sna: Add missing implementation for Triangles sna/trapezoids: Check for alignment after projection sna/gen2: Improve batch decoder. sna/gen2: Flush the batch when we run out of vertex space sna/gen3: Do not assume video updates are always vsync'ed sna/traps: Use the trapezoid path for AddTraps sna/trapezoids: Fast upload path for gpu busy bo sna/trapezoids: Hook up Imprecise AddTraps in lieu of spans sna: Record git-tree used for compilation sna: Prefer memcpy_blt over fbBlt sna/gen5: Prefer BLT for solids sna/gen3: Use a clear pattern for ill-defined radial gradients sna: Mark the bo as reusable after extracting the handle from the buffer gitignore: add git_version.h sna/trapezoids: Prevent a memleak if feed lots of degenerate boxes sna: Fix compilation without timerfd() sna: Provide a direct lookup cache of alpha values sna: Use single precision for computing the texcoord scale factor sna/gen6: Prefer RENDER for copies as it compacts better sna: Avoid the call overhead for the trivial clip case sna/gen5: Avoid bitfields for simple assignments sna/gen5: Fix debug compilation sna/accel: Use correct enum for requesting a write-buffer sna: Don't clear the kernel-needs-flush flag if we emit a MI_FLUSH sna: Reuse the smallest bo that fits the request sna/trapezoids: Implement a mono-rasteriser to skip opacity spans sna/video: Stop advertising unsupported Xv attributes video: Stop advertising unsupported Xv attributes sna: Add a couple of debug statements for why we may not flush the scanout sna/debug: Assert that BLT commands on gen2/3 are properly fenced sna: Clear the list of buffers upon server regen sna/gen3: Reset the shader after playing video sna: assert that the memcpy upload path points to valid regions sna: Yet another s/x/y/ typo sna/trapezoids: Amalgamate adjacent mono spans configure: Introduce --with-builderstring sna: Remove bad assert sna: Debug option to disable tiling sna: Can't free bo from the active list sna/glyphs: Correct offset of fallback-via-mask glyphs sna/glyphs: Disable the glyph cache for debugging sna: Add debug option to force allocaiton of gpu-only pixmaps sna/trapezoids: Ensure we do not overrun the vertical edges for mono sna: Apply the screen offset for direct upload of a composited pixmap sna: perform a warnings reduction pass sna: compile fixes for debugging sna/trapezoids: Fix overflow during sorting of mono edge step sna: Move an assertion to the point of import sna: Use pot buckets for active cache sna/dri: Play with marking bo reusable sna/dri: Bump DRI2INFOREC_VERSION sna: move an assert sna/accel: fix assert to include the offset of copy sna/accel: Only skip undamaging the GPU for reads sna/accel: Always subtract the enlarged region from the outstanding GPU damage sna/accel: Use the PolyFillRect to handle tiled spans sna: Add a debug option to disable caching sna/glyphs: Convert all sub-8bpp masks to a8 sna/gen5: Debug option to disable state caching sna: Paranoid debug flush after every op (as well as before) sna/kgem: Check all operation bo in a single amalgamation sna/glyph: Avoid useless attempt at GPU glyph rendering to a1 destinations sna/glyphs: Add glyphs directly onto a client temporary buffer sna/accel: Debug option to force CPU fallbacks sna/accel: Fix s/x/y/ typo in computing relative drawing coordinates sna/gen7: Fix up a couple instances of my inability to count sna/gen7: Confusion reigns as trying to fix errors found by an outdated checker sna: Check for request retires after every batch sna/gen6: Fix offset of Scan-Line-Compare register sna/io: Only mark the buffer as LAST if we know we will flush the IO sna: Sort partials by remaining space sna/accel: Use the mi*Line routines to convert the line into spans for gpu bo sna/accel: Convert segments into spans similarly to PolyLine sna/accel: Use miPolyArc to convert arcs into spans for gpu bo sna/accel: Don't attempt converting to spans if we will only fallback sna/accel: Micro-optimise sna_fill_spans_blt sna/accel: Only disable the flush migitration if nothing changed sna/accel: Add an compile option to disable use of spans sna/accel: Add a compile option to force flushing on every blockhandler sna/accel: Only throttle after flushing sna/accel: Correct syntax for constifying BoxPtr sna/blt: Use SETUP_MONO to reduce the number of fill relocations sna/blt: SETUP_BLT needs 9 dwords of batch space, not 3! sna/blt: Suppress repeated SETUP_BLT sna: Move the source to the GPU if it is reused sna/gen[23]: Fix compilation with debugging enabled sna: Increase reserved space in batch to accommodate gen5 workaround sna: Use BLT operations to avoid fallbacks in core glyph rendering sna: Support a fast composite hook for solitary boxes sna/gen6: Add render support for fill-one-box sna/gen7: Add render support for fill one sna/gen3: avoid applying zero offset to common spans sna/trapezoid: Perform the NULL check for damage in the caller sna: Mark the spans render functions as fastcall sna: use correct insertion point for sorting partials sna/accel: If the data is already on the GPU, use it for the source sna: Enable single fill fast path for PolySegment sna/gen3: Avoid RENDER/BLT context switch for fill boxes sna: Micro-optimise checking for singular clip boxes sna: More micro-optimisation of messing around with clip regions sna: And free the clip after creation for PolySegments sna: compare against the right array of cache buckets Remove vestigial includes from DRI1 sna/gen2: Trim some surplus state commands sna/blt: Check for reloc overflow when initialising solid fills sna/accel: Check for reloc overflow when adding a new glyph run sna/accel: Correctly offset the damage intersection for glyph runs sna/accel: Actually apply the clip to the glyph extents sna/accel: Fix sense of nothing-to-do due to clipping sna: Ensure that the scanout is flushed before we sleep sna/tiling: Hook up composite_box sna/trapezoids: Fallback if the composite operation is not supported sna/blt: Add a pair of operator reductions for opaque fills Remove a couple of trivial compile warnings for unused variables sna/gen7: Add missing tail to 3DSTATE_SBE sna/gen2: Fix fill-one-box sna/gen2: Eliminate redundant diffuse and rectlist emission sna/accel: Fall-forward for handling a non-copy CopyArea to a dst gpu bo sna/accel: Upload source to GPU for !copy CopyAreas sna: Simplify busy tracking by trusting the bo->gpu flag sna: Prefer to accelerate non-RENDER operations if already using the GPU sna: Defer CPU fallback if fb calls into mi configure: Add a check for pixman version sna/gen3: Improve reduction of render operator to blt sna/gen3: Store floats_per_rect alongside floats_per_vertex sna/gen3: Micro-optimise gen3_rectangle_begin() snb,ivb: Workaround unknown blitter death sna/damage: Clear damage->all when subtracting sna/gen3: Remove memset(0) from fill_boxes sna: Improve debug output for mi/fb fallbacks sna/accel: Implement a simpler path for CopyArea between the same pixmaps sna: Fast path common colour conversions sna/gen5: Rearrange the BLT->RENDER workaround sna/gen3: More removal of memset(0) sna/gen3: Use immediates for black/white solid sources sna: Only retire the flush handler if nothing was submitted within the period sna: Some more debug output for request/bo retirement sna/gen3: Prefer to use the BLT to clear the scratch glyph pixmaps sna/gen3: Prefer to use the BLT where possible for composite ops sna/gen2: Prefer to use the BLT sna/gen2: Precompute floats-per-rect sna/gen6: Micro-optimise gen6_rectangle_begin sna/gen6: Try continuing with the BLT if the last batch was also BLT sna/gen5: Add fill-one implementation sna/gen6: Precompute floats_per_rect sna/gen4: Add fill-one sna/blt: Move the conditional out of the fill-many hotpath sna/gen6: Don't modify composite arguments whilst checking for BLT sna: Micro-optimise fill-spans sna: Use the unlikely wedged() throughout sna: Compute region extents in place to eliminate redundant stack space sna/gen6: Apply the unknown blitter death workaround sna/damage: Avoid reducing the damage for simple tests sna: Enlarge the minimum pixmap size to migrate for Render sna: Don't rewrite the solid colour cache if it hasn't changed sna: Reset the ring flag upon idling sna: The initial aperture check for a set of bo is unlikely to fail sna/blt: Use SCANLINE_BLT for multiple fill boxes sna: Clean up some debug messages for 64bit sna: Add some debug to discern the nature of the Cr fallback sna: Reuse any partial write buffer for readback sna/dri: Perform a little dance to restore the gpu status on release of the bo sna: Actually apply the composite offset for the self-copy sna/damage: Only track the mode globally sna/damage: Stash the last freed damage for quick reallocation sna: Speed-up blitting of unclipped lines sna: Check whether we can blt whilst determining the PolyLine extents sna: Pass a BoxRec to the fill op sna: Remove the memset(0) of the fill op sna: Micro-optimise PolyLine blt sna: Short-circuit GetWindowPixmap() to speed-up pixmap retrieval sna: Fast-path unclipped fill spans sna: Optimise reduce_damage() to handle all-damaged pixmaps sna: Fast path for unclipped rectangles sna: Fast path unclipped points sna: Treat a bo marked as being last seen on the GPU as requiring a flush sna: Fix debug compilation sna: Execute blits directly for PolyRectangle sna/blt: Upload the box using a single 64-bit instruction sna: Flatten the branching for fill-spans sna: Convert diagonal zero-width lines into blits self-copy-damage sna: Use the new fill->boxes for PolyRectangle sna: Use fill->boxes to unroll PolyPoint sna: Use fill->boxes to unroll FillSpans sna: Inline box_intersect() sna/blt: Share the common fill->boxes between blt and render paths sna/blt: Rename the composite paths sna: Handle degenerate copy area whilst wedged sna: Fix debug compilation, again. sna/composite: Discard opaque masks sna/gen2: Cache the last solid colour for spans sna: Suppress an overwritten fill sna/blt: Convert Copy with color 0 into a Clear sna/blt: After submitting the batch, it will be empty sna: Further improve use of fill->boxes for PolyRectangle sna/io: Update batch mode after submitting partial requests sna: Handle singular clip regions for PolyRectangles sna: Clip PolyLines to the current clip box sna: Use fill->boxes for rectilinear blits sna: Use fill->boxes to pack PolyFillRectangle sna: Fix PolyPoint not to always send 512 boxes sna: Fix advance through clip boxes for fill->boxes sna: Tweak zero line spans to include missing last segment sna: Create scratch pixmap on the CPU sna: Use private identifier for internal scratch pixmaps sna: Fast path typically unclipped tiled rects sna/gen2: Reset BLT registers across 2D/3D context switches sna: Faster unclipped spans sna: Call directly into tiled rects for tiled spans. sna: Faster unclipped PolyPoint sna: Faster unclipped PolyFillRect sna: Call miZeroArcLine where appropriate for GPU paths sna: Faster unclipped rectilinear segments sna: Don't flush the render caches if in the process of writing again sna: Retire and search inactive again before creating new buffer sna: Increment clip box when short-circuiting the iteration sna: Further clipping bugs sna: Tweak PolyRectangle blitting sna/genX: Improve reduction of Render operator to BLT alu sna/gen3: Set the src flags for fill sna/composite: Fix incorrect operator reduction for RenderFillRectangles Revert "sna: Don't flush the render caches if in the process of writing again" sna: Push overflow detection to the end of extents sna: Rewrite box32_add_rect() to enable int32_t promotion sna: Fix compilation sna: Convert PolyRectangles to use Box32 NEWS: Add release notes for 2.16.901 configure: Bump version to 2.16.901 Daniel Vetter (5): snb: implement PIPE_CONTROL workaround i810: kill dead i830 defines i810: rip out PIO access functions i810: use vgahw functions instead of roll-your-own i810: kill mmio vga access helpers Jeremy Huddleston (1): Use malloc/calloc/realloc/free directly Kenneth Graunke (1): Fix incorrect maximum PS thread count on IvyBridge Paulo Zanoni (2): Fix "always false" conditionals Remove useless assertion Stefan Dirsch (1): Fix array size calculation for intel_pci_probe(). --- .gitignore | 1 NEWS | 24 configure.ac | 34 src/i965_reg.h | 4 src/i965_render.c | 71 src/intel.h | 9 src/intel_batchbuffer.c | 50 src/intel_driver.c | 7 src/intel_module.c | 4 src/intel_uxa.c | 28 src/intel_video.c | 38 src/legacy/i810/Makefile.am | 1 src/legacy/i810/i810.h | 14 src/legacy/i810/i810_cursor.c | 19 src/legacy/i810/i810_driver.c | 21 src/legacy/i810/i810_io.c | 133 - src/legacy/i810/xvmc/I810XvMC.c | 2 src/sna/Makefile.am | 8 src/sna/compiler.h | 43 src/sna/gen2_render.c | 982 +++++---- src/sna/gen3_render.c | 781 +++++-- src/sna/gen4_render.c | 281 ++ src/sna/gen5_render.c | 397 ++- src/sna/gen5_render.h | 47 src/sna/gen6_render.c | 371 ++- src/sna/gen7_render.c | 324 ++- src/sna/gen7_render.h | 4 src/sna/kgem.c | 502 +++- src/sna/kgem.h | 56 src/sna/kgem_debug.c | 14 src/sna/kgem_debug_gen2.c | 631 +++++ src/sna/kgem_debug_gen3.c | 1 src/sna/sna.h | 64 src/sna/sna_accel.c | 4306 ++++++++++++++++++++++++++++++++-------- src/sna/sna_blt.c | 741 +++++- src/sna/sna_composite.c | 87 src/sna/sna_damage.c | 666 +++++- src/sna/sna_damage.h | 57 src/sna/sna_display.c | 27 src/sna/sna_dri.c | 110 - src/sna/sna_driver.c | 22 src/sna/sna_glyphs.c | 101 src/sna/sna_gradient.c | 67 src/sna/sna_io.c | 33 src/sna/sna_reg.h | 6 src/sna/sna_render.c | 139 - src/sna/sna_render.h | 60 src/sna/sna_render_inline.h | 8 src/sna/sna_tiling.c | 27 src/sna/sna_trapezoids.c | 3116 +++++++++++++++++++++++----- src/sna/sna_video.c | 12 src/sna/sna_video_textured.c | 19 src/xvmc/i965_xvmc.c | 2 src/xvmc/intel_batchbuffer.h | 1 src/xvmc/intel_xvmc.c | 2 src/xvmc/xvmc_vld.c | 2 56 files changed, 11508 insertions(+), 3069 deletions(-) --- From ickle at kemper.freedesktop.org Sun Oct 30 10:19:37 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 10:19:37 -0700 (PDT) Subject: xf86-video-intel: src/sna/blt.c src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_composite.c src/sna/sna_dri.c src/sna/sna_driver.c src/sna/sna_glyphs.c src/sna/sna_io.c src/sna/sna_render.c src/sna/sna_tiling.c src/sna/sna_trapezoids.c src/sna/sna_video_textured.c Message-ID: <20111030171937.1C9FA1000F@kemper.freedesktop.org> src/sna/blt.c | 2 -- src/sna/gen2_render.c | 2 -- src/sna/gen3_render.c | 2 -- src/sna/gen4_render.c | 2 -- src/sna/gen5_render.c | 2 -- src/sna/gen6_render.c | 2 -- src/sna/gen7_render.c | 2 -- src/sna/kgem.c | 2 -- src/sna/sna_accel.c | 2 -- src/sna/sna_blt.c | 2 -- src/sna/sna_composite.c | 2 -- src/sna/sna_dri.c | 2 -- src/sna/sna_driver.c | 2 -- src/sna/sna_glyphs.c | 2 -- src/sna/sna_io.c | 2 -- src/sna/sna_render.c | 2 -- src/sna/sna_tiling.c | 2 -- src/sna/sna_trapezoids.c | 2 -- src/sna/sna_video_textured.c | 2 -- 19 files changed, 38 deletions(-) New commits: commit 1eefb75c91fb769551b485f1b2c6b59023c69906 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 17:17:36 2011 +0000 sna: Don't mess with NDEBUG This is set in configure and redefining it later inside the C files just leads to trouble and broken compilation. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/blt.c b/src/sna/blt.c index ac20372..3b07d83 100644 --- a/src/sna/blt.c +++ b/src/sna/blt.c @@ -34,8 +34,6 @@ #if DEBUG_BLT #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif void diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index d2a296c..2577493 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -41,8 +41,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_COMPOSITE 0 diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index eca841e..bf68841 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -40,8 +40,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_COMPOSITE 0 diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c index c603e67..8f59dc1 100644 --- a/src/sna/gen4_render.c +++ b/src/sna/gen4_render.c @@ -47,8 +47,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif /* gen4 has a serious issue with its shaders that we need to flush diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c index 3006bd1..c48e828 100644 --- a/src/sna/gen5_render.c +++ b/src/sna/gen5_render.c @@ -47,8 +47,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define DBG_NO_STATE_CACHE 0 diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c index b7f0ed0..51d26c8 100644 --- a/src/sna/gen6_render.c +++ b/src/sna/gen6_render.c @@ -47,8 +47,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_COMPOSITE 0 diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c index 4667bad..3be87b7 100644 --- a/src/sna/gen7_render.c +++ b/src/sna/gen7_render.c @@ -47,8 +47,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_COMPOSITE 0 diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 4827fb8..86cde01 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -72,8 +72,6 @@ static inline void list_replace(struct list *old, #if DEBUG_KGEM #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define PAGE_SIZE 4096 diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index c285c97..eb8295c 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -52,8 +52,6 @@ #if DEBUG_ACCEL #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define FORCE_GPU_ONLY 0 diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index ffe81df..1630b35 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -44,8 +44,6 @@ #if DEBUG_BLT #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_BLT_COMPOSITE 0 diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index 0373bad..7c599be 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -39,8 +39,6 @@ #if DEBUG_COMPOSITE #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif static void dst_move_area_to_cpu(PicturePtr picture, diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c index 2fcc060..f724026 100644 --- a/src/sna/sna_dri.c +++ b/src/sna/sna_dri.c @@ -72,8 +72,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #if DEBUG_DRI #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_TRIPPLE_BUFFER 0 diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 83abdb3..3e3f65c 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -78,8 +78,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #if DEBUG_DRIVER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif static OptionInfoRec sna_options[] = { diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index 7b98b0c..7c4b73f 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -73,8 +73,6 @@ #if DEBUG_GLYPHS #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define FALLBACK 0 diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c index f97b88a..a36adc9 100644 --- a/src/sna/sna_io.c +++ b/src/sna/sna_io.c @@ -38,8 +38,6 @@ #if DEBUG_IO #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define PITCH(x, y) ALIGN((x)*(y), 4) diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index 4017f91..badde7c 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -34,8 +34,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_REDIRECT 0 diff --git a/src/sna/sna_tiling.c b/src/sna/sna_tiling.c index 295936b..bab299e 100644 --- a/src/sna/sna_tiling.c +++ b/src/sna/sna_tiling.c @@ -37,8 +37,6 @@ #if DEBUG_RENDER #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif struct sna_tile_state { diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index 80b4733..a6b8562 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -41,8 +41,6 @@ #if DEBUG_TRAPEZOIDS #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define NO_ACCEL 0 diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index 6ff0868..64d54ec 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -42,8 +42,6 @@ #if DEBUG_VIDEO_TEXTURED #undef DBG #define DBG(x) ErrorF x -#else -#define NDEBUG 1 #endif #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) From ickle at kemper.freedesktop.org Sun Oct 30 10:51:35 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Sun, 30 Oct 2011 10:51:35 -0700 (PDT) Subject: xf86-video-intel: 2 commits - src/sna/sna_accel.c uxa/uxa-glyphs.c Message-ID: <20111030175135.2C7081000F@kemper.freedesktop.org> src/sna/sna_accel.c | 195 ++++++++++++++++++++++++++++------------------------ uxa/uxa-glyphs.c | 17 ++++ 2 files changed, 121 insertions(+), 91 deletions(-) New commits: commit 5c45622b889ba66b6476241601e1458d219c45ba Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 17:49:19 2011 +0000 uxa/glyphs: Fallback rather than fail to render with a non-solid Source Reported-by: Uli Schlachter <psychon at znc.in> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31819 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/uxa/uxa-glyphs.c b/uxa/uxa-glyphs.c index 7b2edea..6c9ea0d 100644 --- a/uxa/uxa-glyphs.c +++ b/uxa/uxa-glyphs.c @@ -1033,6 +1033,19 @@ next_glyph: return 0; } +static Bool +is_solid(PicturePtr picture) +{ + if (picture->pSourcePict) { + SourcePict *source = picture->pSourcePict; + return source->type == SourcePictTypeSolidFill; + } else { + return (picture->repeat && + picture->pDrawable->width == 1 && + picture->pDrawable->height == 1); + } +} + void uxa_glyphs(CARD8 op, PicturePtr pSrc, @@ -1053,7 +1066,9 @@ uxa_glyphs(CARD8 op, uxa_screen->swappedOut || uxa_screen->force_fallback || !uxa_drawable_is_offscreen(pDst->pDrawable) || - pDst->alphaMap || pSrc->alphaMap) { + pDst->alphaMap || pSrc->alphaMap || + /* XXX we fail to handle (rare) non-solid sources correctly. */ + !is_solid(pSrc)) { fallback: uxa_check_glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); return; commit e6eb803cb44b01e300fb4b08304227a430912beb Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 17:44:26 2011 +0000 sna: Loop over all clip rects for glyph blt rather than fallback Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index eb8295c..6f0275b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -5375,8 +5375,8 @@ static uint8_t blt_depth(int depth) static bool sna_glyph_blt(DrawablePtr drawable, GCPtr gc, - int x, int y, unsigned int n, - CharInfoPtr *info, pointer base, + int _x, int _y, unsigned int _n, + CharInfoPtr *_info, pointer _base, bool transparent, const BoxRec *extents) { @@ -5384,6 +5384,7 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, PixmapPtr pixmap = get_drawable_pixmap(drawable); struct sna_pixmap *priv = sna_pixmap(pixmap); struct sna_damage **damage; + const BoxRec *last_extents; uint32_t *b; int16_t dx, dy; @@ -5419,25 +5420,16 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, if (!RegionNotEmpty(&clip)) return true; - /* XXX loop over clips using SETUP_CLIP? */ - if (clip.data != NULL) { - DBG(("%s -- fallback too many clip rects [%d]\n", - __FUNCTION__, REGION_NUM_RECTS(&clip))); - RegionUninit(&clip); - return false; - } - damage = priv->gpu_only ? NULL : reduce_damage(drawable, &priv->gpu_damage, extents), get_drawable_deltas(drawable, pixmap, &dx, &dy); - x += drawable->x + dx; - y += drawable->y + dy; + _x += drawable->x + dx; + _y += drawable->y + dy; - clip.extents.x1 += dx; - clip.extents.x2 += dx; - clip.extents.y1 += dy; - clip.extents.y2 += dy; + RegionTranslate(&clip, dx, dy); + extents = REGION_RECTS(&clip); + last_extents = extents + REGION_NUM_RECTS(&clip); kgem_set_mode(&sna->kgem, KGEM_BLT); if (!kgem_check_batch(&sna->kgem, 16) || @@ -5455,8 +5447,8 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, b[1] >>= 2; } b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16; - b[2] = clip.extents.y1 << 16 | clip.extents.x1; - b[3] = clip.extents.y2 << 16 | clip.extents.x2; + b[2] = extents->y1 << 16 | extents->x1; + b[3] = extents->y2 << 16 | extents->x2; b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4, priv->gpu_bo, I915_GEM_DOMAIN_RENDER << 16 | @@ -5468,87 +5460,110 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc, b[7] = 0; sna->kgem.nbatch += 8; - while (n--) { - CharInfoPtr c = *info++; - uint8_t *glyph = FONTGLYPHBITS(base, c); - int w = GLYPHWIDTHPIXELS(c); - int h = GLYPHHEIGHTPIXELS(c); - int stride = GLYPHWIDTHBYTESPADDED(c); - int w8 = (w + 7) >> 3; - int x1, y1, len, i; - uint8_t *byte; + do { + CharInfoPtr *info = _info; + int x = _x, y = _y, n = _n; - if (w == 0 || h == 0) - goto skip; + do { + CharInfoPtr c = *info++; + uint8_t *glyph = FONTGLYPHBITS(base, c); + int w = GLYPHWIDTHPIXELS(c); + int h = GLYPHHEIGHTPIXELS(c); + int stride = GLYPHWIDTHBYTESPADDED(c); + int w8 = (w + 7) >> 3; + int x1, y1, len, i; + uint8_t *byte; + + if (w == 0 || h == 0) + goto skip; + + len = (w8 * h + 7) >> 3 << 1; + DBG(("%s glyph: (%d, %d) x (%d[%d], %d), len=%d\n" ,__FUNCTION__, + x,y, w, w8, h, len)); + + x1 = x + c->metrics.leftSideBearing; + y1 = y - c->metrics.ascent; + + if (x1 >= extents->x2 || y1 >= extents->y2) + goto skip; + if (x1 + w <= extents->x1 || y1 + h <= extents->y1) + goto skip; + + if (!kgem_check_batch(&sna->kgem, 3+len)) { + _kgem_submit(&sna->kgem); + _kgem_set_mode(&sna->kgem, KGEM_BLT); + + b = sna->kgem.batch + sna->kgem.nbatch; + b[0] = XY_SETUP_BLT | 1 << 20; + b[1] = priv->gpu_bo->pitch; + if (sna->kgem.gen >= 40) { + if (priv->gpu_bo->tiling) + b[0] |= 1 << 11; + b[1] >>= 2; + } + b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16; + b[2] = extents->y1 << 16 | extents->x1; + b[3] = extents->y2 << 16 | extents->x2; + b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4, + priv->gpu_bo, + I915_GEM_DOMAIN_RENDER << 16 | + I915_GEM_DOMAIN_RENDER | + KGEM_RELOC_FENCED, + 0); + b[5] = gc->bgPixel; + b[6] = gc->fgPixel; + b[7] = 0; + sna->kgem.nbatch += 8; + } - len = (w8 * h + 7) >> 3 << 1; - DBG(("%s glyph: (%d, %d) x (%d[%d], %d), len=%d\n" ,__FUNCTION__, - x,y, w, w8, h, len)); + b = sna->kgem.batch + sna->kgem.nbatch; + sna->kgem.nbatch += 3 + len; - x1 = x + c->metrics.leftSideBearing; - y1 = y - c->metrics.ascent; + b[0] = XY_TEXT_IMMEDIATE_BLT | (1 + len); + if (priv->gpu_bo->tiling && sna->kgem.gen >= 40) + b[0] |= 1 << 11; + b[1] = (uint16_t)y1 << 16 | (uint16_t)x1; + b[2] = (uint16_t)(y1+h) << 16 | (uint16_t)(x1+w); - if (!kgem_check_batch(&sna->kgem, 3+len)) { - _kgem_submit(&sna->kgem); - _kgem_set_mode(&sna->kgem, KGEM_BLT); + byte = (uint8_t *)&b[3]; + stride -= w8; + do { + i = w8; + do { + *byte++ = byte_reverse(*glyph++); + } while (--i); + glyph += stride; + } while (--h); + while ((byte - (uint8_t *)&b[3]) & 7) + *byte++ = 0; + assert((uint32_t *)byte == sna->kgem.batch + sna->kgem.nbatch); + + if (damage) { + BoxRec r; - b = sna->kgem.batch + sna->kgem.nbatch; - b[0] = XY_SETUP_BLT | 1 << 20; - b[1] = priv->gpu_bo->pitch; - if (sna->kgem.gen >= 40) { - if (priv->gpu_bo->tiling) - b[0] |= 1 << 11; - b[1] >>= 2; + r.x1 = x1; + r.y1 = y1; + r.x2 = x1 + w; + r.y2 = y1 + h; + if (box_intersect(&r, extents)) + sna_damage_add_box(damage, &r); } - b[1] |= 1 << 30 | transparent << 29 | blt_depth(drawable->depth) << 24 | rop << 16; - b[2] = clip.extents.y1 << 16 | clip.extents.x1; - b[3] = clip.extents.y2 << 16 | clip.extents.x2; - b[4] = kgem_add_reloc(&sna->kgem, sna->kgem.nbatch + 4, - priv->gpu_bo, - I915_GEM_DOMAIN_RENDER << 16 | - I915_GEM_DOMAIN_RENDER | - KGEM_RELOC_FENCED, - 0); - b[5] = gc->bgPixel; - b[6] = gc->fgPixel; - b[7] = 0; - sna->kgem.nbatch += 8; - } +skip: + x += c->metrics.characterWidth; + } while (--n); - b = sna->kgem.batch + sna->kgem.nbatch; - b[0] = XY_TEXT_IMMEDIATE_BLT | (1 + len); - if (priv->gpu_bo->tiling && sna->kgem.gen >= 40) - b[0] |= 1 << 11; - b[1] = (uint16_t)y1 << 16 | (uint16_t)x1; - b[2] = (uint16_t)(y1+h) << 16 | (uint16_t)(x1+w); + if (++extents == last_extents) + break; - byte = (uint8_t *)&b[3]; - stride -= w8; - do { - i = w8; - do { - *byte++ = byte_reverse(*glyph++); - } while (--i); - glyph += stride; - } while (--h); - while ((byte - (uint8_t *)&b[3]) & 7) - *byte++ = 0; - sna->kgem.nbatch += 3 + len; - assert((uint32_t *)byte == sna->kgem.batch + sna->kgem.nbatch); - - if (damage) { - BoxRec r; - - r.x1 = x1; - r.y1 = y1; - r.x2 = x1 + w; - r.y2 = y1 + h; - if (box_intersect(&r, &clip.extents)) - sna_damage_add_box(damage, &r); + if (kgem_check_batch(&sna->kgem, 3)) { + b = sna->kgem.batch + sna->kgem.nbatch; + sna->kgem.nbatch += 3; + + b[0] = XY_SETUP_CLIP; + b[1] = extents->y1 << 16 | extents->x1; + b[2] = extents->y2 << 16 | extents->x2; } -skip: - x += c->metrics.characterWidth; - } + } while (1); RegionUninit(&clip); sna->blt_state.fill_bo = 0; From jeremyhu at kemper.freedesktop.org Sun Oct 30 11:09:45 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 30 Oct 2011 11:09:45 -0700 (PDT) Subject: xf86-video-sis: Changes to 'master' Message-ID: <20111030180945.D1F801000F@kemper.freedesktop.org> configure.ac | 2 +- src/sis_driver.c | 38 ++++++++++++++++++++++++++++++++------ src/sis_vga.c | 9 +++++++-- 3 files changed, 40 insertions(+), 9 deletions(-) New commits: commit 0ab07a477a4916923a13c073c3fd6e575e79f725 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 30 11:09:30 2011 -0700 Use pci_device_map_legacy rather than xf86MapDomainMemory on newer servers Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> commit 77046f9be08295dbca69b51987df3308a284d87e Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sat Oct 29 17:44:55 2011 -0700 Convert use of LookupWindow to dixLookupWindow Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 30 11:30:38 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 30 Oct 2011 11:30:38 -0700 (PDT) Subject: xf86-video-xgi: Changes to 'master' Message-ID: <20111030183038.727981000F@kemper.freedesktop.org> src/vgatypes.h | 2 +- src/xgi.h | 2 +- src/xgi_driver.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) New commits: commit b9db7661e6c47ec569dc7fd986147cc5b5b4c3a5 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 30 11:28:27 2011 -0700 Use unsigned long rather than deprecated IOADDRESS Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 30 11:31:13 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 30 Oct 2011 11:31:13 -0700 (PDT) Subject: xf86-video-vmware: Changes to 'master' Message-ID: <20111030183114.0A3241000F@kemper.freedesktop.org> src/vmware.c | 2 ++ 1 file changed, 2 insertions(+) New commits: commit 4c08c2600936efeedb1a33436876ba82a11218e7 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Fri Oct 7 13:15:11 2011 -0700 Build fix for ABI version 12 This results in the vmware driver assuming there is only one PCI domain, which I think is true for everywhere this is expected to run anyway. Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Sun Oct 30 11:44:33 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Sun, 30 Oct 2011 11:44:33 -0700 (PDT) Subject: xf86-video-sunleo: Changes to 'master' Message-ID: <20111030184433.1FCDD10010@kemper.freedesktop.org> src/leo.h | 4 ++++ src/leo_accel.c | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) New commits: commit 68516ee7434c895dfa6edf4a54e54a5880cb8fcb Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 30 11:40:56 2011 -0700 Adjust to DevPrivate API changes Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From keithp at kemper.freedesktop.org Sun Oct 30 16:58:02 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Sun, 30 Oct 2011 16:58:02 -0700 (PDT) Subject: xserver: Branch 'master' - 5 commits Message-ID: <20111030235802.B49571000F@kemper.freedesktop.org> dix/devices.c | 4 ++++ hw/xfree86/common/xf86Xinput.c | 21 ++++++++++++--------- hw/xfree86/parser/scan.c | 17 +++++++++++++---- test/xfree86.c | 26 ++++++++++++++++++++++++++ test/xi2/protocol-common.c | 1 + test/xi2/protocol-eventconvert.c | 4 +--- test/xi2/protocol-xiquerydevice.c | 6 +++--- 7 files changed, 60 insertions(+), 19 deletions(-) New commits: commit 132545ff576cc69ed63f5a08127151fe550de4c3 Merge: d0c6732... d7c44a7... Author: Keith Packard <keithp at keithp.com> Date: Sun Oct 30 16:57:58 2011 -0700 Merge remote-tracking branch 'whot/for-keith' commit d7c44a7c9760449bef263413ad3b20f19b1dc95a Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Mon Oct 24 12:00:32 2011 +1000 dix: block signals when closing all devices When closing down all devices, we manually unset master for all attached devices, but the device's sprite info still points to the master's sprite info. This leaves us a window where the master is freed already but the device isn't yet. A signal during that window causes dereference of the already freed spriteInfo in mieqEnqueue's EnqueueScreen macro. Simply block signals when removing all devices. It's not like we're really worrying about high-responsive input at this stage. https://bugzilla.redhat.com/show_bug.cgi?id=737031 Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Julien Cristau <jcristau at debian.org> diff --git a/dix/devices.c b/dix/devices.c index 7c196e0..673a360 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -985,6 +985,8 @@ CloseDownDevices(void) { DeviceIntPtr dev; + OsBlockSignals(); + /* Float all SDs before closing them. Note that at this point resources * (e.g. cursors) have been freed already, so we can't just call * AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master @@ -1007,6 +1009,8 @@ CloseDownDevices(void) inputInfo.keyboard = NULL; inputInfo.pointer = NULL; XkbDeleteRulesDflts(); + + OsReleaseSignals(); } /** commit 820d9040f50a8440741b3aefbc069a3ad81e824e Author: Servaas Vandenberghe <vdb at picaros.org> Date: Wed Aug 31 07:06:49 2011 +0200 xfree86: fix potential buffer overflow The patch below fixes a potential buffer overflow in xf86addComment(). This occurs if curlen > 0 && eol_seen == 0 && iscomment == 0 , as follows from the code: char *xf86addComment(char *cur, char *add) <...> len = strlen(add); endnewline = add[len - 1] == '\n'; len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen; if ((str = realloc(cur, len + curlen)) == NULL) return cur; cur = str; if (eol_seen || (curlen && !hasnewline)) cur[curlen++] = '\n'; if (!iscomment) cur[curlen++] = '#'; strcpy(cur + curlen, add); if (!endnewline) strcat(cur, "\n"); Signed-off-by: Servaas Vandenberghe <vdb at picaros.org> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> [whot: added buffer overflow test case] Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c index 1cff3bc..99b3257 100644 --- a/hw/xfree86/parser/scan.c +++ b/hw/xfree86/parser/scan.c @@ -1093,7 +1093,7 @@ char * xf86addComment(char *cur, char *add) { char *str; - int len, curlen, iscomment, hasnewline = 0, endnewline; + int len, curlen, iscomment, hasnewline = 0, insnewline, endnewline; if (add == NULL || add[0] == '\0') return cur; @@ -1118,14 +1118,23 @@ xf86addComment(char *cur, char *add) len = strlen(add); endnewline = add[len - 1] == '\n'; - len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen; - if ((str = realloc(cur, len + curlen)) == NULL) + insnewline = eol_seen || (curlen && !hasnewline); + if (insnewline) + len++; + if (!iscomment) + len++; + if (!endnewline) + len++; + + /* Allocate + 1 char for '\0' terminator. */ + str = realloc(cur, curlen + len + 1); + if (!str) return cur; cur = str; - if (eol_seen || (curlen && !hasnewline)) + if (insnewline) cur[curlen++] = '\n'; if (!iscomment) cur[curlen++] = '#'; diff --git a/test/xfree86.c b/test/xfree86.c index 7012e90..448aa91 100644 --- a/test/xfree86.c +++ b/test/xfree86.c @@ -29,6 +29,7 @@ #include "xf86.h" +#include "xf86Parser.h" static void xfree86_option_list_duplicate(void) @@ -73,9 +74,34 @@ xfree86_option_list_duplicate(void) assert(a && b); } +static void +xfree86_add_comment(void) +{ + char *current = NULL, *comment; + char compare[1024] = {0}; + + comment = "# foo"; + current = xf86addComment(current, comment); + strcpy(compare, comment); + strcat(compare, "\n"); + + assert(!strcmp(current, compare)); + + /* this used to overflow */ + strcpy(current, "\n"); + comment = "foobar\n"; + current = xf86addComment(current, comment); + strcpy(compare, "\n#"); + strcat(compare, comment); + assert(!strcmp(current, compare)); + + free(current); +} + int main(int argc, char** argv) { xfree86_option_list_duplicate(); + xfree86_add_comment(); return 0; } commit 63e87b8639eb8e0b4e32e5d3a09099d31a03bbcd Author: Peter Hutterer <peter.hutterer at who-t.net> Date: Tue Oct 25 11:49:26 2011 +1000 xfree86: reduce calls to input_option_get_key/value No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Dan Nicholson <dbn.lists at gmail.com> diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 425b359..ee705a4 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -910,35 +910,38 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs, return BadAlloc; nt_list_for_each_entry(option, options, list.next) { - if (strcasecmp(input_option_get_key(option), "driver") == 0) { + const char *key = input_option_get_key(option); + const char *value = input_option_get_value(option); + + if (strcasecmp(key, "driver") == 0) { if (pInfo->driver) { rval = BadRequest; goto unwind; } - pInfo->driver = xstrdup(input_option_get_value(option)); + pInfo->driver = xstrdup(value); if (!pInfo->driver) { rval = BadAlloc; goto unwind; } } - if (strcasecmp(input_option_get_key(option), "name") == 0 || - strcasecmp(input_option_get_key(option), "identifier") == 0) { + if (strcasecmp(key, "name") == 0 || + strcasecmp(key, "identifier") == 0) { if (pInfo->name) { rval = BadRequest; goto unwind; } - pInfo->name = xstrdup(input_option_get_value(option)); + pInfo->name = xstrdup(value); if (!pInfo->name) { rval = BadAlloc; goto unwind; } } - if (strcmp(input_option_get_key(option), "_source") == 0 && - (strcmp(input_option_get_value(option), "server/hal") == 0 || - strcmp(input_option_get_value(option), "server/udev") == 0 || - strcmp(input_option_get_value(option), "server/wscons") == 0)) { + if (strcmp(key, "_source") == 0 && + (strcmp(value, "server/hal") == 0 || + strcmp(value, "server/udev") == 0 || + strcmp(value, "server/wscons") == 0)) { is_auto = 1; if (!xf86Info.autoAddDevices) { rval = BadMatch; commit 005ab41986b0bb6a4e626aee7a7a542247f422e7 Author: Dave Airlie <airlied at redhat.com> Date: Thu Oct 27 08:38:45 2011 +1000 test: fix two more failing FP3232 tests And put a comment in to explain why we're testing for a frac between .3 and .6. We can't directly compare the frac since the floating/fixed point conversion loses precision. Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c index 56d6bd2..27edfe5 100644 --- a/test/xi2/protocol-common.c +++ b/test/xi2/protocol-common.c @@ -108,6 +108,7 @@ TestPointerProc(DeviceIntPtr pDev, int what) pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; pDev->last.valuators[1] = pDev->valuator->axisVal[1]; + /* protocol-xiquerydevice.c relies on these increment */ SetScrollValuator(pDev, 2, SCROLL_TYPE_VERTICAL, 2.4, SCROLL_FLAG_NONE); SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, SCROLL_FLAG_PREFERRED); break; diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index ba2d96a..dce1c50 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -389,9 +389,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, { FP3232 vi, vo; - vi.integral = trunc(in->valuators.data[i]); - vi.frac = (in->valuators.data[i] - vi.integral) * (1UL << 32); - + vi = double_to_fp3232(in->valuators.data[i]); vo = *values; if (swap) diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c index 63d725f..569aea9 100644 --- a/test/xi2/protocol-xiquerydevice.c +++ b/test/xi2/protocol-xiquerydevice.c @@ -213,9 +213,9 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void } assert(si->increment.integral == si->number); - /* FIXME: frac testing with float/FP issues? */ - assert(si->increment.frac > 0.3 * (1UL << 32)); - assert(si->increment.frac < 0.6 * (1UL << 32)); + /* protocol-common.c sets up increments of 2.4 and 3.5 */ + assert(si->increment.frac > 0.3 * (1ULL << 32)); + assert(si->increment.frac < 0.6 * (1ULL << 32)); } } From whot at kemper.freedesktop.org Sun Oct 30 17:00:28 2011 From: whot at kemper.freedesktop.org (Peter Hutterer) Date: Sun, 30 Oct 2011 17:00:28 -0700 (PDT) Subject: xf86-input-evdev: Changes to 'master' Message-ID: <20111031000028.657E61000F@kemper.freedesktop.org> src/emuThird.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 2aba790ed3acc3ece5e56dac088e0a0a4a04b45d Author: Jools Wills <jools at oxfordinspire.co.uk> Date: Sun Oct 30 23:19:21 2011 +0000 emuThird: Use xf86SetIntOption, not xf86SetBoolOption for integer values Signed-off-by: Jools Wills <jools at oxfordinspire.co.uk> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net> From ickle at kemper.freedesktop.org Mon Oct 31 02:23:15 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 02:23:15 -0700 (PDT) Subject: xf86-video-intel: 4 commits - src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_driver.c src/sna/sna.h Message-ID: <20111031092315.8C4C41000F@kemper.freedesktop.org> src/sna/kgem.c | 24 ++++++++++------ src/sna/kgem.h | 2 - src/sna/sna.h | 4 ++ src/sna/sna_accel.c | 76 ++++++++++++++++++++++++++++++++++++--------------- src/sna/sna_driver.c | 5 +++ 5 files changed, 81 insertions(+), 30 deletions(-) New commits: commit 9c399c74adc5e5bc7d425382a74d84315d2cef02 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 09:20:54 2011 +0000 sna: Add an option to disable the delayed flush Section "Device" Option "DelayedFlush" "False" EndSection Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna.h b/src/sna/sna.h index ae161a2..4ed3fb8 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -192,6 +192,8 @@ enum { OPTION_RELAXED_FENCING, OPTION_VMAP, OPTION_ZAPHOD, + OPTION_DELAYED_FLUSH, + NUM_OPTIONS }; enum { @@ -205,6 +207,7 @@ struct sna { unsigned flags; #define SNA_NO_THROTTLE 0x1 +#define SNA_NO_DELAYED_FLUSH 0x2 int timer[NUM_TIMERS]; int timer_active; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 0b04db8..f6095b5 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -5995,6 +5995,9 @@ static Bool sna_accel_do_flush(struct sna *sna) return FALSE; } + if (sna->flags & SNA_NO_DELAYED_FLUSH) + return TRUE; + if (sna->timer[FLUSH_TIMER] == -1) return TRUE; diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 3e3f65c..46ca5ce 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -91,6 +91,7 @@ static OptionInfoRec sna_options[] = { {OPTION_RELAXED_FENCING, "UseRelaxedFencing", OPTV_BOOLEAN, {0}, TRUE}, {OPTION_VMAP, "UseVmap", OPTV_BOOLEAN, {0}, TRUE}, {OPTION_ZAPHOD, "ZaphodHeads", OPTV_STRING, {0}, FALSE}, + {OPTION_DELAYED_FLUSH, "DelayedFlush", OPTV_BOOLEAN, {0}, TRUE}, {-1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -506,6 +507,8 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) sna->flags = 0; if (!xf86ReturnOptValBool(sna->Options, OPTION_THROTTLE, TRUE)) sna->flags |= SNA_NO_THROTTLE; + if (!xf86ReturnOptValBool(sna->Options, OPTION_DELAYED_FLUSH, TRUE)) + sna->flags |= SNA_NO_DELAYED_FLUSH; xf86DrvMsg(scrn->scrnIndex, X_CONFIG, "Framebuffer %s\n", sna->tiling & SNA_TILING_FB ? "tiled" : "linear"); @@ -515,6 +518,8 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) sna->tiling & SNA_TILING_3D ? "tiled" : "linear"); xf86DrvMsg(scrn->scrnIndex, X_CONFIG, "Throttling %sabled\n", sna->flags & SNA_NO_THROTTLE ? "dis" : "en"); + xf86DrvMsg(scrn->scrnIndex, X_CONFIG, "Delayed flush %sabled\n", + sna->flags & SNA_NO_DELAYED_FLUSH ? "dis" : "en"); if (!sna_mode_pre_init(scrn, sna)) { PreInitCleanup(scrn); commit c8860ce26eaa8f9e876af2354d61c35338076ac8 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 23:25:48 2011 +0000 sna: Report whether anything was retired to the inactive list So that we can skip a fresh search of the inactive list if nothing changed. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 86cde01..60ae5ca 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -586,9 +586,10 @@ static void kgem_bo_unref(struct kgem *kgem, struct kgem_bo *bo) __kgem_bo_destroy(kgem, bo); } -void kgem_retire(struct kgem *kgem) +bool kgem_retire(struct kgem *kgem) { struct kgem_bo *bo, *next; + bool retired = false; DBG(("%s\n", __FUNCTION__)); @@ -602,6 +603,7 @@ void kgem_retire(struct kgem *kgem) bo->gpu = false; list_move(&bo->list, inactive(kgem, bo->size)); list_del(&bo->request); + retired = true; } while (!list_is_empty(&kgem->requests)) { @@ -641,6 +643,7 @@ void kgem_retire(struct kgem *kgem) __FUNCTION__, bo->handle)); list_move(&bo->list, inactive(kgem, bo->size)); + retired = true; } else { DBG(("%s: closing %d\n", __FUNCTION__, bo->handle)); @@ -657,6 +660,7 @@ void kgem_retire(struct kgem *kgem) assert(rq->bo->gpu == 0); list_move(&rq->bo->list, inactive(kgem, rq->bo->size)); + retired = true; } else { kgem->need_purge = 1; gem_close(kgem->fd, rq->bo->handle); @@ -669,6 +673,8 @@ void kgem_retire(struct kgem *kgem) if (kgem->ring && list_is_empty(&kgem->requests)) kgem->ring = kgem->mode; + + return retired; } static void kgem_commit(struct kgem *kgem) @@ -1269,10 +1275,11 @@ struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size) return kgem_bo_reference(bo); if (!list_is_empty(&kgem->requests)) { - kgem_retire(kgem); - bo = search_linear_cache(kgem, size, false); - if (bo) - return kgem_bo_reference(bo); + if (kgem_retire(kgem)) { + bo = search_linear_cache(kgem, size, false); + if (bo) + return kgem_bo_reference(bo); + } } handle = gem_create(kgem->fd, size); @@ -1547,9 +1554,10 @@ next_bo: } if (flags & CREATE_INACTIVE && !list_is_empty(&kgem->requests)) { - kgem_retire(kgem); - flags &= ~CREATE_INACTIVE; - goto skip_active_search; + if (kgem_retire(kgem)) { + flags &= ~CREATE_INACTIVE; + goto skip_active_search; + } } handle = gem_create(kgem->fd, size); diff --git a/src/sna/kgem.h b/src/sna/kgem.h index eb89c63..377670e 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -171,7 +171,7 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem, int tiling, uint32_t flags); -void kgem_retire(struct kgem *kgem); +bool kgem_retire(struct kgem *kgem); void _kgem_submit(struct kgem *kgem); static inline void kgem_submit(struct kgem *kgem) commit a7adcc8e47ba550e7c36a6543a6e0d99040c7354 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 21:19:35 2011 +0000 sna: Stash the last scratch pixmap Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna.h b/src/sna/sna.h index 1bb81d0..ae161a2 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -213,6 +213,7 @@ struct sna { struct list dirty_pixmaps; PixmapPtr front, shadow; + PixmapPtr freed_pixmap; struct sna_mode { uint32_t fb_id; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index c0c72ee..0b04db8 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -135,8 +135,16 @@ static Bool sna_destroy_private(PixmapPtr pixmap, struct sna_pixmap *priv) kgem_bo_destroy(&sna->kgem, priv->cpu_bo); } + if (!sna->freed_pixmap) { + sna->freed_pixmap = pixmap; + priv->gpu_bo = NULL; + priv->cpu_bo = NULL; + priv->mapped = 0; + return false; + } + free(priv); - return TRUE; + return true; } static uint32_t sna_pixmap_choose_tiling(PixmapPtr pixmap) @@ -228,15 +236,25 @@ sna_pixmap_create_scratch(ScreenPtr screen, CREATE_PIXMAP_USAGE_SCRATCH); /* you promise never to access this via the cpu... */ - pixmap = fbCreatePixmap(screen, 0, 0, depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pixmap) - return NullPixmap; - - priv = _sna_pixmap_attach(pixmap); - if (!priv) { - fbDestroyPixmap(pixmap); - return NullPixmap; + if (sna->freed_pixmap) { + pixmap = sna->freed_pixmap; + sna->freed_pixmap = NULL; + + priv = sna_pixmap(pixmap); + memset(priv, 0, sizeof(*priv)); + list_init(&priv->list); + priv->pixmap = pixmap; + } else { + pixmap = fbCreatePixmap(screen, 0, 0, depth, + CREATE_PIXMAP_USAGE_SCRATCH); + if (!pixmap) + return NullPixmap; + + priv = _sna_pixmap_attach(pixmap); + if (!priv) { + fbDestroyPixmap(pixmap); + return NullPixmap; + } } priv->gpu_bo = kgem_create_2d(&sna->kgem, @@ -753,15 +771,22 @@ sna_pixmap_create_upload(ScreenPtr screen, return fbCreatePixmap(screen, width, height, depth, CREATE_PIXMAP_USAGE_SCRATCH); - pixmap = fbCreatePixmap(screen, 0, 0, depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pixmap) - return NullPixmap; + if (sna->freed_pixmap) { + pixmap = sna->freed_pixmap; + sna->freed_pixmap = NULL; - priv = malloc(sizeof(*priv)); - if (!priv) { - fbDestroyPixmap(pixmap); - return NullPixmap; + priv = sna_pixmap(pixmap); + } else { + pixmap = fbCreatePixmap(screen, 0, 0, depth, + CREATE_PIXMAP_USAGE_SCRATCH); + if (!pixmap) + return NullPixmap; + + priv = malloc(sizeof(*priv)); + if (!priv) { + fbDestroyPixmap(pixmap); + return NullPixmap; + } } priv->gpu_bo = kgem_create_buffer(&sna->kgem, @@ -6175,6 +6200,12 @@ Bool sna_accel_create(struct sna *sna) void sna_accel_close(struct sna *sna) { + if (sna->freed_pixmap) { + assert(sna->freed_pixmap->refcnt == 1); + sna_destroy_pixmap(sna->freed_pixmap); + sna->freed_pixmap = NULL; + } + sna_glyphs_close(sna); sna_gradients_close(sna); commit c8d4f5d32af94f712cc81ff495b19907261759ea Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Sun Oct 30 21:21:25 2011 +0000 sna: Correct PolyRectangle verticals to be the end-point not the length Fixes an off-by-one in the drawing of the rectangles caused by a too-literal translation of the rectangles into boxes. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 6f0275b..c0c72ee 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4284,7 +4284,7 @@ zero: b[1].y2 += rr.height; b[2].y1 = rr.y + 1; - b[2].y2 = rr.y + rr.height - 1; + b[2].y2 = rr.y + rr.height; b[2].x1 = rr.x; b[2].x2 = rr.x + 1; @@ -4334,7 +4334,7 @@ zero_clipped: box[1].y2 += rr.height; box[2].y1 = rr.y + 1; - box[2].y2 = box[2].y1 + rr.height - 1; + box[2].y2 = box[2].y1 + rr.height; box[2].x1 = rr.x; box[2].x2 = rr.x + 1; @@ -4392,7 +4392,7 @@ zero_clipped: box[1].y2 += rr.height; box[2].y1 = rr.y + 1; - box[2].y2 = box[2].y1 + rr.height - 1; + box[2].y2 = box[2].y1 + rr.height; box[2].x1 = rr.x; box[2].x2 = rr.x + 1; From ickle at kemper.freedesktop.org Mon Oct 31 03:05:22 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 03:05:22 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna.h Message-ID: <20111031100522.3F1D21000F@kemper.freedesktop.org> src/sna/sna.h | 1 + src/sna/sna_accel.c | 11 ++++++----- src/sna/sna_blt.c | 16 ++++++++++------ 3 files changed, 17 insertions(+), 11 deletions(-) New commits: commit 088728ad26c7efc2d65b97ff22d526c65a0fa442 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 10:04:35 2011 +0000 sna/blt: Don't idiotically override alu for pixel==0 and track alu Another classic and utterly stupid mistake. At least I was consistent in my error. Reported-by: Clemens Eisserer <linuxhippy at gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42414 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna.h b/src/sna/sna.h index 4ed3fb8..f045fa5 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -252,6 +252,7 @@ struct sna { struct { uint32_t fill_bo; uint32_t fill_pixel; + uint32_t fill_alu; } blt_state; union { struct gen2_render_state gen2; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index f6095b5..4cbd194 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3439,7 +3439,8 @@ sna_poly_segment_blt(DrawablePtr drawable, struct sna_fill_op fill; int16_t dx, dy; - DBG(("%s: alu=%d, fg=%08lx\n", __FUNCTION__, gc->alu, gc->fgPixel)); + DBG(("%s: n=%d, alu=%d, fg=%08lx, clipped=%d\n", + __FUNCTION__, n, gc->alu, gc->fgPixel, clipped)); if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return FALSE; @@ -3456,7 +3457,7 @@ sna_poly_segment_blt(DrawablePtr drawable, nbox = ARRAY_SIZE(boxes); n -= nbox; do { - if (seg->x1 < seg->x2) { + if (seg->x1 <= seg->x2) { b->x1 = seg->x1; b->x2 = seg->x2; } else { @@ -3465,7 +3466,7 @@ sna_poly_segment_blt(DrawablePtr drawable, } b->x2++; - if (seg->y1 < seg->y2) { + if (seg->y1 <= seg->y2) { b->y1 = seg->y1; b->y2 = seg->y2; } else { @@ -3502,7 +3503,7 @@ sna_poly_segment_blt(DrawablePtr drawable, nbox = ARRAY_SIZE(boxes); n -= nbox; do { - if (seg->x1 < seg->x2) { + if (seg->x1 <= seg->x2) { b->x1 = seg->x1; b->x2 = seg->x2; } else { @@ -3511,7 +3512,7 @@ sna_poly_segment_blt(DrawablePtr drawable, } b->x2++; - if (seg->y1 < seg->y2) { + if (seg->y1 <= seg->y2) { b->y1 = seg->y1; b->y2 = seg->y2; } else { diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 1630b35..2ae4ac0 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -140,8 +140,8 @@ static bool sna_blt_fill_init(struct sna *sna, if (pitch > MAXSHORT) return FALSE; - if (pixel == 0) - alu = GXclear; + if (alu == GXclear) + pixel = 0; blt->br13 = 1<<31 | (fill_ROP[alu] << 16) | pitch; switch (bpp) { @@ -162,7 +162,8 @@ static bool sna_blt_fill_init(struct sna *sna, } if (sna->blt_state.fill_bo != bo->handle || - sna->blt_state.fill_pixel != pixel) + sna->blt_state.fill_pixel != pixel || + sna->blt_state.fill_alu != alu) { uint32_t *b; @@ -191,6 +192,7 @@ static bool sna_blt_fill_init(struct sna *sna, sna->blt_state.fill_bo = bo->handle; sna->blt_state.fill_pixel = pixel; + sna->blt_state.fill_alu = alu; } return TRUE; @@ -1608,8 +1610,8 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, if (br13 > MAXSHORT) return FALSE; - if (pixel == 0) - alu = GXclear; + if (alu == GXclear) + pixel = 0; br13 |= 1<<31 | fill_ROP[alu] << 16; switch (bpp) { @@ -1627,7 +1629,8 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, } if (sna->blt_state.fill_bo != bo->handle || - sna->blt_state.fill_pixel != pixel) + sna->blt_state.fill_pixel != pixel || + sna->blt_state.fill_alu != alu) { uint32_t *b; @@ -1656,6 +1659,7 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, sna->blt_state.fill_bo = bo->handle; sna->blt_state.fill_pixel = pixel; + sna->blt_state.fill_alu = alu; } do { From ickle at kemper.freedesktop.org Mon Oct 31 04:28:27 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 04:28:27 -0700 (PDT) Subject: xf86-video-intel: 2 commits - src/sna/sna_blt.c src/sna/sna_video.c Message-ID: <20111031112827.ABC3E1000F@kemper.freedesktop.org> src/sna/sna_blt.c | 4 ++ src/sna/sna_video.c | 79 ++++++++++++++++++++-------------------------------- 2 files changed, 35 insertions(+), 48 deletions(-) New commits: commit b1287e49347e0fff67f43d157fa87758d5cbe588 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 11:27:36 2011 +0000 sna/video: Fix copy region for cropped video Reported-by: Clemens Eisserer <linuxhippy at gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42412 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index c8171dc..d1d5b52 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -145,8 +145,7 @@ sna_video_clip_helper(ScrnInfoPtr scrn, * For overlay video, compute the relevant CRTC and * clip video to that */ - crtc = sna_covering_crtc(scrn, dst, video->desired_crtc, - &crtc_box); + crtc = sna_covering_crtc(scrn, dst, video->desired_crtc, &crtc_box); /* For textured video, we don't actually want to clip at all. */ if (crtc && !video->textured) { @@ -262,24 +261,24 @@ sna_video_buffer(struct sna *sna, return video->buf; } -static void sna_memcpy_plane(unsigned char *dst, unsigned char *src, - int height, int width, - int dstPitch, int srcPitch, Rotation rotation) +static void sna_memcpy_plane(uint8_t *dst, const uint8_t *src, + int height, int width, + int dstPitch, int srcPitch, + Rotation rotation) { + const uint8_t *s; int i, j = 0; - unsigned char *s; switch (rotation) { case RR_Rotate_0: /* optimise for the case of no clipping */ if (srcPitch == dstPitch && srcPitch == width) memcpy(dst, src, srcPitch * height); - else - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - src += srcPitch; - dst += dstPitch; - } + else while (height--) { + memcpy(dst, src, width); + src += srcPitch; + dst += dstPitch; + } break; case RR_Rotate_90: for (i = 0; i < height; i++) { @@ -315,51 +314,37 @@ static void sna_memcpy_plane(unsigned char *dst, unsigned char *src, static void sna_copy_planar_data(struct sna_video *video, const struct sna_video_frame *frame, - unsigned char *src, - unsigned char *dst, + const uint8_t *src, + uint8_t *dst, int srcPitch, int srcPitch2, - int srcH, int top, int left) + int srcH, int top, int left, int h, int w) { - unsigned char *src1, *dst1; + uint8_t *d; - /* Copy Y data */ - src1 = src + (top * srcPitch) + left; - - sna_memcpy_plane(dst, src1, - frame->height, frame->width, - frame->pitch[1], srcPitch, + sna_memcpy_plane(dst, src + top * srcPitch + left, + h, w, frame->pitch[1], srcPitch, video->rotation); - /* Copy V data for YV12, or U data for I420 */ - src1 = src + /* start of YUV data */ - (srcH * srcPitch) + /* move over Luma plane */ - ((top >> 1) * srcPitch2) + /* move down from by top lines */ - (left >> 1); /* move left by left pixels */ + src += srcH * srcPitch; /* move over Luma plane */ if (frame->id == FOURCC_I420) - dst1 = dst + frame->UBufOffset; + d = dst + frame->UBufOffset; else - dst1 = dst + frame->VBufOffset; + d = dst + frame->VBufOffset; - sna_memcpy_plane(dst1, src1, - frame->height / 2, frame->width / 2, - frame->pitch[0], srcPitch2, + sna_memcpy_plane(d, src + (top >> 1) * srcPitch2 + (left >> 1), + h / 2, w / 2, frame->pitch[0], srcPitch2, video->rotation); - /* Copy U data for YV12, or V data for I420 */ - src1 = src + /* start of YUV data */ - (srcH * srcPitch) + /* move over Luma plane */ - ((srcH >> 1) * srcPitch2) + /* move over Chroma plane */ - ((top >> 1) * srcPitch2) + /* move down from by top lines */ - (left >> 1); /* move left by left pixels */ + src += (srcH >> 1) * srcPitch2; /* move over Chroma plane */ + if (frame->id == FOURCC_I420) - dst1 = dst + frame->VBufOffset; + d = dst + frame->VBufOffset; else - dst1 = dst + frame->UBufOffset; + d = dst + frame->UBufOffset; - sna_memcpy_plane(dst1, src1, - frame->height / 2, frame->width / 2, - frame->pitch[0], srcPitch2, + sna_memcpy_plane(d, src + (top >> 1) * srcPitch2 + (left >> 1), + h / 2, w / 2, frame->pitch[0], srcPitch2, video->rotation); } @@ -369,10 +354,8 @@ sna_copy_packed_data(struct sna_video *video, unsigned char *buf, unsigned char *dst, int srcPitch, - int top, int left) + int top, int left, int h, int w) { - int w = frame->width; - int h = frame->height; unsigned char *src; unsigned char *s; int i, j; @@ -524,14 +507,14 @@ sna_video_copy_data(struct sna *sna, sna_copy_planar_data(video, frame, buf, dst, srcPitch, srcPitch2, - nlines, top, left); + frame->height, top, left, nlines, npixels); } else { int srcPitch = frame->width << 1; sna_copy_packed_data(video, frame, buf, dst, srcPitch, - top, left); + top, left, nlines, npixels); } munmap(dst, video->buf->size); commit b4ab412cb3eb8d37a33f5eeae5c613090ad2df0f Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 10:37:43 2011 +0000 sna/blt: Optimise fill with GXcopy and pixel==0 to a GXclear Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 2ae4ac0..ae24e62 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -142,6 +142,8 @@ static bool sna_blt_fill_init(struct sna *sna, if (alu == GXclear) pixel = 0; + if (alu == GXcopy && pixel == 0) + alu = GXclear; blt->br13 = 1<<31 | (fill_ROP[alu] << 16) | pitch; switch (bpp) { @@ -1612,6 +1614,8 @@ Bool sna_blt_fill_boxes(struct sna *sna, uint8_t alu, if (alu == GXclear) pixel = 0; + if (alu == GXcopy && pixel == 0) + alu = GXclear; br13 |= 1<<31 | fill_ROP[alu] << 16; switch (bpp) { From ickle at kemper.freedesktop.org Mon Oct 31 04:57:23 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 04:57:23 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111031115724.08A541000F@kemper.freedesktop.org> src/sna/sna_accel.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) New commits: commit 9a2e59bfba6748325918f895b3e58351c7eb4baa Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 11:56:53 2011 +0000 sna: Fix reversal of zero/wide for PolyRectangle Reported-by: Clemens Eisserer <linuxhippy at gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42414 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4cbd194..9ce142d 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4247,7 +4247,7 @@ sna_poly_rectangle_blt(DrawablePtr drawable, struct kgem_bo *bo, struct sna_damage **damage, GCPtr gc, int n, xRectangle *r, - const BoxRec *extents, bool clipped) + const BoxRec *extents, unsigned clipped) { struct sna *sna = to_sna_from_drawable(drawable); PixmapPtr pixmap = get_drawable_pixmap(drawable); @@ -4255,24 +4255,20 @@ sna_poly_rectangle_blt(DrawablePtr drawable, BoxRec boxes[512], *b = boxes, *const last_box = boxes+ARRAY_SIZE(boxes); int16_t dx, dy; static void * const jump[] = { - &&zero, - &&zero_clipped, &&wide, + &&zero, &&wide_clipped, + &&zero_clipped, }; - unsigned v; DBG(("%s: alu=%d, width=%d, fg=%08lx, damge=%p, clipped?=%d\n", __FUNCTION__, gc->alu, gc->lineWidth, gc->fgPixel, damage, clipped)); - if (!sna_fill_init_blt(&fill, sna, pixmap, bo, gc->alu, gc->fgPixel)) return FALSE; get_drawable_deltas(drawable, pixmap, &dx, &dy); - v = !!clipped; - v |= (gc->lineWidth <= 1) << 1; - goto *jump[v]; + goto *jump[(gc->lineWidth <= 1) | clipped]; zero: dx += drawable->x; From ickle at kemper.freedesktop.org Mon Oct 31 05:29:08 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 05:29:08 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c src/sna/sna_display.c src/sna/sna_driver.c src/sna/sna.h Message-ID: <20111031122908.204191000F@kemper.freedesktop.org> src/sna/sna.h | 2 ++ src/sna/sna_accel.c | 4 ++-- src/sna/sna_display.c | 28 +++++++++++++++++++++++++--- src/sna/sna_driver.c | 3 +++ 4 files changed, 32 insertions(+), 5 deletions(-) New commits: commit 59535d0e1c587cfe9249ab1baf9acf8470b49b8b Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 12:10:52 2011 +0000 sna: Set the flush interval based on output vrefresh Rather than a blank 25Hz, use twice the vblank interval to hopefully avoid bad values. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna.h b/src/sna/sna.h index f045fa5..3d2ecaf 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -212,6 +212,8 @@ struct sna { int timer[NUM_TIMERS]; int timer_active; + int flush_interval; + struct list deferred_free; struct list dirty_pixmaps; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 9ce142d..feb13e9 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -6005,9 +6005,9 @@ static Bool sna_accel_do_flush(struct sna *sna) to.it_value.tv_sec = 0; to.it_value.tv_nsec = 10 * 1000 * 1000; - /* Then periodic updates at 25Hz.*/ + /* Then periodic updates at half-vrefresh (update every other vblank) */ to.it_interval.tv_sec = 0; - to.it_interval.tv_nsec = 40 * 1000 * 1000; + to.it_interval.tv_nsec = sna->flush_interval; timerfd_settime(sna->timer[FLUSH_TIMER], 0, &to, NULL); sna->timer_active |= 1 << FLUSH_TIMER; diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index cc7ac9b..98743bc 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -585,6 +585,27 @@ cleanup_fbcon: drmModeFreeFB(fbcon); } +static void update_flush_interval(struct sna *sna) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(sna->scrn); + int i, max_vrefresh = 0; + + for (i = 0; i < xf86_config->num_crtc; i++) { + if (!xf86_config->crtc[i]->enabled) + continue; + + max_vrefresh = max(max_vrefresh, + xf86ModeVRefresh(&xf86_config->crtc[i]->mode)); + } + + if (max_vrefresh == 0) + max_vrefresh = 40; + + sna->flush_interval = 2000 * 1000 * 1000 / max_vrefresh; + DBG(("max_vrefresh=%d, flush_interval=%d ns\n", + max_vrefresh, sna->flush_inteval)); +} + static Bool sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, int x, int y) @@ -652,15 +673,16 @@ sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, kgem_submit(&sna->kgem); mode_to_kmode(&sna_crtc->kmode, mode); - ret = sna_crtc_apply(crtc); - if (!ret) { + if (!sna_crtc_apply(crtc)) { crtc->x = saved_x; crtc->y = saved_y; crtc->rotation = saved_rotation; crtc->mode = saved_mode; + return FALSE; } - return ret; + update_flush_interval(sna); + return TRUE; } static void diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 46ca5ce..0df7ca0 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -504,6 +504,9 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) if (xf86ReturnOptValBool(sna->Options, OPTION_TILING_FB, FALSE)) sna->tiling &= ~SNA_TILING_FB; + /* Default fail-safe value of 25 Hz */ + sna->flush_interval = 40 * 1000 * 1000; + sna->flags = 0; if (!xf86ReturnOptValBool(sna->Options, OPTION_THROTTLE, TRUE)) sna->flags |= SNA_NO_THROTTLE; From agd5f at kemper.freedesktop.org Mon Oct 31 05:41:52 2011 From: agd5f at kemper.freedesktop.org (Alex Deucher) Date: Mon, 31 Oct 2011 05:41:52 -0700 (PDT) Subject: xf86-video-ati: Branch 'master' Message-ID: <20111031124152.70C931000F@kemper.freedesktop.org> src/ati.c | 1 + src/ati.h | 1 - src/atipciids.h | 1 + src/radeon_bios.c | 2 +- src/radeon_dri.c | 1 - 5 files changed, 3 insertions(+), 3 deletions(-) New commits: commit d3d6a5da07aaec5961e51c9a8f90c1490ee101b6 Author: Tormod Volden <debian.tormod at gmail.com> Date: Sat Oct 29 23:08:46 2011 +0200 radeon: do not include xf86PciInfo.h We already use atipciids.h instead most places. Signed-off-by: Tormod Volden <debian.tormod at gmail.com> diff --git a/src/ati.c b/src/ati.c index ea71e88..e1c136f 100644 --- a/src/ati.c +++ b/src/ati.c @@ -63,6 +63,7 @@ #include "atipcirename.h" #include "ati.h" +#include "atipciids.h" #include "ativersion.h" /* names duplicated from version headers */ diff --git a/src/ati.h b/src/ati.h index 86c40a1..b7120d9 100644 --- a/src/ati.h +++ b/src/ati.h @@ -26,7 +26,6 @@ #include <unistd.h> #include <stdint.h> #include "xf86Pci.h" -#include "xf86PciInfo.h" #include "xf86.h" diff --git a/src/atipciids.h b/src/atipciids.h index 5f66aa0..04b5960 100644 --- a/src/atipciids.h +++ b/src/atipciids.h @@ -44,6 +44,7 @@ #ifndef PCI_VENDOR_HP #define PCI_VENDOR_HP 0x103c #endif +#define PCI_VENDOR_SONY 0x104D #include "ati_pciids_gen.h" diff --git a/src/radeon_bios.c b/src/radeon_bios.c index b53a0ed..5f12534 100644 --- a/src/radeon_bios.c +++ b/src/radeon_bios.c @@ -34,7 +34,7 @@ #include "xf86.h" #include "xf86_OSproc.h" -#include "xf86PciInfo.h" +#include "atipciids.h" #include "radeon.h" #include "radeon_reg.h" #include "radeon_macros.h" diff --git a/src/radeon_dri.c b/src/radeon_dri.c index 07f127c..f1ae65e 100644 --- a/src/radeon_dri.c +++ b/src/radeon_dri.c @@ -54,7 +54,6 @@ /* X and server generic header files */ #include "xf86.h" -#include "xf86PciInfo.h" #include "windowstr.h" /* GLX/DRI/DRM definitions */ From ickle at kemper.freedesktop.org Mon Oct 31 07:13:48 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 07:13:48 -0700 (PDT) Subject: xf86-video-intel: 2 commits - src/sna/sna_accel.c src/sna/sna_display.c Message-ID: <20111031141349.04B971000F@kemper.freedesktop.org> src/sna/sna_accel.c | 29 +++++++++++++++-------------- src/sna/sna_display.c | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) New commits: commit 20a4f533958991557a3b05af00f2856657579d68 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 14:14:40 2011 +0000 sna: Apply the GPU damage for clipped PolyFillRectangles Reported-by: Clemens Eisserer <linuxhippy at gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42425 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 5f7e3b9..4c9c09a 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -1368,7 +1368,7 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, int alu = gc ? gc->alu : GXcopy; int16_t tx, ty; - if (n == 0 || (dx | dy) == 0) + if (n == 0 || ((dx | dy) == 0 && alu == GXcopy)) return; DBG(("%s (boxes=%dx[(%d, %d), (%d, %d)...], src=+(%d, %d), alu=%d, pix.size=%dx%d)\n", @@ -5022,8 +5022,11 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, } RegionUninit(&clip); - if (b != boxes) + if (b != boxes) { fill.boxes(sna, &fill, boxes, b-boxes); + if (damage) + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + } } done: fill.done(sna, &fill); diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 98743bc..a82ccd8 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -603,7 +603,7 @@ static void update_flush_interval(struct sna *sna) sna->flush_interval = 2000 * 1000 * 1000 / max_vrefresh; DBG(("max_vrefresh=%d, flush_interval=%d ns\n", - max_vrefresh, sna->flush_inteval)); + max_vrefresh, sna->flush_interval)); } static Bool commit 7172f28c2b36aaa8c3a74ae4a7f699d3d4af10eb Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 12:53:35 2011 +0000 sna: Fix placement of clipped wide PolyRectangle Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index feb13e9..5f7e3b9 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4356,7 +4356,7 @@ zero_clipped: box[1].y2 += rr.height; box[2].y1 = rr.y + 1; - box[2].y2 = box[2].y1 + rr.height; + box[2].y2 = rr.y + rr.height; box[2].x1 = rr.x; box[2].x2 = rr.x + 1; @@ -4414,7 +4414,7 @@ zero_clipped: box[1].y2 += rr.height; box[2].y1 = rr.y + 1; - box[2].y2 = box[2].y1 + rr.height; + box[2].y2 = rr.y + rr.height; box[2].x1 = rr.x; box[2].x2 = rr.x + 1; @@ -4495,12 +4495,11 @@ wide_clipped: box[1].y1 = rr.y + offset3; box[1].y2 = rr.y + rr.height - offset1; - box[2].x1 = rr.x + rr.width - offset1; - box[2].x2 = box[2].x1 + offset2; - box[2].y1 = rr.y + offset3; - box[2].y2 = rr.y + rr.height - offset1; + box[2] = box[1]; + box[3].x1 += rr.width; + box[3].x2 += rr.width; - box[3] = box[1]; + box[3] = box[0]; box[3].y1 += rr.height; box[3].y2 += rr.height; count = 4; @@ -4564,12 +4563,11 @@ wide_clipped: box[1].y1 = rr.y + offset3; box[1].y2 = rr.y + rr.height - offset1; - box[2].x1 = rr.x + rr.width - offset1; - box[2].x2 = box[2].x1 + offset2; - box[2].y1 = rr.y + offset3; - box[2].y2 = rr.y + rr.height - offset1; + box[2] = box[1]; + box[3].x1 += rr.width; + box[3].x2 += rr.width; - box[3] = box[1]; + box[3] = box[0]; box[3].y1 += rr.height; box[3].y2 += rr.height; count = 4; From ickle at kemper.freedesktop.org Mon Oct 31 07:25:47 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 07:25:47 -0700 (PDT) Subject: xf86-video-intel: src/sna/sna_accel.c Message-ID: <20111031142547.3362A1000F@kemper.freedesktop.org> src/sna/sna_accel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) New commits: commit e12375d05bfb32933897b62829d82c6f1aa81d70 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 14:24:19 2011 +0000 sna: Fix a few minor cut'n'paste errors Use the constant value [last_box-box] where applicable. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 4c9c09a..dead314 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -4383,7 +4383,7 @@ zero_clipped: if (++b == last_box) { fill.boxes(sna, &fill, boxes, last_box-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); b = boxes; } } @@ -4434,7 +4434,7 @@ zero_clipped: if (++b == last_box) { fill.boxes(sna, &fill, boxes, last_box-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); b = boxes; } } @@ -4522,7 +4522,7 @@ wide_clipped: if (++b == last_box) { fill.boxes(sna, &fill, boxes, last_box-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); b = boxes; } } @@ -4583,7 +4583,7 @@ wide_clipped: if (++b == last_box) { fill.boxes(sna, &fill, boxes, last_box-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); b = boxes; } } @@ -5025,7 +5025,7 @@ sna_poly_fill_rect_blt(DrawablePtr drawable, if (b != boxes) { fill.boxes(sna, &fill, boxes, b-boxes); if (damage) - sna_damage_add_boxes(damage, boxes, last_box-boxes, 0, 0); + sna_damage_add_boxes(damage, boxes, b-boxes, 0, 0); } } done: From thomash at kemper.freedesktop.org Mon Oct 31 07:29:35 2011 From: thomash at kemper.freedesktop.org (Thomas Hellstrom) Date: Mon, 31 Oct 2011 07:29:35 -0700 (PDT) Subject: xf86-video-vmware: Changes to 'vmwgfx_branch' Message-ID: <20111031142935.3E59F1000F@kemper.freedesktop.org> vmwgfx/vmwgfx_crtc.c | 6 +- vmwgfx/vmwgfx_ctrl.c | 26 +++++------- vmwgfx/vmwgfx_driver.c | 86 ++++++++++++++++++++++++++++++++++++++++- vmwgfx/vmwgfx_driver.h | 5 ++ vmwgfx/vmwgfx_drm.h | 70 +++++++++++++++++++++++++++++++++ vmwgfx/vmwgfx_drmi.c | 16 +++++++ vmwgfx/vmwgfx_drmi.h | 4 + vmwgfx/vmwgfx_output.c | 102 ++++++++++++++++++++++++++++++++++++++++++++----- 8 files changed, 286 insertions(+), 29 deletions(-) New commits: commit cc7c1c961b77c139b95fbb6948204def1b4b908a Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Mon Oct 31 10:50:09 2011 +0100 vmwgfx: Fall back to sw cursors if needed If there is a risc that we need two simultaneous cursors, (two outputs showing the same contents, at least one of them explicit), fall back to sw cursor. Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> commit 427064b57c52c8881c7a64d9c9e21411e79e644b Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Wed Oct 26 16:33:30 2011 +0200 vmwgfx: Fix crtc position of transformed fb The fb allocated for transformed data always matches the scanout region, so set the crtc origin to (0,0) Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> commit 55113dae7cbe99bfb69869831536ff34ed445c73 Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Wed Oct 26 15:08:18 2011 +0200 vmwgfx: Hook up vmwarectrl to the gui layout ioctl Requires drm 2.3. Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> From thomash at kemper.freedesktop.org Mon Oct 31 09:00:43 2011 From: thomash at kemper.freedesktop.org (Thomas Hellstrom) Date: Mon, 31 Oct 2011 09:00:43 -0700 (PDT) Subject: xf86-video-vmware: Changes to 'vmwgfx_branch' Message-ID: <20111031160043.E1D3E10010@kemper.freedesktop.org> vmwgfx/vmwgfx_crtc.c | 33 +++++------- vmwgfx/vmwgfx_driver.c | 127 +++++++++++++++++++++++-------------------------- vmwgfx/vmwgfx_driver.h | 10 +-- vmwgfx/vmwgfx_saa.c | 50 +++++-------------- vmwgfx/vmwgfx_saa.h | 7 +- 5 files changed, 94 insertions(+), 133 deletions(-) New commits: commit b2c4a7e682e14fa8af42415d429d6735117fefcb Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Mon Oct 31 15:14:21 2011 +0100 vmwgfx: Fix acceleration options. Introduce relevant acceleration options and fix up the log printout. Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> Reviewed-by: Alan Hourihane <alanh at vmware.com> commit da85719e9e373ee8da53388cccc71a0f9c8bbefc Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Mon Oct 31 14:40:55 2011 +0100 vmwgfx: Remove a couple of unused options Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> Reviewed-by: Alan Hourihane <alanh at vmware.com> commit b6faecc7613e8c73f0681d20a1a80e5e0ddd4058 Author: Thomas Hellstrom <thellstrom at vmware.com> Date: Mon Oct 31 14:27:29 2011 +0100 vmwgfx: Don't do present readbacks per crtc The kernel now takes care of doing this the right way; no need to duplicate that functionality. Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com> Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> From jeremyhu at kemper.freedesktop.org Mon Oct 31 11:55:54 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 31 Oct 2011 11:55:54 -0700 (PDT) Subject: xf86-video-cirrus: Changes to 'master' Message-ID: <20111031185554.353BB1000F@kemper.freedesktop.org> src/cir_pcirename.h | 5 +++++ 1 file changed, 5 insertions(+) New commits: commit d9c9cc333e8a67749c20b3b30129f4d2297a3e0a Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Sun Oct 30 20:34:47 2011 -0700 Build fix for older servers (error: conflicting types for 'pciTag') /usr/include/xorg/xf86Pci.h:254:25: note: previous declaration of 'pciTag' was here Reported-by: Johannes Obermayr <johannesobermayr at gmx.de> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 31 11:57:01 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 31 Oct 2011 11:57:01 -0700 (PDT) Subject: xf86-video-r128: Branch 'master' Message-ID: <20111031185701.646881000F@kemper.freedesktop.org> src/atipcirename.h | 5 +++++ 1 file changed, 5 insertions(+) New commits: commit 67aaa4698586d75242627b7ce8f4815eeb08f853 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 31 11:56:33 2011 -0700 Build fix for older servers (error: conflicting types for 'pciTag') /usr/include/xorg/xf86Pci.h:254:25: note: previous declaration of 'pciTag' was here Reported-by: Johannes Obermayr <johannesobermayr at gmx.de> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> diff --git a/src/atipcirename.h b/src/atipcirename.h index 7d9d3a8..e65ae3c 100644 --- a/src/atipcirename.h +++ b/src/atipcirename.h @@ -34,6 +34,10 @@ enum region_type { REGION_IO }; +#include "xf86Module.h" + +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 12 + #if (defined(__alpha__) || defined(__ia64__)) && defined (linux) #define PCI_DOM_MASK 0x01fful #else @@ -55,6 +59,7 @@ pciTag(int busnum, int devnum, int funcnum) return tag; } +#endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 12 */ #ifndef XSERVER_LIBPCIACCESS From jeremyhu at kemper.freedesktop.org Mon Oct 31 11:58:09 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 31 Oct 2011 11:58:09 -0700 (PDT) Subject: xf86-video-sis: Changes to 'master' Message-ID: <20111031185809.649D71000F@kemper.freedesktop.org> src/sispcirename.h | 5 +++++ 1 file changed, 5 insertions(+) New commits: commit 8f61875cc77500ef20fe211729e110a103ab305b Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 31 11:57:49 2011 -0700 [PATCH] Build fix for older servers (error: conflicting types for 'pciTag') /usr/include/xorg/xf86Pci.h:254:25: note: previous declaration of 'pciTag' was here Reported-by: Johannes Obermayr <johannesobermayr at gmx.de> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From jeremyhu at kemper.freedesktop.org Mon Oct 31 11:59:41 2011 From: jeremyhu at kemper.freedesktop.org (Jeremy Huddleston) Date: Mon, 31 Oct 2011 11:59:41 -0700 (PDT) Subject: xf86-video-sis: Changes to 'master' Message-ID: <20111031185941.824E21000F@kemper.freedesktop.org> Rebased ref, commits from common ancestor: commit 2b459f385dc2f1b5e769e2ce84b6f4ec099c0a23 Author: Jeremy Huddleston <jeremyhu at apple.com> Date: Mon Oct 31 11:57:49 2011 -0700 Build fix for older servers (error: conflicting types for 'pciTag') /usr/include/xorg/xf86Pci.h:254:25: note: previous declaration of 'pciTag' was here Reported-by: Johannes Obermayr <johannesobermayr at gmx.de> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com> From ickle at kemper.freedesktop.org Mon Oct 31 12:14:11 2011 From: ickle at kemper.freedesktop.org (Chris Wilson) Date: Mon, 31 Oct 2011 12:14:11 -0700 (PDT) Subject: xf86-video-intel: 3 commits - src/sna/gen3_render.c src/sna/sna_accel.c Message-ID: <20111031191412.0A5B71000F@kemper.freedesktop.org> src/sna/gen3_render.c | 2 src/sna/sna_accel.c | 113 ++++++++++++++++++++++---------------------------- 2 files changed, 51 insertions(+), 64 deletions(-) New commits: commit 8939ddbc27efedbb3e446dd26425a6bed39577f2 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 17:45:02 2011 +0000 sna: Improve rendering of thin segments Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index cf3f5d3..346038e 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3820,6 +3820,8 @@ rectangle_continue: */ if (pt2_clipped) length++; + if (length == 0) + continue; if (pt1_clipped) { int clipdx = abs(x1 - x); @@ -3827,24 +3829,22 @@ rectangle_continue: e += clipdy * e2 + (clipdx - clipdy) * e1; } } - if (length == 0) - continue; - e3 = e2 - e1; e = e - e1; + if (sdx < 0) { + x1 = x2; + y1 = y2; + sdy = -sdy; + } + b->x1 = x1; b->y2 = b->y1 = y1; while (--length) { e += e1; + x1++; if (e >= 0) { b->x2 = x1; - if (b->x2 < b->x1) { - int16_t t = b->x1; - b->x1 = b->x2; - b->x2 = t; - } - b->x2++; b->y2++; if (++b == last_box) { ret = &&X_continue; @@ -3855,19 +3855,11 @@ X_continue: y1 += sdy; e += e3; b->y2 = b->y1 = y1; - b->x1 = x1 + sdx; + b->x1 = x1; } - x1 += sdx; } - b->x2 = x1; - if (b->x2 < b->x1) { - int16_t t = b->x1; - b->x1 = b->x2; - b->x2 = t; - } - if (gc->capStyle != CapNotLast) - b->x2++; + b->x2 = ++x1; b->y2++; if (++b == last_box) { ret = &&X_continue2; @@ -3906,6 +3898,8 @@ X_continue2: */ if (pt2_clipped) length++; + if (length == 0) + continue; if (pt1_clipped) { int clipdx = abs(x1 - x); @@ -3913,16 +3907,21 @@ X_continue2: e += clipdx * e2 + (clipdy - clipdx) * e1; } } - if (length == 0) - continue; e3 = e2 - e1; e = e - e1; + if (sdx < 0) { + x1 = x2; + y1 = y2; + sdy = -sdy; + } + b->x2 = b->x1 = x1; b->y1 = y1; while (--length) { e += e1; + y1 += sdy; if (e >= 0) { b->y2 = y1; if (b->y2 < b->y1) { @@ -3931,30 +3930,25 @@ X_continue2: b->y2 = t; } b->x2++; - b->y2++; if (++b == last_box) { ret = &&Y_continue; goto *jump; Y_continue: b = box; } - x1 += sdx; e += e3; - b->x2 = b->x1 = x1; - b->y1 = y1 + sdy; + b->x2 = b->x1 = ++x1; + b->y1 = y1; } - y1 += sdy; } - b->y2 = y1; + b->y2 = y1 + sdy; if (b->y2 < b->y1) { int16_t t = b->y1; b->y1 = b->y2; b->y2 = t; } b->x2++; - if (gc->capStyle != CapNotLast) - b->y2++; if (++b == last_box) { ret = &&Y_continue2; goto *jump; commit 98b830a975e04685455b244a8414a293857cbd00 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 17:41:27 2011 +0000 sna: Improve rendering of thin lines Reported-by: Clemens Eisserer <linuxhippy at gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42443 Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index dead314..cf3f5d3 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2717,10 +2717,8 @@ sna_poly_zero_line_blt(DrawablePtr drawable, y2 = ystart; oc2 = 0; MIOUTCODES(oc2, x2, y2, - extents->x1, - extents->y1, - extents->x2, - extents->y2); + extents->x1, extents->y1, + extents->x2, extents->y2); while (--n) { int16_t sdx, sdy; @@ -2752,10 +2750,8 @@ sna_poly_zero_line_blt(DrawablePtr drawable, oc2 = 0; MIOUTCODES(oc2, x2, y2, - extents->x1, - extents->y1, - extents->x2, - extents->y2); + extents->x1, extents->y1, + extents->x2, extents->y2); if (oc1 & oc2) continue; @@ -2822,6 +2818,8 @@ rectangle_continue: */ if (pt2_clipped) length++; + if (length == 0) + continue; if (pt1_clipped) { int clipdx = abs(x - x1); @@ -2829,24 +2827,23 @@ rectangle_continue: e += clipdy * e2 + (clipdx - clipdy) * e1; } } - if (length == 0) - continue; e3 = e2 - e1; e = e - e1; + if (sdx < 0) { + x = x2; + y = y2; + sdy = -sdy; + } + b->x1 = x; b->y2 = b->y1 = y; while (--length) { e += e1; + x++; if (e >= 0) { b->x2 = x; - if (b->x2 < b->x1) { - int16_t t = b->x1; - b->x1 = b->x2; - b->x2 = t; - } - b->x2++; b->y2++; if (++b == last_box) { ret = &&X_continue; @@ -2857,18 +2854,11 @@ X_continue: y += sdy; e += e3; b->y2 = b->y1 = y; - b->x1 = x + dx; + b->x1 = x; } - x += sdx; } - b->x2 = x; - if (b->x2 < b->x1) { - int16_t t = b->x1; - b->x1 = b->x2; - b->x2 = t; - } - b->x2++; + b->x2 = ++x; b->y2++; if (++b == last_box) { ret = &&X_continue2; @@ -2909,6 +2899,8 @@ X_continue2: */ if (pt2_clipped) length++; + if (length == 0) + continue; if (pt1_clipped) { int clipdx = abs(x - x1); @@ -2916,16 +2908,21 @@ X_continue2: e += clipdx * e2 + (clipdy - clipdx) * e1; } } - if (length == 0) - continue; e3 = e2 - e1; e = e - e1; + if (sdx < 0) { + x = x2; + y = y2; + sdy = -sdy; + } + b->x2 = b->x1 = x; b->y1 = y; while (--length) { e += e1; + y += sdy; if (e >= 0) { b->y2 = y; if (b->y2 < b->y1) { @@ -2934,29 +2931,25 @@ X_continue2: b->y2 = t; } b->x2++; - b->y2++; if (++b == last_box) { ret = &&Y_continue; goto *jump; Y_continue: b = box; } - x += sdx; e += e3; - b->x2 = b->x1 = x; - b->y1 = y + sdy; + b->x2 = b->x1 = ++x; + b->y1 = y; } - y += sdy; } - b->y2 = y; + b->y2 = y + sdy; if (b->y2 < b->y1) { int16_t t = b->y1; b->y1 = b->y2; b->y2 = t; } b->x2++; - b->y2++; if (++b == last_box) { ret = &&Y_continue2; goto *jump; commit 6a5834ae560ef3b05c42b58ee0654316a66eaed0 Author: Chris Wilson <chris at chris-wilson.co.uk> Date: Mon Oct 31 16:28:59 2011 +0000 sna/gen3: Fix invalid assert SHADER_CONSTANT is expected here, the other IMMEDIATES however should have already been handled. Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk> diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c index bf68841..7f68b00 100644 --- a/src/sna/gen3_render.c +++ b/src/sna/gen3_render.c @@ -906,11 +906,11 @@ gen3_composite_emit_shader(struct sna *sna, break; case SHADER_NONE: - case SHADER_CONSTANT: case SHADER_WHITE: case SHADER_BLACK: case SHADER_ZERO: assert(0); + case SHADER_CONSTANT: break; } From keithp at kemper.freedesktop.org Mon Oct 31 15:43:25 2011 From: keithp at kemper.freedesktop.org (Keith Packard) Date: Mon, 31 Oct 2011 15:43:25 -0700 (PDT) Subject: xserver: Branch 'master' Message-ID: <20111031224325.860C51000F@kemper.freedesktop.org> dix/dispatch.c | 8 ++++++++ 1 file changed, 8 insertions(+) New commits: commit 8329afa59dd5ea3adf7adebdb2111a9bccbb126b Author: Aaron Plattner <aplattner at nvidia.com> Date: Mon Oct 31 15:01:12 2011 -0700 dix: Reinstate GetImage window size check Commit 587c3a2d1961834558193e8e14e8e381a077a253 fixed DoGetImage to check windows against their backing drawables, rather than against the screen dimensions, to prevent reading outside the bounds of redirected windows' backing pixmaps (see bug #22804). Unfortunately, while making that change I also removed the check that the rectangle is contained within the bounds of the source window, which is a violation of the specification: If the drawable is a window, the window must be viewable, and it must be the case that, if there were no inferiors or overlapping windows, the specified rectangle of the window would be fully visible on the screen *and wholly contained within the outside edges of the window* (or a Match error results). Note that the borders of the window can be included and read with this request. (emphasis mine) Reinstate the window dimension check, to return BadMatch if the GetImage request falls outside the bounds of the window. Fixes X Test Suite test XGetImage-15: 400|0 15 1 11:05:41|IC Start 200|0 15 11:05:41|TP Start 520|0 15 00005146 1 1|VSW5TESTSUITE PURPOSE 15 520|0 15 00005146 1 2|Assertion XGetImage-15.(A) 520|0 15 00005146 1 3|When the drawable is a window and the window is viewable 520|0 15 00005146 1 4|and it is not the case that given there were no inferiors or 520|0 15 00005146 1 5|overlapping windows the specified rectangle of the window 520|0 15 00005146 1 6|would be fully visible on the screen and wholly contained 520|0 15 00005146 1 7|within the outside edges of the window, then a BadMatch 520|0 15 00005146 1 8|error occurs. 520|0 15 00005146 1 9|METH: Create window which is not fully visible on the screen. 520|0 15 00005146 1 10|METH: Call XMapWindow to make sure the window is viewable. 520|0 15 00005146 1 11|METH: Call XGetImage with rectangle extending beyond edge of screen. 520|0 15 00005146 1 12|METH: Verify XGetImage return value is null. 520|0 15 00005146 1 13|METH: Verify that BadMatch error occurred. 520|0 15 00005146 1 14|METH: Create window which is fully visible on the screen. 520|0 15 00005146 1 15|METH: Call XMapWindow to make sure the window is viewable. 520|0 15 00005146 1 16|METH: Call XGetImage with rectangle extending beyond edge of window. 520|0 15 00005146 1 17|METH: Verify XGetImage return value is null. 520|0 15 00005146 1 18|METH: Verify that BadMatch error occurred. 520|0 15 00005146 1 19|REPORT: Got Success, Expecting BadMatch 520|0 15 00005146 1 20|REPORT: Null image not returned. 220|0 15 1 11:05:41|FAIL Signed-off-by: Aaron Plattner <aplattner at nvidia.com> Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com> Signed-off-by: Keith Packard <keithp at keithp.com> diff --git a/dix/dispatch.c b/dix/dispatch.c index 43cb4d1..2b6cb82 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2029,6 +2029,14 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, if (!pWin->viewable) return BadMatch; + /* If the drawable is a window, the rectangle must be contained within + * its bounds (including the border). */ + if (x < -wBorderWidth(pWin) || + x + width > wBorderWidth(pWin) + (int)pDraw->width || + y < -wBorderWidth(pWin) || + y + height > wBorderWidth(pWin) + (int)pDraw->height) + return BadMatch; + relx += pDraw->x; rely += pDraw->y;