dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: YoungJun Cho <yj44.cho@samsung.com>
To: airlied@linux.ie, dri-devel@lists.freedesktop.org
Cc: sw0312.kim@samsung.com, a.hajda@samsung.com, kyungmin.park@samsung.com
Subject: [RFC PATCH] drm/mipi-dsi: add some generic functions for DCS
Date: Thu, 31 Jul 2014 13:14:42 +0900	[thread overview]
Message-ID: <1406780082-9237-1-git-send-email-yj44.cho@samsung.com> (raw)

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@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 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

             reply	other threads:[~2014-07-31  4:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-31  4:14 YoungJun Cho [this message]
2014-08-05 10:08 ` [RFC PATCH] drm/mipi-dsi: add some generic functions for DCS Thierry Reding
2014-08-07  6:01 ` Andrzej Hajda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1406780082-9237-1-git-send-email-yj44.cho@samsung.com \
    --to=yj44.cho@samsung.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kyungmin.park@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox