Skip to contentSkip to conversation

s3c-fb: Automatically calculate pixel clock when none is given

PATCH In review Maurus Cuelenaere 3 participants 5 messages Jul 13, 2010 – Jul 15, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 s3c-fb: Automatically calculate pixel clock when none is given

This patch adds 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.

---

Changes since v1:
Re-posted this to the correct fbdev mailing list.

---
 drivers/video/s3c-fb.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
drivers/video/s3c-fb.c +25 -0
index 9682ecc..e4715eb 100644
@@ -654,6 +654,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.
@@ -925,6 +947,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, &sfb->windows[win]);
 		if (ret < 0) {
 			dev_err(dev, "failed to create window %d\n", win);
Signature · 1 line
1.7.0.4
Tested-by on v2 1/1
#1 lore raw

Re: [PATCH v2] s3c-fb: Automatically calculate pixel clock when none

I tested this patch by using s5pv210.
It is verified by linux-2.6.32.
The result of test is the same pixel clock as before applying patch.

2010/7/13 Maurus Cuelenaere <[email protected]>

Quoted 57 lines

This patch adds 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.

---

Changes since v1:
Re-posted this to the correct fbdev mailing list.

---
 drivers/video/s3c-fb.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
drivers/video/s3c-fb.c +25 -0
index 9682ecc..e4715eb 100644
@@ -654,6 +654,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.
@@ -925,6 +947,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, &sfb->windows[win]);
 		if (ret < 0) {
 			dev_err(dev, "failed to create window %d\n", win);
#2 lore raw

Re: [PATCH v2] s3c-fb: Automatically calculate pixel clock when

In reply to Maurus Cuelenaere
Quoted 4 lines · On Tue, 13 Jul 2010 02:05:45 +0200 Maurus Cuelenaere <[email protected]>…

This patch adds 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.

So.. we are to assume that there's a platform which doesn't provide the pixel clock data? Adding some information about that in the changelog would have been useful.

#3 lore raw

Re: [PATCH v2] s3c-fb: Automatically calculate pixel clock when none

Op 15-07-10 20:52, Andrew Morton schreef:

Quoted 10 lines
Quoted 4 lines · On Tue, 13 Jul 2010 02:05:45 +0200 Maurus Cuelenaere <[email protected]>…

This patch adds 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.

So.. we are to assume that there's a platform which doesn't provide the pixel clock data? Adding some information about that in the changelog would have been useful.

Not exactly, this allows you to omit the pixel clock data and thus sharing the "algo" used for calculating it; which is done in another patch (not submitted to linux-fbdev, see [1]).

[1] - http://www.spinics.net/lists/linux-samsung-soc/msg02086.html

Signature · 1 line
Maurus Cuelenaere
#4 lore raw

Re: [PATCH v2] s3c-fb: Automatically calculate pixel clock when

Quoted 12 lines · On Thu, 15 Jul 2010 21:23:15 +0200 Maurus Cuelenaere <[email protected]>…

Op 15-07-10 20:52, Andrew Morton schreef:

Quoted 10 lines
Quoted 4 lines · On Tue, 13 Jul 2010 02:05:45 +0200 Maurus Cuelenaere <[email protected]>…

This patch adds 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.

So.. we are to assume that there's a platform which doesn't provide the pixel clock data? Adding some information about that in the changelog would have been useful.

Quoted 6 lines

Not exactly, this allows you to omit the pixel clock data and thus sharing the "algo" used for calculating it; which is done in another patch (not submitted to linux-fbdev, see [1]).

[1] - http://www.spinics.net/lists/linux-samsung-soc/msg02086.html

That means that there's no reason to merge this patch!

So I merged "arm: samsung: remove pixclock from several boards" as well ;)