Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2014 Red Hat. |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 5 | * documentation for any purpose is hereby granted without fee, provided that |
| 6 | * the above copyright notice appear in all copies and that both that copyright |
| 7 | * notice and this permission notice appear in supporting documentation, and |
| 8 | * that the name of the copyright holders not be used in advertising or |
| 9 | * publicity pertaining to distribution of the software without specific, |
| 10 | * written prior permission. The copyright holders make no representations |
| 11 | * about the suitability of this software for any purpose. It is provided "as |
| 12 | * is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 20 | * OF THIS SOFTWARE. |
| 21 | */ |
| 22 | #ifndef _DRM_DP_MST_HELPER_H_ |
| 23 | #define _DRM_DP_MST_HELPER_H_ |
| 24 | |
| 25 | #include <linux/types.h> |
| 26 | #include <drm/drm_dp_helper.h> |
Pandiyan, Dhinakaran | 3f3353b | 2017-04-20 22:51:31 -0700 | [diff] [blame] | 27 | #include <drm/drm_atomic.h> |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 28 | |
Lyude Paul | 12a280c | 2019-06-20 17:59:25 -0400 | [diff] [blame] | 29 | #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS) |
| 30 | #include <linux/stackdepot.h> |
| 31 | #include <linux/timekeeping.h> |
| 32 | |
| 33 | enum drm_dp_mst_topology_ref_type { |
| 34 | DRM_DP_MST_TOPOLOGY_REF_GET, |
| 35 | DRM_DP_MST_TOPOLOGY_REF_PUT, |
| 36 | }; |
| 37 | |
| 38 | struct drm_dp_mst_topology_ref_history { |
| 39 | struct drm_dp_mst_topology_ref_entry { |
| 40 | enum drm_dp_mst_topology_ref_type type; |
| 41 | int count; |
| 42 | ktime_t ts_nsec; |
| 43 | depot_stack_handle_t backtrace; |
| 44 | } *entries; |
| 45 | int len; |
| 46 | }; |
| 47 | #endif /* IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS) */ |
| 48 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 49 | struct drm_dp_mst_branch; |
| 50 | |
| 51 | /** |
Masanari Iida | 32197aa | 2014-10-20 23:53:13 +0900 | [diff] [blame] | 52 | * struct drm_dp_vcpi - Virtual Channel Payload Identifier |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 53 | * @vcpi: Virtual channel ID. |
| 54 | * @pbn: Payload Bandwidth Number for this channel |
| 55 | * @aligned_pbn: PBN aligned with slot size |
| 56 | * @num_slots: number of slots for this PBN |
| 57 | */ |
| 58 | struct drm_dp_vcpi { |
| 59 | int vcpi; |
| 60 | int pbn; |
| 61 | int aligned_pbn; |
| 62 | int num_slots; |
| 63 | }; |
| 64 | |
| 65 | /** |
| 66 | * struct drm_dp_mst_port - MST port |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 67 | * @port_num: port number |
Lyude Paul | 3f9b3f0 | 2019-06-17 17:59:29 -0400 | [diff] [blame] | 68 | * @input: if this port is an input port. Protected by |
| 69 | * &drm_dp_mst_topology_mgr.base.lock. |
| 70 | * @mcs: message capability status - DP 1.2 spec. Protected by |
| 71 | * &drm_dp_mst_topology_mgr.base.lock. |
| 72 | * @ddps: DisplayPort Device Plug Status - DP 1.2. Protected by |
| 73 | * &drm_dp_mst_topology_mgr.base.lock. |
| 74 | * @pdt: Peer Device Type. Protected by |
| 75 | * &drm_dp_mst_topology_mgr.base.lock. |
| 76 | * @ldps: Legacy Device Plug Status. Protected by |
| 77 | * &drm_dp_mst_topology_mgr.base.lock. |
| 78 | * @dpcd_rev: DPCD revision of device on this port. Protected by |
| 79 | * &drm_dp_mst_topology_mgr.base.lock. |
| 80 | * @num_sdp_streams: Number of simultaneous streams. Protected by |
| 81 | * &drm_dp_mst_topology_mgr.base.lock. |
| 82 | * @num_sdp_stream_sinks: Number of stream sinks. Protected by |
| 83 | * &drm_dp_mst_topology_mgr.base.lock. |
Lyude Paul | fcf4638 | 2020-03-06 18:46:20 -0500 | [diff] [blame] | 84 | * @full_pbn: Max possible bandwidth for this port. Protected by |
Lyude Paul | 3f9b3f0 | 2019-06-17 17:59:29 -0400 | [diff] [blame] | 85 | * &drm_dp_mst_topology_mgr.base.lock. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 86 | * @next: link to next port on this branch device |
Lyude Paul | c485e2c | 2019-03-13 13:51:41 -0400 | [diff] [blame] | 87 | * @aux: i2c aux transport to talk to device connected to this port, protected |
Lyude Paul | 3f9b3f0 | 2019-06-17 17:59:29 -0400 | [diff] [blame] | 88 | * by &drm_dp_mst_topology_mgr.base.lock. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 89 | * @parent: branch device parent of this port |
| 90 | * @vcpi: Virtual Channel Payload info for this port. |
Lyude Paul | 3f9b3f0 | 2019-06-17 17:59:29 -0400 | [diff] [blame] | 91 | * @connector: DRM connector this port is connected to. Protected by |
| 92 | * &drm_dp_mst_topology_mgr.base.lock. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 93 | * @mgr: topology manager this port lives under. |
| 94 | * |
| 95 | * This structure represents an MST port endpoint on a device somewhere |
| 96 | * in the MST topology. |
| 97 | */ |
| 98 | struct drm_dp_mst_port { |
Lyude Paul | ebcc0e6 | 2019-01-10 19:53:29 -0500 | [diff] [blame] | 99 | /** |
| 100 | * @topology_kref: refcount for this port's lifetime in the topology, |
| 101 | * only the DP MST helpers should need to touch this |
| 102 | */ |
| 103 | struct kref topology_kref; |
| 104 | |
| 105 | /** |
| 106 | * @malloc_kref: refcount for the memory allocation containing this |
| 107 | * structure. See drm_dp_mst_get_port_malloc() and |
| 108 | * drm_dp_mst_put_port_malloc(). |
| 109 | */ |
| 110 | struct kref malloc_kref; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 111 | |
Lyude Paul | 12a280c | 2019-06-20 17:59:25 -0400 | [diff] [blame] | 112 | #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS) |
| 113 | /** |
| 114 | * @topology_ref_history: A history of each topology |
| 115 | * reference/dereference. See CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS. |
| 116 | */ |
| 117 | struct drm_dp_mst_topology_ref_history topology_ref_history; |
| 118 | #endif |
| 119 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 120 | u8 port_num; |
| 121 | bool input; |
| 122 | bool mcs; |
| 123 | bool ddps; |
| 124 | u8 pdt; |
| 125 | bool ldps; |
| 126 | u8 dpcd_rev; |
| 127 | u8 num_sdp_streams; |
| 128 | u8 num_sdp_stream_sinks; |
Lyude Paul | fcf4638 | 2020-03-06 18:46:20 -0500 | [diff] [blame] | 129 | uint16_t full_pbn; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 130 | struct list_head next; |
Lyude Paul | 14692a3 | 2019-10-16 16:02:59 -0400 | [diff] [blame] | 131 | /** |
| 132 | * @mstb: the branch device connected to this port, if there is one. |
| 133 | * This should be considered protected for reading by |
| 134 | * &drm_dp_mst_topology_mgr.lock. There are two exceptions to this: |
| 135 | * &drm_dp_mst_topology_mgr.up_req_work and |
| 136 | * &drm_dp_mst_topology_mgr.work, which do not grab |
| 137 | * &drm_dp_mst_topology_mgr.lock during reads but are the only |
| 138 | * updaters of this list and are protected from writing concurrently |
| 139 | * by &drm_dp_mst_topology_mgr.probe_lock. |
| 140 | */ |
| 141 | struct drm_dp_mst_branch *mstb; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 142 | struct drm_dp_aux aux; /* i2c bus for this port? */ |
| 143 | struct drm_dp_mst_branch *parent; |
| 144 | |
| 145 | struct drm_dp_vcpi vcpi; |
| 146 | struct drm_connector *connector; |
| 147 | struct drm_dp_mst_topology_mgr *mgr; |
Dave Airlie | c6a0aed | 2014-10-20 16:28:02 +1000 | [diff] [blame] | 148 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 149 | /** |
| 150 | * @cached_edid: for DP logical ports - make tiling work by ensuring |
| 151 | * that the EDID for all connectors is read immediately. |
| 152 | */ |
| 153 | struct edid *cached_edid; |
| 154 | /** |
| 155 | * @has_audio: Tracks whether the sink connector to this port is |
| 156 | * audio-capable. |
| 157 | */ |
Libin Yang | ef8f9be | 2015-12-02 14:09:43 +0800 | [diff] [blame] | 158 | bool has_audio; |
David Francis | a3c2b0f | 2019-06-06 11:20:10 -0400 | [diff] [blame] | 159 | |
Sam Ravnborg | 6c0ac4d | 2020-03-28 14:20:24 +0100 | [diff] [blame] | 160 | /** |
| 161 | * @fec_capable: bool indicating if FEC can be supported up to that |
| 162 | * point in the MST topology. |
| 163 | */ |
David Francis | a3c2b0f | 2019-06-06 11:20:10 -0400 | [diff] [blame] | 164 | bool fec_capable; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 165 | }; |
| 166 | |
Sean Paul | fbc821c | 2020-02-13 16:15:19 -0500 | [diff] [blame] | 167 | /* sideband msg header - not bit struct */ |
| 168 | struct drm_dp_sideband_msg_hdr { |
| 169 | u8 lct; |
| 170 | u8 lcr; |
| 171 | u8 rad[8]; |
| 172 | bool broadcast; |
| 173 | bool path_msg; |
| 174 | u8 msg_len; |
| 175 | bool somt; |
| 176 | bool eomt; |
| 177 | bool seqno; |
| 178 | }; |
| 179 | |
| 180 | struct drm_dp_sideband_msg_rx { |
| 181 | u8 chunk[48]; |
| 182 | u8 msg[256]; |
| 183 | u8 curchunk_len; |
| 184 | u8 curchunk_idx; /* chunk we are parsing now */ |
| 185 | u8 curchunk_hdrlen; |
| 186 | u8 curlen; /* total length of the msg */ |
| 187 | bool have_somt; |
| 188 | bool have_eomt; |
| 189 | struct drm_dp_sideband_msg_hdr initial_hdr; |
| 190 | }; |
| 191 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 192 | /** |
| 193 | * struct drm_dp_mst_branch - MST branch device. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 194 | * @rad: Relative Address to talk to this branch device. |
| 195 | * @lct: Link count total to talk to this branch device. |
| 196 | * @num_ports: number of ports on the branch. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 197 | * @port_parent: pointer to the port parent, NULL if toplevel. |
| 198 | * @mgr: topology manager for this branch device. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 199 | * @link_address_sent: if a link address message has been sent to this device yet. |
Hersen Wu | 5e93b82 | 2016-01-22 17:07:28 -0500 | [diff] [blame] | 200 | * @guid: guid for DP 1.2 branch device. port under this branch can be |
| 201 | * identified by port #. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 202 | * |
| 203 | * This structure represents an MST branch device, there is one |
Hersen Wu | 5e93b82 | 2016-01-22 17:07:28 -0500 | [diff] [blame] | 204 | * primary branch device at the root, along with any other branches connected |
| 205 | * to downstream port of parent branches. |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 206 | */ |
| 207 | struct drm_dp_mst_branch { |
Lyude Paul | ebcc0e6 | 2019-01-10 19:53:29 -0500 | [diff] [blame] | 208 | /** |
| 209 | * @topology_kref: refcount for this branch device's lifetime in the |
| 210 | * topology, only the DP MST helpers should need to touch this |
| 211 | */ |
| 212 | struct kref topology_kref; |
| 213 | |
| 214 | /** |
| 215 | * @malloc_kref: refcount for the memory allocation containing this |
| 216 | * structure. See drm_dp_mst_get_mstb_malloc() and |
| 217 | * drm_dp_mst_put_mstb_malloc(). |
| 218 | */ |
| 219 | struct kref malloc_kref; |
| 220 | |
Lyude Paul | 12a280c | 2019-06-20 17:59:25 -0400 | [diff] [blame] | 221 | #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS) |
| 222 | /** |
| 223 | * @topology_ref_history: A history of each topology |
| 224 | * reference/dereference. See CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS. |
| 225 | */ |
| 226 | struct drm_dp_mst_topology_ref_history topology_ref_history; |
| 227 | #endif |
| 228 | |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 229 | /** |
| 230 | * @destroy_next: linked-list entry used by |
| 231 | * drm_dp_delayed_destroy_work() |
| 232 | */ |
| 233 | struct list_head destroy_next; |
| 234 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 235 | u8 rad[8]; |
| 236 | u8 lct; |
| 237 | int num_ports; |
| 238 | |
Lyude Paul | 14692a3 | 2019-10-16 16:02:59 -0400 | [diff] [blame] | 239 | /** |
| 240 | * @ports: the list of ports on this branch device. This should be |
| 241 | * considered protected for reading by &drm_dp_mst_topology_mgr.lock. |
| 242 | * There are two exceptions to this: |
| 243 | * &drm_dp_mst_topology_mgr.up_req_work and |
| 244 | * &drm_dp_mst_topology_mgr.work, which do not grab |
| 245 | * &drm_dp_mst_topology_mgr.lock during reads but are the only |
| 246 | * updaters of this list and are protected from updating the list |
| 247 | * concurrently by @drm_dp_mst_topology_mgr.probe_lock |
| 248 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 249 | struct list_head ports; |
| 250 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 251 | struct drm_dp_mst_port *port_parent; |
| 252 | struct drm_dp_mst_topology_mgr *mgr; |
| 253 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 254 | bool link_address_sent; |
Hersen Wu | 5e93b82 | 2016-01-22 17:07:28 -0500 | [diff] [blame] | 255 | |
| 256 | /* global unique identifier to identify branch devices */ |
| 257 | u8 guid[16]; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 258 | }; |
| 259 | |
| 260 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 261 | struct drm_dp_nak_reply { |
| 262 | u8 guid[16]; |
| 263 | u8 reason; |
| 264 | u8 nak_data; |
| 265 | }; |
| 266 | |
| 267 | struct drm_dp_link_address_ack_reply { |
| 268 | u8 guid[16]; |
| 269 | u8 nports; |
| 270 | struct drm_dp_link_addr_reply_port { |
| 271 | bool input_port; |
| 272 | u8 peer_device_type; |
| 273 | u8 port_number; |
| 274 | bool mcs; |
| 275 | bool ddps; |
| 276 | bool legacy_device_plug_status; |
| 277 | u8 dpcd_revision; |
| 278 | u8 peer_guid[16]; |
| 279 | u8 num_sdp_streams; |
| 280 | u8 num_sdp_stream_sinks; |
| 281 | } ports[16]; |
| 282 | }; |
| 283 | |
| 284 | struct drm_dp_remote_dpcd_read_ack_reply { |
| 285 | u8 port_number; |
| 286 | u8 num_bytes; |
| 287 | u8 bytes[255]; |
| 288 | }; |
| 289 | |
| 290 | struct drm_dp_remote_dpcd_write_ack_reply { |
| 291 | u8 port_number; |
| 292 | }; |
| 293 | |
| 294 | struct drm_dp_remote_dpcd_write_nak_reply { |
| 295 | u8 port_number; |
| 296 | u8 reason; |
| 297 | u8 bytes_written_before_failure; |
| 298 | }; |
| 299 | |
| 300 | struct drm_dp_remote_i2c_read_ack_reply { |
| 301 | u8 port_number; |
| 302 | u8 num_bytes; |
| 303 | u8 bytes[255]; |
| 304 | }; |
| 305 | |
| 306 | struct drm_dp_remote_i2c_read_nak_reply { |
| 307 | u8 port_number; |
| 308 | u8 nak_reason; |
| 309 | u8 i2c_nak_transaction; |
| 310 | }; |
| 311 | |
| 312 | struct drm_dp_remote_i2c_write_ack_reply { |
| 313 | u8 port_number; |
| 314 | }; |
| 315 | |
Sean Paul | e38c298 | 2020-08-19 10:31:24 -0400 | [diff] [blame] | 316 | struct drm_dp_query_stream_enc_status_ack_reply { |
| 317 | /* Bit[23:16]- Stream Id */ |
| 318 | u8 stream_id; |
| 319 | |
| 320 | /* Bit[15]- Signed */ |
| 321 | bool reply_signed; |
| 322 | |
| 323 | /* Bit[10:8]- Stream Output Sink Type */ |
| 324 | bool unauthorizable_device_present; |
| 325 | bool legacy_device_present; |
| 326 | bool query_capable_device_present; |
| 327 | |
| 328 | /* Bit[12:11]- Stream Output CP Type */ |
| 329 | bool hdcp_1x_device_present; |
| 330 | bool hdcp_2x_device_present; |
| 331 | |
| 332 | /* Bit[4]- Stream Authentication */ |
| 333 | bool auth_completed; |
| 334 | |
| 335 | /* Bit[3]- Stream Encryption */ |
| 336 | bool encryption_enabled; |
| 337 | |
| 338 | /* Bit[2]- Stream Repeater Function Present */ |
| 339 | bool repeater_present; |
| 340 | |
| 341 | /* Bit[1:0]- Stream State */ |
| 342 | u8 state; |
| 343 | }; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 344 | |
Libin Yang | ef8f9be | 2015-12-02 14:09:43 +0800 | [diff] [blame] | 345 | #define DRM_DP_MAX_SDP_STREAMS 16 |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 346 | struct drm_dp_allocate_payload { |
| 347 | u8 port_number; |
| 348 | u8 number_sdp_streams; |
| 349 | u8 vcpi; |
| 350 | u16 pbn; |
Libin Yang | ef8f9be | 2015-12-02 14:09:43 +0800 | [diff] [blame] | 351 | u8 sdp_stream_sink[DRM_DP_MAX_SDP_STREAMS]; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 352 | }; |
| 353 | |
| 354 | struct drm_dp_allocate_payload_ack_reply { |
| 355 | u8 port_number; |
| 356 | u8 vcpi; |
| 357 | u16 allocated_pbn; |
| 358 | }; |
| 359 | |
| 360 | struct drm_dp_connection_status_notify { |
| 361 | u8 guid[16]; |
| 362 | u8 port_number; |
| 363 | bool legacy_device_plug_status; |
| 364 | bool displayport_device_plug_status; |
| 365 | bool message_capability_status; |
| 366 | bool input_port; |
| 367 | u8 peer_device_type; |
| 368 | }; |
| 369 | |
| 370 | struct drm_dp_remote_dpcd_read { |
| 371 | u8 port_number; |
| 372 | u32 dpcd_address; |
| 373 | u8 num_bytes; |
| 374 | }; |
| 375 | |
| 376 | struct drm_dp_remote_dpcd_write { |
| 377 | u8 port_number; |
| 378 | u32 dpcd_address; |
| 379 | u8 num_bytes; |
| 380 | u8 *bytes; |
| 381 | }; |
| 382 | |
Dave Airlie | ae49154 | 2015-10-14 18:51:17 +1000 | [diff] [blame] | 383 | #define DP_REMOTE_I2C_READ_MAX_TRANSACTIONS 4 |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 384 | struct drm_dp_remote_i2c_read { |
| 385 | u8 num_transactions; |
| 386 | u8 port_number; |
Lyude Paul | 2f015ec | 2019-09-03 16:45:45 -0400 | [diff] [blame] | 387 | struct drm_dp_remote_i2c_read_tx { |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 388 | u8 i2c_dev_id; |
| 389 | u8 num_bytes; |
| 390 | u8 *bytes; |
| 391 | u8 no_stop_bit; |
| 392 | u8 i2c_transaction_delay; |
Dave Airlie | ae49154 | 2015-10-14 18:51:17 +1000 | [diff] [blame] | 393 | } transactions[DP_REMOTE_I2C_READ_MAX_TRANSACTIONS]; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 394 | u8 read_i2c_device_id; |
| 395 | u8 num_bytes_read; |
| 396 | }; |
| 397 | |
| 398 | struct drm_dp_remote_i2c_write { |
| 399 | u8 port_number; |
| 400 | u8 write_i2c_device_id; |
| 401 | u8 num_bytes; |
| 402 | u8 *bytes; |
| 403 | }; |
| 404 | |
Sean Paul | e38c298 | 2020-08-19 10:31:24 -0400 | [diff] [blame] | 405 | struct drm_dp_query_stream_enc_status { |
| 406 | u8 stream_id; |
| 407 | u8 client_id[7]; /* 56-bit nonce */ |
| 408 | u8 stream_event; |
| 409 | bool valid_stream_event; |
| 410 | u8 stream_behavior; |
| 411 | u8 valid_stream_behavior; |
| 412 | }; |
| 413 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 414 | /* this covers ENUM_RESOURCES, POWER_DOWN_PHY, POWER_UP_PHY */ |
| 415 | struct drm_dp_port_number_req { |
| 416 | u8 port_number; |
| 417 | }; |
| 418 | |
| 419 | struct drm_dp_enum_path_resources_ack_reply { |
| 420 | u8 port_number; |
David Francis | a3c2b0f | 2019-06-06 11:20:10 -0400 | [diff] [blame] | 421 | bool fec_capable; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 422 | u16 full_payload_bw_number; |
| 423 | u16 avail_payload_bw_number; |
| 424 | }; |
| 425 | |
| 426 | /* covers POWER_DOWN_PHY, POWER_UP_PHY */ |
| 427 | struct drm_dp_port_number_rep { |
| 428 | u8 port_number; |
| 429 | }; |
| 430 | |
| 431 | struct drm_dp_query_payload { |
| 432 | u8 port_number; |
| 433 | u8 vcpi; |
| 434 | }; |
| 435 | |
| 436 | struct drm_dp_resource_status_notify { |
| 437 | u8 port_number; |
| 438 | u8 guid[16]; |
| 439 | u16 available_pbn; |
| 440 | }; |
| 441 | |
| 442 | struct drm_dp_query_payload_ack_reply { |
| 443 | u8 port_number; |
Sean Paul | 268de65 | 2019-08-29 12:52:19 -0400 | [diff] [blame] | 444 | u16 allocated_pbn; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 445 | }; |
| 446 | |
| 447 | struct drm_dp_sideband_msg_req_body { |
| 448 | u8 req_type; |
| 449 | union ack_req { |
| 450 | struct drm_dp_connection_status_notify conn_stat; |
| 451 | struct drm_dp_port_number_req port_num; |
| 452 | struct drm_dp_resource_status_notify resource_stat; |
| 453 | |
| 454 | struct drm_dp_query_payload query_payload; |
| 455 | struct drm_dp_allocate_payload allocate_payload; |
| 456 | |
| 457 | struct drm_dp_remote_dpcd_read dpcd_read; |
| 458 | struct drm_dp_remote_dpcd_write dpcd_write; |
| 459 | |
| 460 | struct drm_dp_remote_i2c_read i2c_read; |
| 461 | struct drm_dp_remote_i2c_write i2c_write; |
Sean Paul | e38c298 | 2020-08-19 10:31:24 -0400 | [diff] [blame] | 462 | |
| 463 | struct drm_dp_query_stream_enc_status enc_status; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 464 | } u; |
| 465 | }; |
| 466 | |
| 467 | struct drm_dp_sideband_msg_reply_body { |
| 468 | u8 reply_type; |
| 469 | u8 req_type; |
| 470 | union ack_replies { |
| 471 | struct drm_dp_nak_reply nak; |
| 472 | struct drm_dp_link_address_ack_reply link_addr; |
| 473 | struct drm_dp_port_number_rep port_number; |
| 474 | |
| 475 | struct drm_dp_enum_path_resources_ack_reply path_resources; |
| 476 | struct drm_dp_allocate_payload_ack_reply allocate_payload; |
| 477 | struct drm_dp_query_payload_ack_reply query_payload; |
| 478 | |
| 479 | struct drm_dp_remote_dpcd_read_ack_reply remote_dpcd_read_ack; |
| 480 | struct drm_dp_remote_dpcd_write_ack_reply remote_dpcd_write_ack; |
| 481 | struct drm_dp_remote_dpcd_write_nak_reply remote_dpcd_write_nack; |
| 482 | |
| 483 | struct drm_dp_remote_i2c_read_ack_reply remote_i2c_read_ack; |
| 484 | struct drm_dp_remote_i2c_read_nak_reply remote_i2c_read_nack; |
| 485 | struct drm_dp_remote_i2c_write_ack_reply remote_i2c_write_ack; |
Sean Paul | e38c298 | 2020-08-19 10:31:24 -0400 | [diff] [blame] | 486 | |
| 487 | struct drm_dp_query_stream_enc_status_ack_reply enc_status; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 488 | } u; |
| 489 | }; |
| 490 | |
| 491 | /* msg is queued to be put into a slot */ |
| 492 | #define DRM_DP_SIDEBAND_TX_QUEUED 0 |
| 493 | /* msg has started transmitting on a slot - still on msgq */ |
| 494 | #define DRM_DP_SIDEBAND_TX_START_SEND 1 |
| 495 | /* msg has finished transmitting on a slot - removed from msgq only in slot */ |
| 496 | #define DRM_DP_SIDEBAND_TX_SENT 2 |
| 497 | /* msg has received a response - removed from slot */ |
| 498 | #define DRM_DP_SIDEBAND_TX_RX 3 |
| 499 | #define DRM_DP_SIDEBAND_TX_TIMEOUT 4 |
| 500 | |
| 501 | struct drm_dp_sideband_msg_tx { |
| 502 | u8 msg[256]; |
| 503 | u8 chunk[48]; |
| 504 | u8 cur_offset; |
| 505 | u8 cur_len; |
| 506 | struct drm_dp_mst_branch *dst; |
| 507 | struct list_head next; |
| 508 | int seqno; |
| 509 | int state; |
| 510 | bool path_msg; |
| 511 | struct drm_dp_sideband_msg_reply_body reply; |
| 512 | }; |
| 513 | |
| 514 | /* sideband msg handler */ |
| 515 | struct drm_dp_mst_topology_mgr; |
| 516 | struct drm_dp_mst_topology_cbs { |
| 517 | /* create a connector for a port */ |
Thierry Reding | 12e6cec | 2014-05-13 11:38:36 +0200 | [diff] [blame] | 518 | struct drm_connector *(*add_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, const char *path); |
Imre Deak | 471bdd0 | 2020-06-04 21:45:00 +0300 | [diff] [blame] | 519 | /* |
| 520 | * Checks for any pending MST interrupts, passing them to MST core for |
| 521 | * processing, the same way an HPD IRQ pulse handler would do this. |
| 522 | * If provided MST core calls this callback from a poll-waiting loop |
| 523 | * when waiting for MST down message replies. The driver is expected |
| 524 | * to guard against a race between this callback and the driver's HPD |
| 525 | * IRQ pulse handler. |
| 526 | */ |
| 527 | void (*poll_hpd_irq)(struct drm_dp_mst_topology_mgr *mgr); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 528 | }; |
| 529 | |
| 530 | #define DP_MAX_PAYLOAD (sizeof(unsigned long) * 8) |
| 531 | |
| 532 | #define DP_PAYLOAD_LOCAL 1 |
| 533 | #define DP_PAYLOAD_REMOTE 2 |
| 534 | #define DP_PAYLOAD_DELETE_LOCAL 3 |
| 535 | |
| 536 | struct drm_dp_payload { |
| 537 | int payload_state; |
| 538 | int start_slot; |
| 539 | int num_slots; |
Dave Airlie | dfda0df | 2014-08-06 16:26:21 +1000 | [diff] [blame] | 540 | int vcpi; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 541 | }; |
| 542 | |
Ville Syrjälä | a4370c7 | 2017-07-12 18:51:02 +0300 | [diff] [blame] | 543 | #define to_dp_mst_topology_state(x) container_of(x, struct drm_dp_mst_topology_state, base) |
| 544 | |
Lyude Paul | eceae14 | 2019-01-10 19:53:41 -0500 | [diff] [blame] | 545 | struct drm_dp_vcpi_allocation { |
| 546 | struct drm_dp_mst_port *port; |
| 547 | int vcpi; |
Mikita Lipski | cd82d82 | 2019-11-06 13:11:23 -0500 | [diff] [blame] | 548 | int pbn; |
Mikita Lipski | 8afb7e6 | 2019-10-28 17:33:32 -0400 | [diff] [blame] | 549 | bool dsc_enabled; |
Lyude Paul | eceae14 | 2019-01-10 19:53:41 -0500 | [diff] [blame] | 550 | struct list_head next; |
| 551 | }; |
| 552 | |
Pandiyan, Dhinakaran | 3f3353b | 2017-04-20 22:51:31 -0700 | [diff] [blame] | 553 | struct drm_dp_mst_topology_state { |
Ville Syrjälä | a4370c7 | 2017-07-12 18:51:02 +0300 | [diff] [blame] | 554 | struct drm_private_state base; |
Lyude Paul | eceae14 | 2019-01-10 19:53:41 -0500 | [diff] [blame] | 555 | struct list_head vcpis; |
Pandiyan, Dhinakaran | 3f3353b | 2017-04-20 22:51:31 -0700 | [diff] [blame] | 556 | struct drm_dp_mst_topology_mgr *mgr; |
Bhawanpreet Lakha | d6c6a76 | 2021-10-25 18:38:22 -0400 | [diff] [blame] | 557 | u8 total_avail_slots; |
| 558 | u8 start_slot; |
Pandiyan, Dhinakaran | 3f3353b | 2017-04-20 22:51:31 -0700 | [diff] [blame] | 559 | }; |
| 560 | |
Ville Syrjälä | a4370c7 | 2017-07-12 18:51:02 +0300 | [diff] [blame] | 561 | #define to_dp_mst_topology_mgr(x) container_of(x, struct drm_dp_mst_topology_mgr, base) |
| 562 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 563 | /** |
| 564 | * struct drm_dp_mst_topology_mgr - DisplayPort MST manager |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 565 | * |
| 566 | * This struct represents the toplevel displayport MST topology manager. |
| 567 | * There should be one instance of this for every MST capable DP connector |
| 568 | * on the GPU. |
| 569 | */ |
| 570 | struct drm_dp_mst_topology_mgr { |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 571 | /** |
Ville Syrjälä | a4370c7 | 2017-07-12 18:51:02 +0300 | [diff] [blame] | 572 | * @base: Base private object for atomic |
| 573 | */ |
| 574 | struct drm_private_obj base; |
| 575 | |
| 576 | /** |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 577 | * @dev: device pointer for adding i2c devices etc. |
| 578 | */ |
Dhinakaran Pandiyan | 7b0a89a | 2017-01-24 15:49:29 -0800 | [diff] [blame] | 579 | struct drm_device *dev; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 580 | /** |
| 581 | * @cbs: callbacks for connector addition and destruction. |
| 582 | */ |
Julia Lawall | 69a0f89 | 2015-12-30 22:20:30 +0100 | [diff] [blame] | 583 | const struct drm_dp_mst_topology_cbs *cbs; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 584 | /** |
| 585 | * @max_dpcd_transaction_bytes: maximum number of bytes to read/write |
| 586 | * in one go. |
| 587 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 588 | int max_dpcd_transaction_bytes; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 589 | /** |
| 590 | * @aux: AUX channel for the DP MST connector this topolgy mgr is |
| 591 | * controlling. |
| 592 | */ |
| 593 | struct drm_dp_aux *aux; |
| 594 | /** |
| 595 | * @max_payloads: maximum number of payloads the GPU can generate. |
| 596 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 597 | int max_payloads; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 598 | /** |
Nikola Cornij | 98025a6 | 2021-04-29 18:11:51 -0400 | [diff] [blame] | 599 | * @max_lane_count: maximum number of lanes the GPU can drive. |
| 600 | */ |
Nikola Cornij | 71b970c | 2021-05-12 17:00:11 -0400 | [diff] [blame] | 601 | int max_lane_count; |
Nikola Cornij | 98025a6 | 2021-04-29 18:11:51 -0400 | [diff] [blame] | 602 | /** |
Nikola Cornij | 71b970c | 2021-05-12 17:00:11 -0400 | [diff] [blame] | 603 | * @max_link_rate: maximum link rate per lane GPU can output, in kHz. |
Nikola Cornij | 98025a6 | 2021-04-29 18:11:51 -0400 | [diff] [blame] | 604 | */ |
Nikola Cornij | 71b970c | 2021-05-12 17:00:11 -0400 | [diff] [blame] | 605 | int max_link_rate; |
Nikola Cornij | 98025a6 | 2021-04-29 18:11:51 -0400 | [diff] [blame] | 606 | /** |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 607 | * @conn_base_id: DRM connector ID this mgr is connected to. Only used |
| 608 | * to build the MST connector path value. |
| 609 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 610 | int conn_base_id; |
| 611 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 612 | /** |
Lyude Paul | 8578336 | 2019-09-03 16:45:56 -0400 | [diff] [blame] | 613 | * @up_req_recv: Message receiver state for up requests. |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 614 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 615 | struct drm_dp_sideband_msg_rx up_req_recv; |
| 616 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 617 | /** |
Lyude Paul | d308a88 | 2020-04-24 14:13:08 -0400 | [diff] [blame] | 618 | * @down_rep_recv: Message receiver state for replies to down |
| 619 | * requests. |
| 620 | */ |
| 621 | struct drm_dp_sideband_msg_rx down_rep_recv; |
| 622 | |
| 623 | /** |
Sean Paul | f794890 | 2019-08-28 20:09:44 -0400 | [diff] [blame] | 624 | * @lock: protects @mst_state, @mst_primary, @dpcd, and |
| 625 | * @payload_id_table_cleared. |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 626 | */ |
| 627 | struct mutex lock; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 628 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 629 | /** |
Lyude Paul | 14692a3 | 2019-10-16 16:02:59 -0400 | [diff] [blame] | 630 | * @probe_lock: Prevents @work and @up_req_work, the only writers of |
| 631 | * &drm_dp_mst_port.mstb and &drm_dp_mst_branch.ports, from racing |
| 632 | * while they update the topology. |
| 633 | */ |
| 634 | struct mutex probe_lock; |
| 635 | |
| 636 | /** |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 637 | * @mst_state: If this manager is enabled for an MST capable port. False |
| 638 | * if no MST sink/branch devices is connected. |
| 639 | */ |
Sean Paul | f794890 | 2019-08-28 20:09:44 -0400 | [diff] [blame] | 640 | bool mst_state : 1; |
| 641 | |
| 642 | /** |
| 643 | * @payload_id_table_cleared: Whether or not we've cleared the payload |
| 644 | * ID table for @mst_primary. Protected by @lock. |
| 645 | */ |
| 646 | bool payload_id_table_cleared : 1; |
| 647 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 648 | /** |
| 649 | * @mst_primary: Pointer to the primary/first branch device. |
| 650 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 651 | struct drm_dp_mst_branch *mst_primary; |
Hersen Wu | 5e93b82 | 2016-01-22 17:07:28 -0500 | [diff] [blame] | 652 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 653 | /** |
| 654 | * @dpcd: Cache of DPCD for primary port. |
| 655 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 656 | u8 dpcd[DP_RECEIVER_CAP_SIZE]; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 657 | /** |
| 658 | * @sink_count: Sink count from DEVICE_SERVICE_IRQ_VECTOR_ESI0. |
| 659 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 660 | u8 sink_count; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 661 | /** |
| 662 | * @pbn_div: PBN to slots divisor. |
| 663 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 664 | int pbn_div; |
Pandiyan, Dhinakaran | a538d61 | 2017-03-16 00:10:24 -0700 | [diff] [blame] | 665 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 666 | /** |
Pandiyan, Dhinakaran | 3f3353b | 2017-04-20 22:51:31 -0700 | [diff] [blame] | 667 | * @funcs: Atomic helper callbacks |
| 668 | */ |
| 669 | const struct drm_private_state_funcs *funcs; |
| 670 | |
| 671 | /** |
Lyude Paul | d308a88 | 2020-04-24 14:13:08 -0400 | [diff] [blame] | 672 | * @qlock: protects @tx_msg_downq and &drm_dp_sideband_msg_tx.state |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 673 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 674 | struct mutex qlock; |
Wayne Lin | 5a64967 | 2020-01-13 17:36:49 +0800 | [diff] [blame] | 675 | |
| 676 | /** |
Lyude Paul | d308a88 | 2020-04-24 14:13:08 -0400 | [diff] [blame] | 677 | * @tx_msg_downq: List of pending down requests |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 678 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 679 | struct list_head tx_msg_downq; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 680 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 681 | /** |
| 682 | * @payload_lock: Protect payload information. |
| 683 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 684 | struct mutex payload_lock; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 685 | /** |
| 686 | * @proposed_vcpis: Array of pointers for the new VCPI allocation. The |
Lyude Paul | a727fe8 | 2020-01-22 14:43:21 -0500 | [diff] [blame] | 687 | * VCPI structure itself is &drm_dp_mst_port.vcpi, and the size of |
| 688 | * this array is determined by @max_payloads. |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 689 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 690 | struct drm_dp_vcpi **proposed_vcpis; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 691 | /** |
Lyude Paul | a727fe8 | 2020-01-22 14:43:21 -0500 | [diff] [blame] | 692 | * @payloads: Array of payloads. The size of this array is determined |
| 693 | * by @max_payloads. |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 694 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 695 | struct drm_dp_payload *payloads; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 696 | /** |
| 697 | * @payload_mask: Elements of @payloads actually in use. Since |
| 698 | * reallocation of active outputs isn't possible gaps can be created by |
| 699 | * disabling outputs out of order compared to how they've been enabled. |
| 700 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 701 | unsigned long payload_mask; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 702 | /** |
| 703 | * @vcpi_mask: Similar to @payload_mask, but for @proposed_vcpis. |
| 704 | */ |
Dave Airlie | dfda0df | 2014-08-06 16:26:21 +1000 | [diff] [blame] | 705 | unsigned long vcpi_mask; |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 706 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 707 | /** |
| 708 | * @tx_waitq: Wait to queue stall for the tx worker. |
| 709 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 710 | wait_queue_head_t tx_waitq; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 711 | /** |
| 712 | * @work: Probe work. |
| 713 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 714 | struct work_struct work; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 715 | /** |
| 716 | * @tx_work: Sideband transmit worker. This can nest within the main |
| 717 | * @work worker for each transaction @work launches. |
| 718 | */ |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 719 | struct work_struct tx_work; |
Dave Airlie | 6b8eeca | 2015-06-15 10:34:28 +1000 | [diff] [blame] | 720 | |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 721 | /** |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 722 | * @destroy_port_list: List of to be destroyed connectors. |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 723 | */ |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 724 | struct list_head destroy_port_list; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 725 | /** |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 726 | * @destroy_branch_device_list: List of to be destroyed branch |
| 727 | * devices. |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 728 | */ |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 729 | struct list_head destroy_branch_device_list; |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 730 | /** |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 731 | * @delayed_destroy_lock: Protects @destroy_port_list and |
| 732 | * @destroy_branch_device_list. |
Daniel Vetter | 132d49d | 2016-07-15 21:48:04 +0200 | [diff] [blame] | 733 | */ |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 734 | struct mutex delayed_destroy_lock; |
Imre Deak | 72822c3 | 2020-06-10 16:47:04 +0300 | [diff] [blame] | 735 | |
| 736 | /** |
| 737 | * @delayed_destroy_wq: Workqueue used for delayed_destroy_work items. |
| 738 | * A dedicated WQ makes it possible to drain any requeued work items |
| 739 | * on it. |
| 740 | */ |
| 741 | struct workqueue_struct *delayed_destroy_wq; |
| 742 | |
Lyude Paul | 7cb12d4 | 2019-02-19 17:41:02 -0500 | [diff] [blame] | 743 | /** |
| 744 | * @delayed_destroy_work: Work item to destroy MST port and branch |
| 745 | * devices, needed to avoid locking inversion. |
| 746 | */ |
| 747 | struct work_struct delayed_destroy_work; |
Lyude Paul | 9408cc9 | 2019-06-17 16:37:18 -0400 | [diff] [blame] | 748 | |
| 749 | /** |
| 750 | * @up_req_list: List of pending up requests from the topology that |
| 751 | * need to be processed, in chronological order. |
| 752 | */ |
| 753 | struct list_head up_req_list; |
| 754 | /** |
| 755 | * @up_req_lock: Protects @up_req_list |
| 756 | */ |
| 757 | struct mutex up_req_lock; |
| 758 | /** |
| 759 | * @up_req_work: Work item to process up requests received from the |
| 760 | * topology. Needed to avoid blocking hotplug handling and sideband |
| 761 | * transmissions. |
| 762 | */ |
| 763 | struct work_struct up_req_work; |
Lyude Paul | 12a280c | 2019-06-20 17:59:25 -0400 | [diff] [blame] | 764 | |
| 765 | #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS) |
| 766 | /** |
| 767 | * @topology_ref_history_lock: protects |
| 768 | * &drm_dp_mst_port.topology_ref_history and |
| 769 | * &drm_dp_mst_branch.topology_ref_history. |
| 770 | */ |
| 771 | struct mutex topology_ref_history_lock; |
| 772 | #endif |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 773 | }; |
| 774 | |
Dhinakaran Pandiyan | 7b0a89a | 2017-01-24 15:49:29 -0800 | [diff] [blame] | 775 | int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, |
| 776 | struct drm_device *dev, struct drm_dp_aux *aux, |
| 777 | int max_dpcd_transaction_bytes, |
Nikola Cornij | 98025a6 | 2021-04-29 18:11:51 -0400 | [diff] [blame] | 778 | int max_payloads, |
Nikola Cornij | 71b970c | 2021-05-12 17:00:11 -0400 | [diff] [blame] | 779 | int max_lane_count, int max_link_rate, |
Nikola Cornij | 98025a6 | 2021-04-29 18:11:51 -0400 | [diff] [blame] | 780 | int conn_base_id); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 781 | |
| 782 | void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr); |
| 783 | |
Lyude Paul | 4b465912 | 2020-08-26 14:24:45 -0400 | [diff] [blame] | 784 | bool drm_dp_read_mst_cap(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE]); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 785 | int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool mst_state); |
| 786 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 787 | int drm_dp_mst_hpd_irq(struct drm_dp_mst_topology_mgr *mgr, u8 *esi, bool *handled); |
| 788 | |
| 789 | |
Lyude Paul | 3f9b3f0 | 2019-06-17 17:59:29 -0400 | [diff] [blame] | 790 | int |
| 791 | drm_dp_mst_detect_port(struct drm_connector *connector, |
| 792 | struct drm_modeset_acquire_ctx *ctx, |
| 793 | struct drm_dp_mst_topology_mgr *mgr, |
| 794 | struct drm_dp_mst_port *port); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 795 | |
| 796 | struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port); |
| 797 | |
Lyude Paul | c869c5f | 2021-04-23 14:43:05 -0400 | [diff] [blame] | 798 | int drm_dp_get_vc_payload_bw(const struct drm_dp_mst_topology_mgr *mgr, |
| 799 | int link_rate, int link_lane_count); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 800 | |
David Francis | dc48529 | 2019-08-21 10:33:26 -0400 | [diff] [blame] | 801 | int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 802 | |
Pandiyan, Dhinakaran | 1e797f5 | 2017-03-16 00:10:26 -0700 | [diff] [blame] | 803 | bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, |
| 804 | struct drm_dp_mst_port *port, int pbn, int slots); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 805 | |
Dave Airlie | 87f5942 | 2015-02-24 09:23:55 +1000 | [diff] [blame] | 806 | int drm_dp_mst_get_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port); |
| 807 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 808 | |
| 809 | void drm_dp_mst_reset_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port); |
| 810 | |
Bhawanpreet Lakha | d6c6a76 | 2021-10-25 18:38:22 -0400 | [diff] [blame] | 811 | void drm_dp_mst_update_slots(struct drm_dp_mst_topology_state *mst_state, uint8_t link_encoding_cap); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 812 | |
| 813 | void drm_dp_mst_deallocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, |
| 814 | struct drm_dp_mst_port *port); |
| 815 | |
| 816 | |
| 817 | int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, |
| 818 | int pbn); |
| 819 | |
| 820 | |
Bhawanpreet Lakha | d6c6a76 | 2021-10-25 18:38:22 -0400 | [diff] [blame] | 821 | int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr, int start_slot); |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 822 | |
| 823 | |
| 824 | int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr); |
| 825 | |
| 826 | int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr); |
| 827 | |
| 828 | void drm_dp_mst_dump_topology(struct seq_file *m, |
| 829 | struct drm_dp_mst_topology_mgr *mgr); |
| 830 | |
| 831 | void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr); |
Lyude Paul | c235316 | 2019-01-08 16:11:29 -0500 | [diff] [blame] | 832 | int __must_check |
Lyude Paul | 6f85f73 | 2019-06-17 19:57:33 -0400 | [diff] [blame] | 833 | drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr, |
| 834 | bool sync); |
Ville Syrjälä | 562836a2 | 2019-07-23 19:28:01 -0400 | [diff] [blame] | 835 | |
| 836 | ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux, |
| 837 | unsigned int offset, void *buffer, size_t size); |
| 838 | ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux, |
| 839 | unsigned int offset, void *buffer, size_t size); |
| 840 | |
| 841 | int drm_dp_mst_connector_late_register(struct drm_connector *connector, |
| 842 | struct drm_dp_mst_port *port); |
| 843 | void drm_dp_mst_connector_early_unregister(struct drm_connector *connector, |
| 844 | struct drm_dp_mst_port *port); |
| 845 | |
Pandiyan, Dhinakaran | 3f3353b | 2017-04-20 22:51:31 -0700 | [diff] [blame] | 846 | struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state, |
| 847 | struct drm_dp_mst_topology_mgr *mgr); |
Lyude Paul | eceae14 | 2019-01-10 19:53:41 -0500 | [diff] [blame] | 848 | int __must_check |
| 849 | drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, |
| 850 | struct drm_dp_mst_topology_mgr *mgr, |
Mikita Lipski | 1c6c1cb | 2019-11-14 16:24:29 -0500 | [diff] [blame] | 851 | struct drm_dp_mst_port *port, int pbn, |
| 852 | int pbn_div); |
Mikita Lipski | 8afb7e6 | 2019-10-28 17:33:32 -0400 | [diff] [blame] | 853 | int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state, |
| 854 | struct drm_dp_mst_port *port, |
| 855 | int pbn, int pbn_div, |
| 856 | bool enable); |
Lyude Paul | eceae14 | 2019-01-10 19:53:41 -0500 | [diff] [blame] | 857 | int __must_check |
Mikita Lipski | 8ec0467 | 2019-11-16 13:32:15 -0500 | [diff] [blame] | 858 | drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, |
| 859 | struct drm_dp_mst_topology_mgr *mgr); |
Lyude Paul | eceae14 | 2019-01-10 19:53:41 -0500 | [diff] [blame] | 860 | int __must_check |
| 861 | drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state, |
| 862 | struct drm_dp_mst_topology_mgr *mgr, |
| 863 | struct drm_dp_mst_port *port); |
Dhinakaran Pandiyan | 0bb9c2b | 2017-09-06 17:14:58 -0700 | [diff] [blame] | 864 | int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr, |
| 865 | struct drm_dp_mst_port *port, bool power_up); |
Sean Paul | e38c298 | 2020-08-19 10:31:24 -0400 | [diff] [blame] | 866 | int drm_dp_send_query_stream_enc_status(struct drm_dp_mst_topology_mgr *mgr, |
| 867 | struct drm_dp_mst_port *port, |
| 868 | struct drm_dp_query_stream_enc_status_ack_reply *status); |
Lyude Paul | eceae14 | 2019-01-10 19:53:41 -0500 | [diff] [blame] | 869 | int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state); |
Pandiyan, Dhinakaran | 3f3353b | 2017-04-20 22:51:31 -0700 | [diff] [blame] | 870 | |
Lyude Paul | ebcc0e6 | 2019-01-10 19:53:29 -0500 | [diff] [blame] | 871 | void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port); |
| 872 | void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port); |
| 873 | |
David Francis | c2bc1b6 | 2019-08-26 09:50:28 -0400 | [diff] [blame] | 874 | struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port); |
| 875 | |
Lyude Paul | bea5c38 | 2019-01-10 19:53:40 -0500 | [diff] [blame] | 876 | extern const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs; |
| 877 | |
| 878 | /** |
| 879 | * __drm_dp_mst_state_iter_get - private atomic state iterator function for |
| 880 | * macro-internal use |
| 881 | * @state: &struct drm_atomic_state pointer |
| 882 | * @mgr: pointer to the &struct drm_dp_mst_topology_mgr iteration cursor |
| 883 | * @old_state: optional pointer to the old &struct drm_dp_mst_topology_state |
| 884 | * iteration cursor |
| 885 | * @new_state: optional pointer to the new &struct drm_dp_mst_topology_state |
| 886 | * iteration cursor |
| 887 | * @i: int iteration cursor, for macro-internal use |
| 888 | * |
| 889 | * Used by for_each_oldnew_mst_mgr_in_state(), |
| 890 | * for_each_old_mst_mgr_in_state(), and for_each_new_mst_mgr_in_state(). Don't |
| 891 | * call this directly. |
| 892 | * |
| 893 | * Returns: |
| 894 | * True if the current &struct drm_private_obj is a &struct |
| 895 | * drm_dp_mst_topology_mgr, false otherwise. |
| 896 | */ |
| 897 | static inline bool |
| 898 | __drm_dp_mst_state_iter_get(struct drm_atomic_state *state, |
| 899 | struct drm_dp_mst_topology_mgr **mgr, |
| 900 | struct drm_dp_mst_topology_state **old_state, |
| 901 | struct drm_dp_mst_topology_state **new_state, |
| 902 | int i) |
| 903 | { |
| 904 | struct __drm_private_objs_state *objs_state = &state->private_objs[i]; |
| 905 | |
| 906 | if (objs_state->ptr->funcs != &drm_dp_mst_topology_state_funcs) |
| 907 | return false; |
| 908 | |
| 909 | *mgr = to_dp_mst_topology_mgr(objs_state->ptr); |
| 910 | if (old_state) |
| 911 | *old_state = to_dp_mst_topology_state(objs_state->old_state); |
| 912 | if (new_state) |
| 913 | *new_state = to_dp_mst_topology_state(objs_state->new_state); |
| 914 | |
| 915 | return true; |
| 916 | } |
| 917 | |
| 918 | /** |
| 919 | * for_each_oldnew_mst_mgr_in_state - iterate over all DP MST topology |
| 920 | * managers in an atomic update |
| 921 | * @__state: &struct drm_atomic_state pointer |
| 922 | * @mgr: &struct drm_dp_mst_topology_mgr iteration cursor |
| 923 | * @old_state: &struct drm_dp_mst_topology_state iteration cursor for the old |
| 924 | * state |
| 925 | * @new_state: &struct drm_dp_mst_topology_state iteration cursor for the new |
| 926 | * state |
| 927 | * @__i: int iteration cursor, for macro-internal use |
| 928 | * |
| 929 | * This iterates over all DRM DP MST topology managers in an atomic update, |
| 930 | * tracking both old and new state. This is useful in places where the state |
| 931 | * delta needs to be considered, for example in atomic check functions. |
| 932 | */ |
| 933 | #define for_each_oldnew_mst_mgr_in_state(__state, mgr, old_state, new_state, __i) \ |
| 934 | for ((__i) = 0; (__i) < (__state)->num_private_objs; (__i)++) \ |
| 935 | for_each_if(__drm_dp_mst_state_iter_get((__state), &(mgr), &(old_state), &(new_state), (__i))) |
| 936 | |
| 937 | /** |
| 938 | * for_each_old_mst_mgr_in_state - iterate over all DP MST topology managers |
| 939 | * in an atomic update |
| 940 | * @__state: &struct drm_atomic_state pointer |
| 941 | * @mgr: &struct drm_dp_mst_topology_mgr iteration cursor |
| 942 | * @old_state: &struct drm_dp_mst_topology_state iteration cursor for the old |
| 943 | * state |
| 944 | * @__i: int iteration cursor, for macro-internal use |
| 945 | * |
| 946 | * This iterates over all DRM DP MST topology managers in an atomic update, |
| 947 | * tracking only the old state. This is useful in disable functions, where we |
| 948 | * need the old state the hardware is still in. |
| 949 | */ |
| 950 | #define for_each_old_mst_mgr_in_state(__state, mgr, old_state, __i) \ |
| 951 | for ((__i) = 0; (__i) < (__state)->num_private_objs; (__i)++) \ |
| 952 | for_each_if(__drm_dp_mst_state_iter_get((__state), &(mgr), &(old_state), NULL, (__i))) |
| 953 | |
| 954 | /** |
| 955 | * for_each_new_mst_mgr_in_state - iterate over all DP MST topology managers |
| 956 | * in an atomic update |
| 957 | * @__state: &struct drm_atomic_state pointer |
| 958 | * @mgr: &struct drm_dp_mst_topology_mgr iteration cursor |
| 959 | * @new_state: &struct drm_dp_mst_topology_state iteration cursor for the new |
| 960 | * state |
| 961 | * @__i: int iteration cursor, for macro-internal use |
| 962 | * |
| 963 | * This iterates over all DRM DP MST topology managers in an atomic update, |
| 964 | * tracking only the new state. This is useful in enable functions, where we |
| 965 | * need the new state the hardware should be in when the atomic commit |
| 966 | * operation has completed. |
| 967 | */ |
| 968 | #define for_each_new_mst_mgr_in_state(__state, mgr, new_state, __i) \ |
| 969 | for ((__i) = 0; (__i) < (__state)->num_private_objs; (__i)++) \ |
| 970 | for_each_if(__drm_dp_mst_state_iter_get((__state), &(mgr), NULL, &(new_state), (__i))) |
| 971 | |
Dave Airlie | ad7f8a1 | 2014-06-05 14:01:32 +1000 | [diff] [blame] | 972 | #endif |