MT7687 API Reference  LinkIt SDK v4
hal_g2d.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_G2D_H__
36 #define __HAL_G2D_H__
37 
38 #include "hal_platform.h"
39 
40 #ifdef HAL_G2D_MODULE_ENABLED
41 
127 #ifdef __cplusplus
128 extern "C" {
129 #endif
130 
131 /*****************************************************************************
132  * Enums
133  *****************************************************************************/
134 
140 typedef enum {
141  HAL_G2D_STATUS_HW_ERROR = -6,
142  HAL_G2D_STATUS_NOT_SUPPORTEDED_COLOR_FORMAT = -5,
143  HAL_G2D_STATUS_INVALID_PARAMETER = -4,
144  HAL_G2D_STATUS_NOT_SUPPORTED = -3,
145  HAL_G2D_STATUS_BUSY = 0,
146  HAL_G2D_STATUS_OK = 1
147 } hal_g2d_status_t;
148 
150 typedef enum {
151  HAL_G2D_CODEC_TYPE_HW = 0
152 } hal_g2d_codec_type_t;
153 
155 typedef enum {
156  HAL_G2D_GET_HANDLE_MODE_BLOCKING = 0,
157  HAL_G2D_GET_HANDLE_MODE_NON_BLOCKING
158 } hal_g2d_get_handle_mode_t;
159 
161 typedef enum {
162  HAL_G2D_COLOR_FORMAT_RGB565 = 0,
163  HAL_G2D_COLOR_FORMAT_RGB888,
164  HAL_G2D_COLOR_FORMAT_BGR888,
165  HAL_G2D_COLOR_FORMAT_ARGB8565,
166  HAL_G2D_COLOR_FORMAT_ARGB6666,
167  HAL_G2D_COLOR_FORMAT_ARGB8888,
168  HAL_G2D_COLOR_FORMAT_PARGB8565,
169  HAL_G2D_COLOR_FORMAT_PARGB6666,
170  HAL_G2D_COLOR_FORMAT_PARGB8888,
171  HAL_G2D_COLOR_FORMAT_UYVY
172 } hal_g2d_color_format_t;
173 
175 typedef enum {
176  HAL_G2D_SUPPORTED_FUNCTION_BITBLT = 0,
177  HAL_G2D_SUPPORTED_FUNCTION_RECTFILL,
178  HAL_G2D_SUPPORTED_FUNCTION_FONT,
179  HAL_G2D_SUPPORTED_FUNCTION_OVERLAY,
180  HAL_G2D_SUPPORTED_FUNCTION_DITHERING
181 } hal_g2d_supported_function_t;
182 
184 typedef enum {
185  HAL_G2D_OVERLAY_LAYER0 = 0,
186  HAL_G2D_OVERLAY_LAYER1 = 1,
187  HAL_G2D_OVERLAY_LAYER2 = 2,
188  HAL_G2D_OVERLAY_LAYER3 = 3
189 } hal_g2d_overlay_layer_t;
190 
192 typedef enum {
193  HAL_G2D_OVERLAY_LAYER_FUNCTION_FONT = 0,
194  HAL_G2D_OVERLAY_LAYER_FUNCTION_RECTFILL,
195  HAL_G2D_OVERLAY_LAYER_FUNCTION_BUFFER
196 } hal_g2d_overlay_layer_function_t;
197 
199 typedef enum {
200  HAL_G2D_ROTATE_ANGLE_0 = 0,
201  HAL_G2D_ROTATE_ANGLE_90,
202  HAL_G2D_ROTATE_ANGLE_180,
203  HAL_G2D_ROTATE_ANGLE_270,
204  HAL_G2D_ROTATE_ANGLE_MIRROR_0,
205  HAL_G2D_ROTATE_ANGLE_MIRROR_90,
206  HAL_G2D_ROTATE_ANGLE_MIRROR_180,
207  HAL_G2D_ROTATE_ANGLE_MIRROR_270
208 } hal_g2d_rotate_angle_t;
209 
211 typedef enum {
212  HAL_G2D_FONT_FORMAT_1_BIT = 0,
213  HAL_G2D_FONT_FORMAT_2_BIT,
214  HAL_G2D_FONT_FORMAT_4_BIT,
215  HAL_G2D_FONT_FORMAT_8_BIT
216 } hal_g2d_font_format_t;
217 
219 typedef enum {
220  HAL_G2D_DITHERING_MODE_DISABLE = 0,
221  HAL_G2D_DITHERING_MODE_RANDOM,
222  HAL_G2D_DITHERING_MODE_FIXED_PATTERN
223 } hal_g2d_dithering_mode_t;
224 
229 /*****************************************************************************
230  * Structures
231  *****************************************************************************/
232 
238 typedef struct hal_g2d_hanele_struct_t hal_g2d_handle_t;
239 
257 typedef bool (*hal_g2d_callback_t)(void *);
258 
263 /*****************************************************************************
264  * Functions
265  *****************************************************************************/
266 
271 hal_g2d_status_t hal_g2d_init(void);
272 
281 hal_g2d_status_t hal_g2d_get_handle(hal_g2d_handle_t **handle_ptr, hal_g2d_codec_type_t codec_type, hal_g2d_get_handle_mode_t handle_mode);
282 
289 hal_g2d_status_t hal_g2d_release_handle(hal_g2d_handle_t *handle);
290 
300 hal_g2d_status_t hal_g2d_query_rgb_buffer_range(hal_g2d_handle_t *handle,
301  uint32_t *min_width, uint32_t *max_width, uint32_t *min_height, uint32_t *max_height);
302 
309 hal_g2d_status_t hal_g2d_register_callback(hal_g2d_handle_t *handle, hal_g2d_callback_t callback);
310 
321 hal_g2d_status_t hal_g2d_set_clipping_window(hal_g2d_handle_t *handle, int32_t x, int32_t y, int32_t width, int32_t height);
322 
336 hal_g2d_status_t hal_g2d_replace_color(hal_g2d_handle_t *handle,
337  uint8_t alpha0, uint8_t red0, uint8_t green0, uint8_t blue0, uint8_t alpha1, uint8_t red1, uint8_t green1, uint8_t blue1);
338 
349 hal_g2d_status_t hal_g2d_set_source_key(hal_g2d_handle_t *handle, uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue);
350 
363 hal_g2d_status_t hal_set_rgb_buffer(hal_g2d_handle_t *handle,
364  uint8_t *buffer, uint32_t size, uint32_t width, uint32_t height, hal_g2d_color_format_t color_format);
365 
377 hal_g2d_status_t hal_g2d_set_rgb_buffer(hal_g2d_handle_t *handle,
378  uint8_t *buffer, uint32_t size, uint32_t width, uint32_t height, hal_g2d_color_format_t color_format);
379 
386 hal_g2d_status_t hal_g2d_get_status(hal_g2d_handle_t *handle);
387 
395 hal_g2d_status_t hal_g2d_query_support(hal_g2d_codec_type_t codec_type, hal_g2d_supported_function_t function_type);
396 
404 hal_g2d_status_t hal_g2d_overlay_enable_layer(hal_g2d_handle_t *handle, hal_g2d_overlay_layer_t layer, bool show_layer);
405 
413 hal_g2d_status_t hal_g2d_overlay_set_layer_function(hal_g2d_handle_t *handle,
414  hal_g2d_overlay_layer_t layer, hal_g2d_overlay_layer_function_t function);
415 
423 hal_g2d_status_t hal_g2d_overlay_set_layer_rectfill_color(hal_g2d_handle_t *handle,
424  hal_g2d_overlay_layer_t layer, uint32_t rectfill_color);
425 
435 hal_g2d_status_t hal_g2d_overlay_set_layer_buffer(hal_g2d_handle_t *handle,
436  hal_g2d_overlay_layer_t layer, uint8_t *buffer, uint32_t size);
437 
450 hal_g2d_status_t hal_g2d_overlay_set_layer_rgb_buffer(hal_g2d_handle_t *handle,
451  hal_g2d_overlay_layer_t layer, uint8_t *buffer, uint32_t size,
452  uint32_t width, uint32_t height, hal_g2d_color_format_t color_format);
453 
467 hal_g2d_status_t hal_g2d_overlay_set_layer_yuv_buffer(hal_g2d_handle_t *handle,
468  hal_g2d_overlay_layer_t layer, uint8_t *buffer[3], uint32_t size[3],
469  uint32_t width, uint32_t height, hal_g2d_color_format_t color_format);
470 
482 hal_g2d_status_t hal_g2d_overlay_set_layer_window(hal_g2d_handle_t *handle,
483  hal_g2d_overlay_layer_t layer, int32_t x, int32_t y, uint32_t width, uint32_t height);
484 
492 hal_g2d_status_t hal_g2d_overlay_set_layer_source_key(hal_g2d_handle_t *handle,
493  hal_g2d_overlay_layer_t layer, uint32_t src_key_value);
494 
502 hal_g2d_status_t hal_g2d_overlay_set_layer_rotation(hal_g2d_handle_t *handle,
503  hal_g2d_overlay_layer_t layer, hal_g2d_rotate_angle_t rotation);
504 
512 hal_g2d_status_t hal_g2d_overlay_set_layer_alpha(hal_g2d_handle_t *handle,
513  hal_g2d_overlay_layer_t layer, uint32_t alpha_value);
514 
521 hal_g2d_status_t hal_g2d_overlay_set_background_color(hal_g2d_handle_t *handle, uint32_t bg_color);
522 
529 hal_g2d_status_t hal_g2d_overlay_set_alpha(hal_g2d_handle_t *handle, uint32_t alpha_value);
530 
538 hal_g2d_status_t hal_g2d_overlay_set_window(hal_g2d_handle_t *handle, int32_t x, int32_t y);
539 
550 hal_g2d_status_t hal_g2d_overlay_set_roi_window(hal_g2d_handle_t *handle, int32_t x, int32_t y, uint32_t width, uint32_t height);
551 
558 hal_g2d_status_t hal_g2d_overlay_start(hal_g2d_handle_t *handle);
559 
570 hal_g2d_status_t hal_g2d_set_dithering(hal_g2d_handle_t *handle, hal_g2d_dithering_mode_t mode, uint8_t red_bit, uint8_t green_bit, uint8_t blue_bit);
571 
580 hal_g2d_status_t hal_g2d_overlay_set_layer_font_format(hal_g2d_handle_t *handle, hal_g2d_overlay_layer_t layer, hal_g2d_font_format_t format);
581 
590 hal_g2d_status_t hal_g2d_overlay_set_layer_font_color(hal_g2d_handle_t *handle, hal_g2d_overlay_layer_t layer, uint32_t color);
591 
603 hal_g2d_status_t hal_g2d_rectfill_set_destination_window(hal_g2d_handle_t *handle, int32_t x, int32_t y, int32_t width, int32_t height);
604 
612 hal_g2d_status_t hal_g2d_rectfill_set_color(hal_g2d_handle_t *handle, uint32_t color);
613 
628 hal_g2d_status_t hal_g2d_rectangle_fill_query_window_range(hal_g2d_handle_t *handle,
629  int32_t *min_x, int32_t *max_x, int32_t *min_y, int32_t *max_y,
630  uint32_t *min_width, uint32_t *max_width, uint32_t *min_height, uint32_t *max_height);
631 
639 hal_g2d_status_t hal_g2d_rectfill_start(hal_g2d_handle_t *handle);
640 
641 #ifdef __cplusplus
642 }
643 #endif
644 
650 #endif /* HAL_G2D_MODULE_ENABLED */
651 #endif /* __HAL_G2D_H__ */