From: Xu YiPing <xuyiping@xxxxxxxxxxxxx> As part of refactoring the kirin driver to better support different hardware revisions, this patch adds a flag to the device specific driver data so that we can conditionally register the connectors at init. Cc: Xinliang Liu <z.liuxinliang@xxxxxxxxxxxxx> Cc: Rongrong Zou <zourongrong@xxxxxxxxx> Cc: Xinwei Kong <kong.kongxinwei@xxxxxxxxxxxxx> Cc: Chen Feng <puck.chen@xxxxxxxxxxxxx> Cc: David Airlie <airlied@xxxxxxxx> Cc: Daniel Vetter <daniel@xxxxxxxx> Cc: dri-devel <dri-devel@xxxxxxxxxxxxxxxxxxxxx> Signed-off-by: Xu YiPing <xuyiping@xxxxxxxxxxxxx> [jstultz: reworded commit message] Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx> --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 + drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 + 3 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index bdd1b00..fcc01c2 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -1076,6 +1076,7 @@ static struct drm_driver ade_driver = { }; struct kirin_drm_data ade_driver_data = { + .register_connects = false, .num_planes = ADE_CH_NUM, .prim_plane = ADE_CH1, .channel_formats = channel_formats, diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index c987b4e..5ee90d7 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -99,6 +99,40 @@ static int compare_of(struct device *dev, void *data) return dev->of_node == data; } +static int kirin_drm_connectors_register(struct drm_device *dev) +{ + struct drm_connector *connector; + struct drm_connector *failed_connector; + struct drm_connector_list_iter conn_iter; + int ret; + + mutex_lock(&dev->mode_config.mutex); + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + ret = drm_connector_register(connector); + if (ret) { + failed_connector = connector; + goto err; + } + } + drm_connector_list_iter_end(&conn_iter); + mutex_unlock(&dev->mode_config.mutex); + + return 0; + +err: + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + if (failed_connector == connector) + break; + drm_connector_unregister(connector); + } + drm_connector_list_iter_end(&conn_iter); + mutex_unlock(&dev->mode_config.mutex); + + return ret; +} + static int kirin_drm_bind(struct device *dev) { struct drm_device *drm_dev; @@ -118,8 +152,17 @@ static int kirin_drm_bind(struct device *dev) drm_fbdev_generic_setup(drm_dev, 32); + /* connectors should be registered after drm device register */ + if (driver_data->register_connects == true) { + ret = kirin_drm_connectors_register(drm_dev); + if (ret) + goto err_drm_dev_unregister; + } + return 0; +err_drm_dev_unregister: + drm_dev_unregister(drm_dev); err_kms_cleanup: kirin_drm_kms_cleanup(drm_dev); err_drm_dev_put: diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 61fb0da..8818ccf 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -43,6 +43,7 @@ struct kirin_drm_data { u32 channel_formats_cnt; int config_max_width; int config_max_height; + bool register_connects; u32 num_planes; u32 prim_plane; -- 2.7.4 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel