MT7687 API Reference  LinkIt SDK v4
hal_display_lcd.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_DISPLAY_LCD_H__
36 #define __HAL_DISPLAY_LCD_H__
37 
38 #include "hal_platform.h"
39 
40 #ifdef HAL_DISPLAY_LCD_MODULE_ENABLED
41 
165 #ifdef __cplusplus
166 extern "C" {
167 #endif
168 
170 typedef enum {
171  HAL_DISPLAY_LCD_LAYER_ROTATE_0 = 0x0,
172  HAL_DISPLAY_LCD_LAYER_ROTATE_90 = 0x1,
173  HAL_DISPLAY_LCD_LAYER_ROTATE_180 = 0x2,
174  HAL_DISPLAY_LCD_LAYER_ROTATE_270 = 0x3,
175  HAL_DISPLAY_LCD_LAYER_ROTATE_0_FLIP = 0x4,
176  HAL_DISPLAY_LCD_LAYER_ROTATE_90_FLIP = 0x5,
177  HAL_DISPLAY_LCD_LAYER_ROTATE_180_FLIP = 0x6,
178  HAL_DISPLAY_LCD_LAYER_ROTATE_270_FLIP = 0x7,
179  HAL_DISPLAY_LCD_LAYER_ROTATE_NUM
180 } hal_display_lcd_layer_rotate_t;
181 
183 typedef enum {
184  HAL_DISPLAY_LCD_STATUS_INITIALIZATION_FAILED = -8,
185  HAL_DISPLAY_LCD_STATUS_COLOR_INITIALIZATION_FAILED = -7,
186  HAL_DISPLAY_LCD_STATUS_DSI_INITIALIZATION_FAILED = -6,
187  HAL_DISPLAY_LCD_STATUS_INVALID_PARAMETER = -5,
188  HAL_DISPLAY_LCD_STATUS_COLOR_INVALID_PARAMETER = -4,
189  HAL_DISPLAY_LCD_STATUS_DSI_INVALID_PARAMETER = -3,
190  HAL_DISPLAY_LCD_STATUS_POWER_FAILED = -2,
191  HAL_DISPLAY_LCD_STATUS_ERROR = -1,
192  HAL_DISPLAY_LCD_STATUS_OK = 0,
193 } hal_display_lcd_status_t;
194 
196 typedef enum {
197  HAL_DISPLAY_LCD_INTERFACE_WIDTH_8 = 0,
198  HAL_DISPLAY_LCD_INTERFACE_WIDTH_9,
199  HAL_DISPLAY_LCD_INTERFACE_WIDTH_16,
200  HAL_DISPLAY_LCD_INTERFACE_WIDTH_18,
201  HAL_DISPLAY_LCD_INTERFACE_WIDTH_24,
202  HAL_DISPLAY_LCD_INTERFACE_WIDTH_32,
203  HAL_DISPLAY_LCD_INTERFACE_WIDTH_NUM
204 } hal_display_lcd_interface_width_t;
205 
207 typedef enum {
208  HAL_DISPLAY_LCD_INTERFACE_2PIN_WIDTH_16 = 2,
209  HAL_DISPLAY_LCD_INTERFACE_2PIN_WIDTH_18 = 3,
210  HAL_DISPLAY_LCD_INTERFACE_2PIN_WIDTH_24 = 4,
211  HAL_DISPLAY_LCD_INTERFACE_2PIN_WIDTH_12 = 6,
212  HAL_DISPLAY_LCD_INTERFACE_2PIN_WIDTH_NUM
213 } hal_display_lcd_interface_2pin_width_t;
214 
216 typedef enum {
217  HAL_DISPLAY_LCD_INTERFACE_START_BYTE_WIDTH_8 = 0,
218  HAL_DISPLAY_LCD_INTERFACE_START_BYTE_WIDTH_9,
219  HAL_DISPLAY_LCD_INTERFACE_START_BYTE_WIDTH_16,
220  HAL_DISPLAY_LCD_INTERFACE_START_BYTE_WIDTH_18,
221  HAL_DISPLAY_LCD_INTERFACE_START_BYTE_WIDTH_24,
222  HAL_DISPLAY_LCD_INTERFACE_START_BYTE_WIDTH_32,
223  HAL_DISPLAY_LCD_INTERFACE_START_BYTE_WIDTH_NUM
224 } hal_display_lcd_interface_start_byte_width_t;
225 
227 typedef enum {
228  HAL_DISPLAY_LCD_INTERFACE_CLOCK_124MHZ = 0,
229  HAL_DISPLAY_LCD_INTERFACE_CLOCK_104MHZ = 1,
230  HAL_DISPLAY_LCD_INTERFACE_CLOCK_91MHZ = 2,
231  HAL_DISPLAY_LCD_INTERFACE_CLOCK_26MHZ = 3,
232  HAL_DISPLAY_LCD_INTERFACE_CLOCK_RSVD = 4
233 } hal_display_lcd_interface_clock_t;
234 
236 typedef enum {
237  HAL_DISPLAY_LCD_LAYER_COLOR_8BPP_INDEX = 0,
238  HAL_DISPLAY_LCD_LAYER_COLOR_RGB565,
239  HAL_DISPLAY_LCD_LAYER_COLOR_UYVY422,
240  HAL_DISPLAY_LCD_LAYER_COLOR_RGB888,
241  HAL_DISPLAY_LCD_LAYER_COLOR_ARGB8888,
242  HAL_DISPLAY_LCD_LAYER_COLOR_PARGB8888,
243  HAL_DISPLAY_LCD_LAYER_COLOR_XRGB,
244  HAL_DISPLAY_LCD_LAYER_COLOR_ARGB6666,
245  HAL_DISPLAY_LCD_LAYER_COLOR_PARGB6666,
246  HAL_DISPLAY_LCD_LAYER_COLOR_4BIT_INDEX,
247  HAL_DISPLAY_LCD_LAYER_COLOR_2BIT_INDEX,
248  HAL_DISPLAY_LCD_LAYER_COLOR_1BIT_INDEX,
249  HAL_DISPLAY_LCD_LAYER_COLOR_NUM
250 } hal_display_lcd_layer_source_color_format_t;
251 
253 typedef enum {
254  HAL_DISPLAY_LCD_ROI_OUTPUT_RGB332 = 0,
255  HAL_DISPLAY_LCD_ROI_OUTPUT_RGB444,
256  HAL_DISPLAY_LCD_ROI_OUTPUT_RGB565,
257  HAL_DISPLAY_LCD_ROI_OUTPUT_RGB666,
258  HAL_DISPLAY_LCD_ROI_OUTPUT_RGB888,
259  HAL_DISPLAY_LCD_ROI_OUTPUT_NUM
260 } hal_display_lcd_output_color_format_t;
261 
263 typedef enum {
264  HAL_DISPLAY_LCD_LAYER0 = 0,
265  HAL_DISPLAY_LCD_LAYER1,
266  HAL_DISPLAY_LCD_LAYER2,
267  HAL_DISPLAY_LCD_LAYER3,
268  HAL_DISPLAY_LCD_LAYER_NUM
269 } hal_display_lcd_layer_t;
270 
272 typedef enum {
273  HAL_DISPLAY_LCD_DRIVING_CURRENT_4MA = 0,
274  HAL_DISPLAY_LCD_DRIVING_CURRENT_8MA,
275  HAL_DISPLAY_LCD_DRIVING_CURRENT_12MA,
276  HAL_DISPLAY_LCD_DRIVING_CURRENT_16MA,
277  HAL_DISPLAY_LCD_DRIVING_CURRENT_NUM
278 } hal_display_lcd_driving_current_t;
279 
281 typedef enum {
282  HAL_DISPLAY_LCD_POWER_DOMAIN_1V8 = 0,
283  HAL_DISPLAY_LCD_POWER_DOMAIN_2V8,
284  HAL_DISPLAY_LCD_POWER_DOMAIN_NUM
285 } hal_display_lcd_power_domain_t;
286 
288 typedef enum {
289  HAL_DISPLAY_LCD_INTERFACE_SERIAL_0 = 0,
290  HAL_DISPLAY_LCD_INTERFACE_SERIAL_1,
291  HAL_DISPLAY_LCD_INTERFACE_NUM
292 } hal_display_lcd_interface_port_t;
293 
294 
307 typedef struct {
308  uint8_t layer_enable;
309  uint8_t alpha;
310  bool alpha_flag;
311  hal_display_lcd_layer_rotate_t rotate;
312  bool source_key_flag;
313  bool rgb_swap_flag;
314  bool byte_swap_flag;
315  bool dither_flag;
316  hal_display_lcd_layer_source_color_format_t color_format;
317  bool destination_key_flag;
318  uint32_t color_key;
319  uint16_t window_x_offset;
320  uint16_t window_y_offset;
321  uint32_t buffer_address;
322  uint16_t row_size;
323  uint16_t column_size;
324  uint16_t pitch;
325 } hal_display_lcd_layer_input_t;
326 
333 typedef struct {
334  uint16_t target_start_x;
335  uint16_t target_start_y;
336  uint16_t target_end_x;
337  uint16_t target_end_y;
338  uint16_t roi_offset_x;
339  uint16_t roi_offset_y;
340  uint32_t roi_background_color;
341  uint32_t main_lcd_output;
342 } hal_display_lcd_roi_output_t;
343 
345 typedef struct {
346  hal_display_lcd_interface_port_t port_number;
347  uint32_t css;
348  uint32_t csh;
349  uint32_t rd_low;
350  uint32_t rd_high;
351  uint32_t wr_low;
352  uint32_t wr_high;
353  hal_display_lcd_interface_clock_t clock_freq;
354 } hal_display_lcd_interface_timing_t;
355 
357 typedef struct {
358  hal_display_lcd_interface_port_t port_number;
359  bool three_wire_mode;
360  bool single_a0_mode;
361  bool cs_stay_low_mode;
362  bool read_from_SDI;
363  hal_display_lcd_interface_width_t width;
364  hal_display_lcd_driving_current_t driving_current;
365  bool hw_cs;
366  hal_display_lcd_power_domain_t power_domain;
367  bool start_byte_mode;
368 } hal_display_lcd_interface_mode_t;
369 
371 typedef struct {
372  hal_display_lcd_interface_port_t port_number;
373  hal_display_lcd_interface_start_byte_width_t start_byte_width;
374  uint32_t byte_switch;
375  uint32_t wr_start_byte;
376  uint32_t wr_start_byte2;
377  uint32_t rd_start_byte;
378 } hal_display_lcd_interface_start_byte_mode_t;
379 
381 typedef struct {
382  hal_display_lcd_interface_port_t port_number;
383  bool two_data_flag;
384  hal_display_lcd_interface_2pin_width_t two_data_width;
385 } hal_display_lcd_interface_2_data_lane_t;
386 
401 typedef void (*hal_display_lcd_callback_t)(void *data);
402 
419 hal_display_lcd_status_t hal_display_lcd_init(uint32_t main_command_address, uint32_t main_data_address, uint32_t main_lcd_output_format);
429 hal_display_lcd_status_t hal_display_lcd_set_interface_timing(hal_display_lcd_interface_timing_t timing_settings);
430 
440 hal_display_lcd_status_t hal_display_lcd_set_interface_mode(hal_display_lcd_interface_mode_t mode_settings);
441 
453 hal_display_lcd_status_t hal_display_lcd_set_interface_2data_lane_mode(hal_display_lcd_interface_port_t port, bool flag, hal_display_lcd_interface_2pin_width_t two_data_width);
454 
464 hal_display_lcd_status_t hal_display_lcd_config_layer(hal_display_lcd_layer_input_t *layer_data);
465 
475 hal_display_lcd_status_t hal_display_lcd_config_roi(hal_display_lcd_roi_output_t *roi_settings);
476 
486 hal_display_lcd_status_t hal_display_lcd_config_start_byte(hal_display_lcd_interface_start_byte_mode_t *start_byte_settings);
487 
497 hal_display_lcd_status_t hal_display_lcd_set_index_color_table(uint32_t *index_table);
498 
508 hal_display_lcd_callback_t hal_display_lcd_register_callback(hal_display_lcd_callback_t lcd_callback);
509 
524 hal_display_lcd_status_t hal_display_lcd_init_te(uint32_t frame_rate, uint32_t back_porch, uint32_t front_porch, uint32_t width, uint32_t height, uint32_t main_lcd_output);
525 
536 hal_display_lcd_status_t hal_display_lcd_calculate_te(uint32_t width, uint32_t height);
537 
548 hal_display_lcd_status_t hal_display_lcd_toggle_reset(uint32_t low_time, uint32_t high_time);
549 
559 hal_display_lcd_status_t hal_display_lcd_start_dma(bool wait_te);
560 
568 uint32_t hal_display_lcd_get_layer_address(hal_display_lcd_layer_t layer);
569 
575 void hal_display_lcd_restore_callback(void);
576 
585 hal_display_lcd_status_t hal_display_lcd_turn_on_mtcmos(void);
586 
594 hal_display_lcd_status_t hal_display_lcd_turn_off_mtcmos(void);
595 
605 hal_display_lcd_status_t hal_display_lcd_set_clock(hal_display_lcd_interface_clock_t clock);
606 
615 hal_display_lcd_status_t hal_display_lcd_apply_setting(void);
616 
624 hal_display_lcd_status_t hal_display_lcd_set_layer_to_default(void);
625 #ifdef __cplusplus
626 }
627 #endif
628 
634 #endif /* HAL_DISPLAY_LCD_MODULE_ENABLED */
635 #endif /* __HAL_DISPLAY_LCD_H__ */