Subversion Repositories Kolibri OS

Rev

Rev 5056 | Rev 6336 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5056 Rev 5270
1
/*
1
/*
2
 * Copyright © 2014 Red Hat.
2
 * Copyright © 2014 Red Hat.
3
 *
3
 *
4
 * Permission to use, copy, modify, distribute, and sell this software and its
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
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
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
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
8
 * that the name of the copyright holders not be used in advertising or
9
 * publicity pertaining to distribution of the software without specific,
9
 * publicity pertaining to distribution of the software without specific,
10
 * written prior permission.  The copyright holders make no representations
10
 * written prior permission.  The copyright holders make no representations
11
 * about the suitability of this software for any purpose.  It is provided "as
11
 * about the suitability of this software for any purpose.  It is provided "as
12
 * is" without express or implied warranty.
12
 * is" without express or implied warranty.
13
 *
13
 *
14
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
14
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
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,
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
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
19
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20
 * OF THIS SOFTWARE.
20
 * OF THIS SOFTWARE.
21
 */
21
 */
22
#ifndef _DRM_DP_MST_HELPER_H_
22
#ifndef _DRM_DP_MST_HELPER_H_
23
#define _DRM_DP_MST_HELPER_H_
23
#define _DRM_DP_MST_HELPER_H_
24
 
24
 
25
#include 
25
#include 
26
#include 
26
#include 
27
 
27
 
28
struct drm_dp_mst_branch;
28
struct drm_dp_mst_branch;
29
 
29
 
30
/**
30
/**
31
 * struct drm_dp_vcpi - Virtual Channel Payload Identifer
31
 * struct drm_dp_vcpi - Virtual Channel Payload Identifier
32
 * @vcpi: Virtual channel ID.
32
 * @vcpi: Virtual channel ID.
33
 * @pbn: Payload Bandwidth Number for this channel
33
 * @pbn: Payload Bandwidth Number for this channel
34
 * @aligned_pbn: PBN aligned with slot size
34
 * @aligned_pbn: PBN aligned with slot size
35
 * @num_slots: number of slots for this PBN
35
 * @num_slots: number of slots for this PBN
36
 */
36
 */
37
struct drm_dp_vcpi {
37
struct drm_dp_vcpi {
38
	int vcpi;
38
	int vcpi;
39
	int pbn;
39
	int pbn;
40
	int aligned_pbn;
40
	int aligned_pbn;
41
	int num_slots;
41
	int num_slots;
42
};
42
};
43
 
43
 
44
/**
44
/**
45
 * struct drm_dp_mst_port - MST port
45
 * struct drm_dp_mst_port - MST port
46
 * @kref: reference count for this port.
46
 * @kref: reference count for this port.
47
 * @guid_valid: for DP 1.2 devices if we have validated the GUID.
47
 * @guid_valid: for DP 1.2 devices if we have validated the GUID.
48
 * @guid: guid for DP 1.2 device on this port.
48
 * @guid: guid for DP 1.2 device on this port.
49
 * @port_num: port number
49
 * @port_num: port number
50
 * @input: if this port is an input port.
50
 * @input: if this port is an input port.
51
 * @mcs: message capability status - DP 1.2 spec.
51
 * @mcs: message capability status - DP 1.2 spec.
52
 * @ddps: DisplayPort Device Plug Status - DP 1.2
52
 * @ddps: DisplayPort Device Plug Status - DP 1.2
53
 * @pdt: Peer Device Type
53
 * @pdt: Peer Device Type
54
 * @ldps: Legacy Device Plug Status
54
 * @ldps: Legacy Device Plug Status
55
 * @dpcd_rev: DPCD revision of device on this port
55
 * @dpcd_rev: DPCD revision of device on this port
56
 * @num_sdp_streams: Number of simultaneous streams
56
 * @num_sdp_streams: Number of simultaneous streams
57
 * @num_sdp_stream_sinks: Number of stream sinks
57
 * @num_sdp_stream_sinks: Number of stream sinks
58
 * @available_pbn: Available bandwidth for this port.
58
 * @available_pbn: Available bandwidth for this port.
59
 * @next: link to next port on this branch device
59
 * @next: link to next port on this branch device
60
 * @mstb: branch device attach below this port
60
 * @mstb: branch device attach below this port
61
 * @aux: i2c aux transport to talk to device connected to this port.
61
 * @aux: i2c aux transport to talk to device connected to this port.
62
 * @parent: branch device parent of this port
62
 * @parent: branch device parent of this port
63
 * @vcpi: Virtual Channel Payload info for this port.
63
 * @vcpi: Virtual Channel Payload info for this port.
64
 * @connector: DRM connector this port is connected to.
64
 * @connector: DRM connector this port is connected to.
65
 * @mgr: topology manager this port lives under.
65
 * @mgr: topology manager this port lives under.
66
 *
66
 *
67
 * This structure represents an MST port endpoint on a device somewhere
67
 * This structure represents an MST port endpoint on a device somewhere
68
 * in the MST topology.
68
 * in the MST topology.
69
 */
69
 */
70
struct drm_dp_mst_port {
70
struct drm_dp_mst_port {
71
	struct kref kref;
71
	struct kref kref;
72
 
72
 
73
	/* if dpcd 1.2 device is on this port - its GUID info */
73
	/* if dpcd 1.2 device is on this port - its GUID info */
74
	bool guid_valid;
74
	bool guid_valid;
75
	u8 guid[16];
75
	u8 guid[16];
76
 
76
 
77
	u8 port_num;
77
	u8 port_num;
78
	bool input;
78
	bool input;
79
	bool mcs;
79
	bool mcs;
80
	bool ddps;
80
	bool ddps;
81
	u8 pdt;
81
	u8 pdt;
82
	bool ldps;
82
	bool ldps;
83
	u8 dpcd_rev;
83
	u8 dpcd_rev;
84
	u8 num_sdp_streams;
84
	u8 num_sdp_streams;
85
	u8 num_sdp_stream_sinks;
85
	u8 num_sdp_stream_sinks;
86
	uint16_t available_pbn;
86
	uint16_t available_pbn;
87
	struct list_head next;
87
	struct list_head next;
88
	struct drm_dp_mst_branch *mstb; /* pointer to an mstb if this port has one */
88
	struct drm_dp_mst_branch *mstb; /* pointer to an mstb if this port has one */
89
	struct drm_dp_aux aux; /* i2c bus for this port? */
89
	struct drm_dp_aux aux; /* i2c bus for this port? */
90
	struct drm_dp_mst_branch *parent;
90
	struct drm_dp_mst_branch *parent;
91
 
91
 
92
	struct drm_dp_vcpi vcpi;
92
	struct drm_dp_vcpi vcpi;
93
	struct drm_connector *connector;
93
	struct drm_connector *connector;
94
	struct drm_dp_mst_topology_mgr *mgr;
94
	struct drm_dp_mst_topology_mgr *mgr;
-
 
95
 
-
 
96
	struct edid *cached_edid; /* for DP logical ports - make tiling work */
95
};
97
};
96
 
98
 
97
/**
99
/**
98
 * struct drm_dp_mst_branch - MST branch device.
100
 * struct drm_dp_mst_branch - MST branch device.
99
 * @kref: reference count for this port.
101
 * @kref: reference count for this port.
100
 * @rad: Relative Address to talk to this branch device.
102
 * @rad: Relative Address to talk to this branch device.
101
 * @lct: Link count total to talk to this branch device.
103
 * @lct: Link count total to talk to this branch device.
102
 * @num_ports: number of ports on the branch.
104
 * @num_ports: number of ports on the branch.
103
 * @msg_slots: one bit per transmitted msg slot.
105
 * @msg_slots: one bit per transmitted msg slot.
104
 * @ports: linked list of ports on this branch.
106
 * @ports: linked list of ports on this branch.
105
 * @port_parent: pointer to the port parent, NULL if toplevel.
107
 * @port_parent: pointer to the port parent, NULL if toplevel.
106
 * @mgr: topology manager for this branch device.
108
 * @mgr: topology manager for this branch device.
107
 * @tx_slots: transmission slots for this device.
109
 * @tx_slots: transmission slots for this device.
108
 * @last_seqno: last sequence number used to talk to this.
110
 * @last_seqno: last sequence number used to talk to this.
109
 * @link_address_sent: if a link address message has been sent to this device yet.
111
 * @link_address_sent: if a link address message has been sent to this device yet.
110
 *
112
 *
111
 * This structure represents an MST branch device, there is one
113
 * This structure represents an MST branch device, there is one
112
 * primary branch device at the root, along with any others connected
114
 * primary branch device at the root, along with any others connected
113
 * to downstream ports
115
 * to downstream ports
114
 */
116
 */
115
struct drm_dp_mst_branch {
117
struct drm_dp_mst_branch {
116
	struct kref kref;
118
	struct kref kref;
117
	u8 rad[8];
119
	u8 rad[8];
118
	u8 lct;
120
	u8 lct;
119
	int num_ports;
121
	int num_ports;
120
 
122
 
121
	int msg_slots;
123
	int msg_slots;
122
	struct list_head ports;
124
	struct list_head ports;
123
 
125
 
124
	/* list of tx ops queue for this port */
126
	/* list of tx ops queue for this port */
125
	struct drm_dp_mst_port *port_parent;
127
	struct drm_dp_mst_port *port_parent;
126
	struct drm_dp_mst_topology_mgr *mgr;
128
	struct drm_dp_mst_topology_mgr *mgr;
127
 
129
 
128
	/* slots are protected by mstb->mgr->qlock */
130
	/* slots are protected by mstb->mgr->qlock */
129
	struct drm_dp_sideband_msg_tx *tx_slots[2];
131
	struct drm_dp_sideband_msg_tx *tx_slots[2];
130
	int last_seqno;
132
	int last_seqno;
131
	bool link_address_sent;
133
	bool link_address_sent;
132
};
134
};
133
 
135
 
134
 
136
 
135
/* sideband msg header - not bit struct */
137
/* sideband msg header - not bit struct */
136
struct drm_dp_sideband_msg_hdr {
138
struct drm_dp_sideband_msg_hdr {
137
	u8 lct;
139
	u8 lct;
138
	u8 lcr;
140
	u8 lcr;
139
	u8 rad[8];
141
	u8 rad[8];
140
	bool broadcast;
142
	bool broadcast;
141
	bool path_msg;
143
	bool path_msg;
142
	u8 msg_len;
144
	u8 msg_len;
143
	bool somt;
145
	bool somt;
144
	bool eomt;
146
	bool eomt;
145
	bool seqno;
147
	bool seqno;
146
};
148
};
147
 
149
 
148
struct drm_dp_nak_reply {
150
struct drm_dp_nak_reply {
149
	u8 guid[16];
151
	u8 guid[16];
150
	u8 reason;
152
	u8 reason;
151
	u8 nak_data;
153
	u8 nak_data;
152
};
154
};
153
 
155
 
154
struct drm_dp_link_address_ack_reply {
156
struct drm_dp_link_address_ack_reply {
155
	u8 guid[16];
157
	u8 guid[16];
156
	u8 nports;
158
	u8 nports;
157
	struct drm_dp_link_addr_reply_port {
159
	struct drm_dp_link_addr_reply_port {
158
		bool input_port;
160
		bool input_port;
159
		u8 peer_device_type;
161
		u8 peer_device_type;
160
		u8 port_number;
162
		u8 port_number;
161
		bool mcs;
163
		bool mcs;
162
		bool ddps;
164
		bool ddps;
163
		bool legacy_device_plug_status;
165
		bool legacy_device_plug_status;
164
		u8 dpcd_revision;
166
		u8 dpcd_revision;
165
		u8 peer_guid[16];
167
		u8 peer_guid[16];
166
		u8 num_sdp_streams;
168
		u8 num_sdp_streams;
167
		u8 num_sdp_stream_sinks;
169
		u8 num_sdp_stream_sinks;
168
	} ports[16];
170
	} ports[16];
169
};
171
};
170
 
172
 
171
struct drm_dp_remote_dpcd_read_ack_reply {
173
struct drm_dp_remote_dpcd_read_ack_reply {
172
	u8 port_number;
174
	u8 port_number;
173
	u8 num_bytes;
175
	u8 num_bytes;
174
	u8 bytes[255];
176
	u8 bytes[255];
175
};
177
};
176
 
178
 
177
struct drm_dp_remote_dpcd_write_ack_reply {
179
struct drm_dp_remote_dpcd_write_ack_reply {
178
	u8 port_number;
180
	u8 port_number;
179
};
181
};
180
 
182
 
181
struct drm_dp_remote_dpcd_write_nak_reply {
183
struct drm_dp_remote_dpcd_write_nak_reply {
182
	u8 port_number;
184
	u8 port_number;
183
	u8 reason;
185
	u8 reason;
184
	u8 bytes_written_before_failure;
186
	u8 bytes_written_before_failure;
185
};
187
};
186
 
188
 
187
struct drm_dp_remote_i2c_read_ack_reply {
189
struct drm_dp_remote_i2c_read_ack_reply {
188
	u8 port_number;
190
	u8 port_number;
189
	u8 num_bytes;
191
	u8 num_bytes;
190
	u8 bytes[255];
192
	u8 bytes[255];
191
};
193
};
192
 
194
 
193
struct drm_dp_remote_i2c_read_nak_reply {
195
struct drm_dp_remote_i2c_read_nak_reply {
194
	u8 port_number;
196
	u8 port_number;
195
	u8 nak_reason;
197
	u8 nak_reason;
196
	u8 i2c_nak_transaction;
198
	u8 i2c_nak_transaction;
197
};
199
};
198
 
200
 
199
struct drm_dp_remote_i2c_write_ack_reply {
201
struct drm_dp_remote_i2c_write_ack_reply {
200
	u8 port_number;
202
	u8 port_number;
201
};
203
};
202
 
204
 
203
 
205
 
204
struct drm_dp_sideband_msg_rx {
206
struct drm_dp_sideband_msg_rx {
205
	u8 chunk[48];
207
	u8 chunk[48];
206
	u8 msg[256];
208
	u8 msg[256];
207
	u8 curchunk_len;
209
	u8 curchunk_len;
208
	u8 curchunk_idx; /* chunk we are parsing now */
210
	u8 curchunk_idx; /* chunk we are parsing now */
209
	u8 curchunk_hdrlen;
211
	u8 curchunk_hdrlen;
210
	u8 curlen; /* total length of the msg */
212
	u8 curlen; /* total length of the msg */
211
	bool have_somt;
213
	bool have_somt;
212
	bool have_eomt;
214
	bool have_eomt;
213
	struct drm_dp_sideband_msg_hdr initial_hdr;
215
	struct drm_dp_sideband_msg_hdr initial_hdr;
214
};
216
};
215
 
217
 
216
 
218
 
217
struct drm_dp_allocate_payload {
219
struct drm_dp_allocate_payload {
218
	u8 port_number;
220
	u8 port_number;
219
	u8 number_sdp_streams;
221
	u8 number_sdp_streams;
220
	u8 vcpi;
222
	u8 vcpi;
221
	u16 pbn;
223
	u16 pbn;
222
	u8 sdp_stream_sink[8];
224
	u8 sdp_stream_sink[8];
223
};
225
};
224
 
226
 
225
struct drm_dp_allocate_payload_ack_reply {
227
struct drm_dp_allocate_payload_ack_reply {
226
	u8 port_number;
228
	u8 port_number;
227
	u8 vcpi;
229
	u8 vcpi;
228
	u16 allocated_pbn;
230
	u16 allocated_pbn;
229
};
231
};
230
 
232
 
231
struct drm_dp_connection_status_notify {
233
struct drm_dp_connection_status_notify {
232
	u8 guid[16];
234
	u8 guid[16];
233
	u8 port_number;
235
	u8 port_number;
234
	bool legacy_device_plug_status;
236
	bool legacy_device_plug_status;
235
	bool displayport_device_plug_status;
237
	bool displayport_device_plug_status;
236
	bool message_capability_status;
238
	bool message_capability_status;
237
	bool input_port;
239
	bool input_port;
238
	u8 peer_device_type;
240
	u8 peer_device_type;
239
};
241
};
240
 
242
 
241
struct drm_dp_remote_dpcd_read {
243
struct drm_dp_remote_dpcd_read {
242
	u8 port_number;
244
	u8 port_number;
243
	u32 dpcd_address;
245
	u32 dpcd_address;
244
	u8 num_bytes;
246
	u8 num_bytes;
245
};
247
};
246
 
248
 
247
struct drm_dp_remote_dpcd_write {
249
struct drm_dp_remote_dpcd_write {
248
	u8 port_number;
250
	u8 port_number;
249
	u32 dpcd_address;
251
	u32 dpcd_address;
250
	u8 num_bytes;
252
	u8 num_bytes;
251
	u8 *bytes;
253
	u8 *bytes;
252
};
254
};
253
 
255
 
254
struct drm_dp_remote_i2c_read {
256
struct drm_dp_remote_i2c_read {
255
	u8 num_transactions;
257
	u8 num_transactions;
256
	u8 port_number;
258
	u8 port_number;
257
	struct {
259
	struct {
258
		u8 i2c_dev_id;
260
		u8 i2c_dev_id;
259
		u8 num_bytes;
261
		u8 num_bytes;
260
		u8 *bytes;
262
		u8 *bytes;
261
		u8 no_stop_bit;
263
		u8 no_stop_bit;
262
		u8 i2c_transaction_delay;
264
		u8 i2c_transaction_delay;
263
	} transactions[4];
265
	} transactions[4];
264
	u8 read_i2c_device_id;
266
	u8 read_i2c_device_id;
265
	u8 num_bytes_read;
267
	u8 num_bytes_read;
266
};
268
};
267
 
269
 
268
struct drm_dp_remote_i2c_write {
270
struct drm_dp_remote_i2c_write {
269
	u8 port_number;
271
	u8 port_number;
270
	u8 write_i2c_device_id;
272
	u8 write_i2c_device_id;
271
	u8 num_bytes;
273
	u8 num_bytes;
272
	u8 *bytes;
274
	u8 *bytes;
273
};
275
};
274
 
276
 
275
/* this covers ENUM_RESOURCES, POWER_DOWN_PHY, POWER_UP_PHY */
277
/* this covers ENUM_RESOURCES, POWER_DOWN_PHY, POWER_UP_PHY */
276
struct drm_dp_port_number_req {
278
struct drm_dp_port_number_req {
277
	u8 port_number;
279
	u8 port_number;
278
};
280
};
279
 
281
 
280
struct drm_dp_enum_path_resources_ack_reply {
282
struct drm_dp_enum_path_resources_ack_reply {
281
	u8 port_number;
283
	u8 port_number;
282
	u16 full_payload_bw_number;
284
	u16 full_payload_bw_number;
283
	u16 avail_payload_bw_number;
285
	u16 avail_payload_bw_number;
284
};
286
};
285
 
287
 
286
/* covers POWER_DOWN_PHY, POWER_UP_PHY */
288
/* covers POWER_DOWN_PHY, POWER_UP_PHY */
287
struct drm_dp_port_number_rep {
289
struct drm_dp_port_number_rep {
288
	u8 port_number;
290
	u8 port_number;
289
};
291
};
290
 
292
 
291
struct drm_dp_query_payload {
293
struct drm_dp_query_payload {
292
	u8 port_number;
294
	u8 port_number;
293
	u8 vcpi;
295
	u8 vcpi;
294
};
296
};
295
 
297
 
296
struct drm_dp_resource_status_notify {
298
struct drm_dp_resource_status_notify {
297
	u8 port_number;
299
	u8 port_number;
298
	u8 guid[16];
300
	u8 guid[16];
299
	u16 available_pbn;
301
	u16 available_pbn;
300
};
302
};
301
 
303
 
302
struct drm_dp_query_payload_ack_reply {
304
struct drm_dp_query_payload_ack_reply {
303
	u8 port_number;
305
	u8 port_number;
304
	u8 allocated_pbn;
306
	u8 allocated_pbn;
305
};
307
};
306
 
308
 
307
struct drm_dp_sideband_msg_req_body {
309
struct drm_dp_sideband_msg_req_body {
308
	u8 req_type;
310
	u8 req_type;
309
	union ack_req {
311
	union ack_req {
310
		struct drm_dp_connection_status_notify conn_stat;
312
		struct drm_dp_connection_status_notify conn_stat;
311
		struct drm_dp_port_number_req port_num;
313
		struct drm_dp_port_number_req port_num;
312
		struct drm_dp_resource_status_notify resource_stat;
314
		struct drm_dp_resource_status_notify resource_stat;
313
 
315
 
314
		struct drm_dp_query_payload query_payload;
316
		struct drm_dp_query_payload query_payload;
315
		struct drm_dp_allocate_payload allocate_payload;
317
		struct drm_dp_allocate_payload allocate_payload;
316
 
318
 
317
		struct drm_dp_remote_dpcd_read dpcd_read;
319
		struct drm_dp_remote_dpcd_read dpcd_read;
318
		struct drm_dp_remote_dpcd_write dpcd_write;
320
		struct drm_dp_remote_dpcd_write dpcd_write;
319
 
321
 
320
		struct drm_dp_remote_i2c_read i2c_read;
322
		struct drm_dp_remote_i2c_read i2c_read;
321
		struct drm_dp_remote_i2c_write i2c_write;
323
		struct drm_dp_remote_i2c_write i2c_write;
322
	} u;
324
	} u;
323
};
325
};
324
 
326
 
325
struct drm_dp_sideband_msg_reply_body {
327
struct drm_dp_sideband_msg_reply_body {
326
	u8 reply_type;
328
	u8 reply_type;
327
	u8 req_type;
329
	u8 req_type;
328
	union ack_replies {
330
	union ack_replies {
329
		struct drm_dp_nak_reply nak;
331
		struct drm_dp_nak_reply nak;
330
		struct drm_dp_link_address_ack_reply link_addr;
332
		struct drm_dp_link_address_ack_reply link_addr;
331
		struct drm_dp_port_number_rep port_number;
333
		struct drm_dp_port_number_rep port_number;
332
 
334
 
333
		struct drm_dp_enum_path_resources_ack_reply path_resources;
335
		struct drm_dp_enum_path_resources_ack_reply path_resources;
334
		struct drm_dp_allocate_payload_ack_reply allocate_payload;
336
		struct drm_dp_allocate_payload_ack_reply allocate_payload;
335
		struct drm_dp_query_payload_ack_reply query_payload;
337
		struct drm_dp_query_payload_ack_reply query_payload;
336
 
338
 
337
		struct drm_dp_remote_dpcd_read_ack_reply remote_dpcd_read_ack;
339
		struct drm_dp_remote_dpcd_read_ack_reply remote_dpcd_read_ack;
338
		struct drm_dp_remote_dpcd_write_ack_reply remote_dpcd_write_ack;
340
		struct drm_dp_remote_dpcd_write_ack_reply remote_dpcd_write_ack;
339
		struct drm_dp_remote_dpcd_write_nak_reply remote_dpcd_write_nack;
341
		struct drm_dp_remote_dpcd_write_nak_reply remote_dpcd_write_nack;
340
 
342
 
341
		struct drm_dp_remote_i2c_read_ack_reply remote_i2c_read_ack;
343
		struct drm_dp_remote_i2c_read_ack_reply remote_i2c_read_ack;
342
		struct drm_dp_remote_i2c_read_nak_reply remote_i2c_read_nack;
344
		struct drm_dp_remote_i2c_read_nak_reply remote_i2c_read_nack;
343
		struct drm_dp_remote_i2c_write_ack_reply remote_i2c_write_ack;
345
		struct drm_dp_remote_i2c_write_ack_reply remote_i2c_write_ack;
344
	} u;
346
	} u;
345
};
347
};
346
 
348
 
347
/* msg is queued to be put into a slot */
349
/* msg is queued to be put into a slot */
348
#define DRM_DP_SIDEBAND_TX_QUEUED 0
350
#define DRM_DP_SIDEBAND_TX_QUEUED 0
349
/* msg has started transmitting on a slot - still on msgq */
351
/* msg has started transmitting on a slot - still on msgq */
350
#define DRM_DP_SIDEBAND_TX_START_SEND 1
352
#define DRM_DP_SIDEBAND_TX_START_SEND 1
351
/* msg has finished transmitting on a slot - removed from msgq only in slot */
353
/* msg has finished transmitting on a slot - removed from msgq only in slot */
352
#define DRM_DP_SIDEBAND_TX_SENT 2
354
#define DRM_DP_SIDEBAND_TX_SENT 2
353
/* msg has received a response - removed from slot */
355
/* msg has received a response - removed from slot */
354
#define DRM_DP_SIDEBAND_TX_RX 3
356
#define DRM_DP_SIDEBAND_TX_RX 3
355
#define DRM_DP_SIDEBAND_TX_TIMEOUT 4
357
#define DRM_DP_SIDEBAND_TX_TIMEOUT 4
356
 
358
 
357
struct drm_dp_sideband_msg_tx {
359
struct drm_dp_sideband_msg_tx {
358
	u8 msg[256];
360
	u8 msg[256];
359
	u8 chunk[48];
361
	u8 chunk[48];
360
	u8 cur_offset;
362
	u8 cur_offset;
361
	u8 cur_len;
363
	u8 cur_len;
362
	struct drm_dp_mst_branch *dst;
364
	struct drm_dp_mst_branch *dst;
363
	struct list_head next;
365
	struct list_head next;
364
	int seqno;
366
	int seqno;
365
	int state;
367
	int state;
366
	bool path_msg;
368
	bool path_msg;
367
	struct drm_dp_sideband_msg_reply_body reply;
369
	struct drm_dp_sideband_msg_reply_body reply;
368
};
370
};
369
 
371
 
370
/* sideband msg handler */
372
/* sideband msg handler */
371
struct drm_dp_mst_topology_mgr;
373
struct drm_dp_mst_topology_mgr;
372
struct drm_dp_mst_topology_cbs {
374
struct drm_dp_mst_topology_cbs {
373
	/* create a connector for a port */
375
	/* create a connector for a port */
374
	struct drm_connector *(*add_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, char *path);
376
	struct drm_connector *(*add_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, const char *path);
375
	void (*destroy_connector)(struct drm_dp_mst_topology_mgr *mgr,
377
	void (*destroy_connector)(struct drm_dp_mst_topology_mgr *mgr,
376
				  struct drm_connector *connector);
378
				  struct drm_connector *connector);
377
	void (*hotplug)(struct drm_dp_mst_topology_mgr *mgr);
379
	void (*hotplug)(struct drm_dp_mst_topology_mgr *mgr);
378
 
380
 
379
};
381
};
380
 
382
 
381
#define DP_MAX_PAYLOAD (sizeof(unsigned long) * 8)
383
#define DP_MAX_PAYLOAD (sizeof(unsigned long) * 8)
382
 
384
 
383
#define DP_PAYLOAD_LOCAL 1
385
#define DP_PAYLOAD_LOCAL 1
384
#define DP_PAYLOAD_REMOTE 2
386
#define DP_PAYLOAD_REMOTE 2
385
#define DP_PAYLOAD_DELETE_LOCAL 3
387
#define DP_PAYLOAD_DELETE_LOCAL 3
386
 
388
 
387
struct drm_dp_payload {
389
struct drm_dp_payload {
388
	int payload_state;
390
	int payload_state;
389
	int start_slot;
391
	int start_slot;
390
	int num_slots;
392
	int num_slots;
-
 
393
	int vcpi;
391
};
394
};
392
 
395
 
393
/**
396
/**
394
 * struct drm_dp_mst_topology_mgr - DisplayPort MST manager
397
 * struct drm_dp_mst_topology_mgr - DisplayPort MST manager
395
 * @dev: device pointer for adding i2c devices etc.
398
 * @dev: device pointer for adding i2c devices etc.
396
 * @cbs: callbacks for connector addition and destruction.
399
 * @cbs: callbacks for connector addition and destruction.
397
 * @max_dpcd_transaction_bytes - maximum number of bytes to read/write in one go.
400
 * @max_dpcd_transaction_bytes - maximum number of bytes to read/write in one go.
398
 * @aux: aux channel for the DP connector.
401
 * @aux: aux channel for the DP connector.
399
 * @max_payloads: maximum number of payloads the GPU can generate.
402
 * @max_payloads: maximum number of payloads the GPU can generate.
400
 * @conn_base_id: DRM connector ID this mgr is connected to.
403
 * @conn_base_id: DRM connector ID this mgr is connected to.
401
 * @down_rep_recv: msg receiver state for down replies.
404
 * @down_rep_recv: msg receiver state for down replies.
402
 * @up_req_recv: msg receiver state for up requests.
405
 * @up_req_recv: msg receiver state for up requests.
403
 * @lock: protects mst state, primary, guid, dpcd.
406
 * @lock: protects mst state, primary, guid, dpcd.
404
 * @mst_state: if this manager is enabled for an MST capable port.
407
 * @mst_state: if this manager is enabled for an MST capable port.
405
 * @mst_primary: pointer to the primary branch device.
408
 * @mst_primary: pointer to the primary branch device.
406
 * @guid_valid: GUID valid for the primary branch device.
409
 * @guid_valid: GUID valid for the primary branch device.
407
 * @guid: GUID for primary port.
410
 * @guid: GUID for primary port.
408
 * @dpcd: cache of DPCD for primary port.
411
 * @dpcd: cache of DPCD for primary port.
409
 * @pbn_div: PBN to slots divisor.
412
 * @pbn_div: PBN to slots divisor.
410
 *
413
 *
411
 * This struct represents the toplevel displayport MST topology manager.
414
 * This struct represents the toplevel displayport MST topology manager.
412
 * There should be one instance of this for every MST capable DP connector
415
 * There should be one instance of this for every MST capable DP connector
413
 * on the GPU.
416
 * on the GPU.
414
 */
417
 */
415
struct drm_dp_mst_topology_mgr {
418
struct drm_dp_mst_topology_mgr {
416
 
419
 
417
	struct device *dev;
420
	struct device *dev;
418
	struct drm_dp_mst_topology_cbs *cbs;
421
	struct drm_dp_mst_topology_cbs *cbs;
419
	int max_dpcd_transaction_bytes;
422
	int max_dpcd_transaction_bytes;
420
	struct drm_dp_aux *aux; /* auxch for this topology mgr to use */
423
	struct drm_dp_aux *aux; /* auxch for this topology mgr to use */
421
	int max_payloads;
424
	int max_payloads;
422
	int conn_base_id;
425
	int conn_base_id;
423
 
426
 
424
	/* only ever accessed from the workqueue - which should be serialised */
427
	/* only ever accessed from the workqueue - which should be serialised */
425
	struct drm_dp_sideband_msg_rx down_rep_recv;
428
	struct drm_dp_sideband_msg_rx down_rep_recv;
426
	struct drm_dp_sideband_msg_rx up_req_recv;
429
	struct drm_dp_sideband_msg_rx up_req_recv;
427
 
430
 
428
	/* pointer to info about the initial MST device */
431
	/* pointer to info about the initial MST device */
429
	struct mutex lock; /* protects mst_state + primary + guid + dpcd */
432
	struct mutex lock; /* protects mst_state + primary + guid + dpcd */
430
 
433
 
431
	bool mst_state;
434
	bool mst_state;
432
	struct drm_dp_mst_branch *mst_primary;
435
	struct drm_dp_mst_branch *mst_primary;
433
	/* primary MST device GUID */
436
	/* primary MST device GUID */
434
	bool guid_valid;
437
	bool guid_valid;
435
	u8 guid[16];
438
	u8 guid[16];
436
	u8 dpcd[DP_RECEIVER_CAP_SIZE];
439
	u8 dpcd[DP_RECEIVER_CAP_SIZE];
437
	u8 sink_count;
440
	u8 sink_count;
438
	int pbn_div;
441
	int pbn_div;
439
	int total_slots;
442
	int total_slots;
440
	int avail_slots;
443
	int avail_slots;
441
	int total_pbn;
444
	int total_pbn;
442
 
445
 
443
	/* messages to be transmitted */
446
	/* messages to be transmitted */
444
	/* qlock protects the upq/downq and in_progress,
447
	/* qlock protects the upq/downq and in_progress,
445
	   the mstb tx_slots and txmsg->state once they are queued */
448
	   the mstb tx_slots and txmsg->state once they are queued */
446
    struct mutex qlock;
449
    struct mutex qlock;
447
	struct list_head tx_msg_downq;
450
	struct list_head tx_msg_downq;
448
	struct list_head tx_msg_upq;
451
	struct list_head tx_msg_upq;
449
	bool tx_down_in_progress;
452
	bool tx_down_in_progress;
450
	bool tx_up_in_progress;
453
	bool tx_up_in_progress;
451
 
454
 
452
	/* payload info + lock for it */
455
	/* payload info + lock for it */
453
	struct mutex payload_lock;
456
	struct mutex payload_lock;
454
	struct drm_dp_vcpi **proposed_vcpis;
457
	struct drm_dp_vcpi **proposed_vcpis;
455
	struct drm_dp_payload *payloads;
458
	struct drm_dp_payload *payloads;
456
	unsigned long payload_mask;
459
	unsigned long payload_mask;
-
 
460
	unsigned long vcpi_mask;
457
 
461
 
458
	wait_queue_head_t tx_waitq;
462
	wait_queue_head_t tx_waitq;
459
	struct work_struct work;
463
	struct work_struct work;
460
 
464
 
461
	struct work_struct tx_work;
465
	struct work_struct tx_work;
462
};
466
};
463
 
467
 
464
int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, struct device *dev, struct drm_dp_aux *aux, int max_dpcd_transaction_bytes, int max_payloads, int conn_base_id);
468
int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, struct device *dev, struct drm_dp_aux *aux, int max_dpcd_transaction_bytes, int max_payloads, int conn_base_id);
465
 
469
 
466
void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr);
470
void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr);
467
 
471
 
468
 
472
 
469
int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool mst_state);
473
int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool mst_state);
470
 
474
 
471
 
475
 
472
int drm_dp_mst_hpd_irq(struct drm_dp_mst_topology_mgr *mgr, u8 *esi, bool *handled);
476
int drm_dp_mst_hpd_irq(struct drm_dp_mst_topology_mgr *mgr, u8 *esi, bool *handled);
473
 
477
 
474
 
478
 
475
enum drm_connector_status drm_dp_mst_detect_port(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
479
enum drm_connector_status drm_dp_mst_detect_port(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
476
 
480
 
477
struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
481
struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
478
 
482
 
479
 
483
 
480
int drm_dp_calc_pbn_mode(int clock, int bpp);
484
int drm_dp_calc_pbn_mode(int clock, int bpp);
481
 
485
 
482
 
486
 
483
bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, int pbn, int *slots);
487
bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, int pbn, int *slots);
484
 
488
 
485
 
489
 
486
void drm_dp_mst_reset_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
490
void drm_dp_mst_reset_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
487
 
491
 
488
 
492
 
489
void drm_dp_mst_deallocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
493
void drm_dp_mst_deallocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
490
				struct drm_dp_mst_port *port);
494
				struct drm_dp_mst_port *port);
491
 
495
 
492
 
496
 
493
int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr,
497
int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr,
494
			   int pbn);
498
			   int pbn);
495
 
499
 
496
 
500
 
497
int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr);
501
int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr);
498
 
502
 
499
 
503
 
500
int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr);
504
int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr);
501
 
505
 
502
int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr);
506
int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr);
503
 
507
 
504
void drm_dp_mst_dump_topology(struct seq_file *m,
508
void drm_dp_mst_dump_topology(struct seq_file *m,
505
			      struct drm_dp_mst_topology_mgr *mgr);
509
			      struct drm_dp_mst_topology_mgr *mgr);
506
 
510
 
507
void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr);
511
void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr);
508
int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr);
512
int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr);
509
#endif
513
#endif