All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <syrjala@sci.fi>
To: James Simmons <jsimmons@infradead.org>
Cc: Linux Fbdev development list <linux-fbdev@vger.kernel.org>,
	DRI development list <dri-devel@lists.sourceforge.net>
Subject: Re: [PATCH] drm modes to fbdev mode patch
Date: Sat, 13 Mar 2010 15:31:48 +0000	[thread overview]
Message-ID: <20100313153147.GD4536@sci.fi> (raw)
In-Reply-To: <alpine.LFD.2.00.1003131440230.12031@casper.infradead.org>

On Sat, Mar 13, 2010 at 02:47:52PM +0000, James Simmons wrote:
> 
> For the fbdev layer the you have your struct fb_var_screeninfo and also 
> struct fb_videomode. The struct fb_videomode was developed for the modes
> database we have. Struct fb_var_screeninfo is more than just resolution 
> data which is why we create struct fb_videomode. The really nice thing 
> is that the conversion from fb_var to fb_videomode always fixes the 
> pixclock to the proper values so you don't need the pixclock = 0 work 
> around. I tested this patch with the intelfb driver and had no problem.
> I have used it in the past with a KMS enabled tdfx drver I wrote. In the 
> future this function can be used for fbdev level mode setting. Please try 
> it out and i hope it can be merged. Thanks.
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 5054970..467ac68 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -581,6 +581,60 @@ int drm_fb_helper_setcolreg(unsigned regno,
>  }
>  EXPORT_SYMBOL(drm_fb_helper_setcolreg);
>  
> +void drm_display_mode_to_fbmode(struct drm_display_mode *mode,
> +                                struct fb_videomode *fbmode)
> +{
> +	fbmode->xres = mode->hdisplay;
> +	fbmode->yres = mode->vdisplay;
> +	fbmode->right_margin = mode->hsync_start - mode->hdisplay;
> +	fbmode->lower_margin = mode->vsync_start - mode->vdisplay;
> +	fbmode->hsync_len = mode->hsync_end - mode->hsync_start;
> +	fbmode->vsync_len = mode->vsync_end - mode->vsync_start;
> +	fbmode->left_margin = mode->htotal - mode->hsync_end;
> +	fbmode->upper_margin = mode->vtotal - mode->vsync_end;
> +	fbmode->refresh = mode->vrefresh;
> +	fbmode->name = mode->name;

Is there some guarantee that mode won't be freed before fbmode? That
would leave fbmode->name pointing to invalid memory.

> +
> +	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> +		fbmode->vmode |= FB_VMODE_INTERLACED;
> +
> +	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
> +		fbmode->vmode |= FB_VMODE_DOUBLE;
> +

What about the sync flags?

> +	/* Doing a var to fb_videomode always create a proper pixclock
> +	 * we can trust, but the reverse is not true. So we create
> +	 * a proper pixclock from the refresh rate wanted. */
> +	fbmode->pixclock = mode->vrefresh * mode->vtotal;
> +	fbmode->pixclock *= mode->htotal;
> +	fbmode->pixclock /= 1000;
> +	fbmode->pixclock = KHZ2PICOS(fbmode->pixclock);
> +}
> +EXPORT_SYMBOL(drm_display_mode_to_fbmode);
> +
> +void fbmode_to_drm_display_mode(struct fb_videomode *fbmode,
> +                                struct drm_display_mode *mode)
> +{
> +	mode->hdisplay = fbmode->xres;
> +	mode->vdisplay = fbmode->yres;
> +	mode->hsync_start = mode->hdisplay + fbmode->right_margin;
> +	mode->vsync_start = mode->vdisplay + fbmode->lower_margin;
> +	mode->hsync_end = mode->hsync_start + fbmode->hsync_len;
> +	mode->vsync_end = mode->vsync_start + fbmode->vsync_len;
> +	mode->htotal = mode->hsync_end + fbmode->left_margin;
> +	mode->vtotal = mode->vsync_end + fbmode->upper_margin;
> +	mode->vrefresh = fbmode->refresh;
> +	mode->clock = PICOS2KHZ(fbmode->pixclock);
> +
> +	if ((fbmode->vmode & FB_VMODE_MASK) = FB_VMODE_INTERLACED)
> +		mode->flags |= DRM_MODE_FLAG_INTERLACE;
> +
> +	if ((fbmode->vmode & FB_VMODE_MASK) = FB_VMODE_DOUBLE)
> +		mode->flags |= DRM_MODE_FLAG_DBLSCAN;

Is interlaced+dblscan considered an invalid combination? The conversion
to the other direction didn't make that assumption.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <syrjala@sci.fi>
To: James Simmons <jsimmons@infradead.org>
Cc: Linux Fbdev development list <linux-fbdev@vger.kernel.org>,
	DRI development list <dri-devel@lists.sourceforge.net>
Subject: Re: [PATCH] drm modes to fbdev mode patch
Date: Sat, 13 Mar 2010 17:31:48 +0200	[thread overview]
Message-ID: <20100313153147.GD4536@sci.fi> (raw)
In-Reply-To: <alpine.LFD.2.00.1003131440230.12031@casper.infradead.org>

On Sat, Mar 13, 2010 at 02:47:52PM +0000, James Simmons wrote:
> 
> For the fbdev layer the you have your struct fb_var_screeninfo and also 
> struct fb_videomode. The struct fb_videomode was developed for the modes
> database we have. Struct fb_var_screeninfo is more than just resolution 
> data which is why we create struct fb_videomode. The really nice thing 
> is that the conversion from fb_var to fb_videomode always fixes the 
> pixclock to the proper values so you don't need the pixclock = 0 work 
> around. I tested this patch with the intelfb driver and had no problem.
> I have used it in the past with a KMS enabled tdfx drver I wrote. In the 
> future this function can be used for fbdev level mode setting. Please try 
> it out and i hope it can be merged. Thanks.
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 5054970..467ac68 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -581,6 +581,60 @@ int drm_fb_helper_setcolreg(unsigned regno,
>  }
>  EXPORT_SYMBOL(drm_fb_helper_setcolreg);
>  
> +void drm_display_mode_to_fbmode(struct drm_display_mode *mode,
> +                                struct fb_videomode *fbmode)
> +{
> +	fbmode->xres = mode->hdisplay;
> +	fbmode->yres = mode->vdisplay;
> +	fbmode->right_margin = mode->hsync_start - mode->hdisplay;
> +	fbmode->lower_margin = mode->vsync_start - mode->vdisplay;
> +	fbmode->hsync_len = mode->hsync_end - mode->hsync_start;
> +	fbmode->vsync_len = mode->vsync_end - mode->vsync_start;
> +	fbmode->left_margin = mode->htotal - mode->hsync_end;
> +	fbmode->upper_margin = mode->vtotal - mode->vsync_end;
> +	fbmode->refresh = mode->vrefresh;
> +	fbmode->name = mode->name;

Is there some guarantee that mode won't be freed before fbmode? That
would leave fbmode->name pointing to invalid memory.

> +
> +	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> +		fbmode->vmode |= FB_VMODE_INTERLACED;
> +
> +	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
> +		fbmode->vmode |= FB_VMODE_DOUBLE;
> +

What about the sync flags?

> +	/* Doing a var to fb_videomode always create a proper pixclock
> +	 * we can trust, but the reverse is not true. So we create
> +	 * a proper pixclock from the refresh rate wanted. */
> +	fbmode->pixclock = mode->vrefresh * mode->vtotal;
> +	fbmode->pixclock *= mode->htotal;
> +	fbmode->pixclock /= 1000;
> +	fbmode->pixclock = KHZ2PICOS(fbmode->pixclock);
> +}
> +EXPORT_SYMBOL(drm_display_mode_to_fbmode);
> +
> +void fbmode_to_drm_display_mode(struct fb_videomode *fbmode,
> +                                struct drm_display_mode *mode)
> +{
> +	mode->hdisplay = fbmode->xres;
> +	mode->vdisplay = fbmode->yres;
> +	mode->hsync_start = mode->hdisplay + fbmode->right_margin;
> +	mode->vsync_start = mode->vdisplay + fbmode->lower_margin;
> +	mode->hsync_end = mode->hsync_start + fbmode->hsync_len;
> +	mode->vsync_end = mode->vsync_start + fbmode->vsync_len;
> +	mode->htotal = mode->hsync_end + fbmode->left_margin;
> +	mode->vtotal = mode->vsync_end + fbmode->upper_margin;
> +	mode->vrefresh = fbmode->refresh;
> +	mode->clock = PICOS2KHZ(fbmode->pixclock);
> +
> +	if ((fbmode->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
> +		mode->flags |= DRM_MODE_FLAG_INTERLACE;
> +
> +	if ((fbmode->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
> +		mode->flags |= DRM_MODE_FLAG_DBLSCAN;

Is interlaced+dblscan considered an invalid combination? The conversion
to the other direction didn't make that assumption.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

  reply	other threads:[~2010-03-13 15:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-13 14:47 [PATCH] drm modes to fbdev mode patch James Simmons
2010-03-13 14:47 ` James Simmons
2010-03-13 15:31 ` Ville Syrjälä [this message]
2010-03-13 15:31   ` Ville Syrjälä
2010-03-13 21:28   ` James Simmons
2010-03-13 21:28     ` James Simmons
2010-03-14  0:52   ` [PATCH v2] " James Simmons
2010-03-14  0:52     ` James Simmons

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=20100313153147.GD4536@sci.fi \
    --to=syrjala@sci.fi \
    --cc=dri-devel@lists.sourceforge.net \
    --cc=jsimmons@infradead.org \
    --cc=linux-fbdev@vger.kernel.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 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.