Lines Matching full:aux
58 struct drm_dp_aux *aux; member
67 * levels to deal with Display Port sink devices and related things like DP aux
68 * channel transfers, EDID reading over DP aux channels, decoding certain DPCD
226 static int __8b10b_clock_recovery_delay_us(const struct drm_dp_aux *aux, u8 rd_interval) in __8b10b_clock_recovery_delay_us() argument
229 drm_dbg_kms(aux->drm_dev, "%s: invalid AUX interval 0x%02x (max 4)\n", in __8b10b_clock_recovery_delay_us()
230 aux->name, rd_interval); in __8b10b_clock_recovery_delay_us()
238 static int __8b10b_channel_eq_delay_us(const struct drm_dp_aux *aux, u8 rd_interval) in __8b10b_channel_eq_delay_us() argument
241 drm_dbg_kms(aux->drm_dev, "%s: invalid AUX interval 0x%02x (max 4)\n", in __8b10b_channel_eq_delay_us()
242 aux->name, rd_interval); in __8b10b_channel_eq_delay_us()
250 static int __128b132b_channel_eq_delay_us(const struct drm_dp_aux *aux, u8 rd_interval) in __128b132b_channel_eq_delay_us() argument
254 drm_dbg_kms(aux->drm_dev, "%s: invalid AUX interval 0x%02x\n", in __128b132b_channel_eq_delay_us()
255 aux->name, rd_interval); in __128b132b_channel_eq_delay_us()
284 static int __read_delay(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE], in __read_delay() argument
287 int (*parse)(const struct drm_dp_aux *aux, u8 rd_interval); in __read_delay()
328 if (drm_dp_dpcd_readb(aux, offset, &rd_interval) != 1) { in __read_delay()
329 drm_dbg_kms(aux->drm_dev, "%s: failed rd interval read\n", in __read_delay()
330 aux->name); in __read_delay()
336 return parse(aux, rd_interval & mask); in __read_delay()
339 int drm_dp_read_clock_recovery_delay(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE], in drm_dp_read_clock_recovery_delay() argument
342 return __read_delay(aux, dpcd, dp_phy, uhbr, true); in drm_dp_read_clock_recovery_delay()
346 int drm_dp_read_channel_eq_delay(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE], in drm_dp_read_channel_eq_delay() argument
349 return __read_delay(aux, dpcd, dp_phy, uhbr, false); in drm_dp_read_channel_eq_delay()
354 int drm_dp_128b132b_read_aux_rd_interval(struct drm_dp_aux *aux) in drm_dp_128b132b_read_aux_rd_interval() argument
359 if (drm_dp_dpcd_readb(aux, DP_128B132B_TRAINING_AUX_RD_INTERVAL, &val) != 1) { in drm_dp_128b132b_read_aux_rd_interval()
360 drm_err(aux->drm_dev, "%s: failed rd interval read\n", in drm_dp_128b132b_read_aux_rd_interval()
361 aux->name); in drm_dp_128b132b_read_aux_rd_interval()
373 void drm_dp_link_train_clock_recovery_delay(const struct drm_dp_aux *aux, in drm_dp_link_train_clock_recovery_delay() argument
383 delay_us = __8b10b_clock_recovery_delay_us(aux, rd_interval); in drm_dp_link_train_clock_recovery_delay()
389 static void __drm_dp_link_train_channel_eq_delay(const struct drm_dp_aux *aux, in __drm_dp_link_train_channel_eq_delay() argument
392 int delay_us = __8b10b_channel_eq_delay_us(aux, rd_interval); in __drm_dp_link_train_channel_eq_delay()
397 void drm_dp_link_train_channel_eq_delay(const struct drm_dp_aux *aux, in drm_dp_link_train_channel_eq_delay() argument
400 __drm_dp_link_train_channel_eq_delay(aux, in drm_dp_link_train_channel_eq_delay()
449 void drm_dp_lttpr_link_train_channel_eq_delay(const struct drm_dp_aux *aux, in drm_dp_lttpr_link_train_channel_eq_delay() argument
456 __drm_dp_link_train_channel_eq_delay(aux, interval); in drm_dp_lttpr_link_train_channel_eq_delay()
495 drm_dp_dump_access(const struct drm_dp_aux *aux, in drm_dp_dump_access() argument
501 drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d) %*ph\n", in drm_dp_dump_access()
502 aux->name, offset, arrow, ret, min(ret, 20), buffer); in drm_dp_dump_access()
504 drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d)\n", in drm_dp_dump_access()
505 aux->name, offset, arrow, ret); in drm_dp_dump_access()
511 * The DisplayPort AUX channel is an abstraction to allow generic, driver-
512 * independent access to AUX functionality. Drivers can take advantage of
517 * Both native and I2C-over-AUX transactions are supported.
520 static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, in drm_dp_dpcd_access() argument
533 mutex_lock(&aux->hw_mutex); in drm_dp_dpcd_access()
536 * If the device attached to the aux bus is powered down then there's in drm_dp_dpcd_access()
539 if (aux->powered_down) { in drm_dp_dpcd_access()
547 * aux i2c transactions but real world devices this wasn't in drm_dp_dpcd_access()
556 ret = aux->transfer(aux, &msg); in drm_dp_dpcd_access()
577 drm_dbg_kms(aux->drm_dev, "%s: Too many retries, giving up. First error: %d\n", in drm_dp_dpcd_access()
578 aux->name, err); in drm_dp_dpcd_access()
582 mutex_unlock(&aux->hw_mutex); in drm_dp_dpcd_access()
588 * @aux: DisplayPort AUX channel (SST)
597 int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset) in drm_dp_dpcd_probe() argument
602 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1); in drm_dp_dpcd_probe()
605 drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, ret); in drm_dp_dpcd_probe()
613 * @aux: DisplayPort AUX channel; for convenience it's OK to pass NULL here
617 * If the endpoint device on the DP AUX bus is known to be powered down
623 void drm_dp_dpcd_set_powered(struct drm_dp_aux *aux, bool powered) in drm_dp_dpcd_set_powered() argument
625 if (!aux) in drm_dp_dpcd_set_powered()
628 mutex_lock(&aux->hw_mutex); in drm_dp_dpcd_set_powered()
629 aux->powered_down = !powered; in drm_dp_dpcd_set_powered()
630 mutex_unlock(&aux->hw_mutex); in drm_dp_dpcd_set_powered()
636 * @aux: DisplayPort AUX channel (SST or MST)
644 * function returns -EPROTO. Errors from the underlying AUX channel transfer
648 ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, in drm_dp_dpcd_read() argument
665 if (!aux->is_remote) { in drm_dp_dpcd_read()
666 ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV); in drm_dp_dpcd_read()
671 if (aux->is_remote) in drm_dp_dpcd_read()
672 ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size); in drm_dp_dpcd_read()
674 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, in drm_dp_dpcd_read()
677 drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret); in drm_dp_dpcd_read()
684 * @aux: DisplayPort AUX channel (SST or MST)
692 * function returns -EPROTO. Errors from the underlying AUX channel transfer
696 ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, in drm_dp_dpcd_write() argument
701 if (aux->is_remote) in drm_dp_dpcd_write()
702 ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size); in drm_dp_dpcd_write()
704 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, in drm_dp_dpcd_write()
707 drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret); in drm_dp_dpcd_write()
714 * @aux: DisplayPort AUX channel
720 int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, in drm_dp_dpcd_read_link_status() argument
723 return drm_dp_dpcd_read(aux, DP_LANE0_1_STATUS, status, in drm_dp_dpcd_read_link_status()
730 * @aux: DisplayPort AUX channel
734 * Fetch the AUX DPCD registers for the DPRX or an LTTPR PHY link status. The
741 int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, in drm_dp_dpcd_read_phy_link_status() argument
748 ret = drm_dp_dpcd_read(aux, in drm_dp_dpcd_read_phy_link_status()
761 ret = drm_dp_dpcd_read(aux, in drm_dp_dpcd_read_phy_link_status()
847 * @aux: DisplayPort AUX channel
853 bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, in drm_dp_send_real_edid_checksum() argument
858 if (drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, in drm_dp_send_real_edid_checksum()
860 drm_err(aux->drm_dev, "%s: DPCD failed read at register 0x%x\n", in drm_dp_send_real_edid_checksum()
861 aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR); in drm_dp_send_real_edid_checksum()
866 if (drm_dp_dpcd_read(aux, DP_TEST_REQUEST, &link_edid_read, 1) < 1) { in drm_dp_send_real_edid_checksum()
867 drm_err(aux->drm_dev, "%s: DPCD failed read at register 0x%x\n", in drm_dp_send_real_edid_checksum()
868 aux->name, DP_TEST_REQUEST); in drm_dp_send_real_edid_checksum()
874 drm_dbg_kms(aux->drm_dev, "%s: Source DUT does not support TEST_EDID_READ\n", in drm_dp_send_real_edid_checksum()
875 aux->name); in drm_dp_send_real_edid_checksum()
879 if (drm_dp_dpcd_write(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, in drm_dp_send_real_edid_checksum()
881 drm_err(aux->drm_dev, "%s: DPCD failed write at register 0x%x\n", in drm_dp_send_real_edid_checksum()
882 aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR); in drm_dp_send_real_edid_checksum()
887 if (drm_dp_dpcd_write(aux, DP_TEST_EDID_CHECKSUM, in drm_dp_send_real_edid_checksum()
889 drm_err(aux->drm_dev, "%s: DPCD failed write at register 0x%x\n", in drm_dp_send_real_edid_checksum()
890 aux->name, DP_TEST_EDID_CHECKSUM); in drm_dp_send_real_edid_checksum()
895 if (drm_dp_dpcd_write(aux, DP_TEST_RESPONSE, &test_resp, 1) < 1) { in drm_dp_send_real_edid_checksum()
896 drm_err(aux->drm_dev, "%s: DPCD failed write at register 0x%x\n", in drm_dp_send_real_edid_checksum()
897 aux->name, DP_TEST_RESPONSE); in drm_dp_send_real_edid_checksum()
915 static int drm_dp_read_extended_dpcd_caps(struct drm_dp_aux *aux, in drm_dp_read_extended_dpcd_caps() argument
932 ret = drm_dp_dpcd_read(aux, DP_DP13_DPCD_REV, &dpcd_ext, in drm_dp_read_extended_dpcd_caps()
940 drm_dbg_kms(aux->drm_dev, in drm_dp_read_extended_dpcd_caps()
942 aux->name, dpcd[DP_DPCD_REV], dpcd_ext[DP_DPCD_REV]); in drm_dp_read_extended_dpcd_caps()
949 drm_dbg_kms(aux->drm_dev, "%s: Base DPCD: %*ph\n", aux->name, DP_RECEIVER_CAP_SIZE, dpcd); in drm_dp_read_extended_dpcd_caps()
959 * @aux: DisplayPort AUX channel
962 * Attempts to read the base DPCD caps for @aux. Additionally, this function
969 int drm_dp_read_dpcd_caps(struct drm_dp_aux *aux, in drm_dp_read_dpcd_caps() argument
974 ret = drm_dp_dpcd_read(aux, DP_DPCD_REV, dpcd, DP_RECEIVER_CAP_SIZE); in drm_dp_read_dpcd_caps()
980 ret = drm_dp_read_extended_dpcd_caps(aux, dpcd); in drm_dp_read_dpcd_caps()
984 drm_dbg_kms(aux->drm_dev, "%s: DPCD: %*ph\n", aux->name, DP_RECEIVER_CAP_SIZE, dpcd); in drm_dp_read_dpcd_caps()
992 * @aux: DisplayPort AUX channel
1003 int drm_dp_read_downstream_info(struct drm_dp_aux *aux, in drm_dp_read_downstream_info() argument
1027 ret = drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, downstream_ports, len); in drm_dp_read_downstream_info()
1033 drm_dbg_kms(aux->drm_dev, "%s: DPCD DFP: %*ph\n", aux->name, len, downstream_ports); in drm_dp_read_downstream_info()
1381 * @aux: DisplayPort AUX channel
1386 int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6]) in drm_dp_downstream_id() argument
1388 return drm_dp_dpcd_read(aux, DP_BRANCH_ID, id, 6); in drm_dp_downstream_id()
1398 * @aux: DisplayPort AUX channel
1405 struct drm_dp_aux *aux) in drm_dp_downstream_debug() argument
1450 drm_dp_downstream_id(aux, id); in drm_dp_downstream_debug()
1453 len = drm_dp_dpcd_read(aux, DP_BRANCH_HW_REV, &rev[0], 1); in drm_dp_downstream_debug()
1458 len = drm_dp_dpcd_read(aux, DP_BRANCH_SW_REV, rev, 2); in drm_dp_downstream_debug()
1585 * @aux: The DP AUX channel to use
1589 * Returns: The current sink count reported by @aux, or a negative error code
1592 int drm_dp_read_sink_count(struct drm_dp_aux *aux) in drm_dp_read_sink_count() argument
1597 ret = drm_dp_dpcd_readb(aux, DP_SINK_COUNT, &count); in drm_dp_read_sink_count()
1608 * I2C-over-AUX implementation
1641 * Calculate the duration of the AUX request/reply in usec. Gives the
1686 /* AUX bitrate is 1MHz, i2c bitrate as specified */ in drm_dp_i2c_msg_duration()
1695 * i2c and AUX transfers.
1717 * Transfer a single I2C-over-AUX message and handle various error conditions,
1724 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
1731 * before giving up the AUX transaction. in drm_dp_i2c_do_msg()
1738 ret = aux->transfer(aux, msg); in drm_dp_i2c_do_msg()
1750 drm_dbg_kms_ratelimited(aux->drm_dev, "%s: transaction timed out\n", in drm_dp_i2c_do_msg()
1751 aux->name); in drm_dp_i2c_do_msg()
1753 drm_dbg_kms(aux->drm_dev, "%s: transaction failed: %d\n", in drm_dp_i2c_do_msg()
1754 aux->name, ret); in drm_dp_i2c_do_msg()
1762 * For I2C-over-AUX transactions this isn't enough, we in drm_dp_i2c_do_msg()
1768 drm_dbg_kms(aux->drm_dev, "%s: native nack (result=%d, size=%zu)\n", in drm_dp_i2c_do_msg()
1769 aux->name, ret, msg->size); in drm_dp_i2c_do_msg()
1773 drm_dbg_kms(aux->drm_dev, "%s: native defer\n", aux->name); in drm_dp_i2c_do_msg()
1787 drm_err(aux->drm_dev, "%s: invalid native reply %#04x\n", in drm_dp_i2c_do_msg()
1788 aux->name, msg->reply); in drm_dp_i2c_do_msg()
1803 drm_dbg_kms(aux->drm_dev, "%s: I2C nack (result=%d, size=%zu)\n", in drm_dp_i2c_do_msg()
1804 aux->name, ret, msg->size); in drm_dp_i2c_do_msg()
1805 aux->i2c_nack_count++; in drm_dp_i2c_do_msg()
1809 drm_dbg_kms(aux->drm_dev, "%s: I2C defer\n", aux->name); in drm_dp_i2c_do_msg()
1814 aux->i2c_defer_count++; in drm_dp_i2c_do_msg()
1823 drm_err(aux->drm_dev, "%s: invalid I2C reply %#04x\n", in drm_dp_i2c_do_msg()
1824 aux->name, msg->reply); in drm_dp_i2c_do_msg()
1829 drm_dbg_kms(aux->drm_dev, "%s: Too many retries, giving up\n", aux->name); in drm_dp_i2c_do_msg()
1847 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
1853 err = drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_drain_msg()
1858 drm_dbg_kms(aux->drm_dev, in drm_dp_i2c_drain_msg()
1860 aux->name, msg.size, err); in drm_dp_i2c_drain_msg()
1872 * Bizlink designed DP->DVI-D Dual Link adapters require the I2C over AUX
1879 "Number of bytes to transfer in a single I2C over DP AUX CH message, (1-16, default 16)");
1884 struct drm_dp_aux *aux = adapter->algo_data; in drm_dp_i2c_xfer() local
1890 if (aux->powered_down) in drm_dp_i2c_xfer()
1906 err = drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_xfer()
1925 err = drm_dp_i2c_drain_msg(aux, &msg); in drm_dp_i2c_xfer()
1949 (void)drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_xfer()
1985 static int drm_dp_aux_get_crc(struct drm_dp_aux *aux, u8 *crc) in drm_dp_aux_get_crc() argument
1990 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_aux_get_crc()
1996 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK_MISC, &buf); in drm_dp_aux_get_crc()
2001 if (count == aux->crc_count) in drm_dp_aux_get_crc()
2004 aux->crc_count = count; in drm_dp_aux_get_crc()
2010 ret = drm_dp_dpcd_read(aux, DP_TEST_CRC_R_CR, crc, 6); in drm_dp_aux_get_crc()
2019 struct drm_dp_aux *aux = container_of(work, struct drm_dp_aux, in drm_dp_aux_crc_work() local
2026 if (WARN_ON(!aux->crtc)) in drm_dp_aux_crc_work()
2029 crtc = aux->crtc; in drm_dp_aux_crc_work()
2035 ret = drm_dp_aux_get_crc(aux, crc_bytes); in drm_dp_aux_crc_work()
2038 ret = drm_dp_aux_get_crc(aux, crc_bytes); in drm_dp_aux_crc_work()
2042 drm_dbg_kms(aux->drm_dev, "%s: Get CRC failed after retrying: %d\n", in drm_dp_aux_crc_work()
2043 aux->name, ret); in drm_dp_aux_crc_work()
2046 drm_dbg_kms(aux->drm_dev, "%s: Failed to get a CRC: %d\n", aux->name, ret); in drm_dp_aux_crc_work()
2058 * drm_dp_remote_aux_init() - minimally initialise a remote aux channel
2059 * @aux: DisplayPort AUX channel
2061 * Used for remote aux channel in general. Merely initialize the crc work
2064 void drm_dp_remote_aux_init(struct drm_dp_aux *aux) in drm_dp_remote_aux_init() argument
2066 INIT_WORK(&aux->crc_work, drm_dp_aux_crc_work); in drm_dp_remote_aux_init()
2071 * drm_dp_aux_init() - minimally initialise an aux channel
2072 * @aux: DisplayPort AUX channel
2076 * grandparents to their AUX adapters (e.g. the AUX adapter is parented by a
2080 * early as possible so that the &drm_device that corresponds to the AUX adapter
2083 * For devices which use a separate platform device for their AUX adapters, this
2087 void drm_dp_aux_init(struct drm_dp_aux *aux) in drm_dp_aux_init() argument
2089 mutex_init(&aux->hw_mutex); in drm_dp_aux_init()
2090 mutex_init(&aux->cec.lock); in drm_dp_aux_init()
2091 INIT_WORK(&aux->crc_work, drm_dp_aux_crc_work); in drm_dp_aux_init()
2093 aux->ddc.algo = &drm_dp_i2c_algo; in drm_dp_aux_init()
2094 aux->ddc.algo_data = aux; in drm_dp_aux_init()
2095 aux->ddc.retries = 3; in drm_dp_aux_init()
2097 aux->ddc.lock_ops = &drm_dp_i2c_lock_ops; in drm_dp_aux_init()
2102 * drm_dp_aux_register() - initialise and register aux channel
2103 * @aux: DisplayPort AUX channel
2106 * should only be called once the parent of @aux, &drm_dp_aux.dev, is
2107 * initialized. For devices which are grandparents of their AUX channels,
2109 * corresponds to @aux. For these devices, it's advised to call
2115 * For devices where the AUX channel is a device that exists independently of
2120 * with the AUX channel (e.g. on bridge detach).
2122 * Drivers which need to use the aux channel before either of the two points
2123 * mentioned above need to call drm_dp_aux_init() in order to use the AUX
2128 int drm_dp_aux_register(struct drm_dp_aux *aux) in drm_dp_aux_register() argument
2132 WARN_ON_ONCE(!aux->drm_dev); in drm_dp_aux_register()
2134 if (!aux->ddc.algo) in drm_dp_aux_register()
2135 drm_dp_aux_init(aux); in drm_dp_aux_register()
2137 aux->ddc.class = I2C_CLASS_DDC; in drm_dp_aux_register()
2138 aux->ddc.owner = THIS_MODULE; in drm_dp_aux_register()
2139 aux->ddc.dev.parent = aux->dev; in drm_dp_aux_register()
2141 strscpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev), in drm_dp_aux_register()
2142 sizeof(aux->ddc.name)); in drm_dp_aux_register()
2144 ret = drm_dp_aux_register_devnode(aux); in drm_dp_aux_register()
2148 ret = i2c_add_adapter(&aux->ddc); in drm_dp_aux_register()
2150 drm_dp_aux_unregister_devnode(aux); in drm_dp_aux_register()
2159 * drm_dp_aux_unregister() - unregister an AUX adapter
2160 * @aux: DisplayPort AUX channel
2162 void drm_dp_aux_unregister(struct drm_dp_aux *aux) in drm_dp_aux_unregister() argument
2164 drm_dp_aux_unregister_devnode(aux); in drm_dp_aux_unregister()
2165 i2c_del_adapter(&aux->ddc); in drm_dp_aux_unregister()
2204 * @aux: DisplayPort AUX channel
2209 int drm_dp_start_crc(struct drm_dp_aux *aux, struct drm_crtc *crtc) in drm_dp_start_crc() argument
2214 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_start_crc()
2218 ret = drm_dp_dpcd_writeb(aux, DP_TEST_SINK, buf | DP_TEST_SINK_START); in drm_dp_start_crc()
2222 aux->crc_count = 0; in drm_dp_start_crc()
2223 aux->crtc = crtc; in drm_dp_start_crc()
2224 schedule_work(&aux->crc_work); in drm_dp_start_crc()
2232 * @aux: DisplayPort AUX channel
2236 int drm_dp_stop_crc(struct drm_dp_aux *aux) in drm_dp_stop_crc() argument
2241 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_stop_crc()
2245 ret = drm_dp_dpcd_writeb(aux, DP_TEST_SINK, buf & ~DP_TEST_SINK_START); in drm_dp_stop_crc()
2249 flush_work(&aux->crc_work); in drm_dp_stop_crc()
2250 aux->crtc = NULL; in drm_dp_stop_crc()
2326 * @aux: DisplayPort AUX channel
2335 int drm_dp_read_desc(struct drm_dp_aux *aux, struct drm_dp_desc *desc, in drm_dp_read_desc() argument
2342 ret = drm_dp_dpcd_read(aux, offset, ident, sizeof(*ident)); in drm_dp_read_desc()
2350 drm_dbg_kms(aux->drm_dev, in drm_dp_read_desc()
2352 aux->name, is_branch ? "branch" : "sink", in drm_dp_read_desc()
2498 static int drm_dp_read_lttpr_regs(struct drm_dp_aux *aux, in drm_dp_read_lttpr_regs() argument
2512 ret = drm_dp_dpcd_read(aux, in drm_dp_read_lttpr_regs()
2526 * @aux: DisplayPort AUX channel
2534 int drm_dp_read_lttpr_common_caps(struct drm_dp_aux *aux, in drm_dp_read_lttpr_common_caps() argument
2538 return drm_dp_read_lttpr_regs(aux, dpcd, in drm_dp_read_lttpr_common_caps()
2546 * @aux: DisplayPort AUX channel
2555 int drm_dp_read_lttpr_phy_caps(struct drm_dp_aux *aux, in drm_dp_read_lttpr_phy_caps() argument
2560 return drm_dp_read_lttpr_regs(aux, dpcd, in drm_dp_read_lttpr_phy_caps()
2661 * @aux: DisplayPort AUX channel
2666 int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux, in drm_dp_get_phy_test_pattern() argument
2672 err = drm_dp_dpcd_readb(aux, DP_TEST_LINK_RATE, &rate); in drm_dp_get_phy_test_pattern()
2677 err = drm_dp_dpcd_readb(aux, DP_TEST_LANE_COUNT, &lanes); in drm_dp_get_phy_test_pattern()
2685 err = drm_dp_dpcd_readb(aux, DP_PHY_TEST_PATTERN, &data->phy_pattern); in drm_dp_get_phy_test_pattern()
2691 err = drm_dp_dpcd_read(aux, DP_TEST_80BIT_CUSTOM_PATTERN_7_0, in drm_dp_get_phy_test_pattern()
2698 err = drm_dp_dpcd_read(aux, DP_TEST_HBR2_SCRAMBLER_RESET, in drm_dp_get_phy_test_pattern()
2711 * @aux: DisplayPort AUX channel
2717 int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux, in drm_dp_set_phy_test_pattern() argument
2727 err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET, in drm_dp_set_phy_test_pattern()
2733 err = drm_dp_dpcd_writeb(aux, in drm_dp_set_phy_test_pattern()
2960 * @aux: DisplayPort AUX channel
2965 int drm_dp_pcon_frl_prepare(struct drm_dp_aux *aux, bool enable_frl_ready_hpd) in drm_dp_pcon_frl_prepare() argument
2974 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); in drm_dp_pcon_frl_prepare()
2982 * @aux: DisplayPort AUX channel
2986 bool drm_dp_pcon_is_frl_ready(struct drm_dp_aux *aux) in drm_dp_pcon_is_frl_ready() argument
2991 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_TX_LINK_STATUS, &buf); in drm_dp_pcon_is_frl_ready()
3004 * @aux: DisplayPort AUX channel
3014 int drm_dp_pcon_frl_configure_1(struct drm_dp_aux *aux, int max_frl_gbps, in drm_dp_pcon_frl_configure_1() argument
3020 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_LINK_CONFIG_1, &buf); in drm_dp_pcon_frl_configure_1()
3055 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); in drm_dp_pcon_frl_configure_1()
3065 * @aux: DisplayPort AUX channel
3074 int drm_dp_pcon_frl_configure_2(struct drm_dp_aux *aux, int max_frl_mask, in drm_dp_pcon_frl_configure_2() argument
3085 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_2, buf); in drm_dp_pcon_frl_configure_2()
3095 * @aux: DisplayPort AUX channel
3099 int drm_dp_pcon_reset_frl_config(struct drm_dp_aux *aux) in drm_dp_pcon_reset_frl_config() argument
3103 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, 0x0); in drm_dp_pcon_reset_frl_config()
3113 * @aux: DisplayPort AUX channel
3117 int drm_dp_pcon_frl_enable(struct drm_dp_aux *aux) in drm_dp_pcon_frl_enable() argument
3122 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_LINK_CONFIG_1, &buf); in drm_dp_pcon_frl_enable()
3126 drm_dbg_kms(aux->drm_dev, "%s: PCON in Autonomous mode, can't enable FRL\n", in drm_dp_pcon_frl_enable()
3127 aux->name); in drm_dp_pcon_frl_enable()
3131 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); in drm_dp_pcon_frl_enable()
3141 * @aux: DisplayPort AUX channel
3145 bool drm_dp_pcon_hdmi_link_active(struct drm_dp_aux *aux) in drm_dp_pcon_hdmi_link_active() argument
3150 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_TX_LINK_STATUS, &buf); in drm_dp_pcon_hdmi_link_active()
3160 * @aux: DisplayPort AUX channel
3169 int drm_dp_pcon_hdmi_link_mode(struct drm_dp_aux *aux, u8 *frl_trained_mask) in drm_dp_pcon_hdmi_link_mode() argument
3175 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_POST_FRL_STATUS, &buf); in drm_dp_pcon_hdmi_link_mode()
3191 * @aux: DisplayPort AUX channel
3196 void drm_dp_pcon_hdmi_frl_link_error_count(struct drm_dp_aux *aux, in drm_dp_pcon_hdmi_frl_link_error_count() argument
3204 if (drm_dp_dpcd_readb(aux, DP_PCON_HDMI_ERROR_STATUS_LN0 + i, &buf) < 0) in drm_dp_pcon_hdmi_frl_link_error_count()
3222 drm_err(aux->drm_dev, "%s: More than %d errors since the last read for lane %d", in drm_dp_pcon_hdmi_frl_link_error_count()
3223 aux->name, num_error, i); in drm_dp_pcon_hdmi_frl_link_error_count()
3334 int drm_dp_pcon_configure_dsc_enc(struct drm_dp_aux *aux, u8 pps_buf_config) in drm_dp_pcon_configure_dsc_enc() argument
3339 ret = drm_dp_dpcd_readb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, &buf); in drm_dp_pcon_configure_dsc_enc()
3350 ret = drm_dp_dpcd_writeb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, buf); in drm_dp_pcon_configure_dsc_enc()
3360 * @aux: DisplayPort AUX channel
3364 int drm_dp_pcon_pps_default(struct drm_dp_aux *aux) in drm_dp_pcon_pps_default() argument
3368 ret = drm_dp_pcon_configure_dsc_enc(aux, DP_PCON_ENC_PPS_OVERRIDE_DISABLED); in drm_dp_pcon_pps_default()
3379 * @aux: DisplayPort AUX channel
3384 int drm_dp_pcon_pps_override_buf(struct drm_dp_aux *aux, u8 pps_buf[128]) in drm_dp_pcon_pps_override_buf() argument
3388 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVERRIDE_BASE, &pps_buf, 128); in drm_dp_pcon_pps_override_buf()
3392 ret = drm_dp_pcon_configure_dsc_enc(aux, DP_PCON_ENC_PPS_OVERRIDE_EN_BUFFER); in drm_dp_pcon_pps_override_buf()
3403 * @aux: DisplayPort AUX channel
3409 int drm_dp_pcon_pps_override_param(struct drm_dp_aux *aux, u8 pps_param[6]) in drm_dp_pcon_pps_override_param() argument
3413 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVRD_SLICE_HEIGHT, &pps_param[0], 2); in drm_dp_pcon_pps_override_param()
3416 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVRD_SLICE_WIDTH, &pps_param[2], 2); in drm_dp_pcon_pps_override_param()
3419 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVRD_BPP, &pps_param[4], 2); in drm_dp_pcon_pps_override_param()
3423 ret = drm_dp_pcon_configure_dsc_enc(aux, DP_PCON_ENC_PPS_OVERRIDE_EN_BUFFER); in drm_dp_pcon_pps_override_param()
3433 * @aux: displayPort AUX channel
3438 int drm_dp_pcon_convert_rgb_to_ycbcr(struct drm_dp_aux *aux, u8 color_spc) in drm_dp_pcon_convert_rgb_to_ycbcr() argument
3443 ret = drm_dp_dpcd_readb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, &buf); in drm_dp_pcon_convert_rgb_to_ycbcr()
3452 ret = drm_dp_dpcd_writeb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, buf); in drm_dp_pcon_convert_rgb_to_ycbcr()
3461 * drm_edp_backlight_set_level() - Set the backlight level of an eDP panel via AUX
3462 * @aux: The DP AUX channel to use
3471 int drm_edp_backlight_set_level(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl, in drm_edp_backlight_set_level() argument
3488 ret = drm_dp_dpcd_write(aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, buf, sizeof(buf)); in drm_edp_backlight_set_level()
3490 drm_err(aux->drm_dev, in drm_edp_backlight_set_level()
3491 "%s: Failed to write aux backlight level: %d\n", in drm_edp_backlight_set_level()
3492 aux->name, ret); in drm_edp_backlight_set_level()
3501 drm_edp_backlight_set_enable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl, in drm_edp_backlight_set_enable() argument
3511 ret = drm_dp_dpcd_readb(aux, DP_EDP_DISPLAY_CONTROL_REGISTER, &buf); in drm_edp_backlight_set_enable()
3513 drm_err(aux->drm_dev, "%s: Failed to read eDP display control register: %d\n", in drm_edp_backlight_set_enable()
3514 aux->name, ret); in drm_edp_backlight_set_enable()
3522 ret = drm_dp_dpcd_writeb(aux, DP_EDP_DISPLAY_CONTROL_REGISTER, buf); in drm_edp_backlight_set_enable()
3524 drm_err(aux->drm_dev, "%s: Failed to write eDP display control register: %d\n", in drm_edp_backlight_set_enable()
3525 aux->name, ret); in drm_edp_backlight_set_enable()
3534 * @aux: The DP AUX channel to use
3536 * @level: The initial backlight level to set via AUX, if there is one
3550 int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl, in drm_edp_backlight_enable() argument
3562 ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count); in drm_edp_backlight_enable()
3564 drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n", in drm_edp_backlight_enable()
3565 aux->name, ret); in drm_edp_backlight_enable()
3569 ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_FREQ_SET, bl->pwm_freq_pre_divider); in drm_edp_backlight_enable()
3571 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_enable()
3572 "%s: Failed to write aux backlight frequency: %d\n", in drm_edp_backlight_enable()
3573 aux->name, ret); in drm_edp_backlight_enable()
3578 ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf); in drm_edp_backlight_enable()
3580 drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n", in drm_edp_backlight_enable()
3581 aux->name, ret); in drm_edp_backlight_enable()
3585 ret = drm_edp_backlight_set_level(aux, bl, level); in drm_edp_backlight_enable()
3588 ret = drm_edp_backlight_set_enable(aux, bl, true); in drm_edp_backlight_enable()
3598 * @aux: The DP AUX channel to use
3601 * This function handles disabling DPCD backlight controls on a panel over AUX.
3611 int drm_edp_backlight_disable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl) in drm_edp_backlight_disable() argument
3615 ret = drm_edp_backlight_set_enable(aux, bl, false); in drm_edp_backlight_disable()
3624 drm_edp_backlight_probe_max(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl, in drm_edp_backlight_probe_max() argument
3634 ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT, &pn); in drm_edp_backlight_probe_max()
3636 drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap: %d\n", in drm_edp_backlight_probe_max()
3637 aux->name, ret); in drm_edp_backlight_probe_max()
3668 ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN, &pn_min); in drm_edp_backlight_probe_max()
3670 drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap min: %d\n", in drm_edp_backlight_probe_max()
3671 aux->name, ret); in drm_edp_backlight_probe_max()
3674 ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MAX, &pn_max); in drm_edp_backlight_probe_max()
3676 drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap max: %d\n", in drm_edp_backlight_probe_max()
3677 aux->name, ret); in drm_edp_backlight_probe_max()
3687 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_probe_max()
3689 aux->name, driver_pwm_freq_hz); in drm_edp_backlight_probe_max()
3700 ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, pn); in drm_edp_backlight_probe_max()
3702 drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n", in drm_edp_backlight_probe_max()
3703 aux->name, ret); in drm_edp_backlight_probe_max()
3711 drm_dbg_kms(aux->drm_dev, "%s: Using backlight frequency from driver (%dHz)\n", in drm_edp_backlight_probe_max()
3712 aux->name, driver_pwm_freq_hz); in drm_edp_backlight_probe_max()
3719 drm_edp_backlight_probe_state(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl, in drm_edp_backlight_probe_state() argument
3726 ret = drm_dp_dpcd_readb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &mode_reg); in drm_edp_backlight_probe_state()
3728 drm_dbg_kms(aux->drm_dev, "%s: Failed to read backlight mode: %d\n", in drm_edp_backlight_probe_state()
3729 aux->name, ret); in drm_edp_backlight_probe_state()
3740 ret = drm_dp_dpcd_read(aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, buf, size); in drm_edp_backlight_probe_state()
3742 drm_dbg_kms(aux->drm_dev, "%s: Failed to read backlight level: %d\n", in drm_edp_backlight_probe_state()
3743 aux->name, ret); in drm_edp_backlight_probe_state()
3763 * @aux: The DP aux device to use for probing
3770 * Initializes a &drm_edp_backlight_info struct by probing @aux for it's backlight capabilities,
3779 drm_edp_backlight_init(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl, in drm_edp_backlight_init() argument
3794 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_init()
3795 "%s: Panel supports neither AUX or PWM brightness control? Aborting\n", in drm_edp_backlight_init()
3796 aux->name); in drm_edp_backlight_init()
3800 ret = drm_edp_backlight_probe_max(aux, bl, driver_pwm_freq_hz, edp_dpcd); in drm_edp_backlight_init()
3804 ret = drm_edp_backlight_probe_state(aux, bl, current_mode); in drm_edp_backlight_init()
3809 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_init()
3811 aux->name, bl->aux_set, bl->aux_enable, *current_mode); in drm_edp_backlight_init()
3813 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_init()
3815 aux->name, *current_level, bl->max, bl->pwm_freq_pre_divider, in drm_edp_backlight_init()
3834 drm_edp_backlight_enable(bl->aux, &bl->info, brightness); in dp_aux_backlight_update_status()
3838 ret = drm_edp_backlight_set_level(bl->aux, &bl->info, brightness); in dp_aux_backlight_update_status()
3841 drm_edp_backlight_disable(bl->aux, &bl->info); in dp_aux_backlight_update_status()
3854 * drm_panel_dp_aux_backlight - create and use DP AUX backlight
3856 * @aux: The DP AUX channel to use
3859 * supports backlight control over DP AUX channel using DPCD
3869 * control over DP AUX will call this function at probe time.
3877 int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) in drm_panel_dp_aux_backlight() argument
3886 if (!panel || !panel->dev || !aux) in drm_panel_dp_aux_backlight()
3889 ret = drm_dp_dpcd_read(aux, DP_EDP_DPCD_REV, edp_dpcd, in drm_panel_dp_aux_backlight()
3895 DRM_DEV_INFO(panel->dev, "DP AUX backlight is not supported\n"); in drm_panel_dp_aux_backlight()
3903 bl->aux = aux; in drm_panel_dp_aux_backlight()
3905 ret = drm_edp_backlight_init(aux, &bl->info, 0, edp_dpcd, in drm_panel_dp_aux_backlight()