linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: maxime.ripard@free-electrons.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 14/21] drm/sun4i: tcon: multiply the vtotal when not in interlace
Date: Thu, 18 May 2017 09:51:21 +0200	[thread overview]
Message-ID: <20170518075121.tfhnbljutcseaxzq@flea.home> (raw)
In-Reply-To: <CAGb2v65ZWHi_Dhsy__yVrz7330pfyMbBDTqoEE37NcSXOU_W7Q@mail.gmail.com>

On Wed, May 17, 2017 at 05:50:45PM +0800, Chen-Yu Tsai wrote:
> On Wed, May 17, 2017 at 3:40 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > It appears that the total vertical resolution needs to be doubled when
> > we're not in interlaced. Make sure that is the case.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> >  drivers/gpu/drm/sun4i/sun4i_tcon.c | 25 +++++++++++++++++++++----
> >  1 file changed, 21 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> > index 62e254aedb57..a0f9a8a516c7 100644
> > --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
> > +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> > @@ -153,7 +153,7 @@ static int sun4i_tcon_get_clk_delay(struct drm_display_mode *mode,
> >  void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
> >                           struct drm_display_mode *mode)
> >  {
> > -       unsigned int bp, hsync, vsync;
> > +       unsigned int bp, hsync, vsync, vtotal;
> >         u8 clk_delay;
> >         u32 val = 0;
> >
> > @@ -192,9 +192,26 @@ void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
> >         DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n",
> >                          mode->crtc_vtotal, bp);
> >
> > +       /*
> > +        * The vertical resolution needs to be doubled in all
> > +        * cases. We could use crtc_vtotal and always multiply by two,
> > +        * but that leads to a rounding error in interlace when vtotal
> > +        * is odd.
> > +        *
> > +        * This happens with TV's PAL for example, where vtotal will
> > +        * be 625, crtc_vtotal 312, and thus crtc_vtotal * 2 will be
> > +        * 624, which apparently confuses the hardware.
> > +        *
> > +        * To work around this, we will always use vtotal, and
> > +        * multiply by two only if we're not in interlace.
> > +        */
> > +       vtotal = mode->vtotal;
> > +       if (!(mode->flags & DRM_MODE_FLAG_INTERLACE))
> > +               vtotal = vtotal * 2;
> > +
> >         /* Set vertical display timings */
> >         regmap_write(tcon->regs, SUN4I_TCON0_BASIC2_REG,
> > -                    SUN4I_TCON0_BASIC2_V_TOTAL(mode->crtc_vtotal * 2) |
> > +                    SUN4I_TCON0_BASIC2_V_TOTAL(vtotal) |
> >                      SUN4I_TCON0_BASIC2_V_BACKPORCH(bp));
> >
> >         /* Set Hsync and Vsync length */
> > @@ -279,9 +296,9 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon,
> >         /* Set vertical display timings */
> >         bp = mode->crtc_vtotal - mode->crtc_vsync_start;
> >         DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n",
> > -                        mode->vtotal, bp);
> > +                        mode->crtc_vtotal, bp);
> 
> You should duplicate the logic from channel 0 to channel 1.
> In fact, interlaced modes happen predominantly on channel 1,
> for composite and HDMI modes.

Gaah, you're right, this was obviously meant for the channel 1.. I'll
resend.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170518/b10ea1ec/attachment.sig>

  reply	other threads:[~2017-05-18  7:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17  7:40 [PATCH v3 00/21] drm: sun4i: Add support for the HDMI controller Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 01/21] clk: divider: Make divider_round_rate take the parent clock Maxime Ripard
2017-05-19  1:54   ` Stephen Boyd
2017-05-17  7:40 ` [PATCH v3 02/21] clk: sunxi-ng: Pass the parent and a pointer to the clocks round rate Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 03/21] clk: sunxi-ng: div: Switch to divider_round_rate Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 04/21] clk: sunxi-ng: mux: Don't just rely on the parent for CLK_SET_RATE_PARENT Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 05/21] clk: sunxi-ng: mux: split out the pre-divider computation code Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 06/21] clk: sunxi-ng: mux: Change pre-divider application function prototype Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 07/21] clk: sunxi-ng: mux: Re-adjust parent rate Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 08/21] clk: sunxi-ng: sun5i: Export video PLLs Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 09/21] drm/sun4i: tcon: Add channel debug Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 10/21] drm/sun4i: tcon: Move the muxing out of the mode set function Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 11/21] drm/sun4i: tcon: Switch mux on only for composite Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 12/21] drm/sun4i: tcon: Fix tcon channel 1 backporch calculation Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 13/21] drm/sun4i: tcon: Change vertical total size computation inconsistency Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 14/21] drm/sun4i: tcon: multiply the vtotal when not in interlace Maxime Ripard
2017-05-17  9:50   ` Chen-Yu Tsai
2017-05-18  7:51     ` Maxime Ripard [this message]
2017-05-17  7:40 ` [PATCH v3 15/21] drm/sun4i: Ignore the generic connectors for components Maxime Ripard
2017-05-17  9:00   ` Chen-Yu Tsai
2017-05-17  7:40 ` [PATCH v3 16/21] dt-bindings: display: sun4i: Add HDMI display bindings Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 17/21] dt-bindings: display: sun4i: Add allwinner, tcon-channel property Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 18/21] drm/sun4i: Add HDMI support Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 19/21] drm/sun4i: Add compatible for the A10s pipeline Maxime Ripard
2017-05-17  9:00   ` Chen-Yu Tsai
2017-05-23  0:33   ` Rob Herring
2017-05-17  7:40 ` [PATCH v3 20/21] ARM: sun5i: a10s: Add the HDMI controller node Maxime Ripard
2017-05-17  7:40 ` [PATCH v3 21/21] ARM: sun5i: a10s-olinuxino: Enable HDMI Maxime Ripard
2017-05-19  7:34 ` [PATCH v3 00/21] drm: sun4i: Add support for the HDMI controller Chen-Yu Tsai

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=20170518075121.tfhnbljutcseaxzq@flea.home \
    --to=maxime.ripard@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 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).