Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions drivers/gpu/drm/apple/dcp-m4-frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ static inline u64 dcp_m4_nits_binary64(u32 nits)
#define DCP_M4_EXT_MAX_WIDTH 5120U
#define DCP_M4_EXT_MAX_HEIGHT 2880U

/*
* Whether the host can scan out an external output of this size: no larger
* than its surfaces and windows hold (above). Modes over it are not offered.
*/
static inline bool dcp_m4_ext_size_ok(u32 width, u32 height)
{
return width && height && width <= DCP_M4_EXT_MAX_WIDTH &&
height <= DCP_M4_EXT_MAX_HEIGHT;
}

/*
* External outputs: any qualified size up to 5120x2880, same surface layout.
* The frame must already be described at its wire DVA in an owned mapping.
Expand Down
29 changes: 17 additions & 12 deletions drivers/gpu/drm/apple/iomfb_m4.c
Original file line number Diff line number Diff line change
Expand Up @@ -3107,12 +3107,13 @@ int iomfb_m4_ext_detect(struct apple_dcp *owner)

/*
* The sink's modes for its DRM connector: the cached 8-bpc RGB SDR timings that
* fit the DPTX link at 24 bits per pixel, when the link rate and lane count
* are known (8b/10b coding); the firmware's own judgement is in the colour
* elements it marks unsafe or DSC-only, which are never used. The preferred
* one is the highest refresh rate at the sink's native size that fits, else
* the largest sink-preferred timing that fits, both at 50 Hz or more (see
* dcp_m4_ext_pick_preferred()), else 1920x1080 at 60 Hz (else the first).
* the host can scan out and that fit the DPTX link at 24 bits per pixel, when
* the link rate and lane count are known (8b/10b coding); the firmware's own
* judgement is in the colour elements it marks unsafe or DSC-only, which are
* never used. The preferred one is the highest refresh rate at the sink's
* native size that fits, else the largest sink-preferred timing that fits,
* both at 50 Hz or more (see dcp_m4_ext_pick_preferred()), else 1920x1080 at
* 60 Hz (else the first).
* Takes ext_modes_lock only, never the session.
*/
/* The DPTX link's capacity in kbit/s at 8b/10b, 0 while not known. */
Expand All @@ -3129,18 +3130,22 @@ static u64 dcp_m4_ext_capacity(struct apple_dcp *owner)
}

/*
* Whether a cached mode fits the link: at 24 bpp uncompressed, at 8 bpp (the
* lowest DSC target) with a colour that needs DSC, whose rate the firmware
* picks itself.
* Whether a cached mode can be shown: no larger than the host can scan out
* (DCP_M4_EXT_MAX_WIDTH x DCP_M4_EXT_MAX_HEIGHT), and within the link: at
* 24 bpp uncompressed, at 8 bpp (the lowest DSC target) with a colour that
* needs DSC, whose rate the firmware picks itself.
*/
static bool dcp_m4_ext_fits(const struct iomfb_m4_ext_mode *e, u64 capacity)
{
if (!dcp_m4_ext_size_ok(e->mode.hdisplay, e->mode.vdisplay))
return false;
return !capacity || (u64)e->mode.clock * (e->dsc ? 8 : 24) <= capacity;
}

/*
* The firmware's IDs of a mode iomfb_m4_ext_get_modes()
* offered: -ENOENT for any other mode, -ENOSPC for one over the link.
* offered: -ENOENT for any other mode, -ENOSPC for one over the link or
* larger than the host can scan out.
*/
int iomfb_m4_ext_mode_ids(struct apple_dcp *owner, const struct drm_display_mode *mode,
struct iomfb_m4_ext_ids *ids)
Expand Down Expand Up @@ -3270,7 +3275,7 @@ static int dcp_m4_ext_pick_preferred(struct iomfb_m4 *dcp, u64 capacity, const c
best = i;
}
if (best >= 0)
*why = "the native size is over the link: the largest preferred timing within it";
*why = "the native size does not fit: the largest preferred timing that does";
return best;
}

Expand Down Expand Up @@ -3323,7 +3328,7 @@ int iomfb_m4_ext_get_modes(struct apple_dcp *owner, struct drm_connector *connec
dcp->ext_logged_modes = added << 16 | skipped;
dcp->ext_logged_link = lanes << 16 | rate;
dcp->ext_logged_pick = pick;
dev_dbg(dcp->dev, "modes: %u of %u (%u over link %u x %u Mbit/s)%s; preferred %ux%u@%d Hz, %d kHz (%s)\n",
dev_dbg(dcp->dev, "modes: %u of %u (%u over the scanout or link %u x %u Mbit/s)%s; preferred %ux%u@%d Hz, %d kHz (%s)\n",
added, total, skipped, lanes, rate * 270,
capacity ? "" : ", link not known: not checked",
p ? p->hdisplay : 0, p ? p->vdisplay : 0, p ? drm_mode_vrefresh(p) : 0,
Expand Down
Loading