Currently DRM framework expects that the HDMI connector driver supports
all infoframe types: it generates the data as required and calls into
the driver to program all of them, letting the driver to soft-fail if
the infoframe is unsupported. This has a major drawback on userspace
API: the framework also registers debugfs files for all Infoframe types,
possibly surprising the users when infoframe is visible in the debugfs
file, but it is not visible on the wire. Drivers are also expected to
return success even for unsuppoted InfoFrame types.
Let drivers declare that they support only a subset of infoframes,
creating a more consistent interface. Make the affected drivers return
-EOPNOTSUPP if they are asked to program (or clear) InfoFrames which are
not supported.
Acked-by: Liu Ying <victor.liu@nxp.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
drivers/gpu/drm/display/drm_bridge_connector.c | 6 +++
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 43 +++++++++++++++++++---
drivers/gpu/drm/drm_connector.c | 4 ++
drivers/gpu/drm/drm_debugfs.c | 16 +++++---
drivers/gpu/drm/rockchip/inno_hdmi.c | 5 ++-
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 3 +-
drivers/gpu/drm/tests/drm_connector_test.c | 28 ++++++++++++++
drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 8 ++++
drivers/gpu/drm/vc4/vc4_hdmi.c | 5 +++
include/drm/drm_bridge.h | 12 +++++-
include/drm/drm_connector.h | 30 ++++++++++++++-
11 files changed, 143 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/drm/display/drm_bridge_connector.c
index baacd21e7341fca95ef3e5b793930ffde9d4d4e3..55bf5ac53739fda098be69a5c61e4934704ce046 100644
--- a/drivers/gpu/drm/display/drm_bridge_connector.c
+++ b/drivers/gpu/drm/display/drm_bridge_connector.c
@@ -783,6 +783,12 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
&drm_bridge_connector_hdmi_funcs,
connector_type, ddc,
supported_formats,
+ bridge->supported_infoframes ? |
+ DRM_CONNECTOR_INFOFRAME_AUDIO |
+ DRM_CONNECTOR_INFOFRAME_AVI |
+ DRM_CONNECTOR_INFOFRAME_DRM |
+ DRM_CONNECTOR_INFOFRAME_SPD |
+ DRM_CONNECTOR_INFOFRAME_VENDOR,
max_bpc);
if (ret)
return ERR_PTR(ret);
diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index a561f124be99a0cd4259dbacf5f5f6651ff8a0ea..9ae996b5a2acf27d23da7108865b721cc8975dbf 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -687,6 +687,9 @@ static int hdmi_generate_avi_infoframe(const struct drm_connector *connector,
infoframe->set = false;
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_AVI))
+ return 0;
+
ret = drm_hdmi_avi_infoframe_from_display_mode(frame, connector, mode);
if (ret)
return ret;
@@ -718,6 +721,9 @@ static int hdmi_generate_spd_infoframe(const struct drm_connector *connector,
infoframe->set = false;
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_SPD))
+ return 0;
+
ret = hdmi_spd_infoframe_init(frame,
connector->hdmi.vendor,
connector->hdmi.product);
@@ -742,6 +748,9 @@ static int hdmi_generate_hdr_infoframe(const struct drm_connector *connector,
infoframe->set = false;
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_DRM))
+ return 0;
+
if (connector->max_bpc < 10)
return 0;
@@ -771,6 +780,9 @@ static int hdmi_generate_hdmi_vendor_infoframe(const struct drm_connector *conne
infoframe->set = false;
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_VENDOR))
+ return 0;
+
if (!info->has_hdmi_infoframe)
return 0;
@@ -898,13 +910,18 @@ static int clear_device_infoframe(struct drm_connector *connector,
struct drm_device *dev = connector->dev;
int ret;
- drm_dbg_kms(dev, "Clearing infoframe type 0x%x\n", type);
-
if (!funcs || !funcs->clear_infoframe) {
drm_dbg_kms(dev, "Function not implemented, bailing.\n");
return 0;
}
+ if (!drm_hdmi_connector_supported_infoframe(connector, type)) {
+ drm_dbg_kms(dev, "Infoframe 0x%02x not supported, bailing.\n", type);
+ return -EOPNOTSUPP;
+ }
+
+ drm_dbg_kms(dev, "Clearing infoframe type 0x%02x\n", type);
+
ret = funcs->clear_infoframe(connector, type);
if (ret) {
drm_dbg_kms(dev, "Call failed: %d\n", ret);
@@ -930,23 +947,29 @@ static int write_device_infoframe(struct drm_connector *connector,
union hdmi_infoframe *frame)
{
const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
+ enum hdmi_infoframe_type type = frame->any.type;
struct drm_device *dev = connector->dev;
u8 buffer[HDMI_INFOFRAME_SIZE(MAX)];
int ret;
int len;
- drm_dbg_kms(dev, "Writing infoframe type %x\n", frame->any.type);
-
if (!funcs || !funcs->write_infoframe) {
drm_dbg_kms(dev, "Function not implemented, bailing.\n");
return -EINVAL;
}
+ if (!drm_hdmi_connector_supported_infoframe(connector, type)) {
+ drm_dbg_kms(dev, "Infoframe 0x%02x not supported, bailing.\n", type);
+ return -EOPNOTSUPP;
+ }
+
+ drm_dbg_kms(dev, "Writing infoframe type 0x%02x\n", type);
+
len = hdmi_infoframe_pack(frame, buffer, sizeof(buffer));
if (len < 0)
return len;
- ret = funcs->write_infoframe(connector, frame->any.type, buffer, len);
+ ret = funcs->write_infoframe(connector, type, buffer, len);
if (ret) {
drm_dbg_kms(dev, "Call failed: %d\n", ret);
return ret;
@@ -1067,6 +1090,11 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co
struct drm_display_info *info = &connector->display_info;
int ret;
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_AUDIO)) {
+ drm_warn_once(connector->dev, "Audio Infoframe not supported, bailing.\n");
+ return -EOPNOTSUPP;
+ }
+
if (!info->is_hdmi)
return 0;
@@ -1102,6 +1130,11 @@ drm_atomic_helper_connector_hdmi_clear_audio_infoframe(struct drm_connector *con
struct drm_display_info *info = &connector->display_info;
int ret;
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_AUDIO)) {
+ drm_warn_once(connector->dev, "Audio Infoframe not supported, bailing.\n");
+ return -EOPNOTSUPP;
+ }
+
if (!info->is_hdmi)
return 0;
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 272d6254ea4784e97ca894ec4d463beebf9fdbf0..92a75684a0f7375d3a94e8c666cb71064ecc8035 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -553,6 +553,7 @@ EXPORT_SYMBOL(drmm_connector_init);
* @connector_type: user visible type of the connector
* @ddc: optional pointer to the associated ddc adapter
* @supported_formats: Bitmask of @hdmi_colorspace listing supported output formats
+ * @supported_infoframes: Bitmask of @DRM_CONNECTOR_INFOFRAME listing Infoframes generated by DRM core
* @max_bpc: Maximum bits per char the HDMI connector supports
*
* Initialises a preallocated HDMI connector. Connectors can be
@@ -576,6 +577,7 @@ int drmm_connector_hdmi_init(struct drm_device *dev,
int connector_type,
struct i2c_adapter *ddc,
unsigned long supported_formats,
+ unsigned long supported_infoframes,
unsigned int max_bpc)
{
int ret;
@@ -623,6 +625,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev,
connector->hdmi.funcs = hdmi_funcs;
+ connector->hdmi.supported_infoframes = supported_infoframes;
+
return 0;
}
EXPORT_SYMBOL(drmm_connector_hdmi_init);
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 365cf337529fa2a88b69516d57360d212419c126..0bf70164550b4eb0551aeab026d5bf1131739a02 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -672,6 +672,9 @@ static int create_hdmi_audio_infoframe_file(struct drm_connector *connector,
{
struct dentry *file;
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_AUDIO))
+ return 0;
+
file = debugfs_create_file("audio", 0400, parent, connector, &audio_infoframe_fops);
if (IS_ERR(file))
return PTR_ERR(file);
@@ -679,7 +682,7 @@ static int create_hdmi_audio_infoframe_file(struct drm_connector *connector,
return 0;
}
-#define DEFINE_INFOFRAME_FILE(_f) \
+#define DEFINE_INFOFRAME_FILE(_f, _F) \
static ssize_t _f##_read_infoframe(struct file *filp, \
char __user *ubuf, \
size_t count, \
@@ -726,6 +729,9 @@ static int create_hdmi_## _f ## _infoframe_file(struct drm_connector *connector,
{ \
struct dentry *file; \
\
+ if (!drm_hdmi_connector_supported_infoframe(connector, HDMI_INFOFRAME_TYPE_ ## _F)) \
+ return 0; \
+ \
file = debugfs_create_file(#_f, 0400, parent, connector, &_f ## _infoframe_fops); \
if (IS_ERR(file)) \
return PTR_ERR(file); \
@@ -733,10 +739,10 @@ static int create_hdmi_## _f ## _infoframe_file(struct drm_connector *connector,
return 0; \
}
-DEFINE_INFOFRAME_FILE(avi);
-DEFINE_INFOFRAME_FILE(hdmi);
-DEFINE_INFOFRAME_FILE(hdr_drm);
-DEFINE_INFOFRAME_FILE(spd);
+DEFINE_INFOFRAME_FILE(avi, AVI);
+DEFINE_INFOFRAME_FILE(hdmi, VENDOR);
+DEFINE_INFOFRAME_FILE(hdr_drm, DRM);
+DEFINE_INFOFRAME_FILE(spd, SPD);
static int create_hdmi_infoframe_files(struct drm_connector *connector,
struct dentry *parent)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index 1ab3ad4bde9ea7305021186ea221d2ff9057fdbb..31d742b7627b8b31ebbd7056c9d44a0454407d6d 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -645,7 +645,7 @@ static int inno_hdmi_disable_frame(struct drm_connector *connector,
if (type != HDMI_INFOFRAME_TYPE_AVI) {
drm_err(connector->dev,
"Unsupported infoframe type: %u\n", type);
- return 0;
+ return -EOPNOTSUPP;
}
hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_BUF_INDEX, INFOFRAME_AVI);
@@ -663,7 +663,7 @@ static int inno_hdmi_upload_frame(struct drm_connector *connector,
if (type != HDMI_INFOFRAME_TYPE_AVI) {
drm_err(connector->dev,
"Unsupported infoframe type: %u\n", type);
- return 0;
+ return -EOPNOTSUPP;
}
inno_hdmi_disable_frame(connector, type);
@@ -1065,6 +1065,7 @@ static int inno_hdmi_register(struct drm_device *drm, struct inno_hdmi *hdmi)
DRM_MODE_CONNECTOR_HDMIA,
hdmi->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_INFOFRAME_AVI,
8);
drm_connector_attach_encoder(&hdmi->connector, encoder);
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index ab0938ba61f7d75dd0bec473807a04a20e1cffbd..f4c8ff60d78250d0100e210210d4e9a64a903af5 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -50,7 +50,7 @@ static int sun4i_hdmi_write_infoframe(struct drm_connector *connector,
if (type != HDMI_INFOFRAME_TYPE_AVI) {
drm_err(connector->dev,
"Unsupported infoframe type: %u\n", type);
- return 0;
+ return -EOPNOTSUPP;
}
for (i = 0; i < len; i++)
@@ -640,6 +640,7 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
DRM_MODE_CONNECTOR_HDMIA,
hdmi->ddc_i2c,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_INFOFRAME_AVI,
8);
if (ret) {
dev_err(dev,
diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
index 22e2d959eb31459f9981fef488228904d67cb6f9..fd28ed2bf8bcecabaabc67f2f8f5ccc1f42525d3 100644
--- a/drivers/gpu/drm/tests/drm_connector_test.c
+++ b/drivers/gpu/drm/tests/drm_connector_test.c
@@ -641,6 +641,13 @@ static struct kunit_suite drm_connector_dynamic_register_test_suite = {
.test_cases = drm_connector_dynamic_register_tests,
};
+#define DRM_CONNECTOR_ALL_INFOFRAMES \
+ (DRM_CONNECTOR_INFOFRAME_AUDIO | \
+ DRM_CONNECTOR_INFOFRAME_AVI | \
+ DRM_CONNECTOR_INFOFRAME_DRM | \
+ DRM_CONNECTOR_INFOFRAME_SPD | \
+ DRM_CONNECTOR_INFOFRAME_VENDOR)
+
/*
* Test that the registration of a bog standard connector works as
* expected and doesn't report any error.
@@ -657,6 +664,7 @@ static void drm_test_connector_hdmi_init_valid(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
}
@@ -677,6 +685,7 @@ static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
NULL,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
}
@@ -697,6 +706,7 @@ static void drm_test_connector_hdmi_init_null_vendor(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -717,6 +727,7 @@ static void drm_test_connector_hdmi_init_null_product(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -743,6 +754,7 @@ static void drm_test_connector_hdmi_init_product_valid(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_MEMEQ(test,
@@ -776,6 +788,7 @@ static void drm_test_connector_hdmi_init_product_length_exact(struct kunit *test
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_MEMEQ(test,
@@ -803,6 +816,7 @@ static void drm_test_connector_hdmi_init_product_length_too_long(struct kunit *t
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -829,6 +843,7 @@ static void drm_test_connector_hdmi_init_vendor_valid(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_MEMEQ(test,
@@ -861,6 +876,7 @@ static void drm_test_connector_hdmi_init_vendor_length_exact(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
KUNIT_EXPECT_MEMEQ(test,
@@ -888,6 +904,7 @@ static void drm_test_connector_hdmi_init_vendor_length_too_long(struct kunit *te
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -908,6 +925,7 @@ static void drm_test_connector_hdmi_init_bpc_invalid(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
9);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -928,6 +946,7 @@ static void drm_test_connector_hdmi_init_bpc_null(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
0);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -953,6 +972,7 @@ static void drm_test_connector_hdmi_init_bpc_8(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
@@ -994,6 +1014,7 @@ static void drm_test_connector_hdmi_init_bpc_10(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
10);
KUNIT_EXPECT_EQ(test, ret, 0);
@@ -1035,6 +1056,7 @@ static void drm_test_connector_hdmi_init_bpc_12(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
12);
KUNIT_EXPECT_EQ(test, ret, 0);
@@ -1071,6 +1093,7 @@ static void drm_test_connector_hdmi_init_formats_empty(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
0,
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -1091,6 +1114,7 @@ static void drm_test_connector_hdmi_init_formats_no_rgb(struct kunit *test)
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_YUV422),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -1149,6 +1173,7 @@ static void drm_test_connector_hdmi_init_formats_yuv420_allowed(struct kunit *te
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
params->supported_formats,
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, params->expected_result);
}
@@ -1170,6 +1195,7 @@ static void drm_test_connector_hdmi_init_type_valid(struct kunit *test)
connector_type,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
}
@@ -1205,6 +1231,7 @@ static void drm_test_connector_hdmi_init_type_invalid(struct kunit *test)
connector_type,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_LT(test, ret, 0);
}
@@ -1482,6 +1509,7 @@ static void drm_test_drm_connector_attach_broadcast_rgb_property_hdmi_connector(
DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc,
BIT(HDMI_COLORSPACE_RGB),
+ DRM_CONNECTOR_ALL_INFOFRAMES,
8);
KUNIT_EXPECT_EQ(test, ret, 0);
diff --git a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
index 8bd412735000cb18e66aeca21433b2ebbefe2b44..2901fcb6b12ee318a4a9c727a62d5290d7c9aa84 100644
--- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
@@ -138,6 +138,13 @@ static const struct drm_connector_funcs dummy_connector_funcs = {
.reset = dummy_hdmi_connector_reset,
};
+#define DRM_CONNECTOR_ALL_INFOFRAMES \
+ (DRM_CONNECTOR_INFOFRAME_AUDIO | \
+ DRM_CONNECTOR_INFOFRAME_AVI | \
+ DRM_CONNECTOR_INFOFRAME_DRM | \
+ DRM_CONNECTOR_INFOFRAME_SPD | \
+ DRM_CONNECTOR_INFOFRAME_VENDOR)
+
static
struct drm_atomic_helper_connector_hdmi_priv *
__connector_hdmi_init(struct kunit *test,
@@ -192,6 +199,7 @@ __connector_hdmi_init(struct kunit *test,
DRM_MODE_CONNECTOR_HDMIA,
NULL,
formats,
+ DRM_CONNECTOR_ALL_INFOFRAMES,
max_bpc);
KUNIT_ASSERT_EQ(test, ret, 0);
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 07c91b450f93ab9e795d040d6f60f485ac71cfe8..2098d04c95e7e733307c90bb9ab5e2631f6f5df0 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -556,6 +556,11 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,
BIT(HDMI_COLORSPACE_RGB) |
BIT(HDMI_COLORSPACE_YUV422) |
BIT(HDMI_COLORSPACE_YUV444),
+ DRM_CONNECTOR_INFOFRAME_AUDIO |
+ DRM_CONNECTOR_INFOFRAME_AVI |
+ DRM_CONNECTOR_INFOFRAME_DRM |
+ DRM_CONNECTOR_INFOFRAME_SPD |
+ DRM_CONNECTOR_INFOFRAME_VENDOR,
max_bpc);
if (ret)
return ret;
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 76e05930f50e00f6ef5999b3f5a476215951028d..a3e3518905a06835f61a1a60bd2f165820f57918 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -788,7 +788,7 @@ struct drm_bridge_funcs {
*
* This callback clears the infoframes in the hardware during commit.
* It will be called multiple times, once for every disabled infoframe
- * type.
+ * type. It should return -EOPNOTSUPP if the frame is not supported.
*
* This callback is optional but it must be implemented by bridges that
* set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops.
@@ -799,7 +799,8 @@ struct drm_bridge_funcs {
* @hdmi_write_infoframe:
*
* Program the infoframe into the hardware. It will be called multiple
- * times, once for every updated infoframe type.
+ * times, once for every updated infoframe type. It should return
+ * -EOPNOTSUPP if the frame is not supported.
*
* This callback is optional but it must be implemented by bridges that
* set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops.
@@ -1205,6 +1206,13 @@ struct drm_bridge {
*/
unsigned int max_bpc;
+ /**
+ * @supported_infoframes: Bitmask of DRM_CONNECTOR_INFOFRAME values,
+ * listing InfoFrames to be generated by the DRM core. This is only
+ * relevant if @DRM_BRIDGE_OP_HDMI is set.
+ */
+ unsigned int supported_infoframes;
+
/**
* @hdmi_cec_dev: device to be used as a containing device for CEC
* functions.
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 8f34f4b8183d83dccd3e820a444fbf74fb6c16f2..7849a2343771ee869cd1e38b30f34d0c2237f4d7 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1256,7 +1256,8 @@ struct drm_connector_hdmi_funcs {
* The @clear_infoframe callback is optional.
*
* Returns:
- * 0 on success, a negative error code otherwise
+ * 0 on success, a negative error code otherwise, it should return
+ * -EOPNOTSUPP if the frame is not supported
*/
int (*clear_infoframe)(struct drm_connector *connector,
enum hdmi_infoframe_type type);
@@ -1273,7 +1274,8 @@ struct drm_connector_hdmi_funcs {
* The @write_infoframe callback is mandatory.
*
* Returns:
- * 0 on success, a negative error code otherwise
+ * 0 on success, a negative error code otherwise, it should return
+ * -EOPNOTSUPP if the frame is not supported
*/
int (*write_infoframe)(struct drm_connector *connector,
enum hdmi_infoframe_type type,
@@ -1839,6 +1841,14 @@ struct drm_connector_hdmi {
*/
unsigned long supported_formats;
+ /**
+ * @supported_infoframes: Bitmask of infoframe types supported by the
+ * controller and generated AS IS by the software.
+ * See @DRM_CONNECTOR_INFOFRAME and
+ * @drm_connector_hdmi_funcs.write_infoframe().
+ */
+ unsigned long supported_infoframes;
+
/**
* @funcs: HDMI connector Control Functions
*/
@@ -2336,6 +2346,7 @@ int drmm_connector_hdmi_init(struct drm_device *dev,
int connector_type,
struct i2c_adapter *ddc,
unsigned long supported_formats,
+ unsigned long supported_infoframes,
unsigned int max_bpc);
void drm_connector_attach_edid_property(struct drm_connector *connector);
int drm_connector_register(struct drm_connector *connector);
@@ -2488,6 +2499,21 @@ void drm_connector_attach_privacy_screen_provider(
struct drm_connector *connector, struct drm_privacy_screen *priv);
void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state);
+#define DRM_CONNECTOR_INFOFRAME(type) ((type) > 0x80 ? BIT((type) - 0x80) : 0)
+
+#define DRM_CONNECTOR_INFOFRAME_AUDIO DRM_CONNECTOR_INFOFRAME(HDMI_INFOFRAME_TYPE_AUDIO)
+#define DRM_CONNECTOR_INFOFRAME_AVI DRM_CONNECTOR_INFOFRAME(HDMI_INFOFRAME_TYPE_AVI)
+#define DRM_CONNECTOR_INFOFRAME_DRM DRM_CONNECTOR_INFOFRAME(HDMI_INFOFRAME_TYPE_DRM)
+#define DRM_CONNECTOR_INFOFRAME_SPD DRM_CONNECTOR_INFOFRAME(HDMI_INFOFRAME_TYPE_SPD)
+#define DRM_CONNECTOR_INFOFRAME_VENDOR DRM_CONNECTOR_INFOFRAME(HDMI_INFOFRAME_TYPE_VENDOR)
+
+static inline bool
+drm_hdmi_connector_supported_infoframe(const struct drm_connector *connector,
+ enum hdmi_infoframe_type type)
+{
+ return connector->hdmi.supported_infoframes & DRM_CONNECTOR_INFOFRAME(type);
+}
+
/**
* struct drm_tile_group - Tile group metadata
* @refcount: reference count
--
2.47.3
On Tue, Sep 09, 2025 at 05:51:59PM +0300, Dmitry Baryshkov wrote: > Currently DRM framework expects that the HDMI connector driver supports > all infoframe types: it generates the data as required and calls into > the driver to program all of them, letting the driver to soft-fail if > the infoframe is unsupported. This has a major drawback on userspace > API: the framework also registers debugfs files for all Infoframe types, > possibly surprising the users when infoframe is visible in the debugfs > file, but it is not visible on the wire. Drivers are also expected to > return success even for unsuppoted InfoFrame types. > > Let drivers declare that they support only a subset of infoframes, > creating a more consistent interface. Make the affected drivers return > -EOPNOTSUPP if they are asked to program (or clear) InfoFrames which are > not supported. > > Acked-by: Liu Ying <victor.liu@nxp.com> > Acked-by: Daniel Stone <daniels@collabora.com> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Again, I still believe that it's a bad idea, goes against what the spec states, and the framework was meant to be. So, no, sorry. That's still a no for me. Please stop sending that patch unless we have a discussion about it and you convince me that it's actually something that we'd need. Maxime
On Wed, Sep 10, 2025 at 01:03:47PM +0200, Maxime Ripard wrote: > On Tue, Sep 09, 2025 at 05:51:59PM +0300, Dmitry Baryshkov wrote: > > Currently DRM framework expects that the HDMI connector driver supports > > all infoframe types: it generates the data as required and calls into > > the driver to program all of them, letting the driver to soft-fail if > > the infoframe is unsupported. This has a major drawback on userspace > > API: the framework also registers debugfs files for all Infoframe types, > > possibly surprising the users when infoframe is visible in the debugfs > > file, but it is not visible on the wire. Drivers are also expected to > > return success even for unsuppoted InfoFrame types. > > > > Let drivers declare that they support only a subset of infoframes, > > creating a more consistent interface. Make the affected drivers return > > -EOPNOTSUPP if they are asked to program (or clear) InfoFrames which are > > not supported. > > > > Acked-by: Liu Ying <victor.liu@nxp.com> > > Acked-by: Daniel Stone <daniels@collabora.com> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > > Again, I still believe that it's a bad idea, goes against what the spec > states, and the framework was meant to be. Please correct me if I'm wrong. The specs (HDMI & CEA) define several infoframes and whether we should be sending them. If I'm reading it correctrly, CEA spec explicitly says 'If the Source supports the transmission of [foo] InfoFrame..." (6.4 - AVI, 6.6 - Audio, 6.7 MPEG, 6.9 - DRM). For other InfoFrames (6.5 SPD, 6.8 NTSC VBI) it just defines that sending those frames is optional. We can't even infer support for InfoFrames from the Source features. E.g. CEA 6.6.1 defines a case when digital audio is allowed to be sent, without sending Audio InfoFrame. As we will be getting more and more features, some of the InfoFrames or data packets will be 'good to have, but not required'. > > So, no, sorry. That's still a no for me. Please stop sending that patch Oops :-) > unless we have a discussion about it and you convince me that it's > actually something that we'd need. My main concern is that the drivers should not opt-out of the features. E.g. if we start supporting ISRC packets or MPEG or NTSC VBI InfoFrames (yes, stupid examples), it should not be required to go through all the drivers, making sure that they disable those. Instead the DRM framework should be able to make decisions like: - The driver supports SPD and the VSDB defines SPD, enable this InfoFrame (BTW, this needs to be done anyway, we should not be sending SPD if it's not defined in VSDB, if I read it correctly). - The driver hints that the pixel data has only 10 meaninful bits of data per component (e.g. out of 12 for DeepColor 36), the Sink has HF-VSDB, send HF-VSIF. - The driver has enabled 3D stereo mode, but it doesn't declare support for HF-VSIF. Send only H14b-VSIF. Similarly (no, I don't have these on my TODO list, these are just examples): - The driver defines support for NTSC VBI, register a VBI device. - The driver defines support for ISRC packets, register ISRC-related properties. - The driver defines support for MPEG Source InfoFrame, provide a way for media players to report frame type and bit rate. - The driver provides limited support for Extended HDR DM InfoFrames, select the correct frame type according to driver capabilities. Without the 'supported' information we should change atomic_check() functions to set infoframe->set to false for all unsupported InfoFrames _and_ go through all the drivers again each time we add support for a feature (e.g. after adding HF-VSIF support). -- With best wishes Dmitry
On Wed, Sep 10, 2025 at 06:16:25PM +0300, Dmitry Baryshkov wrote: > On Wed, Sep 10, 2025 at 01:03:47PM +0200, Maxime Ripard wrote: > > On Tue, Sep 09, 2025 at 05:51:59PM +0300, Dmitry Baryshkov wrote: > > > Currently DRM framework expects that the HDMI connector driver supports > > > all infoframe types: it generates the data as required and calls into > > > the driver to program all of them, letting the driver to soft-fail if > > > the infoframe is unsupported. This has a major drawback on userspace > > > API: the framework also registers debugfs files for all Infoframe types, > > > possibly surprising the users when infoframe is visible in the debugfs > > > file, but it is not visible on the wire. Drivers are also expected to > > > return success even for unsuppoted InfoFrame types. > > > > > > Let drivers declare that they support only a subset of infoframes, > > > creating a more consistent interface. Make the affected drivers return > > > -EOPNOTSUPP if they are asked to program (or clear) InfoFrames which are > > > not supported. > > > > > > Acked-by: Liu Ying <victor.liu@nxp.com> > > > Acked-by: Daniel Stone <daniels@collabora.com> > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > > > > Again, I still believe that it's a bad idea, goes against what the spec > > states, and the framework was meant to be. > > Please correct me if I'm wrong. The specs (HDMI & CEA) define several > infoframes and whether we should be sending them. If I'm reading it > correctrly, CEA spec explicitly says 'If the Source supports the > transmission of [foo] InfoFrame..." (6.4 - AVI, 6.6 - Audio, 6.7 MPEG, > 6.9 - DRM). For other InfoFrames (6.5 SPD, 6.8 NTSC VBI) it just defines > that sending those frames is optional. SPD is indeed optional, but the HDMI spec, (HDMI 1.4b, Section 8.2.1 - Auxiliary Video information (AVI) InfoFrame) states that: A Source shall always transmit an AVI InfoFrame at least once per two Video Fields if the Source: * is ever capable of transmitting an AVI InfoFrame or, * is ever capable of transmitting YCBCR pixel encoding or, * is ever capable of transmitting any colorimetry other than the transmitted video format’s default colorimetry or, * is ever capable of transmitting any xvYCC or future enhanced colorimetry or, * is ever capable of transmitting any Gamut Metadata packet or, * is ever capable of transmitting any video format with multiple allowed pixel repetitions or, * is ever capable of transmitting Content Type other than “no data” or, * is ever capable of transmitting YCC Quantization Range. The AVI InfoFrame shall be transmitted even while such a Source is transmitting RGB and non-pixel-repeated video. When a Source is not explicitly required to transmit AVI InfoFrames, it is recommended that the Source transmit AVI InfoFrames. So it's recommended in every case, and the list kind of makes it mandatory for how Linux uses HDMI. Also, did we ever encounter some hardware that couldn't send AVI? Audio is mandatory when streaming audio, DRM when using HDR, and we don't support the others yet. So the only we support but don't have to send is SPD. > We can't even infer support for InfoFrames from the Source features. > E.g. CEA 6.6.1 defines a case when digital audio is allowed to be sent, > without sending Audio InfoFrame. HDMI 1.4 section 8.2.2 - Audio Infoframe states that: Whenever an active audio stream is being transmitted, an accurate Audio InfoFrame shall be transmitted at least once per two Video Fields. I'd say it takes precedence over CTA-861. > As we will be getting more and more features, some of the InfoFrames > or data packets will be 'good to have, but not required'. And drivers would be free to ignore those. > > So, no, sorry. That's still a no for me. Please stop sending that patch > > Oops :-) > > > unless we have a discussion about it and you convince me that it's > > actually something that we'd need. > > My main concern is that the drivers should not opt-out of the features. > E.g. if we start supporting ISRC packets or MPEG or NTSC VBI InfoFrames > (yes, stupid examples), it should not be required to go through all the > drivers, making sure that they disable those. Instead the DRM framework > should be able to make decisions like: > > - The driver supports SPD and the VSDB defines SPD, enable this > InfoFrame (BTW, this needs to be done anyway, we should not be sending > SPD if it's not defined in VSDB, if I read it correctly). > > - The driver hints that the pixel data has only 10 meaninful bits of > data per component (e.g. out of 12 for DeepColor 36), the Sink has > HF-VSDB, send HF-VSIF. > > - The driver has enabled 3D stereo mode, but it doesn't declare support > for HF-VSIF. Send only H14b-VSIF. > > Similarly (no, I don't have these on my TODO list, these are just > examples): > - The driver defines support for NTSC VBI, register a VBI device. > > - The driver defines support for ISRC packets, register ISRC-related > properties. > > - The driver defines support for MPEG Source InfoFrame, provide a way > for media players to report frame type and bit rate. > > - The driver provides limited support for Extended HDR DM InfoFrames, > select the correct frame type according to driver capabilities. > > Without the 'supported' information we should change atomic_check() > functions to set infoframe->set to false for all unsupported InfoFrames > _and_ go through all the drivers again each time we add support for a > feature (e.g. after adding HF-VSIF support). From what you described here, I think we share a similar goal and have somewhat similar concerns (thanks, btw, it wasn't obvious to me before), we just disagree on the trade-offs and ideal solution :) I agree that we need to sanity check the drivers, and I don't want to go back to the situation we had before where drivers could just ignore infoframes and take the easy way out. It should be hard, and easy to catch during review. I don't think bitflag are a solution because, to me, it kind of fails both. What if, just like the debugfs discussion, we split write_infoframe into write_avi_infoframe (mandatory), write_spd_infoframe (optional), write_audio_infoframe (checked by drm_connector_hdmi_audio_init?) and write_hdr_infoframe (checked in drmm_connector_hdmi_init if max_bpc > 8) How does that sound? Maxime
On Thu, Sep 25, 2025 at 02:36:46PM +0200, Maxime Ripard wrote: > On Wed, Sep 10, 2025 at 06:16:25PM +0300, Dmitry Baryshkov wrote: > > On Wed, Sep 10, 2025 at 01:03:47PM +0200, Maxime Ripard wrote: > > > On Tue, Sep 09, 2025 at 05:51:59PM +0300, Dmitry Baryshkov wrote: > > > > Currently DRM framework expects that the HDMI connector driver supports > > > > all infoframe types: it generates the data as required and calls into > > > > the driver to program all of them, letting the driver to soft-fail if > > > > the infoframe is unsupported. This has a major drawback on userspace > > > > API: the framework also registers debugfs files for all Infoframe types, > > > > possibly surprising the users when infoframe is visible in the debugfs > > > > file, but it is not visible on the wire. Drivers are also expected to > > > > return success even for unsuppoted InfoFrame types. > > > > > > > > Let drivers declare that they support only a subset of infoframes, > > > > creating a more consistent interface. Make the affected drivers return > > > > -EOPNOTSUPP if they are asked to program (or clear) InfoFrames which are > > > > not supported. > > > > > > > > Acked-by: Liu Ying <victor.liu@nxp.com> > > > > Acked-by: Daniel Stone <daniels@collabora.com> > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > > > > > > Again, I still believe that it's a bad idea, goes against what the spec > > > states, and the framework was meant to be. > > > > Please correct me if I'm wrong. The specs (HDMI & CEA) define several > > infoframes and whether we should be sending them. If I'm reading it > > correctrly, CEA spec explicitly says 'If the Source supports the > > transmission of [foo] InfoFrame..." (6.4 - AVI, 6.6 - Audio, 6.7 MPEG, > > 6.9 - DRM). For other InfoFrames (6.5 SPD, 6.8 NTSC VBI) it just defines > > that sending those frames is optional. > > SPD is indeed optional, but the HDMI spec, (HDMI 1.4b, Section 8.2.1 - > Auxiliary Video information (AVI) InfoFrame) states that: > > A Source shall always transmit an AVI InfoFrame at least once per two > Video Fields if the Source: > > * is ever capable of transmitting an AVI InfoFrame or, > * is ever capable of transmitting YCBCR pixel encoding or, > * is ever capable of transmitting any colorimetry other than the > transmitted video format’s default colorimetry or, > * is ever capable of transmitting any xvYCC or future enhanced > colorimetry or, > * is ever capable of transmitting any Gamut Metadata packet or, > * is ever capable of transmitting any video format with multiple > allowed pixel repetitions or, > * is ever capable of transmitting Content Type other than “no data” or, > * is ever capable of transmitting YCC Quantization Range. > > The AVI InfoFrame shall be transmitted even while such a Source is > transmitting RGB and non-pixel-repeated video. When a Source is not > explicitly required to transmit AVI InfoFrames, it is recommended that > the Source transmit AVI InfoFrames. > > So it's recommended in every case, and the list kind of makes it > mandatory for how Linux uses HDMI. Agreed. > > Also, did we ever encounter some hardware that couldn't send AVI? No. > > Audio is mandatory when streaming audio, DRM when using HDR, and we > don't support the others yet. > > So the only we support but don't have to send is SPD. > > > We can't even infer support for InfoFrames from the Source features. > > E.g. CEA 6.6.1 defines a case when digital audio is allowed to be sent, > > without sending Audio InfoFrame. > > HDMI 1.4 section 8.2.2 - Audio Infoframe states that: > > Whenever an active audio stream is being transmitted, an accurate > Audio InfoFrame shall be transmitted at least once per two Video > Fields. > > I'd say it takes precedence over CTA-861. I see, I was referring to CTA indeed. HDMI takes precedence. > > > As we will be getting more and more features, some of the InfoFrames > > or data packets will be 'good to have, but not required'. > > And drivers would be free to ignore those. > > > > So, no, sorry. That's still a no for me. Please stop sending that patch > > > > Oops :-) > > > > > unless we have a discussion about it and you convince me that it's > > > actually something that we'd need. > > > > My main concern is that the drivers should not opt-out of the features. > > E.g. if we start supporting ISRC packets or MPEG or NTSC VBI InfoFrames > > (yes, stupid examples), it should not be required to go through all the > > drivers, making sure that they disable those. Instead the DRM framework > > should be able to make decisions like: > > > > - The driver supports SPD and the VSDB defines SPD, enable this > > InfoFrame (BTW, this needs to be done anyway, we should not be sending > > SPD if it's not defined in VSDB, if I read it correctly). > > > > - The driver hints that the pixel data has only 10 meaninful bits of > > data per component (e.g. out of 12 for DeepColor 36), the Sink has > > HF-VSDB, send HF-VSIF. > > > > - The driver has enabled 3D stereo mode, but it doesn't declare support > > for HF-VSIF. Send only H14b-VSIF. > > > > Similarly (no, I don't have these on my TODO list, these are just > > examples): > > - The driver defines support for NTSC VBI, register a VBI device. > > > > - The driver defines support for ISRC packets, register ISRC-related > > properties. > > > > - The driver defines support for MPEG Source InfoFrame, provide a way > > for media players to report frame type and bit rate. > > > > - The driver provides limited support for Extended HDR DM InfoFrames, > > select the correct frame type according to driver capabilities. > > > > Without the 'supported' information we should change atomic_check() > > functions to set infoframe->set to false for all unsupported InfoFrames > > _and_ go through all the drivers again each time we add support for a > > feature (e.g. after adding HF-VSIF support). > > From what you described here, I think we share a similar goal and have > somewhat similar concerns (thanks, btw, it wasn't obvious to me before), > we just disagree on the trade-offs and ideal solution :) > > I agree that we need to sanity check the drivers, and I don't want to go > back to the situation we had before where drivers could just ignore > infoframes and take the easy way out. > > It should be hard, and easy to catch during review. > > I don't think bitflag are a solution because, to me, it kind of fails > both. > > What if, just like the debugfs discussion, we split write_infoframe into > write_avi_infoframe (mandatory), write_spd_infoframe (optional), > write_audio_infoframe (checked by drm_connector_hdmi_audio_init?) and > write_hdr_infoframe (checked in drmm_connector_hdmi_init if max_bpc > 8) > > How does that sound? I'd say, I really like the single function to be called for writing the infoframes. It makes it much harder for drivers to misbehave or to skip something. Following this discussion, let's take smaller steps: modify the drivers to disable unsupported infoframes in atomic_check() and return an error from write/clear_infoframe if the type is unuspported. Then I'd probably like to correct SPD handling, only sending it if it is supported by the Sink. I still think in the end we should have the bitmask for truly-optional packets and InfoFrames, but having only SPD doesn't provide enough pressure. I'd just leave the FIXME and let somebody working on those features to implement that. I am tempted to implement ISRC support just for the sake of it, but it probably doesn't make any sense. -- With best wishes Dmitry
© 2016 - 2025 Red Hat, Inc.