drm/atmel-hlcdc: make more use of helpers
v2 cover drm/atmel-hlcdc: make more use of helpers
Hi,
This set of patches is mostly about using available helpers when possible to simplify the code and ease the maintenance.
There is a dependency on "drm/panel: simple: restore connector_type fallback", otherwise the atmel-hlcdc driver may fail during the probe.
---
Changes in v2:
- Fix patch 5 warning about uninitialized use of ret.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Ludovic Desroches (8):
drm/atmel-hlcdc: use managed device resources for the display controller drm/atmel-hlcdc: add support for the nomodeset kernel parameter drm/atmel-hlcdc: use drmm_simple_encoder_alloc() drm/atmel-hlcdc: use drm_crtc_mask()
drm/atmel-hlcdc: use devm_drm_of_get_bridge() drm/atmel-hlcdc: use drmm_crtc_alloc_with_planes() drm/atmel-hlcdc: use drmm_universal_plane_alloc() drm/atmel-hlcdc: destroy properly the plane state in the reset callback
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 32 ++--------- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 40 +++++++------ drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 1 + drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 50 +++++----------- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 73 +++++++++++------------- 5 files changed, 75 insertions(+), 121 deletions(-)
---
base-commit: 88cbd8ac379cf5ce68b7efcfd4d1484a6871ee0b
change-id: 20251121-lcd_cleanup_mainline-b6acc75b5a09
Best regards,
Signature · 1 line
Ludovic Desroches <[email protected]>
PATCH v2 1/8 drm/atmel-hlcdc: use managed device resources for the display controller
Take benefit of managed device resources to reduce the risk of memory leak and to simplify error paths.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 25 ++++++++++++------------- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 1 + 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +12 -13
@@ -751,11 +751,16 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)return 0 ; } +static struct atmel_hlcdc_dc *atmel_hlcdc_dc_of_dev (struct drm_device *dev) +{ + return container_of(dev, struct atmel_hlcdc_dc, dev); +} +static int atmel_hlcdc_dc_load (struct drm_device *dev) {struct platform_device *pdev =to_platform_device (dev->dev);const struct of_device_id *match; -struct atmel_hlcdc_dc *dc; +struct atmel_hlcdc_dc *dc =atmel_hlcdc_dc_of_dev (dev);int ret; match =of_match_node (atmel_hlcdc_of_match, dev->dev->parent->of_node);
@@ -769,10 +774,6 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)return -EINVAL ; } - dc =devm_kzalloc (dev->dev,sizeof (*dc),GFP_KERNEL ); -if (!dc) -return -ENOMEM ; - dc->desc = match->data; dc->hlcdc =dev_get_drvdata (dev->dev->parent); dev->dev_private = dc;
@@ -853,16 +854,18 @@ static const struct drm_driver atmel_hlcdc_dc_driver = {static int atmel_hlcdc_dc_drm_probe (struct platform_device *pdev) { +struct atmel_hlcdc_dc *dc;struct drm_device *ddev;int ret; - ddev =drm_dev_alloc (&atmel_hlcdc_dc_driver, &pdev->dev); -if (IS_ERR (ddev)) -return PTR_ERR (ddev); + dc = devm_drm_dev_alloc(&pdev->dev, &atmel_hlcdc_dc_driver, struct atmel_hlcdc_dc, dev); +if (IS_ERR (dc)) +return PTR_ERR (dc); + ddev = &dc->dev; ret =atmel_hlcdc_dc_load (ddev);if (ret) - goto err_put; +return ret; ret =drm_dev_register (ddev,0 );if (ret)
@@ -875,9 +878,6 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev) err_unload:atmel_hlcdc_dc_unload (ddev); -err_put: -drm_dev_put (ddev); -return ret; }
@@ -887,7 +887,6 @@ static void atmel_hlcdc_dc_drm_remove(struct platform_device *pdev)drm_dev_unregister (ddev);atmel_hlcdc_dc_unload (ddev); -drm_dev_put (ddev); }static void atmel_hlcdc_dc_drm_shutdown (struct platform_device *pdev)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h +1 -0
@@ -350,6 +350,7 @@ struct atmel_hlcdc_dc {struct dma_pool *dscrpool;struct atmel_hlcdc *hlcdc;struct drm_crtc *crtc; +struct drm_device dev;struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS ];struct {u32 imr;
Signature · 1 line
2.51.0
PATCH v2 2/8 drm/atmel-hlcdc: add support for the nomodeset kernel parameter
In reply to Ludovic DesrochesAccording to Documentation/admin-guide/kernel-parameters.txt, this parameter can be used to disable kernel modesetting.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +3 -0
@@ -858,6 +858,9 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)struct drm_device *ddev;int ret; +if (drm_firmware_drivers_only ()) +return -ENODEV ; + dc = devm_drm_dev_alloc(&pdev->dev, &atmel_hlcdc_dc_driver, struct atmel_hlcdc_dc, dev);if (IS_ERR (dc))return PTR_ERR (dc);
Signature · 1 line
2.51.0
PATCH v2 3/8 drm/atmel-hlcdc: use drmm_simple_encoder_alloc()
In reply to Ludovic DesrochesSimplify the code using drmm_simple_encoder_alloc to handle allocation and initialization at once.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 27 ++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c +9 -18
@@ -73,22 +73,19 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)struct drm_bridge *bridge;int ret; - ep =of_graph_get_endpoint_by_regs (dev->dev->of_node,0 , endpoint); -if (!ep) -return -ENODEV ; - ret =drm_of_find_panel_or_bridge (dev->dev->of_node,0 , endpoint, &panel, &bridge); -if (ret) { -of_node_put (ep); +if (ret)return ret; - } - output =devm_kzalloc (dev->dev,sizeof (*output),GFP_KERNEL ); -if (!output) { -of_node_put (ep); -return -ENOMEM ; - } + output = drmm_simple_encoder_alloc(dev, struct atmel_hlcdc_rgb_output, + encoder,DRM_MODE_ENCODER_NONE ); +if (IS_ERR (output)) +return PTR_ERR (output); + + ep =of_graph_get_endpoint_by_regs (dev->dev->of_node,0 , endpoint); +if (!ep) +return -ENODEV ; output->bus_fmt =atmel_hlcdc_of_bus_fmt (ep);of_node_put (ep);
@@ -97,10 +94,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)return -EINVAL ; } - ret =drm_simple_encoder_init (dev, &output->encoder, -DRM_MODE_ENCODER_NONE ); -if (ret) -return ret; output->encoder.possible_crtcs =0x1 ;
@@ -120,8 +113,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)drm_panel_bridge_remove (bridge); } -drm_encoder_cleanup (&output->encoder); -return ret; }
Signature · 1 line
2.51.0
PATCH v2 4/8 drm/atmel-hlcdc: use drm_crtc_mask()
In reply to Ludovic DesrochesPrefer using the drm_crtc_mask() helper instead of a raw value. It involves reordering components initialization as we need a valid crtc.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 12 ++++++------ drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +6 -6
@@ -723,12 +723,6 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)drm_mode_config_init (dev); - ret =atmel_hlcdc_create_outputs (dev); -if (ret) { -drm_err (dev,"failed to create HLCDC outputs: %d\n" , ret); -return ret; - } - ret =atmel_hlcdc_create_planes (dev);if (ret) {drm_err (dev,"failed to create planes: %d\n" , ret);
@@ -741,6 +735,12 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)return ret; } + ret =atmel_hlcdc_create_outputs (dev); +if (ret) { +drm_err (dev,"failed to create HLCDC outputs: %d\n" , ret); +return ret; + } + dev->mode_config.min_width = dc->desc->min_width; dev->mode_config.min_height = dc->desc->min_height; dev->mode_config.max_width = dc->desc->max_width;
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c +3 -1
@@ -71,6 +71,8 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)struct device_node *ep;struct drm_panel *panel;struct drm_bridge *bridge; +struct atmel_hlcdc_dc *dc = dev->dev_private; +struct drm_crtc *crtc = dc->crtc;int ret; ret = drm_of_find_panel_or_bridge(dev->dev->of_node, 0, endpoint,
@@ -95,7 +97,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint) } - output->encoder.possible_crtcs =0x1 ;if (panel) { bridge = drm_panel_bridge_add_typed(panel,
@@ -103,6 +104,7 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)if (IS_ERR (bridge))return PTR_ERR (bridge); } + output->encoder.possible_crtcs =drm_crtc_mask (crtc);if (bridge) { ret =drm_bridge_attach (&output->encoder, bridge,NULL ,0 );
Signature · 1 line
2.51.0
PATCH v2 5/8 drm/atmel-hlcdc: use devm_drm_of_get_bridge()
In reply to Ludovic DesrochesGet rid of drm_of_find_panel_or_bridge() as it is deprecated and use devm_drm_of_get_bridge() instead.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 25 +++++------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c +5 -20
@@ -69,16 +69,14 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint) {struct atmel_hlcdc_rgb_output *output;struct device_node *ep; -struct drm_panel *panel;struct drm_bridge *bridge;struct atmel_hlcdc_dc *dc = dev->dev_private;struct drm_crtc *crtc = dc->crtc; -int ret; +int ret =0 ; - ret =drm_of_find_panel_or_bridge (dev->dev->of_node,0 , endpoint, - &panel, &bridge); -if (ret) -return ret; + bridge =devm_drm_of_get_bridge (dev->dev, dev->dev->of_node,0 , endpoint); +if (IS_ERR (bridge)) +return PTR_ERR (bridge); output = drmm_simple_encoder_alloc(dev, struct atmel_hlcdc_rgb_output, encoder,DRM_MODE_ENCODER_NONE );
@@ -97,23 +95,10 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint) } - -if (panel) { - bridge =drm_panel_bridge_add_typed (panel, - DRM_MODE_CONNECTOR_Unknown); -if (IS_ERR (bridge)) -return PTR_ERR (bridge); - } output->encoder.possible_crtcs =drm_crtc_mask (crtc); -if (bridge) { +if (bridge) ret =drm_bridge_attach (&output->encoder, bridge,NULL ,0 ); -if (!ret) -return 0 ; - -if (panel) -drm_panel_bridge_remove (bridge); - }return ret; }
Signature · 1 line
2.51.0
Re: [PATCH v2 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge()
Quoted 4 lines · Ludovic Desroches
Get rid of
drm_of_find_panel_or_bridge()as it is deprecated and usedevm_drm_of_get_bridge()instead.Signed-off-by Ludovic Desroches <[email protected]>
Quoted 55 lines
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 25 +++++------------------- 1 file changed, 5 insertions(+), 20 deletions(-)drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c +5
-20@@ -69,16 +69,14 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint) {struct atmel_hlcdc_rgb_output *output;struct device_node *ep; -struct drm_panel *panel;struct drm_bridge *bridge;struct atmel_hlcdc_dc *dc = dev->dev_private;struct drm_crtc *crtc = dc->crtc; -int ret; +int ret =0 ; - ret =drm_of_find_panel_or_bridge (dev->dev->of_node,0 , endpoint, - &panel, &bridge); -if (ret) -return ret; + bridge =devm_drm_of_get_bridge (dev->dev, dev->dev->of_node,0 , endpoint); +if (IS_ERR (bridge)) +return PTR_ERR (bridge); output = drmm_simple_encoder_alloc(dev, struct atmel_hlcdc_rgb_output, encoder,DRM_MODE_ENCODER_NONE );@@ -97,23 +95,10 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint) } - -if (panel) { - bridge =drm_panel_bridge_add_typed (panel, - DRM_MODE_CONNECTOR_Unknown); -if (IS_ERR (bridge)) -return PTR_ERR (bridge); - } output->encoder.possible_crtcs =drm_crtc_mask (crtc); -if (bridge) { +if (bridge) ret =drm_bridge_attach (&output->encoder, bridge,NULL ,0 ); -if (!ret) -return 0 ; - -if (panel) -drm_panel_bridge_remove (bridge); - }return ret; }
Signature · 2 lines
Thanks and Regards, Manikandan M.
PATCH v2 6/8 drm/atmel-hlcdc: use drmm_crtc_alloc_with_planes()
In reply to Ludovic DesrochesUse drmm_crtc_alloc_with_planes() to simplify the code. As we no longer have to take care about cleanup, we can get rid of atmel_hlcdc_crtc_destroy().
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 32 +++++--------------------- 1 file changed, 6 insertions(+), 26 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +6 -26
@@ -509,14 +509,6 @@ static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = { .atomic_disable = atmel_hlcdc_crtc_atomic_disable, }; -static void atmel_hlcdc_crtc_destroy (struct drm_crtc *c) -{ -struct atmel_hlcdc_crtc *crtc =drm_crtc_to_atmel_hlcdc_crtc (c); - -drm_crtc_cleanup (c); -kfree (crtc); -} -static void atmel_hlcdc_crtc_finish_page_flip (struct atmel_hlcdc_crtc *crtc) {struct drm_device *dev = crtc->base.dev;
@@ -607,7 +599,6 @@ static void atmel_hlcdc_crtc_disable_vblank(struct drm_crtc *c)static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = { .page_flip = drm_atomic_helper_page_flip, .set_config = drm_atomic_helper_set_config, - .destroy = atmel_hlcdc_crtc_destroy, .reset = atmel_hlcdc_crtc_reset, .atomic_duplicate_state = atmel_hlcdc_crtc_duplicate_state, .atomic_destroy_state = atmel_hlcdc_crtc_destroy_state,
@@ -620,15 +611,8 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)struct atmel_hlcdc_plane *primary =NULL , *cursor =NULL ;struct atmel_hlcdc_dc *dc = dev->dev_private;struct atmel_hlcdc_crtc *crtc; -int ret;int i; - crtc =kzalloc (sizeof (*crtc),GFP_KERNEL ); -if (!crtc) -return -ENOMEM ; - - crtc->dc = dc; -for (i =0 ; i <ATMEL_HLCDC_MAX_LAYERS ; i++) {if (!dc->layers[i])continue ;
@@ -646,13 +630,13 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)break ; } } + crtc = drmm_crtc_alloc_with_planes(dev, struct atmel_hlcdc_crtc, base, + &primary->base, &cursor->base, &atmel_hlcdc_crtc_funcs, +NULL ); +if (IS_ERR (crtc)) +return PTR_ERR (crtc); - ret =drm_crtc_init_with_planes (dev, &crtc->base, &primary->base, - &cursor->base, &atmel_hlcdc_crtc_funcs, -NULL ); -if (ret <0 ) - goto fail; - + crtc->dc = dc; crtc->id =drm_crtc_index (&crtc->base);for (i =0 ; i <ATMEL_HLCDC_MAX_LAYERS ; i++) {
@@ -674,8 +658,4 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev) dc->crtc = &crtc->base;return 0 ; - -fail: -atmel_hlcdc_crtc_destroy (&crtc->base); -return ret; }
Signature · 1 line
2.51.0
PATCH v2 7/8 drm/atmel-hlcdc: use drmm_universal_plane_alloc()
In reply to Ludovic DesrochesUse the drmm_universal_plane_alloc() helper to simplify the code. Using it, we no longer need to register the destroy callback for drm_plane_funcs.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +7 -14
@@ -1225,7 +1225,6 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,static const struct drm_plane_funcs layer_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = drm_plane_cleanup, .reset = atmel_hlcdc_plane_reset, .atomic_duplicate_state = atmel_hlcdc_plane_atomic_duplicate_state, .atomic_destroy_state = atmel_hlcdc_plane_atomic_destroy_state,
@@ -1239,12 +1238,6 @@ static int atmel_hlcdc_plane_create(struct drm_device *dev,enum drm_plane_type type;int ret; - plane =devm_kzalloc (dev->dev,sizeof (*plane),GFP_KERNEL ); -if (!plane) -return -ENOMEM ; - -atmel_hlcdc_layer_init (&plane->layer, desc, dc->hlcdc->regmap); -if (desc->type ==ATMEL_HLCDC_BASE_LAYER ) type =DRM_PLANE_TYPE_PRIMARY ;else if (desc->type ==ATMEL_HLCDC_CURSOR_LAYER )
@@ -1252,13 +1245,13 @@ static int atmel_hlcdc_plane_create(struct drm_device *dev,else type =DRM_PLANE_TYPE_OVERLAY ; - ret =drm_universal_plane_init (dev, &plane->base,0 , - &layer_plane_funcs, - desc->formats->formats, - desc->formats->nformats, -NULL , type,NULL ); -if (ret) -return ret; + plane = drmm_universal_plane_alloc(dev, struct atmel_hlcdc_plane, base, 0, + &layer_plane_funcs, desc->formats->formats, + desc->formats->nformats,NULL , type,NULL ); +if (IS_ERR (plane)) +return PTR_ERR (plane); + +atmel_hlcdc_layer_init (&plane->layer, desc, dc->hlcdc->regmap);drm_plane_helper_add (&plane->base, &atmel_hlcdc_layer_plane_helper_funcs);
Signature · 1 line
2.51.0
PATCH v2 8/8 drm/atmel-hlcdc: destroy properly the plane state in the reset callback
In reply to Ludovic DesrochesIf there is a plane state to destroy when doing a plane reset, destroy it using the atmel_hlcdc_plane_destroy_state() function. So we call __drm_atomic_helper_plane_destroy_state() and avoid code duplication.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 52 ++++++++++++------------- 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +26 -26
@@ -1155,32 +1155,6 @@ static int atmel_hlcdc_plane_alloc_dscrs(struct drm_plane *p,return -ENOMEM ; } -static void atmel_hlcdc_plane_reset (struct drm_plane *p) -{ -struct atmel_hlcdc_plane_state *state; - -if (p->state) { - state =drm_plane_state_to_atmel_hlcdc_plane_state (p->state); - -if (state->base.fb) -drm_framebuffer_put (state->base.fb); - -kfree (state); - p->state =NULL ; - } - - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (state) { -if (atmel_hlcdc_plane_alloc_dscrs (p, state)) { -kfree (state); -drm_err (p->dev, -"Failed to allocate initial plane state\n" ); -return ; - } -__drm_atomic_helper_plane_reset (p, &state->base); - } -} -static struct drm_plane_state *atmel_hlcdc_plane_atomic_duplicate_state (struct drm_plane *p) {
@@ -1222,6 +1196,32 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,kfree (state); } +static void atmel_hlcdc_plane_reset (struct drm_plane *p) +{ +struct atmel_hlcdc_plane_state *state; +struct atmel_hlcdc_dc *dc = p->dev->dev_private; +struct atmel_hlcdc_plane *plane =drm_plane_to_atmel_hlcdc_plane (p); + +if (p->state) { +atmel_hlcdc_plane_atomic_destroy_state (p, p->state); + p->state =NULL ; + } + + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (state) { +if (atmel_hlcdc_plane_alloc_dscrs (p, state)) { +kfree (state); +drm_err (p->dev, +"Failed to allocate initial plane state\n" ); +return ; + } +__drm_atomic_helper_plane_reset (p, &state->base); + } + +if (plane->layer.desc->layout.csc) + dc->desc->ops->lcdc_csc_init (plane, plane->layer.desc); +} +static const struct drm_plane_funcs layer_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane,
Signature · 1 line
2.51.0
Re: [PATCH v2 8/8] drm/atmel-hlcdc: destroy properly the plane state in the reset callback
Quoted 5 lines · Ludovic Desroches
If there is a plane state to destroy when doing a plane reset, destroy it using the
atmel_hlcdc_plane_destroy_state()function. So we call__drm_atomic_helper_plane_destroy_state()and avoid code duplication.Signed-off-by Ludovic Desroches <[email protected]>
Quoted 75 lines
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 52 ++++++++++++------------- 1 file changed, 26 insertions(+), 26 deletions(-)drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +26
-26@@ -1155,32 +1155,6 @@ static int atmel_hlcdc_plane_alloc_dscrs(struct drm_plane *p,return -ENOMEM ; } -static void atmel_hlcdc_plane_reset (struct drm_plane *p) -{ -struct atmel_hlcdc_plane_state *state; - -if (p->state) { - state =drm_plane_state_to_atmel_hlcdc_plane_state (p->state); - -if (state->base.fb) -drm_framebuffer_put (state->base.fb); - -kfree (state); - p->state =NULL ; - } - - state =kzalloc (sizeof (*state),GFP_KERNEL ); -if (state) { -if (atmel_hlcdc_plane_alloc_dscrs (p, state)) { -kfree (state); -drm_err (p->dev, -"Failed to allocate initial plane state\n" ); -return ; - } -__drm_atomic_helper_plane_reset (p, &state->base); - } -} -static struct drm_plane_state *atmel_hlcdc_plane_atomic_duplicate_state (struct drm_plane *p) {@@ -1222,6 +1196,32 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,kfree (state); } +static void atmel_hlcdc_plane_reset (struct drm_plane *p) +{ +struct atmel_hlcdc_plane_state *state; +struct atmel_hlcdc_dc *dc = p->dev->dev_private; +struct atmel_hlcdc_plane *plane =drm_plane_to_atmel_hlcdc_plane (p); + +if (p->state) { +atmel_hlcdc_plane_atomic_destroy_state (p, p->state); + p->state =NULL ; + } + + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (state) { +if (atmel_hlcdc_plane_alloc_dscrs (p, state)) { +kfree (state); +drm_err (p->dev, +"Failed to allocate initial plane state\n" ); +return ; + } +__drm_atomic_helper_plane_reset (p, &state->base); + } + +if (plane->layer.desc->layout.csc) + dc->desc->ops->lcdc_csc_init (plane, plane->layer.desc); +} +static const struct drm_plane_funcs layer_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane,
Signature · 2 lines
Thanks and Regards, Manikandan M.
Quoted 9 lines · Ludovic Desroches
Hi,
This set of patches is mostly about using available helpers when possible to simplify the code and ease the maintenance.
There is a dependency on "drm/panel: simple: restore
connector_typefallback", otherwise the atmel-hlcdc driver may fail during the probe.Signed-off-by Ludovic Desroches <[email protected]>
Applied to drm-misc-next.
Thanks!
Quoted 27 lines
---
Changes in v2:
- Fix patch 5 warning about uninitialized use of ret.
- Link to v1: https://lore.kernel.org/r/[email protected]---
Ludovic Desroches (8):
drm/atmel-hlcdc: use managed device resources for the display controller drm/atmel-hlcdc: add support for the nomodeset kernel parameter drm/atmel-hlcdc: usedrmm_simple_encoder_alloc()drm/atmel-hlcdc: usedrm_crtc_mask()
drm/atmel-hlcdc: usedevm_drm_of_get_bridge()drm/atmel-hlcdc: usedrmm_crtc_alloc_with_planes()drm/atmel-hlcdc: usedrmm_universal_plane_alloc()drm/atmel-hlcdc: destroy properly the plane state in the reset callbackdrivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 32 ++--------- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 40 +++++++------ drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 1 + drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 50 +++++----------- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 73 +++++++++++------------- 5 files changed, 75 insertions(+), 121 deletions(-)---
base-commit:88cbd8ac379cf5ce68b7efcfd4d1484a6871ee0b
change-id: 20251121-lcd_cleanup_mainline-b6acc75b5a09Best regards,
Signature · 2 lines
Thanks and Regards, Manikandan M.