Lines Matching refs:crtc
7 * DRM core CRTC related functions
63 * The CRTC modeset helper library provides a default set_config implementation
76 * to the CRTC state. For easier transition this library provides functions to
77 * implement the old semantics required by the CRTC helpers using the new plane
133 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config
134 * @crtc: CRTC to check
136 * Checks whether @crtc is with the current mode setting output configuration
141 * True if @crtc is used, false otherwise.
143 bool drm_helper_crtc_in_use(struct drm_crtc *crtc)
146 struct drm_device *dev = crtc->dev;
158 if (encoder->crtc == crtc && drm_helper_encoder_in_use(encoder))
181 struct drm_crtc *crtc;
189 encoder->crtc = NULL;
193 drm_for_each_crtc(crtc, dev) {
194 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
195 crtc->enabled = drm_helper_crtc_in_use(crtc);
196 if (!crtc->enabled) {
198 (*crtc_funcs->disable)(crtc);
200 (*crtc_funcs->dpms)(crtc, DRM_MODE_DPMS_OFF);
201 crtc->primary->fb = NULL;
211 * will remove any CRTC links of unused encoders and encoder links of
236 * Check the CRTC we're going to map each output to vs. its current
237 * CRTC. If they don't match, we have to disable the output and the CRTC
252 if (encoder->crtc == NULL)
254 /* Disable encoders whose CRTC is about to change */
256 encoder->crtc != (*encoder_funcs->get_crtc)(encoder))
263 * @crtc: CRTC to program
269 * Try to set @mode on @crtc. Give @crtc and its associated connectors a chance
281 bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
286 struct drm_device *dev = crtc->dev;
288 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
299 saved_enabled = crtc->enabled;
300 crtc->enabled = drm_helper_crtc_in_use(crtc);
301 if (!crtc->enabled)
306 crtc->enabled = saved_enabled;
310 saved_mode = crtc->mode;
311 saved_hwmode = crtc->hwmode;
312 saved_x = crtc->x;
313 saved_y = crtc->y;
315 /* Update crtc values up front so the driver can rely on them for mode
318 crtc->mode = *mode;
319 crtc->x = x;
320 crtc->y = y;
322 /* Pass our mode to the connectors and the CRTC to give them a chance to
328 if (encoder->crtc != crtc)
346 if (!(ret = crtc_funcs->mode_fixup(crtc, mode,
348 DRM_DEBUG_KMS("CRTC fixup failed\n");
352 DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
354 crtc->hwmode = *adjusted_mode;
359 if (encoder->crtc != crtc)
373 crtc_funcs->prepare(crtc);
378 ret = !crtc_funcs->mode_set(crtc, mode, adjusted_mode, x, y, old_fb);
384 if (encoder->crtc != crtc)
398 crtc_funcs->commit(crtc);
402 if (encoder->crtc != crtc)
417 drm_calc_timestamping_constants(crtc, &crtc->hwmode);
423 crtc->enabled = saved_enabled;
424 crtc->mode = saved_mode;
425 crtc->hwmode = saved_hwmode;
426 crtc->x = saved_x;
427 crtc->y = saved_y;
435 drm_crtc_helper_disable(struct drm_crtc *crtc)
437 struct drm_device *dev = crtc->dev;
441 /* Decouple all encoders and their attached connectors from this crtc */
445 if (encoder->crtc != crtc)
494 * &drm_crtc_funcs.set_config callback for drivers using the legacy CRTC
501 * mode_fixup encoder and CRTC helper operations to adjust the requested mode,
509 * will call the CRTC &drm_crtc_helper_funcs.mode_set_base helper operation.
514 * and ->commit() CRTC and encoder helper operations, in that order.
545 BUG_ON(!set->crtc);
546 BUG_ON(!set->crtc->helper_private);
552 crtc_funcs = set->crtc->helper_private;
554 dev = set->crtc->dev;
561 DRM_DEBUG_KMS("[CRTC:%d:%s] [FB:%d] #connectors=%d (x y) (%i %i)\n",
562 set->crtc->base.id, set->crtc->name,
566 DRM_DEBUG_KMS("[CRTC:%d:%s] [NOFB]\n",
567 set->crtc->base.id, set->crtc->name);
568 drm_crtc_helper_disable(set->crtc);
597 save_encoder_crtcs[count++] = encoder->crtc;
606 save_set.crtc = set->crtc;
607 save_set.mode = &set->crtc->mode;
608 save_set.x = set->crtc->x;
609 save_set.y = set->crtc->y;
610 save_set.fb = set->crtc->primary->fb;
614 if (set->crtc->primary->fb != set->fb) {
616 if (set->crtc->primary->fb == NULL) {
617 DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
619 } else if (set->fb->format != set->crtc->primary->fb->format) {
625 if (set->x != set->crtc->x || set->y != set->crtc->y)
628 if (!drm_mode_equal(set->mode, &set->crtc->mode)) {
630 drm_mode_debug_printmodeline(&set->crtc->mode);
677 * the appropriate crtc will be set later.
680 connector->encoder->crtc = NULL;
697 if (connector->encoder->crtc == set->crtc)
700 new_crtc = connector->encoder->crtc;
704 new_crtc = set->crtc;
707 /* Make sure the new CRTC will work with the encoder */
714 if (new_crtc != connector->encoder->crtc) {
715 DRM_DEBUG_KMS("crtc changed, full mode switch\n");
717 connector->encoder->crtc = new_crtc;
720 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [CRTC:%d:%s]\n",
735 if (drm_helper_crtc_in_use(set->crtc)) {
739 set->crtc->primary->fb = set->fb;
740 if (!drm_crtc_helper_set_mode(set->crtc, set->mode,
743 DRM_ERROR("failed to set mode on [CRTC:%d:%s]\n",
744 set->crtc->base.id, set->crtc->name);
745 set->crtc->primary->fb = save_set.fb;
758 set->crtc->x = set->x;
759 set->crtc->y = set->y;
760 set->crtc->primary->fb = set->fb;
761 ret = crtc_funcs->mode_set_base(set->crtc,
764 set->crtc->x = save_set.x;
765 set->crtc->y = save_set.y;
766 set->crtc->primary->fb = save_set.fb;
779 encoder->crtc = save_encoder_crtcs[count++];
799 !drm_crtc_helper_set_mode(save_set.crtc, save_set.mode, save_set.x,
839 static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc)
844 struct drm_device *dev = crtc->dev;
848 if (connector->encoder && connector->encoder->crtc == crtc)
862 * &drm_connector_funcs.dpms callback for drivers using the legacy CRTC
865 * This is the main helper function provided by the CRTC helper framework for
880 struct drm_crtc *crtc = encoder ? encoder->crtc : NULL;
894 /* from off to on, do crtc then encoder */
896 if (crtc) {
897 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
899 (*crtc_funcs->dpms) (crtc,
900 drm_helper_choose_crtc_dpms(crtc));
906 /* from on to off, do encoder then crtc */
910 if (crtc) {
911 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
913 (*crtc_funcs->dpms) (crtc,
914 drm_helper_choose_crtc_dpms(crtc));
950 struct drm_crtc *crtc;
959 drm_for_each_crtc(crtc, dev) {
961 if (!crtc->enabled)
964 ret = drm_crtc_helper_set_mode(crtc, &crtc->mode,
965 crtc->x, crtc->y, crtc->primary->fb);
969 DRM_ERROR("failed to set mode on crtc %p\n", crtc);
972 if (drm_helper_choose_crtc_dpms(crtc)) {
975 if(encoder->crtc != crtc)
984 crtc_funcs = crtc->helper_private;
986 (*crtc_funcs->dpms) (crtc,
987 drm_helper_choose_crtc_dpms(crtc));
1012 struct drm_crtc *crtc;
1016 drm_for_each_crtc(crtc, dev)
1017 if (crtc->enabled) {
1019 .crtc = crtc,