Skip to content

Commit 5a7e4c1

Browse files
jannaumarcan
authored andcommitted
drm/apple: Move panel options to its own sub-struct
Fixes overwriting the panel's physical dimensions on poweroff/sleep. Signed-off-by: Janne Grunau <[email protected]>
1 parent 7f2254d commit 5a7e4c1

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

drivers/gpu/drm/apple/dcp-internal.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ struct dcp_brightness {
8080
bool update;
8181
};
8282

83+
/** laptop/AiO integrated panel parameters from DT */
84+
struct dcp_panel {
85+
/// panel width in millimeter
86+
int width_mm;
87+
/// panel height in millimeter
88+
int height_mm;
89+
/// panel has a mini-LED backllight
90+
bool has_mini_led;
91+
};
92+
8393
/* TODO: move IOMFB members to its own struct */
8494
struct apple_dcp {
8595
struct device *dev;
@@ -146,9 +156,6 @@ struct apple_dcp {
146156
/* clear all surfaces on init */
147157
bool surfaces_cleared;
148158

149-
/* panel has a mini-LED backllight */
150-
bool has_mini_led;
151-
152159
/* Modes valid for the connected display */
153160
struct dcp_display_mode *modes;
154161
unsigned int nr_modes;
@@ -173,6 +180,9 @@ struct apple_dcp {
173180
/* Workqueue for updating the initial initial brightness */
174181
struct work_struct bl_register_wq;
175182
struct mutex bl_register_mutex;
183+
184+
/* integrated panel if present */
185+
struct dcp_panel panel;
176186
};
177187

178188
int dcp_backlight_register(struct apple_dcp *dcp);

drivers/gpu/drm/apple/dcp.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,21 @@ void dcp_drm_crtc_vblank(struct apple_crtc *crtc)
5757
void dcp_set_dimensions(struct apple_dcp *dcp)
5858
{
5959
int i;
60+
int width_mm = dcp->width_mm;
61+
int height_mm = dcp->height_mm;
62+
63+
if (width_mm == 0 || height_mm == 0) {
64+
width_mm = dcp->panel.width_mm;
65+
height_mm = dcp->panel.height_mm;
66+
}
6067

6168
/* Set the connector info */
6269
if (dcp->connector) {
6370
struct drm_connector *connector = &dcp->connector->base;
6471

6572
mutex_lock(&connector->dev->mode_config.mutex);
66-
connector->display_info.width_mm = dcp->width_mm;
67-
connector->display_info.height_mm = dcp->height_mm;
73+
connector->display_info.width_mm = width_mm;
74+
connector->display_info.height_mm = height_mm;
6875
mutex_unlock(&connector->dev->mode_config.mutex);
6976
}
7077

@@ -74,8 +81,8 @@ void dcp_set_dimensions(struct apple_dcp *dcp)
7481
* DisplayAttributes, and TimingElements may be sent first
7582
*/
7683
for (i = 0; i < dcp->nr_modes; ++i) {
77-
dcp->modes[i].mode.width_mm = dcp->width_mm;
78-
dcp->modes[i].mode.height_mm = dcp->height_mm;
84+
dcp->modes[i].mode.width_mm = width_mm;
85+
dcp->modes[i].mode.height_mm = height_mm;
7986
}
8087
}
8188

@@ -434,7 +441,7 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
434441
dcp->brightness.scale = 65536;
435442
panel_np = of_get_compatible_child(dev->of_node, "apple,panel-mini-led");
436443
if (panel_np)
437-
dcp->has_mini_led = true;
444+
dcp->panel.has_mini_led = true;
438445
else
439446
panel_np = of_get_compatible_child(dev->of_node, "apple,panel");
440447

@@ -448,10 +455,10 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
448455
dev_err(dev, "Missing property 'apple,max-brightness'\n");
449456
}
450457

451-
of_property_read_u32(panel_np, "width-mm", &dcp->width_mm);
458+
of_property_read_u32(panel_np, "width-mm", &dcp->panel.width_mm);
452459
/* use adjusted height as long as the notch is hidden */
453460
of_property_read_u32(panel_np, height_prop[!dcp->notch_height],
454-
&dcp->height_mm);
461+
&dcp->panel.height_mm);
455462

456463
of_node_put(panel_np);
457464
dcp->connector_type = DRM_MODE_CONNECTOR_eDP;

drivers/gpu/drm/apple/iomfb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ dcpep_cb_get_uint_prop(struct apple_dcp *dcp, struct dcp_get_uint_prop_req *req)
460460
.value = 0
461461
};
462462

463-
if (dcp->has_mini_led &&
463+
if (dcp->panel.has_mini_led &&
464464
memcmp(req->obj, "SUMP", sizeof(req->obj)) == 0) { /* "PMUS */
465465
if (strncmp(req->key, "Temperature", sizeof(req->key)) == 0) {
466466
/*

0 commit comments

Comments
 (0)