Skip to contentSkip to conversation

drm/tegra: Add blend mode properties

PATCH In review Thierry Reding 3 participants 3 messages Aug 26 – Aug 27

Subsystems (3)
lore
Share & tools
lore

Thierry Reding

author maintainer
#0 lore raw

PATCH 1/1 drm/tegra: Add blend mode properties

From: Thierry Reding <[email protected]>

The default programming in the driver matches the "coverage" blend mode, so add the corresponding pixel blend mode property to let userspace know about it.

---
 drivers/gpu/drm/tegra/dc.c  | 6 ++++++
 drivers/gpu/drm/tegra/hub.c | 2 ++
 2 files changed, 8 insertions(+)
drivers/gpu/drm/tegra/dc.c +6 -0
index 0b3fcc7011b35..fefc3761a4bc7 100644
@@ -904,6 +904,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
 						    struct tegra_dc *dc)
 {
 	unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
 	enum drm_plane_type type = DRM_PLANE_TYPE_PRIMARY;
 	struct tegra_plane *plane;
 	unsigned int num_formats;
@@ -939,6 +940,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(&plane->base, blend_caps);
 	drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
 
 	err = drm_plane_create_rotation_property(&plane->base,
@@ -1209,6 +1211,7 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm,
 						      struct tegra_dc *dc)
 {
 	unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
 	struct tegra_plane *plane;
 	unsigned int num_formats;
 	const u32 *formats;
@@ -1252,6 +1255,7 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(&plane->base, &tegra_cursor_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(&plane->base, blend_caps);
 	drm_plane_create_zpos_immutable_property(&plane->base, 255);
 
 	return &plane->base;
@@ -1356,6 +1360,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
 						       bool cursor)
 {
 	unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
 	struct tegra_plane *plane;
 	unsigned int num_formats;
 	enum drm_plane_type type;
@@ -1394,6 +1399,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(&plane->base, blend_caps);
 	drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
 
 	err = drm_plane_create_rotation_property(&plane->base,
drivers/gpu/drm/tegra/hub.c +2 -0
index bd442bfd45407..448f49f3a7d7e 100644
@@ -759,6 +759,7 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
 					    unsigned int index,
 					    enum drm_plane_type type)
 {
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
 	struct tegra_drm *tegra = drm->dev_private;
 	struct tegra_display_hub *hub = tegra->hub;
 	struct tegra_shared_plane *plane;
@@ -797,6 +798,7 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(p, &tegra_shared_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(p, blend_caps);
 	drm_plane_create_zpos_property(p, 0, 0, 255);
 
 	return p;
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The newly added pixel_blend_mode property is not initialized in the plane's reset hook, leading to…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The newly added pixel_blend_mode property is not initialized in the plane's reset hook, leading to an invalid initial atomic state. --

commit dea256106aa6a4944ed84de30a43b82c973ff72f
Author: Thierry Reding <[email protected]>

drm/tegra: Add blend mode properties

The default programming in the driver matches the "coverage" blend mode, so add the corresponding pixel blend mode property to let userspace know about it.

drivers/gpu/drm/tegra/dc.c static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm, · line 943

Quoted 9 lines
drivers/gpu/drm/tegra/dc.c +1 -0
index 0b3fcc7011b35..fefc3761a4bc7 100644
@@ -939,6 +940,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(&plane->base, blend_caps);

[Severity: High]
Since tegra_plane_reset() in drivers/gpu/drm/tegra/plane.c uses kzalloc_obj() to zero-allocate the atomic plane state:

	state = kzalloc_obj(*state);
	if (state) {
		plane->state = &state->base;
		plane->state->plane = plane;

Will this cause atomic commits to fail with -EINVAL if userspace performs a commit without changing the blend mode?

The pixel_blend_mode field is implicitly left at 0 (DRM_MODE_BLEND_PREMULTI). Because only DRM_MODE_BLEND_COVERAGE (enum value 1) is exposed in blend_caps, the core DRM enum validator (drm_property_change_valid_get()) will reject the 0 value when userspace queries and subsequently commits the state.

Should tegra_plane_reset() be updated to explicitly initialize pixel_blend_mode to DRM_MODE_BLEND_COVERAGE?

Quoted 1 line
drivers/gpu/drm/tegra/dc.c +0 -0
 	drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Tested-by Acked-by on v1 1/1
#2 lore raw
In reply to Thierry Reding
Quoted 77 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The default programming in the driver matches the "coverage" blend mode, so add the corresponding pixel blend mode property to let userspace know about it.

---
  drivers/gpu/drm/tegra/dc.c  | 6 ++++++
  drivers/gpu/drm/tegra/hub.c | 2 ++
  2 files changed, 8 insertions(+)
drivers/gpu/drm/tegra/dc.c +6 -0
index 0b3fcc7011b35..fefc3761a4bc7 100644
@@ -904,6 +904,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
  						    struct tegra_dc *dc)
  {
  	unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
  	enum drm_plane_type type = DRM_PLANE_TYPE_PRIMARY;
  	struct tegra_plane *plane;
  	unsigned int num_formats;
@@ -939,6 +940,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
  	}
 
  	drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(&plane->base, blend_caps);
  	drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
 
  	err = drm_plane_create_rotation_property(&plane->base,
@@ -1209,6 +1211,7 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm,
  						      struct tegra_dc *dc)
  {
  	unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
  	struct tegra_plane *plane;
  	unsigned int num_formats;
  	const u32 *formats;
@@ -1252,6 +1255,7 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm,
  	}
 
  	drm_plane_helper_add(&plane->base, &tegra_cursor_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(&plane->base, blend_caps);
  	drm_plane_create_zpos_immutable_property(&plane->base, 255);
 
  	return &plane->base;
@@ -1356,6 +1360,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
  						       bool cursor)
  {
  	unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
  	struct tegra_plane *plane;
  	unsigned int num_formats;
  	enum drm_plane_type type;
@@ -1394,6 +1399,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
  	}
 
  	drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(&plane->base, blend_caps);
  	drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
 
  	err = drm_plane_create_rotation_property(&plane->base,
drivers/gpu/drm/tegra/hub.c +1 -0
index bd442bfd45407..448f49f3a7d7e 100644
@@ -759,6 +759,7 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
  					    unsigned int index,
  					    enum drm_plane_type type)
  {
+	unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
  	struct tegra_drm *tegra = drm->dev_private;
  	struct tegra_display_hub *hub = tegra->hub;
  	struct tegra_shared_plane *plane;

drivers/gpu/drm/tegra/hub.c struct drm_plane *tegra_shared_plane_create(struct drm_device *drm, · line 804

Quoted 7 lines
drivers/gpu/drm/tegra/hub.c +1 -0
@@ -797,6 +798,7 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
  	}
 
  	drm_plane_helper_add(p, &tegra_shared_plane_helper_funcs);
+	drm_plane_create_blend_mode_property(p, blend_caps);
  	drm_plane_create_zpos_property(p, 0, 0, 255);
 
  	return p;

Thanks!
Jon

Signature · 1 line
nvpublic