Message ID | 20171221121101.29161-2-peter.ujfalusi@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Dec 21, 2017 at 02:11:00PM +0200, Peter Ujfalusi wrote: > 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. > > If user space wants to move the primary plane forward, it can set the zpos > of the plane. > > Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> > --- > drivers/gpu/drm/drm_blend.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c > index 4c62dff14893..bdc4f714afb8 100644 > --- a/drivers/gpu/drm/drm_blend.c > +++ b/drivers/gpu/drm/drm_blend.c > @@ -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; > -- > Peter > > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
On 21/12/17 14:55, Ville Syrjälä wrote: > On Thu, Dec 21, 2017 at 02:11:00PM +0200, Peter Ujfalusi wrote: >> 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. 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
On Thu, Dec 21, 2017 at 03:44:56PM +0200, Tomi Valkeinen wrote: > On 21/12/17 14:55, Ville Syrjälä wrote: > > On Thu, Dec 21, 2017 at 02:11:00PM +0200, Peter Ujfalusi wrote: > >> 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. > > 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. 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? > > 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.
On 21/12/17 16:20, Ville Syrjälä wrote: > On Thu, Dec 21, 2017 at 03:44:56PM +0200, Tomi Valkeinen wrote: >> On 21/12/17 14:55, Ville Syrjälä wrote: >>> On Thu, Dec 21, 2017 at 02:11:00PM +0200, Peter Ujfalusi wrote: >>>> 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. >> >> 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. > > 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. >> 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
On Thu, Dec 21, 2017 at 04:31:47PM +0200, Tomi Valkeinen wrote: > On 21/12/17 16:20, Ville Syrjälä wrote: > > On Thu, Dec 21, 2017 at 03:44:56PM +0200, Tomi Valkeinen wrote: > >> On 21/12/17 14:55, Ville Syrjälä wrote: > >>> On Thu, Dec 21, 2017 at 02:11:00PM +0200, Peter Ujfalusi wrote: > >>>> 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. > >> > >> 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. > > > > 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. > > >> 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... 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?
On 21/12/17 17:12, Ville Syrjälä wrote: >> 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... > > 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? 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
On Fri, Dec 22, 2017 at 11:16:47AM +0200, Tomi Valkeinen wrote: > On 21/12/17 17:12, Ville Syrjälä wrote: > > >> 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... > > > > 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? > > 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. IIRC I argued against the normalization, but some people really wanted it for whatever reason.
Hi, On 2017-12-22 12:12, Ville Syrjälä wrote: > On Fri, Dec 22, 2017 at 11:16:47AM +0200, Tomi Valkeinen wrote: >> On 21/12/17 17:12, Ville Syrjälä wrote: >> >>>> 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... >>> >>> 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? >> >> 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. > > 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
On Fri, Dec 22, 2017 at 05:15:05PM +0200, Peter Ujfalusi wrote: > Hi, > > On 2017-12-22 12:12, Ville Syrjälä wrote: > > On Fri, Dec 22, 2017 at 11:16:47AM +0200, Tomi Valkeinen wrote: > >> On 21/12/17 17:12, Ville Syrjälä wrote: > >> > >>>> 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... > >>> > >>> 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? > >> > >> 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. > > > > 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
Hi Daniel, On Tuesday, 9 January 2018 14:42:55 EET Daniel Vetter wrote: > On Fri, Dec 22, 2017 at 05:15:05PM +0200, Peter Ujfalusi wrote: > > On 2017-12-22 12:12, Ville Syrjälä wrote: > > > On Fri, Dec 22, 2017 at 11:16:47AM +0200, Tomi Valkeinen wrote: > > >> On 21/12/17 17:12, Ville Syrjälä wrote: > > >>>> 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... > > >>> > > >>> 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? > > >> > > >> 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. > > > > > > 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). 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.
On Tue, Jan 09, 2018 at 03:40:36PM +0200, Laurent Pinchart wrote: > Hi Daniel, > > On Tuesday, 9 January 2018 14:42:55 EET Daniel Vetter wrote: > > On Fri, Dec 22, 2017 at 05:15:05PM +0200, Peter Ujfalusi wrote: > > > On 2017-12-22 12:12, Ville Syrjälä wrote: > > > > On Fri, Dec 22, 2017 at 11:16:47AM +0200, Tomi Valkeinen wrote: > > > >> On 21/12/17 17:12, Ville Syrjälä wrote: > > > >>>> 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... > > > >>> > > > >>> 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? > > > >> > > > >> 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. > > > > > > > > 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). > > 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
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c index 4c62dff14893..bdc4f714afb8 100644 --- a/drivers/gpu/drm/drm_blend.c +++ b/drivers/gpu/drm/drm_blend.c @@ -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;
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. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> --- drivers/gpu/drm/drm_blend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)