18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * (C) COPYRIGHT 2013-2016 ARM Limited. All rights reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * ARM Mali DP hardware manipulation routines. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __MALIDP_HW_H__ 108c2ecf20Sopenharmony_ci#define __MALIDP_HW_H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/bitops.h> 138c2ecf20Sopenharmony_ci#include "malidp_regs.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct videomode; 168c2ecf20Sopenharmony_cistruct clk; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* Mali DP IP blocks */ 198c2ecf20Sopenharmony_cienum { 208c2ecf20Sopenharmony_ci MALIDP_DE_BLOCK = 0, 218c2ecf20Sopenharmony_ci MALIDP_SE_BLOCK, 228c2ecf20Sopenharmony_ci MALIDP_DC_BLOCK 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* Mali DP layer IDs */ 268c2ecf20Sopenharmony_cienum { 278c2ecf20Sopenharmony_ci DE_VIDEO1 = BIT(0), 288c2ecf20Sopenharmony_ci DE_GRAPHICS1 = BIT(1), 298c2ecf20Sopenharmony_ci DE_GRAPHICS2 = BIT(2), /* used only in DP500 */ 308c2ecf20Sopenharmony_ci DE_VIDEO2 = BIT(3), 318c2ecf20Sopenharmony_ci DE_SMART = BIT(4), 328c2ecf20Sopenharmony_ci SE_MEMWRITE = BIT(5), 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cienum rotation_features { 368c2ecf20Sopenharmony_ci ROTATE_NONE, /* does not support rotation at all */ 378c2ecf20Sopenharmony_ci ROTATE_ANY, /* supports rotation on any buffers */ 388c2ecf20Sopenharmony_ci ROTATE_COMPRESSED, /* supports rotation only on compressed buffers */ 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct malidp_format_id { 428c2ecf20Sopenharmony_ci u32 format; /* DRM fourcc */ 438c2ecf20Sopenharmony_ci u8 layer; /* bitmask of layers supporting it */ 448c2ecf20Sopenharmony_ci u8 id; /* used internally */ 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define MALIDP_INVALID_FORMAT_ID 0xff 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* 508c2ecf20Sopenharmony_ci * hide the differences between register maps 518c2ecf20Sopenharmony_ci * by using a common structure to hold the 528c2ecf20Sopenharmony_ci * base register offsets 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistruct malidp_irq_map { 568c2ecf20Sopenharmony_ci u32 irq_mask; /* mask of IRQs that can be enabled in the block */ 578c2ecf20Sopenharmony_ci u32 vsync_irq; /* IRQ bit used for signaling during VSYNC */ 588c2ecf20Sopenharmony_ci u32 err_mask; /* mask of bits that represent errors */ 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistruct malidp_layer { 628c2ecf20Sopenharmony_ci u16 id; /* layer ID */ 638c2ecf20Sopenharmony_ci u16 base; /* address offset for the register bank */ 648c2ecf20Sopenharmony_ci u16 ptr; /* address offset for the pointer register */ 658c2ecf20Sopenharmony_ci u16 stride_offset; /* offset to the first stride register. */ 668c2ecf20Sopenharmony_ci s16 yuv2rgb_offset; /* offset to the YUV->RGB matrix entries */ 678c2ecf20Sopenharmony_ci u16 mmu_ctrl_offset; /* offset to the MMU control register */ 688c2ecf20Sopenharmony_ci enum rotation_features rot; /* type of rotation supported */ 698c2ecf20Sopenharmony_ci /* address offset for the AFBC decoder registers */ 708c2ecf20Sopenharmony_ci u16 afbc_decoder_offset; 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cienum malidp_scaling_coeff_set { 748c2ecf20Sopenharmony_ci MALIDP_UPSCALING_COEFFS = 1, 758c2ecf20Sopenharmony_ci MALIDP_DOWNSCALING_1_5_COEFFS = 2, 768c2ecf20Sopenharmony_ci MALIDP_DOWNSCALING_2_COEFFS = 3, 778c2ecf20Sopenharmony_ci MALIDP_DOWNSCALING_2_75_COEFFS = 4, 788c2ecf20Sopenharmony_ci MALIDP_DOWNSCALING_4_COEFFS = 5, 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistruct malidp_se_config { 828c2ecf20Sopenharmony_ci u8 scale_enable : 1; 838c2ecf20Sopenharmony_ci u8 enhancer_enable : 1; 848c2ecf20Sopenharmony_ci u8 hcoeff : 3; 858c2ecf20Sopenharmony_ci u8 vcoeff : 3; 868c2ecf20Sopenharmony_ci u8 plane_src_id; 878c2ecf20Sopenharmony_ci u16 input_w, input_h; 888c2ecf20Sopenharmony_ci u16 output_w, output_h; 898c2ecf20Sopenharmony_ci u32 h_init_phase, h_delta_phase; 908c2ecf20Sopenharmony_ci u32 v_init_phase, v_delta_phase; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* regmap features */ 948c2ecf20Sopenharmony_ci#define MALIDP_REGMAP_HAS_CLEARIRQ BIT(0) 958c2ecf20Sopenharmony_ci#define MALIDP_DEVICE_AFBC_SUPPORT_SPLIT BIT(1) 968c2ecf20Sopenharmony_ci#define MALIDP_DEVICE_AFBC_YUV_420_10_SUPPORT_SPLIT BIT(2) 978c2ecf20Sopenharmony_ci#define MALIDP_DEVICE_AFBC_YUYV_USE_422_P2 BIT(3) 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistruct malidp_hw_regmap { 1008c2ecf20Sopenharmony_ci /* address offset of the DE register bank */ 1018c2ecf20Sopenharmony_ci /* is always 0x0000 */ 1028c2ecf20Sopenharmony_ci /* address offset of the DE coefficients registers */ 1038c2ecf20Sopenharmony_ci const u16 coeffs_base; 1048c2ecf20Sopenharmony_ci /* address offset of the SE registers bank */ 1058c2ecf20Sopenharmony_ci const u16 se_base; 1068c2ecf20Sopenharmony_ci /* address offset of the DC registers bank */ 1078c2ecf20Sopenharmony_ci const u16 dc_base; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci /* address offset for the output depth register */ 1108c2ecf20Sopenharmony_ci const u16 out_depth_base; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci /* bitmap with register map features */ 1138c2ecf20Sopenharmony_ci const u8 features; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci /* list of supported layers */ 1168c2ecf20Sopenharmony_ci const u8 n_layers; 1178c2ecf20Sopenharmony_ci const struct malidp_layer *layers; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci const struct malidp_irq_map de_irq_map; 1208c2ecf20Sopenharmony_ci const struct malidp_irq_map se_irq_map; 1218c2ecf20Sopenharmony_ci const struct malidp_irq_map dc_irq_map; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci /* list of supported pixel formats for each layer */ 1248c2ecf20Sopenharmony_ci const struct malidp_format_id *pixel_formats; 1258c2ecf20Sopenharmony_ci const u8 n_pixel_formats; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci /* pitch alignment requirement in bytes */ 1288c2ecf20Sopenharmony_ci const u8 bus_align_bytes; 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* device features */ 1328c2ecf20Sopenharmony_ci/* Unlike DP550/650, DP500 has 3 stride registers in its video layer. */ 1338c2ecf20Sopenharmony_ci#define MALIDP_DEVICE_LV_HAS_3_STRIDES BIT(0) 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cistruct malidp_hw_device; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * Static structure containing hardware specific data and pointers to 1398c2ecf20Sopenharmony_ci * functions that behave differently between various versions of the IP. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_cistruct malidp_hw { 1428c2ecf20Sopenharmony_ci const struct malidp_hw_regmap map; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci /* 1458c2ecf20Sopenharmony_ci * Validate the driver instance against the hardware bits 1468c2ecf20Sopenharmony_ci */ 1478c2ecf20Sopenharmony_ci int (*query_hw)(struct malidp_hw_device *hwdev); 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci /* 1508c2ecf20Sopenharmony_ci * Set the hardware into config mode, ready to accept mode changes 1518c2ecf20Sopenharmony_ci */ 1528c2ecf20Sopenharmony_ci void (*enter_config_mode)(struct malidp_hw_device *hwdev); 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci /* 1558c2ecf20Sopenharmony_ci * Tell hardware to exit configuration mode 1568c2ecf20Sopenharmony_ci */ 1578c2ecf20Sopenharmony_ci void (*leave_config_mode)(struct malidp_hw_device *hwdev); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci /* 1608c2ecf20Sopenharmony_ci * Query if hardware is in configuration mode 1618c2ecf20Sopenharmony_ci */ 1628c2ecf20Sopenharmony_ci bool (*in_config_mode)(struct malidp_hw_device *hwdev); 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci /* 1658c2ecf20Sopenharmony_ci * Set/clear configuration valid flag for hardware parameters that can 1668c2ecf20Sopenharmony_ci * be changed outside the configuration mode to the given value. 1678c2ecf20Sopenharmony_ci * Hardware will use the new settings when config valid is set, 1688c2ecf20Sopenharmony_ci * after the end of the current buffer scanout, and will ignore 1698c2ecf20Sopenharmony_ci * any new values for those parameters if config valid flag is cleared 1708c2ecf20Sopenharmony_ci */ 1718c2ecf20Sopenharmony_ci void (*set_config_valid)(struct malidp_hw_device *hwdev, u8 value); 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci /* 1748c2ecf20Sopenharmony_ci * Set a new mode in hardware. Requires the hardware to be in 1758c2ecf20Sopenharmony_ci * configuration mode before this function is called. 1768c2ecf20Sopenharmony_ci */ 1778c2ecf20Sopenharmony_ci void (*modeset)(struct malidp_hw_device *hwdev, struct videomode *m); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci /* 1808c2ecf20Sopenharmony_ci * Calculate the required rotation memory given the active area 1818c2ecf20Sopenharmony_ci * and the buffer format. 1828c2ecf20Sopenharmony_ci */ 1838c2ecf20Sopenharmony_ci int (*rotmem_required)(struct malidp_hw_device *hwdev, u16 w, u16 h, 1848c2ecf20Sopenharmony_ci u32 fmt, bool has_modifier); 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci int (*se_set_scaling_coeffs)(struct malidp_hw_device *hwdev, 1878c2ecf20Sopenharmony_ci struct malidp_se_config *se_config, 1888c2ecf20Sopenharmony_ci struct malidp_se_config *old_config); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci long (*se_calc_mclk)(struct malidp_hw_device *hwdev, 1918c2ecf20Sopenharmony_ci struct malidp_se_config *se_config, 1928c2ecf20Sopenharmony_ci struct videomode *vm); 1938c2ecf20Sopenharmony_ci /* 1948c2ecf20Sopenharmony_ci * Enable writing to memory the content of the next frame 1958c2ecf20Sopenharmony_ci * @param hwdev - malidp_hw_device structure containing the HW description 1968c2ecf20Sopenharmony_ci * @param addrs - array of addresses for each plane 1978c2ecf20Sopenharmony_ci * @param pitches - array of pitches for each plane 1988c2ecf20Sopenharmony_ci * @param num_planes - number of planes to be written 1998c2ecf20Sopenharmony_ci * @param w - width of the output frame 2008c2ecf20Sopenharmony_ci * @param h - height of the output frame 2018c2ecf20Sopenharmony_ci * @param fmt_id - internal format ID of output buffer 2028c2ecf20Sopenharmony_ci */ 2038c2ecf20Sopenharmony_ci int (*enable_memwrite)(struct malidp_hw_device *hwdev, dma_addr_t *addrs, 2048c2ecf20Sopenharmony_ci s32 *pitches, int num_planes, u16 w, u16 h, u32 fmt_id, 2058c2ecf20Sopenharmony_ci const s16 *rgb2yuv_coeffs); 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci /* 2088c2ecf20Sopenharmony_ci * Disable the writing to memory of the next frame's content. 2098c2ecf20Sopenharmony_ci */ 2108c2ecf20Sopenharmony_ci void (*disable_memwrite)(struct malidp_hw_device *hwdev); 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci u8 features; 2138c2ecf20Sopenharmony_ci}; 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci/* Supported variants of the hardware */ 2168c2ecf20Sopenharmony_cienum { 2178c2ecf20Sopenharmony_ci MALIDP_500 = 0, 2188c2ecf20Sopenharmony_ci MALIDP_550, 2198c2ecf20Sopenharmony_ci MALIDP_650, 2208c2ecf20Sopenharmony_ci /* keep the next entry last */ 2218c2ecf20Sopenharmony_ci MALIDP_MAX_DEVICES 2228c2ecf20Sopenharmony_ci}; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ciextern const struct malidp_hw malidp_device[MALIDP_MAX_DEVICES]; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci/* 2278c2ecf20Sopenharmony_ci * Structure used by the driver during runtime operation. 2288c2ecf20Sopenharmony_ci */ 2298c2ecf20Sopenharmony_cistruct malidp_hw_device { 2308c2ecf20Sopenharmony_ci struct malidp_hw *hw; 2318c2ecf20Sopenharmony_ci void __iomem *regs; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci /* APB clock */ 2348c2ecf20Sopenharmony_ci struct clk *pclk; 2358c2ecf20Sopenharmony_ci /* AXI clock */ 2368c2ecf20Sopenharmony_ci struct clk *aclk; 2378c2ecf20Sopenharmony_ci /* main clock for display core */ 2388c2ecf20Sopenharmony_ci struct clk *mclk; 2398c2ecf20Sopenharmony_ci /* pixel clock for display core */ 2408c2ecf20Sopenharmony_ci struct clk *pxlclk; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci u8 min_line_size; 2438c2ecf20Sopenharmony_ci u16 max_line_size; 2448c2ecf20Sopenharmony_ci u32 output_color_depth; 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci /* track the device PM state */ 2478c2ecf20Sopenharmony_ci bool pm_suspended; 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci /* track the SE memory writeback state */ 2508c2ecf20Sopenharmony_ci u8 mw_state; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci /* size of memory used for rotating layers, up to two banks available */ 2538c2ecf20Sopenharmony_ci u32 rotation_memory[2]; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci /* priority level of RQOS register used for driven the ARQOS signal */ 2568c2ecf20Sopenharmony_ci u32 arqos_value; 2578c2ecf20Sopenharmony_ci}; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistatic inline u32 malidp_hw_read(struct malidp_hw_device *hwdev, u32 reg) 2608c2ecf20Sopenharmony_ci{ 2618c2ecf20Sopenharmony_ci WARN_ON(hwdev->pm_suspended); 2628c2ecf20Sopenharmony_ci return readl(hwdev->regs + reg); 2638c2ecf20Sopenharmony_ci} 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_cistatic inline void malidp_hw_write(struct malidp_hw_device *hwdev, 2668c2ecf20Sopenharmony_ci u32 value, u32 reg) 2678c2ecf20Sopenharmony_ci{ 2688c2ecf20Sopenharmony_ci WARN_ON(hwdev->pm_suspended); 2698c2ecf20Sopenharmony_ci writel(value, hwdev->regs + reg); 2708c2ecf20Sopenharmony_ci} 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_cistatic inline void malidp_hw_setbits(struct malidp_hw_device *hwdev, 2738c2ecf20Sopenharmony_ci u32 mask, u32 reg) 2748c2ecf20Sopenharmony_ci{ 2758c2ecf20Sopenharmony_ci u32 data = malidp_hw_read(hwdev, reg); 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci data |= mask; 2788c2ecf20Sopenharmony_ci malidp_hw_write(hwdev, data, reg); 2798c2ecf20Sopenharmony_ci} 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_cistatic inline void malidp_hw_clearbits(struct malidp_hw_device *hwdev, 2828c2ecf20Sopenharmony_ci u32 mask, u32 reg) 2838c2ecf20Sopenharmony_ci{ 2848c2ecf20Sopenharmony_ci u32 data = malidp_hw_read(hwdev, reg); 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci data &= ~mask; 2878c2ecf20Sopenharmony_ci malidp_hw_write(hwdev, data, reg); 2888c2ecf20Sopenharmony_ci} 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_cistatic inline u32 malidp_get_block_base(struct malidp_hw_device *hwdev, 2918c2ecf20Sopenharmony_ci u8 block) 2928c2ecf20Sopenharmony_ci{ 2938c2ecf20Sopenharmony_ci switch (block) { 2948c2ecf20Sopenharmony_ci case MALIDP_SE_BLOCK: 2958c2ecf20Sopenharmony_ci return hwdev->hw->map.se_base; 2968c2ecf20Sopenharmony_ci case MALIDP_DC_BLOCK: 2978c2ecf20Sopenharmony_ci return hwdev->hw->map.dc_base; 2988c2ecf20Sopenharmony_ci } 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci return 0; 3018c2ecf20Sopenharmony_ci} 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistatic inline void malidp_hw_disable_irq(struct malidp_hw_device *hwdev, 3048c2ecf20Sopenharmony_ci u8 block, u32 irq) 3058c2ecf20Sopenharmony_ci{ 3068c2ecf20Sopenharmony_ci u32 base = malidp_get_block_base(hwdev, block); 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci malidp_hw_clearbits(hwdev, irq, base + MALIDP_REG_MASKIRQ); 3098c2ecf20Sopenharmony_ci} 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_cistatic inline void malidp_hw_enable_irq(struct malidp_hw_device *hwdev, 3128c2ecf20Sopenharmony_ci u8 block, u32 irq) 3138c2ecf20Sopenharmony_ci{ 3148c2ecf20Sopenharmony_ci u32 base = malidp_get_block_base(hwdev, block); 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci malidp_hw_setbits(hwdev, irq, base + MALIDP_REG_MASKIRQ); 3178c2ecf20Sopenharmony_ci} 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ciint malidp_de_irq_init(struct drm_device *drm, int irq); 3208c2ecf20Sopenharmony_civoid malidp_se_irq_hw_init(struct malidp_hw_device *hwdev); 3218c2ecf20Sopenharmony_civoid malidp_de_irq_hw_init(struct malidp_hw_device *hwdev); 3228c2ecf20Sopenharmony_civoid malidp_de_irq_fini(struct malidp_hw_device *hwdev); 3238c2ecf20Sopenharmony_ciint malidp_se_irq_init(struct drm_device *drm, int irq); 3248c2ecf20Sopenharmony_civoid malidp_se_irq_fini(struct malidp_hw_device *hwdev); 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ciu8 malidp_hw_get_format_id(const struct malidp_hw_regmap *map, 3278c2ecf20Sopenharmony_ci u8 layer_id, u32 format, bool has_modifier); 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ciint malidp_format_get_bpp(u32 fmt); 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_cistatic inline u8 malidp_hw_get_pitch_align(struct malidp_hw_device *hwdev, bool rotated) 3328c2ecf20Sopenharmony_ci{ 3338c2ecf20Sopenharmony_ci /* 3348c2ecf20Sopenharmony_ci * only hardware that cannot do 8 bytes bus alignments have further 3358c2ecf20Sopenharmony_ci * constraints on rotated planes 3368c2ecf20Sopenharmony_ci */ 3378c2ecf20Sopenharmony_ci if (hwdev->hw->map.bus_align_bytes == 8) 3388c2ecf20Sopenharmony_ci return 8; 3398c2ecf20Sopenharmony_ci else 3408c2ecf20Sopenharmony_ci return hwdev->hw->map.bus_align_bytes << (rotated ? 2 : 0); 3418c2ecf20Sopenharmony_ci} 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci/* U16.16 */ 3448c2ecf20Sopenharmony_ci#define FP_1_00000 0x00010000 /* 1.0 */ 3458c2ecf20Sopenharmony_ci#define FP_0_66667 0x0000AAAA /* 0.6667 = 1/1.5 */ 3468c2ecf20Sopenharmony_ci#define FP_0_50000 0x00008000 /* 0.5 = 1/2 */ 3478c2ecf20Sopenharmony_ci#define FP_0_36363 0x00005D17 /* 0.36363 = 1/2.75 */ 3488c2ecf20Sopenharmony_ci#define FP_0_25000 0x00004000 /* 0.25 = 1/4 */ 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_cistatic inline enum malidp_scaling_coeff_set 3518c2ecf20Sopenharmony_cimalidp_se_select_coeffs(u32 upscale_factor) 3528c2ecf20Sopenharmony_ci{ 3538c2ecf20Sopenharmony_ci return (upscale_factor >= FP_1_00000) ? MALIDP_UPSCALING_COEFFS : 3548c2ecf20Sopenharmony_ci (upscale_factor >= FP_0_66667) ? MALIDP_DOWNSCALING_1_5_COEFFS : 3558c2ecf20Sopenharmony_ci (upscale_factor >= FP_0_50000) ? MALIDP_DOWNSCALING_2_COEFFS : 3568c2ecf20Sopenharmony_ci (upscale_factor >= FP_0_36363) ? MALIDP_DOWNSCALING_2_75_COEFFS : 3578c2ecf20Sopenharmony_ci MALIDP_DOWNSCALING_4_COEFFS; 3588c2ecf20Sopenharmony_ci} 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci#undef FP_0_25000 3618c2ecf20Sopenharmony_ci#undef FP_0_36363 3628c2ecf20Sopenharmony_ci#undef FP_0_50000 3638c2ecf20Sopenharmony_ci#undef FP_0_66667 3648c2ecf20Sopenharmony_ci#undef FP_1_00000 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_cistatic inline void malidp_se_set_enh_coeffs(struct malidp_hw_device *hwdev) 3678c2ecf20Sopenharmony_ci{ 3688c2ecf20Sopenharmony_ci static const s32 enhancer_coeffs[] = { 3698c2ecf20Sopenharmony_ci -8, -8, -8, -8, 128, -8, -8, -8, -8 3708c2ecf20Sopenharmony_ci }; 3718c2ecf20Sopenharmony_ci u32 val = MALIDP_SE_SET_ENH_LIMIT_LOW(MALIDP_SE_ENH_LOW_LEVEL) | 3728c2ecf20Sopenharmony_ci MALIDP_SE_SET_ENH_LIMIT_HIGH(MALIDP_SE_ENH_HIGH_LEVEL); 3738c2ecf20Sopenharmony_ci u32 image_enh = hwdev->hw->map.se_base + 3748c2ecf20Sopenharmony_ci ((hwdev->hw->map.features & MALIDP_REGMAP_HAS_CLEARIRQ) ? 3758c2ecf20Sopenharmony_ci 0x10 : 0xC) + MALIDP_SE_IMAGE_ENH; 3768c2ecf20Sopenharmony_ci u32 enh_coeffs = image_enh + MALIDP_SE_ENH_COEFF0; 3778c2ecf20Sopenharmony_ci int i; 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci malidp_hw_write(hwdev, val, image_enh); 3808c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(enhancer_coeffs); ++i) 3818c2ecf20Sopenharmony_ci malidp_hw_write(hwdev, enhancer_coeffs[i], enh_coeffs + i * 4); 3828c2ecf20Sopenharmony_ci} 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci/* 3858c2ecf20Sopenharmony_ci * background color components are defined as 12bits values, 3868c2ecf20Sopenharmony_ci * they will be shifted right when stored on hardware that 3878c2ecf20Sopenharmony_ci * supports only 8bits per channel 3888c2ecf20Sopenharmony_ci */ 3898c2ecf20Sopenharmony_ci#define MALIDP_BGND_COLOR_R 0x000 3908c2ecf20Sopenharmony_ci#define MALIDP_BGND_COLOR_G 0x000 3918c2ecf20Sopenharmony_ci#define MALIDP_BGND_COLOR_B 0x000 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci#define MALIDP_COLORADJ_NUM_COEFFS 12 3948c2ecf20Sopenharmony_ci#define MALIDP_COEFFTAB_NUM_COEFFS 64 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci#define MALIDP_GAMMA_LUT_SIZE 4096 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci#define AFBC_SIZE_MASK AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 3998c2ecf20Sopenharmony_ci#define AFBC_SIZE_16X16 AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 4008c2ecf20Sopenharmony_ci#define AFBC_YTR AFBC_FORMAT_MOD_YTR 4018c2ecf20Sopenharmony_ci#define AFBC_SPARSE AFBC_FORMAT_MOD_SPARSE 4028c2ecf20Sopenharmony_ci#define AFBC_CBR AFBC_FORMAT_MOD_CBR 4038c2ecf20Sopenharmony_ci#define AFBC_SPLIT AFBC_FORMAT_MOD_SPLIT 4048c2ecf20Sopenharmony_ci#define AFBC_TILED AFBC_FORMAT_MOD_TILED 4058c2ecf20Sopenharmony_ci#define AFBC_SC AFBC_FORMAT_MOD_SC 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci#define AFBC_MOD_VALID_BITS (AFBC_SIZE_MASK | AFBC_YTR | AFBC_SPLIT | \ 4088c2ecf20Sopenharmony_ci AFBC_SPARSE | AFBC_CBR | AFBC_TILED | AFBC_SC) 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ciextern const u64 malidp_format_modifiers[]; 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci#endif /* __MALIDP_HW_H__ */ 413