From cf9f48e704030b606260919f2da4c4287e51c4af Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Thu, 19 Feb 2015 15:41:15 -0200 Subject: lib: add igt_draw For all those IGT tests that need an easy way to draw rectangles on buffers using different methods. Current planned users: FBC and PSR CRC tests. There is also a tests/kms_draw_crc program to check if the library is sane. v2: - Move the test from lib/tests to tests/ (Daniel). - Add igt_require() to filter out the swizzling/tiling methods we don't support (Daniel). - Simplify reloc handling on the BLT case (Daniel). - Document enum igt_draw_method (Daniel). - Document igt_draw_get_method_name() (Paulo). v3: - Add IGT_DRAW_MMAP_WC (Chris). - Implement the other trivial swizzling methods (Chris). - Remove the gem_sync() calls (Chris). Signed-off-by: Paulo Zanoni --- lib/igt_draw.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 lib/igt_draw.h (limited to 'lib/igt_draw.h') diff --git a/lib/igt_draw.h b/lib/igt_draw.h new file mode 100644 index 00000000..61ffad5c --- /dev/null +++ b/lib/igt_draw.h @@ -0,0 +1,65 @@ +/* + * Copyright © 2015 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. + * + */ + +#ifndef __IGT_DRAW_H__ +#define __IGT_DRAW_H__ + +#include +#include "igt_fb.h" + +/** + *igt_draw_method: + * @IGT_DRAW_MMAP_CPU: draw using a CPU mmap. + * @IGT_DRAW_MMAP_GTT: draw using a GTT mmap. + * @IGT-DRAW_MMAP_WC: draw using the WC mmap. + * @IGT_DRAW_PWRITE: draw using the pwrite ioctl. + * @IGT_DRAW_BLT: draw using the BLT ring. + * @IGT_DRAW_RENDER: draw using the render ring. + * @IGT_DRAW_METHOD_COUNT: useful for iterating through everything. + */ +enum igt_draw_method { + IGT_DRAW_MMAP_CPU, + IGT_DRAW_MMAP_GTT, + IGT_DRAW_MMAP_WC, + IGT_DRAW_PWRITE, + IGT_DRAW_BLT, + IGT_DRAW_RENDER, + IGT_DRAW_METHOD_COUNT, +}; + +const char *igt_draw_get_method_name(enum igt_draw_method method); + +void igt_draw_rect(int fd, drm_intel_bufmgr *bufmgr, drm_intel_context *context, + uint32_t buf_handle, uint32_t buf_size, uint32_t buf_stride, + enum igt_draw_method method, int rect_x, int rect_y, + int rect_w, int rect_h, uint32_t color); + +void igt_draw_rect_fb(int fd, drm_intel_bufmgr *bufmgr, + drm_intel_context *context, struct igt_fb *fb, + enum igt_draw_method method, int rect_x, int rect_y, + int rect_w, int rect_h, uint32_t color); + +void igt_draw_fill_fb(int fd, struct igt_fb *fb, uint32_t color); + +#endif /* __IGT_DRAW_H__ */ -- cgit v1.2.3