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
2 changes: 1 addition & 1 deletion drivers/gpu/drm/apple/dcp-display-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int dcp_metadata_block(struct edid *edid, const struct dcp_display_metada
coordinate[i] = DIV_ROUND_CLOSEST(value, 64);
if (!coordinate[i] || coordinate[i] > 1023)
return -EINVAL;
if ((i & 1) && coordinate[i - 1] + coordinate[i] > 1024)
if (i == 7 && coordinate[6] + coordinate[7] > 1024)
return -EINVAL;
}
/* Degenerate primaries or a white point outside their triangle are not usable. */
Expand Down
11 changes: 9 additions & 2 deletions drivers/gpu/drm/apple/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,11 @@ static int parse_metadata_point(struct dcp_parse_ctx *handle, u32 point[2], u32
if (ret)
return ret;
}
if (seen != (gamma ? 7 : 3) || point[0] + point[1] > 65536)
/*
* A white point is a chromaticity. A primary is passed on as the
* sink reports it: real EDIDs carry primaries with x + y above 1.
*/
if (seen != (gamma ? 7 : 3) || (gamma && point[0] + point[1] > 65536))
return -EINVAL;
return 0;
}
Expand Down Expand Up @@ -1525,7 +1529,10 @@ static int parse_metadata_luminance(struct dcp_parse_ctx *handle,
ret = parse_metadata_number(handle, &values[i], 0, U32_MAX);
}
}
if (!ret && seen == 7 && values[0] && values[1] <= values[0] &&
/* A sink may leave out its frame-average or minimum luminance. */
if (!(seen & 2))
values[1] = values[0];
if (!ret && (seen & 1) && values[0] && values[1] <= values[0] &&
values[2] < values[0]) {
out->max_luminance = values[0];
out->max_fall = values[1];
Expand Down
21 changes: 20 additions & 1 deletion tools/testing/selftests/drivers/gpu/apple-dcp/rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ def wire(value, out):
"Colorimetry": 10, "Depth": 10, "DynamicRange": 0, "EOTF": 0}],
"ID": 62, "Score": 16224, "IsPreferred": True, "IsInterlaced": False, "IsVirtual": False,
}]
sink = copy.deepcopy(fixture)
sink['Chromaticity']['Red'] = {'X': 45248, 'Y': 20992}
del sink['Luminance']['Min']
sink_raw = bytearray(struct.pack('<I', 0xd3))
wire(sink, sink_raw)
timing_raw = bytearray(struct.pack('<I', 0xd3))
wire(timing_fixture, timing_raw)
timing_source = 'static const unsigned char timing_blob[] = {' + ','.join(map(str,timing_raw)) + '};\n'
timing_source += 'static const unsigned char sink_blob[] = {' + ','.join(map(str,sink_raw)) + '};\n'
# A desktop timing with PQ elements: 10-bit preferred, unsafe ones skipped.
def color(i, score, depth, eotf, colorimetry, encoding=0, dynamic=0):
return {"ID": i, "Score": score, "IsVirtual": False, "PixelEncoding": encoding,
Expand Down Expand Up @@ -335,6 +341,19 @@ def color(i, score, depth, eotf, colorimetry, encoding=0, dynamic=0):
assert(metadata.pq && metadata.static_metadata_type1 && metadata.bt2020_rgb);
assert(metadata.max_luminance == 27375011 && metadata.max_fall == 25652679 &&
metadata.min_luminance == 5154);
{
/* Primaries pass as reported; a missing Min is 0, a missing frame average the Max. */
struct dcp_parse_ctx c;
struct dcp_display_metadata s;
assert(!parse(sink_blob, sizeof(sink_blob), &c) && !parse_display_metadata(&c, &s));
assert(s.chromaticity[0][0] == 45248 && s.chromaticity[0][1] == 20992);
assert(s.max_luminance == 27375011 && s.max_fall == 25652679 && s.min_luminance == 0);
const struct drm_edid *e = dcp_metadata_edid(&s, &mode);
assert(!IS_ERR(e));
const u8 *r = (const u8 *)&e->raw;
assert((r[27] << 2 | (r[25] >> 6 & 3)) == 707 && (r[28] << 2 | (r[25] >> 4 & 3)) == 328);
drm_edid_free(e);
}
const struct drm_edid *edid = dcp_metadata_edid(&metadata, &mode);
assert(!IS_ERR(edid) && edid->size == 256);
f = fopen(argv[3], "wb"); assert(f);
Expand Down Expand Up @@ -1172,7 +1191,7 @@ def metadata(root, output):
for path, value in [
(('MaxHorizontalImageSize',), 256), (('MaxVerticalImageSize',), '33'),
(('Chromaticity', 'Red', 'X'), True), (('Chromaticity', 'Blue', 'Y'), 65536),
(('Chromaticity', 'Green', 'Y'), 64000), (('DefaultWhitePoint', 'Gamma'), 65535),
(('DefaultWhitePoint', 'Y'), 64000), (('DefaultWhitePoint', 'Gamma'), 65535),
(('DefaultWhitePoint', 'Gamma'), 240000), (('ProductAttributes', 'ManufacturerID'), 'AC'),
(('ProductAttributes', 'ManufacturerID'), 'A\0R'), (('ProductAttributes', 'LegacyManufacturerID'), 1),
(('ProductAttributes', 'ProductName'), 'x' * 14), (('ProductAttributes', 'ProductID'), 65536),
Expand Down