linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Meson VPU: fix CVBS output
@ 2019-12-08 17:18 Martin Blumenstingl
  2019-12-08 17:18 ` [PATCH v2 1/2] drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code Martin Blumenstingl
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2019-12-08 17:18 UTC (permalink / raw)
  To: linux-amlogic, narmstrong
  Cc: dri-devel, linux-arm-kernel, linux-kernel, airlied, daniel,
	Martin Blumenstingl

The goal of this series is to fix the CVBS output with the Meson VPU
driver. Prior to this series kmscube reported:
  failed to set mode: Invalid argument

Changes since v1 at [0]:
- add patch to remove duplicate code (to match patch #2 easier)
- use drm_mode_match without DRM_MODE_MATCH_ASPECT_RATIO as suggested
  by Neil


[0] https://patchwork.kernel.org/patch/11268161/


Martin Blumenstingl (2):
  drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code
  drm: meson: venc: cvbs: fix CVBS mode matching

 drivers/gpu/drm/meson/meson_venc_cvbs.c | 48 ++++++++++++++-----------
 1 file changed, 27 insertions(+), 21 deletions(-)

-- 
2.24.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code
  2019-12-08 17:18 [PATCH v2 0/2] Meson VPU: fix CVBS output Martin Blumenstingl
@ 2019-12-08 17:18 ` Martin Blumenstingl
  2019-12-08 17:18 ` [PATCH v2 2/2] drm: meson: venc: cvbs: fix CVBS mode matching Martin Blumenstingl
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2019-12-08 17:18 UTC (permalink / raw)
  To: linux-amlogic, narmstrong
  Cc: dri-devel, linux-arm-kernel, linux-kernel, airlied, daniel,
	Martin Blumenstingl

Use a utility function to remove a bit of code duplication between
meson_venc_cvbs_encoder_atomic_check() and
meson_venc_cvbs_encoder_mode_set(). Both need to look up the struct
meson_venc_cvbs based on a drm_display_mode.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpu/drm/meson/meson_venc_cvbs.c | 44 +++++++++++++------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_venc_cvbs.c b/drivers/gpu/drm/meson/meson_venc_cvbs.c
index 9ab27aecfcf3..6b8a074e4ff4 100644
--- a/drivers/gpu/drm/meson/meson_venc_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_venc_cvbs.c
@@ -64,6 +64,21 @@ struct meson_cvbs_mode meson_cvbs_modes[MESON_CVBS_MODES_COUNT] = {
 	},
 };
 
+static const struct meson_cvbs_mode *
+meson_cvbs_get_mode(const struct drm_display_mode *req_mode)
+{
+	int i;
+
+	for (i = 0; i < MESON_CVBS_MODES_COUNT; ++i) {
+		struct meson_cvbs_mode *meson_mode = &meson_cvbs_modes[i];
+
+		if (drm_mode_equal(req_mode, &meson_mode->mode))
+			return meson_mode;
+	}
+
+	return NULL;
+}
+
 /* Connector */
 
 static void meson_cvbs_connector_destroy(struct drm_connector *connector)
@@ -136,14 +151,8 @@ static int meson_venc_cvbs_encoder_atomic_check(struct drm_encoder *encoder,
 					struct drm_crtc_state *crtc_state,
 					struct drm_connector_state *conn_state)
 {
-	int i;
-
-	for (i = 0; i < MESON_CVBS_MODES_COUNT; ++i) {
-		struct meson_cvbs_mode *meson_mode = &meson_cvbs_modes[i];
-
-		if (drm_mode_equal(&crtc_state->mode, &meson_mode->mode))
-			return 0;
-	}
+	if (meson_cvbs_get_mode(&crtc_state->mode))
+		return 0;
 
 	return -EINVAL;
 }
@@ -191,24 +200,17 @@ static void meson_venc_cvbs_encoder_mode_set(struct drm_encoder *encoder,
 				   struct drm_display_mode *mode,
 				   struct drm_display_mode *adjusted_mode)
 {
+	const struct meson_cvbs_mode *meson_mode = meson_cvbs_get_mode(mode);
 	struct meson_venc_cvbs *meson_venc_cvbs =
 					encoder_to_meson_venc_cvbs(encoder);
 	struct meson_drm *priv = meson_venc_cvbs->priv;
-	int i;
 
-	for (i = 0; i < MESON_CVBS_MODES_COUNT; ++i) {
-		struct meson_cvbs_mode *meson_mode = &meson_cvbs_modes[i];
+	if (meson_mode) {
+		meson_venci_cvbs_mode_set(priv, meson_mode->enci);
 
-		if (drm_mode_equal(mode, &meson_mode->mode)) {
-			meson_venci_cvbs_mode_set(priv,
-						  meson_mode->enci);
-
-			/* Setup 27MHz vclk2 for ENCI and VDAC */
-			meson_vclk_setup(priv, MESON_VCLK_TARGET_CVBS,
-					 MESON_VCLK_CVBS, MESON_VCLK_CVBS,
-					 MESON_VCLK_CVBS, true);
-			break;
-		}
+		/* Setup 27MHz vclk2 for ENCI and VDAC */
+		meson_vclk_setup(priv, MESON_VCLK_TARGET_CVBS, MESON_VCLK_CVBS,
+				 MESON_VCLK_CVBS, MESON_VCLK_CVBS, true);
 	}
 }
 
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] drm: meson: venc: cvbs: fix CVBS mode matching
  2019-12-08 17:18 [PATCH v2 0/2] Meson VPU: fix CVBS output Martin Blumenstingl
  2019-12-08 17:18 ` [PATCH v2 1/2] drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code Martin Blumenstingl
@ 2019-12-08 17:18 ` Martin Blumenstingl
  2019-12-09  7:22 ` [PATCH v2 0/2] Meson VPU: fix CVBS output Neil Armstrong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2019-12-08 17:18 UTC (permalink / raw)
  To: linux-amlogic, narmstrong
  Cc: dri-devel, linux-arm-kernel, linux-kernel, airlied, daniel,
	Martin Blumenstingl

With commit 222ec1618c3ace ("drm: Add aspect ratio parsing in DRM
layer") the drm core started honoring the picture_aspect_ratio field
when comparing two drm_display_modes. Prior to that it was ignored.
When the CVBS encoder driver was initially submitted there was no aspect
ratio check.

Switch from drm_mode_equal() to drm_mode_match() without
DRM_MODE_MATCH_ASPECT_RATIO to fix "kmscube" and X.org output using the
CVBS connector. When (for example) kmscube sets the output mode when
using the CVBS connector it passes HDMI_PICTURE_ASPECT_NONE, making the
drm_mode_equal() fail as it include the aspect ratio.

Prior to this patch kmscube reported:
  failed to set mode: Invalid argument

The CVBS mode checking in the sun4i (drivers/gpu/drm/sun4i/sun4i_tv.c
sun4i_tv_mode_to_drm_mode) and ZTE (drivers/gpu/drm/zte/zx_tvenc.c
tvenc_mode_{pal,ntsc}) drivers don't set the "picture_aspect_ratio" at
all. The Meson VPU driver does not rely on the aspect ratio for the CVBS
output so we can safely decouple it from the hdmi_picture_aspect
setting.

Fixes: 222ec1618c3ace ("drm: Add aspect ratio parsing in DRM layer")
Fixes: bbbe775ec5b5da ("drm: Add support for Amlogic Meson Graphic Controller")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpu/drm/meson/meson_venc_cvbs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/meson/meson_venc_cvbs.c b/drivers/gpu/drm/meson/meson_venc_cvbs.c
index 6b8a074e4ff4..1bd6b6d15ffb 100644
--- a/drivers/gpu/drm/meson/meson_venc_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_venc_cvbs.c
@@ -72,7 +72,11 @@ meson_cvbs_get_mode(const struct drm_display_mode *req_mode)
 	for (i = 0; i < MESON_CVBS_MODES_COUNT; ++i) {
 		struct meson_cvbs_mode *meson_mode = &meson_cvbs_modes[i];
 
-		if (drm_mode_equal(req_mode, &meson_mode->mode))
+		if (drm_mode_match(req_mode, &meson_mode->mode,
+				   DRM_MODE_MATCH_TIMINGS |
+				   DRM_MODE_MATCH_CLOCK |
+				   DRM_MODE_MATCH_FLAGS |
+				   DRM_MODE_MATCH_3D_FLAGS))
 			return meson_mode;
 	}
 
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] Meson VPU: fix CVBS output
  2019-12-08 17:18 [PATCH v2 0/2] Meson VPU: fix CVBS output Martin Blumenstingl
  2019-12-08 17:18 ` [PATCH v2 1/2] drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code Martin Blumenstingl
  2019-12-08 17:18 ` [PATCH v2 2/2] drm: meson: venc: cvbs: fix CVBS mode matching Martin Blumenstingl
@ 2019-12-09  7:22 ` Neil Armstrong
  2019-12-09  7:26 ` Neil Armstrong
  2019-12-09  9:34 ` Neil Armstrong
  4 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2019-12-09  7:22 UTC (permalink / raw)
  To: Martin Blumenstingl, linux-amlogic
  Cc: dri-devel, linux-arm-kernel, linux-kernel, airlied, daniel

Hi Martin !

On 08/12/2019 18:18, Martin Blumenstingl wrote:
> The goal of this series is to fix the CVBS output with the Meson VPU
> driver. Prior to this series kmscube reported:
>   failed to set mode: Invalid argument
> 
> Changes since v1 at [0]:
> - add patch to remove duplicate code (to match patch #2 easier)
> - use drm_mode_match without DRM_MODE_MATCH_ASPECT_RATIO as suggested
>   by Neil
> 
> 
> [0] https://patchwork.kernel.org/patch/11268161/
> 
> 
> Martin Blumenstingl (2):
>   drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code
>   drm: meson: venc: cvbs: fix CVBS mode matching
> 
>  drivers/gpu/drm/meson/meson_venc_cvbs.c | 48 ++++++++++++++-----------
>  1 file changed, 27 insertions(+), 21 deletions(-)
> 

For both:
Acked-by: Neil Armstrong <narmstrong@baylibre.com>

I'll squash them to permit an easier backporting to stable kernel !

Neil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] Meson VPU: fix CVBS output
  2019-12-08 17:18 [PATCH v2 0/2] Meson VPU: fix CVBS output Martin Blumenstingl
                   ` (2 preceding siblings ...)
  2019-12-09  7:22 ` [PATCH v2 0/2] Meson VPU: fix CVBS output Neil Armstrong
@ 2019-12-09  7:26 ` Neil Armstrong
  2019-12-09  9:34 ` Neil Armstrong
  4 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2019-12-09  7:26 UTC (permalink / raw)
  To: Martin Blumenstingl, linux-amlogic
  Cc: dri-devel, linux-arm-kernel, linux-kernel, airlied, daniel

On 08/12/2019 18:18, Martin Blumenstingl wrote:
> The goal of this series is to fix the CVBS output with the Meson VPU
> driver. Prior to this series kmscube reported:
>   failed to set mode: Invalid argument
> 
> Changes since v1 at [0]:
> - add patch to remove duplicate code (to match patch #2 easier)
> - use drm_mode_match without DRM_MODE_MATCH_ASPECT_RATIO as suggested
>   by Neil
> 
> 
> [0] https://patchwork.kernel.org/patch/11268161/
> 
> 
> Martin Blumenstingl (2):
>   drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code
>   drm: meson: venc: cvbs: fix CVBS mode matching
> 
>  drivers/gpu/drm/meson/meson_venc_cvbs.c | 48 ++++++++++++++-----------
>  1 file changed, 27 insertions(+), 21 deletions(-)
> 

Hmm seems you are not registered to the dri-devel ML, so I must wait for the ML moderator to accept your mails so they appear on https://patchwork.freedesktop.org/.

Could you register and disable emails reception from dri-devel ? I will be easier in the future.

Neil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] Meson VPU: fix CVBS output
  2019-12-08 17:18 [PATCH v2 0/2] Meson VPU: fix CVBS output Martin Blumenstingl
                   ` (3 preceding siblings ...)
  2019-12-09  7:26 ` Neil Armstrong
@ 2019-12-09  9:34 ` Neil Armstrong
  4 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2019-12-09  9:34 UTC (permalink / raw)
  To: Martin Blumenstingl, linux-amlogic
  Cc: dri-devel, linux-arm-kernel, linux-kernel, airlied, daniel

On 08/12/2019 18:18, Martin Blumenstingl wrote:
> The goal of this series is to fix the CVBS output with the Meson VPU
> driver. Prior to this series kmscube reported:
>   failed to set mode: Invalid argument
> 
> Changes since v1 at [0]:
> - add patch to remove duplicate code (to match patch #2 easier)
> - use drm_mode_match without DRM_MODE_MATCH_ASPECT_RATIO as suggested
>   by Neil
> 
> 
> [0] https://patchwork.kernel.org/patch/11268161/
> 
> 
> Martin Blumenstingl (2):
>   drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code
>   drm: meson: venc: cvbs: fix CVBS mode matching
> 
>  drivers/gpu/drm/meson/meson_venc_cvbs.c | 48 ++++++++++++++-----------
>  1 file changed, 27 insertions(+), 21 deletions(-)
> 

Applied to drm-misc-fixes

Thanks !

Neil

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-12-09  9:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-08 17:18 [PATCH v2 0/2] Meson VPU: fix CVBS output Martin Blumenstingl
2019-12-08 17:18 ` [PATCH v2 1/2] drm: meson: venc: cvbs: deduplicate the meson_cvbs_mode lookup code Martin Blumenstingl
2019-12-08 17:18 ` [PATCH v2 2/2] drm: meson: venc: cvbs: fix CVBS mode matching Martin Blumenstingl
2019-12-09  7:22 ` [PATCH v2 0/2] Meson VPU: fix CVBS output Neil Armstrong
2019-12-09  7:26 ` Neil Armstrong
2019-12-09  9:34 ` Neil Armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).