patches for testing nv12
cover patches for testing nv12
From: chandra konduru <[email protected]>
This patch series made some necessary igt framework changes to support nv12 format. And adds kms_nv12 to test nv12 format. It is having several initial test combinations but any additional tests can be added as needed.
chandra konduru (2):
Prep work for adding NV12 testcase
Adding kms_nv12 to test display NV12 feature
lib/igt_fb.c | 316 +++++++++++++++++++- lib/igt_fb.h | 9 +- lib/intel_batchbuffer.c | 16 +- lib/intel_batchbuffer.h | 3 +- lib/intel_reg.h | 1 + lib/ioctl_wrappers.c | 10 +- lib/ioctl_wrappers.h | 2 +- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 759 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/kms_render.c | 4 +- 11 files changed, 1095 insertions(+), 27 deletions(-) create mode 100644 tests/kms_nv12.c
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://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 kms_render testcase due to above changes
--- lib/igt_fb.c | 316 +++++++++++++++++++++++++++++++++++++++++++++--- lib/igt_fb.h | 9 +- lib/intel_batchbuffer.c | 16 ++- lib/intel_batchbuffer.h | 3 +- lib/intel_reg.h | 1 + lib/ioctl_wrappers.c | 10 +- lib/ioctl_wrappers.h | 2 +- tests/kms_render.c | 4 +- 8 files changed, 334 insertions(+), 27 deletions(-)
lib/igt_fb.c +300 -16
@@ -74,7 +74,7 @@ static struct format_desc_struct {/* helpers to create nice-looking framebuffers */ -static int create_bo_for_fb(int fd, int width, int height, int bpp, +static int create_bo_for_fb(int fd, int width, int height, int bpp, int bpp2, uint64_t tiling, unsigned bo_size, uint32_t *gem_handle_ret, unsigned *size_ret,
@@ -99,13 +99,17 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,for (stride =512 ; stride < v; stride *=2 ) ; - v = stride * height; +/* planar formats height is 1.5x */ + v = stride * (bpp2 ? (height *3 ) /2 : height); +for (size =1024 *1024 ; size < v; size *=2 ) ; }else {/* Scan-out has a 64 byte alignment restriction */ stride = (width * (bpp /8 ) +63 ) & ~63 ; - size = stride * height; + +/* planar formats height is 1.5x */ + size = stride * (bpp2 ? (height *3 ) /2 : height); }if (bo_size ==0 )
@@ -393,6 +397,75 @@ void igt_paint_image(cairo_t *cr, const char *filename, }/** +* igt_get_image_size: +* @filename: filename of the png image +* @width: width of the image +* @height: height of the image +* +* This function returns @width and @height of the png image in @filename, +* which is loaded from the package data directory. +*/ +void +igt_get_image_size (const char *filename,int *width,int *height) +{ +cairo_surface_t *image; +FILE * f; + + f =igt_fopen_data (filename); + + image =cairo_image_surface_create_from_png_stream (&stdio_read_func, f); +igt_assert (cairo_surface_status (image) ==CAIRO_STATUS_SUCCESS ); + + *width =cairo_image_surface_get_width (image); + *height =cairo_image_surface_get_height (image); + +cairo_surface_destroy (image); + +fclose (f); +} + + +/** +* igt_fb_calc_uv: +* @fb: pointer to an #igt_fb structure +* +* This function calculates UV offset in bytes and UV starting line number +* for requested NV12 @fb. +*/ +void +igt_fb_calc_uv (struct igt_fb *fb) +{ +if (fb->drm_format !=DRM_FORMAT_NV12 ) +return ; + +switch (fb->tiling) { +case LOCAL_DRM_FORMAT_MOD_NONE : + fb->uv_y_start = fb->height; +break ; +case LOCAL_I915_FORMAT_MOD_X_TILED : + fb->uv_y_start = fb->height; +break ; +case LOCAL_I915_FORMAT_MOD_Y_TILED : + fb->uv_y_start = fb->height; +break ; +case LOCAL_I915_FORMAT_MOD_Yf_TILED: +/* tile-Yf requires uv to start on a new tile row */ +if (fb->height %64 ) + fb->uv_y_start = (fb->height +63 ) & ~63 ; +else + fb->uv_y_start = fb->height; +break ; +default : +igt_assert (0 ); + } + + fb->uv_offset = fb->uv_y_start * fb->stride; + +/* assert that fb has enough lines to hold y and uv sub-planes */ +igt_assert (fb->size / fb->stride >= fb->uv_y_start + fb->height /2 ); +} + +/** * igt_create_fb_with_bo_size: * @fd: open i915 drm file descriptor * @width: width of the framebuffer in pixel
@@ -418,24 +491,32 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, unsigned bo_size) { uint32_t fb_id; -int bpp; +int bpp, bpp2;memset (fb,0 ,sizeof (*fb)); - bpp =igt_drm_format_to_bpp (format); + bpp =igt_drm_format_to_bpp (format,0 ); + bpp2 =igt_drm_format_to_bpp (format,1 ); -igt_debug ("%s(width=%d, height=%d, format=0x%x [bpp=%d], tiling=0x%" PRIx64", size=%d\n" , - __func__, width, height, format, bpp, tiling, bo_size); -do_or_die (create_bo_for_fb (fd, width, height, bpp, tiling, bo_size, +igt_debug ("%s(width=%d, height=%d, format=0x%x [bpp=%d, %d], tiling=0x%" PRIx64", size=%d\n" , + __func__, width, height, format, bpp, bpp2, tiling, bo_size); +do_or_die (create_bo_for_fb (fd, width, height, bpp, bpp2, tiling, bo_size, &fb->gem_handle, &fb->size, &fb->stride));igt_debug ("%s(handle=%d, pitch=%d)\n" , __func__, fb->gem_handle, fb->stride); + fb->width = width; + fb->height = height; + fb->tiling = tiling; + fb->drm_format = format; + +igt_fb_calc_uv (fb); +if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE && tiling !=LOCAL_I915_FORMAT_MOD_X_TILED ) {do_or_die (__kms_addfb (fd, fb->gem_handle, width, height, - fb->stride, format, tiling, + fb->stride, format, tiling, fb->uv_offset,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); }else {uint32_t handles[4 ];
@@ -449,21 +530,213 @@ igt_create_fb_with_bo_size(int fd, int width, int height, handles[0 ] = fb->gem_handle; pitches[0 ] = fb->stride; +if (format ==DRM_FORMAT_NV12 ) { + handles[1 ] = fb->gem_handle; + pitches[1 ] = fb->stride; + offsets[1 ] = fb->uv_offset; + } +do_or_die (drmModeAddFB2 (fd, width, height, format, handles, pitches, offsets, &fb_id,0 )); } - fb->width = width; - fb->height = height; - fb->tiling = tiling; - fb->drm_format = format; fb->fb_id = fb_id;return fb_id; }/** +* igt_fb_gem_mmap: +* @fd: open i915 drm file descriptor +* @fb: pointer to an #igt_fb structure +* +* This function memory maps gem buffer for cpu access and saves mmap pointer +* in @fb. +*/ +void +igt_fb_gem_mmap (int fd,struct igt_fb *fb) +{ +if (!fb->mmap_gtt) + fb->mmap_gtt =gem_mmap__gtt (fd, fb->gem_handle, fb->size, +PROT_READ |PROT_WRITE ); +igt_assert (fb->mmap_gtt); +} + +/** +* igt_fb_csc_xrgb_to_nv12: +* @fd: open i915 drm file descriptor +* @width: width of the framebuffer to be converted +* @height: height of the framebuffer to be converted +* @dst: pointer to an #igt_fb structure holding destination framebuffer +* @src: pointer to an #igt_fb structure holding source framebuffer +* +* This function converts source framebuffer into destination framebuffer +* format. It also mmaps the underlying gem buffer if it isn't mmaped +* before. +* +* For now: +* - it expects both src and dst fbs are same size and tiling +*/ +void +igt_fb_csc_xrgb_to_nv12 (int fd,struct igt_fb *dst_fb,struct igt_fb *src_fb) +{ +unsigned char *nv12; +unsigned char *xrgb; +unsigned char y, v, u; +float yf, vf, uf; +unsigned char r, g, b; +int i, j; +int xrgb_pos; +int y_pos; +int uv_pos; +int uv_base; +unsigned int obj_tiling; +struct igt_fb *temp_src_fb, *temp_dst_fb; +struct igt_fb fb1, fb2; +int temp_src_id, temp_dst_id; + +igt_assert (dst_fb); +igt_assert (src_fb); +igt_assert (dst_fb->width == src_fb->width); +igt_assert (dst_fb->height == src_fb->height); +igt_assert (src_fb->tiling == dst_fb->tiling); + +igt_assert (src_fb->drm_format ==DRM_FORMAT_XRGB8888 ); +igt_assert (dst_fb->drm_format ==DRM_FORMAT_NV12 ); + +/* +* Steps: Not the best approach but gets job done for igt +* (1) create linear temp_src, temp_dst +* (2) fast blit src --> temp src +* (3) gem map temp_src, temp_dst +* (4) host conversion & copy from temp src --> temp dst +* (5) fast blit temp dst --> dst +* (6) free temp fbs +* +* For Linear/X: +* perform 3 & 4 only +* For Y/Yf: +* perform all steps +*/ + +if (src_fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + src_fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { + + temp_src_fb = &fb1; + temp_dst_fb = &fb2; + +/* (1) create linear temp_src, temp_dst */ + temp_src_id =igt_create_fb (fd, + src_fb->width, src_fb->height, + src_fb->drm_format, +LOCAL_DRM_FORMAT_MOD_NONE , + temp_src_fb); +igt_assert (temp_src_id); + + temp_dst_id =igt_create_fb (fd, + dst_fb->width, dst_fb->height, + dst_fb->drm_format, +LOCAL_DRM_FORMAT_MOD_NONE , + temp_dst_fb); +igt_assert (temp_dst_id); + +if (src_fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED ) + obj_tiling =I915_TILING_Y ; +else + obj_tiling = I915_TILING_Yf; + +/* (2) fast blit src --> temp src */ +igt_blitter_fast_copy__raw (fd, + src_fb->gem_handle, + src_fb->stride, + obj_tiling, +0 ,0 , + temp_src_fb->width, temp_src_fb->height, +igt_drm_format_to_bpp (temp_src_fb->drm_format,0 ), + temp_src_fb->gem_handle, + temp_src_fb->stride, +I915_TILING_NONE , +0 ,0 ); + }else { + temp_src_fb = src_fb; + temp_dst_fb = dst_fb; + } + +/* (3) gem map temp_src, temp_dst */ +igt_fb_gem_mmap (fd, temp_src_fb); +igt_fb_gem_mmap (fd, temp_dst_fb); + +/* (4) host conversion & copy from temp src --> temp dst */ + xrgb = (unsigned char *) temp_src_fb->mmap_gtt; + nv12 = (unsigned char *) temp_dst_fb->mmap_gtt; + uv_base = temp_dst_fb->stride * temp_dst_fb->height; + +for (i =0 ; i < temp_src_fb->height; i++) { + xrgb_pos = i * temp_src_fb->stride; + y_pos = i * temp_dst_fb->stride; + uv_pos = temp_dst_fb->stride * i /2 ; +for (j =0 ; j < temp_src_fb->width; j++) { + b = xrgb[xrgb_pos++]; + g = xrgb[xrgb_pos++]; + r = xrgb[xrgb_pos++]; + xrgb_pos++; + +/* use floats for intermediate calcs, to get better results */ + yf = (0.257 * r) + (0.504 * g) + (0.098 * b) +16 ; + uf = -(0.148 * r) - (0.291 * g) + (0.439 * b) +128 ; + vf = (0.439 * r) - (0.368 * g) - (0.071 * b) +128 ; + + y = (unsigned char ) yf; + u = (unsigned char ) uf; + v = (unsigned char ) vf; + + nv12[y_pos++] = y; + +if (!(j %2 ) && !(i %2 )) { + nv12[uv_base + uv_pos++] = u; + nv12[uv_base + uv_pos++] = v; + } + } + } + +/* (5) fast blit temp dst --> dst */ +if (dst_fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + dst_fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { + +/* blit y-plane */ +igt_blitter_fast_copy__raw (fd, + temp_dst_fb->gem_handle, + temp_dst_fb->stride, +I915_TILING_NONE , +0 ,0 , + dst_fb->width, dst_fb->height, +igt_drm_format_to_bpp (dst_fb->drm_format,0 ), + dst_fb->gem_handle, + dst_fb->stride, + obj_tiling, +0 ,0 ); + +/* blit uv-plane */ +igt_blitter_fast_copy__raw (fd, + temp_dst_fb->gem_handle, + temp_dst_fb->stride, +I915_TILING_NONE , +0 , temp_dst_fb->uv_y_start, + dst_fb->width, dst_fb->height, +igt_drm_format_to_bpp (dst_fb->drm_format,1 ), + dst_fb->gem_handle, + dst_fb->stride, + obj_tiling, +0 , dst_fb->uv_y_start); + +/* (6) free temp fbs */ +igt_remove_fb (fd, temp_src_fb); +igt_remove_fb (fd, temp_dst_fb); + } +} + +/** * igt_create_fb: * @fd: open i915 drm file descriptor * @width: width of the framebuffer in pixel
@@ -686,6 +959,7 @@ static void destroy_cairo_surface__blit(void *arg)I915_TILING_NONE ,0 ,0 ,/* src_x, src_y */ fb->width, fb->height, +0 , fb->gem_handle, fb->stride, obj_tiling,
@@ -712,8 +986,8 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)* cairo). This linear bo will be then blitted to its final * destination, tiling it at the same time. */ - bpp =igt_drm_format_to_bpp (fb->drm_format); - ret = create_bo_for_fb(fd, fb->width, fb->height, bpp, + bpp =igt_drm_format_to_bpp (fb->drm_format,0 ); + ret = create_bo_for_fb(fd, fb->width, fb->height, bpp, 0, LOCAL_DRM_FORMAT_MOD_NONE, 0, &blit->linear.handle, &blit->linear.size,
@@ -734,6 +1008,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) obj_tiling,0 ,0 ,/* src_x, src_y */ fb->width, fb->height, + bpp, blit->linear.handle, blit->linear.stride, I915_TILING_NONE,
@@ -893,15 +1168,24 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth)/** * igt_drm_format_to_bpp: * @drm_format: drm fourcc pixel format code +* @plane: plane id * * Returns: * The bits per pixel for the given drm fourcc pixel format code. Fails hard if * no match was found. */ -uint32_t igt_drm_format_to_bpp (uint32_t drm_format) +uint32_t igt_drm_format_to_bpp (uint32_t drm_format,int plane) {struct format_desc_struct *f; +if (drm_format ==DRM_FORMAT_NV12 && plane ==0 ) +return 8 ; +if (drm_format ==DRM_FORMAT_NV12 && plane ==1 ) +return 16 ; + +if (plane) +return 0 ; +for_each_format (f)if (f->drm_id == drm_format)return f->bpp;
lib/igt_fb.h +8 -1
@@ -54,10 +54,13 @@ struct igt_fb {uint64_t tiling;unsigned size;cairo_surface_t *cairo_surface; +void *mmap_gtt;uint32_t src_x;uint32_t src_y;uint32_t src_w;uint32_t src_h; +uint32_t uv_y_start; +uint32_t uv_offset; };enum igt_text_align {
@@ -82,6 +85,9 @@ unsigned int igt_create_color_fb(int fd, int width, int height,unsigned int igt_create_stereo_fb (int drm_fd,drmModeModeInfo *mode,uint32_t format,uint64_t tiling);void igt_remove_fb (int fd,struct igt_fb *fb); +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);/* cairo-based painting */ cairo_t *igt_get_cairo_ctx (int fd,struct igt_fb *fb);
@@ -98,10 +104,11 @@ void igt_write_fb_to_png(int fd, struct igt_fb *fb, const char *filename);int igt_cairo_printf_line (cairo_t *cr,enum igt_text_align align,double yspacing,const char *fmt, ...) __attribute__((format (printf,4 ,5 ))); +void igt_get_image_size (const char *filename,int *width,int *height);/* 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_formats (const uint32_t **formats,int *format_count);
lib/intel_batchbuffer.c +11 -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; }
@@ -586,6 +589,7 @@ static void exec_blit(int fd,* @src_y: Y coordinate of the source region to copy * @width: Width of the region to copy * @height: Height of the region to copy +* @color_depth: Color depth of the buffer * @dst_handle: GEM handle of the source buffer * @dst_stride: Stride (in bytes) of the destination buffer * @dst_tiling: Tiling mode of the destination buffer
@@ -603,6 +607,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 +626,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) &&
@@ -671,6 +676,7 @@ void igt_blitter_fast_copy__raw(int fd,* @src_y: source pixel y-coordination * @width: width of the copied rectangle * @height: height of the copied rectangle +* @color_depth: Color depth of the buffer * @dst: destination i-g-t buffer object * @dst_x: destination pixel x-coordination * @dst_y: destination pixel y-coordination
@@ -681,7 +687,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 +696,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 -1
@@ -54,6 +54,7 @@#include "intel_chipset.h" #include "intel_io.h" #include "igt_debugfs.h" +#include "igt_fb.h" #include "config.h" #include "ioctl_wrappers.h"
@@ -1221,7 +1222,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 flags,uint32_t *buf_id) +uint32_t uv_offset,uint32_t flags,uint32_t *buf_id) {struct local_drm_mode_fb_cmd2 f;int ret;
@@ -1238,6 +1239,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 =drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f); *buf_id = f.fb_id;
lib/ioctl_wrappers.h +1 -1
@@ -176,6 +176,6 @@ 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 flags,uint32_t *buf_id); +uint32_t uv_offset,uint32_t flags,uint32_t *buf_id);#endif /* IOCTL_WRAPPERS_H */
tests/kms_render.c +2 -2
@@ -78,8 +78,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);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 Adding kms_nv12 to test display NV12 feature
In reply to Chandra KonduruFrom: chandra konduru <[email protected]>
This patch adds kms_nv12 test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling.
v2:
-Added 90/270 tests (me)
-took out crc test as it isn't adding much value due to chroma upsampling (me)
v3:
-Make --list-subtests option work (Tvrtko)
-Make nv12 unsupported test run properly either as a sub test
or along with all other tests (me)
-Added nv12 fb with invalid params (Daniel)
--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 759 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 761 insertions(+) create mode 100644 tests/kms_nv12.c
tests/.gitignore +1 -0
@@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residency
tests/Makefile.sources +1 -0
@@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \
tests/kms_nv12.c new file +759 -0
759 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
Quoted 663 lines · Chandra Konduru
From: chandra konduru <[email protected]>
This patch adds
kms_nv12test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling.v2:
(quoted diff) +0
-2-Added 90/270 tests (me) -took out crc test as it isn't adding much value due to chroma upsampling (me)v3:
(quoted diff) +0
-3-Make --list-subtests option work (Tvrtko) -Make nv12 unsupported test run properly either as a sub test or along with all other tests (me) -Added nv12 fb with invalid params (Daniel)Signed-off-by chandra konduru <[email protected]>--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 759 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 761 insertions(+) create mode 100644 tests/kms_nv12.ctests/.gitignore +1
-0@@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residencytests/Makefile.sources +1
-0@@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \tests/kms_nv12.c new file +608
-0@@ -0,0 +1,759 @@ +/* +* Copyright © 2013,2014 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. +* +*/ + +#include <math.h> +#include <fcntl.h> +#include <sys/stat.h> + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "igt_core.h" +#include "intel_chipset.h" +#include "ioctl_wrappers.h" + +IGT_TEST_DESCRIPTION ("Test display NV12 support" ); + +uint32_t devid; +typedef struct { +int drm_fd; +igt_display_t display; +int num_scalers; +int num_planes; + +struct igt_fb fb1; +struct igt_fb fb1_nv12; +struct igt_fb fb2; +struct igt_fb fb2_nv12; +struct igt_fb fb3; +struct igt_fb fb3_nv12; +int fb_id1; +int fb_id1_nv12; +int fb_id2; +int fb_id2_nv12; +int fb_id3; +int fb_id3_nv12; + +igt_plane_t *plane1; +igt_plane_t *plane2; +igt_plane_t *plane3; + +uint64_t tiled; +int rotation; +}data_t ; + +typedef struct { +int width; +int height; +}res_t ; + +#define IMG_FILE "1080p-left.png" + +static void +paint_pattern (data_t *d,struct igt_fb *fb,uint16_t w,uint16_t h) +{ +cairo_t *cr; + + cr =igt_get_cairo_ctx (d->drm_fd, fb); +igt_paint_test_pattern (cr, w, h); +cairo_destroy (cr); +} + +static void +paint_image (data_t *d,struct igt_fb *fb,uint16_t w,uint16_t h) +{ +cairo_t *cr; + + cr =igt_get_cairo_ctx (d->drm_fd, fb); +igt_paint_image (cr,IMG_FILE ,0 ,0 , w, h); +cairo_destroy (cr); +} + +static void prepare_crtc (data_t *data,igt_output_t *output,enum pipe pipe, +igt_plane_t *plane,drmModeModeInfo *mode,enum igt_commit_style s) +{ +igt_display_t *display = &data->display; + +igt_output_set_pipe (output, pipe); + +/* before allocating, free if any older fb */ +if (data->fb_id1) { +igt_remove_fb (data->drm_fd, &data->fb1); + data->fb_id1 =0 ; + } + +/* allocate fb for plane 1 */ + data->fb_id1 =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + data->tiled,/* tiled */ + &data->fb1); +igt_assert (data->fb_id1); + +paint_pattern (data, &data->fb1, mode->hdisplay, mode->vdisplay); + +/* +* We always set the primary plane to actually enable the pipe as +* there's no way (that works) to light up a pipe with only a sprite +* plane enabled at the moment. +*/ +if (!plane->is_primary) { +igt_plane_t *primary; + + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_plane_set_fb (primary, &data->fb1); + } + +igt_plane_set_fb (plane, &data->fb1); +if (s ==COMMIT_LEGACY ) { +int ret; + ret =drmModeSetCrtc (data->drm_fd, + output->config.crtc->crtc_id, + data->fb_id1, + plane->pan_x, plane->pan_y, + &output->id, +1 , + mode); +igt_assert (ret ==0 ); + }else { +igt_display_commit2 (display, s); + } +} + +static void cleanup_crtc (data_t *data,igt_output_t *output,igt_plane_t *plane) +{ +igt_display_t *display = &data->display; + +if (data->fb_id1) { +igt_remove_fb (data->drm_fd, &data->fb1); + data->fb_id1 =0 ; + } +if (data->fb_id2) { +igt_remove_fb (data->drm_fd, &data->fb2); + data->fb_id2 =0 ; + } +if (data->fb_id3) { +igt_remove_fb (data->drm_fd, &data->fb3); + data->fb_id3 =0 ; + } + +if (data->fb_id1_nv12) { +igt_remove_fb (data->drm_fd, &data->fb1_nv12); + data->fb_id1_nv12 =0 ; + } + +if (data->fb_id2_nv12) { +igt_remove_fb (data->drm_fd, &data->fb2_nv12); + data->fb_id2_nv12 =0 ; + } + +if (data->fb_id3_nv12) { +igt_remove_fb (data->drm_fd, &data->fb3_nv12); + data->fb_id3_nv12 =0 ; + } + +if (!plane->is_primary) { +igt_plane_t *primary; + + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_plane_set_fb (primary,NULL ); + } + +igt_plane_set_fb (plane,NULL ); +igt_output_set_pipe (output,PIPE_ANY ); + +igt_display_commit2 (display,COMMIT_UNIVERSAL ); +} + +static void test_nv12_plane (data_t *d) +{ +igt_display_t *display = &d->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; +int img_width; +int img_height; + +igt_require (d->display.has_universal_planes); +igt_require (d->num_scalers); + +for_each_connected_output (display, output) { +drmModeModeInfo *mode; + mode =igt_output_get_mode (output); + pipe = output->config.pipe; + +igt_output_set_pipe (output, pipe); + +/* get planes */ + d->plane1 =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); + d->plane2 =igt_output_get_plane (output,IGT_PLANE_2 ); +if (d->num_planes >=3 ) + d->plane3 =igt_output_get_plane (output,IGT_PLANE_3 ); + +/* set required rotation */ +igt_plane_set_rotation (d->plane1, d->rotation); +igt_plane_set_rotation (d->plane2, d->rotation); +if (d->num_planes >=3 ) +igt_plane_set_rotation (d->plane3, d->rotation); + +/* Set up display with plane 1 */ +prepare_crtc (d, output, pipe, d->plane1, mode,COMMIT_LEGACY ); + +/* allocate fb2, fb2_nv12, fb1_nv12 with image size */ +igt_get_image_size (IMG_FILE , &img_width, &img_height); + +/* fb2 is in RGB format */ + d->fb_id2 =igt_create_fb (d->drm_fd, + img_width, img_height, +DRM_FORMAT_XRGB8888 , + d->tiled,/* tiled */ + &d->fb2); +igt_assert (d->fb_id2); + +/* fb1_nv12 is in NV12 format */ + d->fb_id1_nv12 =igt_create_fb (d->drm_fd, + img_width, img_height, +DRM_FORMAT_NV12 , + d->tiled,/* tiled */ + &d->fb1_nv12); +igt_assert (d->fb_id1_nv12); + +/* fb2_nv12 is in NV12 format */ + d->fb_id2_nv12 =igt_create_fb (d->drm_fd, + img_width, img_height, +DRM_FORMAT_NV12 , + d->tiled, + &d->fb2_nv12); +igt_assert (d->fb_id2_nv12); + +/* fb3 is in RGB */ + d->fb_id3 =igt_create_fb (d->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_ARGB8888 , + d->tiled,/* tiled */ + &d->fb3); +igt_assert (d->fb_id3); + +/* +* Mimicing some not exactly but closer to some real usage +*/ + +/* set up data for fb2: both fb1_nv12, fb2_nv12 uses this */ +paint_image (d, &d->fb2, img_width, img_height); + +/* set up data in fb1_nv12: fb2 RGB-> fb1_nv12 */ +igt_fb_csc_xrgb_to_nv12 (d->drm_fd, &d->fb1_nv12, &d->fb2); + +/* set up data in fb2_nv12: fb2 RGB-> fb2_nv12 */ +igt_fb_csc_xrgb_to_nv12 (d->drm_fd, &d->fb2_nv12, &d->fb2); + +/* set up data in fb3 */ +paint_pattern (d, &d->fb3, d->fb3.width, d->fb3.height); + +/* Set up fb2_nv12->plane2 mapping. */ +igt_plane_set_fb (d->plane2, &d->fb2_nv12); +/* 2nd plane nv12 windowed - no scaling */ +igt_fb_set_position (&d->fb2_nv12, d->plane2,0 ,0 ); +igt_fb_set_size (&d->fb2_nv12, d->plane2, d->fb2_nv12.width, + d->fb2_nv12.height); +igt_plane_set_position (d->plane2,0 ,0 ); +igt_plane_set_size (d->plane2, d->fb2_nv12.width, d->fb2_nv12.height); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* Change primary plane to nv12 full screen: scaling + NV12 */ +igt_plane_set_fb (d->plane1, &d->fb1_nv12); +igt_fb_set_position (&d->fb1_nv12, d->plane1,0 ,0 ); +igt_fb_set_size (&d->fb1_nv12, d->plane1, d->fb1_nv12.width, + d->fb1_nv12.height); +igt_plane_set_position (d->plane1,0 ,0 ); +igt_plane_set_size (d->plane1, mode->hdisplay, mode->vdisplay); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +if (d->num_planes >=3 ) { +/* Set up fb3->plane3 mapping. */ +igt_plane_set_fb (d->plane3, &d->fb3); + +/* 3rd plane full screen - no scaling. */ +igt_fb_set_position (&d->fb3, d->plane3,0 ,0 ); +igt_fb_set_size (&d->fb3, d->plane3, d->fb3.width, d->fb3.height); +igt_plane_set_position (d->plane3,0 ,0 ); +igt_plane_set_size (d->plane3, d->fb3.width, d->fb3.height); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + } + +/* 2nd plane nv12 up scaling */ +igt_fb_set_position (&d->fb2_nv12, d->plane2,0 ,0 ); +igt_fb_set_size (&d->fb2_nv12, d->plane2, d->fb2_nv12.width, + d->fb2_nv12.height); +igt_plane_set_position (d->plane2,100 ,100 ); +igt_plane_set_size (d->plane2, mode->hdisplay-200 , mode->vdisplay-200 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* 2nd plane nv12 down scaling */ +igt_fb_set_position (&d->fb2_nv12, d->plane2,0 ,0 ); +igt_fb_set_size (&d->fb2_nv12, d->plane2, d->fb2_nv12.width, + d->fb2_nv12.height); +igt_plane_set_position (d->plane2,1024 ,0 ); +igt_plane_set_size (d->plane2, d->fb2_nv12.width *2 /3 , + d->fb2_nv12.height *2 /3 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* Back to single plane mode - rgb & no scaling */ +igt_plane_set_fb (d->plane1, &d->fb1); +igt_plane_set_fb (d->plane2,NULL ); +if (d->num_planes >=3 ) +igt_plane_set_fb (d->plane3,NULL ); +igt_fb_set_position (&d->fb1, d->plane1,0 ,0 ); +igt_fb_set_size (&d->fb1, d->plane1, mode->hdisplay, mode->vdisplay); +igt_plane_set_position (d->plane1,0 ,0 ); +igt_plane_set_size (d->plane1, mode->hdisplay, mode->vdisplay); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* single plane mode - rgb & scaling */ +igt_plane_set_rotation (d->plane1,IGT_ROTATION_0 ); +igt_plane_set_fb (d->plane1, &d->fb1); +igt_fb_set_position (&d->fb1, d->plane1,0 ,0 ); +igt_fb_set_size (&d->fb1, d->plane1, d->fb1.width/2 , d->fb1.height/2 ); +igt_plane_set_position (d->plane1,0 ,0 ); +igt_plane_set_size (d->plane1, mode->hdisplay, mode->vdisplay); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* single plane mode - nv12 & scaling */ +igt_plane_set_fb (d->plane1, &d->fb1_nv12); +igt_fb_set_position (&d->fb1_nv12, d->plane1,0 ,0 ); +igt_fb_set_size (&d->fb1_nv12, d->plane1, d->fb1_nv12.width, + d->fb1_nv12.height); +igt_plane_set_position (d->plane1,0 ,0 ); +igt_plane_set_size (d->plane1, mode->hdisplay, mode->vdisplay); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + + valid_tests++; + +cleanup_crtc (d, output, d->plane1); + } +igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); +} + +static void test_nv12_plane_rotation_90_or_270 (data_t *d) +{ +igt_display_t *display = &d->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; +int i; + +/* +* There are two key scenarios: +* 1) Flip landscape buffer onto portrait display +* 2) Flip portrait buffer onto landscape display +* +* Due to availability of landscape display, going with #2. +*/ +res_t nv12_res_list[] = { + {480 ,720 }, + {720 ,1280 }, + {1080 ,1920 }, + }; + +igt_require (d->display.has_universal_planes); +igt_require (d->num_scalers); + +for_each_connected_output (display, output) { +drmModeModeInfo *mode; + mode =igt_output_get_mode (output); + pipe = output->config.pipe; + +igt_output_set_pipe (output, pipe); + +/* get planes */ + d->plane1 =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); + d->plane2 =igt_output_get_plane (output,IGT_PLANE_2 ); + +for (i =0 ; i <sizeof (nv12_res_list)/sizeof (res_t); i++) { +/* Set up display with plane 1 */ +igt_plane_set_rotation (d->plane1,IGT_ROTATION_0 ); +prepare_crtc (d, output, pipe, d->plane1, mode,COMMIT_LEGACY ); + +/* fb2 is in RGB format */ + d->fb_id2 =igt_create_fb (d->drm_fd, + nv12_res_list[i].width, nv12_res_list[i].height, +DRM_FORMAT_XRGB8888 , + d->tiled, + &d->fb2); +igt_assert (d->fb_id2); + +/* Change primary plane to fb2 RGB with rotation */ +igt_plane_set_rotation (d->plane1, d->rotation); + +igt_plane_set_fb (d->plane1, &d->fb2); +igt_fb_set_position (&d->fb2, d->plane1,0 ,0 ); +igt_fb_set_size (&d->fb2, d->plane1, d->fb2.width, d->fb2.height); +igt_plane_set_position (d->plane1,0 ,0 ); +igt_plane_set_size (d->plane1, mode->hdisplay, mode->vdisplay); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* fb1_nv12 is in NV12 format */ + d->fb_id1_nv12 =igt_create_fb (d->drm_fd, + nv12_res_list[i].width, nv12_res_list[i].height, +DRM_FORMAT_NV12 , + d->tiled, + &d->fb1_nv12); +igt_assert (d->fb_id1_nv12); + +/* fb2_nv12 is in NV12 format */ + d->fb_id2_nv12 =igt_create_fb (d->drm_fd, + nv12_res_list[i].width, nv12_res_list[i].height, +DRM_FORMAT_NV12 , + d->tiled, + &d->fb2_nv12); +igt_assert (d->fb_id2_nv12); + +/* set up data in fb1_nv12: fb2 PATTERN RGB-> fb1_nv12 */ +paint_pattern (d, &d->fb2, d->fb2.width, d->fb2.height); +igt_fb_csc_xrgb_to_nv12 (d->drm_fd, &d->fb1_nv12, &d->fb2); + +/* set up data in fb2_nv12: fb2 PATTERN RGB-> fb2_nv12 */ +paint_pattern (d, &d->fb2, d->fb2.width, d->fb2.height); +igt_fb_csc_xrgb_to_nv12 (d->drm_fd, &d->fb2_nv12, &d->fb2); + +/* set required rotation */ +igt_plane_set_rotation (d->plane1, d->rotation); +igt_plane_set_rotation (d->plane2, d->rotation); + +/* Change primary plane to nv12 full screen: scaling + NV12 */ +igt_plane_set_fb (d->plane1, &d->fb1_nv12); +igt_fb_set_position (&d->fb1_nv12, d->plane1,0 ,0 ); +igt_fb_set_size (&d->fb1_nv12, d->plane1, d->fb1_nv12.width, + d->fb1_nv12.height); +igt_plane_set_position (d->plane1,0 ,0 ); +igt_plane_set_size (d->plane1, mode->hdisplay, mode->vdisplay); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* 2nd plane nv12 windowed */ +igt_plane_set_fb (d->plane2, &d->fb2_nv12); +igt_fb_set_position (&d->fb2_nv12, d->plane2,0 ,0 ); +igt_fb_set_size (&d->fb2_nv12, d->plane2, d->fb2_nv12.width, + d->fb2_nv12.height); +igt_plane_set_position (d->plane2,0 ,0 ); +igt_plane_set_size (d->plane2, d->fb2_nv12.height,d->fb2_nv12.width); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* 2nd plane nv12 up scaling */ +igt_fb_set_position (&d->fb2_nv12, d->plane2,0 ,0 ); +igt_fb_set_size (&d->fb2_nv12, d->plane2, d->fb2_nv12.width, + d->fb2_nv12.height); +igt_plane_set_position (d->plane2,100 ,100 ); +igt_plane_set_size (d->plane2, mode->hdisplay-200 , mode->vdisplay-200 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* 2nd plane nv12 down scaling */ +igt_fb_set_position (&d->fb2_nv12, d->plane2,0 ,0 ); +igt_fb_set_size (&d->fb2_nv12, d->plane2, d->fb2_nv12.width, + d->fb2_nv12.height); +igt_plane_set_position (d->plane2,100 ,100 ); +igt_plane_set_size (d->plane2, d->fb2_nv12.height *2 /3 , + d->fb2_nv12.width *2 /3 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* 2nd plane nv12 down scaling - pan into FB */ +igt_fb_set_position (&d->fb2_nv12, d->plane2,100 ,100 ); +igt_fb_set_size (&d->fb2_nv12, d->plane2, d->fb2_nv12.width-100 , + d->fb2_nv12.height-100 ); +igt_plane_set_position (d->plane2,100 ,100 ); +igt_plane_set_size (d->plane2, (d->fb2_nv12.height-100 ) *2 /3 , + (d->fb2_nv12.width-100 ) *2 /3 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* Back to single plane mode - rgb & no scaling */ +igt_plane_set_rotation (d->plane1,IGT_ROTATION_0 ); +igt_plane_set_fb (d->plane1, &d->fb1); +igt_plane_set_fb (d->plane2,NULL ); +igt_fb_set_position (&d->fb1, d->plane1,0 ,0 ); +igt_fb_set_size (&d->fb1, d->plane1, mode->hdisplay, mode->vdisplay); +igt_plane_set_position (d->plane1,0 ,0 ); +igt_plane_set_size (d->plane1, mode->hdisplay, mode->vdisplay); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_remove_fb (d->drm_fd, &d->fb2); +igt_remove_fb (d->drm_fd, &d->fb2_nv12); +igt_remove_fb (d->drm_fd, &d->fb1_nv12); + d->fb_id2 =0 ; + d->fb_id2_nv12 =0 ; + d->fb_id1_nv12 =0 ; + } + + valid_tests++; + +cleanup_crtc (d, output, d->plane1); + } +igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); +} + +static void test_nv12_unsupported_plane (data_t *d) +{ +igt_display_t *display = &d->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (d->display.has_universal_planes); +igt_require (d->num_scalers); +igt_require (d->num_planes >=3 ); + +for_each_connected_output (display, output) { +drmModeModeInfo *mode; + mode =igt_output_get_mode (output); + pipe = output->config.pipe; + +igt_output_set_pipe (output, pipe); + +/* Set up display with plane 1 */ + d->plane1 =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_plane_set_rotation (d->plane1,IGT_ROTATION_0 ); +prepare_crtc (d, output, pipe, d->plane1, mode,COMMIT_LEGACY ); + + d->fb_id3_nv12 =igt_create_fb (d->drm_fd, +1920 ,1080 , +DRM_FORMAT_NV12 , + d->tiled, + &d->fb3_nv12); +igt_assert (d->fb_id3_nv12); + +/* Set up fb3_nv12->plane3 mapping. */ + d->plane3 =igt_output_get_plane (output,IGT_PLANE_3 ); +igt_plane_set_fb (d->plane3, &d->fb3_nv12); + +/* 3rd plane nv12 windowed - no scaling */ +igt_fb_set_position (&d->fb3_nv12, d->plane3,0 ,0 ); +igt_fb_set_size (&d->fb3_nv12, d->plane3, d->fb3_nv12.width, + d->fb3_nv12.height); +igt_plane_set_position (d->plane3,0 ,0 ); +igt_plane_set_size (d->plane3, d->fb3_nv12.width, d->fb3_nv12.height); + +/* Should fail because NV12 is not supported on plane 3 */ +igt_assert (igt_display_try_commit2 (display,COMMIT_UNIVERSAL ) + == -EINVAL ); + + valid_tests++; + +igt_plane_set_fb (d->plane3,NULL ); +cleanup_crtc (d, output, d->plane1); + } +igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); +} + +static void test_nv12_invalid_fb_params (data_t *d) +{ +igt_display_t *display = &d->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (d->display.has_universal_planes); +igt_require (d->num_scalers); + +for_each_connected_output (display, output) { +struct local_drm_mode_fb_cmd2 f; +int fd = d->drm_fd; +drmModeModeInfo *mode; + + mode =igt_output_get_mode (output); + pipe = output->config.pipe; + +igt_output_set_pipe (output, pipe); + +/* Set up display with plane 1 */ + d->plane1 =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_plane_set_rotation (d->plane1,IGT_ROTATION_0 ); +prepare_crtc (d, output, pipe, d->plane1, mode,COMMIT_LEGACY ); + +/* use igt helper to create bo and addfb tile-Yf, this should pass */ + d->fb_id1_nv12 =igt_create_fb (d->drm_fd, +1920 ,1080 , +DRM_FORMAT_NV12 , + LOCAL_I915_FORMAT_MOD_Yf_TILED, + &d->fb1_nv12); +igt_assert (d->fb_id1_nv12); + +/* now remove fb but keep bo to redo addfb */ +drmModeRmFB (d->drm_fd, d->fb_id1_nv12); + +/* redo AddFB */ +memset (&f,0 ,sizeof (f)); + + f.width = d->fb1_nv12.width; + f.height = d->fb1_nv12.height; + f.pixel_format = d->fb1_nv12.drm_format; + f.flags =LOCAL_DRM_MODE_FB_MODIFIERS ;
tests/kms_nv12.c line 618
Quoted 10 lines
tests/kms_nv12.c new file +10
-0+ f.handles[0 ] = d->fb1_nv12.gem_handle; + f.pitches[0 ] = d->fb1_nv12.stride; + f.modifier[0 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + f.modifier[1 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + +/* test invalid uv start */ + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride; + f.offsets[1 ] =0 ;/* invalid uv start */ +igt_assert (drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f) !=0 );
For such simple invalid input paramaters tests the usual approach is to split them out. Also you don't have to do a modeset for addfb (which will speed things up). Essentially each block with an igt_assert should be its own subtest.
-Daniel
Quoted 148 lines
tests/kms_nv12.c new file +141
-0+ +/* test uv pitch != y pitch */ + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride +1 ;/* invalid pitch */ + f.offsets[1 ] = d->fb1_nv12.uv_offset; +igt_assert (drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f) !=0 ); + +/* test uv gem handle != y gem handle */ + f.handles[1 ] =0xFFFFFFFF ;/* invalid gem handle */ + f.pitches[1 ] = d->fb1_nv12.stride; + f.offsets[1 ] = d->fb1_nv12.uv_offset; +igt_assert (drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f) !=0 ); + +/* test uv offset not aligned to new tile-row */ + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride; + f.offsets[1 ] = d->fb1_nv12.uv_offset +0xFF ;/* not tile-row aligned */ +igt_assert (drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f) !=0 ); + +/* valid params */ + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride; + f.offsets[1 ] = d->fb1_nv12.uv_offset; +igt_assert (drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f) ==0 ); + +/* Free fb */ +igt_remove_fb (d->drm_fd, &d->fb1_nv12); + d->fb_id1_nv12 =0 ; + +/* recreate bo and addfb in tile-Y, this should pass */ + d->fb_id1_nv12 =igt_create_fb (d->drm_fd, +1920 ,1080 , +DRM_FORMAT_NV12 , +LOCAL_I915_FORMAT_MOD_Y_TILED , + &d->fb1_nv12); +igt_assert (d->fb_id1_nv12); + +/* now remove fb but keep bo to redo addfb */ +drmModeRmFB (d->drm_fd, d->fb_id1_nv12); + +/* redo AddFB */ +memset (&f,0 ,sizeof (f)); + + f.width = d->fb1_nv12.width; + f.height = d->fb1_nv12.height; + f.pixel_format = d->fb1_nv12.drm_format; + f.flags =LOCAL_DRM_MODE_FB_MODIFIERS ; + f.handles[0 ] = d->fb1_nv12.gem_handle; + f.pitches[0 ] = d->fb1_nv12.stride; + f.modifier[0 ] =LOCAL_I915_FORMAT_MOD_Y_TILED ; + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride; + f.modifier[1 ] =LOCAL_I915_FORMAT_MOD_Y_TILED ; + +/* test uv offset not 4-line aligned */ + f.offsets[1 ] = d->fb1_nv12.uv_offset + f.pitches[1 ];/* not 4-ln align*/ +igt_assert (drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f) !=0 ); + +/* valid params */ + f.offsets[1 ] = d->fb1_nv12.uv_offset; +igt_assert (drmIoctl (fd,LOCAL_DRM_IOCTL_MODE_ADDFB2 , &f) ==0 ); + + valid_tests++; + +cleanup_crtc (d, output, d->plane1); + } +igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); +} + +igt_main +{ +data_t data = {}; +igt_skip_on_simulation (); + + igt_fixture { + data.drm_fd =drm_open_any (); + +kmstest_set_vt_graphics_mode (); + +igt_display_init (&data.display, data.drm_fd); + + devid =intel_get_drm_devid (data.drm_fd); + data.num_scalers =intel_gen (devid) >=9 ?2 :0 ; + data.num_planes =2 ; +igt_assert (intel_gen (devid) >=9 ); + } + + data.rotation =IGT_ROTATION_0 ; + igt_subtest_f("nv12-plane-linear") { + data.tiled =LOCAL_DRM_FORMAT_MOD_NONE ; +test_nv12_plane (&data); + } + igt_subtest_f("nv12-plane-tile-x") { + data.tiled =LOCAL_I915_FORMAT_MOD_X_TILED ; +test_nv12_plane (&data); + } + igt_subtest_f("nv12-plane-tile-y") { + data.tiled =LOCAL_I915_FORMAT_MOD_Y_TILED ; +test_nv12_plane (&data); + } + + data.rotation =IGT_ROTATION_180 ; + igt_subtest_f("nv12-plane-linear-rot-180") { + data.tiled =LOCAL_DRM_FORMAT_MOD_NONE ; +test_nv12_plane (&data); + } + igt_subtest_f("nv12-plane-tile-x-rot-180") { + data.tiled =LOCAL_I915_FORMAT_MOD_X_TILED ; +test_nv12_plane (&data); + } + igt_subtest_f("nv12-plane-tile-y-rot-180") { + data.tiled =LOCAL_I915_FORMAT_MOD_Y_TILED ; +test_nv12_plane (&data); + } + + data.rotation =IGT_ROTATION_90 ; + igt_subtest_f("nv12-plane-tile-y-rot-90") { + data.tiled =LOCAL_I915_FORMAT_MOD_Y_TILED ; +test_nv12_plane_rotation_90_or_270 (&data); + } + + data.rotation =IGT_ROTATION_270 ; + igt_subtest_f("nv12-plane-tile-y-rot-270") { + data.tiled =LOCAL_I915_FORMAT_MOD_Y_TILED ; +test_nv12_plane_rotation_90_or_270 (&data); + } + + igt_subtest_f("nv12-on-unsupported-plane") { + data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED; +test_nv12_unsupported_plane (&data); + } + + igt_subtest_f("nv12-invalid-fb-params") { + data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED; +test_nv12_invalid_fb_params (&data); + } + + igt_fixture { +igt_display_fini (&data.display); + } +}Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
Quoted 58 lines
Quoted 12 lines
tests/kms_nv12.c new file +12
-0+static void test_nv12_invalid_fb_params (data_t *d) +{ +igt_display_t *display = &d->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (d->display.has_universal_planes); +igt_require (d->num_scalers); + +for_each_connected_output (display, output) { +struct local_drm_mode_fb_cmd2 f;tests/kms_nv12.c
Quoted 10 lines
tests/kms_nv12.c new file +10
-0+int fd = d->drm_fd; +drmModeModeInfo *mode; + + mode =igt_output_get_mode (output); + pipe = output->config.pipe; + +igt_output_set_pipe (output, pipe); + +/* Set up display with plane 1 */ + d->plane1 = igt_output_get_plane(output,
IGT_PLANE_PRIMARY);Review
Quoted 2 lines
(quoted diff) +2
-0+ igt_plane_set_rotation(d->plane1, IGT_ROTATION_0); + prepare_crtc(d, output, pipe, d->plane1, mode,
COMMIT_LEGACY);Review
Quoted 2 lines
(quoted diff) +2
-0+ + /* use igt helper to create bo and addfb tile-Yf, this should pass*/
Quoted 17 lines
tests/kms_nv12.c new file +17
-0+ d->fb_id1_nv12 =igt_create_fb (d->drm_fd, +1920 ,1080 , +DRM_FORMAT_NV12 , + LOCAL_I915_FORMAT_MOD_Yf_TILED, + &d->fb1_nv12); +igt_assert (d->fb_id1_nv12); + +/* now remove fb but keep bo to redo addfb */ +drmModeRmFB (d->drm_fd, d->fb_id1_nv12); + +/* redo AddFB */ +memset (&f,0 ,sizeof (f)); + + f.width = d->fb1_nv12.width; + f.height = d->fb1_nv12.height; + f.pixel_format = d->fb1_nv12.drm_format; + f.flags =LOCAL_DRM_MODE_FB_MODIFIERS ;tests/kms_nv12.c
Quoted 10 lines
tests/kms_nv12.c new file +10
-0+ f.handles[0 ] = d->fb1_nv12.gem_handle; + f.pitches[0 ] = d->fb1_nv12.stride; + f.modifier[0 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + f.modifier[1 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + +/* test invalid uv start */ + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride; + f.offsets[1 ] =0 ;/* invalid uv start */ + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2,&f) != 0);
Quoted 6 lines
For such simple invalid input paramaters tests the usual approach is to split them out. Also you don't have to do a modeset for addfb (which will speed things up). Essentially each block with an
igt_assertshould be its own subtest.
-Daniel
If each block is split into it's own subtest, if one runs just a subtest and without a modeset, I don't know in which state the system is to start the test and doing a modeset will start with a known state.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
Quoted 65 lines · Chandra
Quoted 58 lines
Quoted 12 lines
tests/kms_nv12.c new file +12
-0+static void test_nv12_invalid_fb_params (data_t *d) +{ +igt_display_t *display = &d->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (d->display.has_universal_planes); +igt_require (d->num_scalers); + +for_each_connected_output (display, output) { +struct local_drm_mode_fb_cmd2 f;tests/kms_nv12.c
Quoted 10 lines
tests/kms_nv12.c new file +10
-0+int fd = d->drm_fd; +drmModeModeInfo *mode; + + mode =igt_output_get_mode (output); + pipe = output->config.pipe; + +igt_output_set_pipe (output, pipe); + +/* Set up display with plane 1 */ + d->plane1 = igt_output_get_plane(output,
IGT_PLANE_PRIMARY);Review
Quoted 2 lines
(quoted diff) +2
-0+ igt_plane_set_rotation(d->plane1, IGT_ROTATION_0); + prepare_crtc(d, output, pipe, d->plane1, mode,
COMMIT_LEGACY);Review
Quoted 2 lines
(quoted diff) +2
-0+ + /* use igt helper to create bo and addfb tile-Yf, this should pass*/
Quoted 17 lines
tests/kms_nv12.c new file +17
-0+ d->fb_id1_nv12 =igt_create_fb (d->drm_fd, +1920 ,1080 , +DRM_FORMAT_NV12 , + LOCAL_I915_FORMAT_MOD_Yf_TILED, + &d->fb1_nv12); +igt_assert (d->fb_id1_nv12); + +/* now remove fb but keep bo to redo addfb */ +drmModeRmFB (d->drm_fd, d->fb_id1_nv12); + +/* redo AddFB */ +memset (&f,0 ,sizeof (f)); + + f.width = d->fb1_nv12.width; + f.height = d->fb1_nv12.height; + f.pixel_format = d->fb1_nv12.drm_format; + f.flags =LOCAL_DRM_MODE_FB_MODIFIERS ;tests/kms_nv12.c
Quoted 10 lines
tests/kms_nv12.c new file +10
-0+ f.handles[0 ] = d->fb1_nv12.gem_handle; + f.pitches[0 ] = d->fb1_nv12.stride; + f.modifier[0 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + f.modifier[1 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + +/* test invalid uv start */ + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride; + f.offsets[1 ] =0 ;/* invalid uv start */ + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2,&f) != 0);
Quoted 6 lines
For such simple invalid input paramaters tests the usual approach is to split them out. Also you don't have to do a modeset for addfb (which will speed things up). Essentially each block with an
igt_assertshould be its own subtest.
-Daniel
Quoted 3 lines
If each block is split into it's own subtest, if one runs just a subtest and without a modeset, I don't know in which state the system is to start the test and doing a modeset will start with a known state.
ADDFB ioctl doesn't need any known modeset state at all, and that seems to be the only ioctl you do. Which means you really don't need to do a modeset (it's just overhead). See e.g. the other addfb testcases we have in kms_addfb_basic.c.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] Adding kms_nv12 to test display NV12 feature
Quoted 31 lines
Quoted 27 lines
Quoted 20 lines
Quoted 8 lines
tests/kms_nv12.c new file +8
-0+ +/* redo AddFB */ +memset (&f,0 ,sizeof (f)); + + f.width = d->fb1_nv12.width; + f.height = d->fb1_nv12.height; + f.pixel_format = d->fb1_nv12.drm_format; + f.flags =LOCAL_DRM_MODE_FB_MODIFIERS ;tests/kms_nv12.c
Quoted 10 lines
tests/kms_nv12.c new file +10
-0+ f.handles[0 ] = d->fb1_nv12.gem_handle; + f.pitches[0 ] = d->fb1_nv12.stride; + f.modifier[0 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + f.modifier[1 ] = LOCAL_I915_FORMAT_MOD_Yf_TILED; + +/* test invalid uv start */ + f.handles[1 ] = d->fb1_nv12.gem_handle; + f.pitches[1 ] = d->fb1_nv12.stride; + f.offsets[1 ] =0 ;/* invalid uv start */ + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2,&f) != 0);
Quoted 6 lines
For such simple invalid input paramaters tests the usual approach is to split them out. Also you don't have to do a modeset for addfb (which will speed things up). Essentially each block with an
igt_assertshould be its own subtest.
-DanielQuoted 3 lines
If each block is split into it's own subtest, if one runs just a subtest and without a modeset, I don't know in which state the system is to start the test and doing a modeset will start with a known state.
Quoted 5 lines
ADDFB ioctl doesn't need any known modeset state at all, and that seems to be the only ioctl you do. Which means you really don't need to do a modeset (it's just overhead). See e.g. the other addfb testcases we have in
kms_addfb_basic.c.
-Daniel
I see your point. will check on that and make any necessary updates.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 Adding kms_nv12 to test display NV12 feature
In reply to Chandra KonduruFrom: chandra konduru <[email protected]>
This patch adds kms_nv12 test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling.
v2:
-Added 90/270 tests (me)
-took out crc test as it isn't adding much value due to chroma upsampling (me)
v3:
-Make --list-subtests option work (Tvrtko)
-Make nv12 unsupported test run properly either as a sub test
or along with all other tests (me)
-Added nv12 fb with invalid params (Daniel)
v4:
-Avoid modeset for invalid tests (Daniel)
--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 753 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 755 insertions(+) create mode 100644 tests/kms_nv12.c
tests/.gitignore +1 -0
@@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residency
tests/Makefile.sources +1 -0
@@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \
tests/kms_nv12.c new file +753 -0
753 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 Adding kms_nv12 to test display NV12 feature
In reply to Chandra KonduruFrom: chandra konduru <[email protected]>
This patch adds kms_nv12 test case. It covers testing NV12 in linear/tile-X/tile-Y tiling formats in 0/90/180/270 orientations. For each tiling format, it tests several combinations of planes and its scaling.
v2:
-Added 90/270 tests (me)
-took out crc test as it isn't adding much value due to chroma upsampling (me)
v3:
-Make --list-subtests option work (Tvrtko)
-Make nv12 unsupported test run properly either as a sub test
or along with all other tests (me)
-Added nv12 fb with invalid params (Daniel)
v4:
-Avoid modeset for invalid tests (Daniel)
v5:
-Added negative nv12 addfb tests for modifier and stride alignment (me)
--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_nv12.c | 761 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 763 insertions(+) create mode 100644 tests/kms_nv12.c
tests/.gitignore +1 -0
@@ -155,6 +155,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_nv12 pm_backlight pm_lpsp pm_rc6_residency
tests/Makefile.sources +1 -0
@@ -85,6 +85,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_nv12 \ pm_backlight \ pm_lpsp \ pm_rpm \
tests/kms_nv12.c new file +761 -0
761 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx