blob: 9183ffdd9c3d0e6d01447bb66fd560c035496e68 [file] [log] [blame]
Stefan Bosch48397f12020-07-10 19:07:25 +02001/* SPDX-License-Identifier: GPL-2.0+
2 *
3 * Defines for Mobile Industry Processor Interface (MIPI(R))
4 * Display Working Group standards: DSI, DCS, DBI, DPI
5 *
6 * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
7 * Copyright (C) 2006 Nokia Corporation
8 * Author: Imre Deak <imre.deak@nokia.com>
9 */
10
11#ifndef MIPI_DISPLAY_H
12#define MIPI_DISPLAY_H
13
Tom Rinidec7ea02024-05-20 13:35:03 -060014#include <linux/types.h>
15
Stefan Bosch48397f12020-07-10 19:07:25 +020016/* MIPI DSI Processor-to-Peripheral transaction types */
17enum {
18 MIPI_DSI_V_SYNC_START = 0x01,
19 MIPI_DSI_V_SYNC_END = 0x11,
20 MIPI_DSI_H_SYNC_START = 0x21,
21 MIPI_DSI_H_SYNC_END = 0x31,
22
23 MIPI_DSI_COLOR_MODE_OFF = 0x02,
24 MIPI_DSI_COLOR_MODE_ON = 0x12,
25 MIPI_DSI_SHUTDOWN_PERIPHERAL = 0x22,
26 MIPI_DSI_TURN_ON_PERIPHERAL = 0x32,
27
28 MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM = 0x03,
29 MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM = 0x13,
30 MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM = 0x23,
31
32 MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM = 0x04,
33 MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM = 0x14,
34 MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM = 0x24,
35
36 MIPI_DSI_DCS_SHORT_WRITE = 0x05,
37 MIPI_DSI_DCS_SHORT_WRITE_PARAM = 0x15,
38
39 MIPI_DSI_DCS_READ = 0x06,
40
41 MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE = 0x37,
42
43 MIPI_DSI_END_OF_TRANSMISSION = 0x08,
44
45 MIPI_DSI_NULL_PACKET = 0x09,
46 MIPI_DSI_BLANKING_PACKET = 0x19,
47 MIPI_DSI_GENERIC_LONG_WRITE = 0x29,
48 MIPI_DSI_DCS_LONG_WRITE = 0x39,
49
50 MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20 = 0x0c,
51 MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24 = 0x1c,
52 MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16 = 0x2c,
53
54 MIPI_DSI_PACKED_PIXEL_STREAM_30 = 0x0d,
55 MIPI_DSI_PACKED_PIXEL_STREAM_36 = 0x1d,
56 MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12 = 0x3d,
57
58 MIPI_DSI_PACKED_PIXEL_STREAM_16 = 0x0e,
59 MIPI_DSI_PACKED_PIXEL_STREAM_18 = 0x1e,
60 MIPI_DSI_PIXEL_STREAM_3BYTE_18 = 0x2e,
61 MIPI_DSI_PACKED_PIXEL_STREAM_24 = 0x3e,
62};
63
64/* MIPI DSI Peripheral-to-Processor transaction types */
65enum {
66 MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT = 0x02,
67 MIPI_DSI_RX_END_OF_TRANSMISSION = 0x08,
68 MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE = 0x11,
69 MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE = 0x12,
70 MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE = 0x1a,
71 MIPI_DSI_RX_DCS_LONG_READ_RESPONSE = 0x1c,
72 MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE = 0x21,
73 MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE = 0x22,
74};
75
76/* MIPI DCS commands */
77enum {
78 MIPI_DCS_NOP = 0x00,
79 MIPI_DCS_SOFT_RESET = 0x01,
80 MIPI_DCS_GET_DISPLAY_ID = 0x04,
81 MIPI_DCS_GET_RED_CHANNEL = 0x06,
82 MIPI_DCS_GET_GREEN_CHANNEL = 0x07,
83 MIPI_DCS_GET_BLUE_CHANNEL = 0x08,
84 MIPI_DCS_GET_DISPLAY_STATUS = 0x09,
85 MIPI_DCS_GET_POWER_MODE = 0x0A,
86 MIPI_DCS_GET_ADDRESS_MODE = 0x0B,
87 MIPI_DCS_GET_PIXEL_FORMAT = 0x0C,
88 MIPI_DCS_GET_DISPLAY_MODE = 0x0D,
89 MIPI_DCS_GET_SIGNAL_MODE = 0x0E,
90 MIPI_DCS_GET_DIAGNOSTIC_RESULT = 0x0F,
91 MIPI_DCS_ENTER_SLEEP_MODE = 0x10,
92 MIPI_DCS_EXIT_SLEEP_MODE = 0x11,
93 MIPI_DCS_ENTER_PARTIAL_MODE = 0x12,
94 MIPI_DCS_ENTER_NORMAL_MODE = 0x13,
95 MIPI_DCS_EXIT_INVERT_MODE = 0x20,
96 MIPI_DCS_ENTER_INVERT_MODE = 0x21,
97 MIPI_DCS_SET_GAMMA_CURVE = 0x26,
98 MIPI_DCS_SET_DISPLAY_OFF = 0x28,
99 MIPI_DCS_SET_DISPLAY_ON = 0x29,
100 MIPI_DCS_SET_COLUMN_ADDRESS = 0x2A,
101 MIPI_DCS_SET_PAGE_ADDRESS = 0x2B,
102 MIPI_DCS_WRITE_MEMORY_START = 0x2C,
103 MIPI_DCS_WRITE_LUT = 0x2D,
104 MIPI_DCS_READ_MEMORY_START = 0x2E,
105 MIPI_DCS_SET_PARTIAL_AREA = 0x30,
106 MIPI_DCS_SET_SCROLL_AREA = 0x33,
107 MIPI_DCS_SET_TEAR_OFF = 0x34,
108 MIPI_DCS_SET_TEAR_ON = 0x35,
109 MIPI_DCS_SET_ADDRESS_MODE = 0x36,
110 MIPI_DCS_SET_SCROLL_START = 0x37,
111 MIPI_DCS_EXIT_IDLE_MODE = 0x38,
112 MIPI_DCS_ENTER_IDLE_MODE = 0x39,
113 MIPI_DCS_SET_PIXEL_FORMAT = 0x3A,
114 MIPI_DCS_WRITE_MEMORY_CONTINUE = 0x3C,
115 MIPI_DCS_READ_MEMORY_CONTINUE = 0x3E,
116 MIPI_DCS_SET_TEAR_SCANLINE = 0x44,
117 MIPI_DCS_GET_SCANLINE = 0x45,
118 MIPI_DCS_READ_DDB_START = 0xA1,
119 MIPI_DCS_READ_DDB_CONTINUE = 0xA8,
120};
121
122/* MIPI DCS pixel formats */
123#define MIPI_DCS_PIXEL_FMT_24BIT 7
124#define MIPI_DCS_PIXEL_FMT_18BIT 6
125#define MIPI_DCS_PIXEL_FMT_16BIT 5
126#define MIPI_DCS_PIXEL_FMT_12BIT 3
127#define MIPI_DCS_PIXEL_FMT_8BIT 2
128#define MIPI_DCS_PIXEL_FMT_3BIT 1
129
130/* request ACK from peripheral */
131#define MIPI_DSI_MSG_REQ_ACK BIT(0)
132/* use Low Power Mode to transmit message */
133#define MIPI_DSI_MSG_USE_LPM BIT(1)
134
135/**
136 * struct mipi_dsi_msg - read/write DSI buffer
137 * @channel: virtual channel id
138 * @type: payload data type
139 * @flags: flags controlling this message transmission
140 * @tx_len: length of @tx_buf
141 * @tx_buf: data to be written
142 * @rx_len: length of @rx_buf
143 * @rx_buf: data to be read, or NULL
144 */
145struct mipi_dsi_msg {
146 u8 channel; /* virtual channel id */
147 u8 type; /* payload data type */
148 u16 flags; /* flags controlling this message transmission */
149 size_t tx_len;
150 const void *tx_buf;
151 size_t rx_len;
152 void *rx_buf;
153};
154
155/* DSI mode flags */
156
157/* video mode */
158#define MIPI_DSI_MODE_VIDEO BIT(0)
159/* video burst mode */
160#define MIPI_DSI_MODE_VIDEO_BURST BIT(1)
161/* video pulse mode */
162#define MIPI_DSI_MODE_VIDEO_SYNC_PULSE BIT(2)
163/* enable auto vertical count mode */
164#define MIPI_DSI_MODE_VIDEO_AUTO_VERT BIT(3)
165/* enable hsync-end packets in vsync-pulse and v-porch area */
166#define MIPI_DSI_MODE_VIDEO_HSE BIT(4)
167/* disable hfront-porch area */
168#define MIPI_DSI_MODE_VIDEO_HFP BIT(5)
169/* disable hback-porch area */
170#define MIPI_DSI_MODE_VIDEO_HBP BIT(6)
171/* disable hsync-active area */
172#define MIPI_DSI_MODE_VIDEO_HSA BIT(7)
173/* flush display FIFO on vsync pulse */
174#define MIPI_DSI_MODE_VSYNC_FLUSH BIT(8)
175/* disable EoT packets in HS mode */
176#define MIPI_DSI_MODE_EOT_PACKET BIT(9)
177/* device supports non-continuous clock behavior (DSI spec 5.6.1) */
178#define MIPI_DSI_CLOCK_NON_CONTINUOUS BIT(10)
179/* transmit data in low power */
180#define MIPI_DSI_MODE_LPM BIT(11) /* DSI mode flags */
181
182enum mipi_dsi_pixel_format {
183 MIPI_DSI_FMT_RGB888,
184 MIPI_DSI_FMT_RGB666,
185 MIPI_DSI_FMT_RGB666_PACKED,
186 MIPI_DSI_FMT_RGB565,
187};
188
189/**
190 * struct mipi_dsi_device - DSI peripheral device
191 * @host: DSI host for this peripheral
192 * @dev: driver model device node for this peripheral
193 * @channel: virtual channel assigned to the peripheral
194 * @format: pixel format for video mode
195 * @lanes: number of active data lanes
196 * @mode_flags: DSI operation mode related flags
197 */
198struct mipi_dsi_device {
199 unsigned int channel;
200 unsigned int lanes;
201 enum mipi_dsi_pixel_format format;
202 unsigned long mode_flags;
203 struct mipi_panel_ops *ops;
204 ssize_t (*write_buffer)(struct mipi_dsi_device *dsi,
205 const void *data, size_t len);
206};
207
208struct mipi_panel_ops {
209 int (*init)(struct mipi_dsi_device *dsi, int width, int height);
210 int (*prepare)(struct mipi_dsi_device *dsi);
211 int (*unprepare)(struct mipi_dsi_device *dsi);
212 int (*enable)(struct mipi_dsi_device *dsi);
213 int (*disable)(struct mipi_dsi_device *dsi);
214 void *private_data;
215};
216
217#endif