drm blend/omap: normalized zpos handling
Subsystems (3)
cover drm blend/omap: normalized zpos handling
Hi,
The following two patch will change the omapdrm to use the normalized_zpos when configuring the zpos/zorder of the planes.
In OMAP it is possible to move planes between crtcs freely and it is possible to move even the primary plane from one crtc to another, where it should not be treated as primary anymore (the crtc's primary plane is the primary for the crtc).
The first patch will adjust the sorting of the planes for the given crtc to make sure that the crtc's primary plane, if it has zpos=0 is going to be the bottom plane. If the zpos of the primary plane is changed by user space then we obey this and don't force the bottom position.
Regards,
Peter
---
Peter Ujfalusi (2):
drm/blend: Account also the primary plane of the crtc for
normalized_zpos
drm/omap: Normalize the zpos and use the normalized_zpos in runtime
drivers/gpu/drm/drm_blend.c | 6 +++++- drivers/gpu/drm/omapdrm/omap_drv.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-)
Signature · 9 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/2 drm/blend: Account also the primary plane of the crtc for normalized_zpos
Make sure that the primary plane will get normalized_zpos=0 if it's zpos is set to 0, avoiding other planes to be placed in the background.
If user space wants to move the primary plane forward, it can set the zpos of the plane.
--- drivers/gpu/drm/drm_blend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_blend.c +5 -1
@@ -301,7 +301,11 @@ static int drm_atomic_state_zpos_cmp(const void *a, const void *b)const struct drm_plane_state *sa = *(struct drm_plane_state **)a;const struct drm_plane_state *sb = *(struct drm_plane_state **)b; -if (sa->zpos != sb->zpos) +if (sa->plane == sa->crtc->primary && sa->zpos ==0 ) +return -1 ; +else if (sb->plane == sb->crtc->primary && sb->zpos ==0 ) +return 1 ; +else if (sa->zpos != sb->zpos)return sa->zpos - sb->zpos;else return sa->plane->base.id - sb->plane->base.id;
Signature · 9 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 2 lines · Peter Ujfalusi
Make sure that the primary plane will get normalized_zpos=0 if it's zpos is set to 0, avoiding other planes to be placed in the background.
Can you describe the actual "bad" configuration?
Without knowing the details this looks like it's making things more complicated for no particularly good reason. If you're worried about clients that don't set zpos, then I think you should just assign the default zpos values better and/or allocate the planes in a better order. But it's definitely possible I'm missing the reason why you're doing this.
Quoted 36 lines
If user space wants to move the primary plane forward, it can set the zpos of the plane.
Signed-off-by Peter Ujfalusi <[email protected]>--- drivers/gpu/drm/drm_blend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_blend.c +5
-1@@ -301,7 +301,11 @@ static int drm_atomic_state_zpos_cmp(const void *a, const void *b)const struct drm_plane_state *sa = *(struct drm_plane_state **)a;const struct drm_plane_state *sb = *(struct drm_plane_state **)b; -if (sa->zpos != sb->zpos) +if (sa->plane == sa->crtc->primary && sa->zpos ==0 ) +return -1 ; +else if (sb->plane == sb->crtc->primary && sb->zpos ==0 ) +return 1 ; +else if (sa->zpos != sb->zpos)return sa->zpos - sb->zpos;else return sa->plane->base.id - sb->plane->base.id;Signature · 9 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 4 lines · Ville Syrjälä
Quoted 2 lines · Peter Ujfalusi
Make sure that the primary plane will get normalized_zpos=0 if it's zpos is set to 0, avoiding other planes to be placed in the background.
Quoted 8 lines
Can you describe the actual "bad" configuration?
Without knowing the details this looks like it's making things more complicated for no particularly good reason. If you're worried about clients that don't set zpos, then I think you should just assign the default zpos values better and/or allocate the planes in a better order. But it's definitely possible I'm missing the reason why you're doing this.
Let's say we have two displays and two planes. First display will use crtc0 and plane0 as primary plane, the second display crtc1, plane1. The zpos of primary planes will be set to 0 by default.
The userspace wants to use the second display, with an overlay plane. So it takes the plane0 and moves it to crtc1. Now the second display has two planes with zpos 0, and normalize_zpos will fix it according to the plane id, i.e. the primary plane of the second display will be on top of the "overlay" plane.
I don't think other default zpos values and/or allocating planes in better order can solve this.
If the userspace is required to understand and set zpos, then this patch is not needed. But at least in my test scripts I've hit this a few times =).
Tomi
Signature · 5 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 18 lines · Tomi Valkeinen
Quoted 4 lines · Ville Syrjälä
Quoted 2 lines · Peter Ujfalusi
Make sure that the primary plane will get normalized_zpos=0 if it's zpos is set to 0, avoiding other planes to be placed in the background.
Quoted 8 lines
Can you describe the actual "bad" configuration?
Without knowing the details this looks like it's making things more complicated for no particularly good reason. If you're worried about clients that don't set zpos, then I think you should just assign the default zpos values better and/or allocate the planes in a better order. But it's definitely possible I'm missing the reason why you're doing this.
Let's say we have two displays and two planes. First display will use crtc0 and plane0 as primary plane, the second display crtc1, plane1. The zpos of primary planes will be set to 0 by default.
Quoted 8 lines
The userspace wants to use the second display, with an overlay plane. So it takes the plane0 and moves it to crtc1. Now the second display has two planes with zpos 0, and
normalize_zposwill fix it according to the plane id, i.e. the primary plane of the second display will be on top of the "overlay" plane.I don't think other default zpos values and/or allocating planes in better order can solve this.
Hmm. True. OTOH this messes up the simple "plane id is used to resolve zpos conflicts" logic.
Also since you have multiple primary planes on the same crtc, which primary plane is the "real primary" for the crtc? How would userspace even determine that? I guess the rule could be that the primary planes have to be registered in the same order as the crtcs?
Quoted 3 lines
If the userspace is required to understand and set zpos, then this patch is not needed. But at least in my test scripts I've hit this a few times =).
I think it would be nice if we can just make it a rule that any userspace that moves planes between crtcs has to know about zpos. Otherwise it's pretty much pure luck what stacking order you would get.
And my idea for planes that can move between crtcs is that the default zpos should be assigned globally, probably matching the plane id order as well. Ie. no two planes would default to the same zpos value. And only in case of hardware that has no planes that can move between crtcs you would allocate the default zpos per-crtc.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 28 lines · Ville Syrjälä
Quoted 18 lines · Tomi Valkeinen
Quoted 4 lines · Ville Syrjälä
Quoted 2 lines · Peter Ujfalusi
Make sure that the primary plane will get normalized_zpos=0 if it's zpos is set to 0, avoiding other planes to be placed in the background.
Quoted 8 lines
Can you describe the actual "bad" configuration?
Without knowing the details this looks like it's making things more complicated for no particularly good reason. If you're worried about clients that don't set zpos, then I think you should just assign the default zpos values better and/or allocate the planes in a better order. But it's definitely possible I'm missing the reason why you're doing this.
Let's say we have two displays and two planes. First display will use crtc0 and plane0 as primary plane, the second display crtc1, plane1. The zpos of primary planes will be set to 0 by default.
Quoted 8 lines
The userspace wants to use the second display, with an overlay plane. So it takes the plane0 and moves it to crtc1. Now the second display has two planes with zpos 0, and
normalize_zposwill fix it according to the plane id, i.e. the primary plane of the second display will be on top of the "overlay" plane.I don't think other default zpos values and/or allocating planes in better order can solve this.
Quoted 7 lines
Hmm. True. OTOH this messes up the simple "plane id is used to resolve zpos conflicts" logic.
Also since you have multiple primary planes on the same crtc, which primary plane is the "real primary" for the crtc? How would userspace even determine that? I guess the rule could be that the primary planes have to be registered in the same order as the crtcs?
Hmm, true.
Quoted 7 lines
Quoted 2 lines
If the userspace is required to understand and set zpos, then this patch is not needed. But at least in my test scripts I've hit this a few times =).
I think it would be nice if we can just make it a rule that any userspace that moves planes between crtcs has to know about zpos. Otherwise it's pretty much pure luck what stacking order you would get.
Yes, but how does the userspace know when it is moving planes between crtcs?
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have much meaning. Is that correct?
If so... Then I guess the atomic modesetting client essentially randomly picks which plane it uses as a "root plane" (if it even needs such), and which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...
Tomi
Signature · 5 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 61 lines · Tomi Valkeinen
Quoted 28 lines · Ville Syrjälä
Quoted 18 lines · Tomi Valkeinen
Quoted 4 lines · Ville Syrjälä
Quoted 2 lines · Peter Ujfalusi
Make sure that the primary plane will get normalized_zpos=0 if it's zpos is set to 0, avoiding other planes to be placed in the background.
Quoted 8 lines
Can you describe the actual "bad" configuration?
Without knowing the details this looks like it's making things more complicated for no particularly good reason. If you're worried about clients that don't set zpos, then I think you should just assign the default zpos values better and/or allocate the planes in a better order. But it's definitely possible I'm missing the reason why you're doing this.
Let's say we have two displays and two planes. First display will use crtc0 and plane0 as primary plane, the second display crtc1, plane1. The zpos of primary planes will be set to 0 by default.
Quoted 8 lines
The userspace wants to use the second display, with an overlay plane. So it takes the plane0 and moves it to crtc1. Now the second display has two planes with zpos 0, and
normalize_zposwill fix it according to the plane id, i.e. the primary plane of the second display will be on top of the "overlay" plane.I don't think other default zpos values and/or allocating planes in better order can solve this.
Quoted 7 lines
Hmm. True. OTOH this messes up the simple "plane id is used to resolve zpos conflicts" logic.
Also since you have multiple primary planes on the same crtc, which primary plane is the "real primary" for the crtc? How would userspace even determine that? I guess the rule could be that the primary planes have to be registered in the same order as the crtcs?
Hmm, true.
Quoted 7 lines
Quoted 2 lines
If the userspace is required to understand and set zpos, then this patch is not needed. But at least in my test scripts I've hit this a few times =).
I think it would be nice if we can just make it a rule that any userspace that moves planes between crtcs has to know about zpos. Otherwise it's pretty much pure luck what stacking order you would get.
Yes, but how does the userspace know when it is moving planes between crtcs?
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have much meaning. Is that correct?
Quoted 4 lines
If so... Then I guess the atomic modesetting client essentially randomly picks which plane it uses as a "root plane" (if it even needs such), and which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...
I'm not sure anyone has really thought how userspace would/should assign planes to crtcs. My only idea so far has been the crtc and their preferred primary planes should be registered in the same order. But someone should then also implement that same policy in userspace when it's trying to figure out which plane to use. There are other heuristics it should probably use, like preferring to pick a primary plane for any fullscreen surface.
I guess from functional point of view it shouldn't matter which plane you pick as long as the plane's user visible capabilities are sufficient. But there might be user invisible power saving features and whatnot that only work with specific planes. So from that point of view maybe the order in which the planes get registered is important. Or we could maybe come up with some kind of plane usage hints in the uapi which could help userspace decide?
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 25 lines · Ville Syrjälä
Quoted 12 lines
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have much meaning. Is that correct?
Quoted 4 lines
If so... Then I guess the atomic modesetting client essentially randomly picks which plane it uses as a "root plane" (if it even needs such), and which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...
I'm not sure anyone has really thought how userspace would/should assign planes to crtcs. My only idea so far has been the crtc and their preferred primary planes should be registered in the same order. But someone should then also implement that same policy in userspace when it's trying to figure out which plane to use. There are other heuristics it should probably use, like preferring to pick a primary plane for any fullscreen surface.
Quoted 7 lines
I guess from functional point of view it shouldn't matter which plane you pick as long as the plane's user visible capabilities are sufficient. But there might be user invisible power saving features and whatnot that only work with specific planes. So from that point of view maybe the order in which the planes get registered is important. Or we could maybe come up with some kind of plane usage hints in the uapi which could help userspace decide?
I was thinking about this, and... maybe there isn't even any problem (at least for OMAP). So lets say we set the default plane zpos to the plane index, and that the primary planes are reserved first (i.e. have lower zpos than overlay planes).
We have three different cases:
Legacy modesetting: No problems, primary plane is always at the bottom. If the userspace uses 2+ overlay planes, it can expect the zpos to be based on the plane id, or it can set the zpos.
Atomic+Universal, the application uses one primary plane, and zero or more overlay planes: No problems here, the situation is the same as for legacy.
Atomic+Universal, the application uses more than one primary plane, and zero or more overlay planes: in this case the app _has_ to manage zpos, because using two primary planes in a single screen, and expecting it to work by default, doesn't make sense.
If the above "rules" are valid, then there's no need for this patch.
But one question I don't have a good answer is that why would we want to normalize the zpos, instead of returning an error? If the above rules are valid, I think returning an error is better than normalizing and hiding the bad configuration.
Tomi
Signature · 5 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 55 lines · Tomi Valkeinen
Quoted 25 lines · Ville Syrjälä
Quoted 12 lines
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have much meaning. Is that correct?
Quoted 4 lines
If so... Then I guess the atomic modesetting client essentially randomly picks which plane it uses as a "root plane" (if it even needs such), and which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...
I'm not sure anyone has really thought how userspace would/should assign planes to crtcs. My only idea so far has been the crtc and their preferred primary planes should be registered in the same order. But someone should then also implement that same policy in userspace when it's trying to figure out which plane to use. There are other heuristics it should probably use, like preferring to pick a primary plane for any fullscreen surface.
Quoted 7 lines
I guess from functional point of view it shouldn't matter which plane you pick as long as the plane's user visible capabilities are sufficient. But there might be user invisible power saving features and whatnot that only work with specific planes. So from that point of view maybe the order in which the planes get registered is important. Or we could maybe come up with some kind of plane usage hints in the uapi which could help userspace decide?
I was thinking about this, and... maybe there isn't even any problem (at least for OMAP). So lets say we set the default plane zpos to the plane index, and that the primary planes are reserved first (i.e. have lower zpos than overlay planes).
We have three different cases:
Legacy modesetting: No problems, primary plane is always at the bottom. If the userspace uses 2+ overlay planes, it can expect the zpos to be based on the plane id, or it can set the zpos.
Atomic+Universal, the application uses one primary plane, and zero or more overlay planes: No problems here, the situation is the same as for legacy.
Atomic+Universal, the application uses more than one primary plane, and zero or more overlay planes: in this case the app _has_ to manage zpos, because using two primary planes in a single screen, and expecting it to work by default, doesn't make sense.
Quoted 6 lines
If the above "rules" are valid, then there's no need for this patch.
But one question I don't have a good answer is that why would we want to normalize the zpos, instead of returning an error? If the above rules are valid, I think returning an error is better than normalizing and hiding the bad configuration.
IIRC I argued against the normalization, but some people really wanted it for whatever reason.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Hi,
Quoted 58 lines · Ville Syrjälä
Quoted 57 lines · Tomi Valkeinen
Quoted 25 lines · Ville Syrjälä
Quoted 12 lines
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have much meaning. Is that correct?
Quoted 4 lines
If so... Then I guess the atomic modesetting client essentially randomly picks which plane it uses as a "root plane" (if it even needs such), and which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...
I'm not sure anyone has really thought how userspace would/should assign planes to crtcs. My only idea so far has been the crtc and their preferred primary planes should be registered in the same order. But someone should then also implement that same policy in userspace when it's trying to figure out which plane to use. There are other heuristics it should probably use, like preferring to pick a primary plane for any fullscreen surface.
Quoted 7 lines
I guess from functional point of view it shouldn't matter which plane you pick as long as the plane's user visible capabilities are sufficient. But there might be user invisible power saving features and whatnot that only work with specific planes. So from that point of view maybe the order in which the planes get registered is important. Or we could maybe come up with some kind of plane usage hints in the uapi which could help userspace decide?
I was thinking about this, and... maybe there isn't even any problem (at least for OMAP). So lets say we set the default plane zpos to the plane index, and that the primary planes are reserved first (i.e. have lower zpos than overlay planes).
We have three different cases:
Legacy modesetting: No problems, primary plane is always at the bottom. If the userspace uses 2+ overlay planes, it can expect the zpos to be based on the plane id, or it can set the zpos.
Atomic+Universal, the application uses one primary plane, and zero or more overlay planes: No problems here, the situation is the same as for legacy.
Atomic+Universal, the application uses more than one primary plane, and zero or more overlay planes: in this case the app _has_ to manage zpos, because using two primary planes in a single screen, and expecting it to work by default, doesn't make sense.
If the above "rules" are valid, then there's no need for this patch.
Quoted 7 lines
Quoted 4 lines
But one question I don't have a good answer is that why would we want to normalize the zpos, instead of returning an error? If the above rules are valid, I think returning an error is better than normalizing and hiding the bad configuration.
IIRC I argued against the normalization, but some people really wanted it for whatever reason.
OK, please ignore this series, I'll send a patch instead next year.
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 66 lines · Peter Ujfalusi
Hi,
Quoted 63 lines · Ville Syrjälä
Quoted 61 lines · Tomi Valkeinen
Quoted 25 lines · Ville Syrjälä
Quoted 12 lines
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have much meaning. Is that correct?
Quoted 4 lines
If so... Then I guess the atomic modesetting client essentially randomly picks which plane it uses as a "root plane" (if it even needs such), and which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...
I'm not sure anyone has really thought how userspace would/should assign planes to crtcs. My only idea so far has been the crtc and their preferred primary planes should be registered in the same order. But someone should then also implement that same policy in userspace when it's trying to figure out which plane to use. There are other heuristics it should probably use, like preferring to pick a primary plane for any fullscreen surface.
Quoted 7 lines
I guess from functional point of view it shouldn't matter which plane you pick as long as the plane's user visible capabilities are sufficient. But there might be user invisible power saving features and whatnot that only work with specific planes. So from that point of view maybe the order in which the planes get registered is important. Or we could maybe come up with some kind of plane usage hints in the uapi which could help userspace decide?
I was thinking about this, and... maybe there isn't even any problem (at least for OMAP). So lets say we set the default plane zpos to the plane index, and that the primary planes are reserved first (i.e. have lower zpos than overlay planes).
We have three different cases:
Legacy modesetting: No problems, primary plane is always at the bottom. If the userspace uses 2+ overlay planes, it can expect the zpos to be based on the plane id, or it can set the zpos.
Atomic+Universal, the application uses one primary plane, and zero or more overlay planes: No problems here, the situation is the same as for legacy.
Atomic+Universal, the application uses more than one primary plane, and zero or more overlay planes: in this case the app _has_ to manage zpos, because using two primary planes in a single screen, and expecting it to work by default, doesn't make sense.
If the above "rules" are valid, then there's no need for this patch.
But one question I don't have a good answer is that why would we want to normalize the zpos, instead of returning an error? If the above rules are valid, I think returning an error is better than normalizing and hiding the bad configuration.
Quoted 4 lines
Quoted 2 lines
IIRC I argued against the normalization, but some people really wanted it for whatever reason.
OK, please ignore this series, I'll send a patch instead next year.
So now we end up with a bunch of kms drivers that normalize zpos, and a bunch of others which rejects duplicated zpos.
That sounds even worse. Can we pls try to be consistent (even if it turns out to be a not-so-great uapi decision, it's uapi, so let's not make things worse by making it inconsistent).
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Hi Daniel,
Quoted 77 lines · On Tuesday, 9 January 2018 14:42:55 EET Daniel Vetter wrote:
Quoted 76 lines · Peter Ujfalusi
Quoted 74 lines · Ville Syrjälä
Quoted 63 lines · Tomi Valkeinen
Quoted 30 lines · Ville Syrjälä
Quoted 14 lines
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no
problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have
much meaning. Is that correct?Quoted 6 lines
If so... Then I guess the atomic modesetting client essentially randomly
picks which plane it uses as a "root plane" (if it even needs such), and
which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...I'm not sure anyone has really thought how userspace would/should assign
planes to crtcs. My only idea so far has been the crtc and their preferred primary planes should be registered in the same order. But someone should then also implement that same policy in userspace when it's trying to figure out which plane to use. There are other heuristics it should probably use, like preferring to pick a primary plane for any fullscreen surface.Quoted 9 lines
I guess from functional point of view it shouldn't matter which plane you pick as long as the plane's user visible capabilities are sufficient. But there might be user invisible power saving features and
whatnot that only work with specific planes. So from that point of view
maybe the order in which the planes get registered is important. Or we could maybe come up with some kind of plane usage hints in the uapi which could help userspace decide?I was thinking about this, and... maybe there isn't even any problem (at
least for OMAP). So lets say we set the default plane zpos to the plane index, and that the primary planes are reserved first (i.e. have lower zpos than overlay planes).We have three different cases:
Legacy modesetting: No problems, primary plane is always at the bottom. If the userspace uses 2+ overlay planes, it can expect the zpos to be based on the plane id, or it can set the zpos.
Atomic+Universal, the application uses one primary plane, and zero or more overlay planes: No problems here, the situation is the same as for legacy.
Atomic+Universal, the application uses more than one primary plane, and zero or more overlay planes: in this case the app _has_ to manage zpos, because using two primary planes in a single screen, and expecting it to
work by default, doesn't make sense.Quoted 7 lines
If the above "rules" are valid, then there's no need for this patch.
But one question I don't have a good answer is that why would we want to
normalize the zpos, instead of returning an error? If the above rules are valid, I think returning an error is better than normalizing and hiding the bad configuration.IIRC I argued against the normalization, but some people really wanted it for whatever reason.
Quoted 8 lines
Quoted 1 line
OK, please ignore this series, I'll send a patch instead next year.
So now we end up with a bunch of kms drivers that normalize zpos, and a bunch of others which rejects duplicated zpos.
That sounds even worse. Can we pls try to be consistent (even if it turns out to be a not-so-great uapi decision, it's uapi, so let's not make things worse by making it inconsistent).
For what it's worth, I'd tend to disallow duplicate zpos values. That forces userspace to user atomic and to handle zpos explicitly, and that's exactly why it's my preference as not handling zpos explicitly in userspace will lead to random behaviour at best.
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/blend: Account also the primary plane of the crtc for normalized_zpos
Quoted 85 lines · Laurent Pinchart
Hi Daniel,
Quoted 82 lines · On Tuesday, 9 January 2018 14:42:55 EET Daniel Vetter wrote:
Quoted 73 lines · Peter Ujfalusi
Quoted 72 lines · Ville Syrjälä
Quoted 70 lines · Tomi Valkeinen
Quoted 30 lines · Ville Syrjälä
Quoted 14 lines
If the userspace knows this, then it knows which primary plane is for which crtc, right?
And if it doesn't know this, then the userspace cannot associate any plane to any crtc (except what it configures itself).
So... If using legacy modesetting (and non-universal planes), there's no
problem, primary planes are fixed and at low zpos. If using atomic modesetting and universal planes, there's really no (default) association between planes and crtcs, and "primary plane" doesn't have
much meaning. Is that correct?Quoted 6 lines
If so... Then I guess the atomic modesetting client essentially randomly
picks which plane it uses as a "root plane" (if it even needs such), and
which planes as overlay planes? If that's the case, then this patch doesn't quite fix the issue...I'm not sure anyone has really thought how userspace would/should assign
planes to crtcs. My only idea so far has been the crtc and their preferred primary planes should be registered in the same order. But someone should then also implement that same policy in userspace when it's trying to figure out which plane to use. There are other heuristics it should probably use, like preferring to pick a primary plane for any fullscreen surface.Quoted 9 lines
I guess from functional point of view it shouldn't matter which plane you pick as long as the plane's user visible capabilities are sufficient. But there might be user invisible power saving features and
whatnot that only work with specific planes. So from that point of view
maybe the order in which the planes get registered is important. Or we could maybe come up with some kind of plane usage hints in the uapi which could help userspace decide?I was thinking about this, and... maybe there isn't even any problem (at
least for OMAP). So lets say we set the default plane zpos to the plane index, and that the primary planes are reserved first (i.e. have lower zpos than overlay planes).We have three different cases:
Legacy modesetting: No problems, primary plane is always at the bottom. If the userspace uses 2+ overlay planes, it can expect the zpos to be based on the plane id, or it can set the zpos.
Atomic+Universal, the application uses one primary plane, and zero or more overlay planes: No problems here, the situation is the same as for legacy.
Atomic+Universal, the application uses more than one primary plane, and zero or more overlay planes: in this case the app _has_ to manage zpos, because using two primary planes in a single screen, and expecting it to
work by default, doesn't make sense.If the above "rules" are valid, then there's no need for this patch.
But one question I don't have a good answer is that why would we want to
normalize the zpos, instead of returning an error? If the above rules are valid, I think returning an error is better than normalizing and hiding the bad configuration.Quoted 4 lines
Quoted 2 lines
IIRC I argued against the normalization, but some people really wanted it for whatever reason.
OK, please ignore this series, I'll send a patch instead next year.
So now we end up with a bunch of kms drivers that normalize zpos, and a bunch of others which rejects duplicated zpos.
Quoted 8 lines
Quoted 3 lines
That sounds even worse. Can we pls try to be consistent (even if it turns out to be a not-so-great uapi decision, it's uapi, so let's not make things worse by making it inconsistent).
For what it's worth, I'd tend to disallow duplicate zpos values. That forces userspace to user atomic and to handle zpos explicitly, and that's exactly why it's my preference as not handling zpos explicitly in userspace will lead to random behaviour at best.
I don't care what we're going with tbf, except it should be consistent across drivers ... Everyone just implementing their flavour of bikeshed in their driver is kinda uncool.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/omap: Normalize the zpos and use the normalized_zpos in runtime
In reply to Peter UjfalusiTo avoid zpos collision, use the normalized_zpos when configuring the zorder of the plane.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +25 -1
@@ -21,6 +21,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_blend.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h>
@@ -54,6 +55,29 @@ MODULE_PARM_DESC(displays,* devices */ +int omap_atomic_helper_check (struct drm_device *dev, +struct drm_atomic_state *state) +{ +int ret; + + ret =drm_atomic_helper_check_modeset (dev, state); +if (ret) +return ret; + + ret =drm_atomic_normalize_zpos (dev, state); +if (ret) +return ret; + + ret =drm_atomic_helper_check_planes (dev, state); +if (ret) +return ret; + +if (state->legacy_cursor_update) + state->async_update = !drm_atomic_helper_async_check (dev, state); + +return ret; +} +static void omap_atomic_wait_for_completion (struct drm_device *dev,struct drm_atomic_state *old_state) {
@@ -133,7 +157,7 @@ static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs =static const struct drm_mode_config_funcs omap_mode_config_funcs = { .fb_create = omap_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed, - .atomic_check = drm_atomic_helper_check, + .atomic_check = omap_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, };
drivers/gpu/drm/omapdrm/omap_plane.c +1 -1
@@ -65,7 +65,7 @@ static void omap_plane_atomic_update(struct drm_plane *plane, info.rotation_type =OMAP_DSS_ROT_NONE ; info.rotation =DRM_MODE_ROTATE_0 ; info.global_alpha =0xff ; - info.zorder = state->zpos; + info.zorder = state->normalized_zpos;/* update scanout: */ omap_framebuffer_update_scanout (state->fb, state, &info);
Signature · 9 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/omap: Normalize the zpos and use the normalized_zpos in runtime
Quoted 27 lines · Peter Ujfalusi
To avoid zpos collision, use the
normalized_zposwhen configuring the zorder of the plane.Signed-off-by Peter Ujfalusi <[email protected]>--- drivers/gpu/drm/omapdrm/omap_drv.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-)drivers/gpu/drm/omapdrm/omap_drv.c +3
-0@@ -21,6 +21,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_blend.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> @@ -54,6 +55,29 @@ MODULE_PARM_DESC(displays,* devices */ +int omap_atomic_helper_check (struct drm_device *dev, +struct drm_atomic_state *state)
drivers/gpu/drm/omapdrm/omap_drv.c MODULE_PARM_DESC(displays, · line 69
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +10
-0+{ +int ret; + + ret =drm_atomic_helper_check_modeset (dev, state); +if (ret) +return ret; + + ret =drm_atomic_normalize_zpos (dev, state); +if (ret) +return ret;
Maybe we should call this by default from helpers instead of forcing everyone to reinvent this particular wheel?
exynos and sti have the exact same code as you do here, ans rcar could also reuse it. That feels like we should just fix up drm_atomic_helper_check instead of patching all the drivers. And as long as you never change zpos it shouldn't ever run.
-Daniel
Quoted 42 lines
drivers/gpu/drm/omapdrm/omap_drv.c +12
-1+ + ret =drm_atomic_helper_check_planes (dev, state); +if (ret) +return ret; + +if (state->legacy_cursor_update) + state->async_update = !drm_atomic_helper_async_check (dev, state); + +return ret; +} +static void omap_atomic_wait_for_completion (struct drm_device *dev,struct drm_atomic_state *old_state) {@@ -133,7 +157,7 @@ static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs =static const struct drm_mode_config_funcs omap_mode_config_funcs = { .fb_create = omap_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed, - .atomic_check = drm_atomic_helper_check, + .atomic_check = omap_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, };drivers/gpu/drm/omapdrm/omap_plane.c +1
-1@@ -65,7 +65,7 @@ static void omap_plane_atomic_update(struct drm_plane *plane, info.rotation_type =OMAP_DSS_ROT_NONE ; info.rotation =DRM_MODE_ROTATE_0 ; info.global_alpha =0xff ; - info.zorder = state->zpos; + info.zorder = state->normalized_zpos;/* update scanout: */ omap_framebuffer_update_scanout (state->fb, state, &info);Signature · 4 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/omap: Normalize the zpos and use the normalized_zpos in runtime
Quoted 42 lines · Daniel Vetter
Quoted 27 lines · Peter Ujfalusi
To avoid zpos collision, use the
normalized_zposwhen configuring the zorder of the plane.Signed-off-by Peter Ujfalusi <[email protected]>--- drivers/gpu/drm/omapdrm/omap_drv.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-)drivers/gpu/drm/omapdrm/omap_drv.c +3
-0@@ -21,6 +21,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_blend.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> @@ -54,6 +55,29 @@ MODULE_PARM_DESC(displays,* devices */ +int omap_atomic_helper_check (struct drm_device *dev, +struct drm_atomic_state *state)drivers/gpu/drm/omapdrm/omap_drv.c MODULE_PARM_DESC(displays, · line 69
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +10
-0+{ +int ret; + + ret =drm_atomic_helper_check_modeset (dev, state); +if (ret) +return ret; + + ret =drm_atomic_normalize_zpos (dev, state); +if (ret) +return ret;Maybe we should call this by default from helpers instead of forcing everyone to reinvent this particular wheel?
Quoted 4 lines
exynos and sti have the exact same code as you do here, ans rcar could also reuse it. That feels like we should just fix up
drm_atomic_helper_checkinstead of patching all the drivers. And as long as you never change zpos it shouldn't ever run.
It used to be done within drm_atomic_helper_check_planes() which is called from the drm_atomic_helper_check(), but commit 38d868e41c4b9 drm: Don't force all planes to be added to the state due to zpos
removed it. Drivers need to do this by themselves if they want to use the normalized_zpos.
Quoted 36 lines
-Daniel
Quoted 34 lines
drivers/gpu/drm/omapdrm/omap_drv.c +12
-1+ + ret =drm_atomic_helper_check_planes (dev, state); +if (ret) +return ret; + +if (state->legacy_cursor_update) + state->async_update = !drm_atomic_helper_async_check (dev, state); + +return ret; +} +static void omap_atomic_wait_for_completion (struct drm_device *dev,struct drm_atomic_state *old_state) {@@ -133,7 +157,7 @@ static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs =static const struct drm_mode_config_funcs omap_mode_config_funcs = { .fb_create = omap_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed, - .atomic_check = drm_atomic_helper_check, + .atomic_check = omap_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, };drivers/gpu/drm/omapdrm/omap_plane.c +1
-1@@ -65,7 +65,7 @@ static void omap_plane_atomic_update(struct drm_plane *plane, info.rotation_type =OMAP_DSS_ROT_NONE ; info.rotation =DRM_MODE_ROTATE_0 ; info.global_alpha =0xff ; - info.zorder = state->zpos; + info.zorder = state->normalized_zpos;
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_plane.c +0
-0/* update scanout: */ omap_framebuffer_update_scanout (state->fb, state, &info);Signature · 4 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/omap: Normalize the zpos and use the normalized_zpos in runtime
Quoted 50 lines · Peter Ujfalusi
Quoted 42 lines · Daniel Vetter
Quoted 27 lines · Peter Ujfalusi
To avoid zpos collision, use the
normalized_zposwhen configuring the zorder of the plane.Signed-off-by Peter Ujfalusi <[email protected]>--- drivers/gpu/drm/omapdrm/omap_drv.c | 26 +++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-)drivers/gpu/drm/omapdrm/omap_drv.c +3
-0@@ -21,6 +21,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_blend.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> @@ -54,6 +55,29 @@ MODULE_PARM_DESC(displays,* devices */ +int omap_atomic_helper_check (struct drm_device *dev, +struct drm_atomic_state *state)drivers/gpu/drm/omapdrm/omap_drv.c MODULE_PARM_DESC(displays, · line 69
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +10
-0+{ +int ret; + + ret =drm_atomic_helper_check_modeset (dev, state); +if (ret) +return ret; + + ret =drm_atomic_normalize_zpos (dev, state); +if (ret) +return ret;Maybe we should call this by default from helpers instead of forcing everyone to reinvent this particular wheel?
Quoted 4 lines
exynos and sti have the exact same code as you do here, ans rcar could also reuse it. That feels like we should just fix up
drm_atomic_helper_checkinstead of patching all the drivers. And as long as you never change zpos it shouldn't ever run.
Quoted 7 lines
It used to be done within
drm_atomic_helper_check_planes()which is called from thedrm_atomic_helper_check(), but commit38d868e41c4b9drm: Don't force all planes to be added to the state due to zposremoved it. Drivers need to do this by themselves if they want to use the
normalized_zpos.
Oh right, I forgot about all that again.
-Daniel
Quoted 51 lines
Quoted 37 lines
-Daniel
Quoted 34 lines
drivers/gpu/drm/omapdrm/omap_drv.c +12
-1+ + ret =drm_atomic_helper_check_planes (dev, state); +if (ret) +return ret; + +if (state->legacy_cursor_update) + state->async_update = !drm_atomic_helper_async_check (dev, state); + +return ret; +} +static void omap_atomic_wait_for_completion (struct drm_device *dev,struct drm_atomic_state *old_state) {@@ -133,7 +157,7 @@ static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs =static const struct drm_mode_config_funcs omap_mode_config_funcs = { .fb_create = omap_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed, - .atomic_check = drm_atomic_helper_check, + .atomic_check = omap_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, };drivers/gpu/drm/omapdrm/omap_plane.c +1
-1@@ -65,7 +65,7 @@ static void omap_plane_atomic_update(struct drm_plane *plane, info.rotation_type =OMAP_DSS_ROT_NONE ; info.rotation =DRM_MODE_ROTATE_0 ; info.global_alpha =0xff ; - info.zorder = state->zpos; + info.zorder = state->normalized_zpos;Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_plane.c +0
-0/* update scanout: */ omap_framebuffer_update_scanout (state->fb, state, &info);Signature · 4 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel