diff options
author | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2017-10-03 09:38:07 +0200 |
---|---|---|
committer | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2017-10-20 11:43:33 +0200 |
commit | cca28775d231af94a1e823966238ca88f1e2f7fb (patch) | |
tree | 204d1ec57c9de37b1cbd8f7d1dfd365175a10818 /lib | |
parent | c043428f145addc646c802c9a7fe19630a120e1d (diff) |
lib/igt_kms: Export property blob functions for output/pipe/plane, v2.
With the replace_prop_blob functions we can safely replace the blob for
any property, without having to care about error handling ourselves.
This will for example allow overriding color management blobs, or for
kms_atomic set invalid mode blobs.
The color management blob functions are removed, they can now be
replaced by direct calls to replace the properties.
Changes since v1:
- Fix chamelium tests.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/igt_kms.c | 117 | ||||
-rw-r--r-- | lib/igt_kms.h | 19 |
2 files changed, 101 insertions, 35 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c index e7b9fbab..5f540213 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -2443,8 +2443,88 @@ static int igt_output_commit(igt_output_t *output, return 0; } -static void -igt_pipe_replace_blob(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop, void *ptr, size_t length) +/** + * igt_plane_replace_prop_blob: + * @plane: plane to set property on. + * @prop: property for which the blob will be replaced. + * @ptr: Pointer to contents for the property. + * @length: Length of contents. + * + * This function will destroy the old property blob for the given property, + * and will create a new property blob with the values passed to this function. + * + * The new property blob will be committed when you call igt_display_commit(), + * igt_display_commit2() or igt_display_commit_atomic(). + */ +void +igt_plane_replace_prop_blob(igt_plane_t *plane, enum igt_atomic_plane_properties prop, const void *ptr, size_t length) +{ + igt_display_t *display = plane->pipe->display; + uint64_t *blob = &plane->values[prop]; + uint32_t blob_id = 0; + + if (*blob != 0) + igt_assert(drmModeDestroyPropertyBlob(display->drm_fd, + *blob) == 0); + + if (length > 0) + igt_assert(drmModeCreatePropertyBlob(display->drm_fd, + ptr, length, &blob_id) == 0); + + *blob = blob_id; + igt_plane_set_prop_changed(plane, prop); +} + +/** + * igt_output_replace_prop_blob: + * @output: output to set property on. + * @prop: property for which the blob will be replaced. + * @ptr: Pointer to contents for the property. + * @length: Length of contents. + * + * This function will destroy the old property blob for the given property, + * and will create a new property blob with the values passed to this function. + * + * The new property blob will be committed when you call igt_display_commit(), + * igt_display_commit2() or igt_display_commit_atomic(). + */ +void +igt_output_replace_prop_blob(igt_output_t *output, enum igt_atomic_connector_properties prop, const void *ptr, size_t length) +{ + igt_display_t *display = output->display; + uint64_t *blob = &output->values[prop]; + uint32_t blob_id = 0; + + if (*blob != 0) + igt_assert(drmModeDestroyPropertyBlob(display->drm_fd, + *blob) == 0); + + if (length > 0) + igt_assert(drmModeCreatePropertyBlob(display->drm_fd, + ptr, length, &blob_id) == 0); + + *blob = blob_id; + igt_output_set_prop_changed(output, prop); +} + +/** + * igt_pipe_obj_replace_prop_blob: + * @pipe: pipe to set property on. + * @prop: property for which the blob will be replaced. + * @ptr: Pointer to contents for the property. + * @length: Length of contents. + * + * This function will destroy the old property blob for the given property, + * and will create a new property blob with the values passed to this function. + * + * The new property blob will be committed when you call igt_display_commit(), + * igt_display_commit2() or igt_display_commit_atomic(). + * + * Please use igt_output_override_mode() if you want to set #IGT_CRTC_MODE_ID, + * it works better with legacy commit. + */ +void +igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop, const void *ptr, size_t length) { igt_display_t *display = pipe->display; uint64_t *blob = &pipe->values[prop]; @@ -2836,7 +2916,7 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode) if (pipe) { if (output->display->is_atomic) - igt_pipe_replace_blob(pipe, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(*mode)); + igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(*mode)); else igt_pipe_obj_set_prop_changed(pipe, IGT_CRTC_MODE_ID); } @@ -2865,7 +2945,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) old_output = igt_pipe_get_output(old_pipe); if (!old_output) { if (display->is_atomic) - igt_pipe_replace_blob(old_pipe, IGT_CRTC_MODE_ID, NULL, 0); + igt_pipe_obj_replace_prop_blob(old_pipe, IGT_CRTC_MODE_ID, NULL, 0); else igt_pipe_obj_set_prop_changed(old_pipe, IGT_CRTC_MODE_ID); @@ -2879,7 +2959,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) if (pipe_obj) { if (display->is_atomic) - igt_pipe_replace_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo)); + igt_pipe_obj_replace_prop_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo)); else igt_pipe_obj_set_prop_changed(pipe_obj, IGT_CRTC_MODE_ID); @@ -2908,18 +2988,11 @@ void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force) pipe_obj->values[IGT_CRTC_MODE_ID] = 0; if (output) - igt_pipe_replace_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo)); + igt_pipe_obj_replace_prop_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo)); } else igt_pipe_obj_set_prop_changed(pipe_obj, IGT_CRTC_MODE_ID); } -void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode) -{ - igt_output_set_prop_value(output, IGT_CONNECTOR_SCALING_MODE, scaling_mode); - - igt_require(output->props[IGT_CONNECTOR_SCALING_MODE]); -} - igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx) { igt_pipe_t *pipe; @@ -3119,24 +3192,6 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe) igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)&pipe->out_fence_fd); } -void -igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length) -{ - igt_pipe_replace_blob(pipe, IGT_CRTC_DEGAMMA_LUT, ptr, length); -} - -void -igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length) -{ - igt_pipe_replace_blob(pipe, IGT_CRTC_CTM, ptr, length); -} - -void -igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length) -{ - igt_pipe_replace_blob(pipe, IGT_CRTC_GAMMA_LUT, ptr, length); -} - /** * igt_crtc_set_background: * @pipe: pipe pointer to which background color to be set diff --git a/lib/igt_kms.h b/lib/igt_kms.h index b53127ff..2e4c2343 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -366,7 +366,6 @@ const char *igt_output_name(igt_output_t *output); drmModeModeInfo *igt_output_get_mode(igt_output_t *output); void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode); void igt_output_set_pipe(igt_output_t *output, enum pipe pipe); -void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode); igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx); igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type); igt_output_t *igt_output_from_connector(igt_display_t *display, @@ -381,9 +380,6 @@ static inline bool igt_plane_supports_rotation(igt_plane_t *plane) return plane->props[IGT_PLANE_ROTATION] != 0; } void igt_pipe_request_out_fence(igt_pipe_t *pipe); -void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length); -void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length); -void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length); void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb); void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd); @@ -513,6 +509,10 @@ static inline bool igt_output_is_connected(igt_output_t *output) igt_plane_set_prop_changed(plane, prop); \ } while (0) +extern void igt_plane_replace_prop_blob(igt_plane_t *plane, + enum igt_atomic_plane_properties prop, + const void *ptr, size_t length); + #define igt_output_is_prop_changed(output, prop) \ (!!((output)->changed & (1 << (prop)))) #define igt_output_set_prop_changed(output, prop) \ @@ -527,6 +527,10 @@ static inline bool igt_output_is_connected(igt_output_t *output) igt_output_set_prop_changed(output, prop); \ } while (0) +extern void igt_output_replace_prop_blob(igt_output_t *output, + enum igt_atomic_connector_properties prop, + const void *ptr, size_t length); + #define igt_pipe_obj_is_prop_changed(pipe_obj, prop) \ (!!((pipe_obj)->changed & (1 << (prop)))) @@ -554,6 +558,13 @@ static inline bool igt_output_is_connected(igt_output_t *output) #define igt_pipe_set_prop_value(display, pipe, prop, value) \ igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop, value) +extern void igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe_obj, + enum igt_atomic_crtc_properties prop, + const void *ptr, size_t length); + +#define igt_pipe_replace_prop_blob(display, pipe, prop, ptr, length) \ + igt_pipe_obj_replace_prop_blob(&(display)->pipes[(pipe)], prop, ptr, length) + void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force); void igt_enable_connectors(void); |