2 * Copyright © 2014 Red Hat.
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.
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
22 #ifndef _DRM_DP_MST_HELPER_H_
23 #define _DRM_DP_MST_HELPER_H_
25 #include <linux/types.h>
26 #include <drm/drm_dp_helper.h>
27 #include <drm/drm_atomic.h>
29 #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS)
30 #include <linux/stackdepot.h>
31 #include <linux/timekeeping.h>
33 enum drm_dp_mst_topology_ref_type {
34 DRM_DP_MST_TOPOLOGY_REF_GET,
35 DRM_DP_MST_TOPOLOGY_REF_PUT,
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;
43 depot_stack_handle_t backtrace;
47 #endif /* IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS) */
49 struct drm_dp_mst_branch;
52 * struct drm_dp_vcpi - Virtual Channel Payload Identifier
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
66 * struct drm_dp_mst_port - MST port
67 * @port_num: port number
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.
84 * @available_pbn: Available bandwidth for this port. Protected by
85 * &drm_dp_mst_topology_mgr.base.lock.
86 * @next: link to next port on this branch device
87 * @aux: i2c aux transport to talk to device connected to this port, protected
88 * by &drm_dp_mst_topology_mgr.base.lock.
89 * @parent: branch device parent of this port
90 * @vcpi: Virtual Channel Payload info for this port.
91 * @connector: DRM connector this port is connected to. Protected by
92 * &drm_dp_mst_topology_mgr.base.lock.
93 * @mgr: topology manager this port lives under.
95 * This structure represents an MST port endpoint on a device somewhere
96 * in the MST topology.
98 struct drm_dp_mst_port {
100 * @topology_kref: refcount for this port's lifetime in the topology,
101 * only the DP MST helpers should need to touch this
103 struct kref topology_kref;
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().
110 struct kref malloc_kref;
112 #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS)
114 * @topology_ref_history: A history of each topology
115 * reference/dereference. See CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS.
117 struct drm_dp_mst_topology_ref_history topology_ref_history;
128 u8 num_sdp_stream_sinks;
129 uint16_t available_pbn;
130 struct list_head next;
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.
141 struct drm_dp_mst_branch *mstb;
142 struct drm_dp_aux aux; /* i2c bus for this port? */
143 struct drm_dp_mst_branch *parent;
145 struct drm_dp_vcpi vcpi;
146 struct drm_connector *connector;
147 struct drm_dp_mst_topology_mgr *mgr;
150 * @cached_edid: for DP logical ports - make tiling work by ensuring
151 * that the EDID for all connectors is read immediately.
153 struct edid *cached_edid;
155 * @has_audio: Tracks whether the sink connector to this port is
164 * struct drm_dp_mst_branch - MST branch device.
165 * @rad: Relative Address to talk to this branch device.
166 * @lct: Link count total to talk to this branch device.
167 * @num_ports: number of ports on the branch.
168 * @msg_slots: one bit per transmitted msg slot.
169 * @port_parent: pointer to the port parent, NULL if toplevel.
170 * @mgr: topology manager for this branch device.
171 * @tx_slots: transmission slots for this device.
172 * @last_seqno: last sequence number used to talk to this.
173 * @link_address_sent: if a link address message has been sent to this device yet.
174 * @guid: guid for DP 1.2 branch device. port under this branch can be
175 * identified by port #.
177 * This structure represents an MST branch device, there is one
178 * primary branch device at the root, along with any other branches connected
179 * to downstream port of parent branches.
181 struct drm_dp_mst_branch {
183 * @topology_kref: refcount for this branch device's lifetime in the
184 * topology, only the DP MST helpers should need to touch this
186 struct kref topology_kref;
189 * @malloc_kref: refcount for the memory allocation containing this
190 * structure. See drm_dp_mst_get_mstb_malloc() and
191 * drm_dp_mst_put_mstb_malloc().
193 struct kref malloc_kref;
195 #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS)
197 * @topology_ref_history: A history of each topology
198 * reference/dereference. See CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS.
200 struct drm_dp_mst_topology_ref_history topology_ref_history;
204 * @destroy_next: linked-list entry used by
205 * drm_dp_delayed_destroy_work()
207 struct list_head destroy_next;
215 * @ports: the list of ports on this branch device. This should be
216 * considered protected for reading by &drm_dp_mst_topology_mgr.lock.
217 * There are two exceptions to this:
218 * &drm_dp_mst_topology_mgr.up_req_work and
219 * &drm_dp_mst_topology_mgr.work, which do not grab
220 * &drm_dp_mst_topology_mgr.lock during reads but are the only
221 * updaters of this list and are protected from updating the list
222 * concurrently by @drm_dp_mst_topology_mgr.probe_lock
224 struct list_head ports;
226 /* list of tx ops queue for this port */
227 struct drm_dp_mst_port *port_parent;
228 struct drm_dp_mst_topology_mgr *mgr;
230 /* slots are protected by mstb->mgr->qlock */
231 struct drm_dp_sideband_msg_tx *tx_slots[2];
233 bool link_address_sent;
235 /* global unique identifier to identify branch devices */
240 /* sideband msg header - not bit struct */
241 struct drm_dp_sideband_msg_hdr {
253 struct drm_dp_nak_reply {
259 struct drm_dp_link_address_ack_reply {
262 struct drm_dp_link_addr_reply_port {
268 bool legacy_device_plug_status;
272 u8 num_sdp_stream_sinks;
276 struct drm_dp_remote_dpcd_read_ack_reply {
282 struct drm_dp_remote_dpcd_write_ack_reply {
286 struct drm_dp_remote_dpcd_write_nak_reply {
289 u8 bytes_written_before_failure;
292 struct drm_dp_remote_i2c_read_ack_reply {
298 struct drm_dp_remote_i2c_read_nak_reply {
301 u8 i2c_nak_transaction;
304 struct drm_dp_remote_i2c_write_ack_reply {
309 struct drm_dp_sideband_msg_rx {
313 u8 curchunk_idx; /* chunk we are parsing now */
315 u8 curlen; /* total length of the msg */
318 struct drm_dp_sideband_msg_hdr initial_hdr;
321 #define DRM_DP_MAX_SDP_STREAMS 16
322 struct drm_dp_allocate_payload {
324 u8 number_sdp_streams;
327 u8 sdp_stream_sink[DRM_DP_MAX_SDP_STREAMS];
330 struct drm_dp_allocate_payload_ack_reply {
336 struct drm_dp_connection_status_notify {
339 bool legacy_device_plug_status;
340 bool displayport_device_plug_status;
341 bool message_capability_status;
346 struct drm_dp_remote_dpcd_read {
352 struct drm_dp_remote_dpcd_write {
359 #define DP_REMOTE_I2C_READ_MAX_TRANSACTIONS 4
360 struct drm_dp_remote_i2c_read {
363 struct drm_dp_remote_i2c_read_tx {
368 u8 i2c_transaction_delay;
369 } transactions[DP_REMOTE_I2C_READ_MAX_TRANSACTIONS];
370 u8 read_i2c_device_id;
374 struct drm_dp_remote_i2c_write {
376 u8 write_i2c_device_id;
381 /* this covers ENUM_RESOURCES, POWER_DOWN_PHY, POWER_UP_PHY */
382 struct drm_dp_port_number_req {
386 struct drm_dp_enum_path_resources_ack_reply {
389 u16 full_payload_bw_number;
390 u16 avail_payload_bw_number;
393 /* covers POWER_DOWN_PHY, POWER_UP_PHY */
394 struct drm_dp_port_number_rep {
398 struct drm_dp_query_payload {
403 struct drm_dp_resource_status_notify {
409 struct drm_dp_query_payload_ack_reply {
414 struct drm_dp_sideband_msg_req_body {
417 struct drm_dp_connection_status_notify conn_stat;
418 struct drm_dp_port_number_req port_num;
419 struct drm_dp_resource_status_notify resource_stat;
421 struct drm_dp_query_payload query_payload;
422 struct drm_dp_allocate_payload allocate_payload;
424 struct drm_dp_remote_dpcd_read dpcd_read;
425 struct drm_dp_remote_dpcd_write dpcd_write;
427 struct drm_dp_remote_i2c_read i2c_read;
428 struct drm_dp_remote_i2c_write i2c_write;
432 struct drm_dp_sideband_msg_reply_body {
436 struct drm_dp_nak_reply nak;
437 struct drm_dp_link_address_ack_reply link_addr;
438 struct drm_dp_port_number_rep port_number;
440 struct drm_dp_enum_path_resources_ack_reply path_resources;
441 struct drm_dp_allocate_payload_ack_reply allocate_payload;
442 struct drm_dp_query_payload_ack_reply query_payload;
444 struct drm_dp_remote_dpcd_read_ack_reply remote_dpcd_read_ack;
445 struct drm_dp_remote_dpcd_write_ack_reply remote_dpcd_write_ack;
446 struct drm_dp_remote_dpcd_write_nak_reply remote_dpcd_write_nack;
448 struct drm_dp_remote_i2c_read_ack_reply remote_i2c_read_ack;
449 struct drm_dp_remote_i2c_read_nak_reply remote_i2c_read_nack;
450 struct drm_dp_remote_i2c_write_ack_reply remote_i2c_write_ack;
454 /* msg is queued to be put into a slot */
455 #define DRM_DP_SIDEBAND_TX_QUEUED 0
456 /* msg has started transmitting on a slot - still on msgq */
457 #define DRM_DP_SIDEBAND_TX_START_SEND 1
458 /* msg has finished transmitting on a slot - removed from msgq only in slot */
459 #define DRM_DP_SIDEBAND_TX_SENT 2
460 /* msg has received a response - removed from slot */
461 #define DRM_DP_SIDEBAND_TX_RX 3
462 #define DRM_DP_SIDEBAND_TX_TIMEOUT 4
464 struct drm_dp_sideband_msg_tx {
469 struct drm_dp_mst_branch *dst;
470 struct list_head next;
474 struct drm_dp_sideband_msg_reply_body reply;
477 /* sideband msg handler */
478 struct drm_dp_mst_topology_mgr;
479 struct drm_dp_mst_topology_cbs {
480 /* create a connector for a port */
481 struct drm_connector *(*add_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, const char *path);
482 void (*register_connector)(struct drm_connector *connector);
483 void (*destroy_connector)(struct drm_dp_mst_topology_mgr *mgr,
484 struct drm_connector *connector);
487 #define DP_MAX_PAYLOAD (sizeof(unsigned long) * 8)
489 #define DP_PAYLOAD_LOCAL 1
490 #define DP_PAYLOAD_REMOTE 2
491 #define DP_PAYLOAD_DELETE_LOCAL 3
493 struct drm_dp_payload {
500 #define to_dp_mst_topology_state(x) container_of(x, struct drm_dp_mst_topology_state, base)
502 struct drm_dp_vcpi_allocation {
503 struct drm_dp_mst_port *port;
505 struct list_head next;
508 struct drm_dp_mst_topology_state {
509 struct drm_private_state base;
510 struct list_head vcpis;
511 struct drm_dp_mst_topology_mgr *mgr;
514 #define to_dp_mst_topology_mgr(x) container_of(x, struct drm_dp_mst_topology_mgr, base)
517 * struct drm_dp_mst_topology_mgr - DisplayPort MST manager
519 * This struct represents the toplevel displayport MST topology manager.
520 * There should be one instance of this for every MST capable DP connector
523 struct drm_dp_mst_topology_mgr {
525 * @base: Base private object for atomic
527 struct drm_private_obj base;
530 * @dev: device pointer for adding i2c devices etc.
532 struct drm_device *dev;
534 * @cbs: callbacks for connector addition and destruction.
536 const struct drm_dp_mst_topology_cbs *cbs;
538 * @max_dpcd_transaction_bytes: maximum number of bytes to read/write
541 int max_dpcd_transaction_bytes;
543 * @aux: AUX channel for the DP MST connector this topolgy mgr is
546 struct drm_dp_aux *aux;
548 * @max_payloads: maximum number of payloads the GPU can generate.
552 * @conn_base_id: DRM connector ID this mgr is connected to. Only used
553 * to build the MST connector path value.
558 * @down_rep_recv: Message receiver state for down replies.
560 struct drm_dp_sideband_msg_rx down_rep_recv;
562 * @up_req_recv: Message receiver state for up requests.
564 struct drm_dp_sideband_msg_rx up_req_recv;
567 * @lock: protects @mst_state, @mst_primary, @dpcd, and
568 * @payload_id_table_cleared.
573 * @probe_lock: Prevents @work and @up_req_work, the only writers of
574 * &drm_dp_mst_port.mstb and &drm_dp_mst_branch.ports, from racing
575 * while they update the topology.
577 struct mutex probe_lock;
580 * @mst_state: If this manager is enabled for an MST capable port. False
581 * if no MST sink/branch devices is connected.
586 * @payload_id_table_cleared: Whether or not we've cleared the payload
587 * ID table for @mst_primary. Protected by @lock.
589 bool payload_id_table_cleared : 1;
592 * @mst_primary: Pointer to the primary/first branch device.
594 struct drm_dp_mst_branch *mst_primary;
597 * @dpcd: Cache of DPCD for primary port.
599 u8 dpcd[DP_RECEIVER_CAP_SIZE];
601 * @sink_count: Sink count from DEVICE_SERVICE_IRQ_VECTOR_ESI0.
605 * @pbn_div: PBN to slots divisor.
610 * @funcs: Atomic helper callbacks
612 const struct drm_private_state_funcs *funcs;
615 * @qlock: protects @tx_msg_downq, the &drm_dp_mst_branch.txslost and
616 * &drm_dp_sideband_msg_tx.state once they are queued
620 * @tx_msg_downq: List of pending down replies.
622 struct list_head tx_msg_downq;
625 * @payload_lock: Protect payload information.
627 struct mutex payload_lock;
629 * @proposed_vcpis: Array of pointers for the new VCPI allocation. The
630 * VCPI structure itself is &drm_dp_mst_port.vcpi.
632 struct drm_dp_vcpi **proposed_vcpis;
634 * @payloads: Array of payloads.
636 struct drm_dp_payload *payloads;
638 * @payload_mask: Elements of @payloads actually in use. Since
639 * reallocation of active outputs isn't possible gaps can be created by
640 * disabling outputs out of order compared to how they've been enabled.
642 unsigned long payload_mask;
644 * @vcpi_mask: Similar to @payload_mask, but for @proposed_vcpis.
646 unsigned long vcpi_mask;
649 * @tx_waitq: Wait to queue stall for the tx worker.
651 wait_queue_head_t tx_waitq;
655 struct work_struct work;
657 * @tx_work: Sideband transmit worker. This can nest within the main
658 * @work worker for each transaction @work launches.
660 struct work_struct tx_work;
663 * @destroy_port_list: List of to be destroyed connectors.
665 struct list_head destroy_port_list;
667 * @destroy_branch_device_list: List of to be destroyed branch
670 struct list_head destroy_branch_device_list;
672 * @delayed_destroy_lock: Protects @destroy_port_list and
673 * @destroy_branch_device_list.
675 struct mutex delayed_destroy_lock;
677 * @delayed_destroy_work: Work item to destroy MST port and branch
678 * devices, needed to avoid locking inversion.
680 struct work_struct delayed_destroy_work;
683 * @up_req_list: List of pending up requests from the topology that
684 * need to be processed, in chronological order.
686 struct list_head up_req_list;
688 * @up_req_lock: Protects @up_req_list
690 struct mutex up_req_lock;
692 * @up_req_work: Work item to process up requests received from the
693 * topology. Needed to avoid blocking hotplug handling and sideband
696 struct work_struct up_req_work;
698 #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS)
700 * @topology_ref_history_lock: protects
701 * &drm_dp_mst_port.topology_ref_history and
702 * &drm_dp_mst_branch.topology_ref_history.
704 struct mutex topology_ref_history_lock;
708 int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,
709 struct drm_device *dev, struct drm_dp_aux *aux,
710 int max_dpcd_transaction_bytes,
711 int max_payloads, int conn_base_id);
713 void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr);
716 int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool mst_state);
719 int drm_dp_mst_hpd_irq(struct drm_dp_mst_topology_mgr *mgr, u8 *esi, bool *handled);
723 drm_dp_mst_detect_port(struct drm_connector *connector,
724 struct drm_modeset_acquire_ctx *ctx,
725 struct drm_dp_mst_topology_mgr *mgr,
726 struct drm_dp_mst_port *port);
728 bool drm_dp_mst_port_has_audio(struct drm_dp_mst_topology_mgr *mgr,
729 struct drm_dp_mst_port *port);
730 struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
733 int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);
735 bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
736 struct drm_dp_mst_port *port, int pbn, int slots);
738 int drm_dp_mst_get_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
741 void drm_dp_mst_reset_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
744 void drm_dp_mst_deallocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
745 struct drm_dp_mst_port *port);
748 int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr,
752 int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr);
755 int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr);
757 int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr);
759 void drm_dp_mst_dump_topology(struct seq_file *m,
760 struct drm_dp_mst_topology_mgr *mgr);
762 void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr);
764 drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
767 ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux,
768 unsigned int offset, void *buffer, size_t size);
769 ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
770 unsigned int offset, void *buffer, size_t size);
772 int drm_dp_mst_connector_late_register(struct drm_connector *connector,
773 struct drm_dp_mst_port *port);
774 void drm_dp_mst_connector_early_unregister(struct drm_connector *connector,
775 struct drm_dp_mst_port *port);
777 struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state,
778 struct drm_dp_mst_topology_mgr *mgr);
780 drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
781 struct drm_dp_mst_topology_mgr *mgr,
782 struct drm_dp_mst_port *port, int pbn);
784 drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
785 struct drm_dp_mst_topology_mgr *mgr,
786 struct drm_dp_mst_port *port);
787 int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr,
788 struct drm_dp_mst_port *port, bool power_up);
789 int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state);
791 void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port);
792 void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port);
794 extern const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs;
797 * __drm_dp_mst_state_iter_get - private atomic state iterator function for
799 * @state: &struct drm_atomic_state pointer
800 * @mgr: pointer to the &struct drm_dp_mst_topology_mgr iteration cursor
801 * @old_state: optional pointer to the old &struct drm_dp_mst_topology_state
803 * @new_state: optional pointer to the new &struct drm_dp_mst_topology_state
805 * @i: int iteration cursor, for macro-internal use
807 * Used by for_each_oldnew_mst_mgr_in_state(),
808 * for_each_old_mst_mgr_in_state(), and for_each_new_mst_mgr_in_state(). Don't
809 * call this directly.
812 * True if the current &struct drm_private_obj is a &struct
813 * drm_dp_mst_topology_mgr, false otherwise.
816 __drm_dp_mst_state_iter_get(struct drm_atomic_state *state,
817 struct drm_dp_mst_topology_mgr **mgr,
818 struct drm_dp_mst_topology_state **old_state,
819 struct drm_dp_mst_topology_state **new_state,
822 struct __drm_private_objs_state *objs_state = &state->private_objs[i];
824 if (objs_state->ptr->funcs != &drm_dp_mst_topology_state_funcs)
827 *mgr = to_dp_mst_topology_mgr(objs_state->ptr);
829 *old_state = to_dp_mst_topology_state(objs_state->old_state);
831 *new_state = to_dp_mst_topology_state(objs_state->new_state);
837 * for_each_oldnew_mst_mgr_in_state - iterate over all DP MST topology
838 * managers in an atomic update
839 * @__state: &struct drm_atomic_state pointer
840 * @mgr: &struct drm_dp_mst_topology_mgr iteration cursor
841 * @old_state: &struct drm_dp_mst_topology_state iteration cursor for the old
843 * @new_state: &struct drm_dp_mst_topology_state iteration cursor for the new
845 * @__i: int iteration cursor, for macro-internal use
847 * This iterates over all DRM DP MST topology managers in an atomic update,
848 * tracking both old and new state. This is useful in places where the state
849 * delta needs to be considered, for example in atomic check functions.
851 #define for_each_oldnew_mst_mgr_in_state(__state, mgr, old_state, new_state, __i) \
852 for ((__i) = 0; (__i) < (__state)->num_private_objs; (__i)++) \
853 for_each_if(__drm_dp_mst_state_iter_get((__state), &(mgr), &(old_state), &(new_state), (__i)))
856 * for_each_old_mst_mgr_in_state - iterate over all DP MST topology managers
857 * in an atomic update
858 * @__state: &struct drm_atomic_state pointer
859 * @mgr: &struct drm_dp_mst_topology_mgr iteration cursor
860 * @old_state: &struct drm_dp_mst_topology_state iteration cursor for the old
862 * @__i: int iteration cursor, for macro-internal use
864 * This iterates over all DRM DP MST topology managers in an atomic update,
865 * tracking only the old state. This is useful in disable functions, where we
866 * need the old state the hardware is still in.
868 #define for_each_old_mst_mgr_in_state(__state, mgr, old_state, __i) \
869 for ((__i) = 0; (__i) < (__state)->num_private_objs; (__i)++) \
870 for_each_if(__drm_dp_mst_state_iter_get((__state), &(mgr), &(old_state), NULL, (__i)))
873 * for_each_new_mst_mgr_in_state - iterate over all DP MST topology managers
874 * in an atomic update
875 * @__state: &struct drm_atomic_state pointer
876 * @mgr: &struct drm_dp_mst_topology_mgr iteration cursor
877 * @new_state: &struct drm_dp_mst_topology_state iteration cursor for the new
879 * @__i: int iteration cursor, for macro-internal use
881 * This iterates over all DRM DP MST topology managers in an atomic update,
882 * tracking only the new state. This is useful in enable functions, where we
883 * need the new state the hardware should be in when the atomic commit
884 * operation has completed.
886 #define for_each_new_mst_mgr_in_state(__state, mgr, new_state, __i) \
887 for ((__i) = 0; (__i) < (__state)->num_private_objs; (__i)++) \
888 for_each_if(__drm_dp_mst_state_iter_get((__state), &(mgr), NULL, &(new_state), (__i)))