Rev 6084 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6084 | Rev 6088 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * MIPI DSI Bus |
2 | * MIPI DSI Bus |
3 | * |
3 | * |
4 | * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd. |
4 | * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd. |
5 | * Andrzej Hajda |
5 | * Andrzej Hajda |
6 | * |
6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * Permission is hereby granted, free of charge, to any person obtaining a |
8 | * copy of this software and associated documentation files (the |
8 | * copy of this software and associated documentation files (the |
9 | * "Software"), to deal in the Software without restriction, including |
9 | * "Software"), to deal in the Software without restriction, including |
10 | * without limitation the rights to use, copy, modify, merge, publish, |
10 | * without limitation the rights to use, copy, modify, merge, publish, |
11 | * distribute, sub license, and/or sell copies of the Software, and to |
11 | * distribute, sub license, and/or sell copies of the Software, and to |
12 | * permit persons to whom the Software is furnished to do so, subject to |
12 | * permit persons to whom the Software is furnished to do so, subject to |
13 | * the following conditions: |
13 | * the following conditions: |
14 | * |
14 | * |
15 | * The above copyright notice and this permission notice (including the |
15 | * The above copyright notice and this permission notice (including the |
16 | * next paragraph) shall be included in all copies or substantial portions |
16 | * next paragraph) shall be included in all copies or substantial portions |
17 | * of the Software. |
17 | * of the Software. |
18 | * |
18 | * |
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
22 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
22 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
23 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
23 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
24 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
24 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
26 | */ |
26 | */ |
27 | 27 | ||
28 | #include |
28 | #include |
29 | #include |
29 | #include |
30 | 30 | ||
31 | #include |
31 | #include |
32 | #include |
32 | #include |
33 | //#include |
33 | //#include |
34 | #include |
34 | #include |
35 | //#include |
35 | #include |
36 | 36 | ||
37 | #include |
37 | #include |
38 | 38 | ||
39 | 39 | ||
40 | /** |
40 | /** |
41 | * mipi_dsi_attach - attach a DSI device to its DSI host |
41 | * mipi_dsi_attach - attach a DSI device to its DSI host |
42 | * @dsi: DSI peripheral |
42 | * @dsi: DSI peripheral |
43 | */ |
43 | */ |
44 | int mipi_dsi_attach(struct mipi_dsi_device *dsi) |
44 | int mipi_dsi_attach(struct mipi_dsi_device *dsi) |
45 | { |
45 | { |
46 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; |
46 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; |
47 | 47 | ||
48 | if (!ops || !ops->attach) |
48 | if (!ops || !ops->attach) |
49 | return -ENOSYS; |
49 | return -ENOSYS; |
50 | 50 | ||
51 | return ops->attach(dsi->host, dsi); |
51 | return ops->attach(dsi->host, dsi); |
52 | } |
52 | } |
53 | EXPORT_SYMBOL(mipi_dsi_attach); |
53 | EXPORT_SYMBOL(mipi_dsi_attach); |
54 | 54 | ||
55 | static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi, |
55 | static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi, |
56 | struct mipi_dsi_msg *msg) |
56 | struct mipi_dsi_msg *msg) |
57 | { |
57 | { |
58 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; |
58 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; |
59 | 59 | ||
60 | if (!ops || !ops->transfer) |
60 | if (!ops || !ops->transfer) |
61 | return -ENOSYS; |
61 | return -ENOSYS; |
62 | 62 | ||
63 | if (dsi->mode_flags & MIPI_DSI_MODE_LPM) |
63 | if (dsi->mode_flags & MIPI_DSI_MODE_LPM) |
64 | msg->flags |= MIPI_DSI_MSG_USE_LPM; |
64 | msg->flags |= MIPI_DSI_MSG_USE_LPM; |
65 | 65 | ||
66 | return ops->transfer(dsi->host, msg); |
66 | return ops->transfer(dsi->host, msg); |
67 | } |
67 | } |
68 | 68 | ||
69 | /** |
69 | /** |
70 | * mipi_dsi_packet_format_is_short - check if a packet is of the short format |
70 | * mipi_dsi_packet_format_is_short - check if a packet is of the short format |
71 | * @type: MIPI DSI data type of the packet |
71 | * @type: MIPI DSI data type of the packet |
72 | * |
72 | * |
73 | * Return: true if the packet for the given data type is a short packet, false |
73 | * Return: true if the packet for the given data type is a short packet, false |
74 | * otherwise. |
74 | * otherwise. |
75 | */ |
75 | */ |
76 | bool mipi_dsi_packet_format_is_short(u8 type) |
76 | bool mipi_dsi_packet_format_is_short(u8 type) |
77 | { |
77 | { |
78 | switch (type) { |
78 | switch (type) { |
79 | case MIPI_DSI_V_SYNC_START: |
79 | case MIPI_DSI_V_SYNC_START: |
80 | case MIPI_DSI_V_SYNC_END: |
80 | case MIPI_DSI_V_SYNC_END: |
81 | case MIPI_DSI_H_SYNC_START: |
81 | case MIPI_DSI_H_SYNC_START: |
82 | case MIPI_DSI_H_SYNC_END: |
82 | case MIPI_DSI_H_SYNC_END: |
83 | case MIPI_DSI_END_OF_TRANSMISSION: |
83 | case MIPI_DSI_END_OF_TRANSMISSION: |
84 | case MIPI_DSI_COLOR_MODE_OFF: |
84 | case MIPI_DSI_COLOR_MODE_OFF: |
85 | case MIPI_DSI_COLOR_MODE_ON: |
85 | case MIPI_DSI_COLOR_MODE_ON: |
86 | case MIPI_DSI_SHUTDOWN_PERIPHERAL: |
86 | case MIPI_DSI_SHUTDOWN_PERIPHERAL: |
87 | case MIPI_DSI_TURN_ON_PERIPHERAL: |
87 | case MIPI_DSI_TURN_ON_PERIPHERAL: |
88 | case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM: |
88 | case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM: |
89 | case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM: |
89 | case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM: |
90 | case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM: |
90 | case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM: |
91 | case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM: |
91 | case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM: |
92 | case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM: |
92 | case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM: |
93 | case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM: |
93 | case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM: |
94 | case MIPI_DSI_DCS_SHORT_WRITE: |
94 | case MIPI_DSI_DCS_SHORT_WRITE: |
95 | case MIPI_DSI_DCS_SHORT_WRITE_PARAM: |
95 | case MIPI_DSI_DCS_SHORT_WRITE_PARAM: |
96 | case MIPI_DSI_DCS_READ: |
96 | case MIPI_DSI_DCS_READ: |
97 | case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE: |
97 | case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE: |
98 | return true; |
98 | return true; |
99 | } |
99 | } |
100 | 100 | ||
101 | return false; |
101 | return false; |
102 | } |
102 | } |
103 | EXPORT_SYMBOL(mipi_dsi_packet_format_is_short); |
103 | EXPORT_SYMBOL(mipi_dsi_packet_format_is_short); |
104 | 104 | ||
105 | /** |
105 | /** |
106 | * mipi_dsi_packet_format_is_long - check if a packet is of the long format |
106 | * mipi_dsi_packet_format_is_long - check if a packet is of the long format |
107 | * @type: MIPI DSI data type of the packet |
107 | * @type: MIPI DSI data type of the packet |
108 | * |
108 | * |
109 | * Return: true if the packet for the given data type is a long packet, false |
109 | * Return: true if the packet for the given data type is a long packet, false |
110 | * otherwise. |
110 | * otherwise. |
111 | */ |
111 | */ |
112 | bool mipi_dsi_packet_format_is_long(u8 type) |
112 | bool mipi_dsi_packet_format_is_long(u8 type) |
113 | { |
113 | { |
114 | switch (type) { |
114 | switch (type) { |
115 | case MIPI_DSI_NULL_PACKET: |
115 | case MIPI_DSI_NULL_PACKET: |
116 | case MIPI_DSI_BLANKING_PACKET: |
116 | case MIPI_DSI_BLANKING_PACKET: |
117 | case MIPI_DSI_GENERIC_LONG_WRITE: |
117 | case MIPI_DSI_GENERIC_LONG_WRITE: |
118 | case MIPI_DSI_DCS_LONG_WRITE: |
118 | case MIPI_DSI_DCS_LONG_WRITE: |
119 | case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20: |
119 | case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20: |
120 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24: |
120 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24: |
121 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16: |
121 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16: |
122 | case MIPI_DSI_PACKED_PIXEL_STREAM_30: |
122 | case MIPI_DSI_PACKED_PIXEL_STREAM_30: |
123 | case MIPI_DSI_PACKED_PIXEL_STREAM_36: |
123 | case MIPI_DSI_PACKED_PIXEL_STREAM_36: |
124 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12: |
124 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12: |
125 | case MIPI_DSI_PACKED_PIXEL_STREAM_16: |
125 | case MIPI_DSI_PACKED_PIXEL_STREAM_16: |
126 | case MIPI_DSI_PACKED_PIXEL_STREAM_18: |
126 | case MIPI_DSI_PACKED_PIXEL_STREAM_18: |
127 | case MIPI_DSI_PIXEL_STREAM_3BYTE_18: |
127 | case MIPI_DSI_PIXEL_STREAM_3BYTE_18: |
128 | case MIPI_DSI_PACKED_PIXEL_STREAM_24: |
128 | case MIPI_DSI_PACKED_PIXEL_STREAM_24: |
129 | return true; |
129 | return true; |
130 | } |
130 | } |
131 | 131 | ||
132 | return false; |
132 | return false; |
133 | } |
133 | } |
134 | EXPORT_SYMBOL(mipi_dsi_packet_format_is_long); |
134 | EXPORT_SYMBOL(mipi_dsi_packet_format_is_long); |
135 | 135 | ||
136 | /** |
136 | /** |
137 | * mipi_dsi_create_packet - create a packet from a message according to the |
137 | * mipi_dsi_create_packet - create a packet from a message according to the |
138 | * DSI protocol |
138 | * DSI protocol |
139 | * @packet: pointer to a DSI packet structure |
139 | * @packet: pointer to a DSI packet structure |
140 | * @msg: message to translate into a packet |
140 | * @msg: message to translate into a packet |
141 | * |
141 | * |
142 | * Return: 0 on success or a negative error code on failure. |
142 | * Return: 0 on success or a negative error code on failure. |
143 | */ |
143 | */ |
144 | int mipi_dsi_create_packet(struct mipi_dsi_packet *packet, |
144 | int mipi_dsi_create_packet(struct mipi_dsi_packet *packet, |
145 | const struct mipi_dsi_msg *msg) |
145 | const struct mipi_dsi_msg *msg) |
146 | { |
146 | { |
147 | if (!packet || !msg) |
147 | if (!packet || !msg) |
148 | return -EINVAL; |
148 | return -EINVAL; |
149 | 149 | ||
150 | /* do some minimum sanity checking */ |
150 | /* do some minimum sanity checking */ |
151 | if (!mipi_dsi_packet_format_is_short(msg->type) && |
151 | if (!mipi_dsi_packet_format_is_short(msg->type) && |
152 | !mipi_dsi_packet_format_is_long(msg->type)) |
152 | !mipi_dsi_packet_format_is_long(msg->type)) |
153 | return -EINVAL; |
153 | return -EINVAL; |
154 | 154 | ||
155 | if (msg->channel > 3) |
155 | if (msg->channel > 3) |
156 | return -EINVAL; |
156 | return -EINVAL; |
157 | 157 | ||
158 | memset(packet, 0, sizeof(*packet)); |
158 | memset(packet, 0, sizeof(*packet)); |
159 | packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f); |
159 | packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f); |
160 | 160 | ||
161 | /* TODO: compute ECC if hardware support is not available */ |
161 | /* TODO: compute ECC if hardware support is not available */ |
162 | 162 | ||
163 | /* |
163 | /* |
164 | * Long write packets contain the word count in header bytes 1 and 2. |
164 | * Long write packets contain the word count in header bytes 1 and 2. |
165 | * The payload follows the header and is word count bytes long. |
165 | * The payload follows the header and is word count bytes long. |
166 | * |
166 | * |
167 | * Short write packets encode up to two parameters in header bytes 1 |
167 | * Short write packets encode up to two parameters in header bytes 1 |
168 | * and 2. |
168 | * and 2. |
169 | */ |
169 | */ |
170 | if (mipi_dsi_packet_format_is_long(msg->type)) { |
170 | if (mipi_dsi_packet_format_is_long(msg->type)) { |
171 | packet->header[1] = (msg->tx_len >> 0) & 0xff; |
171 | packet->header[1] = (msg->tx_len >> 0) & 0xff; |
172 | packet->header[2] = (msg->tx_len >> 8) & 0xff; |
172 | packet->header[2] = (msg->tx_len >> 8) & 0xff; |
173 | 173 | ||
174 | packet->payload_length = msg->tx_len; |
174 | packet->payload_length = msg->tx_len; |
175 | packet->payload = msg->tx_buf; |
175 | packet->payload = msg->tx_buf; |
176 | } else { |
176 | } else { |
177 | const u8 *tx = msg->tx_buf; |
177 | const u8 *tx = msg->tx_buf; |
178 | 178 | ||
179 | packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0; |
179 | packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0; |
180 | packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0; |
180 | packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0; |
181 | } |
181 | } |
182 | 182 | ||
183 | packet->size = sizeof(packet->header) + packet->payload_length; |
183 | packet->size = sizeof(packet->header) + packet->payload_length; |
184 | 184 | ||
185 | return 0; |
185 | return 0; |
186 | } |
186 | } |
187 | EXPORT_SYMBOL(mipi_dsi_create_packet); |
187 | EXPORT_SYMBOL(mipi_dsi_create_packet); |
188 | 188 | ||
189 | /* |
189 | /* |
190 | * mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the |
190 | * mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the |
191 | * the payload in a long packet transmitted from the peripheral back to the |
191 | * the payload in a long packet transmitted from the peripheral back to the |
192 | * host processor |
192 | * host processor |
193 | * @dsi: DSI peripheral device |
193 | * @dsi: DSI peripheral device |
194 | * @value: the maximum size of the payload |
194 | * @value: the maximum size of the payload |
195 | * |
195 | * |
196 | * Return: 0 on success or a negative error code on failure. |
196 | * Return: 0 on success or a negative error code on failure. |
197 | */ |
197 | */ |
198 | int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, |
198 | int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, |
199 | u16 value) |
199 | u16 value) |
200 | { |
200 | { |
201 | u8 tx[2] = { value & 0xff, value >> 8 }; |
201 | u8 tx[2] = { value & 0xff, value >> 8 }; |
202 | struct mipi_dsi_msg msg = { |
202 | struct mipi_dsi_msg msg = { |
203 | .channel = dsi->channel, |
203 | .channel = dsi->channel, |
204 | .type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, |
204 | .type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, |
205 | .tx_len = sizeof(tx), |
205 | .tx_len = sizeof(tx), |
206 | .tx_buf = tx, |
206 | .tx_buf = tx, |
207 | }; |
207 | }; |
208 | 208 | ||
209 | return mipi_dsi_device_transfer(dsi, &msg); |
209 | return mipi_dsi_device_transfer(dsi, &msg); |
210 | } |
210 | } |
211 | EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size); |
211 | EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size); |
212 | 212 | ||
213 | /** |
213 | /** |
214 | * mipi_dsi_generic_write() - transmit data using a generic write packet |
214 | * mipi_dsi_generic_write() - transmit data using a generic write packet |
215 | * @dsi: DSI peripheral device |
215 | * @dsi: DSI peripheral device |
216 | * @payload: buffer containing the payload |
216 | * @payload: buffer containing the payload |
217 | * @size: size of payload buffer |
217 | * @size: size of payload buffer |
218 | * |
218 | * |
219 | * This function will automatically choose the right data type depending on |
219 | * This function will automatically choose the right data type depending on |
220 | * the payload length. |
220 | * the payload length. |
221 | * |
221 | * |
222 | * Return: The number of bytes transmitted on success or a negative error code |
222 | * Return: The number of bytes transmitted on success or a negative error code |
223 | * on failure. |
223 | * on failure. |
224 | */ |
224 | */ |
225 | ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, |
225 | ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, |
226 | size_t size) |
226 | size_t size) |
227 | { |
227 | { |
228 | struct mipi_dsi_msg msg = { |
228 | struct mipi_dsi_msg msg = { |
229 | .channel = dsi->channel, |
229 | .channel = dsi->channel, |
230 | .tx_buf = payload, |
230 | .tx_buf = payload, |
231 | .tx_len = size |
231 | .tx_len = size |
232 | }; |
232 | }; |
233 | 233 | ||
234 | switch (size) { |
234 | switch (size) { |
235 | case 0: |
235 | case 0: |
236 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM; |
236 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM; |
237 | break; |
237 | break; |
238 | 238 | ||
239 | case 1: |
239 | case 1: |
240 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM; |
240 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM; |
241 | break; |
241 | break; |
242 | 242 | ||
243 | case 2: |
243 | case 2: |
244 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM; |
244 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM; |
245 | break; |
245 | break; |
246 | 246 | ||
247 | default: |
247 | default: |
248 | msg.type = MIPI_DSI_GENERIC_LONG_WRITE; |
248 | msg.type = MIPI_DSI_GENERIC_LONG_WRITE; |
249 | break; |
249 | break; |
250 | } |
250 | } |
251 | 251 | ||
252 | return mipi_dsi_device_transfer(dsi, &msg); |
252 | return mipi_dsi_device_transfer(dsi, &msg); |
253 | } |
253 | } |
254 | EXPORT_SYMBOL(mipi_dsi_generic_write); |
254 | EXPORT_SYMBOL(mipi_dsi_generic_write); |
255 | 255 | ||
256 | /** |
256 | /** |
257 | * mipi_dsi_generic_read() - receive data using a generic read packet |
257 | * mipi_dsi_generic_read() - receive data using a generic read packet |
258 | * @dsi: DSI peripheral device |
258 | * @dsi: DSI peripheral device |
259 | * @params: buffer containing the request parameters |
259 | * @params: buffer containing the request parameters |
260 | * @num_params: number of request parameters |
260 | * @num_params: number of request parameters |
261 | * @data: buffer in which to return the received data |
261 | * @data: buffer in which to return the received data |
262 | * @size: size of receive buffer |
262 | * @size: size of receive buffer |
263 | * |
263 | * |
264 | * This function will automatically choose the right data type depending on |
264 | * This function will automatically choose the right data type depending on |
265 | * the number of parameters passed in. |
265 | * the number of parameters passed in. |
266 | * |
266 | * |
267 | * Return: The number of bytes successfully read or a negative error code on |
267 | * Return: The number of bytes successfully read or a negative error code on |
268 | * failure. |
268 | * failure. |
269 | */ |
269 | */ |
270 | ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params, |
270 | ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params, |
271 | size_t num_params, void *data, size_t size) |
271 | size_t num_params, void *data, size_t size) |
272 | { |
272 | { |
273 | struct mipi_dsi_msg msg = { |
273 | struct mipi_dsi_msg msg = { |
274 | .channel = dsi->channel, |
274 | .channel = dsi->channel, |
275 | .tx_len = num_params, |
275 | .tx_len = num_params, |
276 | .tx_buf = params, |
276 | .tx_buf = params, |
277 | .rx_len = size, |
277 | .rx_len = size, |
278 | .rx_buf = data |
278 | .rx_buf = data |
279 | }; |
279 | }; |
280 | 280 | ||
281 | switch (num_params) { |
281 | switch (num_params) { |
282 | case 0: |
282 | case 0: |
283 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM; |
283 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM; |
284 | break; |
284 | break; |
285 | 285 | ||
286 | case 1: |
286 | case 1: |
287 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM; |
287 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM; |
288 | break; |
288 | break; |
289 | 289 | ||
290 | case 2: |
290 | case 2: |
291 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM; |
291 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM; |
292 | break; |
292 | break; |
293 | 293 | ||
294 | default: |
294 | default: |
295 | return -EINVAL; |
295 | return -EINVAL; |
296 | } |
296 | } |
297 | 297 | ||
298 | return mipi_dsi_device_transfer(dsi, &msg); |
298 | return mipi_dsi_device_transfer(dsi, &msg); |
299 | } |
299 | } |
300 | EXPORT_SYMBOL(mipi_dsi_generic_read); |
300 | EXPORT_SYMBOL(mipi_dsi_generic_read); |
301 | 301 | ||
302 | /** |
302 | /** |
303 | * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload |
303 | * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload |
304 | * @dsi: DSI peripheral device |
304 | * @dsi: DSI peripheral device |
305 | * @data: buffer containing data to be transmitted |
305 | * @data: buffer containing data to be transmitted |
306 | * @len: size of transmission buffer |
306 | * @len: size of transmission buffer |
307 | * |
307 | * |
308 | * This function will automatically choose the right data type depending on |
308 | * This function will automatically choose the right data type depending on |
309 | * the command payload length. |
309 | * the command payload length. |
310 | * |
310 | * |
311 | * Return: The number of bytes successfully transmitted or a negative error |
311 | * Return: The number of bytes successfully transmitted or a negative error |
312 | * code on failure. |
312 | * code on failure. |
313 | */ |
313 | */ |
314 | ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, |
314 | ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, |
315 | const void *data, size_t len) |
315 | const void *data, size_t len) |
316 | { |
316 | { |
317 | struct mipi_dsi_msg msg = { |
317 | struct mipi_dsi_msg msg = { |
318 | .channel = dsi->channel, |
318 | .channel = dsi->channel, |
319 | .tx_buf = data, |
319 | .tx_buf = data, |
320 | .tx_len = len |
320 | .tx_len = len |
321 | }; |
321 | }; |
322 | 322 | ||
323 | switch (len) { |
323 | switch (len) { |
324 | case 0: |
324 | case 0: |
325 | return -EINVAL; |
325 | return -EINVAL; |
326 | 326 | ||
327 | case 1: |
327 | case 1: |
328 | msg.type = MIPI_DSI_DCS_SHORT_WRITE; |
328 | msg.type = MIPI_DSI_DCS_SHORT_WRITE; |
329 | break; |
329 | break; |
330 | 330 | ||
331 | case 2: |
331 | case 2: |
332 | msg.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM; |
332 | msg.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM; |
333 | break; |
333 | break; |
334 | 334 | ||
335 | default: |
335 | default: |
336 | msg.type = MIPI_DSI_DCS_LONG_WRITE; |
336 | msg.type = MIPI_DSI_DCS_LONG_WRITE; |
337 | break; |
337 | break; |
338 | } |
338 | } |
339 | 339 | ||
340 | return mipi_dsi_device_transfer(dsi, &msg); |
340 | return mipi_dsi_device_transfer(dsi, &msg); |
341 | } |
341 | } |
342 | EXPORT_SYMBOL(mipi_dsi_dcs_write_buffer); |
342 | EXPORT_SYMBOL(mipi_dsi_dcs_write_buffer); |
343 | 343 | ||
344 | /** |
344 | /** |
345 | * mipi_dsi_dcs_write() - send DCS write command |
345 | * mipi_dsi_dcs_write() - send DCS write command |
346 | * @dsi: DSI peripheral device |
346 | * @dsi: DSI peripheral device |
347 | * @cmd: DCS command |
347 | * @cmd: DCS command |
348 | * @data: buffer containing the command payload |
348 | * @data: buffer containing the command payload |
349 | * @len: command payload length |
349 | * @len: command payload length |
350 | * |
350 | * |
351 | * This function will automatically choose the right data type depending on |
351 | * This function will automatically choose the right data type depending on |
352 | * the command payload length. |
352 | * the command payload length. |
353 | * |
353 | * |
354 | * Return: The number of bytes successfully transmitted or a negative error |
354 | * Return: The number of bytes successfully transmitted or a negative error |
355 | * code on failure. |
355 | * code on failure. |
356 | */ |
356 | */ |
357 | ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, |
357 | ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, |
358 | const void *data, size_t len) |
358 | const void *data, size_t len) |
359 | { |
359 | { |
360 | ssize_t err; |
360 | ssize_t err; |
361 | size_t size; |
361 | size_t size; |
362 | u8 *tx; |
362 | u8 *tx; |
363 | 363 | ||
364 | if (len > 0) { |
364 | if (len > 0) { |
365 | size = 1 + len; |
365 | size = 1 + len; |
366 | 366 | ||
367 | tx = kmalloc(size, GFP_KERNEL); |
367 | tx = kmalloc(size, GFP_KERNEL); |
368 | if (!tx) |
368 | if (!tx) |
369 | return -ENOMEM; |
369 | return -ENOMEM; |
370 | 370 | ||
371 | /* concatenate the DCS command byte and the payload */ |
371 | /* concatenate the DCS command byte and the payload */ |
372 | tx[0] = cmd; |
372 | tx[0] = cmd; |
373 | memcpy(&tx[1], data, len); |
373 | memcpy(&tx[1], data, len); |
374 | } else { |
374 | } else { |
375 | tx = &cmd; |
375 | tx = &cmd; |
376 | size = 1; |
376 | size = 1; |
377 | } |
377 | } |
378 | 378 | ||
379 | err = mipi_dsi_dcs_write_buffer(dsi, tx, size); |
379 | err = mipi_dsi_dcs_write_buffer(dsi, tx, size); |
380 | 380 | ||
381 | if (len > 0) |
381 | if (len > 0) |
382 | kfree(tx); |
382 | kfree(tx); |
383 | 383 | ||
384 | return err; |
384 | return err; |
385 | } |
385 | } |
386 | EXPORT_SYMBOL(mipi_dsi_dcs_write); |
386 | EXPORT_SYMBOL(mipi_dsi_dcs_write); |
387 | 387 | ||
388 | /** |
388 | /** |
389 | * mipi_dsi_dcs_read() - send DCS read request command |
389 | * mipi_dsi_dcs_read() - send DCS read request command |
390 | * @dsi: DSI peripheral device |
390 | * @dsi: DSI peripheral device |
391 | * @cmd: DCS command |
391 | * @cmd: DCS command |
392 | * @data: buffer in which to receive data |
392 | * @data: buffer in which to receive data |
393 | * @len: size of receive buffer |
393 | * @len: size of receive buffer |
394 | * |
394 | * |
395 | * Return: The number of bytes read or a negative error code on failure. |
395 | * Return: The number of bytes read or a negative error code on failure. |
396 | */ |
396 | */ |
397 | ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, |
397 | ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, |
398 | size_t len) |
398 | size_t len) |
399 | { |
399 | { |
400 | struct mipi_dsi_msg msg = { |
400 | struct mipi_dsi_msg msg = { |
401 | .channel = dsi->channel, |
401 | .channel = dsi->channel, |
402 | .type = MIPI_DSI_DCS_READ, |
402 | .type = MIPI_DSI_DCS_READ, |
403 | .tx_buf = &cmd, |
403 | .tx_buf = &cmd, |
404 | .tx_len = 1, |
404 | .tx_len = 1, |
405 | .rx_buf = data, |
405 | .rx_buf = data, |
406 | .rx_len = len |
406 | .rx_len = len |
407 | }; |
407 | }; |
408 | 408 | ||
409 | return mipi_dsi_device_transfer(dsi, &msg); |
409 | return mipi_dsi_device_transfer(dsi, &msg); |
410 | } |
410 | } |
411 | EXPORT_SYMBOL(mipi_dsi_dcs_read); |
411 | EXPORT_SYMBOL(mipi_dsi_dcs_read); |
412 | 412 | ||
413 | /** |
413 | /** |
414 | * mipi_dsi_dcs_nop() - send DCS nop packet |
414 | * mipi_dsi_dcs_nop() - send DCS nop packet |
415 | * @dsi: DSI peripheral device |
415 | * @dsi: DSI peripheral device |
416 | * |
416 | * |
417 | * Return: 0 on success or a negative error code on failure. |
417 | * Return: 0 on success or a negative error code on failure. |
418 | */ |
418 | */ |
419 | int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi) |
419 | int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi) |
420 | { |
420 | { |
421 | ssize_t err; |
421 | ssize_t err; |
422 | 422 | ||
423 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_NOP, NULL, 0); |
423 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_NOP, NULL, 0); |
424 | if (err < 0) |
424 | if (err < 0) |
425 | return err; |
425 | return err; |
426 | 426 | ||
427 | return 0; |
427 | return 0; |
428 | } |
428 | } |
429 | EXPORT_SYMBOL(mipi_dsi_dcs_nop); |
429 | EXPORT_SYMBOL(mipi_dsi_dcs_nop); |
430 | 430 | ||
431 | /** |
431 | /** |
432 | * mipi_dsi_dcs_soft_reset() - perform a software reset of the display module |
432 | * mipi_dsi_dcs_soft_reset() - perform a software reset of the display module |
433 | * @dsi: DSI peripheral device |
433 | * @dsi: DSI peripheral device |
434 | * |
434 | * |
435 | * Return: 0 on success or a negative error code on failure. |
435 | * Return: 0 on success or a negative error code on failure. |
436 | */ |
436 | */ |
437 | int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi) |
437 | int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi) |
438 | { |
438 | { |
439 | ssize_t err; |
439 | ssize_t err; |
440 | 440 | ||
441 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SOFT_RESET, NULL, 0); |
441 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SOFT_RESET, NULL, 0); |
442 | if (err < 0) |
442 | if (err < 0) |
443 | return err; |
443 | return err; |
444 | 444 | ||
445 | return 0; |
445 | return 0; |
446 | } |
446 | } |
447 | EXPORT_SYMBOL(mipi_dsi_dcs_soft_reset); |
447 | EXPORT_SYMBOL(mipi_dsi_dcs_soft_reset); |
448 | 448 | ||
449 | /** |
449 | /** |
450 | * mipi_dsi_dcs_get_power_mode() - query the display module's current power |
450 | * mipi_dsi_dcs_get_power_mode() - query the display module's current power |
451 | * mode |
451 | * mode |
452 | * @dsi: DSI peripheral device |
452 | * @dsi: DSI peripheral device |
453 | * @mode: return location for the current power mode |
453 | * @mode: return location for the current power mode |
454 | * |
454 | * |
455 | * Return: 0 on success or a negative error code on failure. |
455 | * Return: 0 on success or a negative error code on failure. |
456 | */ |
456 | */ |
457 | int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode) |
457 | int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode) |
458 | { |
458 | { |
459 | ssize_t err; |
459 | ssize_t err; |
460 | 460 | ||
461 | err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_POWER_MODE, mode, |
461 | err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_POWER_MODE, mode, |
462 | sizeof(*mode)); |
462 | sizeof(*mode)); |
463 | if (err <= 0) { |
463 | if (err <= 0) { |
464 | if (err == 0) |
464 | if (err == 0) |
465 | err = -ENODATA; |
465 | err = -ENODATA; |
466 | 466 | ||
467 | return err; |
467 | return err; |
468 | } |
468 | } |
469 | 469 | ||
470 | return 0; |
470 | return 0; |
471 | } |
471 | } |
472 | EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode); |
472 | EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode); |
473 | 473 | ||
474 | /** |
474 | /** |
475 | * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image |
475 | * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image |
476 | * data used by the interface |
476 | * data used by the interface |
477 | * @dsi: DSI peripheral device |
477 | * @dsi: DSI peripheral device |
478 | * @format: return location for the pixel format |
478 | * @format: return location for the pixel format |
479 | * |
479 | * |
480 | * Return: 0 on success or a negative error code on failure. |
480 | * Return: 0 on success or a negative error code on failure. |
481 | */ |
481 | */ |
482 | int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format) |
482 | int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format) |
483 | { |
483 | { |
484 | ssize_t err; |
484 | ssize_t err; |
485 | 485 | ||
486 | err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format, |
486 | err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format, |
487 | sizeof(*format)); |
487 | sizeof(*format)); |
488 | if (err <= 0) { |
488 | if (err <= 0) { |
489 | if (err == 0) |
489 | if (err == 0) |
490 | err = -ENODATA; |
490 | err = -ENODATA; |
491 | 491 | ||
492 | return err; |
492 | return err; |
493 | } |
493 | } |
494 | 494 | ||
495 | return 0; |
495 | return 0; |
496 | } |
496 | } |
497 | EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format); |
497 | EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format); |
498 | 498 | ||
499 | /** |
499 | /** |
500 | * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the |
500 | * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the |
501 | * display module except interface communication |
501 | * display module except interface communication |
502 | * @dsi: DSI peripheral device |
502 | * @dsi: DSI peripheral device |
503 | * |
503 | * |
504 | * Return: 0 on success or a negative error code on failure. |
504 | * Return: 0 on success or a negative error code on failure. |
505 | */ |
505 | */ |
506 | int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi) |
506 | int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi) |
507 | { |
507 | { |
508 | ssize_t err; |
508 | ssize_t err; |
509 | 509 | ||
510 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); |
510 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); |
511 | if (err < 0) |
511 | if (err < 0) |
512 | return err; |
512 | return err; |
513 | 513 | ||
514 | return 0; |
514 | return 0; |
515 | } |
515 | } |
516 | EXPORT_SYMBOL(mipi_dsi_dcs_enter_sleep_mode); |
516 | EXPORT_SYMBOL(mipi_dsi_dcs_enter_sleep_mode); |
517 | 517 | ||
518 | /** |
518 | /** |
519 | * mipi_dsi_dcs_exit_sleep_mode() - enable all blocks inside the display |
519 | * mipi_dsi_dcs_exit_sleep_mode() - enable all blocks inside the display |
520 | * module |
520 | * module |
521 | * @dsi: DSI peripheral device |
521 | * @dsi: DSI peripheral device |
522 | * |
522 | * |
523 | * Return: 0 on success or a negative error code on failure. |
523 | * Return: 0 on success or a negative error code on failure. |
524 | */ |
524 | */ |
525 | int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi) |
525 | int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi) |
526 | { |
526 | { |
527 | ssize_t err; |
527 | ssize_t err; |
528 | 528 | ||
529 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); |
529 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); |
530 | if (err < 0) |
530 | if (err < 0) |
531 | return err; |
531 | return err; |
532 | 532 | ||
533 | return 0; |
533 | return 0; |
534 | } |
534 | } |
535 | EXPORT_SYMBOL(mipi_dsi_dcs_exit_sleep_mode); |
535 | EXPORT_SYMBOL(mipi_dsi_dcs_exit_sleep_mode); |
536 | 536 | ||
537 | /** |
537 | /** |
538 | * mipi_dsi_dcs_set_display_off() - stop displaying the image data on the |
538 | * mipi_dsi_dcs_set_display_off() - stop displaying the image data on the |
539 | * display device |
539 | * display device |
540 | * @dsi: DSI peripheral device |
540 | * @dsi: DSI peripheral device |
541 | * |
541 | * |
542 | * Return: 0 on success or a negative error code on failure. |
542 | * Return: 0 on success or a negative error code on failure. |
543 | */ |
543 | */ |
544 | int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi) |
544 | int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi) |
545 | { |
545 | { |
546 | ssize_t err; |
546 | ssize_t err; |
547 | 547 | ||
548 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); |
548 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); |
549 | if (err < 0) |
549 | if (err < 0) |
550 | return err; |
550 | return err; |
551 | 551 | ||
552 | return 0; |
552 | return 0; |
553 | } |
553 | } |
554 | EXPORT_SYMBOL(mipi_dsi_dcs_set_display_off); |
554 | EXPORT_SYMBOL(mipi_dsi_dcs_set_display_off); |
555 | 555 | ||
556 | /** |
556 | /** |
557 | * mipi_dsi_dcs_set_display_on() - start displaying the image data on the |
557 | * mipi_dsi_dcs_set_display_on() - start displaying the image data on the |
558 | * display device |
558 | * display device |
559 | * @dsi: DSI peripheral device |
559 | * @dsi: DSI peripheral device |
560 | * |
560 | * |
561 | * Return: 0 on success or a negative error code on failure |
561 | * Return: 0 on success or a negative error code on failure |
562 | */ |
562 | */ |
563 | int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi) |
563 | int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi) |
564 | { |
564 | { |
565 | ssize_t err; |
565 | ssize_t err; |
566 | 566 | ||
567 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); |
567 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); |
568 | if (err < 0) |
568 | if (err < 0) |
569 | return err; |
569 | return err; |
570 | 570 | ||
571 | return 0; |
571 | return 0; |
572 | } |
572 | } |
573 | EXPORT_SYMBOL(mipi_dsi_dcs_set_display_on); |
573 | EXPORT_SYMBOL(mipi_dsi_dcs_set_display_on); |
574 | 574 | ||
575 | /** |
575 | /** |
576 | * mipi_dsi_dcs_set_column_address() - define the column extent of the frame |
576 | * mipi_dsi_dcs_set_column_address() - define the column extent of the frame |
577 | * memory accessed by the host processor |
577 | * memory accessed by the host processor |
578 | * @dsi: DSI peripheral device |
578 | * @dsi: DSI peripheral device |
579 | * @start: first column of frame memory |
579 | * @start: first column of frame memory |
580 | * @end: last column of frame memory |
580 | * @end: last column of frame memory |
581 | * |
581 | * |
582 | * Return: 0 on success or a negative error code on failure. |
582 | * Return: 0 on success or a negative error code on failure. |
583 | */ |
583 | */ |
584 | int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start, |
584 | int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start, |
585 | u16 end) |
585 | u16 end) |
586 | { |
586 | { |
587 | u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff }; |
587 | u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff }; |
588 | ssize_t err; |
588 | ssize_t err; |
589 | 589 | ||
590 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_COLUMN_ADDRESS, payload, |
590 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_COLUMN_ADDRESS, payload, |
591 | sizeof(payload)); |
591 | sizeof(payload)); |
592 | if (err < 0) |
592 | if (err < 0) |
593 | return err; |
593 | return err; |
594 | 594 | ||
595 | return 0; |
595 | return 0; |
596 | } |
596 | } |
597 | EXPORT_SYMBOL(mipi_dsi_dcs_set_column_address); |
597 | EXPORT_SYMBOL(mipi_dsi_dcs_set_column_address); |
598 | 598 | ||
599 | /** |
599 | /** |
600 | * mipi_dsi_dcs_set_page_address() - define the page extent of the frame |
600 | * mipi_dsi_dcs_set_page_address() - define the page extent of the frame |
601 | * memory accessed by the host processor |
601 | * memory accessed by the host processor |
602 | * @dsi: DSI peripheral device |
602 | * @dsi: DSI peripheral device |
603 | * @start: first page of frame memory |
603 | * @start: first page of frame memory |
604 | * @end: last page of frame memory |
604 | * @end: last page of frame memory |
605 | * |
605 | * |
606 | * Return: 0 on success or a negative error code on failure. |
606 | * Return: 0 on success or a negative error code on failure. |
607 | */ |
607 | */ |
608 | int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start, |
608 | int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start, |
609 | u16 end) |
609 | u16 end) |
610 | { |
610 | { |
611 | u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff }; |
611 | u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff }; |
612 | ssize_t err; |
612 | ssize_t err; |
613 | 613 | ||
614 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PAGE_ADDRESS, payload, |
614 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PAGE_ADDRESS, payload, |
615 | sizeof(payload)); |
615 | sizeof(payload)); |
616 | if (err < 0) |
616 | if (err < 0) |
617 | return err; |
617 | return err; |
618 | 618 | ||
619 | return 0; |
619 | return 0; |
620 | } |
620 | } |
621 | EXPORT_SYMBOL(mipi_dsi_dcs_set_page_address); |
621 | EXPORT_SYMBOL(mipi_dsi_dcs_set_page_address); |
622 | 622 | ||
623 | /** |
623 | /** |
624 | * mipi_dsi_dcs_set_tear_off() - turn off the display module's Tearing Effect |
624 | * mipi_dsi_dcs_set_tear_off() - turn off the display module's Tearing Effect |
625 | * output signal on the TE signal line |
625 | * output signal on the TE signal line |
626 | * @dsi: DSI peripheral device |
626 | * @dsi: DSI peripheral device |
627 | * |
627 | * |
628 | * Return: 0 on success or a negative error code on failure |
628 | * Return: 0 on success or a negative error code on failure |
629 | */ |
629 | */ |
630 | int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi) |
630 | int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi) |
631 | { |
631 | { |
632 | ssize_t err; |
632 | ssize_t err; |
633 | 633 | ||
634 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_OFF, NULL, 0); |
634 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_OFF, NULL, 0); |
635 | if (err < 0) |
635 | if (err < 0) |
636 | return err; |
636 | return err; |
637 | 637 | ||
638 | return 0; |
638 | return 0; |
639 | } |
639 | } |
640 | EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_off); |
640 | EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_off); |
641 | 641 | ||
642 | /** |
642 | /** |
643 | * mipi_dsi_dcs_set_tear_on() - turn on the display module's Tearing Effect |
643 | * mipi_dsi_dcs_set_tear_on() - turn on the display module's Tearing Effect |
644 | * output signal on the TE signal line. |
644 | * output signal on the TE signal line. |
645 | * @dsi: DSI peripheral device |
645 | * @dsi: DSI peripheral device |
646 | * @mode: the Tearing Effect Output Line mode |
646 | * @mode: the Tearing Effect Output Line mode |
647 | * |
647 | * |
648 | * Return: 0 on success or a negative error code on failure |
648 | * Return: 0 on success or a negative error code on failure |
649 | */ |
649 | */ |
650 | int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi, |
650 | int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi, |
651 | enum mipi_dsi_dcs_tear_mode mode) |
651 | enum mipi_dsi_dcs_tear_mode mode) |
652 | { |
652 | { |
653 | u8 value = mode; |
653 | u8 value = mode; |
654 | ssize_t err; |
654 | ssize_t err; |
655 | 655 | ||
656 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_ON, &value, |
656 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_ON, &value, |
657 | sizeof(value)); |
657 | sizeof(value)); |
658 | if (err < 0) |
658 | if (err < 0) |
659 | return err; |
659 | return err; |
660 | 660 | ||
661 | return 0; |
661 | return 0; |
662 | } |
662 | } |
663 | EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on); |
663 | EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on); |
664 | 664 | ||
665 | /** |
665 | /** |
666 | * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image |
666 | * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image |
667 | * data used by the interface |
667 | * data used by the interface |
668 | * @dsi: DSI peripheral device |
668 | * @dsi: DSI peripheral device |
669 | * @format: pixel format |
669 | * @format: pixel format |
670 | * |
670 | * |
671 | * Return: 0 on success or a negative error code on failure. |
671 | * Return: 0 on success or a negative error code on failure. |
672 | */ |
672 | */ |
673 | int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) |
673 | int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) |
674 | { |
674 | { |
675 | ssize_t err; |
675 | ssize_t err; |
676 | 676 | ||
677 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, &format, |
677 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, &format, |
678 | sizeof(format)); |
678 | sizeof(format)); |
679 | if (err < 0) |
679 | if (err < 0) |
680 | return err; |
680 | return err; |
681 | 681 | ||
682 | return 0; |
682 | return 0; |
683 | } |
683 | } |
684 | EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format); |
684 | EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format); |
685 | 685 | ||
686 | MODULE_AUTHOR("Andrzej Hajda |
686 | MODULE_AUTHOR("Andrzej Hajda |
687 | MODULE_DESCRIPTION("MIPI DSI Bus"); |
687 | MODULE_DESCRIPTION("MIPI DSI Bus"); |
688 | MODULE_LICENSE("GPL and additional rights");>>>>>>>>>=>=>>>><> |
688 | MODULE_LICENSE("GPL and additional rights");>>>>>>>>>=>=>>>><> |