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 output BPC to the connector state

We'll add automatic selection of the output BPC in a following patch,
but let's add it to the HDMI connector state already.

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-4-c5af16c3aae2@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+63 -6
+20
drivers/gpu/drm/display/drm_hdmi_state_helper.c
··· 18 18 void __drm_atomic_helper_connector_hdmi_reset(struct drm_connector *connector, 19 19 struct drm_connector_state *new_conn_state) 20 20 { 21 + unsigned int max_bpc = connector->max_bpc; 22 + 23 + new_conn_state->max_bpc = max_bpc; 24 + new_conn_state->max_requested_bpc = max_bpc; 21 25 } 22 26 EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset); 23 27 ··· 40 36 int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, 41 37 struct drm_atomic_state *state) 42 38 { 39 + struct drm_connector_state *old_conn_state = 40 + drm_atomic_get_old_connector_state(state, connector); 41 + struct drm_connector_state *new_conn_state = 42 + drm_atomic_get_new_connector_state(state, connector); 43 + 44 + if (old_conn_state->hdmi.output_bpc != new_conn_state->hdmi.output_bpc) { 45 + struct drm_crtc *crtc = new_conn_state->crtc; 46 + struct drm_crtc_state *crtc_state; 47 + 48 + crtc_state = drm_atomic_get_crtc_state(state, crtc); 49 + if (IS_ERR(crtc_state)) 50 + return PTR_ERR(crtc_state); 51 + 52 + crtc_state->mode_changed = true; 53 + } 54 + 43 55 return 0; 44 56 } 45 57 EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check);
+5
drivers/gpu/drm/drm_atomic.c
··· 1143 1143 drm_printf(p, "\tmax_requested_bpc=%d\n", state->max_requested_bpc); 1144 1144 drm_printf(p, "\tcolorspace=%s\n", drm_get_colorspace_name(state->colorspace)); 1145 1145 1146 + if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || 1147 + connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) { 1148 + drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc); 1149 + } 1150 + 1146 1151 if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) 1147 1152 if (state->writeback_job && state->writeback_job->fb) 1148 1153 drm_printf(p, "\tfb=%d\n", state->writeback_job->fb->base.id);
+19 -1
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 + * @max_bpc: Maximum bits per char the HDMI connector supports 462 463 * 463 464 * Initialises a preallocated HDMI connector. Connectors can be 464 465 * subclassed as part of driver connector objects. ··· 476 475 struct drm_connector *connector, 477 476 const struct drm_connector_funcs *funcs, 478 477 int connector_type, 479 - struct i2c_adapter *ddc) 478 + struct i2c_adapter *ddc, 479 + unsigned int max_bpc) 480 480 { 481 481 int ret; 482 482 ··· 485 483 connector_type == DRM_MODE_CONNECTOR_HDMIB)) 486 484 return -EINVAL; 487 485 486 + if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12)) 487 + return -EINVAL; 488 + 488 489 ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); 489 490 if (ret) 490 491 return ret; 492 + 493 + /* 494 + * drm_connector_attach_max_bpc_property() requires the 495 + * connector to have a state. 496 + */ 497 + if (connector->funcs->reset) 498 + connector->funcs->reset(connector); 499 + 500 + drm_connector_attach_max_bpc_property(connector, 8, max_bpc); 501 + connector->max_bpc = max_bpc; 502 + 503 + if (max_bpc > 8) 504 + drm_connector_attach_hdr_output_metadata_property(connector); 491 505 492 506 return 0; 493 507 }
+8 -4
drivers/gpu/drm/tests/drm_connector_test.c
··· 184 184 ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, 185 185 &dummy_funcs, 186 186 DRM_MODE_CONNECTOR_HDMIA, 187 - &priv->ddc); 187 + &priv->ddc, 188 + 8); 188 189 KUNIT_EXPECT_EQ(test, ret, 0); 189 190 } 190 191 ··· 201 200 ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, 202 201 &dummy_funcs, 203 202 DRM_MODE_CONNECTOR_HDMIA, 204 - NULL); 203 + NULL, 204 + 8); 205 205 KUNIT_EXPECT_EQ(test, ret, 0); 206 206 } 207 207 ··· 219 217 ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, 220 218 &dummy_funcs, 221 219 connector_type, 222 - &priv->ddc); 220 + &priv->ddc, 221 + 8); 223 222 KUNIT_EXPECT_EQ(test, ret, 0); 224 223 } 225 224 ··· 251 248 ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, 252 249 &dummy_funcs, 253 250 connector_type, 254 - &priv->ddc); 251 + &priv->ddc, 252 + 8); 255 253 KUNIT_EXPECT_LT(test, ret, 0); 256 254 } 257 255
+11 -1
include/drm/drm_connector.h
··· 1037 1037 * @drm_atomic_helper_connector_hdmi_check(). 1038 1038 */ 1039 1039 struct { 1040 + /** 1041 + * @output_bpc: Bits per color channel to output. 1042 + */ 1043 + unsigned int output_bpc; 1040 1044 } hdmi; 1041 1045 }; 1042 1046 ··· 1691 1687 struct drm_property_blob *path_blob_ptr; 1692 1688 1693 1689 /** 1690 + * @max_bpc: Maximum bits per color channel the connector supports. 1691 + */ 1692 + unsigned int max_bpc; 1693 + 1694 + /** 1694 1695 * @max_bpc_property: Default connector property for the max bpc to be 1695 1696 * driven out of the connector. 1696 1697 */ ··· 1928 1919 struct drm_connector *connector, 1929 1920 const struct drm_connector_funcs *funcs, 1930 1921 int connector_type, 1931 - struct i2c_adapter *ddc); 1922 + struct i2c_adapter *ddc, 1923 + unsigned int max_bpc); 1932 1924 void drm_connector_attach_edid_property(struct drm_connector *connector); 1933 1925 int drm_connector_register(struct drm_connector *connector); 1934 1926 void drm_connector_unregister(struct drm_connector *connector);