Lines Matching +full:s +full:- +full:mode

2  * Copyright (c) 2006-2008 Intel Corporation
57 * track of a per-connector hpd interrupt.
71 drm_mode_validate_flag(const struct drm_display_mode *mode, in drm_mode_validate_flag() argument
74 if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && in drm_mode_validate_flag()
78 if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) && in drm_mode_validate_flag()
82 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) && in drm_mode_validate_flag()
90 drm_mode_validate_pipeline(struct drm_display_mode *mode, in drm_mode_validate_pipeline() argument
95 struct drm_device *dev = connector->dev; in drm_mode_validate_pipeline()
100 ret = drm_connector_mode_valid(connector, mode, ctx, status); in drm_mode_validate_pipeline()
109 *status = drm_encoder_mode_valid(encoder, mode); in drm_mode_validate_pipeline()
112 * will not accept the mode anyway. If all encoders in drm_mode_validate_pipeline()
113 * reject the mode then, at exit, ret will not be in drm_mode_validate_pipeline()
120 &connector->display_info, in drm_mode_validate_pipeline()
121 mode); in drm_mode_validate_pipeline()
132 *status = drm_crtc_mode_valid(crtc, mode); in drm_mode_validate_pipeline()
136 * for this mode. Lets return now. */ in drm_mode_validate_pipeline()
148 struct drm_display_mode *mode; in drm_helper_probe_add_cmdline_mode() local
150 cmdline_mode = &connector->cmdline_mode; in drm_helper_probe_add_cmdline_mode()
151 if (!cmdline_mode->specified) in drm_helper_probe_add_cmdline_mode()
154 /* Only add a GTF mode if we find no matching probed modes */ in drm_helper_probe_add_cmdline_mode()
155 list_for_each_entry(mode, &connector->probed_modes, head) { in drm_helper_probe_add_cmdline_mode()
156 if (mode->hdisplay != cmdline_mode->xres || in drm_helper_probe_add_cmdline_mode()
157 mode->vdisplay != cmdline_mode->yres) in drm_helper_probe_add_cmdline_mode()
160 if (cmdline_mode->refresh_specified) { in drm_helper_probe_add_cmdline_mode()
161 /* The probed mode's vrefresh is set until later */ in drm_helper_probe_add_cmdline_mode()
162 if (drm_mode_vrefresh(mode) != cmdline_mode->refresh) in drm_helper_probe_add_cmdline_mode()
166 /* Mark the matching mode as being preferred by the user */ in drm_helper_probe_add_cmdline_mode()
167 mode->type |= DRM_MODE_TYPE_USERDEF; in drm_helper_probe_add_cmdline_mode()
171 mode = drm_mode_create_from_cmdline_mode(connector->dev, in drm_helper_probe_add_cmdline_mode()
173 if (mode == NULL) in drm_helper_probe_add_cmdline_mode()
176 drm_mode_probed_add(connector, mode); in drm_helper_probe_add_cmdline_mode()
181 const struct drm_display_mode *mode) in drm_crtc_mode_valid() argument
183 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in drm_crtc_mode_valid()
185 if (!crtc_funcs || !crtc_funcs->mode_valid) in drm_crtc_mode_valid()
188 return crtc_funcs->mode_valid(crtc, mode); in drm_crtc_mode_valid()
192 const struct drm_display_mode *mode) in drm_encoder_mode_valid() argument
195 encoder->helper_private; in drm_encoder_mode_valid()
197 if (!encoder_funcs || !encoder_funcs->mode_valid) in drm_encoder_mode_valid()
200 return encoder_funcs->mode_valid(encoder, mode); in drm_encoder_mode_valid()
205 struct drm_display_mode *mode, in drm_connector_mode_valid() argument
210 connector->helper_private; in drm_connector_mode_valid()
215 else if (connector_funcs->mode_valid_ctx) in drm_connector_mode_valid()
216 ret = connector_funcs->mode_valid_ctx(connector, mode, ctx, in drm_connector_mode_valid()
218 else if (connector_funcs->mode_valid) in drm_connector_mode_valid()
219 *status = connector_funcs->mode_valid(connector, mode); in drm_connector_mode_valid()
228 * drm_kms_helper_poll_enable - re-enable output polling.
231 * This function re-enables the output polling work, after it has been
249 if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll) in drm_kms_helper_poll_enable()
254 if (connector->polled & (DRM_CONNECTOR_POLL_CONNECT | in drm_kms_helper_poll_enable()
260 if (dev->mode_config.delayed_event) { in drm_kms_helper_poll_enable()
264 * Use short (1s) delay to handle the initial delayed event. in drm_kms_helper_poll_enable()
276 schedule_delayed_work(&dev->mode_config.output_poll_work, delay); in drm_kms_helper_poll_enable()
283 const struct drm_connector_helper_funcs *funcs = connector->helper_private; in drm_helper_probe_detect_ctx()
290 ret = drm_modeset_lock(&connector->dev->mode_config.connection_mutex, &ctx); in drm_helper_probe_detect_ctx()
292 if (funcs->detect_ctx) in drm_helper_probe_detect_ctx()
293 ret = funcs->detect_ctx(connector, &ctx, force); in drm_helper_probe_detect_ctx()
294 else if (connector->funcs->detect) in drm_helper_probe_detect_ctx()
295 ret = connector->funcs->detect(connector, force); in drm_helper_probe_detect_ctx()
300 if (ret == -EDEADLK) { in drm_helper_probe_detect_ctx()
308 if (ret != connector->status) in drm_helper_probe_detect_ctx()
309 connector->epoch_counter += 1; in drm_helper_probe_detect_ctx()
318 * drm_helper_probe_detect - probe connector status
325 * if @ctx is set, it might also return -EDEADLK.
332 const struct drm_connector_helper_funcs *funcs = connector->helper_private; in drm_helper_probe_detect()
333 struct drm_device *dev = connector->dev; in drm_helper_probe_detect()
339 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx); in drm_helper_probe_detect()
343 if (funcs->detect_ctx) in drm_helper_probe_detect()
344 ret = funcs->detect_ctx(connector, ctx, force); in drm_helper_probe_detect()
345 else if (connector->funcs->detect) in drm_helper_probe_detect()
346 ret = connector->funcs->detect(connector, force); in drm_helper_probe_detect()
350 if (ret != connector->status) in drm_helper_probe_detect()
351 connector->epoch_counter += 1; in drm_helper_probe_detect()
360 connector->helper_private; in drm_helper_probe_get_modes()
363 count = connector_funcs->get_modes(connector); in drm_helper_probe_get_modes()
369 if (count == 0 && connector->status == connector_status_connected) in drm_helper_probe_get_modes()
379 struct drm_device *dev = connector->dev; in __drm_helper_update_and_validate()
380 struct drm_display_mode *mode; in __drm_helper_update_and_validate() local
386 if (connector->interlace_allowed) in __drm_helper_update_and_validate()
388 if (connector->doublescan_allowed) in __drm_helper_update_and_validate()
390 if (connector->stereo_allowed) in __drm_helper_update_and_validate()
393 list_for_each_entry(mode, &connector->modes, head) { in __drm_helper_update_and_validate()
394 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
397 mode->status = drm_mode_validate_driver(dev, mode); in __drm_helper_update_and_validate()
398 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
401 mode->status = drm_mode_validate_size(mode, maxX, maxY); in __drm_helper_update_and_validate()
402 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
405 mode->status = drm_mode_validate_flag(mode, mode_flags); in __drm_helper_update_and_validate()
406 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
409 ret = drm_mode_validate_pipeline(mode, connector, ctx, in __drm_helper_update_and_validate()
410 &mode->status); in __drm_helper_update_and_validate()
416 if (drm_WARN_ON_ONCE(dev, ret != -EDEADLK)) in __drm_helper_update_and_validate()
417 mode->status = MODE_ERROR; in __drm_helper_update_and_validate()
419 return -EDEADLK; in __drm_helper_update_and_validate()
422 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
424 mode->status = drm_mode_validate_ycbcr420(mode, connector); in __drm_helper_update_and_validate()
431 * drm_helper_probe_single_connector_modes - get complete set of display modes
438 * be added to the connector's probed_modes list, then culled (based on validity
443 * for output mode filtering and detection.
447 * 1. All modes currently on the connector's modes list are marked as stale
449 * 2. New modes are added to the connector's probed_modes list with
453 * - &drm_connector_helper_funcs.get_modes vfunc
454 * - if the connector status is connector_status_connected, standard
467 * 4. Any non-stale mode on the modes list then undergoes validation
469 * - drm_mode_validate_basic() performs basic sanity checks
470 * - drm_mode_validate_size() filters out modes larger than @maxX and @maxY
472 * - drm_mode_validate_flag() checks the modes against basic connector
474 * - the optional &drm_connector_helper_funcs.mode_valid or
477 * - the optional &drm_crtc_helper_funcs.mode_valid,
482 * 5. Any mode whose status is not OK is pruned from the connector's modes list,
483 * accompanied by a debug message indicating the reason for the mode's
492 struct drm_device *dev = connector->dev; in drm_helper_probe_single_connector_modes()
493 struct drm_display_mode *mode; in drm_helper_probe_single_connector_modes() local
498 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); in drm_helper_probe_single_connector_modes()
502 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id, in drm_helper_probe_single_connector_modes()
503 connector->name); in drm_helper_probe_single_connector_modes()
506 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx); in drm_helper_probe_single_connector_modes()
507 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
514 list_for_each_entry(mode, &connector->modes, head) in drm_helper_probe_single_connector_modes()
515 mode->status = MODE_STALE; in drm_helper_probe_single_connector_modes()
517 old_status = connector->status; in drm_helper_probe_single_connector_modes()
519 if (connector->force) { in drm_helper_probe_single_connector_modes()
520 if (connector->force == DRM_FORCE_ON || in drm_helper_probe_single_connector_modes()
521 connector->force == DRM_FORCE_ON_DIGITAL) in drm_helper_probe_single_connector_modes()
522 connector->status = connector_status_connected; in drm_helper_probe_single_connector_modes()
524 connector->status = connector_status_disconnected; in drm_helper_probe_single_connector_modes()
525 if (connector->funcs->force) in drm_helper_probe_single_connector_modes()
526 connector->funcs->force(connector); in drm_helper_probe_single_connector_modes()
530 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
536 connector->status = ret; in drm_helper_probe_single_connector_modes()
540 * Normally either the driver's hpd code or the poll loop should in drm_helper_probe_single_connector_modes()
545 if (old_status != connector->status) { in drm_helper_probe_single_connector_modes()
546 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n", in drm_helper_probe_single_connector_modes()
547 connector->base.id, in drm_helper_probe_single_connector_modes()
548 connector->name, in drm_helper_probe_single_connector_modes()
550 drm_get_connector_status_name(connector->status)); in drm_helper_probe_single_connector_modes()
558 dev->mode_config.delayed_event = true; in drm_helper_probe_single_connector_modes()
559 if (dev->mode_config.poll_enabled) in drm_helper_probe_single_connector_modes()
560 schedule_delayed_work(&dev->mode_config.output_poll_work, in drm_helper_probe_single_connector_modes()
564 /* Re-enable polling in case the global poll config changed. */ in drm_helper_probe_single_connector_modes()
565 if (drm_kms_helper_poll != dev->mode_config.poll_running) in drm_helper_probe_single_connector_modes()
568 dev->mode_config.poll_running = drm_kms_helper_poll; in drm_helper_probe_single_connector_modes()
570 if (connector->status == connector_status_disconnected) { in drm_helper_probe_single_connector_modes()
571 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n", in drm_helper_probe_single_connector_modes()
572 connector->base.id, connector->name); in drm_helper_probe_single_connector_modes()
574 drm_mode_prune_invalid(dev, &connector->modes, false); in drm_helper_probe_single_connector_modes()
580 if (count == 0 && (connector->status == connector_status_connected || in drm_helper_probe_single_connector_modes()
581 connector->status == connector_status_unknown)) { in drm_helper_probe_single_connector_modes()
587 * mode) needs to be the default if there's no EDID. in drm_helper_probe_single_connector_modes()
589 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) in drm_helper_probe_single_connector_modes()
595 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
601 drm_mode_prune_invalid(dev, &connector->modes, true); in drm_helper_probe_single_connector_modes()
606 * mode. If all modes were pruned, perhaps because they need more in drm_helper_probe_single_connector_modes()
610 if (list_empty(&connector->modes) && in drm_helper_probe_single_connector_modes()
611 connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { in drm_helper_probe_single_connector_modes()
614 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
618 drm_mode_prune_invalid(dev, &connector->modes, true); in drm_helper_probe_single_connector_modes()
625 if (list_empty(&connector->modes)) in drm_helper_probe_single_connector_modes()
628 drm_mode_sort(&connector->modes); in drm_helper_probe_single_connector_modes()
630 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed modes :\n", connector->base.id, in drm_helper_probe_single_connector_modes()
631 connector->name); in drm_helper_probe_single_connector_modes()
632 list_for_each_entry(mode, &connector->modes, head) { in drm_helper_probe_single_connector_modes()
633 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); in drm_helper_probe_single_connector_modes()
634 drm_mode_debug_printmodeline(mode); in drm_helper_probe_single_connector_modes()
642 * drm_kms_helper_hotplug_event - fire off KMS hotplug events
651 * own, like drm_helper_hpd_irq_event() does - this is assumed to be done by the
654 * This function must be called from process context with no mode
664 if (dev->mode_config.funcs->output_poll_changed) in drm_kms_helper_hotplug_event()
665 dev->mode_config.funcs->output_poll_changed(dev); in drm_kms_helper_hotplug_event()
672 * drm_kms_helper_connector_hotplug_event - fire off a KMS connector hotplug event
676 * fine-grained uevent for a single connector.
680 struct drm_device *dev = connector->dev; in drm_kms_helper_connector_hotplug_event()
684 if (dev->mode_config.funcs->output_poll_changed) in drm_kms_helper_connector_hotplug_event()
685 dev->mode_config.funcs->output_poll_changed(dev); in drm_kms_helper_connector_hotplug_event()
701 if (!dev->mode_config.poll_enabled) in output_poll_execute()
705 changed = dev->mode_config.delayed_event; in output_poll_execute()
706 dev->mode_config.delayed_event = false; in output_poll_execute()
711 if (!mutex_trylock(&dev->mode_config.mutex)) { in output_poll_execute()
719 if (connector->force) in output_poll_execute()
724 if (!connector->polled || connector->polled == DRM_CONNECTOR_POLL_HPD) in output_poll_execute()
727 old_status = connector->status; in output_poll_execute()
731 !(connector->polled & DRM_CONNECTOR_POLL_DISCONNECT)) in output_poll_execute()
736 old_epoch_counter = connector->epoch_counter; in output_poll_execute()
737 connector->status = drm_helper_probe_detect(connector, NULL, false); in output_poll_execute()
738 if (old_epoch_counter != connector->epoch_counter) { in output_poll_execute()
746 * flip-flop between unknown here in the poll work and in output_poll_execute()
754 if (connector->status == connector_status_unknown) { in output_poll_execute()
755 connector->status = old_status; in output_poll_execute()
760 new = drm_get_connector_status_name(connector->status); in output_poll_execute()
762 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] " in output_poll_execute()
763 "status updated from %s to %s\n", in output_poll_execute()
764 connector->base.id, in output_poll_execute()
765 connector->name, in output_poll_execute()
767 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] epoch counter %llu -> %llu\n", in output_poll_execute()
768 connector->base.id, connector->name, in output_poll_execute()
769 old_epoch_counter, connector->epoch_counter); in output_poll_execute()
776 mutex_unlock(&dev->mode_config.mutex); in output_poll_execute()
787 * drm_kms_helper_is_poll_worker - is %current task an output poll worker?
796 * connector ->detect hook.
802 return work && work->func == output_poll_execute; in drm_kms_helper_is_poll_worker()
807 * drm_kms_helper_poll_disable - disable output polling
814 * disabled. Polling is re-enabled by calling drm_kms_helper_poll_enable().
822 if (!dev->mode_config.poll_enabled) in drm_kms_helper_poll_disable()
824 cancel_delayed_work_sync(&dev->mode_config.output_poll_work); in drm_kms_helper_poll_disable()
829 * drm_kms_helper_poll_init - initialize and enable output polling
849 INIT_DELAYED_WORK(&dev->mode_config.output_poll_work, output_poll_execute); in drm_kms_helper_poll_init()
850 dev->mode_config.poll_enabled = true; in drm_kms_helper_poll_init()
857 * drm_kms_helper_poll_fini - disable output polling and clean it up
862 if (!dev->mode_config.poll_enabled) in drm_kms_helper_poll_fini()
865 dev->mode_config.poll_enabled = false; in drm_kms_helper_poll_fini()
866 cancel_delayed_work_sync(&dev->mode_config.output_poll_work); in drm_kms_helper_poll_fini()
872 struct drm_device *dev = connector->dev; in check_connector_changed()
877 drm_WARN_ON(dev, !(connector->polled & DRM_CONNECTOR_POLL_HPD)); in check_connector_changed()
879 drm_WARN_ON(dev, !mutex_is_locked(&dev->mode_config.mutex)); in check_connector_changed()
881 old_status = connector->status; in check_connector_changed()
882 old_epoch_counter = connector->epoch_counter; in check_connector_changed()
883 connector->status = drm_helper_probe_detect(connector, NULL, false); in check_connector_changed()
885 if (old_epoch_counter == connector->epoch_counter) { in check_connector_changed()
886 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Same epoch counter %llu\n", in check_connector_changed()
887 connector->base.id, in check_connector_changed()
888 connector->name, in check_connector_changed()
889 connector->epoch_counter); in check_connector_changed()
894 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] status updated from %s to %s\n", in check_connector_changed()
895 connector->base.id, in check_connector_changed()
896 connector->name, in check_connector_changed()
898 drm_get_connector_status_name(connector->status)); in check_connector_changed()
900 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Changed epoch counter %llu => %llu\n", in check_connector_changed()
901 connector->base.id, in check_connector_changed()
902 connector->name, in check_connector_changed()
904 connector->epoch_counter); in check_connector_changed()
910 * drm_connector_helper_hpd_irq_event - hotplug processing
921 * This function must be called from process context with no mode
932 struct drm_device *dev = connector->dev; in drm_connector_helper_hpd_irq_event()
935 mutex_lock(&dev->mode_config.mutex); in drm_connector_helper_hpd_irq_event()
937 mutex_unlock(&dev->mode_config.mutex); in drm_connector_helper_hpd_irq_event()
941 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Sent hotplug event\n", in drm_connector_helper_hpd_irq_event()
942 connector->base.id, in drm_connector_helper_hpd_irq_event()
943 connector->name); in drm_connector_helper_hpd_irq_event()
951 * drm_helper_hpd_irq_event - hotplug processing
963 * which have a more fine-grained detect logic can use
968 * This function must be called from process context with no mode
983 if (!dev->mode_config.poll_enabled) in drm_helper_hpd_irq_event()
986 mutex_lock(&dev->mode_config.mutex); in drm_helper_hpd_irq_event()
990 if (!(connector->polled & DRM_CONNECTOR_POLL_HPD)) in drm_helper_hpd_irq_event()
1003 mutex_unlock(&dev->mode_config.mutex); in drm_helper_hpd_irq_event()
1018 * drm_crtc_helper_mode_valid_fixed - Validates a display mode
1020 * @mode: the mode to validate
1021 * @fixed_mode: the display hardware's mode
1024 * MODE_OK on success, or another mode-status code otherwise.
1027 const struct drm_display_mode *mode, in drm_crtc_helper_mode_valid_fixed() argument
1030 if (mode->hdisplay != fixed_mode->hdisplay && mode->vdisplay != fixed_mode->vdisplay) in drm_crtc_helper_mode_valid_fixed()
1032 else if (mode->hdisplay != fixed_mode->hdisplay) in drm_crtc_helper_mode_valid_fixed()
1034 else if (mode->vdisplay != fixed_mode->vdisplay) in drm_crtc_helper_mode_valid_fixed()
1042 * drm_connector_helper_get_modes_from_ddc - Updates the connector's EDID
1043 * property from the connector's
1050 * Uses a connector's DDC channel to retrieve EDID data and update the
1051 * connector's EDID property and display modes. Drivers can use this
1060 if (!connector->ddc) in drm_connector_helper_get_modes_from_ddc()
1063 edid = drm_get_edid(connector, connector->ddc); in drm_connector_helper_get_modes_from_ddc()
1078 * drm_connector_helper_get_modes_fixed - Duplicates a display mode for a connector
1080 * @fixed_mode: the display hardware's mode
1083 * that only supports a single fixed mode can use this function in their connector's
1092 struct drm_device *dev = connector->dev; in drm_connector_helper_get_modes_fixed()
1093 struct drm_display_mode *mode; in drm_connector_helper_get_modes_fixed() local
1095 mode = drm_mode_duplicate(dev, fixed_mode); in drm_connector_helper_get_modes_fixed()
1096 if (!mode) { in drm_connector_helper_get_modes_fixed()
1097 drm_err(dev, "Failed to duplicate mode " DRM_MODE_FMT "\n", in drm_connector_helper_get_modes_fixed()
1102 if (mode->name[0] == '\0') in drm_connector_helper_get_modes_fixed()
1103 drm_mode_set_name(mode); in drm_connector_helper_get_modes_fixed()
1105 mode->type |= DRM_MODE_TYPE_PREFERRED; in drm_connector_helper_get_modes_fixed()
1106 drm_mode_probed_add(connector, mode); in drm_connector_helper_get_modes_fixed()
1108 if (mode->width_mm) in drm_connector_helper_get_modes_fixed()
1109 connector->display_info.width_mm = mode->width_mm; in drm_connector_helper_get_modes_fixed()
1110 if (mode->height_mm) in drm_connector_helper_get_modes_fixed()
1111 connector->display_info.height_mm = mode->height_mm; in drm_connector_helper_get_modes_fixed()
1118 * drm_connector_helper_get_modes - Read EDID and update connector.
1121 * Read the EDID using drm_edid_read() (which requires that connector->ddc is