Skip to content

Commit

Permalink
s3c-fb: automatically calculate pixel clock when none is given
Browse files Browse the repository at this point in the history
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 <mcuelenaere@gmail.com>
Cc: Pawel Osciak <p.osciak@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: InKi Dae <inki.dae@samsung.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Tested-by: Donghwa Lee <yiffie9819@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Maurus Cuelenaere authored and Linus Torvalds committed Aug 11, 2010
1 parent 04ab9ef commit 2bb567a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions drivers/video/s3c-fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,28 @@ static struct fb_ops s3c_fb_ops = {
.fb_ioctl = s3c_fb_ioctl,
};

/**
* 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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2bb567a

Please sign in to comment.