Skip to content
Merged
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
20 changes: 20 additions & 0 deletions drivers/gpu/drm/apple/dcp-sdr-edid.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,24 @@ static inline size_t dcp_edid_sdr(u8 *edid, size_t size)
return output;
}

/*
* dcp_edid_sdr() for an output without an sRGB contract, whose link carries
* SDR RGB in the sink's own gamut: the sink's primaries are what its frames
* are shown with, so they stay.
*/
static inline size_t dcp_edid_sdr_native(u8 *edid, size_t size)
{
u8 primaries[DCP_EDID_CHROMATICITY_SIZE];

if (size < DCP_EDID_BLOCK_SIZE)
return 0;
memcpy(primaries, edid + DCP_EDID_CHROMATICITY, sizeof(primaries));
size = dcp_edid_sdr(edid, size);
if (size) {
memcpy(edid + DCP_EDID_CHROMATICITY, primaries, sizeof(primaries));
dcp_edid_checksum(edid);
}
return size;
}

#endif
10 changes: 5 additions & 5 deletions drivers/gpu/drm/apple/iomfb_m4.c
Original file line number Diff line number Diff line change
Expand Up @@ -3334,10 +3334,10 @@ int iomfb_m4_ext_get_modes(struct apple_dcp *owner, struct drm_connector *connec
}

/*
* The EDID the connector publishes, as native26's (dcp_edid_sdr()): this
* scanout is 8-bpc RGB SDR, so the sink's colour capabilities, deep colour
* and 4:2:0 timings go. The last would otherwise make the probe helper prune
* the catalog's mode of a timing the sink lists as 4:2:0 only.
* The EDID the connector publishes (dcp_edid_sdr_native()): this scanout is
* 8-bpc RGB SDR, so the sink's colour capabilities, deep colour and 4:2:0
* timings go. The last would otherwise make the probe helper prune the
* catalog's mode of a timing the sink lists as 4:2:0 only. Its primaries stay.
*/
static const struct drm_edid *iomfb_m4_ext_edid_sdr(const struct drm_edid *edid)
{
Expand All @@ -3352,7 +3352,7 @@ static const struct drm_edid *iomfb_m4_ext_edid_sdr(const struct drm_edid *edid)
copy = kmemdup(raw, size, GFP_KERNEL);
if (!copy)
return ERR_PTR(-ENOMEM);
size = dcp_edid_sdr(copy, size);
size = dcp_edid_sdr_native(copy, size);
sdr = size ? drm_edid_alloc(copy, size) : ERR_PTR(-EPROTO);
kfree(copy);
return sdr ?: ERR_PTR(-ENOMEM);
Expand Down
9 changes: 8 additions & 1 deletion tools/asahi/dcpext26-edid-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,19 @@ def function(name):
memcpy(original,sdr,256);assert(dcp_edid_sdr(sdr,256)==256);assert(!memcmp(sdr,original,256));
for(unsigned n=0;n<128;n++)assert(!dcp_edid_sdr(sdr,n));
assert(!dcp_edid_sdr(sdr,128));
/* The sink's own primaries kept, the rest as above and the checksum right. */
u8 native[384];memset(sdr+25,0x55,10);checksum(sdr);memcpy(native,sdr,sizeof(native));
assert(dcp_edid_sdr(sdr,256)==256);assert(dcp_edid_sdr_native(native,256)==256);
for(unsigned i=0;i<256;i++)assert(native[i]==(i>=25&&i<35?0x55:i==127?native[127]:sdr[i]));
{u8 sum=0;for(unsigned j=0;j<128;j++)sum+=native[j];assert(!sum);}
for(unsigned n=0;n<128;n++)assert(!dcp_edid_sdr_native(native,n));
assert(!dcp_edid_sdr_native(native,128));
/* A CTA with no data collection can still advertise basic stereo audio. */
memset(sdr,0,sizeof(sdr));memcpy(sdr,header,8);sdr[126]=1;
cta=sdr+128;cta[0]=2;cta[1]=3;cta[3]=0x40;checksum(sdr);checksum(cta);
assert(dcp_edid_sdr(sdr,256)==256);assert(sdr[126]==1 && cta[3]==0x40);

puts("PASS SDR EDID identity, audio, timing, colour removal, checksums, bounds and idempotence");
puts("PASS SDR EDID identity, audio, timing, colour removal, native primaries, checksums, bounds and idempotence");
puts("PASS native26 AV identity, stale attachment/owner, bounded EDID length, extension count and checksum failures");
}
'''
Expand Down
4 changes: 3 additions & 1 deletion tools/testing/selftests/drivers/gpu/apple-dcp/rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,8 +1072,10 @@ def publication(root):
if 'dcp_edid_sdr(' in publication:
# Keep extracting the real publication path, including its SDR helper.
# Model only kernel allocation/DRM ownership at the host boundary.
# dcp_edid_sdr_native() is the M4 outputs', not this path's.
sdr = '\n'.join(line for line in (base / 'dcp-sdr-edid.h').read_text().splitlines()
if not line.startswith('#include'))
if not line.startswith('#include')).replace(
'static inline ', 'static inline __attribute__((unused)) ')
publication = sdr + r"""
static void *kmemdup(const void *data,size_t size,int gfp) {
(void)gfp;void *copy=malloc(size);if(copy)memcpy(copy,data,size);return copy;
Expand Down
Loading