All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <a.hajda@samsung.com>
To: Inki Dae <inki.dae@samsung.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org,
	Tobias Jakobi <tjakobi@math.uni-bielefeld.de>,
	Daniel Drake <drake@endlessm.com>
Subject: [PATCH v2 08/11] drm/exynos/mixer: pass actual mode on MIXER to encoder
Date: Fri, 29 Sep 2017 12:05:39 +0200	[thread overview]
Message-ID: <20170929100542.12849-9-a.hajda@samsung.com> (raw)
In-Reply-To: <20170929100542.12849-1-a.hajda@samsung.com>

MIXER in SoCs prior to Exynos5420 supports only 4 video modes:
720x480, 720x576, 1280x720, 1920x1080. Support for other modes can be
enabled by manipulating timings of HDMI. To allow it MIXER must pass
actual video mode to HDMI, the proper way to do it is to modify
adjusted_mode property in crtc::mode_fixup callback. Adding such callback
allows also to simplify mixer_cfg_scan code - choosing mode is performed
already in crtc::mode_fixup. mode_fixup is also better place to check
interlace flag.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 70 +++++++++++++++++++++++++----------
 1 file changed, 50 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 2d8905ea0141..8baa93f80106 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -115,6 +115,7 @@ struct mixer_context {
 	struct clk		*sclk_hdmi;
 	struct clk		*mout_mixer;
 	enum mixer_version_id	mxr_ver;
+	int			scan_value;
 };
 
 struct mixer_drv_data {
@@ -367,23 +368,11 @@ static void mixer_cfg_scan(struct mixer_context *ctx, int width, int height)
 	val = test_bit(MXR_BIT_INTERLACE, &ctx->flags) ?
 		MXR_CFG_SCAN_INTERLACE : MXR_CFG_SCAN_PROGRESSIVE;
 
-	/* setup display size */
-	if (ctx->mxr_ver == MXR_VER_128_0_0_184) {
+	if (ctx->mxr_ver == MXR_VER_128_0_0_184)
 		mixer_reg_write(ctx, MXR_RESOLUTION,
 			MXR_MXR_RES_HEIGHT(height) | MXR_MXR_RES_WIDTH(width));
-	} else {
-		/* choosing between proper HD and SD mode */
-		if (height <= 480)
-			val |= MXR_CFG_SCAN_NTSC | MXR_CFG_SCAN_SD;
-		else if (height <= 576)
-			val |= MXR_CFG_SCAN_PAL | MXR_CFG_SCAN_SD;
-		else if (height <= 720)
-			val |= MXR_CFG_SCAN_HD_720 | MXR_CFG_SCAN_HD;
-		else if (height <= 1080)
-			val |= MXR_CFG_SCAN_HD_1080 | MXR_CFG_SCAN_HD;
-		else
-			val |= MXR_CFG_SCAN_HD_720 | MXR_CFG_SCAN_HD;
-	}
+	else
+		val |= ctx->scan_value;
 
 	mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_SCAN_MASK);
 }
@@ -467,11 +456,6 @@ static void mixer_commit(struct mixer_context *ctx)
 {
 	struct drm_display_mode *mode = &ctx->crtc->base.state->adjusted_mode;
 
-	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
-		__set_bit(MXR_BIT_INTERLACE, &ctx->flags);
-	else
-		__clear_bit(MXR_BIT_INTERLACE, &ctx->flags);
-
 	mixer_cfg_scan(ctx, mode->hdisplay, mode->vdisplay);
 	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
 	mixer_run(ctx);
@@ -1033,6 +1017,51 @@ static int mixer_mode_valid(struct exynos_drm_crtc *crtc,
 	return MODE_BAD;
 }
 
+static bool mixer_mode_fixup(struct exynos_drm_crtc *crtc,
+		   const struct drm_display_mode *mode,
+		   struct drm_display_mode *adjusted_mode)
+{
+	struct mixer_context *ctx = crtc->ctx;
+	int width = mode->hdisplay, height = mode->vdisplay, i;
+
+	struct {
+		int hdisplay, vdisplay, htotal, vtotal, scan_val;
+	} static const modes[] = {
+		{ 720, 480, 858, 525, MXR_CFG_SCAN_NTSC | MXR_CFG_SCAN_SD },
+		{ 720, 576, 864, 625, MXR_CFG_SCAN_PAL | MXR_CFG_SCAN_SD },
+		{ 1280, 720, 1650, 750, MXR_CFG_SCAN_HD_720 | MXR_CFG_SCAN_HD },
+		{ 1920, 1080, 2200, 1125, MXR_CFG_SCAN_HD_1080 | MXR_CFG_SCAN_HD }
+	};
+
+	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+		__set_bit(MXR_BIT_INTERLACE, &ctx->flags);
+	else
+		__clear_bit(MXR_BIT_INTERLACE, &ctx->flags);
+
+	if (ctx->mxr_ver == MXR_VER_128_0_0_184)
+		return true;
+
+	for (i = 0; i < ARRAY_SIZE(modes); ++i)
+		if (width <= modes[i].hdisplay && height <= modes[i].vdisplay) {
+			ctx->scan_value = modes[i].scan_val;
+			if (width < modes[i].hdisplay ||
+			    height < modes[i].vdisplay) {
+				adjusted_mode->hdisplay = modes[i].hdisplay;
+				adjusted_mode->hsync_start = modes[i].hdisplay;
+				adjusted_mode->hsync_end = modes[i].htotal;
+				adjusted_mode->htotal = modes[i].htotal;
+				adjusted_mode->vdisplay = modes[i].vdisplay;
+				adjusted_mode->vsync_start = modes[i].vdisplay;
+				adjusted_mode->vsync_end = modes[i].vtotal;
+				adjusted_mode->vtotal = modes[i].vtotal;
+			}
+
+			return true;
+		}
+
+	return false;
+}
+
 static const struct exynos_drm_crtc_ops mixer_crtc_ops = {
 	.enable			= mixer_enable,
 	.disable		= mixer_disable,
@@ -1043,6 +1072,7 @@ static const struct exynos_drm_crtc_ops mixer_crtc_ops = {
 	.disable_plane		= mixer_disable_plane,
 	.atomic_flush		= mixer_atomic_flush,
 	.mode_valid		= mixer_mode_valid,
+	.mode_fixup		= mixer_mode_fixup,
 };
 
 static const struct mixer_drv_data exynos5420_mxr_drv_data = {
-- 
2.14.1

  parent reply	other threads:[~2017-09-29 10:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170929100545eucas1p24e82643e9ba934c6a0a1f437f4c0891a@eucas1p2.samsung.com>
2017-09-29 10:05 ` [PATCH v2 00/11] drm/exynos: TV path improvements Andrzej Hajda
     [not found]   ` <CGME20170929100546eucas1p2c06bf97d6961259c617b1e6d3a63f081@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 01/11] drm/exynos/mixer: abstract out output mode setup code Andrzej Hajda
     [not found]   ` <CGME20170929100546eucas1p20f2a84d13ea64f5c3329e4e641730643@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 02/11] drm/exynos/mixer: move mode commit to enable callback Andrzej Hajda
     [not found]   ` <CGME20170929100546eucas1p2b1f4313dc1f769609b10b310c2185786@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 03/11] drm/exynos/mixer: move resolution configuration to single function Andrzej Hajda
     [not found]   ` <CGME20170929100547eucas1p2642f5da0380df27d991cf3b2b1e730b3@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 04/11] drm/exynos/mixer: fix mode validation code Andrzej Hajda
     [not found]   ` <CGME20170929100548eucas1p113a840591a4bf961272384516984957e@eucas1p1.samsung.com>
2017-09-29 10:05     ` [PATCH v2 05/11] drm/exynos/mixer: remove mixer_resources sub-structure Andrzej Hajda
2017-10-16 10:02       ` Inki Dae
     [not found]   ` <CGME20170929100548eucas1p2cf6293ef0d013016afcafb4d6194e8be@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 06/11] drm/exynos/hdmi: remove redundant mode field Andrzej Hajda
     [not found]   ` <CGME20170929100548eucas1p26c83f7cf1e82d4cd052e19d4d06cdbfa@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 07/11] drm/exynos: add mode_fixup callback to exynos_drm_crtc_ops Andrzej Hajda
     [not found]   ` <CGME20170929100549eucas1p2eddc8a5e6908a69c9c91be488906852f@eucas1p2.samsung.com>
2017-09-29 10:05     ` Andrzej Hajda [this message]
     [not found]   ` <CGME20170929100549eucas1p2053fdf47957c11fa39d0e026267f088c@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 09/11] drm/exynos/hdmi: quirk for support mode timings conversion Andrzej Hajda
2017-10-17  7:38       ` Inki Dae
2017-10-17  8:04         ` Andrzej Hajda
2017-10-18  2:31           ` Inki Dae
2017-10-18  9:36             ` Andrzej Hajda
     [not found]   ` <CGME20170929100549eucas1p29a39ec9db45d6009f23b89fd2d6b77f9@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 10/11] drm/exynos/mixer: enable support for 1024x768 and 1280x1024 modes Andrzej Hajda
2017-10-17  7:48       ` Inki Dae
2017-10-17  8:09         ` Andrzej Hajda
     [not found]   ` <CGME20170929100550eucas1p28b5fbc7fd3fedeafc0632a6401158dbf@eucas1p2.samsung.com>
2017-09-29 10:05     ` [PATCH v2 11/11] drm/exynos/hdmi: add 85.5MHz pixel clock for v14 HDMI PHY Andrzej Hajda
2017-10-23  1:37   ` [PATCH v2 00/11] drm/exynos: TV path improvements Inki Dae

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170929100542.12849-9-a.hajda@samsung.com \
    --to=a.hajda@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=drake@endlessm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=tjakobi@math.uni-bielefeld.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.