[PATCH v2] drm: make mode_valid callback optional
Daniel Vetter
daniel at ffwll.ch
Thu Apr 3 14:21:51 PDT 2014
On Wed, Apr 02, 2014 at 12:29:46PM +0200, Andrzej Hajda wrote:
> Many drm connectors do not need mode validation.
> The patch makes this callback optional and removes dumb implementations.
>
> Signed-off-by: Andrzej Hajda <a.hajda at samsung.com>
> ---
> v2:
> - added comment and updated DocBook
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
> Documentation/DocBook/drm.tmpl | 6 +++---
> drivers/gpu/drm/ast/ast_mode.c | 7 -------
> drivers/gpu/drm/bridge/ptn3460.c | 7 -------
> drivers/gpu/drm/cirrus/cirrus_mode.c | 8 --------
> drivers/gpu/drm/drm_crtc_helper.c | 2 +-
> drivers/gpu/drm/exynos/exynos_dp_core.c | 7 -------
> drivers/gpu/drm/exynos/exynos_drm_dpi.c | 7 -------
> drivers/gpu/drm/exynos/exynos_drm_vidi.c | 7 -------
> drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 7 -------
> drivers/gpu/drm/rcar-du/rcar_du_vgacon.c | 7 -------
> drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 7 -------
> drivers/staging/imx-drm/imx-hdmi.c | 8 --------
> drivers/staging/imx-drm/imx-ldb.c | 7 -------
> drivers/staging/imx-drm/parallel-display.c | 7 -------
> include/drm/drm_crtc_helper.h | 2 +-
> 15 files changed, 5 insertions(+), 91 deletions(-)
>
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 702c4474..92b4fa3 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -1903,8 +1903,8 @@ void intel_crt_init(struct drm_device *dev)
> <para>
> The function filters out modes larger than
> <parameter>max_width</parameter> and <parameter>max_height</parameter>
> - if specified. It then calls the connector
> - <methodname>mode_valid</methodname> helper operation for each mode in
> + if specified. It then calls the optional connector
> + <methodname>mode_valid</methodname> helper operation for each mode in
> the probed list to check whether the mode is valid for the connector.
> </para>
> </listitem>
> @@ -2265,7 +2265,7 @@ void intel_crt_init(struct drm_device *dev)
> <para>
> 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_*)
> - for unsupported modes. This operation is mandatory.
> + for unsupported modes. This operation is optional.
> </para>
> <para>
> As the mode rejection reason is currently not used beside for
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index a4afdc8..e599d64 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -743,12 +743,6 @@ static int ast_get_modes(struct drm_connector *connector)
> 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)
> {
> struct ast_connector *ast_connector = to_ast_connector(connector);
> @@ -765,7 +759,6 @@ ast_connector_detect(struct drm_connector *connector, bool force)
> }
>
> static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {
> - .mode_valid = ast_mode_valid,
> .get_modes = ast_get_modes,
> .best_encoder = ast_best_single_encoder,
> };
> diff --git a/drivers/gpu/drm/bridge/ptn3460.c b/drivers/gpu/drm/bridge/ptn3460.c
> index a9e5c1a..3ff2813 100644
> --- a/drivers/gpu/drm/bridge/ptn3460.c
> +++ b/drivers/gpu/drm/bridge/ptn3460.c
> @@ -225,12 +225,6 @@ out:
> 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 ptn3460_bridge *ptn_bridge;
> @@ -242,7 +236,6 @@ struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector)
>
> struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = {
> .get_modes = ptn3460_get_modes,
> - .mode_valid = ptn3460_mode_valid,
> .best_encoder = ptn3460_best_encoder,
> };
>
> diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
> index 2d64aea..057c7d1 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_mode.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
> @@ -502,13 +502,6 @@ static int cirrus_vga_get_modes(struct drm_connector *connector)
> 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
> *connector)
> {
> @@ -543,7 +536,6 @@ static void cirrus_connector_destroy(struct drm_connector *connector)
>
> struct drm_connector_helper_funcs cirrus_vga_connector_helper_funcs = {
> .get_modes = cirrus_vga_get_modes,
> - .mode_valid = cirrus_vga_mode_valid,
> .best_encoder = cirrus_connector_best_encoder,
> };
>
> diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
> index 1fbe842..3ca0aed 100644
> --- a/drivers/gpu/drm/drm_crtc_helper.c
> +++ b/drivers/gpu/drm/drm_crtc_helper.c
> @@ -186,7 +186,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
> drm_mode_validate_flag(connector, mode_flags);
>
> 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);
> }
> diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
> index a59bca9..a135025 100644
> --- a/drivers/gpu/drm/exynos/exynos_dp_core.c
> +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
> @@ -949,12 +949,6 @@ static int exynos_dp_get_modes(struct drm_connector *connector)
> 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(
> struct drm_connector *connector)
> {
> @@ -965,7 +959,6 @@ static struct drm_encoder *exynos_dp_best_encoder(
>
> static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
> .get_modes = exynos_dp_get_modes,
> - .mode_valid = exynos_dp_mode_valid,
> .best_encoder = exynos_dp_best_encoder,
> };
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
> index 2b09c7c..82e52c7 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
> @@ -94,12 +94,6 @@ static int exynos_dpi_get_modes(struct drm_connector *connector)
> return 0;
> }
>
> -static int exynos_dpi_mode_valid(struct drm_connector *connector,
> - struct drm_display_mode *mode)
> -{
> - return MODE_OK;
> -}
> -
> static struct drm_encoder *
> 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 = {
> .get_modes = exynos_dpi_get_modes,
> - .mode_valid = exynos_dpi_mode_valid,
> .best_encoder = exynos_dpi_best_encoder,
> };
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> index 7afead9..b698086 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> @@ -533,12 +533,6 @@ static int vidi_get_modes(struct drm_connector *connector)
> 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)
> {
> struct vidi_context *ctx = ctx_from_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 = {
> .get_modes = vidi_get_modes,
> - .mode_valid = vidi_mode_valid,
> .best_encoder = vidi_best_encoder,
> };
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
> index 4f3ba93..289048d 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
> @@ -57,15 +57,8 @@ static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector)
> 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 = {
> .get_modes = rcar_du_lvds_connector_get_modes,
> - .mode_valid = rcar_du_lvds_connector_mode_valid,
> .best_encoder = rcar_du_connector_best_encoder,
> };
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
> index 41d563a..ccfe64c 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
> @@ -25,15 +25,8 @@ static int rcar_du_vga_connector_get_modes(struct drm_connector *connector)
> 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 = {
> .get_modes = rcar_du_vga_connector_get_modes,
> - .mode_valid = rcar_du_vga_connector_mode_valid,
> .best_encoder = rcar_du_connector_best_encoder,
> };
>
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
> index e9e5e6d..faf176b 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
> @@ -674,12 +674,6 @@ static int shmob_drm_connector_get_modes(struct drm_connector *connector)
> 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 *
> 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 = {
> .get_modes = shmob_drm_connector_get_modes,
> - .mode_valid = shmob_drm_connector_mode_valid,
> .best_encoder = shmob_drm_connector_best_encoder,
> };
>
> diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c
> index f996e08..11ba1ea 100644
> --- a/drivers/staging/imx-drm/imx-hdmi.c
> +++ b/drivers/staging/imx-drm/imx-hdmi.c
> @@ -1560,13 +1560,6 @@ static int imx_hdmi_connector_get_modes(struct drm_connector *connector)
> return 0;
> }
>
> -static int imx_hdmi_connector_mode_valid(struct drm_connector *connector,
> - struct drm_display_mode *mode)
> -{
> -
> - return MODE_OK;
> -}
> -
> static struct drm_encoder *imx_hdmi_connector_best_encoder(struct drm_connector
> *connector)
> {
> @@ -1656,7 +1649,6 @@ static struct drm_connector_funcs imx_hdmi_connector_funcs = {
>
> static struct drm_connector_helper_funcs imx_hdmi_connector_helper_funcs = {
> .get_modes = imx_hdmi_connector_get_modes,
> - .mode_valid = imx_hdmi_connector_mode_valid,
> .best_encoder = imx_hdmi_connector_best_encoder,
> };
>
> diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c
> index c703e98..1ce0927 100644
> --- a/drivers/staging/imx-drm/imx-ldb.c
> +++ b/drivers/staging/imx-drm/imx-ldb.c
> @@ -120,12 +120,6 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector)
> return num_modes;
> }
>
> -static int imx_ldb_connector_mode_valid(struct drm_connector *connector,
> - struct drm_display_mode *mode)
> -{
> - return 0;
> -}
> -
> static struct drm_encoder *imx_ldb_connector_best_encoder(
> struct drm_connector *connector)
> {
> @@ -331,7 +325,6 @@ static struct drm_connector_funcs imx_ldb_connector_funcs = {
> static struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = {
> .get_modes = imx_ldb_connector_get_modes,
> .best_encoder = imx_ldb_connector_best_encoder,
> - .mode_valid = imx_ldb_connector_mode_valid,
> };
>
> static struct drm_encoder_funcs imx_ldb_encoder_funcs = {
> diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c
> index 823d015..7b9da66 100644
> --- a/drivers/staging/imx-drm/parallel-display.c
> +++ b/drivers/staging/imx-drm/parallel-display.c
> @@ -85,12 +85,6 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
> return num_modes;
> }
>
> -static int imx_pd_connector_mode_valid(struct drm_connector *connector,
> - struct drm_display_mode *mode)
> -{
> - return 0;
> -}
> -
> static struct drm_encoder *imx_pd_connector_best_encoder(
> struct drm_connector *connector)
> {
> @@ -147,7 +141,6 @@ static struct drm_connector_funcs imx_pd_connector_funcs = {
> static struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = {
> .get_modes = imx_pd_connector_get_modes,
> .best_encoder = imx_pd_connector_best_encoder,
> - .mode_valid = imx_pd_connector_mode_valid,
> };
>
> static struct drm_encoder_funcs imx_pd_encoder_funcs = {
> diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
> index 0bb34ca..80d2ca8 100644
> --- a/include/drm/drm_crtc_helper.h
> +++ b/include/drm/drm_crtc_helper.h
> @@ -114,7 +114,7 @@ struct drm_encoder_helper_funcs {
> /**
> * drm_connector_helper_funcs - helper operations for connectors
> * @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.
> */
> --
> 1.8.3.2
>
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
More information about the dri-devel
mailing list