drm/plane-helper: Add a drm_plane_helper_atomic_check() helper
Subsystems (3)
Javier Martinez Canillas
maintainerPATCH 1/1 drm/plane-helper: Add a drm_plane_helper_atomic_check() helper
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)
drivers/gpu/drm/drm_plane_helper.c +29 -0
@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check +* +* Provides a default plane state check handler for primary planes whose atomic +* state scale and position is not expected to change because the primary plane +* is always a fullscreen scanout buffer. +* +* RETURNS: +* Zero on success, or an errno code otherwise. +*/ +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state) +{ +struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); +struct drm_crtc *new_crtc = new_plane_state->crtc; +struct drm_crtc_state *new_crtc_state =NULL ; + +if (new_crtc) + new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); + +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false); +} +EXPORT_SYMBOL (drm_plane_helper_atomic_check);
drivers/gpu/drm/solomon/ssd130x.c +1 -17
@@ -565,22 +565,6 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_mreturn ret; } -static int ssd130x_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - -return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -} -static void ssd130x_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {
@@ -623,7 +607,7 @@ static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,static const struct drm_plane_helper_funcs ssd130x_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = ssd130x_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = ssd130x_primary_plane_helper_atomic_update, .atomic_disable = ssd130x_primary_plane_helper_atomic_disable, };
drivers/gpu/drm/tiny/simpledrm.c +1 -24
@@ -469,29 +469,6 @@ static const uint64_t simpledrm_primary_plane_format_modifiers[] = { DRM_FORMAT_MOD_INVALID }; -static int simpledrm_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; -int ret; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ; -} -static void simpledrm_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {
@@ -543,7 +520,7 @@ static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *planstatic const struct drm_plane_helper_funcs simpledrm_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = simpledrm_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = simpledrm_primary_plane_helper_atomic_update, .atomic_disable = simpledrm_primary_plane_helper_atomic_disable, };
include/drm/drm_plane_helper.h +2 -0
@@ -41,5 +41,7 @@ int drm_plane_helper_update_primary(struct drm_plane *plane, struct drm_crtc *crint drm_plane_helper_disable_primary (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx);void drm_plane_helper_destroy (struct drm_plane *plane); +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state);#endif
Signature · 1 line
2.37.1
Quoted 22 lines · Javier Martinez Canillas
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)drivers/gpu/drm/drm_plane_helper.c +0
-0
drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 8 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check
That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Quoted 117 lines
drivers/gpu/drm/drm_plane_helper.c +24
-0+* +* Provides a default plane state check handler for primary planes whose atomic +* state scale and position is not expected to change because the primary plane +* is always a fullscreen scanout buffer. +* +* RETURNS: +* Zero on success, or an errno code otherwise. +*/ +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state) +{ +struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); +struct drm_crtc *new_crtc = new_plane_state->crtc; +struct drm_crtc_state *new_crtc_state =NULL ; + +if (new_crtc) + new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); + +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false); +} +EXPORT_SYMBOL (drm_plane_helper_atomic_check);drivers/gpu/drm/solomon/ssd130x.c +1
-17@@ -565,22 +565,6 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_mreturn ret; } -static int ssd130x_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - -return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -} -static void ssd130x_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -623,7 +607,7 @@ static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,static const struct drm_plane_helper_funcs ssd130x_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = ssd130x_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = ssd130x_primary_plane_helper_atomic_update, .atomic_disable = ssd130x_primary_plane_helper_atomic_disable, };drivers/gpu/drm/tiny/simpledrm.c +1
-24@@ -469,29 +469,6 @@ static const uint64_t simpledrm_primary_plane_format_modifiers[] = { DRM_FORMAT_MOD_INVALID }; -static int simpledrm_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; -int ret; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ; -} -static void simpledrm_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -543,7 +520,7 @@ static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *planstatic const struct drm_plane_helper_funcs simpledrm_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = simpledrm_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = simpledrm_primary_plane_helper_atomic_update, .atomic_disable = simpledrm_primary_plane_helper_atomic_disable, };include/drm/drm_plane_helper.h +2
-0@@ -41,5 +41,7 @@ int drm_plane_helper_update_primary(struct drm_plane *plane, struct drm_crtc *crint drm_plane_helper_disable_primary (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx);void drm_plane_helper_destroy (struct drm_plane *plane); +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state);#endif Signature · 1 line
2.37.1
Signature · 2 lines
Ville Syrjälä Intel
Thomas Zimmermann
maintainerHi
Am 12.09.22 um 12:40 schrieb Ville Syrjälä:
Quoted 18 lines · Javier Martinez Canillas
Quoted 17 lines
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)
Quoted 16 lines
drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 13 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using 'new_state' and 'old_state' explicitly in several places now.
Best regards
Thomas
Quoted 119 lines
Quoted 118 lines
drivers/gpu/drm/drm_plane_helper.c +24
-0+* +* Provides a default plane state check handler for primary planes whose atomic +* state scale and position is not expected to change because the primary plane +* is always a fullscreen scanout buffer. +* +* RETURNS: +* Zero on success, or an errno code otherwise. +*/ +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state) +{ +struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); +struct drm_crtc *new_crtc = new_plane_state->crtc; +struct drm_crtc_state *new_crtc_state =NULL ; + +if (new_crtc) + new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); + +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false); +} +EXPORT_SYMBOL (drm_plane_helper_atomic_check);drivers/gpu/drm/solomon/ssd130x.c +1
-17@@ -565,22 +565,6 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_mreturn ret; } -static int ssd130x_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - -return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -} -static void ssd130x_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -623,7 +607,7 @@ static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,static const struct drm_plane_helper_funcs ssd130x_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = ssd130x_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = ssd130x_primary_plane_helper_atomic_update, .atomic_disable = ssd130x_primary_plane_helper_atomic_disable, };drivers/gpu/drm/tiny/simpledrm.c +1
-24@@ -469,29 +469,6 @@ static const uint64_t simpledrm_primary_plane_format_modifiers[] = { DRM_FORMAT_MOD_INVALID }; -static int simpledrm_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; -int ret; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ; -} -static void simpledrm_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -543,7 +520,7 @@ static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *planstatic const struct drm_plane_helper_funcs simpledrm_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = simpledrm_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = simpledrm_primary_plane_helper_atomic_update, .atomic_disable = simpledrm_primary_plane_helper_atomic_disable, };include/drm/drm_plane_helper.h +2
-0@@ -41,5 +41,7 @@ int drm_plane_helper_update_primary(struct drm_plane *plane, struct drm_crtc *crint drm_plane_helper_disable_primary (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx);void drm_plane_helper_destroy (struct drm_plane *plane); +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state);#endif Signature · 1 line
2.37.1
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Quoted 38 lines · Thomas Zimmermann
Hi
Am 12.09.22 um 12:40 schrieb Ville Syrjälä:
Quoted 18 lines · Javier Martinez Canillas
Quoted 17 lines
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)Quoted 16 lines
drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 13 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Quoted 3 lines
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using '
new_state' and 'old_state' explicitly in several places now.
There is no old or new drm_atomic_state. It contains both.
Quoted 131 lines
Best regards
ThomasQuoted 119 lines
Quoted 118 lines
drivers/gpu/drm/drm_plane_helper.c +24
-0+* +* Provides a default plane state check handler for primary planes whose atomic +* state scale and position is not expected to change because the primary plane +* is always a fullscreen scanout buffer. +* +* RETURNS: +* Zero on success, or an errno code otherwise. +*/ +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state) +{ +struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); +struct drm_crtc *new_crtc = new_plane_state->crtc; +struct drm_crtc_state *new_crtc_state =NULL ; + +if (new_crtc) + new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); + +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false); +} +EXPORT_SYMBOL (drm_plane_helper_atomic_check);drivers/gpu/drm/solomon/ssd130x.c +1
-17@@ -565,22 +565,6 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_mreturn ret; } -static int ssd130x_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - -return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -} -static void ssd130x_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -623,7 +607,7 @@ static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,static const struct drm_plane_helper_funcs ssd130x_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = ssd130x_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = ssd130x_primary_plane_helper_atomic_update, .atomic_disable = ssd130x_primary_plane_helper_atomic_disable, };drivers/gpu/drm/tiny/simpledrm.c +1
-24@@ -469,29 +469,6 @@ static const uint64_t simpledrm_primary_plane_format_modifiers[] = { DRM_FORMAT_MOD_INVALID }; -static int simpledrm_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; -int ret; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ; -} -static void simpledrm_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -543,7 +520,7 @@ static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *planstatic const struct drm_plane_helper_funcs simpledrm_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = simpledrm_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = simpledrm_primary_plane_helper_atomic_update, .atomic_disable = simpledrm_primary_plane_helper_atomic_disable, };include/drm/drm_plane_helper.h +2
-0@@ -41,5 +41,7 @@ int drm_plane_helper_update_primary(struct drm_plane *plane, struct drm_crtc *crint drm_plane_helper_disable_primary (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx);void drm_plane_helper_destroy (struct drm_plane *plane); +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state);#endif Signature · 1 line
2.37.1Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Signature · 2 lines
Ville Syrjälä Intel
Thomas Zimmermann
maintainerHi
Am 12.09.22 um 13:18 schrieb Ville Syrjälä:
Quoted 39 lines · Thomas Zimmermann
Quoted 38 lines
Hi
Am 12.09.22 um 12:40 schrieb Ville Syrjälä:
Quoted 34 lines · Javier Martinez Canillas
Quoted 22 lines
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)drivers/gpu/drm/drm_plane_helper.c +0
-0drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 8 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Quoted 5 lines
Quoted 3 lines
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using '
new_state' and 'old_state' explicitly in several places now.There is no old or new
drm_atomic_state. It contains both.
I (vaguely) remember a bug where a driver tried drm_atomic_get_new_plane_state() with the (old) state that's passed to atomic_update. It didn't return the expected results and modesetting gave slightly wrong results. So we began to be more precise about new and old. And whatever is stored in 'plane->state' is then just 'the state'.
I understand that the semantics of atomic_check are different from atomic_update, but it still doesn't hurt to talk of new_state IMHO.
Best regards
Thomas
Quoted 136 lines
Quoted 132 lines
Best regards
ThomasQuoted 119 lines
Quoted 118 lines
drivers/gpu/drm/drm_plane_helper.c +24
-0+* +* Provides a default plane state check handler for primary planes whose atomic +* state scale and position is not expected to change because the primary plane +* is always a fullscreen scanout buffer. +* +* RETURNS: +* Zero on success, or an errno code otherwise. +*/ +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state) +{ +struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); +struct drm_crtc *new_crtc = new_plane_state->crtc; +struct drm_crtc_state *new_crtc_state =NULL ; + +if (new_crtc) + new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); + +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false); +} +EXPORT_SYMBOL (drm_plane_helper_atomic_check);drivers/gpu/drm/solomon/ssd130x.c +1
-17@@ -565,22 +565,6 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_mreturn ret; } -static int ssd130x_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - -return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -} -static void ssd130x_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -623,7 +607,7 @@ static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,static const struct drm_plane_helper_funcs ssd130x_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = ssd130x_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = ssd130x_primary_plane_helper_atomic_update, .atomic_disable = ssd130x_primary_plane_helper_atomic_disable, };drivers/gpu/drm/tiny/simpledrm.c +1
-24@@ -469,29 +469,6 @@ static const uint64_t simpledrm_primary_plane_format_modifiers[] = { DRM_FORMAT_MOD_INVALID }; -static int simpledrm_primary_plane_helper_atomic_check (struct drm_plane *plane, -struct drm_atomic_state *new_state) -{ -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane); -struct drm_crtc *new_crtc = new_plane_state->crtc; -struct drm_crtc_state *new_crtc_state =NULL ; -int ret; - -if (new_crtc) - new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ; -} -static void simpledrm_primary_plane_helper_atomic_update (struct drm_plane *plane,struct drm_atomic_state *old_state) {@@ -543,7 +520,7 @@ static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *planstatic const struct drm_plane_helper_funcs simpledrm_primary_plane_helper_funcs = {DRM_GEM_SHADOW_PLANE_HELPER_FUNCS , - .atomic_check = simpledrm_primary_plane_helper_atomic_check, + .atomic_check = drm_plane_helper_atomic_check, .atomic_update = simpledrm_primary_plane_helper_atomic_update, .atomic_disable = simpledrm_primary_plane_helper_atomic_disable, };include/drm/drm_plane_helper.h +2
-0@@ -41,5 +41,7 @@ int drm_plane_helper_update_primary(struct drm_plane *plane, struct drm_crtc *crint drm_plane_helper_disable_primary (struct drm_plane *plane,struct drm_modeset_acquire_ctx *ctx);void drm_plane_helper_destroy (struct drm_plane *plane); +int drm_plane_helper_atomic_check (struct drm_plane *plane, +struct drm_atomic_state *new_state);#endif Signature · 1 line
2.37.1Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Quoted 46 lines · Thomas Zimmermann
Hi
Am 12.09.22 um 13:18 schrieb Ville Syrjälä:
Quoted 43 lines · Thomas Zimmermann
Quoted 41 lines
Hi
Am 12.09.22 um 12:40 schrieb Ville Syrjälä:
Quoted 18 lines · Javier Martinez Canillas
Quoted 17 lines
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)Quoted 16 lines
drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 13 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using '
new_state' and 'old_state' explicitly in several places now.
Quoted 6 lines
Quoted 1 line
There is no old or new
drm_atomic_state. It contains both.I (vaguely) remember a bug where a driver tried
drm_atomic_get_new_plane_state()with the (old) state that's passed toatomic_update. It didn't return the expected results and modesetting gave slightly wrong results.
As there is no wrong drm_atomic_state to pass I don't think it could have been the case.
Quoted 2 lines
So we began to be more precise about new
and old. And whatever is stored in 'plane->state' is then just 'the state'.
There were certainly a lot of confusion before the explicit new/old state stuff was added whether foo->state/etc. was the old or the new state. And labeling things as explicitly old vs. new when passing in individual object states certainly makes sense. But that doesn't really have anything to do with mislabeling the overall drm_atomic_state.
Quoted 3 lines
I understand that the semantics of
atomic_checkare different fromatomic_update, but it still doesn't hurt to talk ofnew_stateIMHO.
IMO it's just confusing. Makes the reader think there is somehow different drm_atomic_states for old vs. new states when there isn't. I also wouldn't call it new_state for .atomic_update() either.
In both cases you have the old and new states in there and how exactly they get used in the hooks is more of an implementation detail. The only rules you would have to follow is that at the end of .atomic_update() the hardware state matches the new state, and .atomic_check() makes sure the transition from the old to the new state is possible.
I've proposed renaming drm_atomic_state to eg. drm_atomic_transaction a few times before but no one took the bait so far...
Signature · 2 lines
Ville Syrjälä Intel
Thomas Zimmermann
maintainerHi
Am 12.09.22 um 14:34 schrieb Ville Syrjälä:
Quoted 74 lines · Thomas Zimmermann
Quoted 46 lines
Hi
Am 12.09.22 um 13:18 schrieb Ville Syrjälä:
Quoted 43 lines · Thomas Zimmermann
Quoted 41 lines
Hi
Am 12.09.22 um 12:40 schrieb Ville Syrjälä:
Quoted 18 lines · Javier Martinez Canillas
Quoted 17 lines
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)Quoted 16 lines
drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 13 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using '
new_state' and 'old_state' explicitly in several places now.Quoted 6 lines
Quoted 1 line
There is no old or new
drm_atomic_state. It contains both.I (vaguely) remember a bug where a driver tried
drm_atomic_get_new_plane_state()with the (old) state that's passed toatomic_update. It didn't return the expected results and modesetting gave slightly wrong results.As there is no wrong
drm_atomic_stateto pass I don't think it could have been the case.Quoted 2 lines
So we began to be more precise about new
and old. And whatever is stored in 'plane->state' is then just 'the state'.There were certainly a lot of confusion before the explicit new/old state stuff was added whether foo->state/etc. was the old or the new state. And labeling things as explicitly old vs. new when passing in individual object states certainly makes sense. But that doesn't really have anything to do with mislabeling the overall
drm_atomic_state.Quoted 3 lines
I understand that the semantics of
atomic_checkare different fromatomic_update, but it still doesn't hurt to talk ofnew_stateIMHO.IMO it's just confusing. Makes the reader think there is somehow different
drm_atomic_statesfor old vs. new states when there isn't. I also wouldn't call itnew_statefor .atomic_update() either.
Quoted 6 lines
In both cases you have the old and new states in there and how exactly they get used in the hooks is more of an implementation detail. The only rules you would have to follow is that at the end of .atomic_update() the hardware state matches the new state, and .atomic_check() makes sure the transition from the old to the new state is possible.
From what I understand:
In atomic_check(), plane->state is the current state and the state argument is the state to be validated. Calling drm_atomic_get_new_plane_state() will return the plane's new state.
If you call drm_atomic_get_old_plane_state() from atomic_check(), what will it return?
In atomic_update() plane->state is the state to be committed and the state argument is the old state before the start of the atomic commit. And calling drm_atomic_get_new_plane_state() will *not* the return the plane's new state (i.e., the one in plane->state) IIRC. (As I mentioned, there was a related bug in one of the drivers.) So we began to call this 'old_state'.
My point is: the state passed to the check and commit functions are different things, even though they appear to be the same.
Quoted 4 lines
I've proposed renaming
drm_atomic_stateto eg.drm_atomic_transactiona few times before but no one took the bait so far...
If you really don't like new_state, then let's call it state_tx.
Best regards
Thomas
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Javier Martinez Canillas
maintainerHello Ville and Thomas,
On 9/12/22 16:22, Thomas Zimmermann wrote:
[...]
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ +/** + * drm_plane_helper_atomic_check() - Helper to check primary planes states + * @plane: plane to check + * @new_state: plane state to checkThat is not a plane state. Also should s/new_// since it's just
Right. What's the proper name? hardware state, modeset state, atomic state ?
Quoted 40 lines
Quoted 33 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
the overall atomic state thing rather than some new or old state.
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using '
new_state' and 'old_state' explicitly in several places now.Quoted 6 lines
Quoted 1 line
There is no old or new
drm_atomic_state. It contains both.I (vaguely) remember a bug where a driver tried
drm_atomic_get_new_plane_state()with the (old) state that's passed toatomic_update. It didn't return the expected results and modesetting gave slightly wrong results.As there is no wrong
drm_atomic_stateto pass I don't think it could have been the case.Quoted 2 lines
So we began to be more precise about new
and old. And whatever is stored in 'plane->state' is then just 'the state'.There were certainly a lot of confusion before the explicit new/old state stuff was added whether foo->state/etc. was the old or the new state. And labeling things as explicitly old vs. new when passing in individual object states certainly makes sense. But that doesn't really have anything to do with mislabeling the overall
drm_atomic_state.Quoted 3 lines
I understand that the semantics of
atomic_checkare different fromatomic_update, but it still doesn't hurt to talk ofnew_stateIMHO.IMO it's just confusing. Makes the reader think there is somehow different
drm_atomic_statesfor old vs. new states when there isn't. I also wouldn't call itnew_statefor .atomic_update() either.Quoted 6 lines
In both cases you have the old and new states in there and how exactly they get used in the hooks is more of an implementation detail. The only rules you would have to follow is that at the end of .atomic_update() the hardware state matches the new state, and .atomic_check() makes sure the transition from the old to the new state is possible.
Quoted 6 lines
From what I understand:
In
atomic_check(),plane->stateis the current state and the state argument is the state to be validated. Callingdrm_atomic_get_new_plane_state()will return the plane's new state.
That's my understanding as well.
Quoted 10 lines
If you call
drm_atomic_get_old_plane_state()fromatomic_check(), what will it return?In
atomic_update()plane->stateis the state to be committed and the state argument is the old state before the start of the atomic commit. And callingdrm_atomic_get_new_plane_state()will *not* the return the plane's new state (i.e., the one inplane->state) IIRC. (As I mentioned, there was a related bug in one of the drivers.) So we began to call this 'old_state'.
Quoted 3 lines
My point is: the state passed to the check and commit functions are different things, even though they appear to be the same.
Agree.
Maybe instead of new and old current_state and commit_state would be more clear ?
Quoted 7 lines
Quoted 4 lines
I've proposed renaming
drm_atomic_stateto eg.drm_atomic_transactiona few times before but no one took the bait so far...If you really don't like
new_state, then let's call itstate_tx.
I would prefer if for this patch we call it either new_state or just state to be consistent with the other helpers. And then we can as a follow-up change the naming used by all the helpers.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Quoted 84 lines · Thomas Zimmermann
Hi
Am 12.09.22 um 14:34 schrieb Ville Syrjälä:
Quoted 74 lines · Thomas Zimmermann
Quoted 46 lines
Hi
Am 12.09.22 um 13:18 schrieb Ville Syrjälä:
Quoted 43 lines · Thomas Zimmermann
Quoted 41 lines
Hi
Am 12.09.22 um 12:40 schrieb Ville Syrjälä:
Quoted 18 lines · Javier Martinez Canillas
Quoted 17 lines
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)Quoted 16 lines
drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 13 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using '
new_state' and 'old_state' explicitly in several places now.Quoted 6 lines
Quoted 1 line
There is no old or new
drm_atomic_state. It contains both.I (vaguely) remember a bug where a driver tried
drm_atomic_get_new_plane_state()with the (old) state that's passed toatomic_update. It didn't return the expected results and modesetting gave slightly wrong results.As there is no wrong
drm_atomic_stateto pass I don't think it could have been the case.Quoted 2 lines
So we began to be more precise about new
and old. And whatever is stored in 'plane->state' is then just 'the state'.There were certainly a lot of confusion before the explicit new/old state stuff was added whether foo->state/etc. was the old or the new state. And labeling things as explicitly old vs. new when passing in individual object states certainly makes sense. But that doesn't really have anything to do with mislabeling the overall
drm_atomic_state.Quoted 3 lines
I understand that the semantics of
atomic_checkare different fromatomic_update, but it still doesn't hurt to talk ofnew_stateIMHO.IMO it's just confusing. Makes the reader think there is somehow different
drm_atomic_statesfor old vs. new states when there isn't. I also wouldn't call itnew_statefor .atomic_update() either.Quoted 6 lines
In both cases you have the old and new states in there and how exactly they get used in the hooks is more of an implementation detail. The only rules you would have to follow is that at the end of .atomic_update() the hardware state matches the new state, and .atomic_check() makes sure the transition from the old to the new state is possible.
Quoted 5 lines
From what I understand:
In
atomic_check(),plane->stateis the current state and the state argument is the state to be validated. Callingdrm_atomic_get_new_plane_state()will return the plane's new state.
You should pretty much never use plane->state anywhere. Just use drm_atomic_get_{,old,new}_plane_state() & co. Outside of exceptional cases plane->state should only be accessed by duplicate_state() and swap_state().
Quoted 3 lines
If you call
drm_atomic_get_old_plane_state()fromatomic_check(), what will it return?
Before swap state:
- drm_atomic_get_old_plane_state() points to the same thing as plane->state, or NULL if the plane is not part of the drm_atomic_state
- drm_atomic_get_new_plane_state() points to the newly duplicated state only tracked within drm_atomic_state, or NULL if the plane is not part of the drm_atomic_state
After swap state:
- drm_atomic_get_old_plane_state() still points to the same thing as before, even though plane->state no longer points there. This old state is no longer visible outside the drm_atomic_state and will get destoyed when the drm_atomic_state gets nuked once the commit has been done
- drm_atomic_get_new_plane_state() still points to the same thing as before, and now plane->state also points to it
But all you really need to know is you have a transaction (drm_atomic_state) and each object taking part in it will have an old state (= the object's state before the transaction has been commited), and new state (= the object's state after the transaction has been commited).
Quoted 29 lines
In
atomic_update()plane->stateis the state to be committed and the state argument is the old state before the start of the atomic commit. And callingdrm_atomic_get_new_plane_state()will *not* the return the plane's new state (i.e., the one inplane->state) IIRC. (As I mentioned, there was a related bug in one of the drivers.) So we began to call this 'old_state'.My point is: the state passed to the check and commit functions are different things, even though they appear to be the same.
Quoted 4 lines
I've proposed renaming
drm_atomic_stateto eg.drm_atomic_transactiona few times before but no one took the bait so far...If you really don't like
new_state, then let's call itstate_tx.Best regards
ThomasSignature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Signature · 2 lines
Ville Syrjälä Intel
Thomas Zimmermann
maintainerHi
Am 12.09.22 um 19:16 schrieb Ville Syrjälä:
Quoted 108 lines · Thomas Zimmermann
Quoted 84 lines
Hi
Am 12.09.22 um 14:34 schrieb Ville Syrjälä:
Quoted 74 lines · Thomas Zimmermann
Quoted 46 lines
Hi
Am 12.09.22 um 13:18 schrieb Ville Syrjälä:
Quoted 43 lines · Thomas Zimmermann
Quoted 41 lines
Hi
Am 12.09.22 um 12:40 schrieb Ville Syrjälä:
Quoted 18 lines · Javier Martinez Canillas
Quoted 17 lines
Provides a default plane state check handler for primary planes that are a fullscreen scanout buffer and whose state scale and position can't change.
There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a plane helper and make drivers use it.
Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/drm_plane_helper.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 18 +----------------- drivers/gpu/drm/tiny/simpledrm.c | 25 +------------------------ include/drm/drm_plane_helper.h | 2 ++ 4 files changed, 33 insertions(+), 41 deletions(-)Quoted 16 lines
drivers/gpu/drm/drm_plane_helper.c void drm_plane_helper_destroy(struct drm_plane *plane) · line 285
Quoted 13 lines
drivers/gpu/drm/drm_plane_helper.c +5
-0@@ -278,3 +278,32 @@ void drm_plane_helper_destroy(struct drm_plane *plane)kfree (plane); }EXPORT_SYMBOL (drm_plane_helper_destroy); + +/** +* drm_plane_helper_atomic_check() - Helper to check primary planes states +* @plane: plane to check +* @new_state: plane state to check That is not a plane state. Also should s/new_// since it's just the overall atomic state thing rather than some new or old state.
Using only 'state' is non-intuitive and has lead to bugs where sub-state was retrieved from the wrong state information. So we've been using '
new_state' and 'old_state' explicitly in several places now.Quoted 6 lines
Quoted 1 line
There is no old or new
drm_atomic_state. It contains both.I (vaguely) remember a bug where a driver tried
drm_atomic_get_new_plane_state()with the (old) state that's passed toatomic_update. It didn't return the expected results and modesetting gave slightly wrong results.As there is no wrong
drm_atomic_stateto pass I don't think it could have been the case.Quoted 2 lines
So we began to be more precise about new
and old. And whatever is stored in 'plane->state' is then just 'the state'.There were certainly a lot of confusion before the explicit new/old state stuff was added whether foo->state/etc. was the old or the new state. And labeling things as explicitly old vs. new when passing in individual object states certainly makes sense. But that doesn't really have anything to do with mislabeling the overall
drm_atomic_state.Quoted 3 lines
I understand that the semantics of
atomic_checkare different fromatomic_update, but it still doesn't hurt to talk ofnew_stateIMHO.IMO it's just confusing. Makes the reader think there is somehow different
drm_atomic_statesfor old vs. new states when there isn't. I also wouldn't call itnew_statefor .atomic_update() either.Quoted 6 lines
In both cases you have the old and new states in there and how exactly they get used in the hooks is more of an implementation detail. The only rules you would have to follow is that at the end of .atomic_update() the hardware state matches the new state, and .atomic_check() makes sure the transition from the old to the new state is possible.
Quoted 5 lines
From what I understand:
In
atomic_check(),plane->stateis the current state and the state argument is the state to be validated. Callingdrm_atomic_get_new_plane_state()will return the plane's new state.You should pretty much never use
plane->stateanywhere. Just use drm_atomic_get_{,old,new}_plane_state() & co. Outside of exceptional casesplane->stateshould only be accessed byduplicate_state()andswap_state().Quoted 3 lines
If you call
drm_atomic_get_old_plane_state()fromatomic_check(), what will it return?Before swap state:
-drm_atomic_get_old_plane_state()points to the same thing asplane->state, or NULL if the plane is not part of thedrm_atomic_state
-drm_atomic_get_new_plane_state()points to the newly duplicated state only tracked withindrm_atomic_state, or NULL if the plane is not part of thedrm_atomic_state
Quoted 8 lines
After swap state:
-drm_atomic_get_old_plane_state()still points to the same thing as before, even thoughplane->stateno longer points there. This old state is no longer visible outside thedrm_atomic_stateand will get destoyed when thedrm_atomic_stategets nuked once the commit has been done
-drm_atomic_get_new_plane_state()still points to the same thing as before, and nowplane->statealso points to it
This is exactly what I always assumed, but I remember finding a situation where this didn't work as expected. (If only I could find it again.) Anyway, as it's supposed to be the correct let's do exactly this.
Best regards
Thomas
Quoted 40 lines
But all you really need to know is you have a transaction (
drm_atomic_state) and each object taking part in it will have an old state (= the object's state before the transaction has been commited), and new state (= the object's state after the transaction has been commited).Quoted 29 lines
In
atomic_update()plane->stateis the state to be committed and the state argument is the old state before the start of the atomic commit. And callingdrm_atomic_get_new_plane_state()will *not* the return the plane's new state (i.e., the one inplane->state) IIRC. (As I mentioned, there was a related bug in one of the drivers.) So we began to call this 'old_state'.My point is: the state passed to the check and commit functions are different things, even though they appear to be the same.
Quoted 4 lines
I've proposed renaming
drm_atomic_stateto eg.drm_atomic_transactiona few times before but no one took the bait so far...If you really don't like
new_state, then let's call itstate_tx.Best regards
ThomasSignature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev