Lines Matching +full:hpd +full:- +full:reliable +full:- +full:delay

2  * Copyright (c) 2006-2008 Intel Corporation
57 * track of a per-connector hpd interrupt.
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()
95 struct drm_device *dev = connector->dev; in drm_mode_validate_pipeline()
120 &connector->display_info, in drm_mode_validate_pipeline()
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()
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()
162 if (drm_mode_vrefresh(mode) != cmdline_mode->refresh) 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()
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()
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()
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()
234 connector->helper_private; in drm_kms_helper_disable_hpd()
236 if (funcs && funcs->disable_hpd) in drm_kms_helper_disable_hpd()
237 funcs->disable_hpd(connector); in drm_kms_helper_disable_hpd()
251 connector->helper_private; in drm_kms_helper_enable_hpd()
253 if (funcs && funcs->enable_hpd) in drm_kms_helper_enable_hpd()
254 funcs->enable_hpd(connector); in drm_kms_helper_enable_hpd()
256 if (connector->polled & (DRM_CONNECTOR_POLL_CONNECT | in drm_kms_helper_enable_hpd()
268 unsigned long delay = DRM_OUTPUT_POLL_PERIOD; in reschedule_output_poll_work() local
270 if (dev->mode_config.delayed_event) in reschedule_output_poll_work()
274 * Use short (1s) delay to handle the initial delayed event. in reschedule_output_poll_work()
275 * This delay should not be needed, but Optimus/nouveau will in reschedule_output_poll_work()
281 delay = HZ; in reschedule_output_poll_work()
283 schedule_delayed_work(&dev->mode_config.output_poll_work, delay); in reschedule_output_poll_work()
287 * drm_kms_helper_poll_enable - re-enable output polling.
290 * This function re-enables the output polling work, after it has been
306 if (drm_WARN_ON_ONCE(dev, !dev->mode_config.poll_enabled) || in drm_kms_helper_poll_enable()
307 !drm_kms_helper_poll || dev->mode_config.poll_running) in drm_kms_helper_poll_enable()
311 dev->mode_config.delayed_event) in drm_kms_helper_poll_enable()
314 dev->mode_config.poll_running = true; in drm_kms_helper_poll_enable()
319 * drm_kms_helper_poll_reschedule - reschedule the output polling work
336 if (dev->mode_config.poll_running) in drm_kms_helper_poll_reschedule()
344 const struct drm_connector_helper_funcs *funcs = connector->helper_private; in drm_helper_probe_detect_ctx()
351 ret = drm_modeset_lock(&connector->dev->mode_config.connection_mutex, &ctx); in drm_helper_probe_detect_ctx()
353 if (funcs->detect_ctx) in drm_helper_probe_detect_ctx()
354 ret = funcs->detect_ctx(connector, &ctx, force); in drm_helper_probe_detect_ctx()
355 else if (connector->funcs->detect) in drm_helper_probe_detect_ctx()
356 ret = connector->funcs->detect(connector, force); in drm_helper_probe_detect_ctx()
361 if (ret == -EDEADLK) { in drm_helper_probe_detect_ctx()
369 if (ret != connector->status) in drm_helper_probe_detect_ctx()
370 connector->epoch_counter += 1; in drm_helper_probe_detect_ctx()
379 * drm_helper_probe_detect - probe connector status
386 * if @ctx is set, it might also return -EDEADLK.
393 const struct drm_connector_helper_funcs *funcs = connector->helper_private; in drm_helper_probe_detect()
394 struct drm_device *dev = connector->dev; in drm_helper_probe_detect()
400 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx); in drm_helper_probe_detect()
404 if (funcs->detect_ctx) in drm_helper_probe_detect()
405 ret = funcs->detect_ctx(connector, ctx, force); in drm_helper_probe_detect()
406 else if (connector->funcs->detect) in drm_helper_probe_detect()
407 ret = connector->funcs->detect(connector, force); in drm_helper_probe_detect()
411 if (ret != connector->status) in drm_helper_probe_detect()
412 connector->epoch_counter += 1; in drm_helper_probe_detect()
421 connector->helper_private; in drm_helper_probe_get_modes()
424 count = connector_funcs->get_modes(connector); in drm_helper_probe_get_modes()
428 drm_err(connector->dev, ".get_modes() returned %pe\n", in drm_helper_probe_get_modes()
437 if (count == 0 && connector->status == connector_status_connected) in drm_helper_probe_get_modes()
447 struct drm_device *dev = connector->dev; in __drm_helper_update_and_validate()
454 if (connector->interlace_allowed) in __drm_helper_update_and_validate()
456 if (connector->doublescan_allowed) in __drm_helper_update_and_validate()
458 if (connector->stereo_allowed) in __drm_helper_update_and_validate()
461 list_for_each_entry(mode, &connector->modes, head) { in __drm_helper_update_and_validate()
462 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
465 mode->status = drm_mode_validate_driver(dev, mode); in __drm_helper_update_and_validate()
466 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
469 mode->status = drm_mode_validate_size(mode, maxX, maxY); in __drm_helper_update_and_validate()
470 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
473 mode->status = drm_mode_validate_flag(mode, mode_flags); in __drm_helper_update_and_validate()
474 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
477 mode->status = drm_mode_validate_ycbcr420(mode, connector); in __drm_helper_update_and_validate()
478 if (mode->status != MODE_OK) in __drm_helper_update_and_validate()
482 &mode->status); in __drm_helper_update_and_validate()
488 if (drm_WARN_ON_ONCE(dev, ret != -EDEADLK)) in __drm_helper_update_and_validate()
489 mode->status = MODE_ERROR; in __drm_helper_update_and_validate()
491 return -EDEADLK; in __drm_helper_update_and_validate()
499 * drm_helper_probe_single_connector_modes - get complete set of display modes
521 * - &drm_connector_helper_funcs.get_modes vfunc
522 * - if the connector status is connector_status_connected, standard
535 * 4. Any non-stale mode on the modes list then undergoes validation
537 * - drm_mode_validate_basic() performs basic sanity checks
538 * - drm_mode_validate_size() filters out modes larger than @maxX and @maxY
540 * - drm_mode_validate_flag() checks the modes against basic connector
542 * - the optional &drm_connector_helper_funcs.mode_valid or
545 * - the optional &drm_crtc_helper_funcs.mode_valid,
560 struct drm_device *dev = connector->dev; in drm_helper_probe_single_connector_modes()
566 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); in drm_helper_probe_single_connector_modes()
570 drm_dbg_kms(dev, "[CONNECTOR:%d:%s]\n", connector->base.id, in drm_helper_probe_single_connector_modes()
571 connector->name); in drm_helper_probe_single_connector_modes()
574 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx); in drm_helper_probe_single_connector_modes()
575 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
582 list_for_each_entry(mode, &connector->modes, head) in drm_helper_probe_single_connector_modes()
583 mode->status = MODE_STALE; in drm_helper_probe_single_connector_modes()
585 old_status = connector->status; in drm_helper_probe_single_connector_modes()
587 if (connector->force) { in drm_helper_probe_single_connector_modes()
588 if (connector->force == DRM_FORCE_ON || in drm_helper_probe_single_connector_modes()
589 connector->force == DRM_FORCE_ON_DIGITAL) in drm_helper_probe_single_connector_modes()
590 connector->status = connector_status_connected; in drm_helper_probe_single_connector_modes()
592 connector->status = connector_status_disconnected; in drm_helper_probe_single_connector_modes()
593 if (connector->funcs->force) in drm_helper_probe_single_connector_modes()
594 connector->funcs->force(connector); in drm_helper_probe_single_connector_modes()
598 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
604 connector->status = ret; in drm_helper_probe_single_connector_modes()
608 * Normally either the driver's hpd code or the poll loop should in drm_helper_probe_single_connector_modes()
613 if (old_status != connector->status) { in drm_helper_probe_single_connector_modes()
615 connector->base.id, connector->name, in drm_helper_probe_single_connector_modes()
617 drm_get_connector_status_name(connector->status)); in drm_helper_probe_single_connector_modes()
625 dev->mode_config.delayed_event = true; in drm_helper_probe_single_connector_modes()
626 if (dev->mode_config.poll_enabled) in drm_helper_probe_single_connector_modes()
628 &dev->mode_config.output_poll_work, in drm_helper_probe_single_connector_modes()
633 * Re-enable polling in case the global poll config changed but polling in drm_helper_probe_single_connector_modes()
636 if (dev->mode_config.poll_enabled) in drm_helper_probe_single_connector_modes()
639 if (connector->status == connector_status_disconnected) { in drm_helper_probe_single_connector_modes()
641 connector->base.id, connector->name); in drm_helper_probe_single_connector_modes()
643 drm_mode_prune_invalid(dev, &connector->modes, false); in drm_helper_probe_single_connector_modes()
649 if (count == 0 && (connector->status == connector_status_connected || in drm_helper_probe_single_connector_modes()
650 connector->status == connector_status_unknown)) { in drm_helper_probe_single_connector_modes()
658 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) in drm_helper_probe_single_connector_modes()
664 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
670 drm_mode_prune_invalid(dev, &connector->modes, true); in drm_helper_probe_single_connector_modes()
679 if (list_empty(&connector->modes) && in drm_helper_probe_single_connector_modes()
680 connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { in drm_helper_probe_single_connector_modes()
683 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
687 drm_mode_prune_invalid(dev, &connector->modes, true); in drm_helper_probe_single_connector_modes()
694 if (list_empty(&connector->modes)) in drm_helper_probe_single_connector_modes()
697 drm_mode_sort(&connector->modes); in drm_helper_probe_single_connector_modes()
700 connector->base.id, connector->name); in drm_helper_probe_single_connector_modes()
702 list_for_each_entry(mode, &connector->modes, head) { in drm_helper_probe_single_connector_modes()
713 * drm_kms_helper_hotplug_event - fire off KMS hotplug events
722 * own, like drm_helper_hpd_irq_event() does - this is assumed to be done by the
739 * drm_kms_helper_connector_hotplug_event - fire off a KMS connector hotplug event
743 * fine-grained uevent for a single connector.
747 struct drm_device *dev = connector->dev; in drm_kms_helper_connector_hotplug_event()
764 if (!dev->mode_config.poll_enabled) in output_poll_execute()
768 changed = dev->mode_config.delayed_event; in output_poll_execute()
769 dev->mode_config.delayed_event = false; in output_poll_execute()
772 if (dev->mode_config.poll_running) { in output_poll_execute()
774 dev->mode_config.poll_running = false; in output_poll_execute()
779 if (!mutex_trylock(&dev->mode_config.mutex)) { in output_poll_execute()
787 if (connector->force) in output_poll_execute()
790 /* Ignore HPD capable connectors and connectors where we don't in output_poll_execute()
792 if (!connector->polled || connector->polled == DRM_CONNECTOR_POLL_HPD) in output_poll_execute()
795 old_status = connector->status; in output_poll_execute()
799 !(connector->polled & DRM_CONNECTOR_POLL_DISCONNECT)) in output_poll_execute()
804 old_epoch_counter = connector->epoch_counter; in output_poll_execute()
805 connector->status = drm_helper_probe_detect(connector, NULL, false); in output_poll_execute()
806 if (old_epoch_counter != connector->epoch_counter) { in output_poll_execute()
814 * flip-flop between unknown here in the poll work and in output_poll_execute()
822 if (connector->status == connector_status_unknown) { in output_poll_execute()
823 connector->status = old_status; in output_poll_execute()
828 new = drm_get_connector_status_name(connector->status); in output_poll_execute()
831 connector->base.id, connector->name, in output_poll_execute()
833 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] epoch counter %llu -> %llu\n", in output_poll_execute()
834 connector->base.id, connector->name, in output_poll_execute()
835 old_epoch_counter, connector->epoch_counter); in output_poll_execute()
842 mutex_unlock(&dev->mode_config.mutex); in output_poll_execute()
853 * drm_kms_helper_is_poll_worker - is %current task an output poll worker?
862 * connector ->detect hook.
868 return work && work->func == output_poll_execute; in drm_kms_helper_is_poll_worker()
873 * drm_kms_helper_poll_disable - disable output polling
880 * disabled. Polling is re-enabled by calling drm_kms_helper_poll_enable().
891 if (drm_WARN_ON(dev, !dev->mode_config.poll_enabled)) in drm_kms_helper_poll_disable()
894 if (dev->mode_config.poll_running) in drm_kms_helper_poll_disable()
897 cancel_delayed_work_sync(&dev->mode_config.output_poll_work); in drm_kms_helper_poll_disable()
899 dev->mode_config.poll_running = false; in drm_kms_helper_poll_disable()
904 * drm_kms_helper_poll_init - initialize and enable output polling
908 * @dev. Drivers which do not have reliable hotplug support in hardware can use
924 INIT_DELAYED_WORK(&dev->mode_config.output_poll_work, output_poll_execute); in drm_kms_helper_poll_init()
925 dev->mode_config.poll_enabled = true; in drm_kms_helper_poll_init()
932 * drm_kms_helper_poll_fini - disable output polling and clean it up
937 if (!dev->mode_config.poll_enabled) in drm_kms_helper_poll_fini()
942 dev->mode_config.poll_enabled = false; in drm_kms_helper_poll_fini()
952 * drmm_kms_helper_poll_init - initialize and enable output polling
974 struct drm_device *dev = connector->dev; in check_connector_changed()
978 /* Only handle HPD capable connectors. */ in check_connector_changed()
979 drm_WARN_ON(dev, !(connector->polled & DRM_CONNECTOR_POLL_HPD)); in check_connector_changed()
981 drm_WARN_ON(dev, !mutex_is_locked(&dev->mode_config.mutex)); in check_connector_changed()
983 old_status = connector->status; in check_connector_changed()
984 old_epoch_counter = connector->epoch_counter; in check_connector_changed()
985 connector->status = drm_helper_probe_detect(connector, NULL, false); in check_connector_changed()
987 if (old_epoch_counter == connector->epoch_counter) { in check_connector_changed()
989 connector->base.id, in check_connector_changed()
990 connector->name, in check_connector_changed()
991 connector->epoch_counter); in check_connector_changed()
997 connector->base.id, in check_connector_changed()
998 connector->name, in check_connector_changed()
1000 drm_get_connector_status_name(connector->status)); in check_connector_changed()
1003 connector->base.id, in check_connector_changed()
1004 connector->name, in check_connector_changed()
1006 connector->epoch_counter); in check_connector_changed()
1012 * drm_connector_helper_hpd_irq_event - hotplug processing
1034 struct drm_device *dev = connector->dev; in drm_connector_helper_hpd_irq_event()
1037 mutex_lock(&dev->mode_config.mutex); in drm_connector_helper_hpd_irq_event()
1039 mutex_unlock(&dev->mode_config.mutex); in drm_connector_helper_hpd_irq_event()
1044 connector->base.id, in drm_connector_helper_hpd_irq_event()
1045 connector->name); in drm_connector_helper_hpd_irq_event()
1053 * drm_helper_hpd_irq_event - hotplug processing
1065 * which have a more fine-grained detect logic can use
1085 if (!dev->mode_config.poll_enabled) in drm_helper_hpd_irq_event()
1088 mutex_lock(&dev->mode_config.mutex); in drm_helper_hpd_irq_event()
1091 /* Only handle HPD capable connectors. */ in drm_helper_hpd_irq_event()
1092 if (!(connector->polled & DRM_CONNECTOR_POLL_HPD)) in drm_helper_hpd_irq_event()
1105 mutex_unlock(&dev->mode_config.mutex); in drm_helper_hpd_irq_event()
1120 * drm_crtc_helper_mode_valid_fixed - Validates a display mode
1126 * MODE_OK on success, or another mode-status code otherwise.
1132 if (mode->hdisplay != fixed_mode->hdisplay && mode->vdisplay != fixed_mode->vdisplay) in drm_crtc_helper_mode_valid_fixed()
1134 else if (mode->hdisplay != fixed_mode->hdisplay) in drm_crtc_helper_mode_valid_fixed()
1136 else if (mode->vdisplay != fixed_mode->vdisplay) in drm_crtc_helper_mode_valid_fixed()
1144 * drm_connector_helper_get_modes_fixed - Duplicates a display mode for a connector
1158 struct drm_device *dev = connector->dev; in drm_connector_helper_get_modes_fixed()
1168 if (mode->name[0] == '\0') in drm_connector_helper_get_modes_fixed()
1171 mode->type |= DRM_MODE_TYPE_PREFERRED; in drm_connector_helper_get_modes_fixed()
1174 if (mode->width_mm) in drm_connector_helper_get_modes_fixed()
1175 connector->display_info.width_mm = mode->width_mm; in drm_connector_helper_get_modes_fixed()
1176 if (mode->height_mm) in drm_connector_helper_get_modes_fixed()
1177 connector->display_info.height_mm = mode->height_mm; in drm_connector_helper_get_modes_fixed()
1184 * drm_connector_helper_get_modes - Read EDID and update connector.
1187 * Read the EDID using drm_edid_read() (which requires that connector->ddc is
1220 * drm_connector_helper_tv_get_modes - Fills the modes availables to a TV connector
1234 struct drm_device *dev = connector->dev; in drm_connector_helper_tv_get_modes()
1236 dev->mode_config.tv_mode_property; in drm_connector_helper_tv_get_modes()
1237 struct drm_cmdline_mode *cmdline = &connector->cmdline_mode; in drm_connector_helper_tv_get_modes()
1251 for (i = 0; i < tv_mode_property->num_values; i++) in drm_connector_helper_tv_get_modes()
1252 supported_tv_modes |= BIT(tv_mode_property->values[i]); in drm_connector_helper_tv_get_modes()
1259 if (drm_object_property_get_default_value(&connector->base, in drm_connector_helper_tv_get_modes()
1264 if (cmdline->tv_mode_specified) in drm_connector_helper_tv_get_modes()
1265 default_mode = cmdline->tv_mode; in drm_connector_helper_tv_get_modes()
1294 mode->type |= DRM_MODE_TYPE_PREFERRED; in drm_connector_helper_tv_get_modes()
1303 * drm_connector_helper_detect_from_ddc - Read EDID and detect connector status.
1306 * @force: Perform screen-destructive operations, if necessary
1309 * which requires connector->ddc to be set. Returns connector_status_connected
1319 struct i2c_adapter *ddc = connector->ddc; in drm_connector_helper_detect_from_ddc()