162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd 462306a36Sopenharmony_ci * Author:Mark Yao <mark.yao@rock-chips.com> 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/component.h> 862306a36Sopenharmony_ci#include <linux/mod_devicetable.h> 962306a36Sopenharmony_ci#include <linux/module.h> 1062306a36Sopenharmony_ci#include <linux/of.h> 1162306a36Sopenharmony_ci#include <linux/platform_device.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <drm/drm_fourcc.h> 1462306a36Sopenharmony_ci#include <drm/drm_plane.h> 1562306a36Sopenharmony_ci#include <drm/drm_print.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#include "rockchip_drm_vop.h" 1862306a36Sopenharmony_ci#include "rockchip_vop_reg.h" 1962306a36Sopenharmony_ci#include "rockchip_drm_drv.h" 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define _VOP_REG(off, _mask, _shift, _write_mask, _relaxed) \ 2262306a36Sopenharmony_ci { \ 2362306a36Sopenharmony_ci .offset = off, \ 2462306a36Sopenharmony_ci .mask = _mask, \ 2562306a36Sopenharmony_ci .shift = _shift, \ 2662306a36Sopenharmony_ci .write_mask = _write_mask, \ 2762306a36Sopenharmony_ci .relaxed = _relaxed, \ 2862306a36Sopenharmony_ci } 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define VOP_REG(off, _mask, _shift) \ 3162306a36Sopenharmony_ci _VOP_REG(off, _mask, _shift, false, true) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#define VOP_REG_SYNC(off, _mask, _shift) \ 3462306a36Sopenharmony_ci _VOP_REG(off, _mask, _shift, false, false) 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#define VOP_REG_MASK_SYNC(off, _mask, _shift) \ 3762306a36Sopenharmony_ci _VOP_REG(off, _mask, _shift, true, false) 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cistatic const uint32_t formats_win_full[] = { 4062306a36Sopenharmony_ci DRM_FORMAT_XRGB8888, 4162306a36Sopenharmony_ci DRM_FORMAT_ARGB8888, 4262306a36Sopenharmony_ci DRM_FORMAT_XBGR8888, 4362306a36Sopenharmony_ci DRM_FORMAT_ABGR8888, 4462306a36Sopenharmony_ci DRM_FORMAT_RGB888, 4562306a36Sopenharmony_ci DRM_FORMAT_BGR888, 4662306a36Sopenharmony_ci DRM_FORMAT_RGB565, 4762306a36Sopenharmony_ci DRM_FORMAT_BGR565, 4862306a36Sopenharmony_ci DRM_FORMAT_NV12, 4962306a36Sopenharmony_ci DRM_FORMAT_NV21, 5062306a36Sopenharmony_ci DRM_FORMAT_NV16, 5162306a36Sopenharmony_ci DRM_FORMAT_NV61, 5262306a36Sopenharmony_ci DRM_FORMAT_NV24, 5362306a36Sopenharmony_ci DRM_FORMAT_NV42, 5462306a36Sopenharmony_ci}; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cistatic const uint64_t format_modifiers_win_full[] = { 5762306a36Sopenharmony_ci DRM_FORMAT_MOD_LINEAR, 5862306a36Sopenharmony_ci DRM_FORMAT_MOD_INVALID, 5962306a36Sopenharmony_ci}; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_cistatic const uint64_t format_modifiers_win_full_afbc[] = { 6262306a36Sopenharmony_ci ROCKCHIP_AFBC_MOD, 6362306a36Sopenharmony_ci DRM_FORMAT_MOD_LINEAR, 6462306a36Sopenharmony_ci DRM_FORMAT_MOD_INVALID, 6562306a36Sopenharmony_ci}; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_cistatic const uint32_t formats_win_lite[] = { 6862306a36Sopenharmony_ci DRM_FORMAT_XRGB8888, 6962306a36Sopenharmony_ci DRM_FORMAT_ARGB8888, 7062306a36Sopenharmony_ci DRM_FORMAT_XBGR8888, 7162306a36Sopenharmony_ci DRM_FORMAT_ABGR8888, 7262306a36Sopenharmony_ci DRM_FORMAT_RGB888, 7362306a36Sopenharmony_ci DRM_FORMAT_BGR888, 7462306a36Sopenharmony_ci DRM_FORMAT_RGB565, 7562306a36Sopenharmony_ci DRM_FORMAT_BGR565, 7662306a36Sopenharmony_ci}; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_cistatic const uint64_t format_modifiers_win_lite[] = { 7962306a36Sopenharmony_ci DRM_FORMAT_MOD_LINEAR, 8062306a36Sopenharmony_ci DRM_FORMAT_MOD_INVALID, 8162306a36Sopenharmony_ci}; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_cistatic const struct vop_scl_regs rk3036_win0_scl = { 8462306a36Sopenharmony_ci .scale_yrgb_x = VOP_REG(RK3036_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0), 8562306a36Sopenharmony_ci .scale_yrgb_y = VOP_REG(RK3036_WIN0_SCL_FACTOR_YRGB, 0xffff, 16), 8662306a36Sopenharmony_ci .scale_cbcr_x = VOP_REG(RK3036_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0), 8762306a36Sopenharmony_ci .scale_cbcr_y = VOP_REG(RK3036_WIN0_SCL_FACTOR_CBR, 0xffff, 16), 8862306a36Sopenharmony_ci}; 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_cistatic const struct vop_scl_regs rk3036_win1_scl = { 9162306a36Sopenharmony_ci .scale_yrgb_x = VOP_REG(RK3036_WIN1_SCL_FACTOR_YRGB, 0xffff, 0x0), 9262306a36Sopenharmony_ci .scale_yrgb_y = VOP_REG(RK3036_WIN1_SCL_FACTOR_YRGB, 0xffff, 16), 9362306a36Sopenharmony_ci}; 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_cistatic const struct vop_win_phy rk3036_win0_data = { 9662306a36Sopenharmony_ci .scl = &rk3036_win0_scl, 9762306a36Sopenharmony_ci .data_formats = formats_win_full, 9862306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 9962306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full, 10062306a36Sopenharmony_ci .enable = VOP_REG(RK3036_SYS_CTRL, 0x1, 0), 10162306a36Sopenharmony_ci .format = VOP_REG(RK3036_SYS_CTRL, 0x7, 3), 10262306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3036_SYS_CTRL, 0x1, 15), 10362306a36Sopenharmony_ci .act_info = VOP_REG(RK3036_WIN0_ACT_INFO, 0x1fff1fff, 0), 10462306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3036_WIN0_DSP_INFO, 0x0fff0fff, 0), 10562306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3036_WIN0_DSP_ST, 0x1fff1fff, 0), 10662306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3036_WIN0_YRGB_MST, 0xffffffff, 0), 10762306a36Sopenharmony_ci .uv_mst = VOP_REG(RK3036_WIN0_CBR_MST, 0xffffffff, 0), 10862306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3036_WIN0_VIR, 0xffff, 0), 10962306a36Sopenharmony_ci .uv_vir = VOP_REG(RK3036_WIN0_VIR, 0x1fff, 16), 11062306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 18), 11162306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3036_ALPHA_CTRL, 0x1, 0), 11262306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(RK3036_DSP_CTRL0, 0x1, 29), 11362306a36Sopenharmony_ci}; 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_cistatic const struct vop_win_phy rk3036_win1_data = { 11662306a36Sopenharmony_ci .scl = &rk3036_win1_scl, 11762306a36Sopenharmony_ci .data_formats = formats_win_lite, 11862306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 11962306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 12062306a36Sopenharmony_ci .enable = VOP_REG(RK3036_SYS_CTRL, 0x1, 1), 12162306a36Sopenharmony_ci .format = VOP_REG(RK3036_SYS_CTRL, 0x7, 6), 12262306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3036_SYS_CTRL, 0x1, 19), 12362306a36Sopenharmony_ci .act_info = VOP_REG(RK3036_WIN1_ACT_INFO, 0x1fff1fff, 0), 12462306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3036_WIN1_DSP_INFO, 0x0fff0fff, 0), 12562306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3036_WIN1_DSP_ST, 0x1fff1fff, 0), 12662306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3036_WIN1_MST, 0xffffffff, 0), 12762306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3036_WIN1_VIR, 0xffff, 0), 12862306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 19), 12962306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3036_ALPHA_CTRL, 0x1, 1), 13062306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(RK3036_DSP_CTRL0, 0x1, 29), 13162306a36Sopenharmony_ci}; 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_cistatic const struct vop_win_data rk3036_vop_win_data[] = { 13462306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3036_win0_data, 13562306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 13662306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3036_win1_data, 13762306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 13862306a36Sopenharmony_ci}; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_cistatic const int rk3036_vop_intrs[] = { 14162306a36Sopenharmony_ci DSP_HOLD_VALID_INTR, 14262306a36Sopenharmony_ci FS_INTR, 14362306a36Sopenharmony_ci LINE_FLAG_INTR, 14462306a36Sopenharmony_ci BUS_ERROR_INTR, 14562306a36Sopenharmony_ci}; 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_cistatic const struct vop_intr rk3036_intr = { 14862306a36Sopenharmony_ci .intrs = rk3036_vop_intrs, 14962306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(rk3036_vop_intrs), 15062306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(RK3036_INT_STATUS, 0xfff, 12), 15162306a36Sopenharmony_ci .status = VOP_REG_SYNC(RK3036_INT_STATUS, 0xf, 0), 15262306a36Sopenharmony_ci .enable = VOP_REG_SYNC(RK3036_INT_STATUS, 0xf, 4), 15362306a36Sopenharmony_ci .clear = VOP_REG_SYNC(RK3036_INT_STATUS, 0xf, 8), 15462306a36Sopenharmony_ci}; 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_cistatic const struct vop_modeset rk3036_modeset = { 15762306a36Sopenharmony_ci .htotal_pw = VOP_REG(RK3036_DSP_HTOTAL_HS_END, 0x1fff1fff, 0), 15862306a36Sopenharmony_ci .hact_st_end = VOP_REG(RK3036_DSP_HACT_ST_END, 0x1fff1fff, 0), 15962306a36Sopenharmony_ci .vtotal_pw = VOP_REG(RK3036_DSP_VTOTAL_VS_END, 0x1fff1fff, 0), 16062306a36Sopenharmony_ci .vact_st_end = VOP_REG(RK3036_DSP_VACT_ST_END, 0x1fff1fff, 0), 16162306a36Sopenharmony_ci}; 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_cistatic const struct vop_output rk3036_output = { 16462306a36Sopenharmony_ci .pin_pol = VOP_REG(RK3036_DSP_CTRL0, 0xf, 4), 16562306a36Sopenharmony_ci}; 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_cistatic const struct vop_common rk3036_common = { 16862306a36Sopenharmony_ci .standby = VOP_REG_SYNC(RK3036_SYS_CTRL, 0x1, 30), 16962306a36Sopenharmony_ci .out_mode = VOP_REG(RK3036_DSP_CTRL0, 0xf, 0), 17062306a36Sopenharmony_ci .dsp_blank = VOP_REG(RK3036_DSP_CTRL1, 0x1, 24), 17162306a36Sopenharmony_ci .dither_down_sel = VOP_REG(RK3036_DSP_CTRL0, 0x1, 27), 17262306a36Sopenharmony_ci .dither_down_en = VOP_REG(RK3036_DSP_CTRL0, 0x1, 11), 17362306a36Sopenharmony_ci .dither_down_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 10), 17462306a36Sopenharmony_ci .cfg_done = VOP_REG_SYNC(RK3036_REG_CFG_DONE, 0x1, 0), 17562306a36Sopenharmony_ci}; 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_cistatic const struct vop_data rk3036_vop = { 17862306a36Sopenharmony_ci .intr = &rk3036_intr, 17962306a36Sopenharmony_ci .common = &rk3036_common, 18062306a36Sopenharmony_ci .modeset = &rk3036_modeset, 18162306a36Sopenharmony_ci .output = &rk3036_output, 18262306a36Sopenharmony_ci .win = rk3036_vop_win_data, 18362306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3036_vop_win_data), 18462306a36Sopenharmony_ci .max_output = { 1920, 1080 }, 18562306a36Sopenharmony_ci}; 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_cistatic const struct vop_win_phy rk3126_win1_data = { 18862306a36Sopenharmony_ci .data_formats = formats_win_lite, 18962306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 19062306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 19162306a36Sopenharmony_ci .enable = VOP_REG(RK3036_SYS_CTRL, 0x1, 1), 19262306a36Sopenharmony_ci .format = VOP_REG(RK3036_SYS_CTRL, 0x7, 6), 19362306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3036_SYS_CTRL, 0x1, 19), 19462306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3126_WIN1_DSP_INFO, 0x0fff0fff, 0), 19562306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3126_WIN1_DSP_ST, 0x1fff1fff, 0), 19662306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3126_WIN1_MST, 0xffffffff, 0), 19762306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3036_WIN1_VIR, 0xffff, 0), 19862306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 19), 19962306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3036_ALPHA_CTRL, 0x1, 1), 20062306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(RK3036_DSP_CTRL0, 0x1, 29), 20162306a36Sopenharmony_ci}; 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_cistatic const struct vop_win_data rk3126_vop_win_data[] = { 20462306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3036_win0_data, 20562306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 20662306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3126_win1_data, 20762306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 20862306a36Sopenharmony_ci}; 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_cistatic const struct vop_data rk3126_vop = { 21162306a36Sopenharmony_ci .intr = &rk3036_intr, 21262306a36Sopenharmony_ci .common = &rk3036_common, 21362306a36Sopenharmony_ci .modeset = &rk3036_modeset, 21462306a36Sopenharmony_ci .output = &rk3036_output, 21562306a36Sopenharmony_ci .win = rk3126_vop_win_data, 21662306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3126_vop_win_data), 21762306a36Sopenharmony_ci .max_output = { 1920, 1080 }, 21862306a36Sopenharmony_ci}; 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_cistatic const int px30_vop_intrs[] = { 22162306a36Sopenharmony_ci FS_INTR, 22262306a36Sopenharmony_ci 0, 0, 22362306a36Sopenharmony_ci LINE_FLAG_INTR, 22462306a36Sopenharmony_ci 0, 22562306a36Sopenharmony_ci BUS_ERROR_INTR, 22662306a36Sopenharmony_ci 0, 0, 22762306a36Sopenharmony_ci DSP_HOLD_VALID_INTR, 22862306a36Sopenharmony_ci}; 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_cistatic const struct vop_intr px30_intr = { 23162306a36Sopenharmony_ci .intrs = px30_vop_intrs, 23262306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(px30_vop_intrs), 23362306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(PX30_LINE_FLAG, 0xfff, 0), 23462306a36Sopenharmony_ci .status = VOP_REG_MASK_SYNC(PX30_INTR_STATUS, 0xffff, 0), 23562306a36Sopenharmony_ci .enable = VOP_REG_MASK_SYNC(PX30_INTR_EN, 0xffff, 0), 23662306a36Sopenharmony_ci .clear = VOP_REG_MASK_SYNC(PX30_INTR_CLEAR, 0xffff, 0), 23762306a36Sopenharmony_ci}; 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_cistatic const struct vop_common px30_common = { 24062306a36Sopenharmony_ci .standby = VOP_REG_SYNC(PX30_SYS_CTRL2, 0x1, 1), 24162306a36Sopenharmony_ci .out_mode = VOP_REG(PX30_DSP_CTRL2, 0xf, 16), 24262306a36Sopenharmony_ci .dsp_blank = VOP_REG(PX30_DSP_CTRL2, 0x1, 14), 24362306a36Sopenharmony_ci .dither_down_en = VOP_REG(PX30_DSP_CTRL2, 0x1, 8), 24462306a36Sopenharmony_ci .dither_down_sel = VOP_REG(PX30_DSP_CTRL2, 0x1, 7), 24562306a36Sopenharmony_ci .dither_down_mode = VOP_REG(PX30_DSP_CTRL2, 0x1, 6), 24662306a36Sopenharmony_ci .cfg_done = VOP_REG_SYNC(PX30_REG_CFG_DONE, 0x1, 0), 24762306a36Sopenharmony_ci}; 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_cistatic const struct vop_modeset px30_modeset = { 25062306a36Sopenharmony_ci .htotal_pw = VOP_REG(PX30_DSP_HTOTAL_HS_END, 0x0fff0fff, 0), 25162306a36Sopenharmony_ci .hact_st_end = VOP_REG(PX30_DSP_HACT_ST_END, 0x0fff0fff, 0), 25262306a36Sopenharmony_ci .vtotal_pw = VOP_REG(PX30_DSP_VTOTAL_VS_END, 0x0fff0fff, 0), 25362306a36Sopenharmony_ci .vact_st_end = VOP_REG(PX30_DSP_VACT_ST_END, 0x0fff0fff, 0), 25462306a36Sopenharmony_ci}; 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_cistatic const struct vop_output px30_output = { 25762306a36Sopenharmony_ci .rgb_dclk_pol = VOP_REG(PX30_DSP_CTRL0, 0x1, 1), 25862306a36Sopenharmony_ci .rgb_pin_pol = VOP_REG(PX30_DSP_CTRL0, 0x7, 2), 25962306a36Sopenharmony_ci .rgb_en = VOP_REG(PX30_DSP_CTRL0, 0x1, 0), 26062306a36Sopenharmony_ci .mipi_dclk_pol = VOP_REG(PX30_DSP_CTRL0, 0x1, 25), 26162306a36Sopenharmony_ci .mipi_pin_pol = VOP_REG(PX30_DSP_CTRL0, 0x7, 26), 26262306a36Sopenharmony_ci .mipi_en = VOP_REG(PX30_DSP_CTRL0, 0x1, 24), 26362306a36Sopenharmony_ci}; 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_cistatic const struct vop_scl_regs px30_win_scl = { 26662306a36Sopenharmony_ci .scale_yrgb_x = VOP_REG(PX30_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0), 26762306a36Sopenharmony_ci .scale_yrgb_y = VOP_REG(PX30_WIN0_SCL_FACTOR_YRGB, 0xffff, 16), 26862306a36Sopenharmony_ci .scale_cbcr_x = VOP_REG(PX30_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0), 26962306a36Sopenharmony_ci .scale_cbcr_y = VOP_REG(PX30_WIN0_SCL_FACTOR_CBR, 0xffff, 16), 27062306a36Sopenharmony_ci}; 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_cistatic const struct vop_win_phy px30_win0_data = { 27362306a36Sopenharmony_ci .scl = &px30_win_scl, 27462306a36Sopenharmony_ci .data_formats = formats_win_full, 27562306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 27662306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full, 27762306a36Sopenharmony_ci .enable = VOP_REG(PX30_WIN0_CTRL0, 0x1, 0), 27862306a36Sopenharmony_ci .format = VOP_REG(PX30_WIN0_CTRL0, 0x7, 1), 27962306a36Sopenharmony_ci .rb_swap = VOP_REG(PX30_WIN0_CTRL0, 0x1, 12), 28062306a36Sopenharmony_ci .uv_swap = VOP_REG(PX30_WIN0_CTRL0, 0x1, 15), 28162306a36Sopenharmony_ci .act_info = VOP_REG(PX30_WIN0_ACT_INFO, 0xffffffff, 0), 28262306a36Sopenharmony_ci .dsp_info = VOP_REG(PX30_WIN0_DSP_INFO, 0xffffffff, 0), 28362306a36Sopenharmony_ci .dsp_st = VOP_REG(PX30_WIN0_DSP_ST, 0xffffffff, 0), 28462306a36Sopenharmony_ci .yrgb_mst = VOP_REG(PX30_WIN0_YRGB_MST0, 0xffffffff, 0), 28562306a36Sopenharmony_ci .uv_mst = VOP_REG(PX30_WIN0_CBR_MST0, 0xffffffff, 0), 28662306a36Sopenharmony_ci .yrgb_vir = VOP_REG(PX30_WIN0_VIR, 0x1fff, 0), 28762306a36Sopenharmony_ci .uv_vir = VOP_REG(PX30_WIN0_VIR, 0x1fff, 16), 28862306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(PX30_WIN0_ALPHA_CTRL, 0x1, 2), 28962306a36Sopenharmony_ci .alpha_mode = VOP_REG(PX30_WIN0_ALPHA_CTRL, 0x1, 1), 29062306a36Sopenharmony_ci .alpha_en = VOP_REG(PX30_WIN0_ALPHA_CTRL, 0x1, 0), 29162306a36Sopenharmony_ci}; 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_cistatic const struct vop_win_phy px30_win1_data = { 29462306a36Sopenharmony_ci .data_formats = formats_win_lite, 29562306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 29662306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 29762306a36Sopenharmony_ci .enable = VOP_REG(PX30_WIN1_CTRL0, 0x1, 0), 29862306a36Sopenharmony_ci .format = VOP_REG(PX30_WIN1_CTRL0, 0x7, 4), 29962306a36Sopenharmony_ci .rb_swap = VOP_REG(PX30_WIN1_CTRL0, 0x1, 12), 30062306a36Sopenharmony_ci .uv_swap = VOP_REG(PX30_WIN1_CTRL0, 0x1, 15), 30162306a36Sopenharmony_ci .dsp_info = VOP_REG(PX30_WIN1_DSP_INFO, 0xffffffff, 0), 30262306a36Sopenharmony_ci .dsp_st = VOP_REG(PX30_WIN1_DSP_ST, 0xffffffff, 0), 30362306a36Sopenharmony_ci .yrgb_mst = VOP_REG(PX30_WIN1_MST, 0xffffffff, 0), 30462306a36Sopenharmony_ci .yrgb_vir = VOP_REG(PX30_WIN1_VIR, 0x1fff, 0), 30562306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(PX30_WIN1_ALPHA_CTRL, 0x1, 2), 30662306a36Sopenharmony_ci .alpha_mode = VOP_REG(PX30_WIN1_ALPHA_CTRL, 0x1, 1), 30762306a36Sopenharmony_ci .alpha_en = VOP_REG(PX30_WIN1_ALPHA_CTRL, 0x1, 0), 30862306a36Sopenharmony_ci}; 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_cistatic const struct vop_win_phy px30_win2_data = { 31162306a36Sopenharmony_ci .data_formats = formats_win_lite, 31262306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 31362306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 31462306a36Sopenharmony_ci .gate = VOP_REG(PX30_WIN2_CTRL0, 0x1, 4), 31562306a36Sopenharmony_ci .enable = VOP_REG(PX30_WIN2_CTRL0, 0x1, 0), 31662306a36Sopenharmony_ci .format = VOP_REG(PX30_WIN2_CTRL0, 0x3, 5), 31762306a36Sopenharmony_ci .rb_swap = VOP_REG(PX30_WIN2_CTRL0, 0x1, 20), 31862306a36Sopenharmony_ci .dsp_info = VOP_REG(PX30_WIN2_DSP_INFO0, 0x0fff0fff, 0), 31962306a36Sopenharmony_ci .dsp_st = VOP_REG(PX30_WIN2_DSP_ST0, 0x1fff1fff, 0), 32062306a36Sopenharmony_ci .yrgb_mst = VOP_REG(PX30_WIN2_MST0, 0xffffffff, 0), 32162306a36Sopenharmony_ci .yrgb_vir = VOP_REG(PX30_WIN2_VIR0_1, 0x1fff, 0), 32262306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(PX30_WIN2_ALPHA_CTRL, 0x1, 2), 32362306a36Sopenharmony_ci .alpha_mode = VOP_REG(PX30_WIN2_ALPHA_CTRL, 0x1, 1), 32462306a36Sopenharmony_ci .alpha_en = VOP_REG(PX30_WIN2_ALPHA_CTRL, 0x1, 0), 32562306a36Sopenharmony_ci}; 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_cistatic const struct vop_win_data px30_vop_big_win_data[] = { 32862306a36Sopenharmony_ci { .base = 0x00, .phy = &px30_win0_data, 32962306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 33062306a36Sopenharmony_ci { .base = 0x00, .phy = &px30_win1_data, 33162306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 33262306a36Sopenharmony_ci { .base = 0x00, .phy = &px30_win2_data, 33362306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 33462306a36Sopenharmony_ci}; 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_cistatic const struct vop_data px30_vop_big = { 33762306a36Sopenharmony_ci .version = VOP_VERSION(2, 6), 33862306a36Sopenharmony_ci .intr = &px30_intr, 33962306a36Sopenharmony_ci .feature = VOP_FEATURE_INTERNAL_RGB, 34062306a36Sopenharmony_ci .common = &px30_common, 34162306a36Sopenharmony_ci .modeset = &px30_modeset, 34262306a36Sopenharmony_ci .output = &px30_output, 34362306a36Sopenharmony_ci .win = px30_vop_big_win_data, 34462306a36Sopenharmony_ci .win_size = ARRAY_SIZE(px30_vop_big_win_data), 34562306a36Sopenharmony_ci .max_output = { 1920, 1080 }, 34662306a36Sopenharmony_ci}; 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_cistatic const struct vop_win_data px30_vop_lit_win_data[] = { 34962306a36Sopenharmony_ci { .base = 0x00, .phy = &px30_win1_data, 35062306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 35162306a36Sopenharmony_ci}; 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_cistatic const struct vop_data px30_vop_lit = { 35462306a36Sopenharmony_ci .version = VOP_VERSION(2, 5), 35562306a36Sopenharmony_ci .intr = &px30_intr, 35662306a36Sopenharmony_ci .feature = VOP_FEATURE_INTERNAL_RGB, 35762306a36Sopenharmony_ci .common = &px30_common, 35862306a36Sopenharmony_ci .modeset = &px30_modeset, 35962306a36Sopenharmony_ci .output = &px30_output, 36062306a36Sopenharmony_ci .win = px30_vop_lit_win_data, 36162306a36Sopenharmony_ci .win_size = ARRAY_SIZE(px30_vop_lit_win_data), 36262306a36Sopenharmony_ci .max_output = { 1920, 1080 }, 36362306a36Sopenharmony_ci}; 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_cistatic const struct vop_scl_regs rk3066_win_scl = { 36662306a36Sopenharmony_ci .scale_yrgb_x = VOP_REG(RK3066_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0), 36762306a36Sopenharmony_ci .scale_yrgb_y = VOP_REG(RK3066_WIN0_SCL_FACTOR_YRGB, 0xffff, 16), 36862306a36Sopenharmony_ci .scale_cbcr_x = VOP_REG(RK3066_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0), 36962306a36Sopenharmony_ci .scale_cbcr_y = VOP_REG(RK3066_WIN0_SCL_FACTOR_CBR, 0xffff, 16), 37062306a36Sopenharmony_ci}; 37162306a36Sopenharmony_ci 37262306a36Sopenharmony_cistatic const struct vop_win_phy rk3066_win0_data = { 37362306a36Sopenharmony_ci .scl = &rk3066_win_scl, 37462306a36Sopenharmony_ci .data_formats = formats_win_full, 37562306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 37662306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full, 37762306a36Sopenharmony_ci .enable = VOP_REG(RK3066_SYS_CTRL1, 0x1, 0), 37862306a36Sopenharmony_ci .format = VOP_REG(RK3066_SYS_CTRL1, 0x7, 4), 37962306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 19), 38062306a36Sopenharmony_ci .uv_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 22), 38162306a36Sopenharmony_ci .act_info = VOP_REG(RK3066_WIN0_ACT_INFO, 0x1fff1fff, 0), 38262306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3066_WIN0_DSP_INFO, 0x0fff0fff, 0), 38362306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3066_WIN0_DSP_ST, 0x1fff1fff, 0), 38462306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3066_WIN0_YRGB_MST0, 0xffffffff, 0), 38562306a36Sopenharmony_ci .uv_mst = VOP_REG(RK3066_WIN0_CBR_MST0, 0xffffffff, 0), 38662306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3066_WIN0_VIR, 0xffff, 0), 38762306a36Sopenharmony_ci .uv_vir = VOP_REG(RK3066_WIN0_VIR, 0x1fff, 16), 38862306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 21), 38962306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3066_BLEND_CTRL, 0x1, 0), 39062306a36Sopenharmony_ci}; 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_cistatic const struct vop_win_phy rk3066_win1_data = { 39362306a36Sopenharmony_ci .data_formats = formats_win_full, 39462306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 39562306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full, 39662306a36Sopenharmony_ci .enable = VOP_REG(RK3066_SYS_CTRL1, 0x1, 1), 39762306a36Sopenharmony_ci .format = VOP_REG(RK3066_SYS_CTRL1, 0x7, 7), 39862306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 23), 39962306a36Sopenharmony_ci .uv_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 26), 40062306a36Sopenharmony_ci .act_info = VOP_REG(RK3066_WIN1_ACT_INFO, 0x1fff1fff, 0), 40162306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3066_WIN1_DSP_INFO, 0x0fff0fff, 0), 40262306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3066_WIN1_DSP_ST, 0x1fff1fff, 0), 40362306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3066_WIN1_YRGB_MST, 0xffffffff, 0), 40462306a36Sopenharmony_ci .uv_mst = VOP_REG(RK3066_WIN1_CBR_MST, 0xffffffff, 0), 40562306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3066_WIN1_VIR, 0xffff, 0), 40662306a36Sopenharmony_ci .uv_vir = VOP_REG(RK3066_WIN1_VIR, 0x1fff, 16), 40762306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 22), 40862306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3066_BLEND_CTRL, 0x1, 1), 40962306a36Sopenharmony_ci}; 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_cistatic const struct vop_win_phy rk3066_win2_data = { 41262306a36Sopenharmony_ci .data_formats = formats_win_lite, 41362306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 41462306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 41562306a36Sopenharmony_ci .enable = VOP_REG(RK3066_SYS_CTRL1, 0x1, 2), 41662306a36Sopenharmony_ci .format = VOP_REG(RK3066_SYS_CTRL1, 0x7, 10), 41762306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 27), 41862306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3066_WIN2_DSP_INFO, 0x0fff0fff, 0), 41962306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3066_WIN2_DSP_ST, 0x1fff1fff, 0), 42062306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3066_WIN2_MST, 0xffffffff, 0), 42162306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3066_WIN2_VIR, 0xffff, 0), 42262306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 23), 42362306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3066_BLEND_CTRL, 0x1, 2), 42462306a36Sopenharmony_ci}; 42562306a36Sopenharmony_ci 42662306a36Sopenharmony_cistatic const struct vop_modeset rk3066_modeset = { 42762306a36Sopenharmony_ci .htotal_pw = VOP_REG(RK3066_DSP_HTOTAL_HS_END, 0x1fff1fff, 0), 42862306a36Sopenharmony_ci .hact_st_end = VOP_REG(RK3066_DSP_HACT_ST_END, 0x1fff1fff, 0), 42962306a36Sopenharmony_ci .vtotal_pw = VOP_REG(RK3066_DSP_VTOTAL_VS_END, 0x1fff1fff, 0), 43062306a36Sopenharmony_ci .vact_st_end = VOP_REG(RK3066_DSP_VACT_ST_END, 0x1fff1fff, 0), 43162306a36Sopenharmony_ci}; 43262306a36Sopenharmony_ci 43362306a36Sopenharmony_cistatic const struct vop_output rk3066_output = { 43462306a36Sopenharmony_ci .pin_pol = VOP_REG(RK3066_DSP_CTRL0, 0x7, 4), 43562306a36Sopenharmony_ci}; 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_cistatic const struct vop_common rk3066_common = { 43862306a36Sopenharmony_ci .standby = VOP_REG(RK3066_SYS_CTRL0, 0x1, 1), 43962306a36Sopenharmony_ci .out_mode = VOP_REG(RK3066_DSP_CTRL0, 0xf, 0), 44062306a36Sopenharmony_ci .cfg_done = VOP_REG(RK3066_REG_CFG_DONE, 0x1, 0), 44162306a36Sopenharmony_ci .dither_down_en = VOP_REG(RK3066_DSP_CTRL0, 0x1, 11), 44262306a36Sopenharmony_ci .dither_down_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 10), 44362306a36Sopenharmony_ci .dsp_blank = VOP_REG(RK3066_DSP_CTRL1, 0x1, 24), 44462306a36Sopenharmony_ci .dither_up = VOP_REG(RK3066_DSP_CTRL0, 0x1, 9), 44562306a36Sopenharmony_ci .dsp_lut_en = VOP_REG(RK3066_SYS_CTRL1, 0x1, 31), 44662306a36Sopenharmony_ci .data_blank = VOP_REG(RK3066_DSP_CTRL1, 0x1, 25), 44762306a36Sopenharmony_ci}; 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_cistatic const struct vop_win_data rk3066_vop_win_data[] = { 45062306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3066_win0_data, 45162306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 45262306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3066_win1_data, 45362306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 45462306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3066_win2_data, 45562306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 45662306a36Sopenharmony_ci}; 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_cistatic const int rk3066_vop_intrs[] = { 45962306a36Sopenharmony_ci /* 46062306a36Sopenharmony_ci * hs_start interrupt fires at frame-start, so serves 46162306a36Sopenharmony_ci * the same purpose as dsp_hold in the driver. 46262306a36Sopenharmony_ci */ 46362306a36Sopenharmony_ci DSP_HOLD_VALID_INTR, 46462306a36Sopenharmony_ci FS_INTR, 46562306a36Sopenharmony_ci LINE_FLAG_INTR, 46662306a36Sopenharmony_ci BUS_ERROR_INTR, 46762306a36Sopenharmony_ci}; 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_cistatic const struct vop_intr rk3066_intr = { 47062306a36Sopenharmony_ci .intrs = rk3066_vop_intrs, 47162306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(rk3066_vop_intrs), 47262306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(RK3066_INT_STATUS, 0xfff, 12), 47362306a36Sopenharmony_ci .status = VOP_REG(RK3066_INT_STATUS, 0xf, 0), 47462306a36Sopenharmony_ci .enable = VOP_REG(RK3066_INT_STATUS, 0xf, 4), 47562306a36Sopenharmony_ci .clear = VOP_REG(RK3066_INT_STATUS, 0xf, 8), 47662306a36Sopenharmony_ci}; 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_cistatic const struct vop_data rk3066_vop = { 47962306a36Sopenharmony_ci .version = VOP_VERSION(2, 1), 48062306a36Sopenharmony_ci .intr = &rk3066_intr, 48162306a36Sopenharmony_ci .common = &rk3066_common, 48262306a36Sopenharmony_ci .modeset = &rk3066_modeset, 48362306a36Sopenharmony_ci .output = &rk3066_output, 48462306a36Sopenharmony_ci .win = rk3066_vop_win_data, 48562306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3066_vop_win_data), 48662306a36Sopenharmony_ci .max_output = { 1920, 1080 }, 48762306a36Sopenharmony_ci}; 48862306a36Sopenharmony_ci 48962306a36Sopenharmony_cistatic const struct vop_scl_regs rk3188_win_scl = { 49062306a36Sopenharmony_ci .scale_yrgb_x = VOP_REG(RK3188_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0), 49162306a36Sopenharmony_ci .scale_yrgb_y = VOP_REG(RK3188_WIN0_SCL_FACTOR_YRGB, 0xffff, 16), 49262306a36Sopenharmony_ci .scale_cbcr_x = VOP_REG(RK3188_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0), 49362306a36Sopenharmony_ci .scale_cbcr_y = VOP_REG(RK3188_WIN0_SCL_FACTOR_CBR, 0xffff, 16), 49462306a36Sopenharmony_ci}; 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_cistatic const struct vop_win_phy rk3188_win0_data = { 49762306a36Sopenharmony_ci .scl = &rk3188_win_scl, 49862306a36Sopenharmony_ci .data_formats = formats_win_full, 49962306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 50062306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full, 50162306a36Sopenharmony_ci .enable = VOP_REG(RK3188_SYS_CTRL, 0x1, 0), 50262306a36Sopenharmony_ci .format = VOP_REG(RK3188_SYS_CTRL, 0x7, 3), 50362306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3188_SYS_CTRL, 0x1, 15), 50462306a36Sopenharmony_ci .uv_swap = VOP_REG(RK3188_SYS_CTRL, 0x1, 18), 50562306a36Sopenharmony_ci .act_info = VOP_REG(RK3188_WIN0_ACT_INFO, 0x1fff1fff, 0), 50662306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3188_WIN0_DSP_INFO, 0x0fff0fff, 0), 50762306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3188_WIN0_DSP_ST, 0x1fff1fff, 0), 50862306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3188_WIN0_YRGB_MST0, 0xffffffff, 0), 50962306a36Sopenharmony_ci .uv_mst = VOP_REG(RK3188_WIN0_CBR_MST0, 0xffffffff, 0), 51062306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3188_WIN_VIR, 0x1fff, 0), 51162306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 18), 51262306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3188_ALPHA_CTRL, 0x1, 0), 51362306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(RK3188_DSP_CTRL0, 0x1, 29), 51462306a36Sopenharmony_ci}; 51562306a36Sopenharmony_ci 51662306a36Sopenharmony_cistatic const struct vop_win_phy rk3188_win1_data = { 51762306a36Sopenharmony_ci .data_formats = formats_win_lite, 51862306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 51962306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 52062306a36Sopenharmony_ci .enable = VOP_REG(RK3188_SYS_CTRL, 0x1, 1), 52162306a36Sopenharmony_ci .format = VOP_REG(RK3188_SYS_CTRL, 0x7, 6), 52262306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3188_SYS_CTRL, 0x1, 19), 52362306a36Sopenharmony_ci /* no act_info on window1 */ 52462306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3188_WIN1_DSP_INFO, 0x07ff07ff, 0), 52562306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3188_WIN1_DSP_ST, 0x0fff0fff, 0), 52662306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3188_WIN1_MST, 0xffffffff, 0), 52762306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3188_WIN_VIR, 0x1fff, 16), 52862306a36Sopenharmony_ci .alpha_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 19), 52962306a36Sopenharmony_ci .alpha_en = VOP_REG(RK3188_ALPHA_CTRL, 0x1, 1), 53062306a36Sopenharmony_ci .alpha_pre_mul = VOP_REG(RK3188_DSP_CTRL0, 0x1, 29), 53162306a36Sopenharmony_ci}; 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_cistatic const struct vop_modeset rk3188_modeset = { 53462306a36Sopenharmony_ci .htotal_pw = VOP_REG(RK3188_DSP_HTOTAL_HS_END, 0x0fff0fff, 0), 53562306a36Sopenharmony_ci .hact_st_end = VOP_REG(RK3188_DSP_HACT_ST_END, 0x0fff0fff, 0), 53662306a36Sopenharmony_ci .vtotal_pw = VOP_REG(RK3188_DSP_VTOTAL_VS_END, 0x0fff0fff, 0), 53762306a36Sopenharmony_ci .vact_st_end = VOP_REG(RK3188_DSP_VACT_ST_END, 0x0fff0fff, 0), 53862306a36Sopenharmony_ci}; 53962306a36Sopenharmony_ci 54062306a36Sopenharmony_cistatic const struct vop_output rk3188_output = { 54162306a36Sopenharmony_ci .pin_pol = VOP_REG(RK3188_DSP_CTRL0, 0xf, 4), 54262306a36Sopenharmony_ci}; 54362306a36Sopenharmony_ci 54462306a36Sopenharmony_cistatic const struct vop_common rk3188_common = { 54562306a36Sopenharmony_ci .gate_en = VOP_REG(RK3188_SYS_CTRL, 0x1, 31), 54662306a36Sopenharmony_ci .standby = VOP_REG(RK3188_SYS_CTRL, 0x1, 30), 54762306a36Sopenharmony_ci .out_mode = VOP_REG(RK3188_DSP_CTRL0, 0xf, 0), 54862306a36Sopenharmony_ci .cfg_done = VOP_REG(RK3188_REG_CFG_DONE, 0x1, 0), 54962306a36Sopenharmony_ci .dither_down_sel = VOP_REG(RK3188_DSP_CTRL0, 0x1, 27), 55062306a36Sopenharmony_ci .dither_down_en = VOP_REG(RK3188_DSP_CTRL0, 0x1, 11), 55162306a36Sopenharmony_ci .dither_down_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 10), 55262306a36Sopenharmony_ci .dsp_blank = VOP_REG(RK3188_DSP_CTRL1, 0x1, 24), 55362306a36Sopenharmony_ci .dither_up = VOP_REG(RK3188_DSP_CTRL0, 0x1, 9), 55462306a36Sopenharmony_ci .dsp_lut_en = VOP_REG(RK3188_SYS_CTRL, 0x1, 28), 55562306a36Sopenharmony_ci .data_blank = VOP_REG(RK3188_DSP_CTRL1, 0x1, 25), 55662306a36Sopenharmony_ci}; 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_cistatic const struct vop_win_data rk3188_vop_win_data[] = { 55962306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3188_win0_data, 56062306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 56162306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3188_win1_data, 56262306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 56362306a36Sopenharmony_ci}; 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_cistatic const int rk3188_vop_intrs[] = { 56662306a36Sopenharmony_ci /* 56762306a36Sopenharmony_ci * hs_start interrupt fires at frame-start, so serves 56862306a36Sopenharmony_ci * the same purpose as dsp_hold in the driver. 56962306a36Sopenharmony_ci */ 57062306a36Sopenharmony_ci DSP_HOLD_VALID_INTR, 57162306a36Sopenharmony_ci FS_INTR, 57262306a36Sopenharmony_ci LINE_FLAG_INTR, 57362306a36Sopenharmony_ci BUS_ERROR_INTR, 57462306a36Sopenharmony_ci}; 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_cistatic const struct vop_intr rk3188_vop_intr = { 57762306a36Sopenharmony_ci .intrs = rk3188_vop_intrs, 57862306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(rk3188_vop_intrs), 57962306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(RK3188_INT_STATUS, 0xfff, 12), 58062306a36Sopenharmony_ci .status = VOP_REG(RK3188_INT_STATUS, 0xf, 0), 58162306a36Sopenharmony_ci .enable = VOP_REG(RK3188_INT_STATUS, 0xf, 4), 58262306a36Sopenharmony_ci .clear = VOP_REG(RK3188_INT_STATUS, 0xf, 8), 58362306a36Sopenharmony_ci}; 58462306a36Sopenharmony_ci 58562306a36Sopenharmony_cistatic const struct vop_data rk3188_vop = { 58662306a36Sopenharmony_ci .intr = &rk3188_vop_intr, 58762306a36Sopenharmony_ci .common = &rk3188_common, 58862306a36Sopenharmony_ci .modeset = &rk3188_modeset, 58962306a36Sopenharmony_ci .output = &rk3188_output, 59062306a36Sopenharmony_ci .win = rk3188_vop_win_data, 59162306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3188_vop_win_data), 59262306a36Sopenharmony_ci .feature = VOP_FEATURE_INTERNAL_RGB, 59362306a36Sopenharmony_ci .max_output = { 2048, 1536 }, 59462306a36Sopenharmony_ci}; 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_cistatic const struct vop_scl_extension rk3288_win_full_scl_ext = { 59762306a36Sopenharmony_ci .cbcr_vsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 31), 59862306a36Sopenharmony_ci .cbcr_vsu_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 30), 59962306a36Sopenharmony_ci .cbcr_hsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 28), 60062306a36Sopenharmony_ci .cbcr_ver_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 26), 60162306a36Sopenharmony_ci .cbcr_hor_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 24), 60262306a36Sopenharmony_ci .yrgb_vsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 23), 60362306a36Sopenharmony_ci .yrgb_vsu_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 22), 60462306a36Sopenharmony_ci .yrgb_hsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 20), 60562306a36Sopenharmony_ci .yrgb_ver_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 18), 60662306a36Sopenharmony_ci .yrgb_hor_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 16), 60762306a36Sopenharmony_ci .line_load_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 15), 60862306a36Sopenharmony_ci .cbcr_axi_gather_num = VOP_REG(RK3288_WIN0_CTRL1, 0x7, 12), 60962306a36Sopenharmony_ci .yrgb_axi_gather_num = VOP_REG(RK3288_WIN0_CTRL1, 0xf, 8), 61062306a36Sopenharmony_ci .vsd_cbcr_gt2 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 7), 61162306a36Sopenharmony_ci .vsd_cbcr_gt4 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 6), 61262306a36Sopenharmony_ci .vsd_yrgb_gt2 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 5), 61362306a36Sopenharmony_ci .vsd_yrgb_gt4 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 4), 61462306a36Sopenharmony_ci .bic_coe_sel = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 2), 61562306a36Sopenharmony_ci .cbcr_axi_gather_en = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 1), 61662306a36Sopenharmony_ci .yrgb_axi_gather_en = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 0), 61762306a36Sopenharmony_ci .lb_mode = VOP_REG(RK3288_WIN0_CTRL0, 0x7, 5), 61862306a36Sopenharmony_ci}; 61962306a36Sopenharmony_ci 62062306a36Sopenharmony_cistatic const struct vop_scl_regs rk3288_win_full_scl = { 62162306a36Sopenharmony_ci .ext = &rk3288_win_full_scl_ext, 62262306a36Sopenharmony_ci .scale_yrgb_x = VOP_REG(RK3288_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0), 62362306a36Sopenharmony_ci .scale_yrgb_y = VOP_REG(RK3288_WIN0_SCL_FACTOR_YRGB, 0xffff, 16), 62462306a36Sopenharmony_ci .scale_cbcr_x = VOP_REG(RK3288_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0), 62562306a36Sopenharmony_ci .scale_cbcr_y = VOP_REG(RK3288_WIN0_SCL_FACTOR_CBR, 0xffff, 16), 62662306a36Sopenharmony_ci}; 62762306a36Sopenharmony_ci 62862306a36Sopenharmony_cistatic const struct vop_win_phy rk3288_win01_data = { 62962306a36Sopenharmony_ci .scl = &rk3288_win_full_scl, 63062306a36Sopenharmony_ci .data_formats = formats_win_full, 63162306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 63262306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full, 63362306a36Sopenharmony_ci .enable = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 0), 63462306a36Sopenharmony_ci .format = VOP_REG(RK3288_WIN0_CTRL0, 0x7, 1), 63562306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 12), 63662306a36Sopenharmony_ci .uv_swap = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 15), 63762306a36Sopenharmony_ci .act_info = VOP_REG(RK3288_WIN0_ACT_INFO, 0x1fff1fff, 0), 63862306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3288_WIN0_DSP_INFO, 0x0fff0fff, 0), 63962306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3288_WIN0_DSP_ST, 0x1fff1fff, 0), 64062306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3288_WIN0_YRGB_MST, 0xffffffff, 0), 64162306a36Sopenharmony_ci .uv_mst = VOP_REG(RK3288_WIN0_CBR_MST, 0xffffffff, 0), 64262306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 0), 64362306a36Sopenharmony_ci .uv_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 16), 64462306a36Sopenharmony_ci .src_alpha_ctl = VOP_REG(RK3288_WIN0_SRC_ALPHA_CTRL, 0xff, 0), 64562306a36Sopenharmony_ci .dst_alpha_ctl = VOP_REG(RK3288_WIN0_DST_ALPHA_CTRL, 0xff, 0), 64662306a36Sopenharmony_ci .channel = VOP_REG(RK3288_WIN0_CTRL2, 0xff, 0), 64762306a36Sopenharmony_ci}; 64862306a36Sopenharmony_ci 64962306a36Sopenharmony_cistatic const struct vop_win_phy rk3288_win23_data = { 65062306a36Sopenharmony_ci .data_formats = formats_win_lite, 65162306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 65262306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 65362306a36Sopenharmony_ci .enable = VOP_REG(RK3288_WIN2_CTRL0, 0x1, 4), 65462306a36Sopenharmony_ci .gate = VOP_REG(RK3288_WIN2_CTRL0, 0x1, 0), 65562306a36Sopenharmony_ci .format = VOP_REG(RK3288_WIN2_CTRL0, 0x7, 1), 65662306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3288_WIN2_CTRL0, 0x1, 12), 65762306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3288_WIN2_DSP_INFO0, 0x0fff0fff, 0), 65862306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3288_WIN2_DSP_ST0, 0x1fff1fff, 0), 65962306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3288_WIN2_MST0, 0xffffffff, 0), 66062306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3288_WIN2_VIR0_1, 0x1fff, 0), 66162306a36Sopenharmony_ci .src_alpha_ctl = VOP_REG(RK3288_WIN2_SRC_ALPHA_CTRL, 0xff, 0), 66262306a36Sopenharmony_ci .dst_alpha_ctl = VOP_REG(RK3288_WIN2_DST_ALPHA_CTRL, 0xff, 0), 66362306a36Sopenharmony_ci}; 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_cistatic const struct vop_modeset rk3288_modeset = { 66662306a36Sopenharmony_ci .htotal_pw = VOP_REG(RK3288_DSP_HTOTAL_HS_END, 0x1fff1fff, 0), 66762306a36Sopenharmony_ci .hact_st_end = VOP_REG(RK3288_DSP_HACT_ST_END, 0x1fff1fff, 0), 66862306a36Sopenharmony_ci .vtotal_pw = VOP_REG(RK3288_DSP_VTOTAL_VS_END, 0x1fff1fff, 0), 66962306a36Sopenharmony_ci .vact_st_end = VOP_REG(RK3288_DSP_VACT_ST_END, 0x1fff1fff, 0), 67062306a36Sopenharmony_ci .hpost_st_end = VOP_REG(RK3288_POST_DSP_HACT_INFO, 0x1fff1fff, 0), 67162306a36Sopenharmony_ci .vpost_st_end = VOP_REG(RK3288_POST_DSP_VACT_INFO, 0x1fff1fff, 0), 67262306a36Sopenharmony_ci}; 67362306a36Sopenharmony_ci 67462306a36Sopenharmony_cistatic const struct vop_output rk3288_output = { 67562306a36Sopenharmony_ci .pin_pol = VOP_REG(RK3288_DSP_CTRL0, 0xf, 4), 67662306a36Sopenharmony_ci .rgb_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 12), 67762306a36Sopenharmony_ci .hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13), 67862306a36Sopenharmony_ci .edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14), 67962306a36Sopenharmony_ci .mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15), 68062306a36Sopenharmony_ci}; 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_cistatic const struct vop_common rk3288_common = { 68362306a36Sopenharmony_ci .standby = VOP_REG_SYNC(RK3288_SYS_CTRL, 0x1, 22), 68462306a36Sopenharmony_ci .gate_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 23), 68562306a36Sopenharmony_ci .mmu_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 20), 68662306a36Sopenharmony_ci .dither_down_sel = VOP_REG(RK3288_DSP_CTRL1, 0x1, 4), 68762306a36Sopenharmony_ci .dither_down_mode = VOP_REG(RK3288_DSP_CTRL1, 0x1, 3), 68862306a36Sopenharmony_ci .dither_down_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 2), 68962306a36Sopenharmony_ci .pre_dither_down = VOP_REG(RK3288_DSP_CTRL1, 0x1, 1), 69062306a36Sopenharmony_ci .dither_up = VOP_REG(RK3288_DSP_CTRL1, 0x1, 6), 69162306a36Sopenharmony_ci .dsp_lut_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 0), 69262306a36Sopenharmony_ci .data_blank = VOP_REG(RK3288_DSP_CTRL0, 0x1, 19), 69362306a36Sopenharmony_ci .dsp_blank = VOP_REG(RK3288_DSP_CTRL0, 0x3, 18), 69462306a36Sopenharmony_ci .out_mode = VOP_REG(RK3288_DSP_CTRL0, 0xf, 0), 69562306a36Sopenharmony_ci .cfg_done = VOP_REG_SYNC(RK3288_REG_CFG_DONE, 0x1, 0), 69662306a36Sopenharmony_ci}; 69762306a36Sopenharmony_ci 69862306a36Sopenharmony_ci/* 69962306a36Sopenharmony_ci * Note: rk3288 has a dedicated 'cursor' window, however, that window requires 70062306a36Sopenharmony_ci * special support to get alpha blending working. For now, just use overlay 70162306a36Sopenharmony_ci * window 3 for the drm cursor. 70262306a36Sopenharmony_ci * 70362306a36Sopenharmony_ci */ 70462306a36Sopenharmony_cistatic const struct vop_win_data rk3288_vop_win_data[] = { 70562306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3288_win01_data, 70662306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 70762306a36Sopenharmony_ci { .base = 0x40, .phy = &rk3288_win01_data, 70862306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 70962306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3288_win23_data, 71062306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 71162306a36Sopenharmony_ci { .base = 0x50, .phy = &rk3288_win23_data, 71262306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 71362306a36Sopenharmony_ci}; 71462306a36Sopenharmony_ci 71562306a36Sopenharmony_cistatic const int rk3288_vop_intrs[] = { 71662306a36Sopenharmony_ci DSP_HOLD_VALID_INTR, 71762306a36Sopenharmony_ci FS_INTR, 71862306a36Sopenharmony_ci LINE_FLAG_INTR, 71962306a36Sopenharmony_ci BUS_ERROR_INTR, 72062306a36Sopenharmony_ci}; 72162306a36Sopenharmony_ci 72262306a36Sopenharmony_cistatic const struct vop_intr rk3288_vop_intr = { 72362306a36Sopenharmony_ci .intrs = rk3288_vop_intrs, 72462306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(rk3288_vop_intrs), 72562306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(RK3288_INTR_CTRL0, 0x1fff, 12), 72662306a36Sopenharmony_ci .status = VOP_REG(RK3288_INTR_CTRL0, 0xf, 0), 72762306a36Sopenharmony_ci .enable = VOP_REG(RK3288_INTR_CTRL0, 0xf, 4), 72862306a36Sopenharmony_ci .clear = VOP_REG(RK3288_INTR_CTRL0, 0xf, 8), 72962306a36Sopenharmony_ci}; 73062306a36Sopenharmony_ci 73162306a36Sopenharmony_cistatic const struct vop_data rk3288_vop = { 73262306a36Sopenharmony_ci .version = VOP_VERSION(3, 1), 73362306a36Sopenharmony_ci .feature = VOP_FEATURE_OUTPUT_RGB10, 73462306a36Sopenharmony_ci .intr = &rk3288_vop_intr, 73562306a36Sopenharmony_ci .common = &rk3288_common, 73662306a36Sopenharmony_ci .modeset = &rk3288_modeset, 73762306a36Sopenharmony_ci .output = &rk3288_output, 73862306a36Sopenharmony_ci .win = rk3288_vop_win_data, 73962306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3288_vop_win_data), 74062306a36Sopenharmony_ci .lut_size = 1024, 74162306a36Sopenharmony_ci /* 74262306a36Sopenharmony_ci * This is the maximum resolution for the VOPB, the VOPL can only do 74362306a36Sopenharmony_ci * 2560x1600, but we can't distinguish them as they have the same 74462306a36Sopenharmony_ci * compatible. 74562306a36Sopenharmony_ci */ 74662306a36Sopenharmony_ci .max_output = { 3840, 2160 }, 74762306a36Sopenharmony_ci}; 74862306a36Sopenharmony_ci 74962306a36Sopenharmony_cistatic const int rk3368_vop_intrs[] = { 75062306a36Sopenharmony_ci FS_INTR, 75162306a36Sopenharmony_ci 0, 0, 75262306a36Sopenharmony_ci LINE_FLAG_INTR, 75362306a36Sopenharmony_ci 0, 75462306a36Sopenharmony_ci BUS_ERROR_INTR, 75562306a36Sopenharmony_ci 0, 0, 0, 0, 0, 0, 0, 75662306a36Sopenharmony_ci DSP_HOLD_VALID_INTR, 75762306a36Sopenharmony_ci}; 75862306a36Sopenharmony_ci 75962306a36Sopenharmony_cistatic const struct vop_intr rk3368_vop_intr = { 76062306a36Sopenharmony_ci .intrs = rk3368_vop_intrs, 76162306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(rk3368_vop_intrs), 76262306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(RK3368_LINE_FLAG, 0xffff, 0), 76362306a36Sopenharmony_ci .line_flag_num[1] = VOP_REG(RK3368_LINE_FLAG, 0xffff, 16), 76462306a36Sopenharmony_ci .status = VOP_REG_MASK_SYNC(RK3368_INTR_STATUS, 0x3fff, 0), 76562306a36Sopenharmony_ci .enable = VOP_REG_MASK_SYNC(RK3368_INTR_EN, 0x3fff, 0), 76662306a36Sopenharmony_ci .clear = VOP_REG_MASK_SYNC(RK3368_INTR_CLEAR, 0x3fff, 0), 76762306a36Sopenharmony_ci}; 76862306a36Sopenharmony_ci 76962306a36Sopenharmony_cistatic const struct vop_win_phy rk3368_win01_data = { 77062306a36Sopenharmony_ci .scl = &rk3288_win_full_scl, 77162306a36Sopenharmony_ci .data_formats = formats_win_full, 77262306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 77362306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full, 77462306a36Sopenharmony_ci .enable = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 0), 77562306a36Sopenharmony_ci .format = VOP_REG(RK3368_WIN0_CTRL0, 0x7, 1), 77662306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 12), 77762306a36Sopenharmony_ci .uv_swap = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 15), 77862306a36Sopenharmony_ci .x_mir_en = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 21), 77962306a36Sopenharmony_ci .y_mir_en = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 22), 78062306a36Sopenharmony_ci .act_info = VOP_REG(RK3368_WIN0_ACT_INFO, 0x1fff1fff, 0), 78162306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3368_WIN0_DSP_INFO, 0x0fff0fff, 0), 78262306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3368_WIN0_DSP_ST, 0x1fff1fff, 0), 78362306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3368_WIN0_YRGB_MST, 0xffffffff, 0), 78462306a36Sopenharmony_ci .uv_mst = VOP_REG(RK3368_WIN0_CBR_MST, 0xffffffff, 0), 78562306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3368_WIN0_VIR, 0x3fff, 0), 78662306a36Sopenharmony_ci .uv_vir = VOP_REG(RK3368_WIN0_VIR, 0x3fff, 16), 78762306a36Sopenharmony_ci .src_alpha_ctl = VOP_REG(RK3368_WIN0_SRC_ALPHA_CTRL, 0xff, 0), 78862306a36Sopenharmony_ci .dst_alpha_ctl = VOP_REG(RK3368_WIN0_DST_ALPHA_CTRL, 0xff, 0), 78962306a36Sopenharmony_ci .channel = VOP_REG(RK3368_WIN0_CTRL2, 0xff, 0), 79062306a36Sopenharmony_ci}; 79162306a36Sopenharmony_ci 79262306a36Sopenharmony_cistatic const struct vop_win_phy rk3368_win23_data = { 79362306a36Sopenharmony_ci .data_formats = formats_win_lite, 79462306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_lite), 79562306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_lite, 79662306a36Sopenharmony_ci .gate = VOP_REG(RK3368_WIN2_CTRL0, 0x1, 0), 79762306a36Sopenharmony_ci .enable = VOP_REG(RK3368_WIN2_CTRL0, 0x1, 4), 79862306a36Sopenharmony_ci .format = VOP_REG(RK3368_WIN2_CTRL0, 0x3, 5), 79962306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3368_WIN2_CTRL0, 0x1, 20), 80062306a36Sopenharmony_ci .y_mir_en = VOP_REG(RK3368_WIN2_CTRL1, 0x1, 15), 80162306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3368_WIN2_DSP_INFO0, 0x0fff0fff, 0), 80262306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3368_WIN2_DSP_ST0, 0x1fff1fff, 0), 80362306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3368_WIN2_MST0, 0xffffffff, 0), 80462306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3368_WIN2_VIR0_1, 0x1fff, 0), 80562306a36Sopenharmony_ci .src_alpha_ctl = VOP_REG(RK3368_WIN2_SRC_ALPHA_CTRL, 0xff, 0), 80662306a36Sopenharmony_ci .dst_alpha_ctl = VOP_REG(RK3368_WIN2_DST_ALPHA_CTRL, 0xff, 0), 80762306a36Sopenharmony_ci}; 80862306a36Sopenharmony_ci 80962306a36Sopenharmony_cistatic const struct vop_win_data rk3368_vop_win_data[] = { 81062306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3368_win01_data, 81162306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 81262306a36Sopenharmony_ci { .base = 0x40, .phy = &rk3368_win01_data, 81362306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 81462306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3368_win23_data, 81562306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 81662306a36Sopenharmony_ci { .base = 0x50, .phy = &rk3368_win23_data, 81762306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 81862306a36Sopenharmony_ci}; 81962306a36Sopenharmony_ci 82062306a36Sopenharmony_cistatic const struct vop_output rk3368_output = { 82162306a36Sopenharmony_ci .rgb_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 19), 82262306a36Sopenharmony_ci .hdmi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 23), 82362306a36Sopenharmony_ci .edp_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 27), 82462306a36Sopenharmony_ci .mipi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 31), 82562306a36Sopenharmony_ci .rgb_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 16), 82662306a36Sopenharmony_ci .hdmi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 20), 82762306a36Sopenharmony_ci .edp_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 24), 82862306a36Sopenharmony_ci .mipi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 28), 82962306a36Sopenharmony_ci .rgb_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 12), 83062306a36Sopenharmony_ci .hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13), 83162306a36Sopenharmony_ci .edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14), 83262306a36Sopenharmony_ci .mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15), 83362306a36Sopenharmony_ci}; 83462306a36Sopenharmony_ci 83562306a36Sopenharmony_cistatic const struct vop_misc rk3368_misc = { 83662306a36Sopenharmony_ci .global_regdone_en = VOP_REG(RK3368_SYS_CTRL, 0x1, 11), 83762306a36Sopenharmony_ci}; 83862306a36Sopenharmony_ci 83962306a36Sopenharmony_cistatic const struct vop_data rk3368_vop = { 84062306a36Sopenharmony_ci .version = VOP_VERSION(3, 2), 84162306a36Sopenharmony_ci .intr = &rk3368_vop_intr, 84262306a36Sopenharmony_ci .common = &rk3288_common, 84362306a36Sopenharmony_ci .modeset = &rk3288_modeset, 84462306a36Sopenharmony_ci .output = &rk3368_output, 84562306a36Sopenharmony_ci .misc = &rk3368_misc, 84662306a36Sopenharmony_ci .win = rk3368_vop_win_data, 84762306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3368_vop_win_data), 84862306a36Sopenharmony_ci .max_output = { 4096, 2160 }, 84962306a36Sopenharmony_ci}; 85062306a36Sopenharmony_ci 85162306a36Sopenharmony_cistatic const struct vop_intr rk3366_vop_intr = { 85262306a36Sopenharmony_ci .intrs = rk3368_vop_intrs, 85362306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(rk3368_vop_intrs), 85462306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(RK3366_LINE_FLAG, 0xffff, 0), 85562306a36Sopenharmony_ci .line_flag_num[1] = VOP_REG(RK3366_LINE_FLAG, 0xffff, 16), 85662306a36Sopenharmony_ci .status = VOP_REG_MASK_SYNC(RK3366_INTR_STATUS0, 0xffff, 0), 85762306a36Sopenharmony_ci .enable = VOP_REG_MASK_SYNC(RK3366_INTR_EN0, 0xffff, 0), 85862306a36Sopenharmony_ci .clear = VOP_REG_MASK_SYNC(RK3366_INTR_CLEAR0, 0xffff, 0), 85962306a36Sopenharmony_ci}; 86062306a36Sopenharmony_ci 86162306a36Sopenharmony_cistatic const struct vop_data rk3366_vop = { 86262306a36Sopenharmony_ci .version = VOP_VERSION(3, 4), 86362306a36Sopenharmony_ci .intr = &rk3366_vop_intr, 86462306a36Sopenharmony_ci .common = &rk3288_common, 86562306a36Sopenharmony_ci .modeset = &rk3288_modeset, 86662306a36Sopenharmony_ci .output = &rk3368_output, 86762306a36Sopenharmony_ci .misc = &rk3368_misc, 86862306a36Sopenharmony_ci .win = rk3368_vop_win_data, 86962306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3368_vop_win_data), 87062306a36Sopenharmony_ci .max_output = { 4096, 2160 }, 87162306a36Sopenharmony_ci}; 87262306a36Sopenharmony_ci 87362306a36Sopenharmony_cistatic const struct vop_output rk3399_output = { 87462306a36Sopenharmony_ci .dp_dclk_pol = VOP_REG(RK3399_DSP_CTRL1, 0x1, 19), 87562306a36Sopenharmony_ci .rgb_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 19), 87662306a36Sopenharmony_ci .hdmi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 23), 87762306a36Sopenharmony_ci .edp_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 27), 87862306a36Sopenharmony_ci .mipi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 31), 87962306a36Sopenharmony_ci .dp_pin_pol = VOP_REG(RK3399_DSP_CTRL1, 0x7, 16), 88062306a36Sopenharmony_ci .rgb_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 16), 88162306a36Sopenharmony_ci .hdmi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 20), 88262306a36Sopenharmony_ci .edp_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 24), 88362306a36Sopenharmony_ci .mipi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 28), 88462306a36Sopenharmony_ci .dp_en = VOP_REG(RK3399_SYS_CTRL, 0x1, 11), 88562306a36Sopenharmony_ci .rgb_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 12), 88662306a36Sopenharmony_ci .hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13), 88762306a36Sopenharmony_ci .edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14), 88862306a36Sopenharmony_ci .mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15), 88962306a36Sopenharmony_ci .mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3), 89062306a36Sopenharmony_ci}; 89162306a36Sopenharmony_ci 89262306a36Sopenharmony_cistatic const struct vop_common rk3399_common = { 89362306a36Sopenharmony_ci .standby = VOP_REG_SYNC(RK3399_SYS_CTRL, 0x1, 22), 89462306a36Sopenharmony_ci .gate_en = VOP_REG(RK3399_SYS_CTRL, 0x1, 23), 89562306a36Sopenharmony_ci .mmu_en = VOP_REG(RK3399_SYS_CTRL, 0x1, 20), 89662306a36Sopenharmony_ci .dither_down_sel = VOP_REG(RK3399_DSP_CTRL1, 0x1, 4), 89762306a36Sopenharmony_ci .dither_down_mode = VOP_REG(RK3399_DSP_CTRL1, 0x1, 3), 89862306a36Sopenharmony_ci .dither_down_en = VOP_REG(RK3399_DSP_CTRL1, 0x1, 2), 89962306a36Sopenharmony_ci .pre_dither_down = VOP_REG(RK3399_DSP_CTRL1, 0x1, 1), 90062306a36Sopenharmony_ci .dither_up = VOP_REG(RK3399_DSP_CTRL1, 0x1, 6), 90162306a36Sopenharmony_ci .dsp_lut_en = VOP_REG(RK3399_DSP_CTRL1, 0x1, 0), 90262306a36Sopenharmony_ci .update_gamma_lut = VOP_REG(RK3399_DSP_CTRL1, 0x1, 7), 90362306a36Sopenharmony_ci .lut_buffer_index = VOP_REG(RK3399_DBG_POST_REG1, 0x1, 1), 90462306a36Sopenharmony_ci .data_blank = VOP_REG(RK3399_DSP_CTRL0, 0x1, 19), 90562306a36Sopenharmony_ci .dsp_blank = VOP_REG(RK3399_DSP_CTRL0, 0x3, 18), 90662306a36Sopenharmony_ci .out_mode = VOP_REG(RK3399_DSP_CTRL0, 0xf, 0), 90762306a36Sopenharmony_ci .cfg_done = VOP_REG_SYNC(RK3399_REG_CFG_DONE, 0x1, 0), 90862306a36Sopenharmony_ci}; 90962306a36Sopenharmony_ci 91062306a36Sopenharmony_cistatic const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = { 91162306a36Sopenharmony_ci .y2r_coefficients = { 91262306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0), 91362306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16), 91462306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0), 91562306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16), 91662306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0), 91762306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16), 91862306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0), 91962306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16), 92062306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0), 92162306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0), 92262306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0), 92362306a36Sopenharmony_ci VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0), 92462306a36Sopenharmony_ci }, 92562306a36Sopenharmony_ci}; 92662306a36Sopenharmony_ci 92762306a36Sopenharmony_cistatic const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { }; 92862306a36Sopenharmony_ci 92962306a36Sopenharmony_cistatic const struct vop_win_yuv2yuv_data rk3399_vop_big_win_yuv2yuv_data[] = { 93062306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data, 93162306a36Sopenharmony_ci .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1) }, 93262306a36Sopenharmony_ci { .base = 0x60, .phy = &rk3399_yuv2yuv_win01_data, 93362306a36Sopenharmony_ci .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 9) }, 93462306a36Sopenharmony_ci { .base = 0xC0, .phy = &rk3399_yuv2yuv_win23_data }, 93562306a36Sopenharmony_ci { .base = 0x120, .phy = &rk3399_yuv2yuv_win23_data }, 93662306a36Sopenharmony_ci 93762306a36Sopenharmony_ci}; 93862306a36Sopenharmony_ci 93962306a36Sopenharmony_cistatic const struct vop_win_phy rk3399_win01_data = { 94062306a36Sopenharmony_ci .scl = &rk3288_win_full_scl, 94162306a36Sopenharmony_ci .data_formats = formats_win_full, 94262306a36Sopenharmony_ci .nformats = ARRAY_SIZE(formats_win_full), 94362306a36Sopenharmony_ci .format_modifiers = format_modifiers_win_full_afbc, 94462306a36Sopenharmony_ci .enable = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 0), 94562306a36Sopenharmony_ci .format = VOP_REG(RK3288_WIN0_CTRL0, 0x7, 1), 94662306a36Sopenharmony_ci .rb_swap = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 12), 94762306a36Sopenharmony_ci .uv_swap = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 15), 94862306a36Sopenharmony_ci .x_mir_en = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 21), 94962306a36Sopenharmony_ci .y_mir_en = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 22), 95062306a36Sopenharmony_ci .act_info = VOP_REG(RK3288_WIN0_ACT_INFO, 0x1fff1fff, 0), 95162306a36Sopenharmony_ci .dsp_info = VOP_REG(RK3288_WIN0_DSP_INFO, 0x0fff0fff, 0), 95262306a36Sopenharmony_ci .dsp_st = VOP_REG(RK3288_WIN0_DSP_ST, 0x1fff1fff, 0), 95362306a36Sopenharmony_ci .yrgb_mst = VOP_REG(RK3288_WIN0_YRGB_MST, 0xffffffff, 0), 95462306a36Sopenharmony_ci .uv_mst = VOP_REG(RK3288_WIN0_CBR_MST, 0xffffffff, 0), 95562306a36Sopenharmony_ci .yrgb_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 0), 95662306a36Sopenharmony_ci .uv_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 16), 95762306a36Sopenharmony_ci .src_alpha_ctl = VOP_REG(RK3288_WIN0_SRC_ALPHA_CTRL, 0xff, 0), 95862306a36Sopenharmony_ci .dst_alpha_ctl = VOP_REG(RK3288_WIN0_DST_ALPHA_CTRL, 0xff, 0), 95962306a36Sopenharmony_ci .channel = VOP_REG(RK3288_WIN0_CTRL2, 0xff, 0), 96062306a36Sopenharmony_ci}; 96162306a36Sopenharmony_ci 96262306a36Sopenharmony_ci/* 96362306a36Sopenharmony_ci * rk3399 vop big windows register layout is same as rk3288, but we 96462306a36Sopenharmony_ci * have a separate rk3399 win data array here so that we can advertise 96562306a36Sopenharmony_ci * AFBC on the primary plane. 96662306a36Sopenharmony_ci */ 96762306a36Sopenharmony_cistatic const struct vop_win_data rk3399_vop_win_data[] = { 96862306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3399_win01_data, 96962306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 97062306a36Sopenharmony_ci { .base = 0x40, .phy = &rk3368_win01_data, 97162306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 97262306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3368_win23_data, 97362306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 97462306a36Sopenharmony_ci { .base = 0x50, .phy = &rk3368_win23_data, 97562306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 97662306a36Sopenharmony_ci}; 97762306a36Sopenharmony_ci 97862306a36Sopenharmony_cistatic const struct vop_afbc rk3399_vop_afbc = { 97962306a36Sopenharmony_ci .rstn = VOP_REG(RK3399_AFBCD0_CTRL, 0x1, 3), 98062306a36Sopenharmony_ci .enable = VOP_REG(RK3399_AFBCD0_CTRL, 0x1, 0), 98162306a36Sopenharmony_ci .win_sel = VOP_REG(RK3399_AFBCD0_CTRL, 0x3, 1), 98262306a36Sopenharmony_ci .format = VOP_REG(RK3399_AFBCD0_CTRL, 0x1f, 16), 98362306a36Sopenharmony_ci .hreg_block_split = VOP_REG(RK3399_AFBCD0_CTRL, 0x1, 21), 98462306a36Sopenharmony_ci .hdr_ptr = VOP_REG(RK3399_AFBCD0_HDR_PTR, 0xffffffff, 0), 98562306a36Sopenharmony_ci .pic_size = VOP_REG(RK3399_AFBCD0_PIC_SIZE, 0xffffffff, 0), 98662306a36Sopenharmony_ci}; 98762306a36Sopenharmony_ci 98862306a36Sopenharmony_cistatic const struct vop_data rk3399_vop_big = { 98962306a36Sopenharmony_ci .version = VOP_VERSION(3, 5), 99062306a36Sopenharmony_ci .feature = VOP_FEATURE_OUTPUT_RGB10, 99162306a36Sopenharmony_ci .intr = &rk3366_vop_intr, 99262306a36Sopenharmony_ci .common = &rk3399_common, 99362306a36Sopenharmony_ci .modeset = &rk3288_modeset, 99462306a36Sopenharmony_ci .output = &rk3399_output, 99562306a36Sopenharmony_ci .afbc = &rk3399_vop_afbc, 99662306a36Sopenharmony_ci .misc = &rk3368_misc, 99762306a36Sopenharmony_ci .win = rk3399_vop_win_data, 99862306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3399_vop_win_data), 99962306a36Sopenharmony_ci .win_yuv2yuv = rk3399_vop_big_win_yuv2yuv_data, 100062306a36Sopenharmony_ci .lut_size = 1024, 100162306a36Sopenharmony_ci .max_output = { 4096, 2160 }, 100262306a36Sopenharmony_ci}; 100362306a36Sopenharmony_ci 100462306a36Sopenharmony_cistatic const struct vop_win_data rk3399_vop_lit_win_data[] = { 100562306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3368_win01_data, 100662306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 100762306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3368_win23_data, 100862306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR}, 100962306a36Sopenharmony_ci}; 101062306a36Sopenharmony_ci 101162306a36Sopenharmony_cistatic const struct vop_win_yuv2yuv_data rk3399_vop_lit_win_yuv2yuv_data[] = { 101262306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data, 101362306a36Sopenharmony_ci .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1)}, 101462306a36Sopenharmony_ci { .base = 0x60, .phy = &rk3399_yuv2yuv_win23_data }, 101562306a36Sopenharmony_ci}; 101662306a36Sopenharmony_ci 101762306a36Sopenharmony_cistatic const struct vop_data rk3399_vop_lit = { 101862306a36Sopenharmony_ci .version = VOP_VERSION(3, 6), 101962306a36Sopenharmony_ci .intr = &rk3366_vop_intr, 102062306a36Sopenharmony_ci .common = &rk3399_common, 102162306a36Sopenharmony_ci .modeset = &rk3288_modeset, 102262306a36Sopenharmony_ci .output = &rk3399_output, 102362306a36Sopenharmony_ci .misc = &rk3368_misc, 102462306a36Sopenharmony_ci .win = rk3399_vop_lit_win_data, 102562306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3399_vop_lit_win_data), 102662306a36Sopenharmony_ci .win_yuv2yuv = rk3399_vop_lit_win_yuv2yuv_data, 102762306a36Sopenharmony_ci .lut_size = 256, 102862306a36Sopenharmony_ci .max_output = { 2560, 1600 }, 102962306a36Sopenharmony_ci}; 103062306a36Sopenharmony_ci 103162306a36Sopenharmony_cistatic const struct vop_win_data rk3228_vop_win_data[] = { 103262306a36Sopenharmony_ci { .base = 0x00, .phy = &rk3288_win01_data, 103362306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 103462306a36Sopenharmony_ci { .base = 0x40, .phy = &rk3288_win01_data, 103562306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 103662306a36Sopenharmony_ci}; 103762306a36Sopenharmony_ci 103862306a36Sopenharmony_cistatic const struct vop_data rk3228_vop = { 103962306a36Sopenharmony_ci .version = VOP_VERSION(3, 7), 104062306a36Sopenharmony_ci .feature = VOP_FEATURE_OUTPUT_RGB10, 104162306a36Sopenharmony_ci .intr = &rk3366_vop_intr, 104262306a36Sopenharmony_ci .common = &rk3288_common, 104362306a36Sopenharmony_ci .modeset = &rk3288_modeset, 104462306a36Sopenharmony_ci .output = &rk3399_output, 104562306a36Sopenharmony_ci .misc = &rk3368_misc, 104662306a36Sopenharmony_ci .win = rk3228_vop_win_data, 104762306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3228_vop_win_data), 104862306a36Sopenharmony_ci .max_output = { 4096, 2160 }, 104962306a36Sopenharmony_ci}; 105062306a36Sopenharmony_ci 105162306a36Sopenharmony_cistatic const struct vop_modeset rk3328_modeset = { 105262306a36Sopenharmony_ci .htotal_pw = VOP_REG(RK3328_DSP_HTOTAL_HS_END, 0x1fff1fff, 0), 105362306a36Sopenharmony_ci .hact_st_end = VOP_REG(RK3328_DSP_HACT_ST_END, 0x1fff1fff, 0), 105462306a36Sopenharmony_ci .vtotal_pw = VOP_REG(RK3328_DSP_VTOTAL_VS_END, 0x1fff1fff, 0), 105562306a36Sopenharmony_ci .vact_st_end = VOP_REG(RK3328_DSP_VACT_ST_END, 0x1fff1fff, 0), 105662306a36Sopenharmony_ci .hpost_st_end = VOP_REG(RK3328_POST_DSP_HACT_INFO, 0x1fff1fff, 0), 105762306a36Sopenharmony_ci .vpost_st_end = VOP_REG(RK3328_POST_DSP_VACT_INFO, 0x1fff1fff, 0), 105862306a36Sopenharmony_ci}; 105962306a36Sopenharmony_ci 106062306a36Sopenharmony_cistatic const struct vop_output rk3328_output = { 106162306a36Sopenharmony_ci .rgb_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 19), 106262306a36Sopenharmony_ci .hdmi_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 23), 106362306a36Sopenharmony_ci .edp_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 27), 106462306a36Sopenharmony_ci .mipi_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 31), 106562306a36Sopenharmony_ci .rgb_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 12), 106662306a36Sopenharmony_ci .hdmi_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 13), 106762306a36Sopenharmony_ci .edp_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 14), 106862306a36Sopenharmony_ci .mipi_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 15), 106962306a36Sopenharmony_ci .rgb_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 16), 107062306a36Sopenharmony_ci .hdmi_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 20), 107162306a36Sopenharmony_ci .edp_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 24), 107262306a36Sopenharmony_ci .mipi_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 28), 107362306a36Sopenharmony_ci}; 107462306a36Sopenharmony_ci 107562306a36Sopenharmony_cistatic const struct vop_misc rk3328_misc = { 107662306a36Sopenharmony_ci .global_regdone_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 11), 107762306a36Sopenharmony_ci}; 107862306a36Sopenharmony_ci 107962306a36Sopenharmony_cistatic const struct vop_common rk3328_common = { 108062306a36Sopenharmony_ci .standby = VOP_REG_SYNC(RK3328_SYS_CTRL, 0x1, 22), 108162306a36Sopenharmony_ci .dither_down_sel = VOP_REG(RK3328_DSP_CTRL1, 0x1, 4), 108262306a36Sopenharmony_ci .dither_down_mode = VOP_REG(RK3328_DSP_CTRL1, 0x1, 3), 108362306a36Sopenharmony_ci .dither_down_en = VOP_REG(RK3328_DSP_CTRL1, 0x1, 2), 108462306a36Sopenharmony_ci .pre_dither_down = VOP_REG(RK3328_DSP_CTRL1, 0x1, 1), 108562306a36Sopenharmony_ci .dither_up = VOP_REG(RK3328_DSP_CTRL1, 0x1, 6), 108662306a36Sopenharmony_ci .dsp_blank = VOP_REG(RK3328_DSP_CTRL0, 0x3, 18), 108762306a36Sopenharmony_ci .out_mode = VOP_REG(RK3328_DSP_CTRL0, 0xf, 0), 108862306a36Sopenharmony_ci .cfg_done = VOP_REG_SYNC(RK3328_REG_CFG_DONE, 0x1, 0), 108962306a36Sopenharmony_ci}; 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_cistatic const struct vop_intr rk3328_vop_intr = { 109262306a36Sopenharmony_ci .intrs = rk3368_vop_intrs, 109362306a36Sopenharmony_ci .nintrs = ARRAY_SIZE(rk3368_vop_intrs), 109462306a36Sopenharmony_ci .line_flag_num[0] = VOP_REG(RK3328_LINE_FLAG, 0xffff, 0), 109562306a36Sopenharmony_ci .line_flag_num[1] = VOP_REG(RK3328_LINE_FLAG, 0xffff, 16), 109662306a36Sopenharmony_ci .status = VOP_REG_MASK_SYNC(RK3328_INTR_STATUS0, 0xffff, 0), 109762306a36Sopenharmony_ci .enable = VOP_REG_MASK_SYNC(RK3328_INTR_EN0, 0xffff, 0), 109862306a36Sopenharmony_ci .clear = VOP_REG_MASK_SYNC(RK3328_INTR_CLEAR0, 0xffff, 0), 109962306a36Sopenharmony_ci}; 110062306a36Sopenharmony_ci 110162306a36Sopenharmony_cistatic const struct vop_win_data rk3328_vop_win_data[] = { 110262306a36Sopenharmony_ci { .base = 0xd0, .phy = &rk3368_win01_data, 110362306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_PRIMARY }, 110462306a36Sopenharmony_ci { .base = 0x1d0, .phy = &rk3368_win01_data, 110562306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_OVERLAY }, 110662306a36Sopenharmony_ci { .base = 0x2d0, .phy = &rk3368_win01_data, 110762306a36Sopenharmony_ci .type = DRM_PLANE_TYPE_CURSOR }, 110862306a36Sopenharmony_ci}; 110962306a36Sopenharmony_ci 111062306a36Sopenharmony_cistatic const struct vop_data rk3328_vop = { 111162306a36Sopenharmony_ci .version = VOP_VERSION(3, 8), 111262306a36Sopenharmony_ci .feature = VOP_FEATURE_OUTPUT_RGB10, 111362306a36Sopenharmony_ci .intr = &rk3328_vop_intr, 111462306a36Sopenharmony_ci .common = &rk3328_common, 111562306a36Sopenharmony_ci .modeset = &rk3328_modeset, 111662306a36Sopenharmony_ci .output = &rk3328_output, 111762306a36Sopenharmony_ci .misc = &rk3328_misc, 111862306a36Sopenharmony_ci .win = rk3328_vop_win_data, 111962306a36Sopenharmony_ci .win_size = ARRAY_SIZE(rk3328_vop_win_data), 112062306a36Sopenharmony_ci .max_output = { 4096, 2160 }, 112162306a36Sopenharmony_ci}; 112262306a36Sopenharmony_ci 112362306a36Sopenharmony_cistatic const struct of_device_id vop_driver_dt_match[] = { 112462306a36Sopenharmony_ci { .compatible = "rockchip,rk3036-vop", 112562306a36Sopenharmony_ci .data = &rk3036_vop }, 112662306a36Sopenharmony_ci { .compatible = "rockchip,rk3126-vop", 112762306a36Sopenharmony_ci .data = &rk3126_vop }, 112862306a36Sopenharmony_ci { .compatible = "rockchip,px30-vop-big", 112962306a36Sopenharmony_ci .data = &px30_vop_big }, 113062306a36Sopenharmony_ci { .compatible = "rockchip,px30-vop-lit", 113162306a36Sopenharmony_ci .data = &px30_vop_lit }, 113262306a36Sopenharmony_ci { .compatible = "rockchip,rk3066-vop", 113362306a36Sopenharmony_ci .data = &rk3066_vop }, 113462306a36Sopenharmony_ci { .compatible = "rockchip,rk3188-vop", 113562306a36Sopenharmony_ci .data = &rk3188_vop }, 113662306a36Sopenharmony_ci { .compatible = "rockchip,rk3288-vop", 113762306a36Sopenharmony_ci .data = &rk3288_vop }, 113862306a36Sopenharmony_ci { .compatible = "rockchip,rk3368-vop", 113962306a36Sopenharmony_ci .data = &rk3368_vop }, 114062306a36Sopenharmony_ci { .compatible = "rockchip,rk3366-vop", 114162306a36Sopenharmony_ci .data = &rk3366_vop }, 114262306a36Sopenharmony_ci { .compatible = "rockchip,rk3399-vop-big", 114362306a36Sopenharmony_ci .data = &rk3399_vop_big }, 114462306a36Sopenharmony_ci { .compatible = "rockchip,rk3399-vop-lit", 114562306a36Sopenharmony_ci .data = &rk3399_vop_lit }, 114662306a36Sopenharmony_ci { .compatible = "rockchip,rk3228-vop", 114762306a36Sopenharmony_ci .data = &rk3228_vop }, 114862306a36Sopenharmony_ci { .compatible = "rockchip,rk3328-vop", 114962306a36Sopenharmony_ci .data = &rk3328_vop }, 115062306a36Sopenharmony_ci {}, 115162306a36Sopenharmony_ci}; 115262306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, vop_driver_dt_match); 115362306a36Sopenharmony_ci 115462306a36Sopenharmony_cistatic int vop_probe(struct platform_device *pdev) 115562306a36Sopenharmony_ci{ 115662306a36Sopenharmony_ci struct device *dev = &pdev->dev; 115762306a36Sopenharmony_ci 115862306a36Sopenharmony_ci if (!dev->of_node) { 115962306a36Sopenharmony_ci DRM_DEV_ERROR(dev, "can't find vop devices\n"); 116062306a36Sopenharmony_ci return -ENODEV; 116162306a36Sopenharmony_ci } 116262306a36Sopenharmony_ci 116362306a36Sopenharmony_ci return component_add(dev, &vop_component_ops); 116462306a36Sopenharmony_ci} 116562306a36Sopenharmony_ci 116662306a36Sopenharmony_cistatic void vop_remove(struct platform_device *pdev) 116762306a36Sopenharmony_ci{ 116862306a36Sopenharmony_ci component_del(&pdev->dev, &vop_component_ops); 116962306a36Sopenharmony_ci} 117062306a36Sopenharmony_ci 117162306a36Sopenharmony_cistruct platform_driver vop_platform_driver = { 117262306a36Sopenharmony_ci .probe = vop_probe, 117362306a36Sopenharmony_ci .remove_new = vop_remove, 117462306a36Sopenharmony_ci .driver = { 117562306a36Sopenharmony_ci .name = "rockchip-vop", 117662306a36Sopenharmony_ci .of_match_table = vop_driver_dt_match, 117762306a36Sopenharmony_ci }, 117862306a36Sopenharmony_ci}; 1179