Skip to contentSkip to conversation

drm: Fix HDMI_STATIC_METADATA_TYPE1 constant.

PATCH In review Mario Kleiner 3 participants 19 messages Jan 24, 2021 – Feb 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Fix HDMI_STATIC_METADATA_TYPE1 constant.

According to the CTA 861.G spec, HDMI_STATIC_METADATA_TYPE1 is not 1, but zero, so fix this enum.

While this doesn't cause problems in the kernel yet, as the constant isn't actively used by drivers yet, it did create confusion while debugging HDR problems in yours truly, and also potential bugs in userspace components, as the wrong enum propagates to components, e.g., like it did already into intel-gpu-tools (tests/kms_hdr.c) or is used as wrong reference when writing future new userspace HDR components like compositors.

Fixes fbb5d0353c62 ("drm: Add HDR source metadata property")
Cc Uma Shankar <[email protected]>
Cc Shashank Sharma <[email protected]>
Cc Ville Syrjälä <[email protected]>
---
 include/linux/hdmi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/hdmi.h +1 -1
index 9850d59d6f1c..c8ec982ff498 100644
@@ -156,7 +156,7 @@ enum hdmi_content_type {
 };
 
 enum hdmi_metadata_type {
-	HDMI_STATIC_METADATA_TYPE1 = 1,
+	HDMI_STATIC_METADATA_TYPE1 = 0,
 };
 
 enum hdmi_eotf {
Signature · 6 lines
2.25.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 12 lines · Mario Kleiner

According to the CTA 861.G spec, HDMI_STATIC_METADATA_TYPE1 is not 1, but zero, so fix this enum.

While this doesn't cause problems in the kernel yet, as the constant isn't actively used by drivers yet, it did create confusion while debugging HDR problems in yours truly, and also potential bugs in userspace components, as the wrong enum propagates to components, e.g., like it did already into intel-gpu-tools (tests/kms_hdr.c) or is used as wrong reference when writing future new userspace HDR components like compositors.

Quoted 5 lines
Fixes fbb5d0353c62 ("drm: Add HDR source metadata property")
Cc Uma Shankar <[email protected]>
Cc Shashank Sharma <[email protected]>
Cc Ville Syrjälä <[email protected]>

Sadly I think it's too late for this. Some user-space (like Kodi) already has copied over the kernel definitions, and libdrm already has a release with the wrong value.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 21 lines · Simon Ser
Quoted 12 lines · Mario Kleiner

According to the CTA 861.G spec, HDMI_STATIC_METADATA_TYPE1 is not 1, but zero, so fix this enum.

While this doesn't cause problems in the kernel yet, as the constant isn't actively used by drivers yet, it did create confusion while debugging HDR problems in yours truly, and also potential bugs in userspace components, as the wrong enum propagates to components, e.g., like it did already into intel-gpu-tools (tests/kms_hdr.c) or is used as wrong reference when writing future new userspace HDR components like compositors.

Quoted 5 lines
Fixes fbb5d0353c62 ("drm: Add HDR source metadata property")
Cc Uma Shankar <[email protected]>
Cc Shashank Sharma <[email protected]>
Cc Ville Syrjälä <[email protected]>
Quoted 4 lines

Sadly I think it's too late for this. Some user-space (like Kodi) already has copied over the kernel definitions, and libdrm already has a release with the wrong value.

But it still needs to be fixed if we want working HDR. I thought libdrm copies the definitions from the kernel periodically, so the fix should propagate?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 3 lines · Mario Kleiner

But it still needs to be fixed if we want working HDR. I thought libdrm copies the definitions from the kernel periodically, so the fix should propagate?

There will always be user-space that sends 1 instead of 0. This shouldn't fail on more recent kernels or it will be a regression.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 10 lines · Simon Ser
Quoted 3 lines · Mario Kleiner

But it still needs to be fixed if we want working HDR. I thought libdrm copies the definitions from the kernel periodically, so the fix should propagate?

There will always be user-space that sends 1 instead of 0. This shouldn't fail on more recent kernels or it will be a regression.

Yes, i know, regressing user-space is bad, but in this very specific case a "good" one, if ever. At the moment, it wouldn't regress userspace simply because the kernel doesn't actually check for the correct value in its HDR metadata handling. But the value itself is sent as HDMI HDR metadata to the attached HDR display monitor, so if the monitors firmware checks, it will classify the wrong value of 1 as invalid and disable HDR mode on the display, which is certainly not what a HDR client application wants. And future HDR standards which will actually allocate the value 1 to a different mode of HDR operation will switch to the wrong mode / misinterpret the sent HDR metadata with hillarious results, which is also not in the interest of a HDR client application, or a HDR capable compositor.

Iow. if clients continue to use the wrong value 1 then HDR display will break in various ways on correctly implemented HDR displays, but in a mystifying and hard to debug way. The kernel rejecting a wrong setting explicitly and forcing a bug fix in the client would be a blessing in this case.

I spent weeks last year, going in circles and hunting ghost bugs related to HDR because much of the HDR stuff, both drivers and monitor firmware seems to be in not a great shape. "Less wrong" would be a big step forward. Especially with the cheaper HDR monitors it is difficult to see when things go wrong, because we don't have good expectations on how proper HDR should look and the lower end HDR displays don't help.

-mario

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 32 lines · Mario Kleiner
Quoted 10 lines · Simon Ser
Quoted 3 lines · Mario Kleiner

But it still needs to be fixed if we want working HDR. I thought libdrm copies the definitions from the kernel periodically, so the fix should propagate?

There will always be user-space that sends 1 instead of 0. This shouldn't fail on more recent kernels or it will be a regression.

Yes, i know, regressing user-space is bad, but in this very specific case a "good" one, if ever. At the moment, it wouldn't regress userspace simply because the kernel doesn't actually check for the correct value in its HDR metadata handling. But the value itself is sent as HDMI HDR metadata to the attached HDR display monitor, so if the monitors firmware checks, it will classify the wrong value of 1 as invalid and disable HDR mode on the display, which is certainly not what a HDR client application wants. And future HDR standards which will actually allocate the value 1 to a different mode of HDR operation will switch to the wrong mode / misinterpret the sent HDR metadata with hillarious results, which is also not in the interest of a HDR client application, or a HDR capable compositor.

Iow. if clients continue to use the wrong value 1 then HDR display will break in various ways on correctly implemented HDR displays, but in a mystifying and hard to debug way. The kernel rejecting a wrong setting explicitly and forcing a bug fix in the client would be a blessing in this case.

Quoted 6 lines

I spent weeks last year, going in circles and hunting ghost bugs related to HDR because much of the HDR stuff, both drivers and monitor firmware seems to be in not a great shape. "Less wrong" would be a big step forward. Especially with the cheaper HDR monitors it is difficult to see when things go wrong, because we don't have good expectations on how proper HDR should look and the lower end HDR displays don't help.

This is not an uapi defintion anyway so fixing should be fine. I don't think we even check any of the client provided values, or do we? EOTF I think we do check, but IMO that check should probably just be nuked as well if we don't bother checking anything else.

I was in fact going to suggest nuking this entire hdr_sink_metadata parsing as unused, but looks like amdgpu has started to use it for some backlight stuff of all things.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw
Quoted 5 lines · Simon Ser
Quoted 1 line

This is not an uapi defintion anyway so fixing should be fine.

Oh, my bad, I thought this was in drm_mode.h, but it's not. Then yeah should be completely fine to fix it.

Good! The beginning of the end of a sad story ;). So i guess i can get your r-b's for it?

Will this fix propagate into igt and libdrm? Or are separate fixup patches needed?

Simon, could you let the Kodi devs know in case you have a line to them? I didn't know that there is even one more real-world HDR client for Linux, apart from AMD's amdvlk Vulkan driver, which does things right and doesn't need fixing.

thanks
mario

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 10 lines · Mario Kleiner
Quoted 5 lines · Simon Ser
Quoted 1 line

This is not an uapi defintion anyway so fixing should be fine.

Oh, my bad, I thought this was in drm_mode.h, but it's not. Then yeah

should be completely fine to fix it.

Good! The beginning of the end of a sad story ;). So i guess i can get your r-b's for it?

Sorry, I haven't verified that this wouldn't break the world, so I'm not comfortable giving a R-b.

Quoted 1 line

Will this fix propagate into igt and libdrm? Or are separate fixup patches needed?

No, since this is not part of UAPI.

Quoted 4 lines

Simon, could you let the Kodi devs know in case you have a line to them? I didn't know that there is even one more real-world HDR client for Linux, apart from AMD's amdvlk Vulkan driver, which does things right and doesn't need fixing.

Seems like Kodi hardcodes the bad version:

https://github.com/xbmc/xbmc/blob/aa5c2e79c069ba7d0ab1d8ad930e4294bf554680/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h#L24

Maybe we should add the good version in UAPI header?
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw
Quoted 11 lines · Simon Ser

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 6 lines · Mario Kleiner
Quoted 4 lines · Simon Ser
Quoted 1 line

This is not an uapi defintion anyway so fixing should be fine.

Oh, my bad, I thought this was in drm_mode.h, but it's not. Then yeah

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

should be completely fine to fix it.

Good! The beginning of the end of a sad story ;). So i guess i can get your r-b's for it?

Sorry, I haven't verified that this wouldn't break the world, so I'm not comfortable giving a R-b.

Breaking the world is pretty unlikely for an unused #define, but I understand.

I guess Ville will have access to the relevant spec to verify: It is the CTA-861-G spec, table 44 in section 6.9 and also specifically section 6.9.1.

Quoted 5 lines
Quoted 1 line

Will this fix propagate into igt and libdrm? Or are separate fixup

patches needed?

No, since this is not part of UAPI.

Ok. I'll submit patches once this one landed in the kernel.

Quoted 6 lines
Quoted 5 lines

Simon, could you let the Kodi devs know in case you have a line to them? I didn't know that there is even one more real-world HDR client for Linux, apart from AMD's amdvlk Vulkan driver, which does things right and doesn't need fixing.

Quoted 6 lines

Seems like Kodi hardcodes the bad version:

https://github.com/xbmc/xbmc/blob/aa5c2e79c069ba7d0ab1d8ad930e4294bf554680/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h#L24

Thanks. I've filed an issue to them under:

https://github.com/xbmc/xbmc/issues/19122

Quoted 2 lines

Maybe we should add the good version in UAPI header?

I'm scared that future HDR definitions would be as carefully done and reviewed as this one, given how much harder it would be to fix them :/ But maybe that's just exhausted me who spent too many weeks dealing with HDR bugs everywhere.

-mario

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

Ping! Anybody wanna review the most trivial, obviously correct, and non-intrusive patch ever to fix a real bug? The Kodi devs changed their broken constant and as if by magic, some LG TV now has working HDR support, so we now know the constant is actually expected to be correct by at least some real display hw out there.

thanks,
-mario

Quoted 60 lines · Mario Kleiner
Quoted 11 lines · Simon Ser

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 6 lines · Mario Kleiner
Quoted 4 lines · Simon Ser
Quoted 1 line

This is not an uapi defintion anyway so fixing should be fine.

Oh, my bad, I thought this was in drm_mode.h, but it's not. Then yeah

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

should be completely fine to fix it.

Good! The beginning of the end of a sad story ;). So i guess i can get your r-b's for it?

Sorry, I haven't verified that this wouldn't break the world, so I'm not comfortable giving a R-b.

Breaking the world is pretty unlikely for an unused #define, but I understand.

I guess Ville will have access to the relevant spec to verify: It is the CTA-861-G spec, table 44 in section 6.9 and also specifically section 6.9.1.

Quoted 5 lines
Quoted 1 line

Will this fix propagate into igt and libdrm? Or are separate fixup

patches needed?

No, since this is not part of UAPI.

Ok. I'll submit patches once this one landed in the kernel.

Quoted 6 lines
Quoted 5 lines

Simon, could you let the Kodi devs know in case you have a line to them? I didn't know that there is even one more real-world HDR client for Linux, apart from AMD's amdvlk Vulkan driver, which does things right and doesn't need fixing.

Quoted 6 lines

Seems like Kodi hardcodes the bad version:

https://github.com/xbmc/xbmc/blob/aa5c2e79c069ba7d0ab1d8ad930e4294bf554680/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h#L24

Thanks. I've filed an issue to them under:

https://github.com/xbmc/xbmc/issues/19122

Quoted 2 lines

Maybe we should add the good version in UAPI header?

Quoted 8 lines

I'm scared that future HDR definitions would be as carefully done and reviewed as this one, given how much harder it would be to fix them :/ But maybe that's just exhausted me who spent too many weeks dealing with HDR bugs everywhere.

-mario

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw
Quoted 12 lines · Simon Ser
Quoted 1 line · Mario Kleiner

Ping!

I now understand the problem better.

I'll push to drm-misc-next in a few days if no-one complains. Ping me again if I forget.

Thanks! I'll prepare patches with the same fix for libdrm and igt as well soon.
-mario

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw
Quoted 1 line · Mario Kleiner

I'll prepare patches with the same fix for libdrm and igt as well soon.

Please don't submit patches for drm_fourcc.h to downstream if they vendor the whole file. Instead, update it from the kernel once your patch is merged to drm-next. For instance, see [1] for libdrm.

Simon

[1]: https://gitlab.freedesktop.org/mesa/drm/-/blob/master/include/drm/README
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw
Quoted 10 lines · Simon Ser
Quoted 1 line · Mario Kleiner

I'll prepare patches with the same fix for libdrm and igt as well soon.

Please don't submit patches for drm_fourcc.h to downstream if they vendor the
whole file. Instead, update it from the kernel once your patch is merged to drm-next. For instance, see [1] for libdrm.

Quoted 5 lines

Simon

[1]:
https://gitlab.freedesktop.org/mesa/drm/-/blob/master/include/drm/README

Ok. Thanks for the info,
-mario

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw
In reply to Ville Syrjälä
Quoted 44 lines · Ville Syrjälä
Quoted 9 lines · Mario Kleiner
Quoted 7 lines · Simon Ser
Quoted 3 lines · Mario Kleiner

But it still needs to be fixed if we want working HDR. I thought libdrm copies the definitions from the kernel periodically, so the fix should propagate?

Quoted 5 lines
Quoted 3 lines

There will always be user-space that sends 1 instead of 0. This shouldn't fail on more recent kernels or it will be a regression.

Yes, i know, regressing user-space is bad, but in this very specific

case a

Quoted 2 lines

"good" one, if ever. At the moment, it wouldn't regress userspace simply because the kernel doesn't actually check for the correct value in its

HDR

Quoted 1 line

metadata handling. But the value itself is sent as HDMI HDR metadata to

the

Quoted 9 lines

attached HDR display monitor, so if the monitors firmware checks, it will classify the wrong value of 1 as invalid and disable HDR mode on the display, which is certainly not what a HDR client application wants. And future HDR standards which will actually allocate the value 1 to a different mode of HDR operation will switch to the wrong mode / misinterpret the sent HDR metadata with hillarious results, which is also not in the interest of a HDR client application, or a HDR capable compositor.

Quoted 4 lines

Iow. if clients continue to use the wrong value 1 then HDR display will break in various ways on correctly implemented HDR displays, but in a mystifying and hard to debug way. The kernel rejecting a wrong setting explicitly and forcing a bug fix in the client would be a blessing in

this

Quoted 3 lines

case.

I spent weeks last year, going in circles and hunting ghost bugs related

to

Quoted 1 line

HDR because much of the HDR stuff, both drivers and monitor firmware

seems

Quoted 2 lines

to be in not a great shape. "Less wrong" would be a big step forward. Especially with the cheaper HDR monitors it is difficult to see when

things

Quoted 10 lines
Quoted 1 line

go wrong, because we don't have good expectations on how proper HDR

should

Quoted 1 line

look and the lower end HDR displays don't help.

This is not an uapi defintion anyway so fixing should be fine. I don't think we even check any of the client provided values, or do we? EOTF I think we do check, but IMO that check should probably just be nuked as well if we don't bother checking anything else.

I think we check only EOTF atm. That check does make sense though, as userspace getting that wrong will definitely knock out even low-end HDR monitors. My tests with a - supposed to be pretty good according to tests - DisplayHDR-600 monitor suggest that that's pretty much the only thing the monitor actually uses, apart from CRC checking the data packet.

Quoted 4 lines

I was in fact going to suggest nuking this entire hdr_sink_metadata parsing as unused, but looks like amdgpu has started to use it for some backlight stuff of all things.

My gut feeling says we will need this info in the kernel in the future, independent of current users. Probably especially if one wants to do interesting things which combine HDR with VRR/DP-Adaptive sync, or future HDR standards (dynamic HDR metadata?), those infos in the kernel may become quite useful.
In some way it would even be nice to have all that info exposed in parsed
form as a connector property or such, so all clients can use the same parsed data instead of reinventing the wheel. So I'd vote against nuking it.

Thanks,
-mario

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#18 lore raw
Quoted 3 lines · Mario Kleiner

 In some way it would even be nice to have all that info exposed in parsed form as a connector property or such, so all clients can use the same parsed data instead of reinventing the wheel.

So far the policy has more or less been: if the kernel doesn't need to understand it and user-space can grab it from the EDID, don't expose it as a property. Maybe a user-space library would be better to avoid reinventing the wheel.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel