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()
349 if (!(ret = crtc_funcs->mode_fixup(crtc, mode, in drm_crtc_helper_set_mode()
351 drm_dbg_kms(dev, "[CRTC:%d:%s] mode fixup failed\n", in drm_crtc_helper_set_mode()
352 crtc->base.id, crtc->name); in drm_crtc_helper_set_mode()
356 drm_dbg_kms(dev, "[CRTC:%d:%s]\n", crtc->base.id, crtc->name); in drm_crtc_helper_set_mode()
358 drm_mode_copy(&crtc->hwmode, adjusted_mode); in drm_crtc_helper_set_mode()
363 if (encoder->crtc != crtc) in drm_crtc_helper_set_mode()
377 crtc_funcs->prepare(crtc); in drm_crtc_helper_set_mode()
382 ret = !crtc_funcs->mode_set(crtc, mode, adjusted_mode, x, y, old_fb); in drm_crtc_helper_set_mode()
388 if (encoder->crtc != crtc) in drm_crtc_helper_set_mode()
402 crtc_funcs->commit(crtc); in drm_crtc_helper_set_mode()
406 if (encoder->crtc != crtc) in drm_crtc_helper_set_mode()
421 drm_calc_timestamping_constants(crtc, &crtc->hwmode); in drm_crtc_helper_set_mode()
427 crtc->enabled = saved_enabled; in drm_crtc_helper_set_mode()
428 drm_mode_copy(&crtc->mode, &saved_mode); in drm_crtc_helper_set_mode()
429 drm_mode_copy(&crtc->hwmode, &saved_hwmode); in drm_crtc_helper_set_mode()
430 crtc->x = saved_x; in drm_crtc_helper_set_mode()
431 crtc->y = saved_y; in drm_crtc_helper_set_mode()
439 * drm_crtc_helper_atomic_check() - Helper to check CRTC atomic-state
440 * @crtc: CRTC to check
443 * Provides a default CRTC-state check handler for CRTCs that only have
444 * one primary plane attached to it. This is often the case for the CRTC
450 int drm_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state) in drm_crtc_helper_atomic_check() argument
452 struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc); in drm_crtc_helper_atomic_check()
462 drm_crtc_helper_disable(struct drm_crtc *crtc) in drm_crtc_helper_disable() argument
464 struct drm_device *dev = crtc->dev; in drm_crtc_helper_disable()
468 /* Decouple all encoders and their attached connectors from this crtc */ in drm_crtc_helper_disable()
472 if (encoder->crtc != crtc) in drm_crtc_helper_disable()
521 * &drm_crtc_funcs.set_config callback for drivers using the legacy CRTC
528 * mode_fixup encoder and CRTC helper operations to adjust the requested mode,
536 * will call the CRTC &drm_crtc_helper_funcs.mode_set_base helper operation.
541 * and ->commit() CRTC and encoder helper operations, in that order.
570 BUG_ON(!set->crtc); in drm_crtc_helper_set_config()
571 BUG_ON(!set->crtc->helper_private); in drm_crtc_helper_set_config()
577 crtc_funcs = set->crtc->helper_private; in drm_crtc_helper_set_config()
579 dev = set->crtc->dev; in drm_crtc_helper_set_config()
589 drm_dbg_kms(dev, "[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_dbg_kms(dev, "[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_dbg_kms(dev, "[CRTC:%d:%s] no fb, full mode set\n", in drm_crtc_helper_set_config()
646 set->crtc->base.id, set->crtc->name); in drm_crtc_helper_set_config()
648 } else if (set->fb->format != set->crtc->primary->fb->format) { in drm_crtc_helper_set_config()
654 if (set->x != set->crtc->x || set->y != set->crtc->y) in drm_crtc_helper_set_config()
657 if (!drm_mode_equal(set->mode, &set->crtc->mode)) { in drm_crtc_helper_set_config()
658 drm_dbg_kms(dev, "[CRTC:%d:%s] modes are different, full mode set:\n", in drm_crtc_helper_set_config()
659 set->crtc->base.id, set->crtc->name); in drm_crtc_helper_set_config()
660 drm_dbg_kms(dev, DRM_MODE_FMT "\n", DRM_MODE_ARG(&set->crtc->mode)); in drm_crtc_helper_set_config()
709 * the appropriate crtc will be set later. in drm_crtc_helper_set_config()
712 connector->encoder->crtc = NULL; in drm_crtc_helper_set_config()
729 if (connector->encoder->crtc == set->crtc) in drm_crtc_helper_set_config()
732 new_crtc = connector->encoder->crtc; in drm_crtc_helper_set_config()
736 new_crtc = set->crtc; in drm_crtc_helper_set_config()
739 /* Make sure the new CRTC will work with the encoder */ in drm_crtc_helper_set_config()
746 if (new_crtc != connector->encoder->crtc) { in drm_crtc_helper_set_config()
747 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] CRTC changed, full mode switch\n", in drm_crtc_helper_set_config()
750 connector->encoder->crtc = new_crtc; in drm_crtc_helper_set_config()
753 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] to [CRTC:%d:%s]\n", in drm_crtc_helper_set_config()
768 if (drm_helper_crtc_in_use(set->crtc)) { in drm_crtc_helper_set_config()
769 drm_dbg_kms(dev, "[CRTC:%d:%s] attempting to set mode from userspace: " DRM_MODE_FMT "\n", in drm_crtc_helper_set_config()
770 set->crtc->base.id, set->crtc->name, DRM_MODE_ARG(set->mode)); in drm_crtc_helper_set_config()
771 set->crtc->primary->fb = set->fb; in drm_crtc_helper_set_config()
772 if (!drm_crtc_helper_set_mode(set->crtc, set->mode, in drm_crtc_helper_set_config()
775 drm_err(dev, "[CRTC:%d:%s] failed to set mode\n", in drm_crtc_helper_set_config()
776 set->crtc->base.id, set->crtc->name); in drm_crtc_helper_set_config()
777 set->crtc->primary->fb = save_set.fb; in drm_crtc_helper_set_config()
781 drm_dbg_kms(dev, "[CRTC:%d:%s] Setting connector DPMS state to on\n", in drm_crtc_helper_set_config()
782 set->crtc->base.id, set->crtc->name); in drm_crtc_helper_set_config()
791 set->crtc->x = set->x; in drm_crtc_helper_set_config()
792 set->crtc->y = set->y; in drm_crtc_helper_set_config()
793 set->crtc->primary->fb = set->fb; in drm_crtc_helper_set_config()
794 ret = crtc_funcs->mode_set_base(set->crtc, in drm_crtc_helper_set_config()
797 set->crtc->x = save_set.x; in drm_crtc_helper_set_config()
798 set->crtc->y = save_set.y; in drm_crtc_helper_set_config()
799 set->crtc->primary->fb = save_set.fb; in drm_crtc_helper_set_config()
812 encoder->crtc = save_encoder_crtcs[count++]; in drm_crtc_helper_set_config()
832 !drm_crtc_helper_set_mode(save_set.crtc, save_set.mode, save_set.x, in drm_crtc_helper_set_config()
872 static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc) in drm_helper_choose_crtc_dpms() argument
877 struct drm_device *dev = crtc->dev; in drm_helper_choose_crtc_dpms()
881 if (connector->encoder && connector->encoder->crtc == crtc) in drm_helper_choose_crtc_dpms()
895 * &drm_connector_funcs.dpms callback for drivers using the legacy CRTC
898 * This is the main helper function provided by the CRTC helper framework for
913 struct drm_crtc *crtc = encoder ? encoder->crtc : NULL; in drm_helper_connector_dpms() local
927 /* from off to on, do crtc then encoder */ in drm_helper_connector_dpms()
929 if (crtc) { in drm_helper_connector_dpms()
930 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in drm_helper_connector_dpms()
933 (*crtc_funcs->dpms) (crtc, in drm_helper_connector_dpms()
934 drm_helper_choose_crtc_dpms(crtc)); in drm_helper_connector_dpms()
940 /* from on to off, do encoder then crtc */ in drm_helper_connector_dpms()
944 if (crtc) { in drm_helper_connector_dpms()
945 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in drm_helper_connector_dpms()
948 (*crtc_funcs->dpms) (crtc, in drm_helper_connector_dpms()
949 drm_helper_choose_crtc_dpms(crtc)); in drm_helper_connector_dpms()
985 struct drm_crtc *crtc; in drm_helper_resume_force_mode() local
994 drm_for_each_crtc(crtc, dev) { in drm_helper_resume_force_mode()
996 if (!crtc->enabled) in drm_helper_resume_force_mode()
999 ret = drm_crtc_helper_set_mode(crtc, &crtc->mode, in drm_helper_resume_force_mode()
1000 crtc->x, crtc->y, crtc->primary->fb); in drm_helper_resume_force_mode()
1004 drm_err(dev, "failed to set mode on crtc %p\n", crtc); in drm_helper_resume_force_mode()
1007 if (drm_helper_choose_crtc_dpms(crtc)) { in drm_helper_resume_force_mode()
1010 if(encoder->crtc != crtc) in drm_helper_resume_force_mode()
1019 crtc_funcs = crtc->helper_private; in drm_helper_resume_force_mode()
1021 (*crtc_funcs->dpms) (crtc, in drm_helper_resume_force_mode()
1022 drm_helper_choose_crtc_dpms(crtc)); in drm_helper_resume_force_mode()
1047 struct drm_crtc *crtc; in drm_helper_force_disable_all() local
1051 drm_for_each_crtc(crtc, dev) in drm_helper_force_disable_all()
1052 if (crtc->enabled) { in drm_helper_force_disable_all()
1054 .crtc = crtc, in drm_helper_force_disable_all()