drm/modes: Support video parameters with only reflect option
Subsystems (2)
PATCH 1/1 drm/modes: Support video parameters with only reflect option
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the panel_orientation with cmdline->rotation_reflection does not handle the case when cmdline->rotation_reflection does not have any rotation set.
(i.e. cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK == 0)
Example:
*rotation = DRM_MODE_ROTATE_0 (no panel_orientation) cmdline->rotation_reflection = DRM_MODE_REFLECT_X (video=MODE,reflect_x)
The current code does:
panel_rot = ilog2(*rotation & DRM_MODE_ROTATE_MASK); cmdline_rot = ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK); sum_rot = (panel_rot + cmdline_rot) % 4;
and therefore:
panel_rot = ilog2(DRM_MODE_ROTATE_0) = ilog2(1) = 0 cmdline_rot = ilog2(0) = -1
sum_rot = (0 + -1) % 4 = -1 % 4 = 3
...
*rotation = DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X
So we incorrectly generate DRM_MODE_ROTATE_270 in this case. To prevent cmdline_rot from becoming -1, we need to treat the rotation as DRM_MODE_ROTATE_0.
On the other hand, there is no need to go through that calculation at all if no rotation is set in rotation_reflection.
A simple XOR is enough to combine the reflections.
Finally, also allow DRM_MODE_ROTATE_0 in the if statement below. DRM_MODE_ROTATE_0 means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).
This makes video parameters with only reflect option work correctly.
--- drivers/gpu/drm/drm_client_modeset.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_client_modeset.c +16 -11
@@ -859,19 +859,23 @@ bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation)*/ cmdline = &connector->cmdline_mode;if (cmdline->specified && cmdline->rotation_reflection) { -unsigned int cmdline_rest, panel_rest; -unsigned int cmdline_rot, panel_rot; -unsigned int sum_rot, sum_rest; +if (cmdline->rotation_reflection &DRM_MODE_ROTATE_MASK ) { +unsigned int cmdline_rest, panel_rest; +unsigned int cmdline_rot, panel_rot; +unsigned int sum_rot, sum_rest; - panel_rot =ilog2 (*rotation &DRM_MODE_ROTATE_MASK ); - cmdline_rot =ilog2 (cmdline->rotation_reflection &DRM_MODE_ROTATE_MASK ); - sum_rot = (panel_rot + cmdline_rot) %4 ; + panel_rot =ilog2 (*rotation &DRM_MODE_ROTATE_MASK ); + cmdline_rot =ilog2 (cmdline->rotation_reflection &DRM_MODE_ROTATE_MASK ); + sum_rot = (panel_rot + cmdline_rot) %4 ; - panel_rest = *rotation & ~DRM_MODE_ROTATE_MASK ; - cmdline_rest = cmdline->rotation_reflection & ~DRM_MODE_ROTATE_MASK ; - sum_rest = panel_rest ^ cmdline_rest; + panel_rest = *rotation & ~DRM_MODE_ROTATE_MASK ; + cmdline_rest = cmdline->rotation_reflection & ~DRM_MODE_ROTATE_MASK ; + sum_rest = panel_rest ^ cmdline_rest; - *rotation = (1 << sum_rot) | sum_rest; + *rotation = (1 << sum_rot) | sum_rest; + }else { + *rotation ^= cmdline->rotation_reflection; + } }/*
@@ -879,7 +883,8 @@ bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation)* depending on the hardware this may require the framebuffer * to be in a specific tiling format. */ -if ((*rotation &DRM_MODE_ROTATE_MASK ) !=DRM_MODE_ROTATE_180 || +if (((*rotation &DRM_MODE_ROTATE_MASK ) !=DRM_MODE_ROTATE_0 && + (*rotation &DRM_MODE_ROTATE_MASK ) !=DRM_MODE_ROTATE_180 ) || !plane->rotation_property)return false;
Signature · 6 lines
2.24.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maxime Ripard
maintainerHi,
Quoted 33 lines · Stephan Gerhold
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the
panel_orientationwithcmdline->rotation_reflectiondoes not handle the case whencmdline->rotation_reflectiondoes not have any rotation set.
(i.e.cmdline->rotation_reflection&DRM_MODE_ROTATE_MASK== 0)Example:
*rotation =DRM_MODE_ROTATE_0(nopanel_orientation)cmdline->rotation_reflection=DRM_MODE_REFLECT_X(video=MODE,reflect_x)The current code does:
panel_rot=ilog2(*rotation & DRM_MODE_ROTATE_MASK);cmdline_rot=ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);sum_rot= (panel_rot+cmdline_rot) % 4;and therefore:
panel_rot=ilog2(DRM_MODE_ROTATE_0)= ilog2(1) = 0cmdline_rot= ilog2(0) = -1
sum_rot= (0 + -1) % 4 = -1 % 4 = 3
...
*rotation =DRM_MODE_ROTATE_270|DRM_MODE_REFLECT_XSo we incorrectly generate
DRM_MODE_ROTATE_270in this case. To preventcmdline_rotfrom becoming -1, we need to treat the rotation asDRM_MODE_ROTATE_0.On the other hand, there is no need to go through that calculation at all if no rotation is set in
rotation_reflection.
A simple XOR is enough to combine the reflections.
Quoted 7 lines
Finally, also allow
DRM_MODE_ROTATE_0in the if statement below.DRM_MODE_ROTATE_0means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).This makes video parameters with only reflect option work correctly.
Signed-off-by Stephan Gerhold <[email protected]>
Thanks for that commit message.
Can you also add a selftest to make sure we don't get a regression in the future?
Thanks!
Maxime
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 40 lines · Maxime Ripard
Hi,
Quoted 37 lines · Stephan Gerhold
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the
panel_orientationwithcmdline->rotation_reflectiondoes not handle the case whencmdline->rotation_reflectiondoes not have any rotation set.
(i.e.cmdline->rotation_reflection&DRM_MODE_ROTATE_MASK== 0)Example:
*rotation =DRM_MODE_ROTATE_0(nopanel_orientation)cmdline->rotation_reflection=DRM_MODE_REFLECT_X(video=MODE,reflect_x)The current code does:
panel_rot=ilog2(*rotation & DRM_MODE_ROTATE_MASK);cmdline_rot=ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);sum_rot= (panel_rot+cmdline_rot) % 4;and therefore:
panel_rot=ilog2(DRM_MODE_ROTATE_0)= ilog2(1) = 0cmdline_rot= ilog2(0) = -1
sum_rot= (0 + -1) % 4 = -1 % 4 = 3
...
*rotation =DRM_MODE_ROTATE_270|DRM_MODE_REFLECT_XSo we incorrectly generate
DRM_MODE_ROTATE_270in this case. To preventcmdline_rotfrom becoming -1, we need to treat the rotation asDRM_MODE_ROTATE_0.On the other hand, there is no need to go through that calculation at all if no rotation is set in
rotation_reflection.
A simple XOR is enough to combine the reflections.Finally, also allow
DRM_MODE_ROTATE_0in the if statement below.DRM_MODE_ROTATE_0means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).
Quoted 8 lines
Quoted 3 lines
This makes video parameters with only reflect option work correctly.
Signed-off-by Stephan Gerhold <[email protected]>Thanks for that commit message.
Can you also add a selftest to make sure we don't get a regression in the future?
Can you explain how/where I would add a test for drm_client_rotation() in drm_client_modeset.c? I'm not familiar with selftests to be honest.
I found test-drm_cmdline_parser.c but that seems to cover only the cmdline parsing (which is working correctly already).
Thanks,
Stephan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maxime Ripard
maintainerHi Stephan,
Quoted 47 lines · Stephan Gerhold
Quoted 46 lines · Maxime Ripard
Hi,
Quoted 33 lines · Stephan Gerhold
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the
panel_orientationwithcmdline->rotation_reflectiondoes not handle the case whencmdline->rotation_reflectiondoes not have any rotation set.
(i.e.cmdline->rotation_reflection&DRM_MODE_ROTATE_MASK== 0)Example:
*rotation =DRM_MODE_ROTATE_0(nopanel_orientation)cmdline->rotation_reflection=DRM_MODE_REFLECT_X(video=MODE,reflect_x)The current code does:
panel_rot=ilog2(*rotation & DRM_MODE_ROTATE_MASK);cmdline_rot=ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);sum_rot= (panel_rot+cmdline_rot) % 4;and therefore:
panel_rot=ilog2(DRM_MODE_ROTATE_0)= ilog2(1) = 0cmdline_rot= ilog2(0) = -1
sum_rot= (0 + -1) % 4 = -1 % 4 = 3
...
*rotation =DRM_MODE_ROTATE_270|DRM_MODE_REFLECT_XSo we incorrectly generate
DRM_MODE_ROTATE_270in this case. To preventcmdline_rotfrom becoming -1, we need to treat the rotation asDRM_MODE_ROTATE_0.On the other hand, there is no need to go through that calculation at all if no rotation is set in
rotation_reflection.
A simple XOR is enough to combine the reflections.Quoted 7 lines
Finally, also allow
DRM_MODE_ROTATE_0in the if statement below.DRM_MODE_ROTATE_0means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).This makes video parameters with only reflect option work correctly.
Signed-off-by Stephan Gerhold <[email protected]>Thanks for that commit message.
Quoted 8 lines
Quoted 2 lines
Can you also add a selftest to make sure we don't get a regression in the future?
Can you explain how/where I would add a test for
drm_client_rotation()indrm_client_modeset.c? I'm not familiar with selftests to be honest.I found
test-drm_cmdline_parser.cbut that seems to cover only the cmdline parsing (which is working correctly already).
The cmdline here is the kernel command line. You were mentionning in your commit log that video=540x960,reflect_x was broken?
But yeah, I meant this one.
Maxime
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 53 lines · Maxime Ripard
Hi Stephan,
Quoted 50 lines · Stephan Gerhold
Quoted 48 lines · Maxime Ripard
Hi,
Quoted 33 lines · Stephan Gerhold
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the
panel_orientationwithcmdline->rotation_reflectiondoes not handle the case whencmdline->rotation_reflectiondoes not have any rotation set.
(i.e.cmdline->rotation_reflection&DRM_MODE_ROTATE_MASK== 0)Example:
*rotation =DRM_MODE_ROTATE_0(nopanel_orientation)cmdline->rotation_reflection=DRM_MODE_REFLECT_X(video=MODE,reflect_x)The current code does:
panel_rot=ilog2(*rotation & DRM_MODE_ROTATE_MASK);cmdline_rot=ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);sum_rot= (panel_rot+cmdline_rot) % 4;and therefore:
panel_rot=ilog2(DRM_MODE_ROTATE_0)= ilog2(1) = 0cmdline_rot= ilog2(0) = -1
sum_rot= (0 + -1) % 4 = -1 % 4 = 3
...
*rotation =DRM_MODE_ROTATE_270|DRM_MODE_REFLECT_XSo we incorrectly generate
DRM_MODE_ROTATE_270in this case. To preventcmdline_rotfrom becoming -1, we need to treat the rotation asDRM_MODE_ROTATE_0.On the other hand, there is no need to go through that calculation at all if no rotation is set in
rotation_reflection.
A simple XOR is enough to combine the reflections.Quoted 7 lines
Finally, also allow
DRM_MODE_ROTATE_0in the if statement below.DRM_MODE_ROTATE_0means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).This makes video parameters with only reflect option work correctly.
Signed-off-by Stephan Gerhold <[email protected]>Thanks for that commit message.
Can you also add a selftest to make sure we don't get a regression in the future?
Quoted 9 lines
Quoted 5 lines
Can you explain how/where I would add a test for
drm_client_rotation()indrm_client_modeset.c? I'm not familiar with selftests to be honest.I found
test-drm_cmdline_parser.cbut that seems to cover only the cmdline parsing (which is working correctly already).The cmdline here is the kernel command line. You were mentionning in your commit log that video=540x960,reflect_x was broken?
The parameter is parsed correctly and placed into connector->cmdline_mode. Therefore, not the *parsing* is broken, only the way we try to apply and merge them with the panel orientation in drm_client_modeset.c.
There are existing test cases for the parsing of parameters similar to video=540x960,reflect_x, see drm_cmdline_test_hmirror()
in the aforementioned test file.
Maybe my commit message was not as clear as I hoped :)
Thanks,
Stephan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maxime Ripard
maintainerHi Stephan,
Quoted 66 lines · Stephan Gerhold
Quoted 51 lines · Maxime Ripard
Quoted 50 lines · Stephan Gerhold
Quoted 48 lines · Maxime Ripard
Hi,
Quoted 33 lines · Stephan Gerhold
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the
panel_orientationwithcmdline->rotation_reflectiondoes not handle the case whencmdline->rotation_reflectiondoes not have any rotation set.
(i.e.cmdline->rotation_reflection&DRM_MODE_ROTATE_MASK== 0)Example:
*rotation =DRM_MODE_ROTATE_0(nopanel_orientation)cmdline->rotation_reflection=DRM_MODE_REFLECT_X(video=MODE,reflect_x)The current code does:
panel_rot=ilog2(*rotation & DRM_MODE_ROTATE_MASK);cmdline_rot=ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);sum_rot= (panel_rot+cmdline_rot) % 4;and therefore:
panel_rot=ilog2(DRM_MODE_ROTATE_0)= ilog2(1) = 0cmdline_rot= ilog2(0) = -1
sum_rot= (0 + -1) % 4 = -1 % 4 = 3
...
*rotation =DRM_MODE_ROTATE_270|DRM_MODE_REFLECT_XSo we incorrectly generate
DRM_MODE_ROTATE_270in this case. To preventcmdline_rotfrom becoming -1, we need to treat the rotation asDRM_MODE_ROTATE_0.On the other hand, there is no need to go through that calculation at all if no rotation is set in
rotation_reflection.
A simple XOR is enough to combine the reflections.Quoted 7 lines
Finally, also allow
DRM_MODE_ROTATE_0in the if statement below.DRM_MODE_ROTATE_0means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).This makes video parameters with only reflect option work correctly.
Signed-off-by Stephan Gerhold <[email protected]>Thanks for that commit message.
Can you also add a selftest to make sure we don't get a regression in the future?
Quoted 9 lines
Quoted 5 lines
Can you explain how/where I would add a test for
drm_client_rotation()indrm_client_modeset.c? I'm not familiar with selftests to be honest.I found
test-drm_cmdline_parser.cbut that seems to cover only the cmdline parsing (which is working correctly already).The cmdline here is the kernel command line. You were mentionning in your commit log that video=540x960,reflect_x was broken?
The parameter is parsed correctly and placed into
connector->cmdline_mode. Therefore, not the *parsing* is broken, only the way we try to apply and merge them with the panel orientation indrm_client_modeset.c.
Quoted 5 lines
There are existing test cases for the parsing of parameters similar to video=540x960,reflect_x, see
drm_cmdline_test_hmirror()
in the aforementioned test file.Maybe my commit message was not as clear as I hoped :)
Ah, I see what you meant by "silently ignored" now :)
Yeah, maybe we can change that by "not taken into account when applying the mode" or something like that?
Maxime
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 73 lines · Maxime Ripard
Hi Stephan,
Quoted 70 lines · Stephan Gerhold
Quoted 51 lines · Maxime Ripard
Quoted 50 lines · Stephan Gerhold
Quoted 48 lines · Maxime Ripard
Hi,
Quoted 33 lines · Stephan Gerhold
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the
panel_orientationwithcmdline->rotation_reflectiondoes not handle the case whencmdline->rotation_reflectiondoes not have any rotation set.
(i.e.cmdline->rotation_reflection&DRM_MODE_ROTATE_MASK== 0)Example:
*rotation =DRM_MODE_ROTATE_0(nopanel_orientation)cmdline->rotation_reflection=DRM_MODE_REFLECT_X(video=MODE,reflect_x)The current code does:
panel_rot=ilog2(*rotation & DRM_MODE_ROTATE_MASK);cmdline_rot=ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);sum_rot= (panel_rot+cmdline_rot) % 4;and therefore:
panel_rot=ilog2(DRM_MODE_ROTATE_0)= ilog2(1) = 0cmdline_rot= ilog2(0) = -1
sum_rot= (0 + -1) % 4 = -1 % 4 = 3
...
*rotation =DRM_MODE_ROTATE_270|DRM_MODE_REFLECT_XSo we incorrectly generate
DRM_MODE_ROTATE_270in this case. To preventcmdline_rotfrom becoming -1, we need to treat the rotation asDRM_MODE_ROTATE_0.On the other hand, there is no need to go through that calculation at all if no rotation is set in
rotation_reflection.
A simple XOR is enough to combine the reflections.Quoted 7 lines
Finally, also allow
DRM_MODE_ROTATE_0in the if statement below.DRM_MODE_ROTATE_0means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).This makes video parameters with only reflect option work correctly.
Signed-off-by Stephan Gerhold <[email protected]>Thanks for that commit message.
Can you also add a selftest to make sure we don't get a regression in the future?
Quoted 9 lines
Quoted 5 lines
Can you explain how/where I would add a test for
drm_client_rotation()indrm_client_modeset.c? I'm not familiar with selftests to be honest.I found
test-drm_cmdline_parser.cbut that seems to cover only the cmdline parsing (which is working correctly already).The cmdline here is the kernel command line. You were mentionning in your commit log that video=540x960,reflect_x was broken?
The parameter is parsed correctly and placed into
connector->cmdline_mode. Therefore, not the *parsing* is broken, only the way we try to apply and merge them with the panel orientation indrm_client_modeset.c.There are existing test cases for the parsing of parameters similar to video=540x960,reflect_x, see
drm_cmdline_test_hmirror()
in the aforementioned test file.
Quoted 6 lines
Quoted 1 line
Maybe my commit message was not as clear as I hoped :)
Ah, I see what you meant by "silently ignored" now :)
Yeah, maybe we can change that by "not taken into account when applying the mode" or something like that?
Sure, I will try to clarify it for v2.
Anything else I should change?
Thanks,
Stephan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maxime Ripard
maintainerQuoted 76 lines · Stephan Gerhold
Quoted 75 lines · Maxime Ripard
Hi Stephan,
Quoted 71 lines · Stephan Gerhold
Quoted 51 lines · Maxime Ripard
Quoted 50 lines · Stephan Gerhold
Quoted 48 lines · Maxime Ripard
Hi,
Quoted 33 lines · Stephan Gerhold
At the moment, video mode parameters like video=540x960,reflect_x, (without rotation set) are silently ignored.
One of the reasons for this is that the calculation that combines the
panel_orientationwithcmdline->rotation_reflectiondoes not handle the case whencmdline->rotation_reflectiondoes not have any rotation set.
(i.e.cmdline->rotation_reflection&DRM_MODE_ROTATE_MASK== 0)Example:
*rotation =DRM_MODE_ROTATE_0(nopanel_orientation)cmdline->rotation_reflection=DRM_MODE_REFLECT_X(video=MODE,reflect_x)The current code does:
panel_rot=ilog2(*rotation & DRM_MODE_ROTATE_MASK);cmdline_rot=ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);sum_rot= (panel_rot+cmdline_rot) % 4;and therefore:
panel_rot=ilog2(DRM_MODE_ROTATE_0)= ilog2(1) = 0cmdline_rot= ilog2(0) = -1
sum_rot= (0 + -1) % 4 = -1 % 4 = 3
...
*rotation =DRM_MODE_ROTATE_270|DRM_MODE_REFLECT_XSo we incorrectly generate
DRM_MODE_ROTATE_270in this case. To preventcmdline_rotfrom becoming -1, we need to treat the rotation asDRM_MODE_ROTATE_0.On the other hand, there is no need to go through that calculation at all if no rotation is set in
rotation_reflection.
A simple XOR is enough to combine the reflections.Quoted 7 lines
Finally, also allow
DRM_MODE_ROTATE_0in the if statement below.DRM_MODE_ROTATE_0means "no rotation" and should therefore not require any special handling (e.g. specific tiling format).This makes video parameters with only reflect option work correctly.
Signed-off-by Stephan Gerhold <[email protected]>Thanks for that commit message.
Can you also add a selftest to make sure we don't get a regression in the future?
Quoted 9 lines
Quoted 5 lines
Can you explain how/where I would add a test for
drm_client_rotation()indrm_client_modeset.c? I'm not familiar with selftests to be honest.I found
test-drm_cmdline_parser.cbut that seems to cover only the cmdline parsing (which is working correctly already).The cmdline here is the kernel command line. You were mentionning in your commit log that video=540x960,reflect_x was broken?
The parameter is parsed correctly and placed into
connector->cmdline_mode. Therefore, not the *parsing* is broken, only the way we try to apply and merge them with the panel orientation indrm_client_modeset.c.There are existing test cases for the parsing of parameters similar to video=540x960,reflect_x, see
drm_cmdline_test_hmirror()
in the aforementioned test file.Maybe my commit message was not as clear as I hoped :)
Quoted 8 lines
Quoted 4 lines
Ah, I see what you meant by "silently ignored" now :)
Yeah, maybe we can change that by "not taken into account when applying the mode" or something like that?
Sure, I will try to clarify it for v2.
Anything else I should change?
The rest looks fine to me.
Thanks!
Maxime
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel