Lines Matching +full:mali +full:- +full:dp500

1 // SPDX-License-Identifier: GPL-2.0-only
6 * ARM Mali DP500/DP550/DP650 hardware manipulation routines. This is where
29 MW_ONESHOT, /* SE in one-shot mode for writeback */
196 [MALIDP_UPSCALING_COEFFS - 1] = {
210 [MALIDP_DOWNSCALING_1_5_COEFFS - 1] = {
224 [MALIDP_DOWNSCALING_2_COEFFS - 1] = {
238 [MALIDP_DOWNSCALING_2_75_COEFFS - 1] = {
252 [MALIDP_DOWNSCALING_4_COEFFS - 1] = {
276 hwdev->min_line_size = 2; in malidp500_query_hw()
277 hwdev->max_line_size = SZ_2K * ln_size_mult; in malidp500_query_hw()
278 hwdev->rotation_memory[0] = SZ_1K * 64 * ln_size_mult; in malidp500_query_hw()
279 hwdev->rotation_memory[1] = 0; /* no second rotation memory bank */ in malidp500_query_hw()
290 status = malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_REG_STATUS); in malidp500_enter_config_mode()
298 count--; in malidp500_enter_config_mode()
310 status = malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_REG_STATUS); in malidp500_leave_config_mode()
314 count--; in malidp500_leave_config_mode()
323 status = malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_REG_STATUS); in malidp500_in_config_mode()
342 malidp_hw_write(hwdev, hwdev->output_color_depth, in malidp500_modeset()
343 hwdev->hw->map.out_depth_base); in malidp500_modeset()
345 if (mode->flags & DISPLAY_FLAGS_HSYNC_HIGH) in malidp500_modeset()
347 if (mode->flags & DISPLAY_FLAGS_VSYNC_HIGH) in malidp500_modeset()
353 * Mali-DP500 encodes the background color like this: in malidp500_modeset()
354 * - red @ MALIDP500_BGND_COLOR[12:0] in malidp500_modeset()
355 * - green @ MALIDP500_BGND_COLOR[27:16] in malidp500_modeset()
356 * - blue @ (MALIDP500_BGND_COLOR + 4)[12:0] in malidp500_modeset()
363 val = MALIDP_DE_H_FRONTPORCH(mode->hfront_porch) | in malidp500_modeset()
364 MALIDP_DE_H_BACKPORCH(mode->hback_porch); in malidp500_modeset()
367 val = MALIDP500_DE_V_FRONTPORCH(mode->vfront_porch) | in malidp500_modeset()
368 MALIDP_DE_V_BACKPORCH(mode->vback_porch); in malidp500_modeset()
371 val = MALIDP_DE_H_SYNCWIDTH(mode->hsync_len) | in malidp500_modeset()
372 MALIDP_DE_V_SYNCWIDTH(mode->vsync_len); in malidp500_modeset()
375 val = MALIDP_DE_H_ACTIVE(mode->hactive) | MALIDP_DE_V_ACTIVE(mode->vactive); in malidp500_modeset()
378 if (mode->flags & DISPLAY_FLAGS_INTERLACED) in malidp500_modeset()
387 if (hwdev->arqos_value) { in malidp500_modeset()
388 val = hwdev->arqos_value; in malidp500_modeset()
396 int bpp = info->cpp[0] * 8; in malidp_format_get_bpp()
452 u8 h = (u8)se_config->hcoeff - 1; in malidp500_se_set_scaling_coeffs()
453 u8 v = (u8)se_config->vcoeff - 1; in malidp500_se_set_scaling_coeffs()
457 return -EINVAL; in malidp500_se_set_scaling_coeffs()
459 if ((h == v) && (se_config->hcoeff != old_config->hcoeff || in malidp500_se_set_scaling_coeffs()
460 se_config->vcoeff != old_config->vcoeff)) { in malidp500_se_set_scaling_coeffs()
466 if (se_config->vcoeff != old_config->vcoeff) in malidp500_se_set_scaling_coeffs()
470 if (se_config->hcoeff != old_config->hcoeff) in malidp500_se_set_scaling_coeffs()
484 unsigned long pxlclk = vm->pixelclock; /* Hz */ in malidp500_se_calc_mclk()
485 unsigned long htotal = vm->hactive + vm->hfront_porch + in malidp500_se_calc_mclk()
486 vm->hback_porch + vm->hsync_len; in malidp500_se_calc_mclk()
487 unsigned long input_size = se_config->input_w * se_config->input_h; in malidp500_se_calc_mclk()
497 if (se_config->scale_enable) { in malidp500_se_calc_mclk()
498 a = 15 * input_size / (htotal * se_config->output_h); in malidp500_se_calc_mclk()
503 ret = clk_get_rate(hwdev->mclk); in malidp500_se_calc_mclk()
507 return -EINVAL; in malidp500_se_calc_mclk()
524 if (hwdev->mw_state != MW_NOT_ENABLED) in malidp500_enable_memwrite()
525 hwdev->mw_state = MW_RESTART; in malidp500_enable_memwrite()
527 hwdev->mw_state = MW_START; in malidp500_enable_memwrite()
566 if (hwdev->mw_state == MW_START || hwdev->mw_state == MW_RESTART) in malidp500_disable_memwrite()
567 hwdev->mw_state = MW_STOP; in malidp500_disable_memwrite()
577 hwdev->min_line_size = 2; in malidp550_query_hw()
581 hwdev->max_line_size = SZ_2K; in malidp550_query_hw()
586 hwdev->max_line_size = SZ_4K; in malidp550_query_hw()
591 hwdev->max_line_size = 1280; in malidp550_query_hw()
597 hwdev->max_line_size = 0; in malidp550_query_hw()
598 return -EINVAL; in malidp550_query_hw()
601 hwdev->rotation_memory[0] = hwdev->rotation_memory[1] = rsize * SZ_1K; in malidp550_query_hw()
611 status = malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_REG_STATUS); in malidp550_enter_config_mode()
619 count--; in malidp550_enter_config_mode()
631 status = malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_REG_STATUS); in malidp550_leave_config_mode()
635 count--; in malidp550_leave_config_mode()
644 status = malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_REG_STATUS); in malidp550_in_config_mode()
663 malidp_hw_write(hwdev, hwdev->output_color_depth, in malidp550_modeset()
664 hwdev->hw->map.out_depth_base); in malidp550_modeset()
667 * Mali-DP550 and Mali-DP650 encode the background color like this: in malidp550_modeset()
668 * - red @ MALIDP550_DE_BGND_COLOR[23:16] in malidp550_modeset()
669 * - green @ MALIDP550_DE_BGND_COLOR[15:8] in malidp550_modeset()
670 * - blue @ MALIDP550_DE_BGND_COLOR[7:0] in malidp550_modeset()
680 val = MALIDP_DE_H_FRONTPORCH(mode->hfront_porch) | in malidp550_modeset()
681 MALIDP_DE_H_BACKPORCH(mode->hback_porch); in malidp550_modeset()
684 val = MALIDP550_DE_V_FRONTPORCH(mode->vfront_porch) | in malidp550_modeset()
685 MALIDP_DE_V_BACKPORCH(mode->vback_porch); in malidp550_modeset()
688 val = MALIDP_DE_H_SYNCWIDTH(mode->hsync_len) | in malidp550_modeset()
689 MALIDP_DE_V_SYNCWIDTH(mode->vsync_len); in malidp550_modeset()
690 if (mode->flags & DISPLAY_FLAGS_HSYNC_HIGH) in malidp550_modeset()
692 if (mode->flags & DISPLAY_FLAGS_VSYNC_HIGH) in malidp550_modeset()
696 val = MALIDP_DE_H_ACTIVE(mode->hactive) | MALIDP_DE_V_ACTIVE(mode->vactive); in malidp550_modeset()
699 if (mode->flags & DISPLAY_FLAGS_INTERLACED) in malidp550_modeset()
753 return -EINVAL; in malidpx50_get_bytes_per_column()
774 return -EINVAL; in malidp550_rotmem_required()
780 if (bytes_per_column == -EINVAL) in malidp550_rotmem_required()
800 if (bytes_per_column == -EINVAL) in malidp650_rotmem_required()
812 u32 new_value = MALIDP550_SE_CTL_VCSEL(se_config->vcoeff) | in malidp550_se_set_scaling_coeffs()
813 MALIDP550_SE_CTL_HCSEL(se_config->hcoeff); in malidp550_se_set_scaling_coeffs()
825 unsigned long pxlclk = vm->pixelclock; in malidp550_se_calc_mclk()
826 unsigned long htotal = vm->hactive + vm->hfront_porch + in malidp550_se_calc_mclk()
827 vm->hback_porch + vm->hsync_len; in malidp550_se_calc_mclk()
831 if (se_config->scale_enable) { in malidp550_se_calc_mclk()
832 numerator = max(se_config->input_w, se_config->output_w) * in malidp550_se_calc_mclk()
833 se_config->input_h; in malidp550_se_calc_mclk()
834 numerator += se_config->output_w * in malidp550_se_calc_mclk()
835 (se_config->output_h - in malidp550_se_calc_mclk()
836 min(se_config->input_h, se_config->output_h)); in malidp550_se_calc_mclk()
837 denominator = (htotal - 2) * se_config->output_h; in malidp550_se_calc_mclk()
844 ret = clk_get_rate(hwdev->mclk); in malidp550_se_calc_mclk()
848 return -EINVAL; in malidp550_se_calc_mclk()
864 hwdev->mw_state = MW_ONESHOT; in malidp550_enable_memwrite()
913 hwdev->min_line_size = 4; in malidp650_query_hw()
919 hwdev->max_line_size = 0; in malidp650_query_hw()
920 return -EINVAL; in malidp650_query_hw()
922 hwdev->max_line_size = SZ_4K; in malidp650_query_hw()
927 hwdev->max_line_size = 2560; in malidp650_query_hw()
932 hwdev->rotation_memory[0] = hwdev->rotation_memory[1] = rsize * SZ_1K; in malidp650_query_hw()
1096 for (i = 0; i < map->n_pixel_formats; i++) { in malidp_hw_get_format_id()
1097 if (((map->pixel_formats[i].layer & layer_id) == layer_id) && in malidp_hw_get_format_id()
1098 (map->pixel_formats[i].format == format)) { in malidp_hw_get_format_id()
1106 (map->features & MALIDP_DEVICE_AFBC_YUYV_USE_422_P2)) in malidp_hw_get_format_id()
1109 return map->pixel_formats[i].id; in malidp_hw_get_format_id()
1162 if (hwdev->hw->map.features & MALIDP_REGMAP_HAS_CLEARIRQ) in malidp_hw_clear_irq()
1178 hwdev = malidp->dev; in malidp_de_irq()
1179 hw = hwdev->hw; in malidp_de_irq()
1180 de = &hw->map.de_irq_map; in malidp_de_irq()
1187 if (hwdev->pm_suspended) in malidp_de_irq()
1191 dc_status = malidp_hw_read(hwdev, hw->map.dc_base + MALIDP_REG_STATUS); in malidp_de_irq()
1192 if (dc_status & hw->map.dc_irq_map.vsync_irq) { in malidp_de_irq()
1195 if (malidp->event != NULL) { in malidp_de_irq()
1196 spin_lock(&drm->event_lock); in malidp_de_irq()
1197 drm_crtc_send_vblank_event(&malidp->crtc, malidp->event); in malidp_de_irq()
1198 malidp->event = NULL; in malidp_de_irq()
1199 spin_unlock(&drm->event_lock); in malidp_de_irq()
1201 atomic_set(&malidp->config_valid, MALIDP_CONFIG_VALID_DONE); in malidp_de_irq()
1206 if (!(status & de->irq_mask)) in malidp_de_irq()
1211 status &= (mask | de->err_mask); in malidp_de_irq()
1212 if ((status & de->vsync_irq) && malidp->crtc.enabled) in malidp_de_irq()
1213 drm_crtc_handle_vblank(&malidp->crtc); in malidp_de_irq()
1216 if (status & de->err_mask) { in malidp_de_irq()
1217 malidp_error(malidp, &malidp->de_errors, status, in malidp_de_irq()
1218 drm_crtc_vblank_count(&malidp->crtc)); in malidp_de_irq()
1231 wake_up(&malidp->wq); in malidp_de_irq_thread_handler()
1246 hwdev->hw->map.dc_irq_map.irq_mask); in malidp_de_irq_hw_init()
1250 hwdev->hw->map.de_irq_map.irq_mask); in malidp_de_irq_hw_init()
1256 struct malidp_hw_device *hwdev = malidp->dev; in malidp_de_irq_init()
1265 ret = devm_request_threaded_irq(drm->dev, irq, malidp_de_irq, in malidp_de_irq_init()
1267 IRQF_SHARED, "malidp-de", drm); in malidp_de_irq_init()
1281 hwdev->hw->map.de_irq_map.irq_mask); in malidp_de_irq_fini()
1283 hwdev->hw->map.dc_irq_map.irq_mask); in malidp_de_irq_fini()
1290 struct malidp_hw_device *hwdev = malidp->dev; in malidp_se_irq()
1291 struct malidp_hw *hw = hwdev->hw; in malidp_se_irq()
1292 const struct malidp_irq_map *se = &hw->map.se_irq_map; in malidp_se_irq()
1300 if (hwdev->pm_suspended) in malidp_se_irq()
1303 status = malidp_hw_read(hwdev, hw->map.se_base + MALIDP_REG_STATUS); in malidp_se_irq()
1304 if (!(status & (se->irq_mask | se->err_mask))) in malidp_se_irq()
1308 if (status & se->err_mask) in malidp_se_irq()
1309 malidp_error(malidp, &malidp->se_errors, status, in malidp_se_irq()
1310 drm_crtc_vblank_count(&malidp->crtc)); in malidp_se_irq()
1312 mask = malidp_hw_read(hwdev, hw->map.se_base + MALIDP_REG_MASKIRQ); in malidp_se_irq()
1315 if (status & se->vsync_irq) { in malidp_se_irq()
1316 switch (hwdev->mw_state) { in malidp_se_irq()
1318 drm_writeback_signal_completion(&malidp->mw_connector, 0); in malidp_se_irq()
1321 drm_writeback_signal_completion(&malidp->mw_connector, 0); in malidp_se_irq()
1323 hwdev->mw_state = MW_NOT_ENABLED; in malidp_se_irq()
1326 drm_writeback_signal_completion(&malidp->mw_connector, 0); in malidp_se_irq()
1329 /* writeback started, need to emulate one-shot mode */ in malidp_se_irq()
1330 hw->disable_memwrite(hwdev); in malidp_se_irq()
1336 status = malidp_hw_read(hwdev, hw->map.dc_base + MALIDP_REG_STATUS); in malidp_se_irq()
1337 if ((atomic_read(&malidp->config_valid) != MALIDP_CONFIG_START) || in malidp_se_irq()
1338 (status & hw->map.dc_irq_map.vsync_irq)) in malidp_se_irq()
1339 hw->set_config_valid(hwdev, 1); in malidp_se_irq()
1356 hwdev->hw->map.se_irq_map.irq_mask); in malidp_se_irq_hw_init()
1367 struct malidp_hw_device *hwdev = malidp->dev; in malidp_se_irq_init()
1374 ret = devm_request_threaded_irq(drm->dev, irq, malidp_se_irq, in malidp_se_irq_init()
1376 IRQF_SHARED, "malidp-se", drm); in malidp_se_irq_init()
1382 hwdev->mw_state = MW_NOT_ENABLED; in malidp_se_irq_init()
1391 hwdev->hw->map.se_irq_map.irq_mask); in malidp_se_irq_fini()