Skip to contentSkip to conversation

drm/mipi-dsi: add some generic functions for DCS

RFC PATCH In review YoungJun Cho 3 participants 3 messages Jul 31, 2014 – Aug 7, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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.

---
 drivers/gpu/drm/drm_mipi_dsi.c | 113 +++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_mipi_dsi.h     |  14 +++++
 2 files changed, 127 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +113 -0
index 6b2bbda..ba506d7 100644
@@ -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);
include/drm/drm_mipi_dsi.h +14 -0
index 1c41e49..5af2d0e 100644
@@ -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
Signature · 1 line
1.9.0
#1 lore raw
Quoted 21 lines · YoungJun Cho

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.

Quoted 7 lines
---
 drivers/gpu/drm/drm_mipi_dsi.c | 113 +++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_mipi_dsi.h     |  14 +++++
 2 files changed, 127 insertions(+)

I've applied this patch after applying some cleanup and rebasing onto some changes I've been working on. I also broke it up into two separate patches, one for the mipi_dsi_set_maximum_return_packet_size() function and another for the DCS command implementations.

I also have a bunch of other functions that I need for a panel driver that I'm working on. I'll send those out shortly.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
In reply to YoungJun Cho

Hi YoungJun, Thierry,

Quoted 8 lines · YoungJun Cho

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.

Quoted 7 lines

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.

I wonder if it wouldn't be better to make these functions inline.

Regards
Andrzej

Quoted 170 lines

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.

---
 drivers/gpu/drm/drm_mipi_dsi.c | 113 +++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_mipi_dsi.h     |  14 +++++
 2 files changed, 127 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +113 -0
index 6b2bbda..ba506d7 100644
@@ -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);
include/drm/drm_mipi_dsi.h +14 -0
index 1c41e49..5af2d0e 100644
@@ -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