diff options
author | Maurus Cuelenaere <[email protected]> | 2010-08-10 18:02:44 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2010-08-11 08:59:12 -0700 |
commit | 2bb567a38950f0917aecfe1a3e46720d8bbb0020 (patch) | |
tree | 58187f4c8263dd3efcae7b018066517caece374e | |
parent | 04ab9ef97771ba88789672a1f0d0ddcf8dbc0924 (diff) |
s3c-fb: automatically calculate pixel clock when none is given
Add a simple algorithm which calculates the pixel clock based on the video
mode parameters. This is only done when no pixel clock is supplied
through the platform data.
This allows drivers to omit the pixel clock data and thus share the
algorithm used for calculating it.
Signed-off-by: Maurus Cuelenaere <[email protected]>
Cc: Pawel Osciak <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: InKi Dae <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Russell King <[email protected]>
Tested-by: Donghwa Lee <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | drivers/video/s3c-fb.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c index 8ea974dd92c5..f9aca9d13d1b 100644 --- a/drivers/video/s3c-fb.c +++ b/drivers/video/s3c-fb.c @@ -1027,6 +1027,28 @@ static struct fb_ops s3c_fb_ops = { }; /** + * s3c_fb_missing_pixclock() - calculates pixel clock + * @mode: The video mode to change. + * + * Calculate the pixel clock when none has been given through platform data. + */ +static void __devinit s3c_fb_missing_pixclock(struct fb_videomode *mode) +{ + u64 pixclk = 1000000000000ULL; + u32 div; + + div = mode->left_margin + mode->hsync_len + mode->right_margin + + mode->xres; + div *= mode->upper_margin + mode->vsync_len + mode->lower_margin + + mode->yres; + div *= mode->refresh ? : 60; + + do_div(pixclk, div); + + mode->pixclock = pixclk; +} + +/** * s3c_fb_alloc_memory() - allocate display memory for framebuffer window * @sfb: The base resources for the hardware. * @win: The window to initialise memory for. @@ -1364,6 +1386,9 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev) if (!pd->win[win]) continue; + if (!pd->win[win]->win_mode.pixclock) + s3c_fb_missing_pixclock(&pd->win[win]->win_mode); + ret = s3c_fb_probe_win(sfb, win, fbdrv->win[win], &sfb->windows[win]); if (ret < 0) { |