forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathdcp-internal.h
More file actions
278 lines (211 loc) · 6.34 KB
/
dcp-internal.h
File metadata and controls
278 lines (211 loc) · 6.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/* Copyright 2021 Alyssa Rosenzweig */
#ifndef __APPLE_DCP_INTERNAL_H__
#define __APPLE_DCP_INTERNAL_H__
#include <linux/backlight.h>
#include <linux/device.h>
#include <linux/ioport.h>
#include <linux/mutex.h>
#include <linux/mux/consumer.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
#include <linux/usb/typec_mux.h>
#include "dptxep.h"
#include "iomfb.h"
#include "iomfb_v12_3.h"
#include "iomfb_v13_3.h"
#include "epic/dpavservep.h"
#define DCP_MAX_PLANES 2
struct apple_dcp;
struct apple_dcp_afkep;
struct dcpav_service_epic;
enum dcp_firmware_version {
DCP_FIRMWARE_UNKNOWN,
DCP_FIRMWARE_V_12_3,
DCP_FIRMWARE_V_13_5,
};
enum {
SYSTEM_ENDPOINT = 0x20,
TEST_ENDPOINT = 0x21,
DCP_EXPERT_ENDPOINT = 0x22,
DISP0_ENDPOINT = 0x23,
DPAVSERV_ENDPOINT = 0x28,
AV_ENDPOINT = 0x29,
DPTX_ENDPOINT = 0x2a,
HDCP_ENDPOINT = 0x2b,
REMOTE_ALLOC_ENDPOINT = 0x2d,
IOMFB_ENDPOINT = 0x37,
};
/* Temporary backing for a chunked transfer via setDCPAVPropStart/Chunk/End */
struct dcp_chunks {
size_t length;
void *data;
};
#define DCP_MAX_MAPPINGS (128) /* should be enough */
#define MAX_DISP_REGISTERS (7)
struct dcp_mem_descriptor {
size_t size;
void *buf;
dma_addr_t dva;
struct sg_table map;
u64 reg;
};
/* Limit on call stack depth (arbitrary). Some nesting is required */
#define DCP_MAX_CALL_DEPTH 8
typedef void (*dcp_callback_t)(struct apple_dcp *, void *, void *);
struct dcp_channel {
dcp_callback_t callbacks[DCP_MAX_CALL_DEPTH];
void *cookies[DCP_MAX_CALL_DEPTH];
void *output[DCP_MAX_CALL_DEPTH];
u16 end[DCP_MAX_CALL_DEPTH];
/* Current depth of the call stack. Less than DCP_MAX_CALL_DEPTH */
u8 depth;
/* Already warned about busy channel */
bool warned_busy;
};
struct dcp_fb_reference {
struct list_head head;
struct drm_framebuffer *fb;
u32 swap_id;
};
#define MAX_NOTCH_HEIGHT 160
struct dcp_brightness {
struct backlight_device *bl_dev;
u32 maximum;
u32 dac;
int nits;
int scale;
bool update;
};
struct audiosrv_data;
/** laptop/AiO integrated panel parameters from DT */
struct dcp_panel {
/// panel width in millimeter
int width_mm;
/// panel height in millimeter
int height_mm;
/// panel has a mini-LED backlight
bool has_mini_led;
};
struct apple_dcp_hw_data {
u32 num_dptx_ports;
};
/* TODO: move IOMFB members to its own struct */
struct apple_dcp {
struct device *dev;
struct platform_device *piodma;
struct iommu_domain *iommu_dom;
struct apple_rtkit *rtk;
struct apple_crtc *crtc;
struct apple_connector *connector;
struct apple_dcp_hw_data hw;
/* firmware version and compatible firmware version */
enum dcp_firmware_version fw_compat;
/* Coprocessor control register */
void __iomem *coproc_reg;
/* DCP has crashed */
bool crashed;
/************* IOMFB **************************************************
* everything below is mostly used inside IOMFB but it could make *
* sense to keep some of the members in apple_dcp. *
**********************************************************************/
/* clock rate request by dcp in */
struct clk *clk;
/* DCP shared memory */
void *shmem;
/* Display registers mappable to the DCP */
struct resource *disp_registers[MAX_DISP_REGISTERS];
unsigned int nr_disp_registers;
struct resource disp_bw_scratch_res;
struct resource disp_bw_doorbell_res;
u32 disp_bw_scratch_index;
u32 disp_bw_scratch_offset;
u32 disp_bw_doorbell_index;
u32 disp_bw_doorbell_offset;
u32 index;
/* Bitmap of memory descriptors used for mappings made by the DCP */
DECLARE_BITMAP(memdesc_map, DCP_MAX_MAPPINGS);
/* Indexed table of memory descriptors */
struct dcp_mem_descriptor memdesc[DCP_MAX_MAPPINGS];
struct dcp_channel ch_cmd, ch_oobcmd;
struct dcp_channel ch_cb, ch_oobcb, ch_async, ch_oobasync;
/* iomfb EP callback handlers */
const iomfb_cb_handler *cb_handlers;
/* Active chunked transfer. There can only be one at a time. */
struct dcp_chunks chunks;
/* Queued swap. Owned by the DCP to avoid per-swap memory allocation */
union {
struct dcp_swap_submit_req_v12_3 v12_3;
struct dcp_swap_submit_req_v13_3 v13_3;
} swap;
/* swap id of the last completed swap */
u32 last_swap_id;
ktime_t swap_start;
/* Current display mode */
bool during_modeset;
bool valid_mode;
bool use_timestamps;
bool vrr_enabled;
struct dcp_set_digital_out_mode_req mode;
/* completion for active turning true */
struct completion start_done;
/* Is the DCP booted? */
bool active;
/* eDP display without DP-HDMI conversion */
bool main_display;
/* clear all surfaces on init */
bool surfaces_cleared;
/* enable CRC calculation */
bool crc_enabled;
/* Modes valid for the connected display */
struct dcp_display_mode *modes;
unsigned int nr_modes;
/* Attributes of the connector */
int connector_type;
/* Attributes of the connected display */
int width_mm, height_mm;
unsigned notch_height;
/* Workqueue for sending vblank events when a dcp swap is not possible */
struct work_struct vblank_wq;
/* List of referenced drm_framebuffers which can be unreferenced
* on the next successfully completed swap.
*/
struct list_head swapped_out_fbs;
struct dcp_brightness brightness;
/* Workqueue for updating the initial brightness */
struct work_struct bl_register_wq;
struct mutex bl_register_mutex;
/* Workqueue for updating the brightness */
struct work_struct bl_update_wq;
/* integrated panel if present */
struct dcp_panel panel;
struct apple_dcp_afkep *systemep;
struct completion systemep_done;
struct apple_dcp_afkep *ibootep;
struct apple_dcp_afkep *dcpavservep;
struct dcpavserv dcpavserv;
struct apple_dcp_afkep *avep;
struct audiosrv_data *audiosrv;
struct apple_dcp_afkep *dptxep;
struct dptx_port dptxport[2];
/* debugfs entries */
struct dentry *ep_debugfs[0x20];
/* these fields are output port specific */
struct phy *phy;
struct mux_control *xbar;
struct typec_mux *typec_mux;
struct gpio_desc *hdmi_hpd;
struct gpio_desc *hdmi_pwren;
struct gpio_desc *dp2hdmi_pwren;
struct mutex hpd_mutex;
u32 dptx_phy;
u32 dptx_die;
int hdmi_hpd_irq;
};
void dcp_drm_crtc_page_flip(struct apple_dcp *dcp, ktime_t now);
int dcp_backlight_register(struct apple_dcp *dcp);
int dcp_backlight_update(struct apple_dcp *dcp);
bool dcp_has_panel(struct apple_dcp *dcp);
#define DCP_AUDIO_MAX_CHANS 15
#endif /* __APPLE_DCP_INTERNAL_H__ */