[PATCH RFC v2 03/20] drm: Factor out common color_pipeline property initialization code
Louis Chauvet
louis.chauvet at bootlin.com
Fri Sep 19 05:43:18 PDT 2025
Le 18/09/2025 à 02:43, Nícolas F. R. A. Prado a écrit :
> In preparation for sharing the initialization code for the color
> pipeline property between pre- and post-blend color pipelines, factor
> out the common initialization to a separate function.
>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado at collabora.com>
Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
> ---
> drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/drm_crtc_internal.h | 5 +++++
> drivers/gpu/drm/drm_plane.c | 36 +++++-------------------------
> 3 files changed, 54 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 46655339003db2a1b43441434839e26f61d79b4e..94e60cffd29972aa979ac2f1932be7a6a97f3ada 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -959,3 +959,47 @@ bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state)
> return hweight32(crtc_state->encoder_mask) > 1;
> }
> EXPORT_SYMBOL(drm_crtc_in_clone_mode);
> +
> +struct drm_property *
> +drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
> + const struct drm_prop_enum_list *pipelines,
> + int num_pipelines)
> +{
> + struct drm_prop_enum_list *all_pipelines;
> + struct drm_property *prop;
> + int len = 0;
> + int i;
> +
> + all_pipelines = kcalloc(num_pipelines + 1,
> + sizeof(*all_pipelines),
> + GFP_KERNEL);
> +
> + if (!all_pipelines) {
> + drm_err(dev, "failed to allocate color pipeline\n");
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + /* Create default Bypass color pipeline */
> + all_pipelines[len].type = 0;
> + all_pipelines[len].name = "Bypass";
> + len++;
> +
> + /* Add all other color pipelines */
> + for (i = 0; i < num_pipelines; i++, len++) {
> + all_pipelines[len].type = pipelines[i].type;
> + all_pipelines[len].name = pipelines[i].name;
> + }
> +
> + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
> + "COLOR_PIPELINE",
> + all_pipelines, len);
> + if (IS_ERR(prop)) {
> + kfree(all_pipelines);
> + return prop;
> + }
> +
> + drm_object_attach_property(obj, prop, 0);
> +
> + kfree(all_pipelines);
> + return prop;
> +}
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index c094092296448093c5cd192ecdc8ea9a50769c90..e3dbdcbfa385b940ec0b5476adde6146fe4afde1 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -35,6 +35,7 @@
> #ifndef __DRM_CRTC_INTERNAL_H__
> #define __DRM_CRTC_INTERNAL_H__
>
> +#include <drm/drm_property.h>
> #include <linux/err.h>
> #include <linux/types.h>
>
> @@ -79,6 +80,10 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
> int drm_crtc_register_all(struct drm_device *dev);
> void drm_crtc_unregister_all(struct drm_device *dev);
> int drm_crtc_force_disable(struct drm_crtc *crtc);
> +struct drm_property *
> +drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
> + const struct drm_prop_enum_list *pipelines,
> + int num_pipelines);
>
> struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
>
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index f6cfa8ac090c7bc49c7f276993bba7e9800da140..60dbfcab495600dd44c15260a1fa6135db59c6e2 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -1839,43 +1839,17 @@ int drm_plane_create_color_pipeline_property(struct drm_plane *plane,
> const struct drm_prop_enum_list *pipelines,
> int num_pipelines)
> {
> - struct drm_prop_enum_list *all_pipelines;
> struct drm_property *prop;
> - int len = 0;
> - int i;
> -
> - all_pipelines = kcalloc(num_pipelines + 1,
> - sizeof(*all_pipelines),
> - GFP_KERNEL);
> -
> - if (!all_pipelines) {
> - drm_err(plane->dev, "failed to allocate color pipeline\n");
> - return -ENOMEM;
> - }
>
> - /* Create default Bypass color pipeline */
> - all_pipelines[len].type = 0;
> - all_pipelines[len].name = "Bypass";
> - len++;
> -
> - /* Add all other color pipelines */
> - for (i = 0; i < num_pipelines; i++, len++) {
> - all_pipelines[len].type = pipelines[i].type;
> - all_pipelines[len].name = pipelines[i].name;
> - }
> -
> - prop = drm_property_create_enum(plane->dev, DRM_MODE_PROP_ATOMIC,
> - "COLOR_PIPELINE",
> - all_pipelines, len);
> - if (IS_ERR(prop)) {
> - kfree(all_pipelines);
> + prop = drm_common_create_color_pipeline_property(plane->dev,
> + &plane->base,
> + pipelines,
> + num_pipelines);
> + if (IS_ERR(prop))
> return PTR_ERR(prop);
> - }
>
> - drm_object_attach_property(&plane->base, prop, 0);
> plane->color_pipeline_property = prop;
>
> - kfree(all_pipelines);
> return 0;
> }
> EXPORT_SYMBOL(drm_plane_create_color_pipeline_property);
>
--
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
More information about the linux-arm-kernel
mailing list