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()
538 * aux i2c transactions but real world devices this wasn't in drm_dp_dpcd_access()
547 ret = aux->transfer(aux, &msg); in drm_dp_dpcd_access()
568 drm_dbg_kms(aux->drm_dev, "%s: Too many retries, giving up. First error: %d\n", in drm_dp_dpcd_access()
569 aux->name, err); in drm_dp_dpcd_access()
573 mutex_unlock(&aux->hw_mutex); in drm_dp_dpcd_access()
579 * @aux: DisplayPort AUX channel (SST)
588 int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset) in drm_dp_dpcd_probe() argument
593 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1); in drm_dp_dpcd_probe()
596 drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, ret); in drm_dp_dpcd_probe()
604 * @aux: DisplayPort AUX channel (SST or MST)
612 * function returns -EPROTO. Errors from the underlying AUX channel transfer
616 ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, in drm_dp_dpcd_read() argument
633 if (!aux->is_remote) { in drm_dp_dpcd_read()
634 ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV); in drm_dp_dpcd_read()
639 if (aux->is_remote) in drm_dp_dpcd_read()
640 ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size); in drm_dp_dpcd_read()
642 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, in drm_dp_dpcd_read()
645 drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret); in drm_dp_dpcd_read()
652 * @aux: DisplayPort AUX channel (SST or MST)
660 * function returns -EPROTO. Errors from the underlying AUX channel transfer
664 ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, in drm_dp_dpcd_write() argument
669 if (aux->is_remote) in drm_dp_dpcd_write()
670 ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size); in drm_dp_dpcd_write()
672 ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, in drm_dp_dpcd_write()
675 drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret); in drm_dp_dpcd_write()
682 * @aux: DisplayPort AUX channel
688 int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, in drm_dp_dpcd_read_link_status() argument
691 return drm_dp_dpcd_read(aux, DP_LANE0_1_STATUS, status, in drm_dp_dpcd_read_link_status()
698 * @aux: DisplayPort AUX channel
702 * Fetch the AUX DPCD registers for the DPRX or an LTTPR PHY link status. The
709 int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, in drm_dp_dpcd_read_phy_link_status() argument
716 ret = drm_dp_dpcd_read(aux, in drm_dp_dpcd_read_phy_link_status()
729 ret = drm_dp_dpcd_read(aux, in drm_dp_dpcd_read_phy_link_status()
815 * @aux: DisplayPort AUX channel
821 bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, in drm_dp_send_real_edid_checksum() argument
826 if (drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, in drm_dp_send_real_edid_checksum()
828 drm_err(aux->drm_dev, "%s: DPCD failed read at register 0x%x\n", in drm_dp_send_real_edid_checksum()
829 aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR); in drm_dp_send_real_edid_checksum()
834 if (drm_dp_dpcd_read(aux, DP_TEST_REQUEST, &link_edid_read, 1) < 1) { in drm_dp_send_real_edid_checksum()
835 drm_err(aux->drm_dev, "%s: DPCD failed read at register 0x%x\n", in drm_dp_send_real_edid_checksum()
836 aux->name, DP_TEST_REQUEST); in drm_dp_send_real_edid_checksum()
842 drm_dbg_kms(aux->drm_dev, "%s: Source DUT does not support TEST_EDID_READ\n", in drm_dp_send_real_edid_checksum()
843 aux->name); in drm_dp_send_real_edid_checksum()
847 if (drm_dp_dpcd_write(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, in drm_dp_send_real_edid_checksum()
849 drm_err(aux->drm_dev, "%s: DPCD failed write at register 0x%x\n", in drm_dp_send_real_edid_checksum()
850 aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR); in drm_dp_send_real_edid_checksum()
855 if (drm_dp_dpcd_write(aux, DP_TEST_EDID_CHECKSUM, in drm_dp_send_real_edid_checksum()
857 drm_err(aux->drm_dev, "%s: DPCD failed write at register 0x%x\n", in drm_dp_send_real_edid_checksum()
858 aux->name, DP_TEST_EDID_CHECKSUM); in drm_dp_send_real_edid_checksum()
863 if (drm_dp_dpcd_write(aux, DP_TEST_RESPONSE, &test_resp, 1) < 1) { in drm_dp_send_real_edid_checksum()
864 drm_err(aux->drm_dev, "%s: DPCD failed write at register 0x%x\n", in drm_dp_send_real_edid_checksum()
865 aux->name, DP_TEST_RESPONSE); in drm_dp_send_real_edid_checksum()
883 static int drm_dp_read_extended_dpcd_caps(struct drm_dp_aux *aux, in drm_dp_read_extended_dpcd_caps() argument
900 ret = drm_dp_dpcd_read(aux, DP_DP13_DPCD_REV, &dpcd_ext, in drm_dp_read_extended_dpcd_caps()
908 drm_dbg_kms(aux->drm_dev, in drm_dp_read_extended_dpcd_caps()
910 aux->name, dpcd[DP_DPCD_REV], dpcd_ext[DP_DPCD_REV]); in drm_dp_read_extended_dpcd_caps()
917 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()
927 * @aux: DisplayPort AUX channel
930 * Attempts to read the base DPCD caps for @aux. Additionally, this function
937 int drm_dp_read_dpcd_caps(struct drm_dp_aux *aux, in drm_dp_read_dpcd_caps() argument
942 ret = drm_dp_dpcd_read(aux, DP_DPCD_REV, dpcd, DP_RECEIVER_CAP_SIZE); in drm_dp_read_dpcd_caps()
948 ret = drm_dp_read_extended_dpcd_caps(aux, dpcd); in drm_dp_read_dpcd_caps()
952 drm_dbg_kms(aux->drm_dev, "%s: DPCD: %*ph\n", aux->name, DP_RECEIVER_CAP_SIZE, dpcd); in drm_dp_read_dpcd_caps()
960 * @aux: DisplayPort AUX channel
971 int drm_dp_read_downstream_info(struct drm_dp_aux *aux, in drm_dp_read_downstream_info() argument
995 ret = drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, downstream_ports, len); in drm_dp_read_downstream_info()
1001 drm_dbg_kms(aux->drm_dev, "%s: DPCD DFP: %*ph\n", aux->name, len, downstream_ports); in drm_dp_read_downstream_info()
1349 * @aux: DisplayPort AUX channel
1354 int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6]) in drm_dp_downstream_id() argument
1356 return drm_dp_dpcd_read(aux, DP_BRANCH_ID, id, 6); in drm_dp_downstream_id()
1366 * @aux: DisplayPort AUX channel
1373 struct drm_dp_aux *aux) in drm_dp_downstream_debug() argument
1418 drm_dp_downstream_id(aux, id); in drm_dp_downstream_debug()
1421 len = drm_dp_dpcd_read(aux, DP_BRANCH_HW_REV, &rev[0], 1); in drm_dp_downstream_debug()
1426 len = drm_dp_dpcd_read(aux, DP_BRANCH_SW_REV, rev, 2); in drm_dp_downstream_debug()
1553 * @aux: The DP AUX channel to use
1557 * Returns: The current sink count reported by @aux, or a negative error code
1560 int drm_dp_read_sink_count(struct drm_dp_aux *aux) in drm_dp_read_sink_count() argument
1565 ret = drm_dp_dpcd_readb(aux, DP_SINK_COUNT, &count); in drm_dp_read_sink_count()
1576 * I2C-over-AUX implementation
1609 * Calculate the duration of the AUX request/reply in usec. Gives the
1654 /* AUX bitrate is 1MHz, i2c bitrate as specified */ in drm_dp_i2c_msg_duration()
1663 * i2c and AUX transfers.
1685 * Transfer a single I2C-over-AUX message and handle various error conditions,
1692 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
1699 * before giving up the AUX transaction. in drm_dp_i2c_do_msg()
1706 ret = aux->transfer(aux, msg); in drm_dp_i2c_do_msg()
1718 drm_dbg_kms_ratelimited(aux->drm_dev, "%s: transaction timed out\n", in drm_dp_i2c_do_msg()
1719 aux->name); in drm_dp_i2c_do_msg()
1721 drm_dbg_kms(aux->drm_dev, "%s: transaction failed: %d\n", in drm_dp_i2c_do_msg()
1722 aux->name, ret); in drm_dp_i2c_do_msg()
1730 * For I2C-over-AUX transactions this isn't enough, we in drm_dp_i2c_do_msg()
1736 drm_dbg_kms(aux->drm_dev, "%s: native nack (result=%d, size=%zu)\n", in drm_dp_i2c_do_msg()
1737 aux->name, ret, msg->size); in drm_dp_i2c_do_msg()
1741 drm_dbg_kms(aux->drm_dev, "%s: native defer\n", aux->name); in drm_dp_i2c_do_msg()
1755 drm_err(aux->drm_dev, "%s: invalid native reply %#04x\n", in drm_dp_i2c_do_msg()
1756 aux->name, msg->reply); in drm_dp_i2c_do_msg()
1771 drm_dbg_kms(aux->drm_dev, "%s: I2C nack (result=%d, size=%zu)\n", in drm_dp_i2c_do_msg()
1772 aux->name, ret, msg->size); in drm_dp_i2c_do_msg()
1773 aux->i2c_nack_count++; in drm_dp_i2c_do_msg()
1777 drm_dbg_kms(aux->drm_dev, "%s: I2C defer\n", aux->name); in drm_dp_i2c_do_msg()
1782 aux->i2c_defer_count++; in drm_dp_i2c_do_msg()
1791 drm_err(aux->drm_dev, "%s: invalid I2C reply %#04x\n", in drm_dp_i2c_do_msg()
1792 aux->name, msg->reply); in drm_dp_i2c_do_msg()
1797 drm_dbg_kms(aux->drm_dev, "%s: Too many retries, giving up\n", aux->name); in drm_dp_i2c_do_msg()
1815 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
1821 err = drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_drain_msg()
1826 drm_dbg_kms(aux->drm_dev, in drm_dp_i2c_drain_msg()
1828 aux->name, msg.size, err); in drm_dp_i2c_drain_msg()
1840 * Bizlink designed DP->DVI-D Dual Link adapters require the I2C over AUX
1847 "Number of bytes to transfer in a single I2C over DP AUX CH message, (1-16, default 16)");
1852 struct drm_dp_aux *aux = adapter->algo_data; in drm_dp_i2c_xfer() local
1871 err = drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_xfer()
1890 err = drm_dp_i2c_drain_msg(aux, &msg); in drm_dp_i2c_xfer()
1914 (void)drm_dp_i2c_do_msg(aux, &msg); in drm_dp_i2c_xfer()
1950 static int drm_dp_aux_get_crc(struct drm_dp_aux *aux, u8 *crc) in drm_dp_aux_get_crc() argument
1955 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_aux_get_crc()
1961 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK_MISC, &buf); in drm_dp_aux_get_crc()
1966 if (count == aux->crc_count) in drm_dp_aux_get_crc()
1969 aux->crc_count = count; in drm_dp_aux_get_crc()
1975 ret = drm_dp_dpcd_read(aux, DP_TEST_CRC_R_CR, crc, 6); in drm_dp_aux_get_crc()
1984 struct drm_dp_aux *aux = container_of(work, struct drm_dp_aux, in drm_dp_aux_crc_work() local
1991 if (WARN_ON(!aux->crtc)) in drm_dp_aux_crc_work()
1994 crtc = aux->crtc; in drm_dp_aux_crc_work()
2000 ret = drm_dp_aux_get_crc(aux, crc_bytes); in drm_dp_aux_crc_work()
2003 ret = drm_dp_aux_get_crc(aux, crc_bytes); in drm_dp_aux_crc_work()
2007 drm_dbg_kms(aux->drm_dev, "%s: Get CRC failed after retrying: %d\n", in drm_dp_aux_crc_work()
2008 aux->name, ret); in drm_dp_aux_crc_work()
2011 drm_dbg_kms(aux->drm_dev, "%s: Failed to get a CRC: %d\n", aux->name, ret); in drm_dp_aux_crc_work()
2023 * drm_dp_remote_aux_init() - minimally initialise a remote aux channel
2024 * @aux: DisplayPort AUX channel
2026 * Used for remote aux channel in general. Merely initialize the crc work
2029 void drm_dp_remote_aux_init(struct drm_dp_aux *aux) in drm_dp_remote_aux_init() argument
2031 INIT_WORK(&aux->crc_work, drm_dp_aux_crc_work); in drm_dp_remote_aux_init()
2036 * drm_dp_aux_init() - minimally initialise an aux channel
2037 * @aux: DisplayPort AUX channel
2041 * grandparents to their AUX adapters (e.g. the AUX adapter is parented by a
2045 * early as possible so that the &drm_device that corresponds to the AUX adapter
2048 * For devices which use a separate platform device for their AUX adapters, this
2052 void drm_dp_aux_init(struct drm_dp_aux *aux) in drm_dp_aux_init() argument
2054 mutex_init(&aux->hw_mutex); in drm_dp_aux_init()
2055 mutex_init(&aux->cec.lock); in drm_dp_aux_init()
2056 INIT_WORK(&aux->crc_work, drm_dp_aux_crc_work); in drm_dp_aux_init()
2058 aux->ddc.algo = &drm_dp_i2c_algo; in drm_dp_aux_init()
2059 aux->ddc.algo_data = aux; in drm_dp_aux_init()
2060 aux->ddc.retries = 3; in drm_dp_aux_init()
2062 aux->ddc.lock_ops = &drm_dp_i2c_lock_ops; in drm_dp_aux_init()
2067 * drm_dp_aux_register() - initialise and register aux channel
2068 * @aux: DisplayPort AUX channel
2071 * should only be called once the parent of @aux, &drm_dp_aux.dev, is
2072 * initialized. For devices which are grandparents of their AUX channels,
2074 * corresponds to @aux. For these devices, it's advised to call
2080 * For devices where the AUX channel is a device that exists independently of
2085 * with the AUX channel (e.g. on bridge detach).
2087 * Drivers which need to use the aux channel before either of the two points
2088 * mentioned above need to call drm_dp_aux_init() in order to use the AUX
2093 int drm_dp_aux_register(struct drm_dp_aux *aux) in drm_dp_aux_register() argument
2097 WARN_ON_ONCE(!aux->drm_dev); in drm_dp_aux_register()
2099 if (!aux->ddc.algo) in drm_dp_aux_register()
2100 drm_dp_aux_init(aux); in drm_dp_aux_register()
2102 aux->ddc.class = I2C_CLASS_DDC; in drm_dp_aux_register()
2103 aux->ddc.owner = THIS_MODULE; in drm_dp_aux_register()
2104 aux->ddc.dev.parent = aux->dev; in drm_dp_aux_register()
2106 strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev), in drm_dp_aux_register()
2107 sizeof(aux->ddc.name)); in drm_dp_aux_register()
2109 ret = drm_dp_aux_register_devnode(aux); in drm_dp_aux_register()
2113 ret = i2c_add_adapter(&aux->ddc); in drm_dp_aux_register()
2115 drm_dp_aux_unregister_devnode(aux); in drm_dp_aux_register()
2124 * drm_dp_aux_unregister() - unregister an AUX adapter
2125 * @aux: DisplayPort AUX channel
2127 void drm_dp_aux_unregister(struct drm_dp_aux *aux) in drm_dp_aux_unregister() argument
2129 drm_dp_aux_unregister_devnode(aux); in drm_dp_aux_unregister()
2130 i2c_del_adapter(&aux->ddc); in drm_dp_aux_unregister()
2169 * @aux: DisplayPort AUX channel
2174 int drm_dp_start_crc(struct drm_dp_aux *aux, struct drm_crtc *crtc) in drm_dp_start_crc() argument
2179 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_start_crc()
2183 ret = drm_dp_dpcd_writeb(aux, DP_TEST_SINK, buf | DP_TEST_SINK_START); in drm_dp_start_crc()
2187 aux->crc_count = 0; in drm_dp_start_crc()
2188 aux->crtc = crtc; in drm_dp_start_crc()
2189 schedule_work(&aux->crc_work); in drm_dp_start_crc()
2197 * @aux: DisplayPort AUX channel
2201 int drm_dp_stop_crc(struct drm_dp_aux *aux) in drm_dp_stop_crc() argument
2206 ret = drm_dp_dpcd_readb(aux, DP_TEST_SINK, &buf); in drm_dp_stop_crc()
2210 ret = drm_dp_dpcd_writeb(aux, DP_TEST_SINK, buf & ~DP_TEST_SINK_START); in drm_dp_stop_crc()
2214 flush_work(&aux->crc_work); in drm_dp_stop_crc()
2215 aux->crtc = NULL; in drm_dp_stop_crc()
2291 * @aux: DisplayPort AUX channel
2300 int drm_dp_read_desc(struct drm_dp_aux *aux, struct drm_dp_desc *desc, in drm_dp_read_desc() argument
2307 ret = drm_dp_dpcd_read(aux, offset, ident, sizeof(*ident)); in drm_dp_read_desc()
2315 drm_dbg_kms(aux->drm_dev, in drm_dp_read_desc()
2317 aux->name, is_branch ? "branch" : "sink", in drm_dp_read_desc()
2463 static int drm_dp_read_lttpr_regs(struct drm_dp_aux *aux, in drm_dp_read_lttpr_regs() argument
2477 ret = drm_dp_dpcd_read(aux, in drm_dp_read_lttpr_regs()
2491 * @aux: DisplayPort AUX channel
2499 int drm_dp_read_lttpr_common_caps(struct drm_dp_aux *aux, in drm_dp_read_lttpr_common_caps() argument
2503 return drm_dp_read_lttpr_regs(aux, dpcd, in drm_dp_read_lttpr_common_caps()
2511 * @aux: DisplayPort AUX channel
2520 int drm_dp_read_lttpr_phy_caps(struct drm_dp_aux *aux, in drm_dp_read_lttpr_phy_caps() argument
2525 return drm_dp_read_lttpr_regs(aux, dpcd, in drm_dp_read_lttpr_phy_caps()
2626 * @aux: DisplayPort AUX channel
2631 int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux, in drm_dp_get_phy_test_pattern() argument
2637 err = drm_dp_dpcd_readb(aux, DP_TEST_LINK_RATE, &rate); in drm_dp_get_phy_test_pattern()
2642 err = drm_dp_dpcd_readb(aux, DP_TEST_LANE_COUNT, &lanes); in drm_dp_get_phy_test_pattern()
2650 err = drm_dp_dpcd_readb(aux, DP_PHY_TEST_PATTERN, &data->phy_pattern); in drm_dp_get_phy_test_pattern()
2656 err = drm_dp_dpcd_read(aux, DP_TEST_80BIT_CUSTOM_PATTERN_7_0, in drm_dp_get_phy_test_pattern()
2663 err = drm_dp_dpcd_read(aux, DP_TEST_HBR2_SCRAMBLER_RESET, in drm_dp_get_phy_test_pattern()
2676 * @aux: DisplayPort AUX channel
2682 int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux, in drm_dp_set_phy_test_pattern() argument
2692 err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET, in drm_dp_set_phy_test_pattern()
2698 err = drm_dp_dpcd_writeb(aux, in drm_dp_set_phy_test_pattern()
2925 * @aux: DisplayPort AUX channel
2930 int drm_dp_pcon_frl_prepare(struct drm_dp_aux *aux, bool enable_frl_ready_hpd) in drm_dp_pcon_frl_prepare() argument
2939 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); in drm_dp_pcon_frl_prepare()
2947 * @aux: DisplayPort AUX channel
2951 bool drm_dp_pcon_is_frl_ready(struct drm_dp_aux *aux) in drm_dp_pcon_is_frl_ready() argument
2956 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_TX_LINK_STATUS, &buf); in drm_dp_pcon_is_frl_ready()
2969 * @aux: DisplayPort AUX channel
2979 int drm_dp_pcon_frl_configure_1(struct drm_dp_aux *aux, int max_frl_gbps, in drm_dp_pcon_frl_configure_1() argument
2985 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_LINK_CONFIG_1, &buf); in drm_dp_pcon_frl_configure_1()
3020 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); in drm_dp_pcon_frl_configure_1()
3030 * @aux: DisplayPort AUX channel
3039 int drm_dp_pcon_frl_configure_2(struct drm_dp_aux *aux, int max_frl_mask, in drm_dp_pcon_frl_configure_2() argument
3050 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_2, buf); in drm_dp_pcon_frl_configure_2()
3060 * @aux: DisplayPort AUX channel
3064 int drm_dp_pcon_reset_frl_config(struct drm_dp_aux *aux) in drm_dp_pcon_reset_frl_config() argument
3068 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, 0x0); in drm_dp_pcon_reset_frl_config()
3078 * @aux: DisplayPort AUX channel
3082 int drm_dp_pcon_frl_enable(struct drm_dp_aux *aux) in drm_dp_pcon_frl_enable() argument
3087 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_LINK_CONFIG_1, &buf); in drm_dp_pcon_frl_enable()
3091 drm_dbg_kms(aux->drm_dev, "%s: PCON in Autonomous mode, can't enable FRL\n", in drm_dp_pcon_frl_enable()
3092 aux->name); in drm_dp_pcon_frl_enable()
3096 ret = drm_dp_dpcd_writeb(aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); in drm_dp_pcon_frl_enable()
3106 * @aux: DisplayPort AUX channel
3110 bool drm_dp_pcon_hdmi_link_active(struct drm_dp_aux *aux) in drm_dp_pcon_hdmi_link_active() argument
3115 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_TX_LINK_STATUS, &buf); in drm_dp_pcon_hdmi_link_active()
3125 * @aux: DisplayPort AUX channel
3134 int drm_dp_pcon_hdmi_link_mode(struct drm_dp_aux *aux, u8 *frl_trained_mask) in drm_dp_pcon_hdmi_link_mode() argument
3140 ret = drm_dp_dpcd_readb(aux, DP_PCON_HDMI_POST_FRL_STATUS, &buf); in drm_dp_pcon_hdmi_link_mode()
3156 * @aux: DisplayPort AUX channel
3161 void drm_dp_pcon_hdmi_frl_link_error_count(struct drm_dp_aux *aux, in drm_dp_pcon_hdmi_frl_link_error_count() argument
3169 if (drm_dp_dpcd_readb(aux, DP_PCON_HDMI_ERROR_STATUS_LN0 + i, &buf) < 0) in drm_dp_pcon_hdmi_frl_link_error_count()
3187 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()
3188 aux->name, num_error, i); in drm_dp_pcon_hdmi_frl_link_error_count()
3299 int drm_dp_pcon_configure_dsc_enc(struct drm_dp_aux *aux, u8 pps_buf_config) in drm_dp_pcon_configure_dsc_enc() argument
3304 ret = drm_dp_dpcd_readb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, &buf); in drm_dp_pcon_configure_dsc_enc()
3315 ret = drm_dp_dpcd_writeb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, buf); in drm_dp_pcon_configure_dsc_enc()
3325 * @aux: DisplayPort AUX channel
3329 int drm_dp_pcon_pps_default(struct drm_dp_aux *aux) in drm_dp_pcon_pps_default() argument
3333 ret = drm_dp_pcon_configure_dsc_enc(aux, DP_PCON_ENC_PPS_OVERRIDE_DISABLED); in drm_dp_pcon_pps_default()
3344 * @aux: DisplayPort AUX channel
3349 int drm_dp_pcon_pps_override_buf(struct drm_dp_aux *aux, u8 pps_buf[128]) in drm_dp_pcon_pps_override_buf() argument
3353 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVERRIDE_BASE, &pps_buf, 128); in drm_dp_pcon_pps_override_buf()
3357 ret = drm_dp_pcon_configure_dsc_enc(aux, DP_PCON_ENC_PPS_OVERRIDE_EN_BUFFER); in drm_dp_pcon_pps_override_buf()
3368 * @aux: DisplayPort AUX channel
3374 int drm_dp_pcon_pps_override_param(struct drm_dp_aux *aux, u8 pps_param[6]) in drm_dp_pcon_pps_override_param() argument
3378 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVRD_SLICE_HEIGHT, &pps_param[0], 2); in drm_dp_pcon_pps_override_param()
3381 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVRD_SLICE_WIDTH, &pps_param[2], 2); in drm_dp_pcon_pps_override_param()
3384 ret = drm_dp_dpcd_write(aux, DP_PCON_HDMI_PPS_OVRD_BPP, &pps_param[4], 2); in drm_dp_pcon_pps_override_param()
3388 ret = drm_dp_pcon_configure_dsc_enc(aux, DP_PCON_ENC_PPS_OVERRIDE_EN_BUFFER); in drm_dp_pcon_pps_override_param()
3398 * @aux: displayPort AUX channel
3403 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
3408 ret = drm_dp_dpcd_readb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, &buf); in drm_dp_pcon_convert_rgb_to_ycbcr()
3417 ret = drm_dp_dpcd_writeb(aux, DP_PROTOCOL_CONVERTER_CONTROL_2, buf); in drm_dp_pcon_convert_rgb_to_ycbcr()
3426 * drm_edp_backlight_set_level() - Set the backlight level of an eDP panel via AUX
3427 * @aux: The DP AUX channel to use
3436 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
3453 ret = drm_dp_dpcd_write(aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, buf, sizeof(buf)); in drm_edp_backlight_set_level()
3455 drm_err(aux->drm_dev, in drm_edp_backlight_set_level()
3456 "%s: Failed to write aux backlight level: %d\n", in drm_edp_backlight_set_level()
3457 aux->name, ret); in drm_edp_backlight_set_level()
3466 drm_edp_backlight_set_enable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl, in drm_edp_backlight_set_enable() argument
3476 ret = drm_dp_dpcd_readb(aux, DP_EDP_DISPLAY_CONTROL_REGISTER, &buf); in drm_edp_backlight_set_enable()
3478 drm_err(aux->drm_dev, "%s: Failed to read eDP display control register: %d\n", in drm_edp_backlight_set_enable()
3479 aux->name, ret); in drm_edp_backlight_set_enable()
3487 ret = drm_dp_dpcd_writeb(aux, DP_EDP_DISPLAY_CONTROL_REGISTER, buf); in drm_edp_backlight_set_enable()
3489 drm_err(aux->drm_dev, "%s: Failed to write eDP display control register: %d\n", in drm_edp_backlight_set_enable()
3490 aux->name, ret); in drm_edp_backlight_set_enable()
3499 * @aux: The DP AUX channel to use
3501 * @level: The initial backlight level to set via AUX, if there is one
3515 int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl, in drm_edp_backlight_enable() argument
3527 ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count); in drm_edp_backlight_enable()
3529 drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n", in drm_edp_backlight_enable()
3530 aux->name, ret); in drm_edp_backlight_enable()
3534 ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_FREQ_SET, bl->pwm_freq_pre_divider); in drm_edp_backlight_enable()
3536 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_enable()
3537 "%s: Failed to write aux backlight frequency: %d\n", in drm_edp_backlight_enable()
3538 aux->name, ret); in drm_edp_backlight_enable()
3543 ret = drm_dp_dpcd_writeb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, dpcd_buf); in drm_edp_backlight_enable()
3545 drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux backlight mode: %d\n", in drm_edp_backlight_enable()
3546 aux->name, ret); in drm_edp_backlight_enable()
3550 ret = drm_edp_backlight_set_level(aux, bl, level); in drm_edp_backlight_enable()
3553 ret = drm_edp_backlight_set_enable(aux, bl, true); in drm_edp_backlight_enable()
3563 * @aux: The DP AUX channel to use
3566 * This function handles disabling DPCD backlight controls on a panel over AUX.
3576 int drm_edp_backlight_disable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl) in drm_edp_backlight_disable() argument
3580 ret = drm_edp_backlight_set_enable(aux, bl, false); in drm_edp_backlight_disable()
3589 drm_edp_backlight_probe_max(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl, in drm_edp_backlight_probe_max() argument
3599 ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT, &pn); in drm_edp_backlight_probe_max()
3601 drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap: %d\n", in drm_edp_backlight_probe_max()
3602 aux->name, ret); in drm_edp_backlight_probe_max()
3633 ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN, &pn_min); in drm_edp_backlight_probe_max()
3635 drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap min: %d\n", in drm_edp_backlight_probe_max()
3636 aux->name, ret); in drm_edp_backlight_probe_max()
3639 ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MAX, &pn_max); in drm_edp_backlight_probe_max()
3641 drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap max: %d\n", in drm_edp_backlight_probe_max()
3642 aux->name, ret); in drm_edp_backlight_probe_max()
3652 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_probe_max()
3654 aux->name, driver_pwm_freq_hz); in drm_edp_backlight_probe_max()
3665 ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, pn); in drm_edp_backlight_probe_max()
3667 drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n", in drm_edp_backlight_probe_max()
3668 aux->name, ret); in drm_edp_backlight_probe_max()
3676 drm_dbg_kms(aux->drm_dev, "%s: Using backlight frequency from driver (%dHz)\n", in drm_edp_backlight_probe_max()
3677 aux->name, driver_pwm_freq_hz); in drm_edp_backlight_probe_max()
3684 drm_edp_backlight_probe_state(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl, in drm_edp_backlight_probe_state() argument
3691 ret = drm_dp_dpcd_readb(aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &mode_reg); in drm_edp_backlight_probe_state()
3693 drm_dbg_kms(aux->drm_dev, "%s: Failed to read backlight mode: %d\n", in drm_edp_backlight_probe_state()
3694 aux->name, ret); in drm_edp_backlight_probe_state()
3705 ret = drm_dp_dpcd_read(aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB, buf, size); in drm_edp_backlight_probe_state()
3707 drm_dbg_kms(aux->drm_dev, "%s: Failed to read backlight level: %d\n", in drm_edp_backlight_probe_state()
3708 aux->name, ret); in drm_edp_backlight_probe_state()
3728 * @aux: The DP aux device to use for probing
3735 * Initializes a &drm_edp_backlight_info struct by probing @aux for it's backlight capabilities,
3744 drm_edp_backlight_init(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl, in drm_edp_backlight_init() argument
3759 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_init()
3760 "%s: Panel supports neither AUX or PWM brightness control? Aborting\n", in drm_edp_backlight_init()
3761 aux->name); in drm_edp_backlight_init()
3765 ret = drm_edp_backlight_probe_max(aux, bl, driver_pwm_freq_hz, edp_dpcd); in drm_edp_backlight_init()
3769 ret = drm_edp_backlight_probe_state(aux, bl, current_mode); in drm_edp_backlight_init()
3774 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_init()
3776 aux->name, bl->aux_set, bl->aux_enable, *current_mode); in drm_edp_backlight_init()
3778 drm_dbg_kms(aux->drm_dev, in drm_edp_backlight_init()
3780 aux->name, *current_level, bl->max, bl->pwm_freq_pre_divider, in drm_edp_backlight_init()
3799 drm_edp_backlight_enable(bl->aux, &bl->info, brightness); in dp_aux_backlight_update_status()
3803 ret = drm_edp_backlight_set_level(bl->aux, &bl->info, brightness); in dp_aux_backlight_update_status()
3806 drm_edp_backlight_disable(bl->aux, &bl->info); in dp_aux_backlight_update_status()
3819 * drm_panel_dp_aux_backlight - create and use DP AUX backlight
3821 * @aux: The DP AUX channel to use
3824 * supports backlight control over DP AUX channel using DPCD
3834 * control over DP AUX will call this function at probe time.
3842 int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux) in drm_panel_dp_aux_backlight() argument
3851 if (!panel || !panel->dev || !aux) in drm_panel_dp_aux_backlight()
3854 ret = drm_dp_dpcd_read(aux, DP_EDP_DPCD_REV, edp_dpcd, in drm_panel_dp_aux_backlight()
3860 DRM_DEV_INFO(panel->dev, "DP AUX backlight is not supported\n"); in drm_panel_dp_aux_backlight()
3868 bl->aux = aux; in drm_panel_dp_aux_backlight()
3870 ret = drm_edp_backlight_init(aux, &bl->info, 0, edp_dpcd, in drm_panel_dp_aux_backlight()