Lines Matching full:crtc
5 * DRM core CRTC related functions
68 * The CRTC modeset helper library provides a default set_config implementation
81 * to the CRTC state. For easier transition this library provides functions to
82 * implement the old semantics required by the CRTC helpers using the new plane
138 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config
139 * @crtc: CRTC to check
141 * Checks whether @crtc is with the current mode setting output configuration
146 * True if @crtc is used, false otherwise.
148 bool drm_helper_crtc_in_use(struct drm_crtc *crtc) in drm_helper_crtc_in_use() argument
151 struct drm_device *dev = crtc->dev; in drm_helper_crtc_in_use()
163 if (encoder->crtc == crtc && drm_helper_encoder_in_use(encoder)) in drm_helper_crtc_in_use()
186 struct drm_crtc *crtc; in __drm_helper_disable_unused_functions() local
194 encoder->crtc = NULL; in __drm_helper_disable_unused_functions()
198 drm_for_each_crtc(crtc, dev) { in __drm_helper_disable_unused_functions()
199 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in __drm_helper_disable_unused_functions()
201 crtc->enabled = drm_helper_crtc_in_use(crtc); in __drm_helper_disable_unused_functions()
202 if (!crtc->enabled) { in __drm_helper_disable_unused_functions()
204 (*crtc_funcs->disable)(crtc); in __drm_helper_disable_unused_functions()
206 (*crtc_funcs->dpms)(crtc, DRM_MODE_DPMS_OFF); in __drm_helper_disable_unused_functions()
207 crtc->primary->fb = NULL; in __drm_helper_disable_unused_functions()
217 * will remove any CRTC links of unused encoders and encoder links of
242 * Check the CRTC we're going to map each output to vs. its current
243 * CRTC. If they don't match, we have to disable the output and the CRTC
258 if (encoder->crtc == NULL) in drm_crtc_prepare_encoders()
265 * @crtc: CRTC to program
271 * Try to set @mode on @crtc. Give @crtc and its associated connectors a chance
283 bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, in drm_crtc_helper_set_mode() argument
288 struct drm_device *dev = crtc->dev; in drm_crtc_helper_set_mode()
290 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in drm_crtc_helper_set_mode()
301 saved_enabled = crtc->enabled; in drm_crtc_helper_set_mode()
302 crtc->enabled = drm_helper_crtc_in_use(crtc); in drm_crtc_helper_set_mode()
303 if (!crtc->enabled) in drm_crtc_helper_set_mode()
308 crtc->enabled = saved_enabled; in drm_crtc_helper_set_mode()
312 drm_mode_init(&saved_mode, &crtc->mode); in drm_crtc_helper_set_mode()
313 drm_mode_init(&saved_hwmode, &crtc->hwmode); in drm_crtc_helper_set_mode()
314 saved_x = crtc->x; in drm_crtc_helper_set_mode()
315 saved_y = crtc->y; in drm_crtc_helper_set_mode()
317 /* Update crtc values up front so the driver can rely on them for mode in drm_crtc_helper_set_mode()
320 drm_mode_copy(&crtc->mode, mode); in drm_crtc_helper_set_mode()
321 crtc->x = x; in drm_crtc_helper_set_mode()
322 crtc->y = y; in drm_crtc_helper_set_mode()
324 /* Pass our mode to the connectors and the CRTC to give them a chance to in drm_crtc_helper_set_mode()
330 if (encoder->crtc != crtc) in drm_crtc_helper_set_mode()
348 if (!(ret = crtc_funcs->mode_fixup(crtc, mode, in drm_crtc_helper_set_mode()
350 DRM_DEBUG_KMS("CRTC fixup failed\n"); in drm_crtc_helper_set_mode()
354 DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name); in drm_crtc_helper_set_mode()
356 drm_mode_copy(&crtc->hwmode, adjusted_mode); in drm_crtc_helper_set_mode()
361 if (encoder->crtc != crtc) in drm_crtc_helper_set_mode()
375 crtc_funcs->prepare(crtc); in drm_crtc_helper_set_mode()
380 ret = !crtc_funcs->mode_set(crtc, mode, adjusted_mode, x, y, old_fb); in drm_crtc_helper_set_mode()
386 if (encoder->crtc != crtc) in drm_crtc_helper_set_mode()
400 crtc_funcs->commit(crtc); in drm_crtc_helper_set_mode()
404 if (encoder->crtc != crtc) in drm_crtc_helper_set_mode()
419 drm_calc_timestamping_constants(crtc, &crtc->hwmode); in drm_crtc_helper_set_mode()
425 crtc->enabled = saved_enabled; in drm_crtc_helper_set_mode()
426 drm_mode_copy(&crtc->mode, &saved_mode); in drm_crtc_helper_set_mode()
427 drm_mode_copy(&crtc->hwmode, &saved_hwmode); in drm_crtc_helper_set_mode()
428 crtc->x = saved_x; in drm_crtc_helper_set_mode()
429 crtc->y = saved_y; in drm_crtc_helper_set_mode()
437 * drm_crtc_helper_atomic_check() - Helper to check CRTC atomic-state
438 * @crtc: CRTC to check
441 * Provides a default CRTC-state check handler for CRTCs that only have
444 * This is often the case for the CRTC of simple framebuffers. See also
451 int drm_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state) in drm_crtc_helper_atomic_check() argument
453 struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc); in drm_crtc_helper_atomic_check()
463 drm_crtc_helper_disable(struct drm_crtc *crtc) in drm_crtc_helper_disable() argument
465 struct drm_device *dev = crtc->dev; in drm_crtc_helper_disable()
469 /* Decouple all encoders and their attached connectors from this crtc */ in drm_crtc_helper_disable()
473 if (encoder->crtc != crtc) in drm_crtc_helper_disable()
522 * &drm_crtc_funcs.set_config callback for drivers using the legacy CRTC
529 * mode_fixup encoder and CRTC helper operations to adjust the requested mode,
537 * will call the CRTC &drm_crtc_helper_funcs.mode_set_base helper operation.
542 * and ->commit() CRTC and encoder helper operations, in that order.
573 BUG_ON(!set->crtc); in drm_crtc_helper_set_config()
574 BUG_ON(!set->crtc->helper_private); in drm_crtc_helper_set_config()
580 crtc_funcs = set->crtc->helper_private; in drm_crtc_helper_set_config()
582 dev = set->crtc->dev; in drm_crtc_helper_set_config()
589 DRM_DEBUG_KMS("[CRTC:%d:%s] [FB:%d] #connectors=%d (x y) (%i %i)\n", in drm_crtc_helper_set_config()
590 set->crtc->base.id, set->crtc->name, in drm_crtc_helper_set_config()
594 DRM_DEBUG_KMS("[CRTC:%d:%s] [NOFB]\n", in drm_crtc_helper_set_config()
595 set->crtc->base.id, set->crtc->name); in drm_crtc_helper_set_config()
596 drm_crtc_helper_disable(set->crtc); in drm_crtc_helper_set_config()
625 save_encoder_crtcs[count++] = encoder->crtc; in drm_crtc_helper_set_config()
634 save_set.crtc = set->crtc; in drm_crtc_helper_set_config()
635 save_set.mode = &set->crtc->mode; in drm_crtc_helper_set_config()
636 save_set.x = set->crtc->x; in drm_crtc_helper_set_config()
637 save_set.y = set->crtc->y; in drm_crtc_helper_set_config()
638 save_set.fb = set->crtc->primary->fb; in drm_crtc_helper_set_config()
642 if (set->crtc->primary->fb != set->fb) { in drm_crtc_helper_set_config()
644 if (set->crtc->primary->fb == NULL) { in drm_crtc_helper_set_config()
645 DRM_DEBUG_KMS("crtc has no fb, full mode set\n"); in drm_crtc_helper_set_config()
647 } else if (set->fb->format != set->crtc->primary->fb->format) { in drm_crtc_helper_set_config()
653 if (set->x != set->crtc->x || set->y != set->crtc->y) in drm_crtc_helper_set_config()
656 if (!drm_mode_equal(set->mode, &set->crtc->mode)) { in drm_crtc_helper_set_config()
658 drm_mode_debug_printmodeline(&set->crtc->mode); in drm_crtc_helper_set_config()
705 * the appropriate crtc will be set later. in drm_crtc_helper_set_config()
708 connector->encoder->crtc = NULL; in drm_crtc_helper_set_config()
725 if (connector->encoder->crtc == set->crtc) in drm_crtc_helper_set_config()
728 new_crtc = connector->encoder->crtc; in drm_crtc_helper_set_config()
732 new_crtc = set->crtc; in drm_crtc_helper_set_config()
735 /* Make sure the new CRTC will work with the encoder */ in drm_crtc_helper_set_config()
742 if (new_crtc != connector->encoder->crtc) { in drm_crtc_helper_set_config()
743 DRM_DEBUG_KMS("crtc changed, full mode switch\n"); in drm_crtc_helper_set_config()
745 connector->encoder->crtc = new_crtc; in drm_crtc_helper_set_config()
748 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [CRTC:%d:%s]\n", in drm_crtc_helper_set_config()
763 if (drm_helper_crtc_in_use(set->crtc)) { in drm_crtc_helper_set_config()
767 set->crtc->primary->fb = set->fb; in drm_crtc_helper_set_config()
768 if (!drm_crtc_helper_set_mode(set->crtc, set->mode, in drm_crtc_helper_set_config()
771 DRM_ERROR("failed to set mode on [CRTC:%d:%s]\n", in drm_crtc_helper_set_config()
772 set->crtc->base.id, set->crtc->name); in drm_crtc_helper_set_config()
773 set->crtc->primary->fb = save_set.fb; in drm_crtc_helper_set_config()
786 set->crtc->x = set->x; in drm_crtc_helper_set_config()
787 set->crtc->y = set->y; in drm_crtc_helper_set_config()
788 set->crtc->primary->fb = set->fb; in drm_crtc_helper_set_config()
789 ret = crtc_funcs->mode_set_base(set->crtc, in drm_crtc_helper_set_config()
792 set->crtc->x = save_set.x; in drm_crtc_helper_set_config()
793 set->crtc->y = save_set.y; in drm_crtc_helper_set_config()
794 set->crtc->primary->fb = save_set.fb; in drm_crtc_helper_set_config()
807 encoder->crtc = save_encoder_crtcs[count++]; in drm_crtc_helper_set_config()
827 !drm_crtc_helper_set_mode(save_set.crtc, save_set.mode, save_set.x, in drm_crtc_helper_set_config()
867 static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc) in drm_helper_choose_crtc_dpms() argument
872 struct drm_device *dev = crtc->dev; in drm_helper_choose_crtc_dpms()
876 if (connector->encoder && connector->encoder->crtc == crtc) in drm_helper_choose_crtc_dpms()
890 * &drm_connector_funcs.dpms callback for drivers using the legacy CRTC
893 * This is the main helper function provided by the CRTC helper framework for
908 struct drm_crtc *crtc = encoder ? encoder->crtc : NULL; in drm_helper_connector_dpms() local
922 /* from off to on, do crtc then encoder */ in drm_helper_connector_dpms()
924 if (crtc) { in drm_helper_connector_dpms()
925 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in drm_helper_connector_dpms()
928 (*crtc_funcs->dpms) (crtc, in drm_helper_connector_dpms()
929 drm_helper_choose_crtc_dpms(crtc)); in drm_helper_connector_dpms()
935 /* from on to off, do encoder then crtc */ in drm_helper_connector_dpms()
939 if (crtc) { in drm_helper_connector_dpms()
940 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in drm_helper_connector_dpms()
943 (*crtc_funcs->dpms) (crtc, in drm_helper_connector_dpms()
944 drm_helper_choose_crtc_dpms(crtc)); in drm_helper_connector_dpms()
980 struct drm_crtc *crtc; in drm_helper_resume_force_mode() local
989 drm_for_each_crtc(crtc, dev) { in drm_helper_resume_force_mode()
991 if (!crtc->enabled) in drm_helper_resume_force_mode()
994 ret = drm_crtc_helper_set_mode(crtc, &crtc->mode, in drm_helper_resume_force_mode()
995 crtc->x, crtc->y, crtc->primary->fb); in drm_helper_resume_force_mode()
999 DRM_ERROR("failed to set mode on crtc %p\n", crtc); in drm_helper_resume_force_mode()
1002 if (drm_helper_choose_crtc_dpms(crtc)) { in drm_helper_resume_force_mode()
1005 if(encoder->crtc != crtc) in drm_helper_resume_force_mode()
1014 crtc_funcs = crtc->helper_private; in drm_helper_resume_force_mode()
1016 (*crtc_funcs->dpms) (crtc, in drm_helper_resume_force_mode()
1017 drm_helper_choose_crtc_dpms(crtc)); in drm_helper_resume_force_mode()
1042 struct drm_crtc *crtc; in drm_helper_force_disable_all() local
1046 drm_for_each_crtc(crtc, dev) in drm_helper_force_disable_all()
1047 if (crtc->enabled) { in drm_helper_force_disable_all()
1049 .crtc = crtc, in drm_helper_force_disable_all()