Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/connector: hdmi: Add support for output format

Just like BPC, we'll add support for automatic selection of the output
format for HDMI connectors.

Let's add the needed defaults and fields for now.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240527-kms-hdmi-connector-state-v15-7-c5af16c3aae2@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+81 -6
+2 -1
drivers/gpu/drm/display/drm_hdmi_state_helper.c
··· 45 45 struct drm_connector_state *new_conn_state = 46 46 drm_atomic_get_new_connector_state(state, connector); 47 47 48 - if (old_conn_state->hdmi.output_bpc != new_conn_state->hdmi.output_bpc) { 48 + if (old_conn_state->hdmi.output_bpc != new_conn_state->hdmi.output_bpc || 49 + old_conn_state->hdmi.output_format != new_conn_state->hdmi.output_format) { 49 50 struct drm_crtc *crtc = new_conn_state->crtc; 50 51 struct drm_crtc_state *crtc_state; 51 52
+2
drivers/gpu/drm/drm_atomic.c
··· 1146 1146 if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || 1147 1147 connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { 1148 1148 drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc); 1149 + drm_printf(p, "\toutput_format=%s\n", 1150 + drm_hdmi_connector_get_output_format_name(state->hdmi.output_format)); 1149 1151 } 1150 1152 1151 1153 if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
+31
drivers/gpu/drm/drm_connector.c
··· 459 459 * @funcs: callbacks for this connector 460 460 * @connector_type: user visible type of the connector 461 461 * @ddc: optional pointer to the associated ddc adapter 462 + * @supported_formats: Bitmask of @hdmi_colorspace listing supported output formats 462 463 * @max_bpc: Maximum bits per char the HDMI connector supports 463 464 * 464 465 * Initialises a preallocated HDMI connector. Connectors can be ··· 478 477 const struct drm_connector_funcs *funcs, 479 478 int connector_type, 480 479 struct i2c_adapter *ddc, 480 + unsigned long supported_formats, 481 481 unsigned int max_bpc) 482 482 { 483 483 int ret; ··· 487 485 connector_type == DRM_MODE_CONNECTOR_HDMIB)) 488 486 return -EINVAL; 489 487 488 + if (!supported_formats || !(supported_formats & BIT(HDMI_COLORSPACE_RGB))) 489 + return -EINVAL; 490 + 490 491 if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12)) 491 492 return -EINVAL; 492 493 493 494 ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); 494 495 if (ret) 495 496 return ret; 497 + 498 + connector->hdmi.supported_formats = supported_formats; 496 499 497 500 /* 498 501 * drm_connector_attach_max_bpc_property() requires the ··· 1207 1200 BIT(DRM_MODE_COLORIMETRY_OPYCC_601) | 1208 1201 BIT(DRM_MODE_COLORIMETRY_BT2020_CYCC) | 1209 1202 BIT(DRM_MODE_COLORIMETRY_BT2020_YCC); 1203 + 1204 + static const char * const output_format_str[] = { 1205 + [HDMI_COLORSPACE_RGB] = "RGB", 1206 + [HDMI_COLORSPACE_YUV420] = "YUV 4:2:0", 1207 + [HDMI_COLORSPACE_YUV422] = "YUV 4:2:2", 1208 + [HDMI_COLORSPACE_YUV444] = "YUV 4:4:4", 1209 + }; 1210 + 1211 + /* 1212 + * drm_hdmi_connector_get_output_format_name() - Return a string for HDMI connector output format 1213 + * @fmt: Output format to compute name of 1214 + * 1215 + * Returns: the name of the output format, or NULL if the type is not 1216 + * valid. 1217 + */ 1218 + const char * 1219 + drm_hdmi_connector_get_output_format_name(enum hdmi_colorspace fmt) 1220 + { 1221 + if (fmt >= ARRAY_SIZE(output_format_str)) 1222 + return NULL; 1223 + 1224 + return output_format_str[fmt]; 1225 + } 1226 + EXPORT_SYMBOL(drm_hdmi_connector_get_output_format_name); 1210 1227 1211 1228 /** 1212 1229 * DOC: standard connector properties
+9
drivers/gpu/drm/tests/drm_connector_test.c
··· 187 187 &dummy_funcs, 188 188 DRM_MODE_CONNECTOR_HDMIA, 189 189 &priv->ddc, 190 + BIT(HDMI_COLORSPACE_RGB), 190 191 8); 191 192 KUNIT_EXPECT_EQ(test, ret, 0); 192 193 } ··· 205 204 &dummy_funcs, 206 205 DRM_MODE_CONNECTOR_HDMIA, 207 206 NULL, 207 + BIT(HDMI_COLORSPACE_RGB), 208 208 8); 209 209 KUNIT_EXPECT_EQ(test, ret, 0); 210 210 } ··· 223 221 &dummy_funcs, 224 222 DRM_MODE_CONNECTOR_HDMIA, 225 223 &priv->ddc, 224 + BIT(HDMI_COLORSPACE_RGB), 226 225 9); 227 226 KUNIT_EXPECT_LT(test, ret, 0); 228 227 } ··· 241 238 &dummy_funcs, 242 239 DRM_MODE_CONNECTOR_HDMIA, 243 240 &priv->ddc, 241 + BIT(HDMI_COLORSPACE_RGB), 244 242 0); 245 243 KUNIT_EXPECT_LT(test, ret, 0); 246 244 } ··· 264 260 &dummy_funcs, 265 261 DRM_MODE_CONNECTOR_HDMIA, 266 262 &priv->ddc, 263 + BIT(HDMI_COLORSPACE_RGB), 267 264 8); 268 265 KUNIT_EXPECT_EQ(test, ret, 0); 269 266 ··· 303 298 &dummy_funcs, 304 299 DRM_MODE_CONNECTOR_HDMIA, 305 300 &priv->ddc, 301 + BIT(HDMI_COLORSPACE_RGB), 306 302 10); 307 303 KUNIT_EXPECT_EQ(test, ret, 0); 308 304 ··· 342 336 &dummy_funcs, 343 337 DRM_MODE_CONNECTOR_HDMIA, 344 338 &priv->ddc, 339 + BIT(HDMI_COLORSPACE_RGB), 345 340 12); 346 341 KUNIT_EXPECT_EQ(test, ret, 0); 347 342 ··· 377 370 &dummy_funcs, 378 371 connector_type, 379 372 &priv->ddc, 373 + BIT(HDMI_COLORSPACE_RGB), 380 374 8); 381 375 KUNIT_EXPECT_EQ(test, ret, 0); 382 376 } ··· 410 402 &dummy_funcs, 411 403 connector_type, 412 404 &priv->ddc, 405 + BIT(HDMI_COLORSPACE_RGB), 413 406 8); 414 407 KUNIT_EXPECT_LT(test, ret, 0); 415 408 }
+17 -5
drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
··· 149 149 static 150 150 struct drm_atomic_helper_connector_hdmi_priv * 151 151 drm_atomic_helper_connector_hdmi_init(struct kunit *test, 152 + unsigned int formats, 152 153 unsigned int max_bpc) 153 154 { 154 155 struct drm_atomic_helper_connector_hdmi_priv *priv; ··· 193 192 &dummy_connector_funcs, 194 193 DRM_MODE_CONNECTOR_HDMIA, 195 194 NULL, 195 + formats, 196 196 max_bpc); 197 197 KUNIT_ASSERT_EQ(test, ret, 0); 198 198 ··· 229 227 struct drm_crtc *crtc; 230 228 int ret; 231 229 232 - priv = drm_atomic_helper_connector_hdmi_init(test, 10); 230 + priv = drm_atomic_helper_connector_hdmi_init(test, 231 + BIT(HDMI_COLORSPACE_RGB), 232 + 10); 233 233 KUNIT_ASSERT_NOT_NULL(test, priv); 234 234 235 235 ctx = drm_kunit_helper_acquire_ctx_alloc(test); ··· 298 294 struct drm_crtc *crtc; 299 295 int ret; 300 296 301 - priv = drm_atomic_helper_connector_hdmi_init(test, 10); 297 + priv = drm_atomic_helper_connector_hdmi_init(test, 298 + BIT(HDMI_COLORSPACE_RGB), 299 + 10); 302 300 KUNIT_ASSERT_NOT_NULL(test, priv); 303 301 304 302 ctx = drm_kunit_helper_acquire_ctx_alloc(test); ··· 369 363 struct drm_connector_state *conn_state; 370 364 struct drm_connector *conn; 371 365 372 - priv = drm_atomic_helper_connector_hdmi_init(test, 8); 366 + priv = drm_atomic_helper_connector_hdmi_init(test, 367 + BIT(HDMI_COLORSPACE_RGB), 368 + 8); 373 369 KUNIT_ASSERT_NOT_NULL(test, priv); 374 370 375 371 conn = &priv->connector; ··· 393 385 struct drm_connector_state *conn_state; 394 386 struct drm_connector *conn; 395 387 396 - priv = drm_atomic_helper_connector_hdmi_init(test, 10); 388 + priv = drm_atomic_helper_connector_hdmi_init(test, 389 + BIT(HDMI_COLORSPACE_RGB), 390 + 10); 397 391 KUNIT_ASSERT_NOT_NULL(test, priv); 398 392 399 393 conn = &priv->connector; ··· 417 407 struct drm_connector_state *conn_state; 418 408 struct drm_connector *conn; 419 409 420 - priv = drm_atomic_helper_connector_hdmi_init(test, 12); 410 + priv = drm_atomic_helper_connector_hdmi_init(test, 411 + BIT(HDMI_COLORSPACE_RGB), 412 + 12); 421 413 KUNIT_ASSERT_NOT_NULL(test, priv); 422 414 423 415 conn = &priv->connector;
+20
include/drm/drm_connector.h
··· 368 368 DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, 369 369 }; 370 370 371 + const char * 372 + drm_hdmi_connector_get_output_format_name(enum hdmi_colorspace fmt); 373 + 371 374 /** 372 375 * struct drm_monitor_range_info - Panel's Monitor range in EDID for 373 376 * &drm_display_info ··· 1044 1041 * @output_bpc: Bits per color channel to output. 1045 1042 */ 1046 1043 unsigned int output_bpc; 1044 + 1045 + /** 1046 + * @output_format: Pixel format to output in. 1047 + */ 1048 + enum hdmi_colorspace output_format; 1047 1049 } hdmi; 1048 1050 }; 1049 1051 ··· 1914 1906 1915 1907 /** @hdr_sink_metadata: HDR Metadata Information read from sink */ 1916 1908 struct hdr_sink_metadata hdr_sink_metadata; 1909 + 1910 + /** 1911 + * @hdmi: HDMI-related variable and properties. 1912 + */ 1913 + struct { 1914 + /** 1915 + * @supported_formats: Bitmask of @hdmi_colorspace 1916 + * supported by the controller. 1917 + */ 1918 + unsigned long supported_formats; 1919 + } hdmi; 1917 1920 }; 1918 1921 1919 1922 #define obj_to_connector(x) container_of(x, struct drm_connector, base) ··· 1948 1929 const struct drm_connector_funcs *funcs, 1949 1930 int connector_type, 1950 1931 struct i2c_adapter *ddc, 1932 + unsigned long supported_formats, 1951 1933 unsigned int max_bpc); 1952 1934 void drm_connector_attach_edid_property(struct drm_connector *connector); 1953 1935 int drm_connector_register(struct drm_connector *connector);