Commit f9b0e251 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Daniel Vetter

drm: make mode_valid callback optional

Many drm connectors do not need mode validation.
The patch makes this callback optional and removes dumb implementations.

v2: Rebase:
- imx move to a shared (but still dummy) ->mode_valid implementation.
- probe helpers have been extracted to drm_probe_helper.c

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> (v1)
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 0967e6a5
...@@ -1903,8 +1903,8 @@ void intel_crt_init(struct drm_device *dev) ...@@ -1903,8 +1903,8 @@ void intel_crt_init(struct drm_device *dev)
<para> <para>
The function filters out modes larger than The function filters out modes larger than
<parameter>max_width</parameter> and <parameter>max_height</parameter> <parameter>max_width</parameter> and <parameter>max_height</parameter>
if specified. It then calls the connector if specified. It then calls the optional connector
<methodname>mode_valid</methodname> helper operation for each mode in <methodname>mode_valid</methodname> helper operation for each mode in
the probed list to check whether the mode is valid for the connector. the probed list to check whether the mode is valid for the connector.
</para> </para>
</listitem> </listitem>
...@@ -2265,7 +2265,7 @@ void intel_crt_init(struct drm_device *dev) ...@@ -2265,7 +2265,7 @@ void intel_crt_init(struct drm_device *dev)
<para> <para>
Verify whether a mode is valid for the connector. Return MODE_OK for Verify whether a mode is valid for the connector. Return MODE_OK for
supported modes and one of the enum drm_mode_status values (MODE_*) supported modes and one of the enum drm_mode_status values (MODE_*)
for unsupported modes. This operation is mandatory. for unsupported modes. This operation is optional.
</para> </para>
<para> <para>
As the mode rejection reason is currently not used beside for As the mode rejection reason is currently not used beside for
......
...@@ -743,12 +743,6 @@ static int ast_get_modes(struct drm_connector *connector) ...@@ -743,12 +743,6 @@ static int ast_get_modes(struct drm_connector *connector)
return 0; return 0;
} }
static int ast_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static void ast_connector_destroy(struct drm_connector *connector) static void ast_connector_destroy(struct drm_connector *connector)
{ {
struct ast_connector *ast_connector = to_ast_connector(connector); struct ast_connector *ast_connector = to_ast_connector(connector);
...@@ -765,7 +759,6 @@ ast_connector_detect(struct drm_connector *connector, bool force) ...@@ -765,7 +759,6 @@ ast_connector_detect(struct drm_connector *connector, bool force)
} }
static const struct drm_connector_helper_funcs ast_connector_helper_funcs = { static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {
.mode_valid = ast_mode_valid,
.get_modes = ast_get_modes, .get_modes = ast_get_modes,
.best_encoder = ast_best_single_encoder, .best_encoder = ast_best_single_encoder,
}; };
......
...@@ -225,12 +225,6 @@ int ptn3460_get_modes(struct drm_connector *connector) ...@@ -225,12 +225,6 @@ int ptn3460_get_modes(struct drm_connector *connector)
return num_modes; return num_modes;
} }
static int ptn3460_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector) struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector)
{ {
struct ptn3460_bridge *ptn_bridge; struct ptn3460_bridge *ptn_bridge;
...@@ -242,7 +236,6 @@ struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector) ...@@ -242,7 +236,6 @@ struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector)
struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = { struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = {
.get_modes = ptn3460_get_modes, .get_modes = ptn3460_get_modes,
.mode_valid = ptn3460_mode_valid,
.best_encoder = ptn3460_best_encoder, .best_encoder = ptn3460_best_encoder,
}; };
......
...@@ -505,13 +505,6 @@ static int cirrus_vga_get_modes(struct drm_connector *connector) ...@@ -505,13 +505,6 @@ static int cirrus_vga_get_modes(struct drm_connector *connector)
return count; return count;
} }
static int cirrus_vga_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
/* Any mode we've added is valid */
return MODE_OK;
}
static struct drm_encoder *cirrus_connector_best_encoder(struct drm_connector static struct drm_encoder *cirrus_connector_best_encoder(struct drm_connector
*connector) *connector)
{ {
...@@ -546,7 +539,6 @@ static void cirrus_connector_destroy(struct drm_connector *connector) ...@@ -546,7 +539,6 @@ static void cirrus_connector_destroy(struct drm_connector *connector)
struct drm_connector_helper_funcs cirrus_vga_connector_helper_funcs = { struct drm_connector_helper_funcs cirrus_vga_connector_helper_funcs = {
.get_modes = cirrus_vga_get_modes, .get_modes = cirrus_vga_get_modes,
.mode_valid = cirrus_vga_mode_valid,
.best_encoder = cirrus_connector_best_encoder, .best_encoder = cirrus_connector_best_encoder,
}; };
......
...@@ -169,7 +169,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, ...@@ -169,7 +169,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
drm_mode_validate_flag(connector, mode_flags); drm_mode_validate_flag(connector, mode_flags);
list_for_each_entry(mode, &connector->modes, head) { list_for_each_entry(mode, &connector->modes, head) {
if (mode->status == MODE_OK) if (mode->status == MODE_OK && connector_funcs->mode_valid)
mode->status = connector_funcs->mode_valid(connector, mode->status = connector_funcs->mode_valid(connector,
mode); mode);
} }
......
...@@ -949,12 +949,6 @@ static int exynos_dp_get_modes(struct drm_connector *connector) ...@@ -949,12 +949,6 @@ static int exynos_dp_get_modes(struct drm_connector *connector)
return 1; return 1;
} }
static int exynos_dp_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static struct drm_encoder *exynos_dp_best_encoder( static struct drm_encoder *exynos_dp_best_encoder(
struct drm_connector *connector) struct drm_connector *connector)
{ {
...@@ -965,7 +959,6 @@ static struct drm_encoder *exynos_dp_best_encoder( ...@@ -965,7 +959,6 @@ static struct drm_encoder *exynos_dp_best_encoder(
static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = { static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
.get_modes = exynos_dp_get_modes, .get_modes = exynos_dp_get_modes,
.mode_valid = exynos_dp_mode_valid,
.best_encoder = exynos_dp_best_encoder, .best_encoder = exynos_dp_best_encoder,
}; };
......
...@@ -94,12 +94,6 @@ static int exynos_dpi_get_modes(struct drm_connector *connector) ...@@ -94,12 +94,6 @@ static int exynos_dpi_get_modes(struct drm_connector *connector)
return 0; return 0;
} }
static int exynos_dpi_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static struct drm_encoder * static struct drm_encoder *
exynos_dpi_best_encoder(struct drm_connector *connector) exynos_dpi_best_encoder(struct drm_connector *connector)
{ {
...@@ -110,7 +104,6 @@ exynos_dpi_best_encoder(struct drm_connector *connector) ...@@ -110,7 +104,6 @@ exynos_dpi_best_encoder(struct drm_connector *connector)
static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = { static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = {
.get_modes = exynos_dpi_get_modes, .get_modes = exynos_dpi_get_modes,
.mode_valid = exynos_dpi_mode_valid,
.best_encoder = exynos_dpi_best_encoder, .best_encoder = exynos_dpi_best_encoder,
}; };
......
...@@ -533,12 +533,6 @@ static int vidi_get_modes(struct drm_connector *connector) ...@@ -533,12 +533,6 @@ static int vidi_get_modes(struct drm_connector *connector)
return drm_add_edid_modes(connector, edid); return drm_add_edid_modes(connector, edid);
} }
static int vidi_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector) static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector)
{ {
struct vidi_context *ctx = ctx_from_connector(connector); struct vidi_context *ctx = ctx_from_connector(connector);
...@@ -548,7 +542,6 @@ static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector) ...@@ -548,7 +542,6 @@ static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector)
static struct drm_connector_helper_funcs vidi_connector_helper_funcs = { static struct drm_connector_helper_funcs vidi_connector_helper_funcs = {
.get_modes = vidi_get_modes, .get_modes = vidi_get_modes,
.mode_valid = vidi_mode_valid,
.best_encoder = vidi_best_encoder, .best_encoder = vidi_best_encoder,
}; };
......
...@@ -57,15 +57,8 @@ static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector) ...@@ -57,15 +57,8 @@ static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector)
return 1; return 1;
} }
static int rcar_du_lvds_connector_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static const struct drm_connector_helper_funcs connector_helper_funcs = { static const struct drm_connector_helper_funcs connector_helper_funcs = {
.get_modes = rcar_du_lvds_connector_get_modes, .get_modes = rcar_du_lvds_connector_get_modes,
.mode_valid = rcar_du_lvds_connector_mode_valid,
.best_encoder = rcar_du_connector_best_encoder, .best_encoder = rcar_du_connector_best_encoder,
}; };
......
...@@ -25,15 +25,8 @@ static int rcar_du_vga_connector_get_modes(struct drm_connector *connector) ...@@ -25,15 +25,8 @@ static int rcar_du_vga_connector_get_modes(struct drm_connector *connector)
return 0; return 0;
} }
static int rcar_du_vga_connector_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static const struct drm_connector_helper_funcs connector_helper_funcs = { static const struct drm_connector_helper_funcs connector_helper_funcs = {
.get_modes = rcar_du_vga_connector_get_modes, .get_modes = rcar_du_vga_connector_get_modes,
.mode_valid = rcar_du_vga_connector_mode_valid,
.best_encoder = rcar_du_connector_best_encoder, .best_encoder = rcar_du_connector_best_encoder,
}; };
......
...@@ -674,12 +674,6 @@ static int shmob_drm_connector_get_modes(struct drm_connector *connector) ...@@ -674,12 +674,6 @@ static int shmob_drm_connector_get_modes(struct drm_connector *connector)
return 1; return 1;
} }
static int shmob_drm_connector_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
static struct drm_encoder * static struct drm_encoder *
shmob_drm_connector_best_encoder(struct drm_connector *connector) shmob_drm_connector_best_encoder(struct drm_connector *connector)
{ {
...@@ -690,7 +684,6 @@ shmob_drm_connector_best_encoder(struct drm_connector *connector) ...@@ -690,7 +684,6 @@ shmob_drm_connector_best_encoder(struct drm_connector *connector)
static const struct drm_connector_helper_funcs connector_helper_funcs = { static const struct drm_connector_helper_funcs connector_helper_funcs = {
.get_modes = shmob_drm_connector_get_modes, .get_modes = shmob_drm_connector_get_modes,
.mode_valid = shmob_drm_connector_mode_valid,
.best_encoder = shmob_drm_connector_best_encoder, .best_encoder = shmob_drm_connector_best_encoder,
}; };
......
...@@ -200,13 +200,6 @@ static const struct file_operations imx_drm_driver_fops = { ...@@ -200,13 +200,6 @@ static const struct file_operations imx_drm_driver_fops = {
.llseek = noop_llseek, .llseek = noop_llseek,
}; };
int imx_drm_connector_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
return MODE_OK;
}
EXPORT_SYMBOL(imx_drm_connector_mode_valid);
void imx_drm_connector_destroy(struct drm_connector *connector) void imx_drm_connector_destroy(struct drm_connector *connector)
{ {
drm_sysfs_connector_remove(connector); drm_sysfs_connector_remove(connector);
......
...@@ -50,8 +50,6 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, ...@@ -50,8 +50,6 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
int imx_drm_encoder_parse_of(struct drm_device *drm, int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np); struct drm_encoder *encoder, struct device_node *np);
int imx_drm_connector_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode);
void imx_drm_connector_destroy(struct drm_connector *connector); void imx_drm_connector_destroy(struct drm_connector *connector);
void imx_drm_encoder_destroy(struct drm_encoder *encoder); void imx_drm_encoder_destroy(struct drm_encoder *encoder);
......
...@@ -1492,7 +1492,6 @@ static struct drm_connector_funcs imx_hdmi_connector_funcs = { ...@@ -1492,7 +1492,6 @@ static struct drm_connector_funcs imx_hdmi_connector_funcs = {
static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = { static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = {
.get_modes = imx_hdmi_connector_get_modes, .get_modes = imx_hdmi_connector_get_modes,
.mode_valid = imx_drm_connector_mode_valid,
.best_encoder = imx_hdmi_connector_best_encoder, .best_encoder = imx_hdmi_connector_best_encoder,
}; };
......
...@@ -317,7 +317,6 @@ static struct drm_connector_funcs imx_ldb_connector_funcs = { ...@@ -317,7 +317,6 @@ static struct drm_connector_funcs imx_ldb_connector_funcs = {
static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = { static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = {
.get_modes = imx_ldb_connector_get_modes, .get_modes = imx_ldb_connector_get_modes,
.best_encoder = imx_ldb_connector_best_encoder, .best_encoder = imx_ldb_connector_best_encoder,
.mode_valid = imx_drm_connector_mode_valid,
}; };
static struct drm_encoder_funcs imx_ldb_encoder_funcs = { static struct drm_encoder_funcs imx_ldb_encoder_funcs = {
......
...@@ -251,10 +251,6 @@ static int imx_tve_connector_mode_valid(struct drm_connector *connector, ...@@ -251,10 +251,6 @@ static int imx_tve_connector_mode_valid(struct drm_connector *connector,
unsigned long rate; unsigned long rate;
int ret; int ret;
ret = imx_drm_connector_mode_valid(connector, mode);
if (ret != MODE_OK)
return ret;
/* pixel clock with 2x oversampling */ /* pixel clock with 2x oversampling */
rate = clk_round_rate(tve->clk, 2000UL * mode->clock) / 2000; rate = clk_round_rate(tve->clk, 2000UL * mode->clock) / 2000;
if (rate == mode->clock) if (rate == mode->clock)
......
...@@ -148,7 +148,6 @@ static struct drm_connector_funcs imx_pd_connector_funcs = { ...@@ -148,7 +148,6 @@ static struct drm_connector_funcs imx_pd_connector_funcs = {
static struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = { static struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = {
.get_modes = imx_pd_connector_get_modes, .get_modes = imx_pd_connector_get_modes,
.best_encoder = imx_pd_connector_best_encoder, .best_encoder = imx_pd_connector_best_encoder,
.mode_valid = imx_drm_connector_mode_valid,
}; };
static struct drm_encoder_funcs imx_pd_encoder_funcs = { static struct drm_encoder_funcs imx_pd_encoder_funcs = {
......
...@@ -114,7 +114,7 @@ struct drm_encoder_helper_funcs { ...@@ -114,7 +114,7 @@ struct drm_encoder_helper_funcs {
/** /**
* drm_connector_helper_funcs - helper operations for connectors * drm_connector_helper_funcs - helper operations for connectors
* @get_modes: get mode list for this connector * @get_modes: get mode list for this connector
* @mode_valid: is this mode valid on the given connector? * @mode_valid (optional): is this mode valid on the given connector?
* *
* The helper operations are called by the mid-layer CRTC helper. * The helper operations are called by the mid-layer CRTC helper.
*/ */
......
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