From: "NĂcolas F. R. A. Prado" <[email protected]> In preparation for sharing the initialization code for the color pipeline property between pre-blend (plane) and post-blend (crtc) color pipelines, factor out the common initialization to a separate function.
Signed-off-by: NĂcolas F. R. A. Prado <[email protected]> Co-developed-by: Ariel D'Alessandro <[email protected]> Signed-off-by: Ariel D'Alessandro <[email protected]> Reviewed-by: Louis Chauvet <[email protected]> --- drivers/gpu/drm/drm_plane.c | 35 ++++----------------------------- drivers/gpu/drm/drm_property.c | 44 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_property.h | 5 +++++ 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index bed2562bf911b..3d7324757d7b2 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1839,43 +1839,16 @@ 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_color_pipeline(plane->dev, &plane->base, + pipelines, num_pipelines); + if (IS_ERR(prop)) + return PTR_ERR(prop); - prop = drm_property_create_enum(plane->dev, DRM_MODE_PROP_ATOMIC, - "COLOR_PIPELINE", - all_pipelines, len); - if (!prop) { - kfree(all_pipelines); - return -ENOMEM; - } - 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); diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c index 596272149a359..cc2a1422599ac 100644 --- a/drivers/gpu/drm/drm_property.c +++ b/drivers/gpu/drm/drm_property.c @@ -997,3 +997,47 @@ void drm_property_change_valid_put(struct drm_property *property, } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) drm_property_blob_put(obj_to_blob(ref)); } + +struct drm_property * +drm_property_create_color_pipeline(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 (!prop) { + kfree(all_pipelines); + return ERR_PTR(-ENOMEM); + } + + drm_object_attach_property(obj, prop, 0); + + kfree(all_pipelines); + return prop; +} diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h index 082f29156b3e3..3acf340635226 100644 --- a/include/drm/drm_property.h +++ b/include/drm/drm_property.h @@ -296,6 +296,11 @@ bool drm_property_replace_blob(struct drm_property_blob **blob, struct drm_property_blob *drm_property_blob_get(struct drm_property_blob *blob); void drm_property_blob_put(struct drm_property_blob *blob); +struct drm_property * +drm_property_create_color_pipeline(struct drm_device *dev, struct drm_mode_object *obj, + const struct drm_prop_enum_list *pipelines, + int num_pipelines); + /** * drm_property_find - find property object * @dev: DRM device -- 2.51.0
