Test case for NV12 functionality
cover Test case for NV12 functionality
This series implements a test case for checking NV12 functionality for linear/tile-X/tile-Y tiling formats. The series adds NV12 functionality to the IGT library.
The series is based on previous version posted by Chandra Konduru during 2015 based on the IGT framework available then. Previous version reference links:
https://patchwork.freedesktop.org/patch/57590/
https://patchwork.freedesktop.org/patch/59067/
chandra konduru (2):
Prep work for adding NV12 testcase
tests/test_nv12.c: This patch adds test_nv12 test case. It is a simple
test that covers testing NV12 in linear/tile-X/tile-Y tiling formats.
lib/igt_draw.c | 2 +- lib/igt_fb.c | 189 ++++++++++++++++++++++++++++++++------- lib/igt_fb.h | 12 ++- lib/intel_batchbuffer.c | 14 +-- lib/intel_batchbuffer.h | 3 +- lib/intel_reg.h | 1 + lib/ioctl_wrappers.c | 9 ++ lib/ioctl_wrappers.h | 1 + tests/Makefile.sources | 1 + tests/kms_frontbuffer_tracking.c | 6 +- tests/kms_render.c | 4 +- tests/kms_rotation_crc.c | 8 +- tests/prime_vgem.c | 2 +- tests/test_nv12.c | 171 +++++++++++++++++++++++++++++++++++ 14 files changed, 374 insertions(+), 49 deletions(-) create mode 100644 tests/test_nv12.c
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/2 Prep work for adding NV12 testcase
From: chandra konduru <[email protected]>
This patch adds necessary prep work for nv12 testcase:
- updated fb allocation functions to handle NV12 format
- igt helper function to return png image size
- igt helper function to calculate start of uv in a given NV12 buffer
- igt helper function to map buffer for host access
- populates fb->...[4] parameters for NV12
- igt helper function to convert RGB data to NV12
- updated drm_format to bpp to handle NV12
- updated fast copy blit function to deal NV12 subplanes
- made an update to few tests due to above changes
v1: Reference https://patchwork.freedesktop.org/patch/57590/
Was previously posted by Chandra Konduru on Aug 20 2015 based on the IGT
framework available at that time.
v2: Rebased as per the current IGT framework/changes (me)
--- lib/igt_draw.c | 2 +- lib/igt_fb.c | 189 ++++++++++++++++++++++++++++++++------- lib/igt_fb.h | 12 ++- lib/intel_batchbuffer.c | 14 +-- lib/intel_batchbuffer.h | 3 +- lib/intel_reg.h | 1 + lib/ioctl_wrappers.c | 9 ++ lib/ioctl_wrappers.h | 1 + tests/kms_frontbuffer_tracking.c | 6 +- tests/kms_render.c | 4 +- tests/kms_rotation_crc.c | 8 +- tests/prime_vgem.c | 2 +- 12 files changed, 202 insertions(+), 49 deletions(-)
lib/igt_draw.c +1 -1
@@ -652,7 +652,7 @@ void igt_draw_rect_fb(int fd, drm_intel_bufmgr *bufmgr, {igt_draw_rect (fd, bufmgr, context, fb->gem_handle, fb->size, fb->stride, method, rect_x, rect_y, rect_w, rect_h, color, -igt_drm_format_to_bpp (fb->drm_format)); +igt_drm_format_to_bpp (fb->drm_format,0 )); }/**
lib/igt_fb.c +159 -30
263 lines not on this page · raw message
lib/igt_fb.h +10 -2
@@ -72,6 +72,9 @@ typedef struct igt_fb {uint64_t tiling;unsigned int size;cairo_surface_t *cairo_surface; +void *mmap_gtt; +uint32_t uv_y_start; +uint32_t uv_offset;unsigned int domain; } igt_fb_t;
@@ -95,7 +98,10 @@ enum igt_text_align { align_hcenter = 0x08, }; -void igt_calc_fb_size (int fd,int width,int height,int bpp,uint64_t tiling, +void igt_fb_gem_mmap (int fd,struct igt_fb *fb); +void igt_fb_csc_xrgb_to_nv12 (int fd,struct igt_fb *dst,struct igt_fb *src); +void igt_fb_calc_uv (struct igt_fb *fb); +void igt_calc_fb_size (int fd,int width,int height,int bpp,uint32_t format,uint64_t tiling,unsigned *size_ret,unsigned *stride_ret); unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
@@ -152,9 +158,11 @@ int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,/* helpers to handle drm fourcc codes */ uint32_t igt_bpp_depth_to_drm_format (int bpp,int depth); -uint32_t igt_drm_format_to_bpp (uint32_t drm_format); +uint32_t igt_drm_format_to_bpp (uint32_t drm_format,int plane);const char *igt_format_str (uint32_t drm_format);void igt_get_all_cairo_formats (const uint32_t **formats,int *format_count); +void igt_get_image_size (const char *filename,int *width,int *height); +#endif /* __IGT_FB_H__ */
lib/intel_batchbuffer.c +9 -5
@@ -519,7 +519,7 @@ static uint32_t fast_copy_dword0(unsigned int src_tiling, }static uint32_t fast_copy_dword1 (unsigned int src_tiling, -unsigned int dst_tiling) +unsigned int dst_tiling,uint32_t color_depth) {uint32_t dword1 =0 ;
@@ -528,7 +528,10 @@ static uint32_t fast_copy_dword1(unsigned int src_tiling,if (dst_tiling == I915_TILING_Yf) dword1 |= XY_FAST_COPY_DST_TILING_Yf; - dword1 |=XY_FAST_COPY_COLOR_DEPTH_32 ; +if (color_depth ==8 ) + dword1 |=XY_FAST_COPY_COLOR_DEPTH_8 ; +else + dword1 |=XY_FAST_COPY_COLOR_DEPTH_32 ;return dword1; }
@@ -603,6 +606,7 @@ void igt_blitter_fast_copy__raw(int fd,/* size */ unsigned int width, unsigned int height, + uint32_t color_depth,/* dst */ uint32_t dst_handle,
@@ -621,7 +625,7 @@ void igt_blitter_fast_copy__raw(int fd, src_pitch =fast_copy_pitch (src_stride, src_tiling); dst_pitch =fast_copy_pitch (dst_stride, dst_tiling); dword0 =fast_copy_dword0 (src_tiling, dst_tiling); - dword1 =fast_copy_dword1 (src_tiling, dst_tiling); + dword1 =fast_copy_dword1 (src_tiling, dst_tiling, color_depth);#define CHECK_RANGE (x) ((x) >= 0 && (x) < (1 << 15)) assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
@@ -681,7 +685,7 @@ void igt_blitter_fast_copy__raw(int fd,*/ void igt_blitter_fast_copy (struct intel_batchbuffer *batch,struct igt_buf *src,unsigned src_x,unsigned src_y, -unsigned width,unsigned height, +unsigned width,unsigned height,uint32_t color_depth,struct igt_buf *dst,unsigned dst_x,unsigned dst_y) {uint32_t src_pitch, dst_pitch;
@@ -690,7 +694,7 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch, src_pitch =fast_copy_pitch (src->stride, src->tiling); dst_pitch =fast_copy_pitch (dst->stride, src->tiling); dword0 =fast_copy_dword0 (src->tiling, dst->tiling); - dword1 =fast_copy_dword1 (src->tiling, dst->tiling); + dword1 =fast_copy_dword1 (src->tiling, dst->tiling, color_depth);#define CHECK_RANGE (x) ((x) >= 0 && (x) < (1 << 15)) assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
lib/intel_batchbuffer.h +2 -1
@@ -227,7 +227,7 @@ unsigned igt_buf_height(struct igt_buf *buf);void igt_blitter_fast_copy (struct intel_batchbuffer *batch,struct igt_buf *src,unsigned src_x,unsigned src_y, -unsigned width,unsigned height, +unsigned width,unsigned height,uint32_t color_depth,struct igt_buf *dst,unsigned dst_x,unsigned dst_y); void igt_blitter_fast_copy__raw(int fd,
@@ -239,6 +239,7 @@ void igt_blitter_fast_copy__raw(int fd,/* size */ unsigned int width, unsigned int height, + uint32_t color_depth,/* dst */ uint32_t dst_handle,
lib/intel_reg.h +1 -0
@@ -2530,6 +2530,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE./* dword 1 */ #define XY_FAST_COPY_SRC_TILING_Yf (1 << 31)#define XY_FAST_COPY_DST_TILING_Yf (1 << 30) +#define XY_FAST_COPY_COLOR_DEPTH_8 (0 << 24)#define XY_FAST_COPY_COLOR_DEPTH_32 (3 << 24)#define MI_STORE_DWORD_IMM ((0x20<<23)|2)
lib/ioctl_wrappers.c +9 -0
@@ -55,6 +55,7 @@#include "intel_io.h" #include "igt_debugfs.h" #include "config.h" +#include "igt_fb.h" #ifdef HAVE_VALGRIND #include <valgrind/valgrind.h>
@@ -1827,6 +1828,7 @@ void igt_require_fb_modifiers(int fd)int __kms_addfb (int fd,uint32_t handle,uint32_t width,uint32_t height,uint32_t stride,uint32_t pixel_format,uint64_t modifier, +uint32_t uv_offset,uint32_t flags,uint32_t *buf_id) {struct local_drm_mode_fb_cmd2 f;
@@ -1844,6 +1846,13 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, f.pitches[0 ] = stride; f.modifier[0 ] = modifier; +if (pixel_format ==DRM_FORMAT_NV12 ) { + f.handles[1 ] = handle; + f.pitches[1 ] = stride; + f.offsets[1 ] = uv_offset; + f.modifier[1 ] = modifier; + } + ret =igt_ioctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f); *buf_id = f.fb_id;
lib/ioctl_wrappers.h +1 -0
@@ -253,6 +253,7 @@ void igt_require_fb_modifiers(int fd);*/ int __kms_addfb (int fd,uint32_t handle,uint32_t width,uint32_t height,uint32_t stride,uint32_t pixel_format,uint64_t modifier, +uint32_t uv_offset,uint32_t flags,uint32_t *buf_id);/**
tests/kms_frontbuffer_tracking.c +3 -3
@@ -576,13 +576,13 @@ static void create_fb(enum pixel_format pformat, int width, int height,* the same size regardless of tiling since we want to properly exercise * the Kernel's specific tiling-checking code paths without accidentally * hitting size-checking ones first. */ - bpp =igt_drm_format_to_bpp (format); + bpp =igt_drm_format_to_bpp (format,0 );if (plane ==PLANE_CUR ) tiling_for_size =LOCAL_DRM_FORMAT_MOD_NONE ;else tiling_for_size = opt.tiling; -igt_calc_fb_size (drm.fd, width, height, bpp, tiling_for_size, &size, +igt_calc_fb_size (drm.fd, width, height, bpp, format, tiling_for_size, &size, &stride); igt_create_fb_with_bo_size(drm.fd, width, height, format, tiling, fb,
@@ -1208,7 +1208,7 @@ static void start_busy_thread(struct igt_fb *fb) busy_thread.width = fb->width; busy_thread.height = fb->height; busy_thread.color =pick_color (fb,COLOR_PRIM_BG ); - busy_thread.bpp =igt_drm_format_to_bpp (fb->drm_format); + busy_thread.bpp =igt_drm_format_to_bpp (fb->drm_format,0 ); rc =pthread_create (&busy_thread.thread,NULL , busy_thread_func,NULL );igt_assert_eq (rc,0 );
tests/kms_render.c +2 -2
@@ -80,8 +80,8 @@ static void gpu_blit(struct igt_fb *dst_fb, struct igt_fb *src_fb)igt_assert (dst_fb->drm_format == src_fb->drm_format);igt_assert (src_fb->drm_format ==DRM_FORMAT_RGB565 || -igt_drm_format_to_bpp (src_fb->drm_format) !=16 ); - bpp =igt_drm_format_to_bpp (src_fb->drm_format); +igt_drm_format_to_bpp (src_fb->drm_format,0 ) !=16 ); + bpp =igt_drm_format_to_bpp (src_fb->drm_format,0 ); dst_bo =gem_handle_to_libdrm_bo (bufmgr, drm_fd,"destination" , dst_fb->gem_handle);igt_assert (dst_bo);
tests/kms_rotation_crc.c +4 -4
@@ -391,7 +391,7 @@ static void test_plane_rotation_ytiled_obj(data_t *data,igt_display_t *display = &data->display;uint64_t tiling =LOCAL_I915_FORMAT_MOD_Y_TILED ;uint32_t format =DRM_FORMAT_XRGB8888 ; -int bpp =igt_drm_format_to_bpp (format); +int bpp =igt_drm_format_to_bpp (format,0 );enum igt_commit_style commit =COMMIT_LEGACY ;int fd = data->gfx_fd;igt_plane_t *plane;
@@ -426,7 +426,7 @@ static void test_plane_rotation_ytiled_obj(data_t *data,igt_assert_eq (ret,0 );do_or_die (__kms_addfb (fd, gem_handle, w, h, stride, - format, tiling,LOCAL_DRM_MODE_FB_MODIFIERS , + format, tiling,0 ,LOCAL_DRM_MODE_FB_MODIFIERS , &data->fb.fb_id)); data->fb.width = w; data->fb.height = h;
@@ -461,7 +461,7 @@ static void test_plane_rotation_exhaust_fences(data_t *data,igt_display_t *display = &data->display;uint64_t tiling =LOCAL_I915_FORMAT_MOD_Y_TILED ;uint32_t format =DRM_FORMAT_XRGB8888 ; -int bpp =igt_drm_format_to_bpp (format); +int bpp =igt_drm_format_to_bpp (format,0 );enum igt_commit_style commit =COMMIT_LEGACY ;int fd = data->gfx_fd;igt_plane_t *plane;
@@ -513,7 +513,7 @@ static void test_plane_rotation_exhaust_fences(data_t *data, } ret = (__kms_addfb (fd, gem_handle, w, h, stride, - format, tiling,LOCAL_DRM_MODE_FB_MODIFIERS , + format, tiling,0 ,LOCAL_DRM_MODE_FB_MODIFIERS , &data2[i].fb.fb_id));if (ret) {igt_warn ("failed to create framebuffer\n" );
tests/prime_vgem.c +1 -1
@@ -695,7 +695,7 @@ static void test_flip(int i915, int vgem, unsigned hang)do_or_die (__kms_addfb (i915, handle[i], bo[i].width, bo[i].height, bo[i].pitch, -DRM_FORMAT_XRGB8888 ,I915_TILING_NONE , +DRM_FORMAT_XRGB8888 ,I915_TILING_NONE ,0 ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id[i]));igt_assert (fb_id[i]); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 tests/test_nv12.c: This patch adds test_nv12 test case. It is a simple test that covers testing NV12 in linear/tile-X/tile-Y tiling formats.
In reply to Vidya SrinivasFrom: chandra konduru <[email protected]>
Previous version reference https://patchwork.freedesktop.org/patch/59067/
was posted by Chandra Konduru on Sept 9 2015 based on the
IGT framework available at that time
Current version: Rebased as per current IGT (me).
This version tests basic NV12
in linear/tile-X/tile-Y tiling formats.
--- tests/Makefile.sources | 1 + tests/test_nv12.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 tests/test_nv12.c
tests/Makefile.sources +1 -0
@@ -233,6 +233,7 @@ TESTS_progs = \ tools_test \ vgem_basic \ vgem_slow \ + test_nv12 \ $(NULL) TESTS_progs_X = \
tests/test_nv12.c new file +171 -0
171 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx