18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd 48c2ecf20Sopenharmony_ci * Author:Mark Yao <mark.yao@rock-chips.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _ROCKCHIP_DRM_VOP_H 88c2ecf20Sopenharmony_ci#define _ROCKCHIP_DRM_VOP_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* 118c2ecf20Sopenharmony_ci * major: IP major version, used for IP structure 128c2ecf20Sopenharmony_ci * minor: big feature change under same structure 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci#define VOP_VERSION(major, minor) ((major) << 8 | (minor)) 158c2ecf20Sopenharmony_ci#define VOP_MAJOR(version) ((version) >> 8) 168c2ecf20Sopenharmony_ci#define VOP_MINOR(version) ((version) & 0xff) 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define NUM_YUV2YUV_COEFFICIENTS 12 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* AFBC supports a number of configurable modes. Relevant to us is block size 218c2ecf20Sopenharmony_ci * (16x16 or 32x8), storage modifiers (SPARSE, SPLIT), and the YUV-like 228c2ecf20Sopenharmony_ci * colourspace transform (YTR). 16x16 SPARSE mode is always used. SPLIT mode 238c2ecf20Sopenharmony_ci * could be enabled via the hreg_block_split register, but is not currently 248c2ecf20Sopenharmony_ci * handled. The colourspace transform is implicitly always assumed by the 258c2ecf20Sopenharmony_ci * decoder, so consumers must use this transform as well. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * Failure to match modifiers will cause errors displaying AFBC buffers 288c2ecf20Sopenharmony_ci * produced by conformant AFBC producers, including Mesa. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci#define ROCKCHIP_AFBC_MOD \ 318c2ecf20Sopenharmony_ci DRM_FORMAT_MOD_ARM_AFBC( \ 328c2ecf20Sopenharmony_ci AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE \ 338c2ecf20Sopenharmony_ci | AFBC_FORMAT_MOD_YTR \ 348c2ecf20Sopenharmony_ci ) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cienum vop_data_format { 378c2ecf20Sopenharmony_ci VOP_FMT_ARGB8888 = 0, 388c2ecf20Sopenharmony_ci VOP_FMT_RGB888, 398c2ecf20Sopenharmony_ci VOP_FMT_RGB565, 408c2ecf20Sopenharmony_ci VOP_FMT_YUV420SP = 4, 418c2ecf20Sopenharmony_ci VOP_FMT_YUV422SP, 428c2ecf20Sopenharmony_ci VOP_FMT_YUV444SP, 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct vop_reg { 468c2ecf20Sopenharmony_ci uint32_t mask; 478c2ecf20Sopenharmony_ci uint16_t offset; 488c2ecf20Sopenharmony_ci uint8_t shift; 498c2ecf20Sopenharmony_ci bool write_mask; 508c2ecf20Sopenharmony_ci bool relaxed; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistruct vop_afbc { 548c2ecf20Sopenharmony_ci struct vop_reg enable; 558c2ecf20Sopenharmony_ci struct vop_reg win_sel; 568c2ecf20Sopenharmony_ci struct vop_reg format; 578c2ecf20Sopenharmony_ci struct vop_reg hreg_block_split; 588c2ecf20Sopenharmony_ci struct vop_reg pic_size; 598c2ecf20Sopenharmony_ci struct vop_reg hdr_ptr; 608c2ecf20Sopenharmony_ci struct vop_reg rstn; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistruct vop_modeset { 648c2ecf20Sopenharmony_ci struct vop_reg htotal_pw; 658c2ecf20Sopenharmony_ci struct vop_reg hact_st_end; 668c2ecf20Sopenharmony_ci struct vop_reg hpost_st_end; 678c2ecf20Sopenharmony_ci struct vop_reg vtotal_pw; 688c2ecf20Sopenharmony_ci struct vop_reg vact_st_end; 698c2ecf20Sopenharmony_ci struct vop_reg vpost_st_end; 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistruct vop_output { 738c2ecf20Sopenharmony_ci struct vop_reg pin_pol; 748c2ecf20Sopenharmony_ci struct vop_reg dp_pin_pol; 758c2ecf20Sopenharmony_ci struct vop_reg dp_dclk_pol; 768c2ecf20Sopenharmony_ci struct vop_reg edp_pin_pol; 778c2ecf20Sopenharmony_ci struct vop_reg edp_dclk_pol; 788c2ecf20Sopenharmony_ci struct vop_reg hdmi_pin_pol; 798c2ecf20Sopenharmony_ci struct vop_reg hdmi_dclk_pol; 808c2ecf20Sopenharmony_ci struct vop_reg mipi_pin_pol; 818c2ecf20Sopenharmony_ci struct vop_reg mipi_dclk_pol; 828c2ecf20Sopenharmony_ci struct vop_reg rgb_pin_pol; 838c2ecf20Sopenharmony_ci struct vop_reg rgb_dclk_pol; 848c2ecf20Sopenharmony_ci struct vop_reg dp_en; 858c2ecf20Sopenharmony_ci struct vop_reg edp_en; 868c2ecf20Sopenharmony_ci struct vop_reg hdmi_en; 878c2ecf20Sopenharmony_ci struct vop_reg mipi_en; 888c2ecf20Sopenharmony_ci struct vop_reg mipi_dual_channel_en; 898c2ecf20Sopenharmony_ci struct vop_reg rgb_en; 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistruct vop_common { 938c2ecf20Sopenharmony_ci struct vop_reg cfg_done; 948c2ecf20Sopenharmony_ci struct vop_reg dsp_blank; 958c2ecf20Sopenharmony_ci struct vop_reg data_blank; 968c2ecf20Sopenharmony_ci struct vop_reg pre_dither_down; 978c2ecf20Sopenharmony_ci struct vop_reg dither_down_sel; 988c2ecf20Sopenharmony_ci struct vop_reg dither_down_mode; 998c2ecf20Sopenharmony_ci struct vop_reg dither_down_en; 1008c2ecf20Sopenharmony_ci struct vop_reg dither_up; 1018c2ecf20Sopenharmony_ci struct vop_reg dsp_lut_en; 1028c2ecf20Sopenharmony_ci struct vop_reg gate_en; 1038c2ecf20Sopenharmony_ci struct vop_reg mmu_en; 1048c2ecf20Sopenharmony_ci struct vop_reg out_mode; 1058c2ecf20Sopenharmony_ci struct vop_reg standby; 1068c2ecf20Sopenharmony_ci}; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistruct vop_misc { 1098c2ecf20Sopenharmony_ci struct vop_reg global_regdone_en; 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistruct vop_intr { 1138c2ecf20Sopenharmony_ci const int *intrs; 1148c2ecf20Sopenharmony_ci uint32_t nintrs; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci struct vop_reg line_flag_num[2]; 1178c2ecf20Sopenharmony_ci struct vop_reg enable; 1188c2ecf20Sopenharmony_ci struct vop_reg clear; 1198c2ecf20Sopenharmony_ci struct vop_reg status; 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct vop_scl_extension { 1238c2ecf20Sopenharmony_ci struct vop_reg cbcr_vsd_mode; 1248c2ecf20Sopenharmony_ci struct vop_reg cbcr_vsu_mode; 1258c2ecf20Sopenharmony_ci struct vop_reg cbcr_hsd_mode; 1268c2ecf20Sopenharmony_ci struct vop_reg cbcr_ver_scl_mode; 1278c2ecf20Sopenharmony_ci struct vop_reg cbcr_hor_scl_mode; 1288c2ecf20Sopenharmony_ci struct vop_reg yrgb_vsd_mode; 1298c2ecf20Sopenharmony_ci struct vop_reg yrgb_vsu_mode; 1308c2ecf20Sopenharmony_ci struct vop_reg yrgb_hsd_mode; 1318c2ecf20Sopenharmony_ci struct vop_reg yrgb_ver_scl_mode; 1328c2ecf20Sopenharmony_ci struct vop_reg yrgb_hor_scl_mode; 1338c2ecf20Sopenharmony_ci struct vop_reg line_load_mode; 1348c2ecf20Sopenharmony_ci struct vop_reg cbcr_axi_gather_num; 1358c2ecf20Sopenharmony_ci struct vop_reg yrgb_axi_gather_num; 1368c2ecf20Sopenharmony_ci struct vop_reg vsd_cbcr_gt2; 1378c2ecf20Sopenharmony_ci struct vop_reg vsd_cbcr_gt4; 1388c2ecf20Sopenharmony_ci struct vop_reg vsd_yrgb_gt2; 1398c2ecf20Sopenharmony_ci struct vop_reg vsd_yrgb_gt4; 1408c2ecf20Sopenharmony_ci struct vop_reg bic_coe_sel; 1418c2ecf20Sopenharmony_ci struct vop_reg cbcr_axi_gather_en; 1428c2ecf20Sopenharmony_ci struct vop_reg yrgb_axi_gather_en; 1438c2ecf20Sopenharmony_ci struct vop_reg lb_mode; 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct vop_scl_regs { 1478c2ecf20Sopenharmony_ci const struct vop_scl_extension *ext; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci struct vop_reg scale_yrgb_x; 1508c2ecf20Sopenharmony_ci struct vop_reg scale_yrgb_y; 1518c2ecf20Sopenharmony_ci struct vop_reg scale_cbcr_x; 1528c2ecf20Sopenharmony_ci struct vop_reg scale_cbcr_y; 1538c2ecf20Sopenharmony_ci}; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_cistruct vop_yuv2yuv_phy { 1568c2ecf20Sopenharmony_ci struct vop_reg y2r_coefficients[NUM_YUV2YUV_COEFFICIENTS]; 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistruct vop_win_phy { 1608c2ecf20Sopenharmony_ci const struct vop_scl_regs *scl; 1618c2ecf20Sopenharmony_ci const uint32_t *data_formats; 1628c2ecf20Sopenharmony_ci uint32_t nformats; 1638c2ecf20Sopenharmony_ci const uint64_t *format_modifiers; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci struct vop_reg enable; 1668c2ecf20Sopenharmony_ci struct vop_reg gate; 1678c2ecf20Sopenharmony_ci struct vop_reg format; 1688c2ecf20Sopenharmony_ci struct vop_reg rb_swap; 1698c2ecf20Sopenharmony_ci struct vop_reg act_info; 1708c2ecf20Sopenharmony_ci struct vop_reg dsp_info; 1718c2ecf20Sopenharmony_ci struct vop_reg dsp_st; 1728c2ecf20Sopenharmony_ci struct vop_reg yrgb_mst; 1738c2ecf20Sopenharmony_ci struct vop_reg uv_mst; 1748c2ecf20Sopenharmony_ci struct vop_reg yrgb_vir; 1758c2ecf20Sopenharmony_ci struct vop_reg uv_vir; 1768c2ecf20Sopenharmony_ci struct vop_reg y_mir_en; 1778c2ecf20Sopenharmony_ci struct vop_reg x_mir_en; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci struct vop_reg dst_alpha_ctl; 1808c2ecf20Sopenharmony_ci struct vop_reg src_alpha_ctl; 1818c2ecf20Sopenharmony_ci struct vop_reg alpha_pre_mul; 1828c2ecf20Sopenharmony_ci struct vop_reg alpha_mode; 1838c2ecf20Sopenharmony_ci struct vop_reg alpha_en; 1848c2ecf20Sopenharmony_ci struct vop_reg channel; 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistruct vop_win_yuv2yuv_data { 1888c2ecf20Sopenharmony_ci uint32_t base; 1898c2ecf20Sopenharmony_ci const struct vop_yuv2yuv_phy *phy; 1908c2ecf20Sopenharmony_ci struct vop_reg y2r_en; 1918c2ecf20Sopenharmony_ci}; 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cistruct vop_win_data { 1948c2ecf20Sopenharmony_ci uint32_t base; 1958c2ecf20Sopenharmony_ci const struct vop_win_phy *phy; 1968c2ecf20Sopenharmony_ci enum drm_plane_type type; 1978c2ecf20Sopenharmony_ci}; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_cistruct vop_data { 2008c2ecf20Sopenharmony_ci uint32_t version; 2018c2ecf20Sopenharmony_ci const struct vop_intr *intr; 2028c2ecf20Sopenharmony_ci const struct vop_common *common; 2038c2ecf20Sopenharmony_ci const struct vop_misc *misc; 2048c2ecf20Sopenharmony_ci const struct vop_modeset *modeset; 2058c2ecf20Sopenharmony_ci const struct vop_output *output; 2068c2ecf20Sopenharmony_ci const struct vop_afbc *afbc; 2078c2ecf20Sopenharmony_ci const struct vop_win_yuv2yuv_data *win_yuv2yuv; 2088c2ecf20Sopenharmony_ci const struct vop_win_data *win; 2098c2ecf20Sopenharmony_ci unsigned int win_size; 2108c2ecf20Sopenharmony_ci unsigned int lut_size; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci#define VOP_FEATURE_OUTPUT_RGB10 BIT(0) 2138c2ecf20Sopenharmony_ci#define VOP_FEATURE_INTERNAL_RGB BIT(1) 2148c2ecf20Sopenharmony_ci u64 feature; 2158c2ecf20Sopenharmony_ci}; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci/* interrupt define */ 2188c2ecf20Sopenharmony_ci#define DSP_HOLD_VALID_INTR (1 << 0) 2198c2ecf20Sopenharmony_ci#define FS_INTR (1 << 1) 2208c2ecf20Sopenharmony_ci#define LINE_FLAG_INTR (1 << 2) 2218c2ecf20Sopenharmony_ci#define BUS_ERROR_INTR (1 << 3) 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci#define INTR_MASK (DSP_HOLD_VALID_INTR | FS_INTR | \ 2248c2ecf20Sopenharmony_ci LINE_FLAG_INTR | BUS_ERROR_INTR) 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci#define DSP_HOLD_VALID_INTR_EN(x) ((x) << 4) 2278c2ecf20Sopenharmony_ci#define FS_INTR_EN(x) ((x) << 5) 2288c2ecf20Sopenharmony_ci#define LINE_FLAG_INTR_EN(x) ((x) << 6) 2298c2ecf20Sopenharmony_ci#define BUS_ERROR_INTR_EN(x) ((x) << 7) 2308c2ecf20Sopenharmony_ci#define DSP_HOLD_VALID_INTR_MASK (1 << 4) 2318c2ecf20Sopenharmony_ci#define FS_INTR_MASK (1 << 5) 2328c2ecf20Sopenharmony_ci#define LINE_FLAG_INTR_MASK (1 << 6) 2338c2ecf20Sopenharmony_ci#define BUS_ERROR_INTR_MASK (1 << 7) 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci#define INTR_CLR_SHIFT 8 2368c2ecf20Sopenharmony_ci#define DSP_HOLD_VALID_INTR_CLR (1 << (INTR_CLR_SHIFT + 0)) 2378c2ecf20Sopenharmony_ci#define FS_INTR_CLR (1 << (INTR_CLR_SHIFT + 1)) 2388c2ecf20Sopenharmony_ci#define LINE_FLAG_INTR_CLR (1 << (INTR_CLR_SHIFT + 2)) 2398c2ecf20Sopenharmony_ci#define BUS_ERROR_INTR_CLR (1 << (INTR_CLR_SHIFT + 3)) 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci#define DSP_LINE_NUM(x) (((x) & 0x1fff) << 12) 2428c2ecf20Sopenharmony_ci#define DSP_LINE_NUM_MASK (0x1fff << 12) 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/* src alpha ctrl define */ 2458c2ecf20Sopenharmony_ci#define SRC_FADING_VALUE(x) (((x) & 0xff) << 24) 2468c2ecf20Sopenharmony_ci#define SRC_GLOBAL_ALPHA(x) (((x) & 0xff) << 16) 2478c2ecf20Sopenharmony_ci#define SRC_FACTOR_M0(x) (((x) & 0x7) << 6) 2488c2ecf20Sopenharmony_ci#define SRC_ALPHA_CAL_M0(x) (((x) & 0x1) << 5) 2498c2ecf20Sopenharmony_ci#define SRC_BLEND_M0(x) (((x) & 0x3) << 3) 2508c2ecf20Sopenharmony_ci#define SRC_ALPHA_M0(x) (((x) & 0x1) << 2) 2518c2ecf20Sopenharmony_ci#define SRC_COLOR_M0(x) (((x) & 0x1) << 1) 2528c2ecf20Sopenharmony_ci#define SRC_ALPHA_EN(x) (((x) & 0x1) << 0) 2538c2ecf20Sopenharmony_ci/* dst alpha ctrl define */ 2548c2ecf20Sopenharmony_ci#define DST_FACTOR_M0(x) (((x) & 0x7) << 6) 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci/* 2578c2ecf20Sopenharmony_ci * display output interface supported by rockchip lcdc 2588c2ecf20Sopenharmony_ci */ 2598c2ecf20Sopenharmony_ci#define ROCKCHIP_OUT_MODE_P888 0 2608c2ecf20Sopenharmony_ci#define ROCKCHIP_OUT_MODE_P666 1 2618c2ecf20Sopenharmony_ci#define ROCKCHIP_OUT_MODE_P565 2 2628c2ecf20Sopenharmony_ci/* for use special outface */ 2638c2ecf20Sopenharmony_ci#define ROCKCHIP_OUT_MODE_AAAA 15 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci/* output flags */ 2668c2ecf20Sopenharmony_ci#define ROCKCHIP_OUTPUT_DSI_DUAL BIT(0) 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cienum alpha_mode { 2698c2ecf20Sopenharmony_ci ALPHA_STRAIGHT, 2708c2ecf20Sopenharmony_ci ALPHA_INVERSE, 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_cienum global_blend_mode { 2748c2ecf20Sopenharmony_ci ALPHA_GLOBAL, 2758c2ecf20Sopenharmony_ci ALPHA_PER_PIX, 2768c2ecf20Sopenharmony_ci ALPHA_PER_PIX_GLOBAL, 2778c2ecf20Sopenharmony_ci}; 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_cienum alpha_cal_mode { 2808c2ecf20Sopenharmony_ci ALPHA_SATURATION, 2818c2ecf20Sopenharmony_ci ALPHA_NO_SATURATION, 2828c2ecf20Sopenharmony_ci}; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_cienum color_mode { 2858c2ecf20Sopenharmony_ci ALPHA_SRC_PRE_MUL, 2868c2ecf20Sopenharmony_ci ALPHA_SRC_NO_PRE_MUL, 2878c2ecf20Sopenharmony_ci}; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_cienum factor_mode { 2908c2ecf20Sopenharmony_ci ALPHA_ZERO, 2918c2ecf20Sopenharmony_ci ALPHA_ONE, 2928c2ecf20Sopenharmony_ci ALPHA_SRC, 2938c2ecf20Sopenharmony_ci ALPHA_SRC_INVERSE, 2948c2ecf20Sopenharmony_ci ALPHA_SRC_GLOBAL, 2958c2ecf20Sopenharmony_ci}; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cienum scale_mode { 2988c2ecf20Sopenharmony_ci SCALE_NONE = 0x0, 2998c2ecf20Sopenharmony_ci SCALE_UP = 0x1, 3008c2ecf20Sopenharmony_ci SCALE_DOWN = 0x2 3018c2ecf20Sopenharmony_ci}; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cienum lb_mode { 3048c2ecf20Sopenharmony_ci LB_YUV_3840X5 = 0x0, 3058c2ecf20Sopenharmony_ci LB_YUV_2560X8 = 0x1, 3068c2ecf20Sopenharmony_ci LB_RGB_3840X2 = 0x2, 3078c2ecf20Sopenharmony_ci LB_RGB_2560X4 = 0x3, 3088c2ecf20Sopenharmony_ci LB_RGB_1920X5 = 0x4, 3098c2ecf20Sopenharmony_ci LB_RGB_1280X8 = 0x5 3108c2ecf20Sopenharmony_ci}; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_cienum sacle_up_mode { 3138c2ecf20Sopenharmony_ci SCALE_UP_BIL = 0x0, 3148c2ecf20Sopenharmony_ci SCALE_UP_BIC = 0x1 3158c2ecf20Sopenharmony_ci}; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_cienum scale_down_mode { 3188c2ecf20Sopenharmony_ci SCALE_DOWN_BIL = 0x0, 3198c2ecf20Sopenharmony_ci SCALE_DOWN_AVG = 0x1 3208c2ecf20Sopenharmony_ci}; 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_cienum dither_down_mode { 3238c2ecf20Sopenharmony_ci RGB888_TO_RGB565 = 0x0, 3248c2ecf20Sopenharmony_ci RGB888_TO_RGB666 = 0x1 3258c2ecf20Sopenharmony_ci}; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_cienum dither_down_mode_sel { 3288c2ecf20Sopenharmony_ci DITHER_DOWN_ALLEGRO = 0x0, 3298c2ecf20Sopenharmony_ci DITHER_DOWN_FRC = 0x1 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cienum vop_pol { 3338c2ecf20Sopenharmony_ci HSYNC_POSITIVE = 0, 3348c2ecf20Sopenharmony_ci VSYNC_POSITIVE = 1, 3358c2ecf20Sopenharmony_ci DEN_NEGATIVE = 2 3368c2ecf20Sopenharmony_ci}; 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci#define FRAC_16_16(mult, div) (((mult) << 16) / (div)) 3398c2ecf20Sopenharmony_ci#define SCL_FT_DEFAULT_FIXPOINT_SHIFT 12 3408c2ecf20Sopenharmony_ci#define SCL_MAX_VSKIPLINES 4 3418c2ecf20Sopenharmony_ci#define MIN_SCL_FT_AFTER_VSKIP 1 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_cistatic inline uint16_t scl_cal_scale(int src, int dst, int shift) 3448c2ecf20Sopenharmony_ci{ 3458c2ecf20Sopenharmony_ci return ((src * 2 - 3) << (shift - 1)) / (dst - 1); 3468c2ecf20Sopenharmony_ci} 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_cistatic inline uint16_t scl_cal_scale2(int src, int dst) 3498c2ecf20Sopenharmony_ci{ 3508c2ecf20Sopenharmony_ci return ((src - 1) << 12) / (dst - 1); 3518c2ecf20Sopenharmony_ci} 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci#define GET_SCL_FT_BILI_DN(src, dst) scl_cal_scale(src, dst, 12) 3548c2ecf20Sopenharmony_ci#define GET_SCL_FT_BILI_UP(src, dst) scl_cal_scale(src, dst, 16) 3558c2ecf20Sopenharmony_ci#define GET_SCL_FT_BIC(src, dst) scl_cal_scale(src, dst, 16) 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_cistatic inline uint16_t scl_get_bili_dn_vskip(int src_h, int dst_h, 3588c2ecf20Sopenharmony_ci int vskiplines) 3598c2ecf20Sopenharmony_ci{ 3608c2ecf20Sopenharmony_ci int act_height; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci act_height = DIV_ROUND_UP(src_h, vskiplines); 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci if (act_height == dst_h) 3658c2ecf20Sopenharmony_ci return GET_SCL_FT_BILI_DN(src_h, dst_h) / vskiplines; 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci return GET_SCL_FT_BILI_DN(act_height, dst_h); 3688c2ecf20Sopenharmony_ci} 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_cistatic inline enum scale_mode scl_get_scl_mode(int src, int dst) 3718c2ecf20Sopenharmony_ci{ 3728c2ecf20Sopenharmony_ci if (src < dst) 3738c2ecf20Sopenharmony_ci return SCALE_UP; 3748c2ecf20Sopenharmony_ci else if (src > dst) 3758c2ecf20Sopenharmony_ci return SCALE_DOWN; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci return SCALE_NONE; 3788c2ecf20Sopenharmony_ci} 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_cistatic inline int scl_get_vskiplines(uint32_t srch, uint32_t dsth) 3818c2ecf20Sopenharmony_ci{ 3828c2ecf20Sopenharmony_ci uint32_t vskiplines; 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci for (vskiplines = SCL_MAX_VSKIPLINES; vskiplines > 1; vskiplines /= 2) 3858c2ecf20Sopenharmony_ci if (srch >= vskiplines * dsth * MIN_SCL_FT_AFTER_VSKIP) 3868c2ecf20Sopenharmony_ci break; 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci return vskiplines; 3898c2ecf20Sopenharmony_ci} 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_cistatic inline int scl_vop_cal_lb_mode(int width, bool is_yuv) 3928c2ecf20Sopenharmony_ci{ 3938c2ecf20Sopenharmony_ci int lb_mode; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci if (is_yuv) { 3968c2ecf20Sopenharmony_ci if (width > 1280) 3978c2ecf20Sopenharmony_ci lb_mode = LB_YUV_3840X5; 3988c2ecf20Sopenharmony_ci else 3998c2ecf20Sopenharmony_ci lb_mode = LB_YUV_2560X8; 4008c2ecf20Sopenharmony_ci } else { 4018c2ecf20Sopenharmony_ci if (width > 2560) 4028c2ecf20Sopenharmony_ci lb_mode = LB_RGB_3840X2; 4038c2ecf20Sopenharmony_ci else if (width > 1920) 4048c2ecf20Sopenharmony_ci lb_mode = LB_RGB_2560X4; 4058c2ecf20Sopenharmony_ci else 4068c2ecf20Sopenharmony_ci lb_mode = LB_RGB_1920X5; 4078c2ecf20Sopenharmony_ci } 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci return lb_mode; 4108c2ecf20Sopenharmony_ci} 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ciextern const struct component_ops vop_component_ops; 4138c2ecf20Sopenharmony_ci#endif /* _ROCKCHIP_DRM_VOP_H */ 414