Hi!
   This patch takes a little explaining. After the cleaned up of the fbdev 
api a few years back I realized the fbdev api had many short comings. One 
of them was the mapping of 1 to 1 for the framebuffer to display. So I 
started to move that way gradually. What ended up was a new struct 
fb_videomode. It is used for the modedb code and the idea was we over time
would move away from fb_var_screeeninfo. It never happened but now that 
dri is doing mode setting its a clean slate. Future patches will uses 
these functions. Note a nice bonus is that fb_videomode always does the 
right thing when it comes to the pixclock. 

I have tested these patch with a KMS enabled tdfx driver port I have done.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 9c92461..d020e57 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -755,6 +755,60 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo 
*var,
 }
 EXPORT_SYMBOL(drm_fb_helper_pan_display);
 
+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;
+
+       if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+               fbmode->vmode |= FB_VMODE_INTERLACED;
+
+       if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
+               fbmode->vmode |= FB_VMODE_DOUBLE; 
+
+       /* 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;
+
+       drm_mode_set_name(mode);
+}
+EXPORT_SYMBOL(fbmode_to_drm_display_mode);
+
 int drm_fb_helper_single_fb_probe(struct drm_device *dev,
                                  int preferred_bpp,
                                  int (*fb_create)(struct drm_device *dev,
   


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to