drm/connector: Provide generic support for underscan
Subsystems (4)
v2 cover drm/connector: Provide generic support for underscan
Hello,
This is an attempt at providing generic support for underscan connector props. We already have 3 drivers defining the same underscan, underscan vborder and underscan hborder properties (amd, radeon and nouveau) and I am about to add a new one, hence my proposal to put the prop parsing code in the core and add ->underscan fields to drm_connector_state.
In this v2, I also converted the nouveau driver to the generic approach. The amdgpu and radeon ones can't be converted since they're still not converted to the atomic interface.
Regards,
Boris
Boris Brezillon (4):
drm/connector: Add generic underscan properties drm/vc4: Take underscan setup into account when updating planes drm/vc4: Attach underscan props to the HDMI connector drm/nouveau: Switch to the generic underscan props
drivers/gpu/drm/drm_atomic.c | 12 +++ drivers/gpu/drm/drm_connector.c | 127 ++++++++++++++++++++++++++++ drivers/gpu/drm/nouveau/nouveau_connector.c | 39 ++------- drivers/gpu/drm/nouveau/nouveau_connector.h | 9 -- drivers/gpu/drm/nouveau/nouveau_display.c | 14 --- drivers/gpu/drm/nouveau/nouveau_display.h | 3 - drivers/gpu/drm/nouveau/nv50_display.c | 17 ++-- drivers/gpu/drm/vc4/vc4_hdmi.c | 25 ++++++ drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++- include/drm/drm_connector.h | 80 ++++++++++++++++++ 10 files changed, 310 insertions(+), 65 deletions(-)
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20180511145919.22447-1-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org
PATCH v2 1/4 drm/connector: Add generic underscan properties
We have 3 drivers defining the "underscan", "underscan hborder" and "underscan vborder" properties (radeon, amd and nouveau) and we are about to add the same kind of thing in VC4.
Define generic underscan props and add new fields to the drm_connector state so that the property parsing logic can be shared by all DRM drivers.
A driver can now attach underscan properties to its connector through the drm_connector_attach_underscan_properties() helper, and can check/apply the underscan setup based on the drm_connector_state->underscan fields.
---
Changes in v2:
- Add a new section in the connector props doc to describe underscan props
- Fix description of auto mode (auto means apply underscan for HDMI monitors only)
- Fix description of vborder/hborder:
right_border = left_border = hborder
top_border = bottom_border = vborder
not
right_border = left_border = hborder / 2
top_border = bottom_border = vborder / 2
- Rename drm_underscan into drm_underscan_state
--- drivers/gpu/drm/drm_atomic.c | 12 ++++ drivers/gpu/drm/drm_connector.c | 127 ++++++++++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 80 +++++++++++++++++++++++++ 3 files changed, 219 insertions(+)
drivers/gpu/drm/drm_atomic.c +12 -0
@@ -1278,6 +1278,12 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,return -EINVAL ; } state->content_protection = val; + }else if (property == connector->underscan_mode_property) { + state->underscan.mode = val; + }else if (property == connector->underscan_hborder_property) { + state->underscan.hborder = val; + }else if (property == connector->underscan_vborder_property) { + state->underscan.vborder = val; }else if (connector->funcs->atomic_set_property) {return connector->funcs->atomic_set_property (connector, state, property, val);
@@ -1359,6 +1365,12 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->scaling_mode; }else if (property == connector->content_protection_property) { *val = state->content_protection; + }else if (property == connector->underscan_mode_property) { + *val = state->underscan.mode; + }else if (property == connector->underscan_hborder_property) { + *val = state->underscan.hborder; + }else if (property == connector->underscan_vborder_property) { + *val = state->underscan.vborder; }else if (connector->funcs->atomic_get_property) {return connector->funcs->atomic_get_property (connector, state, property, val);
drivers/gpu/drm/drm_connector.c +127 -0
139 lines not on this page · raw message
include/drm/drm_connector.h +80 -0
104 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 2/4 drm/vc4: Take underscan setup into account when updating planes
In reply to a message not in the archiveApplying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an vc4_plane_underscan_adj() function doing that and call it from vc4_plane_setup_clipping_and_scaling() so that we are ready to attach underscan properties to the HDMI connector.
---
Changes in v2:
- Take changes on hborder/vborder meaning into account
--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_plane.c +48 -1
@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; + + crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ; + + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay; + +if (!vc4_pstate->crtc_w || !vc4_pstate->crtc_h) +return -EINVAL ; + +return 0 ; +} +static int vc4_plane_setup_clipping_and_scaling (struct drm_plane_state *state) {struct drm_plane *plane = state->plane;
@@ -269,7 +312,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)int num_planes = fb->format->num_planes;u32 h_subsample =1 ;u32 v_subsample =1 ; -int i; +int i, ret;for (i =0 ; i < num_planes; i++) vc4_state->offsets[i] = bo->paddr + fb->offsets[i];
@@ -292,6 +335,10 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) vc4_state->crtc_w = state->crtc_w; vc4_state->crtc_h = state->crtc_h; + ret =vc4_plane_underscan_adj (state); +if (ret) +return ret; + vc4_state->x_scaling[0 ] =vc4_get_scaling_mode (vc4_state->src_w[0 ], vc4_state->crtc_w); vc4_state->y_scaling[0] = vc4_get_scaling_mode(vc4_state->src_h[0],
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180511145919.22447-3-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 39 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +15
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ;
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 10 lines
drivers/gpu/drm/vc4/vc4_plane.c +10
-0+ +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; + + crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;
border * 2 ?
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 11 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;
So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop. Maybe we just have to require the scaling mode to be set to fullscreen to allow borders to be specified explictly?
Quoted 37 lines
drivers/gpu/drm/vc4/vc4_plane.c +12
-1+ +if (!vc4_pstate->crtc_w || !vc4_pstate->crtc_h) +return -EINVAL ; + +return 0 ; +} +static int vc4_plane_setup_clipping_and_scaling (struct drm_plane_state *state) {struct drm_plane *plane = state->plane;@@ -269,7 +312,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)int num_planes = fb->format->num_planes;u32 h_subsample =1 ;u32 v_subsample =1 ; -int i; +int i, ret;for (i =0 ; i < num_planes; i++) vc4_state->offsets[i] = bo->paddr + fb->offsets[i];@@ -292,6 +335,10 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) vc4_state->crtc_w = state->crtc_w; vc4_state->crtc_h = state->crtc_h; + ret =vc4_plane_underscan_adj (state); +if (ret) +return ret; + vc4_state->x_scaling[0 ] =vc4_get_scaling_mode (vc4_state->src_w[0 ], vc4_state->crtc_w); vc4_state->y_scaling[0] = vc4_get_scaling_mode(vc4_state->src_h[0],Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +
Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
Quoted 4 lines
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop.
Nouveau seems to expose both, and I don't see why we couldn't.
Quoted 36 lines
Maybe we just have to require the scaling mode to be set to fullscreen to allow borders to be specified explictly?
Quoted 33 lines
drivers/gpu/drm/vc4/vc4_plane.c +12
-1+ +if (!vc4_pstate->crtc_w || !vc4_pstate->crtc_h) +return -EINVAL ; + +return 0 ; +} +static int vc4_plane_setup_clipping_and_scaling (struct drm_plane_state *state) {struct drm_plane *plane = state->plane;@@ -269,7 +312,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)int num_planes = fb->format->num_planes;u32 h_subsample =1 ;u32 v_subsample =1 ; -int i; +int i, ret;for (i =0 ; i < num_planes; i++) vc4_state->offsets[i] = bo->paddr + fb->offsets[i];@@ -292,6 +335,10 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) vc4_state->crtc_w = state->crtc_w; vc4_state->crtc_h = state->crtc_h; + ret =vc4_plane_underscan_adj (state); +if (ret) +return ret; + vc4_state->x_scaling[0 ] =vc4_get_scaling_mode (vc4_state->src_w[0 ], vc4_state->crtc_w); vc4_state->y_scaling[0] = vc4_get_scaling_mode(vc4_state->src_h[0],Signature · 1 line
2.14.1
Quoted 5 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 75 lines · Boris Brezillon
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
Quoted 3 lines
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
I don't think you can just not scale it. The user asked for the cursor to be at a specific place with a specific size. Can't just ignore that and do something else. Also eg. i915 would definitely scale the cursor since we'd just scale the entire crtc instead of scaling individual planes. Different drivers doing different things wouldn't be good.
Quoted 7 lines
Quoted 5 lines
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop.
Nouveau seems to expose both, and I don't see why we couldn't.
First of all the interaction of these borders with panels that have a fixed mode would need to be properly specified. Do we apply the borders against the user mode or the panel's native mode? I guess the latter would be a bit easier (would also match how the TV margins behave I suppose). But that does leave open the question of how would generic userspace know which case it's dealing with? Eg. if it wants to underscan by some specific percentage it has to calculate the borders based on the correct mode, otherwise the results aren't going to match the expectations.
Quoted 42 lines
Quoted 42 lines
Maybe we just have to require the scaling mode to be set to fullscreen to allow borders to be specified explictly?
Quoted 37 lines
drivers/gpu/drm/vc4/vc4_plane.c +12
-1+ +if (!vc4_pstate->crtc_w || !vc4_pstate->crtc_h) +return -EINVAL ; + +return 0 ; +} +static int vc4_plane_setup_clipping_and_scaling (struct drm_plane_state *state) {struct drm_plane *plane = state->plane;@@ -269,7 +312,7 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)int num_planes = fb->format->num_planes;u32 h_subsample =1 ;u32 v_subsample =1 ; -int i; +int i, ret;for (i =0 ; i < num_planes; i++) vc4_state->offsets[i] = bo->paddr + fb->offsets[i];@@ -292,6 +335,10 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) vc4_state->crtc_w = state->crtc_w; vc4_state->crtc_h = state->crtc_h; + ret =vc4_plane_underscan_adj (state); +if (ret) +return ret; + vc4_state->x_scaling[0 ] =vc4_get_scaling_mode (vc4_state->src_w[0 ], vc4_state->crtc_w); vc4_state->y_scaling[0] = vc4_get_scaling_mode(vc4_state->src_h[0],Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 80 lines · On Fri, 11 May 2018 19:54:02 +0300 Ville Syrjälä…
Quoted 75 lines · Boris Brezillon
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
Quoted 3 lines
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
Quoted 6 lines
I don't think you can just not scale it. The user asked for the cursor to be at a specific place with a specific size. Can't just ignore that and do something else. Also eg. i915 would definitely scale the cursor since we'd just scale the entire crtc instead of scaling individual planes. Different drivers doing different things wouldn't be good.
Except in our case the scaling takes place before the composition, so we don't have a choice.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop.
Quoted 5 lines
Quoted 1 line
Nouveau seems to expose both, and I don't see why we couldn't.
First of all the interaction of these borders with panels that have a fixed mode would need to be properly specified. Do we apply the borders against the user mode or the panel's native mode?
Hm, I'm a bit lost. Isn't crtc_state->mode supposed to contain the mode that is about to be applied, no matter if it's a usermode or one of the mode returned by the display?
Quoted 7 lines
I guess
the latter would be a bit easier (would also match how the TV margins behave I suppose). But that does leave open the question of how would generic userspace know which case it's dealing with? Eg. if it wants to underscan by some specific percentage it has to calculate the borders based on the correct mode, otherwise the results aren't going to match the expectations.
I don't get it, sorry. Borders are relative to the mode applied by userspace. So if it needs to express borders as a ratio of the resolution, then for sure userspace will have to do the math, but I don't see the problem here.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 90 lines · Boris Brezillon
Quoted 80 lines · On Fri, 11 May 2018 19:54:02 +0300 Ville Syrjälä…
Quoted 75 lines · Boris Brezillon
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
Quoted 3 lines
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
Quoted 6 lines
I don't think you can just not scale it. The user asked for the cursor to be at a specific place with a specific size. Can't just ignore that and do something else. Also eg. i915 would definitely scale the cursor since we'd just scale the entire crtc instead of scaling individual planes. Different drivers doing different things wouldn't be good.
Quoted 2 lines
Except in our case the scaling takes place before the composition, so we don't have a choice.
The choice is to either do what userspace asked, or return an error.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop.
Nouveau seems to expose both, and I don't see why we couldn't.
Quoted 7 lines
Quoted 3 lines
First of all the interaction of these borders with panels that have a fixed mode would need to be properly specified. Do we apply the borders against the user mode or the panel's native mode?
Hm, I'm a bit lost. Isn't
crtc_state->modesupposed to contain the mode that is about to be applied, no matter if it's a usermode or one of the mode returned by the display?
No. With fixed mode panels the user mode is a lie. Only hdisplay/vdisplay mean anything. The actual timings are known only to the kernel. Well, userspace can perhaps make an educated guess based on the connector's mode list and the presence of the scaling mode property.
Quoted 13 lines
Quoted 8 lines
I guess
the latter would be a bit easier (would also match how the TV margins behave I suppose). But that does leave open the question of how would generic userspace know which case it's dealing with? Eg. if it wants to underscan by some specific percentage it has to calculate the borders based on the correct mode, otherwise the results aren't going to match the expectations.I don't get it, sorry. Borders are relative to the mode applied by userspace. So if it needs to express borders as a ratio of the resolution, then for sure userspace will have to do the math, but I don't see the problem here.
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 91 lines · On Fri, 11 May 2018 20:29:48 +0300 Ville Syrjälä…
Quoted 90 lines · Boris Brezillon
Quoted 86 lines · On Fri, 11 May 2018 19:54:02 +0300 Ville Syrjälä…
Quoted 75 lines · Boris Brezillon
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
Quoted 3 lines
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
I don't think you can just not scale it. The user asked for the cursor to be at a specific place with a specific size. Can't just ignore that and do something else. Also eg. i915 would definitely scale the cursor since we'd just scale the entire crtc instead of scaling individual planes. Different drivers doing different things wouldn't be good.
Quoted 4 lines
Quoted 2 lines
Except in our case the scaling takes place before the composition, so we don't have a choice.
The choice is to either do what userspace asked, or return an error.
Come on! If we can't use underscan when there's a cursor plane enabled this feature is pretty much useless. But let's take a real use case to show you how negligible the lack of scaling on the cursor plane will be. Say you have borders taking 10% of you screen (which is already a lot), and your cursor is a plane of 64x64 pixels, you'll end up with a 64x64 cursor instead of 58x58. Quite frankly, I doubt you'll notice the difference.
Anyway, I'd like to hear back from Eric on that, since he is the one who asked me to work on this feature.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
Quoted 8 lines
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop.
Nouveau seems to expose both, and I don't see why we couldn't.
First of all the interaction of these borders with panels that have a fixed mode would need to be properly specified. Do we apply the borders against the user mode or the panel's native mode?
Quoted 7 lines
Quoted 3 lines
Hm, I'm a bit lost. Isn't
crtc_state->modesupposed to contain the mode that is about to be applied, no matter if it's a usermode or one of the mode returned by the display?No. With fixed mode panels the user mode is a lie. Only hdisplay/vdisplay mean anything. The actual timings are known only to the kernel.
So now you say that the driver can silently ignore what the userspace asked for and set what he thinks is appropriate based on what the HW supports. This clearly contradicts the statement you make a few lines
above: driver should apply what userspace asked for or return an error when it's not possible.
Quoted 2 lines
Well, userspace can perhaps make an educated guess based on the connector's mode list and the presence of the scaling mode property.
But guess what? Where is the actual 'HW' mode stored if it's not in crtc_state->mode? I mean, the drivers needs to know what to apply, and almost all drivers are using atomic states to extract this information.
On a side note, I'd like to repeat what I already said before: I don't care how this "define borders" feature is exposed to userspace, as long as we have a way to express that the display we're using has borders and the output image should be scaled+moved accordingly.
So now it's time to reach a consensus, because I'm not going to try and guess what you expect. When I asked Daniel earlier this week whether he wanted me to do things differently than I did in my v1 or try to match what other drivers were already doing with the underscan prop, he told me we should try to converge to a generic underscan solution that keeps the existing userspace interface unchanged (basically what radeon, amdgpu and nouveau drivers expose today). You don't seem to agree with that. So now I'd like a clear answer, what should I do?
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 99 lines · Boris Brezillon
Quoted 91 lines · On Fri, 11 May 2018 20:29:48 +0300 Ville Syrjälä…
Quoted 90 lines · Boris Brezillon
Quoted 86 lines · On Fri, 11 May 2018 19:54:02 +0300 Ville Syrjälä…
Quoted 75 lines · Boris Brezillon
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
Quoted 3 lines
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
I don't think you can just not scale it. The user asked for the cursor to be at a specific place with a specific size. Can't just ignore that and do something else. Also eg. i915 would definitely scale the cursor since we'd just scale the entire crtc instead of scaling individual planes. Different drivers doing different things wouldn't be good.
Quoted 4 lines
Quoted 2 lines
Except in our case the scaling takes place before the composition, so we don't have a choice.
The choice is to either do what userspace asked, or return an error.
Quoted 7 lines
Come on! If we can't use underscan when there's a cursor plane enabled this feature is pretty much useless. But let's take a real use case to show you how negligible the lack of scaling on the cursor plane will be. Say you have borders taking 10% of you screen (which is already a lot), and your cursor is a plane of 64x64 pixels, you'll end up with a 64x64 cursor instead of 58x58. Quite frankly, I doubt you'll notice the difference.
Now you're assuming the cursor is only ever used as a cursor. It can be used for other things and those may need to be positioned pixel perfect in relation to other planes/fb contents.
We used to play is fast and loose in i915 when it came to the sprite plane coordinates. People generally hated that, at least when it came to the atomic ioctl. Basically we just adjusted the src/dst coordinates until the hw was happy with them, partially ignoring what the user had asked. Maarten recently nuked that code, and so now we either respect the user's choice or we return an error.
I guess one way out of this conundrum would be to allow the cursor to violate the user's requested parameters when controlled via the legacy cursor ioctls. There are no atomicity guarantees there, so I guess we could also say there are no other correctness guarantees either. Not sure if the accuracy of the hotspot might become an issue though.
Another option might be to just scale the cursor as well. If I understand correctly the "cursor can't be scaled" limitation just comes from the fact that some vblank synced resource needs to be reconfigured whenever the scaling changes. So doing that for unthrottled cursor updates is not easy. But in this case the underscan properties are what determines the scaling so maybe that resource could be reconfigured whenever the those props change to make sure the cursor can always be scaled appropriately?
Quoted 27 lines
Anyway, I'd like to hear back from Eric on that, since he is the one who asked me to work on this feature.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
Quoted 8 lines
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop.
Nouveau seems to expose both, and I don't see why we couldn't.
First of all the interaction of these borders with panels that have a fixed mode would need to be properly specified. Do we apply the borders against the user mode or the panel's native mode?
Quoted 7 lines
Quoted 3 lines
Hm, I'm a bit lost. Isn't
crtc_state->modesupposed to contain the mode that is about to be applied, no matter if it's a usermode or one of the mode returned by the display?No. With fixed mode panels the user mode is a lie. Only hdisplay/vdisplay mean anything. The actual timings are known only to the kernel.
Quoted 5 lines
So now you say that the driver can silently ignore what the userspace asked for and set what he thinks is appropriate based on what the HW supports. This clearly contradicts the statement you make a few lines
above: driver should apply what userspace asked for or return an error when it's not possible.
It's an unfortunate legacy uapi design we have to live with. I agree that it would be much better if userspace had more explicit control over the crtc scaling/borders/etc.
Quoted 7 lines
Quoted 3 lines
Well, userspace can perhaps make an educated guess based on the connector's mode list and the presence of the scaling mode property.
But guess what? Where is the actual 'HW' mode stored if it's not in
crtc_state->mode? I mean, the drivers needs to know what to apply, and almost all drivers are using atomic states to extract this information.
adjusted_mode is there for the driver to do as they wish. Eg. in i915 LVDS/eDP/DSI/etc. encoders will overwrite the adjusted_mode with the panel's native mode at the appropriate time (for other encoder types we just populate adjusted_mode with the user mode).
For the user it will still *look* like the mode they asked for (ie. hdisplay/vdisplay determine how many visible pixels there are), but internally we've replaced the timings with something different and there may or may not scaling involved (depend on the scaling mode property).
Quoted 6 lines
On a side note, I'd like to repeat what I already said before: I don't care how this "define borders" feature is exposed to userspace, as long as we have a way to express that the display we're using has borders and the output image should be scaled+moved accordingly.
Quoted 8 lines
So now it's time to reach a consensus, because I'm not going to try and guess what you expect. When I asked Daniel earlier this week whether he wanted me to do things differently than I did in my v1 or try to match what other drivers were already doing with the underscan prop, he told me we should try to converge to a generic underscan solution that keeps the existing userspace interface unchanged (basically what radeon, amdgpu and nouveau drivers expose today). You don't seem to agree with that. So now I'd like a clear answer, what should I do?
What do those drivers do when it comes to planes? I would expect that they just scale the entire crtc instead of individual planes.
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
Quoted 126 lines · Ville Syrjälä
Quoted 99 lines · Boris Brezillon
Quoted 91 lines · On Fri, 11 May 2018 20:29:48 +0300 Ville Syrjälä…
Quoted 90 lines · Boris Brezillon
Quoted 86 lines · On Fri, 11 May 2018 19:54:02 +0300 Ville Syrjälä…
Quoted 75 lines · Boris Brezillon
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
Quoted 3 lines
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
I don't think you can just not scale it. The user asked for the cursor to be at a specific place with a specific size. Can't just ignore that and do something else. Also eg. i915 would definitely scale the cursor since we'd just scale the entire crtc instead of scaling individual planes. Different drivers doing different things wouldn't be good.
Quoted 4 lines
Quoted 2 lines
Except in our case the scaling takes place before the composition, so we don't have a choice.
The choice is to either do what userspace asked, or return an error.
Quoted 7 lines
Come on! If we can't use underscan when there's a cursor plane enabled this feature is pretty much useless. But let's take a real use case to show you how negligible the lack of scaling on the cursor plane will be. Say you have borders taking 10% of you screen (which is already a lot), and your cursor is a plane of 64x64 pixels, you'll end up with a 64x64 cursor instead of 58x58. Quite frankly, I doubt you'll notice the difference.
Now you're assuming the cursor is only ever used as a cursor. It can be used for other things and those may need to be positioned pixel perfect in relation to other planes/fb contents.
We used to play is fast and loose in i915 when it came to the sprite plane coordinates. People generally hated that, at least when it came to the atomic ioctl. Basically we just adjusted the src/dst coordinates until the hw was happy with them, partially ignoring what the user had asked. Maarten recently nuked that code, and so now we either respect the user's choice or we return an error.
I guess one way out of this conundrum would be to allow the cursor to violate the user's requested parameters when controlled via the legacy cursor ioctls. There are no atomicity guarantees there, so I guess we could also say there are no other correctness guarantees either. Not sure if the accuracy of the hotspot might become an issue though.
Quoted 8 lines
Another option might be to just scale the cursor as well. If I understand correctly the "cursor can't be scaled" limitation just comes from the fact that some vblank synced resource needs to be reconfigured whenever the scaling changes. So doing that for unthrottled cursor updates is not easy. But in this case the underscan properties are what determines the scaling so maybe that resource could be reconfigured whenever the those props change to make sure the cursor can always be scaled appropriately?
Yeah, we had no application for it, so it wasn't supported. I don't think it would be hard to have a previously-scaled cursor move, it's just that we need to fall back to a synchronous plane update if the scaling parameters change.
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Re: [PATCH v2 2/4] drm/vc4: Take underscan setup into account when updating planes
In reply to a message not in the archiveQuoted 110 lines · Ville Syrjälä
Quoted 90 lines · Boris Brezillon
Quoted 80 lines · On Fri, 11 May 2018 19:54:02 +0300 Ville Syrjälä…
Quoted 75 lines · Boris Brezillon
Quoted 44 lines · On Fri, 11 May 2018 18:34:50 +0300 Ville Syrjälä…
Quoted 43 lines · Boris Brezillon
Applying an underscan setup is just a matter of scaling all planes appropriately and adjusting the CRTC X/Y offset to account for the horizontal and vertical border.
Create an
vc4_plane_underscan_adj()function doing that and call it fromvc4_plane_setup_clipping_and_scaling()so that we are ready to attach underscan properties to the HDMI connector.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v2:
- Take changes on hborder/vborder meaning into account--- drivers/gpu/drm/vc4/vc4_plane.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_plane.c +19
-0@@ -258,6 +258,49 @@ static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) } } +static int vc4_plane_underscan_adj (struct drm_plane_state *pstate) +{ +struct vc4_plane_state *vc4_pstate =to_vc4_plane_state (pstate); +struct drm_connector_state *conn_state =NULL ; +struct drm_connector *conn; +struct drm_crtc_state *crtc_state; +int i; + +for_each_new_connector_in_state (pstate->state, conn, conn_state, i) { +if (conn_state->crtc == pstate->crtc) +break ; + } + +if (i == pstate->state->num_connector) +return 0 ; + +if (conn_state->underscan.mode !=DRM_UNDERSCAN_ON ) +return 0 ; +Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 285
Quoted 6 lines
drivers/gpu/drm/vc4/vc4_plane.c +6
-0+ crtc_state =drm_atomic_get_new_crtc_state (pstate->state, + pstate->crtc); + +if (conn_state->underscan.hborder >= crtc_state->mode.hdisplay || + conn_state->underscan.vborder >= crtc_state->mode.vdisplay) +return -EINVAL ;border * 2 ?
Oops, indeed. I'll fix that.
Quoted 16 lines
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 296
Quoted 12 lines
drivers/gpu/drm/vc4/vc4_plane.c +11
-0+ + vc4_pstate->crtc_x += conn_state->underscan.hborder; + vc4_pstate->crtc_y += conn_state->underscan.vborder; + vc4_pstate->crtc_w = (vc4_pstate->crtc_w * + (crtc_state->mode.hdisplay - + (conn_state->underscan.hborder *2 ))) / + crtc_state->mode.hdisplay; + vc4_pstate->crtc_h = (vc4_pstate->crtc_h * + (crtc_state->mode.vdisplay - + (conn_state->underscan.vborder *2 ))) / + crtc_state->mode.vdisplay;So you're now scaling all planes? The code seems to reject scaling for the cursor plane, how are you dealing with that? Or just no cursor allowed when underscanning?
Quoted 3 lines
No, I just didn't test with a cursor plane. We should probably avoid scaling the cursor plane and just adjust its position. Eric any opinion on that?
Quoted 6 lines
I don't think you can just not scale it. The user asked for the cursor to be at a specific place with a specific size. Can't just ignore that and do something else. Also eg. i915 would definitely scale the cursor since we'd just scale the entire crtc instead of scaling individual planes. Different drivers doing different things wouldn't be good.
Quoted 2 lines
Except in our case the scaling takes place before the composition, so we don't have a choice.
The choice is to either do what userspace asked, or return an error.
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
Quoted 7 lines
I'm also wondering if there's any way we can reconcile these border props with the scaling mode prop, should we ever wish to expose these props on connectors that already have the scaling mode prop.
Nouveau seems to expose both, and I don't see why we couldn't.
First of all the interaction of these borders with panels that have a fixed mode would need to be properly specified. Do we apply the borders against the user mode or the panel's native mode?
Quoted 8 lines
Quoted 3 lines
Hm, I'm a bit lost. Isn't
crtc_state->modesupposed to contain the mode that is about to be applied, no matter if it's a usermode or one of the mode returned by the display?No. With fixed mode panels the user mode is a lie. Only hdisplay/vdisplay mean anything. The actual timings are known only to the kernel. Well, userspace can perhaps make an educated guess based on the connector's mode list and the presence of the scaling mode property.
Let's just not expose the property on devices with fixed mode panels. Problem solved because all this property is is a way to work around HDMI monitors doing something awful, and trying to build something more general isn't serving anyone.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 4/4 drm/nouveau: Switch to the generic underscan props
In reply to a message not in the archiveNow that underscan props can be parsed by the core and assigned to conn_state->underscan.xxx, we can rely on this implementation and get rid of the nouveau-specific underscan props.
--- drivers/gpu/drm/nouveau/nouveau_connector.c | 39 +++++------------------------ drivers/gpu/drm/nouveau/nouveau_connector.h | 9 ------- drivers/gpu/drm/nouveau/nouveau_display.c | 14 ----------- drivers/gpu/drm/nouveau/nouveau_display.h | 3 --- drivers/gpu/drm/nouveau/nv50_display.c | 17 +++++++++---- 5 files changed, 18 insertions(+), 64 deletions(-)
drivers/gpu/drm/nouveau/nouveau_connector.c +6 -33
@@ -105,12 +105,6 @@ nouveau_conn_atomic_get_property(struct drm_connector *connector,if (property == dev->mode_config.scaling_mode_property) *val = asyc->scaler.mode; -else if (property == disp->underscan_property) - *val = asyc->scaler.underscan.mode; -else if (property == disp->underscan_hborder_property) - *val = asyc->scaler.underscan.hborder; -else if (property == disp->underscan_vborder_property) - *val = asyc->scaler.underscan.vborder;else if (property == disp->dithering_mode) *val = asyc->dither.mode;else if (property == disp->dithering_depth)
@@ -170,24 +164,6 @@ nouveau_conn_atomic_set_property(struct drm_connector *connector, asyc->set.scaler = true; } }else -if (property == disp->underscan_property) { -if (asyc->scaler.underscan.mode != val) { - asyc->scaler.underscan.mode = val; - asyc->set.scaler = true; - } - }else -if (property == disp->underscan_hborder_property) { -if (asyc->scaler.underscan.hborder != val) { - asyc->scaler.underscan.hborder = val; - asyc->set.scaler = true; - } - }else -if (property == disp->underscan_vborder_property) { -if (asyc->scaler.underscan.vborder != val) { - asyc->scaler.underscan.vborder = val; - asyc->set.scaler = true; - } - }else if (property == disp->dithering_mode) {if (asyc->dither.mode != val) { asyc->dither.mode = val;
@@ -256,7 +232,6 @@ nouveau_conn_reset(struct drm_connector *connector) asyc->dither.mode =DITHERING_MODE_AUTO ; asyc->dither.depth =DITHERING_DEPTH_AUTO ; asyc->scaler.mode =DRM_MODE_SCALE_NONE ; - asyc->scaler.underscan.mode =UNDERSCAN_OFF ; asyc->procamp.color_vibrance =150 ; asyc->procamp.vibrant_hue =90 ;
@@ -285,18 +260,16 @@ nouveau_conn_attach_properties(struct drm_connector *connector) dvi_i_subconnector_property, 0);/* Add overscan compensation options to digital outputs. */ -if (disp->underscan_property && +if (disp->disp.oclass >=NV50_DISP && (connector->connector_type ==DRM_MODE_CONNECTOR_DVID || connector->connector_type ==DRM_MODE_CONNECTOR_DVII || connector->connector_type ==DRM_MODE_CONNECTOR_HDMIA || connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort)) { -drm_object_attach_property (&connector->base, - disp->underscan_property, -UNDERSCAN_OFF ); -drm_object_attach_property (&connector->base, - disp->underscan_hborder_property,0 ); -drm_object_attach_property (&connector->base, - disp->underscan_vborder_property,0 ); +WARN_ON (drm_connector_attach_underscan_properties (connector, +BIT (DRM_UNDERSCAN_OFF ) | +BIT (DRM_UNDERSCAN_ON ) | +BIT (DRM_UNDERSCAN_AUTO ), +128 ,128 )); }/* Add hue and saturation options. */
drivers/gpu/drm/nouveau/nouveau_connector.h +0 -9
@@ -111,15 +111,6 @@ struct nouveau_conn_atom {struct {int mode;/* DRM_MODE_SCALE_* */ -struct { -enum { -UNDERSCAN_OFF , -UNDERSCAN_ON , -UNDERSCAN_AUTO , - } mode; -u32 hborder; -u32 vborder; - } underscan;bool full; } scaler;
drivers/gpu/drm/nouveau/nouveau_display.c +0 -14
@@ -303,13 +303,6 @@ struct nouveau_drm_prop_enum_list {char *name; }; -static struct nouveau_drm_prop_enum_list underscan[] = { - {6 ,UNDERSCAN_AUTO ,"auto" }, - {6 ,UNDERSCAN_OFF ,"off" }, - {6 ,UNDERSCAN_ON ,"on" }, - {} -}; -static struct nouveau_drm_prop_enum_list dither_mode[] = { {7 ,DITHERING_MODE_AUTO ,"auto" }, {7 ,DITHERING_MODE_OFF ,"off" },
@@ -464,13 +457,6 @@ nouveau_display_create_properties(struct drm_device *dev)PROP_ENUM (disp->dithering_mode, gen,"dithering mode" , dither_mode);PROP_ENUM (disp->dithering_depth, gen,"dithering depth" , dither_depth); -PROP_ENUM (disp->underscan_property, gen,"underscan" , underscan); - - disp->underscan_hborder_property = -drm_property_create_range (dev,0 ,"underscan hborder" ,0 ,128 ); - - disp->underscan_vborder_property = -drm_property_create_range (dev,0 ,"underscan vborder" ,0 ,128 );if (gen <1 )return ;
drivers/gpu/drm/nouveau/nouveau_display.h +0 -3
@@ -42,9 +42,6 @@ struct nouveau_display {struct drm_property *dithering_mode;struct drm_property *dithering_depth; -struct drm_property *underscan_property; -struct drm_property *underscan_hborder_property; -struct drm_property *underscan_vborder_property;/* not really hue and saturation: */ struct drm_property *vibrant_hue_property;struct drm_property *color_vibrance_property;
drivers/gpu/drm/nouveau/nv50_display.c +12 -5
@@ -2057,11 +2057,11 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,* ratio the same as the backend mode unless overridden by the * user setting both hborder and vborder properties. */ -if ((asyc->scaler.underscan.mode ==UNDERSCAN_ON || - (asyc->scaler.underscan.mode ==UNDERSCAN_AUTO && +if ((asyc->state.underscan.mode ==DRM_UNDERSCAN_ON || + (asyc->state.underscan.mode ==DRM_UNDERSCAN_AUTO &&drm_detect_hdmi_monitor (edid)))) { -u32 bX = asyc->scaler.underscan.hborder; -u32 bY = asyc->scaler.underscan.vborder; +u32 bX = asyc->state.underscan.hborder; +u32 bY = asyc->state.underscan.vborder;u32 r = (asyh->view.oH <<19 ) / asyh->view.oW;if (bX) {
@@ -2185,8 +2185,8 @@ nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state)struct nv50_head *head =nv50_head (crtc);struct nv50_head_atom *armh =nv50_head_atom (crtc->state);struct nv50_head_atom *asyh =nv50_head_atom (state); +struct drm_connector_state *conns, *oldconns;struct nouveau_conn_atom *asyc =NULL ; -struct drm_connector_state *conns;struct drm_connector *conn;int i;
@@ -2199,6 +2199,13 @@ nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state) } } +for_each_oldnew_connector_in_state (asyh->state.state, conn, + oldconns, conns, i) { +if (memcmp (&oldconns->underscan, &conns->underscan, +sizeof (conns->underscan))) + asyc->set.scaler = true; + } +if (armh->state.active) {if (asyc) {if (asyh->state.mode_changed)
Signature · 6 lines
2.14.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH v2 3/4 drm/vc4: Attach underscan props to the HDMI connector
In reply to Boris BrezillonNow that the plane code takes the underscan setup into account, we can safely attach the underscan props to the HDMI connector.
We also take care of filling AVI infoframes correctly to expose the top/botton/left/right bar.
Note that these underscan props match pretty well the overscan_{left,right,top,bottom} properties defined in config.txt and parsed by the VC4 firmware.
---
Changes in v2:
- none
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +25 -0
@@ -323,6 +323,16 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev, DRM_MODE_CONNECTOR_HDMIA);drm_connector_helper_add (connector, &vc4_hdmi_connector_helper_funcs); +/* The hborder and vborder limit is arbitrarily set to 1024 which +* should be more than enough for real use cases. Note that the actual +* limitation comes from the display mode: +* hborder < hdisplay && vborder < vdisplay +*/ +drm_connector_attach_underscan_properties (connector, +BIT (DRM_UNDERSCAN_OFF ) | +BIT (DRM_UNDERSCAN_ON ), +1024 ,1024 ); + connector->polled = (DRM_CONNECTOR_POLL_CONNECT |DRM_CONNECTOR_POLL_DISCONNECT );
@@ -408,6 +418,9 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder,static void vc4_hdmi_set_avi_infoframe (struct drm_encoder *encoder) {struct vc4_hdmi_encoder *vc4_encoder =to_vc4_hdmi_encoder (encoder); +struct vc4_dev *vc4 = encoder->dev->dev_private; +struct vc4_hdmi *hdmi = vc4->hdmi; +struct drm_connector_state *cstate = hdmi->connector->state;struct drm_crtc *crtc = encoder->crtc;const struct drm_display_mode *mode = &crtc->state->adjusted_mode;union hdmi_infoframe frame;
@@ -426,6 +439,18 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder) vc4_encoder->rgb_range_selectable, false); +if (cstate->underscan.mode ==DRM_UNDERSCAN_ON ) { +if (cstate->underscan.hborder) { + frame.avi.right_bar = cstate->underscan.hborder /2 ; + frame.avi.left_bar = frame.avi.right_bar; + } + +if (cstate->underscan.vborder) { + frame.avi.top_bar = cstate->underscan.vborder /2 ; + frame.avi.bottom_bar = frame.avi.top_bar; + } + } +vc4_hdmi_write_infoframe (encoder, &frame); }
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel