Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: mali-dp: Enable image enhancement when scaling

Apply image enhacement when we are upscaling by a factor of 2
or more in either direction.

Signed-off-by: Mihail Atanassov <mihail.atanassov@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>

authored by

Mihail Atanassov and committed by
Liviu Dudau
0274e6a0 28ce675b

+42 -1
+6 -1
drivers/gpu/drm/arm/malidp_crtc.c
··· 288 288 if (!(h_upscale_factor >> 16) || !(v_upscale_factor >> 16)) 289 289 return -EINVAL; 290 290 291 + s->enhancer_enable = ((h_upscale_factor >> 16) >= 2 || 292 + (v_upscale_factor >> 16) >= 2); 293 + 291 294 s->input_w = pstate->src_w >> 16; 292 295 s->input_h = pstate->src_h >> 16; 293 296 s->output_w = pstate->crtc_w; ··· 533 530 534 531 drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs); 535 532 drm_mode_crtc_set_gamma_size(&malidp->crtc, MALIDP_GAMMA_LUT_SIZE); 536 - /* No inverse-gamma: it is per-plane */ 533 + /* No inverse-gamma: it is per-plane. */ 537 534 drm_crtc_enable_color_mgmt(&malidp->crtc, 0, true, MALIDP_GAMMA_LUT_SIZE); 535 + 536 + malidp_se_set_enh_coeffs(malidp->dev); 538 537 539 538 return 0; 540 539
+3
drivers/gpu/drm/arm/malidp_drv.c
··· 138 138 val = malidp_hw_read(hwdev, se_control); 139 139 val |= MALIDP_SE_SCALING_EN | MALIDP_SE_ALPHA_EN; 140 140 141 + val &= ~MALIDP_SE_ENH(MALIDP_SE_ENH_MASK); 142 + val |= s->enhancer_enable ? MALIDP_SE_ENH(3) : 0; 143 + 141 144 val |= MALIDP_SE_RGBO_IF_EN; 142 145 malidp_hw_write(hwdev, val, se_control); 143 146
+20
drivers/gpu/drm/arm/malidp_hw.h
··· 71 71 72 72 struct malidp_se_config { 73 73 u8 scale_enable : 1; 74 + u8 enhancer_enable : 1; 74 75 u8 hcoeff : 3; 75 76 u8 vcoeff : 3; 76 77 u8 plane_src_id; ··· 296 295 #undef FP_0_50000 297 296 #undef FP_0_66667 298 297 #undef FP_1_00000 298 + 299 + static inline void malidp_se_set_enh_coeffs(struct malidp_hw_device *hwdev) 300 + { 301 + static const s32 enhancer_coeffs[] = { 302 + -8, -8, -8, -8, 128, -8, -8, -8, -8 303 + }; 304 + u32 val = MALIDP_SE_SET_ENH_LIMIT_LOW(MALIDP_SE_ENH_LOW_LEVEL) | 305 + MALIDP_SE_SET_ENH_LIMIT_HIGH(MALIDP_SE_ENH_HIGH_LEVEL); 306 + u32 image_enh = hwdev->map.se_base + 307 + ((hwdev->map.features & MALIDP_REGMAP_HAS_CLEARIRQ) ? 308 + 0x10 : 0xC) + MALIDP_SE_IMAGE_ENH; 309 + u32 enh_coeffs = image_enh + MALIDP_SE_ENH_COEFF0; 310 + int i; 311 + 312 + malidp_hw_write(hwdev, val, image_enh); 313 + for (i = 0; i < ARRAY_SIZE(enhancer_coeffs); ++i) 314 + malidp_hw_write(hwdev, enhancer_coeffs[i], enh_coeffs + i * 4); 315 + } 316 + 299 317 /* 300 318 * background color components are defined as 12bits values, 301 319 * they will be shifted right when stored on hardware that
+13
drivers/gpu/drm/arm/malidp_regs.h
··· 109 109 /* Scaling engine registers and masks. */ 110 110 #define MALIDP_SE_SCALING_EN (1 << 0) 111 111 #define MALIDP_SE_ALPHA_EN (1 << 1) 112 + #define MALIDP_SE_ENH_MASK 3 113 + #define MALIDP_SE_ENH(x) (((x) & MALIDP_SE_ENH_MASK) << 2) 112 114 #define MALIDP_SE_RGBO_IF_EN (1 << 4) 113 115 #define MALIDP550_SE_CTL_SEL_MASK 7 114 116 #define MALIDP550_SE_CTL_VCSEL(x) \ ··· 141 139 #define MALIDP_SE_COEFFTAB_DATA_MASK 0x3fff 142 140 #define MALIDP_SE_SET_COEFFTAB_DATA(x) \ 143 141 ((x) & MALIDP_SE_COEFFTAB_DATA_MASK) 142 + /* Enhance coeffents reigster offset */ 143 + #define MALIDP_SE_IMAGE_ENH 0x3C 144 + /* ENH_LIMITS offset 0x0 */ 145 + #define MALIDP_SE_ENH_LOW_LEVEL 24 146 + #define MALIDP_SE_ENH_HIGH_LEVEL 63 147 + #define MALIDP_SE_ENH_LIMIT_MASK 0xfff 148 + #define MALIDP_SE_SET_ENH_LIMIT_LOW(x) \ 149 + ((x) & MALIDP_SE_ENH_LIMIT_MASK) 150 + #define MALIDP_SE_SET_ENH_LIMIT_HIGH(x) \ 151 + (((x) & MALIDP_SE_ENH_LIMIT_MASK) << 16) 152 + #define MALIDP_SE_ENH_COEFF0 0x04 144 153 145 154 /* register offsets and bits specific to DP500 */ 146 155 #define MALIDP500_ADDR_SPACE_SIZE 0x01000