Lines Matching refs:dpu_enc
223 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_get_drm_fmt() local
228 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_get_drm_fmt()
229 info = &dpu_enc->connector->display_info; in dpu_encoder_get_drm_fmt()
241 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_needs_periph_flush() local
247 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_needs_periph_flush()
248 disp_info = &dpu_enc->disp_info; in dpu_encoder_needs_periph_flush()
258 const struct dpu_encoder_virt *dpu_enc; in dpu_encoder_is_widebus_enabled() local
263 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_is_widebus_enabled()
264 disp_info = &dpu_enc->disp_info; in dpu_encoder_is_widebus_enabled()
277 const struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_is_dsc_enabled() local
279 return dpu_enc->dsc ? true : false; in dpu_encoder_is_dsc_enabled()
284 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_get_crc_values_cnt() local
287 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_get_crc_values_cnt()
289 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_get_crc_values_cnt()
290 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_get_crc_values_cnt()
302 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_setup_misr() local
306 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_setup_misr()
308 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_setup_misr()
309 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_setup_misr()
320 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_get_crc() local
329 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_get_crc()
331 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_get_crc()
332 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_get_crc()
478 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_get_vsync_count() local
479 struct dpu_encoder_phys *phys = dpu_enc ? dpu_enc->cur_master : NULL; in dpu_encoder_get_vsync_count()
485 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_get_linecount() local
489 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_get_linecount()
490 phys = dpu_enc ? dpu_enc->cur_master : NULL; in dpu_encoder_get_linecount()
502 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_helper_split_config() local
512 dpu_enc = to_dpu_encoder_virt(phys_enc->parent); in dpu_encoder_helper_split_config()
514 disp_info = &dpu_enc->disp_info; in dpu_encoder_helper_split_config()
540 DPU_DEBUG_ENC(dpu_enc, "enable %d\n", cfg.en); in dpu_encoder_helper_split_config()
549 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_use_dsc_merge() local
553 if (dpu_enc->phys_encs[i]) in dpu_encoder_use_dsc_merge()
557 if (dpu_enc->dsc) in dpu_encoder_use_dsc_merge()
566 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_get_dsc_config() local
567 int index = dpu_enc->disp_info.h_tile_instance[0]; in dpu_encoder_get_dsc_config()
569 if (dpu_enc->disp_info.intf_type == INTF_DSI) in dpu_encoder_get_dsc_config()
576 struct dpu_encoder_virt *dpu_enc, in dpu_encoder_get_topology() argument
586 if (dpu_enc->phys_encs[i]) in dpu_encoder_get_topology()
666 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_virt_atomic_check() local
683 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_virt_atomic_check()
684 DPU_DEBUG_ENC(dpu_enc, "\n"); in dpu_encoder_virt_atomic_check()
687 disp_info = &dpu_enc->disp_info; in dpu_encoder_virt_atomic_check()
698 topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode, crtc_state, dsc); in dpu_encoder_virt_atomic_check()
715 if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) in dpu_encoder_virt_atomic_check()
717 else if (!topology.needs_cdm && dpu_enc->cur_master->hw_cdm) in dpu_encoder_virt_atomic_check()
739 static void _dpu_encoder_update_vsync_source(struct dpu_encoder_virt *dpu_enc, in _dpu_encoder_update_vsync_source() argument
750 if (!dpu_enc || !disp_info) { in _dpu_encoder_update_vsync_source()
752 dpu_enc != NULL, disp_info != NULL); in _dpu_encoder_update_vsync_source()
754 } else if (dpu_enc->num_phys_encs > ARRAY_SIZE(dpu_enc->hw_pp)) { in _dpu_encoder_update_vsync_source()
756 dpu_enc->num_phys_encs, in _dpu_encoder_update_vsync_source()
757 (int) ARRAY_SIZE(dpu_enc->hw_pp)); in _dpu_encoder_update_vsync_source()
761 drm_enc = &dpu_enc->base; in _dpu_encoder_update_vsync_source()
773 for (i = 0; i < dpu_enc->num_phys_encs; i++) in _dpu_encoder_update_vsync_source()
774 vsync_cfg.ppnumber[i] = dpu_enc->hw_pp[i]->idx; in _dpu_encoder_update_vsync_source()
776 vsync_cfg.pp_count = dpu_enc->num_phys_encs; in _dpu_encoder_update_vsync_source()
777 vsync_cfg.frame_rate = drm_mode_vrefresh(&dpu_enc->base.crtc->state->adjusted_mode); in _dpu_encoder_update_vsync_source()
783 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in _dpu_encoder_update_vsync_source()
784 phys_enc = dpu_enc->phys_encs[i]; in _dpu_encoder_update_vsync_source()
795 struct dpu_encoder_virt *dpu_enc; in _dpu_encoder_irq_enable() local
803 dpu_enc = to_dpu_encoder_virt(drm_enc); in _dpu_encoder_irq_enable()
805 DPU_DEBUG_ENC(dpu_enc, "\n"); in _dpu_encoder_irq_enable()
806 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in _dpu_encoder_irq_enable()
807 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in _dpu_encoder_irq_enable()
815 struct dpu_encoder_virt *dpu_enc; in _dpu_encoder_irq_disable() local
823 dpu_enc = to_dpu_encoder_virt(drm_enc); in _dpu_encoder_irq_disable()
825 DPU_DEBUG_ENC(dpu_enc, "\n"); in _dpu_encoder_irq_disable()
826 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in _dpu_encoder_irq_disable()
827 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in _dpu_encoder_irq_disable()
837 struct dpu_encoder_virt *dpu_enc; in _dpu_encoder_resource_enable() local
839 dpu_enc = to_dpu_encoder_virt(drm_enc); in _dpu_encoder_resource_enable()
845 if (!dpu_enc->cur_master) { in _dpu_encoder_resource_enable()
861 struct dpu_encoder_virt *dpu_enc; in _dpu_encoder_resource_disable() local
863 dpu_enc = to_dpu_encoder_virt(drm_enc); in _dpu_encoder_resource_disable()
869 if (!dpu_enc->cur_master) { in _dpu_encoder_resource_disable()
884 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_resource_control() local
892 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_resource_control()
894 is_vid_mode = !dpu_enc->disp_info.is_cmd_mode; in dpu_encoder_resource_control()
900 if (!dpu_enc->idle_pc_supported && in dpu_encoder_resource_control()
906 trace_dpu_enc_rc(DRMID(drm_enc), sw_event, dpu_enc->idle_pc_supported, in dpu_encoder_resource_control()
907 dpu_enc->rc_state, "begin"); in dpu_encoder_resource_control()
912 if (cancel_delayed_work_sync(&dpu_enc->delayed_off_work)) in dpu_encoder_resource_control()
913 DPU_DEBUG_ENC(dpu_enc, "sw_event:%d, work cancelled\n", in dpu_encoder_resource_control()
916 mutex_lock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
919 if (dpu_enc->rc_state == DPU_ENC_RC_STATE_ON) { in dpu_encoder_resource_control()
922 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
924 } else if (dpu_enc->rc_state != DPU_ENC_RC_STATE_OFF && in dpu_encoder_resource_control()
925 dpu_enc->rc_state != DPU_ENC_RC_STATE_IDLE) { in dpu_encoder_resource_control()
928 dpu_enc->rc_state); in dpu_encoder_resource_control()
929 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
933 if (is_vid_mode && dpu_enc->rc_state == DPU_ENC_RC_STATE_IDLE) in dpu_encoder_resource_control()
938 dpu_enc->rc_state = DPU_ENC_RC_STATE_ON; in dpu_encoder_resource_control()
941 dpu_enc->idle_pc_supported, dpu_enc->rc_state, in dpu_encoder_resource_control()
944 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
954 if (dpu_enc->rc_state != DPU_ENC_RC_STATE_ON) { in dpu_encoder_resource_control()
957 dpu_enc->rc_state); in dpu_encoder_resource_control()
971 queue_delayed_work(priv->wq, &dpu_enc->delayed_off_work, in dpu_encoder_resource_control()
972 msecs_to_jiffies(dpu_enc->idle_timeout)); in dpu_encoder_resource_control()
975 dpu_enc->idle_pc_supported, dpu_enc->rc_state, in dpu_encoder_resource_control()
981 if (cancel_delayed_work_sync(&dpu_enc->delayed_off_work)) in dpu_encoder_resource_control()
982 DPU_DEBUG_ENC(dpu_enc, "sw_event:%d, work cancelled\n", in dpu_encoder_resource_control()
985 mutex_lock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
988 dpu_enc->rc_state == DPU_ENC_RC_STATE_IDLE) { in dpu_encoder_resource_control()
992 else if (dpu_enc->rc_state == DPU_ENC_RC_STATE_OFF || in dpu_encoder_resource_control()
993 dpu_enc->rc_state == DPU_ENC_RC_STATE_IDLE) { in dpu_encoder_resource_control()
996 dpu_enc->rc_state); in dpu_encoder_resource_control()
997 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1001 dpu_enc->rc_state = DPU_ENC_RC_STATE_PRE_OFF; in dpu_encoder_resource_control()
1004 dpu_enc->idle_pc_supported, dpu_enc->rc_state, in dpu_encoder_resource_control()
1007 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1011 mutex_lock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1014 if (dpu_enc->rc_state == DPU_ENC_RC_STATE_OFF) { in dpu_encoder_resource_control()
1017 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1019 } else if (dpu_enc->rc_state == DPU_ENC_RC_STATE_ON) { in dpu_encoder_resource_control()
1021 DRMID(drm_enc), sw_event, dpu_enc->rc_state); in dpu_encoder_resource_control()
1022 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1030 if (dpu_enc->rc_state == DPU_ENC_RC_STATE_PRE_OFF) in dpu_encoder_resource_control()
1033 dpu_enc->rc_state = DPU_ENC_RC_STATE_OFF; in dpu_encoder_resource_control()
1036 dpu_enc->idle_pc_supported, dpu_enc->rc_state, in dpu_encoder_resource_control()
1039 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1043 mutex_lock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1045 if (dpu_enc->rc_state != DPU_ENC_RC_STATE_ON) { in dpu_encoder_resource_control()
1047 DRMID(drm_enc), sw_event, dpu_enc->rc_state); in dpu_encoder_resource_control()
1048 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1056 if (dpu_enc->frame_busy_mask[0]) { in dpu_encoder_resource_control()
1058 DRMID(drm_enc), sw_event, dpu_enc->rc_state); in dpu_encoder_resource_control()
1059 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1068 dpu_enc->rc_state = DPU_ENC_RC_STATE_IDLE; in dpu_encoder_resource_control()
1071 dpu_enc->idle_pc_supported, dpu_enc->rc_state, in dpu_encoder_resource_control()
1074 mutex_unlock(&dpu_enc->rc_lock); in dpu_encoder_resource_control()
1081 dpu_enc->idle_pc_supported, dpu_enc->rc_state, in dpu_encoder_resource_control()
1087 dpu_enc->idle_pc_supported, dpu_enc->rc_state, in dpu_encoder_resource_control()
1095 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_prepare_wb_job() local
1098 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_prepare_wb_job()
1100 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_prepare_wb_job()
1101 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_prepare_wb_job()
1112 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_cleanup_wb_job() local
1115 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_cleanup_wb_job()
1117 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_cleanup_wb_job()
1118 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_cleanup_wb_job()
1130 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_virt_atomic_mode_set() local
1146 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_virt_atomic_mode_set()
1147 DPU_DEBUG_ENC(dpu_enc, "\n"); in dpu_encoder_virt_atomic_mode_set()
1168 dpu_enc->hw_pp[i] = i < num_pp ? to_dpu_hw_pingpong(hw_pp[i]) in dpu_encoder_virt_atomic_mode_set()
1175 dpu_enc->hw_dsc[i] = to_dpu_hw_dsc(hw_dsc[i]); in dpu_encoder_virt_atomic_mode_set()
1176 dsc_mask |= BIT(dpu_enc->hw_dsc[i]->idx - DSC_0); in dpu_encoder_virt_atomic_mode_set()
1179 dpu_enc->dsc_mask = dsc_mask; in dpu_encoder_virt_atomic_mode_set()
1181 if ((dpu_enc->disp_info.intf_type == INTF_WB && conn_state->writeback_job) || in dpu_encoder_virt_atomic_mode_set()
1182 dpu_enc->disp_info.intf_type == INTF_DP) { in dpu_encoder_virt_atomic_mode_set()
1188 dpu_enc->cur_master->hw_cdm = hw_cdm ? to_dpu_hw_cdm(hw_cdm) : NULL; in dpu_encoder_virt_atomic_mode_set()
1191 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_virt_atomic_mode_set()
1192 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_virt_atomic_mode_set()
1194 phys->hw_pp = dpu_enc->hw_pp[i]; in dpu_encoder_virt_atomic_mode_set()
1196 DPU_ERROR_ENC(dpu_enc, in dpu_encoder_virt_atomic_mode_set()
1203 DPU_ERROR_ENC(dpu_enc, in dpu_encoder_virt_atomic_mode_set()
1216 struct dpu_encoder_virt *dpu_enc = NULL; in _dpu_encoder_virt_enable_helper() local
1224 dpu_enc = to_dpu_encoder_virt(drm_enc); in _dpu_encoder_virt_enable_helper()
1225 if (!dpu_enc || !dpu_enc->cur_master) { in _dpu_encoder_virt_enable_helper()
1231 if (dpu_enc->disp_info.intf_type == INTF_DP && in _dpu_encoder_virt_enable_helper()
1232 dpu_enc->cur_master->hw_mdptop && in _dpu_encoder_virt_enable_helper()
1233 dpu_enc->cur_master->hw_mdptop->ops.intf_audio_select) in _dpu_encoder_virt_enable_helper()
1234 dpu_enc->cur_master->hw_mdptop->ops.intf_audio_select( in _dpu_encoder_virt_enable_helper()
1235 dpu_enc->cur_master->hw_mdptop); in _dpu_encoder_virt_enable_helper()
1237 if (dpu_enc->disp_info.is_cmd_mode) in _dpu_encoder_virt_enable_helper()
1238 _dpu_encoder_update_vsync_source(dpu_enc, &dpu_enc->disp_info); in _dpu_encoder_virt_enable_helper()
1240 if (dpu_enc->disp_info.intf_type == INTF_DSI && in _dpu_encoder_virt_enable_helper()
1241 !WARN_ON(dpu_enc->num_phys_encs == 0)) { in _dpu_encoder_virt_enable_helper()
1242 unsigned bpc = dpu_enc->connector->display_info.bpc; in _dpu_encoder_virt_enable_helper()
1244 if (!dpu_enc->hw_pp[i]) in _dpu_encoder_virt_enable_helper()
1246 _dpu_encoder_setup_dither(dpu_enc->hw_pp[i], bpc); in _dpu_encoder_virt_enable_helper()
1253 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_virt_runtime_resume() local
1255 mutex_lock(&dpu_enc->enc_lock); in dpu_encoder_virt_runtime_resume()
1257 if (!dpu_enc->enabled) in dpu_encoder_virt_runtime_resume()
1260 if (dpu_enc->cur_slave && dpu_enc->cur_slave->ops.restore) in dpu_encoder_virt_runtime_resume()
1261 dpu_enc->cur_slave->ops.restore(dpu_enc->cur_slave); in dpu_encoder_virt_runtime_resume()
1262 if (dpu_enc->cur_master && dpu_enc->cur_master->ops.restore) in dpu_encoder_virt_runtime_resume()
1263 dpu_enc->cur_master->ops.restore(dpu_enc->cur_master); in dpu_encoder_virt_runtime_resume()
1268 mutex_unlock(&dpu_enc->enc_lock); in dpu_encoder_virt_runtime_resume()
1274 struct dpu_encoder_virt *dpu_enc = NULL; in dpu_encoder_virt_atomic_enable() local
1278 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_virt_atomic_enable()
1279 dpu_enc->dsc = dpu_encoder_get_dsc_config(drm_enc); in dpu_encoder_virt_atomic_enable()
1281 atomic_set(&dpu_enc->frame_done_timeout_cnt, 0); in dpu_encoder_virt_atomic_enable()
1283 mutex_lock(&dpu_enc->enc_lock); in dpu_encoder_virt_atomic_enable()
1285 dpu_enc->commit_done_timedout = false; in dpu_encoder_virt_atomic_enable()
1287 dpu_enc->connector = drm_atomic_get_new_connector_for_encoder(state, drm_enc); in dpu_encoder_virt_atomic_enable()
1289 cur_mode = &dpu_enc->base.crtc->state->adjusted_mode; in dpu_encoder_virt_atomic_enable()
1291 dpu_enc->wide_bus_en = dpu_encoder_is_widebus_enabled(drm_enc); in dpu_encoder_virt_atomic_enable()
1297 if (dpu_enc->cur_slave && dpu_enc->cur_slave->ops.enable) in dpu_encoder_virt_atomic_enable()
1298 dpu_enc->cur_slave->ops.enable(dpu_enc->cur_slave); in dpu_encoder_virt_atomic_enable()
1300 if (dpu_enc->cur_master && dpu_enc->cur_master->ops.enable) in dpu_encoder_virt_atomic_enable()
1301 dpu_enc->cur_master->ops.enable(dpu_enc->cur_master); in dpu_encoder_virt_atomic_enable()
1305 DPU_ERROR_ENC(dpu_enc, "dpu resource control failed: %d\n", in dpu_encoder_virt_atomic_enable()
1312 dpu_enc->enabled = true; in dpu_encoder_virt_atomic_enable()
1315 mutex_unlock(&dpu_enc->enc_lock); in dpu_encoder_virt_atomic_enable()
1321 struct dpu_encoder_virt *dpu_enc = NULL; in dpu_encoder_virt_atomic_disable() local
1326 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_virt_atomic_disable()
1327 DPU_DEBUG_ENC(dpu_enc, "\n"); in dpu_encoder_virt_atomic_disable()
1340 mutex_lock(&dpu_enc->enc_lock); in dpu_encoder_virt_atomic_disable()
1341 dpu_enc->enabled = false; in dpu_encoder_virt_atomic_disable()
1350 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_virt_atomic_disable()
1351 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_virt_atomic_disable()
1359 if (atomic_xchg(&dpu_enc->frame_done_timeout_ms, 0)) { in dpu_encoder_virt_atomic_disable()
1361 del_timer_sync(&dpu_enc->frame_done_timer); in dpu_encoder_virt_atomic_disable()
1366 dpu_enc->connector = NULL; in dpu_encoder_virt_atomic_disable()
1368 DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n"); in dpu_encoder_virt_atomic_disable()
1370 mutex_unlock(&dpu_enc->enc_lock); in dpu_encoder_virt_atomic_disable()
1395 struct dpu_encoder_virt *dpu_enc = NULL; in dpu_encoder_vblank_callback() local
1402 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_vblank_callback()
1406 spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags); in dpu_encoder_vblank_callback()
1407 if (dpu_enc->crtc) in dpu_encoder_vblank_callback()
1408 dpu_crtc_vblank_callback(dpu_enc->crtc); in dpu_encoder_vblank_callback()
1409 spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); in dpu_encoder_vblank_callback()
1434 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_assign_crtc() local
1437 spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags); in dpu_encoder_assign_crtc()
1439 WARN_ON(crtc && dpu_enc->crtc); in dpu_encoder_assign_crtc()
1440 dpu_enc->crtc = crtc; in dpu_encoder_assign_crtc()
1441 spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); in dpu_encoder_assign_crtc()
1447 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_toggle_vblank_for_crtc() local
1453 spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags); in dpu_encoder_toggle_vblank_for_crtc()
1454 if (dpu_enc->crtc != crtc) { in dpu_encoder_toggle_vblank_for_crtc()
1455 spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); in dpu_encoder_toggle_vblank_for_crtc()
1458 spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); in dpu_encoder_toggle_vblank_for_crtc()
1460 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_toggle_vblank_for_crtc()
1461 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_toggle_vblank_for_crtc()
1472 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_frame_done_callback() local
1479 if (!dpu_enc->frame_busy_mask[0]) { in dpu_encoder_frame_done_callback()
1492 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_frame_done_callback()
1493 if (dpu_enc->phys_encs[i] == ready_phys) { in dpu_encoder_frame_done_callback()
1495 dpu_enc->frame_busy_mask[0]); in dpu_encoder_frame_done_callback()
1496 clear_bit(i, dpu_enc->frame_busy_mask); in dpu_encoder_frame_done_callback()
1500 if (!dpu_enc->frame_busy_mask[0]) { in dpu_encoder_frame_done_callback()
1501 atomic_set(&dpu_enc->frame_done_timeout_ms, 0); in dpu_encoder_frame_done_callback()
1502 del_timer(&dpu_enc->frame_done_timer); in dpu_encoder_frame_done_callback()
1507 if (dpu_enc->crtc) in dpu_encoder_frame_done_callback()
1508 dpu_crtc_frame_event_cb(dpu_enc->crtc, event); in dpu_encoder_frame_done_callback()
1511 if (dpu_enc->crtc) in dpu_encoder_frame_done_callback()
1512 dpu_crtc_frame_event_cb(dpu_enc->crtc, event); in dpu_encoder_frame_done_callback()
1518 struct dpu_encoder_virt *dpu_enc = container_of(work, in dpu_encoder_off_work() local
1521 dpu_encoder_resource_control(&dpu_enc->base, in dpu_encoder_off_work()
1524 dpu_encoder_frame_done_callback(&dpu_enc->base, NULL, in dpu_encoder_off_work()
1630 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_helper_hw_reset() local
1635 dpu_enc = to_dpu_encoder_virt(phys_enc->parent); in dpu_encoder_helper_hw_reset()
1647 DPU_ERROR_ENC(dpu_enc, "ctl %d reset failure\n", ctl->idx); in dpu_encoder_helper_hw_reset()
1663 static void _dpu_encoder_kickoff_phys(struct dpu_encoder_virt *dpu_enc) in _dpu_encoder_kickoff_phys() argument
1672 spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags); in _dpu_encoder_kickoff_phys()
1675 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in _dpu_encoder_kickoff_phys()
1676 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in _dpu_encoder_kickoff_phys()
1689 set_bit(i, dpu_enc->frame_busy_mask); in _dpu_encoder_kickoff_phys()
1693 _dpu_encoder_trigger_flush(&dpu_enc->base, phys, 0x0); in _dpu_encoder_kickoff_phys()
1699 if (pending_flush && dpu_enc->cur_master) { in _dpu_encoder_kickoff_phys()
1701 &dpu_enc->base, in _dpu_encoder_kickoff_phys()
1702 dpu_enc->cur_master, in _dpu_encoder_kickoff_phys()
1706 _dpu_encoder_trigger_start(dpu_enc->cur_master); in _dpu_encoder_kickoff_phys()
1708 spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); in _dpu_encoder_kickoff_phys()
1713 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_trigger_kickoff_pending() local
1723 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_trigger_kickoff_pending()
1724 disp_info = &dpu_enc->disp_info; in dpu_encoder_trigger_kickoff_pending()
1726 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_trigger_kickoff_pending()
1727 phys = dpu_enc->phys_encs[i]; in dpu_encoder_trigger_kickoff_pending()
1733 if ((phys == dpu_enc->cur_master) && in dpu_encoder_trigger_kickoff_pending()
1740 static u32 _dpu_encoder_calculate_linetime(struct dpu_encoder_virt *dpu_enc, in _dpu_encoder_calculate_linetime() argument
1750 if (!dpu_enc->cur_master) in _dpu_encoder_calculate_linetime()
1753 if (!dpu_enc->cur_master->ops.get_line_count) { in _dpu_encoder_calculate_linetime()
1780 DPU_DEBUG_ENC(dpu_enc, in _dpu_encoder_calculate_linetime()
1790 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_vsync_time() local
1796 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_vsync_time()
1804 line_time = _dpu_encoder_calculate_linetime(dpu_enc, mode); in dpu_encoder_vsync_time()
1808 cur_line = dpu_enc->cur_master->ops.get_line_count(dpu_enc->cur_master); in dpu_encoder_vsync_time()
1825 DPU_DEBUG_ENC(dpu_enc, in dpu_encoder_vsync_time()
1884 static void dpu_encoder_prep_dsc(struct dpu_encoder_virt *dpu_enc, in dpu_encoder_prep_dsc() argument
1888 struct dpu_encoder_phys *enc_master = dpu_enc->cur_master; in dpu_encoder_prep_dsc()
1900 hw_pp[i] = dpu_enc->hw_pp[i]; in dpu_encoder_prep_dsc()
1901 hw_dsc[i] = dpu_enc->hw_dsc[i]; in dpu_encoder_prep_dsc()
1904 DPU_ERROR_ENC(dpu_enc, "invalid params for DSC\n"); in dpu_encoder_prep_dsc()
1935 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_prepare_for_kickoff() local
1940 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_prepare_for_kickoff()
1946 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_prepare_for_kickoff()
1947 phys = dpu_enc->phys_encs[i]; in dpu_encoder_prepare_for_kickoff()
1960 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_prepare_for_kickoff()
1961 dpu_encoder_helper_hw_reset(dpu_enc->phys_encs[i]); in dpu_encoder_prepare_for_kickoff()
1965 if (dpu_enc->dsc) in dpu_encoder_prepare_for_kickoff()
1966 dpu_encoder_prep_dsc(dpu_enc, dpu_enc->dsc); in dpu_encoder_prepare_for_kickoff()
1971 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_is_valid_for_commit() local
1975 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_is_valid_for_commit()
1978 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_is_valid_for_commit()
1979 phys = dpu_enc->phys_encs[i]; in dpu_encoder_is_valid_for_commit()
1992 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_kickoff() local
1998 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_kickoff()
2005 atomic_set(&dpu_enc->frame_done_timeout_ms, timeout_ms); in dpu_encoder_kickoff()
2006 mod_timer(&dpu_enc->frame_done_timer, in dpu_encoder_kickoff()
2010 _dpu_encoder_kickoff_phys(dpu_enc); in dpu_encoder_kickoff()
2013 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_kickoff()
2014 phys = dpu_enc->phys_encs[i]; in dpu_encoder_kickoff()
2070 static void dpu_encoder_unprep_dsc(struct dpu_encoder_virt *dpu_enc) in dpu_encoder_unprep_dsc() argument
2073 struct dpu_encoder_phys *enc_master = dpu_enc->cur_master; in dpu_encoder_unprep_dsc()
2080 hw_pp[i] = dpu_enc->hw_pp[i]; in dpu_encoder_unprep_dsc()
2081 hw_dsc[i] = dpu_enc->hw_dsc[i]; in dpu_encoder_unprep_dsc()
2093 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_helper_phys_cleanup() local
2095 dpu_enc = to_dpu_encoder_virt(phys_enc->parent); in dpu_encoder_helper_phys_cleanup()
2115 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_helper_phys_cleanup()
2116 if (dpu_enc->phys_encs[i] && phys_enc->hw_intf->ops.bind_pingpong_blk) in dpu_encoder_helper_phys_cleanup()
2118 dpu_enc->phys_encs[i]->hw_intf, in dpu_encoder_helper_phys_cleanup()
2124 dpu_enc->phys_encs[i]->hw_intf->idx); in dpu_encoder_helper_phys_cleanup()
2146 if (dpu_enc->dsc) { in dpu_encoder_helper_phys_cleanup()
2147 dpu_encoder_unprep_dsc(dpu_enc); in dpu_encoder_helper_phys_cleanup()
2148 dpu_enc->dsc = NULL; in dpu_encoder_helper_phys_cleanup()
2253 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); in _dpu_encoder_status_show() local
2256 mutex_lock(&dpu_enc->enc_lock); in _dpu_encoder_status_show()
2257 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in _dpu_encoder_status_show()
2258 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in _dpu_encoder_status_show()
2265 atomic_read(&dpu_enc->frame_done_timeout_cnt)); in _dpu_encoder_status_show()
2269 mutex_unlock(&dpu_enc->enc_lock); in _dpu_encoder_status_show()
2289 struct dpu_encoder_virt *dpu_enc, in dpu_encoder_virt_add_phys_encs() argument
2294 DPU_DEBUG_ENC(dpu_enc, "\n"); in dpu_encoder_virt_add_phys_encs()
2300 if (dpu_enc->num_phys_encs + NUM_PHYS_ENCODER_TYPES >= in dpu_encoder_virt_add_phys_encs()
2301 ARRAY_SIZE(dpu_enc->phys_encs)) { in dpu_encoder_virt_add_phys_encs()
2302 DPU_ERROR_ENC(dpu_enc, "too many physical encoders %d\n", in dpu_encoder_virt_add_phys_encs()
2303 dpu_enc->num_phys_encs); in dpu_encoder_virt_add_phys_encs()
2312 DPU_ERROR_ENC(dpu_enc, "failed to init wb enc: %ld\n", in dpu_encoder_virt_add_phys_encs()
2317 dpu_enc->phys_encs[dpu_enc->num_phys_encs] = enc; in dpu_encoder_virt_add_phys_encs()
2318 ++dpu_enc->num_phys_encs; in dpu_encoder_virt_add_phys_encs()
2323 DPU_ERROR_ENC(dpu_enc, "failed to init cmd enc: %ld\n", in dpu_encoder_virt_add_phys_encs()
2328 dpu_enc->phys_encs[dpu_enc->num_phys_encs] = enc; in dpu_encoder_virt_add_phys_encs()
2329 ++dpu_enc->num_phys_encs; in dpu_encoder_virt_add_phys_encs()
2334 DPU_ERROR_ENC(dpu_enc, "failed to init vid enc: %ld\n", in dpu_encoder_virt_add_phys_encs()
2339 dpu_enc->phys_encs[dpu_enc->num_phys_encs] = enc; in dpu_encoder_virt_add_phys_encs()
2340 ++dpu_enc->num_phys_encs; in dpu_encoder_virt_add_phys_encs()
2344 dpu_enc->cur_slave = enc; in dpu_encoder_virt_add_phys_encs()
2346 dpu_enc->cur_master = enc; in dpu_encoder_virt_add_phys_encs()
2351 static int dpu_encoder_setup_display(struct dpu_encoder_virt *dpu_enc, in dpu_encoder_setup_display() argument
2359 if (!dpu_enc) { in dpu_encoder_setup_display()
2360 DPU_ERROR("invalid arg(s), enc %d\n", dpu_enc != NULL); in dpu_encoder_setup_display()
2364 dpu_enc->cur_master = NULL; in dpu_encoder_setup_display()
2368 phys_params.parent = &dpu_enc->base; in dpu_encoder_setup_display()
2369 phys_params.enc_spinlock = &dpu_enc->enc_spinlock; in dpu_encoder_setup_display()
2376 dpu_enc->idle_pc_supported = in dpu_encoder_setup_display()
2379 mutex_lock(&dpu_enc->enc_lock); in dpu_encoder_setup_display()
2408 DPU_ERROR_ENC(dpu_enc, "no intf or wb block assigned at idx: %d\n", i); in dpu_encoder_setup_display()
2414 DPU_ERROR_ENC(dpu_enc, in dpu_encoder_setup_display()
2421 dpu_enc, &phys_params); in dpu_encoder_setup_display()
2423 DPU_ERROR_ENC(dpu_enc, "failed to add phys encs\n"); in dpu_encoder_setup_display()
2428 mutex_unlock(&dpu_enc->enc_lock); in dpu_encoder_setup_display()
2435 struct dpu_encoder_virt *dpu_enc = from_timer(dpu_enc, t, in dpu_encoder_frame_done_timeout() local
2437 struct drm_encoder *drm_enc = &dpu_enc->base; in dpu_encoder_frame_done_timeout()
2445 if (!dpu_enc->frame_busy_mask[0] || !dpu_enc->crtc) { in dpu_encoder_frame_done_timeout()
2447 DRMID(drm_enc), dpu_enc->frame_busy_mask[0]); in dpu_encoder_frame_done_timeout()
2449 } else if (!atomic_xchg(&dpu_enc->frame_done_timeout_ms, 0)) { in dpu_encoder_frame_done_timeout()
2454 DPU_ERROR_ENC_RATELIMITED(dpu_enc, "frame done timeout\n"); in dpu_encoder_frame_done_timeout()
2456 if (atomic_inc_return(&dpu_enc->frame_done_timeout_cnt) == 1) in dpu_encoder_frame_done_timeout()
2461 dpu_crtc_frame_event_cb(dpu_enc->crtc, event); in dpu_encoder_frame_done_timeout()
2481 struct dpu_encoder_virt *dpu_enc; in dpu_encoder_init() local
2484 dpu_enc = drmm_encoder_alloc(dev, struct dpu_encoder_virt, base, in dpu_encoder_init()
2486 if (IS_ERR(dpu_enc)) in dpu_encoder_init()
2487 return ERR_CAST(dpu_enc); in dpu_encoder_init()
2489 drm_encoder_helper_add(&dpu_enc->base, &dpu_encoder_helper_funcs); in dpu_encoder_init()
2491 spin_lock_init(&dpu_enc->enc_spinlock); in dpu_encoder_init()
2492 dpu_enc->enabled = false; in dpu_encoder_init()
2493 mutex_init(&dpu_enc->enc_lock); in dpu_encoder_init()
2494 mutex_init(&dpu_enc->rc_lock); in dpu_encoder_init()
2496 ret = dpu_encoder_setup_display(dpu_enc, dpu_kms, disp_info); in dpu_encoder_init()
2502 atomic_set(&dpu_enc->frame_done_timeout_ms, 0); in dpu_encoder_init()
2503 atomic_set(&dpu_enc->frame_done_timeout_cnt, 0); in dpu_encoder_init()
2504 timer_setup(&dpu_enc->frame_done_timer, in dpu_encoder_init()
2507 INIT_DELAYED_WORK(&dpu_enc->delayed_off_work, in dpu_encoder_init()
2509 dpu_enc->idle_timeout = IDLE_TIMEOUT; in dpu_encoder_init()
2511 memcpy(&dpu_enc->disp_info, disp_info, sizeof(*disp_info)); in dpu_encoder_init()
2513 DPU_DEBUG_ENC(dpu_enc, "created\n"); in dpu_encoder_init()
2515 return &dpu_enc->base; in dpu_encoder_init()
2530 struct dpu_encoder_virt *dpu_enc = NULL; in dpu_encoder_wait_for_commit_done() local
2537 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_wait_for_commit_done()
2538 DPU_DEBUG_ENC(dpu_enc, "\n"); in dpu_encoder_wait_for_commit_done()
2540 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_wait_for_commit_done()
2541 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_wait_for_commit_done()
2547 if (ret == -ETIMEDOUT && !dpu_enc->commit_done_timedout) { in dpu_encoder_wait_for_commit_done()
2548 dpu_enc->commit_done_timedout = true; in dpu_encoder_wait_for_commit_done()
2571 struct dpu_encoder_virt *dpu_enc = NULL; in dpu_encoder_wait_for_tx_complete() local
2578 dpu_enc = to_dpu_encoder_virt(drm_enc); in dpu_encoder_wait_for_tx_complete()
2579 DPU_DEBUG_ENC(dpu_enc, "\n"); in dpu_encoder_wait_for_tx_complete()
2581 for (i = 0; i < dpu_enc->num_phys_encs; i++) { in dpu_encoder_wait_for_tx_complete()
2582 struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; in dpu_encoder_wait_for_tx_complete()
2598 struct dpu_encoder_virt *dpu_enc = NULL; in dpu_encoder_get_intf_mode() local
2604 dpu_enc = to_dpu_encoder_virt(encoder); in dpu_encoder_get_intf_mode()
2606 if (dpu_enc->cur_master) in dpu_encoder_get_intf_mode()
2607 return dpu_enc->cur_master->intf_mode; in dpu_encoder_get_intf_mode()
2609 if (dpu_enc->num_phys_encs) in dpu_encoder_get_intf_mode()
2610 return dpu_enc->phys_encs[0]->intf_mode; in dpu_encoder_get_intf_mode()
2618 struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(encoder); in dpu_encoder_helper_get_dsc() local
2620 return dpu_enc->dsc_mask; in dpu_encoder_helper_get_dsc()