neuwld

patched neuwld library (tracked)
git clone https://git.daat.foo/neuwld.git
Log | Files | Refs | README | LICENSE

commit 2b0441a51293d15fdc7b7695b262675b9ab371f4
parent 573d91fe70b1bbb5ebf9e3ab3401ae61c94a7188
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 31 Jan 2014 14:13:51 -0800

intel: Merge libintelbatch into wld

Diffstat:
MMakefile | 6+++---
Mintel.c | 3++-
Aintel/batch.c | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aintel/batch.h | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aintel/blt.h | 350+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aintel/i965_pci_ids.h | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aintel/local.mk | 6++++++
Aintel/mi.h | 50++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 713 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile @@ -34,8 +34,8 @@ ifeq ($(ENABLE_DRM),1) WLD_HEADERS += drm.h ifneq ($(findstring intel,$(DRM_DRIVERS)),) - WLD_REQUIRES_PRIVATE += libdrm_intel intelbatch - WLD_SOURCES += intel.c + WLD_REQUIRES_PRIVATE += libdrm_intel + WLD_SOURCES += intel.c intel/batch.c WLD_CPPFLAGS += -DWITH_DRM_INTEL=1 endif @@ -110,7 +110,7 @@ pkgconfig = $(sort $(foreach pkg,$(1),$(if $($(pkg)_$(3)),$($(pkg)_$(3)), \ .PHONY: all all: $(TARGETS) -include protocol/local.mk +include $(foreach dir,intel protocol,$(dir)/local.mk) .deps: @mkdir "$@" diff --git a/intel.c b/intel.c @@ -23,10 +23,11 @@ #include "drm-private.h" #include "drm.h" +#include "intel/batch.h" +#include "intel/blt.h" #include "wld-private.h" #include <unistd.h> -#include <intelbatch.h> #include <intel_bufmgr.h> #include <i915_drm.h> diff --git a/intel/batch.c b/intel/batch.c @@ -0,0 +1,107 @@ +/* wld: intel/batch.c + * + * Copyright (c) 2013, 2014 Michael Forney + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "batch.h" +#include "mi.h" + +#include <i915_drm.h> +#include <stdlib.h> + +static const struct intel_device_info device_info_i965 = { .gen = 4 }; +static const struct intel_device_info device_info_g4x = { .gen = 4 }; +static const struct intel_device_info device_info_ilk = { .gen = 5 }; +static const struct intel_device_info device_info_snb_gt1 = { .gen = 6 }; +static const struct intel_device_info device_info_snb_gt2 = { .gen = 6 }; +static const struct intel_device_info device_info_ivb_gt1 = { .gen = 7 }; +static const struct intel_device_info device_info_ivb_gt2 = { .gen = 7 }; +static const struct intel_device_info device_info_byt = { .gen = 7 }; +static const struct intel_device_info device_info_hsw_gt1 = { .gen = 7 }; +static const struct intel_device_info device_info_hsw_gt2 = { .gen = 7 }; +static const struct intel_device_info device_info_hsw_gt3 = { .gen = 7 }; + +static const struct intel_device_info * device_info(int device_id) +{ + switch (device_id) + { +#define CHIPSET(device_id, type, name) \ + case device_id: return &device_info_ ## type; +#include "i965_pci_ids.h" +#undef CHIPSET + default: return NULL; + } +} + +struct intel_batch * intel_batch_new(drm_intel_bufmgr * bufmgr) +{ + struct intel_batch * batch; + int device_id = drm_intel_bufmgr_gem_get_devid(bufmgr); + + batch = malloc(sizeof *batch); + + if (!batch) + goto error0; + + batch->command_count = 0; + batch->device_info = device_info(device_id); + + if (!batch->device_info) + goto error1; + + /* Alignment argument (4096) is not used */ + batch->bo = drm_intel_bo_alloc(bufmgr, "batchbuffer", + sizeof batch->commands, 4096); + + return batch; + + error1: + free(batch); + error0: + return NULL; +} + +void intel_batch_destroy(struct intel_batch * batch) +{ + drm_intel_bo_unreference(batch->bo); + free(batch); +} + +void intel_batch_flush(struct intel_batch * batch) +{ + if (batch->command_count == 0) + return; + + intel_batch_add_dword(batch, MI_BATCH_BUFFER_END); + + /* Pad the batch buffer to the next quad-word. */ + if (batch->command_count & 1) + intel_batch_add_dword(batch, MI_NOOP); + + drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2, + batch->commands); + drm_intel_bo_mrb_exec(batch->bo, batch->command_count << 2, NULL, 0, 0, + batch->device_info->gen >= 6 ? I915_EXEC_BLT + : I915_EXEC_DEFAULT); + drm_intel_gem_bo_clear_relocs(batch->bo, 0); + batch->command_count = 0; +} + diff --git a/intel/batch.h b/intel/batch.h @@ -0,0 +1,102 @@ +/* wld: intel/batch.h + * + * Copyright (c) 2013, 2014 Michael Forney + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef WLD_INTEL_BATCH_H +#define WLD_INTEL_BATCH_H + +#include <stdarg.h> +#include <stdint.h> +#include <intel_bufmgr.h> + +#define INTEL_BATCH_MAX_COMMANDS (1 << 13) +#define INTEL_BATCH_RESERVED_COMMANDS 2 +#define INTEL_BATCH_SIZE (INTEL_BATCH_MAX_COMMANDS << 2) + +enum intel_batch_result +{ + INTEL_BATCH_SUCCESS, + INTEL_BATCH_NO_SPACE +}; + +struct intel_device_info +{ + int gen; +}; + +struct intel_batch +{ + const struct intel_device_info * device_info; + drm_intel_bo * bo; + uint32_t commands[INTEL_BATCH_MAX_COMMANDS]; + uint32_t command_count; +}; + +struct intel_batch * intel_batch_new(drm_intel_bufmgr * bufmgr); + +void intel_batch_destroy(struct intel_batch * batch); + +void intel_batch_flush(struct intel_batch * batch); + +static inline uint32_t intel_batch_check_space(struct intel_batch * batch, + uint32_t size) +{ + return (INTEL_BATCH_MAX_COMMANDS - INTEL_BATCH_RESERVED_COMMANDS + - batch->command_count) >= size; +} + +static inline void intel_batch_ensure_space(struct intel_batch * batch, uint32_t size) +{ + if (!intel_batch_check_space(batch, size)) + intel_batch_flush(batch); +} + +static inline void intel_batch_add_dword(struct intel_batch * batch, + uint32_t dword) +{ + batch->commands[batch->command_count++] = dword; +} + +static inline void intel_batch_add_dwords_va(struct intel_batch * batch, + uint32_t count, va_list dwords) +{ + while (count--) + intel_batch_add_dword(batch, va_arg(dwords, uint32_t)); +} + +static inline void intel_batch_add_dwords(struct intel_batch * batch, + uint32_t count, ...) +{ + va_list dwords; + va_start(dwords, count); + intel_batch_add_dwords_va(batch, count, dwords); + va_end(dwords); +} + +static inline uint32_t intel_batch_offset(struct intel_batch * batch, + uint32_t command_index) +{ + return (batch->command_count + command_index) << 2; +} + +#endif + diff --git a/intel/blt.h b/intel/blt.h @@ -0,0 +1,350 @@ +/* wld: intel/blt.h + * + * Copyright (c) 2013, 2014 Michael Forney + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef WLD_INTEL_BLT_H +#define WLD_INTEL_BLT_H + +#include <i915_drm.h> +#include <intel_bufmgr.h> + +#define INTEL_CLIENT_BLT 0x2 + +enum intel_blt_op +{ + INTEL_BLT_OP_XY_SETUP_BLT = 0x01, + INTEL_BLT_OP_XY_TEXT_BLT = 0x26, + INTEL_BLT_OP_XY_TEXT_IMMEDIATE_BLT = 0x31, + INTEL_BLT_OP_XY_COLOR_BLT = 0x50, + INTEL_BLT_OP_XY_SRC_COPY_BLT = 0x53 +}; + +enum intel_blt_32bpp_mask +{ + INTEL_BLT_32BPP_MASK_ALPHA = (1 << 0), + INTEL_BLT_32BPP_MASK_RGB = (1 << 1) +}; + +enum intel_blt_packing +{ + INTEL_BLT_PACKING_BIT = 0, + INTEL_BLT_PACKING_BYTE = 1 +}; + +enum intel_blt_color_depth +{ + INTEL_BLT_COLOR_DEPTH_8BIT = 0x0, + INTEL_BLT_COLOR_DEPTH_16BIT_565 = 0x1, + INTEL_BLT_COLOR_DEPTH_16BIT_1555 = 0x2, + INTEL_BLT_COLOR_DEPTH_32BIT = 0x3 +}; + +enum intel_blt_raster_operation +{ + INTEL_BLT_RASTER_OPERATION_SRC = 0xcc, + INTEL_BLT_RASTER_OPERATION_PAT = 0xf0 +}; + +/* BR00 : BLT Opcode & Control */ +#define INTEL_BLT_BR00_CLIENT(x) ((x) << 29) /* 31:29 */ +#define INTEL_BLT_BR00_OP(x) ((x) << 22) /* 28:22 */ +#define INTEL_BLT_BR00_32BPP_MASK(x) ((x) << 20) /* 21:20 */ + /* 19:17 */ +#define INTEL_BLT_BR00_PACKING(x) ((x) << 16) /* 16 */ +#define INTEL_BLT_BR00_SRC_TILING_ENABLE(x) ((x) << 15) /* 15 */ + /* 14:12 */ +#define INTEL_BLT_BR00_DST_TILING_ENABLE(x) ((x) << 11) /* 11 */ +#define INTEL_BLT_BR00_DWORD_LENGTH(x) ((x) << 0) /* 7:0 */ + +/* BR01 : Setup BLT Raster OP, Control, and Destination Offset */ +#define INTEL_BLT_BR01_SOLID_PATTERN(x) ((x) << 31) /* 31 */ +#define INTEL_BLT_BR01_CLIPPING_ENABLE(x) ((x) << 30) /* 30 */ +#define INTEL_BLT_BR01_MONO_SRC_TRANSPARENCY(x) ((x) << 29) /* 29 */ +#define INTEL_BLT_BR01_MONO_PAT_TRANSPARENCY(x) ((x) << 28) /* 28 */ +#define INTEL_BLT_BR01_COLOR_DEPTH(x) ((x) << 24) /* 25:24 */ +#define INTEL_BLT_BR01_RASTER_OPERATION(x) ((x) << 16) /* 23:16 */ +#define INTEL_BLT_BR01_DST_PITCH(x) ((x) << 0) /* 15:0 */ + +/* BR05 : Setup Expansion Background Color */ +#define INTEL_BLT_BR05_BACKGROUND_COLOR(x) ((x) << 0) /* 31:0 */ + +/* BR06 : Setup Expansion Foreground Color */ +#define INTEL_BLT_BR06_FOREGROUND_COLOR(x) ((x) << 0) /* 31:0 */ + +/* BR07 : Setup Blit Color Pattern Address */ + /* 31:29 */ +#define INTEL_BLT_BR07_PAT_ADDRESS(x) ((x) << 6) /* 28:6 */ + /* 5:0 */ + +/* BR09 : Destination Address */ + /* 31:29 */ +#define INTEL_BLT_BR09_DST_ADDRESS(x) ((x) << 0) /* 28:0 */ + +/* BR11 : Source Pitch */ + /* 31:16 */ +#define INTEL_BLT_BR11_SRC_PITCH(x) ((x) << 0) /* 15:0 */ + +/* BR12 : Source Address */ + /* 31:29 */ +#define INTEL_BLT_BR12_SRC_ADDRESS(x) ((x) << 0) /* 28:0 */ + +/* BR13 : BLT Raster OP, Control, and Destination Pitch */ +#define INTEL_BLT_BR13_SOLID_PATTERN(x) ((x) << 31) /* 31 */ +#define INTEL_BLT_BR13_CLIPPING_ENABLE(x) ((x) << 30) /* 30 */ +#define INTEL_BLT_BR13_MONO_SRC_TRANSPARENT(x) ((x) << 29) /* 29 */ +#define INTEL_BLT_BR13_MONO_PAT_TRANSPARENT(x) ((x) << 28) /* 28 */ +#define INTEL_BLT_BR13_COLOR_DEPTH(x) ((x) << 24) /* 25:24 */ +#define INTEL_BLT_BR13_RASTER_OPERATION(x) ((x) << 16) /* 23:16 */ +#define INTEL_BLT_BR13_DST_PITCH(x) ((x) << 0) /* 15:0 */ + +/* BR16 : Pattern Expansion Background & Solid Pattern Color */ +#define INTEL_BLT_BR16_COLOR(x) ((x) << 0) /* 31 : 0 */ + +/* BR22 : Destination Top Left */ +#define INTEL_BLT_BR22_DST_Y1(x) ((x) << 16) /* 31:16 */ +#define INTEL_BLT_BR22_DST_X1(x) ((x) << 0) /* 16:0 */ + +/* BR23 : Destination Bottom Right */ +#define INTEL_BLT_BR23_DST_Y2(x) ((x) << 16) /* 31:16 */ +#define INTEL_BLT_BR23_DST_X2(x) ((x) << 0) /* 16:0 */ + +/* BR24 : Clip Rectangle Top Left */ + /* 31 */ +#define INTEL_BLT_BR24_CLP_Y1(x) ((x) << 16) /* 30:16 */ + /* 15 */ +#define INTEL_BLT_BR24_CLP_X1(x) ((x) << 0) /* 14:0 */ + +/* BR25 : Clip Rectangle Bottom Right */ + /* 31 */ +#define INTEL_BLT_BR25_CLP_Y2(x) ((x) << 16) /* 30:16 */ + /* 15 */ +#define INTEL_BLT_BR25_CLP_X2(x) ((x) << 0) /* 14:0 */ + +/* BR26 : Source Top Left */ +#define INTEL_BLT_BR26_SRC_Y1(x) ((x) << 16) /* 31:16 */ +#define INTEL_BLT_BR26_SRC_X1(x) ((x) << 0) /* 15:0 */ + +static inline void xy_setup_blt(struct intel_batch * batch, + bool monochrome_source_transparency, + uint8_t raster_operation, + uint32_t background_color, + uint32_t foreground_color, + drm_intel_bo * dst, uint16_t dst_pitch) +{ + uint32_t tiling_mode, swizzle_mode; + + intel_batch_ensure_space(batch, 8); + + drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode); + drm_intel_bo_emit_reloc_fence + (batch->bo, intel_batch_offset(batch, 4), dst, 0, + I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); + + intel_batch_add_dwords(batch, 8, + INTEL_BLT_BR00_CLIENT(INTEL_CLIENT_BLT) + | INTEL_BLT_BR00_OP(INTEL_BLT_OP_XY_SETUP_BLT) + | INTEL_BLT_BR00_32BPP_MASK(INTEL_BLT_32BPP_MASK_ALPHA + | INTEL_BLT_32BPP_MASK_RGB) + | INTEL_BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE) + | INTEL_BLT_BR00_DWORD_LENGTH(6), + + INTEL_BLT_BR01_CLIPPING_ENABLE(false) + | INTEL_BLT_BR01_MONO_SRC_TRANSPARENCY(monochrome_source_transparency) + | INTEL_BLT_BR01_COLOR_DEPTH(INTEL_BLT_COLOR_DEPTH_32BIT) + | INTEL_BLT_BR01_RASTER_OPERATION(raster_operation) + | INTEL_BLT_BR01_DST_PITCH(tiling_mode == I915_TILING_NONE + ? dst_pitch : dst_pitch >> 2), + + /* XXX: No clipping yet */ + INTEL_BLT_BR24_CLP_Y1(0) + | INTEL_BLT_BR24_CLP_X1(0), + + INTEL_BLT_BR25_CLP_Y2(0) + | INTEL_BLT_BR25_CLP_X2(0), + + INTEL_BLT_BR09_DST_ADDRESS(dst->offset), + INTEL_BLT_BR05_BACKGROUND_COLOR(background_color), + INTEL_BLT_BR06_FOREGROUND_COLOR(foreground_color), + INTEL_BLT_BR07_PAT_ADDRESS(0) + ); +} + +static inline int xy_text_blt(struct intel_batch * batch, + drm_intel_bo * src, uint32_t src_offset, + drm_intel_bo * dst, + int16_t dst_x1, int16_t dst_y1, + int16_t dst_x2, int16_t dst_y2) +{ + uint32_t tiling_mode, swizzle_mode; + + if (!intel_batch_check_space(batch, 4)) + return INTEL_BATCH_NO_SPACE; + + drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode); + + drm_intel_bo_emit_reloc_fence + (batch->bo, intel_batch_offset(batch, 3), src, src_offset, + I915_GEM_DOMAIN_RENDER, 0); + + intel_batch_add_dwords(batch, 4, + INTEL_BLT_BR00_CLIENT(INTEL_CLIENT_BLT) + | INTEL_BLT_BR00_OP(INTEL_BLT_OP_XY_TEXT_BLT) + | INTEL_BLT_BR00_PACKING(INTEL_BLT_PACKING_BYTE) + | INTEL_BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE) + | INTEL_BLT_BR00_DWORD_LENGTH(2), + + INTEL_BLT_BR22_DST_Y1(dst_y1) | INTEL_BLT_BR22_DST_X1(dst_x1), + INTEL_BLT_BR23_DST_Y2(dst_y2) | INTEL_BLT_BR23_DST_X2(dst_x2), + INTEL_BLT_BR12_SRC_ADDRESS(src->offset + src_offset) + ); + + return INTEL_BATCH_SUCCESS; +} + +static inline int xy_text_immediate_blt(struct intel_batch * batch, + drm_intel_bo * dst, + int16_t dst_x1, int16_t dst_y1, + int16_t dst_x2, int16_t dst_y2, + uint16_t count, uint32_t * immediates) +{ + /* Round up to the next even number. */ + uint8_t dwords = (count + 1) & ~1; + uint32_t index; + uint32_t tiling_mode, swizzle_mode; + + if (!intel_batch_check_space(batch, 3 + dwords)) + return INTEL_BATCH_NO_SPACE; + + drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode); + + intel_batch_add_dwords(batch, 3, + INTEL_BLT_BR00_CLIENT(INTEL_CLIENT_BLT) + | INTEL_BLT_BR00_OP(INTEL_BLT_OP_XY_TEXT_IMMEDIATE_BLT) + | INTEL_BLT_BR00_PACKING(INTEL_BLT_PACKING_BYTE) + | INTEL_BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE) + | INTEL_BLT_BR00_DWORD_LENGTH(1 + dwords), + + INTEL_BLT_BR22_DST_Y1(dst_y1) | INTEL_BLT_BR22_DST_X1(dst_x1), + INTEL_BLT_BR23_DST_Y2(dst_y2) | INTEL_BLT_BR23_DST_X2(dst_x2) + ); + + for (index = 0; index < count; ++index) + intel_batch_add_dword(batch, *immediates++); + + /* From BLT engine documentation: + * + * The IMMEDIATE_BLT data MUST transfer an even number of doublewords. The + * BLT engine will hang if it does not get an even number of doublewords. */ + if (count & 1) + intel_batch_add_dword(batch, 0); + + return INTEL_BATCH_SUCCESS; +} + +static inline void xy_src_copy_blt(struct intel_batch * batch, + drm_intel_bo * src, uint16_t src_pitch, + uint16_t src_x, uint16_t src_y, + drm_intel_bo * dst, uint16_t dst_pitch, + uint16_t dst_x, uint16_t dst_y, + uint16_t width, uint16_t height) +{ + uint32_t src_tiling_mode, dst_tiling_mode, swizzle; + + intel_batch_ensure_space(batch, 8); + + drm_intel_bo_get_tiling(dst, &dst_tiling_mode, &swizzle); + drm_intel_bo_get_tiling(src, &src_tiling_mode, &swizzle); + + drm_intel_bo_emit_reloc_fence + (batch->bo, intel_batch_offset(batch, 4), dst, 0, + I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); + drm_intel_bo_emit_reloc_fence + (batch->bo, intel_batch_offset(batch, 7), src, 0, + I915_GEM_DOMAIN_RENDER, 0); + + intel_batch_add_dwords(batch, 8, + INTEL_BLT_BR00_CLIENT(INTEL_CLIENT_BLT) + | INTEL_BLT_BR00_OP(INTEL_BLT_OP_XY_SRC_COPY_BLT) + | INTEL_BLT_BR00_32BPP_MASK(INTEL_BLT_32BPP_MASK_ALPHA + | INTEL_BLT_32BPP_MASK_RGB) + | INTEL_BLT_BR00_SRC_TILING_ENABLE(src_tiling_mode != I915_TILING_NONE) + | INTEL_BLT_BR00_DST_TILING_ENABLE(dst_tiling_mode != I915_TILING_NONE) + | INTEL_BLT_BR00_DWORD_LENGTH(6), + + INTEL_BLT_BR13_CLIPPING_ENABLE(false) + | INTEL_BLT_BR13_COLOR_DEPTH(INTEL_BLT_COLOR_DEPTH_32BIT) + | INTEL_BLT_BR13_RASTER_OPERATION(INTEL_BLT_RASTER_OPERATION_SRC) + | INTEL_BLT_BR13_DST_PITCH(dst_tiling_mode == I915_TILING_NONE + ? dst_pitch : dst_pitch >> 2), + + INTEL_BLT_BR22_DST_Y1(dst_y) | INTEL_BLT_BR22_DST_X1(dst_x), + + INTEL_BLT_BR23_DST_Y2(dst_y + height) + | INTEL_BLT_BR23_DST_X2(dst_x + width), + + INTEL_BLT_BR09_DST_ADDRESS(dst->offset), + INTEL_BLT_BR26_SRC_Y1(src_y) | INTEL_BLT_BR26_SRC_X1(src_x), + INTEL_BLT_BR11_SRC_PITCH(src_tiling_mode == I915_TILING_NONE + ? src_pitch : src_pitch >> 2), + INTEL_BLT_BR12_SRC_ADDRESS(src->offset) + ); +} + +static inline void xy_color_blt(struct intel_batch * batch, + drm_intel_bo * dst, uint16_t dst_pitch, + uint16_t dst_x1, uint16_t dst_y1, + uint16_t dst_x2, uint16_t dst_y2, + uint32_t color) +{ + uint32_t tiling_mode, swizzle_mode; + + intel_batch_ensure_space(batch, 6); + + drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode); + + drm_intel_bo_emit_reloc_fence + (batch->bo, intel_batch_offset(batch, 4), dst, 0, + I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER); + + intel_batch_add_dwords(batch, 6, + INTEL_BLT_BR00_CLIENT(INTEL_CLIENT_BLT) + | INTEL_BLT_BR00_OP(INTEL_BLT_OP_XY_COLOR_BLT) + | INTEL_BLT_BR00_32BPP_MASK(INTEL_BLT_32BPP_MASK_ALPHA + | INTEL_BLT_32BPP_MASK_RGB) + | INTEL_BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE) + | INTEL_BLT_BR00_DWORD_LENGTH(4), + + INTEL_BLT_BR13_CLIPPING_ENABLE(false) + | INTEL_BLT_BR13_COLOR_DEPTH(INTEL_BLT_COLOR_DEPTH_32BIT) + | INTEL_BLT_BR13_RASTER_OPERATION(INTEL_BLT_RASTER_OPERATION_PAT) + | INTEL_BLT_BR13_DST_PITCH(tiling_mode == I915_TILING_NONE + ? dst_pitch : dst_pitch >> 2), + + INTEL_BLT_BR22_DST_Y1(dst_y1) | INTEL_BLT_BR22_DST_X1(dst_x1), + INTEL_BLT_BR23_DST_Y2(dst_y2) | INTEL_BLT_BR23_DST_X2(dst_x2), + INTEL_BLT_BR09_DST_ADDRESS(dst->offset), + INTEL_BLT_BR16_COLOR(color) + ); +} + +#endif + diff --git a/intel/i965_pci_ids.h b/intel/i965_pci_ids.h @@ -0,0 +1,93 @@ +CHIPSET(0x29A2, i965, "Intel(R) 965G") +CHIPSET(0x2992, i965, "Intel(R) 965Q") +CHIPSET(0x2982, i965, "Intel(R) 965G") +CHIPSET(0x2972, i965, "Intel(R) 946GZ") +CHIPSET(0x2A02, i965, "Intel(R) 965GM") +CHIPSET(0x2A12, i965, "Intel(R) 965GME/GLE") +CHIPSET(0x2A42, g4x, "Mobile IntelĀ® GM45 Express Chipset") +CHIPSET(0x2E02, g4x, "Intel(R) Integrated Graphics Device") +CHIPSET(0x2E12, g4x, "Intel(R) Q45/Q43") +CHIPSET(0x2E22, g4x, "Intel(R) G45/G43") +CHIPSET(0x2E32, g4x, "Intel(R) G41") +CHIPSET(0x2E42, g4x, "Intel(R) B43") +CHIPSET(0x2E92, g4x, "Intel(R) B43") +CHIPSET(0x0042, ilk, "Intel(R) Ironlake Desktop") +CHIPSET(0x0046, ilk, "Intel(R) Ironlake Mobile") +CHIPSET(0x0102, snb_gt1, "Intel(R) Sandybridge Desktop") +CHIPSET(0x0112, snb_gt2, "Intel(R) Sandybridge Desktop") +CHIPSET(0x0122, snb_gt2, "Intel(R) Sandybridge Desktop") +CHIPSET(0x0106, snb_gt1, "Intel(R) Sandybridge Mobile") +CHIPSET(0x0116, snb_gt2, "Intel(R) Sandybridge Mobile") +CHIPSET(0x0126, snb_gt2, "Intel(R) Sandybridge Mobile") +CHIPSET(0x010A, snb_gt1, "Intel(R) Sandybridge Server") +CHIPSET(0x0152, ivb_gt1, "Intel(R) Ivybridge Desktop") +CHIPSET(0x0162, ivb_gt2, "Intel(R) Ivybridge Desktop") +CHIPSET(0x0156, ivb_gt1, "Intel(R) Ivybridge Mobile") +CHIPSET(0x0166, ivb_gt2, "Intel(R) Ivybridge Mobile") +CHIPSET(0x015a, ivb_gt1, "Intel(R) Ivybridge Server") +CHIPSET(0x016a, ivb_gt2, "Intel(R) Ivybridge Server") +CHIPSET(0x0402, hsw_gt1, "Intel(R) Haswell Desktop") +CHIPSET(0x0412, hsw_gt2, "Intel(R) Haswell Desktop") +CHIPSET(0x0422, hsw_gt3, "Intel(R) Haswell Desktop") +CHIPSET(0x0406, hsw_gt1, "Intel(R) Haswell Mobile") +CHIPSET(0x0416, hsw_gt2, "Intel(R) Haswell Mobile") +CHIPSET(0x0426, hsw_gt3, "Intel(R) Haswell Mobile") +CHIPSET(0x040A, hsw_gt1, "Intel(R) Haswell Server") +CHIPSET(0x041A, hsw_gt2, "Intel(R) Haswell Server") +CHIPSET(0x042A, hsw_gt3, "Intel(R) Haswell Server") +CHIPSET(0x040B, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x041B, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x042B, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x040E, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x041E, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x042E, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0C02, hsw_gt1, "Intel(R) Haswell Desktop") +CHIPSET(0x0C12, hsw_gt2, "Intel(R) Haswell Desktop") +CHIPSET(0x0C22, hsw_gt3, "Intel(R) Haswell Desktop") +CHIPSET(0x0C06, hsw_gt1, "Intel(R) Haswell Mobile") +CHIPSET(0x0C16, hsw_gt2, "Intel(R) Haswell Mobile") +CHIPSET(0x0C26, hsw_gt3, "Intel(R) Haswell Mobile") +CHIPSET(0x0C0A, hsw_gt1, "Intel(R) Haswell Server") +CHIPSET(0x0C1A, hsw_gt2, "Intel(R) Haswell Server") +CHIPSET(0x0C2A, hsw_gt3, "Intel(R) Haswell Server") +CHIPSET(0x0C0B, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x0C1B, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x0C2B, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0C0E, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x0C1E, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x0C2E, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0A02, hsw_gt1, "Intel(R) Haswell Desktop") +CHIPSET(0x0A12, hsw_gt2, "Intel(R) Haswell Desktop") +CHIPSET(0x0A22, hsw_gt3, "Intel(R) Haswell Desktop") +CHIPSET(0x0A06, hsw_gt1, "Intel(R) Haswell Mobile") +CHIPSET(0x0A16, hsw_gt2, "Intel(R) Haswell Mobile") +CHIPSET(0x0A26, hsw_gt3, "Intel(R) Haswell Mobile") +CHIPSET(0x0A0A, hsw_gt1, "Intel(R) Haswell Server") +CHIPSET(0x0A1A, hsw_gt2, "Intel(R) Haswell Server") +CHIPSET(0x0A2A, hsw_gt3, "Intel(R) Haswell Server") +CHIPSET(0x0A0B, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x0A1B, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x0A2B, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0A0E, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x0A1E, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x0A2E, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0D02, hsw_gt1, "Intel(R) Haswell Desktop") +CHIPSET(0x0D12, hsw_gt2, "Intel(R) Haswell Desktop") +CHIPSET(0x0D22, hsw_gt3, "Intel(R) Haswell Desktop") +CHIPSET(0x0D06, hsw_gt1, "Intel(R) Haswell Mobile") +CHIPSET(0x0D16, hsw_gt2, "Intel(R) Haswell Mobile") +CHIPSET(0x0D26, hsw_gt3, "Intel(R) Haswell Mobile") +CHIPSET(0x0D0A, hsw_gt1, "Intel(R) Haswell Server") +CHIPSET(0x0D1A, hsw_gt2, "Intel(R) Haswell Server") +CHIPSET(0x0D2A, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0D0B, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x0D1B, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x0D2B, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0D0E, hsw_gt1, "Intel(R) Haswell") +CHIPSET(0x0D1E, hsw_gt2, "Intel(R) Haswell") +CHIPSET(0x0D2E, hsw_gt3, "Intel(R) Haswell") +CHIPSET(0x0F31, byt, "Intel(R) Bay Trail") +CHIPSET(0x0F32, byt, "Intel(R) Bay Trail") +CHIPSET(0x0F33, byt, "Intel(R) Bay Trail") +CHIPSET(0x0157, byt, "Intel(R) Bay Trail") +CHIPSET(0x0155, byt, "Intel(R) Bay Trail") diff --git a/intel/local.mk b/intel/local.mk @@ -0,0 +1,6 @@ +# wld: intel/local.mk + +dir := intel + +include common.mk + diff --git a/intel/mi.h b/intel/mi.h @@ -0,0 +1,50 @@ +/* wld: intel/mi.h + * + * Copyright (c) 2013, 2014 Michael Forney + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef WLD_INTEL_MI_H +#define WLD_INTEL_MI_H + +#define INTEL_CLIENT_MI 0x0 + +#define MI_OP(opcode) ( \ + INTEL_CLIENT_MI << 29 /* 31:29 */ \ + | opcode << 23 /* 28:23 */ \ +) + +#define MI_NOOP MI_OP(0x00) +#define MI_FLUSH MI_OP(0x04) +#define MI_BATCH_BUFFER_END MI_OP(0x0A) + +/* MI_NOOP */ +#define MI_NOOP_IDENTIFICATION_NUMBER(number) (1 << 22 | number) + +/* MI_FLUSH */ +#define MI_FLUSH_ENABLE_PROTECTED_MEMORY (1 << 6) +#define MI_FLUSH_DISABLE_INDIRECT_STATE_POINTERS (1 << 5) +#define MI_FLUSH_CLEAR_GENERIC_MEDIA_STATE (1 << 4) +#define MI_FLUSH_RESET_GLOBAL_SNAPSHOT_COUNT (1 << 3) +#define MI_FLUSH_INHIBIT_RENDER_CACHE_FLUSH (1 << 2) +#define MI_FLUSH_INVALIDATE_STATE_INSTRUCTION_CACHE (1 << 1) + +#endif +