drm/omap: add crtc properties
Subsystems (3)
cover drm/omap: add crtc properties
This patchset adds the following CRTC properties:
- background color
- transparency keying property
- alpha blender on DSS3
Tomi Valkeinen (3):
drm/omap: add crtc background property
drm/omap: add crtc transparency key property
drm/omap: add alpha blender property
drivers/gpu/drm/omapdrm/dss/dispc.c | 4 +- drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 +- drivers/gpu/drm/omapdrm/omap_crtc.c | 85 ++++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_drv.c | 30 ++++++++++ drivers/gpu/drm/omapdrm/omap_drv.h | 6 ++ 5 files changed, 121 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 drm/omap: add crtc background property
From: Tomi Valkeinen <[email protected]>
Add DRM properties for crtc background color property. Background color is shown on areas where there are no planes.
--- drivers/gpu/drm/omapdrm/omap_crtc.c | 22 +++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_drv.c | 7 +++++++ drivers/gpu/drm/omapdrm/omap_drv.h | 3 +++ 3 files changed, 31 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/omap_crtc.c +21 -1
@@ -24,6 +24,8 @@ struct omap_crtc_state {unsigned int rotation;unsigned int zpos;bool manually_updated; + +u32 default_color; };#define to_omap_crtc (x) container_of(x, struct omap_crtc, base)
@@ -395,13 +397,14 @@ static void omap_crtc_cpr_coefs_from_ctm(const struct drm_color_ctm *ctm,static void omap_crtc_write_crtc_properties (struct drm_crtc *crtc) { +const struct omap_crtc_state *omap_state =to_omap_crtc_state (crtc->state);struct omap_drm_private *priv = crtc->dev->dev_private;struct omap_crtc *omap_crtc =to_omap_crtc (crtc);struct omap_overlay_manager_info info;memset (&info,0 ,sizeof (info)); - info.default_color =0x000000 ; + info.default_color = omap_state->default_color; info.trans_enabled = false; info.partial_alpha_enabled = false;
@@ -668,6 +671,7 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, {struct omap_drm_private *priv = crtc->dev->dev_private;struct drm_plane_state *plane_state; +struct omap_crtc_state *omap_state =to_omap_crtc_state (state);/* * Delegate property set to the primary plane. Get the plane state and
@@ -683,6 +687,8 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, plane_state->rotation = val; else if (property == priv->zorder_prop) plane_state->zpos = val; + else if (property == priv->background_color_prop) + omap_state->default_color = val; else return -EINVAL;
@@ -701,6 +707,8 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, *val = omap_state->rotation; else if (property == priv->zorder_prop) *val = omap_state->zpos; + else if (property == priv->background_color_prop) + *val = omap_state->default_color; else return -EINVAL;
@@ -741,6 +749,8 @@ omap_crtc_duplicate_state(struct drm_crtc *crtc) state->rotation = current_state->rotation; state->manually_updated = current_state->manually_updated; + state->default_color = current_state->default_color; +return &state->base; }
@@ -778,6 +788,15 @@ static const char *channel_names[] = { [OMAP_DSS_CHANNEL_LCD3] = "lcd3", }; +static void omap_crtc_install_properties (struct drm_crtc *crtc) +{ +struct drm_device *dev = crtc->dev; +struct drm_mode_object *obj = &crtc->base; +struct omap_drm_private *priv = dev->dev_private; + +drm_object_attach_property (obj, priv->background_color_prop,0 ); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init(struct drm_device *dev, struct omap_drm_pipeline *pipe,
@@ -843,6 +862,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,drm_mode_crtc_set_gamma_size (crtc, gamma_lut_size); } +omap_crtc_install_properties (crtc);omap_plane_install_properties (crtc->primary, &crtc->base);return crtc;
drivers/gpu/drm/omapdrm/omap_drv.c +7 -0
@@ -200,6 +200,13 @@ static int omap_modeset_init_properties(struct drm_device *dev)if (!priv->zorder_prop)return -ENOMEM ; +/* crtc properties */ + + priv->background_color_prop = +drm_property_create_range (dev,0 ,"background" ,0 ,0xffffff ); +if (!priv->background_color_prop) +return -ENOMEM ; +return 0 ; }
drivers/gpu/drm/omapdrm/omap_drv.h +3 -0
@@ -73,6 +73,9 @@ struct omap_drm_private {/* properties: */ struct drm_property *zorder_prop; +/* crtc properties */ +struct drm_property *background_color_prop; +/* irq handling: */ spinlock_t wait_lock;/* protects the wait_list */ struct list_head wait_list;/* list of omap_irq_wait */
Signature · 1 line
2.25.1
PATCH 2/3 drm/omap: add crtc transparency key property
In reply to Neil ArmstrongFrom: Tomi Valkeinen <[email protected]>
Add support for transparency keying.
User space must understand how the TCK works and needs to place the planes to correct zpos. The generic zpos normalization in DRM however is going to do normalization and might move the position of the planes which breaks the TCK as planes are no longer in the position where application deliberately placed them.
If the TCK is enabled for the crtc then use the zpos configured by the application instead of the normalized positions and at the same time do a sanity check against overlapping zpos.
--- drivers/gpu/drm/omapdrm/omap_crtc.c | 53 ++++++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_drv.c | 18 ++++++++++ drivers/gpu/drm/omapdrm/omap_drv.h | 2 ++ 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/omap_crtc.c +52 -1
@@ -26,6 +26,8 @@ struct omap_crtc_state {bool manually_updated;u32 default_color; +unsigned int trans_key_mode; +unsigned int trans_key; };#define to_omap_crtc (x) container_of(x, struct omap_crtc, base)
@@ -405,9 +407,25 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)memset (&info,0 ,sizeof (info)); info.default_color = omap_state->default_color; - info.trans_enabled = false; info.partial_alpha_enabled = false; + info.trans_key = omap_state->trans_key; + +switch (omap_state->trans_key_mode) { +case 0 : +default : + info.trans_enabled = false; +break ; +case 1 : + info.trans_enabled = true; + info.trans_key_type =OMAP_DSS_COLOR_KEY_GFX_DST ; +break ; +case 2 : + info.trans_enabled = true; + info.trans_key_type =OMAP_DSS_COLOR_KEY_VID_SRC ; +break ; + } +if (crtc->state->ctm) {struct drm_color_ctm *ctm = crtc->state->ctm->data;
@@ -584,6 +602,7 @@ static int omap_crtc_atomic_check(struct drm_crtc *crtc, {struct drm_crtc_state *crtc_state =drm_atomic_get_new_crtc_state (state, crtc); +const struct omap_crtc_state *omap_state =to_omap_crtc_state (crtc_state);struct drm_plane_state *pri_state;if (crtc_state->color_mgmt_changed && crtc_state->degamma_lut) {
@@ -594,6 +613,25 @@ static int omap_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } +if (omap_state->trans_key_mode) { +struct drm_plane *plane; +struct drm_plane_state *plane_state; +u32 zpos_mask =0 ; + +drm_for_each_plane_mask (plane, crtc->dev, crtc_state->plane_mask) { + plane_state = +drm_atomic_get_plane_state (crtc_state->state, plane); +if (IS_ERR (plane_state)) +return PTR_ERR (plane_state); + +if (zpos_mask &BIT (plane_state->zpos)) +return -EINVAL ; + + zpos_mask |=BIT (plane_state->zpos); + plane_state->normalized_zpos = plane_state->zpos; + } + } + pri_state =drm_atomic_get_new_plane_state (state, crtc->primary);if (pri_state) {
@@ -689,6 +727,10 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, plane_state->zpos = val; else if (property == priv->background_color_prop) omap_state->default_color = val; + else if (property == priv->trans_key_mode_prop) + omap_state->trans_key_mode = val; + else if (property == priv->trans_key_prop) + omap_state->trans_key = val; else return -EINVAL;
@@ -709,6 +751,10 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, *val = omap_state->zpos; else if (property == priv->background_color_prop) *val = omap_state->default_color; + else if (property == priv->trans_key_mode_prop) + *val = omap_state->trans_key_mode; + else if (property == priv->trans_key_prop) + *val = omap_state->trans_key; else return -EINVAL;
@@ -751,6 +797,9 @@ omap_crtc_duplicate_state(struct drm_crtc *crtc) state->default_color = current_state->default_color; + state->trans_key_mode = current_state->trans_key_mode; + state->trans_key = current_state->trans_key; +return &state->base; }
@@ -795,6 +844,8 @@ static void omap_crtc_install_properties(struct drm_crtc *crtc)struct omap_drm_private *priv = dev->dev_private;drm_object_attach_property (obj, priv->background_color_prop,0 ); +drm_object_attach_property (obj, priv->trans_key_mode_prop,0 ); +drm_object_attach_property (obj, priv->trans_key_prop,0 ); }/* initialize crtc */
drivers/gpu/drm/omapdrm/omap_drv.c +18 -0
@@ -195,6 +195,12 @@ static int omap_modeset_init_properties(struct drm_device *dev)struct omap_drm_private *priv = dev->dev_private;unsigned int num_planes =dispc_get_num_ovls (priv->dispc); +static const struct drm_prop_enum_list trans_key_mode_list[] = { + {0 ,"disable" }, + {1 ,"gfx-dst" }, + {2 ,"vid-src" }, + }; + priv->zorder_prop =drm_property_create_range (dev,0 ,"zorder" ,0 , num_planes -1 );if (!priv->zorder_prop)
@@ -207,6 +213,18 @@ static int omap_modeset_init_properties(struct drm_device *dev)if (!priv->background_color_prop)return -ENOMEM ; + priv->trans_key_mode_prop = +drm_property_create_enum (dev,0 ,"trans-key-mode" , + trans_key_mode_list, +ARRAY_SIZE (trans_key_mode_list)); +if (!priv->trans_key_mode_prop) +return -ENOMEM ; + + priv->trans_key_prop = +drm_property_create_range (dev,0 ,"trans-key" ,0 ,0xffffff ); +if (!priv->trans_key_prop) +return -ENOMEM ; +return 0 ; }
drivers/gpu/drm/omapdrm/omap_drv.h +2 -0
@@ -75,6 +75,8 @@ struct omap_drm_private {/* crtc properties */ struct drm_property *background_color_prop; +struct drm_property *trans_key_mode_prop; +struct drm_property *trans_key_prop;/* irq handling: */ spinlock_t wait_lock;/* protects the wait_list */
Signature · 1 line
2.25.1
PATCH 3/3 drm/omap: add alpha blender property
In reply to Neil ArmstrongFrom: Tomi Valkeinen <[email protected]>
Add support to enable/disable alpha blender on DSS3.
--- drivers/gpu/drm/omapdrm/dss/dispc.c | 4 ++-- drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 +- drivers/gpu/drm/omapdrm/omap_crtc.c | 10 +++++++++- drivers/gpu/drm/omapdrm/omap_drv.c | 5 +++++ drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 5 files changed, 18 insertions(+), 4 deletions(-)
drivers/gpu/drm/omapdrm/dss/dispc.c +2 -2
@@ -2995,7 +2995,7 @@ void dispc_mgr_setup(struct dispc_device *dispc, info->trans_key);dispc_mgr_enable_trans_key (dispc, channel, info->trans_enabled);dispc_mgr_enable_alpha_fixed_zorder (dispc, channel, - info->partial_alpha_enabled); + info->alpha_blender_enabled);if (dispc_has_feature (dispc,FEAT_CPR )) {dispc_mgr_enable_cpr (dispc, channel, info->cpr_enable);dispc_mgr_set_cpr_coef (dispc, channel, &info->cpr_coefs);
@@ -4588,7 +4588,7 @@ static const struct dispc_errata_i734_data { .mgri = { .default_color = 0, .trans_enabled = false, - .partial_alpha_enabled = false, + .alpha_blender_enabled = false, .cpr_enable = false, }, .lcd_conf = {
drivers/gpu/drm/omapdrm/dss/omapdss.h +1 -1
@@ -175,7 +175,7 @@ struct omap_overlay_manager_info {u32 trans_key;bool trans_enabled; -bool partial_alpha_enabled; +bool alpha_blender_enabled;bool cpr_enable;struct omap_dss_cpr_coefs cpr_coefs;
drivers/gpu/drm/omapdrm/omap_crtc.c +9 -1
@@ -28,6 +28,7 @@ struct omap_crtc_state {u32 default_color;unsigned int trans_key_mode;unsigned int trans_key; +bool alpha_blender_enabled; };#define to_omap_crtc (x) container_of(x, struct omap_crtc, base)
@@ -407,7 +408,6 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)memset (&info,0 ,sizeof (info)); info.default_color = omap_state->default_color; - info.partial_alpha_enabled = false; info.trans_key = omap_state->trans_key;
@@ -426,6 +426,8 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)break ; } + info.alpha_blender_enabled = omap_state->alpha_blender_enabled; +if (crtc->state->ctm) {struct drm_color_ctm *ctm = crtc->state->ctm->data;
@@ -731,6 +733,8 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, omap_state->trans_key_mode = val; else if (property == priv->trans_key_prop) omap_state->trans_key = val; + else if (property == priv->alpha_blender_prop) + omap_state->alpha_blender_enabled = !!val; else return -EINVAL;
@@ -755,6 +759,8 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, *val = omap_state->trans_key_mode; else if (property == priv->trans_key_prop) *val = omap_state->trans_key; + else if (property == priv->alpha_blender_prop) + *val = omap_state->alpha_blender_enabled; else return -EINVAL;
@@ -799,6 +805,7 @@ omap_crtc_duplicate_state(struct drm_crtc *crtc) state->trans_key_mode = current_state->trans_key_mode; state->trans_key = current_state->trans_key; + state->alpha_blender_enabled = current_state->alpha_blender_enabled;return &state->base; }
@@ -846,6 +853,7 @@ static void omap_crtc_install_properties(struct drm_crtc *crtc)drm_object_attach_property (obj, priv->background_color_prop,0 );drm_object_attach_property (obj, priv->trans_key_mode_prop,0 );drm_object_attach_property (obj, priv->trans_key_prop,0 ); +drm_object_attach_property (obj, priv->alpha_blender_prop,0 ); }/* initialize crtc */
drivers/gpu/drm/omapdrm/omap_drv.c +5 -0
@@ -225,6 +225,11 @@ static int omap_modeset_init_properties(struct drm_device *dev)if (!priv->trans_key_prop)return -ENOMEM ; + priv->alpha_blender_prop = +drm_property_create_bool (dev,0 ,"alpha_blender" ); +if (!priv->alpha_blender_prop) +return -ENOMEM ; +return 0 ; }
drivers/gpu/drm/omapdrm/omap_drv.h +1 -0
@@ -77,6 +77,7 @@ struct omap_drm_private {struct drm_property *background_color_prop;struct drm_property *trans_key_mode_prop;struct drm_property *trans_key_prop; +struct drm_property *alpha_blender_prop;/* irq handling: */ spinlock_t wait_lock;/* protects the wait_list */
Signature · 1 line
2.25.1
Hi Neil,
Quoted 9 lines · Neil Armstrong
This patchset adds the following CRTC properties:
- background color
- transparency keying property
- alpha blender on DSS3Tomi Valkeinen (3):
drm/omap: add crtc background property
drm/omap: add crtc transparency key property
drm/omap: add alpha blender property
Nack, these don't comply with DRM uAPI rules. That's why I never sent them upstream.
https://www.kernel.org/doc/html/latest/gpu/drm-uapi.html#open-source-userspace-requirements
Tomi
Hi Tomi,
Quoted 8 lines · Tomi Valkeinen
Hi Neil,
Quoted 5 lines · Neil Armstrong
This patchset adds the following CRTC properties:
- background color
- transparency keying property
- alpha blender on DSS3
Quoted 8 lines
Quoted 4 lines
Tomi Valkeinen (3):
drm/omap: add crtc background property
drm/omap: add crtc transparency key property
drm/omap: add alpha blender propertyNack, these don't comply with DRM uAPI rules. That's why I never sent them upstream.
https://www.kernel.org/doc/html/latest/gpu/drm-uapi.html#open-source-userspace-requirements
Thanks for the reply, I was wondering why !
Neil
Quoted 2 lines
Tomi