[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f18770de-a206-99c2-fde2-a793209833e6@tronnes.org>
Date: Tue, 30 Aug 2022 17:29:56 +0200
From: Noralf Trønnes <noralf@...nnes.org>
To: Maxime Ripard <maxime@...no.tech>,
Maxime Ripard <mripard@...nel.org>,
Ben Skeggs <bskeggs@...hat.com>,
David Airlie <airlied@...ux.ie>, Chen-Yu Tsai <wens@...e.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Lyude Paul <lyude@...hat.com>,
Philipp Zabel <p.zabel@...gutronix.de>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>,
Karol Herbst <kherbst@...hat.com>,
Emma Anholt <emma@...olt.net>, Daniel Vetter <daniel@...ll.ch>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>
Cc: Hans de Goede <hdegoede@...hat.com>,
linux-arm-kernel@...ts.infradead.org,
Phil Elwell <phil@...pberrypi.com>,
intel-gfx@...ts.freedesktop.org,
Dave Stevenson <dave.stevenson@...pberrypi.com>,
dri-devel@...ts.freedesktop.org, Dom Cobley <dom@...pberrypi.com>,
linux-kernel@...r.kernel.org, nouveau@...ts.freedesktop.org,
linux-sunxi@...ts.linux.dev,
Mateusz Kwiatkowski <kfyatek+publicgit@...il.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Noralf Trønnes <noralf@...nnes.org>
Subject: Re: [PATCH v2 26/41] drm/vc4: vec: Refactor VEC TV mode setting
Den 29.08.2022 15.11, skrev Maxime Ripard:
> From: Mateusz Kwiatkowski <kfyatek+publicgit@...il.com>
>
>
>
> Change the mode_set function pointer logic to declarative config0,
>
> config1 and custom_freq fields, to make TV mode setting logic more
>
> concise and uniform.
>
>
>
> Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@...il.com>
>
> Signed-off-by: Maxime Ripard <maxime@...no.tech>
>
>
>
> diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c
>
> index 72eee0cbb615..9a37c3fcc295 100644
>
> --- a/drivers/gpu/drm/vc4/vc4_vec.c
>
> +++ b/drivers/gpu/drm/vc4/vc4_vec.c
>
> @@ -194,7 +194,9 @@ enum vc4_vec_tv_mode_id {
>
>
>
> struct vc4_vec_tv_mode {
>
> const struct drm_display_mode *mode;
>
> - void (*mode_set)(struct vc4_vec *vec);
>
> + u32 config0;
>
> + u32 config1;
>
> + u32 custom_freq;
>
> };
>
>
>
> static const struct debugfs_reg32 vec_regs[] = {
>
> @@ -224,34 +226,6 @@ static const struct debugfs_reg32 vec_regs[] = {
>
> VC4_REG32(VEC_DAC_MISC),
>
> };
>
>
>
> -static void vc4_vec_ntsc_mode_set(struct vc4_vec *vec)
>
> -{
>
> - struct drm_device *drm = vec->connector.dev;
>
> - int idx;
>
> -
>
> - if (!drm_dev_enter(drm, &idx))
>
> - return;
>
> -
>
> - VEC_WRITE(VEC_CONFIG0, VEC_CONFIG0_NTSC_STD | VEC_CONFIG0_PDEN);
>
> - VEC_WRITE(VEC_CONFIG1, VEC_CONFIG1_C_CVBS_CVBS);
>
> -
>
> - drm_dev_exit(idx);
>
> -}
>
> -
>
> -static void vc4_vec_ntsc_j_mode_set(struct vc4_vec *vec)
>
> -{
>
> - struct drm_device *drm = vec->connector.dev;
>
> - int idx;
>
> -
>
> - if (!drm_dev_enter(drm, &idx))
>
> - return;
>
> -
>
> - VEC_WRITE(VEC_CONFIG0, VEC_CONFIG0_NTSC_STD);
>
> - VEC_WRITE(VEC_CONFIG1, VEC_CONFIG1_C_CVBS_CVBS);
>
> -
>
> - drm_dev_exit(idx);
>
> -}
>
> -
>
> static const struct drm_display_mode ntsc_mode = {
>
> DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 13500,
>
> 720, 720 + 14, 720 + 14 + 64, 720 + 14 + 64 + 60, 0,
>
> @@ -259,37 +233,6 @@ static const struct drm_display_mode ntsc_mode = {
>
> DRM_MODE_FLAG_INTERLACE)
>
> };
>
>
>
> -static void vc4_vec_pal_mode_set(struct vc4_vec *vec)
>
> -{
>
> - struct drm_device *drm = vec->connector.dev;
>
> - int idx;
>
> -
>
> - if (!drm_dev_enter(drm, &idx))
>
> - return;
>
> -
>
> - VEC_WRITE(VEC_CONFIG0, VEC_CONFIG0_PAL_BDGHI_STD);
>
> - VEC_WRITE(VEC_CONFIG1, VEC_CONFIG1_C_CVBS_CVBS);
>
> -
>
> - drm_dev_exit(idx);
>
> -}
>
> -
>
> -static void vc4_vec_pal_m_mode_set(struct vc4_vec *vec)
>
> -{
>
> - struct drm_device *drm = vec->connector.dev;
>
> - int idx;
>
> -
>
> - if (!drm_dev_enter(drm, &idx))
>
> - return;
>
> -
>
> - VEC_WRITE(VEC_CONFIG0, VEC_CONFIG0_PAL_BDGHI_STD);
>
> - VEC_WRITE(VEC_CONFIG1,
>
> - VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ);
>
> - VEC_WRITE(VEC_FREQ3_2, 0x223b);
>
> - VEC_WRITE(VEC_FREQ1_0, 0x61d1);
>
> -
>
> - drm_dev_exit(idx);
>
> -}
>
> -
>
> static const struct drm_display_mode pal_mode = {
>
> DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 13500,
>
> 720, 720 + 20, 720 + 20 + 64, 720 + 20 + 64 + 60, 0,
>
> @@ -300,19 +243,24 @@ static const struct drm_display_mode pal_mode = {
>
> static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = {
>
> [VC4_VEC_TV_MODE_NTSC] = {
>
> .mode = &ntsc_mode,
>
> - .mode_set = vc4_vec_ntsc_mode_set,
>
> + .config0 = VEC_CONFIG0_NTSC_STD | VEC_CONFIG0_PDEN,
>
> + .config1 = VEC_CONFIG1_C_CVBS_CVBS,
>
> },
>
> [VC4_VEC_TV_MODE_NTSC_J] = {
>
> .mode = &ntsc_mode,
>
> - .mode_set = vc4_vec_ntsc_j_mode_set,
>
> + .config0 = VEC_CONFIG0_NTSC_STD,
>
> + .config1 = VEC_CONFIG1_C_CVBS_CVBS,
>
> },
>
> [VC4_VEC_TV_MODE_PAL] = {
>
> .mode = &pal_mode,
>
> - .mode_set = vc4_vec_pal_mode_set,
>
> + .config0 = VEC_CONFIG0_PAL_BDGHI_STD,
>
> + .config1 = VEC_CONFIG1_C_CVBS_CVBS,
>
> },
>
> [VC4_VEC_TV_MODE_PAL_M] = {
>
> .mode = &pal_mode,
>
> - .mode_set = vc4_vec_pal_m_mode_set,
>
> + .config0 = VEC_CONFIG0_PAL_BDGHI_STD,
>
> + .config1 = VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ,
>
> + .custom_freq = 0x223b61d1,
>
> },
>
> };
>
>
>
> @@ -470,7 +418,16 @@ static void vc4_vec_encoder_enable(struct drm_encoder *encoder,
>
> /* Mask all interrupts. */
>
> VEC_WRITE(VEC_MASK0, 0);
>
>
>
> - vec->tv_mode->mode_set(vec);
>
> + VEC_WRITE(VEC_CONFIG0, vec->tv_mode->config0);
>
> + VEC_WRITE(VEC_CONFIG1, vec->tv_mode->config1);
>
> +
>
> + if (vec->tv_mode->custom_freq != 0) {
Nit: '!= 0' is not necessary and not common either in kernel code.
Reviewed-by: Noralf Trønnes <noralf@...nnes.org>
>
> + VEC_WRITE(VEC_FREQ3_2,
>
> + (vec->tv_mode->custom_freq >> 16) &
>
> + 0xffff);
>
> + VEC_WRITE(VEC_FREQ1_0,
>
> + vec->tv_mode->custom_freq & 0xffff);
>
> + }
>
>
>
> VEC_WRITE(VEC_DAC_MISC,
>
> VEC_DAC_MISC_VID_ACT | VEC_DAC_MISC_DAC_RST_N);
>
>
>
Powered by blists - more mailing lists