drm/connector: Provide generic support for underscan
Subsystems (3)
v3 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.
This v3 was based on the "VC4 cursor scaling" changes, and thus address Ville's concern about cursor plane not being rescaled with the other ones.
Note that I dropped the nouveau conversion. I'll post a new version once/if the generic stuff are accepted.
Regards,
Boris
Boris Brezillon (3):
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
drivers/gpu/drm/drm_atomic_uapi.c | 12 +++ drivers/gpu/drm/drm_connector.c | 127 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_crtc.c | 47 +++++++++++ drivers/gpu/drm/vc4/vc4_drv.h | 3 + drivers/gpu/drm/vc4/vc4_hdmi.c | 25 ++++++ drivers/gpu/drm/vc4/vc4_plane.c | 50 ++++++++++++ include/drm/drm_connector.h | 80 +++++++++++++++++++ 7 files changed, 344 insertions(+)
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v3 1/3 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 v3:
- None
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_uapi.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_uapi.c +12 -0
@@ -740,6 +740,12 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,return set_out_fence_for_connector (state->state, connector, fence_ptr); + }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);
@@ -799,6 +805,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 (property == config->writeback_fb_id_property) {/* Writeback framebuffer is one-shot, write and forget */ *val =0 ;
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.17.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): 20181122112331.17735-2-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org
Re: [PATCH v3 1/3] drm/connector: Add generic underscan properties
Hi Boris,
Just because I happened to read the docs in here, one typo below:
Quoted 71 lines · Boris Brezillon
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_connectorstate 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 thedrm_connector_state->underscanfields.Signed-off-by Boris Brezillon <[email protected]>---
Changes in v3:
- NoneChanges 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
- Renamedrm_underscanintodrm_underscan_state
---drivers/gpu/drm/drm_atomic_uapi.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_uapi.c +12
-0@@ -740,6 +740,12 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,return set_out_fence_for_connector (state->state, connector, fence_ptr); + }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);@@ -799,6 +805,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 (property == config->writeback_fb_id_property) {/* Writeback framebuffer is one-shot, write and forget */ *val =0 ;drivers/gpu/drm/drm_connector.c +0
-0
drivers/gpu/drm/drm_connector.c DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list) · line 977
Quoted 7 lines
drivers/gpu/drm/drm_connector.c +4
-0@@ -971,6 +971,38 @@ DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list)* can also expose this property to external outputs, in which case they * must support "None", which should be the default (since external screens * have a built-in scaler). +* +* Connectors for non-analog outputs may also have standardized underscan +* properties (drivers can set this up by calling +* drm_connector_attach_content_protection_property() on initialization):
Should be drm_connector_attach_underscan_properties()
Cheers,
-Brian
Quoted 252 lines
drivers/gpu/drm/drm_connector.c +123
-0+* +* underscan: +* This properties defines whether underscan is activated or not, and when +* it is activated, how the horizontal and vertical borders are calculated: +* +* off: +* Underscan is disabled. The output image shouldn't be scaled to +* take screen borders into account. +* on: +* Underscan is activated and horizontal and vertical borders are +* specified through the "underscan hborder" and +* "underscan vborder" properties. +* auto: +* Underscan is activated only for HDMI monitors. +* +* underscan hborder: +* Horizontal border expressed in pixels. The border is symmetric, which +* means you'll have a border of 'hborder' pixels on the left and on the +* same border on the right. +* When this value is 0 and underscan is "on" or "auto", the driver will +* pick a default value (the default value is driver dependent). +* +* underscan vborder: +* Vertical border expressed in pixels. The border is symmetric, which +* means you'll have a border of 'vborder' pixels on the top and the same +* border on the bottom. +* When this value is 0 and underscan is "on" or "auto", the driver will +* pick a default value (the default value is driver dependent). */ int drm_connector_create_standard_properties (struct drm_device *dev)@@ -1241,6 +1273,101 @@ int drm_mode_create_tv_properties(struct drm_device *dev, }EXPORT_SYMBOL (drm_mode_create_tv_properties); +static const struct drm_prop_enum_list drm_underscan_mode_enum_list[] = { + {DRM_UNDERSCAN_OFF ,"off" }, + {DRM_UNDERSCAN_ON ,"on" }, + {DRM_UNDERSCAN_AUTO ,"auto" }, +}; + +/** +* drm_connector_attach_underscan_properties - attach atomic underscan +* properties +* @connector: connector to attach underscan mode properties on. +* @mode_mask: bitmask of %DRM_UNDERSCAN_XX modes encoding the supported +* underscan modes. +* @max_hborder: maximum size of the horizontal border expressed in pixels. +* Should be > 0. +* @max_vborder: maximum size of the vertical border expressed in pixels. +* Should be > 0. +* +* This is used to add support for underscan to atomic drivers. +* The underscan config will be set to &drm_connector_state.underscan +* and can be used from &drm_connector_helper_funcs->atomic_check for +* validation. +* +* Returns: +* Zero on success, negative errno on failure. +*/ +int drm_connector_attach_underscan_properties (struct drm_connector *connector, +u32 mode_mask,u64 max_hborder, +u64 max_vborder) +{ +unsigned int i, nmodes =ARRAY_SIZE (drm_underscan_mode_enum_list); +struct drm_device *dev = connector->dev; +struct drm_property *prop; + +if (!max_hborder || !max_vborder) +return -EINVAL ; + +if (!hweight32 (mode_mask) || (mode_mask & ~GENMASK (nmodes -1 ,0 ))) +return -EINVAL ; + + prop =drm_property_create (dev,DRM_MODE_PROP_ENUM ,"underscan" , +hweight32 (mode_mask)); +if (!prop) +return -ENOMEM ; + +for (i =0 ; i <ARRAY_SIZE (drm_underscan_mode_enum_list); i++) { +const struct drm_prop_enum_list *entry; +int ret; + +if (!(BIT (i) & mode_mask)) +continue ; + + entry = &drm_underscan_mode_enum_list[i]; + ret =drm_property_add_enum (prop, entry->type, entry->name); +if (ret) + goto err_free_mode_prop; + } + + connector->underscan_mode_property = prop; + + prop =drm_property_create_range (dev,0 ,"underscan hborder" ,0 , + max_hborder); +if (!prop) + goto err_free_mode_prop; + + connector->underscan_hborder_property = prop; + + prop =drm_property_create_range (dev,0 ,"underscan vborder" ,0 , + max_vborder); +if (!prop) + goto err_free_hborder_prop; + + connector->underscan_vborder_property = prop; + +drm_object_attach_property (&connector->base, + connector->underscan_mode_property, +DRM_UNDERSCAN_OFF ); +drm_object_attach_property (&connector->base, + connector->underscan_hborder_property,0 ); +drm_object_attach_property (&connector->base, + connector->underscan_vborder_property,0 ); + +return 0 ; + +err_free_hborder_prop: +drm_property_destroy (dev, connector->underscan_hborder_property); + connector->underscan_hborder_property =NULL ; + +err_free_mode_prop: +drm_property_destroy (dev, connector->underscan_mode_property); + connector->underscan_mode_property =NULL ; + +return -ENOMEM ; +} +EXPORT_SYMBOL (drm_connector_attach_underscan_properties); +/** * drm_mode_create_scaling_mode_property - create scaling mode property * @dev: DRM device include/drm/drm_connector.h +80
-0@@ -377,6 +377,53 @@ struct drm_tv_connector_state {unsigned int hue; }; +/** +* enum drm_underscan_mode - Underscan mode +* +* This enum is used to track the underscan mode. +* +* @DRM_UNDERSCAN_OFF: No underscan applied, the output image will be unchanged +* @DRM_UNDERSCAN_ON: Underscan is enabled, and horizontal/vertical border size +* are specified through the &struct_drm_underscan->hborder +* and &struct_drm_underscan->vborder fields. +* @DRM_UNDERSCAN_AUTO: Underscan is enabled and &struct_drm_underscan->hborder +* and &struct_drm_underscan->vborder are guessed by the +* driver. +*/ +enum drm_underscan_mode { +DRM_UNDERSCAN_OFF , +DRM_UNDERSCAN_ON , +DRM_UNDERSCAN_AUTO , +}; + +/** +* struct drm_underscan_state - Underscan properties attached to a connector +* state +* +* This can be used to tell the CRTC how the image should be scaled/placed in +* order to cover fit in the display connected through this connector. Most of +* the time used to address situations where the display borders are hidden. +* Can also be used to compensate overscan done on the display side. +*/ +struct drm_underscan_state { +/** +* @mode: Underscan mode. +*/ +enum drm_underscan_mode mode; + +/** +* @hborder: Horizontal border. This values encodes both the left and +* right borders: left_border = right_border = hborder / 2. +*/ +unsigned int hborder; + +/** +* @vborder: Vertical border. This values encodes both the top and +* bottom borders: top_border = bottom_border = vborder / 2. +*/ +unsigned int vborder; +}; +/** * struct drm_connector_state - mutable connector state */ @@ -461,6 +508,13 @@ struct drm_connector_state {* drm_writeback_signal_completion() */ struct drm_writeback_job *writeback_job; + +/** +* @underscan: Underscan information. Most commonly used to adjust +* image when the display has borders covering part of the image of +* when it's doing overscan on its own. +*/ +struct drm_underscan_state underscan; };/** @@ -924,6 +978,29 @@ struct drm_connector {*/ struct drm_property_blob *path_blob_ptr; +/** +* @underscan_mode_property: Optional connector underscan mode. Used by +* the driver to scale the output image and compensate an overscan done +* on the display side. +*/ +struct drm_property *underscan_mode_property; + +/** +* @underscan_hborder_property: Optional connector underscan horizontal +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_hborder_property; + +/** +* @underscan_hborder_property: Optional connector underscan vertical +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_vborder_property; +#define DRM_CONNECTOR_POLL_HPD (1 << 0)#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)@@ -1180,6 +1257,9 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev);int drm_mode_create_tv_properties (struct drm_device *dev,unsigned int num_modes,const char *const modes[]); +int drm_connector_attach_underscan_properties (struct drm_connector *connector, +u32 mode_mask,u64 max_hborder, +u64 max_vborder);int drm_mode_create_scaling_mode_property (struct drm_device *dev);int drm_connector_attach_content_type_property (struct drm_connector *dev); int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,Signature · 6 lines
2.17.1 _______________________________________________ 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
Eric Anholt
Reviewed-byRe: [PATCH v3 1/3] drm/connector: Add generic underscan properties
Quoted 5 lines · Brian Starkey
Hi Boris,
Just because I happened to read the docs in here, one typo below:
On Thu, Nov 22, 2018 at 12:23:29PM +0100, Boris Brezillon wrote:
Quoted 14 lines
drivers/gpu/drm/drm_connector.c DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list) · line 977
Quoted 12 lines
drivers/gpu/drm/drm_connector.c +4
-0@@ -971,6 +971,38 @@ DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list)* can also expose this property to external outputs, in which case they * must support "None", which should be the default (since external screens * have a built-in scaler). +* +* Connectors for non-analog outputs may also have standardized underscan +* properties (drivers can set this up by calling +* drm_connector_attach_content_protection_property() on initialization): Should be
drm_connector_attach_underscan_properties()
Other than this typo, this series is:
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 1/3] drm/connector: Add generic underscan properties
In reply to a message not in the archiveQuoted 16 lines · Boris Brezillon
include/drm/drm_connector.h +12
-0@@ -924,6 +978,29 @@ struct drm_connector {*/ struct drm_property_blob *path_blob_ptr; +/** +* @underscan_mode_property: Optional connector underscan mode. Used by +* the driver to scale the output image and compensate an overscan done +* on the display side. +*/ +struct drm_property *underscan_mode_property; + +/** +* @underscan_hborder_property: Optional connector underscan horizontal +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side.
include/drm/drm_connector.h struct drm_connector { · line 1002
Quoted 10 lines
include/drm/drm_connector.h +10
-0+*/ +struct drm_property *underscan_hborder_property; + +/** +* @underscan_hborder_property: Optional connector underscan vertical +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_vborder_property;
I'm wondering why we're adding these new props when we already have the (slightly more flexible) margin properties for TV out. We could just reuse those AFAICS.
Quoted 16 lines
include/drm/drm_connector.h +4
-0+#define DRM_CONNECTOR_POLL_HPD (1 << 0)#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)@@ -1180,6 +1257,9 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev);int drm_mode_create_tv_properties (struct drm_device *dev,unsigned int num_modes,const char *const modes[]); +int drm_connector_attach_underscan_properties (struct drm_connector *connector, +u32 mode_mask,u64 max_hborder, +u64 max_vborder);int drm_mode_create_scaling_mode_property (struct drm_device *dev);int drm_connector_attach_content_type_property (struct drm_connector *dev); int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,Signature · 1 line
2.17.1
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH v3 1/3] drm/connector: Add generic underscan properties
Quoted 23 lines · On Mon, 3 Dec 2018 16:40:11 +0200 Ville Syrjälä…
Quoted 22 lines · Boris Brezillon
include/drm/drm_connector.h +18
-0@@ -924,6 +978,29 @@ struct drm_connector {*/ struct drm_property_blob *path_blob_ptr; +/** +* @underscan_mode_property: Optional connector underscan mode. Used by +* the driver to scale the output image and compensate an overscan done +* on the display side. +*/ +struct drm_property *underscan_mode_property; + +/** +* @underscan_hborder_property: Optional connector underscan horizontal +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_hborder_property; + +/** +* @underscan_hborder_property: Optional connector underscan vertical +* border (expressed in pixels). Used by the driver to adjust the
Quoted 8 lines
include/drm/drm_connector.h struct drm_connector { · line 1002
Quoted 4 lines
include/drm/drm_connector.h +4
-0+* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_vborder_property;I'm wondering why we're adding these new props when we already have the (slightly more flexible) margin properties for TV out. We could just reuse those AFAICS.
I'm not against the idea, but I can't use drm_mode_create_tv_properties() directly, as most props created by this function are not applicable to an HDMI displays. Should I move the margins props out of the tv_connector_state and provide new helpers to create those props?
Quoted 18 lines
Quoted 17 lines
include/drm/drm_connector.h +4
-0+#define DRM_CONNECTOR_POLL_HPD (1 << 0)#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)@@ -1180,6 +1257,9 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev);int drm_mode_create_tv_properties (struct drm_device *dev,unsigned int num_modes,const char *const modes[]); +int drm_connector_attach_underscan_properties (struct drm_connector *connector, +u32 mode_mask,u64 max_hborder, +u64 max_vborder);int drm_mode_create_scaling_mode_property (struct drm_device *dev);int drm_connector_attach_content_type_property (struct drm_connector *dev); int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,Signature · 1 line
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 1/3] drm/connector: Add generic underscan properties
Quoted 35 lines · Boris Brezillon
Quoted 23 lines · On Mon, 3 Dec 2018 16:40:11 +0200 Ville Syrjälä…
Quoted 22 lines · Boris Brezillon
include/drm/drm_connector.h +18
-0@@ -924,6 +978,29 @@ struct drm_connector {*/ struct drm_property_blob *path_blob_ptr; +/** +* @underscan_mode_property: Optional connector underscan mode. Used by +* the driver to scale the output image and compensate an overscan done +* on the display side. +*/ +struct drm_property *underscan_mode_property; + +/** +* @underscan_hborder_property: Optional connector underscan horizontal +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_hborder_property; + +/** +* @underscan_hborder_property: Optional connector underscan vertical +* border (expressed in pixels). Used by the driver to adjust the Quoted 8 lines
include/drm/drm_connector.h struct drm_connector { · line 1002
Quoted 4 lines
include/drm/drm_connector.h +4
-0+* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_vborder_property;I'm wondering why we're adding these new props when we already have the (slightly more flexible) margin properties for TV out. We could just reuse those AFAICS.
Quoted 5 lines
I'm not against the idea, but I can't use
drm_mode_create_tv_properties()directly, as most props created by this function are not applicable to an HDMI displays. Should I move the margins props out of thetv_connector_stateand provide new helpers to create those props?
TV margin props look good to me, FWIW.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH v3 1/3] drm/connector: Add generic underscan properties
Quoted 37 lines · Eric Anholt
Quoted 35 lines · Boris Brezillon
Quoted 31 lines · On Mon, 3 Dec 2018 16:40:11 +0200 Ville Syrjälä…
Quoted 16 lines · Boris Brezillon
include/drm/drm_connector.h +12
-0@@ -924,6 +978,29 @@ struct drm_connector {*/ struct drm_property_blob *path_blob_ptr; +/** +* @underscan_mode_property: Optional connector underscan mode. Used by +* the driver to scale the output image and compensate an overscan done +* on the display side. +*/ +struct drm_property *underscan_mode_property; + +/** +* @underscan_hborder_property: Optional connector underscan horizontal +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side. include/drm/drm_connector.h struct drm_connector { · line 1002
Quoted 10 lines
include/drm/drm_connector.h +10
-0+*/ +struct drm_property *underscan_hborder_property; + +/** +* @underscan_hborder_property: Optional connector underscan vertical +* border (expressed in pixels). Used by the driver to adjust the +* output image position and compensate an overscan done on the display +* side. +*/ +struct drm_property *underscan_vborder_property;I'm wondering why we're adding these new props when we already have the (slightly more flexible) margin properties for TV out. We could just reuse those AFAICS.
Quoted 7 lines
Quoted 5 lines
I'm not against the idea, but I can't use
drm_mode_create_tv_properties()directly, as most props created by this function are not applicable to an HDMI displays. Should I move the margins props out of thetv_connector_stateand provide new helpers to create those props?TV margin props look good to me, FWIW.
Yeah extracting the margin props from the tv props sounds like a good idea. If we go full ocd we'd also split out margin_connector_state or something like that (should be doable with some cocci), but not sure that's fully worth it. Tuning margins is largely an analog TV issue I think, so could just leave them there.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20181122112331.17735-1-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org
PATCH v3 2/3 drm/vc4: Take underscan setup into account when updating planes
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 from vc4_plane_setup_clipping_and_scaling() so that we are ready to attach underscan properties to the HDMI connector.
---
Changes in v3:
- Rebase on top of the "cursor rescaling" changes
Changes in v2:
- Take changes on hborder/vborder meaning into account
--- drivers/gpu/drm/vc4/vc4_crtc.c | 47 +++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_drv.h | 3 ++ drivers/gpu/drm/vc4/vc4_plane.c | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+)
drivers/gpu/drm/vc4/vc4_crtc.c +47 -0
@@ -49,6 +49,11 @@ struct vc4_crtc_state {struct drm_mm_node mm;bool feed_txp;bool txp_armed; + +struct { +unsigned int vborder; +unsigned int hborder; + } underscan; }; static inline struct vc4_crtc_state *
@@ -624,6 +629,39 @@ static enum drm_mode_status vc4_crtc_mode_valid(struct drm_crtc *crtc,return MODE_OK ; } +void vc4_crtc_get_underscan_borders (struct drm_crtc_state *state, +unsigned int *vborder, +unsigned int *hborder) +{ +struct vc4_crtc_state *vc4_state =to_vc4_crtc_state (state); +struct drm_connector_state *conn_state; +struct drm_connector *conn; +int i; + + *vborder = vc4_state->underscan.vborder; + *hborder = vc4_state->underscan.hborder; + +/* We have to interate over all new connector states because +* vc4_crtc_get_underscan_borders() might be called before +* vc4_crtc_atomic_check() which means underscan info in vc4_crtc_state +* might be outdated. +*/ +for_each_new_connector_in_state (state->state, conn, conn_state, i) { +if (conn_state->crtc != state->crtc) +continue ; + +if (conn_state->underscan.mode ==DRM_UNDERSCAN_ON ) { + *vborder = conn_state->underscan.vborder; + *hborder = conn_state->underscan.hborder; + }else { + *vborder =0 ; + *hborder =0 ; + } + +break ; + } +} +static int vc4_crtc_atomic_check (struct drm_crtc *crtc,struct drm_crtc_state *state) {
@@ -657,6 +695,7 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc,return ret;for_each_new_connector_in_state (state->state, conn, conn_state, i) { +unsigned int vborder =0 , hborder =0 ;if (conn_state->crtc != crtc)continue ;
@@ -671,6 +710,13 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc, vc4_state->feed_txp = false; } +if (conn_state->underscan.mode ==DRM_UNDERSCAN_ON ) { + vborder = conn_state->underscan.vborder; + hborder = conn_state->underscan.hborder; + } + + vc4_state->underscan.vborder = vborder; + vc4_state->underscan.hborder = hborder;break ; }
@@ -972,6 +1018,7 @@ static struct drm_crtc_state *vc4_crtc_duplicate_state(struct drm_crtc *crtc) old_vc4_state =to_vc4_crtc_state (crtc->state); vc4_state->feed_txp = old_vc4_state->feed_txp; + vc4_state->underscan = old_vc4_state->underscan;__drm_atomic_helper_crtc_duplicate_state (crtc, &vc4_state->base);return &vc4_state->base;
drivers/gpu/drm/vc4/vc4_drv.h +3 -0
@@ -707,6 +707,9 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, const struct drm_display_mode *mode);void vc4_crtc_handle_vblank (struct vc4_crtc *crtc);void vc4_crtc_txp_armed (struct drm_crtc_state *state); +void vc4_crtc_get_underscan_borders (struct drm_crtc_state *state, +unsigned int *vborder, +unsigned int *hborder);/* vc4_debugfs.c */ int vc4_debugfs_init (struct drm_minor *minor);
drivers/gpu/drm/vc4/vc4_plane.c +50 -0
62 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH v3 3/3 drm/vc4: Attach underscan props to the HDMI connector
In reply to a message not in the archiveNow 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 v3:
- none
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.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx