kms: Add universal plane support
PATCH 1/4 kms: Add universal plane support
Add support for universal planes. This involves revamping the existing plane handling a bit to allow primary & cursor planes to come from the DRM plane list, rather than always being manually added. Also, eliminate the hard-coded position of primary & cursor in the plane list since the DRM could return them in any order.
To minimize impact for existing tests, we add a new igt_display_use_universal_commits() call to toggle between universal and legacy API's for programming the primary and cursor planes.
--- lib/igt_kms.c | 132 +++++++++++++++++++++++++++++++++++++++++++++------------- lib/igt_kms.h | 5 +++ 2 files changed, 107 insertions(+), 30 deletions(-)
lib/igt_kms.c +102 -30
@@ -500,27 +500,24 @@ void igt_display_init(igt_display_t *display, int drm_fd)*/ display->n_pipes = resources->count_crtcs; +drmSetClientCap (drm_fd,DRM_CLIENT_CAP_UNIVERSAL_PLANES ,1 ); plane_resources =drmModeGetPlaneResources (display->drm_fd);igt_assert (plane_resources);for (i =0 ; i < display->n_pipes; i++) {igt_pipe_t *pipe = &display->pipes[i]; -igt_plane_t *plane; -int p, j; +igt_plane_t *plane =NULL ; +int p =0 , j; pipe->display = display; pipe->pipe = i; -/* primary plane */ - p =IGT_PLANE_PRIMARY ; - plane = &pipe->planes[p]; - plane->pipe = pipe; - plane->index = p; - plane->is_primary = true; -/* add the planes that can be used with that pipe */ for (j =0 ; j < plane_resources->count_planes; j++) {drmModePlane *drm_plane; +drmModeObjectPropertiesPtr proplist; +drmModePropertyPtr prop; +int k; drm_plane =drmModeGetPlane (display->drm_fd, plane_resources->planes[j]);
@@ -531,21 +528,67 @@ void igt_display_init(igt_display_t *display, int drm_fd)continue ; } - p++; plane = &pipe->planes[p]; plane->pipe = pipe; - plane->index = p; + plane->index = p++; plane->drm_plane = drm_plane; + + prop =NULL ; + proplist =drmModeObjectGetProperties (display->drm_fd, + plane_resources->planes[j], +DRM_MODE_OBJECT_PLANE ); +for (k =0 ; k < proplist->count_props; k++) { + prop =drmModeGetProperty (display->drm_fd, proplist->props[k]); +if (!prop) +continue ; + +if (strcmp (prop->name,"type" ) !=0 ) { +drmModeFreeProperty (prop); +continue ; + } + +switch (proplist->prop_values[k]) { +case DRM_PLANE_TYPE_PRIMARY : + plane->is_primary =1 ; + display->has_universal_planes =1 ; +break ; +case DRM_PLANE_TYPE_CURSOR : + plane->is_cursor =1 ; + pipe->has_cursor =1 ; + display->has_universal_planes =1 ; +break ; + } + +drmModeFreeProperty (prop); +break ; + } + } -/* cursor plane */ - p++; - plane = &pipe->planes[p]; - plane->pipe = pipe; - plane->index = p; - plane->is_cursor = true; +/* +* Add a drm_plane-less primary plane for kernels without +* universal plane support. +*/ +if (!display->has_universal_planes) { + plane = &pipe->planes[p]; + plane->pipe = pipe; + plane->index = p++; + plane->is_primary = true; + } - pipe->n_planes = ++p; +/* +* Add drm_plane-less cursor plane for kernels that don't +* expose a universal cursor plane. +*/ +if (!pipe->has_cursor) { +/* cursor plane */ + plane = &pipe->planes[p]; + plane->pipe = pipe; + plane->index = p++; + plane->is_cursor = true; + } + + pipe->n_planes = p;/* make sure we don't overflow the plane array */ igt_assert (pipe->n_planes <=IGT_MAX_PLANES );
@@ -700,16 +743,29 @@ static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, enum igt_plane plane) {int idx; -/* Cursor plane is always the upper plane */ -if (plane ==IGT_PLANE_CURSOR ) - idx = pipe->n_planes -1 ; -else { -igt_assert_f (plane >=0 && plane < (pipe->n_planes), -"plane=%d\n" , plane); - idx = plane; +for (idx =0 ; idx < pipe->n_planes; idx++) { +switch (plane) { +case IGT_PLANE_PRIMARY : +if (pipe->planes[idx].is_primary) +return &pipe->planes[idx]; +break ; +case IGT_PLANE_CURSOR : +if (pipe->planes[idx].is_cursor) +return &pipe->planes[idx]; +break ; +case IGT_PLANE_2 : +if (!pipe->planes[idx].is_primary && + !pipe->planes[idx].is_cursor) +return &pipe->planes[idx]; +default : +if (!pipe->planes[idx].is_primary && + !pipe->planes[idx].is_cursor) +/* Consume this overlay and keep searching for another */ + plane--; + } } -return &pipe->planes[idx]; +return NULL ; }static uint32_t igt_plane_get_fb_id (igt_plane_t *plane)
@@ -761,6 +817,8 @@ static int igt_drm_plane_commit(igt_plane_t *plane, igt_output_t *output)uint32_t fb_id, crtc_id;int ret; +igt_assert (plane->drm_plane); + fb_id =igt_plane_get_fb_id (plane); crtc_id = output->config.crtc->crtc_id; pipe =igt_output_get_driving_pipe (output);
@@ -820,7 +878,11 @@ static int igt_drm_plane_commit(igt_plane_t *plane, igt_output_t *output)static int igt_plane_commit (igt_plane_t *plane,igt_output_t *output) { -if (plane->is_cursor) { +struct igt_display *display = plane->pipe->display; + +if (display->commit_universal && plane->drm_plane) { +igt_drm_plane_commit (plane, output); + }else if (plane->is_cursor) {igt_cursor_commit (plane, output); }else if (plane->is_primary) {/* state updated by SetCrtc */
@@ -838,8 +900,8 @@ static int igt_output_commit(igt_output_t *output)int i; pipe =igt_output_get_driving_pipe (output); -if (pipe->need_set_crtc) { -igt_plane_t *primary = &pipe->planes[0 ]; +if (pipe->need_set_crtc && !display->commit_universal) { +igt_plane_t *primary =igt_pipe_get_plane (pipe,IGT_PLANE_PRIMARY );drmModeModeInfo *mode;uint32_t fb_id, crtc_id;int ret;
@@ -889,7 +951,7 @@ static int igt_output_commit(igt_output_t *output) primary->fb_changed = false; } -if (pipe->need_set_cursor) { +if (pipe->need_set_cursor && !display->commit_universal) {igt_plane_t *cursor;uint32_t gem_handle, crtc_id;int ret;
@@ -940,6 +1002,16 @@ static int igt_output_commit(igt_output_t *output)return 0 ; } +/* +* Indicate whether future display commits should use universal plane API's +* or legacy API's. +*/ +void igt_display_use_universal_commits (igt_display_t *display, +bool use_universal) +{ + display->commit_universal = use_universal; +} +int igt_display_commit (igt_display_t *display) {int i;
lib/igt_kms.h +5 -0
@@ -121,6 +121,7 @@ struct igt_pipe { unsigned int need_set_crtc : 1; unsigned int need_set_cursor : 1; unsigned int need_wait_for_vblank : 1; + unsigned int has_cursor : 1;#define IGT_MAX_PLANES 4int n_planes;igt_plane_t planes[IGT_MAX_PLANES ];
@@ -143,6 +144,8 @@ struct igt_display {unsigned long pipes_in_use;igt_output_t *outputs;igt_pipe_t pipes[I915_MAX_PIPES ]; +bool has_universal_planes; +bool commit_universal; };/* set vt into graphics mode, required to prevent fbcon from interfering */
@@ -150,6 +153,8 @@ void igt_set_vt_graphics_mode(void);void igt_display_init (igt_display_t *display,int drm_fd);void igt_display_fini (igt_display_t *display); +void igt_display_use_universal_commits (igt_display_t *display, +bool use_universal);int igt_display_commit (igt_display_t *display);int igt_display_get_n_pipes (igt_display_t *display);
Signature · 1 line
1.8.5.1
PATCH 2/4 kms: Add igt_drm_plane_try_commit()
For some of our tests, we want to make sure that bogus plane programming attempts fail with the expected error code. Add igt_drm_plane_try_commit() that will just return the error code on failure rather than failing the current subtest. This lets us test the return value against the expected error code.
--- lib/igt_kms.c | 21 ++++++++++++++++++--- lib/igt_kms.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-)
lib/igt_kms.c +18 -3
@@ -810,7 +810,11 @@ static int igt_cursor_commit(igt_plane_t *plane, igt_output_t *output)return 0 ; } -static int igt_drm_plane_commit (igt_plane_t *plane,igt_output_t *output) +/* +* Attempt to commit a plane; if the DRM call to program the plane fails, +* just return an error code (but don't fail the current subtest). +*/ +int igt_drm_plane_try_commit (igt_plane_t *plane,igt_output_t *output) {igt_display_t *display = output->display;igt_pipe_t *pipe;
@@ -842,7 +846,8 @@ static int igt_drm_plane_commit(igt_plane_t *plane, igt_output_t *output)IGT_FIXED (0 ,0 ),/* src_w */ IGT_FIXED(0,0) /* src_h */); -igt_assert (ret ==0 ); +if (ret) +return ret; plane->fb_changed = false; }else if (plane->fb_changed || plane->position_changed) {
@@ -866,7 +871,8 @@ static int igt_drm_plane_commit(igt_plane_t *plane, igt_output_t *output)IGT_FIXED (plane->fb->width,0 ),/* src_w */ IGT_FIXED(plane->fb->height,0) /* src_h */); -igt_assert (ret ==0 ); +if (ret) +return ret; plane->fb_changed = false; plane->position_changed = false;
@@ -876,6 +882,15 @@ static int igt_drm_plane_commit(igt_plane_t *plane, igt_output_t *output)return 0 ; } +static int igt_drm_plane_commit (igt_plane_t *plane,igt_output_t *output) +{ +int ret =igt_drm_plane_try_commit (plane, output); + +igt_assert (ret ==0 ); + +return 0 ; +} +static int igt_plane_commit (igt_plane_t *plane,igt_output_t *output) {struct igt_display *display = plane->pipe->display;
lib/igt_kms.h +1 -0
@@ -157,6 +157,7 @@ void igt_display_use_universal_commits(igt_display_t *display, bool use_universal);int igt_display_commit (igt_display_t *display);int igt_display_get_n_pipes (igt_display_t *display); +int igt_drm_plane_try_commit (igt_plane_t *plane,igt_output_t *output);const char *igt_output_name (igt_output_t *output);drmModeModeInfo *igt_output_get_mode (igt_output_t *output);
Signature · 1 line
1.8.5.1
PATCH 3/4 kms_plane: Update for universal plane changes
In reply to Matt RoperRecent changes in igt_kms to support universal planes have removed the plane list order guarantees that kms_plane depended upon. Ensure that we loop over the entire plane list properly and then selectively skip non-overlay planes.
While we're at it, update a couple igt_output_get_plane() calls to use plane enums rather than integer values to make it clear what we're actually doing.
--- tests/kms_plane.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tests/kms_plane.c +8 -3
@@ -94,7 +94,7 @@ test_position_init(test_position_t *test, igt_output_t *output, enum pipe pipe) test->pipe_crc =igt_pipe_crc_new (pipe,INTEL_PIPE_CRC_SOURCE_AUTO );igt_output_set_pipe (output, pipe); - primary =igt_output_get_plane (output,0 ); + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); mode =igt_output_get_mode (output); igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
@@ -146,9 +146,14 @@ test_plane_position_with_output(data_t *data,test_position_init (&test, output, pipe); mode =igt_output_get_mode (output); - primary =igt_output_get_plane (output,0 ); + primary =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); sprite =igt_output_get_plane (output, plane); +if (sprite->is_primary) { +test_position_fini (&test, output); +igt_skip ("Skipping primary plane\n" ); + } +create_fb_for_mode__position (data, mode,100 ,100 ,64 ,64 , &primary_fb);igt_plane_set_fb (primary, &primary_fb);
@@ -213,7 +218,7 @@ run_tests_for_pipe(data_t *data, enum pipe pipe) {int plane; -for (plane =1 ; plane <IGT_MAX_PLANES ; plane++) +for (plane =0 ; plane <IGT_MAX_PLANES ; plane++)run_tests_for_pipe_plane (data, pipe, plane); }
Signature · 1 line
1.8.5.1
PATCH 4/4 kms_universal_plane: Universal plane testing (v2)
In reply to Matt RoperAdd a simple test to exercise universal plane support.
v2:
- Test that pageflips error out gracefully when the primary plane is disabled before the ioctl, or between ioctl and pageflip execution.
- Test that nothing blows up if we try to disable the primary plane immediately after a pageflip (presumably before the pageflip actually completes).
- Test that we can setup primary + sprite planes with the CRTC off and then have them show up properly when we enable the CRTC (drmModeSetCrtc with fb = -1).
- Test that we can modeset properly after having disabled the primary plane
- Test that proper error codes are returned for invalid plane programming attempts.
--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_universal_plane.c | 523 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 525 insertions(+) create mode 100644 tests/kms_universal_plane.c
tests/.gitignore +1 -0
@@ -121,6 +121,7 @@ kms_pipe_crc_basic kms_plane kms_render kms_setmode +kms_universal_plane multi-tests.txt pm_lpsp pm_pc8
tests/Makefile.sources +1 -0
@@ -65,6 +65,7 @@ TESTS_progs_M = \ kms_plane \ kms_render \ kms_setmode \ + kms_universal_plane \ pm_lpsp \ pm_pc8 \ pm_rps \
tests/kms_universal_plane.c new file +523 -0
523 lines not on this page · raw message
Signature · 6 lines
1.8.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 kms_universal_plane: Universal plane testing (v3)
Add a simple test to exercise universal plane support.
v3:
- For testing while crtc is off, switch between several different primary plane fb's before reenabling the crtc. This will help catch pin/unpin mistakes.
v2:
- Test that pageflips error out gracefully when the primary plane is disabled before the ioctl, or between ioctl and pageflip execution.
- Test that nothing blows up if we try to disable the primary plane immediately after a pageflip (presumably before the pageflip actually completes).
- Test that we can setup primary + sprite planes with the CRTC off and then have them show up properly when we enable the CRTC (drmModeSetCrtc with fb = -1).
- Test that we can modeset properly after having disabled the primary plane
- Test that proper error codes are returned for invalid plane programming attempts.
--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_universal_plane.c | 530 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 532 insertions(+) create mode 100644 tests/kms_universal_plane.c
tests/.gitignore +1 -0
@@ -121,6 +121,7 @@ kms_pipe_crc_basic kms_plane kms_render kms_setmode +kms_universal_plane multi-tests.txt pm_lpsp pm_pc8
tests/Makefile.sources +1 -0
@@ -65,6 +65,7 @@ TESTS_progs_M = \ kms_plane \ kms_render \ kms_setmode \ + kms_universal_plane \ pm_lpsp \ pm_pc8 \ pm_rps \
tests/kms_universal_plane.c new file +530 -0
530 lines not on this page · raw message
Signature · 6 lines
1.8.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 kms_universal_plane: Universal plane testing (v4)
Add a simple test to exercise universal plane support.
v4:
- Test disabling the primary plane explicitly when it has previously been implicitly disabled due to clipping.
- Skip test if igt_pipe_crc_new() fails
v3:
- For testing while crtc is off, switch between several different primary plane fb's before reenabling the crtc. This will help catch pin/unpin mistakes.
v2:
- Test that pageflips error out gracefully when the primary plane is disabled before the ioctl, or between ioctl and pageflip execution.
- Test that nothing blows up if we try to disable the primary plane immediately after a pageflip (presumably before the pageflip actually completes).
- Test that we can setup primary + sprite planes with the CRTC off and then have them show up properly when we enable the CRTC (drmModeSetCrtc with fb = -1).
- Test that we can modeset properly after having disabled the primary plane
- Test that proper error codes are returned for invalid plane programming attempts.
--- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_universal_plane.c | 581 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 583 insertions(+) create mode 100644 tests/kms_universal_plane.c
tests/.gitignore +1 -0
@@ -123,6 +123,7 @@ kms_pipe_crc_basic kms_plane kms_render kms_setmode +kms_universal_plane multi-tests.txt pm_lpsp pm_rpm
tests/Makefile.sources +1 -0
@@ -68,6 +68,7 @@ TESTS_progs_M = \ kms_plane \ kms_render \ kms_setmode \ + kms_universal_plane \ pm_lpsp \ pm_rpm \ pm_rps \
tests/kms_universal_plane.c new file +581 -0
581 lines not on this page · raw message
Signature · 6 lines
1.8.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx