From patchwork Thu Jul 31 04:14:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YoungJun Cho X-Patchwork-Id: 4653241 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7C21CC0338 for ; Thu, 31 Jul 2014 04:14:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89ADF20149 for ; Thu, 31 Jul 2014 04:14:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2ECF7200F0 for ; Thu, 31 Jul 2014 04:14:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D52166E17A; Wed, 30 Jul 2014 21:14:49 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id E23346E17A for ; Wed, 30 Jul 2014 21:14:47 -0700 (PDT) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9K00H856GMWZ10@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 31 Jul 2014 13:14:46 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.46]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id C6.B0.19786.5B2C9D35; Thu, 31 Jul 2014 13:14:45 +0900 (KST) X-AuditID: cbfee68e-b7fab6d000004d4a-83-53d9c2b5973b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 61.BA.05196.5B2C9D35; Thu, 31 Jul 2014 13:14:45 +0900 (KST) Received: from localhost.localdomain ([10.252.75.90]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N9K007LH6GINCB0@mmp2.samsung.com>; Thu, 31 Jul 2014 13:14:45 +0900 (KST) From: YoungJun Cho To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [RFC PATCH] drm/mipi-dsi: add some generic functions for DCS Date: Thu, 31 Jul 2014 13:14:42 +0900 Message-id: <1406780082-9237-1-git-send-email-yj44.cho@samsung.com> X-Mailer: git-send-email 1.9.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHLMWRmVeSWpSXmKPExsVy+t8zPd2th24GGxxtsrC4te4cq0XvuZNM Fle+vmezmHR/AovFi3sXWSzONr1ht5gx+SWbxc9d81gcODx2zrrL7rH92wNWj/vdx5k8+ras YgxgieKySUnNySxLLdK3S+DK+NXylaXgjWHFijdHmRoYn2l0MXJySAiYSOy72c4EYYtJXLi3 nq2LkYtDSGAZo8Saf19ZYIpenXwMViQkMJ1R4tQZP4iiViaJN3u/sYIk2AQ0JZ5/3AFmiwiY SnRMWgrWzCwwlVHiagtfFyMHh7CAq8TB/aIgYRYBVYlH23Ywg9i8As4Sk3a/hNolJzHl9wJ2 kPkSAs3sEh+evWCDaBCQ+Db5EAvIHAkBWYlNB5gh6iUlDq64wTKBUXABI8MqRtHUguSC4qT0 IiO94sTc4tK8dL3k/NxNjJCw7dvBePOA9SHGZKBxE5mlRJPzgWGfVxJvaGxmZGFqYmpsZG5p RpqwkjjvoodJQUIC6YklqdmpqQWpRfFFpTmpxYcYmTg4pRoY85PeFLikHFx0U2H7Nl+FGWJF Hm9Ou53aZPlg/9/C8jS+ryLtXSbTPKOL1U6+aEiQfnPRqnMSu6/p0lvsbe8FmYNt3ofkT+j9 M/Xz6UzbT1PnPnR4tvfewp38Wdn3dzQYh/CzSNfN+sApckxx7rlnjxTeqq+KiMxMef91PfuF VeXeq9SEzqucVGIpzkg01GIuKk4EACVWv/hxAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42I5/e+xoO7WQzeDDT6vM7a4te4cq0XvuZNM Fle+vmezmHR/AovFi3sXWSzONr1ht5gx+SWbxc9d81gcODx2zrrL7rH92wNWj/vdx5k8+ras YgxgiWpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wB OkRJoSwxpxQoFJBYXKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjHmPGr5StLwRvDihVvjjI1 MD7T6GLk5JAQMJF4dfIxE4QtJnHh3no2EFtIYDqjxKkzfl2MXEB2K5PEm73fWEESbAKaEs8/ 7gCzRQRMJTomLWUBsZkFpjJKXG3h62Lk4BAWcJU4uF8UJMwioCrxaNsOZhCbV8BZYtLulywQ u+QkpvxewD6BkXsBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjOCoeCa9g3FVg8UhRgEO RiUe3h8mN4OFWBPLiitzDzFKcDArifAeXAAU4k1JrKxKLcqPLyrNSS0+xGgKtH0is5Rocj4w YvNK4g2NTcyMLI3MjE3MjY2VxHkPtloHCgmkJ5akZqemFqQWwfQxcXBKNTDqithOuZXMnCRS utrJfWr+CcuyXoHNS76WXDpxSoCv7OHvPUHGAlahASXyN5aLz14ZEn6Z77uawso2A6uWvI7L PEdyuFpfHeKpP/JE4HSoxUOzD7vXtnge2spQvcP58Ab2uD83n95jc3GvTg//deD/PVPueycv BUwJ9z8jVNww6/La+Mg9GbOVWIozEg21mIuKEwFIux06oAIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: sw0312.kim@samsung.com, a.hajda@samsung.com, kyungmin.park@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Inki Dae Acked-by: Kyungmin Park --- 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