13d0407baSopenharmony_ci/* 23d0407baSopenharmony_ci * Copyright (C) 2021 Rockchip Electronics Co., Ltd. 33d0407baSopenharmony_ci * Authors: 43d0407baSopenharmony_ci * Cerf Yu <cerf.yu@rock-chips.com> 53d0407baSopenharmony_ci * 63d0407baSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 73d0407baSopenharmony_ci * you may not use this file except in compliance with the License. 83d0407baSopenharmony_ci * You may obtain a copy of the License at 93d0407baSopenharmony_ci * 103d0407baSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 113d0407baSopenharmony_ci * 123d0407baSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 133d0407baSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 143d0407baSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 153d0407baSopenharmony_ci * See the License for the specific language governing permissions and 163d0407baSopenharmony_ci * limitations under the License. 173d0407baSopenharmony_ci */ 183d0407baSopenharmony_ci 193d0407baSopenharmony_ci#ifndef _RGA_IM2D_COMMON_H_ 203d0407baSopenharmony_ci#define _RGA_IM2D_COMMON_H_ 213d0407baSopenharmony_ci 223d0407baSopenharmony_ci#include "drmrga.h" 233d0407baSopenharmony_ci#include "im2d.h" 243d0407baSopenharmony_ci#include "im2d_hardware.h" 253d0407baSopenharmony_ci 263d0407baSopenharmony_ci#define ALIGN(val, align) (((val) + ((align) - 1)) & ~((align) - 1)) 273d0407baSopenharmony_ci#define DOWN_ALIGN(val, align) ((val) & ~((align) - 1)) 283d0407baSopenharmony_ci#define UNUSED(...) (void)(__VA_ARGS__) 293d0407baSopenharmony_ci/* 303d0407baSopenharmony_ci * version bit: 313d0407baSopenharmony_ci * 0~7b build 323d0407baSopenharmony_ci * 8~15b revision 333d0407baSopenharmony_ci * 16~23b minor 343d0407baSopenharmony_ci * 24~31b major 353d0407baSopenharmony_ci */ 363d0407baSopenharmony_ci#define RGA_GET_API_VERSION(v) {\ 373d0407baSopenharmony_ci (((v) >> 24) & 0xff), \ 383d0407baSopenharmony_ci (((v) >> 16) & 0xff), \ 393d0407baSopenharmony_ci (((v) >> 8) & 0xff), \ 403d0407baSopenharmony_ci {0}\ 413d0407baSopenharmony_ci } 423d0407baSopenharmony_ci 433d0407baSopenharmony_ci#define ERR_MSG_LEN 300 443d0407baSopenharmony_ci 453d0407baSopenharmony_ciint imSetErrorMsg(const char* format, ...); 463d0407baSopenharmony_ci 473d0407baSopenharmony_cibool rga_is_buffer_valid(rga_buffer_t buf); 483d0407baSopenharmony_cibool rga_is_rect_valid(im_rect rect); 493d0407baSopenharmony_civoid empty_structure(rga_buffer_t *src, rga_buffer_t *dst, rga_buffer_t *pat, 503d0407baSopenharmony_ci im_rect *srect, im_rect *drect, im_rect *prect, im_opt_t *opt); 513d0407baSopenharmony_ciIM_STATUS rga_set_buffer_info(rga_buffer_t dst, rga_info_t* dstinfo); 523d0407baSopenharmony_ciIM_STATUS rga_set_buffer_info(const rga_buffer_t src, rga_buffer_t dst, rga_info_t* srcinfo, rga_info_t* dstinfo); 533d0407baSopenharmony_ciinline void rga_apply_rect(rga_buffer_t *image, im_rect *rect) { 543d0407baSopenharmony_ci if (rect->width > 0 && rect->height > 0) { 553d0407baSopenharmony_ci image->width = rect->width; 563d0407baSopenharmony_ci image->height = rect->height; 573d0407baSopenharmony_ci } 583d0407baSopenharmony_ci} 593d0407baSopenharmony_ci 603d0407baSopenharmony_ciIM_STATUS rga_get_info(rga_info_table_entry *return_table); 613d0407baSopenharmony_ciIM_STATUS rga_check_driver(void); 623d0407baSopenharmony_ci 633d0407baSopenharmony_ciIM_STATUS rga_check_info(const char *name, const rga_buffer_t info, const im_rect rect, int resolution_usage); 643d0407baSopenharmony_ciIM_STATUS rga_check_limit(rga_buffer_t src, rga_buffer_t dst, int scale_usage, int mode_usage); 653d0407baSopenharmony_ciIM_STATUS rga_check_format(const char *name, rga_buffer_t info, im_rect rect, int format_usage, int mode_usgae); 663d0407baSopenharmony_ciIM_STATUS rga_check_align(const char *name, rga_buffer_t info, int byte_stride); 673d0407baSopenharmony_ciIM_STATUS rga_check_blend(rga_buffer_t src, rga_buffer_t pat, rga_buffer_t dst, int pat_enable, int mode_usage); 683d0407baSopenharmony_ciIM_STATUS rga_check_rotate(int mode_usage, rga_info_table_entry &table); 693d0407baSopenharmony_ciIM_STATUS rga_check_feature(rga_buffer_t src, rga_buffer_t pat, rga_buffer_t dst, 703d0407baSopenharmony_ci int pat_enable, int mode_usage, int feature_usage); 713d0407baSopenharmony_ci 723d0407baSopenharmony_ciIM_API IM_STATUS rga_import_buffers(struct rga_buffer_pool *buffer_pool); 733d0407baSopenharmony_ciIM_API IM_STATUS rga_release_buffers(struct rga_buffer_pool *buffer_pool); 743d0407baSopenharmony_ciIM_API rga_buffer_handle_t rga_import_buffer(uint64_t memory, int type, uint32_t size); 753d0407baSopenharmony_ciIM_API rga_buffer_handle_t rga_import_buffer(uint64_t memory, int type, im_handle_param_t *param); 763d0407baSopenharmony_ciIM_API IM_STATUS rga_release_buffer(int handle); 773d0407baSopenharmony_ci 783d0407baSopenharmony_ciIM_STATUS rga_get_opt(im_opt_t *opt, void *ptr); 793d0407baSopenharmony_ci 803d0407baSopenharmony_ciIM_API im_ctx_id_t rga_begin_job(uint32_t flags); 813d0407baSopenharmony_ciIM_API IM_STATUS rga_cancel(im_ctx_id_t id); 823d0407baSopenharmony_ci 833d0407baSopenharmony_ci#endif 84