dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Egbert Eich <eich@suse.com>
To: "Y.C. Chen" <yc_chen@aspeedtech.com>
Cc: airlied@redhat.com, dri-devel@lists.freedesktop.org, eich@suse.com
Subject: Re: [PATCH 2/2] drm/ast: Add reduced/non-reduced mode parsing for wide screen mode
Date: Fri, 22 Aug 2014 17:28:23 +0200	[thread overview]
Message-ID: <21495.24983.475258.133171@linux-qknr.fritz.box> (raw)
In-Reply-To: yc_chen@aspeedtech.com wrote on Friday, 22 August 2014 at 11:00:18 +0800


Hi YC,

Y.C. Chen writes:
 > From: "Y.C. Chen" <yc_chen@aspeedtech.com>
 > 
 > Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
 > ---
 >  drivers/gpu/drm/ast/ast_mode.c   | 32 +++++++++++++++++++++++-------
 >  drivers/gpu/drm/ast/ast_tables.h | 42 ++++++++++++++++++++++++----------------
 >  2 files changed, 50 insertions(+), 24 deletions(-)
 > 
 > diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
 > index 5389350..5533920 100644
 > --- a/drivers/gpu/drm/ast/ast_mode.c
 > +++ b/drivers/gpu/drm/ast/ast_mode.c
 > @@ -141,14 +141,30 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
 >  	}
 >  
 >  	refresh_rate = drm_mode_vrefresh(mode);
 > -	while (vbios_mode->enh_table->refresh_rate < refresh_rate) {
 > -		vbios_mode->enh_table++;
 > -		if ((vbios_mode->enh_table->refresh_rate > refresh_rate) ||
 > -		    (vbios_mode->enh_table->refresh_rate == 0xff)) {
 > +	do {
 > +		if ((vbios_mode->enh_table->flags & WideScreenMode) &&
 > +		    (((mode->flags & DRM_MODE_FLAG_NVSYNC)  &&
 > +		      (vbios_mode->enh_table->flags & PVSync))  ||
 > +	 	     ((mode->flags & DRM_MODE_FLAG_PVSYNC)  &&
 > +		      (vbios_mode->enh_table->flags & NVSync))  ||
 > +		     ((mode->flags & DRM_MODE_FLAG_NHSYNC)  &&
 > +		      (vbios_mode->enh_table->flags & PHSync))  ||
 > +		     ((mode->flags & DRM_MODE_FLAG_PHSYNC)  &&
 > +		      (vbios_mode->enh_table->flags & NHSync)))) {
 > +			vbios_mode->enh_table++;
 > +			continue;
 > +		}
 > +		if (vbios_mode->enh_table->refresh_rate < refresh_rate) {
 > +			vbios_mode->enh_table++;
 > +		}
 > +		if ((vbios_mode->enh_table->refresh_rate_index > 1) &&
 > +		    (vbios_mode->enh_table->refresh_rate > refresh_rate)) {
 >  			vbios_mode->enh_table--;
 >  			break;
 >  		}
 > -	}
 > +	} while (vbios_mode->enh_table->refresh_rate != 0xff);
 > +	if (vbios_mode->enh_table->refresh_rate == 0xff)
 > +		vbios_mode->enh_table--;

I've tested this and experimented around a bit and came up with code like this:

        bool check_sync;
        struct ast_vbios_enhtable *best = NULL;
        [..]

        refresh_rate = drm_mode_vrefresh(mode);
        check_sync = vbios_mode->enh_table->flags & WideScreenMode;
        do {
                struct ast_vbios_enhtable *loop = best = vbios_mode->enh_table;

                while (loop->refresh_rate != 0xff) {
                        if ((check_sync) &&
                            (((mode->flags & DRM_MODE_FLAG_NVSYNC)  &&
                              (loop->flags & PVSync))  ||
                             ((mode->flags & DRM_MODE_FLAG_PVSYNC)  &&
                              (loop->flags & NVSync))  ||
                             ((mode->flags & DRM_MODE_FLAG_NHSYNC)  &&
                              (loop->flags & PHSync))  ||
                             ((mode->flags & DRM_MODE_FLAG_PHSYNC)  &&
                              (loop->flags & NHSync)))) {
                                loop++;
                                continue;
                        }
                        if (loop->refresh_rate <= refresh_rate
                            && loop->refresh_rate > best->refresh_rate)
                                best = loop;
                        loop++;
                }
                if (!check_sync)
                        break;
                check_sync = 0;
        } while (1);
        if (!best)
                return false;
        vbios_mode->enh_table = best;

This way the code doesn't make the assumption that the refresh rates
are in ascending order and we can map the sync polarities for all modes,
not just the wide screen ones.

 >  
 >  	hborder = (vbios_mode->enh_table->flags & HBorder) ? 8 : 0;
 >  	vborder = (vbios_mode->enh_table->flags & VBorder) ? 8 : 0;
 > @@ -419,8 +435,10 @@ static void ast_set_sync_reg(struct drm_device *dev, struct drm_display_mode *mo
 >  	struct ast_private *ast = dev->dev_private;
 >  	u8 jreg;
 >  
 > -	jreg = ast_io_read8(ast, AST_IO_MISC_PORT_READ);
 > -	jreg |= (vbios_mode->enh_table->flags & SyncNN);
 > +	jreg  = ast_io_read8(ast, AST_IO_MISC_PORT_READ);
 > +	jreg &= 0xC0;

This should be: 
        jreg &= ~0xC0U;

 > +	if (vbios_mode->enh_table->flags & NVSync) jreg |= 0x80;
 > +	if (vbios_mode->enh_table->flags & NHSync) jreg |= 0x40;
 >  	ast_io_write8(ast, AST_IO_MISC_PORT_WRITE, jreg);
 >  }
 >  

Cheers,
	Egbert.

  reply	other threads:[~2014-08-22 15:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-22  3:00 [PATCH 1/2] drm/ast: Add missing entry to dclk_table[] Y.C. Chen
2014-08-22  3:00 ` [PATCH 2/2] drm/ast: Add reduced/non-reduced mode parsing for wide screen mode Y.C. Chen
2014-08-22 15:28   ` Egbert Eich [this message]
2014-08-22 15:28   ` Egbert Eich
2014-08-22 15:57     ` YC Chen
2014-08-27  1:29   ` [PATCH v2] drm/ast: Improve mode matching Y.C. Chen
2014-08-27 12:28     ` Egbert Eich
2014-08-28  9:11       ` [PATCH v3] drm/ast: Add reduced blanking modes for wide screen mode Y.C. Chen
2014-09-15 11:12         ` Steven You2 Liang
2014-08-22 15:09 ` [PATCH 1/2] drm/ast: Add missing entry to dclk_table[] Egbert Eich

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=21495.24983.475258.133171@linux-qknr.fritz.box \
    --to=eich@suse.com \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=yc_chen@aspeedtech.com \
    /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