[PATCH v1 10/12] drm/omapdrm: Use drm_bridge_funcs.atomic_check
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Sep 19 08:33:02 PDT 2022
Hi Sam,
Thank you for the patch.
On Sun, Jul 17, 2022 at 07:57:59PM +0200, Sam Ravnborg wrote:
> Replace the deprecated drm_bridge_funcs.mode_fixup() with
> drm_bridge_funcs.atomic_check().
>
> drm_bridge_funcs.atomic_check() requires the atomic state operations,
> update these to the default implementations.
> Likewise update enable/disable to their atomic variants.
>
> With these changes omapdrm now implement the full bridge atomic API.
>
> Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
> Cc: Sam Ravnborg <sam at ravnborg.org>
> Cc: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> Cc: Cai Huoqing <cai.huoqing at linux.dev>
> Cc: Arnd Bergmann <arnd at arndb.de>
> Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
> ---
> drivers/gpu/drm/omapdrm/dss/dpi.c | 31 ++++++++++++++++++------------
> drivers/gpu/drm/omapdrm/dss/sdi.c | 31 ++++++++++++++++++------------
> drivers/gpu/drm/omapdrm/dss/venc.c | 28 +++++++++++++++++----------
> 3 files changed, 56 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 030f997eccd0..0a0b49750eca 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -21,6 +21,7 @@
> #include <linux/string.h>
> #include <linux/sys_soc.h>
>
> +#include <drm/drm_atomic_state_helper.h>
> #include <drm/drm_bridge.h>
>
> #include "dss.h"
> @@ -454,21 +455,22 @@ dpi_bridge_mode_valid(struct drm_bridge *bridge,
> return MODE_OK;
> }
>
> -static bool dpi_bridge_mode_fixup(struct drm_bridge *bridge,
> - const struct drm_display_mode *mode,
> - struct drm_display_mode *adjusted_mode)
> +static int dpi_bridge_atomic_check(struct drm_bridge *bridge,
> + struct drm_bridge_state *bridge_state,
> + struct drm_crtc_state *crtc_state,
> + struct drm_connector_state *conn_state)
> {
> struct dpi_data *dpi = drm_bridge_to_dpi(bridge);
> - unsigned long clock = mode->clock * 1000;
> + unsigned long clock = crtc_state->mode.clock * 1000;
> int ret;
>
> ret = dpi_clock_update(dpi, &clock);
> if (ret < 0)
> - return false;
> + return ret;
>
> - adjusted_mode->clock = clock / 1000;
> + crtc_state->adjusted_mode.clock = clock / 1000;
>
> - return true;
> + return 0;
> }
>
> static void dpi_bridge_mode_set(struct drm_bridge *bridge,
> @@ -480,7 +482,8 @@ static void dpi_bridge_mode_set(struct drm_bridge *bridge,
> dpi->pixelclock = adjusted_mode->clock * 1000;
> }
>
> -static void dpi_bridge_enable(struct drm_bridge *bridge)
> +static void dpi_bridge_atomic_enable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_bridge_state)
> {
> struct dpi_data *dpi = drm_bridge_to_dpi(bridge);
> int r;
> @@ -531,7 +534,8 @@ static void dpi_bridge_enable(struct drm_bridge *bridge)
> regulator_disable(dpi->vdds_dsi_reg);
> }
>
> -static void dpi_bridge_disable(struct drm_bridge *bridge)
> +static void dpi_bridge_atomic_disable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_bridge_state)
> {
> struct dpi_data *dpi = drm_bridge_to_dpi(bridge);
>
> @@ -552,10 +556,13 @@ static void dpi_bridge_disable(struct drm_bridge *bridge)
> static const struct drm_bridge_funcs dpi_bridge_funcs = {
> .attach = dpi_bridge_attach,
> .mode_valid = dpi_bridge_mode_valid,
> - .mode_fixup = dpi_bridge_mode_fixup,
> + .atomic_check = dpi_bridge_atomic_check,
> .mode_set = dpi_bridge_mode_set,
> - .enable = dpi_bridge_enable,
> - .disable = dpi_bridge_disable,
> + .atomic_enable = dpi_bridge_atomic_enable,
> + .atomic_disable = dpi_bridge_atomic_disable,
> + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> + .atomic_reset = drm_atomic_helper_bridge_reset,
> };
>
> static void dpi_bridge_init(struct dpi_data *dpi)
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 91eaae3b9481..73b728722c2f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -15,6 +15,7 @@
> #include <linux/regulator/consumer.h>
> #include <linux/string.h>
>
> +#include <drm/drm_atomic_state_helper.h>
> #include <drm/drm_bridge.h>
>
> #include "dss.h"
> @@ -159,12 +160,13 @@ sdi_bridge_mode_valid(struct drm_bridge *bridge,
> return MODE_OK;
> }
>
> -static bool sdi_bridge_mode_fixup(struct drm_bridge *bridge,
> - const struct drm_display_mode *mode,
> - struct drm_display_mode *adjusted_mode)
> +static int sdi_bridge_atomic_check(struct drm_bridge *bridge,
> + struct drm_bridge_state *bridge_state,
> + struct drm_crtc_state *crtc_state,
> + struct drm_connector_state *conn_state)
> {
> struct sdi_device *sdi = drm_bridge_to_sdi(bridge);
> - unsigned long pixelclock = mode->clock * 1000;
> + unsigned long pixelclock = crtc_state->mode.clock * 1000;
> struct dispc_clock_info dispc_cinfo;
> unsigned long fck;
> unsigned long pck;
> @@ -172,7 +174,7 @@ static bool sdi_bridge_mode_fixup(struct drm_bridge *bridge,
>
> ret = sdi_calc_clock_div(sdi, pixelclock, &fck, &dispc_cinfo);
> if (ret < 0)
> - return false;
> + return ret;
>
> pck = fck / dispc_cinfo.lck_div / dispc_cinfo.pck_div;
>
> @@ -181,9 +183,9 @@ static bool sdi_bridge_mode_fixup(struct drm_bridge *bridge,
> "pixel clock adjusted from %lu Hz to %lu Hz\n",
> pixelclock, pck);
>
> - adjusted_mode->clock = pck / 1000;
> + crtc_state->adjusted_mode.clock = pck / 1000;
>
> - return true;
> + return 0;
> }
>
> static void sdi_bridge_mode_set(struct drm_bridge *bridge,
> @@ -195,7 +197,8 @@ static void sdi_bridge_mode_set(struct drm_bridge *bridge,
> sdi->pixelclock = adjusted_mode->clock * 1000;
> }
>
> -static void sdi_bridge_enable(struct drm_bridge *bridge)
> +static void sdi_bridge_atomic_enable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_bridge_state)
> {
> struct sdi_device *sdi = drm_bridge_to_sdi(bridge);
> struct dispc_clock_info dispc_cinfo;
> @@ -258,7 +261,8 @@ static void sdi_bridge_enable(struct drm_bridge *bridge)
> regulator_disable(sdi->vdds_sdi_reg);
> }
>
> -static void sdi_bridge_disable(struct drm_bridge *bridge)
> +static void sdi_bridge_atomic_disable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_bridge_state)
> {
> struct sdi_device *sdi = drm_bridge_to_sdi(bridge);
>
> @@ -274,10 +278,13 @@ static void sdi_bridge_disable(struct drm_bridge *bridge)
> static const struct drm_bridge_funcs sdi_bridge_funcs = {
> .attach = sdi_bridge_attach,
> .mode_valid = sdi_bridge_mode_valid,
> - .mode_fixup = sdi_bridge_mode_fixup,
> + .atomic_check = sdi_bridge_atomic_check,
> .mode_set = sdi_bridge_mode_set,
> - .enable = sdi_bridge_enable,
> - .disable = sdi_bridge_disable,
> + .atomic_enable = sdi_bridge_atomic_enable,
> + .atomic_disable = sdi_bridge_atomic_disable,
> + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> + .atomic_reset = drm_atomic_helper_bridge_reset,
> };
>
> static void sdi_bridge_init(struct sdi_device *sdi)
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 4480b69ab5a7..994e6399d574 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -25,6 +25,7 @@
> #include <linux/component.h>
> #include <linux/sys_soc.h>
>
> +#include <drm/drm_atomic_state_helper.h>
> #include <drm/drm_bridge.h>
>
> #include "omapdss.h"
> @@ -564,11 +565,13 @@ venc_bridge_mode_valid(struct drm_bridge *bridge,
> }
> }
>
> -static bool venc_bridge_mode_fixup(struct drm_bridge *bridge,
> - const struct drm_display_mode *mode,
> - struct drm_display_mode *adjusted_mode)
> +static int venc_bridge_atomic_check(struct drm_bridge *bridge,
> + struct drm_bridge_state *bridge_state,
> + struct drm_crtc_state *crtc_state,
> + struct drm_connector_state *conn_state)
> {
> const struct drm_display_mode *venc_mode;
> + struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
>
> switch (venc_get_videomode(adjusted_mode)) {
> case VENC_MODE_PAL:
> @@ -580,14 +583,14 @@ static bool venc_bridge_mode_fixup(struct drm_bridge *bridge,
> break;
>
> default:
> - return false;
> + return -EINVAL;
> }
>
> drm_mode_copy(adjusted_mode, venc_mode);
> drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
> drm_mode_set_name(adjusted_mode);
>
> - return true;
> + return 0;
> }
>
> static void venc_bridge_mode_set(struct drm_bridge *bridge,
> @@ -613,14 +616,16 @@ static void venc_bridge_mode_set(struct drm_bridge *bridge,
> dispc_set_tv_pclk(venc->dss->dispc, 13500000);
> }
>
> -static void venc_bridge_enable(struct drm_bridge *bridge)
> +static void venc_bridge_atomic_enable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_bridge_state)
> {
> struct venc_device *venc = drm_bridge_to_venc(bridge);
>
> venc_power_on(venc);
> }
>
> -static void venc_bridge_disable(struct drm_bridge *bridge)
> +static void venc_bridge_atomic_disable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_bridge_state)
> {
> struct venc_device *venc = drm_bridge_to_venc(bridge);
>
> @@ -654,11 +659,14 @@ static int venc_bridge_get_modes(struct drm_bridge *bridge,
> static const struct drm_bridge_funcs venc_bridge_funcs = {
> .attach = venc_bridge_attach,
> .mode_valid = venc_bridge_mode_valid,
> - .mode_fixup = venc_bridge_mode_fixup,
> + .atomic_check = venc_bridge_atomic_check,
> .mode_set = venc_bridge_mode_set,
> - .enable = venc_bridge_enable,
> - .disable = venc_bridge_disable,
> + .atomic_enable = venc_bridge_atomic_enable,
> + .atomic_disable = venc_bridge_atomic_disable,
> .get_modes = venc_bridge_get_modes,
> + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> + .atomic_reset = drm_atomic_helper_bridge_reset,
> };
>
> static void venc_bridge_init(struct venc_device *venc)
--
Regards,
Laurent Pinchart
More information about the linux-arm-kernel
mailing list