Commit aadb3e16 authored by Maxime Ripard's avatar Maxime Ripard

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: default avatarDave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240527-kms-hdmi-connector-state-v15-4-c5af16c3aae2@kernel.orgSigned-off-by: default avatarMaxime Ripard <mripard@kernel.org>
parent 54cb39e2
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
void __drm_atomic_helper_connector_hdmi_reset(struct drm_connector *connector, void __drm_atomic_helper_connector_hdmi_reset(struct drm_connector *connector,
struct drm_connector_state *new_conn_state) struct drm_connector_state *new_conn_state)
{ {
unsigned int max_bpc = connector->max_bpc;
new_conn_state->max_bpc = max_bpc;
new_conn_state->max_requested_bpc = max_bpc;
} }
EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset); EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset);
...@@ -36,6 +40,22 @@ EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset); ...@@ -36,6 +40,22 @@ EXPORT_SYMBOL(__drm_atomic_helper_connector_hdmi_reset);
int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
struct drm_atomic_state *state) struct drm_atomic_state *state)
{ {
struct drm_connector_state *old_conn_state =
drm_atomic_get_old_connector_state(state, connector);
struct drm_connector_state *new_conn_state =
drm_atomic_get_new_connector_state(state, connector);
if (old_conn_state->hdmi.output_bpc != new_conn_state->hdmi.output_bpc) {
struct drm_crtc *crtc = new_conn_state->crtc;
struct drm_crtc_state *crtc_state;
crtc_state = drm_atomic_get_crtc_state(state, crtc);
if (IS_ERR(crtc_state))
return PTR_ERR(crtc_state);
crtc_state->mode_changed = true;
}
return 0; return 0;
} }
EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check); EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check);
...@@ -1143,6 +1143,11 @@ static void drm_atomic_connector_print_state(struct drm_printer *p, ...@@ -1143,6 +1143,11 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,
drm_printf(p, "\tmax_requested_bpc=%d\n", state->max_requested_bpc); drm_printf(p, "\tmax_requested_bpc=%d\n", state->max_requested_bpc);
drm_printf(p, "\tcolorspace=%s\n", drm_get_colorspace_name(state->colorspace)); drm_printf(p, "\tcolorspace=%s\n", drm_get_colorspace_name(state->colorspace));
if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {
drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc);
}
if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
if (state->writeback_job && state->writeback_job->fb) if (state->writeback_job && state->writeback_job->fb)
drm_printf(p, "\tfb=%d\n", state->writeback_job->fb->base.id); drm_printf(p, "\tfb=%d\n", state->writeback_job->fb->base.id);
......
...@@ -459,6 +459,7 @@ EXPORT_SYMBOL(drmm_connector_init); ...@@ -459,6 +459,7 @@ EXPORT_SYMBOL(drmm_connector_init);
* @funcs: callbacks for this connector * @funcs: callbacks for this connector
* @connector_type: user visible type of the connector * @connector_type: user visible type of the connector
* @ddc: optional pointer to the associated ddc adapter * @ddc: optional pointer to the associated ddc adapter
* @max_bpc: Maximum bits per char the HDMI connector supports
* *
* Initialises a preallocated HDMI connector. Connectors can be * Initialises a preallocated HDMI connector. Connectors can be
* subclassed as part of driver connector objects. * subclassed as part of driver connector objects.
...@@ -475,7 +476,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev, ...@@ -475,7 +476,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev,
struct drm_connector *connector, struct drm_connector *connector,
const struct drm_connector_funcs *funcs, const struct drm_connector_funcs *funcs,
int connector_type, int connector_type,
struct i2c_adapter *ddc) struct i2c_adapter *ddc,
unsigned int max_bpc)
{ {
int ret; int ret;
...@@ -483,10 +485,26 @@ int drmm_connector_hdmi_init(struct drm_device *dev, ...@@ -483,10 +485,26 @@ int drmm_connector_hdmi_init(struct drm_device *dev,
connector_type == DRM_MODE_CONNECTOR_HDMIB)) connector_type == DRM_MODE_CONNECTOR_HDMIB))
return -EINVAL; return -EINVAL;
if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12))
return -EINVAL;
ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc);
if (ret) if (ret)
return ret; return ret;
/*
* drm_connector_attach_max_bpc_property() requires the
* connector to have a state.
*/
if (connector->funcs->reset)
connector->funcs->reset(connector);
drm_connector_attach_max_bpc_property(connector, 8, max_bpc);
connector->max_bpc = max_bpc;
if (max_bpc > 8)
drm_connector_attach_hdr_output_metadata_property(connector);
return 0; return 0;
} }
EXPORT_SYMBOL(drmm_connector_hdmi_init); EXPORT_SYMBOL(drmm_connector_hdmi_init);
......
...@@ -184,7 +184,8 @@ static void drm_test_connector_hdmi_init_valid(struct kunit *test) ...@@ -184,7 +184,8 @@ static void drm_test_connector_hdmi_init_valid(struct kunit *test)
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs, &dummy_funcs,
DRM_MODE_CONNECTOR_HDMIA, DRM_MODE_CONNECTOR_HDMIA,
&priv->ddc); &priv->ddc,
8);
KUNIT_EXPECT_EQ(test, ret, 0); KUNIT_EXPECT_EQ(test, ret, 0);
} }
...@@ -200,7 +201,8 @@ static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test) ...@@ -200,7 +201,8 @@ static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test)
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs, &dummy_funcs,
DRM_MODE_CONNECTOR_HDMIA, DRM_MODE_CONNECTOR_HDMIA,
NULL); NULL,
8);
KUNIT_EXPECT_EQ(test, ret, 0); KUNIT_EXPECT_EQ(test, ret, 0);
} }
...@@ -217,7 +219,8 @@ static void drm_test_connector_hdmi_init_type_valid(struct kunit *test) ...@@ -217,7 +219,8 @@ static void drm_test_connector_hdmi_init_type_valid(struct kunit *test)
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs, &dummy_funcs,
connector_type, connector_type,
&priv->ddc); &priv->ddc,
8);
KUNIT_EXPECT_EQ(test, ret, 0); KUNIT_EXPECT_EQ(test, ret, 0);
} }
...@@ -248,7 +251,8 @@ static void drm_test_connector_hdmi_init_type_invalid(struct kunit *test) ...@@ -248,7 +251,8 @@ static void drm_test_connector_hdmi_init_type_invalid(struct kunit *test)
ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
&dummy_funcs, &dummy_funcs,
connector_type, connector_type,
&priv->ddc); &priv->ddc,
8);
KUNIT_EXPECT_LT(test, ret, 0); KUNIT_EXPECT_LT(test, ret, 0);
} }
......
...@@ -1037,6 +1037,10 @@ struct drm_connector_state { ...@@ -1037,6 +1037,10 @@ struct drm_connector_state {
* @drm_atomic_helper_connector_hdmi_check(). * @drm_atomic_helper_connector_hdmi_check().
*/ */
struct { struct {
/**
* @output_bpc: Bits per color channel to output.
*/
unsigned int output_bpc;
} hdmi; } hdmi;
}; };
...@@ -1686,6 +1690,11 @@ struct drm_connector { ...@@ -1686,6 +1690,11 @@ struct drm_connector {
*/ */
struct drm_property_blob *path_blob_ptr; struct drm_property_blob *path_blob_ptr;
/**
* @max_bpc: Maximum bits per color channel the connector supports.
*/
unsigned int max_bpc;
/** /**
* @max_bpc_property: Default connector property for the max bpc to be * @max_bpc_property: Default connector property for the max bpc to be
* driven out of the connector. * driven out of the connector.
...@@ -1919,7 +1928,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev, ...@@ -1919,7 +1928,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev,
struct drm_connector *connector, struct drm_connector *connector,
const struct drm_connector_funcs *funcs, const struct drm_connector_funcs *funcs,
int connector_type, int connector_type,
struct i2c_adapter *ddc); struct i2c_adapter *ddc,
unsigned int max_bpc);
void drm_connector_attach_edid_property(struct drm_connector *connector); void drm_connector_attach_edid_property(struct drm_connector *connector);
int drm_connector_register(struct drm_connector *connector); int drm_connector_register(struct drm_connector *connector);
void drm_connector_unregister(struct drm_connector *connector); void drm_connector_unregister(struct drm_connector *connector);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment