lib/igt_fb: Add support for the NV12 format.
cover lib/igt_fb: Add support for the NV12 format.
This patch series will allow us to create framebuffers with NV12 support. Tests don't have to handle NV12 differently, and can draw to it the same way as any other format.
I've validated this against kms_plane.pixel-format-pipe-*-planes and kms_plane_scaling, which will automatically use NV12 if available because it filters usable formats through igt_get_all_cairo_formats().
Maarten Lankhorst (8):
lib/igt_fb: Add igt_put_cairo_ctx as counter to igt_get_cairo_ctx lib/igt_fb: Pass format to igt_calc_fb_size
lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb lib/intel_batchbuffer: Add delta argument to
igt_blitter_fast_copy__raw
lib/intel_batchbuffer: Add src/dst delta arguments to
igt_blitter_fast_copy too
lib/fb: Add support for creating planar framebuffers tests/kms_render: Copy all planes when copying fb lib/igt_fb: Add support for NV12 format through conversion
lib/igt_fb.c | 629 ++++++++++++++++++++++++++++++-------- lib/igt_fb.h | 13 +- lib/intel_batchbuffer.c | 41 ++- lib/intel_batchbuffer.h | 16 +- lib/ioctl_wrappers.c | 11 +- lib/ioctl_wrappers.h | 2 +- tests/gem_concurrent_all.c | 4 +- tests/gem_read_read_speed.c | 4 +- tests/kms_chv_cursor_fail.c | 3 +- tests/kms_color.c | 4 +- tests/kms_concurrent.c | 3 +- tests/kms_crtc_background_color.c | 2 +- tests/kms_cursor_crc.c | 23 +- tests/kms_draw_crc.c | 2 +- tests/kms_flip.c | 3 +- tests/kms_frontbuffer_tracking.c | 4 +- tests/kms_mmap_write_crc.c | 4 +- tests/kms_plane.c | 9 +- tests/kms_plane_multiple.c | 3 +- tests/kms_plane_scaling.c | 3 +- tests/kms_psr_sink_crc.c | 2 +- tests/kms_render.c | 17 +- tests/kms_rotation_crc.c | 7 +- tests/kms_setmode.c | 2 +- tests/prime_vgem.c | 2 +- tests/testdisplay.c | 8 +- 26 files changed, 617 insertions(+), 204 deletions(-)
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/8 lib/igt_fb: Add igt_put_cairo_ctx as counter to igt_get_cairo_ctx
This will allow support for NV12 in the future, where igt_get_cairo_ctx will return a RGB image to draw with, which will be converted in igt_put_cairo_ctx so tests don't have to add special support for NV12.
This is the same as cairo_destroy + checking for errors, but not all tests use this correctly so it's better to have a single handler for it.
--- lib/igt_fb.c | 34 ++++++++++++++++++++++++---------- lib/igt_fb.h | 1 + tests/kms_chv_cursor_fail.c | 3 +-- tests/kms_color.c | 4 ++-- tests/kms_concurrent.c | 3 +-- tests/kms_crtc_background_color.c | 2 +- tests/kms_cursor_crc.c | 23 +++++++++++++++++++---- tests/kms_flip.c | 3 +-- tests/kms_mmap_write_crc.c | 4 ++-- tests/kms_plane.c | 9 +++------ tests/kms_plane_multiple.c | 3 +-- tests/kms_plane_scaling.c | 3 +-- tests/kms_psr_sink_crc.c | 2 +- tests/kms_render.c | 2 +- tests/kms_rotation_crc.c | 2 +- tests/kms_setmode.c | 2 +- tests/testdisplay.c | 8 ++------ 17 files changed, 63 insertions(+), 45 deletions(-)
lib/igt_fb.c +24 -10
@@ -771,8 +771,7 @@ unsigned int igt_create_color_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_color (cr,0 ,0 , width, height, r, g, b); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }
@@ -809,8 +808,7 @@ unsigned int igt_create_pattern_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_test_pattern (cr, width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }
@@ -853,8 +851,7 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_color (cr,0 ,0 , width, height, r, g, b);igt_paint_test_pattern (cr, width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }
@@ -897,8 +894,7 @@ unsigned int igt_create_image_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_image (cr, filename,0 ,0 , width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }
@@ -998,7 +994,7 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, layout.right.x, layout.right.y, layout.right.width, layout.right.height); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, &fb, cr);return fb_id; }
@@ -1206,7 +1202,7 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)* * This initializes a cairo surface for @fb and then allocates a drawing context * for it. The return cairo drawing context should be released by calling -* cairo_destroy(). This also sets a default font for drawing text on +* igt_put_cairo_ctx(). This also sets a default font for drawing text on * framebuffers. * * Returns:
@@ -1229,6 +1225,24 @@ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb)return cr; } +/** +* igt_put_cairo_ctx: +* @fd: open i915 drm file descriptor +* @fb: pointer to an #igt_fb structure +* @cr: the cairo context returned by igt_get_cairo_ctx. +* +* This releases the cairo surface @cr returned by igt_get_cairo_ctx() +* for @fb, and writes the changes out to the framebuffer if cairo doesn't +* have native support for the format. +*/ +void igt_put_cairo_ctx (int fd,struct igt_fb *fb,cairo_t *cr) +{ +cairo_status_t ret =cairo_status (cr); +igt_assert_f (ret ==CAIRO_STATUS_SUCCESS ,"Cairo failed to draw with %s\n" ,cairo_status_to_string (ret)); + +cairo_destroy (cr); +} +/** * igt_remove_fb: * @fd: open i915 drm file descriptor
lib/igt_fb.h +1 -0
@@ -131,6 +131,7 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling);cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb);cairo_surface_t *igt_cairo_image_surface_create_from_png (const char *filename);cairo_t *igt_get_cairo_ctx (int fd,struct igt_fb *fb); +void igt_put_cairo_ctx (int fd,struct igt_fb *fb,cairo_t *cr);void igt_paint_color (cairo_t *cr,int x,int y,int w,int h,double r,double g,double b); void igt_paint_color_alpha(cairo_t *cr, int x, int y, int w, int h,
tests/kms_chv_cursor_fail.c +1 -2
@@ -87,8 +87,7 @@ static void create_cursor_fb(data_t *data, int cur_w, int cur_h)else igt_paint_color_alpha (cr,0 ,0 , data->fb.width, data->fb.height,0.0 ,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr); }static void cursor_move (data_t *data,int x,int y,int i)
tests/kms_color.c +2 -2
@@ -86,7 +86,7 @@ static void paint_gradient_rectangles(data_t *data, colors[i].b); } -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); } static void paint_rectangles(data_t *data,
@@ -103,7 +103,7 @@ static void paint_rectangles(data_t *data, colors[i].r, colors[i].g, colors[i].b); } -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }static double *generate_table (uint32_t lut_size,double exp)
tests/kms_concurrent.c +1 -2
@@ -148,8 +148,7 @@ create_fb_for_mode_position(data_t *data, drmModeModeInfo *mode, rect_w[i], rect_h[i], 0.0, 0.0, 0.0); } -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb[primary->index], cr); } static void
tests/kms_crtc_background_color.c +1 -1
@@ -69,7 +69,7 @@ paint_background(data_t *data, struct igt_fb *fb, drmModeModeInfo *mode, b = (double ) ((background &0xFF0000 ) >>16 ) /255.0 ;igt_paint_color_alpha (cr,0 ,0 , w, h, r, g, b, alpha); -cairo_destroy (cr); +igt_put_cairo_ctx (data->gfx_fd, &data->fb, cr); } static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
tests/kms_cursor_crc.c +19 -4
@@ -141,13 +141,16 @@ static void do_single_test(data_t *data, int x, int y)igt_pipe_crc_t *pipe_crc = data->pipe_crc;igt_crc_t crc, ref_crc;igt_plane_t *cursor; -cairo_t *cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb); +cairo_t *cr;int ret =0 ;igt_print_activity ();/* Hardware test */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_test_pattern (cr, data->screenw, data->screenh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +cursor_enable (data); cursor =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_CURSOR );igt_plane_set_position (cursor, x, y);
@@ -190,7 +193,9 @@ static void do_single_test(data_t *data, int x, int y)igt_display_commit (display);/* Now render the same in software and collect crc */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);draw_cursor (cr, x, y, data->curw, data->curh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr);igt_display_commit (display);igt_wait_for_vblank (data->drm_fd, data->pipe);
@@ -198,20 +203,25 @@ static void do_single_test(data_t *data, int x, int y)igt_assert_crc_equal (&crc, &ref_crc);/* Clear screen afterwards */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color (cr,0 ,0 , data->screenw, data->screenh,0.0 ,0.0 ,0.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); }static void do_fail_test (data_t *data,int x,int y,int expect) {igt_display_t *display = &data->display;igt_plane_t *cursor; -cairo_t *cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb); +cairo_t *cr;int ret;igt_print_activity ();/* Hardware test */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_test_pattern (cr, data->screenw, data->screenh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +cursor_enable (data); cursor =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_CURSOR );igt_plane_set_position (cursor, x, y);
@@ -446,7 +456,7 @@ static void create_cursor_fb(data_t *data, int cur_w, int cur_h) cr =igt_get_cairo_ctx (data->drm_fd, &data->fb);draw_cursor (cr,0 ,0 , cur_w, cur_h); -igt_assert (cairo_status (cr) ==0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr); }static bool has_nonsquare_cursors (uint32_t devid)
@@ -486,6 +496,7 @@ static void test_cursor_size(data_t *data)/* Use a solid white rectangle as the cursor */ cr =igt_get_cairo_ctx (data->drm_fd, &data->fb);igt_paint_color_alpha (cr,0 ,0 , cursor_max_size, cursor_max_size,1.0 ,1.0 ,1.0 ,1.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr);/* Hardware test loop */ cursor_enable (data);
@@ -501,16 +512,20 @@ static void test_cursor_size(data_t *data) }cursor_disable (data);/* Software test loop */ - cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);for (i =0 , size = cursor_max_size; size >=64 ; size /=2 , i++) {/* Now render the same in software and collect crc */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color_alpha (cr,0 ,0 , size, size,1.0 ,1.0 ,1.0 ,1.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +igt_display_commit (display);igt_wait_for_vblank (data->drm_fd, data->pipe);igt_pipe_crc_collect_crc (pipe_crc, &ref_crc);/* Clear screen afterwards */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color (cr,0 ,0 , data->screenw, data->screenh,0.0 ,0.0 ,0.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr);igt_assert_crc_equal (&crc[i], &ref_crc); } }
tests/kms_flip.c +1 -2
@@ -976,8 +976,7 @@ static void paint_flip_mode(struct igt_fb *fb, bool odd_frame)cairo_set_source_rgb (cr,1 ,1 ,1 );cairo_fill (cr); -igt_assert (!cairo_status (cr)); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr); } static int
tests/kms_mmap_write_crc.c +2 -2
@@ -92,7 +92,7 @@ static void test(data_t *data) cr =igt_get_cairo_ctx (data->drm_fd, fb);igt_paint_test_pattern (cr, fb->width, fb->height); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr);/* flip to it to make it UC/WC and fully flushed */ igt_plane_set_fb (data->primary, fb);
@@ -135,7 +135,7 @@ static void test(data_t *data)* fully flushed */ cr =igt_get_cairo_ctx (data->drm_fd, fb);igt_paint_test_pattern (cr, fb->width, fb->height); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr);igt_plane_set_fb (data->primary, fb);igt_display_commit (display);
tests/kms_plane.c +3 -6
@@ -138,8 +138,7 @@ create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,igt_paint_color (cr,0 ,0 , mode->hdisplay, mode->vdisplay,0.0 ,1.0 ,0.0 );igt_paint_color (cr, rect_x, rect_y, rect_w, rect_h,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }enum {
@@ -279,8 +278,7 @@ create_fb_for_mode__panning(data_t *data, drmModeModeInfo *mode, mode->hdisplay, mode->vdisplay, 0.0, 0.0, 1.0); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }enum {
@@ -436,8 +434,7 @@ static void test_format_plane(data_t *data, enum pipe pipe, 0.0, 1.0, 0.0);if (width >=164 && height >=164 )igt_paint_color (cr,100 ,100 ,64 ,64 ,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &fb, cr);igt_plane_set_fb (plane, &fb);igt_display_commit2 (&data->display,COMMIT_UNIVERSAL );
tests/kms_plane_multiple.c +1 -2
@@ -173,8 +173,7 @@ create_fb_for_mode_position(data_t *data, igt_output_t *output, drmModeModeInfo rect_w[i], rect_h[i], 0.0, 0.0, 0.0); } -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb[primary->index], cr); }
tests/kms_plane_scaling.c +1 -2
@@ -120,8 +120,7 @@ static void paint_fb(data_t *d, struct igt_fb *fb) cr =igt_get_cairo_ctx (d->drm_fd, fb);igt_paint_color (cr,0 ,0 , fb->width, fb->height,0.0 ,1.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (d->drm_fd, fb, cr); } static void check_scaling_pipe_plane_rot(data_t *d, igt_plane_t *plane,
tests/kms_psr_sink_crc.c +1 -1
@@ -91,7 +91,7 @@ static void create_cursor_fb(data_t *data) cr =igt_get_cairo_ctx (data->drm_fd, &data->fb_white);igt_paint_color_alpha (cr,0 ,0 ,64 ,64 ,1.0 ,1.0 ,1.0 ,1.0 ); -igt_assert (cairo_status (cr) ==0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb_white, cr); }
tests/kms_render.c +1 -1
@@ -55,7 +55,7 @@ static int paint_fb(struct igt_fb *fb, const char *test_name,igt_cairo_printf_line (cr, align_hcenter,10 ,"%s" , mode_format_str);igt_cairo_printf_line (cr, align_hcenter,10 ,"%s" , cconf_str); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr);return 0 ; }
tests/kms_rotation_crc.c +1 -1
@@ -120,7 +120,7 @@ paint_squares(data_t *data, igt_rotation_t rotation,igt_paint_color (cr,0 , h /2 , w /2 , h /2 ,RGB_COLOR (bl));igt_paint_color (cr, w /2 , h /2 , w /2 , h /2 ,RGB_COLOR (br)); -cairo_destroy (cr); +igt_put_cairo_ctx (data->gfx_fd, fb, cr); } static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
tests/kms_setmode.c +1 -1
@@ -161,7 +161,7 @@ static int paint_fb(struct igt_fb *fb, const char *test_name, crtc_str[i]); } -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr);return 0 ; }
tests/testdisplay.c +2 -6
@@ -227,9 +227,7 @@ paint_color_key(struct igt_fb *fb_info)cairo_set_source_rgb (cr,.8 ,.8 ,.8 );cairo_fill (cr); -igt_assert (!cairo_status (cr)); - -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb_info, cr); }static void paint_image (cairo_t *cr,const char *file)
@@ -294,9 +292,7 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)if (qr_code)paint_image (cr,"pass.png" ); -igt_assert (!cairo_status (cr)); - -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr); }static void sighandler (int signo)
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/8] lib/igt_fb: Add igt_put_cairo_ctx as counter to igt_get_cairo_ctx
Quoted 3 lines · Maarten Lankhorst
This will allow support for NV12 in the future, where
igt_get_cairo_ctxwill return a RGB image to draw with, which will be converted inigt_put_cairo_ctxso tests don't have to add special support for NV12.
Why do we need a special funciton? As in, can't you just do it the same as we handle the gtt vs. blit stuff?
Quoted 468 lines
This is the same as
cairo_destroy+ checking for errors, but not all tests use this correctly so it's better to have a single handler for it.Signed-off-by Maarten Lankhorst <[email protected]>--- lib/igt_fb.c | 34 ++++++++++++++++++++++++---------- lib/igt_fb.h | 1 + tests/kms_chv_cursor_fail.c | 3 +-- tests/kms_color.c | 4 ++-- tests/kms_concurrent.c | 3 +-- tests/kms_crtc_background_color.c | 2 +- tests/kms_cursor_crc.c | 23 +++++++++++++++++++---- tests/kms_flip.c | 3 +-- tests/kms_mmap_write_crc.c | 4 ++-- tests/kms_plane.c | 9 +++------ tests/kms_plane_multiple.c | 3 +-- tests/kms_plane_scaling.c | 3 +-- tests/kms_psr_sink_crc.c | 2 +- tests/kms_render.c | 2 +- tests/kms_rotation_crc.c | 2 +- tests/kms_setmode.c | 2 +- tests/testdisplay.c | 8 ++------ 17 files changed, 63 insertions(+), 45 deletions(-)lib/igt_fb.c +24
-10@@ -771,8 +771,7 @@ unsigned int igt_create_color_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_color (cr,0 ,0 , width, height, r, g, b); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -809,8 +808,7 @@ unsigned int igt_create_pattern_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_test_pattern (cr, width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -853,8 +851,7 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_color (cr,0 ,0 , width, height, r, g, b);igt_paint_test_pattern (cr, width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -897,8 +894,7 @@ unsigned int igt_create_image_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_image (cr, filename,0 ,0 , width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -998,7 +994,7 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, layout.right.x, layout.right.y, layout.right.width, layout.right.height); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, &fb, cr);return fb_id; }@@ -1206,7 +1202,7 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)* * This initializes a cairo surface for @fb and then allocates a drawing context * for it. The return cairo drawing context should be released by calling -* cairo_destroy(). This also sets a default font for drawing text on +* igt_put_cairo_ctx(). This also sets a default font for drawing text on * framebuffers. * * Returns: @@ -1229,6 +1225,24 @@ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb)return cr; } +/** +* igt_put_cairo_ctx: +* @fd: open i915 drm file descriptor +* @fb: pointer to an #igt_fb structure +* @cr: the cairo context returned by igt_get_cairo_ctx. +* +* This releases the cairo surface @cr returned by igt_get_cairo_ctx() +* for @fb, and writes the changes out to the framebuffer if cairo doesn't +* have native support for the format. +*/ +void igt_put_cairo_ctx (int fd,struct igt_fb *fb,cairo_t *cr) +{ +cairo_status_t ret =cairo_status (cr); +igt_assert_f (ret ==CAIRO_STATUS_SUCCESS ,"Cairo failed to draw with %s\n" ,cairo_status_to_string (ret)); + +cairo_destroy (cr); +} +/** * igt_remove_fb: * @fd: open i915 drm file descriptor lib/igt_fb.h +1
-0@@ -131,6 +131,7 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling);cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb);cairo_surface_t *igt_cairo_image_surface_create_from_png (const char *filename);cairo_t *igt_get_cairo_ctx (int fd,struct igt_fb *fb); +void igt_put_cairo_ctx (int fd,struct igt_fb *fb,cairo_t *cr);void igt_paint_color (cairo_t *cr,int x,int y,int w,int h,double r,double g,double b); void igt_paint_color_alpha(cairo_t *cr, int x, int y, int w, int h,tests/kms_chv_cursor_fail.c +1
-2@@ -87,8 +87,7 @@ static void create_cursor_fb(data_t *data, int cur_w, int cur_h)else igt_paint_color_alpha (cr,0 ,0 , data->fb.width, data->fb.height,0.0 ,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr); }static void cursor_move (data_t *data,int x,int y,int i)tests/kms_color.c +2
-2@@ -86,7 +86,7 @@ static void paint_gradient_rectangles(data_t *data, colors[i].b); } -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); } static void paint_rectangles(data_t *data,@@ -103,7 +103,7 @@ static void paint_rectangles(data_t *data, colors[i].r, colors[i].g, colors[i].b); } -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }static double *generate_table (uint32_t lut_size,double exp)tests/kms_concurrent.c +1
-2@@ -148,8 +148,7 @@ create_fb_for_mode_position(data_t *data, drmModeModeInfo *mode, rect_w[i], rect_h[i], 0.0, 0.0, 0.0); } -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb[primary->index], cr); } static voidtests/kms_crtc_background_color.c +1
-1@@ -69,7 +69,7 @@ paint_background(data_t *data, struct igt_fb *fb, drmModeModeInfo *mode, b = (double ) ((background &0xFF0000 ) >>16 ) /255.0 ;igt_paint_color_alpha (cr,0 ,0 , w, h, r, g, b, alpha); -cairo_destroy (cr); +igt_put_cairo_ctx (data->gfx_fd, &data->fb, cr); } static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,tests/kms_cursor_crc.c +19
-4@@ -141,13 +141,16 @@ static void do_single_test(data_t *data, int x, int y)igt_pipe_crc_t *pipe_crc = data->pipe_crc;igt_crc_t crc, ref_crc;igt_plane_t *cursor; -cairo_t *cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb); +cairo_t *cr;int ret =0 ;igt_print_activity ();/* Hardware test */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_test_pattern (cr, data->screenw, data->screenh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +cursor_enable (data); cursor =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_CURSOR );igt_plane_set_position (cursor, x, y);@@ -190,7 +193,9 @@ static void do_single_test(data_t *data, int x, int y)igt_display_commit (display);/* Now render the same in software and collect crc */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);draw_cursor (cr, x, y, data->curw, data->curh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr);igt_display_commit (display);igt_wait_for_vblank (data->drm_fd, data->pipe);@@ -198,20 +203,25 @@ static void do_single_test(data_t *data, int x, int y)igt_assert_crc_equal (&crc, &ref_crc);/* Clear screen afterwards */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color (cr,0 ,0 , data->screenw, data->screenh,0.0 ,0.0 ,0.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); }static void do_fail_test (data_t *data,int x,int y,int expect) {igt_display_t *display = &data->display;igt_plane_t *cursor; -cairo_t *cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb); +cairo_t *cr;int ret;igt_print_activity ();/* Hardware test */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_test_pattern (cr, data->screenw, data->screenh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +cursor_enable (data); cursor =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_CURSOR );igt_plane_set_position (cursor, x, y);@@ -446,7 +456,7 @@ static void create_cursor_fb(data_t *data, int cur_w, int cur_h) cr =igt_get_cairo_ctx (data->drm_fd, &data->fb);draw_cursor (cr,0 ,0 , cur_w, cur_h); -igt_assert (cairo_status (cr) ==0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr); }static bool has_nonsquare_cursors (uint32_t devid)@@ -486,6 +496,7 @@ static void test_cursor_size(data_t *data)/* Use a solid white rectangle as the cursor */ cr =igt_get_cairo_ctx (data->drm_fd, &data->fb);igt_paint_color_alpha (cr,0 ,0 , cursor_max_size, cursor_max_size,1.0 ,1.0 ,1.0 ,1.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr);/* Hardware test loop */ cursor_enable (data);@@ -501,16 +512,20 @@ static void test_cursor_size(data_t *data) }cursor_disable (data);/* Software test loop */ - cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);for (i =0 , size = cursor_max_size; size >=64 ; size /=2 , i++) {/* Now render the same in software and collect crc */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color_alpha (cr,0 ,0 , size, size,1.0 ,1.0 ,1.0 ,1.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +igt_display_commit (display);igt_wait_for_vblank (data->drm_fd, data->pipe);igt_pipe_crc_collect_crc (pipe_crc, &ref_crc);/* Clear screen afterwards */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color (cr,0 ,0 , data->screenw, data->screenh,0.0 ,0.0 ,0.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr);igt_assert_crc_equal (&crc[i], &ref_crc); } }tests/kms_flip.c +1
-2@@ -976,8 +976,7 @@ static void paint_flip_mode(struct igt_fb *fb, bool odd_frame)cairo_set_source_rgb (cr,1 ,1 ,1 );cairo_fill (cr); -igt_assert (!cairo_status (cr)); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr); } static inttests/kms_mmap_write_crc.c +2
-2@@ -92,7 +92,7 @@ static void test(data_t *data) cr =igt_get_cairo_ctx (data->drm_fd, fb);igt_paint_test_pattern (cr, fb->width, fb->height); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr);/* flip to it to make it UC/WC and fully flushed */ igt_plane_set_fb (data->primary, fb);@@ -135,7 +135,7 @@ static void test(data_t *data)* fully flushed */ cr =igt_get_cairo_ctx (data->drm_fd, fb);igt_paint_test_pattern (cr, fb->width, fb->height); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr);igt_plane_set_fb (data->primary, fb);igt_display_commit (display);tests/kms_plane.c +3
-6@@ -138,8 +138,7 @@ create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,igt_paint_color (cr,0 ,0 , mode->hdisplay, mode->vdisplay,0.0 ,1.0 ,0.0 );igt_paint_color (cr, rect_x, rect_y, rect_w, rect_h,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }enum {@@ -279,8 +278,7 @@ create_fb_for_mode__panning(data_t *data, drmModeModeInfo *mode, mode->hdisplay, mode->vdisplay, 0.0, 0.0, 1.0); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }enum {@@ -436,8 +434,7 @@ static void test_format_plane(data_t *data, enum pipe pipe, 0.0, 1.0, 0.0);if (width >=164 && height >=164 )igt_paint_color (cr,100 ,100 ,64 ,64 ,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &fb, cr);igt_plane_set_fb (plane, &fb);igt_display_commit2 (&data->display,COMMIT_UNIVERSAL );tests/kms_plane_multiple.c +1
-2@@ -173,8 +173,7 @@ create_fb_for_mode_position(data_t *data, igt_output_t *output, drmModeModeInfo rect_w[i], rect_h[i], 0.0, 0.0, 0.0); } -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb[primary->index], cr); }tests/kms_plane_scaling.c +1
-2@@ -120,8 +120,7 @@ static void paint_fb(data_t *d, struct igt_fb *fb) cr =igt_get_cairo_ctx (d->drm_fd, fb);igt_paint_color (cr,0 ,0 , fb->width, fb->height,0.0 ,1.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (d->drm_fd, fb, cr); } static void check_scaling_pipe_plane_rot(data_t *d, igt_plane_t *plane,tests/kms_psr_sink_crc.c +1
-1@@ -91,7 +91,7 @@ static void create_cursor_fb(data_t *data) cr =igt_get_cairo_ctx (data->drm_fd, &data->fb_white);igt_paint_color_alpha (cr,0 ,0 ,64 ,64 ,1.0 ,1.0 ,1.0 ,1.0 ); -igt_assert (cairo_status (cr) ==0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb_white, cr); }tests/kms_render.c +1
-1@@ -55,7 +55,7 @@ static int paint_fb(struct igt_fb *fb, const char *test_name,igt_cairo_printf_line (cr, align_hcenter,10 ,"%s" , mode_format_str);igt_cairo_printf_line (cr, align_hcenter,10 ,"%s" , cconf_str); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr);return 0 ; }tests/kms_rotation_crc.c +1
-1@@ -120,7 +120,7 @@ paint_squares(data_t *data, igt_rotation_t rotation,igt_paint_color (cr,0 , h /2 , w /2 , h /2 ,RGB_COLOR (bl));igt_paint_color (cr, w /2 , h /2 , w /2 , h /2 ,RGB_COLOR (br)); -cairo_destroy (cr); +igt_put_cairo_ctx (data->gfx_fd, fb, cr); } static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,tests/kms_setmode.c +1
-1@@ -161,7 +161,7 @@ static int paint_fb(struct igt_fb *fb, const char *test_name, crtc_str[i]); } -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr);return 0 ; }tests/testdisplay.c +2
-6@@ -227,9 +227,7 @@ paint_color_key(struct igt_fb *fb_info)cairo_set_source_rgb (cr,.8 ,.8 ,.8 );cairo_fill (cr); -igt_assert (!cairo_status (cr)); - -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb_info, cr); }static void paint_image (cairo_t *cr,const char *file)@@ -294,9 +292,7 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)if (qr_code)paint_image (cr,"pass.png" ); -igt_assert (!cairo_status (cr)); - -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr); }static void sighandler (int signo)Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/8] lib/igt_fb: Add igt_put_cairo_ctx as counter to igt_get_cairo_ctx
Hey,
Op 23-01-18 om 16:50 schreef Ville Syrjälä:
Quoted 7 lines · Maarten Lankhorst
Quoted 3 lines
This will allow support for NV12 in the future, where
igt_get_cairo_ctxwill return a RGB image to draw with, which will be converted inigt_put_cairo_ctxso tests don't have to add special support for NV12.Why do we need a special funciton? As in, can't you just do it the same as we handle the gtt vs. blit stuff?
The cairo_destroy() call will do the actual conversion back, but with this helper we can actually check that every call to get() is followed by a put() and errors are consistently checked. Not all callers have both, so I felt it better to put it in the core..
~Maarten
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/8] lib/igt_fb: Add igt_put_cairo_ctx as counter to igt_get_cairo_ctx
Quoted 14 lines · Maarten Lankhorst
Hey,
Op 23-01-18 om 16:50 schreef Ville Syrjälä:
Quoted 11 lines · Maarten Lankhorst
Quoted 6 lines
This will allow support for NV12 in the future, where
igt_get_cairo_ctx
will return a RGB image to draw with, which will be converted inigt_put_cairo_ctxso tests don't have to add special support for NV12.Why do we need a special funciton? As in, can't you just do it the same as we handle the gtt vs. blit stuff?
Quoted 6 lines
The
cairo_destroy()call will do the actual conversion back, but with this helper we can
actually check that every call toget()is followed by aput()and errors are consistently
checked. Not all callers have both, so I felt it better to put it in the core..
From the naming convention point of view, I would use set() instead of put() as we have a get() as counterpart.
Quoted 6 lines
~Maarten
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/8] lib/igt_fb: Add igt_put_cairo_ctx as counter to igt_get_cairo_ctx
Op 25-01-18 om 12:43 schreef Mika Kahola:
Quoted 13 lines · Maarten Lankhorst
Quoted 12 lines
Hey,
Op 23-01-18 om 16:50 schreef Ville Syrjälä:
Quoted 9 lines · Maarten Lankhorst
Quoted 5 lines
This will allow support for NV12 in the future, where
igt_get_cairo_ctx
will return a RGB image to draw with, which will be converted inigt_put_cairo_ctxso tests don't have to add special support for NV12.Why do we need a special funciton? As in, can't you just do it the same as we handle the gtt vs. blit stuff?
Quoted 8 lines
Quoted 6 lines
The
cairo_destroy()call will do the actual conversion back, but with this helper we can
actually check that every call toget()is followed by aput()and errors are consistently
checked. Not all callers have both, so I felt it better to put it in the core..From the naming convention point of view, I would use
set()instead ofput()as we have aget()as counterpart.
Lot of places using get() to acquire a ref, put() to release it. So I think it makes sense..
~Maarten
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 1/8] lib/igt_fb: Add igt_put_cairo_ctx as counter to igt_get_cairo_ctx
In reply to Maarten LankhorstQuoted 100 lines · Maarten Lankhorst
This will allow support for NV12 in the future, where
igt_get_cairo_ctxwill return a RGB image to draw with, which will be converted inigt_put_cairo_ctxso tests don't have to add special support for NV12.This is the same as
cairo_destroy+ checking for errors, but not all tests use this correctly so it's better to have a single handler for it.Signed-off-by Maarten Lankhorst <[email protected]>--- lib/igt_fb.c | 34 ++++++++++++++++++++++++---------- lib/igt_fb.h | 1 + tests/kms_chv_cursor_fail.c | 3 +-- tests/kms_color.c | 4 ++-- tests/kms_concurrent.c | 3 +-- tests/kms_crtc_background_color.c | 2 +- tests/kms_cursor_crc.c | 23 +++++++++++++++++++---- tests/kms_flip.c | 3 +-- tests/kms_mmap_write_crc.c | 4 ++-- tests/kms_plane.c | 9 +++------ tests/kms_plane_multiple.c | 3 +-- tests/kms_plane_scaling.c | 3 +-- tests/kms_psr_sink_crc.c | 2 +- tests/kms_render.c | 2 +- tests/kms_rotation_crc.c | 2 +- tests/kms_setmode.c | 2 +- tests/testdisplay.c | 8 ++------ 17 files changed, 63 insertions(+), 45 deletions(-)lib/igt_fb.c +12
-10@@ -771,8 +771,7 @@ unsigned int igt_create_color_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_color (cr,0 ,0 , width, height, r, g, b); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -809,8 +808,7 @@ unsigned int igt_create_pattern_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_test_pattern (cr, width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -853,8 +851,7 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_color (cr,0 ,0 , width, height, r, g, b);igt_paint_test_pattern (cr, width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -897,8 +894,7 @@ unsigned int igt_create_image_fb(int fd, int width, int height, cr =igt_get_cairo_ctx (fd, fb);igt_paint_image (cr, filename,0 ,0 , width, height); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (fd, fb, cr);return fb_id; }@@ -998,7 +994,7 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, layout.right.x, layout.right.y, layout.right.width, layout.right.height); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, &fb, cr);return fb_id; }@@ -1206,7 +1202,7 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)* * This initializes a cairo surface for @fb and then allocates a drawing context * for it. The return cairo drawing context should be released by calling -* cairo_destroy(). This also sets a default font for drawing text on +* igt_put_cairo_ctx(). This also sets a default font for drawing text on * framebuffers. * * Returns: @@ -1229,6 +1225,24 @@ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb)return cr; } +/** +* igt_put_cairo_ctx: +* @fd: open i915 drm file descriptor +* @fb: pointer to an #igt_fb structure +* @cr: the cairo context returned by igt_get_cairo_ctx. +*
lib/igt_fb.c cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb) · line 1243
Quoted 10 lines
lib/igt_fb.c +10
-0+* This releases the cairo surface @cr returned by igt_get_cairo_ctx() +* for @fb, and writes the changes out to the framebuffer if cairo doesn't +* have native support for the format. +*/ +void igt_put_cairo_ctx (int fd,struct igt_fb *fb,cairo_t *cr) +{ +cairo_status_t ret =cairo_status (cr); +igt_assert_f (ret ==CAIRO_STATUS_SUCCESS ,"Cairo failed to draw with %s\n" ,cairo_status_to_string (ret)); + +cairo_destroy (cr);
I was looking at the whole cairo surface stuff, and it looks to me like igt_get_cairo_surface() is missing a cairo_surface_reference() for the case where already have fb->cairo_surface.
Maybe we should also add some asserts into eg. igt_plane_set_fb() to make sure there is no fb->cairo_surface around anymore, to guarantee that we've actually copied the contents from the temp surface back to the real bo?
Anyway, this patch seems fine to me so
Quoted 361 lines
lib/igt_fb.c +2
-0+} +/** * igt_remove_fb: * @fd: open i915 drm file descriptor lib/igt_fb.h +1
-0@@ -131,6 +131,7 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling);cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb);cairo_surface_t *igt_cairo_image_surface_create_from_png (const char *filename);cairo_t *igt_get_cairo_ctx (int fd,struct igt_fb *fb); +void igt_put_cairo_ctx (int fd,struct igt_fb *fb,cairo_t *cr);void igt_paint_color (cairo_t *cr,int x,int y,int w,int h,double r,double g,double b); void igt_paint_color_alpha(cairo_t *cr, int x, int y, int w, int h,tests/kms_chv_cursor_fail.c +1
-2@@ -87,8 +87,7 @@ static void create_cursor_fb(data_t *data, int cur_w, int cur_h)else igt_paint_color_alpha (cr,0 ,0 , data->fb.width, data->fb.height,0.0 ,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr); }static void cursor_move (data_t *data,int x,int y,int i)tests/kms_color.c +2
-2@@ -86,7 +86,7 @@ static void paint_gradient_rectangles(data_t *data, colors[i].b); } -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); } static void paint_rectangles(data_t *data,@@ -103,7 +103,7 @@ static void paint_rectangles(data_t *data, colors[i].r, colors[i].g, colors[i].b); } -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }static double *generate_table (uint32_t lut_size,double exp)tests/kms_concurrent.c +1
-2@@ -148,8 +148,7 @@ create_fb_for_mode_position(data_t *data, drmModeModeInfo *mode, rect_w[i], rect_h[i], 0.0, 0.0, 0.0); } -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb[primary->index], cr); } static voidtests/kms_crtc_background_color.c +1
-1@@ -69,7 +69,7 @@ paint_background(data_t *data, struct igt_fb *fb, drmModeModeInfo *mode, b = (double ) ((background &0xFF0000 ) >>16 ) /255.0 ;igt_paint_color_alpha (cr,0 ,0 , w, h, r, g, b, alpha); -cairo_destroy (cr); +igt_put_cairo_ctx (data->gfx_fd, &data->fb, cr); } static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,tests/kms_cursor_crc.c +19
-4@@ -141,13 +141,16 @@ static void do_single_test(data_t *data, int x, int y)igt_pipe_crc_t *pipe_crc = data->pipe_crc;igt_crc_t crc, ref_crc;igt_plane_t *cursor; -cairo_t *cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb); +cairo_t *cr;int ret =0 ;igt_print_activity ();/* Hardware test */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_test_pattern (cr, data->screenw, data->screenh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +cursor_enable (data); cursor =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_CURSOR );igt_plane_set_position (cursor, x, y);@@ -190,7 +193,9 @@ static void do_single_test(data_t *data, int x, int y)igt_display_commit (display);/* Now render the same in software and collect crc */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);draw_cursor (cr, x, y, data->curw, data->curh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr);igt_display_commit (display);igt_wait_for_vblank (data->drm_fd, data->pipe);@@ -198,20 +203,25 @@ static void do_single_test(data_t *data, int x, int y)igt_assert_crc_equal (&crc, &ref_crc);/* Clear screen afterwards */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color (cr,0 ,0 , data->screenw, data->screenh,0.0 ,0.0 ,0.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); }static void do_fail_test (data_t *data,int x,int y,int expect) {igt_display_t *display = &data->display;igt_plane_t *cursor; -cairo_t *cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb); +cairo_t *cr;int ret;igt_print_activity ();/* Hardware test */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_test_pattern (cr, data->screenw, data->screenh); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +cursor_enable (data); cursor =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_CURSOR );igt_plane_set_position (cursor, x, y);@@ -446,7 +456,7 @@ static void create_cursor_fb(data_t *data, int cur_w, int cur_h) cr =igt_get_cairo_ctx (data->drm_fd, &data->fb);draw_cursor (cr,0 ,0 , cur_w, cur_h); -igt_assert (cairo_status (cr) ==0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr); }static bool has_nonsquare_cursors (uint32_t devid)@@ -486,6 +496,7 @@ static void test_cursor_size(data_t *data)/* Use a solid white rectangle as the cursor */ cr =igt_get_cairo_ctx (data->drm_fd, &data->fb);igt_paint_color_alpha (cr,0 ,0 , cursor_max_size, cursor_max_size,1.0 ,1.0 ,1.0 ,1.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb, cr);/* Hardware test loop */ cursor_enable (data);@@ -501,16 +512,20 @@ static void test_cursor_size(data_t *data) }cursor_disable (data);/* Software test loop */ - cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);for (i =0 , size = cursor_max_size; size >=64 ; size /=2 , i++) {/* Now render the same in software and collect crc */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color_alpha (cr,0 ,0 , size, size,1.0 ,1.0 ,1.0 ,1.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr); +igt_display_commit (display);igt_wait_for_vblank (data->drm_fd, data->pipe);igt_pipe_crc_collect_crc (pipe_crc, &ref_crc);/* Clear screen afterwards */ + cr =igt_get_cairo_ctx (data->drm_fd, &data->primary_fb);igt_paint_color (cr,0 ,0 , data->screenw, data->screenh,0.0 ,0.0 ,0.0 ); +igt_put_cairo_ctx (data->drm_fd, &data->primary_fb, cr);igt_assert_crc_equal (&crc[i], &ref_crc); } }tests/kms_flip.c +1
-2@@ -976,8 +976,7 @@ static void paint_flip_mode(struct igt_fb *fb, bool odd_frame)cairo_set_source_rgb (cr,1 ,1 ,1 );cairo_fill (cr); -igt_assert (!cairo_status (cr)); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr); } static inttests/kms_mmap_write_crc.c +2
-2@@ -92,7 +92,7 @@ static void test(data_t *data) cr =igt_get_cairo_ctx (data->drm_fd, fb);igt_paint_test_pattern (cr, fb->width, fb->height); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr);/* flip to it to make it UC/WC and fully flushed */ igt_plane_set_fb (data->primary, fb);@@ -135,7 +135,7 @@ static void test(data_t *data)* fully flushed */ cr =igt_get_cairo_ctx (data->drm_fd, fb);igt_paint_test_pattern (cr, fb->width, fb->height); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr);igt_plane_set_fb (data->primary, fb);igt_display_commit (display);tests/kms_plane.c +3
-6@@ -138,8 +138,7 @@ create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,igt_paint_color (cr,0 ,0 , mode->hdisplay, mode->vdisplay,0.0 ,1.0 ,0.0 );igt_paint_color (cr, rect_x, rect_y, rect_w, rect_h,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }enum {@@ -279,8 +278,7 @@ create_fb_for_mode__panning(data_t *data, drmModeModeInfo *mode, mode->hdisplay, mode->vdisplay, 0.0, 0.0, 1.0); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, fb, cr); }enum {@@ -436,8 +434,7 @@ static void test_format_plane(data_t *data, enum pipe pipe, 0.0, 1.0, 0.0);if (width >=164 && height >=164 )igt_paint_color (cr,100 ,100 ,64 ,64 ,0.0 ,0.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &fb, cr);igt_plane_set_fb (plane, &fb);igt_display_commit2 (&data->display,COMMIT_UNIVERSAL );tests/kms_plane_multiple.c +1
-2@@ -173,8 +173,7 @@ create_fb_for_mode_position(data_t *data, igt_output_t *output, drmModeModeInfo rect_w[i], rect_h[i], 0.0, 0.0, 0.0); } -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (data->drm_fd, &data->fb[primary->index], cr); }tests/kms_plane_scaling.c +1
-2@@ -120,8 +120,7 @@ static void paint_fb(data_t *d, struct igt_fb *fb) cr =igt_get_cairo_ctx (d->drm_fd, fb);igt_paint_color (cr,0 ,0 , fb->width, fb->height,0.0 ,1.0 ,0.0 ); -igt_assert (cairo_status (cr) ==0 ); -cairo_destroy (cr); +igt_put_cairo_ctx (d->drm_fd, fb, cr); } static void check_scaling_pipe_plane_rot(data_t *d, igt_plane_t *plane,tests/kms_psr_sink_crc.c +1
-1@@ -91,7 +91,7 @@ static void create_cursor_fb(data_t *data) cr =igt_get_cairo_ctx (data->drm_fd, &data->fb_white);igt_paint_color_alpha (cr,0 ,0 ,64 ,64 ,1.0 ,1.0 ,1.0 ,1.0 ); -igt_assert (cairo_status (cr) ==0 ); +igt_put_cairo_ctx (data->drm_fd, &data->fb_white, cr); }tests/kms_render.c +1
-1@@ -55,7 +55,7 @@ static int paint_fb(struct igt_fb *fb, const char *test_name,igt_cairo_printf_line (cr, align_hcenter,10 ,"%s" , mode_format_str);igt_cairo_printf_line (cr, align_hcenter,10 ,"%s" , cconf_str); -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr);return 0 ; }tests/kms_rotation_crc.c +1
-1@@ -120,7 +120,7 @@ paint_squares(data_t *data, igt_rotation_t rotation,igt_paint_color (cr,0 , h /2 , w /2 , h /2 ,RGB_COLOR (bl));igt_paint_color (cr, w /2 , h /2 , w /2 , h /2 ,RGB_COLOR (br)); -cairo_destroy (cr); +igt_put_cairo_ctx (data->gfx_fd, fb, cr); } static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,tests/kms_setmode.c +1
-1@@ -161,7 +161,7 @@ static int paint_fb(struct igt_fb *fb, const char *test_name, crtc_str[i]); } -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr);return 0 ; }tests/testdisplay.c +2
-6@@ -227,9 +227,7 @@ paint_color_key(struct igt_fb *fb_info)cairo_set_source_rgb (cr,.8 ,.8 ,.8 );cairo_fill (cr); -igt_assert (!cairo_status (cr)); - -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb_info, cr); }static void paint_image (cairo_t *cr,const char *file)@@ -294,9 +292,7 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)if (qr_code)paint_image (cr,"pass.png" ); -igt_assert (!cairo_status (cr)); - -cairo_destroy (cr); +igt_put_cairo_ctx (drm_fd, fb, cr); }static void sighandler (int signo)Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 2/8 lib/igt_fb: Pass format to igt_calc_fb_size
In reply to Maarten Lankhorstbpp is only sufficient to calculate dimensions for packed formats, in case of planar formats we need to pass the drm format fourcc, which will give us better information.
This is required for supporting planar framebuffers.
--- lib/igt_fb.c | 10 ++++++---- lib/igt_fb.h | 2 +- tests/kms_frontbuffer_tracking.c | 4 +--- 3 files changed, 8 insertions(+), 8 deletions(-)
lib/igt_fb.c +6 -4
@@ -147,7 +147,7 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,* @fd: the DRM file descriptor * @width: width of the framebuffer in pixels * @height: height of the framebuffer in pixels -* @bpp: bytes per pixel of the framebuffer +* @format: drm fourcc pixel format code * @tiling: tiling layout of the framebuffer (as framebuffer modifier) * @size_ret: returned size for the framebuffer * @stride_ret: returned stride for the framebuffer
@@ -155,10 +155,11 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,* This function returns valid stride and size values for a framebuffer with the * specified parameters. */ -void igt_calc_fb_size (int fd,int width,int height,int bpp,uint64_t tiling, +void igt_calc_fb_size (int fd,int width,int height,uint32_t format,uint64_t tiling,unsigned *size_ret,unsigned *stride_ret) {unsigned int tile_width, tile_height, stride, size; +int bpp =igt_drm_format_to_bpp (format);int byte_width = width * (bpp /8 );igt_get_fb_tile_size (fd, tiling, bpp, &tile_width, &tile_height);
@@ -249,13 +250,12 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format, unsigned *size_ret, unsigned *stride_ret, bool *is_dumb) { - int bpp = igt_drm_format_to_bpp(format); int bo;if (tiling || size || stride) {unsigned calculated_size, calculated_stride; -igt_calc_fb_size (fd, width, height, bpp, tiling, +igt_calc_fb_size (fd, width, height, format, tiling, &calculated_size, &calculated_stride);if (stride ==0 ) stride = calculated_stride;
@@ -290,6 +290,8 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format,return -EINVAL ; } }else { +int bpp =igt_drm_format_to_bpp (format); +if (is_dumb) *is_dumb = true;
lib/igt_fb.h +1 -1
@@ -90,7 +90,7 @@ enum igt_text_align {void igt_get_fb_tile_size (int fd,uint64_t tiling,int fb_bpp,unsigned *width_ret,unsigned *height_ret); -void igt_calc_fb_size (int fd,int width,int height,int bpp,uint64_t tiling, +void igt_calc_fb_size (int fd,int width,int height,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,
tests/kms_frontbuffer_tracking.c +1 -3
@@ -541,7 +541,6 @@ static void create_fb(enum pixel_format pformat, int width, int height, {uint32_t format;unsigned int size, stride; -int bpp;uint64_t tiling_for_size;switch (pformat) {
@@ -576,13 +575,12 @@ 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);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, format, tiling_for_size, &size, &stride); igt_create_fb_with_bo_size(drm.fd, width, height, format, tiling, fb,
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 2/8] lib/igt_fb: Pass format to igt_calc_fb_size
Quoted 6 lines · Maarten Lankhorst
bpp is only sufficient to calculate dimensions for packed formats, in case of planar formats we need to pass the drm format fourcc, which will give us better information.
This is required for supporting planar framebuffers.
Quoted 119 lines
Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 10 ++++++----
lib/igt_fb.h | 2 +-
tests/kms_frontbuffer_tracking.c | 4 +---3 files changed, 8 insertions(+), 8 deletions(-)lib/igt_fb.c +1
-1@@ -147,7 +147,7 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, * @fd: the DRM file descriptor * @width: width of the framebuffer in pixels * @height: height of the framebuffer in pixels - * @bpp: bytes per pixel of the framebuffer + * @format: drm fourcc pixel format code * @tiling: tiling layout of the framebuffer (as framebuffer modifier)* @size_ret: returned size for the framebuffer
* @stride_ret: returned stride for the framebufferlib/igt_fb.c +0
-0@@ -155,10 +155,11 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, * This function returns valid stride and size values for aframebuffer with the
* specified parameters.
*/
-void igt_calc_fb_size(int fd, int width, int height, int bpp,uint64_ttiling,
+void igt_calc_fb_size(int fd, int width, int height,uint32_tformat,uint64_ttiling,
unsigned*size_ret, unsigned*stride_ret) {
unsigned inttile_width,tile_height, stride, size;lib/igt_fb.c +1
-0+int bpp =igt_drm_format_to_bpp (format);int
byte_width= width * (bpp / 8);
igt_get_fb_tile_size(fd, tiling, bpp, &tile_width, &tile_height);lib/igt_fb.c +0
-0@@ -249,13 +250,12 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format,unsigned
*size_ret, unsigned*stride_ret,
bool*is_dumb)
{lib/igt_fb.c +0
-1-int bpp =igt_drm_format_to_bpp (format);int bo;
if (tiling || size || stride) {
unsignedcalculated_size,calculated_stride;lib/igt_fb.c +1
-1- igt_calc_fb_size(fd, width, height, bpp, tiling, + igt_calc_fb_size(fd, width, height, format, tiling,&calculated_size,
&calculated_stride);
if (stride == 0)
stride =calculated_stride;lib/igt_fb.c +2
-0@@ -290,6 +290,8 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format, return -EINVAL; } } else { +int bpp =igt_drm_format_to_bpp (format); + if (is_dumb) *is_dumb = true;lib/igt_fb.h +0
-0@@ -90,7 +90,7 @@ enum igt_text_align {
voidigt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, unsigned *width_ret, unsigned *height_ret);
-void igt_calc_fb_size(int fd, int width, int height, int bpp,uint64_ttiling,
+void igt_calc_fb_size(int fd, int width, int height,uint32_tformat,uint64_ttiling,
unsigned*size_ret, unsigned*stride_ret); unsigned int
igt_create_fb_with_bo_size(int fd, int width, int height,tests/kms_frontbuffer_tracking.c +0
-1@@ -541,7 +541,6 @@ static void create_fb(enum pixel_format pformat, int width, int height, { uint32_t format; unsigned int size, stride; -int bpp; uint64_t tiling_for_size;
switch (pformat) {tests/kms_frontbuffer_tracking.c +0
-0@@ -576,13 +575,12 @@ static void create_fb(enum pixel_format pformat, int width, int height, * the same size regardless of tiling since we want toproperly exercise
* the Kernel's specific tiling-checking code paths without accidentally
* hitting size-checking ones first. */tests/kms_frontbuffer_tracking.c +0
-1- bpp =igt_drm_format_to_bpp (format);if (plane ==
PLANE_CUR)
tiling_for_size=LOCAL_DRM_FORMAT_MOD_NONE; else
tiling_for_size= opt.tiling;tests/kms_frontbuffer_tracking.c +0
-1- igt_calc_fb_size(drm.fd, width, height, bpp,
tiling_for_size, &size,tests/kms_frontbuffer_tracking.c +1
-0+ igt_calc_fb_size(drm.fd, width, height, format,
tiling_for_size, &size,
&stride);
igt_create_fb_with_bo_size(drm.fd, width, height, format, tiling, fb,
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 3/8 lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb
In reply to Maarten LankhorstBy adding support for planar formats to igt_calc_fb_size and create_bo_for_fb, we can calculate dimensions and create backing storage for planar framebuffers.
This is required for adding support to create planar framebuffers in the next patch.
--- lib/igt_fb.c | 168 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 123 insertions(+), 45 deletions(-)
lib/igt_fb.c +123 -45
@@ -54,14 +54,16 @@*/ /* drm fourcc/cairo format maps */ -#define DF (did, cid, _bpp, _depth) \ - { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp, _depth } +#define DF (did, cid, ...) \ + { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, __VA_ARGS__ }static struct format_desc_struct {uint32_t drm_id;cairo_format_t cairo_id;const char *name;int bpp;int depth; +int planes; +int plane_bpp[4 ]; } format_desc[] = {DF (RGB565 ,RGB16_565 ,16 ,16 ),//DF(RGB888, INVALID, 24, 24),
@@ -74,6 +76,20 @@ static struct format_desc_struct {#define for_each_format (f) \ for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++) +static struct format_desc_struct *lookup_drm_format (uint32_t drm_format) +{ +struct format_desc_struct *format; + +for_each_format (format) { +if (format->drm_id != drm_format) +continue ; + +return format; + } + +return NULL ; +} +/** * igt_get_fb_tile_size: * @fd: the DRM file descriptor
@@ -142,27 +158,68 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } -/** -* igt_calc_fb_size: -* @fd: the DRM file descriptor -* @width: width of the framebuffer in pixels -* @height: height of the framebuffer in pixels -* @format: drm fourcc pixel format code -* @tiling: tiling layout of the framebuffer (as framebuffer modifier) -* @size_ret: returned size for the framebuffer -* @stride_ret: returned stride for the framebuffer -* -* This function returns valid stride and size values for a framebuffer with the -* specified parameters. -*/ -void igt_calc_fb_size (int fd,int width,int height,uint32_t format,uint64_t tiling, -unsigned *size_ret,unsigned *stride_ret) +static unsigned planar_stride (struct format_desc_struct *format,unsigned width,int plane) +{ +unsigned cpp = format->plane_bpp[plane] /8 ; + +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 * cpp; + +return width * cpp; +} + +static unsigned planar_height (struct format_desc_struct *format,unsigned height,int plane) +{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (height +1 ) /2 ; + +return height; +} + +static void calc_fb_size_planar (int fd,int width,int height, +struct format_desc_struct *format, +uint64_t tiling,unsigned *size_ret, +unsigned *stride_ret,unsigned *offsets) +{ +int plane; +unsigned stride =0 , tile_width, tile_height; + + *size_ret =0 ; + +for (plane =0 ; plane < format->planes; plane++) { +unsigned plane_stride; + +igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); + + plane_stride =ALIGN (planar_stride (format, width, plane), tile_width); +if (stride < plane_stride) + stride = plane_stride; + } + +for (plane =0 ; plane < format->planes; plane++) { +if (offsets) + offsets[plane] = *size_ret; + +igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); + + *size_ret += stride *ALIGN (planar_height (format, height, plane), tile_height); + } + +if (offsets) +for (; plane <4 ; plane++) + offsets[plane] =0 ; + + *stride_ret = stride; +} + +static void calc_fb_size_packed (int fd,int width,int height, +struct format_desc_struct *format,uint64_t tiling, +unsigned *size_ret,unsigned *stride_ret) {unsigned int tile_width, tile_height, stride, size; -int bpp =igt_drm_format_to_bpp (format); -int byte_width = width * (bpp /8 ); +int byte_width = width * (format->bpp /8 ); -igt_get_fb_tile_size (fd, tiling, bpp, &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling, format->bpp, &tile_width, &tile_height);if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE &&intel_gen (intel_get_drm_devid (fd)) <=3 ) {
@@ -176,7 +233,7 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t t* tiled. But then that failure is expected. */ - v = width * bpp /8 ; + v = byte_width;for (stride =512 ; stride < v; stride *=2 ) ;
@@ -192,6 +249,31 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t t *size_ret = size; } +/** +* igt_calc_fb_size: +* @fd: the DRM file descriptor +* @width: width of the framebuffer in pixels +* @height: height of the framebuffer in pixels +* @format: drm fourcc pixel format code +* @tiling: tiling layout of the framebuffer (as framebuffer modifier) +* @size_ret: returned size for the framebuffer +* @stride_ret: returned stride for the framebuffer +* +* This function returns valid stride and size values for a framebuffer with the +* specified parameters. +*/ +void igt_calc_fb_size (int fd,int width,int height,uint32_t drm_format,uint64_t tiling, +unsigned *size_ret,unsigned *stride_ret) +{ +struct format_desc_struct *format =lookup_drm_format (drm_format); +igt_assert (format); + +if (format->planes >1 ) +calc_fb_size_planar (fd, width, height, format, tiling, size_ret, stride_ret,NULL ); +else +calc_fb_size_packed (fd, width, height, format, tiling, size_ret, stride_ret); +} +/** * igt_fb_mod_to_tiling: * @modifier: DRM framebuffer modifier
@@ -245,17 +327,20 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling) }/* helpers to create nice-looking framebuffers */ -static int create_bo_for_fb (int fd,int width,int height,uint32_t format, +static int create_bo_for_fb (int fd,int width,int height, +struct format_desc_struct *format,uint64_t tiling,unsigned size,unsigned stride,unsigned *size_ret,unsigned *stride_ret,bool *is_dumb) {int bo; -if (tiling || size || stride) { +igt_assert (format); + +if (tiling || size || stride || format->planes >1 ) {unsigned calculated_size, calculated_stride; -igt_calc_fb_size (fd, width, height, format, tiling, +igt_calc_fb_size (fd, width, height, format->drm_id, tiling, &calculated_size, &calculated_stride);if (stride ==0 ) stride = calculated_stride;
@@ -290,12 +375,10 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format,return -EINVAL ; } }else { -int bpp =igt_drm_format_to_bpp (format); -if (is_dumb) *is_dumb = true; -return kmstest_dumb_create (fd, width, height, bpp, stride_ret, +return kmstest_dumb_create (fd, width, height, format->bpp, stride_ret, size_ret); } }
@@ -323,8 +406,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, unsigned stride, unsigned *size_ret, unsigned *stride_ret, bool *is_dumb) { - return create_bo_for_fb(fd, width, height, format, modifier, 0, stride, -size_ret ,stride_ret ,is_dumb ); + return create_bo_for_fb(fd, width, height, lookup_drm_format(format), + modifier, 0, stride, size_ret, stride_ret, is_dumb); }/**
@@ -671,9 +754,10 @@ igt_create_fb_with_bo_size(int fd, int width, int height,igt_debug ("%s(width=%d, height=%d, format=0x%x, tiling=0x%" PRIx64", size=%d)\n" , __func__, width, height, format, tiling, bo_size); - fb->gem_handle =create_bo_for_fb (fd, width, height, format, tiling, - bo_size, bo_stride, &fb->size, - &fb->stride, &fb->is_dumb); + fb->gem_handle =create_bo_for_fb (fd, width, height, +lookup_drm_format (format), + tiling, bo_size, bo_stride, + &fb->size, &fb->stride, &fb->is_dumb);igt_assert (fb->gem_handle >0 ); igt_debug("%s(handle=%d, pitch=%d)\n",
@@ -1069,7 +1153,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)* destination, tiling it at the same time. */ blit->linear.handle = create_bo_for_fb(fd, fb->width, fb->height, - fb->drm_format, + lookup_drm_format(fb->drm_format), LOCAL_DRM_FORMAT_MOD_NONE, 0, 0, &blit->linear.size, &blit->linear.stride,
@@ -1293,14 +1377,12 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth)*/ uint32_t igt_drm_format_to_bpp (uint32_t drm_format) { -struct format_desc_struct *f; +struct format_desc_struct *f =lookup_drm_format (drm_format); -for_each_format (f) -if (f->drm_id == drm_format) -return f->bpp; - -igt_assert_f (0 ,"can't find a bpp format for %08x (%s)\n" , +igt_assert_f (f,"can't find a bpp format for %08x (%s)\n" , drm_format,igt_format_str (drm_format)); + +return f->bpp; }/**
@@ -1313,13 +1395,9 @@ uint32_t igt_drm_format_to_bpp(uint32_t drm_format)*/ const char *igt_format_str (uint32_t drm_format) { -struct format_desc_struct *f; - -for_each_format (f) -if (f->drm_id == drm_format) -return f->name; +struct format_desc_struct *f =lookup_drm_format (drm_format); -return "invalid" ; +return f ? f->name :"invalid" ; }/**
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/8] lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb
Quoted 33 lines · Maarten Lankhorst
By adding support for planar formats to
igt_calc_fb_sizeandcreate_bo_for_fb,
we can calculate dimensions and create backing storage for planar framebuffers.This is required for adding support to create planar framebuffers in the next patch.
Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 168 +++++++++++++++++++++++++++++++++++++++++++----
------------1 file changed, 123 insertions(+), 45 deletions(-)lib/igt_fb.c +0
-0@@ -54,14 +54,16 @@*/
/* drm fourcc/cairo format maps */lib/igt_fb.c +0
-2-#define DF (did, cid, _bpp, _depth) \ - { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp, _depth}
lib/igt_fb.c +2
-0+#define DF (did, cid, ...) \ + { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, __VA_ARGS__ }static struct
format_desc_struct{
uint32_tdrm_id;
cairo_format_tcairo_id;
const char *name;
int bpp;
int depth;
lib/igt_fb.c line 66
Quoted 2 lines
lib/igt_fb.c +2
-0+int planes; +int plane_bpp[4 ];
should we define a max value for this instead of hardcoded one?
Quoted 101 lines
} format_desc[] = {
DF(RGB565, RGB16_565, 16, 16),
//DF(RGB888, INVALID, 24, 24),lib/igt_fb.c +0
-0@@ -74,6 +76,20 @@ static struct format_desc_struct { #define for_each_format(f) \for (f =
format_desc; f -format_desc<ARRAY_SIZE(format_desc); f++)
+static structformat_desc_struct*lookup_drm_format(uint32_tdrm_format)lib/igt_fb.c +13
-0+{ +struct format_desc_struct *format; + +for_each_format (format) { +if (format->drm_id != drm_format) +continue ; + +return format; + } + +return NULL ; +} +/**
*igt_get_fb_tile_size:
* @fd: the DRM file descriptorlib/igt_fb.c +0
-0@@ -142,27 +158,68 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } }
-/**
- *igt_calc_fb_size:
- * @fd: the DRM file descriptor
- * @width: width of the framebuffer in pixels
- * @height: height of the framebuffer in pixels
- * @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
- * @size_ret: returned size for the framebuffer
- * @stride_ret: returned stride for the framebuffer
- *
- * This function returns valid stride and size values for a framebuffer with the
- * specified parameters.
- */
-void igt_calc_fb_size(int fd, int width, int height,uint32_tformat,uint64_ttiling,lib/igt_fb.c +1
-1- unsigned *size_ret, unsigned *stride_ret) +static unsigned planar_stride(struct format_desc_struct *format,unsigned width, int plane)
lib/igt_fb.c +10
-0+{ +unsigned cpp = format->plane_bpp[plane] /8 ; + +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 * cpp; + +return width * cpp; +} + +static unsigned planar_height(struct format_desc_struct *format,unsigned height, int plane)
lib/igt_fb.c +11
-0+{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (height +1 ) /2 ; + +return height; +} + +static void calc_fb_size_planar (int fd,int width,int height, +struct format_desc_struct *format, +uint64_t tiling,unsigned *size_ret, + unsigned *stride_ret, unsigned*offsets)
lib/igt_fb.c +10
-0+{ +int plane; +unsigned stride =0 , tile_width, tile_height; + + *size_ret =0 ; + +for (plane =0 ; plane < format->planes; plane++) { +unsigned plane_stride; + + igt_get_fb_tile_size(fd, tiling, format-Quoted 1 line
plane_bpp[plane],
&tile_width,&tile_height);lib/igt_fb.c +2
-0+ + plane_stride = ALIGN(planar_stride(format, width,plane),
tile_width);lib/igt_fb.c +9
-0+if (stride < plane_stride) + stride = plane_stride; + } + +for (plane =0 ; plane < format->planes; plane++) { +if (offsets) + offsets[plane] = *size_ret; + + igt_get_fb_tile_size(fd, tiling, format-Quoted 1 line
plane_bpp[plane],
&tile_width,&tile_height);lib/igt_fb.c +2
-0+ + *size_ret += stride * ALIGN(planar_height(format,height, plane),
tile_height);
lib/igt_fb.c void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, · line 209
Quoted 4 lines
lib/igt_fb.c +4
-0+ } + +if (offsets) +for (; plane <4 ; plane++)
We could loop through max define value here too instead of hardcoded one.
Quoted 209 lines
lib/igt_fb.c +7
-0+ offsets[plane] =0 ; + + *stride_ret = stride; +} + +static void calc_fb_size_packed(int fd, int width, int height, + struct format_desc_struct *format,
uint64_ttiling,lib/igt_fb.c +1
-0+unsigned *size_ret, unsigned
*stride_ret)
{
unsigned inttile_width,tile_height, stride, size;lib/igt_fb.c +1
-2-int bpp =igt_drm_format_to_bpp (format); -int byte_width = width * (bpp /8 ); +int byte_width = width * (format->bpp /8 );lib/igt_fb.c +0
-1- igt_get_fb_tile_size(fd, tiling, bpp, &tile_width,
&tile_height);lib/igt_fb.c +1
-0+ igt_get_fb_tile_size(fd, tiling, format->bpp, &tile_width,
&tile_height);
if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE&& intel_gen(intel_get_drm_devid(fd)) <= 3) {lib/igt_fb.c +0
-0@@ -176,7 +233,7 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tformat,uint64_tt
* tiled. But then that failure is expected. */lib/igt_fb.c +1
-1- v = width * bpp /8 ; + v = byte_width;for (stride = 512; stride < v; stride *= 2) ;
lib/igt_fb.c +0
-0@@ -192,6 +249,31 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tformat,uint64_tt
*size_ret= size;
}
+/**
+ *igt_calc_fb_size:
+ * @fd: the DRM file descriptor
+ * @width: width of the framebuffer in pixels
+ * @height: height of the framebuffer in pixels
+ * @format: drm fourcc pixel format code
+ * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @size_ret: returned size for the framebuffer
+ * @stride_ret: returned stride for the framebuffer
+ *
+ * This function returns valid stride and size values for a framebuffer with the
+ * specified parameters.
+ */
+void igt_calc_fb_size(int fd, int width, int height,uint32_tdrm_format,uint64_ttiling,lib/igt_fb.c +3
-0+ unsigned *size_ret, unsigned *stride_ret) +{ + struct format_desc_struct *format =
lookup_drm_format(drm_format);lib/igt_fb.c +4
-0+igt_assert (format); + +if (format->planes >1 ) + calc_fb_size_planar(fd, width, height, format,tiling,
size_ret,stride_ret, NULL);lib/igt_fb.c +2
-0+else + calc_fb_size_packed(fd, width, height, format,tiling,
size_ret,stride_ret);lib/igt_fb.c +2
-0+} +/**
*igt_fb_mod_to_tiling:
* @modifier: DRM framebuffer modifierlib/igt_fb.c +0
-0@@ -245,17 +327,20 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling) }
/* helpers to create nice-looking framebuffers */ -static int create_bo_for_fb(int fd, int width, int height,uint32_tformat,lib/igt_fb.c +2
-0+static int create_bo_for_fb(int fd, int width, int height, + struct format_desc_struct *format,uint64_t tiling, unsigned size, unsigned stride,
unsigned*size_ret, unsigned*stride_ret,
bool*is_dumb)
{
int bo;lib/igt_fb.c +3
-1-if (tiling || size || stride) { +igt_assert (format); + +if (tiling || size || stride || format->planes >1 ) {unsigned
calculated_size,calculated_stride;lib/igt_fb.c +1
-1- igt_calc_fb_size(fd, width, height, format, tiling, + igt_calc_fb_size(fd, width, height, format->drm_id,tiling,
&calculated_size,&calculated_stride);
if (stride == 0)
stride =calculated_stride;lib/igt_fb.c +0
-2@@ -290,12 +375,10 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format, return -EINVAL; } } else { -int bpp =igt_drm_format_to_bpp (format); - if (is_dumb) *is_dumb = true;lib/igt_fb.c +0
-1- return kmstest_dumb_create(fd, width, height, bpp,
stride_ret,lib/igt_fb.c +1
-0+ return kmstest_dumb_create(fd, width, height,
format->bpp,stride_ret,
size_ret); }
}lib/igt_fb.c +0
-0@@ -323,8 +406,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height,unsigned stride, unsigned
*size_ret,
unsigned*stride_ret, bool*is_dumb)
{lib/igt_fb.c +0
-1- return create_bo_for_fb(fd, width, height, format, modifier,0, stride,
lib/igt_fb.c +1
-1- size_ret, stride_ret, is_dumb); + return create_bo_for_fb(fd, width, height,
lookup_drm_format(format),lib/igt_fb.c +1
-0+ modifier, 0, stride, size_ret,
stride_ret,is_dumb);
}
/**lib/igt_fb.c +0
-0@@ -671,9 +754,10 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%d)\n",
__func__, width, height, format, tiling,bo_size);lib/igt_fb.c +0
-1- fb->gem_handle = create_bo_for_fb(fd, width, height, format,tiling,
lib/igt_fb.c +0
-1- bo_size, bo_stride, &fb-Quoted 1 line
size,
lib/igt_fb.c +0
-1- &fb->stride, &fb-Quoted 1 line
is_dumb);lib/igt_fb.c +3
-0+ fb->gem_handle = create_bo_for_fb(fd, width, height, + lookup_drm_format(format), + tiling, bo_size,
bo_stride,lib/igt_fb.c +1
-0+ &fb->size, &fb->stride,
&fb->is_dumb);
igt_assert(fb->gem_handle > 0);
igt_debug("%s(handle=%d, pitch=%d)\n",lib/igt_fb.c +0
-0@@ -1069,7 +1153,7 @@ static void create_cairo_surface__blit(int fd,struct igt_fb *fb) * destination, tiling it at the same time. */
blit->linear.handle= create_bo_for_fb(fd,fb->width, fb-Quoted 1 line
height,
lib/igt_fb.c +1
-1- fb->drm_format, + lookup_drm_format(fb-Quoted 1 line
drm_format),LOCAL_DRM_FORMAT_MOD_ NONE, 0,
0, &blit-Quoted 1 line
linear.size,
&blit->linear.stride,
lib/igt_fb.c +1
-1@@ -1293,14 +1377,12 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp,int depth) */ uint32_t igt_drm_format_to_bpp(uint32_t drm_format) { -struct format_desc_struct *f; +struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +1
-5-for_each_format (f) -if (f->drm_id == drm_format) -return f->bpp; - - igt_assert_f(0, "can't find a bpp format for %08x (%s)\n", + igt_assert_f(f, "can't find a bpp format for %08x (%s)\n",drm_format,
igt_format_str(drm_format));lib/igt_fb.c +2
-0+ +return f->bpp;}
/**lib/igt_fb.c +1
-5@@ -1313,13 +1395,9 @@ uint32_t igt_drm_format_to_bpp(uint32_tdrm_format) */ const char *igt_format_str(uint32_t drm_format) { -struct format_desc_struct *f; - -for_each_format (f) -if (f->drm_id == drm_format) -return f->name; +struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +1
-1-return "invalid" ; +return f ? f->name :"invalid" ;}
/**
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/8] lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb
Op 26-01-18 om 10:00 schreef Mika Kahola:
Quoted 29 lines · Maarten Lankhorst
Quoted 28 lines
By adding support for planar formats to
igt_calc_fb_sizeandcreate_bo_for_fb,
we can calculate dimensions and create backing storage for planar framebuffers.This is required for adding support to create planar framebuffers in the next patch.
Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 168 +++++++++++++++++++++++++++++++++++++++++++----
------------1 file changed, 123 insertions(+), 45 deletions(-)lib/igt_fb.c +0
-0@@ -54,14 +54,16 @@*/
/* drm fourcc/cairo format maps */lib/igt_fb.c +0
-2-#define DF (did, cid, _bpp, _depth) \ - { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp, _depth}
lib/igt_fb.c +2
-0+#define DF (did, cid, ...) \ + { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, __VA_ARGS__ }static struct
format_desc_struct{
Quoted 8 lines
lib/igt_fb.c line 66
Quoted 7 lines
uint32_tdrm_id;
cairo_format_tcairo_id;
const char *name;
int bpp;
int depth;lib/igt_fb.c +2
-0+int planes; +int plane_bpp[4 ];should we define a max value for this instead of hardcoded one?
4 planes is the maximum ever. Alpha, R, G and B.
Quoted 309 lines
Quoted 101 lines
} format_desc[] = {
DF(RGB565, RGB16_565, 16, 16),
//DF(RGB888, INVALID, 24, 24),lib/igt_fb.c +0
-0@@ -74,6 +76,20 @@ static struct format_desc_struct { #define for_each_format(f) \for (f =
format_desc; f -format_desc<ARRAY_SIZE(format_desc); f++)
+static structformat_desc_struct*lookup_drm_format(uint32_tdrm_format)lib/igt_fb.c +13
-0+{ +struct format_desc_struct *format; + +for_each_format (format) { +if (format->drm_id != drm_format) +continue ; + +return format; + } + +return NULL ; +} +/**
*igt_get_fb_tile_size:
* @fd: the DRM file descriptorlib/igt_fb.c +0
-0@@ -142,27 +158,68 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } }
-/**
- *igt_calc_fb_size:
- * @fd: the DRM file descriptor
- * @width: width of the framebuffer in pixels
- * @height: height of the framebuffer in pixels
- * @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
- * @size_ret: returned size for the framebuffer
- * @stride_ret: returned stride for the framebuffer
- *
- * This function returns valid stride and size values for a framebuffer with the
- * specified parameters.
- */
-void igt_calc_fb_size(int fd, int width, int height,uint32_tformat,uint64_ttiling,lib/igt_fb.c +1
-1- unsigned *size_ret, unsigned *stride_ret) +static unsigned planar_stride(struct format_desc_struct *format,unsigned width, int plane)
lib/igt_fb.c +10
-0+{ +unsigned cpp = format->plane_bpp[plane] /8 ; + +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 * cpp; + +return width * cpp; +} + +static unsigned planar_height(struct format_desc_struct *format,unsigned height, int plane)
lib/igt_fb.c +11
-0+{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (height +1 ) /2 ; + +return height; +} + +static void calc_fb_size_planar (int fd,int width,int height, +struct format_desc_struct *format, +uint64_t tiling,unsigned *size_ret, + unsigned *stride_ret, unsigned*offsets)
lib/igt_fb.c +10
-0+{ +int plane; +unsigned stride =0 , tile_width, tile_height; + + *size_ret =0 ; + +for (plane =0 ; plane < format->planes; plane++) { +unsigned plane_stride; + + igt_get_fb_tile_size(fd, tiling, format-Quoted 1 line
plane_bpp[plane],
&tile_width,&tile_height);lib/igt_fb.c +2
-0+ + plane_stride = ALIGN(planar_stride(format, width,plane),
tile_width);lib/igt_fb.c +9
-0+if (stride < plane_stride) + stride = plane_stride; + } + +for (plane =0 ; plane < format->planes; plane++) { +if (offsets) + offsets[plane] = *size_ret; + + igt_get_fb_tile_size(fd, tiling, format-Quoted 1 line
plane_bpp[plane],
&tile_width,&tile_height);lib/igt_fb.c +2
-0+ + *size_ret += stride * ALIGN(planar_height(format,height, plane),
tile_height);lib/igt_fb.c void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, · line 209
Quoted 4 lines
lib/igt_fb.c +4
-0+ } + +if (offsets) +for (; plane <4 ; plane++)We could loop through max define value here too instead of hardcoded one.
Quoted 201 lines
lib/igt_fb.c +7
-0+ offsets[plane] =0 ; + + *stride_ret = stride; +} + +static void calc_fb_size_packed(int fd, int width, int height, + struct format_desc_struct *format,
uint64_ttiling,lib/igt_fb.c +1
-0+unsigned *size_ret, unsigned
*stride_ret)
{
unsigned inttile_width,tile_height, stride, size;lib/igt_fb.c +1
-2-int bpp =igt_drm_format_to_bpp (format); -int byte_width = width * (bpp /8 ); +int byte_width = width * (format->bpp /8 );lib/igt_fb.c +0
-1- igt_get_fb_tile_size(fd, tiling, bpp, &tile_width,
&tile_height);lib/igt_fb.c +1
-0+ igt_get_fb_tile_size(fd, tiling, format->bpp, &tile_width,
&tile_height);
if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE&& intel_gen(intel_get_drm_devid(fd)) <= 3) {lib/igt_fb.c +0
-0@@ -176,7 +233,7 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tformat,uint64_tt
* tiled. But then that failure is expected. */lib/igt_fb.c +1
-1- v = width * bpp /8 ; + v = byte_width;for (stride = 512; stride < v; stride *= 2) ;
lib/igt_fb.c +0
-0@@ -192,6 +249,31 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tformat,uint64_tt
*size_ret= size;
}
+/**
+ *igt_calc_fb_size:
+ * @fd: the DRM file descriptor
+ * @width: width of the framebuffer in pixels
+ * @height: height of the framebuffer in pixels
+ * @format: drm fourcc pixel format code
+ * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @size_ret: returned size for the framebuffer
+ * @stride_ret: returned stride for the framebuffer
+ *
+ * This function returns valid stride and size values for a framebuffer with the
+ * specified parameters.
+ */
+void igt_calc_fb_size(int fd, int width, int height,uint32_tdrm_format,uint64_ttiling,lib/igt_fb.c +3
-0+ unsigned *size_ret, unsigned *stride_ret) +{ + struct format_desc_struct *format =
lookup_drm_format(drm_format);lib/igt_fb.c +4
-0+igt_assert (format); + +if (format->planes >1 ) + calc_fb_size_planar(fd, width, height, format,tiling,
size_ret,stride_ret, NULL);lib/igt_fb.c +2
-0+else + calc_fb_size_packed(fd, width, height, format,tiling,
size_ret,stride_ret);lib/igt_fb.c +2
-0+} +/**
*igt_fb_mod_to_tiling:
* @modifier: DRM framebuffer modifierlib/igt_fb.c +0
-0@@ -245,17 +327,20 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling) }
/* helpers to create nice-looking framebuffers */ -static int create_bo_for_fb(int fd, int width, int height,uint32_tformat,lib/igt_fb.c +2
-0+static int create_bo_for_fb(int fd, int width, int height, + struct format_desc_struct *format,uint64_t tiling, unsigned size, unsigned stride,
unsigned*size_ret, unsigned*stride_ret,
bool*is_dumb)
{
int bo;lib/igt_fb.c +3
-1-if (tiling || size || stride) { +igt_assert (format); + +if (tiling || size || stride || format->planes >1 ) {unsigned
calculated_size,calculated_stride;lib/igt_fb.c +1
-1- igt_calc_fb_size(fd, width, height, format, tiling, + igt_calc_fb_size(fd, width, height, format->drm_id,tiling,
&calculated_size,&calculated_stride);
if (stride == 0)
stride =calculated_stride;lib/igt_fb.c +0
-2@@ -290,12 +375,10 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format, return -EINVAL; } } else { -int bpp =igt_drm_format_to_bpp (format); - if (is_dumb) *is_dumb = true;lib/igt_fb.c +0
-1- return kmstest_dumb_create(fd, width, height, bpp,
stride_ret,lib/igt_fb.c +1
-0+ return kmstest_dumb_create(fd, width, height,
format->bpp,stride_ret,
size_ret); }
}lib/igt_fb.c +0
-0@@ -323,8 +406,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height,unsigned stride, unsigned
*size_ret,
unsigned*stride_ret, bool*is_dumb)
{lib/igt_fb.c +0
-1- return create_bo_for_fb(fd, width, height, format, modifier,0, stride,
lib/igt_fb.c +1
-1- size_ret, stride_ret, is_dumb); + return create_bo_for_fb(fd, width, height,
lookup_drm_format(format),lib/igt_fb.c +1
-0+ modifier, 0, stride, size_ret,
stride_ret,is_dumb);
}
/**lib/igt_fb.c +0
-0@@ -671,9 +754,10 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%d)\n",
__func__, width, height, format, tiling,bo_size);lib/igt_fb.c +0
-1- fb->gem_handle = create_bo_for_fb(fd, width, height, format,tiling,
lib/igt_fb.c +0
-1- bo_size, bo_stride, &fb-Quoted 1 line
size,
lib/igt_fb.c +0
-1- &fb->stride, &fb-Quoted 1 line
is_dumb);lib/igt_fb.c +3
-0+ fb->gem_handle = create_bo_for_fb(fd, width, height, + lookup_drm_format(format), + tiling, bo_size,
bo_stride,lib/igt_fb.c +1
-0+ &fb->size, &fb->stride,
&fb->is_dumb);
igt_assert(fb->gem_handle > 0);
igt_debug("%s(handle=%d, pitch=%d)\n",lib/igt_fb.c +0
-0@@ -1069,7 +1153,7 @@ static void create_cairo_surface__blit(int fd,struct igt_fb *fb) * destination, tiling it at the same time. */
blit->linear.handle= create_bo_for_fb(fd,fb->width, fb-Quoted 1 line
height,
lib/igt_fb.c +1
-1- fb->drm_format, + lookup_drm_format(fb-Quoted 1 line
drm_format),LOCAL_DRM_FORMAT_MOD_ NONE, 0,
0, &blit-Quoted 1 line
linear.size,
&blit->linear.stride,
lib/igt_fb.c +1
-1@@ -1293,14 +1377,12 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp,int depth) */ uint32_t igt_drm_format_to_bpp(uint32_t drm_format) { -struct format_desc_struct *f; +struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +1
-5-for_each_format (f) -if (f->drm_id == drm_format) -return f->bpp; - - igt_assert_f(0, "can't find a bpp format for %08x (%s)\n", + igt_assert_f(f, "can't find a bpp format for %08x (%s)\n",drm_format,
igt_format_str(drm_format));lib/igt_fb.c +2
-0+ +return f->bpp;}
/**lib/igt_fb.c +0
-5@@ -1313,13 +1395,9 @@ uint32_t igt_drm_format_to_bpp(uint32_tdrm_format) */ const char *igt_format_str(uint32_t drm_format) { -struct format_desc_struct *f; - -for_each_format (f) -if (f->drm_id == drm_format) -return f->name;
Quoted 8 lines
Quoted 8 lines
lib/igt_fb.c +1
-0+struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +1
-1-return "invalid" ; +return f ? f->name :"invalid" ;}
/**
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/8] lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb
Quoted 45 lines · Maarten Lankhorst
Op 26-01-18 om 10:00 schreef Mika Kahola:
Quoted 36 lines · Maarten Lankhorst
Quoted 34 lines
By adding support for planar formats to
igt_calc_fb_sizeandcreate_bo_for_fb,
we can calculate dimensions and create backing storage for planar framebuffers.This is required for adding support to create planar framebuffers in
the next patch.Signed-off-by Maarten Lankhorst <[email protected]om>
---
lib/igt_fb.c | 168 +++++++++++++++++++++++++++++++++++++++++++
----
------------1 file changed, 123 insertions(+), 45 deletions(-)lib/igt_fb.c +0
-0@@ -54,14 +54,16 @@*/
/* drm fourcc/cairo format maps */lib/igt_fb.c +0
-2-#define DF (did, cid, _bpp, _depth) \ - { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp,
_depth
}lib/igt_fb.c +2
-0+#define DF (did, cid, ...) \ + { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did,
__VA_ARGS__}
static structformat_desc_struct{Quoted 8 lines
lib/igt_fb.c line 66
Quoted 7 lines
uint32_tdrm_id;
cairo_format_tcairo_id;
const char *name;
int bpp;
int depth;lib/igt_fb.c +2
-0+int planes; +int plane_bpp[4 ];should we define a max value for this instead of hardcoded one?
Quoted 1 line
4 planes is the maximum ever. Alpha, R, G and B.
Yes, but even so I'm not really a fan of harcoded values.
Quoted 357 lines
Quoted 356 lines
Quoted 109 lines
} format_desc[] = {
DF(RGB565, RGB16_565, 16, 16),
//DF(RGB888, INVALID, 24, 24),lib/igt_fb.c +0
-0@@ -74,6 +76,20 @@ static struct format_desc_struct { #define for_each_format(f) \for (f =
format_desc; f -format_desc<ARRAY_SIZE(format_desc); f++)
+static structformat_desc_struct*lookup_drm_format(uint32_tdrm_format)lib/igt_fb.c +13
-0+{ +struct format_desc_struct *format; + +for_each_format (format) { +if (format->drm_id != drm_format) +continue ; + +return format; + } + +return NULL ; +} +/**
*igt_get_fb_tile_size:
* @fd: the DRM file descriptorlib/igt_fb.c +0
-0@@ -142,27 +158,68 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } }
-/**
- *igt_calc_fb_size:
- * @fd: the DRM file descriptor
- * @width: width of the framebuffer in pixels
- * @height: height of the framebuffer in pixels
- * @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
- * @size_ret: returned size for the framebuffer
- * @stride_ret: returned stride for the framebuffer
- *
- * This function returns valid stride and size values for a framebuffer with the
- * specified parameters.
- */
-void igt_calc_fb_size(int fd, int width, int height,uint32_tformat,uint64_ttiling,lib/igt_fb.c +1
-1- unsigned *size_ret, unsigned *stride_ret) +static unsigned planar_stride(struct format_desc_struct *format,unsigned width, int plane)
lib/igt_fb.c +10
-0+{ +unsigned cpp = format->plane_bpp[plane] /8 ; + +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 * cpp; + +return width * cpp; +} + +static unsigned planar_height(struct format_desc_struct *format,unsigned height, int plane)
lib/igt_fb.c +9
-0+{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (height +1 ) /2 ; + +return height; +} + +static void calc_fb_size_planar (int fd,int width,int height, + struct format_desc_struct*format,
lib/igt_fb.c +1
-0+uint64_t tiling, unsigned
*size_ret,lib/igt_fb.c +1
-0+unsigned *stride_ret, unsigned*offsets)
lib/igt_fb.c +10
-0+{ +int plane; +unsigned stride =0 , tile_width, tile_height; + + *size_ret =0 ; + +for (plane =0 ; plane < format->planes; plane++) { +unsigned plane_stride; + + igt_get_fb_tile_size(fd, tiling, format-Quoted 2 lines
plane_bpp[plane],
&tile_width,&tile_height);lib/igt_fb.c +2
-0+ + plane_stride = ALIGN(planar_stride(format,width,
plane),tile_width);lib/igt_fb.c +9
-0+if (stride < plane_stride) + stride = plane_stride; + } + +for (plane =0 ; plane < format->planes; plane++) { +if (offsets) + offsets[plane] = *size_ret; + + igt_get_fb_tile_size(fd, tiling, format-Quoted 2 lines
plane_bpp[plane],
&tile_width,&tile_height);lib/igt_fb.c +2
-0+ + *size_ret += stride *ALIGN(planar_height(format,
height, plane),tile_height);lib/igt_fb.c void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, · line 209
Quoted 4 lines
lib/igt_fb.c +4
-0+ } + +if (offsets) +for (; plane <4 ; plane++)We could loop through max define value here too instead of hardcoded
one.Quoted 239 lines
lib/igt_fb.c +7
-0+ offsets[plane] =0 ; + + *stride_ret = stride; +} + +static void calc_fb_size_packed (int fd,int width,int height, + struct format_desc_struct*format,
uint64_ttiling,lib/igt_fb.c +1
-0+unsigned *size_ret, unsigned
*stride_ret)
{
unsigned inttile_width,tile_height, stride, size;lib/igt_fb.c +1
-2-int bpp =igt_drm_format_to_bpp (format); -int byte_width = width * (bpp /8 ); +int byte_width = width * (format->bpp /8 );lib/igt_fb.c +0
-1- igt_get_fb_tile_size(fd, tiling, bpp, &tile_width,
&tile_height);lib/igt_fb.c +1
-0+ igt_get_fb_tile_size(fd, tiling, format->bpp,
&tile_width,&tile_height);
if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE&& intel_gen(intel_get_drm_devid(fd)) <= 3) {lib/igt_fb.c +0
-0@@ -176,7 +233,7 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tformat,uint64_tt
* tiled. But then that failure is expected. */lib/igt_fb.c +1
-1- v = width * bpp /8 ; + v = byte_width;for (stride = 512; stride < v; stride *= 2) ;
lib/igt_fb.c +0
-0@@ -192,6 +249,31 @@ void igt_calc_fb_size(int fd, int width, intheight,
uint32_tformat,uint64_tt
*size_ret= size;
}
+/**
+ *igt_calc_fb_size:
+ * @fd: the DRM file descriptor
+ * @width: width of the framebuffer in pixels
+ * @height: height of the framebuffer in pixels
+ * @format: drm fourcc pixel format code
+ * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @size_ret: returned size for the framebuffer
+ * @stride_ret: returned stride for the framebuffer
+ *
+ * This function returns valid stride and size values for a framebuffer with the
+ * specified parameters.
+ */
+void igt_calc_fb_size(int fd, int width, int height,uint32_tdrm_format,uint64_ttiling,lib/igt_fb.c +3
-0+ unsigned *size_ret, unsigned *stride_ret) +{ + struct format_desc_struct *format =
lookup_drm_format(drm_format);lib/igt_fb.c +4
-0+igt_assert (format); + +if (format->planes >1 ) + calc_fb_size_planar(fd, width, height, format,tiling,
size_ret,stride_ret, NULL);lib/igt_fb.c +2
-0+else + calc_fb_size_packed(fd, width, height, format,tiling,
size_ret,stride_ret);lib/igt_fb.c +2
-0+} +/**
*igt_fb_mod_to_tiling:
* @modifier: DRM framebuffer modifierlib/igt_fb.c +0
-0@@ -245,17 +327,20 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling) }
/* helpers to create nice-looking framebuffers */ -static int create_bo_for_fb(int fd, int width, int height,uint32_t
format,lib/igt_fb.c +2
-0+static int create_bo_for_fb(int fd, int width, int height, + struct format_desc_struct *format,uint64_t tiling, unsigned size, unsigned
stride,
unsigned*size_ret, unsigned*stride_ret,
bool*is_dumb)
{
int bo;lib/igt_fb.c +3
-1-if (tiling || size || stride) { +igt_assert (format); + +if (tiling || size || stride || format->planes >1 ) {unsigned
calculated_size,calculated_stride;lib/igt_fb.c +0
-1- igt_calc_fb_size(fd, width, height, format,tiling,
lib/igt_fb.c +1
-0+ igt_calc_fb_size(fd, width, height, format-Quoted 1 line
drm_id,tiling,
&calculated_size,&calculated_stride);
if (stride == 0)
stride =calculated_stride;lib/igt_fb.c +0
-2@@ -290,12 +375,10 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format, return -EINVAL; } } else { -int bpp =igt_drm_format_to_bpp (format); - if (is_dumb) *is_dumb = true;lib/igt_fb.c +0
-1- return kmstest_dumb_create(fd, width, height,bpp,
stride_ret,lib/igt_fb.c +1
-0+ return kmstest_dumb_create(fd, width, height,
format->bpp,stride_ret,
size_ret); }
}lib/igt_fb.c +0
-0@@ -323,8 +406,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height,unsigned stride, unsigned
*size_ret,
unsigned*stride_ret, bool*is_dumb)
{lib/igt_fb.c +0
-1- return create_bo_for_fb(fd, width, height, format,modifier,
0, stride,lib/igt_fb.c +1
-1- size_ret, stride_ret, is_dumb); + return create_bo_for_fb(fd, width, height,
lookup_drm_format(format),lib/igt_fb.c +1
-0+ modifier, 0, stride, size_ret,
stride_ret,is_dumb);
}
/**lib/igt_fb.c +0
-0@@ -671,9 +754,10 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%d)\n",
__func__, width, height, format, tiling,bo_size);lib/igt_fb.c +0
-1- fb->gem_handle = create_bo_for_fb(fd, width, height,format,
tiling,lib/igt_fb.c +0
-1- bo_size, bo_stride,&fb-
Quoted 2 lines
size,
lib/igt_fb.c +0
-1- &fb->stride, &fb-Quoted 2 lines
is_dumb);lib/igt_fb.c +2
-0+ fb->gem_handle = create_bo_for_fb(fd, width, height, + lookup_drm_format(format),
lib/igt_fb.c +1
-0+ tiling, bo_size,
bo_stride,lib/igt_fb.c +1
-0+ &fb->size, &fb-Quoted 1 line
stride,
&fb->is_dumb);
igt_assert(fb->gem_handle > 0);
igt_debug("%s(handle=%d, pitch=%d)\n",lib/igt_fb.c +0
-0@@ -1069,7 +1153,7 @@ static void create_cairo_surface__blit(intfd, struct igt_fb *fb) * destination, tiling it at the same time. */ blit->linear.handle = create_bo_for_fb(fd, fb->width,fb-
Quoted 2 lines
height,
lib/igt_fb.c +1
-1- fb->drm_format, + lookup_drm_format(fb-
Quoted 2 lines
drm_format),LOCAL_DRM_FORMAT_
MOD_
NONE, 0,
0, &blit-Quoted 2 lines
linear.size,
&blit-
Quoted 1 line
linear.stride,
lib/igt_fb.c +1
-1@@ -1293,14 +1377,12 @@ uint32_t igt_bpp_depth_to_drm_format(intbpp, int depth) */ uint32_t igt_drm_format_to_bpp(uint32_t drm_format) { -struct format_desc_struct *f; +struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +0
-5-for_each_format (f) -if (f->drm_id == drm_format) -return f->bpp; - - igt_assert_f(0, "can't find a bpp format for %08x(%s)\n",
lib/igt_fb.c +1
-0+ igt_assert_f(f, "can't find a bpp format for %08x(%s)\n",
drm_format,igt_format_str(drm_format));lib/igt_fb.c +2
-0+ +return f->bpp;}
/**lib/igt_fb.c +1
-5@@ -1313,13 +1395,9 @@ uint32_t igt_drm_format_to_bpp(uint32_tdrm_format) */ const char *igt_format_str(uint32_t drm_format) { -struct format_desc_struct *f; - -for_each_format (f) -if (f->drm_id == drm_format) -return f->name; +struct format_desc_struct *f =lookup_drm_format (drm_format);lib/igt_fb.c +1
-1-return "invalid" ; +return f ? f->name :"invalid" ;}
/**
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/8] lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb
Op 26-01-18 om 11:24 schreef Mika Kahola:
Quoted 44 lines · Maarten Lankhorst
Quoted 43 lines
Op 26-01-18 om 10:00 schreef Mika Kahola:
Quoted 42 lines · Maarten Lankhorst
Quoted 38 lines
By adding support for planar formats to
igt_calc_fb_sizeandcreate_bo_for_fb,
we can calculate dimensions and create backing storage for planar framebuffers.This is required for adding support to create planar framebuffers in
the next patch.Signed-off-by Maarten Lankhorst <[email protected]om>
---
lib/igt_fb.c | 168 +++++++++++++++++++++++++++++++++++++++++++
----
------------1 file changed, 123 insertions(+), 45 deletions(-)lib/igt_fb.c +0
-0@@ -54,14 +54,16 @@*/
/* drm fourcc/cairo format maps */lib/igt_fb.c +0
-2-#define DF (did, cid, _bpp, _depth) \ - { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp,
_depth
}lib/igt_fb.c +2
-0+#define DF (did, cid, ...) \ + { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did,
__VA_ARGS__}
static structformat_desc_struct{
uint32_tdrm_id;
cairo_format_tcairo_id;
const char *name;
int bpp;
int depth;lib/igt_fb.c line 66
Quoted 2 lines
lib/igt_fb.c +2
-0+int planes; +int plane_bpp[4 ];should we define a max value for this instead of hardcoded one?
Quoted 2 lines
Quoted 1 line
4 planes is the maximum ever. Alpha, R, G and B.
Yes, but even so I'm not really a fan of harcoded values.
Only the array definitions use those values. There aren't even planar formats that support > 4 planes,
and uapi/drm/drm_mode.h also uses 4 everywhere. It's fine unless we everextend the kernel api to support
more than 4 planes, but this is very unlikely since the hw doesn't even exist. I think it's fine to hardcode this. All users use ARRAY_SIZE or sizeof as appropriate, so it won't matter much.
~Maarten
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/8] lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb
Quoted 54 lines · Maarten Lankhorst
Op 26-01-18 om 11:24 schreef Mika Kahola:
Quoted 53 lines · Maarten Lankhorst
Quoted 51 lines
Op 26-01-18 om 10:00 schreef Mika Kahola:
Quoted 40 lines · Maarten Lankhorst
Quoted 38 lines
By adding support for planar formats to
igt_calc_fb_sizeandcreate_bo_for_fb,
we can calculate dimensions and create backing storage for planar
framebuffers.This is required for adding support to create planar framebuffers
in
the next patch.Signed-off-by Maarten Lankhorst <[email protected]
el.c
om>
---
lib/igt_fb.c | 168
+++++++++++++++++++++++++++++++++++++++++++
----
------------1 file changed, 123 insertions(+), 45 deletions(-)lib/igt_fb.c +0
-0@@ -54,14 +54,16 @@*/
/* drm fourcc/cairo format maps */lib/igt_fb.c +0
-2-#define DF (did, cid, _bpp, _depth) \ - { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp,
_depth
}lib/igt_fb.c +2
-0+#define DF (did, cid, ...) \ + { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did,
__VA_ARGS__}
static structformat_desc_struct{Quoted 8 lines
lib/igt_fb.c line 66
Quoted 7 lines
uint32_tdrm_id;
cairo_format_tcairo_id;
const char *name;
int bpp;
int depth;lib/igt_fb.c +2
-0+int planes; +int plane_bpp[4 ];should we define a max value for this instead of hardcoded one?
4 planes is the maximum ever. Alpha, R, G and B.
Quoted 8 lines
Quoted 1 line
Yes, but even so I'm not really a fan of harcoded values.
Only the array definitions use those values. There aren't even planar formats that support > 4 planes,
anduapi/drm/drm_mode.halso uses 4 everywhere. It's fine unless we everextend the kernel api to support
more than 4 planes, but this is very unlikely since the hw doesn't even exist. I think it's fine to hardcode this. All users useARRAY_SIZEor sizeof as appropriate, so it won't matter much.
What I was after on my comment was that when you are browsing through the patch or the file itself, you don't realize that easily what is meant with these hardcoded values. You have to stop for a second to think and then you figure it out. The comment was all about enhancing readability. For loops, maybe we could use ARRAY_SIZE() here too?
Quoted 2 lines
~Maarten
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 3/8] lib/fb: Handle planar formats in igt_calc_fb_size and create_bo_for_fb
In reply to Maarten LankhorstQuoted 15 lines · Maarten Lankhorst
By adding support for planar formats to
igt_calc_fb_sizeandcreate_bo_for_fb, we can calculate dimensions and create backing storage for planar framebuffers.This is required for adding support to create planar framebuffers in the next patch.
Signed-off-by Maarten Lankhorst <[email protected]>--- lib/igt_fb.c | 168 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 123 insertions(+), 45 deletions(-)lib/igt_fb.c +0
-0
lib/igt_fb.c line 58
Quoted 7 lines
lib/igt_fb.c +2
-2@@ -54,14 +54,16 @@*/ /* drm fourcc/cairo format maps */ -#define DF (did, cid, _bpp, _depth) \ - { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, _bpp, _depth } +#define DF (did, cid, ...) \ + { DRM_FORMAT_##did, CAIRO_FORMAT_##cid, # did, __VA_ARGS__ }
I don't think this macro is providing any benefit to us since it can't even protect against did vs. cid typoes. IMO just kill it and switch to named initializers.
Quoted 12 lines
lib/igt_fb.c +2
-0static struct format_desc_struct {uint32_t drm_id;cairo_format_t cairo_id;const char *name;int bpp;int depth; +int planes; +int plane_bpp[4 ]; } format_desc[] = {DF (RGB565 ,RGB16_565 ,16 ,16 ),//DF(RGB888, INVALID, 24, 24),
lib/igt_fb.c static struct format_desc_struct { · line 79
Quoted 4 lines
lib/igt_fb.c +1
-0@@ -74,6 +76,20 @@ static struct format_desc_struct {#define for_each_format (f) \ for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++) +static struct format_desc_struct *lookup_drm_format (uint32_t drm_format)
The function name feels a bit misleading. Makes me thing it returns a drm fourcc.
lib/igt_fb.c static struct format_desc_struct { · line 85
Quoted 6 lines
lib/igt_fb.c +6
-0+{ +struct format_desc_struct *format; + +for_each_format (format) { +if (format->drm_id != drm_format) +continue ;
Or just
if (a == b)
return whatever;
Anyway apart from those things look pretty reasonable to me, so with the misleading function name made better this is
Quoted 252 lines
lib/igt_fb.c +112
-43+ +return format; + } + +return NULL ; +} +/** * igt_get_fb_tile_size: * @fd: the DRM file descriptor @@ -142,27 +158,68 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } -/** -* igt_calc_fb_size: -* @fd: the DRM file descriptor -* @width: width of the framebuffer in pixels -* @height: height of the framebuffer in pixels -* @format: drm fourcc pixel format code -* @tiling: tiling layout of the framebuffer (as framebuffer modifier) -* @size_ret: returned size for the framebuffer -* @stride_ret: returned stride for the framebuffer -* -* This function returns valid stride and size values for a framebuffer with the -* specified parameters. -*/ -void igt_calc_fb_size (int fd,int width,int height,uint32_t format,uint64_t tiling, -unsigned *size_ret,unsigned *stride_ret) +static unsigned planar_stride (struct format_desc_struct *format,unsigned width,int plane) +{ +unsigned cpp = format->plane_bpp[plane] /8 ; + +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 * cpp; + +return width * cpp; +} + +static unsigned planar_height (struct format_desc_struct *format,unsigned height,int plane) +{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (height +1 ) /2 ; + +return height; +} + +static void calc_fb_size_planar (int fd,int width,int height, +struct format_desc_struct *format, +uint64_t tiling,unsigned *size_ret, +unsigned *stride_ret,unsigned *offsets) +{ +int plane; +unsigned stride =0 , tile_width, tile_height; + + *size_ret =0 ; + +for (plane =0 ; plane < format->planes; plane++) { +unsigned plane_stride; + +igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); + + plane_stride =ALIGN (planar_stride (format, width, plane), tile_width); +if (stride < plane_stride) + stride = plane_stride; + } + +for (plane =0 ; plane < format->planes; plane++) { +if (offsets) + offsets[plane] = *size_ret; + +igt_get_fb_tile_size (fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height); + + *size_ret += stride *ALIGN (planar_height (format, height, plane), tile_height); + } + +if (offsets) +for (; plane <4 ; plane++) + offsets[plane] =0 ; + + *stride_ret = stride; +} + +static void calc_fb_size_packed (int fd,int width,int height, +struct format_desc_struct *format,uint64_t tiling, +unsigned *size_ret,unsigned *stride_ret) {unsigned int tile_width, tile_height, stride, size; -int bpp =igt_drm_format_to_bpp (format); -int byte_width = width * (bpp /8 ); +int byte_width = width * (format->bpp /8 ); -igt_get_fb_tile_size (fd, tiling, bpp, &tile_width, &tile_height); +igt_get_fb_tile_size (fd, tiling, format->bpp, &tile_width, &tile_height);if (tiling !=LOCAL_DRM_FORMAT_MOD_NONE &&intel_gen (intel_get_drm_devid (fd)) <=3 ) {@@ -176,7 +233,7 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t t* tiled. But then that failure is expected. */ - v = width * bpp /8 ; + v = byte_width;for (stride =512 ; stride < v; stride *=2 ) ;@@ -192,6 +249,31 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t t *size_ret = size; } +/** +* igt_calc_fb_size: +* @fd: the DRM file descriptor +* @width: width of the framebuffer in pixels +* @height: height of the framebuffer in pixels +* @format: drm fourcc pixel format code +* @tiling: tiling layout of the framebuffer (as framebuffer modifier) +* @size_ret: returned size for the framebuffer +* @stride_ret: returned stride for the framebuffer +* +* This function returns valid stride and size values for a framebuffer with the +* specified parameters. +*/ +void igt_calc_fb_size (int fd,int width,int height,uint32_t drm_format,uint64_t tiling, +unsigned *size_ret,unsigned *stride_ret) +{ +struct format_desc_struct *format =lookup_drm_format (drm_format); +igt_assert (format); + +if (format->planes >1 ) +calc_fb_size_planar (fd, width, height, format, tiling, size_ret, stride_ret,NULL ); +else +calc_fb_size_packed (fd, width, height, format, tiling, size_ret, stride_ret); +} +/** * igt_fb_mod_to_tiling: * @modifier: DRM framebuffer modifier @@ -245,17 +327,20 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling) }/* helpers to create nice-looking framebuffers */ -static int create_bo_for_fb (int fd,int width,int height,uint32_t format, +static int create_bo_for_fb (int fd,int width,int height, +struct format_desc_struct *format,uint64_t tiling,unsigned size,unsigned stride,unsigned *size_ret,unsigned *stride_ret,bool *is_dumb) {int bo; -if (tiling || size || stride) { +igt_assert (format); + +if (tiling || size || stride || format->planes >1 ) {unsigned calculated_size, calculated_stride; -igt_calc_fb_size (fd, width, height, format, tiling, +igt_calc_fb_size (fd, width, height, format->drm_id, tiling, &calculated_size, &calculated_stride);if (stride ==0 ) stride = calculated_stride;@@ -290,12 +375,10 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format,return -EINVAL ; } }else { -int bpp =igt_drm_format_to_bpp (format); -if (is_dumb) *is_dumb = true; -return kmstest_dumb_create (fd, width, height, bpp, stride_ret, +return kmstest_dumb_create (fd, width, height, format->bpp, stride_ret, size_ret); } }@@ -323,8 +406,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, unsigned stride, unsigned *size_ret, unsigned *stride_ret, bool *is_dumb) { - return create_bo_for_fb(fd, width, height, format, modifier, 0, stride, -size_ret ,stride_ret ,is_dumb ); + return create_bo_for_fb(fd, width, height, lookup_drm_format(format), + modifier, 0, stride, size_ret, stride_ret, is_dumb); }/** @@ -671,9 +754,10 @@ igt_create_fb_with_bo_size(int fd, int width, int height,igt_debug ("%s(width=%d, height=%d, format=0x%x, tiling=0x%" PRIx64", size=%d)\n" , __func__, width, height, format, tiling, bo_size); - fb->gem_handle =create_bo_for_fb (fd, width, height, format, tiling, - bo_size, bo_stride, &fb->size, - &fb->stride, &fb->is_dumb); + fb->gem_handle =create_bo_for_fb (fd, width, height, +lookup_drm_format (format), + tiling, bo_size, bo_stride, + &fb->size, &fb->stride, &fb->is_dumb);igt_assert (fb->gem_handle >0 ); igt_debug("%s(handle=%d, pitch=%d)\n",@@ -1069,7 +1153,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)* destination, tiling it at the same time. */ blit->linear.handle = create_bo_for_fb(fd, fb->width, fb->height, - fb->drm_format, + lookup_drm_format(fb->drm_format), LOCAL_DRM_FORMAT_MOD_NONE, 0, 0, &blit->linear.size, &blit->linear.stride,@@ -1293,14 +1377,12 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth)*/ uint32_t igt_drm_format_to_bpp (uint32_t drm_format) { -struct format_desc_struct *f; +struct format_desc_struct *f =lookup_drm_format (drm_format); -for_each_format (f) -if (f->drm_id == drm_format) -return f->bpp; - -igt_assert_f (0 ,"can't find a bpp format for %08x (%s)\n" , +igt_assert_f (f,"can't find a bpp format for %08x (%s)\n" , drm_format,igt_format_str (drm_format)); + +return f->bpp; }/** @@ -1313,13 +1395,9 @@ uint32_t igt_drm_format_to_bpp(uint32_t drm_format)*/ const char *igt_format_str (uint32_t drm_format) { -struct format_desc_struct *f; - -for_each_format (f) -if (f->drm_id == drm_format) -return f->name; +struct format_desc_struct *f =lookup_drm_format (drm_format); -return "invalid" ; +return f ? f->name :"invalid" ; }/** Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 4/8 lib/intel_batchbuffer: Add delta argument to igt_blitter_fast_copy__raw
In reply to Maarten LankhorstAdding a delta offset will allow us to copy planar framebuffers with this function.
--- lib/igt_fb.c | 8 ++++---- lib/intel_batchbuffer.c | 15 ++++++++++----- lib/intel_batchbuffer.h | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-)
lib/igt_fb.c +4 -4
@@ -1121,13 +1121,13 @@ static void destroy_cairo_surface__blit(void *arg) I915_GEM_DOMAIN_GTT, 0);igt_blitter_fast_copy__raw (blit->fd, - blit->linear.handle, + blit->linear.handle,0 , blit->linear.stride,I915_TILING_NONE ,0 ,0 ,/* src_x, src_y */ fb->width, fb->height,igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle, + fb->gem_handle,0 , fb->stride, obj_tiling,0 ,0 /* dst_x, dst_y */ );
@@ -1169,13 +1169,13 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_GTT, 0);igt_blitter_fast_copy__raw (fd, - fb->gem_handle, + fb->gem_handle,0 , fb->stride, obj_tiling,0 ,0 ,/* src_x, src_y */ fb->width, fb->height,igt_drm_format_to_bpp (fb->drm_format), - blit->linear.handle, + blit->linear.handle,0 , blit->linear.stride,I915_TILING_NONE ,0 ,0 /* dst_x, dst_y */ );
lib/intel_batchbuffer.c +10 -5
@@ -554,11 +554,12 @@ static uint32_t fast_copy_dword1(unsigned int src_tiling,static void fill_relocation (struct drm_i915_gem_relocation_entry *reloc, -uint32_t gem_handle,uint32_t offset,/* in dwords */ +uint32_t gem_handle,uint32_t delta,/* in bytes */ +uint32_t offset,/* in dwords */ uint32_t read_domains,uint32_t write_domains) { reloc->target_handle = gem_handle; - reloc->delta =0 ; + reloc->delta = delta; reloc->offset = offset *sizeof (uint32_t ); reloc->presumed_offset =0 ; reloc->read_domains = read_domains;
@@ -599,6 +600,7 @@ static void exec_blit(int fd,* igt_blitter_fast_copy__raw: * @fd: file descriptor of the i915 driver * @src_handle: GEM handle of the source buffer +* @src_delta: offset into the source GEM bo, in bytes * @src_stride: Stride (in bytes) of the source buffer * @src_tiling: Tiling mode of the source buffer * @src_x: X coordinate of the source region to copy
@@ -606,7 +608,8 @@ static void exec_blit(int fd,* @width: Width of the region to copy * @height: Height of the region to copy * @bpp: source and destination bits per pixel -* @dst_handle: GEM handle of the source buffer +* @dst_handle: GEM handle of the destination buffer +* @dst_delta: offset into the destination GEM bo, in bytes * @dst_stride: Stride (in bytes) of the destination buffer * @dst_tiling: Tiling mode of the destination buffer * @dst_x: X coordinate of destination
@@ -617,6 +620,7 @@ static void exec_blit(int fd, void igt_blitter_fast_copy__raw(int fd, /* src */ uint32_t src_handle, + unsigned int src_delta, unsigned int src_stride, unsigned int src_tiling, unsigned int src_x, unsigned src_y,
@@ -629,6 +633,7 @@ void igt_blitter_fast_copy__raw(int fd,/* dst */ uint32_t dst_handle, + unsigned dst_delta, unsigned int dst_stride, unsigned int dst_tiling, unsigned int dst_x, unsigned dst_y)
@@ -673,9 +678,9 @@ void igt_blitter_fast_copy__raw(int fd, batch_handle =gem_create (fd,4096 );gem_write (fd, batch_handle,0 , batch,sizeof (batch)); -fill_relocation (&relocs[0 ], dst_handle,4 , +fill_relocation (&relocs[0 ], dst_handle, dst_delta,4 ,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER ); -fill_relocation (&relocs[1 ], src_handle,8 ,I915_GEM_DOMAIN_RENDER ,0 ); +fill_relocation (&relocs[1 ], src_handle, src_delta,8 ,I915_GEM_DOMAIN_RENDER ,0 );fill_object (&objs[0 ], dst_handle,NULL ,0 );fill_object (&objs[1 ], src_handle,NULL ,0 );
lib/intel_batchbuffer.h +2 -0
@@ -234,6 +234,7 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch, void igt_blitter_fast_copy__raw(int fd, /* src */ uint32_t src_handle, + unsigned int src_delta, unsigned int src_stride, unsigned int src_tiling, unsigned int src_x, unsigned src_y,
@@ -246,6 +247,7 @@ void igt_blitter_fast_copy__raw(int fd,/* dst */ uint32_t dst_handle, + unsigned int dst_delta, unsigned int dst_stride, unsigned int dst_tiling, unsigned int dst_x, unsigned dst_y);
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 4/8] lib/intel_batchbuffer: Add delta argument to igt_blitter_fast_copy__raw
Quoted 4 lines · Maarten Lankhorst
Adding a delta offset will allow us to copy planar framebuffers with this
function.
Quoted 138 lines
Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 8 ++++----
lib/intel_batchbuffer.c | 15 ++++++++++-----
lib/intel_batchbuffer.h | 2 ++3 files changed, 16 insertions(+), 9 deletions(-)lib/igt_fb.c +0
-0@@ -1121,13 +1121,13 @@ static void destroy_cairo_surface__blit(void *arg) I915_GEM_DOMAIN_GTT, 0);
igt_blitter_fast_copy__raw(blit->fd,lib/igt_fb.c +1
-1- blit->linear.handle, + blit->linear.handle, 0,blit->linear.stride,
I915_TILING_NONE, 0, 0, /*src_x,src_y*/fb->width,fb->height, igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +1
-1- fb->gem_handle, + fb->gem_handle, 0,fb->stride,
obj_tiling,
0, 0 /*dst_x,dst_y*/);lib/igt_fb.c +0
-0@@ -1169,13 +1169,13 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_GTT, 0);
igt_blitter_fast_copy__raw(fd,lib/igt_fb.c +1
-1- fb->gem_handle, + fb->gem_handle, 0,fb->stride,
obj_tiling,
0, 0, /*src_x,src_y*/fb->width,fb->height, igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +1
-1- blit->linear.handle, + blit->linear.handle, 0,blit->linear.stride,
I915_TILING_NONE, 0, 0 /*dst_x,dst_y*/);lib/intel_batchbuffer.c +0
-0@@ -554,11 +554,12 @@ static uint32_t fast_copy_dword1(unsigned int src_tiling,
static void
fill_relocation(structdrm_i915_gem_relocation_entry*reloc,lib/intel_batchbuffer.c +0
-1- uint32_t gem_handle, uint32_t offset, /* in dwords*/
lib/intel_batchbuffer.c +2
-0+ uint32_t gem_handle, uint32_t delta, /* in bytes */ + uint32_t offset, /* in dwords */
uint32_tread_domains,uint32_twrite_domains) {
reloc->target_handle=gem_handle;lib/intel_batchbuffer.c +1
-1- reloc->delta =0 ; + reloc->delta = delta;
reloc->offset= offset *sizeof(uint32_t);reloc->presumed_offset= 0;reloc->read_domains=read_domains;lib/intel_batchbuffer.c +4
-1@@ -599,6 +600,7 @@ static void exec_blit(int fd, * igt_blitter_fast_copy__raw: * @fd: file descriptor of the i915 driver * @src_handle: GEM handle of the source buffer + * @src_delta: offset into the source GEM bo, in bytes * @src_stride: Stride (in bytes) of the source buffer * @src_tiling: Tiling mode of the source buffer * @src_x: X coordinate of the source region to copy@@ -606,7 +608,8 @@ static void exec_blit(int fd, * @width: Width of the region to copy * @height: Height of the region to copy * @bpp: source and destination bits per pixel - * @dst_handle: GEM handle of the source buffer + * @dst_handle: GEM handle of the destination buffer + * @dst_delta: offset into the destination GEM bo, in bytes * @dst_stride: Stride (in bytes) of the destination buffer * @dst_tiling: Tiling mode of the destination buffer * @dst_x: X coordinate of destination@@ -617,6 +620,7 @@ static void exec_blit(int fd, void igt_blitter_fast_copy__raw(int fd, /* src */ uint32_t src_handle, + unsigned int src_delta, unsigned int src_stride, unsigned int src_tiling, unsigned int src_x, unsigned src_y,@@ -629,6 +633,7 @@ void igt_blitter_fast_copy__raw(int fd,
/* dst */uint32_tdst_handle,lib/intel_batchbuffer.c +1
-0+ unsigned dst_delta,unsigned int
dst_stride, unsigned intdst_tiling, unsigned intdst_x, unsigneddst_y)lib/intel_batchbuffer.c +0
-0@@ -673,9 +678,9 @@ void igt_blitter_fast_copy__raw(int fd, batch_handle = gem_create(fd, 4096); gem_write(fd, batch_handle, 0, batch, sizeof(batch));lib/intel_batchbuffer.c +1
-1- fill_relocation(&relocs[0], dst_handle, 4, + fill_relocation(&relocs[0], dst_handle, dst_delta, 4,
I915_GEM_DOMAIN_RENDER,I915_GEM_DOMAIN_RENDER);lib/intel_batchbuffer.c +0
-1- fill_relocation(&relocs[1], src_handle, 8,
I915_GEM_DOMAIN_RENDER, 0);lib/intel_batchbuffer.c +1
-0+ fill_relocation(&relocs[1], src_handle, src_delta, 8,
I915_GEM_DOMAIN_RENDER, 0);
fill_object(&objs[0], dst_handle, NULL, 0);fill_object(&objs[1], src_handle, NULL, 0);lib/intel_batchbuffer.h +1
-0@@ -234,6 +234,7 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch, void igt_blitter_fast_copy__raw(int fd, /* src */ uint32_t src_handle, + unsigned int src_delta, unsigned int src_stride, unsigned int src_tiling,unsigned int
src_x, unsignedsrc_y,lib/intel_batchbuffer.h +0
-0@@ -246,6 +247,7 @@ void igt_blitter_fast_copy__raw(int fd,
/* dst */uint32_tdst_handle,lib/intel_batchbuffer.h +1
-0+ unsigned int dst_delta,unsigned int
dst_stride, unsigned intdst_tiling, unsigned intdst_x, unsigneddst_y);
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/1 lib/intel_batchbuffer: Add delta argument to igt_blitter_fast_copy__raw, v2.
In reply to Maarten LankhorstAdding a delta offset will allow us to copy planar framebuffers with this function.
Changes since v1:
- Set src and destination addresses to the delta, in case BO is mapped at offset 0.
--- lib/igt_fb.c | 8 ++++---- lib/intel_batchbuffer.c | 19 ++++++++++++------- lib/intel_batchbuffer.h | 2 ++ 3 files changed, 18 insertions(+), 11 deletions(-)
lib/igt_fb.c +4 -4
@@ -1121,13 +1121,13 @@ static void destroy_cairo_surface__blit(void *arg) I915_GEM_DOMAIN_GTT, 0);igt_blitter_fast_copy__raw (blit->fd, - blit->linear.handle, + blit->linear.handle,0 , blit->linear.stride,I915_TILING_NONE ,0 ,0 ,/* src_x, src_y */ fb->width, fb->height,igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle, + fb->gem_handle,0 , fb->stride, obj_tiling,0 ,0 /* dst_x, dst_y */ );
@@ -1169,13 +1169,13 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_GTT, 0);igt_blitter_fast_copy__raw (fd, - fb->gem_handle, + fb->gem_handle,0 , fb->stride, obj_tiling,0 ,0 ,/* src_x, src_y */ fb->width, fb->height,igt_drm_format_to_bpp (fb->drm_format), - blit->linear.handle, + blit->linear.handle,0 , blit->linear.stride,I915_TILING_NONE ,0 ,0 /* dst_x, dst_y */ );
lib/intel_batchbuffer.c +12 -7
@@ -554,11 +554,12 @@ static uint32_t fast_copy_dword1(unsigned int src_tiling,static void fill_relocation (struct drm_i915_gem_relocation_entry *reloc, -uint32_t gem_handle,uint32_t offset,/* in dwords */ +uint32_t gem_handle,uint32_t delta,/* in bytes */ +uint32_t offset,/* in dwords */ uint32_t read_domains,uint32_t write_domains) { reloc->target_handle = gem_handle; - reloc->delta =0 ; + reloc->delta = delta; reloc->offset = offset *sizeof (uint32_t ); reloc->presumed_offset =0 ; reloc->read_domains = read_domains;
@@ -599,6 +600,7 @@ static void exec_blit(int fd,* igt_blitter_fast_copy__raw: * @fd: file descriptor of the i915 driver * @src_handle: GEM handle of the source buffer +* @src_delta: offset into the source GEM bo, in bytes * @src_stride: Stride (in bytes) of the source buffer * @src_tiling: Tiling mode of the source buffer * @src_x: X coordinate of the source region to copy
@@ -606,7 +608,8 @@ static void exec_blit(int fd,* @width: Width of the region to copy * @height: Height of the region to copy * @bpp: source and destination bits per pixel -* @dst_handle: GEM handle of the source buffer +* @dst_handle: GEM handle of the destination buffer +* @dst_delta: offset into the destination GEM bo, in bytes * @dst_stride: Stride (in bytes) of the destination buffer * @dst_tiling: Tiling mode of the destination buffer * @dst_x: X coordinate of destination
@@ -617,6 +620,7 @@ static void exec_blit(int fd, void igt_blitter_fast_copy__raw(int fd, /* src */ uint32_t src_handle, + unsigned int src_delta, unsigned int src_stride, unsigned int src_tiling, unsigned int src_x, unsigned src_y,
@@ -629,6 +633,7 @@ void igt_blitter_fast_copy__raw(int fd,/* dst */ uint32_t dst_handle, + unsigned dst_delta, unsigned int dst_stride, unsigned int dst_tiling, unsigned int dst_x, unsigned dst_y)
@@ -659,11 +664,11 @@ void igt_blitter_fast_copy__raw(int fd, batch[i++] = dword1 | dst_pitch; batch[i++] = (dst_y <<16 ) | dst_x;/* dst x1,y1 */ batch[i++] = ((dst_y + height) <<16 ) | (dst_x + width);/* dst x2,y2 */ - batch[i++] =0 ;/* dst address lower bits */ + batch[i++] = dst_delta;/* dst address lower bits */ batch[i++] =0 ;/* dst address upper bits */ batch[i++] = (src_y <<16 ) | src_x;/* src x1,y1 */ batch[i++] = src_pitch; - batch[i++] =0 ;/* src address lower bits */ + batch[i++] = src_delta;/* src address lower bits */ batch[i++] =0 ;/* src address upper bits */ batch[i++] =MI_BATCH_BUFFER_END ; batch[i++] =MI_NOOP ;
@@ -673,9 +678,9 @@ void igt_blitter_fast_copy__raw(int fd, batch_handle =gem_create (fd,4096 );gem_write (fd, batch_handle,0 , batch,sizeof (batch)); -fill_relocation (&relocs[0 ], dst_handle,4 , +fill_relocation (&relocs[0 ], dst_handle, dst_delta,4 ,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER ); -fill_relocation (&relocs[1 ], src_handle,8 ,I915_GEM_DOMAIN_RENDER ,0 ); +fill_relocation (&relocs[1 ], src_handle, src_delta,8 ,I915_GEM_DOMAIN_RENDER ,0 );fill_object (&objs[0 ], dst_handle,NULL ,0 );fill_object (&objs[1 ], src_handle,NULL ,0 );
lib/intel_batchbuffer.h +2 -0
@@ -234,6 +234,7 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch, void igt_blitter_fast_copy__raw(int fd, /* src */ uint32_t src_handle, + unsigned int src_delta, unsigned int src_stride, unsigned int src_tiling, unsigned int src_x, unsigned src_y,
@@ -246,6 +247,7 @@ void igt_blitter_fast_copy__raw(int fd,/* dst */ uint32_t dst_handle, + unsigned int dst_delta, unsigned int dst_stride, unsigned int dst_tiling, unsigned int dst_x, unsigned dst_y);
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 5/8 lib/intel_batchbuffer: Add src/dst delta arguments to igt_blitter_fast_copy too
In reply to Maarten LankhorstNothing uses this currently, but other copy functions have the same delta now.
--- lib/intel_batchbuffer.c | 12 ++++++++---- lib/intel_batchbuffer.h | 10 ++++++---- 2 files changed, 14 insertions(+), 8 deletions(-)
lib/intel_batchbuffer.c +8 -4
@@ -695,12 +695,14 @@ void igt_blitter_fast_copy__raw(int fd,* igt_blitter_fast_copy: * @batch: batchbuffer object * @src: source i-g-t buffer object +* @src_delta: offset into the source i-g-t bo * @src_x: source pixel x-coordination * @src_y: source pixel y-coordination * @width: width of the copied rectangle * @height: height of the copied rectangle * @bpp: source and destination bits per pixel * @dst: destination i-g-t buffer object +* @dst_delta: offset into the destination i-g-t bo * @dst_x: destination pixel x-coordination * @dst_y: destination pixel y-coordination *
@@ -709,10 +711,12 @@ void igt_blitter_fast_copy__raw(int fd,* The source and destination surfaces cannot overlap. */ void igt_blitter_fast_copy (struct intel_batchbuffer *batch, -struct igt_buf *src,unsigned src_x,unsigned src_y, +struct igt_buf *src,unsigned src_delta, +unsigned src_x,unsigned src_y,unsigned width,unsigned height,int bpp, -struct igt_buf *dst,unsigned dst_x,unsigned dst_y) +struct igt_buf *dst,unsigned dst_delta, +unsigned dst_x,unsigned dst_y) {uint32_t src_pitch, dst_pitch;uint32_t dword0, dword1;
@@ -736,11 +740,11 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch,OUT_BATCH (dword1 | dst_pitch);OUT_BATCH ((dst_y <<16 ) | dst_x);/* dst x1,y1 */ OUT_BATCH (((dst_y + height) <<16 ) | (dst_x + width));/* dst x2,y2 */ -OUT_RELOC (dst->bo,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER ,0 ); +OUT_RELOC (dst->bo,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER , dst_delta);OUT_BATCH (0 );/* dst address upper bits */ OUT_BATCH ((src_y <<16 ) | src_x);/* src x1,y1 */ OUT_BATCH (src_pitch); -OUT_RELOC (src->bo,I915_GEM_DOMAIN_RENDER ,0 ,0 ); +OUT_RELOC (src->bo,I915_GEM_DOMAIN_RENDER ,0 , src_delta);OUT_BATCH (0 );/* src address upper bits */ ADVANCE_BATCH ();
lib/intel_batchbuffer.h +6 -4
@@ -226,10 +226,12 @@ unsigned igt_buf_width(struct igt_buf *buf);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, -int bpp, -struct igt_buf *dst,unsigned dst_x,unsigned dst_y); +struct igt_buf *src,unsigned src_delta, +unsigned src_x,unsigned src_y, +unsigned width,unsigned height, +int bpp, +struct igt_buf *dst,unsigned dst_delta, +unsigned dst_x,unsigned dst_y); void igt_blitter_fast_copy__raw(int fd,/* src */
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 5/8] lib/intel_batchbuffer: Add src/dst delta arguments to igt_blitter_fast_copy too
Quoted 3 lines · Maarten Lankhorst
Nothing uses this currently, but other copy functions have the same delta now.
Quoted 83 lines
Signed-off-by Maarten Lankhorst <[email protected]>---
lib/intel_batchbuffer.c | 12 ++++++++----
lib/intel_batchbuffer.h | 10 ++++++----2 files changed, 14 insertions(+), 8 deletions(-)lib/intel_batchbuffer.c +6
-2@@ -695,12 +695,14 @@ void igt_blitter_fast_copy__raw(int fd, * igt_blitter_fast_copy: * @batch: batchbuffer object * @src: source i-g-t buffer object + * @src_delta: offset into the source i-g-t bo * @src_x: source pixel x-coordination * @src_y: source pixel y-coordination * @width: width of the copied rectangle * @height: height of the copied rectangle * @bpp: source and destination bits per pixel * @dst: destination i-g-t buffer object + * @dst_delta: offset into the destination i-g-t bo * @dst_x: destination pixel x-coordination * @dst_y: destination pixel y-coordination *@@ -709,10 +711,12 @@ void igt_blitter_fast_copy__raw(int fd,* The source and destination surfaces cannot overlap. */ void igt_blitter_fast_copy(struct intel_batchbuffer *batch, - struct igt_buf *src, unsigned src_x, unsigned src_y, + struct igt_buf *src, unsigned src_delta, + unsigned src_x, unsigned src_y, unsigned width, unsigned height, int bpp, - struct igt_buf *dst, unsigned dst_x, unsigned dst_y) + struct igt_buf *dst, unsigned dst_delta, + unsigned dst_x, unsigned dst_y) {
uint32_tsrc_pitch,dst_pitch;
uint32_tdword0, dword1;lib/intel_batchbuffer.c +0
-0@@ -736,11 +740,11 @@ void igt_blitter_fast_copy(structintel_batchbuffer *batch, OUT_BATCH(dword1 | dst_pitch);
OUT_BATCH((dst_y << 16) | dst_x); /* dst x1,y1 */OUT_BATCH(((dst_y + height) << 16) | (dst_x + width)); /* dst x2,y2 */lib/intel_batchbuffer.c +0
-1- OUT_RELOC(dst->bo, I915_GEM_DOMAIN_RENDER,
I915_GEM_DOMAIN_RENDER, 0);lib/intel_batchbuffer.c +1
-0+ OUT_RELOC(dst->bo, I915_GEM_DOMAIN_RENDER,
I915_GEM_DOMAIN_RENDER,dst_delta);
OUT_BATCH(0); /* dst address upper bits */
OUT_BATCH((src_y << 16) | src_x); /* src x1,y1 */OUT_BATCH(src_pitch);lib/intel_batchbuffer.c +1
-1-OUT_RELOC (src->bo,I915_GEM_DOMAIN_RENDER ,0 ,0 ); +OUT_RELOC (src->bo,I915_GEM_DOMAIN_RENDER ,0 , src_delta);
OUT_BATCH(0); /* src address upper bits */
ADVANCE_BATCH();lib/intel_batchbuffer.h +0
-0@@ -226,10 +226,12 @@ unsigned igt_buf_width(struct igt_buf *buf); unsigned igt_buf_height(struct igt_buf *buf);
void igt_blitter_fast_copy(structintel_batchbuffer*batch,lib/intel_batchbuffer.h +0
-1- struct igt_buf *src, unsigned src_x,unsigned
src_y,lib/intel_batchbuffer.h +0
-3- unsigned width, unsigned height, - int bpp, - struct igt_buf *dst, unsigned dst_x,unsigned
dst_y);lib/intel_batchbuffer.h +6
-0+ struct igt_buf *src, unsigned src_delta, + unsigned src_x, unsigned src_y, + unsigned width, unsigned height, + int bpp, + struct igt_buf *dst, unsigned dst_delta, + unsigned dst_x, unsigned dst_y);
void igt_blitter_fast_copy__raw(int fd,
/* src */
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 6/8 lib/fb: Add support for creating planar framebuffers
In reply to Maarten LankhorstAdd support to create planar framebuffers, but don't add formats that support them yet. This first requires conversion to the RGB24 format.
--- lib/igt_fb.c | 75 +++++++++++++++++++++++++++++++++++------------- lib/igt_fb.h | 10 +++++++ lib/ioctl_wrappers.c | 11 +++++-- lib/ioctl_wrappers.h | 2 +- tests/kms_draw_crc.c | 2 +- tests/kms_rotation_crc.c | 5 ++-- tests/prime_vgem.c | 2 +- 7 files changed, 80 insertions(+), 27 deletions(-)
lib/igt_fb.c +55 -20
@@ -158,14 +158,19 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } +static unsigned planar_width (struct format_desc_struct *format,unsigned width,int plane) +{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 ; + +return width; +} +static unsigned planar_stride (struct format_desc_struct *format,unsigned width,int plane) {unsigned cpp = format->plane_bpp[plane] /8 ; -if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) -return (width +1 ) /2 * cpp; - -return width * cpp; +return planar_width (format, width, plane) * cpp; }static unsigned planar_height (struct format_desc_struct *format,unsigned height,int plane)
@@ -331,7 +336,7 @@ static int create_bo_for_fb(int fd, int width, int height,struct format_desc_struct *format, uint64_t tiling, unsigned size, unsigned stride, unsigned *size_ret, unsigned *stride_ret, - bool *is_dumb) + uint32_t *offsets, bool *is_dumb) { int bo;
@@ -340,8 +345,15 @@ static int create_bo_for_fb(int fd, int width, int height,if (tiling || size || stride || format->planes >1 ) {unsigned calculated_size, calculated_stride; -igt_calc_fb_size (fd, width, height, format->drm_id, tiling, - &calculated_size, &calculated_stride); +if (format->planes >1 ) +calc_fb_size_planar (fd, width, height, format, tiling, + &calculated_size, &calculated_stride, offsets); +else { +memset (offsets,0 ,4 *sizeof (*offsets)); +calc_fb_size_packed (fd, width, height, format, tiling, + &calculated_size, &calculated_stride); + } +if (stride ==0 ) stride = calculated_stride;if (size ==0 )
@@ -407,7 +419,7 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, unsigned *stride_ret, bool *is_dumb) { return create_bo_for_fb(fd, width, height, lookup_drm_format(format), - modifier, 0, stride, size_ret, stride_ret, is_dumb); + modifier, 0, stride, size_ret, stride_ret, NULL, is_dumb); }/**
@@ -748,16 +760,20 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, unsigned bo_size, unsigned bo_stride) { + struct format_desc_struct *f = lookup_drm_format(format);uint32_t fb_id; +int i; + +igt_assert_f (f,"DRM format %08x not found\n" , format);memset (fb,0 ,sizeof (*fb));igt_debug ("%s(width=%d, height=%d, format=0x%x, tiling=0x%" PRIx64", size=%d)\n" , __func__, width, height, format, tiling, bo_size); - fb->gem_handle =create_bo_for_fb (fd, width, height, -lookup_drm_format (format), + fb->gem_handle =create_bo_for_fb (fd, width, height, f, tiling, bo_size, bo_stride, - &fb->size, &fb->stride, &fb->is_dumb); + &fb->size, &fb->stride, + fb->offsets, &fb->is_dumb);igt_assert (fb->gem_handle >0 ); igt_debug("%s(handle=%d, pitch=%d)\n",
@@ -766,22 +782,24 @@ igt_create_fb_with_bo_size(int fd, int width, int height,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->offsets,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); }else {uint32_t handles[4 ];uint32_t pitches[4 ]; -uint32_t offsets[4 ];memset (handles,0 ,sizeof (handles));memset (pitches,0 ,sizeof (pitches)); -memset (offsets,0 ,sizeof (offsets)); handles[0 ] = fb->gem_handle; pitches[0 ] = fb->stride; +for (i =0 ; i < f->planes; i++) { + handles[i] = fb->gem_handle; + pitches[i] = fb->stride; + }do_or_die (drmModeAddFB2 (fd, width, height, format, - handles, pitches, offsets, + handles, pitches, fb->offsets, &fb_id,0 )); }
@@ -791,6 +809,17 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->drm_format = format; fb->fb_id = fb_id; fb->fd = fd; + fb->num_planes = f->planes ?:1 ; + fb->plane_bpp[0 ] = f->bpp; + fb->plane_height[0 ] = height; + fb->plane_width[0 ] = width; + +/* if f->planes is set, then plane_bpp is valid too so use that. */ +for (i =0 ; i < f->planes; i++) { + fb->plane_bpp[i] = f->plane_bpp[i]; + fb->plane_height[i] =planar_height (f, height, i); + fb->plane_width[i] =planar_width (f, width, i); + }return fb_id; }
@@ -1127,7 +1156,8 @@ static void destroy_cairo_surface__blit(void *arg)0 ,0 ,/* src_x, src_y */ fb->width, fb->height,igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle,0 , + fb->gem_handle, + fb->offsets[0 ], fb->stride, obj_tiling, 0, 0 /* dst_x, dst_y */);
@@ -1143,6 +1173,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)struct fb_blit_upload *blit;cairo_format_t cairo_format;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); +uint32_t offsets[4 ]; blit =malloc (sizeof (*blit));igt_assert (blit);
@@ -1157,7 +1188,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)LOCAL_DRM_FORMAT_MOD_NONE ,0 ,0 , &blit->linear.size, &blit->linear.stride, - &blit->linear.is_dumb); + offsets, &blit->linear.is_dumb);igt_assert (blit->linear.handle >0 );
@@ -1169,7 +1200,8 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_GTT, 0); igt_blitter_fast_copy__raw(fd, - fb->gem_handle, 0, + fb->gem_handle, + fb->offsets[0], fb->stride, obj_tiling, 0, 0, /* src_x, src_y */
@@ -1257,14 +1289,17 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)* @fd: open drm file descriptor * @fb: pointer to an #igt_fb structure * -* This function stores the contents of the supplied framebuffer into a cairo -* surface and returns it. +* This function stores the contents of the supplied framebuffer's plane +* into a cairo surface and returns it. * * Returns: * A pointer to a cairo surface with the contents of the framebuffer. */ cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb) { +/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */ +igt_assert (fb->num_planes <2 ); +if (fb->cairo_surface ==NULL ) {if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)
lib/igt_fb.h +10 -0
@@ -50,6 +50,11 @@* @size: size in bytes of the underlying backing storage * @cairo_surface: optionally attached cairo drawing surface * @domain: current domain for cache flushing tracking on i915.ko +* @num_planes: Amount of planes on this fb. >1 for planar formats. +* @offsets: Offset for each plane in bytes. +* @plane_bpp: The bpp for each plane. +* @plane_width: The width for each plane. +* @plane_height: The height for each plane. * * Tracking structure for KMS framebuffer objects. */
@@ -66,6 +71,11 @@ typedef struct igt_fb {unsigned int size;cairo_surface_t *cairo_surface;unsigned int domain; +unsigned int num_planes; +uint32_t offsets[4 ]; +unsigned int plane_bpp[4 ]; +unsigned int plane_width[4 ]; +unsigned int plane_height[4 ]; } igt_fb_t;/**
lib/ioctl_wrappers.c +9 -2
@@ -1659,10 +1659,10 @@ 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 *offsets,uint32_t flags,uint32_t *buf_id) {struct drm_mode_fb_cmd2 f; -int ret; +int ret, i;igt_require_fb_modifiers (fd);
@@ -1676,6 +1676,13 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, f.pitches[0 ] = stride; f.modifier[0 ] = modifier; +for (i =1 ; i <4 && offsets && offsets[i]; i++) { + f.handles[i] = handle; + f.pitches[i] = stride; + f.modifier[i] = modifier; + f.offsets[i] = offsets[i]; + } + ret =igt_ioctl (fd,DRM_IOCTL_MODE_ADDFB2 , &f); *buf_id = f.fb_id;
lib/ioctl_wrappers.h +1 -1
@@ -236,7 +236,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 *offsets,uint32_t flags,uint32_t *buf_id);/** * to_user_pointer:
tests/kms_draw_crc.c +1 -1
@@ -163,7 +163,7 @@ static bool format_is_supported(uint32_t format, uint64_t modifier) format, modifier, 0, NULL, &stride, NULL); ret =__kms_addfb (drm_fd, gem_handle,64 ,64 , - stride, format, modifier, + stride, format, modifier,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id);drmModeRmFB (drm_fd, fb_id);gem_close (drm_fd, gem_handle);
tests/kms_rotation_crc.c +3 -2
@@ -520,7 +520,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,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &data->fb.fb_id)); data->fb.width = w; data->fb.height = h;
@@ -601,7 +601,8 @@ 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,NULL , +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
@@ -723,7 +723,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 ,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id[i]));igt_assert (fb_id[i]); }
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/1 lib/fb: Add support for creating planar framebuffers, v2.
Add support to create planar framebuffers, but don't add formats that support them yet. This first requires conversion to the RGB24 format.
Changes since v1:
- Don't crash in igt_create_bo_with_dimensions().
--- lib/igt_fb.c | 76 +++++++++++++++++++++++++++++++++++------------- lib/igt_fb.h | 10 +++++++ lib/ioctl_wrappers.c | 11 +++++-- lib/ioctl_wrappers.h | 2 +- tests/kms_draw_crc.c | 2 +- tests/kms_rotation_crc.c | 5 ++-- tests/prime_vgem.c | 2 +- 7 files changed, 81 insertions(+), 27 deletions(-)
lib/igt_fb.c +56 -20
@@ -158,14 +158,19 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } +static unsigned planar_width (struct format_desc_struct *format,unsigned width,int plane) +{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 ; + +return width; +} +static unsigned planar_stride (struct format_desc_struct *format,unsigned width,int plane) {unsigned cpp = format->plane_bpp[plane] /8 ; -if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) -return (width +1 ) /2 * cpp; - -return width * cpp; +return planar_width (format, width, plane) * cpp; }static unsigned planar_height (struct format_desc_struct *format,unsigned height,int plane)
@@ -331,7 +336,7 @@ static int create_bo_for_fb(int fd, int width, int height,struct format_desc_struct *format, uint64_t tiling, unsigned size, unsigned stride, unsigned *size_ret, unsigned *stride_ret, - bool *is_dumb) + uint32_t *offsets, bool *is_dumb) { int bo;
@@ -340,8 +345,16 @@ static int create_bo_for_fb(int fd, int width, int height,if (tiling || size || stride || format->planes >1 ) {unsigned calculated_size, calculated_stride; -igt_calc_fb_size (fd, width, height, format->drm_id, tiling, - &calculated_size, &calculated_stride); +if (format->planes >1 ) +calc_fb_size_planar (fd, width, height, format, tiling, + &calculated_size, &calculated_stride, offsets); +else { +if (offsets) +memset (offsets,0 ,4 *sizeof (*offsets)); +calc_fb_size_packed (fd, width, height, format, tiling, + &calculated_size, &calculated_stride); + } +if (stride ==0 ) stride = calculated_stride;if (size ==0 )
@@ -407,7 +420,7 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, unsigned *stride_ret, bool *is_dumb) { return create_bo_for_fb(fd, width, height, lookup_drm_format(format), - modifier, 0, stride, size_ret, stride_ret, is_dumb); + modifier, 0, stride, size_ret, stride_ret, NULL, is_dumb); }/**
@@ -748,16 +761,20 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, unsigned bo_size, unsigned bo_stride) { + struct format_desc_struct *f = lookup_drm_format(format);uint32_t fb_id; +int i; + +igt_assert_f (f,"DRM format %08x not found\n" , format);memset (fb,0 ,sizeof (*fb));igt_debug ("%s(width=%d, height=%d, format=0x%x, tiling=0x%" PRIx64", size=%d)\n" , __func__, width, height, format, tiling, bo_size); - fb->gem_handle =create_bo_for_fb (fd, width, height, -lookup_drm_format (format), + fb->gem_handle =create_bo_for_fb (fd, width, height, f, tiling, bo_size, bo_stride, - &fb->size, &fb->stride, &fb->is_dumb); + &fb->size, &fb->stride, + fb->offsets, &fb->is_dumb);igt_assert (fb->gem_handle >0 ); igt_debug("%s(handle=%d, pitch=%d)\n",
@@ -766,22 +783,24 @@ igt_create_fb_with_bo_size(int fd, int width, int height,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->offsets,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); }else {uint32_t handles[4 ];uint32_t pitches[4 ]; -uint32_t offsets[4 ];memset (handles,0 ,sizeof (handles));memset (pitches,0 ,sizeof (pitches)); -memset (offsets,0 ,sizeof (offsets)); handles[0 ] = fb->gem_handle; pitches[0 ] = fb->stride; +for (i =0 ; i < f->planes; i++) { + handles[i] = fb->gem_handle; + pitches[i] = fb->stride; + }do_or_die (drmModeAddFB2 (fd, width, height, format, - handles, pitches, offsets, + handles, pitches, fb->offsets, &fb_id,0 )); }
@@ -791,6 +810,17 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->drm_format = format; fb->fb_id = fb_id; fb->fd = fd; + fb->num_planes = f->planes ?:1 ; + fb->plane_bpp[0 ] = f->bpp; + fb->plane_height[0 ] = height; + fb->plane_width[0 ] = width; + +/* if f->planes is set, then plane_bpp is valid too so use that. */ +for (i =0 ; i < f->planes; i++) { + fb->plane_bpp[i] = f->plane_bpp[i]; + fb->plane_height[i] =planar_height (f, height, i); + fb->plane_width[i] =planar_width (f, width, i); + }return fb_id; }
@@ -1127,7 +1157,8 @@ static void destroy_cairo_surface__blit(void *arg)0 ,0 ,/* src_x, src_y */ fb->width, fb->height,igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle,0 , + fb->gem_handle, + fb->offsets[0 ], fb->stride, obj_tiling, 0, 0 /* dst_x, dst_y */);
@@ -1143,6 +1174,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)struct fb_blit_upload *blit;cairo_format_t cairo_format;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); +uint32_t offsets[4 ]; blit =malloc (sizeof (*blit));igt_assert (blit);
@@ -1157,7 +1189,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)LOCAL_DRM_FORMAT_MOD_NONE ,0 ,0 , &blit->linear.size, &blit->linear.stride, - &blit->linear.is_dumb); + offsets, &blit->linear.is_dumb);igt_assert (blit->linear.handle >0 );
@@ -1169,7 +1201,8 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_GTT, 0); igt_blitter_fast_copy__raw(fd, - fb->gem_handle, 0, + fb->gem_handle, + fb->offsets[0], fb->stride, obj_tiling, 0, 0, /* src_x, src_y */
@@ -1257,14 +1290,17 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)* @fd: open drm file descriptor * @fb: pointer to an #igt_fb structure * -* This function stores the contents of the supplied framebuffer into a cairo -* surface and returns it. +* This function stores the contents of the supplied framebuffer's plane +* into a cairo surface and returns it. * * Returns: * A pointer to a cairo surface with the contents of the framebuffer. */ cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb) { +/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */ +igt_assert (fb->num_planes <2 ); +if (fb->cairo_surface ==NULL ) {if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)
lib/igt_fb.h +10 -0
@@ -50,6 +50,11 @@* @size: size in bytes of the underlying backing storage * @cairo_surface: optionally attached cairo drawing surface * @domain: current domain for cache flushing tracking on i915.ko +* @num_planes: Amount of planes on this fb. >1 for planar formats. +* @offsets: Offset for each plane in bytes. +* @plane_bpp: The bpp for each plane. +* @plane_width: The width for each plane. +* @plane_height: The height for each plane. * * Tracking structure for KMS framebuffer objects. */
@@ -66,6 +71,11 @@ typedef struct igt_fb {unsigned int size;cairo_surface_t *cairo_surface;unsigned int domain; +unsigned int num_planes; +uint32_t offsets[4 ]; +unsigned int plane_bpp[4 ]; +unsigned int plane_width[4 ]; +unsigned int plane_height[4 ]; } igt_fb_t;/**
lib/ioctl_wrappers.c +9 -2
@@ -1659,10 +1659,10 @@ 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 *offsets,uint32_t flags,uint32_t *buf_id) {struct drm_mode_fb_cmd2 f; -int ret; +int ret, i;igt_require_fb_modifiers (fd);
@@ -1676,6 +1676,13 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, f.pitches[0 ] = stride; f.modifier[0 ] = modifier; +for (i =1 ; i <4 && offsets && offsets[i]; i++) { + f.handles[i] = handle; + f.pitches[i] = stride; + f.modifier[i] = modifier; + f.offsets[i] = offsets[i]; + } + ret =igt_ioctl (fd,DRM_IOCTL_MODE_ADDFB2 , &f); *buf_id = f.fb_id;
lib/ioctl_wrappers.h +1 -1
@@ -236,7 +236,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 *offsets,uint32_t flags,uint32_t *buf_id);/** * to_user_pointer:
tests/kms_draw_crc.c +1 -1
@@ -163,7 +163,7 @@ static bool format_is_supported(uint32_t format, uint64_t modifier) format, modifier, 0, NULL, &stride, NULL); ret =__kms_addfb (drm_fd, gem_handle,64 ,64 , - stride, format, modifier, + stride, format, modifier,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id);drmModeRmFB (drm_fd, fb_id);gem_close (drm_fd, gem_handle);
tests/kms_rotation_crc.c +3 -2
@@ -520,7 +520,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,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &data->fb.fb_id)); data->fb.width = w; data->fb.height = h;
@@ -601,7 +601,8 @@ 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,NULL , +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
@@ -723,7 +723,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 ,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id[i]));igt_assert (fb_id[i]); }
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/1 lib/fb: Add support for creating planar framebuffers, v3.
Add support to create planar framebuffers, but don't add formats that support them yet. This first requires conversion to the RGB24 format.
Changes since v1:
- Don't crash in igt_create_bo_with_dimensions().
Changes since v2:
- Zero offsets for dumb fb too.
--- lib/igt_fb.c | 76 +++++++++++++++++++++++++++++++++++------------- lib/igt_fb.h | 10 +++++++ lib/ioctl_wrappers.c | 11 +++++-- lib/ioctl_wrappers.h | 2 +- tests/kms_draw_crc.c | 2 +- tests/kms_rotation_crc.c | 5 ++-- tests/prime_vgem.c | 2 +- 7 files changed, 81 insertions(+), 27 deletions(-)
lib/igt_fb.c +56 -20
@@ -158,14 +158,19 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } } +static unsigned planar_width (struct format_desc_struct *format,unsigned width,int plane) +{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 ; + +return width; +} +static unsigned planar_stride (struct format_desc_struct *format,unsigned width,int plane) {unsigned cpp = format->plane_bpp[plane] /8 ; -if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) -return (width +1 ) /2 * cpp; - -return width * cpp; +return planar_width (format, width, plane) * cpp; }static unsigned planar_height (struct format_desc_struct *format,unsigned height,int plane)
@@ -331,17 +336,25 @@ static int create_bo_for_fb(int fd, int width, int height,struct format_desc_struct *format, uint64_t tiling, unsigned size, unsigned stride, unsigned *size_ret, unsigned *stride_ret, - bool *is_dumb) + uint32_t *offsets, bool *is_dumb) { int bo;igt_assert (format); +if (offsets) +memset (offsets,0 ,4 *sizeof (*offsets)); +if (tiling || size || stride || format->planes >1 ) {unsigned calculated_size, calculated_stride; -igt_calc_fb_size (fd, width, height, format->drm_id, tiling, - &calculated_size, &calculated_stride); +if (format->planes >1 ) +calc_fb_size_planar (fd, width, height, format, tiling, + &calculated_size, &calculated_stride, offsets); +else +calc_fb_size_packed (fd, width, height, format, tiling, + &calculated_size, &calculated_stride); +if (stride ==0 ) stride = calculated_stride;if (size ==0 )
@@ -407,7 +420,7 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, unsigned *stride_ret, bool *is_dumb) { return create_bo_for_fb(fd, width, height, lookup_drm_format(format), - modifier, 0, stride, size_ret, stride_ret, is_dumb); + modifier, 0, stride, size_ret, stride_ret, NULL, is_dumb); }/**
@@ -748,16 +761,20 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, unsigned bo_size, unsigned bo_stride) { + struct format_desc_struct *f = lookup_drm_format(format);uint32_t fb_id; +int i; + +igt_assert_f (f,"DRM format %08x not found\n" , format);memset (fb,0 ,sizeof (*fb));igt_debug ("%s(width=%d, height=%d, format=0x%x, tiling=0x%" PRIx64", size=%d)\n" , __func__, width, height, format, tiling, bo_size); - fb->gem_handle =create_bo_for_fb (fd, width, height, -lookup_drm_format (format), + fb->gem_handle =create_bo_for_fb (fd, width, height, f, tiling, bo_size, bo_stride, - &fb->size, &fb->stride, &fb->is_dumb); + &fb->size, &fb->stride, + fb->offsets, &fb->is_dumb);igt_assert (fb->gem_handle >0 ); igt_debug("%s(handle=%d, pitch=%d)\n",
@@ -766,22 +783,24 @@ igt_create_fb_with_bo_size(int fd, int width, int height,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->offsets,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id)); }else {uint32_t handles[4 ];uint32_t pitches[4 ]; -uint32_t offsets[4 ];memset (handles,0 ,sizeof (handles));memset (pitches,0 ,sizeof (pitches)); -memset (offsets,0 ,sizeof (offsets)); handles[0 ] = fb->gem_handle; pitches[0 ] = fb->stride; +for (i =0 ; i < f->planes; i++) { + handles[i] = fb->gem_handle; + pitches[i] = fb->stride; + }do_or_die (drmModeAddFB2 (fd, width, height, format, - handles, pitches, offsets, + handles, pitches, fb->offsets, &fb_id,0 )); }
@@ -791,6 +810,17 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->drm_format = format; fb->fb_id = fb_id; fb->fd = fd; + fb->num_planes = f->planes ?:1 ; + fb->plane_bpp[0 ] = f->bpp; + fb->plane_height[0 ] = height; + fb->plane_width[0 ] = width; + +/* if f->planes is set, then plane_bpp is valid too so use that. */ +for (i =0 ; i < f->planes; i++) { + fb->plane_bpp[i] = f->plane_bpp[i]; + fb->plane_height[i] =planar_height (f, height, i); + fb->plane_width[i] =planar_width (f, width, i); + }return fb_id; }
@@ -1127,7 +1157,8 @@ static void destroy_cairo_surface__blit(void *arg)0 ,0 ,/* src_x, src_y */ fb->width, fb->height,igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle,0 , + fb->gem_handle, + fb->offsets[0 ], fb->stride, obj_tiling, 0, 0 /* dst_x, dst_y */);
@@ -1143,6 +1174,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)struct fb_blit_upload *blit;cairo_format_t cairo_format;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); +uint32_t offsets[4 ]; blit =malloc (sizeof (*blit));igt_assert (blit);
@@ -1157,7 +1189,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)LOCAL_DRM_FORMAT_MOD_NONE ,0 ,0 , &blit->linear.size, &blit->linear.stride, - &blit->linear.is_dumb); + offsets, &blit->linear.is_dumb);igt_assert (blit->linear.handle >0 );
@@ -1169,7 +1201,8 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_GTT, 0); igt_blitter_fast_copy__raw(fd, - fb->gem_handle, 0, + fb->gem_handle, + fb->offsets[0], fb->stride, obj_tiling, 0, 0, /* src_x, src_y */
@@ -1257,14 +1290,17 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)* @fd: open drm file descriptor * @fb: pointer to an #igt_fb structure * -* This function stores the contents of the supplied framebuffer into a cairo -* surface and returns it. +* This function stores the contents of the supplied framebuffer's plane +* into a cairo surface and returns it. * * Returns: * A pointer to a cairo surface with the contents of the framebuffer. */ cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb) { +/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */ +igt_assert (fb->num_planes <2 ); +if (fb->cairo_surface ==NULL ) {if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)
lib/igt_fb.h +10 -0
@@ -50,6 +50,11 @@* @size: size in bytes of the underlying backing storage * @cairo_surface: optionally attached cairo drawing surface * @domain: current domain for cache flushing tracking on i915.ko +* @num_planes: Amount of planes on this fb. >1 for planar formats. +* @offsets: Offset for each plane in bytes. +* @plane_bpp: The bpp for each plane. +* @plane_width: The width for each plane. +* @plane_height: The height for each plane. * * Tracking structure for KMS framebuffer objects. */
@@ -66,6 +71,11 @@ typedef struct igt_fb {unsigned int size;cairo_surface_t *cairo_surface;unsigned int domain; +unsigned int num_planes; +uint32_t offsets[4 ]; +unsigned int plane_bpp[4 ]; +unsigned int plane_width[4 ]; +unsigned int plane_height[4 ]; } igt_fb_t;/**
lib/ioctl_wrappers.c +9 -2
@@ -1659,10 +1659,10 @@ 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 *offsets,uint32_t flags,uint32_t *buf_id) {struct drm_mode_fb_cmd2 f; -int ret; +int ret, i;igt_require_fb_modifiers (fd);
@@ -1676,6 +1676,13 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, f.pitches[0 ] = stride; f.modifier[0 ] = modifier; +for (i =1 ; i <4 && offsets && offsets[i]; i++) { + f.handles[i] = handle; + f.pitches[i] = stride; + f.modifier[i] = modifier; + f.offsets[i] = offsets[i]; + } + ret =igt_ioctl (fd,DRM_IOCTL_MODE_ADDFB2 , &f); *buf_id = f.fb_id;
lib/ioctl_wrappers.h +1 -1
@@ -236,7 +236,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 *offsets,uint32_t flags,uint32_t *buf_id);/** * to_user_pointer:
tests/kms_draw_crc.c +1 -1
@@ -163,7 +163,7 @@ static bool format_is_supported(uint32_t format, uint64_t modifier) format, modifier, 0, NULL, &stride, NULL); ret =__kms_addfb (drm_fd, gem_handle,64 ,64 , - stride, format, modifier, + stride, format, modifier,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id);drmModeRmFB (drm_fd, fb_id);gem_close (drm_fd, gem_handle);
tests/kms_rotation_crc.c +3 -2
@@ -520,7 +520,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,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &data->fb.fb_id)); data->fb.width = w; data->fb.height = h;
@@ -601,7 +601,8 @@ 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,NULL , +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
@@ -723,7 +723,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 ,NULL ,LOCAL_DRM_MODE_FB_MODIFIERS , &fb_id[i]));igt_assert (fb_id[i]); }
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t] lib/fb: Add support for creating planar framebuffers, v3.
Quoted 9 lines · Maarten Lankhorst
Add support to create planar framebuffers, but don't add formats that support them yet. This first requires conversion to the RGB24 format.
Changes since v1:
- Don't crash inigt_create_bo_with_dimensions().
Changes since v2:
- Zero offsets for dumb fb too.
Quoted 386 lines
Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 76 +++++++++++++++++++++++++++++++++++---
----------
lib/igt_fb.h | 10 +++++++lib/ioctl_wrappers.c | 11 +++++-- lib/ioctl_wrappers.h | 2 +- tests/kms_draw_crc.c | 2 +- tests/kms_rotation_crc.c | 5 ++-- tests/prime_vgem.c | 2 +- 7 files changed, 81 insertions(+), 27 deletions(-)lib/igt_fb.c +0
-0@@ -158,14 +158,19 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, } }
+static unsignedplanar_width(struct format_desc_struct *format, unsigned width, int plane)lib/igt_fb.c +7
-0+{ +if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) +return (width +1 ) /2 ; + +return width; +} +static unsigned
planar_stride(struct format_desc_struct *format, unsigned width, int plane)
{
unsigned cpp = format->plane_bpp[plane] / 8;lib/igt_fb.c +1
-4-if (format->drm_id ==DRM_FORMAT_NV12 && plane ==1 ) -return (width +1 ) /2 * cpp; - -return width * cpp; +return planar_width (format, width, plane) * cpp;}
static unsignedplanar_height(struct format_desc_struct *format, unsigned height, int plane)lib/igt_fb.c +0
-0@@ -331,17 +336,25 @@ static int create_bo_for_fb(int fd, int width, int height, struct format_desc_struct *format,uint64_t tiling, unsigned size, unsigned stride,
unsigned*size_ret, unsigned*stride_ret,lib/igt_fb.c +1
-1- bool *is_dumb) + uint32_t *offsets, bool *is_dumb){
int bo;
igt_assert(format);lib/igt_fb.c +3
-0+if (offsets) +memset (offsets,0 ,4 *sizeof (*offsets)); +if (tiling || size || stride ||
format->planes> 1) { unsignedcalculated_size,calculated_stride;lib/igt_fb.c +0
-1- igt_calc_fb_size(fd, width, height, format->drm_id,tiling,
lib/igt_fb.c +0
-1- &calculated_size,
&calculated_stride);lib/igt_fb.c +2
-0+if (format->planes >1 ) + calc_fb_size_planar(fd, width, height,format, tiling,
lib/igt_fb.c +1
-0+ &calculated_size,
&calculated_stride, offsets);lib/igt_fb.c +2
-0+else + calc_fb_size_packed(fd, width, height,format, tiling,
lib/igt_fb.c +1
-0+ &calculated_size,
&calculated_stride);
+
if (stride == 0)
stride =calculated_stride; if (size == 0)lib/igt_fb.c +0
-0@@ -407,7 +420,7 @@ int igt_create_bo_with_dimensions(int fd, int width, int height,unsigned
*stride_ret, bool*is_dumb)
{
return create_bo_for_fb(fd, width, height,lookup_drm_format(format),lib/igt_fb.c +0
-1- modifier, 0, stride, size_ret,
stride_ret,is_dumb);lib/igt_fb.c +1
-0+ modifier, 0, stride, size_ret,
stride_ret, NULL,is_dumb);
}
/**lib/igt_fb.c +4
-0@@ -748,16 +761,20 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, unsigned bo_size, unsigned bo_stride) { +struct format_desc_struct *f =lookup_drm_format (format); uint32_t fb_id; +int i; + +igt_assert_f (f,"DRM format %08x not found\n" , format);
memset(fb, 0, sizeof(*fb));
igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%d)\n",
__func__, width, height, format, tiling,bo_size);lib/igt_fb.c +1
-2- fb->gem_handle = create_bo_for_fb(fd, width, height, - lookup_drm_format(format), + fb->gem_handle = create_bo_for_fb(fd, width, height, f,tiling,
bo_size,bo_stride,lib/igt_fb.c +0
-1- &fb->size, &fb->stride,
&fb->is_dumb);lib/igt_fb.c +2
-0+ &fb->size, &fb->stride, + fb->offsets, &fb-Quoted 1 line
is_dumb);
igt_assert(fb->gem_handle > 0);
igt_debug("%s(handle=%d, pitch=%d)\n",lib/igt_fb.c +0
-0@@ -766,22 +783,24 @@ igt_create_fb_with_bo_size(int fd, int width, int height,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,lib/igt_fb.c +1
-1- fb->stride, format, tiling, + fb->stride, format, tiling,
fb->offsets,
LOCAL_DRM_MODE_FB_MODIFIERS,&fb_id));
} else {
uint32_thandles[4];
uint32_tpitches[4];lib/igt_fb.c +0
-1-uint32_t offsets[4 ];
memset(handles, 0, sizeof(handles));memset(pitches, 0, sizeof(pitches));lib/igt_fb.c +0
-1-memset (offsets,0 ,sizeof (offsets));
handles[0] =fb->gem_handle;
pitches[0] =fb->stride;lib/igt_fb.c +4
-0+for (i =0 ; i < f->planes; i++) { + handles[i] = fb->gem_handle; + pitches[i] = fb->stride; + }
do_or_die(drmModeAddFB2(fd, width, height, format,lib/igt_fb.c +1
-1- handles, pitches, offsets, + handles, pitches, fb-Quoted 1 line
offsets,
&fb_id, 0)); }lib/igt_fb.c +6
-0@@ -791,6 +810,17 @@ igt_create_fb_with_bo_size(int fd, int width,int height, fb->drm_format = format; fb->fb_id = fb_id; fb->fd = fd; + fb->num_planes = f->planes ?:1 ; + fb->plane_bpp[0 ] = f->bpp; + fb->plane_height[0 ] = height; + fb->plane_width[0 ] = width; + +/* if f->planes is set, then plane_bpp is valid too so use that. */
lib/igt_fb.c +5
-0+for (i =0 ; i < f->planes; i++) { + fb->plane_bpp[i] = f->plane_bpp[i]; + fb->plane_height[i] =planar_height (f, height, i); + fb->plane_width[i] =planar_width (f, width, i); + }
returnfb_id;
}lib/igt_fb.c +0
-0@@ -1127,7 +1157,8 @@ static void destroy_cairo_surface__blit(void *arg)0, 0, /*
src_x,src_y*/fb->width,fb->height, igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +2
-1- fb->gem_handle, 0, + fb->gem_handle, + fb->offsets[0],fb->stride,
obj_tiling,
0, 0 /*dst_x,dst_y*/);lib/igt_fb.c +1
-0@@ -1143,6 +1174,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) struct fb_blit_upload *blit; cairo_format_t cairo_format; unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->tiling); +uint32_t offsets[4 ];
blit = malloc(sizeof(*blit));
igt_assert(blit);lib/igt_fb.c +0
-0@@ -1157,7 +1189,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)LOCAL_DRM_FORMAT_MOD_ NONE, 0,
0, &blit-Quoted 1 line
linear.size,
&blit->linear.stride,
lib/igt_fb.c +0
-1- &blit-Quoted 1 line
linear.is_dumb);
lib/igt_fb.c +1
-0+ offsets, &blit-Quoted 1 line
linear.is_dumb);
igt_assert(blit->linear.handle > 0);lib/igt_fb.c +0
-0@@ -1169,7 +1201,8 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_GTT, 0);
igt_blitter_fast_copy__raw(fd,lib/igt_fb.c +2
-1- fb->gem_handle, 0, + fb->gem_handle, + fb->offsets[0],fb->stride,
obj_tiling,
0, 0, /*src_x,src_y*/lib/igt_fb.c +0
-1@@ -1257,14 +1290,17 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) * @fd: open drm file descriptor * @fb: pointer to an #igt_fb structure * - * This function stores the contents of the supplied framebufferinto a cairo
- * surface and returns it.
+ * This function stores the contents of the supplied framebuffer's plane
+ * into a cairo surface and returns it.
*
* Returns:
* A pointer to a cairo surface with the contents of the framebuffer.
*/
cairo_surface_t *igt_get_cairo_surface(int fd, structigt_fb*fb) {lib/igt_fb.c +1
-0+/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */
lib/igt_fb.c +2
-0+igt_assert (fb->num_planes <2 ); +if (
fb->cairo_surface== NULL) {
if (fb->tiling==LOCAL_I915_FORMAT_MOD_Y_TILED||fb->tiling==LOCAL_I915_FORMAT_MOD_Yf_TILED)lib/igt_fb.h +10
-0@@ -50,6 +50,11 @@* @size: size in bytes of the underlying backing storage * @cairo_surface: optionally attached cairo drawing surface * @domain: current domain for cache flushing tracking on i915.ko +* @num_planes: Amount of planes on this fb. >1 for planar formats. +* @offsets: Offset for each plane in bytes. +* @plane_bpp: The bpp for each plane. +* @plane_width: The width for each plane. +* @plane_height: The height for each plane. * * Tracking structure for KMS framebuffer objects. */ @@ -66,6 +71,11 @@ typedef struct igt_fb { unsigned int size; cairo_surface_t *cairo_surface; unsigned int domain; +unsigned int num_planes; +uint32_t offsets[4 ]; +unsigned int plane_bpp[4 ]; +unsigned int plane_width[4 ]; +unsigned int plane_height[4 ]; } igt_fb_t;
/**lib/ioctl_wrappers.c +0
-0@@ -1659,10 +1659,10 @@ void igt_require_fb_modifiers(int fd)
int __kms_addfb(int fd,uint32_thandle,uint32_twidth,uint32_theight,
uint32_tstride,uint32_tpixel_format,uint64_tmodifier,lib/ioctl_wrappers.c +1
-1- uint32_t flags, uint32_t *buf_id) + uint32_t *offsets, uint32_t flags, uint32_t *buf_id){
structdrm_mode_fb_cmd2f;lib/ioctl_wrappers.c +1
-1-int ret; +int ret, i;
igt_require_fb_modifiers(fd);lib/ioctl_wrappers.c +0
-0@@ -1676,6 +1676,13 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height, f.pitches[0] = stride; f.modifier[0] = modifier;lib/ioctl_wrappers.c +7
-0+for (i =1 ; i <4 && offsets && offsets[i]; i++) { + f.handles[i] = handle; + f.pitches[i] = stride; + f.modifier[i] = modifier; + f.offsets[i] = offsets[i]; + } +ret =
igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f);
*buf_id= f.fb_id;lib/ioctl_wrappers.h +0
-0@@ -236,7 +236,7 @@ void igt_require_fb_modifiers(int fd);*/ int __kms_addfb(int fd,
uint32_thandle,uint32_twidth,uint32_theight,
uint32_tstride,uint32_tpixel_format,uint64_tmodifier,lib/ioctl_wrappers.h +1
-1- uint32_t flags, uint32_t *buf_id); + uint32_t *offsets, uint32_t flags, uint32_t
*buf_id);
/**
*to_user_pointer:tests/kms_draw_crc.c +1
-1@@ -163,7 +163,7 @@ static bool format_is_supported(uint32_t format, uint64_t modifier) format, modifier, 0, NULL, &stride, NULL); ret = __kms_addfb(drm_fd, gem_handle, 64, 64, - stride, format, modifier, + stride, format, modifier, NULL, LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id);
drmModeRmFB(drm_fd, fb_id);
gem_close(drm_fd, gem_handle);tests/kms_rotation_crc.c +0
-0@@ -520,7 +520,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,tests/kms_rotation_crc.c +1
-1- format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS, + format, tiling, NULL, LOCAL_DRM_MODE_FB_MODIFIERS,&data->fb.fb_id));
data->fb.width= w;
data->fb.height= h;tests/kms_rotation_crc.c +0
-0@@ -601,7 +601,8 @@ static void test_plane_rotation_exhaust_fences(data_t *data, }
ret = (__kms_addfb(fd,gem_handle, w, h, stride,tests/kms_rotation_crc.c +2
-1- format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS, + format, tiling, NULL, + LOCAL_DRM_MODE_FB_MODIFIERS,&data2[i].fb.fb_id));
if (ret) {
igt_warn("failed to create framebuffer\n");tests/prime_vgem.c +0
-0@@ -723,7 +723,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,tests/prime_vgem.c +0
-1- DRM_FORMAT_XRGB8888,
I915_TILING_NONE,tests/prime_vgem.c +1
-0+ DRM_FORMAT_XRGB8888,
I915_TILING_NONE, NULL,
LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id[i]));
igt_assert(fb_id[i]);
}
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 7/8 tests/kms_render: Copy all planes when copying fb
In reply to Maarten LankhorstThis is required to make the test pass when we start enabling planar formats in the future.
--- lib/intel_batchbuffer.c | 14 ++++++++------ lib/intel_batchbuffer.h | 4 ++-- tests/gem_concurrent_all.c | 4 ++-- tests/gem_read_read_speed.c | 4 ++-- tests/kms_render.c | 15 +++++++++------ 5 files changed, 23 insertions(+), 18 deletions(-)
lib/intel_batchbuffer.c +8 -6
@@ -310,10 +310,12 @@ intel_batchbuffer_data(struct intel_batchbuffer *batch,* intel_blt_copy: * @batch: batchbuffer object * @src_bo: source libdrm buffer object +* @src_delta: offset into the source bo, in bytes * @src_x1: source pixel x-coordination * @src_y1: source pixel y-coordination * @src_pitch: @src_bo's pitch in bytes * @dst_bo: destination libdrm buffer object +* @sdst_delta: offset into the source bo, in bytes * @dst_x1: destination pixel x-coordination * @dst_y1: destination pixel y-coordination * @dst_pitch: @dst_bo's pitch in bytes
@@ -326,8 +328,8 @@ intel_batchbuffer_data(struct intel_batchbuffer *batch,*/ void intel_blt_copy (struct intel_batchbuffer *batch, -drm_intel_bo *src_bo,int src_x1,int src_y1,int src_pitch, -drm_intel_bo *dst_bo,int dst_x1,int dst_y1,int dst_pitch, +drm_intel_bo *src_bo,uint32_t src_delta,int src_x1,int src_y1,int src_pitch, +drm_intel_bo *dst_bo,uint32_t dst_delta,int dst_x1,int dst_y1,int dst_pitch,int width,int height,int bpp) {const int gen = batch->gen;
@@ -387,10 +389,10 @@ intel_blt_copy(struct intel_batchbuffer *batch, dst_pitch);OUT_BATCH ((dst_y1 <<16 ) | dst_x1);/* dst x1,y1 */ OUT_BATCH (((dst_y1 + height) <<16 ) | (dst_x1 + width));/* dst x2,y2 */ -OUT_RELOC_FENCED (dst_bo,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER ,0 ); +OUT_RELOC_FENCED (dst_bo,I915_GEM_DOMAIN_RENDER ,I915_GEM_DOMAIN_RENDER , dst_delta);OUT_BATCH ((src_y1 <<16 ) | src_x1);/* src x1,y1 */ OUT_BATCH (src_pitch); -OUT_RELOC_FENCED (src_bo,I915_GEM_DOMAIN_RENDER ,0 ,0 ); +OUT_RELOC_FENCED (src_bo,I915_GEM_DOMAIN_RENDER ,0 , src_delta);ADVANCE_BATCH ();#define CMD_POLY_STIPPLE_OFFSET 0x7906
@@ -431,8 +433,8 @@ intel_copy_bo(struct intel_batchbuffer *batch,igt_assert (size %4096 ==0 );intel_blt_copy (batch, - src_bo,0 ,0 ,4096 , - dst_bo,0 ,0 ,4096 , + src_bo,0 ,0 ,0 ,4096 , + dst_bo,0 ,0 ,0 ,4096 ,4096 /4 , size/4096 ,32 ); }
lib/intel_batchbuffer.h +2 -2
@@ -181,8 +181,8 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,void intel_blt_copy (struct intel_batchbuffer *batch, -drm_intel_bo *src_bo,int src_x1,int src_y1,int src_pitch, -drm_intel_bo *dst_bo,int dst_x1,int dst_y1,int dst_pitch, +drm_intel_bo *src_bo,uint32_t src_delta,int src_x1,int src_y1,int src_pitch, +drm_intel_bo *dst_bo,uint32_t dst_delta,int dst_x1,int dst_y1,int dst_pitch,int width,int height,int bpp); void intel_copy_bo(struct intel_batchbuffer *batch, drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
tests/gem_concurrent_all.c +2 -2
@@ -874,8 +874,8 @@ static void render_copy_bo(struct buffers *b, drm_intel_bo *dst, drm_intel_bo *sstatic void blt_copy_bo (struct buffers *b,drm_intel_bo *dst,drm_intel_bo *src) {intel_blt_copy (b->batch, - src,0 ,0 ,4 *b->width, - dst,0 ,0 ,4 *b->width, + src,0 ,0 ,0 ,4 *b->width, + dst,0 ,0 ,0 ,4 *b->width, b->width, b->height,32 ); }
tests/gem_read_read_speed.c +2 -2
@@ -83,8 +83,8 @@ static drm_intel_bo *bcs_copy_bo(drm_intel_bo *dst, drm_intel_bo *src)drm_intel_bo_reference (bo);intel_blt_copy (batch, - src,0 ,0 ,4 *width, - dst,0 ,0 ,4 *width, + src,0 ,0 ,0 ,4 *width, + dst,0 ,0 ,0 ,4 *width, width, height,32 );return bo;
tests/kms_render.c +9 -6
@@ -64,7 +64,7 @@ static void gpu_blit(struct igt_fb *dst_fb, struct igt_fb *src_fb) {drm_intel_bo *dst_bo;drm_intel_bo *src_bo; -int bpp; +int i;static drm_intel_bufmgr *bufmgr;struct intel_batchbuffer *batch;uint32_t devid;
@@ -79,7 +79,7 @@ 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); + dst_bo =gem_handle_to_libdrm_bo (bufmgr, drm_fd,"destination" , dst_fb->gem_handle);igt_assert (dst_bo);
@@ -87,10 +87,13 @@ static void gpu_blit(struct igt_fb *dst_fb, struct igt_fb *src_fb) src_fb->gem_handle);igt_assert (src_bo); -intel_blt_copy (batch, - src_bo,0 ,0 , src_fb->width * bpp /8 , - dst_bo,0 ,0 , dst_fb->width * bpp /8 , - src_fb->width, src_fb->height, bpp); +for (i =0 ; i < src_fb->num_planes; i++) { +intel_blt_copy (batch, + src_bo, src_fb->offsets[i],0 ,0 , src_fb->stride, + dst_bo, dst_fb->offsets[i],0 ,0 , dst_fb->stride, + src_fb->plane_width[i], src_fb->plane_height[i], + src_fb->plane_bpp[i]); + }intel_batchbuffer_flush (batch);gem_quiescent_gpu (drm_fd);
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 7/8] tests/kms_render: Copy all planes when copying fb
Quoted 3 lines · Maarten Lankhorst
This is required to make the test pass when we start enabling planar formats in the future.
Quoted 172 lines
Signed-off-by Maarten Lankhorst <[email protected]>---
lib/intel_batchbuffer.c | 14 ++++++++------
lib/intel_batchbuffer.h | 4 ++--
tests/gem_concurrent_all.c | 4 ++--
tests/gem_read_read_speed.c | 4 ++--
tests/kms_render.c | 15 +++++++++------5 files changed, 23 insertions(+), 18 deletions(-)lib/intel_batchbuffer.c +2
-0@@ -310,10 +310,12 @@ intel_batchbuffer_data(struct intel_batchbuffer *batch, * intel_blt_copy: * @batch: batchbuffer object * @src_bo: source libdrm buffer object + * @src_delta: offset into the source bo, in bytes * @src_x1: source pixel x-coordination * @src_y1: source pixel y-coordination * @src_pitch: @src_bo's pitch in bytes * @dst_bo: destination libdrm buffer object + * @sdst_delta: offset into the source bo, in bytes * @dst_x1: destination pixel x-coordination * @dst_y1: destination pixel y-coordination* @dst_pitch: @dst_bo's pitch in bytes
lib/intel_batchbuffer.c +0
-0@@ -326,8 +328,8 @@ intel_batchbuffer_data(struct intel_batchbuffer*batch, */ void
intel_blt_copy(structintel_batchbuffer*batch,lib/intel_batchbuffer.c +0
-1- drm_intel_bo *src_bo, int src_x1, int src_y1, int
src_pitch,lib/intel_batchbuffer.c +0
-1- drm_intel_bo *dst_bo, int dst_x1, int dst_y1, int
dst_pitch,lib/intel_batchbuffer.c +1
-0+ drm_intel_bo *src_bo, uint32_t src_delta, int src_x1,int
src_y1, intsrc_pitch,lib/intel_batchbuffer.c +1
-0+ drm_intel_bo *dst_bo, uint32_t dst_delta, int dst_x1,int
dst_y1, intdst_pitch,
int width, int height, int bpp)
{
const int gen =batch->gen;lib/intel_batchbuffer.c +0
-0@@ -387,10 +389,10 @@ intel_blt_copy(struct intel_batchbuffer *batch, dst_pitch);
OUT_BATCH((dst_y1 << 16) | dst_x1); /* dst x1,y1 */OUT_BATCH(((dst_y1 + height) << 16) | (dst_x1 + width)); /* dst x2,y2 */lib/intel_batchbuffer.c +0
-1- OUT_RELOC_FENCED(dst_bo, I915_GEM_DOMAIN_RENDER,
I915_GEM_DOMAIN_RENDER, 0);lib/intel_batchbuffer.c +1
-0+ OUT_RELOC_FENCED(dst_bo, I915_GEM_DOMAIN_RENDER,
I915_GEM_DOMAIN_RENDER,dst_delta);OUT_BATCH((src_y1 << 16) | src_x1); /* src x1,y1 */OUT_BATCH(src_pitch);lib/intel_batchbuffer.c +1
-1-OUT_RELOC_FENCED (src_bo,I915_GEM_DOMAIN_RENDER ,0 ,0 ); + OUT_RELOC_FENCED(src_bo, I915_GEM_DOMAIN_RENDER, 0,
src_delta);
ADVANCE_BATCH();
#define CMD_POLY_STIPPLE_OFFSET 0x7906lib/intel_batchbuffer.c +0
-0@@ -431,8 +433,8 @@ intel_copy_bo(struct intel_batchbuffer *batch, igt_assert(size % 4096 == 0);
intel_blt_copy(batch,lib/intel_batchbuffer.c +2
-2- src_bo, 0, 0, 4096, - dst_bo, 0, 0, 4096, + src_bo, 0, 0, 0, 4096, + dst_bo, 0, 0, 0, 4096,4096/4, size/4096, 32);
}lib/intel_batchbuffer.h +0
-0@@ -181,8 +181,8 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
void
intel_blt_copy(structintel_batchbuffer*batch,lib/intel_batchbuffer.h +0
-1- drm_intel_bo *src_bo, int src_x1, int src_y1, int
src_pitch,lib/intel_batchbuffer.h +0
-1- drm_intel_bo *dst_bo, int dst_x1, int dst_y1, int
dst_pitch,lib/intel_batchbuffer.h +1
-0+ drm_intel_bo *src_bo, uint32_t src_delta, int src_x1,int
src_y1, intsrc_pitch,lib/intel_batchbuffer.h +1
-0+ drm_intel_bo *dst_bo, uint32_t dst_delta, int dst_x1,int
dst_y1, intdst_pitch,
int width, int height, int bpp);
void intel_copy_bo(structintel_batchbuffer*batch,drm_intel_bo*dst_bo,drm_intel_bo*src_bo,tests/gem_concurrent_all.c +0
-0@@ -874,8 +874,8 @@ static void render_copy_bo(struct buffers *b,
drm_intel_bo*dst,drm_intel_bo*s
static voidblt_copy_bo(struct buffers *b, drm_intel_bo *dst, drm_intel_bo *src)
{
intel_blt_copy(b->batch,tests/gem_concurrent_all.c +2
-2- src, 0, 0, 4*b->width, - dst, 0, 0, 4*b->width, + src, 0, 0, 0, 4*b->width, + dst, 0, 0, 0, 4*b->width,b->width,
b->height, 32);
}tests/gem_read_read_speed.c +0
-0@@ -83,8 +83,8 @@ static drm_intel_bo *bcs_copy_bo(drm_intel_bo *dst, drm_intel_bo *src) drm_intel_bo_reference(bo);
intel_blt_copy(batch,tests/gem_read_read_speed.c +2
-2- src, 0, 0, 4*width, - dst, 0, 0, 4*width, + src, 0, 0, 0, 4*width, + dst, 0, 0, 0, 4*width,width, height, 32);
return bo;tests/kms_render.c +1
-1@@ -64,7 +64,7 @@ static void gpu_blit(struct igt_fb *dst_fb, struct igt_fb *src_fb) { drm_intel_bo *dst_bo; drm_intel_bo *src_bo; -int bpp; +int i; static drm_intel_bufmgr *bufmgr; struct intel_batchbuffer *batch;
uint32_tdevid;tests/kms_render.c +0
-0@@ -79,7 +79,7 @@ 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);tests/kms_render.c +1
-1- bpp =igt_drm_format_to_bpp (src_fb->drm_format); +
dst_bo= gem_handle_to_libdrm_bo(bufmgr,drm_fd, "destination",
dst_fb->gem_handle);igt_assert(dst_bo);tests/kms_render.c +0
-0@@ -87,10 +87,13 @@ static void gpu_blit(struct igt_fb *dst_fb, struct igt_fb *src_fb) src_fb->gem_handle); igt_assert(src_bo);tests/kms_render.c +3
-4-intel_blt_copy (batch, - src_bo, 0, 0, src_fb->width * bpp / 8, - dst_bo, 0, 0, dst_fb->width * bpp / 8, - src_fb->width, src_fb->height, bpp); +for (i =0 ; i < src_fb->num_planes; i++) { + intel_blt_copy(batch, + src_bo, src_fb->offsets[i], 0, 0,
src_fb->stride,tests/kms_render.c +1
-0+ dst_bo, dst_fb->offsets[i], 0, 0,
dst_fb->stride,tests/kms_render.c +1
-0+ src_fb->plane_width[i], src_fb-Quoted 1 line
plane_height[i],
tests/kms_render.c +2
-0+ src_fb->plane_bpp[i]); + }
intel_batchbuffer_flush(batch);
gem_quiescent_gpu(drm_fd);
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 7/8] tests/kms_render: Copy all planes when copying fb
Quoted 6 lines · Mika Kahola
Quoted 3 lines · Maarten Lankhorst
This is required to make the test pass when we start enabling planar formats in the future.
Reviewed-by Mika Kahola <[email protected]>
Seems like the whole series have been merged but this patch. Any reason for it?
- Arek
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 7/8] tests/kms_render: Copy all planes when copying fb
Op 28-02-18 om 16:40 schreef Arkadiusz Hiler:
Quoted 9 lines · Mika Kahola
Quoted 5 lines · Maarten Lankhorst
Quoted 3 lines
This is required to make the test pass when we start enabling planar formats in the future.
Reviewed-by Mika Kahola <[email protected]>Seems like the whole series have been merged but this patch. Any reason for it?
- Arek
kms_render has been removed by another patch. :)
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 7/8] tests/kms_render: Copy all planes when copying fb
In reply to Arkadiusz HilerQuoted 11 lines · Arkadiusz Hiler
Quoted 6 lines · Mika Kahola
Quoted 3 lines · Maarten Lankhorst
This is required to make the test pass when we start enabling planar formats in the future.
Reviewed-by Mika Kahola <[email protected]>Seems like the whole series have been merged but this patch. Any reason for it?
- Arek
Ccing Maarten :-)
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 8/8 lib/igt_fb: Add support for NV12 format through conversion
In reply to Maarten LankhorstFor NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.709 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y:
Y Y Y Y UV UV Y Y Y Y
Some work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO.
When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising even further for me.
--- lib/igt_fb.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 318 insertions(+), 72 deletions(-)
lib/igt_fb.c +318 -72
@@ -70,6 +70,7 @@ static struct format_desc_struct {DF (XRGB8888 ,RGB24 ,32 ,24 ),DF (XRGB2101010 ,RGB30 ,32 ,30 ),DF (ARGB8888 ,ARGB32 ,32 ,32 ), + DF(NV12, RGB24, 32, -1, 2, {8, 16}), };#undef DF
@@ -363,14 +364,20 @@ static int create_bo_for_fb(int fd, int width, int height, *is_dumb = false;if (is_i915_device (fd)) { -uint32_t *ptr; +uint8_t *ptr; bo =gem_create (fd, size);gem_set_tiling (fd, bo,igt_fb_mod_to_tiling (tiling), stride);/* Ensure the framebuffer is preallocated */ - ptr =gem_mmap__gtt (fd, bo, size,PROT_READ ); -igt_assert (*ptr ==0 ); + ptr =gem_mmap__gtt (fd, bo, size,PROT_READ |PROT_WRITE ); +igt_assert (*(uint32_t *)ptr ==0 ); + +if (format->drm_id ==DRM_FORMAT_NV12 ) { +/* component formats have a different zero point */ +memset (ptr,16 , offsets[1 ]); +memset (ptr + offsets[1 ],0x80 , (height +1 )/2 * stride); + }gem_munmap (ptr, size);if (size_ret)
@@ -1126,103 +1133,117 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format) drm_format, igt_format_str(drm_format)); } +struct fb_blit_linear { +uint32_t handle; +unsigned size, stride; +uint8_t *map; +bool is_dumb; +uint32_t offsets[4 ]; +}; +struct fb_blit_upload {int fd;struct igt_fb *fb; -struct { -uint32_t handle; -unsigned size, stride; -uint8_t *map; -bool is_dumb; - } linear; +struct fb_blit_linear linear; }; -static void destroy_cairo_surface__blit (void *arg) +static void free_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); +int i; -gem_munmap (blit->linear.map, blit->linear.size); - fb->cairo_surface =NULL ; +gem_munmap (linear->map, linear->size); +gem_set_domain (fd, linear->handle, +I915_GEM_DOMAIN_GTT ,0 ); + +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + linear->handle, + linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); +gem_close (fd, linear->handle); +} -gem_set_domain (blit->fd, blit->linear.handle, -I915_GEM_DOMAIN_GTT ,0 ); +static void destroy_cairo_surface__blit (void *arg) +{ +struct fb_blit_upload *blit = arg; -igt_blitter_fast_copy__raw (blit->fd, - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (blit->fd, blit->linear.handle); -gem_close (blit->fd, blit->linear.handle); + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit->fd, blit->fb, &blit->linear);free (blit); } -static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +static void setup_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit; -cairo_format_t cairo_format;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -uint32_t offsets[4 ]; - - blit =malloc (sizeof (*blit)); -igt_assert (blit); +int i;/* * We create a linear BO that we'll map for the CPU to write to (using * cairo). This linear bo will be then blitted to its final * destination, tiling it at the same time. */ - blit->linear.handle =create_bo_for_fb (fd, fb->width, fb->height, + linear->handle =create_bo_for_fb (fd, fb->width, fb->height,lookup_drm_format (fb->drm_format),LOCAL_DRM_FORMAT_MOD_NONE ,0 , -0 , &blit->linear.size, - &blit->linear.stride, - offsets, &blit->linear.is_dumb); - -igt_assert (blit->linear.handle >0 ); +0 , &linear->size, + &linear->stride, + linear->offsets, &linear->is_dumb); - blit->fd = fd; - blit->fb = fb; +igt_assert (linear->handle >0 );/* Copy fb content to linear BO */ -gem_set_domain (fd, blit->linear.handle, +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_GTT ,0 ); -igt_blitter_fast_copy__raw (fd, - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (fd, blit->linear.handle); - -gem_set_domain (fd, blit->linear.handle, +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + linear->handle, linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); + +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU );/* Setup cairo context */ - blit->linear.map =gem_mmap__cpu (fd, - blit->linear.handle, -0 , - blit->linear.size, -PROT_READ |PROT_WRITE ); + linear->map =gem_mmap__cpu (fd, linear->handle, +0 , linear->size,PROT_READ |PROT_WRITE ); +} + +static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; +setup_linear_mapping (fd, fb, &blit->linear); cairo_format =drm_format_to_cairo (fb->drm_format); fb->cairo_surface =
@@ -1284,6 +1305,232 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); } +struct fb_convert_blit_upload { +int fd; +struct igt_fb *fb; + +struct { +uint8_t *map; +unsigned stride, size; + } rgb24; + +struct fb_blit_linear linear; +}; + +static uint8_t clamprgb (float val) { +if (val <0 ) +return 0 ; +if (val >255 ) +return 255 ; + +return (uint8_t )val; +} + +static void convert_nv12_to_rgb24 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +const uint8_t *y, *uv; +uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->linear.stride; +uint8_t *buf =malloc (blit->linear.size); + +/* +* Reading from the BO is awfully slow because of lack of read caching, +* it's faster to copy the whole BO to a temporary buffer and convert +* from there. +*/ +memcpy (buf, blit->linear.map, blit->linear.size); + y = &buf[blit->linear.offsets[0 ]]; + uv = &buf[blit->linear.offsets[1 ]]; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, y1, cb, cr; +/* Convert 1x2 pixel blocks */ + + y0 =1.164f * (y[j] -16.f ); + y1 =1.164f * (y[j + planar_stride] -16.f ); + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + r_ =0.000f * cb +1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ =2.112f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +2 + rgb24_stride] =clamprgb (y1 + r_); + + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 +1 + rgb24_stride] =clamprgb (y1 + g_); + + rgb24[j *4 ] =clamprgb (y0 + b_); + rgb24[j *4 + rgb24_stride] =clamprgb (y1 + b_); + } + + rgb24 +=2 * rgb24_stride; + y +=2 * planar_stride; + uv += planar_stride; + } + +if (fb->height &1 ) { +/* Convert last row */ +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, cb, cr; +/* Convert single pixel */ + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + y0 =1.164f * (y[j] -16.f ); + r_ =0.000f * cb +1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ =2.112f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 ] =clamprgb (y0 + b_); + } + } + +free (buf); +} + +static void convert_rgb24_to_nv12 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; +uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +const uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride; +unsigned planar_stride = blit->linear.stride; + +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +for (i =0 ; i < fb->plane_height[0 ]; i++) { +/* Use limited color range BT.709 */ + +for (j =0 ; j < fb->plane_width[0 ]; j++) { +float yf =0.183f * rgb24[j *4 +2 ] + +0.614f * rgb24[j *4 +1 ] + +0.062f * rgb24[j *4 ] +16 ; + + y[j] = (uint8_t )yf; + } + + rgb24 += rgb24_stride; + y += planar_stride; + } + + rgb24 = blit->rgb24.map; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +/* +* Pixel center for Cb'Cr' is between the left top and +* bottom pixel in a 2x2 block, so take the average. +*/ +float uf =-0.101f /2 * rgb24[j *8 +2 ] + +-0.101f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.339f /2 * rgb24[j *8 +1 ] + +-0.339f /2 * rgb24[j *8 +1 + rgb24_stride] + +0.439f /2 * rgb24[j *8 ] + +0.439f /2 * rgb24[j *8 + rgb24_stride] +128 ; +float vf =0.439f /2 * rgb24[j *8 +2 ] + +0.439f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.339f /2 * rgb24[j *8 +1 ] + +-0.339f /2 * rgb24[j *8 +1 + rgb24_stride] + +-0.040f /2 * rgb24[j *8 ] + +-0.040f /2 * rgb24[j *8 + rgb24_stride] +128 ; + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + + rgb24 +=2 * rgb24_stride; + uv += planar_stride; + } + +/* Last row cannot be interpolated between 2 pixels, take the single value */ +if (i < fb->plane_height[1 ]) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +float uf =-0.101f * rgb24[j *8 +2 ] + +-0.339f * rgb24[j *8 +1 ] + +0.439f * rgb24[j *8 ] +128 ; +float vf =0.439f * rgb24[j *8 +2 ] + +-0.339f * rgb24[j *8 +1 ] + +-0.040f * rgb24[j *8 ] +128 ; + + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + } +} + +static void destroy_cairo_surface__convert (void *arg) +{ +struct fb_convert_blit_upload *blit = arg; +struct igt_fb *fb = blit->fb; + +/* Convert back to planar! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +convert_rgb24_to_nv12 (fb, blit); + +munmap (blit->rgb24.map, blit->rgb24.size); + +if (blit->linear.handle) +free_linear_mapping (blit->fd, blit->fb, &blit->linear); +else +gem_munmap (blit->linear.map, fb->size); + +free (blit); + + fb->cairo_surface =NULL ; +} + +static void create_cairo_surface__convert (int fd,struct igt_fb *fb) +{ +struct fb_convert_blit_upload *blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; + blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); + blit->rgb24.size =ALIGN (blit->rgb24.stride * fb->height,sysconf (_SC_PAGESIZE)); + blit->rgb24.map =mmap (NULL , blit->rgb24.size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 ); +igt_assert (blit->rgb24.map !=MAP_FAILED ); + +if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { +setup_linear_mapping (fd, fb, &blit->linear); + }else { + blit->linear.handle =0 ; + blit->linear.map =gem_mmap__gtt (fd, fb->gem_handle, fb->size, +PROT_READ |PROT_WRITE ); +igt_assert (blit->linear.map); + blit->linear.stride = fb->stride; + blit->linear.size = fb->size; +memcpy (blit->linear.offsets, fb->offsets,sizeof (fb->offsets)); + } + +/* Convert to linear! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); +convert_nv12_to_rgb24 (fb, blit); + + fb->cairo_surface = +cairo_image_surface_create_for_data (blit->rgb24.map, +CAIRO_FORMAT_RGB24 , + fb->width, fb->height, + blit->rgb24.stride); + +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t *)create_cairo_surface__convert, + blit, destroy_cairo_surface__convert); +} +/** * igt_get_cairo_surface: * @fd: open drm file descriptor
@@ -1297,11 +1544,10 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)*/ cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb) { -/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */ -igt_assert (fb->num_planes <2 ); -if (fb->cairo_surface ==NULL ) { -if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || +if (fb->num_planes >1 ) +create_cairo_surface__convert (fd, fb); +else if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)create_cairo_surface__blit (fd, fb);else
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 8/8] lib/igt_fb: Add support for NV12 format through conversion
Quoted 280 lines · Maarten Lankhorst
For NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.709 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y:
Y Y Y Y
UV UV
Y Y Y YSome work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO.
When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising
even further for me.Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++-
----------1 file changed, 318 insertions(+), 72 deletions(-)lib/igt_fb.c +1
-0@@ -70,6 +70,7 @@ static struct format_desc_struct { DF(XRGB8888, RGB24, 32, 24), DF(XRGB2101010, RGB30, 32, 30), DF(ARGB8888, ARGB32, 32, 32), + DF(NV12, RGB24, 32, -1, 2, {8, 16}), }; #undef DFlib/igt_fb.c +0
-0@@ -363,14 +364,20 @@ static int create_bo_for_fb(int fd, int width,int height, *is_dumb = false;
if (is_i915_device(fd)) {lib/igt_fb.c +1
-1-uint32_t *ptr; +uint8_t *ptr;
bo =gem_create(fd, size);gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
/* Ensure the framebuffer is preallocated */lib/igt_fb.c +0
-1- ptr = gem_mmap__gtt(fd, bo, size,
PROT_READ);lib/igt_fb.c +1
-1-igt_assert (*ptr ==0 ); + ptr = gem_mmap__gtt(fd, bo, size, PROT_READ|
PROT_WRITE);lib/igt_fb.c +4
-0+igt_assert (*(uint32_t *)ptr ==0 ); + +if (format->drm_id ==DRM_FORMAT_NV12 ) { +/* component formats have a different zero point */
lib/igt_fb.c +2
-0+memset (ptr,16 , offsets[1 ]); + memset(ptr + offsets[1], 0x80,(height + 1)/2 * stride);
lib/igt_fb.c +1
-0+ }
gem_munmap(ptr, size);
if (size_ret)lib/igt_fb.c +0
-0@@ -1126,103 +1133,117 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format) drm_format, igt_format_str(drm_format)); }lib/igt_fb.c +8
-0+struct fb_blit_linear { +uint32_t handle; +unsigned size, stride; +uint8_t *map; +bool is_dumb; +uint32_t offsets[4 ]; +}; +struct
fb_blit_upload{
int fd;
structigt_fb*fb;lib/igt_fb.c +1
-6-struct { -uint32_t handle; -unsigned size, stride; -uint8_t *map; -bool is_dumb; - } linear; +struct fb_blit_linear linear;};
lib/igt_fb.c +1
-1-static void destroy_cairo_surface__blit (void *arg) +static void free_linear_mapping(int fd, struct igt_fb *fb, struct
fb_blit_linear*linear)
{lib/igt_fb.c +0
-2-struct fb_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb;unsigned int
obj_tiling=igt_fb_mod_to_tiling(fb->tiling);lib/igt_fb.c +1
-0+int i;lib/igt_fb.c +12
-2-gem_munmap (blit->linear.map, blit->linear.size); - fb->cairo_surface =NULL ; +gem_munmap (linear->map, linear->size); +gem_set_domain (fd, linear->handle, + I915_GEM_DOMAIN_GTT, 0); + +for (i =0 ; i < fb->num_planes; i++) + igt_blitter_fast_copy__raw(fd, + linear->handle, + linear->offsets[i], + linear->stride, + I915_TILING_NONE, + 0, 0, /* src_x, src_y */ + fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c +10
-0+ fb->plane_bpp[i], + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, + 0, 0 /* dst_x, dst_y */); + +gem_sync (fd, linear->handle); +gem_close (fd, linear->handle); +}lib/igt_fb.c +3
-2-gem_set_domain (blit->fd, blit->linear.handle, -I915_GEM_DOMAIN_GTT ,0 ); +static void destroy_cairo_surface__blit (void *arg) +{ +struct fb_blit_upload *blit = arg;lib/igt_fb.c +0
-7- igt_blitter_fast_copy__raw(blit->fd, - blit->linear.handle, 0, - blit->linear.stride, - I915_TILING_NONE, - 0, 0, /* src_x, src_y */ - fb->width, fb->height, - igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +3
-8- fb->gem_handle, - fb->offsets[0], - fb->stride, - obj_tiling, - 0, 0 /* dst_x, dst_y */); - -gem_sync (blit->fd, blit->linear.handle); -gem_close (blit->fd, blit->linear.handle); + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit->fd, blit->fb, &blit->linear);
free(blit);
}lib/igt_fb.c +1
-1-static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +static void setup_linear_mapping(int fd, struct igt_fb *fb, struct
fb_blit_linear*linear)
{lib/igt_fb.c +0
-2-struct fb_blit_upload *blit; -cairo_format_t cairo_format;unsigned int
obj_tiling=igt_fb_mod_to_tiling(fb->tiling);lib/igt_fb.c +1
-4-uint32_t offsets[4 ]; - - blit =malloc (sizeof (*blit)); -igt_assert (blit); +int i;
/*
* We create a linear BO that we'll map for the CPU to write to (using
* cairo). This linear bo will be then blitted to its final
* destination, tiling it at the same time.
*/lib/igt_fb.c +0
-1- blit->linear.handle = create_bo_for_fb(fd, fb->width, fb-Quoted 1 line
height,
lib/igt_fb.c +1
-0+ linear->handle = create_bo_for_fb(fd, fb->width, fb->height,lookup_drm_format(fb-
Quoted 1 line
drm_format),LOCAL_DRM_FORMAT_MOD_ NONE, 0,
lib/igt_fb.c +0
-1- 0, &blit-Quoted 1 line
linear.size,
lib/igt_fb.c +0
-2- &blit->linear.stride, - offsets, &blit-Quoted 1 line
linear.is_dumb);
lib/igt_fb.c +3
-2- -igt_assert (blit->linear.handle >0 ); + 0, &linear->size, + &linear->stride, + linear->offsets,
&linear->is_dumb);lib/igt_fb.c +1
-2- blit->fd = fd; - blit->fb = fb; +igt_assert (linear->handle >0 );
/* Copy fb content to linear BO */lib/igt_fb.c +1
-1- gem_set_domain(fd, blit->linear.handle, + gem_set_domain(fd, linear->handle,
I915_GEM_DOMAIN_GTT, 0);lib/igt_fb.c +0
-8- igt_blitter_fast_copy__raw(fd, - fb->gem_handle, - fb->offsets[0], - fb->stride, - obj_tiling, - 0, 0, /* src_x, src_y */ - fb->width, fb->height, - igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +8
-8- blit->linear.handle, 0, - blit->linear.stride, - I915_TILING_NONE, - 0, 0 /* dst_x, dst_y */); - -gem_sync (fd, blit->linear.handle); - - gem_set_domain(fd, blit->linear.handle, +for (i =0 ; i < fb->num_planes; i++) + igt_blitter_fast_copy__raw(fd, + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, + 0, 0, /* src_x, src_y */ + fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c +2
-0+ fb->plane_bpp[i], + linear->handle, linear-Quoted 1 line
offsets[i],
lib/igt_fb.c +7
-0+ linear->stride, + I915_TILING_NONE, + 0, 0 /* dst_x, dst_y */); + +gem_sync (fd, linear->handle); + + gem_set_domain(fd, linear->handle,I915_GEM_DOMAIN_CPU,
I915_GEM_DOMAIN_CPU);
/* Setup cairo context */lib/igt_fb.c +2
-5- blit->linear.map =gem_mmap__cpu (fd, - blit->linear.handle, - 0, - blit->linear.size, - PROT_READ | PROT_WRITE); + linear->map = gem_mmap__cpu(fd, linear->handle, + 0, linear->size, PROT_READ |
PROT_WRITE);lib/igt_fb.c +13
-0+} + +static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; +setup_linear_mapping (fd, fb, &blit->linear);
cairo_format=drm_format_to_cairo(fb->drm_format);fb->cairo_surface=lib/igt_fb.c +0
-0@@ -1284,6 +1305,232 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); }lib/igt_fb.c +9
-0+struct fb_convert_blit_upload { +int fd; +struct igt_fb *fb; + +struct { +uint8_t *map; +unsigned stride, size; + } rgb24; +
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1326
Quoted 10 lines
lib/igt_fb.c +10
-0+struct fb_blit_linear linear; +}; + +static uint8_t clamprgb (float val) { +if (val <0 ) +return 0 ; +if (val >255 ) +return 255 ; + +return (uint8_t )val;
I'm thinking of this rounding issue. Should we use rounding to the nearest integer here, instead of floor? Does the way we do rounding have an effect on test results if we first grab the reference CRC and then run a test in NV12 format?
Quoted 60 lines
lib/igt_fb.c +3
-0+} + +static void convert_nv12_to_rgb24(struct igt_fb *fb, struct
fb_convert_blit_upload*blit)lib/igt_fb.c +5
-0+{ +int i, j; +const uint8_t *y, *uv; +uint8_t *rgb24 = blit->rgb24.map; + unsigned rgb24_stride = blit->rgb24.stride, planar_stride =
blit->linear.stride;lib/igt_fb.c +4
-0+uint8_t *buf =malloc (blit->linear.size); + +/* +* Reading from the BO is awfully slow because of lack of read caching,
lib/igt_fb.c +1
-0+ * it's faster to copy the whole BO to a temporary bufferand convert
lib/igt_fb.c +23
-0+* from there. +*/ +memcpy (buf, blit->linear.map, blit->linear.size); + y = &buf[blit->linear.offsets[0 ]]; + uv = &buf[blit->linear.offsets[1 ]]; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, y1, cb, cr; +/* Convert 1x2 pixel blocks */ + + y0 =1.164f * (y[j] -16.f ); + y1 =1.164f * (y[j + planar_stride] -16.f ); + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + r_ = 0.000f * cb + 1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ = 2.112f * cb + 0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j * 4 + 2 + rgb24_stride] =
clamprgb(y1 + r_);lib/igt_fb.c +3
-0+ + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j * 4 + 1 + rgb24_stride] =
clamprgb(y1 + g_);lib/igt_fb.c +3
-0+ + rgb24[j *4 ] =clamprgb (y0 + b_); + rgb24[j * 4 + rgb24_stride] = clamprgb(y1 +b_);
lib/igt_fb.c +11
-0+ } + + rgb24 +=2 * rgb24_stride; + y +=2 * planar_stride; + uv += planar_stride; + } + +if (fb->height &1 ) { +/* Convert last row */ +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, cb, cr;
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1389
Quoted 10 lines
lib/igt_fb.c +10
-0+/* Convert single pixel */ + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + y0 =1.164f * (y[j] -16.f ); + r_ = 0.000f * cb + 1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ = 2.112f * cb + 0.000f * cr; +
Do you have a reference for these conversion coefficients? According to https://www.fourcc.org/fccyvrgb.php there are a few opinions how this conversion should be handled?
Quoted 22 lines
lib/igt_fb.c +10
-0+ rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 ] =clamprgb (y0 + b_); + } + } + +free (buf); +} + +static void convert_rgb24_to_nv12(struct igt_fb *fb, struct
fb_convert_blit_upload*blit)lib/igt_fb.c +10
-0+{ +int i, j; +uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; +uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +const uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride; +unsigned planar_stride = blit->linear.stride; + + igt_assert_f(fb->drm_format == DRM_FORMAT_NV12, + "Conversion not implemented for !NV12 planarformats\n");
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1419
Quoted 10 lines
lib/igt_fb.c +10
-0+ +for (i =0 ; i < fb->plane_height[0 ]; i++) { +/* Use limited color range BT.709 */ + +for (j =0 ; j < fb->plane_width[0 ]; j++) { +float yf =0.183f * rgb24[j *4 +2 ] + + 0.614f * rgb24[j * 4 + 1] + + 0.062f * rgb24[j * 4] + 16; + + y[j] = (uint8_t )yf;
We could use clamprgb() here too. Just in case.
Quoted 35 lines
lib/igt_fb.c +12
-0+ } + + rgb24 += rgb24_stride; + y += planar_stride; + } + + rgb24 = blit->rgb24.map; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +/* +* Pixel center for Cb'Cr' is between the left top and
lib/igt_fb.c +1
-0+ * bottom pixel in a 2x2 block, so take theaverage.
lib/igt_fb.c +3
-0+*/ +float uf =-0.101f /2 * rgb24[j *8 +2 ] + + -0.101f/2 * rgb24[j * 8 + 2 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.339f/2 * rgb24[j * 8 + 1] + + -0.339f/2 * rgb24[j * 8 + 1 +
rgb24_stride] +lib/igt_fb.c +2
-0+ 0.439f/2 * rgb24[j * 8] + + 0.439f/2 * rgb24[j * 8 +
rgb24_stride] + 128;lib/igt_fb.c +2
-0+ float vf = 0.439f/2 * rgb24[j * 8 + 2] + + 0.439f/2 * rgb24[j * 8 + 2 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.339f/2 * rgb24[j * 8 + 1] + + -0.339f/2 * rgb24[j * 8 + 1 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.040f/2 * rgb24[j * 8] + + -0.040f/2 * rgb24[j * 8 +
rgb24_stride] + 128;
lib/igt_fb.c
Quoted 2 lines
lib/igt_fb.c +2
-0+ uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf;
Maybe add rounding & clamping here too?
Quoted 10 lines
lib/igt_fb.c +7
-0+ } + + rgb24 +=2 * rgb24_stride; + uv += planar_stride; + } + +/* Last row cannot be interpolated between 2 pixels, take the single value */
lib/igt_fb.c +1
-0+if (i < fb->plane_height[1 ]) {
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1465
Quoted 10 lines
lib/igt_fb.c +10
-0+for (j =0 ; j < fb->plane_width[1 ]; j++) { +float uf =-0.101f * rgb24[j *8 +2 ] + + -0.339f * rgb24[j * 8 + 1] + + 0.439f * rgb24[j * 8] + 128; + float vf = 0.439f * rgb24[j * 8 + 2] + + -0.339f * rgb24[j * 8 + 1] + + -0.040f * rgb24[j * 8] + 128; + + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf;
rounding & clamping?
Quoted 102 lines
lib/igt_fb.c +12
-0+ } + } +} + +static void destroy_cairo_surface__convert (void *arg) +{ +struct fb_convert_blit_upload *blit = arg; +struct igt_fb *fb = blit->fb; + +/* Convert back to planar! */ + igt_assert_f(fb->drm_format == DRM_FORMAT_NV12, + "Conversion not implemented for !NV12 planarformats\n");
lib/igt_fb.c +7
-0+ +convert_rgb24_to_nv12 (fb, blit); + +munmap (blit->rgb24.map, blit->rgb24.size); + +if (blit->linear.handle) + free_linear_mapping(blit->fd, blit->fb, &blit-Quoted 1 line
linear);
lib/igt_fb.c +17
-0+else +gem_munmap (blit->linear.map, fb->size); + +free (blit); + + fb->cairo_surface =NULL ; +} + +static void create_cairo_surface__convert (int fd,struct igt_fb *fb) +{ +struct fb_convert_blit_upload *blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; + blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); + blit->rgb24.size = ALIGN(blit->rgb24.stride * fb->height,
sysconf(_SC_PAGESIZE));lib/igt_fb.c +1
-0+ blit->rgb24.map = mmap(NULL, blit->rgb24.size, PROT_READ |
PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);lib/igt_fb.c +8
-0+igt_assert (blit->rgb24.map !=MAP_FAILED ); + +if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { +setup_linear_mapping (fd, fb, &blit->linear); + }else { + blit->linear.handle =0 ; + blit->linear.map = gem_mmap__gtt(fd, fb->gem_handle,
fb->size,lib/igt_fb.c +1
-0+ PROT_READ |
PROT_WRITE);lib/igt_fb.c +4
-0+igt_assert (blit->linear.map); + blit->linear.stride = fb->stride; + blit->linear.size = fb->size; + memcpy(blit->linear.offsets, fb->offsets, sizeof(fb-Quoted 1 line
offsets));
lib/igt_fb.c +5
-0+ } + +/* Convert to linear! */ + igt_assert_f(fb->drm_format == DRM_FORMAT_NV12, + "Conversion not implemented for !NV12 planarformats\n");
lib/igt_fb.c +5
-0+convert_nv12_to_rgb24 (fb, blit); + + fb->cairo_surface = +cairo_image_surface_create_for_data (blit->rgb24.map, + CAIRO_FORMAT_RGB24,
lib/igt_fb.c +1
-0+ fb->width, fb-Quoted 1 line
height,
lib/igt_fb.c +1
-0+ blit-Quoted 1 line
rgb24.stride);
lib/igt_fb.c +3
-0+ +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t*)create_cairo_surface__convert,
lib/igt_fb.c +1
-0+ blit,
destroy_cairo_surface__convert);lib/igt_fb.c +2
-0+} +/**
*igt_get_cairo_surface:
* @fd: open drm file descriptorlib/igt_fb.c +0
-1@@ -1297,11 +1544,10 @@ static void create_cairo_surface__gtt(int fd,struct igt_fb *fb) */ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb) { -/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */
lib/igt_fb.c +0
-2-igt_assert (fb->num_planes <2 ); -if (
fb->cairo_surface== NULL) {lib/igt_fb.c +3
-1- if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED || +if (fb->num_planes >1 ) +create_cairo_surface__convert (fd, fb); + else if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED||
fb->tiling ==LOCAL_I915_FORMAT_MOD_Yf_TILED)create_cairo_surface__blit(fd, fb); else
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 8/8] lib/igt_fb: Add support for NV12 format through conversion
Quoted 361 lines · Mika Kahola
Quoted 280 lines · Maarten Lankhorst
For NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.709 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y:
Y Y Y Y
UV UV
Y Y Y YSome work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO.
When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising
even further for me.Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++-
----------1 file changed, 318 insertions(+), 72 deletions(-)lib/igt_fb.c +1
-0@@ -70,6 +70,7 @@ static struct format_desc_struct { DF(XRGB8888, RGB24, 32, 24), DF(XRGB2101010, RGB30, 32, 30), DF(ARGB8888, ARGB32, 32, 32), + DF(NV12, RGB24, 32, -1, 2, {8, 16}), }; #undef DFlib/igt_fb.c +0
-0@@ -363,14 +364,20 @@ static int create_bo_for_fb(int fd, int width,int height, *is_dumb = false;
if (is_i915_device(fd)) {lib/igt_fb.c +1
-1-uint32_t *ptr; +uint8_t *ptr;
bo =gem_create(fd, size);gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
/* Ensure the framebuffer is preallocated */lib/igt_fb.c +0
-1- ptr = gem_mmap__gtt(fd, bo, size,
PROT_READ);lib/igt_fb.c +1
-1-igt_assert (*ptr ==0 ); + ptr = gem_mmap__gtt(fd, bo, size, PROT_READ|
PROT_WRITE);lib/igt_fb.c +4
-0+igt_assert (*(uint32_t *)ptr ==0 ); + +if (format->drm_id ==DRM_FORMAT_NV12 ) { +/* component formats have a different zero point */
lib/igt_fb.c +2
-0+memset (ptr,16 , offsets[1 ]); + memset(ptr + offsets[1], 0x80,(height + 1)/2 * stride);
lib/igt_fb.c +1
-0+ }
gem_munmap(ptr, size);
if (size_ret)lib/igt_fb.c +0
-0@@ -1126,103 +1133,117 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format) drm_format, igt_format_str(drm_format)); }lib/igt_fb.c +8
-0+struct fb_blit_linear { +uint32_t handle; +unsigned size, stride; +uint8_t *map; +bool is_dumb; +uint32_t offsets[4 ]; +}; +struct
fb_blit_upload{
int fd;
structigt_fb*fb;lib/igt_fb.c +1
-6-struct { -uint32_t handle; -unsigned size, stride; -uint8_t *map; -bool is_dumb; - } linear; +struct fb_blit_linear linear;};
lib/igt_fb.c +1
-1-static void destroy_cairo_surface__blit (void *arg) +static void free_linear_mapping(int fd, struct igt_fb *fb, struct
fb_blit_linear*linear)
{lib/igt_fb.c +0
-2-struct fb_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb;unsigned int
obj_tiling=igt_fb_mod_to_tiling(fb->tiling);lib/igt_fb.c +1
-0+int i;lib/igt_fb.c +12
-2-gem_munmap (blit->linear.map, blit->linear.size); - fb->cairo_surface =NULL ; +gem_munmap (linear->map, linear->size); +gem_set_domain (fd, linear->handle, + I915_GEM_DOMAIN_GTT, 0); + +for (i =0 ; i < fb->num_planes; i++) + igt_blitter_fast_copy__raw(fd, + linear->handle, + linear->offsets[i], + linear->stride, + I915_TILING_NONE, + 0, 0, /* src_x, src_y */ + fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c +10
-0+ fb->plane_bpp[i], + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, + 0, 0 /* dst_x, dst_y */); + +gem_sync (fd, linear->handle); +gem_close (fd, linear->handle); +}lib/igt_fb.c +3
-2-gem_set_domain (blit->fd, blit->linear.handle, -I915_GEM_DOMAIN_GTT ,0 ); +static void destroy_cairo_surface__blit (void *arg) +{ +struct fb_blit_upload *blit = arg;lib/igt_fb.c +0
-7- igt_blitter_fast_copy__raw(blit->fd, - blit->linear.handle, 0, - blit->linear.stride, - I915_TILING_NONE, - 0, 0, /* src_x, src_y */ - fb->width, fb->height, - igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +3
-8- fb->gem_handle, - fb->offsets[0], - fb->stride, - obj_tiling, - 0, 0 /* dst_x, dst_y */); - -gem_sync (blit->fd, blit->linear.handle); -gem_close (blit->fd, blit->linear.handle); + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit->fd, blit->fb, &blit->linear);
free(blit);
}lib/igt_fb.c +1
-1-static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +static void setup_linear_mapping(int fd, struct igt_fb *fb, struct
fb_blit_linear*linear)
{lib/igt_fb.c +0
-2-struct fb_blit_upload *blit; -cairo_format_t cairo_format;unsigned int
obj_tiling=igt_fb_mod_to_tiling(fb->tiling);lib/igt_fb.c +1
-4-uint32_t offsets[4 ]; - - blit =malloc (sizeof (*blit)); -igt_assert (blit); +int i;
/*
* We create a linear BO that we'll map for the CPU to write to (using
* cairo). This linear bo will be then blitted to its final
* destination, tiling it at the same time.
*/lib/igt_fb.c +0
-1- blit->linear.handle = create_bo_for_fb(fd, fb->width, fb-Quoted 1 line
height,
lib/igt_fb.c +1
-0+ linear->handle = create_bo_for_fb(fd, fb->width, fb->height,lookup_drm_format(fb-
Quoted 1 line
drm_format),LOCAL_DRM_FORMAT_MOD_ NONE, 0,
lib/igt_fb.c +0
-1- 0, &blit-Quoted 1 line
linear.size,
lib/igt_fb.c +0
-2- &blit->linear.stride, - offsets, &blit-Quoted 1 line
linear.is_dumb);
lib/igt_fb.c +3
-2- -igt_assert (blit->linear.handle >0 ); + 0, &linear->size, + &linear->stride, + linear->offsets,
&linear->is_dumb);lib/igt_fb.c +1
-2- blit->fd = fd; - blit->fb = fb; +igt_assert (linear->handle >0 );
/* Copy fb content to linear BO */lib/igt_fb.c +1
-1- gem_set_domain(fd, blit->linear.handle, + gem_set_domain(fd, linear->handle,
I915_GEM_DOMAIN_GTT, 0);lib/igt_fb.c +0
-8- igt_blitter_fast_copy__raw(fd, - fb->gem_handle, - fb->offsets[0], - fb->stride, - obj_tiling, - 0, 0, /* src_x, src_y */ - fb->width, fb->height, - igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +8
-8- blit->linear.handle, 0, - blit->linear.stride, - I915_TILING_NONE, - 0, 0 /* dst_x, dst_y */); - -gem_sync (fd, blit->linear.handle); - - gem_set_domain(fd, blit->linear.handle, +for (i =0 ; i < fb->num_planes; i++) + igt_blitter_fast_copy__raw(fd, + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, + 0, 0, /* src_x, src_y */ + fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c +2
-0+ fb->plane_bpp[i], + linear->handle, linear-Quoted 1 line
offsets[i],
lib/igt_fb.c +7
-0+ linear->stride, + I915_TILING_NONE, + 0, 0 /* dst_x, dst_y */); + +gem_sync (fd, linear->handle); + + gem_set_domain(fd, linear->handle,I915_GEM_DOMAIN_CPU,
I915_GEM_DOMAIN_CPU);
/* Setup cairo context */lib/igt_fb.c +2
-5- blit->linear.map =gem_mmap__cpu (fd, - blit->linear.handle, - 0, - blit->linear.size, - PROT_READ | PROT_WRITE); + linear->map = gem_mmap__cpu(fd, linear->handle, + 0, linear->size, PROT_READ |
PROT_WRITE);lib/igt_fb.c +13
-0+} + +static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; +setup_linear_mapping (fd, fb, &blit->linear);
cairo_format=drm_format_to_cairo(fb->drm_format);fb->cairo_surface=lib/igt_fb.c +0
-0@@ -1284,6 +1305,232 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); }lib/igt_fb.c +9
-0+struct fb_convert_blit_upload { +int fd; +struct igt_fb *fb; + +struct { +uint8_t *map; +unsigned stride, size; + } rgb24; +lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1326
Quoted 10 lines
lib/igt_fb.c +10
-0+struct fb_blit_linear linear; +}; + +static uint8_t clamprgb (float val) { +if (val <0 ) +return 0 ; +if (val >255 ) +return 255 ; + +return (uint8_t )val;I'm thinking of this rounding issue. Should we use rounding to the nearest integer here, instead of floor? Does the way we do rounding have an effect on test results if we first grab the reference CRC and then run a test in NV12 format?
Quoted 65 lines
lib/igt_fb.c +3
-0+} + +static void convert_nv12_to_rgb24(struct igt_fb *fb, struct
fb_convert_blit_upload*blit)lib/igt_fb.c +5
-0+{ +int i, j; +const uint8_t *y, *uv; +uint8_t *rgb24 = blit->rgb24.map; + unsigned rgb24_stride = blit->rgb24.stride, planar_stride =
blit->linear.stride;lib/igt_fb.c +4
-0+uint8_t *buf =malloc (blit->linear.size); + +/* +* Reading from the BO is awfully slow because of lack of read caching,
lib/igt_fb.c +1
-0+ * it's faster to copy the whole BO to a temporary bufferand convert
lib/igt_fb.c +23
-0+* from there. +*/ +memcpy (buf, blit->linear.map, blit->linear.size); + y = &buf[blit->linear.offsets[0 ]]; + uv = &buf[blit->linear.offsets[1 ]]; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, y1, cb, cr; +/* Convert 1x2 pixel blocks */ + + y0 =1.164f * (y[j] -16.f ); + y1 =1.164f * (y[j + planar_stride] -16.f ); + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + r_ = 0.000f * cb + 1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ = 2.112f * cb + 0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j * 4 + 2 + rgb24_stride] =
clamprgb(y1 + r_);lib/igt_fb.c +3
-0+ + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j * 4 + 1 + rgb24_stride] =
clamprgb(y1 + g_);lib/igt_fb.c +3
-0+ + rgb24[j *4 ] =clamprgb (y0 + b_); + rgb24[j * 4 + rgb24_stride] = clamprgb(y1 +b_);
lib/igt_fb.c +16
-0+ } + + rgb24 +=2 * rgb24_stride; + y +=2 * planar_stride; + uv += planar_stride; + } + +if (fb->height &1 ) { +/* Convert last row */ +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, cb, cr; +/* Convert single pixel */ + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; +
Quoted 8 lines
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1360
Quoted 5 lines
lib/igt_fb.c +5
-0+ y0 =1.164f * (y[j] -16.f ); + r_ = 0.000f * cb + 1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ = 2.112f * cb + 0.000f * cr; +Do you have a reference for these conversion coefficients? According to https://www.fourcc.org/fccyvrgb.php there are a few opinions how this conversion should be handled?
We probably don't want to hardcode these in the code since we'll want to test other encodings besides limited range BT.601. I think the cleanest approach is to derive the coefficients from the Kr/Kb values, but that might not lend itself well to tweaking the coefficients to match the hardware output (if that's necessary).
Quoted 203 lines
Quoted 23 lines
lib/igt_fb.c +10
-0+ rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 ] =clamprgb (y0 + b_); + } + } + +free (buf); +} + +static void convert_rgb24_to_nv12(struct igt_fb *fb, struct
fb_convert_blit_upload*blit)lib/igt_fb.c +10
-0+{ +int i, j; +uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; +uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +const uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride; +unsigned planar_stride = blit->linear.stride; + + igt_assert_f(fb->drm_format == DRM_FORMAT_NV12, + "Conversion not implemented for !NV12 planarformats\n");
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1419
Quoted 10 lines
lib/igt_fb.c +10
-0+ +for (i =0 ; i < fb->plane_height[0 ]; i++) { +/* Use limited color range BT.709 */ + +for (j =0 ; j < fb->plane_width[0 ]; j++) { +float yf =0.183f * rgb24[j *4 +2 ] + + 0.614f * rgb24[j * 4 + 1] + + 0.062f * rgb24[j * 4] + 16; + + y[j] = (uint8_t )yf;We could use
clamprgb()here too. Just in case.Quoted 35 lines
lib/igt_fb.c +12
-0+ } + + rgb24 += rgb24_stride; + y += planar_stride; + } + + rgb24 = blit->rgb24.map; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +/* +* Pixel center for Cb'Cr' is between the left top and
lib/igt_fb.c +1
-0+ * bottom pixel in a 2x2 block, so take theaverage.
lib/igt_fb.c +3
-0+*/ +float uf =-0.101f /2 * rgb24[j *8 +2 ] + + -0.101f/2 * rgb24[j * 8 + 2 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.339f/2 * rgb24[j * 8 + 1] + + -0.339f/2 * rgb24[j * 8 + 1 +
rgb24_stride] +lib/igt_fb.c +2
-0+ 0.439f/2 * rgb24[j * 8] + + 0.439f/2 * rgb24[j * 8 +
rgb24_stride] + 128;lib/igt_fb.c +2
-0+ float vf = 0.439f/2 * rgb24[j * 8 + 2] + + 0.439f/2 * rgb24[j * 8 + 2 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.339f/2 * rgb24[j * 8 + 1] + + -0.339f/2 * rgb24[j * 8 + 1 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.040f/2 * rgb24[j * 8] + + -0.040f/2 * rgb24[j * 8 +
rgb24_stride] + 128;lib/igt_fb.c
Quoted 2 lines
lib/igt_fb.c +2
-0+ uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf;Maybe add rounding & clamping here too?
Quoted 10 lines
lib/igt_fb.c +7
-0+ } + + rgb24 +=2 * rgb24_stride; + uv += planar_stride; + } + +/* Last row cannot be interpolated between 2 pixels, take the single value */
lib/igt_fb.c +1
-0+if (i < fb->plane_height[1 ]) {lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1465
Quoted 10 lines
lib/igt_fb.c +10
-0+for (j =0 ; j < fb->plane_width[1 ]; j++) { +float uf =-0.101f * rgb24[j *8 +2 ] + + -0.339f * rgb24[j * 8 + 1] + + 0.439f * rgb24[j * 8] + 128; + float vf = 0.439f * rgb24[j * 8 + 2] + + -0.339f * rgb24[j * 8 + 1] + + -0.040f * rgb24[j * 8] + 128; + + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf;rounding & clamping?
Quoted 102 lines
lib/igt_fb.c +12
-0+ } + } +} + +static void destroy_cairo_surface__convert (void *arg) +{ +struct fb_convert_blit_upload *blit = arg; +struct igt_fb *fb = blit->fb; + +/* Convert back to planar! */ + igt_assert_f(fb->drm_format == DRM_FORMAT_NV12, + "Conversion not implemented for !NV12 planarformats\n");
lib/igt_fb.c +7
-0+ +convert_rgb24_to_nv12 (fb, blit); + +munmap (blit->rgb24.map, blit->rgb24.size); + +if (blit->linear.handle) + free_linear_mapping(blit->fd, blit->fb, &blit-Quoted 1 line
linear);
lib/igt_fb.c +17
-0+else +gem_munmap (blit->linear.map, fb->size); + +free (blit); + + fb->cairo_surface =NULL ; +} + +static void create_cairo_surface__convert (int fd,struct igt_fb *fb) +{ +struct fb_convert_blit_upload *blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; + blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); + blit->rgb24.size = ALIGN(blit->rgb24.stride * fb->height,
sysconf(_SC_PAGESIZE));lib/igt_fb.c +1
-0+ blit->rgb24.map = mmap(NULL, blit->rgb24.size, PROT_READ |
PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);lib/igt_fb.c +8
-0+igt_assert (blit->rgb24.map !=MAP_FAILED ); + +if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { +setup_linear_mapping (fd, fb, &blit->linear); + }else { + blit->linear.handle =0 ; + blit->linear.map = gem_mmap__gtt(fd, fb->gem_handle,
fb->size,lib/igt_fb.c +1
-0+ PROT_READ |
PROT_WRITE);lib/igt_fb.c +4
-0+igt_assert (blit->linear.map); + blit->linear.stride = fb->stride; + blit->linear.size = fb->size; + memcpy(blit->linear.offsets, fb->offsets, sizeof(fb-Quoted 1 line
offsets));
lib/igt_fb.c +5
-0+ } + +/* Convert to linear! */ + igt_assert_f(fb->drm_format == DRM_FORMAT_NV12, + "Conversion not implemented for !NV12 planarformats\n");
lib/igt_fb.c +5
-0+convert_nv12_to_rgb24 (fb, blit); + + fb->cairo_surface = +cairo_image_surface_create_for_data (blit->rgb24.map, + CAIRO_FORMAT_RGB24,
lib/igt_fb.c +1
-0+ fb->width, fb-Quoted 1 line
height,
lib/igt_fb.c +1
-0+ blit-Quoted 1 line
rgb24.stride);
lib/igt_fb.c +3
-0+ +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t*)create_cairo_surface__convert,
lib/igt_fb.c +1
-0+ blit,
destroy_cairo_surface__convert);lib/igt_fb.c +2
-0+} +/**
*igt_get_cairo_surface:
* @fd: open drm file descriptorlib/igt_fb.c +0
-1@@ -1297,11 +1544,10 @@ static void create_cairo_surface__gtt(int fd,struct igt_fb *fb) */ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb) { -/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */
lib/igt_fb.c +0
-2-igt_assert (fb->num_planes <2 ); -if (
fb->cairo_surface== NULL) {lib/igt_fb.c +3
-1- if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED || +if (fb->num_planes >1 ) +create_cairo_surface__convert (fd, fb); + else if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED||
fb->tiling ==LOCAL_I915_FORMAT_MOD_Yf_TILED)create_cairo_surface__blit(fd, fb); elseSignature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t 8/8] lib/igt_fb: Add support for NV12 format through conversion
Op 31-01-18 om 15:32 schreef Ville Syrjälä:
Quoted 370 lines · Mika Kahola
Quoted 361 lines · Maarten Lankhorst
Quoted 280 lines
For NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.709 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y:
Y Y Y Y
UV UV
Y Y Y YSome work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO.
When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising
even further for me.Signed-off-by Maarten Lankhorst <[email protected]>---
lib/igt_fb.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++-
----------1 file changed, 318 insertions(+), 72 deletions(-)lib/igt_fb.c +1
-0@@ -70,6 +70,7 @@ static struct format_desc_struct { DF(XRGB8888, RGB24, 32, 24), DF(XRGB2101010, RGB30, 32, 30), DF(ARGB8888, ARGB32, 32, 32), + DF(NV12, RGB24, 32, -1, 2, {8, 16}), }; #undef DFlib/igt_fb.c +0
-0@@ -363,14 +364,20 @@ static int create_bo_for_fb(int fd, int width,int height, *is_dumb = false;
if (is_i915_device(fd)) {lib/igt_fb.c +1
-1-uint32_t *ptr; +uint8_t *ptr;
bo =gem_create(fd, size);gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
/* Ensure the framebuffer is preallocated */lib/igt_fb.c +0
-1- ptr = gem_mmap__gtt(fd, bo, size,
PROT_READ);lib/igt_fb.c +1
-1-igt_assert (*ptr ==0 ); + ptr = gem_mmap__gtt(fd, bo, size, PROT_READ|
PROT_WRITE);lib/igt_fb.c +4
-0+igt_assert (*(uint32_t *)ptr ==0 ); + +if (format->drm_id ==DRM_FORMAT_NV12 ) { +/* component formats have a different zero point */
lib/igt_fb.c +2
-0+memset (ptr,16 , offsets[1 ]); + memset(ptr + offsets[1], 0x80,(height + 1)/2 * stride);
lib/igt_fb.c +1
-0+ }
gem_munmap(ptr, size);
if (size_ret)lib/igt_fb.c +0
-0@@ -1126,103 +1133,117 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format) drm_format, igt_format_str(drm_format)); }lib/igt_fb.c +8
-0+struct fb_blit_linear { +uint32_t handle; +unsigned size, stride; +uint8_t *map; +bool is_dumb; +uint32_t offsets[4 ]; +}; +struct
fb_blit_upload{
int fd;
structigt_fb*fb;lib/igt_fb.c +1
-6-struct { -uint32_t handle; -unsigned size, stride; -uint8_t *map; -bool is_dumb; - } linear; +struct fb_blit_linear linear;};
lib/igt_fb.c +1
-1-static void destroy_cairo_surface__blit (void *arg) +static void free_linear_mapping(int fd, struct igt_fb *fb, struct
fb_blit_linear*linear)
{lib/igt_fb.c +0
-2-struct fb_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb;unsigned int
obj_tiling=igt_fb_mod_to_tiling(fb->tiling);lib/igt_fb.c +1
-0+int i;lib/igt_fb.c +12
-2-gem_munmap (blit->linear.map, blit->linear.size); - fb->cairo_surface =NULL ; +gem_munmap (linear->map, linear->size); +gem_set_domain (fd, linear->handle, + I915_GEM_DOMAIN_GTT, 0); + +for (i =0 ; i < fb->num_planes; i++) + igt_blitter_fast_copy__raw(fd, + linear->handle, + linear->offsets[i], + linear->stride, + I915_TILING_NONE, + 0, 0, /* src_x, src_y */ + fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c +10
-0+ fb->plane_bpp[i], + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, + 0, 0 /* dst_x, dst_y */); + +gem_sync (fd, linear->handle); +gem_close (fd, linear->handle); +}lib/igt_fb.c +3
-2-gem_set_domain (blit->fd, blit->linear.handle, -I915_GEM_DOMAIN_GTT ,0 ); +static void destroy_cairo_surface__blit (void *arg) +{ +struct fb_blit_upload *blit = arg;lib/igt_fb.c +0
-7- igt_blitter_fast_copy__raw(blit->fd, - blit->linear.handle, 0, - blit->linear.stride, - I915_TILING_NONE, - 0, 0, /* src_x, src_y */ - fb->width, fb->height, - igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +3
-8- fb->gem_handle, - fb->offsets[0], - fb->stride, - obj_tiling, - 0, 0 /* dst_x, dst_y */); - -gem_sync (blit->fd, blit->linear.handle); -gem_close (blit->fd, blit->linear.handle); + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit->fd, blit->fb, &blit->linear);
free(blit);
}lib/igt_fb.c +1
-1-static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +static void setup_linear_mapping(int fd, struct igt_fb *fb, struct
fb_blit_linear*linear)
{lib/igt_fb.c +0
-2-struct fb_blit_upload *blit; -cairo_format_t cairo_format;unsigned int
obj_tiling=igt_fb_mod_to_tiling(fb->tiling);lib/igt_fb.c +1
-4-uint32_t offsets[4 ]; - - blit =malloc (sizeof (*blit)); -igt_assert (blit); +int i;
/*
* We create a linear BO that we'll map for the CPU to write to (using
* cairo). This linear bo will be then blitted to its final
* destination, tiling it at the same time.
*/lib/igt_fb.c +0
-1- blit->linear.handle = create_bo_for_fb(fd, fb->width, fb-Quoted 1 line
height,
lib/igt_fb.c +1
-0+ linear->handle = create_bo_for_fb(fd, fb->width, fb->height,lookup_drm_format(fb-
Quoted 1 line
drm_format),LOCAL_DRM_FORMAT_MOD_ NONE, 0,
lib/igt_fb.c +0
-1- 0, &blit-Quoted 1 line
linear.size,
lib/igt_fb.c +0
-2- &blit->linear.stride, - offsets, &blit-Quoted 1 line
linear.is_dumb);
lib/igt_fb.c +3
-2- -igt_assert (blit->linear.handle >0 ); + 0, &linear->size, + &linear->stride, + linear->offsets,
&linear->is_dumb);lib/igt_fb.c +1
-2- blit->fd = fd; - blit->fb = fb; +igt_assert (linear->handle >0 );
/* Copy fb content to linear BO */lib/igt_fb.c +1
-1- gem_set_domain(fd, blit->linear.handle, + gem_set_domain(fd, linear->handle,
I915_GEM_DOMAIN_GTT, 0);lib/igt_fb.c +0
-8- igt_blitter_fast_copy__raw(fd, - fb->gem_handle, - fb->offsets[0], - fb->stride, - obj_tiling, - 0, 0, /* src_x, src_y */ - fb->width, fb->height, - igt_drm_format_to_bpp(fb-Quoted 1 line
drm_format),lib/igt_fb.c +8
-8- blit->linear.handle, 0, - blit->linear.stride, - I915_TILING_NONE, - 0, 0 /* dst_x, dst_y */); - -gem_sync (fd, blit->linear.handle); - - gem_set_domain(fd, blit->linear.handle, +for (i =0 ; i < fb->num_planes; i++) + igt_blitter_fast_copy__raw(fd, + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, + 0, 0, /* src_x, src_y */ + fb->plane_width[i], fb-Quoted 1 line
plane_height[i],
lib/igt_fb.c +2
-0+ fb->plane_bpp[i], + linear->handle, linear-Quoted 1 line
offsets[i],
lib/igt_fb.c +7
-0+ linear->stride, + I915_TILING_NONE, + 0, 0 /* dst_x, dst_y */); + +gem_sync (fd, linear->handle); + + gem_set_domain(fd, linear->handle,I915_GEM_DOMAIN_CPU,
I915_GEM_DOMAIN_CPU);
/* Setup cairo context */lib/igt_fb.c +2
-5- blit->linear.map =gem_mmap__cpu (fd, - blit->linear.handle, - 0, - blit->linear.size, - PROT_READ | PROT_WRITE); + linear->map = gem_mmap__cpu(fd, linear->handle, + 0, linear->size, PROT_READ |
PROT_WRITE);lib/igt_fb.c +13
-0+} + +static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; +setup_linear_mapping (fd, fb, &blit->linear);
cairo_format=drm_format_to_cairo(fb->drm_format);fb->cairo_surface=lib/igt_fb.c +0
-0@@ -1284,6 +1305,232 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); }lib/igt_fb.c +9
-0+struct fb_convert_blit_upload { +int fd; +struct igt_fb *fb; + +struct { +uint8_t *map; +unsigned stride, size; + } rgb24; +lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1326
Quoted 10 lines
lib/igt_fb.c +10
-0+struct fb_blit_linear linear; +}; + +static uint8_t clamprgb (float val) { +if (val <0 ) +return 0 ; +if (val >255 ) +return 255 ; + +return (uint8_t )val;I'm thinking of this rounding issue. Should we use rounding to the nearest integer here, instead of floor? Does the way we do rounding have an effect on test results if we first grab the reference CRC and then run a test in NV12 format?
Quoted 65 lines
lib/igt_fb.c +3
-0+} + +static void convert_nv12_to_rgb24(struct igt_fb *fb, struct
fb_convert_blit_upload*blit)lib/igt_fb.c +5
-0+{ +int i, j; +const uint8_t *y, *uv; +uint8_t *rgb24 = blit->rgb24.map; + unsigned rgb24_stride = blit->rgb24.stride, planar_stride =
blit->linear.stride;lib/igt_fb.c +4
-0+uint8_t *buf =malloc (blit->linear.size); + +/* +* Reading from the BO is awfully slow because of lack of read caching,
lib/igt_fb.c +1
-0+ * it's faster to copy the whole BO to a temporary bufferand convert
lib/igt_fb.c +23
-0+* from there. +*/ +memcpy (buf, blit->linear.map, blit->linear.size); + y = &buf[blit->linear.offsets[0 ]]; + uv = &buf[blit->linear.offsets[1 ]]; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, y1, cb, cr; +/* Convert 1x2 pixel blocks */ + + y0 =1.164f * (y[j] -16.f ); + y1 =1.164f * (y[j + planar_stride] -16.f ); + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + r_ = 0.000f * cb + 1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ = 2.112f * cb + 0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j * 4 + 2 + rgb24_stride] =
clamprgb(y1 + r_);lib/igt_fb.c +3
-0+ + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j * 4 + 1 + rgb24_stride] =
clamprgb(y1 + g_);lib/igt_fb.c +3
-0+ + rgb24[j *4 ] =clamprgb (y0 + b_); + rgb24[j * 4 + rgb24_stride] = clamprgb(y1 +b_);
lib/igt_fb.c +16
-0+ } + + rgb24 +=2 * rgb24_stride; + y +=2 * planar_stride; + uv += planar_stride; + } + +if (fb->height &1 ) { +/* Convert last row */ +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, cb, cr; +/* Convert single pixel */ + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; +Quoted 8 lines
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1360
Quoted 5 lines
lib/igt_fb.c +5
-0+ y0 =1.164f * (y[j] -16.f ); + r_ = 0.000f * cb + 1.793f * cr; + g_ =-0.213f * cb +-0.533f * cr; + b_ = 2.112f * cb + 0.000f * cr; +Do you have a reference for these conversion coefficients? According to https://www.fourcc.org/fccyvrgb.php there are a few opinions how this conversion should be handled?
Quoted 5 lines
We probably don't want to hardcode these in the code since we'll want to test other encodings besides limited range BT.601. I think the cleanest approach is to derive the coefficients from the Kr/Kb values, but that might not lend itself well to tweaking the coefficients to match the hardware output (if that's necessary).
This is limited range BT.709. If we ever add support for encodings we can worry about it. :)
I think being 100% color accurate is not necessary for NV12, just as long as we are consistent.
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
lib/igt_fb.c +10
-0+ rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 ] =clamprgb (y0 + b_); + } + } + +free (buf); +} + +static void convert_rgb24_to_nv12(struct igt_fb *fb, struct
fb_convert_blit_upload*blit)lib/igt_fb.c +10
-0+{ +int i, j; +uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; +uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +const uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride; +unsigned planar_stride = blit->linear.stride; + + igt_assert_f(fb->drm_format == DRM_FORMAT_NV12, + "Conversion not implemented for !NV12 planarformats\n");
lib/igt_fb.c +3
-0+ +for (i =0 ; i < fb->plane_height[0 ]; i++) { +/* Use limited color range BT.709 */
Quoted 8 lines
Quoted 8 lines
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1419
Quoted 7 lines
lib/igt_fb.c +7
-0+ +for (j =0 ; j < fb->plane_width[0 ]; j++) { +float yf =0.183f * rgb24[j *4 +2 ] + + 0.614f * rgb24[j * 4 + 1] + + 0.062f * rgb24[j * 4] + 16; + + y[j] = (uint8_t )yf;We could use
clamprgb()here too. Just in case.
Since it's limited range, I don't think we'll hit it in practice..
Quoted 1 line
Quoted 1 line
Quoted 1 line
0.183 * 255 + .614 * 255 + .062 * 255 + 16
235.045
Quoted 1 line
Quoted 1 line
Quoted 1 line
0.183 * 0 + .614 * 0 + .062 * 0 + 16
16.0
u min/max:
Quoted 1 line
Quoted 1 line
Quoted 1 line
-.101 * 255 - .339 * 255 + 128
15.799999999999983
Quoted 1 line
Quoted 1 line
Quoted 1 line
.439 * 255 + 128
239.945
v min/max:
Quoted 1 line
Quoted 1 line
Quoted 1 line
-.339 * 255 + -.040 * 255 + 128
31.35499999999999
Quoted 1 line
Quoted 1 line
Quoted 1 line
.439 * 255 + 128
239.945
So it's pretty much contained between 15 and 240, no need to clamp..
Quoted 51 lines
Quoted 51 lines
Quoted 35 lines
lib/igt_fb.c +12
-0+ } + + rgb24 += rgb24_stride; + y += planar_stride; + } + + rgb24 = blit->rgb24.map; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +/* +* Pixel center for Cb'Cr' is between the left top and
lib/igt_fb.c +1
-0+ * bottom pixel in a 2x2 block, so take theaverage.
lib/igt_fb.c +3
-0+*/ +float uf =-0.101f /2 * rgb24[j *8 +2 ] + + -0.101f/2 * rgb24[j * 8 + 2 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.339f/2 * rgb24[j * 8 + 1] + + -0.339f/2 * rgb24[j * 8 + 1 +
rgb24_stride] +lib/igt_fb.c +2
-0+ 0.439f/2 * rgb24[j * 8] + + 0.439f/2 * rgb24[j * 8 +
rgb24_stride] + 128;lib/igt_fb.c +2
-0+ float vf = 0.439f/2 * rgb24[j * 8 + 2] + + 0.439f/2 * rgb24[j * 8 + 2 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.339f/2 * rgb24[j * 8 + 1] + + -0.339f/2 * rgb24[j * 8 + 1 +
rgb24_stride] +lib/igt_fb.c +2
-0+ -0.040f/2 * rgb24[j * 8] + + -0.040f/2 * rgb24[j * 8 +
rgb24_stride] + 128;lib/igt_fb.c
Quoted 2 lines
lib/igt_fb.c +2
-0+ uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf;Maybe add rounding & clamping here too?
Quoted 13 lines
lib/igt_fb.c +7
-0+ } + + rgb24 +=2 * rgb24_stride; + uv += planar_stride; + } + +/* Last row cannot be interpolated between 2 pixels, take the single value */
lib/igt_fb.c +4
-0+if (i < fb->plane_height[1 ]) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +float uf =-0.101f * rgb24[j *8 +2 ] + + -0.339f * rgb24[j * 8 + 1] +
Quoted 8 lines
Quoted 8 lines
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1465
Quoted 7 lines
lib/igt_fb.c +7
-0+ 0.439f * rgb24[j * 8] + 128; + float vf = 0.439f * rgb24[j * 8 + 2] + + -0.339f * rgb24[j * 8 + 1] + + -0.040f * rgb24[j * 8] + 128; + + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf;rounding & clamping?
I left out the clamping for Y and UV because we can overflow/undeflow by 16. If necessary I can re-add it. :)
~Maarten
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/1 lib/igt_fb: Add support for NV12 format through conversion, v2.
In reply to Ville SyrjäläFor NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.601 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y:
Y Y Y Y UV UV Y Y Y Y
Some work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO.
When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising even further for me.
Changes since v1:
- Use BT.601 instead of BT.709 coefficients. (Ville)
--- lib/igt_fb.c | 391 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 319 insertions(+), 72 deletions(-)
lib/igt_fb.c +319 -72
@@ -70,6 +70,7 @@ static struct format_desc_struct {DF (XRGB8888 ,RGB24 ,32 ,24 ),DF (XRGB2101010 ,RGB30 ,32 ,30 ),DF (ARGB8888 ,ARGB32 ,32 ,32 ), + DF(NV12, RGB24, 32, -1, 2, {8, 16}), };#undef DF
@@ -364,14 +365,20 @@ static int create_bo_for_fb(int fd, int width, int height, *is_dumb = false;if (is_i915_device (fd)) { -uint32_t *ptr; +uint8_t *ptr; bo =gem_create (fd, size);gem_set_tiling (fd, bo,igt_fb_mod_to_tiling (tiling), stride);/* Ensure the framebuffer is preallocated */ - ptr =gem_mmap__gtt (fd, bo, size,PROT_READ ); -igt_assert (*ptr ==0 ); + ptr =gem_mmap__gtt (fd, bo, size,PROT_READ |PROT_WRITE ); +igt_assert (*(uint32_t *)ptr ==0 ); + +if (format->drm_id ==DRM_FORMAT_NV12 ) { +/* component formats have a different zero point */ +memset (ptr,16 , offsets[1 ]); +memset (ptr + offsets[1 ],0x80 , (height +1 )/2 * stride); + }gem_munmap (ptr, size);if (size_ret)
@@ -1127,103 +1134,117 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format) drm_format, igt_format_str(drm_format)); } +struct fb_blit_linear { +uint32_t handle; +unsigned size, stride; +uint8_t *map; +bool is_dumb; +uint32_t offsets[4 ]; +}; +struct fb_blit_upload {int fd;struct igt_fb *fb; -struct { -uint32_t handle; -unsigned size, stride; -uint8_t *map; -bool is_dumb; - } linear; +struct fb_blit_linear linear; }; -static void destroy_cairo_surface__blit (void *arg) +static void free_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); +int i; -gem_munmap (blit->linear.map, blit->linear.size); - fb->cairo_surface =NULL ; +gem_munmap (linear->map, linear->size); +gem_set_domain (fd, linear->handle, +I915_GEM_DOMAIN_GTT ,0 ); + +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + linear->handle, + linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); +gem_close (fd, linear->handle); +} -gem_set_domain (blit->fd, blit->linear.handle, -I915_GEM_DOMAIN_GTT ,0 ); +static void destroy_cairo_surface__blit (void *arg) +{ +struct fb_blit_upload *blit = arg; -igt_blitter_fast_copy__raw (blit->fd, - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (blit->fd, blit->linear.handle); -gem_close (blit->fd, blit->linear.handle); + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit->fd, blit->fb, &blit->linear);free (blit); } -static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +static void setup_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit; -cairo_format_t cairo_format;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -uint32_t offsets[4 ]; - - blit =malloc (sizeof (*blit)); -igt_assert (blit); +int i;/* * We create a linear BO that we'll map for the CPU to write to (using * cairo). This linear bo will be then blitted to its final * destination, tiling it at the same time. */ - blit->linear.handle =create_bo_for_fb (fd, fb->width, fb->height, + linear->handle =create_bo_for_fb (fd, fb->width, fb->height,lookup_drm_format (fb->drm_format),LOCAL_DRM_FORMAT_MOD_NONE ,0 , -0 , &blit->linear.size, - &blit->linear.stride, - offsets, &blit->linear.is_dumb); - -igt_assert (blit->linear.handle >0 ); +0 , &linear->size, + &linear->stride, + linear->offsets, &linear->is_dumb); - blit->fd = fd; - blit->fb = fb; +igt_assert (linear->handle >0 );/* Copy fb content to linear BO */ -gem_set_domain (fd, blit->linear.handle, +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_GTT ,0 ); -igt_blitter_fast_copy__raw (fd, - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (fd, blit->linear.handle); - -gem_set_domain (fd, blit->linear.handle, +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + linear->handle, linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); + +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU );/* Setup cairo context */ - blit->linear.map =gem_mmap__cpu (fd, - blit->linear.handle, -0 , - blit->linear.size, -PROT_READ |PROT_WRITE ); + linear->map =gem_mmap__cpu (fd, linear->handle, +0 , linear->size,PROT_READ |PROT_WRITE ); +} + +static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; +setup_linear_mapping (fd, fb, &blit->linear); cairo_format =drm_format_to_cairo (fb->drm_format); fb->cairo_surface =
@@ -1285,6 +1306,233 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); } +struct fb_convert_blit_upload { +int fd; +struct igt_fb *fb; + +struct { +uint8_t *map; +unsigned stride, size; + } rgb24; + +struct fb_blit_linear linear; +}; + +static uint8_t clamprgb (float val) { +if (val <0 ) +return 0 ; +if (val >255 ) +return 255 ; + +return (uint8_t )val; +} + +static void convert_nv12_to_rgb24 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +const uint8_t *y, *uv; +uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->linear.stride; +uint8_t *buf =malloc (blit->linear.size); + +/* +* Reading from the BO is awfully slow because of lack of read caching, +* it's faster to copy the whole BO to a temporary buffer and convert +* from there. +*/ +memcpy (buf, blit->linear.map, blit->linear.size); + y = &buf[blit->linear.offsets[0 ]]; + uv = &buf[blit->linear.offsets[1 ]]; + +/* Convert from limited color range BT.601 */ +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, y1, cb, cr; +/* Convert 1x2 pixel blocks */ + + y0 =1.164f * (y[j] -16.f ); + y1 =1.164f * (y[j + planar_stride] -16.f ); + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + r_ =0.000f * cb +1.596f * cr; + g_ =-0.392f * cb +-0.813f * cr; + b_ =2.017f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +2 + rgb24_stride] =clamprgb (y1 + r_); + + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 +1 + rgb24_stride] =clamprgb (y1 + g_); + + rgb24[j *4 ] =clamprgb (y0 + b_); + rgb24[j *4 + rgb24_stride] =clamprgb (y1 + b_); + } + + rgb24 +=2 * rgb24_stride; + y +=2 * planar_stride; + uv += planar_stride; + } + +if (fb->height &1 ) { +/* Convert last row */ +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, cb, cr; +/* Convert single pixel */ + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + y0 =1.164f * (y[j] -16.f ); + r_ =0.000f * cb +1.596f * cr; + g_ =-0.392f * cb +-0.813f * cr; + b_ =2.017f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 ] =clamprgb (y0 + b_); + } + } + +free (buf); +} + +static void convert_rgb24_to_nv12 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; +uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +const uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride; +unsigned planar_stride = blit->linear.stride; + +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +for (i =0 ; i < fb->plane_height[0 ]; i++) { +/* Use limited color range BT.601 */ + +for (j =0 ; j < fb->plane_width[0 ]; j++) { +float yf =0.257f * rgb24[j *4 +2 ] + +0.504f * rgb24[j *4 +1 ] + +0.098f * rgb24[j *4 ] +16 ; + + y[j] = (uint8_t )yf; + } + + rgb24 += rgb24_stride; + y += planar_stride; + } + + rgb24 = blit->rgb24.map; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +/* +* Pixel center for Cb'Cr' is between the left top and +* bottom pixel in a 2x2 block, so take the average. +*/ +float uf =-0.148f /2 * rgb24[j *8 +2 ] + +-0.148f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.291f /2 * rgb24[j *8 +1 ] + +-0.291f /2 * rgb24[j *8 +1 + rgb24_stride] + +0.439f /2 * rgb24[j *8 ] + +0.439f /2 * rgb24[j *8 + rgb24_stride] +128 ; +float vf =0.439f /2 * rgb24[j *8 +2 ] + +0.439f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.368f /2 * rgb24[j *8 +1 ] + +-0.368f /2 * rgb24[j *8 +1 + rgb24_stride] + +-0.071f /2 * rgb24[j *8 ] + +-0.071f /2 * rgb24[j *8 + rgb24_stride] +128 ; + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + + rgb24 +=2 * rgb24_stride; + uv += planar_stride; + } + +/* Last row cannot be interpolated between 2 pixels, take the single value */ +if (i < fb->plane_height[1 ]) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +float uf =-0.148f * rgb24[j *8 +2 ] + +-0.291f * rgb24[j *8 +1 ] + +0.439f * rgb24[j *8 ] +128 ; +float vf =0.439f * rgb24[j *8 +2 ] + +-0.368f * rgb24[j *8 +1 ] + +-0.071f * rgb24[j *8 ] +128 ; + + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + } +} + +static void destroy_cairo_surface__convert (void *arg) +{ +struct fb_convert_blit_upload *blit = arg; +struct igt_fb *fb = blit->fb; + +/* Convert back to planar! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +convert_rgb24_to_nv12 (fb, blit); + +munmap (blit->rgb24.map, blit->rgb24.size); + +if (blit->linear.handle) +free_linear_mapping (blit->fd, blit->fb, &blit->linear); +else +gem_munmap (blit->linear.map, fb->size); + +free (blit); + + fb->cairo_surface =NULL ; +} + +static void create_cairo_surface__convert (int fd,struct igt_fb *fb) +{ +struct fb_convert_blit_upload *blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; + blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); + blit->rgb24.size =ALIGN (blit->rgb24.stride * fb->height,sysconf (_SC_PAGESIZE)); + blit->rgb24.map =mmap (NULL , blit->rgb24.size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 ); +igt_assert (blit->rgb24.map !=MAP_FAILED ); + +if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { +setup_linear_mapping (fd, fb, &blit->linear); + }else { + blit->linear.handle =0 ; + blit->linear.map =gem_mmap__gtt (fd, fb->gem_handle, fb->size, +PROT_READ |PROT_WRITE ); +igt_assert (blit->linear.map); + blit->linear.stride = fb->stride; + blit->linear.size = fb->size; +memcpy (blit->linear.offsets, fb->offsets,sizeof (fb->offsets)); + } + +/* Convert to linear! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); +convert_nv12_to_rgb24 (fb, blit); + + fb->cairo_surface = +cairo_image_surface_create_for_data (blit->rgb24.map, +CAIRO_FORMAT_RGB24 , + fb->width, fb->height, + blit->rgb24.stride); + +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t *)create_cairo_surface__convert, + blit, destroy_cairo_surface__convert); +} +/** * igt_get_cairo_surface: * @fd: open drm file descriptor
@@ -1298,11 +1546,10 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)*/ cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb) { -/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */ -igt_assert (fb->num_planes <2 ); -if (fb->cairo_surface ==NULL ) { -if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || +if (fb->num_planes >1 ) +create_cairo_surface__convert (fd, fb); +else if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)create_cairo_surface__blit (fd, fb);else
Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for NV12 format through conversion, v2.
Quoted 31 lines · Maarten Lankhorst
For NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.601 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y:
Y Y Y Y UV UV Y Y Y YSome work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO.
When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising even further for me.
Changes since v1:
- Use BT.601 instead of BT.709 coefficients. (Ville)Signed-off-by Maarten Lankhorst <[email protected]>--- lib/igt_fb.c | 391 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 319 insertions(+), 72 deletions(-)lib/igt_fb.c +0
-0
lib/igt_fb.c static struct format_desc_struct { · line 73
Quoted 4 lines
lib/igt_fb.c +1
-0@@ -70,6 +70,7 @@ static struct format_desc_struct {DF (XRGB8888 ,RGB24 ,32 ,24 ),DF (XRGB2101010 ,RGB30 ,32 ,30 ),DF (ARGB8888 ,ARGB32 ,32 ,32 ), + DF(NV12, RGB24, 32, -1, 2, {8, 16}),
This is getting pretty much unredable. Switching to named initializers as a followup might seem prudent.
Quoted 266 lines
lib/igt_fb.c +140
-68};#undef DF@@ -364,14 +365,20 @@ static int create_bo_for_fb(int fd, int width, int height, *is_dumb = false;if (is_i915_device (fd)) { -uint32_t *ptr; +uint8_t *ptr; bo =gem_create (fd, size);gem_set_tiling (fd, bo,igt_fb_mod_to_tiling (tiling), stride);/* Ensure the framebuffer is preallocated */ - ptr =gem_mmap__gtt (fd, bo, size,PROT_READ ); -igt_assert (*ptr ==0 ); + ptr =gem_mmap__gtt (fd, bo, size,PROT_READ |PROT_WRITE ); +igt_assert (*(uint32_t *)ptr ==0 ); + +if (format->drm_id ==DRM_FORMAT_NV12 ) { +/* component formats have a different zero point */ +memset (ptr,16 , offsets[1 ]); +memset (ptr + offsets[1 ],0x80 , (height +1 )/2 * stride); + }gem_munmap (ptr, size);if (size_ret)@@ -1127,103 +1134,117 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format) drm_format, igt_format_str(drm_format)); } +struct fb_blit_linear { +uint32_t handle; +unsigned size, stride; +uint8_t *map; +bool is_dumb; +uint32_t offsets[4 ]; +}; +struct fb_blit_upload {int fd;struct igt_fb *fb; -struct { -uint32_t handle; -unsigned size, stride; -uint8_t *map; -bool is_dumb; - } linear; +struct fb_blit_linear linear; }; -static void destroy_cairo_surface__blit (void *arg) +static void free_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); +int i; -gem_munmap (blit->linear.map, blit->linear.size); - fb->cairo_surface =NULL ; +gem_munmap (linear->map, linear->size); +gem_set_domain (fd, linear->handle, +I915_GEM_DOMAIN_GTT ,0 ); + +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + linear->handle, + linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); +gem_close (fd, linear->handle); +} -gem_set_domain (blit->fd, blit->linear.handle, -I915_GEM_DOMAIN_GTT ,0 ); +static void destroy_cairo_surface__blit (void *arg) +{ +struct fb_blit_upload *blit = arg; -igt_blitter_fast_copy__raw (blit->fd, - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (blit->fd, blit->linear.handle); -gem_close (blit->fd, blit->linear.handle); + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit->fd, blit->fb, &blit->linear);free (blit); } -static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +static void setup_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit; -cairo_format_t cairo_format;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -uint32_t offsets[4 ]; - - blit =malloc (sizeof (*blit)); -igt_assert (blit); +int i;/* * We create a linear BO that we'll map for the CPU to write to (using * cairo). This linear bo will be then blitted to its final * destination, tiling it at the same time. */ - blit->linear.handle =create_bo_for_fb (fd, fb->width, fb->height, + linear->handle =create_bo_for_fb (fd, fb->width, fb->height,lookup_drm_format (fb->drm_format),LOCAL_DRM_FORMAT_MOD_NONE ,0 , -0 , &blit->linear.size, - &blit->linear.stride, - offsets, &blit->linear.is_dumb); - -igt_assert (blit->linear.handle >0 ); +0 , &linear->size, + &linear->stride, + linear->offsets, &linear->is_dumb); - blit->fd = fd; - blit->fb = fb; +igt_assert (linear->handle >0 );/* Copy fb content to linear BO */ -gem_set_domain (fd, blit->linear.handle, +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_GTT ,0 ); -igt_blitter_fast_copy__raw (fd, - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (fd, blit->linear.handle); - -gem_set_domain (fd, blit->linear.handle, +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + linear->handle, linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); + +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU );/* Setup cairo context */ - blit->linear.map =gem_mmap__cpu (fd, - blit->linear.handle, -0 , - blit->linear.size, -PROT_READ |PROT_WRITE ); + linear->map =gem_mmap__cpu (fd, linear->handle, +0 , linear->size,PROT_READ |PROT_WRITE ); +} + +static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; +setup_linear_mapping (fd, fb, &blit->linear); cairo_format =drm_format_to_cairo (fb->drm_format); fb->cairo_surface =@@ -1285,6 +1306,233 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); } +struct fb_convert_blit_upload { +int fd; +struct igt_fb *fb; + +struct { +uint8_t *map; +unsigned stride, size; + } rgb24; + +struct fb_blit_linear linear; +}; + +static uint8_t clamprgb (float val) { +if (val <0 ) +return 0 ; +if (val >255 ) +return 255 ; + +return (uint8_t )val; +} + +static void convert_nv12_to_rgb24 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +const uint8_t *y, *uv; +uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->linear.stride; +uint8_t *buf =malloc (blit->linear.size); + +/* +* Reading from the BO is awfully slow because of lack of read caching, +* it's faster to copy the whole BO to a temporary buffer and convert +* from there. +*/ +memcpy (buf, blit->linear.map, blit->linear.size); + y = &buf[blit->linear.offsets[0 ]]; + uv = &buf[blit->linear.offsets[1 ]]; + +/* Convert from limited color range BT.601 */ +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, y1, cb, cr; +/* Convert 1x2 pixel blocks */ + + y0 =1.164f * (y[j] -16.f ); + y1 =1.164f * (y[j + planar_stride] -16.f ); + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + r_ =0.000f * cb +1.596f * cr; + g_ =-0.392f * cb +-0.813f * cr;
lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1370
Quoted 10 lines
lib/igt_fb.c +10
-0+ b_ =2.017f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +2 + rgb24_stride] =clamprgb (y1 + r_); + + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 +1 + rgb24_stride] =clamprgb (y1 + g_); + + rgb24[j *4 ] =clamprgb (y0 + b_); + rgb24[j *4 + rgb24_stride] =clamprgb (y1 + b_);
Just replicating the same chroma for four pixels is pretty crude, but since this is for testing I guess we don't really care. Given that I guess we could even process in 2x2 blocks instead.
The coefficients looks correct enough to me.
Quoted 190 lines
lib/igt_fb.c +168
-4+ } + + rgb24 +=2 * rgb24_stride; + y +=2 * planar_stride; + uv += planar_stride; + } + +if (fb->height &1 ) { +/* Convert last row */ +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, cb, cr; +/* Convert single pixel */ + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + y0 =1.164f * (y[j] -16.f ); + r_ =0.000f * cb +1.596f * cr; + g_ =-0.392f * cb +-0.813f * cr; + b_ =2.017f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 ] =clamprgb (y0 + b_); + } + } + +free (buf); +} + +static void convert_rgb24_to_nv12 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; +uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +const uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride; +unsigned planar_stride = blit->linear.stride; + +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +for (i =0 ; i < fb->plane_height[0 ]; i++) { +/* Use limited color range BT.601 */ + +for (j =0 ; j < fb->plane_width[0 ]; j++) { +float yf =0.257f * rgb24[j *4 +2 ] + +0.504f * rgb24[j *4 +1 ] + +0.098f * rgb24[j *4 ] +16 ; + + y[j] = (uint8_t )yf; + } + + rgb24 += rgb24_stride; + y += planar_stride; + } + + rgb24 = blit->rgb24.map; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +/* +* Pixel center for Cb'Cr' is between the left top and +* bottom pixel in a 2x2 block, so take the average. +*/ +float uf =-0.148f /2 * rgb24[j *8 +2 ] + +-0.148f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.291f /2 * rgb24[j *8 +1 ] + +-0.291f /2 * rgb24[j *8 +1 + rgb24_stride] + +0.439f /2 * rgb24[j *8 ] + +0.439f /2 * rgb24[j *8 + rgb24_stride] +128 ; +float vf =0.439f /2 * rgb24[j *8 +2 ] + +0.439f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.368f /2 * rgb24[j *8 +1 ] + +-0.368f /2 * rgb24[j *8 +1 + rgb24_stride] + +-0.071f /2 * rgb24[j *8 ] + +-0.071f /2 * rgb24[j *8 + rgb24_stride] +128 ; + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + + rgb24 +=2 * rgb24_stride; + uv += planar_stride; + } + +/* Last row cannot be interpolated between 2 pixels, take the single value */ +if (i < fb->plane_height[1 ]) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +float uf =-0.148f * rgb24[j *8 +2 ] + +-0.291f * rgb24[j *8 +1 ] + +0.439f * rgb24[j *8 ] +128 ; +float vf =0.439f * rgb24[j *8 +2 ] + +-0.368f * rgb24[j *8 +1 ] + +-0.071f * rgb24[j *8 ] +128 ; + + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + } +} + +static void destroy_cairo_surface__convert (void *arg) +{ +struct fb_convert_blit_upload *blit = arg; +struct igt_fb *fb = blit->fb; + +/* Convert back to planar! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +convert_rgb24_to_nv12 (fb, blit); + +munmap (blit->rgb24.map, blit->rgb24.size); + +if (blit->linear.handle) +free_linear_mapping (blit->fd, blit->fb, &blit->linear); +else +gem_munmap (blit->linear.map, fb->size); + +free (blit); + + fb->cairo_surface =NULL ; +} + +static void create_cairo_surface__convert (int fd,struct igt_fb *fb) +{ +struct fb_convert_blit_upload *blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; + blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); + blit->rgb24.size =ALIGN (blit->rgb24.stride * fb->height,sysconf (_SC_PAGESIZE)); + blit->rgb24.map =mmap (NULL , blit->rgb24.size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 ); +igt_assert (blit->rgb24.map !=MAP_FAILED ); + +if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { +setup_linear_mapping (fd, fb, &blit->linear); + }else { + blit->linear.handle =0 ; + blit->linear.map =gem_mmap__gtt (fd, fb->gem_handle, fb->size, +PROT_READ |PROT_WRITE ); +igt_assert (blit->linear.map); + blit->linear.stride = fb->stride; + blit->linear.size = fb->size; +memcpy (blit->linear.offsets, fb->offsets,sizeof (fb->offsets)); + } + +/* Convert to linear! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); +convert_nv12_to_rgb24 (fb, blit); + + fb->cairo_surface = +cairo_image_surface_create_for_data (blit->rgb24.map, +CAIRO_FORMAT_RGB24 , + fb->width, fb->height, + blit->rgb24.stride); + +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t *)create_cairo_surface__convert, + blit, destroy_cairo_surface__convert); +} +/** * igt_get_cairo_surface: * @fd: open drm file descriptor @@ -1298,11 +1546,10 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)*/ cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb) { -/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */ -igt_assert (fb->num_planes <2 ); -if (fb->cairo_surface ==NULL ) { -if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || +if (fb->num_planes >1 ) +create_cairo_surface__convert (fd, fb); +else if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)create_cairo_surface__blit (fd, fb);else Signature · 6 lines
2.15.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for NV12 format through conversion, v2.
Op 01-02-18 om 15:23 schreef Ville Syrjälä:
Quoted 509 lines · Maarten Lankhorst
Quoted 31 lines
For NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.601 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y:
Y Y Y Y UV UV Y Y Y YSome work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO.
When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising even further for me.
Changes since v1:
- Use BT.601 instead of BT.709 coefficients. (Ville)Signed-off-by Maarten Lankhorst <[email protected]>--- lib/igt_fb.c | 391 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 319 insertions(+), 72 deletions(-)lib/igt_fb.c +0
-0lib/igt_fb.c static struct format_desc_struct { · line 73
Quoted 4 lines
lib/igt_fb.c +1
-0@@ -70,6 +70,7 @@ static struct format_desc_struct {DF (XRGB8888 ,RGB24 ,32 ,24 ),DF (XRGB2101010 ,RGB30 ,32 ,30 ),DF (ARGB8888 ,ARGB32 ,32 ,32 ), + DF(NV12, RGB24, 32, -1, 2, {8, 16}),This is getting pretty much unredable. Switching to named initializers as a followup might seem prudent.
Quoted 266 lines
lib/igt_fb.c +140
-68};#undef DF@@ -364,14 +365,20 @@ static int create_bo_for_fb(int fd, int width, int height, *is_dumb = false;if (is_i915_device (fd)) { -uint32_t *ptr; +uint8_t *ptr; bo =gem_create (fd, size);gem_set_tiling (fd, bo,igt_fb_mod_to_tiling (tiling), stride);/* Ensure the framebuffer is preallocated */ - ptr =gem_mmap__gtt (fd, bo, size,PROT_READ ); -igt_assert (*ptr ==0 ); + ptr =gem_mmap__gtt (fd, bo, size,PROT_READ |PROT_WRITE ); +igt_assert (*(uint32_t *)ptr ==0 ); + +if (format->drm_id ==DRM_FORMAT_NV12 ) { +/* component formats have a different zero point */ +memset (ptr,16 , offsets[1 ]); +memset (ptr + offsets[1 ],0x80 , (height +1 )/2 * stride); + }gem_munmap (ptr, size);if (size_ret)@@ -1127,103 +1134,117 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format) drm_format, igt_format_str(drm_format)); } +struct fb_blit_linear { +uint32_t handle; +unsigned size, stride; +uint8_t *map; +bool is_dumb; +uint32_t offsets[4 ]; +}; +struct fb_blit_upload {int fd;struct igt_fb *fb; -struct { -uint32_t handle; -unsigned size, stride; -uint8_t *map; -bool is_dumb; - } linear; +struct fb_blit_linear linear; }; -static void destroy_cairo_surface__blit (void *arg) +static void free_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit = arg; -struct igt_fb *fb = blit->fb;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); +int i; -gem_munmap (blit->linear.map, blit->linear.size); - fb->cairo_surface =NULL ; +gem_munmap (linear->map, linear->size); +gem_set_domain (fd, linear->handle, +I915_GEM_DOMAIN_GTT ,0 ); + +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + linear->handle, + linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); +gem_close (fd, linear->handle); +} -gem_set_domain (blit->fd, blit->linear.handle, -I915_GEM_DOMAIN_GTT ,0 ); +static void destroy_cairo_surface__blit (void *arg) +{ +struct fb_blit_upload *blit = arg; -igt_blitter_fast_copy__raw (blit->fd, - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (blit->fd, blit->linear.handle); -gem_close (blit->fd, blit->linear.handle); + blit->fb->cairo_surface =NULL ; + +free_linear_mapping (blit->fd, blit->fb, &blit->linear);free (blit); } -static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +static void setup_linear_mapping (int fd,struct igt_fb *fb,struct fb_blit_linear *linear) { -struct fb_blit_upload *blit; -cairo_format_t cairo_format;unsigned int obj_tiling =igt_fb_mod_to_tiling (fb->tiling); -uint32_t offsets[4 ]; - - blit =malloc (sizeof (*blit)); -igt_assert (blit); +int i;/* * We create a linear BO that we'll map for the CPU to write to (using * cairo). This linear bo will be then blitted to its final * destination, tiling it at the same time. */ - blit->linear.handle =create_bo_for_fb (fd, fb->width, fb->height, + linear->handle =create_bo_for_fb (fd, fb->width, fb->height,lookup_drm_format (fb->drm_format),LOCAL_DRM_FORMAT_MOD_NONE ,0 , -0 , &blit->linear.size, - &blit->linear.stride, - offsets, &blit->linear.is_dumb); - -igt_assert (blit->linear.handle >0 ); +0 , &linear->size, + &linear->stride, + linear->offsets, &linear->is_dumb); - blit->fd = fd; - blit->fb = fb; +igt_assert (linear->handle >0 );/* Copy fb content to linear BO */ -gem_set_domain (fd, blit->linear.handle, +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_GTT ,0 ); -igt_blitter_fast_copy__raw (fd, - fb->gem_handle, - fb->offsets[0 ], - fb->stride, - obj_tiling, -0 ,0 ,/* src_x, src_y */ - fb->width, fb->height, -igt_drm_format_to_bpp (fb->drm_format), - blit->linear.handle,0 , - blit->linear.stride, -I915_TILING_NONE , -0 ,0 /* dst_x, dst_y */ ); - -gem_sync (fd, blit->linear.handle); - -gem_set_domain (fd, blit->linear.handle, +for (i =0 ; i < fb->num_planes; i++) +igt_blitter_fast_copy__raw (fd, + fb->gem_handle, + fb->offsets[i], + fb->stride, + obj_tiling, +0 ,0 ,/* src_x, src_y */ + fb->plane_width[i], fb->plane_height[i], + fb->plane_bpp[i], + linear->handle, linear->offsets[i], + linear->stride, +I915_TILING_NONE , +0 ,0 /* dst_x, dst_y */ ); + +gem_sync (fd, linear->handle); + +gem_set_domain (fd, linear->handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU );/* Setup cairo context */ - blit->linear.map =gem_mmap__cpu (fd, - blit->linear.handle, -0 , - blit->linear.size, -PROT_READ |PROT_WRITE ); + linear->map =gem_mmap__cpu (fd, linear->handle, +0 , linear->size,PROT_READ |PROT_WRITE ); +} + +static void create_cairo_surface__blit (int fd,struct igt_fb *fb) +{ +struct fb_blit_upload *blit; +cairo_format_t cairo_format; + + blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; +setup_linear_mapping (fd, fb, &blit->linear); cairo_format =drm_format_to_cairo (fb->drm_format); fb->cairo_surface =@@ -1285,6 +1306,233 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); } +struct fb_convert_blit_upload { +int fd; +struct igt_fb *fb; + +struct { +uint8_t *map; +unsigned stride, size; + } rgb24; + +struct fb_blit_linear linear; +}; + +static uint8_t clamprgb (float val) { +if (val <0 ) +return 0 ; +if (val >255 ) +return 255 ; + +return (uint8_t )val; +} + +static void convert_nv12_to_rgb24 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +const uint8_t *y, *uv; +uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride, planar_stride = blit->linear.stride; +uint8_t *buf =malloc (blit->linear.size); + +/* +* Reading from the BO is awfully slow because of lack of read caching, +* it's faster to copy the whole BO to a temporary buffer and convert +* from there. +*/ +memcpy (buf, blit->linear.map, blit->linear.size); + y = &buf[blit->linear.offsets[0 ]]; + uv = &buf[blit->linear.offsets[1 ]]; + +/* Convert from limited color range BT.601 */ +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, y1, cb, cr; +/* Convert 1x2 pixel blocks */ + + y0 =1.164f * (y[j] -16.f ); + y1 =1.164f * (y[j + planar_stride] -16.f ); + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + r_ =0.000f * cb +1.596f * cr; + g_ =-0.392f * cb +-0.813f * cr;lib/igt_fb.c static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) · line 1370
Quoted 10 lines
lib/igt_fb.c +10
-0+ b_ =2.017f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +2 + rgb24_stride] =clamprgb (y1 + r_); + + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 +1 + rgb24_stride] =clamprgb (y1 + g_); + + rgb24[j *4 ] =clamprgb (y0 + b_); + rgb24[j *4 + rgb24_stride] =clamprgb (y1 + b_);Just replicating the same chroma for four pixels is pretty crude, but since this is for testing I guess we don't really care. Given that I guess we could even process in 2x2 blocks instead.
The coefficients looks correct enough to me.
Reviewed-by Ville Syrjälä <[email protected]>Quoted 186 lines
lib/igt_fb.c +168
-4+ } + + rgb24 +=2 * rgb24_stride; + y +=2 * planar_stride; + uv += planar_stride; + } + +if (fb->height &1 ) { +/* Convert last row */ +for (j =0 ; j < fb->width; j++) { +float r_, g_, b_, y0, cb, cr; +/* Convert single pixel */ + + cb = uv[j & ~1 ] -128.f ; + cr = uv[j |1 ] -128.f ; + + y0 =1.164f * (y[j] -16.f ); + r_ =0.000f * cb +1.596f * cr; + g_ =-0.392f * cb +-0.813f * cr; + b_ =2.017f * cb +0.000f * cr; + + rgb24[j *4 +2 ] =clamprgb (y0 + r_); + rgb24[j *4 +1 ] =clamprgb (y0 + g_); + rgb24[j *4 ] =clamprgb (y0 + b_); + } + } + +free (buf); +} + +static void convert_rgb24_to_nv12 (struct igt_fb *fb,struct fb_convert_blit_upload *blit) +{ +int i, j; +uint8_t *y = &blit->linear.map[blit->linear.offsets[0 ]]; +uint8_t *uv = &blit->linear.map[blit->linear.offsets[1 ]]; +const uint8_t *rgb24 = blit->rgb24.map; +unsigned rgb24_stride = blit->rgb24.stride; +unsigned planar_stride = blit->linear.stride; + +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +for (i =0 ; i < fb->plane_height[0 ]; i++) { +/* Use limited color range BT.601 */ + +for (j =0 ; j < fb->plane_width[0 ]; j++) { +float yf =0.257f * rgb24[j *4 +2 ] + +0.504f * rgb24[j *4 +1 ] + +0.098f * rgb24[j *4 ] +16 ; + + y[j] = (uint8_t )yf; + } + + rgb24 += rgb24_stride; + y += planar_stride; + } + + rgb24 = blit->rgb24.map; + +for (i =0 ; i < fb->height /2 ; i++) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +/* +* Pixel center for Cb'Cr' is between the left top and +* bottom pixel in a 2x2 block, so take the average. +*/ +float uf =-0.148f /2 * rgb24[j *8 +2 ] + +-0.148f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.291f /2 * rgb24[j *8 +1 ] + +-0.291f /2 * rgb24[j *8 +1 + rgb24_stride] + +0.439f /2 * rgb24[j *8 ] + +0.439f /2 * rgb24[j *8 + rgb24_stride] +128 ; +float vf =0.439f /2 * rgb24[j *8 +2 ] + +0.439f /2 * rgb24[j *8 +2 + rgb24_stride] + +-0.368f /2 * rgb24[j *8 +1 ] + +-0.368f /2 * rgb24[j *8 +1 + rgb24_stride] + +-0.071f /2 * rgb24[j *8 ] + +-0.071f /2 * rgb24[j *8 + rgb24_stride] +128 ; + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + + rgb24 +=2 * rgb24_stride; + uv += planar_stride; + } + +/* Last row cannot be interpolated between 2 pixels, take the single value */ +if (i < fb->plane_height[1 ]) { +for (j =0 ; j < fb->plane_width[1 ]; j++) { +float uf =-0.148f * rgb24[j *8 +2 ] + +-0.291f * rgb24[j *8 +1 ] + +0.439f * rgb24[j *8 ] +128 ; +float vf =0.439f * rgb24[j *8 +2 ] + +-0.368f * rgb24[j *8 +1 ] + +-0.071f * rgb24[j *8 ] +128 ; + + uv[j *2 ] = (uint8_t )uf; + uv[j *2 +1 ] = (uint8_t )vf; + } + } +} + +static void destroy_cairo_surface__convert (void *arg) +{ +struct fb_convert_blit_upload *blit = arg; +struct igt_fb *fb = blit->fb; + +/* Convert back to planar! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); + +convert_rgb24_to_nv12 (fb, blit); + +munmap (blit->rgb24.map, blit->rgb24.size); + +if (blit->linear.handle) +free_linear_mapping (blit->fd, blit->fb, &blit->linear); +else +gem_munmap (blit->linear.map, fb->size); + +free (blit); + + fb->cairo_surface =NULL ; +} + +static void create_cairo_surface__convert (int fd,struct igt_fb *fb) +{ +struct fb_convert_blit_upload *blit =malloc (sizeof (*blit)); +igt_assert (blit); + + blit->fd = fd; + blit->fb = fb; + blit->rgb24.stride =ALIGN (fb->width *4 ,16 ); + blit->rgb24.size =ALIGN (blit->rgb24.stride * fb->height,sysconf (_SC_PAGESIZE)); + blit->rgb24.map =mmap (NULL , blit->rgb24.size,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 ); +igt_assert (blit->rgb24.map !=MAP_FAILED ); + +if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) { +setup_linear_mapping (fd, fb, &blit->linear); + }else { + blit->linear.handle =0 ; + blit->linear.map =gem_mmap__gtt (fd, fb->gem_handle, fb->size, +PROT_READ |PROT_WRITE ); +igt_assert (blit->linear.map); + blit->linear.stride = fb->stride; + blit->linear.size = fb->size; +memcpy (blit->linear.offsets, fb->offsets,sizeof (fb->offsets)); + } + +/* Convert to linear! */ +igt_assert_f (fb->drm_format ==DRM_FORMAT_NV12 , +"Conversion not implemented for !NV12 planar formats\n" ); +convert_nv12_to_rgb24 (fb, blit); + + fb->cairo_surface = +cairo_image_surface_create_for_data (blit->rgb24.map, +CAIRO_FORMAT_RGB24 , + fb->width, fb->height, + blit->rgb24.stride); + +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t *)create_cairo_surface__convert, + blit, destroy_cairo_surface__convert); +} +/** * igt_get_cairo_surface: * @fd: open drm file descriptor @@ -1298,11 +1546,10 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)*/ cairo_surface_t *igt_get_cairo_surface (int fd,struct igt_fb *fb) { -/* This doesn't work for planar formats for now, but we will convert them to RGB24 in the future. */ -igt_assert (fb->num_planes <2 ); -if (fb->cairo_surface ==NULL ) { -if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || +if (fb->num_planes >1 ) +create_cairo_surface__convert (fd, fb); +else if (fb->tiling ==LOCAL_I915_FORMAT_MOD_Y_TILED || fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)create_cairo_surface__blit (fd, fb);else Signature · 1 line
2.15.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Thanks, pushed!
~Maarten
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for lib/igt_fb: Add support for the NV12 format.
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format.
URL : https://patchwork.freedesktop.org/series/36965/
State : failure
== Summary ==
IGT patchset tested on top of latest successful build cb2e65dae7e8ca3f388f43aeec3e7d7dc5d2cfb4 man: Update for new igt-dev mailing list
with latest DRM-Tip kernel build CI_DRM_3673cbdcbeb1eb09 drm-tip: 2018y-01m-23d-13h-00m-40s UTC integration manifest
No testlist changes.
Test debugfs_test:
Subgroup read_all_entries:
dmesg-fail -> DMESG-WARN (fi-elk-e7500) fdo#103989
Test kms_addfb_basic:
Subgroup addfb25-bad-modifier:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup addfb25-framebuffer-vs-set-tiling:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup addfb25-modifier-no-flag:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup addfb25-x-tiled:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup addfb25-x-tiled-mismatch:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup addfb25-yf-tiled:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup addfb25-y-tiled:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup addfb25-y-tiled-small:
skip -> FAIL (fi-gdg-551)
skip -> FAIL (fi-blb-e6850)
skip -> FAIL (fi-pnv-d510)
skip -> FAIL (fi-bwr-2160)
skip -> FAIL (fi-elk-e7500)
skip -> FAIL (fi-ilk-650)
skip -> FAIL (fi-snb-2520m)
skip -> FAIL (fi-snb-2600)
skip -> FAIL (fi-ivb-3520m)
skip -> FAIL (fi-ivb-3770)
skip -> FAIL (fi-byt-j1900)
skip -> FAIL (fi-byt-n2820)
skip -> FAIL (fi-hsw-4770)
skip -> FAIL (fi-hsw-4770r)
skip -> FAIL (fi-bdw-5557u)
skip -> FAIL (fi-bdw-gvtdvm)
skip -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup bad-pitch-0:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup bad-pitch-1024:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup bad-pitch-128:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557u)
pass -> FAIL (fi-bdw-gvtdvm)
pass -> FAIL (fi-bsw-n3050)
pass -> FAIL (fi-skl-6260u)
pass -> FAIL (fi-skl-6600u)
pass -> FAIL (fi-skl-6700hq)
pass -> FAIL (fi-skl-6700k2)
pass -> FAIL (fi-skl-6770hq)
pass -> FAIL (fi-skl-guc)
pass -> FAIL (fi-skl-gvtdvm)
pass -> FAIL (fi-bxt-dsi)
pass -> FAIL (fi-bxt-j4205)
pass -> FAIL (fi-kbl-7500u)
pass -> FAIL (fi-kbl-7560u)
pass -> FAIL (fi-kbl-r)
pass -> FAIL (fi-glk-1)
Subgroup bad-pitch-256:
pass -> FAIL (fi-gdg-551)
pass -> FAIL (fi-blb-e6850)
pass -> FAIL (fi-pnv-d510)
pass -> FAIL (fi-bwr-2160)
pass -> FAIL (fi-elk-e7500)
pass -> FAIL (fi-ilk-650)
pass -> FAIL (fi-snb-2520m)
pass -> FAIL (fi-snb-2600)
pass -> FAIL (fi-ivb-3520m)
pass -> FAIL (fi-ivb-3770)
pass -> FAIL (fi-byt-j1900)
pass -> FAIL (fi-byt-n2820)
pass -> FAIL (fi-hsw-4770)
pass -> FAIL (fi-hsw-4770r)
pass -> FAIL (fi-bdw-5557== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_816/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Add support for the NV12 format. (rev2)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev2)
URL : https://patchwork.freedesktop.org/series/36965/
State : success
== Summary ==
IGT patchset tested on top of latest successful build 37bd27f28a868c287faf361864a16e77b8d9246f tools/intel_vbt_decode: add --describe option
with latest DRM-Tip kernel build CI_DRM_3673cbdcbeb1eb09 drm-tip: 2018y-01m-23d-13h-00m-40s UTC integration manifest
No testlist changes.
Test debugfs_test:
Subgroup read_all_entries:
dmesg-fail -> DMESG-WARN (fi-elk-e7500) fdo#103989fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:423s fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:436s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:376s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:491s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:281s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:485s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:488s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:471s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:459s fi-elk-e7500 total:224 pass:168 dwarn:10 dfail:0 fail:0 skip:45 fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:278s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:514s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:393s fi-hsw-4770r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:400s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:413s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:451s fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:421s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:461s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:500s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:501s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:583s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:431s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:512s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:530s fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:494s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:482s fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:418s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:434s fi-snb-2520m total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:518s fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:405s Blacklisted hosts: fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:566s fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:473s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_817/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.IGT: failure for lib/igt_fb: Add support for the NV12 format.
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format.
URL : https://patchwork.freedesktop.org/series/36965/
State : failure
== Summary ==
Test kms_addfb_basic:
Subgroup size-max:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-63:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-32:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup invalid-get-prop-any:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup unused-handle:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bo-too-small:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-128:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-yf-tiled:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-0:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-bad-modifier:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-x-tiled-mismatch:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-modifier-no-flag:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup tile-pitch-mismatch:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup invalid-get-prop:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-apl)
Subgroup unused-pitches:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup unused-modifier:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup clobberred-modifier:
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-y-tiled:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-x-tiled:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup too-high:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-65536:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-1024:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup no-handle:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup too-wide:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bo-too-small-due-to-tiling:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-y-tiled-small:
skip -> FAIL (shard-snb)
skip -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup small-bo:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup invalid-set-prop-any:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-256:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup unused-offsets:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup basic-x-tiled:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup addfb25-framebuffer-vs-set-tiling:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup invalid-set-prop:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup framebuffer-vs-set-tiling:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup basic-y-tiled:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup basic:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup bad-pitch-999:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Test kms_draw_crc:
Subgroup draw-method-xrgb8888-mmap-cpu-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-blt-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-mmap-cpu-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-render-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-mmap-cpu-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-render-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-render-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-mmap-gtt-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl) fdo#103326
Subgroup draw-method-rgb565-render-xtiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
skip -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-mmap-gtt-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-pwrite-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-render-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
skip -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-mmap-gtt-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-pwrite-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-blt-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-mmap-wc-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-mmap-gtt-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-pwrite-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-mmap-cpu-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-pwrite-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-pwrite-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-mmap-wc-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-mmap-wc-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-blt-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-blt-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-mmap-wc-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-mmap-cpu-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-render-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-mmap-cpu-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-mmap-gtt-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-pwrite-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-blt-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-blt-xtiled:
pass -> CRASH (shard-snb)
pass -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb8888-mmap-wc-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-xrgb2101010-mmap-gtt-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Subgroup draw-method-rgb565-mmap-wc-ytiled:
skip -> CRASH (shard-snb)
skip -> CRASH (shard-hsw)
pass -> CRASH (shard-apl)
Test kms_rotation_crc:
Subgroup sprite-rotation-90:
pass -> FAIL (shard-apl) fdo#103356 +4
Subgroup primary-rotation-90-flip:
pass -> FAIL (shard-apl) fdo#103925 +2
Subgroup primary-rotation-270:
pass -> FAIL (shard-apl)
Subgroup primary-rotation-270-flip:
pass -> FAIL (shard-apl) fdo#103511
Test kms_flip:
Subgroup 2x-flip-vs-expired-vblank:
pass -> FAIL (shard-hsw) fdo#102887
Subgroup flip-vs-modeset-vs-hang:
pass -> DMESG-WARN (shard-snb) fdo#103821 +1
Subgroup vblank-vs-modeset-suspend-interruptible:
skip -> PASS (shard-hsw) fdo#103540 +1
Subgroup plain-flip-fb-recreate:
pass -> FAIL (shard-apl) fdo#100368
Test perf:
Subgroup oa-exponents:
pass -> FAIL (shard-apl) fdo#102254
Test kms_busy:
Subgroup extended-pageflip-hang-newfb-render-b:
skip -> PASS (shard-snb)
Test gem_eio:
Subgroup in-flight-suspend:
fail -> PASS (shard-hsw) fdo#104676 +1
Test kms_render:
Subgroup gpu-blit:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup direct-render:
pass -> FAIL (shard-snb) fdo#104312
pass -> FAIL (shard-hsw) fdo#102614
pass -> FAIL (shard-apl)
Test kms_vblank:
Subgroup query-forked-busy:
skip -> PASS (shard-snb)
Subgroup query-busy:
skip -> PASS (shard-snb)fdo#103326 https://bugs.freedesktop.org/show_bug.cgi?id=103326
fdo#103356 https://bugs.freedesktop.org/show_bug.cgi?id=103356
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#103511 https://bugs.freedesktop.org/show_bug.cgi?id=103511
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#103821 https://bugs.freedesktop.org/show_bug.cgi?id=103821
fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#104676 https://bugs.freedesktop.org/show_bug.cgi?id=104676
fdo#104312 https://bugs.freedesktop.org/show_bug.cgi?id=104312
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
shard-apl total:2753 pass:1631 dwarn:1 dfail:0 fail:73 skip:1011 time:13913s shard-hsw total:2753 pass:1670 dwarn:1 dfail:0 fail:50 skip:995 time:15254s shard-snb total:2753 pass:1261 dwarn:3 dfail:0 fail:50 skip:1403 time:7907s
Blacklisted hosts:
shard-kbl total:2747 pass:1732 dwarn:14 dfail:2 fail:74 skip:888 time:10411s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_816/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.IGT: failure for lib/igt_fb: Add support for the NV12 format. (rev2)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev2)
URL : https://patchwork.freedesktop.org/series/36965/
State : failure
== Summary ==
Test perf:
Subgroup oa-exponents:
pass -> FAIL (shard-apl) fdo#102254
Test drv_suspend:
Subgroup forcewake:
pass -> SKIP (shard-snb)
Test kms_rotation_crc:
Subgroup sprite-rotation-90-pos-100-0:
pass -> FAIL (shard-apl) fdo#103356 +4
Subgroup primary-rotation-90:
pass -> FAIL (shard-apl) fdo#103925 +2
Subgroup primary-rotation-270-flip:
pass -> FAIL (shard-apl) fdo#103511
Subgroup primary-rotation-270:
pass -> FAIL (shard-apl)
Test kms_cursor_crc:
Subgroup cursor-256x256-suspend:
pass -> SKIP (shard-snb) fdo#103375
Test kms_flip:
Subgroup vblank-vs-modeset-suspend-interruptible:
skip -> PASS (shard-hsw) fdo#103540 +1
Test kms_vblank:
Subgroup query-idle:
pass -> INCOMPLETE (shard-hsw)
Subgroup query-busy:
skip -> PASS (shard-snb)
Subgroup query-forked-busy:
skip -> PASS (shard-snb)
Test kms_render:
Subgroup gpu-blit:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup direct-render:
pass -> FAIL (shard-snb) fdo#104312
pass -> FAIL (shard-hsw) fdo#102614
pass -> FAIL (shard-apl)
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-offscren-pri-shrfb-draw-blt:
pass -> FAIL (shard-snb) fdo#101623
Test kms_sysfs_edid_timing:
warn -> PASS (shard-apl) fdo#100047
Test gem_eio:
Subgroup in-flight-external:
fail -> PASS (shard-hsw) fdo#104676
Test kms_busy:
Subgroup extended-pageflip-hang-newfb-render-b:
skip -> PASS (shard-snb)fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#103356 https://bugs.freedesktop.org/show_bug.cgi?id=103356
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#103511 https://bugs.freedesktop.org/show_bug.cgi?id=103511
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#104312 https://bugs.freedesktop.org/show_bug.cgi?id=104312
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
fdo#104676 https://bugs.freedesktop.org/show_bug.cgi?id=104676
shard-apl total:2753 pass:1704 dwarn:1 dfail:0 fail:35 skip:1013 time:13947s shard-hsw total:2646 pass:1669 dwarn:1 dfail:0 fail:11 skip:963 time:13864s shard-snb total:2753 pass:1314 dwarn:1 dfail:0 fail:13 skip:1425 time:7853s
Blacklisted hosts:
shard-kbl total:2753 pass:1816 dwarn:14 dfail:0 fail:36 skip:887 time:10908s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_817/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Add support for the NV12 format. (rev3)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev3)
URL : https://patchwork.freedesktop.org/series/36965/
State : success
== Summary ==
IGT patchset tested on top of latest successful build 63f7ef01908c9925bbacbbbac76fdc0ba15967c5 kms_vblank: Remove teardown code from cleanup_crtc
with latest DRM-Tip kernel build CI_DRM_3680ef2011c63806 drm-tip: 2018y-01m-24d-09h-45m-08s UTC integration manifest
No testlist changes.
Test debugfs_test:
Subgroup read_all_entries:
dmesg-fail -> DMESG-WARN (fi-elk-e7500) fdo#103989 +1
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
incomplete -> PASS (fi-snb-2520m) fdo#103713fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:418s fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:425s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:374s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:496s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:281s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:489s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:487s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:471s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:460s fi-elk-e7500 total:224 pass:169 dwarn:9 dfail:0 fail:0 skip:45 fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:280s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:528s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:392s fi-hsw-4770r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:404s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:413s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:454s fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:425s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:461s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:497s fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:454s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:504s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:592s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:429s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:511s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:532s fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:490s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:477s fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:416s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:437s fi-snb-2520m total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:531s fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:401s Blacklisted hosts: fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:571s fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:473s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_819/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.IGT: failure for lib/igt_fb: Add support for the NV12 format. (rev3)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev3)
URL : https://patchwork.freedesktop.org/series/36965/
State : failure
== Summary ==
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-offscren-pri-shrfb-draw-blt:
pass -> FAIL (shard-snb) fdo#101623 +1
Test perf:
Subgroup oa-exponents:
pass -> FAIL (shard-apl) fdo#102254
Test kms_flip:
Subgroup 2x-plain-flip-ts-check-interruptible:
pass -> FAIL (shard-hsw)
Subgroup flip-vs-expired-vblank:
pass -> FAIL (shard-apl) fdo#102887
Test kms_render:
Subgroup direct-render:
pass -> FAIL (shard-snb) fdo#104312
pass -> FAIL (shard-hsw) fdo#102614
pass -> FAIL (shard-apl)
Subgroup gpu-blit:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Test gem_exec_suspend:
Subgroup basic-s3:
skip -> PASS (shard-snb) fdo#103880fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#104312 https://bugs.freedesktop.org/show_bug.cgi?id=104312
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#103880 https://bugs.freedesktop.org/show_bug.cgi?id=103880
shard-apl total:2838 pass:1748 dwarn:1 dfail:0 fail:27 skip:1062 time:12613s shard-hsw total:2838 pass:1732 dwarn:1 dfail:0 fail:14 skip:1090 time:11816s shard-snb total:2838 pass:1326 dwarn:1 dfail:0 fail:14 skip:1497 time:6621s
Blacklisted hosts:
shard-kbl total:2838 pass:1861 dwarn:9 dfail:0 fail:26 skip:942 time:9646s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_819/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Add support for the NV12 format. (rev4)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev4)
URL : https://patchwork.freedesktop.org/series/36965/
State : success
== Summary ==
IGT patchset tested on top of latest successful build 2649a091a0a67e6d4106024fb6d74cf7119f350f lib: Refactor igt_wait() to use library timers
with latest DRM-Tip kernel build CI_DRM_36892bbded26cfa2 drm-tip: 2018y-01m-29d-10h-43m-15s UTC integration manifest
No testlist changes.
Test debugfs_test:
Subgroup read_all_entries:
pass -> INCOMPLETE (fi-snb-2520m) fdo#103713fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:430s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:376s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:493s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:282s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:485s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:498s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:480s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:460s fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:574s fi-elk-e7500 total:224 pass:168 dwarn:9 dfail:1 fail:0 skip:45 fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:282s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:515s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:396s fi-hsw-4770r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:400s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:414s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:451s fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:423s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:460s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:499s fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:452s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:503s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:583s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:437s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:512s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:529s fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:491s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:494s fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:419s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:435s fi-snb-2520m total:3 pass:2 dwarn:0 dfail:0 fail:0 skip:0 fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:407s Blacklisted hosts: fi-cnl-y2 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:531s fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:472s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_830/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.IGT: failure for lib/igt_fb: Add support for the NV12 format. (rev4)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev4)
URL : https://patchwork.freedesktop.org/series/36965/
State : failure
== Summary ==
Test syncobj_wait:
Subgroup wait-any-snapshot:
fail -> PASS (shard-apl)
Test kms_flip:
Subgroup flip-vs-modeset-vs-hang:
pass -> DMESG-WARN (shard-snb) fdo#103821
Test gem_eio:
Subgroup in-flight:
dmesg-warn -> PASS (shard-snb) fdo#104058
Test kms_render:
Subgroup gpu-blit:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup direct-render:
pass -> FAIL (shard-snb) fdo#104312
pass -> FAIL (shard-hsw) fdo#102614
pass -> FAIL (shard-apl)
Test kms_plane:
Subgroup plane-panning-bottom-right-suspend-pipe-a-planes:
skip -> PASS (shard-snb) fdo#102365
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-pri-shrfb-draw-blt:
dmesg-fail -> PASS (shard-apl) fdo#101623 +2
Test perf_pmu:
Subgroup frequency:
fail -> PASS (shard-apl) fdo#104829
Test kms_plane_multiple:
Subgroup atomic-pipe-b-tiling-none:
pass -> FAIL (shard-apl) fdo#103166
Test gem_tiled_swapping:
Subgroup non-threaded:
pass -> SKIP (shard-apl)fdo#103821 https://bugs.freedesktop.org/show_bug.cgi?id=103821
fdo#104058 https://bugs.freedesktop.org/show_bug.cgi?id=104058
fdo#104312 https://bugs.freedesktop.org/show_bug.cgi?id=104312
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#104829 https://bugs.freedesktop.org/show_bug.cgi?id=104829
fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
shard-apl total:2838 pass:1749 dwarn:1 dfail:0 fail:23 skip:1065 time:12698s shard-hsw total:2838 pass:1734 dwarn:1 dfail:0 fail:12 skip:1090 time:11881s shard-snb total:2838 pass:1327 dwarn:2 dfail:0 fail:12 skip:1497 time:6567s
Blacklisted hosts:
shard-kbl total:2838 pass:1847 dwarn:22 dfail:2 fail:24 skip:943 time:9529s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_830/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for lib/igt_fb: Add support for the NV12 format. (rev5)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev5)
URL : https://patchwork.freedesktop.org/series/36965/
State : success
== Summary ==
IGT patchset tested on top of latest successful build 7f0be0e7d9becb79630093bf0e6daeadcd937062 tools/intel_reg: Add reading and writing registers through engine
with latest DRM-Tip kernel build CI_DRM_3708ae93f9b9acf3 drm-tip: 2018y-01m-31d-16h-31m-38s UTC integration manifest
No testlist changes.
Test kms_chamelium:
Subgroup common-hpd-after-suspend:
dmesg-warn -> PASS (fi-skl-6700k2) fdo#104108
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
incomplete -> PASS (fi-snb-2520m) fdo#103713fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:418s fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:425s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:372s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:488s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:282s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:483s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:486s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:468s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:454s fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:578s fi-elk-e7500 total:224 pass:168 dwarn:10 dfail:0 fail:0 skip:45 fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:281s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:512s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:390s fi-hsw-4770r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:403s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:419s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:452s fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:413s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:457s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:497s fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:456s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:498s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:579s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:436s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:505s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:528s fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:493s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:472s fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:418s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:432s fi-snb-2520m total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:530s fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:405s
Blacklisted hosts:
fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:469s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_842/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.IGT: failure for lib/igt_fb: Add support for the NV12 format. (rev5)
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_fb: Add support for the NV12 format. (rev5)
URL : https://patchwork.freedesktop.org/series/36965/
State : failure
== Summary ==
Test kms_flip:
Subgroup blocking-wf_vblank:
pass -> FAIL (shard-hsw) fdo#103928
Subgroup wf_vblank-ts-check-interruptible:
fail -> PASS (shard-apl) fdo#100368
Subgroup modeset-vs-vblank-race-interruptible:
fail -> PASS (shard-apl) fdo#103060
Subgroup basic-plain-flip:
skip -> PASS (shard-apl)
Subgroup flip-vs-modeset-vs-hang-interruptible:
pass -> DMESG-WARN (shard-snb) fdo#104311
Subgroup flip-vs-expired-vblank:
pass -> FAIL (shard-snb)
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-shrfb-pgflip-blt:
fail -> PASS (shard-apl) fdo#101623 +2
Subgroup fbc-shrfb-scaledprimary:
skip -> PASS (shard-apl) fdo#103167 +1
Subgroup fbc-rgb101010-draw-mmap-gtt:
skip -> PASS (shard-apl)
Test kms_rmfb:
Subgroup rmfb-ioctl:
skip -> PASS (shard-apl)
Test perf_pmu:
Subgroup frequency:
pass -> FAIL (shard-apl) fdo#104829
Test kms_cursor_legacy:
Subgroup cursor-vs-flip-legacy:
pass -> FAIL (shard-apl) fdo#103355
Subgroup cursora-vs-flipa-atomic:
skip -> PASS (shard-apl)
Subgroup basic-flip-after-cursor-varying-size:
skip -> PASS (shard-apl) fdo#102670
Test kms_vblank:
Subgroup crtc-id:
skip -> PASS (shard-apl)
Subgroup pipe-b-accuracy-idle:
skip -> FAIL (shard-apl)
Subgroup pipe-c-wait-forked-busy:
skip -> PASS (shard-apl)
Subgroup pipe-a-ts-continuation-dpms-suspend:
pass -> FAIL (shard-snb)
Subgroup pipe-c-ts-continuation-suspend:
dmesg-warn -> PASS (shard-apl)
Subgroup pipe-a-query-busy:
skip -> PASS (shard-apl)
Test kms_draw_crc:
Subgroup draw-method-xrgb8888-render-untiled:
skip -> PASS (shard-apl)
Subgroup draw-method-xrgb2101010-render-xtiled:
skip -> PASS (shard-apl)
Test kms_cursor_crc:
Subgroup cursor-256x256-dpms:
skip -> PASS (shard-apl)
Subgroup cursor-128x42-random:
skip -> PASS (shard-apl)
Subgroup cursor-256x256-rapid-movement:
skip -> PASS (shard-apl) fdo#103326
Test gem_eio:
Subgroup in-flight:
fail -> PASS (shard-hsw) fdo#104676 +1
Subgroup in-flight-contexts:
pass -> DMESG-WARN (shard-snb) fdo#104058
Test kms_ccs:
Subgroup pipe-b-bad-pixel-format:
skip -> PASS (shard-apl)
Test kms_plane_multiple:
Subgroup atomic-pipe-b-tiling-yf:
fail -> PASS (shard-apl)
Subgroup legacy-pipe-a-tiling-x:
skip -> PASS (shard-apl)
Test kms_pipe_crc_basic:
Subgroup read-crc-pipe-c:
skip -> PASS (shard-apl) fdo#103191
Subgroup nonblocking-crc-pipe-c-frame-sequence:
skip -> PASS (shard-apl) fdo#103481
Subgroup read-crc-pipe-a:
skip -> PASS (shard-apl)
Test kms_chv_cursor_fail:
Subgroup pipe-a-128x128-bottom-edge:
skip -> PASS (shard-apl)
Test kms_busy:
Subgroup extended-modeset-hang-oldfb-with-reset-render-c:
skip -> PASS (shard-apl) fdo#103336
Subgroup extended-modeset-hang-newfb-with-reset-render-c:
skip -> PASS (shard-apl)
Test kms_render:
Subgroup gpu-blit:
pass -> FAIL (shard-snb)
pass -> FAIL (shard-hsw)
pass -> FAIL (shard-apl)
Subgroup direct-render:
pass -> FAIL (shard-snb) fdo#104312
pass -> FAIL (shard-hsw) fdo#102614
pass -> FAIL (shard-apl)
Test perf:
Subgroup oa-exponents:
fail -> PASS (shard-apl) fdo#102254
Subgroup oa-formats:
pass -> SKIP (shard-hsw) fdo#104151
Test kms_sysfs_edid_timing:
warn -> PASS (shard-apl) fdo#100047
Test kms_color:
Subgroup pipe-a-ctm-0-75:
skip -> PASS (shard-apl)
Test kms_rotation_crc:
Subgroup primary-rotation-90-y-tiled:
skip -> PASS (shard-apl)
Test kms_plane_scaling:
Subgroup pipe-c-plane-scaling:
skip -> PASS (shard-apl)fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#104311 https://bugs.freedesktop.org/show_bug.cgi?id=104311
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#104829 https://bugs.freedesktop.org/show_bug.cgi?id=104829
fdo#103355 https://bugs.freedesktop.org/show_bug.cgi?id=103355
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
fdo#103326 https://bugs.freedesktop.org/show_bug.cgi?id=103326
fdo#104676 https://bugs.freedesktop.org/show_bug.cgi?id=104676
fdo#104058 https://bugs.freedesktop.org/show_bug.cgi?id=104058
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
fdo#103336 https://bugs.freedesktop.org/show_bug.cgi?id=103336
fdo#104312 https://bugs.freedesktop.org/show_bug.cgi?id=104312
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#104151 https://bugs.freedesktop.org/show_bug.cgi?id=104151
fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
shard-apl total:2838 pass:1747 dwarn:1 dfail:0 fail:26 skip:1064 time:12376s shard-hsw total:2838 pass:1732 dwarn:1 dfail:0 fail:13 skip:1091 time:11550s shard-snb total:2838 pass:1324 dwarn:3 dfail:0 fail:14 skip:1497 time:6552s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_842/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev