linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] video: OF display-timings support for ocfb
@ 2014-06-11 20:17 Franck Jullien
  2014-06-17 21:08 ` Stefan Kristiansson
  2014-06-23 12:01 ` Tomi Valkeinen
  0 siblings, 2 replies; 4+ messages in thread
From: Franck Jullien @ 2014-06-11 20:17 UTC (permalink / raw)
  To: linux-kernel, linux-fbdev
  Cc: tomi.valkeinen, plagnioj, stefan.kristiansson, Franck Jullien

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
---
 drivers/video/fbdev/Kconfig |    2 ++
 drivers/video/fbdev/ocfb.c  |   31 ++++++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index e1f4727..b4ac6bb 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -942,6 +942,8 @@ config FB_OPENCORES
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
+	select VIDEOMODE_HELPERS
+	select FB_MODE_HELPERS
 	help
 	  This enables support for the OpenCores VGA/LCD core.
 
diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c
index 7f9dc9b..6d15565 100644
--- a/drivers/video/fbdev/ocfb.c
+++ b/drivers/video/fbdev/ocfb.c
@@ -22,6 +22,8 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 
+#include <video/of_display_timing.h>
+
 /* OCFB register defines */
 #define OCFB_CTRL	0x000
 #define OCFB_STAT	0x004
@@ -310,11 +312,30 @@ static int ocfb_probe(struct platform_device *pdev)
 	fbdev->info.device = &pdev->dev;
 	fbdev->info.par = fbdev;
 
-	/* Video mode setup */
-	if (!fb_find_mode(&fbdev->info.var, &fbdev->info, mode_option,
-			  NULL, 0, &default_mode, 16)) {
-		dev_err(&pdev->dev, "No valid video modes found\n");
-		return -EINVAL;
+	if (!mode_option && IS_ENABLED(CONFIG_OF)) {
+		struct fb_videomode mode;
+		u32 bpp;
+
+		ret = of_get_fb_videomode(pdev->dev.of_node, &mode,
+					  OF_USE_NATIVE_MODE);
+		if (ret)
+			return ret;
+
+		fb_videomode_to_var(&fbdev->info.var, &mode);
+
+		ret = of_property_read_u32(pdev->dev.of_node, "bits-per-pixel",
+					   &bpp);
+		if (ret)
+			return ret;
+
+		fbdev->info.var.bits_per_pixel = bpp;
+
+	} else {
+		if (!fb_find_mode(&fbdev->info.var, &fbdev->info, mode_option,
+				  NULL, 0, &default_mode, 16)) {
+			dev_err(&pdev->dev, "No valid video modes found\n");
+			return -EINVAL;
+		}
 	}
 	ocfb_init_var(fbdev);
 	ocfb_init_fix(fbdev);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] video: OF display-timings support for ocfb
  2014-06-11 20:17 [PATCH] video: OF display-timings support for ocfb Franck Jullien
@ 2014-06-17 21:08 ` Stefan Kristiansson
  2014-06-23 12:01 ` Tomi Valkeinen
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Kristiansson @ 2014-06-17 21:08 UTC (permalink / raw)
  To: Franck Jullien; +Cc: linux-kernel, linux-fbdev, tomi.valkeinen, plagnioj

On Wed, Jun 11, 2014 at 10:17:51PM +0200, Franck Jullien wrote:
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
>  drivers/video/fbdev/Kconfig |    2 ++
>  drivers/video/fbdev/ocfb.c  |   31 ++++++++++++++++++++++++++-----
>  2 files changed, 28 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
> index e1f4727..b4ac6bb 100644
> --- a/drivers/video/fbdev/Kconfig
> +++ b/drivers/video/fbdev/Kconfig
> @@ -942,6 +942,8 @@ config FB_OPENCORES
>  	select FB_CFB_FILLRECT
>  	select FB_CFB_COPYAREA
>  	select FB_CFB_IMAGEBLIT
> +	select VIDEOMODE_HELPERS
> +	select FB_MODE_HELPERS
>  	help
>  	  This enables support for the OpenCores VGA/LCD core.
>  
> diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c
> index 7f9dc9b..6d15565 100644
> --- a/drivers/video/fbdev/ocfb.c
> +++ b/drivers/video/fbdev/ocfb.c
> @@ -22,6 +22,8 @@
>  #include <linux/string.h>
>  #include <linux/slab.h>
>  
> +#include <video/of_display_timing.h>
> +
>  /* OCFB register defines */
>  #define OCFB_CTRL	0x000
>  #define OCFB_STAT	0x004
> @@ -310,11 +312,30 @@ static int ocfb_probe(struct platform_device *pdev)
>  	fbdev->info.device = &pdev->dev;
>  	fbdev->info.par = fbdev;
>  
> -	/* Video mode setup */
> -	if (!fb_find_mode(&fbdev->info.var, &fbdev->info, mode_option,
> -			  NULL, 0, &default_mode, 16)) {
> -		dev_err(&pdev->dev, "No valid video modes found\n");
> -		return -EINVAL;
> +	if (!mode_option && IS_ENABLED(CONFIG_OF)) {
> +		struct fb_videomode mode;
> +		u32 bpp;
> +
> +		ret = of_get_fb_videomode(pdev->dev.of_node, &mode,
> +					  OF_USE_NATIVE_MODE);
> +		if (ret)
> +			return ret;
> +
> +		fb_videomode_to_var(&fbdev->info.var, &mode);
> +
> +		ret = of_property_read_u32(pdev->dev.of_node, "bits-per-pixel",
> +					   &bpp);
> +		if (ret)
> +			return ret;
> +
> +		fbdev->info.var.bits_per_pixel = bpp;
> +
> +	} else {
> +		if (!fb_find_mode(&fbdev->info.var, &fbdev->info, mode_option,
> +				  NULL, 0, &default_mode, 16)) {
> +			dev_err(&pdev->dev, "No valid video modes found\n");
> +			return -EINVAL;
> +		}
>  	}
>  	ocfb_init_var(fbdev);
>  	ocfb_init_fix(fbdev);


Nice, this was something that was discussed as a possible future improvement
when I first posted this driver.

Acked-by: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] video: OF display-timings support for ocfb
  2014-06-11 20:17 [PATCH] video: OF display-timings support for ocfb Franck Jullien
  2014-06-17 21:08 ` Stefan Kristiansson
@ 2014-06-23 12:01 ` Tomi Valkeinen
  2014-06-24  6:59   ` Stefan Kristiansson
  1 sibling, 1 reply; 4+ messages in thread
From: Tomi Valkeinen @ 2014-06-23 12:01 UTC (permalink / raw)
  To: Franck Jullien, linux-kernel, linux-fbdev; +Cc: plagnioj, stefan.kristiansson

[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]

On 11/06/14 23:17, Franck Jullien wrote:
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
>  drivers/video/fbdev/Kconfig |    2 ++
>  drivers/video/fbdev/ocfb.c  |   31 ++++++++++++++++++++++++++-----
>  2 files changed, 28 insertions(+), 5 deletions(-)

You need to add binding documentation if you add new things to the
driver's DT support. Actually, we seem to be missing the the binding
documentation totally, even if the driver has 'of_device_id' table...

> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
> index e1f4727..b4ac6bb 100644
> --- a/drivers/video/fbdev/Kconfig
> +++ b/drivers/video/fbdev/Kconfig
> @@ -942,6 +942,8 @@ config FB_OPENCORES
>  	select FB_CFB_FILLRECT
>  	select FB_CFB_COPYAREA
>  	select FB_CFB_IMAGEBLIT
> +	select VIDEOMODE_HELPERS
> +	select FB_MODE_HELPERS
>  	help
>  	  This enables support for the OpenCores VGA/LCD core.
>  
> diff --git a/drivers/video/fbdev/ocfb.c b/drivers/video/fbdev/ocfb.c
> index 7f9dc9b..6d15565 100644
> --- a/drivers/video/fbdev/ocfb.c
> +++ b/drivers/video/fbdev/ocfb.c
> @@ -22,6 +22,8 @@
>  #include <linux/string.h>
>  #include <linux/slab.h>
>  
> +#include <video/of_display_timing.h>
> +
>  /* OCFB register defines */
>  #define OCFB_CTRL	0x000
>  #define OCFB_STAT	0x004
> @@ -310,11 +312,30 @@ static int ocfb_probe(struct platform_device *pdev)
>  	fbdev->info.device = &pdev->dev;
>  	fbdev->info.par = fbdev;
>  
> -	/* Video mode setup */
> -	if (!fb_find_mode(&fbdev->info.var, &fbdev->info, mode_option,
> -			  NULL, 0, &default_mode, 16)) {
> -		dev_err(&pdev->dev, "No valid video modes found\n");
> -		return -EINVAL;
> +	if (!mode_option && IS_ENABLED(CONFIG_OF)) {

This doesn't look correct. The kernel may have CONFIG_OF enabled, even
if the board does not use OF.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] video: OF display-timings support for ocfb
  2014-06-23 12:01 ` Tomi Valkeinen
@ 2014-06-24  6:59   ` Stefan Kristiansson
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Kristiansson @ 2014-06-24  6:59 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: Franck Jullien, linux-kernel, linux-fbdev, plagnioj

On Mon, Jun 23, 2014 at 03:01:36PM +0300, Tomi Valkeinen wrote:
> On 11/06/14 23:17, Franck Jullien wrote:
> > Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> > ---
> >  drivers/video/fbdev/Kconfig |    2 ++
> >  drivers/video/fbdev/ocfb.c  |   31 ++++++++++++++++++++++++++-----
> >  2 files changed, 28 insertions(+), 5 deletions(-)
> 
> You need to add binding documentation if you add new things to the
> driver's DT support. Actually, we seem to be missing the the binding
> documentation totally, even if the driver has 'of_device_id' table...
> 

Right, I'll take the blame for the missing driver binding documentation,
I'll write something up and post a patch for that.
But, where should it go?
Documentation/devicetree/bindings/video/
or
Documentation/devicetree/bindings/fb/

Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-24  6:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-11 20:17 [PATCH] video: OF display-timings support for ocfb Franck Jullien
2014-06-17 21:08 ` Stefan Kristiansson
2014-06-23 12:01 ` Tomi Valkeinen
2014-06-24  6:59   ` Stefan Kristiansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).