[RFC PATCH] drm/mipi-dsi: add some generic functions for DCS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds some generic functions for DCS like below
to standize on common APIs rather than per-driver
implementations.

mipi_dcs_enter_sleep_mode() / mipi_dcs_exit_sleep_mode()
- These are required to disable / enable all blocks inside
  the display module.

mipi_dcs_set_display_off() / mipi_dcs_set_display_on()
- These are required to stop / start displaying the image
  data on the display device.

mipi_dcs_set_tear_off() / mipi_dcs_set_tear_on()
- These are required to turn off or on the display module's
  TE output signal on the TE signal line.

mipi_dsi_set_maximum_return_packet_size()
- Although it is not related with DCS, it is required before
  using mipi_dsi_dcs_read() to specify the maximum size of
  the payload in a long packet.

Signed-off-by: YoungJun Cho <yj44.cho@xxxxxxxxxxx>
Acked-by: Inki Dae <inki.dae@xxxxxxxxxxx>
Acked-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
---
 drivers/gpu/drm/drm_mipi_dsi.c | 113 +++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_mipi_dsi.h     |  14 +++++
 2 files changed, 127 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 6b2bbda..ba506d7 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -269,6 +269,119 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, unsigned int channel,
 }
 EXPORT_SYMBOL(mipi_dsi_dcs_read);
 
+/**
+ * mipi_dsi_set_maximum_return_packet_size
+ * - specify the maximum size of the payload in a Long packet transmitted from
+ *   peripheral back to the host processor
+ * @dsi: DSI peripheral device
+ * @size: the maximum size of the payload
+ */
+int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
+						u16 size)
+{
+	const struct mipi_dsi_host_ops *ops = dsi->host->ops;
+	struct mipi_dsi_msg msg;
+
+	if (!ops || !ops->transfer)
+		return -ENOSYS;
+
+	memset(&msg, 0, sizeof(msg));
+	msg.channel = dsi->channel;
+	msg.type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE;
+	msg.tx_len = sizeof(size);
+	msg.tx_buf = (const void *)(&size);
+
+	return ops->transfer(dsi->host, &msg);
+}
+EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size);
+
+/**
+ * mipi_dcs_enter_sleep_mode - disable all unnecessary blocks inside the display
+ *                             module except interface communication
+ * @dsi: DSI peripheral device
+ */
+int mipi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi)
+{
+	u8 data = MIPI_DCS_ENTER_SLEEP_MODE;
+
+	return mipi_dsi_dcs_write(dsi, dsi->channel, (const void *)&data,
+					sizeof(data));
+}
+EXPORT_SYMBOL(mipi_dcs_enter_sleep_mode);
+
+/**
+ * mipi_dcs_exit_sleep_mode - enable all blocks inside the display module
+ * @dsi: DSI peripheral device
+ */
+int mipi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi)
+{
+	u8 data = MIPI_DCS_EXIT_SLEEP_MODE;
+
+	return mipi_dsi_dcs_write(dsi, dsi->channel, (const void *)&data,
+					sizeof(data));
+}
+EXPORT_SYMBOL(mipi_dcs_exit_sleep_mode);
+
+/**
+ * mipi_dcs_set_display_off - stop displaying the image data on the display device
+ * @dsi: DSI peripheral device
+ */
+int mipi_dcs_set_display_off(struct mipi_dsi_device *dsi)
+{
+	u8 data = MIPI_DCS_SET_DISPLAY_OFF;
+
+	return mipi_dsi_dcs_write(dsi, dsi->channel, (const void *)&data,
+					sizeof(data));
+}
+EXPORT_SYMBOL(mipi_dcs_set_display_off);
+
+/**
+ * mipi_dcs_set_display_on - start displaying the image data on the display device
+ * @dsi: DSI peripheral device
+ */
+int mipi_dcs_set_display_on(struct mipi_dsi_device *dsi)
+{
+	u8 data = MIPI_DCS_SET_DISPLAY_ON;
+
+	return mipi_dsi_dcs_write(dsi, dsi->channel, (const void *)&data,
+					sizeof(data));
+}
+EXPORT_SYMBOL(mipi_dcs_set_display_on);
+
+/**
+ * mipi_dcs_set_tear_off - turn off the display module's Tearing Effect output
+ *                         signal on the TE signal line
+ * @dsi: DSI peripheral device
+ */
+int mipi_dcs_set_tear_off(struct mipi_dsi_device *dsi)
+{
+	u8 data = MIPI_DCS_SET_TEAR_OFF;
+
+	return mipi_dsi_dcs_write(dsi, dsi->channel, (const void *)&data,
+					sizeof(data));
+}
+EXPORT_SYMBOL(mipi_dcs_set_tear_off);
+
+/**
+ * mipi_dcs_set_tear_on - turn on the display module's Tearing Effect output
+ *                        signal on the TE signal line.
+ * @dsi: DSI peripheral device
+ * @mode: the Tearing Effect output line mode
+ *  - MIPI_DCS_TEAR_MODE_VBLANK: the TE output line consists of V-Blanking
+ *                               information only
+ *  - MIPI_DCS_TEAR_MODE_VHBLANK : the TE output line consists of both
+ *                                 V-Blanking and H-Blanking information
+ */
+int mipi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
+				enum mipi_dcs_tear_mode mode)
+{
+	u8 data[2] = { MIPI_DCS_SET_TEAR_ON, mode };
+
+	return mipi_dsi_dcs_write(dsi, dsi->channel, (const void *)data,
+					sizeof(data));
+}
+EXPORT_SYMBOL(mipi_dcs_set_tear_on);
+
 static int mipi_dsi_drv_probe(struct device *dev)
 {
 	struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 1c41e49..5af2d0e 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -106,6 +106,11 @@ enum mipi_dsi_pixel_format {
 	MIPI_DSI_FMT_RGB565,
 };
 
+enum mipi_dcs_tear_mode {
+	MIPI_DCS_TEAR_MODE_VBLANK,
+	MIPI_DCS_TEAR_MODE_VHBLANK,
+};
+
 /**
  * struct mipi_dsi_device - DSI peripheral device
  * @host: DSI host for this peripheral
@@ -133,6 +138,15 @@ int mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, unsigned int channel,
 		       const void *data, size_t len);
 ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, unsigned int channel,
 			  u8 cmd, void *data, size_t len);
+int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
+						u16 size);
+int mipi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
+int mipi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
+int mipi_dcs_set_display_off(struct mipi_dsi_device *dsi);
+int mipi_dcs_set_display_on(struct mipi_dsi_device *dsi);
+int mipi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
+int mipi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
+				enum mipi_dcs_tear_mode mode);
 
 /**
  * struct mipi_dsi_driver - DSI driver
-- 
1.9.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux