Lines Matching +full:poll +full:- +full:retry +full:- +full:count

2  * Copyright (c) 2006-2008 Intel Corporation
57 * track of a per-connector hpd interrupt.
68 module_param_named(poll, drm_kms_helper_poll, bool, 0600);
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()
228 * drm_kms_helper_poll_enable - re-enable output polling.
231 * This function re-enables the output polling work, after it has been
244 bool poll = false; in drm_kms_helper_poll_enable() local
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()
256 poll = true; in drm_kms_helper_poll_enable()
260 if (dev->mode_config.delayed_event) { in drm_kms_helper_poll_enable()
268 * drm_helper_probe_single_connector_modes() in case the poll in drm_kms_helper_poll_enable()
271 poll = true; in drm_kms_helper_poll_enable()
275 if (poll) 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()
289 retry: 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()
302 goto retry; 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()
358 * drm_helper_probe_single_connector_modes - get complete set of display modes
380 * - &drm_connector_helper_funcs.get_modes vfunc
381 * - if the connector status is connector_status_connected, standard
394 * 4. Any non-stale mode on the modes list then undergoes validation
396 * - drm_mode_validate_basic() performs basic sanity checks
397 * - drm_mode_validate_size() filters out modes larger than @maxX and @maxY
399 * - drm_mode_validate_flag() checks the modes against basic connector
401 * - the optional &drm_connector_helper_funcs.mode_valid or
404 * - the optional &drm_crtc_helper_funcs.mode_valid,
419 struct drm_device *dev = connector->dev; in drm_helper_probe_single_connector_modes()
422 connector->helper_private; in drm_helper_probe_single_connector_modes()
423 int count = 0, ret; in drm_helper_probe_single_connector_modes() local
429 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); in drm_helper_probe_single_connector_modes()
433 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id, in drm_helper_probe_single_connector_modes()
434 connector->name); in drm_helper_probe_single_connector_modes()
436 retry: in drm_helper_probe_single_connector_modes()
437 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx); in drm_helper_probe_single_connector_modes()
438 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
440 goto retry; in drm_helper_probe_single_connector_modes()
445 list_for_each_entry(mode, &connector->modes, head) in drm_helper_probe_single_connector_modes()
446 mode->status = MODE_STALE; in drm_helper_probe_single_connector_modes()
448 old_status = connector->status; in drm_helper_probe_single_connector_modes()
450 if (connector->force) { in drm_helper_probe_single_connector_modes()
451 if (connector->force == DRM_FORCE_ON || in drm_helper_probe_single_connector_modes()
452 connector->force == DRM_FORCE_ON_DIGITAL) in drm_helper_probe_single_connector_modes()
453 connector->status = connector_status_connected; in drm_helper_probe_single_connector_modes()
455 connector->status = connector_status_disconnected; in drm_helper_probe_single_connector_modes()
456 if (connector->funcs->force) in drm_helper_probe_single_connector_modes()
457 connector->funcs->force(connector); in drm_helper_probe_single_connector_modes()
461 if (ret == -EDEADLK) { in drm_helper_probe_single_connector_modes()
463 goto retry; in drm_helper_probe_single_connector_modes()
467 connector->status = ret; in drm_helper_probe_single_connector_modes()
471 * Normally either the driver's hpd code or the poll loop should in drm_helper_probe_single_connector_modes()
476 if (old_status != connector->status) { in drm_helper_probe_single_connector_modes()
478 connector->base.id, in drm_helper_probe_single_connector_modes()
479 connector->name, in drm_helper_probe_single_connector_modes()
481 drm_get_connector_status_name(connector->status)); in drm_helper_probe_single_connector_modes()
486 * locks. Fire up the poll struct instead, it will in drm_helper_probe_single_connector_modes()
489 dev->mode_config.delayed_event = true; in drm_helper_probe_single_connector_modes()
490 if (dev->mode_config.poll_enabled) in drm_helper_probe_single_connector_modes()
491 schedule_delayed_work(&dev->mode_config.output_poll_work, in drm_helper_probe_single_connector_modes()
495 /* Re-enable polling in case the global poll config changed. */ in drm_helper_probe_single_connector_modes()
496 if (drm_kms_helper_poll != dev->mode_config.poll_running) in drm_helper_probe_single_connector_modes()
499 dev->mode_config.poll_running = drm_kms_helper_poll; in drm_helper_probe_single_connector_modes()
501 if (connector->status == connector_status_disconnected) { in drm_helper_probe_single_connector_modes()
503 connector->base.id, connector->name); in drm_helper_probe_single_connector_modes()
509 count = (*connector_funcs->get_modes)(connector); in drm_helper_probe_single_connector_modes()
515 if (count == 0 && connector->status == connector_status_connected) in drm_helper_probe_single_connector_modes()
516 count = drm_add_override_edid_modes(connector); in drm_helper_probe_single_connector_modes()
518 if (count == 0 && connector->status == connector_status_connected) in drm_helper_probe_single_connector_modes()
519 count = drm_add_modes_noedid(connector, 1024, 768); in drm_helper_probe_single_connector_modes()
520 count += drm_helper_probe_add_cmdline_mode(connector); in drm_helper_probe_single_connector_modes()
521 if (count == 0) in drm_helper_probe_single_connector_modes()
526 if (connector->interlace_allowed) in drm_helper_probe_single_connector_modes()
528 if (connector->doublescan_allowed) in drm_helper_probe_single_connector_modes()
530 if (connector->stereo_allowed) in drm_helper_probe_single_connector_modes()
533 list_for_each_entry(mode, &connector->modes, head) { in drm_helper_probe_single_connector_modes()
534 if (mode->status != MODE_OK) in drm_helper_probe_single_connector_modes()
537 mode->status = drm_mode_validate_driver(dev, mode); in drm_helper_probe_single_connector_modes()
538 if (mode->status != MODE_OK) in drm_helper_probe_single_connector_modes()
541 mode->status = drm_mode_validate_size(mode, maxX, maxY); in drm_helper_probe_single_connector_modes()
542 if (mode->status != MODE_OK) in drm_helper_probe_single_connector_modes()
545 mode->status = drm_mode_validate_flag(mode, mode_flags); in drm_helper_probe_single_connector_modes()
546 if (mode->status != MODE_OK) in drm_helper_probe_single_connector_modes()
550 &mode->status); in drm_helper_probe_single_connector_modes()
556 if (drm_WARN_ON_ONCE(dev, ret != -EDEADLK)) { in drm_helper_probe_single_connector_modes()
557 mode->status = MODE_ERROR; in drm_helper_probe_single_connector_modes()
560 goto retry; in drm_helper_probe_single_connector_modes()
564 if (mode->status != MODE_OK) in drm_helper_probe_single_connector_modes()
566 mode->status = drm_mode_validate_ycbcr420(mode, connector); in drm_helper_probe_single_connector_modes()
570 drm_mode_prune_invalid(dev, &connector->modes, verbose_prune); in drm_helper_probe_single_connector_modes()
575 if (list_empty(&connector->modes)) in drm_helper_probe_single_connector_modes()
578 drm_mode_sort(&connector->modes); in drm_helper_probe_single_connector_modes()
580 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed modes :\n", connector->base.id, in drm_helper_probe_single_connector_modes()
581 connector->name); in drm_helper_probe_single_connector_modes()
582 list_for_each_entry(mode, &connector->modes, head) { in drm_helper_probe_single_connector_modes()
587 return count; in drm_helper_probe_single_connector_modes()
592 * drm_kms_helper_hotplug_event - fire off KMS hotplug events
601 * own, like drm_helper_hpd_irq_event() does - this is assumed to be done by the
611 if (dev->mode_config.funcs->output_poll_changed) in drm_kms_helper_hotplug_event()
612 dev->mode_config.funcs->output_poll_changed(dev); in drm_kms_helper_hotplug_event()
627 if (!dev->mode_config.poll_enabled) in output_poll_execute()
631 changed = dev->mode_config.delayed_event; in output_poll_execute()
632 dev->mode_config.delayed_event = false; in output_poll_execute()
637 if (!mutex_trylock(&dev->mode_config.mutex)) { in output_poll_execute()
645 if (connector->force) in output_poll_execute()
650 if (!connector->polled || connector->polled == DRM_CONNECTOR_POLL_HPD) in output_poll_execute()
653 old_status = connector->status; in output_poll_execute()
654 /* if we are connected and don't want to poll for disconnect in output_poll_execute()
657 !(connector->polled & DRM_CONNECTOR_POLL_DISCONNECT)) in output_poll_execute()
662 connector->status = drm_helper_probe_detect(connector, NULL, false); in output_poll_execute()
663 if (old_status != connector->status) { in output_poll_execute()
667 * The poll work sets force=false when calling detect so in output_poll_execute()
671 * flip-flop between unknown here in the poll work and in output_poll_execute()
679 if (connector->status == connector_status_unknown) { in output_poll_execute()
680 connector->status = old_status; in output_poll_execute()
685 new = drm_get_connector_status_name(connector->status); in output_poll_execute()
689 connector->base.id, in output_poll_execute()
690 connector->name, in output_poll_execute()
698 mutex_unlock(&dev->mode_config.mutex); in output_poll_execute()
709 * drm_kms_helper_is_poll_worker - is %current task an output poll worker?
711 * Determine if %current task is an output poll worker. This can be used
714 * One use case is to avoid a deadlock between the output poll worker and
718 * connector ->detect hook.
724 return work && work->func == output_poll_execute; in drm_kms_helper_is_poll_worker()
729 * drm_kms_helper_poll_disable - disable output polling
736 * disabled. Polling is re-enabled by calling drm_kms_helper_poll_enable().
744 if (!dev->mode_config.poll_enabled) in drm_kms_helper_poll_disable()
746 cancel_delayed_work_sync(&dev->mode_config.output_poll_work); in drm_kms_helper_poll_disable()
751 * drm_kms_helper_poll_init - initialize and enable output polling
756 * this helper infrastructure to regularly poll such connectors for changes in
771 INIT_DELAYED_WORK(&dev->mode_config.output_poll_work, output_poll_execute); in drm_kms_helper_poll_init()
772 dev->mode_config.poll_enabled = true; in drm_kms_helper_poll_init()
779 * drm_kms_helper_poll_fini - disable output polling and clean it up
784 if (!dev->mode_config.poll_enabled) in drm_kms_helper_poll_fini()
787 dev->mode_config.poll_enabled = false; in drm_kms_helper_poll_fini()
788 cancel_delayed_work_sync(&dev->mode_config.output_poll_work); in drm_kms_helper_poll_fini()
793 * drm_helper_hpd_irq_event - hotplug processing
805 * which have a more fine-grained detect logic should bypass this code and
823 if (!dev->mode_config.poll_enabled) in drm_helper_hpd_irq_event()
826 mutex_lock(&dev->mode_config.mutex); in drm_helper_hpd_irq_event()
830 if (!(connector->polled & DRM_CONNECTOR_POLL_HPD)) in drm_helper_hpd_irq_event()
833 old_status = connector->status; in drm_helper_hpd_irq_event()
835 old_epoch_counter = connector->epoch_counter; in drm_helper_hpd_irq_event()
837 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Old epoch counter %llu\n", connector->base.id, in drm_helper_hpd_irq_event()
838 connector->name, in drm_helper_hpd_irq_event()
841 connector->status = drm_helper_probe_detect(connector, NULL, false); in drm_helper_hpd_irq_event()
843 connector->base.id, in drm_helper_hpd_irq_event()
844 connector->name, in drm_helper_hpd_irq_event()
846 drm_get_connector_status_name(connector->status)); in drm_helper_hpd_irq_event()
849 connector->base.id, in drm_helper_hpd_irq_event()
850 connector->name, in drm_helper_hpd_irq_event()
851 connector->epoch_counter); in drm_helper_hpd_irq_event()
857 if (old_epoch_counter != connector->epoch_counter) in drm_helper_hpd_irq_event()
862 mutex_unlock(&dev->mode_config.mutex); in drm_helper_hpd_irq_event()