Skip to content

Commit f0fa69b

Browse files
ManMowermripard
authored andcommitted
drm/connector: hdmi: Fix writing Dynamic Range Mastering infoframes
The largest infoframe we create is the DRM (Dynamic Range Mastering) infoframe which is 26 bytes + a 4 byte header, for a total of 30 bytes. With HDMI_MAX_INFOFRAME_SIZE set to 29 bytes, as it is now, we allocate too little space to pack a DRM infoframe in write_device_infoframe(), leading to an ENOSPC return from hdmi_infoframe_pack(), and never calling the connector's write_infoframe() vfunc. Instead of having HDMI_MAX_INFOFRAME_SIZE defined in two places, replace HDMI_MAX_INFOFRAME_SIZE with HDMI_INFOFRAME_SIZE(MAX) and make MAX 27 bytes - which is defined by the HDMI specification to be the largest infoframe payload. Fixes: f378b77 ("drm/connector: hdmi: Add Infoframes generation") Fixes: c602e49 ("drm/connector: hdmi: Create Infoframe DebugFS entries") Signed-off-by: Derek Foreman <[email protected]> Acked-by: Maxime Ripard <[email protected]> Reviewed-by: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Maxime Ripard <[email protected]>
1 parent 440d52b commit f0fa69b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

drivers/gpu/drm/display/drm_hdmi_state_helper.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,6 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
521521
}
522522
EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check);
523523

524-
#define HDMI_MAX_INFOFRAME_SIZE 29
525-
526524
static int clear_device_infoframe(struct drm_connector *connector,
527525
enum hdmi_infoframe_type type)
528526
{
@@ -563,7 +561,7 @@ static int write_device_infoframe(struct drm_connector *connector,
563561
{
564562
const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
565563
struct drm_device *dev = connector->dev;
566-
u8 buffer[HDMI_MAX_INFOFRAME_SIZE];
564+
u8 buffer[HDMI_INFOFRAME_SIZE(MAX)];
567565
int ret;
568566
int len;
569567

drivers/gpu/drm/drm_debugfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,6 @@ static const struct file_operations drm_connector_fops = {
520520
.write = connector_write
521521
};
522522

523-
#define HDMI_MAX_INFOFRAME_SIZE 29
524-
525523
static ssize_t
526524
audio_infoframe_read(struct file *filp, char __user *ubuf, size_t count, loff_t *ppos)
527525
{
@@ -579,7 +577,7 @@ static ssize_t _f##_read_infoframe(struct file *filp, \
579577
struct drm_connector *connector; \
580578
union hdmi_infoframe *frame; \
581579
struct drm_device *dev; \
582-
u8 buf[HDMI_MAX_INFOFRAME_SIZE]; \
580+
u8 buf[HDMI_INFOFRAME_SIZE(MAX)]; \
583581
ssize_t len = 0; \
584582
\
585583
connector = filp->private_data; \

include/linux/hdmi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ enum hdmi_infoframe_type {
5959
#define HDMI_DRM_INFOFRAME_SIZE 26
6060
#define HDMI_VENDOR_INFOFRAME_SIZE 4
6161

62+
/*
63+
* HDMI 1.3a table 5-14 states that the largest InfoFrame_length is 27,
64+
* not including the packet header or checksum byte. We include the
65+
* checksum byte in HDMI_INFOFRAME_HEADER_SIZE, so this should allow
66+
* HDMI_INFOFRAME_SIZE(MAX) to be the largest buffer we could ever need
67+
* for any HDMI infoframe.
68+
*/
69+
#define HDMI_MAX_INFOFRAME_SIZE 27
70+
6271
#define HDMI_INFOFRAME_SIZE(type) \
6372
(HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
6473

0 commit comments

Comments
 (0)