Message ID | 20200415074034.175360-53-daniel.vetter@ffwll.ch (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | devm_drm_dev_alloc, v2 | expand |
On Wed, Apr 15, 2020 at 09:40:27AM +0200, Daniel Vetter wrote: > That way we can get rid of this final piece of init code, and use the > simple pipe helpers as intended. > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > Cc: Alexey Brodkin <abrodkin@synopsys.com> One nit below, with this addressed: Acked-by: Sam Ravnborg <sam@ravnborg.org> > --- > drivers/gpu/drm/arc/arcpgu_drv.c | 51 ++++++++++---------------------- > 1 file changed, 16 insertions(+), 35 deletions(-) > > diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c > index b0c941d91545..857812f25bec 100644 > --- a/drivers/gpu/drm/arc/arcpgu_drv.c > +++ b/drivers/gpu/drm/arc/arcpgu_drv.c > @@ -95,32 +95,11 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = { > .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, > }; > > -static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np) > +static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector) > { > - struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); > - struct drm_encoder *encoder; > - struct drm_connector *connector; > - int ret; > - > - encoder = &arcpgu->pipe.encoder; > - > - connector = &arcpgu->sim_conn; > drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs); > - > - ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, > + return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, > DRM_MODE_CONNECTOR_VIRTUAL); Please fix indent. > - if (ret < 0) { > - dev_err(drm->dev, "failed to initialize drm connector\n"); > - return ret; > - } > - > - ret = drm_connector_attach_encoder(connector, encoder); > - if (ret < 0) { > - dev_err(drm->dev, "could not attach connector to encoder\n"); > - return ret; > - } > - > - return 0; > } > > #define ENCODE_PGU_XY(x, y) ((((x) - 1) << 16) | ((y) - 1)) > @@ -273,6 +252,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) > { > struct platform_device *pdev = to_platform_device(arcpgu->drm.dev); > struct device_node *encoder_node = NULL, *endpoint_node = NULL; > + struct drm_connector *connector = NULL; > struct drm_device *drm = &arcpgu->drm; > struct resource *res; > int ret; > @@ -307,13 +287,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) > if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32))) > return -ENODEV; > > - ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, > - arc_pgu_supported_formats, > - ARRAY_SIZE(arc_pgu_supported_formats), > - NULL, NULL); > - if (ret) > - return ret; > - > /* > * There is only one output port inside each device. It is linked with > * encoder endpoint. > @@ -322,8 +295,21 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) > if (endpoint_node) { > encoder_node = of_graph_get_remote_port_parent(endpoint_node); > of_node_put(endpoint_node); > + } else { > + connector = &arcpgu->sim_conn; > + dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); > + ret = arcpgu_drm_sim_init(drm, connector); > + if (ret < 0) > + return ret; > } > > + ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, > + arc_pgu_supported_formats, > + ARRAY_SIZE(arc_pgu_supported_formats), > + NULL, connector); > + if (ret) > + return ret; > + > if (encoder_node) { > struct drm_bridge *bridge; > > @@ -335,11 +321,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) > ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge); > if (ret) > return ret; > - } else { > - dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); > - ret = arcpgu_drm_sim_init(drm, NULL); > - if (ret < 0) > - return ret; > } > > drm_mode_config_reset(drm); > -- > 2.25.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c index b0c941d91545..857812f25bec 100644 --- a/drivers/gpu/drm/arc/arcpgu_drv.c +++ b/drivers/gpu/drm/arc/arcpgu_drv.c @@ -95,32 +95,11 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np) +static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector) { - struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); - struct drm_encoder *encoder; - struct drm_connector *connector; - int ret; - - encoder = &arcpgu->pipe.encoder; - - connector = &arcpgu->sim_conn; drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs); - - ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, + return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); - if (ret < 0) { - dev_err(drm->dev, "failed to initialize drm connector\n"); - return ret; - } - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret < 0) { - dev_err(drm->dev, "could not attach connector to encoder\n"); - return ret; - } - - return 0; } #define ENCODE_PGU_XY(x, y) ((((x) - 1) << 16) | ((y) - 1)) @@ -273,6 +252,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) { struct platform_device *pdev = to_platform_device(arcpgu->drm.dev); struct device_node *encoder_node = NULL, *endpoint_node = NULL; + struct drm_connector *connector = NULL; struct drm_device *drm = &arcpgu->drm; struct resource *res; int ret; @@ -307,13 +287,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32))) return -ENODEV; - ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, - arc_pgu_supported_formats, - ARRAY_SIZE(arc_pgu_supported_formats), - NULL, NULL); - if (ret) - return ret; - /* * There is only one output port inside each device. It is linked with * encoder endpoint. @@ -322,8 +295,21 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) if (endpoint_node) { encoder_node = of_graph_get_remote_port_parent(endpoint_node); of_node_put(endpoint_node); + } else { + connector = &arcpgu->sim_conn; + dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); + ret = arcpgu_drm_sim_init(drm, connector); + if (ret < 0) + return ret; } + ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, + arc_pgu_supported_formats, + ARRAY_SIZE(arc_pgu_supported_formats), + NULL, connector); + if (ret) + return ret; + if (encoder_node) { struct drm_bridge *bridge; @@ -335,11 +321,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu) ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge); if (ret) return ret; - } else { - dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); - ret = arcpgu_drm_sim_init(drm, NULL); - if (ret < 0) - return ret; } drm_mode_config_reset(drm);
That way we can get rid of this final piece of init code, and use the simple pipe helpers as intended. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Cc: Alexey Brodkin <abrodkin@synopsys.com> --- drivers/gpu/drm/arc/arcpgu_drv.c | 51 ++++++++++---------------------- 1 file changed, 16 insertions(+), 35 deletions(-)