Lines Matching full:aux

43  * levels to deal with Display Port sink devices and related things like DP aux
44 * channel transfers, EDID reading over DP aux channels, decoding certain DPCD
141 DRM_DEBUG_KMS("AUX interval %lu, out of range (max 4)\n", in drm_dp_link_train_clock_recovery_delay()
159 DRM_DEBUG_KMS("AUX interval %lu, out of range (max 4)\n", in drm_dp_link_train_channel_eq_delay()
188 drm_dp_dump_access(const struct drm_dp_aux *aux, in drm_dp_dump_access() argument
194 DRM_DEBUG_DP("%s: 0x%05x AUX %s (ret=%3d) %*ph\n", in drm_dp_dump_access()
195 aux->name, offset, arrow, ret, min(ret, 20), buffer); in drm_dp_dump_access()
197 DRM_DEBUG_DP("%s: 0x%05x AUX %s (ret=%3d)\n", in drm_dp_dump_access()
198 aux->name, offset, arrow, ret); in drm_dp_dump_access()
204 * The DisplayPort AUX channel is an abstraction to allow generic, driver-
205 * independent access to AUX functionality. Drivers can take advantage of
210 * Both native and I2C-over-AUX transactions are supported.
213 static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, in drm_dp_dpcd_access() argument
226 mutex_lock(&aux->hw_mutex); in drm_dp_dpcd_access()
231 * aux i2c transactions but real world devices this wasn't in drm_dp_dpcd_access()
240 ret = aux->transfer(aux, &msg); in drm_dp_dpcd_access()
262 aux->name, err); in drm_dp_dpcd_access()
266 mutex_unlock(&aux->hw_mutex); in drm_dp_dpcd_access()
272 * @aux: DisplayPort AUX channel (SST or MST)
280 * function returns -EPROTO. Errors from the underlying AUX channel transfer
284 ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, in drm_dp_dpcd_read() argument
301 if (!aux->is_remote) { in drm_dp_dpcd_read()
302 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, in drm_dp_dpcd_read()
308 if (aux->is_remote) in drm_dp_dpcd_read()
309 ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size); in drm_dp_dpcd_read()
311 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, in drm_dp_dpcd_read()
315 drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret); in drm_dp_dpcd_read()
322 * @aux: DisplayPort AUX channel (SST or MST)
330 * function returns -EPROTO. Errors from the underlying AUX channel transfer
334 ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, in drm_dp_dpcd_write() argument
339 if (aux->is_remote) in drm_dp_dpcd_write()
340 ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size); in drm_dp_dpcd_write()
342 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, in drm_dp_dpcd_write()
345 drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret); in drm_dp_dpcd_write()
352 * @aux: DisplayPort AUX channel
358 int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, in drm_dp_dpcd_read_link_status() argument
361 return drm_dp_dpcd_read(aux, DP_LANE0_1_STATUS, status, in drm_dp_dpcd_read_link_status()
432 * @aux: DisplayPort AUX channel
438 bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, in drm_dp_send_real_edid_checksum() argument
443 if (drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, in drm_dp_send_real_edid_checksum()
446 aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR); in drm_dp_send_real_edid_checksum()
451 if (drm_dp_dpcd_read(aux, DP_TEST_REQUEST, &link_edid_read, 1) < 1) { in drm_dp_send_real_edid_checksum()
453 aux->name, DP_TEST_REQUEST); in drm_dp_send_real_edid_checksum()
460 aux->name); in drm_dp_send_real_edid_checksum()
464 if (drm_dp_dpcd_write(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, in drm_dp_send_real_edid_checksum()
467 aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR); in drm_dp_send_real_edid_checksum()
472 if (drm_dp_dpcd_write(aux, DP_TEST_EDID_CHECKSUM, in drm_dp_send_real_edid_checksum()
475 aux->name, DP_TEST_EDID_CHECKSUM); in drm_dp_send_real_edid_checksum()
480 if (drm_dp_dpcd_write(aux, DP_TEST_RESPONSE, &test_resp, 1) < 1) { in drm_dp_send_real_edid_checksum()
482 aux->name, DP_TEST_RESPONSE); in drm_dp_send_real_edid_checksum()
500 static int drm_dp_read_extended_dpcd_caps(struct drm_dp_aux *aux, in drm_dp_read_extended_dpcd_caps() argument
517 ret = drm_dp_dpcd_read(aux, DP_DP13_DPCD_REV, &dpcd_ext, in drm_dp_read_extended_dpcd_caps()
526 aux->name, dpcd[DP_DPCD_REV], in drm_dp_read_extended_dpcd_caps()
535 aux->name, DP_RECEIVER_CAP_SIZE, dpcd); in drm_dp_read_extended_dpcd_caps()
545 * @aux: DisplayPort AUX channel
548 * Attempts to read the base DPCD caps for @aux. Additionally, this function
555 int drm_dp_read_dpcd_caps(struct drm_dp_aux *aux, in drm_dp_read_dpcd_caps() argument
560 ret = drm_dp_dpcd_read(aux, DP_DPCD_REV, dpcd, DP_RECEIVER_CAP_SIZE); in drm_dp_read_dpcd_caps()
566 ret = drm_dp_read_extended_dpcd_caps(aux, dpcd); in drm_dp_read_dpcd_caps()
571 aux->name, DP_RECEIVER_CAP_SIZE, dpcd); in drm_dp_read_dpcd_caps()
579 * @aux: DisplayPort AUX channel
590 int drm_dp_read_downstream_info(struct drm_dp_aux *aux, in drm_dp_read_downstream_info() argument
609 ret = drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, downstream_ports, len); in drm_dp_read_downstream_info()
616 aux->name, len, downstream_ports); in drm_dp_read_downstream_info()
932 * @aux: DisplayPort AUX channel
937 int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6]) in drm_dp_downstream_id() argument
939 return drm_dp_dpcd_read(aux, DP_BRANCH_ID, id, 6); in drm_dp_downstream_id()
949 * @aux: DisplayPort AUX channel
956 struct drm_dp_aux *aux) in drm_dp_downstream_debug() argument
1001 drm_dp_downstream_id(aux, id); in drm_dp_downstream_debug()
1004 len = drm_dp_dpcd_read(aux, DP_BRANCH_HW_REV, &rev[0], 1); in drm_dp_downstream_debug()
1009 len = drm_dp_dpcd_read(aux, DP_BRANCH_SW_REV, rev, 2); in drm_dp_downstream_debug()
1136 * @aux: The DP AUX channel to use
1140 * Returns: The current sink count reported by @aux, or a negative error code
1143 int drm_dp_read_sink_count(struct drm_dp_aux *aux) in drm_dp_read_sink_count() argument
1148 ret = drm_dp_dpcd_readb(aux, DP_SINK_COUNT, &count); in drm_dp_read_sink_count()
1159 * I2C-over-AUX implementation
1192 * Calculate the duration of the AUX request/reply in usec. Gives the
1237 /* AUX bitrate is 1MHz, i2c bitrate as specified */ in drm_dp_i2c_msg_duration()
1246 * i2c and AUX transfers.
1268 * Transfer a single I2C-over-AUX message and handle various error conditions,
1275 static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) in drm_dp_i2c_do_msg() argument
1282 * before giving up the AUX transaction. in drm_dp_i2c_do_msg()
1289 ret = aux->transfer(aux, msg); in drm_dp_i2c_do_msg()
1302 aux->name); in drm_dp_i2c_do_msg()
1305 aux->name, ret); in drm_dp_i2c_do_msg()
1313 * For I2C-over-AUX transactions this isn't enough, we in drm_dp_i2c_do_msg()
1320 aux->name, ret, msg->size); in drm_dp_i2c_do_msg()
1324 DRM_DEBUG_KMS("%s: native defer\n", aux->name); in drm_dp_i2c_do_msg()
1339 aux->name, msg->reply); in drm_dp_i2c_do_msg()
1355 aux->name, ret, msg->size); in drm_dp_i2c_do_msg()
1356 aux->i2c_nack_count++; in drm_dp_i2c_do_msg()
1360 DRM_DEBUG_KMS("%s: I2C defer\n", aux->name); in drm_dp_i2c_do_msg()
1365 aux->i2c_defer_count++; in drm_dp_i2c_do_msg()
1375 aux->name, msg->reply); in drm_dp_i2c_do_msg()
1380 DRM_DEBUG_KMS("%s: Too many retries, giving up\n", aux->name); in drm_dp_i2c_do_msg()
1398 static int drm_dp_i2c_drain_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *orig_msg) in drm_dp_i2c_drain_msg() argument
1404 err = drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_drain_msg()
1410 aux->name, msg.size, err); in drm_dp_i2c_drain_msg()
1422 * Bizlink designed DP->DVI-D Dual Link adapters require the I2C over AUX
1429 "Number of bytes to transfer in a single I2C over DP AUX CH message, (1-16, default 16)");
1434 struct drm_dp_aux *aux = adapter->algo_data; in drm_dp_i2c_xfer() local
1453 err = drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_xfer()
1472 err = drm_dp_i2c_drain_msg(aux, &msg); in drm_dp_i2c_xfer()
1496 (void)drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_xfer()
1532 static int drm_dp_aux_get_crc(struct drm_dp_aux *aux, u8 *crc) in drm_dp_aux_get_crc() argument
1537 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_aux_get_crc()
1543 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK_MISC, &buf); in drm_dp_aux_get_crc()
1548 if (count == aux->crc_count) in drm_dp_aux_get_crc()
1551 aux->crc_count = count; in drm_dp_aux_get_crc()
1557 ret = drm_dp_dpcd_read(aux, DP_TEST_CRC_R_CR, crc, 6); in drm_dp_aux_get_crc()
1566 struct drm_dp_aux *aux = container_of(work, struct drm_dp_aux, in drm_dp_aux_crc_work() local
1573 if (WARN_ON(!aux->crtc)) in drm_dp_aux_crc_work()
1576 crtc = aux->crtc; in drm_dp_aux_crc_work()
1582 ret = drm_dp_aux_get_crc(aux, crc_bytes); in drm_dp_aux_crc_work()
1585 ret = drm_dp_aux_get_crc(aux, crc_bytes); in drm_dp_aux_crc_work()
1590 aux->name, ret); in drm_dp_aux_crc_work()
1594 aux->name, ret); in drm_dp_aux_crc_work()
1606 * drm_dp_remote_aux_init() - minimally initialise a remote aux channel
1607 * @aux: DisplayPort AUX channel
1609 * Used for remote aux channel in general. Merely initialize the crc work
1612 void drm_dp_remote_aux_init(struct drm_dp_aux *aux) in drm_dp_remote_aux_init() argument
1614 INIT_WORK(&aux->crc_work, drm_dp_aux_crc_work); in drm_dp_remote_aux_init()
1619 * drm_dp_aux_init() - minimally initialise an aux channel
1620 * @aux: DisplayPort AUX channel
1627 void drm_dp_aux_init(struct drm_dp_aux *aux) in drm_dp_aux_init() argument
1629 mutex_init(&aux->hw_mutex); in drm_dp_aux_init()
1630 mutex_init(&aux->cec.lock); in drm_dp_aux_init()
1631 INIT_WORK(&aux->crc_work, drm_dp_aux_crc_work); in drm_dp_aux_init()
1633 aux->ddc.algo = &drm_dp_i2c_algo; in drm_dp_aux_init()
1634 aux->ddc.algo_data = aux; in drm_dp_aux_init()
1635 aux->ddc.retries = 3; in drm_dp_aux_init()
1637 aux->ddc.lock_ops = &drm_dp_i2c_lock_ops; in drm_dp_aux_init()
1642 * drm_dp_aux_register() - initialise and register aux channel
1643 * @aux: DisplayPort AUX channel
1651 * Drivers which need to use the aux channel before that point (e.g. at driver
1657 int drm_dp_aux_register(struct drm_dp_aux *aux) in drm_dp_aux_register() argument
1661 if (!aux->ddc.algo) in drm_dp_aux_register()
1662 drm_dp_aux_init(aux); in drm_dp_aux_register()
1664 aux->ddc.class = I2C_CLASS_DDC; in drm_dp_aux_register()
1665 aux->ddc.owner = THIS_MODULE; in drm_dp_aux_register()
1666 aux->ddc.dev.parent = aux->dev; in drm_dp_aux_register()
1668 strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev), in drm_dp_aux_register()
1669 sizeof(aux->ddc.name)); in drm_dp_aux_register()
1671 ret = drm_dp_aux_register_devnode(aux); in drm_dp_aux_register()
1675 ret = i2c_add_adapter(&aux->ddc); in drm_dp_aux_register()
1677 drm_dp_aux_unregister_devnode(aux); in drm_dp_aux_register()
1686 * drm_dp_aux_unregister() - unregister an AUX adapter
1687 * @aux: DisplayPort AUX channel
1689 void drm_dp_aux_unregister(struct drm_dp_aux *aux) in drm_dp_aux_unregister() argument
1691 drm_dp_aux_unregister_devnode(aux); in drm_dp_aux_unregister()
1692 i2c_del_adapter(&aux->ddc); in drm_dp_aux_unregister()
1731 * @aux: DisplayPort AUX channel
1736 int drm_dp_start_crc(struct drm_dp_aux *aux, struct drm_crtc *crtc) in drm_dp_start_crc() argument
1741 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_start_crc()
1745 ret = drm_dp_dpcd_writeb(aux, DP_TEST_SINK, buf | DP_TEST_SINK_START); in drm_dp_start_crc()
1749 aux->crc_count = 0; in drm_dp_start_crc()
1750 aux->crtc = crtc; in drm_dp_start_crc()
1751 schedule_work(&aux->crc_work); in drm_dp_start_crc()
1759 * @aux: DisplayPort AUX channel
1763 int drm_dp_stop_crc(struct drm_dp_aux *aux) in drm_dp_stop_crc() argument
1768 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_stop_crc()
1772 ret = drm_dp_dpcd_writeb(aux, DP_TEST_SINK, buf & ~DP_TEST_SINK_START); in drm_dp_stop_crc()
1776 flush_work(&aux->crc_work); in drm_dp_stop_crc()
1777 aux->crtc = NULL; in drm_dp_stop_crc()
1871 * Some Dell CML 2020 systems have panels support both AUX and PWM
1872 * backlight control, and some only support AUX backlight control. All
1873 * said panels start up in AUX mode by default, and we don't have any
1933 * @aux: DisplayPort AUX channel
1942 int drm_dp_read_desc(struct drm_dp_aux *aux, struct drm_dp_desc *desc, in drm_dp_read_desc() argument
1949 ret = drm_dp_dpcd_read(aux, offset, ident, sizeof(*ident)); in drm_dp_read_desc()
1958 aux->name, is_branch ? "branch" : "sink", in drm_dp_read_desc()
2108 * @aux: DisplayPort AUX channel
2113 int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux, in drm_dp_get_phy_test_pattern() argument
2119 err = drm_dp_dpcd_readb(aux, DP_TEST_LINK_RATE, &rate); in drm_dp_get_phy_test_pattern()
2124 err = drm_dp_dpcd_readb(aux, DP_TEST_LANE_COUNT, &lanes); in drm_dp_get_phy_test_pattern()
2132 err = drm_dp_dpcd_readb(aux, DP_PHY_TEST_PATTERN, &data->phy_pattern); in drm_dp_get_phy_test_pattern()
2138 err = drm_dp_dpcd_read(aux, DP_TEST_80BIT_CUSTOM_PATTERN_7_0, in drm_dp_get_phy_test_pattern()
2145 err = drm_dp_dpcd_read(aux, DP_TEST_HBR2_SCRAMBLER_RESET, in drm_dp_get_phy_test_pattern()
2158 * @aux: DisplayPort AUX channel
2164 int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux, in drm_dp_set_phy_test_pattern() argument
2175 err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, link_config, 2); in drm_dp_set_phy_test_pattern()
2183 err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET, in drm_dp_set_phy_test_pattern()
2189 err = drm_dp_dpcd_writeb(aux, in drm_dp_set_phy_test_pattern()