Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83af0a48 authored by Benjamin Gaignard's avatar Benjamin Gaignard Committed by Daniel Vetter
Browse files

drm: sti: use late_register and early_unregister callbacks



Make sti driver use register callback to move debugfs
initialization out of sub-components creation.
This will allow to convert driver .load() to
drm_dev_alloc() and drm_dev_register().

sti_compositor bring up 2 crtc but only one debugfs init is
needed so use drm_crtc_index to do it on the first one.
This can't be done in sti_drv because only sti_compositor have
access to the devices.
It is almost the same for sti_encoder which handle multiple
encoder while one only debugfs entry is needed so add a boolean
to avoid multiple debugfs initialization

Signed-off-by: default avatarBenjamin Gaignard <benjamin.gaignard@linaro.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466514580-15194-3-git-send-email-benjamin.gaignard@linaro.org
parent a104299b
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -55,6 +55,26 @@ struct sti_compositor_data stih416_compositor_data = {
	},
};

int sti_compositor_debufs_init(struct sti_compositor *compo,
			       struct drm_minor *minor)
{
	int ret = 0, i;

	for (i = 0; compo->vid[i]; i++) {
		ret = vid_debugfs_init(compo->vid[i], minor);
		if (ret)
			return ret;
	}

	for (i = 0; compo->mixer[i]; i++) {
		ret = sti_mixer_debugfs_init(compo->mixer[i], minor);
		if (ret)
			return ret;
	}

	return 0;
}

static int sti_compositor_bind(struct device *dev,
			       struct device *master,
			       void *data)
+3 −0
Original line number Diff line number Diff line
@@ -81,4 +81,7 @@ struct sti_compositor {
	struct notifier_block vtg_vblank_nb;
};

int sti_compositor_debufs_init(struct sti_compositor *compo,
			       struct drm_minor *minor);

#endif
+12 −0
Original line number Diff line number Diff line
@@ -331,6 +331,17 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
	}
}

static int sti_crtc_late_register(struct drm_crtc *crtc)
{
	struct sti_mixer *mixer = to_sti_mixer(crtc);
	struct sti_compositor *compo = dev_get_drvdata(mixer->dev);

	if (drm_crtc_index(crtc) == 0)
		return sti_compositor_debufs_init(compo, crtc->dev->primary);

	return 0;
}

static const struct drm_crtc_funcs sti_crtc_funcs = {
	.set_config = drm_atomic_helper_set_config,
	.page_flip = drm_atomic_helper_page_flip,
@@ -339,6 +350,7 @@ static const struct drm_crtc_funcs sti_crtc_funcs = {
	.reset = drm_atomic_helper_crtc_reset,
	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
	.late_register = sti_crtc_late_register,
};

bool sti_crtc_is_main(struct drm_crtc *crtc)
+28 −4
Original line number Diff line number Diff line
@@ -329,6 +329,33 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = {
	.atomic_disable = sti_cursor_atomic_disable,
};

static void sti_cursor_destroy(struct drm_plane *drm_plane)
{
	DRM_DEBUG_DRIVER("\n");

	drm_plane_helper_disable(drm_plane);
	drm_plane_cleanup(drm_plane);
}

static int sti_cursor_late_register(struct drm_plane *drm_plane)
{
	struct sti_plane *plane = to_sti_plane(drm_plane);
	struct sti_cursor *cursor = to_sti_cursor(plane);

	return cursor_debugfs_init(cursor, drm_plane->dev->primary);
}

struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
	.update_plane = drm_atomic_helper_update_plane,
	.disable_plane = drm_atomic_helper_disable_plane,
	.destroy = sti_cursor_destroy,
	.set_property = sti_plane_set_property,
	.reset = drm_atomic_helper_plane_reset,
	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
	.late_register = sti_cursor_late_register,
};

struct drm_plane *sti_cursor_create(struct drm_device *drm_dev,
				    struct device *dev, int desc,
				    void __iomem *baseaddr,
@@ -363,7 +390,7 @@ struct drm_plane *sti_cursor_create(struct drm_device *drm_dev,

	res = drm_universal_plane_init(drm_dev, &cursor->plane.drm_plane,
				       possible_crtcs,
				       &sti_plane_helpers_funcs,
				       &sti_cursor_plane_helpers_funcs,
				       cursor_supported_formats,
				       ARRAY_SIZE(cursor_supported_formats),
				       DRM_PLANE_TYPE_CURSOR, NULL);
@@ -377,9 +404,6 @@ struct drm_plane *sti_cursor_create(struct drm_device *drm_dev,

	sti_plane_init_property(&cursor->plane, DRM_PLANE_TYPE_CURSOR);

	if (cursor_debugfs_init(cursor, drm_dev->primary))
		DRM_ERROR("CURSOR debugfs setup failed\n");

	return &cursor->plane.drm_plane;

err_plane:
+10 −8
Original line number Diff line number Diff line
@@ -404,24 +404,29 @@ sti_dvo_connector_detect(struct drm_connector *connector, bool force)
	return connector_status_disconnected;
}

static void sti_dvo_connector_destroy(struct drm_connector *connector)
static int sti_dvo_late_register(struct drm_connector *connector)
{
	struct sti_dvo_connector *dvo_connector
		= to_sti_dvo_connector(connector);
	struct sti_dvo *dvo = dvo_connector->dvo;

	if (dvo_debugfs_init(dvo, dvo->drm_dev->primary)) {
		DRM_ERROR("DVO debugfs setup failed\n");
		return -EINVAL;
	}

	drm_connector_unregister(connector);
	drm_connector_cleanup(connector);
	kfree(dvo_connector);
	return 0;
}

static const struct drm_connector_funcs sti_dvo_connector_funcs = {
	.dpms = drm_atomic_helper_connector_dpms,
	.fill_modes = drm_helper_probe_single_connector_modes,
	.detect = sti_dvo_connector_detect,
	.destroy = sti_dvo_connector_destroy,
	.destroy = drm_connector_cleanup,
	.reset = drm_atomic_helper_connector_reset,
	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
	.late_register = sti_dvo_late_register,
};

static struct drm_encoder *sti_dvo_find_encoder(struct drm_device *dev)
@@ -502,9 +507,6 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
		goto err_sysfs;
	}

	if (dvo_debugfs_init(dvo, drm_dev->primary))
		DRM_ERROR("DVO debugfs setup failed\n");

	return 0;

err_sysfs:
Loading