Lines Matching +full:no +full:- +full:hpd
1 // SPDX-License-Identifier: GPL-2.0
3 * DisplayPort CEC-Tunneling-over-AUX support
19 * Unfortunately it turns out that we have a chicken-and-egg situation
20 * here. Quite a few active (mini-)DP-to-HDMI or USB-C-to-HDMI adapters
21 * have a converter chip that supports CEC-Tunneling-over-AUX (usually the
23 * useless. Note that MegaChips 2900-based adapters appear to have good
27 * Sadly there is no way for this driver to know this. What happens is
33 * was never supported by any OS. So there was no easy way of testing it,
34 * and no incentive to correctly wire up the CEC pin.
41 * https://hverkuil.home.xs4all.nl/cec-status.txt
47 * As far as I can see there is no mechanism defined in the DisplayPort
56 * These functions take care of supporting the CEC-Tunneling-over-AUX
57 * feature of DisplayPort-to-HDMI adapters.
61 * When the EDID is unset because the HPD went low, then the CEC DPCD registers
62 * typically can no longer be read (true for a DP-to-HDMI adapter since it is
63 * powered by the HPD). However, some displays toggle the HPD off and on for a
68 * actually unregistered. Only if the HPD does not return within that time will
75 * soon as the HPD disappears.
77 * The default is one second to prevent short HPD glitches from unregistering
81 * registers remain available even if the HPD goes low since it is not powered
82 * by the HPD. In that case the CEC adapter will never be unregistered during
90 "CEC unregister delay in seconds, 0: no delay, >= 1000: never unregister");
111 la_mask |= adap->log_addrs.log_addr_mask | (1 << addr); in drm_dp_cec_adap_log_addr()
122 unsigned int retries = min(5, attempts - 1); in drm_dp_cec_adap_transmit()
126 msg->msg, msg->len); in drm_dp_cec_adap_transmit()
131 (msg->len - 1) | (retries << 4) | in drm_dp_cec_adap_transmit()
143 if (!(adap->capabilities & CEC_CAP_MONITOR_ALL)) in drm_dp_cec_adap_monitor_all_enable()
167 (int)sizeof(id->oui), id->oui); in drm_dp_cec_adap_status()
169 (int)strnlen(id->device_id, sizeof(id->device_id)), in drm_dp_cec_adap_status()
170 id->device_id); in drm_dp_cec_adap_status()
171 seq_printf(file, "HW Rev: %d.%d\n", id->hw_rev >> 4, id->hw_rev & 0xf); in drm_dp_cec_adap_status()
177 id->sw_major_rev, id->sw_minor_rev, in drm_dp_cec_adap_status()
178 id->sw_major_rev, id->sw_minor_rev); in drm_dp_cec_adap_status()
191 struct cec_adapter *adap = aux->cec.adap; in drm_dp_cec_received()
214 struct cec_adapter *adap = aux->cec.adap; in drm_dp_cec_handle_irq()
236 * drm_dp_cec_irq() - handle CEC interrupt, if any
239 * Should be called when handling an IRQ_HPD request. If CEC-tunneling-over-AUX
247 /* No transfer function was set, so not a DP connector */ in drm_dp_cec_irq()
248 if (!aux->transfer) in drm_dp_cec_irq()
251 mutex_lock(&aux->cec.lock); in drm_dp_cec_irq()
252 if (!aux->cec.adap) in drm_dp_cec_irq()
263 mutex_unlock(&aux->cec.lock); in drm_dp_cec_irq()
280 * Called if the HPD was low for more than drm_dp_cec_unregister_delay
288 mutex_lock(&aux->cec.lock); in drm_dp_cec_unregister_work()
289 cec_unregister_adapter(aux->cec.adap); in drm_dp_cec_unregister_work()
290 aux->cec.adap = NULL; in drm_dp_cec_unregister_work()
291 mutex_unlock(&aux->cec.lock); in drm_dp_cec_unregister_work()
295 * A new EDID is set. If there is no CEC adapter, then create one. If
302 struct drm_connector *connector = aux->cec.connector; in drm_dp_cec_set_edid()
309 /* No transfer function was set, so not a DP connector */ in drm_dp_cec_set_edid()
310 if (!aux->transfer) in drm_dp_cec_set_edid()
323 cancel_delayed_work_sync(&aux->cec.unregister_work); in drm_dp_cec_set_edid()
325 mutex_lock(&aux->cec.lock); in drm_dp_cec_set_edid()
328 cec_unregister_adapter(aux->cec.adap); in drm_dp_cec_set_edid()
329 aux->cec.adap = NULL; in drm_dp_cec_set_edid()
338 if (aux->cec.adap) { in drm_dp_cec_set_edid()
339 if (aux->cec.adap->capabilities == cec_caps && in drm_dp_cec_set_edid()
340 aux->cec.adap->available_log_addrs == num_las) { in drm_dp_cec_set_edid()
342 cec_s_phys_addr_from_edid(aux->cec.adap, edid); in drm_dp_cec_set_edid()
349 cec_unregister_adapter(aux->cec.adap); in drm_dp_cec_set_edid()
353 aux->cec.adap = cec_allocate_adapter(&drm_dp_cec_adap_ops, in drm_dp_cec_set_edid()
354 aux, connector->name, cec_caps, in drm_dp_cec_set_edid()
356 if (IS_ERR(aux->cec.adap)) { in drm_dp_cec_set_edid()
357 aux->cec.adap = NULL; in drm_dp_cec_set_edid()
362 cec_s_conn_info(aux->cec.adap, &conn_info); in drm_dp_cec_set_edid()
364 if (cec_register_adapter(aux->cec.adap, connector->dev->dev)) { in drm_dp_cec_set_edid()
365 cec_delete_adapter(aux->cec.adap); in drm_dp_cec_set_edid()
366 aux->cec.adap = NULL; in drm_dp_cec_set_edid()
373 cec_s_phys_addr_from_edid(aux->cec.adap, edid); in drm_dp_cec_set_edid()
376 mutex_unlock(&aux->cec.lock); in drm_dp_cec_set_edid()
381 * The EDID disappeared (likely because of the HPD going down).
385 /* No transfer function was set, so not a DP connector */ in drm_dp_cec_unset_edid()
386 if (!aux->transfer) in drm_dp_cec_unset_edid()
389 cancel_delayed_work_sync(&aux->cec.unregister_work); in drm_dp_cec_unset_edid()
391 mutex_lock(&aux->cec.lock); in drm_dp_cec_unset_edid()
392 if (!aux->cec.adap) in drm_dp_cec_unset_edid()
395 cec_phys_addr_invalidate(aux->cec.adap); in drm_dp_cec_unset_edid()
406 * seconds. This to debounce short HPD off-and-on cycles from in drm_dp_cec_unset_edid()
409 schedule_delayed_work(&aux->cec.unregister_work, in drm_dp_cec_unset_edid()
413 mutex_unlock(&aux->cec.lock); in drm_dp_cec_unset_edid()
418 * drm_dp_cec_register_connector() - register a new connector
430 WARN_ON(aux->cec.adap); in drm_dp_cec_register_connector()
431 if (WARN_ON(!aux->transfer)) in drm_dp_cec_register_connector()
433 aux->cec.connector = connector; in drm_dp_cec_register_connector()
434 INIT_DELAYED_WORK(&aux->cec.unregister_work, in drm_dp_cec_register_connector()
440 * drm_dp_cec_unregister_connector() - unregister the CEC adapter, if any
445 if (!aux->cec.adap) in drm_dp_cec_unregister_connector()
447 cancel_delayed_work_sync(&aux->cec.unregister_work); in drm_dp_cec_unregister_connector()
448 cec_unregister_adapter(aux->cec.adap); in drm_dp_cec_unregister_connector()
449 aux->cec.adap = NULL; in drm_dp_cec_unregister_connector()