[RFC,08/13] drm/connector: hdmi: Add custom hook to filter TMDS character rate
Commit Message
Most of the HDMI controllers have an upper TMDS character rate limit
they can't exceed. On "embedded"-grade display controllers, it will
typically be lower than what high-grade monitors can provide these days,
so drivers will filter the TMDS character rate based on the controller
capabilities.
To make that easier to handle for drivers, let's provide an optional
hook to be implemented by drivers so they can tell the HDMI controller
helpers if a given TMDS character rate is reachable for them or not.
This will then be useful to figure out the best format and bpc count for
a given mode.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/drm_hdmi_connector.c | 8 ++++++++
include/drm/drm_connector.h | 30 ++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
@@ -263,12 +263,16 @@ drm_hdmi_connector_clock_valid(const struct drm_hdmi_connector *hdmi_connector,
const struct drm_display_mode *mode,
unsigned long long clock)
{
+ const struct drm_hdmi_connector_funcs *funcs = hdmi_connector->funcs;
const struct drm_connector *connector = &hdmi_connector->base;
const struct drm_display_info *info = &connector->display_info;
if (info->max_tmds_clock && clock > info->max_tmds_clock * 1000)
return MODE_CLOCK_HIGH;
+ if (funcs && funcs->tmds_char_rate_valid)
+ return funcs->tmds_char_rate_valid(hdmi_connector, mode, clock);
+
return MODE_OK;
}
@@ -458,6 +462,7 @@ EXPORT_SYMBOL(drm_atomic_helper_hdmi_connector_print_state);
* drmm_hdmi_connector_init - Init a preallocated HDMI connector
* @dev: DRM device
* @hdmi_connector: A pointer to the HDMI connector to init
+ * @funcs: callbacks for this connector
* @connector_type: user visible type of the connector
* @ddc: optional pointer to the associated ddc adapter
* @max_bpc: Maximum bits per char the HDMI connector supports
@@ -476,6 +481,7 @@ EXPORT_SYMBOL(drm_atomic_helper_hdmi_connector_print_state);
int drmm_hdmi_connector_init(struct drm_device *dev,
struct drm_hdmi_connector *hdmi_connector,
const struct drm_connector_funcs *funcs,
+ const struct drm_hdmi_connector_funcs *hdmi_funcs,
int connector_type,
struct i2c_adapter *ddc,
unsigned int max_bpc)
@@ -516,6 +522,8 @@ int drmm_hdmi_connector_init(struct drm_device *dev,
hdmi_connector->max_bpc = max_bpc;
}
+ hdmi_connector->funcs = hdmi_funcs;
+
return 0;
}
EXPORT_SYMBOL(drmm_hdmi_connector_init);
@@ -2131,12 +2131,41 @@ bool
drm_atomic_helper_hdmi_connector_is_full_range(const struct drm_hdmi_connector *hdmi_connector,
const struct drm_hdmi_connector_state *hdmi_state);
+/**
+ * struct drm_hdmi_connector_funcs - drm_hdmi_connector control functions
+ */
+struct drm_hdmi_connector_funcs {
+ /**
+ * @tmds_char_rate_valid:
+ *
+ * This callback is invoked at atomic_check time to figure out
+ * whether a particular TMDS character rate is supported by the
+ * driver.
+ *
+ * The @tmds_char_rate_valid callback is optional.
+ *
+ * Returns:
+ *
+ * Either &drm_mode_status.MODE_OK or one of the failure reasons
+ * in &enum drm_mode_status.
+ */
+ enum drm_mode_status
+ (*tmds_char_rate_valid)(const struct drm_hdmi_connector *connector,
+ const struct drm_display_mode *mode,
+ unsigned long long tmds_rate);
+};
+
struct drm_hdmi_connector {
/**
* @base: Base Connector
*/
struct drm_connector base;
+ /**
+ * @funcs: HDMI connector Control Functions
+ */
+ const struct drm_hdmi_connector_funcs *funcs;
+
/**
* @max_bpc: Maximum bits per character the connector supports.
*/
@@ -2160,6 +2189,7 @@ drm_hdmi_connector_compute_mode_clock(const struct drm_display_mode *mode,
int drmm_hdmi_connector_init(struct drm_device *dev,
struct drm_hdmi_connector *hdmi_connector,
const struct drm_connector_funcs *funcs,
+ const struct drm_hdmi_connector_funcs *hdmi_funcs,
int connector_type,
struct i2c_adapter *ddc,
unsigned int max_bpc);