Commit b6c1048c authored by Tomi Valkeinen's avatar Tomi Valkeinen
Browse files

drm/omap: dsi: split video mode enable/disable into separate func



Clean up the code by separating video-mode enable/disable code into
functions of their own.

Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201215104657.802264-81-tomi.valkeinen@ti.com
parent 7b93de98
Loading
Loading
Loading
Loading
+57 −44
Original line number Diff line number Diff line
@@ -3209,21 +3209,12 @@ static int dsi_configure_pins(struct dsi_data *dsi,
	return 0;
}

static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
static int dsi_enable_video_mode(struct dsi_data *dsi, int vc)
{
	struct dsi_data *dsi = to_dsi_data(dssdev);
	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
	u8 data_type;
	u16 word_count;
	int r;

	r = dsi_init_dispc(dsi);
	if (r) {
		dev_err(dsi->dev, "failed to init dispc!\n");
		return;
	}

	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
	switch (dsi->pix_fmt) {
	case MIPI_DSI_FMT_RGB888:
		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
@@ -3238,8 +3229,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
		break;
	default:
			r = -EINVAL;
			goto err_pix_fmt;
		return -EINVAL;
	}

	dsi_if_enable(dsi, false);
@@ -3255,6 +3245,37 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)

	dsi_vc_enable(dsi, vc, true);
	dsi_if_enable(dsi, true);

	return 0;
}

static void dsi_disable_video_mode(struct dsi_data *dsi, int vc)
{
	dsi_if_enable(dsi, false);
	dsi_vc_enable(dsi, vc, false);

	/* MODE, 0 = command mode */
	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);

	dsi_vc_enable(dsi, vc, true);
	dsi_if_enable(dsi, true);
}

static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
{
	struct dsi_data *dsi = to_dsi_data(dssdev);
	int r;

	r = dsi_init_dispc(dsi);
	if (r) {
		dev_err(dsi->dev, "failed to init dispc!\n");
		return;
	}

	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
		r = dsi_enable_video_mode(dsi, vc);
		if (r)
			goto err_video_mode;
	}

	r = dss_mgr_enable(&dsi->output);
@@ -3268,7 +3289,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
		dsi_if_enable(dsi, false);
		dsi_vc_enable(dsi, vc, false);
	}
err_pix_fmt:
err_video_mode:
	dsi_uninit_dispc(dsi);
	dev_err(dsi->dev, "failed to enable DSI encoder!\n");
	return;
@@ -3278,16 +3299,8 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
{
	struct dsi_data *dsi = to_dsi_data(dssdev);

	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
		dsi_if_enable(dsi, false);
		dsi_vc_enable(dsi, vc, false);

		/* MODE, 0 = command mode */
		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);

		dsi_vc_enable(dsi, vc, true);
		dsi_if_enable(dsi, true);
	}
	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
		dsi_disable_video_mode(dsi, vc);

	dss_mgr_disable(&dsi->output);