summaryrefslogtreecommitdiff
path: root/lib/igt_draw.c
diff options
context:
space:
mode:
authorAkash Goel <akash.goel@intel.com>2017-04-28 20:07:31 +0530
committerPaulo Zanoni <paulo.r.zanoni@intel.com>2017-07-13 17:05:16 -0300
commita844ccbdbab9fd16c37de81281c6281bc800e97a (patch)
treedf87c0ca5e567205eead7cb84c64ce9fa2c22229 /lib/igt_draw.c
parent64362a8932ba947d3b55c9d7afc5af404bf89224 (diff)
lib/igt_draw: Add Y-tiling support for IGT_DRAW_BLT method
v2: Moved identical code into a single function (Paulo) v3 (from Paulo): stay under 80 columns. Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Akash Goel <akash.goel@intel.com> Signed-off-by: Praveen Paneri <praveen.paneri@intel.com> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Diffstat (limited to 'lib/igt_draw.c')
-rw-r--r--lib/igt_draw.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/igt_draw.c b/lib/igt_draw.c
index 29aec850..db55cd99 100644
--- a/lib/igt_draw.c
+++ b/lib/igt_draw.c
@@ -31,6 +31,7 @@
#include "igt_core.h"
#include "igt_fb.h"
#include "ioctl_wrappers.h"
+#include "i830_reg.h"
/**
* SECTION:igt_draw
@@ -212,6 +213,35 @@ static void set_pixel(void *_ptr, int index, uint32_t color, int bpp)
}
}
+static void switch_blt_tiling(struct intel_batchbuffer *batch, uint32_t tiling,
+ bool on)
+{
+ uint32_t bcs_swctrl;
+
+ /* Default is X-tile */
+ if (tiling != I915_TILING_Y)
+ return;
+
+ bcs_swctrl = (0x3 << 16) | (on ? 0x3 : 0x0);
+
+ /* To change the tile register, insert an MI_FLUSH_DW followed by an
+ * MI_LOAD_REGISTER_IMM
+ */
+ BEGIN_BATCH(4, 0);
+ OUT_BATCH(MI_FLUSH_DW | 2);
+ OUT_BATCH(0x0);
+ OUT_BATCH(0x0);
+ OUT_BATCH(0x0);
+ ADVANCE_BATCH();
+
+ BEGIN_BATCH(4, 0);
+ OUT_BATCH(MI_LOAD_REGISTER_IMM);
+ OUT_BATCH(0x22200); /* BCS_SWCTRL */
+ OUT_BATCH(bcs_swctrl);
+ OUT_BATCH(MI_NOOP);
+ ADVANCE_BATCH();
+}
+
static void draw_rect_ptr_linear(void *ptr, uint32_t stride,
struct rect *rect, uint32_t color, int bpp)
{
@@ -445,6 +475,8 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
blt_cmd_tiling = (tiling) ? XY_COLOR_BLT_TILED : 0;
pitch = (tiling) ? buf->stride / 4 : buf->stride;
+ switch_blt_tiling(batch, tiling, true);
+
BEGIN_BATCH(6, 1);
OUT_BATCH(XY_COLOR_BLT_CMD_NOLEN | XY_COLOR_BLT_WRITE_ALPHA |
XY_COLOR_BLT_WRITE_RGB | blt_cmd_tiling | blt_cmd_len);
@@ -455,6 +487,8 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
OUT_BATCH(color);
ADVANCE_BATCH();
+ switch_blt_tiling(batch, tiling, false);
+
intel_batchbuffer_flush(batch);
intel_batchbuffer_free(batch);
}