Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH 3/6] au1200fb: make number of windows configurable at load time.
From: Manuel Lauss @ 2011-09-02 14:40 UTC (permalink / raw)
  To: linux-fbdev

Make the number of framebuffer windows and the window configuration
selectable at the kernel commandline instead of hardcoding it
in the kernel config.

Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
---
 drivers/video/au1200fb.c |   53 +++++++++++++++++++++++++++++++++------------
 1 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 480ecb1..4b58f7b 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -46,10 +46,6 @@
 #include <asm/mach-au1x00/au1000.h>
 #include "au1200fb.h"
 
-#ifndef CONFIG_FB_AU1200_DEVS
-#define CONFIG_FB_AU1200_DEVS 4
-#endif
-
 #define DRIVER_NAME "au1200fb"
 #define DRIVER_DESC "LCD controller driver for AU1200 processors"
 
@@ -154,7 +150,6 @@ struct au1200fb_device {
 	dma_addr_t    		fb_phys;
 };
 
-static struct fb_info *_au1200fb_infos[CONFIG_FB_AU1200_DEVS];
 /********************************************************************/
 
 /* LCD controller restrictions */
@@ -167,10 +162,18 @@ static struct fb_info *_au1200fb_infos[CONFIG_FB_AU1200_DEVS];
 /* Default number of visible screen buffer to allocate */
 #define AU1200FB_NBR_VIDEO_BUFFERS 1
 
+/* Default maximum number of fb devices to create */
+#define MAX_DEVICE_COUNT	4
+
+/* Default window configuration entry to use (see windows[]) */
+#define DEFAULT_WINDOW_INDEX	2
+
 /********************************************************************/
 
+static struct fb_info *_au1200fb_infos[MAX_DEVICE_COUNT];
 static struct au1200_lcd *lcd = (struct au1200_lcd *) AU1200_LCD_ADDR;
-static int window_index = 2; /* default is zero */
+static int device_count = MAX_DEVICE_COUNT;
+static int window_index = DEFAULT_WINDOW_INDEX;	/* default is zero */
 static int panel_index = 2; /* default is zero */
 static struct window_settings *win;
 static struct panel_settings *panel;
@@ -683,7 +686,7 @@ static int fbinfo2index (struct fb_info *fb_info)
 {
 	int i;
 
-	for (i = 0; i < CONFIG_FB_AU1200_DEVS; ++i) {
+	for (i = 0; i < device_count; ++i) {
 		if (fb_info = _au1200fb_infos[i])
 			return i;
 	}
@@ -1599,7 +1602,7 @@ static int __devinit au1200fb_drv_probe(struct platform_device *dev)
 	/* Kickstart the panel */
 	au1200_setpanel(panel);
 
-	for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) {
+	for (plane = 0; plane < device_count; ++plane) {
 		bpp = winbpp(win->w[plane].mode_winctrl1);
 		if (win->w[plane].xres = 0)
 			win->w[plane].xres = panel->Xres;
@@ -1699,7 +1702,7 @@ static int __devexit au1200fb_drv_remove(struct platform_device *dev)
 	/* Turn off the panel */
 	au1200_setpanel(NULL);
 
-	for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane)	{
+	for (plane = 0; plane < device_count; ++plane)	{
 		fbi = _au1200fb_infos[plane];
 		fbdev = fbi->par;
 
@@ -1741,7 +1744,7 @@ static int au1200fb_drv_resume(struct device *dev)
 	/* Kickstart the panel */
 	au1200_setpanel(panel);
 
-	for (i = 0; i < CONFIG_FB_AU1200_DEVS; i++) {
+	for (i = 0; i < device_count; i++) {
 		fbi = _au1200fb_infos[i];
 		au1200fb_fb_set_par(fbi);
 	}
@@ -1776,10 +1779,10 @@ static struct platform_driver au1200fb_driver = {
 
 /* Kernel driver */
 
-static void au1200fb_setup(void)
+static int au1200fb_setup(void)
 {
-	char* options = NULL;
-	char* this_opt;
+	char *options = NULL;
+	char *this_opt, *endptr;
 	int num_panels = ARRAY_SIZE(known_lcd_panels);
 	int panel_idx = -1;
 
@@ -1824,12 +1827,33 @@ static void au1200fb_setup(void)
 				nohwcursor = 1;
 			}
 
+			else if (strncmp(this_opt, "devices:", 8) = 0) {
+				this_opt += 8;
+				device_count = simple_strtol(this_opt,
+							     &endptr, 0);
+				if ((device_count < 0) ||
+				    (device_count > MAX_DEVICE_COUNT))
+					device_count = MAX_DEVICE_COUNT;
+			}
+
+			else if (strncmp(this_opt, "wincfg:", 7) = 0) {
+				this_opt += 7;
+				window_index = simple_strtol(this_opt,
+							     &endptr, 0);
+				if ((window_index < 0) ||
+				    (window_index >= ARRAY_SIZE(windows)))
+					window_index = DEFAULT_WINDOW_INDEX;
+			}
+
+			else if (strncmp(this_opt, "off", 3) = 0)
+				return 1;
 			/* Unsupported option */
 			else {
 				print_warn("Unsupported option \"%s\"", this_opt);
 			}
 		}
 	}
+	return 0;
 }
 
 static int __init au1200fb_init(void)
@@ -1837,7 +1861,8 @@ static int __init au1200fb_init(void)
 	print_info("" DRIVER_DESC "");
 
 	/* Setup driver with options */
-	au1200fb_setup();
+	if (au1200fb_setup())
+		return -ENODEV;
 
 	/* Point to the panel selected */
 	panel = &known_lcd_panels[panel_index];
-- 
1.7.6


^ permalink raw reply related

* [PATCH 4/6] au1200fb: switch to FB_SYS helpers
From: Manuel Lauss @ 2011-09-02 14:40 UTC (permalink / raw)
  To: linux-fbdev

Since all video memory is in system ram, use FB_SYS helpers.

Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
---
 drivers/video/Kconfig    |    7 ++++---
 drivers/video/au1200fb.c |    8 +++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 549b960..5e19de9 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1756,9 +1756,10 @@ config FB_AU1100
 config FB_AU1200
 	bool "Au1200 LCD Driver"
 	depends on (FB = y) && MIPS && SOC_AU1200
-	select FB_CFB_FILLRECT
-	select FB_CFB_COPYAREA
-	select FB_CFB_IMAGEBLIT
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
 	help
 	  This is the framebuffer driver for the AMD Au1200 SOC.  It can drive
 	  various panels and CRTs by passing in kernel cmd line option
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 4b58f7b..b1b16d9 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -1502,9 +1502,11 @@ static struct fb_ops au1200fb_fb_ops = {
 	.fb_set_par	= au1200fb_fb_set_par,
 	.fb_setcolreg	= au1200fb_fb_setcolreg,
 	.fb_blank	= au1200fb_fb_blank,
-	.fb_fillrect	= cfb_fillrect,
-	.fb_copyarea	= cfb_copyarea,
-	.fb_imageblit	= cfb_imageblit,
+	.fb_fillrect	= sys_fillrect,
+	.fb_copyarea	= sys_copyarea,
+	.fb_imageblit	= sys_imageblit,
+	.fb_read	= fb_sys_read,
+	.fb_write	= fb_sys_write,
 	.fb_sync	= NULL,
 	.fb_ioctl	= au1200fb_ioctl,
 	.fb_mmap	= au1200fb_fb_mmap,
-- 
1.7.6


^ permalink raw reply related

* [PATCH 5/6] au1200fb: fix hardcoded IRQ
From: Manuel Lauss @ 2011-09-02 14:40 UTC (permalink / raw)
  To: linux-fbdev

Use the IRQ provided by platform resource information.
Required for Au1300 support.

Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
---
 drivers/video/au1200fb.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index b1b16d9..ed5dcdb2 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -1595,7 +1595,7 @@ static int __devinit au1200fb_drv_probe(struct platform_device *dev)
 	struct au1200fb_device *fbdev;
 	struct fb_info *fbi = NULL;
 	unsigned long page;
-	int bpp, plane, ret;
+	int bpp, plane, ret, irq;
 
 	/* shut gcc up */
 	ret = 0;
@@ -1671,10 +1671,12 @@ static int __devinit au1200fb_drv_probe(struct platform_device *dev)
 	}
 
 	/* Now hook interrupt too */
-	if ((ret = request_irq(AU1200_LCD_INT, au1200fb_handle_irq,
-		 	  IRQF_DISABLED | IRQF_SHARED, "lcd", (void *)dev)) < 0) {
+	irq = platform_get_irq(dev, 0);
+	ret = request_irq(irq, au1200fb_handle_irq,
+			  IRQF_DISABLED | IRQF_SHARED, "lcd", (void *)dev);
+	if (ret) {
 		print_err("fail to request interrupt line %d (err: %d)",
-			  AU1200_LCD_INT, ret);
+			  irq, ret);
 		goto failed;
 	}
 
@@ -1722,7 +1724,7 @@ static int __devexit au1200fb_drv_remove(struct platform_device *dev)
 		_au1200fb_infos[plane] = NULL;
 	}
 
-	free_irq(AU1200_LCD_INT, (void *)dev);
+	free_irq(platform_get_irq(dev, 0), (void *)dev);
 
 	return 0;
 }
-- 
1.7.6


^ permalink raw reply related

* [PATCH 6/6] fbdev: au1200fb: silence debug output
From: Manuel Lauss @ 2011-09-02 14:40 UTC (permalink / raw)
  To: linux-fbdev

it's annoying and takes up way too much space in dmesg.

Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
---
 drivers/video/au1200fb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index ed5dcdb2..a19a40e 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -49,7 +49,7 @@
 #define DRIVER_NAME "au1200fb"
 #define DRIVER_DESC "LCD controller driver for AU1200 processors"
 
-#define DEBUG 1
+#define DEBUG 0
 
 #define print_err(f, arg...) printk(KERN_ERR DRIVER_NAME ": " f "\n", ## arg)
 #define print_warn(f, arg...) printk(KERN_WARNING DRIVER_NAME ": " f "\n", ## arg)
-- 
1.7.6


^ permalink raw reply related

* Re: [PATCH] fb: avoid possible deadlock caused by fb_set_suspend
From: Guennadi Liakhovetski @ 2011-09-02 16:06 UTC (permalink / raw)
  To: Florian Tobias Schandinat
  Cc: Bruno Prémont, lethal, linux-fbdev, francis.moro, torvalds,
	linux-kernel, Herton Ronaldo Krzesinski, stable
In-Reply-To: <4E5FA7F9.9030802@gmx.de>

Hi Florian

On Thu, 1 Sep 2011, Florian Tobias Schandinat wrote:

> ping
> 
> Guennadi, I really want this issue fixed. Please have a look at Bruno's patch
> otherwise your driver might remain or get even more broken...
> 
> I am scheduling Herton's patch for the next merge window.

So, the patch looks simple and correct, when applied on top of 
http://marc.info/?l=linux-kernel&m\x130833638508657&w=2
But it doesn't apply anymore and after fixing a trivial merge conflict, it 
fails to build, which is also trivially fixed. Please, add my

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

to the set and use this updated version:

diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index 7d54e2c..647ba98 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -1111,6 +1111,7 @@ static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate,
 static void sh_hdmi_edid_work_fn(struct work_struct *work)
 {
 	struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work);
+	struct fb_info *info;
 	struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
 	struct sh_mobile_lcdc_chan *ch;
 	int ret;
@@ -1123,8 +1124,9 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
 
 	mutex_lock(&hdmi->mutex);
 
+	info = hdmi->info;
+
 	if (hdmi->hp_state = HDMI_HOTPLUG_CONNECTED) {
-		struct fb_info *info = hdmi->info;
 		unsigned long parent_rate = 0, hdmi_rate;
 
 		ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate);
@@ -1148,42 +1150,45 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
 
 		ch = info->par;
 
-		console_lock();
+		if (lock_fb_info(info)) {
+			console_lock();
 
-		/* HDMI plug in */
-		if (!sh_hdmi_must_reconfigure(hdmi) &&
-		    info->state = FBINFO_STATE_RUNNING) {
-			/*
-			 * First activation with the default monitor - just turn
-			 * on, if we run a resume here, the logo disappears
-			 */
-			if (lock_fb_info(info)) {
+			/* HDMI plug in */
+			if (!sh_hdmi_must_reconfigure(hdmi) &&
+			    info->state = FBINFO_STATE_RUNNING) {
+				/*
+				 * First activation with the default monitor - just turn
+				 * on, if we run a resume here, the logo disappears
+				 */
 				info->var.width = hdmi->var.width;
 				info->var.height = hdmi->var.height;
 				sh_hdmi_display_on(hdmi, info);
-				unlock_fb_info(info);
+			} else {
+				/* New monitor or have to wake up */
+				fb_set_suspend(info, 0);
 			}
-		} else {
-			/* New monitor or have to wake up */
-			fb_set_suspend(info, 0);
-		}
 
-		console_unlock();
+			console_unlock();
+			unlock_fb_info(info);
+		}
 	} else {
 		ret = 0;
-		if (!hdmi->info)
+		if (!info)
 			goto out;
 
 		hdmi->monspec.modedb_len = 0;
 		fb_destroy_modedb(hdmi->monspec.modedb);
 		hdmi->monspec.modedb = NULL;
 
-		console_lock();
+		if (lock_fb_info(info)) {
+			console_lock();
 
-		/* HDMI disconnect */
-		fb_set_suspend(hdmi->info, 1);
+			/* HDMI disconnect */
+			fb_set_suspend(info, 1);
 
-		console_unlock();
+			console_unlock();
+			unlock_fb_info(info);
+		}
 	}
 
 out:

Thanks
Guennadi

> 
> 
> Regards,
> 
> Florian Tobias Schandinat
> 
> 
> On 06/18/2011 09:19 AM, Bruno Prémont wrote:
> > Guennadi, could you have a look at (completely untested) patch which avoids
> > possible deadlock due to inverted lock taking order on hotplug as well
> > as "readding" lock_fb_info() for fb_set_suspend() call after Herton's
> > patch to fb_set_suspend().
> > 
> > Thanks,
> > Bruno
> > 
> > 
> > On Sat, 18 June 2011 Bruno Prémont <bonbons@linux-vserver.org> wrote:
> >> On Fri, 17 June 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:
> >>> From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> >>>
> >>> A lock ordering issue can cause deadlocks: in framebuffer/console code,
> >>> all needed struct fb_info locks are taken before acquire_console_sem(),
> >>> in places which need to take console semaphore.
> >>>
> >>> But fb_set_suspend is always called with console semaphore held, and
> >>> inside it we call lock_fb_info which gets the fb_info lock, inverse
> >>> locking order of what the rest of the code does. This causes a real
> >>> deadlock issue, when we write to state fb sysfs attribute (which calls
> >>> fb_set_suspend) while a framebuffer is being unregistered by
> >>> remove_conflicting_framebuffers, as can be shown by following show
> >>> blocked state trace on a test program which loads i915 and runs another
> >>> forked processes writing to state attribute:
> >>>
> >>> Test process with semaphore held and trying to get fb_info lock:
> >>
> >> ...
> >>
> >>> fb-test2 which reproduces above is available on kernel.org bug #26232.
> >>> To solve this issue, avoid calling lock_fb_info inside fb_set_suspend,
> >>> and move it out to where needed (callers of fb_set_suspend must call
> >>> lock_fb_info before if needed). So far, the only place which needs to
> >>> call lock_fb_info is store_fbstate, all other places which calls
> >>> fb_set_suspend are suspend/resume hooks that should not need the lock as
> >>> they should be run only when processes are already frozen in
> >>> suspend/resume.
> >>
> >> From a quick look through FB drivers in 2.6.39 I've found one that would need
> >> more work:
> >> - drivers/video/sh_mobile_hdmi.c: sh_hdmi_edid_work_fn()
> >>   Should get changed to
> >>   a) right locking order in case (hdmi->hp_state = HDMI_HOTPLUG_CONNECTED)
> >>   b) lock fb_info in the other case
> >>   For this one fb_set_suspend() does get call in a hotplug worker,
> >>   thus independently on suspend/resume process.
> >>
> >> The rest does match the suspend/resume hook pattern mentioned.
> >>
> >> Bruno
> >>
> >>
> >>> References: https://bugzilla.kernel.org/show_bug.cgi?id&232
> >>> Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> >>> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
> >>> Cc: stable@kernel.org
> >>> ---
> >>>  drivers/video/fbmem.c   |    3 ---
> >>>  drivers/video/fbsysfs.c |    3 +++
> >>>  2 files changed, 3 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> >>> index 5aac00e..ad93629 100644
> >>> --- a/drivers/video/fbmem.c
> >>> +++ b/drivers/video/fbmem.c
> >>> @@ -1738,8 +1738,6 @@ void fb_set_suspend(struct fb_info *info, int state)
> >>>  {
> >>>  	struct fb_event event;
> >>>  
> >>> -	if (!lock_fb_info(info))
> >>> -		return;
> >>>  	event.info = info;
> >>>  	if (state) {
> >>>  		fb_notifier_call_chain(FB_EVENT_SUSPEND, &event);
> >>> @@ -1748,7 +1746,6 @@ void fb_set_suspend(struct fb_info *info, int state)
> >>>  		info->state = FBINFO_STATE_RUNNING;
> >>>  		fb_notifier_call_chain(FB_EVENT_RESUME, &event);
> >>>  	}
> >>> -	unlock_fb_info(info);
> >>>  }
> >>>  
> >>>  /**
> >>> diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
> >>> index 04251ce..67afa9c 100644
> >>> --- a/drivers/video/fbsysfs.c
> >>> +++ b/drivers/video/fbsysfs.c
> >>> @@ -399,9 +399,12 @@ static ssize_t store_fbstate(struct device *device,
> >>>  
> >>>  	state = simple_strtoul(buf, &last, 0);
> >>>  
> >>> +	if (!lock_fb_info(fb_info))
> >>> +		return -ENODEV;
> >>>  	console_lock();
> >>>  	fb_set_suspend(fb_info, (int)state);
> >>>  	console_unlock();
> >>> +	unlock_fb_info(fb_info);
> >>>  
> >>>  	return count;
> >>>  }
> > 
> > 
> > diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
> > index 2b9e56a..b1a13ab 100644
> > --- a/drivers/video/sh_mobile_hdmi.c
> > +++ b/drivers/video/sh_mobile_hdmi.c
> > @@ -1151,27 +1151,27 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
> >  
> >  		ch = info->par;
> >  
> > -		console_lock();
> > +		if (lock_fb_info(info)) {
> > +			console_lock();
> >  
> > -		/* HDMI plug in */
> > -		if (!sh_hdmi_must_reconfigure(hdmi) &&
> > -		    info->state = FBINFO_STATE_RUNNING) {
> > -			/*
> > -			 * First activation with the default monitor - just turn
> > -			 * on, if we run a resume here, the logo disappears
> > -			 */
> > -			if (lock_fb_info(info)) {
> > +			/* HDMI plug in */
> > +			if (!sh_hdmi_must_reconfigure(hdmi) &&
> > +			    info->state = FBINFO_STATE_RUNNING) {
> > +				/*
> > +				 * First activation with the default monitor - just turn
> > +				 * on, if we run a resume here, the logo disappears
> > +				 */
> >  				info->var.width = hdmi->var.width;
> >  				info->var.height = hdmi->var.height;
> >  				sh_hdmi_display_on(hdmi, info);
> > -				unlock_fb_info(info);
> > +			} else {
> > +				/* New monitor or have to wake up */
> > +				fb_set_suspend(info, 0);
> >  			}
> > -		} else {
> > -			/* New monitor or have to wake up */
> > -			fb_set_suspend(info, 0);
> > -		}
> >  
> > -		console_unlock();
> > +			console_unlock();
> > +			unlock_fb_info(info);
> > +		}
> >  	} else {
> >  		ret = 0;
> >  		if (!hdmi->info)
> > @@ -1181,12 +1181,15 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
> >  		fb_destroy_modedb(hdmi->monspec.modedb);
> >  		hdmi->monspec.modedb = NULL;
> >  
> > -		console_lock();
> > +		if (lock_fb_info(info)) {
> > +			console_lock();
> >  
> > -		/* HDMI disconnect */
> > -		fb_set_suspend(hdmi->info, 1);
> > +			/* HDMI disconnect */
> > +			fb_set_suspend(hdmi->info, 1);
> >  
> > -		console_unlock();
> > +			console_unlock();
> > +			unlock_fb_info(info);
> > +		}
> >  		pm_runtime_put(hdmi->dev);
> >  	}
> >  
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply related

* Re: [PATCH] fb: avoid possible deadlock caused by fb_set_suspend
From: Florian Tobias Schandinat @ 2011-09-02 16:46 UTC (permalink / raw)
  To: Bruno Prémont
  Cc: Guennadi Liakhovetski, lethal, linux-fbdev, francis.moro,
	torvalds, linux-kernel, Herton Ronaldo Krzesinski, stable
In-Reply-To: <Pine.LNX.4.64.1109021802560.4731@axis700.grange>

Hi Bruno, Guennadi,

On 09/02/2011 04:06 PM, Guennadi Liakhovetski wrote:
> Hi Florian
> 
> On Thu, 1 Sep 2011, Florian Tobias Schandinat wrote:
> 
>> ping
>>
>> Guennadi, I really want this issue fixed. Please have a look at Bruno's patch
>> otherwise your driver might remain or get even more broken...
>>
>> I am scheduling Herton's patch for the next merge window.
> 
> So, the patch looks simple and correct, when applied on top of 
> http://marc.info/?l=linux-kernel&m\x130833638508657&w=2
> But it doesn't apply anymore and after fixing a trivial merge conflict, it 
> fails to build, which is also trivially fixed. Please, add my
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

So I guess we can finally solve this issue, thanks.

On the other hand I just noticed the original patch didn't have Bruno's
Signed-off and a commit message was missing. So may I ask you, Bruno, to add
your Signed-off or preferably resend the version tested by Guennadi in the
appropriate patch format.


Thanks,

Florian Tobias Schandinat

> 
> to the set and use this updated version:
> 
> diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
> index 7d54e2c..647ba98 100644
> --- a/drivers/video/sh_mobile_hdmi.c
> +++ b/drivers/video/sh_mobile_hdmi.c
> @@ -1111,6 +1111,7 @@ static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate,
>  static void sh_hdmi_edid_work_fn(struct work_struct *work)
>  {
>  	struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work);
> +	struct fb_info *info;
>  	struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
>  	struct sh_mobile_lcdc_chan *ch;
>  	int ret;
> @@ -1123,8 +1124,9 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
>  
>  	mutex_lock(&hdmi->mutex);
>  
> +	info = hdmi->info;
> +
>  	if (hdmi->hp_state = HDMI_HOTPLUG_CONNECTED) {
> -		struct fb_info *info = hdmi->info;
>  		unsigned long parent_rate = 0, hdmi_rate;
>  
>  		ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate);
> @@ -1148,42 +1150,45 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
>  
>  		ch = info->par;
>  
> -		console_lock();
> +		if (lock_fb_info(info)) {
> +			console_lock();
>  
> -		/* HDMI plug in */
> -		if (!sh_hdmi_must_reconfigure(hdmi) &&
> -		    info->state = FBINFO_STATE_RUNNING) {
> -			/*
> -			 * First activation with the default monitor - just turn
> -			 * on, if we run a resume here, the logo disappears
> -			 */
> -			if (lock_fb_info(info)) {
> +			/* HDMI plug in */
> +			if (!sh_hdmi_must_reconfigure(hdmi) &&
> +			    info->state = FBINFO_STATE_RUNNING) {
> +				/*
> +				 * First activation with the default monitor - just turn
> +				 * on, if we run a resume here, the logo disappears
> +				 */
>  				info->var.width = hdmi->var.width;
>  				info->var.height = hdmi->var.height;
>  				sh_hdmi_display_on(hdmi, info);
> -				unlock_fb_info(info);
> +			} else {
> +				/* New monitor or have to wake up */
> +				fb_set_suspend(info, 0);
>  			}
> -		} else {
> -			/* New monitor or have to wake up */
> -			fb_set_suspend(info, 0);
> -		}
>  
> -		console_unlock();
> +			console_unlock();
> +			unlock_fb_info(info);
> +		}
>  	} else {
>  		ret = 0;
> -		if (!hdmi->info)
> +		if (!info)
>  			goto out;
>  
>  		hdmi->monspec.modedb_len = 0;
>  		fb_destroy_modedb(hdmi->monspec.modedb);
>  		hdmi->monspec.modedb = NULL;
>  
> -		console_lock();
> +		if (lock_fb_info(info)) {
> +			console_lock();
>  
> -		/* HDMI disconnect */
> -		fb_set_suspend(hdmi->info, 1);
> +			/* HDMI disconnect */
> +			fb_set_suspend(info, 1);
>  
> -		console_unlock();
> +			console_unlock();
> +			unlock_fb_info(info);
> +		}
>  	}
>  
>  out:
> 
> Thanks
> Guennadi
> 
>>
>>
>> Regards,
>>
>> Florian Tobias Schandinat
>>
>>
>> On 06/18/2011 09:19 AM, Bruno Prémont wrote:
>>> Guennadi, could you have a look at (completely untested) patch which avoids
>>> possible deadlock due to inverted lock taking order on hotplug as well
>>> as "readding" lock_fb_info() for fb_set_suspend() call after Herton's
>>> patch to fb_set_suspend().
>>>
>>> Thanks,
>>> Bruno
>>>
>>>
>>> On Sat, 18 June 2011 Bruno Prémont <bonbons@linux-vserver.org> wrote:
>>>> On Fri, 17 June 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:
>>>>> From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
>>>>>
>>>>> A lock ordering issue can cause deadlocks: in framebuffer/console code,
>>>>> all needed struct fb_info locks are taken before acquire_console_sem(),
>>>>> in places which need to take console semaphore.
>>>>>
>>>>> But fb_set_suspend is always called with console semaphore held, and
>>>>> inside it we call lock_fb_info which gets the fb_info lock, inverse
>>>>> locking order of what the rest of the code does. This causes a real
>>>>> deadlock issue, when we write to state fb sysfs attribute (which calls
>>>>> fb_set_suspend) while a framebuffer is being unregistered by
>>>>> remove_conflicting_framebuffers, as can be shown by following show
>>>>> blocked state trace on a test program which loads i915 and runs another
>>>>> forked processes writing to state attribute:
>>>>>
>>>>> Test process with semaphore held and trying to get fb_info lock:
>>>>
>>>> ...
>>>>
>>>>> fb-test2 which reproduces above is available on kernel.org bug #26232.
>>>>> To solve this issue, avoid calling lock_fb_info inside fb_set_suspend,
>>>>> and move it out to where needed (callers of fb_set_suspend must call
>>>>> lock_fb_info before if needed). So far, the only place which needs to
>>>>> call lock_fb_info is store_fbstate, all other places which calls
>>>>> fb_set_suspend are suspend/resume hooks that should not need the lock as
>>>>> they should be run only when processes are already frozen in
>>>>> suspend/resume.
>>>>
>>>> From a quick look through FB drivers in 2.6.39 I've found one that would need
>>>> more work:
>>>> - drivers/video/sh_mobile_hdmi.c: sh_hdmi_edid_work_fn()
>>>>   Should get changed to
>>>>   a) right locking order in case (hdmi->hp_state = HDMI_HOTPLUG_CONNECTED)
>>>>   b) lock fb_info in the other case
>>>>   For this one fb_set_suspend() does get call in a hotplug worker,
>>>>   thus independently on suspend/resume process.
>>>>
>>>> The rest does match the suspend/resume hook pattern mentioned.
>>>>
>>>> Bruno
>>>>
>>>>
>>>>> References: https://bugzilla.kernel.org/show_bug.cgi?id&232
>>>>> Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
>>>>> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
>>>>> Cc: stable@kernel.org
>>>>> ---
>>>>>  drivers/video/fbmem.c   |    3 ---
>>>>>  drivers/video/fbsysfs.c |    3 +++
>>>>>  2 files changed, 3 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
>>>>> index 5aac00e..ad93629 100644
>>>>> --- a/drivers/video/fbmem.c
>>>>> +++ b/drivers/video/fbmem.c
>>>>> @@ -1738,8 +1738,6 @@ void fb_set_suspend(struct fb_info *info, int state)
>>>>>  {
>>>>>  	struct fb_event event;
>>>>>  
>>>>> -	if (!lock_fb_info(info))
>>>>> -		return;
>>>>>  	event.info = info;
>>>>>  	if (state) {
>>>>>  		fb_notifier_call_chain(FB_EVENT_SUSPEND, &event);
>>>>> @@ -1748,7 +1746,6 @@ void fb_set_suspend(struct fb_info *info, int state)
>>>>>  		info->state = FBINFO_STATE_RUNNING;
>>>>>  		fb_notifier_call_chain(FB_EVENT_RESUME, &event);
>>>>>  	}
>>>>> -	unlock_fb_info(info);
>>>>>  }
>>>>>  
>>>>>  /**
>>>>> diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
>>>>> index 04251ce..67afa9c 100644
>>>>> --- a/drivers/video/fbsysfs.c
>>>>> +++ b/drivers/video/fbsysfs.c
>>>>> @@ -399,9 +399,12 @@ static ssize_t store_fbstate(struct device *device,
>>>>>  
>>>>>  	state = simple_strtoul(buf, &last, 0);
>>>>>  
>>>>> +	if (!lock_fb_info(fb_info))
>>>>> +		return -ENODEV;
>>>>>  	console_lock();
>>>>>  	fb_set_suspend(fb_info, (int)state);
>>>>>  	console_unlock();
>>>>> +	unlock_fb_info(fb_info);
>>>>>  
>>>>>  	return count;
>>>>>  }
>>>
>>>
>>> diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
>>> index 2b9e56a..b1a13ab 100644
>>> --- a/drivers/video/sh_mobile_hdmi.c
>>> +++ b/drivers/video/sh_mobile_hdmi.c
>>> @@ -1151,27 +1151,27 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
>>>  
>>>  		ch = info->par;
>>>  
>>> -		console_lock();
>>> +		if (lock_fb_info(info)) {
>>> +			console_lock();
>>>  
>>> -		/* HDMI plug in */
>>> -		if (!sh_hdmi_must_reconfigure(hdmi) &&
>>> -		    info->state = FBINFO_STATE_RUNNING) {
>>> -			/*
>>> -			 * First activation with the default monitor - just turn
>>> -			 * on, if we run a resume here, the logo disappears
>>> -			 */
>>> -			if (lock_fb_info(info)) {
>>> +			/* HDMI plug in */
>>> +			if (!sh_hdmi_must_reconfigure(hdmi) &&
>>> +			    info->state = FBINFO_STATE_RUNNING) {
>>> +				/*
>>> +				 * First activation with the default monitor - just turn
>>> +				 * on, if we run a resume here, the logo disappears
>>> +				 */
>>>  				info->var.width = hdmi->var.width;
>>>  				info->var.height = hdmi->var.height;
>>>  				sh_hdmi_display_on(hdmi, info);
>>> -				unlock_fb_info(info);
>>> +			} else {
>>> +				/* New monitor or have to wake up */
>>> +				fb_set_suspend(info, 0);
>>>  			}
>>> -		} else {
>>> -			/* New monitor or have to wake up */
>>> -			fb_set_suspend(info, 0);
>>> -		}
>>>  
>>> -		console_unlock();
>>> +			console_unlock();
>>> +			unlock_fb_info(info);
>>> +		}
>>>  	} else {
>>>  		ret = 0;
>>>  		if (!hdmi->info)
>>> @@ -1181,12 +1181,15 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
>>>  		fb_destroy_modedb(hdmi->monspec.modedb);
>>>  		hdmi->monspec.modedb = NULL;
>>>  
>>> -		console_lock();
>>> +		if (lock_fb_info(info)) {
>>> +			console_lock();
>>>  
>>> -		/* HDMI disconnect */
>>> -		fb_set_suspend(hdmi->info, 1);
>>> +			/* HDMI disconnect */
>>> +			fb_set_suspend(hdmi->info, 1);
>>>  
>>> -		console_unlock();
>>> +			console_unlock();
>>> +			unlock_fb_info(info);
>>> +		}
>>>  		pm_runtime_put(hdmi->dev);
>>>  	}
>>>  
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
> 
> ---
> Guennadi Liakhovetski, Ph.D.
> Freelance Open-Source Software Developer
> http://www.open-technology.de/
> 


^ permalink raw reply

* [PATCH] fb: sh-mobile: Fix deadlock risk between lock_fb_info() and
From: Bruno Prémont @ 2011-09-02 17:24 UTC (permalink / raw)
  To: Florian Tobias Schandinat
  Cc: Guennadi Liakhovetski, lethal, linux-fbdev, francis.moro,
	torvalds, linux-kernel, Herton Ronaldo Krzesinski, stable
In-Reply-To: <4E61086C.3050102@gmx.de>

Following on Herton's patch "fb: avoid possible deadlock caused by
fb_set_suspend" which moves lock_fb_info() out of fb_set_suspend()
to its callers, correct sh-mobile's locking around call to
fb_set_suspend() and the same sort of deaklocks with console_lock()
due to order of taking the lock.

console_lock() must be taken while fb_info is already locked and fb_info
must be locked while calling fb_set_suspend().

Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Hi Florian,

> On the other hand I just noticed the original patch didn't have
> Bruno's Signed-off and a commit message was missing. So may I ask you,
> Bruno, to add your Signed-off or preferably resend the version tested
> by Guennadi in the appropriate patch format.

Here it is with commit message and the Signed-off-by's.

Thanks,
Bruno




 drivers/video/sh_mobile_hdmi.c |   47 ++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index 7d54e2c..647ba98 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -1111,6 +1111,7 @@ static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate,
 static void sh_hdmi_edid_work_fn(struct work_struct *work)
 {
 	struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work);
+	struct fb_info *info;
 	struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
 	struct sh_mobile_lcdc_chan *ch;
 	int ret;
@@ -1123,8 +1124,9 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
 
 	mutex_lock(&hdmi->mutex);
 
+	info = hdmi->info;
+
 	if (hdmi->hp_state = HDMI_HOTPLUG_CONNECTED) {
-		struct fb_info *info = hdmi->info;
 		unsigned long parent_rate = 0, hdmi_rate;
 
 		ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate);
@@ -1148,42 +1150,45 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
 
 		ch = info->par;
 
-		console_lock();
+		if (lock_fb_info(info)) {
+			console_lock();
 
-		/* HDMI plug in */
-		if (!sh_hdmi_must_reconfigure(hdmi) &&
-		    info->state = FBINFO_STATE_RUNNING) {
-			/*
-			 * First activation with the default monitor - just turn
-			 * on, if we run a resume here, the logo disappears
-			 */
-			if (lock_fb_info(info)) {
+			/* HDMI plug in */
+			if (!sh_hdmi_must_reconfigure(hdmi) &&
+			    info->state = FBINFO_STATE_RUNNING) {
+				/*
+				 * First activation with the default monitor - just turn
+				 * on, if we run a resume here, the logo disappears
+				 */
 				info->var.width = hdmi->var.width;
 				info->var.height = hdmi->var.height;
 				sh_hdmi_display_on(hdmi, info);
-				unlock_fb_info(info);
+			} else {
+				/* New monitor or have to wake up */
+				fb_set_suspend(info, 0);
 			}
-		} else {
-			/* New monitor or have to wake up */
-			fb_set_suspend(info, 0);
-		}
 
-		console_unlock();
+			console_unlock();
+			unlock_fb_info(info);
+		}
 	} else {
 		ret = 0;
-		if (!hdmi->info)
+		if (!info)
 			goto out;
 
 		hdmi->monspec.modedb_len = 0;
 		fb_destroy_modedb(hdmi->monspec.modedb);
 		hdmi->monspec.modedb = NULL;
 
-		console_lock();
+		if (lock_fb_info(info)) {
+			console_lock();
 
-		/* HDMI disconnect */
-		fb_set_suspend(hdmi->info, 1);
+			/* HDMI disconnect */
+			fb_set_suspend(info, 1);
 
-		console_unlock();
+			console_unlock();
+			unlock_fb_info(info);
+		}
 	}
 
 out:

^ permalink raw reply related

* Re: [PATCH 6/6] fbdev: au1200fb: silence debug output
From: Florian Tobias Schandinat @ 2011-09-02 20:51 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1314974451-8535-7-git-send-email-manuel.lauss@googlemail.com>

On 09/02/2011 02:40 PM, Manuel Lauss wrote:
> it's annoying and takes up way too much space in dmesg.

...and is no longer needed, I guess.

I applied this patch.
As I merged Paul's old branch when I replaced it in linux-next I already had the
5 other patches.


Thanks,

Florian Tobias Schandinat

> 
> Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
> ---
>  drivers/video/au1200fb.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
> index ed5dcdb2..a19a40e 100644
> --- a/drivers/video/au1200fb.c
> +++ b/drivers/video/au1200fb.c
> @@ -49,7 +49,7 @@
>  #define DRIVER_NAME "au1200fb"
>  #define DRIVER_DESC "LCD controller driver for AU1200 processors"
>  
> -#define DEBUG 1
> +#define DEBUG 0
>  
>  #define print_err(f, arg...) printk(KERN_ERR DRIVER_NAME ": " f "\n", ## arg)
>  #define print_warn(f, arg...) printk(KERN_WARNING DRIVER_NAME ": " f "\n", ## arg)


^ permalink raw reply

* Re: [PATCH] fb: sh-mobile: Fix deadlock risk between lock_fb_info()
From: Florian Tobias Schandinat @ 2011-09-02 20:54 UTC (permalink / raw)
  To: Bruno Prémont
  Cc: Guennadi Liakhovetski, lethal, linux-fbdev, francis.moro,
	torvalds, linux-kernel, Herton Ronaldo Krzesinski, stable
In-Reply-To: <20110902192403.10f9cff7@neptune.home>

On 09/02/2011 05:24 PM, Bruno Prémont wrote:
> Following on Herton's patch "fb: avoid possible deadlock caused by
> fb_set_suspend" which moves lock_fb_info() out of fb_set_suspend()
> to its callers, correct sh-mobile's locking around call to
> fb_set_suspend() and the same sort of deaklocks with console_lock()
> due to order of taking the lock.
> 
> console_lock() must be taken while fb_info is already locked and fb_info
> must be locked while calling fb_set_suspend().
> 
> Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
> 
> Hi Florian,
> 
>> On the other hand I just noticed the original patch didn't have
>> Bruno's Signed-off and a commit message was missing. So may I ask you,
>> Bruno, to add your Signed-off or preferably resend the version tested
>> by Guennadi in the appropriate patch format.
> 
> Here it is with commit message and the Signed-off-by's.

Applied and added stable as Cc as I think this should be applied as well
whenever Herton's patch is applied.


Thanks,

Florian Tobias Schandinat

> 
> Thanks,
> Bruno
> 
> 
> 
> 
>  drivers/video/sh_mobile_hdmi.c |   47 ++++++++++++++++++++++-----------------
>  1 files changed, 26 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
> index 7d54e2c..647ba98 100644
> --- a/drivers/video/sh_mobile_hdmi.c
> +++ b/drivers/video/sh_mobile_hdmi.c
> @@ -1111,6 +1111,7 @@ static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate,
>  static void sh_hdmi_edid_work_fn(struct work_struct *work)
>  {
>  	struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work);
> +	struct fb_info *info;
>  	struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
>  	struct sh_mobile_lcdc_chan *ch;
>  	int ret;
> @@ -1123,8 +1124,9 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
>  
>  	mutex_lock(&hdmi->mutex);
>  
> +	info = hdmi->info;
> +
>  	if (hdmi->hp_state = HDMI_HOTPLUG_CONNECTED) {
> -		struct fb_info *info = hdmi->info;
>  		unsigned long parent_rate = 0, hdmi_rate;
>  
>  		ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate);
> @@ -1148,42 +1150,45 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
>  
>  		ch = info->par;
>  
> -		console_lock();
> +		if (lock_fb_info(info)) {
> +			console_lock();
>  
> -		/* HDMI plug in */
> -		if (!sh_hdmi_must_reconfigure(hdmi) &&
> -		    info->state = FBINFO_STATE_RUNNING) {
> -			/*
> -			 * First activation with the default monitor - just turn
> -			 * on, if we run a resume here, the logo disappears
> -			 */
> -			if (lock_fb_info(info)) {
> +			/* HDMI plug in */
> +			if (!sh_hdmi_must_reconfigure(hdmi) &&
> +			    info->state = FBINFO_STATE_RUNNING) {
> +				/*
> +				 * First activation with the default monitor - just turn
> +				 * on, if we run a resume here, the logo disappears
> +				 */
>  				info->var.width = hdmi->var.width;
>  				info->var.height = hdmi->var.height;
>  				sh_hdmi_display_on(hdmi, info);
> -				unlock_fb_info(info);
> +			} else {
> +				/* New monitor or have to wake up */
> +				fb_set_suspend(info, 0);
>  			}
> -		} else {
> -			/* New monitor or have to wake up */
> -			fb_set_suspend(info, 0);
> -		}
>  
> -		console_unlock();
> +			console_unlock();
> +			unlock_fb_info(info);
> +		}
>  	} else {
>  		ret = 0;
> -		if (!hdmi->info)
> +		if (!info)
>  			goto out;
>  
>  		hdmi->monspec.modedb_len = 0;
>  		fb_destroy_modedb(hdmi->monspec.modedb);
>  		hdmi->monspec.modedb = NULL;
>  
> -		console_lock();
> +		if (lock_fb_info(info)) {
> +			console_lock();
>  
> -		/* HDMI disconnect */
> -		fb_set_suspend(hdmi->info, 1);
> +			/* HDMI disconnect */
> +			fb_set_suspend(info, 1);
>  
> -		console_unlock();
> +			console_unlock();
> +			unlock_fb_info(info);
> +		}
>  	}
>  
>  out:
> 


^ permalink raw reply

* Re: [PATCH] video: mb862xx-i2c: fix for reliable decoder register
From: Florian Tobias Schandinat @ 2011-09-02 20:57 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1314892421-13471-1-git-send-email-agust@denx.de>

On 09/01/2011 03:53 PM, Anatolij Gustschin wrote:
> Increase delay when polling for tx status. This fixes
> the unreliable video decoder i2c register access.
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>

Looks good to me, applied.


Thanks,

Florian Tobias Schandinat

> ---
>  drivers/video/mb862xx/mb862xx-i2c.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/video/mb862xx/mb862xx-i2c.c b/drivers/video/mb862xx/mb862xx-i2c.c
> index b953099..934081d 100644
> --- a/drivers/video/mb862xx/mb862xx-i2c.c
> +++ b/drivers/video/mb862xx/mb862xx-i2c.c
> @@ -23,7 +23,7 @@ static int mb862xx_i2c_wait_event(struct i2c_adapter *adap)
>  	u32 reg;
>  
>  	do {
> -		udelay(1);
> +		udelay(10);
>  		reg = inreg(i2c, GC_I2C_BCR);
>  		if (reg & (I2C_INT | I2C_BER))
>  			break;


^ permalink raw reply

* [RFC v2] allow multiple concurrent visible displays
From: Florian Tobias Schandinat @ 2011-09-03  1:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-fbdev, Greg Kroah-Hartman, Dave Airlie, Arnd Bergmann,
	Bernie Thompson, Martin Decky, Florian Tobias Schandinat

Hi all,

this is the second version of my multi-display support.

Compared to the first version:
The bug reported in the first patch that prevented booting when 
"fbcon=cmap:01" was given is fixed (annoying NULL pointer in vc)
and a dummy vc_display_fg management was added to prevent 
modifying vc structures we do not "own".
The second patch is new and a hack that allows graphic and console 
applications to work concurrently.

Background:
At the moment only one display (in multi-display setups) will be 
updated when
(1) multiple console applications run on different displays
(2) a graphic application runs in the active vt on one display and a 
    console application on another display
(3) multiple graphic (framebuffer) applications run on different
    displays (usually)

The first patch fixes (1) and I'm pretty happy with it. Works well 
for me except rarely cursor visibility glitches but that might be a 
bug somewhere else.

(2) requires some sort of policy change. At the moment we forbid 
any console from working just because on one vt a graphic 
application started. Obviously that's not what I want and also not 
what most applications require. Therefore changing it to only allow 
the application to use the graphic resource associated with the vt 
it switches to KD_GRAPHIC seems reasonable to me. If there are 
concerns about compatiblity we could make this change an option or 
introduce a new KD_PGRAPHICS which behaves as I want (though the 
last one would be ugly and require changing all userspace to work).
My second patch gives this functionality but I do not expect it to 
be acceptable as is. At first I wanted to revert f700d6e5 but for 
some reason the result did not even boot so I hacked my way around 
it. Basically my question here aside the policy change is why do we 
blank when entering graphics mode and why do we not allow updates 
to other consoles when one is blanked?

(3) is a completly different beast which will probably require 
changes in userspace applications. Most framebuffer applications at 
the moment just access the framebuffer if they are in the current 
vt and stop on vt change. To make this working concurrently the 
applications would need a way to get a notification when its 
visibility changes. As this one requires much more work and thought 
than the (1) and (2) I'll at first concentrate on solving those.
But if anyone has any suggestions on this one I'd be verry happy.


Best regards,

Florian Tobias Schandinat


Florian Tobias Schandinat (2):
  fbdev: allow multiple concurrent visible consoles
  vt: dirty hack

 drivers/tty/vt/vt.c           |    4 +---
 drivers/video/console/fbcon.c |   34 ++++++++++++++++++++++++++++++----
 drivers/video/console/fbcon.h |    1 +
 3 files changed, 32 insertions(+), 7 deletions(-)


^ permalink raw reply

* [PATCH 1/2] fbdev: allow multiple concurrent visible consoles
From: Florian Tobias Schandinat @ 2011-09-03  1:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-fbdev, Greg Kroah-Hartman, Dave Airlie, Arnd Bergmann,
	Bernie Thompson, Martin Decky, Florian Tobias Schandinat
In-Reply-To: <1315013361-3191-1-git-send-email-FlorianSchandinat@gmx.de>

This patch allows having multiple visible consoles that receive
display updates. For example one can have running "top" to monitor
the system on fb0 and at the same time work on a shell on fb1.
At the moment that works only with consoles, not with console and
graphical application nor with two graphical applications.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
 drivers/video/console/fbcon.c |   34 ++++++++++++++++++++++++++++++----
 drivers/video/console/fbcon.h |    1 +
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 8745637..ce9a686 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -94,6 +94,7 @@ enum {
 };
 
 static struct display fb_display[MAX_NR_CONSOLES];
+static struct vc_data *dummy_fg;
 
 static signed char con2fb_map[MAX_NR_CONSOLES];
 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
@@ -816,7 +817,8 @@ static int set_con2fb_map(int unit, int newidx, int user)
 	int oldidx = con2fb_map[unit];
 	struct fb_info *info = registered_fb[newidx];
 	struct fb_info *oldinfo = NULL;
- 	int found, err = 0;
+	struct fbcon_ops *ops;
+	int found, err = 0, visible = vc && CON_IS_VISIBLE(vc);
 
 	if (oldidx = newidx)
 		return 0;
@@ -839,6 +841,15 @@ static int set_con2fb_map(int unit, int newidx, int user)
 	if (!err && !found)
  		err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
 
+	if (!err && vc && oldinfo && oldinfo->fbcon_par) {
+		ops = oldinfo->fbcon_par;
+		if (vc->vc_display_fg = &ops->vc_fg) {
+			if (CON_IS_VISIBLE(vc))
+				ops->vc_fg = NULL;
+
+			vc->vc_display_fg = &dummy_fg;
+		}
+	}
 
 	/*
 	 * If old fb is not mapped to any of the consoles,
@@ -852,6 +863,13 @@ static int set_con2fb_map(int unit, int newidx, int user)
  		int show_logo = (fg_console = 0 && !user &&
  				 logo_shown != FBCON_LOGO_DONTSHOW);
 
+		ops = info->fbcon_par;
+		if (!ops->vc_fg || visible)
+			ops->vc_fg = vc;
+
+		if (vc && vc->vc_display_fg = &dummy_fg)
+			vc->vc_display_fg = &ops->vc_fg;
+
  		if (!found)
  			fbcon_add_cursor_timer(info);
  		con2fb_map_boot[unit] = newidx;
@@ -1023,8 +1041,10 @@ static void fbcon_init(struct vc_data *vc, int init)
 	int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
 	int cap, ret;
 
-	if (info_idx = -1 || info = NULL)
-	    return;
+	if (info_idx = -1 || info = NULL) {
+		vc->vc_display_fg = &dummy_fg;
+		return;
+	}
 
 	cap = info->flags;
 
@@ -1089,6 +1109,10 @@ static void fbcon_init(struct vc_data *vc, int init)
 		con_copy_unimap(vc, svc);
 
 	ops = info->fbcon_par;
+	if (!ops->vc_fg)
+		ops->vc_fg = vc;
+
+	vc->vc_display_fg = &ops->vc_fg;
 	p->con_rotate = initial_rotation;
 	set_blitting_type(vc, info);
 
@@ -1184,8 +1208,10 @@ static void fbcon_deinit(struct vc_data *vc)
 	if (!ops)
 		goto finished;
 
-	if (CON_IS_VISIBLE(vc))
+	if (CON_IS_VISIBLE(vc)) {
 		fbcon_del_cursor_timer(info);
+		ops->vc_fg = NULL;
+	}
 
 	ops->flags &= ~FBCON_FLAGS_INIT;
 finished:
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index 6bd2e0c..adc7316 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -69,6 +69,7 @@ struct fbcon_ops {
 	struct timer_list cursor_timer; /* Cursor timer */
 	struct fb_cursor cursor_state;
 	struct display *p;
+	struct vc_data *vc_fg;
         int    currcon;	                /* Current VC. */
 	int    cursor_flash;
 	int    cursor_reset;
-- 
1.6.3.2


^ permalink raw reply related

* [PATCH 2/2] vt: dirty hack
From: Florian Tobias Schandinat @ 2011-09-03  1:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-fbdev, Greg Kroah-Hartman, Dave Airlie, Arnd Bergmann,
	Bernie Thompson, Martin Decky, Florian Tobias Schandinat
In-Reply-To: <1315013361-3191-1-git-send-email-FlorianSchandinat@gmx.de>

---
 drivers/tty/vt/vt.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index b3915b7..8332004 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3740,7 +3740,6 @@ void do_blank_screen(int entering_gfx)
 		hide_cursor(vc);
 		save_screen(vc);
 		vc->vc_sw->con_blank(vc, -1, 1);
-		console_blanked = fg_console + 1;
 		blank_state = blank_off;
 		set_origin(vc);
 		return;
@@ -3752,7 +3751,6 @@ void do_blank_screen(int entering_gfx)
 
 	/* don't blank graphics */
 	if (vc->vc_mode != KD_TEXT) {
-		console_blanked = fg_console + 1;
 		return;
 	}
 
@@ -3795,7 +3793,7 @@ void do_unblank_screen(int leaving_gfx)
 	WARN_CONSOLE_UNLOCKED();
 
 	ignore_poke = 0;
-	if (!console_blanked)
+	if (!console_blanked && !leaving_gfx)
 		return;
 	if (!vc_cons_allocated(fg_console)) {
 		/* impossible */
-- 
1.6.3.2


^ permalink raw reply related

* [RFC] fbdev: remove display subsystem
From: Florian Tobias Schandinat @ 2011-09-03  1:36 UTC (permalink / raw)
  To: linux-fbdev
  Cc: linux-kernel, Florian Tobias Schandinat, James Simmons,
	Andrew Morton

This four year old subsystem does not have a single in-tree user
not even in staging and as far as I know also none out-of-tree.
I think that justifies removing it which cleans the config up.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: James Simmons <jsimmons@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 drivers/video/Kconfig                 |    1 -
 drivers/video/Makefile                |    2 +-
 drivers/video/display/Kconfig         |   24 ----
 drivers/video/display/Makefile        |    6 -
 drivers/video/display/display-sysfs.c |  219 ---------------------------------
 include/linux/display.h               |   61 ---------
 6 files changed, 1 insertions(+), 312 deletions(-)
 delete mode 100644 drivers/video/display/Kconfig
 delete mode 100644 drivers/video/display/Makefile
 delete mode 100644 drivers/video/display/display-sysfs.c
 delete mode 100644 include/linux/display.h

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 903ace5..62048ea 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2397,7 +2397,6 @@ source "drivers/video/omap/Kconfig"
 source "drivers/video/omap2/Kconfig"
 
 source "drivers/video/backlight/Kconfig"
-source "drivers/video/display/Kconfig"
 
 if VT
 	source "drivers/video/console/Kconfig"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 4307910..67e05c3 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -13,7 +13,7 @@ fb-objs                           := $(fb-y)
 
 obj-$(CONFIG_VT)		  += console/
 obj-$(CONFIG_LOGO)		  += logo/
-obj-y				  += backlight/ display/
+obj-y				  += backlight/
 
 obj-$(CONFIG_FB_CFB_FILLRECT)  += cfbfillrect.o
 obj-$(CONFIG_FB_CFB_COPYAREA)  += cfbcopyarea.o
diff --git a/drivers/video/display/Kconfig b/drivers/video/display/Kconfig
deleted file mode 100644
index f99af93..0000000
--- a/drivers/video/display/Kconfig
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Display drivers configuration
-#
-
-menu "Display device support"
-
-config DISPLAY_SUPPORT
-	tristate "Display panel/monitor support"
-	---help---
-	  This framework adds support for low-level control of a display.
-	  This includes support for power.
-
-	  Enable this to be able to choose the drivers for controlling the
-	  physical display panel/monitor on some platforms. This not only
-	  covers LCD displays for PDAs but also other types of displays
-	  such as CRT, TVout etc.
-
-	  To have support for your specific display panel you will have to
-	  select the proper drivers which depend on this option.
-
-comment "Display hardware drivers"
-	depends on DISPLAY_SUPPORT
-
-endmenu
diff --git a/drivers/video/display/Makefile b/drivers/video/display/Makefile
deleted file mode 100644
index c0ea832..0000000
--- a/drivers/video/display/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# Display drivers
-
-display-objs				:= display-sysfs.o
-
-obj-$(CONFIG_DISPLAY_SUPPORT)		+= display.o
-
diff --git a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c
deleted file mode 100644
index 0c647d7..0000000
--- a/drivers/video/display/display-sysfs.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- *  display-sysfs.c - Display output driver sysfs interface
- *
- *  Copyright (C) 2007 James Simmons <jsimmons@infradead.org>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or (at
- *  your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-#include <linux/module.h>
-#include <linux/display.h>
-#include <linux/ctype.h>
-#include <linux/idr.h>
-#include <linux/err.h>
-#include <linux/kdev_t.h>
-#include <linux/slab.h>
-
-static ssize_t display_show_name(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	struct display_device *dsp = dev_get_drvdata(dev);
-	return snprintf(buf, PAGE_SIZE, "%s\n", dsp->name);
-}
-
-static ssize_t display_show_type(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	struct display_device *dsp = dev_get_drvdata(dev);
-	return snprintf(buf, PAGE_SIZE, "%s\n", dsp->type);
-}
-
-static ssize_t display_show_contrast(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	struct display_device *dsp = dev_get_drvdata(dev);
-	ssize_t rc = -ENXIO;
-
-	mutex_lock(&dsp->lock);
-	if (likely(dsp->driver) && dsp->driver->get_contrast)
-		rc = sprintf(buf, "%d\n", dsp->driver->get_contrast(dsp));
-	mutex_unlock(&dsp->lock);
-	return rc;
-}
-
-static ssize_t display_store_contrast(struct device *dev,
-					struct device_attribute *attr,
-					const char *buf, size_t count)
-{
-	struct display_device *dsp = dev_get_drvdata(dev);
-	ssize_t ret = -EINVAL, size;
-	int contrast;
-	char *endp;
-
-	contrast = simple_strtoul(buf, &endp, 0);
-	size = endp - buf;
-
-	if (isspace(*endp))
-		size++;
-
-	if (size != count)
-		return ret;
-
-	mutex_lock(&dsp->lock);
-	if (likely(dsp->driver && dsp->driver->set_contrast)) {
-		pr_debug("display: set contrast to %d\n", contrast);
-		dsp->driver->set_contrast(dsp, contrast);
-		ret = count;
-	}
-	mutex_unlock(&dsp->lock);
-	return ret;
-}
-
-static ssize_t display_show_max_contrast(struct device *dev,
-					struct device_attribute *attr,
-					char *buf)
-{
-	struct display_device *dsp = dev_get_drvdata(dev);
-	ssize_t rc = -ENXIO;
-
-	mutex_lock(&dsp->lock);
-	if (likely(dsp->driver))
-		rc = sprintf(buf, "%d\n", dsp->driver->max_contrast);
-	mutex_unlock(&dsp->lock);
-	return rc;
-}
-
-static struct device_attribute display_attrs[] = {
-	__ATTR(name, S_IRUGO, display_show_name, NULL),
-	__ATTR(type, S_IRUGO, display_show_type, NULL),
-	__ATTR(contrast, S_IRUGO | S_IWUSR, display_show_contrast, display_store_contrast),
-	__ATTR(max_contrast, S_IRUGO, display_show_max_contrast, NULL),
-};
-
-static int display_suspend(struct device *dev, pm_message_t state)
-{
-	struct display_device *dsp = dev_get_drvdata(dev);
-
-	mutex_lock(&dsp->lock);
-	if (likely(dsp->driver->suspend))
-		dsp->driver->suspend(dsp, state);
-	mutex_unlock(&dsp->lock);
-	return 0;
-};
-
-static int display_resume(struct device *dev)
-{
-	struct display_device *dsp = dev_get_drvdata(dev);
-
-	mutex_lock(&dsp->lock);
-	if (likely(dsp->driver->resume))
-		dsp->driver->resume(dsp);
-	mutex_unlock(&dsp->lock);
-	return 0;
-};
-
-static struct mutex allocated_dsp_lock;
-static DEFINE_IDR(allocated_dsp);
-static struct class *display_class;
-
-struct display_device *display_device_register(struct display_driver *driver,
-						struct device *parent, void *devdata)
-{
-	struct display_device *new_dev = NULL;
-	int ret = -EINVAL;
-
-	if (unlikely(!driver))
-		return ERR_PTR(ret);
-
-	mutex_lock(&allocated_dsp_lock);
-	ret = idr_pre_get(&allocated_dsp, GFP_KERNEL);
-	mutex_unlock(&allocated_dsp_lock);
-	if (!ret)
-		return ERR_PTR(ret);
-
-	new_dev = kzalloc(sizeof(struct display_device), GFP_KERNEL);
-	if (likely(new_dev) && unlikely(driver->probe(new_dev, devdata))) {
-		// Reserve the index for this display
-		mutex_lock(&allocated_dsp_lock);
-		ret = idr_get_new(&allocated_dsp, new_dev, &new_dev->idx);
-		mutex_unlock(&allocated_dsp_lock);
-
-		if (!ret) {
-			new_dev->dev = device_create(display_class, parent,
-						     MKDEV(0, 0), new_dev,
-						     "display%d", new_dev->idx);
-			if (!IS_ERR(new_dev->dev)) {
-				new_dev->parent = parent;
-				new_dev->driver = driver;
-				mutex_init(&new_dev->lock);
-				return new_dev;
-			}
-			mutex_lock(&allocated_dsp_lock);
-			idr_remove(&allocated_dsp, new_dev->idx);
-			mutex_unlock(&allocated_dsp_lock);
-			ret = -EINVAL;
-		}
-	}
-	kfree(new_dev);
-	return ERR_PTR(ret);
-}
-EXPORT_SYMBOL(display_device_register);
-
-void display_device_unregister(struct display_device *ddev)
-{
-	if (!ddev)
-		return;
-	// Free device
-	mutex_lock(&ddev->lock);
-	device_unregister(ddev->dev);
-	mutex_unlock(&ddev->lock);
-	// Mark device index as available
-	mutex_lock(&allocated_dsp_lock);
-	idr_remove(&allocated_dsp, ddev->idx);
-	mutex_unlock(&allocated_dsp_lock);
-	kfree(ddev);
-}
-EXPORT_SYMBOL(display_device_unregister);
-
-static int __init display_class_init(void)
-{
-	display_class = class_create(THIS_MODULE, "display");
-	if (IS_ERR(display_class)) {
-		printk(KERN_ERR "Failed to create display class\n");
-		display_class = NULL;
-		return -EINVAL;
-	}
-	display_class->dev_attrs = display_attrs;
-	display_class->suspend = display_suspend;
-	display_class->resume = display_resume;
-	mutex_init(&allocated_dsp_lock);
-	return 0;
-}
-
-static void __exit display_class_exit(void)
-{
-	class_destroy(display_class);
-}
-
-module_init(display_class_init);
-module_exit(display_class_exit);
-
-MODULE_DESCRIPTION("Display Hardware handling");
-MODULE_AUTHOR("James Simmons <jsimmons@infradead.org>");
-MODULE_LICENSE("GPL");
-
diff --git a/include/linux/display.h b/include/linux/display.h
deleted file mode 100644
index 3bf70d6..0000000
--- a/include/linux/display.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *  Copyright (C) 2006 James Simmons <jsimmons@infradead.org>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or (at
- *  your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-#ifndef _LINUX_DISPLAY_H
-#define _LINUX_DISPLAY_H
-
-#include <linux/device.h>
-
-struct display_device;
-
-/* This structure defines all the properties of a Display. */
-struct display_driver {
-	int  (*set_contrast)(struct display_device *, unsigned int);
-	int  (*get_contrast)(struct display_device *);
-	void (*suspend)(struct display_device *, pm_message_t state);
-	void (*resume)(struct display_device *);
-	int  (*probe)(struct display_device *, void *);
-	int  (*remove)(struct display_device *);
-	int  max_contrast;
-};
-
-struct display_device {
-	struct module *owner;			/* Owner module */
-	struct display_driver *driver;
-	struct device *parent;			/* This is the parent */
-	struct device *dev;			/* This is this display device */
-	struct mutex lock;
-	void *priv_data;
-	char type[16];
-	char *name;
-	int idx;
-};
-
-extern struct display_device *display_device_register(struct display_driver *driver,
-					struct device *dev, void *devdata);
-extern void display_device_unregister(struct display_device *dev);
-
-extern int probe_edid(struct display_device *dev, void *devdata);
-
-#define to_display_device(obj) container_of(obj, struct display_device, class_dev)
-
-#endif
-- 
1.7.2.5


^ permalink raw reply related

* Re: [PATCH 2/2] vt: dirty hack
From: Alan Cox @ 2011-09-03 10:25 UTC (permalink / raw)
  To: Florian Tobias Schandinat
  Cc: linux-kernel, linux-fbdev, Greg Kroah-Hartman, Dave Airlie,
	Arnd Bergmann, Bernie Thompson, Martin Decky
In-Reply-To: <1315013361-3191-3-git-send-email-FlorianSchandinat@gmx.de>

On Sat,  3 Sep 2011 01:29:21 +0000
Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:

All of the vt stuff wants doing properly not as hacks.

I think the fundamental change you need is to instroduce some sort of
vc->group pointer and vc group object that holds all the globals in the
vt layer for each group (ie move fg_console, console_blanked etc).

That can be done in steps, and once done you can then start to use
vc->group-> within the fbcon driver and possibly also have a per fb
group data attached to vc->group->fb or similar.

Hacks are fine for early prototyping but doing it right means thinking
about the data structures you ultimately need so that existing systems
work, multi-monitor continues to work and you can do proper multi-console
stuff.

I'm all for it happening done right, and some things like being able to
attach an fb console to arbitary GEM objects would allow very nice
integration of the console into things like Wayland.

Alan

^ permalink raw reply

* Re: [PATCH 2/2] vt: dirty hack
From: Florian Tobias Schandinat @ 2011-09-03 16:36 UTC (permalink / raw)
  To: Alan Cox
  Cc: Florian Tobias Schandinat, linux-kernel, linux-fbdev,
	Greg Kroah-Hartman, Dave Airlie, Arnd Bergmann, Bernie Thompson,
	Martin Decky
In-Reply-To: <20110903112542.5d3cbfcc@lxorguk.ukuu.org.uk>

Hi Alan,

On 09/03/2011 10:25 AM, Alan Cox wrote:
> On Sat,  3 Sep 2011 01:29:21 +0000
> Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:
> 
> All of the vt stuff wants doing properly not as hacks.
> 
> I think the fundamental change you need is to instroduce some sort of
> vc->group pointer and vc group object that holds all the globals in the
> vt layer for each group (ie move fg_console, console_blanked etc).

It sounds like a good idea. But I doubt that I need all of them for what
I want to achieve. For example, I think fg_console should be a console 
that gets keyboard data, but in my setup I have only one keyboard so that 
would not be needed. Note that the concept of visibility is already 
available for drivers via vc_display_fg which is used by CON_IS_VISIBLE()
my problem is just that it does not help if no updates are performed 
because everything is blanked (due to the lack of per display blanking).
Still your suggestion would be interesting to pursue later on to build 
multiple terminals, I guess Bernie would like that.

> That can be done in steps, and once done you can then start to use
> vc->group-> within the fbcon driver and possibly also have a per fb
> group data attached to vc->group->fb or similar.

Okay, I tried to implement this for blanking as it was already done for 
vc_display_fg, see the patch below. Does it look better?

> Hacks are fine for early prototyping but doing it right means thinking
> about the data structures you ultimately need so that existing systems
> work, multi-monitor continues to work and you can do proper multi-console
> stuff.
>
> I'm all for it happening done right, and some things like being able to
> attach an fb console to arbitary GEM objects would allow very nice
> integration of the console into things like Wayland.
> 
> Alan


Thanks,

Florian Tobias Schandinat


vt: allow per display blanking

At the moment blanking always affects all displays as it is done in
a global variable. This patch allows display driver to override it
and have their private blanking. The design is pretty much the same
as for vc_display_fg which is used for implementing per
driver/display visibility.
---
 drivers/tty/vt/vt.c            |   32 ++++++++++++++++----------------
 drivers/video/console/fbcon.c  |    9 ++++++---
 drivers/video/console/fbcon.h  |    1 +
 include/linux/console_struct.h |    1 +
 4 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index b3915b7..bc42f8e 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -277,7 +277,7 @@ static void notify_update(struct vc_data *vc)
 #ifdef VT_BUF_VRAM_ONLY
 #define DO_UPDATE(vc)	0
 #else
-#define DO_UPDATE(vc)	(CON_IS_VISIBLE(vc) && !console_blanked)
+#define DO_UPDATE(vc)	(CON_IS_VISIBLE(vc) && !*vc->vc_display_blanked)
 #endif
 
 static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed)
@@ -619,7 +619,7 @@ static void hide_cursor(struct vc_data *vc)
 
 static void set_cursor(struct vc_data *vc)
 {
-	if (!IS_FG(vc) || console_blanked ||
+	if (!IS_FG(vc) || *vc->vc_display_blanked ||
 	    vc->vc_mode = KD_GRAPHICS)
 		return;
 	if (vc->vc_deccm) {
@@ -753,6 +753,7 @@ static void visual_init(struct vc_data *vc, int num, int init)
 	__module_get(vc->vc_sw->owner);
 	vc->vc_num = num;
 	vc->vc_display_fg = &master_display_fg;
+	vc->vc_display_blanked = &console_blanked;
 	vc->vc_uni_pagedir_loc = &vc->vc_uni_pagedir;
 	vc->vc_uni_pagedir = 0;
 	vc->vc_hi_font_mask = 0;
@@ -2684,7 +2685,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
 			console_unlock();
 			break;
 		case TIOCL_BLANKEDSCREEN:
-			ret = console_blanked;
+			ret = *vc_cons[fg_console].d->vc_display_blanked;
 			break;
 		default:
 			ret = -EINVAL;
@@ -3454,9 +3455,9 @@ int con_debug_enter(struct vc_data *vc)
 	saved_last_console = last_console;
 	saved_want_console = want_console;
 	saved_vc_mode = vc->vc_mode;
-	saved_console_blanked = console_blanked;
+	saved_console_blanked = *vc->vc_display_blanked;
 	vc->vc_mode = KD_TEXT;
-	console_blanked = 0;
+	*vc->vc_display_blanked = 0;
 	if (vc->vc_sw->con_debug_enter)
 		ret = vc->vc_sw->con_debug_enter(vc);
 #ifdef CONFIG_KGDB_KDB
@@ -3498,10 +3499,9 @@ int con_debug_leave(void)
 	fg_console = saved_fg_console;
 	last_console = saved_last_console;
 	want_console = saved_want_console;
-	console_blanked = saved_console_blanked;
-	vc_cons[fg_console].d->vc_mode = saved_vc_mode;
-
 	vc = vc_cons[fg_console].d;
+	*vc->vc_display_blanked = saved_console_blanked;
+	vc->vc_mode = saved_vc_mode;
 	if (vc->vc_sw->con_debug_leave)
 		ret = vc->vc_sw->con_debug_leave(vc);
 	return ret;
@@ -3727,7 +3727,7 @@ void do_blank_screen(int entering_gfx)
 
 	WARN_CONSOLE_UNLOCKED();
 
-	if (console_blanked) {
+	if (*vc->vc_display_blanked) {
 		if (blank_state = blank_vesa_wait) {
 			blank_state = blank_off;
 			vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0);
@@ -3740,7 +3740,7 @@ void do_blank_screen(int entering_gfx)
 		hide_cursor(vc);
 		save_screen(vc);
 		vc->vc_sw->con_blank(vc, -1, 1);
-		console_blanked = fg_console + 1;
+		*vc->vc_display_blanked = fg_console + 1;
 		blank_state = blank_off;
 		set_origin(vc);
 		return;
@@ -3752,7 +3752,7 @@ void do_blank_screen(int entering_gfx)
 
 	/* don't blank graphics */
 	if (vc->vc_mode != KD_TEXT) {
-		console_blanked = fg_console + 1;
+		*vc->vc_display_blanked = fg_console + 1;
 		return;
 	}
 
@@ -3763,7 +3763,7 @@ void do_blank_screen(int entering_gfx)
 	save_screen(vc);
 	/* In case we need to reset origin, blanking hook returns 1 */
 	i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0);
-	console_blanked = fg_console + 1;
+	*vc->vc_display_blanked = fg_console + 1;
 	if (i)
 		set_origin(vc);
 
@@ -3795,8 +3795,6 @@ void do_unblank_screen(int leaving_gfx)
 	WARN_CONSOLE_UNLOCKED();
 
 	ignore_poke = 0;
-	if (!console_blanked)
-		return;
 	if (!vc_cons_allocated(fg_console)) {
 		/* impossible */
 		pr_warning("unblank_screen: tty %d not allocated ??\n",
@@ -3804,6 +3802,8 @@ void do_unblank_screen(int leaving_gfx)
 		return;
 	}
 	vc = vc_cons[fg_console].d;
+	if (!*vc->vc_display_blanked)
+		return;
 	/* Try to unblank in oops case too */
 	if (vc->vc_mode != KD_TEXT && !vt_force_oops_output(vc))
 		return; /* but leave console_blanked != 0 */
@@ -3813,7 +3813,7 @@ void do_unblank_screen(int leaving_gfx)
 		blank_state = blank_normal_wait;
 	}
 
-	console_blanked = 0;
+	*vc->vc_display_blanked = 0;
 	if (vc->vc_sw->con_blank(vc, 0, leaving_gfx) || vt_force_oops_output(vc))
 		/* Low-level driver cannot restore -> do it ourselves */
 		update_screen(vc);
@@ -3871,7 +3871,7 @@ void poke_blanked_console(void)
 
 	if (ignore_poke || !vc_cons[fg_console].d || vc_cons[fg_console].d->vc_mode = KD_GRAPHICS)
 		return;
-	if (console_blanked)
+	if (*vc_cons[fg_console].d->vc_display_blanked)
 		unblank_screen();
 	else if (blankinterval) {
 		mod_timer(&console_timer, jiffies + (blankinterval * HZ));
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index ce9a686..bb2bc13 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -294,7 +294,7 @@ static int get_color(struct vc_data *vc, struct fb_info *info,
 	int depth = fb_get_color_depth(&info->var, &info->fix);
 	int color = 0;
 
-	if (console_blanked) {
+	if (*vc->vc_display_blanked) {
 		unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
 
 		c = vc->vc_video_erase_char & charmask;
@@ -312,7 +312,7 @@ static int get_color(struct vc_data *vc, struct fb_info *info,
 		int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0;
 		int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col;
 
-		if (console_blanked)
+		if (*vc->vc_display_blanked)
 			fg = bg;
 
 		color = (is_fg) ? fg : bg;
@@ -867,8 +867,10 @@ static int set_con2fb_map(int unit, int newidx, int user)
 		if (!ops->vc_fg || visible)
 			ops->vc_fg = vc;
 
-		if (vc && vc->vc_display_fg = &dummy_fg)
+		if (vc && vc->vc_display_fg = &dummy_fg) {
 			vc->vc_display_fg = &ops->vc_fg;
+			vc->vc_display_blanked = &ops->vc_blanked;
+		}
 
  		if (!found)
  			fbcon_add_cursor_timer(info);
@@ -1113,6 +1115,7 @@ static void fbcon_init(struct vc_data *vc, int init)
 		ops->vc_fg = vc;
 
 	vc->vc_display_fg = &ops->vc_fg;
+	vc->vc_display_blanked = &ops->vc_blanked;
 	p->con_rotate = initial_rotation;
 	set_blitting_type(vc, info);
 
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index adc7316..8d5f173 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -70,6 +70,7 @@ struct fbcon_ops {
 	struct fb_cursor cursor_state;
 	struct display *p;
 	struct vc_data *vc_fg;
+	int    vc_blanked;
         int    currcon;	                /* Current VC. */
 	int    cursor_flash;
 	int    cursor_reset;
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index 7f0c329..086e623 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -104,6 +104,7 @@ struct vc_data {
 	unsigned int	vc_bell_pitch;		/* Console bell pitch */
 	unsigned int	vc_bell_duration;	/* Console bell duration */
 	struct vc_data **vc_display_fg;		/* [!] Ptr to var holding fg console for this display */
+		 int	*vc_display_blanked;
 	unsigned long	vc_uni_pagedir;
 	unsigned long	*vc_uni_pagedir_loc;  /* [!] Location of uni_pagedir variable for this console */
 	bool vc_panic_force_write; /* when oops/panic this VC can accept forced output/blanking */
-- 
1.6.3.2


^ permalink raw reply related

* Re: [PATCH] Add support for SMSC UFX6000/7000 USB display adapters
From: Florian Tobias Schandinat @ 2011-09-05 17:07 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1313150823-2527-1-git-send-email-steve.glendinning@smsc.com>

On 08/18/2011 02:20 PM, Steve Glendinning wrote:
> This patch adds framebuffer suport for SMSC's UFX6000 (USB 2.0) and
> UFX7000 (USB 3.0) display adapters.
> 
> Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>

Um, you silently ignored my comments about missing comments for understanding
the values used in ufx_config_sys_clk and ufx_config_ddr2, the inefficient PLL
calculation (well, at least it is good documented the way it is) and there are
still a lot of casts in ufx_raw_rect. That does not necessarily mean you have to
change it but it would have helped if you explained why you do things the way
you do them.
Anyway, as those are just cosmetic or efficiency issues and you fixed the
important things, I applied this patch.


Regards,

Florian Tobias Schandinat


PS: do not send HTML e-mails, most people and lists here will drop them as spam


> ---
>  MAINTAINERS             |    6 +
>  drivers/video/Kconfig   |   16 +
>  drivers/video/Makefile  |    1 +
>  drivers/video/smscufx.c | 1994 +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 2017 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/video/smscufx.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1d445f5..e7b6b6d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5920,6 +5920,12 @@ L:	netdev@vger.kernel.org
>  S:	Supported
>  F:	drivers/net/smsc9420.*
>  
> +SMSC UFX6000 and UFX7000 USB to VGA DRIVER
> +M:	Steve Glendinning <steve.glendinning@smsc.com>
> +L:	linux-fbdev@vger.kernel.org
> +S:	Supported
> +F:	drivers/video/smscufx.c
> +
>  SN-IA64 (Itanium) SUB-PLATFORM
>  M:	Jes Sorensen <jes@sgi.com>
>  L:	linux-altix@sgi.com
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 549b960..8bfb387 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -2110,6 +2110,22 @@ config FB_SM501
>  
>  	  If unsure, say N.
>  
> +config FB_SMSCUFX
> +	tristate "SMSC UFX6000/7000 USB Framebuffer support"
> +	depends on FB && USB
> +	select FB_MODE_HELPERS
> +	select FB_SYS_FILLRECT
> +	select FB_SYS_COPYAREA
> +	select FB_SYS_IMAGEBLIT
> +	select FB_SYS_FOPS
> +	select FB_DEFERRED_IO
> +	---help---
> +	  This is a kernel framebuffer driver for SMSC UFX USB devices.
> +	  Supports fbdev clients like xf86-video-fbdev, kdrive, fbi, and
> +	  mplayer -vo fbdev. Supports both UFX6000 (USB 2.0) and UFX7000
> +	  (USB 3.0) devices.
> +	  To compile as a module, choose M here: the module name is smscufx.
> +
>  config FB_UDL
>  	tristate "Displaylink USB Framebuffer support"
>  	depends on FB && USB
> diff --git a/drivers/video/Makefile b/drivers/video/Makefile
> index 8b83129..f3546ec 100644
> --- a/drivers/video/Makefile
> +++ b/drivers/video/Makefile
> @@ -127,6 +127,7 @@ obj-$(CONFIG_FB_IBM_GXT4500)	  += gxt4500.o
>  obj-$(CONFIG_FB_PS3)		  += ps3fb.o
>  obj-$(CONFIG_FB_SM501)            += sm501fb.o
>  obj-$(CONFIG_FB_UDL)		  += udlfb.o
> +obj-$(CONFIG_FB_SMSCUFX)	  += smscufx.o
>  obj-$(CONFIG_FB_XILINX)           += xilinxfb.o
>  obj-$(CONFIG_SH_MIPI_DSI)	  += sh_mipi_dsi.o
>  obj-$(CONFIG_FB_SH_MOBILE_HDMI)	  += sh_mobile_hdmi.o
> diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
> new file mode 100644
> index 0000000..c6b86e7
> --- /dev/null
> +++ b/drivers/video/smscufx.c
> @@ -0,0 +1,1994 @@
> +/*
> + * smscufx.c -- Framebuffer driver for SMSC UFX USB controller
> + *
> + * Copyright (C) 2011 Steve Glendinning <steve.glendinning@smsc.com>
> + * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it>
> + * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com>
> + * Copyright (C) 2009 Bernie Thompson <bernie@plugable.com>
> + *
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License v2. See the file COPYING in the main directory of this archive for
> + * more details.
> + *
> + * Based on udlfb, with work from Florian Echtler, Henrik Bjerregaard Pedersen,
> + * and others.
> + *
> + * Works well with Bernie Thompson's X DAMAGE patch to xf86-video-fbdev
> + * available from http://git.plugable.com
> + *
> + * Layout is based on skeletonfb by James Simmons and Geert Uytterhoeven,
> + * usb-skeleton by GregKH.
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/usb.h>
> +#include <linux/uaccess.h>
> +#include <linux/mm.h>
> +#include <linux/fb.h>
> +#include <linux/vmalloc.h>
> +#include <linux/slab.h>
> +#include <linux/delay.h>
> +#include "edid.h"
> +
> +#define check_warn(status, fmt, args...) \
> +	({ if (status < 0) pr_warn(fmt, ##args); })
> +
> +#define check_warn_return(status, fmt, args...) \
> +	({ if (status < 0) { pr_warn(fmt, ##args); return status; } })
> +
> +#define check_warn_goto_error(status, fmt, args...) \
> +	({ if (status < 0) { pr_warn(fmt, ##args); goto error; } })
> +
> +#define all_bits_set(x, bits) (((x) & (bits)) = (bits))
> +
> +#define USB_VENDOR_REQUEST_WRITE_REGISTER	0xA0
> +#define USB_VENDOR_REQUEST_READ_REGISTER	0xA1
> +
> +/*
> + * TODO: Propose standard fb.h ioctl for reporting damage,
> + * using _IOWR() and one of the existing area structs from fb.h
> + * Consider these ioctls deprecated, but they're still used by the
> + * DisplayLink X server as yet - need both to be modified in tandem
> + * when new ioctl(s) are ready.
> + */
> +#define UFX_IOCTL_RETURN_EDID	(0xAD)
> +#define UFX_IOCTL_REPORT_DAMAGE	(0xAA)
> +
> +/* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */
> +#define BULK_SIZE		(512)
> +#define MAX_TRANSFER		(PAGE_SIZE*16 - BULK_SIZE)
> +#define WRITES_IN_FLIGHT	(4)
> +
> +#define GET_URB_TIMEOUT		(HZ)
> +#define FREE_URB_TIMEOUT	(HZ*2)
> +
> +#define BPP			2
> +
> +#define UFX_DEFIO_WRITE_DELAY	5 /* fb_deferred_io.delay in jiffies */
> +#define UFX_DEFIO_WRITE_DISABLE	(HZ*60) /* "disable" with long delay */
> +
> +struct dloarea {
> +	int x, y;
> +	int w, h;
> +};
> +
> +struct urb_node {
> +	struct list_head entry;
> +	struct ufx_data *dev;
> +	struct delayed_work release_urb_work;
> +	struct urb *urb;
> +};
> +
> +struct urb_list {
> +	struct list_head list;
> +	spinlock_t lock;
> +	struct semaphore limit_sem;
> +	int available;
> +	int count;
> +	size_t size;
> +};
> +
> +struct ufx_data {
> +	struct usb_device *udev;
> +	struct device *gdev; /* &udev->dev */
> +	struct fb_info *info;
> +	struct urb_list urbs;
> +	struct kref kref;
> +	int fb_count;
> +	bool virtualized; /* true when physical usb device not present */
> +	struct delayed_work free_framebuffer_work;
> +	atomic_t usb_active; /* 0 = update virtual buffer, but no usb traffic */
> +	atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */
> +	char *edid; /* null until we read edid from hw or get from sysfs */
> +	size_t edid_size;
> +	u32 pseudo_palette[256];
> +};
> +
> +static struct fb_fix_screeninfo ufx_fix = {
> +	.id =           "smscufx",
> +	.type =         FB_TYPE_PACKED_PIXELS,
> +	.visual =       FB_VISUAL_TRUECOLOR,
> +	.xpanstep =     0,
> +	.ypanstep =     0,
> +	.ywrapstep =    0,
> +	.accel =        FB_ACCEL_NONE,
> +};
> +
> +static const u32 smscufx_info_flags = FBINFO_DEFAULT | FBINFO_READS_FAST |
> +	FBINFO_VIRTFB |	FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_FILLRECT |
> +	FBINFO_HWACCEL_COPYAREA | FBINFO_MISC_ALWAYS_SETPAR;
> +
> +static struct usb_device_id id_table[] = {
> +	{USB_DEVICE(0x0424, 0x9d00),},
> +	{USB_DEVICE(0x0424, 0x9d01),},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(usb, id_table);
> +
> +/* module options */
> +static int console;   /* Optionally allow fbcon to consume first framebuffer */
> +static int fb_defio = true;  /* Optionally enable fb_defio mmap support */
> +
> +/* ufx keeps a list of urbs for efficient bulk transfers */
> +static void ufx_urb_completion(struct urb *urb);
> +static struct urb *ufx_get_urb(struct ufx_data *dev);
> +static int ufx_submit_urb(struct ufx_data *dev, struct urb * urb, size_t len);
> +static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size);
> +static void ufx_free_urb_list(struct ufx_data *dev);
> +
> +/* reads a control register */
> +static int ufx_reg_read(struct ufx_data *dev, u32 index, u32 *data)
> +{
> +	u32 *buf = kmalloc(4, GFP_KERNEL);
> +	int ret;
> +
> +	BUG_ON(!dev);
> +
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
> +		USB_VENDOR_REQUEST_READ_REGISTER,
> +		USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> +		00, index, buf, 4, USB_CTRL_GET_TIMEOUT);
> +
> +	le32_to_cpus(buf);
> +	*data = *buf;
> +	kfree(buf);
> +
> +	if (unlikely(ret < 0))
> +		pr_warn("Failed to read register index 0x%08x\n", index);
> +
> +	return ret;
> +}
> +
> +/* writes a control register */
> +static int ufx_reg_write(struct ufx_data *dev, u32 index, u32 data)
> +{
> +	u32 *buf = kmalloc(4, GFP_KERNEL);
> +	int ret;
> +
> +	BUG_ON(!dev);
> +
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	*buf = data;
> +	cpu_to_le32s(buf);
> +
> +	ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
> +		USB_VENDOR_REQUEST_WRITE_REGISTER,
> +		USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> +		00, index, buf, 4, USB_CTRL_SET_TIMEOUT);
> +
> +	kfree(buf);
> +
> +	if (unlikely(ret < 0))
> +		pr_warn("Failed to write register index 0x%08x with value "
> +			"0x%08x\n", index, data);
> +
> +	return ret;
> +}
> +
> +static int ufx_reg_clear_and_set_bits(struct ufx_data *dev, u32 index,
> +	u32 bits_to_clear, u32 bits_to_set)
> +{
> +	u32 data;
> +	int status = ufx_reg_read(dev, index, &data);
> +	check_warn_return(status, "ufx_reg_clear_and_set_bits error reading "
> +		"0x%x", index);
> +
> +	data &= (~bits_to_clear);
> +	data |= bits_to_set;
> +
> +	status = ufx_reg_write(dev, index, data);
> +	check_warn_return(status, "ufx_reg_clear_and_set_bits error writing "
> +		"0x%x", index);
> +
> +	return 0;
> +}
> +
> +static int ufx_reg_set_bits(struct ufx_data *dev, u32 index, u32 bits)
> +{
> +	return ufx_reg_clear_and_set_bits(dev, index, 0, bits);
> +}
> +
> +static int ufx_reg_clear_bits(struct ufx_data *dev, u32 index, u32 bits)
> +{
> +	return ufx_reg_clear_and_set_bits(dev, index, bits, 0);
> +}
> +
> +static int ufx_lite_reset(struct ufx_data *dev)
> +{
> +	int status;
> +	u32 value;
> +
> +	status = ufx_reg_write(dev, 0x3008, 0x00000001);
> +	check_warn_return(status, "ufx_lite_reset error writing 0x3008");
> +
> +	status = ufx_reg_read(dev, 0x3008, &value);
> +	check_warn_return(status, "ufx_lite_reset error reading 0x3008");
> +
> +	return (value = 0) ? 0 : -EIO;
> +}
> +
> +/* If display is unblanked, then blank it */
> +static int ufx_blank(struct ufx_data *dev, bool wait)
> +{
> +	u32 dc_ctrl, dc_sts;
> +	int i;
> +
> +	int status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +	check_warn_return(status, "ufx_blank error reading 0x2004");
> +
> +	status = ufx_reg_read(dev, 0x2000, &dc_ctrl);
> +	check_warn_return(status, "ufx_blank error reading 0x2000");
> +
> +	/* return success if display is already blanked */
> +	if ((dc_sts & 0x00000100) || (dc_ctrl & 0x00000100))
> +		return 0;
> +
> +	/* request the DC to blank the display */
> +	dc_ctrl |= 0x00000100;
> +	status = ufx_reg_write(dev, 0x2000, dc_ctrl);
> +	check_warn_return(status, "ufx_blank error writing 0x2000");
> +
> +	/* return success immediately if we don't have to wait */
> +	if (!wait)
> +		return 0;
> +
> +	for (i = 0; i < 250; i++) {
> +		status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +		check_warn_return(status, "ufx_blank error reading 0x2004");
> +
> +		if (dc_sts & 0x00000100)
> +			return 0;
> +	}
> +
> +	/* timed out waiting for display to blank */
> +	return -EIO;
> +}
> +
> +/* If display is blanked, then unblank it */
> +static int ufx_unblank(struct ufx_data *dev, bool wait)
> +{
> +	u32 dc_ctrl, dc_sts;
> +	int i;
> +
> +	int status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +	check_warn_return(status, "ufx_unblank error reading 0x2004");
> +
> +	status = ufx_reg_read(dev, 0x2000, &dc_ctrl);
> +	check_warn_return(status, "ufx_unblank error reading 0x2000");
> +
> +	/* return success if display is already unblanked */
> +	if (((dc_sts & 0x00000100) = 0) || ((dc_ctrl & 0x00000100) = 0))
> +		return 0;
> +
> +	/* request the DC to unblank the display */
> +	dc_ctrl &= ~0x00000100;
> +	status = ufx_reg_write(dev, 0x2000, dc_ctrl);
> +	check_warn_return(status, "ufx_unblank error writing 0x2000");
> +
> +	/* return success immediately if we don't have to wait */
> +	if (!wait)
> +		return 0;
> +
> +	for (i = 0; i < 250; i++) {
> +		status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +		check_warn_return(status, "ufx_unblank error reading 0x2004");
> +
> +		if ((dc_sts & 0x00000100) = 0)
> +			return 0;
> +	}
> +
> +	/* timed out waiting for display to unblank */
> +	return -EIO;
> +}
> +
> +/* If display is enabled, then disable it */
> +static int ufx_disable(struct ufx_data *dev, bool wait)
> +{
> +	u32 dc_ctrl, dc_sts;
> +	int i;
> +
> +	int status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +	check_warn_return(status, "ufx_disable error reading 0x2004");
> +
> +	status = ufx_reg_read(dev, 0x2000, &dc_ctrl);
> +	check_warn_return(status, "ufx_disable error reading 0x2000");
> +
> +	/* return success if display is already disabled */
> +	if (((dc_sts & 0x00000001) = 0) || ((dc_ctrl & 0x00000001) = 0))
> +		return 0;
> +
> +	/* request the DC to disable the display */
> +	dc_ctrl &= ~(0x00000001);
> +	status = ufx_reg_write(dev, 0x2000, dc_ctrl);
> +	check_warn_return(status, "ufx_disable error writing 0x2000");
> +
> +	/* return success immediately if we don't have to wait */
> +	if (!wait)
> +		return 0;
> +
> +	for (i = 0; i < 250; i++) {
> +		status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +		check_warn_return(status, "ufx_disable error reading 0x2004");
> +
> +		if ((dc_sts & 0x00000001) = 0)
> +			return 0;
> +	}
> +
> +	/* timed out waiting for display to disable */
> +	return -EIO;
> +}
> +
> +/* If display is disabled, then enable it */
> +static int ufx_enable(struct ufx_data *dev, bool wait)
> +{
> +	u32 dc_ctrl, dc_sts;
> +	int i;
> +
> +	int status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +	check_warn_return(status, "ufx_enable error reading 0x2004");
> +
> +	status = ufx_reg_read(dev, 0x2000, &dc_ctrl);
> +	check_warn_return(status, "ufx_enable error reading 0x2000");
> +
> +	/* return success if display is already enabled */
> +	if ((dc_sts & 0x00000001) || (dc_ctrl & 0x00000001))
> +		return 0;
> +
> +	/* request the DC to enable the display */
> +	dc_ctrl |= 0x00000001;
> +	status = ufx_reg_write(dev, 0x2000, dc_ctrl);
> +	check_warn_return(status, "ufx_enable error writing 0x2000");
> +
> +	/* return success immediately if we don't have to wait */
> +	if (!wait)
> +		return 0;
> +
> +	for (i = 0; i < 250; i++) {
> +		status = ufx_reg_read(dev, 0x2004, &dc_sts);
> +		check_warn_return(status, "ufx_enable error reading 0x2004");
> +
> +		if (dc_sts & 0x00000001)
> +			return 0;
> +	}
> +
> +	/* timed out waiting for display to enable */
> +	return -EIO;
> +}
> +
> +static int ufx_config_sys_clk(struct ufx_data *dev)
> +{
> +	int status = ufx_reg_write(dev, 0x700C, 0x8000000F);
> +	check_warn_return(status, "error writing 0x700C");
> +
> +	status = ufx_reg_write(dev, 0x7014, 0x0010024F);
> +	check_warn_return(status, "error writing 0x7014");
> +
> +	status = ufx_reg_write(dev, 0x7010, 0x00000000);
> +	check_warn_return(status, "error writing 0x7010");
> +
> +	status = ufx_reg_clear_bits(dev, 0x700C, 0x0000000A);
> +	check_warn_return(status, "error clearing PLL1 bypass in 0x700C");
> +	msleep(1);
> +
> +	status = ufx_reg_clear_bits(dev, 0x700C, 0x80000000);
> +	check_warn_return(status, "error clearing output gate in 0x700C");
> +
> +	return 0;
> +}
> +
> +static int ufx_config_ddr2(struct ufx_data *dev)
> +{
> +	int status, i = 0;
> +	u32 tmp;
> +
> +	status = ufx_reg_write(dev, 0x0004, 0x001F0F77);
> +	check_warn_return(status, "error writing 0x0004");
> +
> +	status = ufx_reg_write(dev, 0x0008, 0xFFF00000);
> +	check_warn_return(status, "error writing 0x0008");
> +
> +	status = ufx_reg_write(dev, 0x000C, 0x0FFF2222);
> +	check_warn_return(status, "error writing 0x000C");
> +
> +	status = ufx_reg_write(dev, 0x0010, 0x00030814);
> +	check_warn_return(status, "error writing 0x0010");
> +
> +	status = ufx_reg_write(dev, 0x0014, 0x00500019);
> +	check_warn_return(status, "error writing 0x0014");
> +
> +	status = ufx_reg_write(dev, 0x0018, 0x020D0F15);
> +	check_warn_return(status, "error writing 0x0018");
> +
> +	status = ufx_reg_write(dev, 0x001C, 0x02532305);
> +	check_warn_return(status, "error writing 0x001C");
> +
> +	status = ufx_reg_write(dev, 0x0020, 0x0B030905);
> +	check_warn_return(status, "error writing 0x0020");
> +
> +	status = ufx_reg_write(dev, 0x0024, 0x00000827);
> +	check_warn_return(status, "error writing 0x0024");
> +
> +	status = ufx_reg_write(dev, 0x0028, 0x00000000);
> +	check_warn_return(status, "error writing 0x0028");
> +
> +	status = ufx_reg_write(dev, 0x002C, 0x00000042);
> +	check_warn_return(status, "error writing 0x002C");
> +
> +	status = ufx_reg_write(dev, 0x0030, 0x09520000);
> +	check_warn_return(status, "error writing 0x0030");
> +
> +	status = ufx_reg_write(dev, 0x0034, 0x02223314);
> +	check_warn_return(status, "error writing 0x0034");
> +
> +	status = ufx_reg_write(dev, 0x0038, 0x00430043);
> +	check_warn_return(status, "error writing 0x0038");
> +
> +	status = ufx_reg_write(dev, 0x003C, 0xF00F000F);
> +	check_warn_return(status, "error writing 0x003C");
> +
> +	status = ufx_reg_write(dev, 0x0040, 0xF380F00F);
> +	check_warn_return(status, "error writing 0x0040");
> +
> +	status = ufx_reg_write(dev, 0x0044, 0xF00F0496);
> +	check_warn_return(status, "error writing 0x0044");
> +
> +	status = ufx_reg_write(dev, 0x0048, 0x03080406);
> +	check_warn_return(status, "error writing 0x0048");
> +
> +	status = ufx_reg_write(dev, 0x004C, 0x00001000);
> +	check_warn_return(status, "error writing 0x004C");
> +
> +	status = ufx_reg_write(dev, 0x005C, 0x00000007);
> +	check_warn_return(status, "error writing 0x005C");
> +
> +	status = ufx_reg_write(dev, 0x0100, 0x54F00012);
> +	check_warn_return(status, "error writing 0x0100");
> +
> +	status = ufx_reg_write(dev, 0x0104, 0x00004012);
> +	check_warn_return(status, "error writing 0x0104");
> +
> +	status = ufx_reg_write(dev, 0x0118, 0x40404040);
> +	check_warn_return(status, "error writing 0x0118");
> +
> +	status = ufx_reg_write(dev, 0x0000, 0x00000001);
> +	check_warn_return(status, "error writing 0x0000");
> +
> +	while (i++ < 500) {
> +		status = ufx_reg_read(dev, 0x0000, &tmp);
> +		check_warn_return(status, "error reading 0x0000");
> +
> +		if (all_bits_set(tmp, 0xC0000000))
> +			return 0;
> +	}
> +
> +	pr_err("DDR2 initialisation timed out, reg 0x0000=0x%08x", tmp);
> +	return -ETIMEDOUT;
> +}
> +
> +struct pll_values {
> +	u32 div_r0;
> +	u32 div_f0;
> +	u32 div_q0;
> +	u32 range0;
> +	u32 div_r1;
> +	u32 div_f1;
> +	u32 div_q1;
> +	u32 range1;
> +};
> +
> +static u32 ufx_calc_range(u32 ref_freq)
> +{
> +	if (ref_freq >= 88000000)
> +		return 7;
> +
> +	if (ref_freq >= 54000000)
> +		return 6;
> +
> +	if (ref_freq >= 34000000)
> +		return 5;
> +
> +	if (ref_freq >= 21000000)
> +		return 4;
> +
> +	if (ref_freq >= 13000000)
> +		return 3;
> +
> +	if (ref_freq >= 8000000)
> +		return 2;
> +
> +	return 1;
> +}
> +
> +/* calculates PLL divider settings for a desired target frequency */
> +static void ufx_calc_pll_values(const u32 clk_pixel_pll, struct pll_values *asic_pll)
> +{
> +	const u32 ref_clk = 25000000;
> +	u32 div_r0, div_f0, div_q0, div_r1, div_f1, div_q1;
> +	u32 min_error = clk_pixel_pll;
> +
> +	for (div_r0 = 1; div_r0 <= 32; div_r0++) {
> +		u32 ref_freq0 = ref_clk / div_r0;
> +		if (ref_freq0 < 5000000)
> +			break;
> +
> +		if (ref_freq0 > 200000000)
> +			continue;
> +
> +		for (div_f0 = 1; div_f0 <= 256; div_f0++) {
> +			u32 vco_freq0 = ref_freq0 * div_f0;
> +
> +			if (vco_freq0 < 350000000)
> +				continue;
> +
> +			if (vco_freq0 > 700000000)
> +				break;
> +
> +			for (div_q0 = 0; div_q0 < 7; div_q0++) {
> +				u32 pllout_freq0 = vco_freq0 / (1 << div_q0);
> +
> +				if (pllout_freq0 < 5000000)
> +					break;
> +
> +				if (pllout_freq0 > 200000000)
> +					continue;
> +
> +				for (div_r1 = 1; div_r1 <= 32; div_r1++) {
> +					u32 ref_freq1 = pllout_freq0 / div_r1;
> +
> +					if (ref_freq1 < 5000000)
> +						break;
> +
> +					for (div_f1 = 1; div_f1 <= 256; div_f1++) {
> +						u32 vco_freq1 = ref_freq1 * div_f1;
> +
> +						if (vco_freq1 < 350000000)
> +							continue;
> +
> +						if (vco_freq1 > 700000000)
> +							break;
> +
> +						for (div_q1 = 0; div_q1 < 7; div_q1++) {
> +							u32 pllout_freq1 = vco_freq1 / (1 << div_q1);
> +							int error = abs(pllout_freq1 - clk_pixel_pll);
> +
> +							if (pllout_freq1 < 5000000)
> +								break;
> +
> +							if (pllout_freq1 > 700000000)
> +								continue;
> +
> +							if (error < min_error) {
> +								min_error = error;
> +
> +								/* final returned value is equal to calculated value - 1
> +								 * because a value of 0 = divide by 1 */
> +								asic_pll->div_r0 = div_r0 - 1;
> +								asic_pll->div_f0 = div_f0 - 1;
> +								asic_pll->div_q0 = div_q0;
> +								asic_pll->div_r1 = div_r1 - 1;
> +								asic_pll->div_f1 = div_f1 - 1;
> +								asic_pll->div_q1 = div_q1;
> +
> +								asic_pll->range0 = ufx_calc_range(ref_freq0);
> +								asic_pll->range1 = ufx_calc_range(ref_freq1);
> +
> +								if (min_error = 0)
> +									return;
> +							}
> +						}
> +					}
> +				}
> +			}
> +		}
> +	}
> +}
> +
> +/* sets analog bit PLL configuration values */
> +static int ufx_config_pix_clk(struct ufx_data *dev, u32 pixclock)
> +{
> +	struct pll_values asic_pll = {0};
> +	u32 value, clk_pixel, clk_pixel_pll;
> +	int status;
> +
> +	/* convert pixclock (in ps) to frequency (in Hz) */
> +	clk_pixel = PICOS2KHZ(pixclock) * 1000;
> +	pr_debug("pixclock %d ps = clk_pixel %d Hz", pixclock, clk_pixel);
> +
> +	/* clk_pixel = 1/2 clk_pixel_pll */
> +	clk_pixel_pll = clk_pixel * 2;
> +
> +	ufx_calc_pll_values(clk_pixel_pll, &asic_pll);
> +
> +	/* Keep BYPASS and RESET signals asserted until configured */
> +	status = ufx_reg_write(dev, 0x7000, 0x8000000F);
> +	check_warn_return(status, "error writing 0x7000");
> +
> +	value = (asic_pll.div_f1 | (asic_pll.div_r1 << 8) |
> +		(asic_pll.div_q1 << 16) | (asic_pll.range1 << 20));
> +	status = ufx_reg_write(dev, 0x7008, value);
> +	check_warn_return(status, "error writing 0x7008");
> +
> +	value = (asic_pll.div_f0 | (asic_pll.div_r0 << 8) |
> +		(asic_pll.div_q0 << 16) | (asic_pll.range0 << 20));
> +	status = ufx_reg_write(dev, 0x7004, value);
> +	check_warn_return(status, "error writing 0x7004");
> +
> +	status = ufx_reg_clear_bits(dev, 0x7000, 0x00000005);
> +	check_warn_return(status,
> +		"error clearing PLL0 bypass bits in 0x7000");
> +	msleep(1);
> +
> +	status = ufx_reg_clear_bits(dev, 0x7000, 0x0000000A);
> +	check_warn_return(status,
> +		"error clearing PLL1 bypass bits in 0x7000");
> +	msleep(1);
> +
> +	status = ufx_reg_clear_bits(dev, 0x7000, 0x80000000);
> +	check_warn_return(status, "error clearing gate bits in 0x7000");
> +
> +	return 0;
> +}
> +
> +static int ufx_set_vid_mode(struct ufx_data *dev, struct fb_var_screeninfo *var)
> +{
> +	u32 temp;
> +	u16 h_total, h_active, h_blank_start, h_blank_end, h_sync_start, h_sync_end;
> +	u16 v_total, v_active, v_blank_start, v_blank_end, v_sync_start, v_sync_end;
> +
> +	int status = ufx_reg_write(dev, 0x8028, 0);
> +	check_warn_return(status, "ufx_set_vid_mode error disabling RGB pad");
> +
> +	status = ufx_reg_write(dev, 0x8024, 0);
> +	check_warn_return(status, "ufx_set_vid_mode error disabling VDAC");
> +
> +	/* shut everything down before changing timing */
> +	status = ufx_blank(dev, true);
> +	check_warn_return(status, "ufx_set_vid_mode error blanking display");
> +
> +	status = ufx_disable(dev, true);
> +	check_warn_return(status, "ufx_set_vid_mode error disabling display");
> +
> +	status = ufx_config_pix_clk(dev, var->pixclock);
> +	check_warn_return(status, "ufx_set_vid_mode error configuring pixclock");
> +
> +	status = ufx_reg_write(dev, 0x2000, 0x00000104);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2000");
> +
> +	/* set horizontal timings */
> +	h_total = var->xres + var->right_margin + var->hsync_len + var->left_margin;
> +	h_active = var->xres;
> +	h_blank_start = var->xres + var->right_margin;
> +	h_blank_end = var->xres + var->right_margin + var->hsync_len;
> +	h_sync_start = var->xres + var->right_margin;
> +	h_sync_end = var->xres + var->right_margin + var->hsync_len;
> +
> +	temp = ((h_total - 1) << 16) | (h_active - 1);
> +	status = ufx_reg_write(dev, 0x2008, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2008");
> +
> +	temp = ((h_blank_start - 1) << 16) | (h_blank_end - 1);
> +	status = ufx_reg_write(dev, 0x200C, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x200C");
> +
> +	temp = ((h_sync_start - 1) << 16) | (h_sync_end - 1);
> +	status = ufx_reg_write(dev, 0x2010, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2010");
> +
> +	/* set vertical timings */
> +	v_total = var->upper_margin + var->yres + var->lower_margin + var->vsync_len;
> +	v_active = var->yres;
> +	v_blank_start = var->yres + var->lower_margin;
> +	v_blank_end = var->yres + var->lower_margin + var->vsync_len;
> +	v_sync_start = var->yres + var->lower_margin;
> +	v_sync_end = var->yres + var->lower_margin + var->vsync_len;
> +
> +	temp = ((v_total - 1) << 16) | (v_active - 1);
> +	status = ufx_reg_write(dev, 0x2014, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2014");
> +
> +	temp = ((v_blank_start - 1) << 16) | (v_blank_end - 1);
> +	status = ufx_reg_write(dev, 0x2018, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2018");
> +
> +	temp = ((v_sync_start - 1) << 16) | (v_sync_end - 1);
> +	status = ufx_reg_write(dev, 0x201C, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x201C");
> +
> +	status = ufx_reg_write(dev, 0x2020, 0x00000000);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2020");
> +
> +	status = ufx_reg_write(dev, 0x2024, 0x00000000);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2024");
> +
> +	/* Set the frame length register (#pix * 2 bytes/pixel) */
> +	temp = var->xres * var->yres * 2;
> +	temp = (temp + 7) & (~0x7);
> +	status = ufx_reg_write(dev, 0x2028, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2028");
> +
> +	/* enable desired output interface & disable others */
> +	status = ufx_reg_write(dev, 0x2040, 0);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2040");
> +
> +	status = ufx_reg_write(dev, 0x2044, 0);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2044");
> +
> +	status = ufx_reg_write(dev, 0x2048, 0);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2048");
> +
> +	/* set the sync polarities & enable bit */
> +	temp = 0x00000001;
> +	if (var->sync & FB_SYNC_HOR_HIGH_ACT)
> +		temp |= 0x00000010;
> +
> +	if (var->sync & FB_SYNC_VERT_HIGH_ACT)
> +		temp |= 0x00000008;
> +
> +	status = ufx_reg_write(dev, 0x2040, temp);
> +	check_warn_return(status, "ufx_set_vid_mode error writing 0x2040");
> +
> +	/* start everything back up */
> +	status = ufx_enable(dev, true);
> +	check_warn_return(status, "ufx_set_vid_mode error enabling display");
> +
> +	/* Unblank the display */
> +	status = ufx_unblank(dev, true);
> +	check_warn_return(status, "ufx_set_vid_mode error unblanking display");
> +
> +	/* enable RGB pad */
> +	status = ufx_reg_write(dev, 0x8028, 0x00000003);
> +	check_warn_return(status, "ufx_set_vid_mode error enabling RGB pad");
> +
> +	/* enable VDAC */
> +	status = ufx_reg_write(dev, 0x8024, 0x00000007);
> +	check_warn_return(status, "ufx_set_vid_mode error enabling VDAC");
> +
> +	return 0;
> +}
> +
> +static int ufx_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)
> +{
> +	unsigned long start = vma->vm_start;
> +	unsigned long size = vma->vm_end - vma->vm_start;
> +	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
> +	unsigned long page, pos;
> +
> +	if (offset + size > info->fix.smem_len)
> +		return -EINVAL;
> +
> +	pos = (unsigned long)info->fix.smem_start + offset;
> +
> +	pr_debug("mmap() framebuffer addr:%lu size:%lu\n",
> +		  pos, size);
> +
> +	while (size > 0) {
> +		page = vmalloc_to_pfn((void *)pos);
> +		if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
> +			return -EAGAIN;
> +
> +		start += PAGE_SIZE;
> +		pos += PAGE_SIZE;
> +		if (size > PAGE_SIZE)
> +			size -= PAGE_SIZE;
> +		else
> +			size = 0;
> +	}
> +
> +	vma->vm_flags |= VM_RESERVED;	/* avoid to swap out this VMA */
> +	return 0;
> +}
> +
> +static void ufx_raw_rect(struct ufx_data *dev, char *cmd, int x, int y,
> +	int width, int height)
> +{
> +	size_t packed_line_len = ALIGN((width * 2), 4);
> +	size_t packed_rect_len = packed_line_len * height;
> +	int line;
> +
> +	BUG_ON(!dev);
> +	BUG_ON(!dev->info);
> +
> +	/* command word */
> +	*((u32 *)&cmd[0]) = cpu_to_le32(0x01);
> +
> +	/* length word */
> +	*((u32 *)&cmd[4]) = cpu_to_le32(packed_rect_len + 16);
> +
> +	*((u16 *)&cmd[8]) = cpu_to_le16(x);
> +	*((u16 *)&cmd[10]) = cpu_to_le16(y);
> +	*((u16 *)&cmd[12]) = cpu_to_le16(width);
> +	*((u16 *)&cmd[14]) = cpu_to_le16(height);
> +
> +	/* frame base address */
> +	*((u32 *)&cmd[16]) = cpu_to_le32(0 & 0xffffff80);
> +
> +	/* color mode and horizontal resolution */
> +	*((u16 *)&cmd[20]) = cpu_to_le16(0x4000 | dev->info->var.xres);
> +
> +	/* vertical resolution */
> +	*((u16 *)&cmd[22]) = cpu_to_le16(dev->info->var.yres);
> +
> +	/* packed data */
> +	for (line = 0; line < height; line++) {
> +		const int line_offset = dev->info->fix.line_length * (y + line);
> +		const int byte_offset = line_offset + (x * BPP);
> +		memcpy(&cmd[24 + (packed_line_len * line)],
> +			(char *)dev->info->fix.smem_start + byte_offset, width * BPP);
> +	}
> +}
> +
> +int ufx_handle_damage(struct ufx_data *dev, int x, int y,
> +	int width, int height)
> +{
> +	size_t packed_line_len = ALIGN((width * 2), 4);
> +	int len, status, urb_lines, start_line = 0;
> +
> +	if ((width <= 0) || (height <= 0) ||
> +	    (x + width > dev->info->var.xres) ||
> +	    (y + height > dev->info->var.yres))
> +		return -EINVAL;
> +
> +	if (!atomic_read(&dev->usb_active))
> +		return 0;
> +
> +	while (start_line < height) {
> +		struct urb *urb = ufx_get_urb(dev);
> +		if (!urb) {
> +			pr_warn("ufx_handle_damage unable to get urb");
> +			return 0;
> +		}
> +
> +		/* assume we have enough space to transfer at least one line */
> +		BUG_ON(urb->transfer_buffer_length < (24 + (width * 2)));
> +
> +		/* calculate the maximum number of lines we could fit in */
> +		urb_lines = (urb->transfer_buffer_length - 24) / packed_line_len;
> +
> +		/* but we might not need this many */
> +		urb_lines = min(urb_lines, (height - start_line));
> +
> +		memset(urb->transfer_buffer, 0, urb->transfer_buffer_length);
> +
> +		ufx_raw_rect(dev, urb->transfer_buffer, x, (y + start_line), width, urb_lines);
> +		len = 24 + (packed_line_len * urb_lines);
> +
> +		status = ufx_submit_urb(dev, urb, len);
> +		check_warn_return(status, "Error submitting URB");
> +
> +		start_line += urb_lines;
> +	}
> +
> +	return 0;
> +}
> +
> +/* Path triggered by usermode clients who write to filesystem
> + * e.g. cat filename > /dev/fb1
> + * Not used by X Windows or text-mode console. But useful for testing.
> + * Slow because of extra copy and we must assume all pixels dirty. */
> +static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf,
> +			  size_t count, loff_t *ppos)
> +{
> +	ssize_t result;
> +	struct ufx_data *dev = info->par;
> +	u32 offset = (u32) *ppos;
> +
> +	result = fb_sys_write(info, buf, count, ppos);
> +
> +	if (result > 0) {
> +		int start = max((int)(offset / info->fix.line_length) - 1, 0);
> +		int lines = min((u32)((result / info->fix.line_length) + 1),
> +				(u32)info->var.yres);
> +
> +		ufx_handle_damage(dev, 0, start, info->var.xres, lines);
> +	}
> +
> +	return result;
> +}
> +
> +static void ufx_ops_copyarea(struct fb_info *info,
> +				const struct fb_copyarea *area)
> +{
> +
> +	struct ufx_data *dev = info->par;
> +
> +	sys_copyarea(info, area);
> +
> +	ufx_handle_damage(dev, area->dx, area->dy,
> +			area->width, area->height);
> +}
> +
> +static void ufx_ops_imageblit(struct fb_info *info,
> +				const struct fb_image *image)
> +{
> +	struct ufx_data *dev = info->par;
> +
> +	sys_imageblit(info, image);
> +
> +	ufx_handle_damage(dev, image->dx, image->dy,
> +			image->width, image->height);
> +}
> +
> +static void ufx_ops_fillrect(struct fb_info *info,
> +			  const struct fb_fillrect *rect)
> +{
> +	struct ufx_data *dev = info->par;
> +
> +	sys_fillrect(info, rect);
> +
> +	ufx_handle_damage(dev, rect->dx, rect->dy, rect->width,
> +			      rect->height);
> +}
> +
> +/* NOTE: fb_defio.c is holding info->fbdefio.mutex
> + *   Touching ANY framebuffer memory that triggers a page fault
> + *   in fb_defio will cause a deadlock, when it also tries to
> + *   grab the same mutex. */
> +static void ufx_dpy_deferred_io(struct fb_info *info,
> +				struct list_head *pagelist)
> +{
> +	struct page *cur;
> +	struct fb_deferred_io *fbdefio = info->fbdefio;
> +	struct ufx_data *dev = info->par;
> +
> +	if (!fb_defio)
> +		return;
> +
> +	if (!atomic_read(&dev->usb_active))
> +		return;
> +
> +	/* walk the written page list and render each to device */
> +	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
> +		/* create a rectangle of full screen width that encloses the
> +		 * entire dirty framebuffer page */
> +		const int x = 0;
> +		const int width = dev->info->var.xres;
> +		const int y = (cur->index << PAGE_SHIFT) / (width * 2);
> +		int height = (PAGE_SIZE / (width * 2)) + 1;
> +		height = min(height, (int)(dev->info->var.yres - y));
> +
> +		BUG_ON(y >= dev->info->var.yres);
> +		BUG_ON((y + height) > dev->info->var.yres);
> +
> +		ufx_handle_damage(dev, x, y, width, height);
> +	}
> +}
> +
> +static int ufx_ops_ioctl(struct fb_info *info, unsigned int cmd,
> +			 unsigned long arg)
> +{
> +	struct ufx_data *dev = info->par;
> +	struct dloarea *area = NULL;
> +
> +	if (!atomic_read(&dev->usb_active))
> +		return 0;
> +
> +	/* TODO: Update X server to get this from sysfs instead */
> +	if (cmd = UFX_IOCTL_RETURN_EDID) {
> +		char *edid = (char *)arg;
> +		if (copy_to_user(edid, dev->edid, dev->edid_size))
> +			return -EFAULT;
> +		return 0;
> +	}
> +
> +	/* TODO: Help propose a standard fb.h ioctl to report mmap damage */
> +	if (cmd = UFX_IOCTL_REPORT_DAMAGE) {
> +		/* If we have a damage-aware client, turn fb_defio "off"
> +		 * To avoid perf imact of unecessary page fault handling.
> +		 * Done by resetting the delay for this fb_info to a very
> +		 * long period. Pages will become writable and stay that way.
> +		 * Reset to normal value when all clients have closed this fb.
> +		 */
> +		if (info->fbdefio)
> +			info->fbdefio->delay = UFX_DEFIO_WRITE_DISABLE;
> +
> +		area = (struct dloarea *)arg;
> +
> +		if (area->x < 0)
> +			area->x = 0;
> +
> +		if (area->x > info->var.xres)
> +			area->x = info->var.xres;
> +
> +		if (area->y < 0)
> +			area->y = 0;
> +
> +		if (area->y > info->var.yres)
> +			area->y = info->var.yres;
> +
> +		ufx_handle_damage(dev, area->x, area->y, area->w, area->h);
> +	}
> +
> +	return 0;
> +}
> +
> +/* taken from vesafb */
> +static int
> +ufx_ops_setcolreg(unsigned regno, unsigned red, unsigned green,
> +	       unsigned blue, unsigned transp, struct fb_info *info)
> +{
> +	int err = 0;
> +
> +	if (regno >= info->cmap.len)
> +		return 1;
> +
> +	if (regno < 16) {
> +		if (info->var.red.offset = 10) {
> +			/* 1:5:5:5 */
> +			((u32 *) (info->pseudo_palette))[regno] > +			    ((red & 0xf800) >> 1) |
> +			    ((green & 0xf800) >> 6) | ((blue & 0xf800) >> 11);
> +		} else {
> +			/* 0:5:6:5 */
> +			((u32 *) (info->pseudo_palette))[regno] > +			    ((red & 0xf800)) |
> +			    ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
> +		}
> +	}
> +
> +	return err;
> +}
> +
> +/* It's common for several clients to have framebuffer open simultaneously.
> + * e.g. both fbcon and X. Makes things interesting.
> + * Assumes caller is holding info->lock (for open and release at least) */
> +static int ufx_ops_open(struct fb_info *info, int user)
> +{
> +	struct ufx_data *dev = info->par;
> +
> +	/* fbcon aggressively connects to first framebuffer it finds,
> +	 * preventing other clients (X) from working properly. Usually
> +	 * not what the user wants. Fail by default with option to enable. */
> +	if (user = 0 && !console)
> +		return -EBUSY;
> +
> +	/* If the USB device is gone, we don't accept new opens */
> +	if (dev->virtualized)
> +		return -ENODEV;
> +
> +	dev->fb_count++;
> +
> +	kref_get(&dev->kref);
> +
> +	if (fb_defio && (info->fbdefio = NULL)) {
> +		/* enable defio at last moment if not disabled by client */
> +
> +		struct fb_deferred_io *fbdefio;
> +
> +		fbdefio = kmalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
> +
> +		if (fbdefio) {
> +			fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
> +			fbdefio->deferred_io = ufx_dpy_deferred_io;
> +		}
> +
> +		info->fbdefio = fbdefio;
> +		fb_deferred_io_init(info);
> +	}
> +
> +	pr_debug("open /dev/fb%d user=%d fb_info=%p count=%d",
> +		info->node, user, info, dev->fb_count);
> +
> +	return 0;
> +}
> +
> +/*
> + * Called when all client interfaces to start transactions have been disabled,
> + * and all references to our device instance (ufx_data) are released.
> + * Every transaction must have a reference, so we know are fully spun down
> + */
> +static void ufx_free(struct kref *kref)
> +{
> +	struct ufx_data *dev = container_of(kref, struct ufx_data, kref);
> +
> +	/* this function will wait for all in-flight urbs to complete */
> +	if (dev->urbs.count > 0)
> +		ufx_free_urb_list(dev);
> +
> +	pr_debug("freeing ufx_data %p", dev);
> +
> +	kfree(dev);
> +}
> +
> +static void ufx_release_urb_work(struct work_struct *work)
> +{
> +	struct urb_node *unode = container_of(work, struct urb_node,
> +					      release_urb_work.work);
> +
> +	up(&unode->dev->urbs.limit_sem);
> +}
> +
> +static void ufx_free_framebuffer_work(struct work_struct *work)
> +{
> +	struct ufx_data *dev = container_of(work, struct ufx_data,
> +					    free_framebuffer_work.work);
> +	struct fb_info *info = dev->info;
> +	int node = info->node;
> +
> +	unregister_framebuffer(info);
> +
> +	if (info->cmap.len != 0)
> +		fb_dealloc_cmap(&info->cmap);
> +	if (info->monspecs.modedb)
> +		fb_destroy_modedb(info->monspecs.modedb);
> +	if (info->screen_base)
> +		vfree(info->screen_base);
> +
> +	fb_destroy_modelist(&info->modelist);
> +
> +	dev->info = 0;
> +
> +	/* Assume info structure is freed after this point */
> +	framebuffer_release(info);
> +
> +	pr_debug("fb_info for /dev/fb%d has been freed", node);
> +
> +	/* ref taken in probe() as part of registering framebfufer */
> +	kref_put(&dev->kref, ufx_free);
> +}
> +
> +/*
> + * Assumes caller is holding info->lock mutex (for open and release at least)
> + */
> +static int ufx_ops_release(struct fb_info *info, int user)
> +{
> +	struct ufx_data *dev = info->par;
> +
> +	dev->fb_count--;
> +
> +	/* We can't free fb_info here - fbmem will touch it when we return */
> +	if (dev->virtualized && (dev->fb_count = 0))
> +		schedule_delayed_work(&dev->free_framebuffer_work, HZ);
> +
> +	if ((dev->fb_count = 0) && (info->fbdefio)) {
> +		fb_deferred_io_cleanup(info);
> +		kfree(info->fbdefio);
> +		info->fbdefio = NULL;
> +		info->fbops->fb_mmap = ufx_ops_mmap;
> +	}
> +
> +	pr_debug("released /dev/fb%d user=%d count=%d",
> +		  info->node, user, dev->fb_count);
> +
> +	kref_put(&dev->kref, ufx_free);
> +
> +	return 0;
> +}
> +
> +/* Check whether a video mode is supported by the chip
> + * We start from monitor's modes, so don't need to filter that here */
> +static int ufx_is_valid_mode(struct fb_videomode *mode,
> +		struct fb_info *info)
> +{
> +	if ((mode->xres * mode->yres) > (2048 * 1152)) {
> +		pr_debug("%dx%d too many pixels",
> +		       mode->xres, mode->yres);
> +		return 0;
> +	}
> +
> +	if (mode->pixclock < 5000) {
> +		pr_debug("%dx%d %dps pixel clock too fast",
> +		       mode->xres, mode->yres, mode->pixclock);
> +		return 0;
> +	}
> +
> +	pr_debug("%dx%d (pixclk %dps %dMHz) valid mode", mode->xres, mode->yres,
> +		mode->pixclock, (1000000 / mode->pixclock));
> +	return 1;
> +}
> +
> +static void ufx_var_color_format(struct fb_var_screeninfo *var)
> +{
> +	const struct fb_bitfield red = { 11, 5, 0 };
> +	const struct fb_bitfield green = { 5, 6, 0 };
> +	const struct fb_bitfield blue = { 0, 5, 0 };
> +
> +	var->bits_per_pixel = 16;
> +	var->red = red;
> +	var->green = green;
> +	var->blue = blue;
> +}
> +
> +static int ufx_ops_check_var(struct fb_var_screeninfo *var,
> +				struct fb_info *info)
> +{
> +	struct fb_videomode mode;
> +
> +	/* TODO: support dynamically changing framebuffer size */
> +	if ((var->xres * var->yres * 2) > info->fix.smem_len)
> +		return -EINVAL;
> +
> +	/* set device-specific elements of var unrelated to mode */
> +	ufx_var_color_format(var);
> +
> +	fb_var_to_videomode(&mode, var);
> +
> +	if (!ufx_is_valid_mode(&mode, info))
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static int ufx_ops_set_par(struct fb_info *info)
> +{
> +	struct ufx_data *dev = info->par;
> +	int result;
> +	u16 *pix_framebuffer;
> +	int i;
> +
> +	pr_debug("set_par mode %dx%d", info->var.xres, info->var.yres);
> +	result = ufx_set_vid_mode(dev, &info->var);
> +
> +	if ((result = 0) && (dev->fb_count = 0)) {
> +		/* paint greenscreen */
> +		pix_framebuffer = (u16 *) info->screen_base;
> +		for (i = 0; i < info->fix.smem_len / 2; i++)
> +			pix_framebuffer[i] = 0x37e6;
> +
> +		ufx_handle_damage(dev, 0, 0, info->var.xres, info->var.yres);
> +	}
> +
> +	/* re-enable defio if previously disabled by damage tracking */
> +	if (info->fbdefio)
> +		info->fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
> +
> +	return result;
> +}
> +
> +/* In order to come back from full DPMS off, we need to set the mode again */
> +static int ufx_ops_blank(int blank_mode, struct fb_info *info)
> +{
> +	struct ufx_data *dev = info->par;
> +	ufx_set_vid_mode(dev, &info->var);
> +	return 0;
> +}
> +
> +static struct fb_ops ufx_ops = {
> +	.owner = THIS_MODULE,
> +	.fb_read = fb_sys_read,
> +	.fb_write = ufx_ops_write,
> +	.fb_setcolreg = ufx_ops_setcolreg,
> +	.fb_fillrect = ufx_ops_fillrect,
> +	.fb_copyarea = ufx_ops_copyarea,
> +	.fb_imageblit = ufx_ops_imageblit,
> +	.fb_mmap = ufx_ops_mmap,
> +	.fb_ioctl = ufx_ops_ioctl,
> +	.fb_open = ufx_ops_open,
> +	.fb_release = ufx_ops_release,
> +	.fb_blank = ufx_ops_blank,
> +	.fb_check_var = ufx_ops_check_var,
> +	.fb_set_par = ufx_ops_set_par,
> +};
> +
> +/* Assumes &info->lock held by caller
> + * Assumes no active clients have framebuffer open */
> +static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
> +{
> +	int retval = -ENOMEM;
> +	int old_len = info->fix.smem_len;
> +	int new_len;
> +	unsigned char *old_fb = info->screen_base;
> +	unsigned char *new_fb;
> +
> +	pr_debug("Reallocating framebuffer. Addresses will change!");
> +
> +	new_len = info->fix.line_length * info->var.yres;
> +
> +	if (PAGE_ALIGN(new_len) > old_len) {
> +		/*
> +		 * Alloc system memory for virtual framebuffer
> +		 */
> +		new_fb = vmalloc(new_len);
> +		if (!new_fb) {
> +			pr_err("Virtual framebuffer alloc failed");
> +			goto error;
> +		}
> +
> +		if (info->screen_base) {
> +			memcpy(new_fb, old_fb, old_len);
> +			vfree(info->screen_base);
> +		}
> +
> +		info->screen_base = new_fb;
> +		info->fix.smem_len = PAGE_ALIGN(new_len);
> +		info->fix.smem_start = (unsigned long) new_fb;
> +		info->flags = smscufx_info_flags;
> +	}
> +
> +	retval = 0;
> +
> +error:
> +	return retval;
> +}
> +
> +/* sets up I2C Controller for 100 Kbps, std. speed, 7-bit addr, master,
> + * restart enabled, but no start byte, enable controller */
> +static int ufx_i2c_init(struct ufx_data *dev)
> +{
> +	u32 tmp;
> +
> +	/* disable the controller before it can be reprogrammed */
> +	int status = ufx_reg_write(dev, 0x106C, 0x00);
> +	check_warn_return(status, "failed to disable I2C");
> +
> +	/* Setup the clock count registers
> +	 * (12+1) = 13 clks @ 2.5 MHz = 5.2 uS */
> +	status = ufx_reg_write(dev, 0x1018, 12);
> +	check_warn_return(status, "error writing 0x1018");
> +
> +	/* (6+8) = 14 clks @ 2.5 MHz = 5.6 uS */
> +	status = ufx_reg_write(dev, 0x1014, 6);
> +	check_warn_return(status, "error writing 0x1014");
> +
> +	status = ufx_reg_read(dev, 0x1000, &tmp);
> +	check_warn_return(status, "error reading 0x1000");
> +
> +	/* set speed to std mode */
> +	tmp &= ~(0x06);
> +	tmp |= 0x02;
> +
> +	/* 7-bit (not 10-bit) addressing */
> +	tmp &= ~(0x10);
> +
> +	/* enable restart conditions and master mode */
> +	tmp |= 0x21;
> +
> +	status = ufx_reg_write(dev, 0x1000, tmp);
> +	check_warn_return(status, "error writing 0x1000");
> +
> +	/* Set normal tx using target address 0 */
> +	status = ufx_reg_clear_and_set_bits(dev, 0x1004, 0xC00, 0x000);
> +	check_warn_return(status, "error setting TX mode bits in 0x1004");
> +
> +	/* Enable the controller */
> +	status = ufx_reg_write(dev, 0x106C, 0x01);
> +	check_warn_return(status, "failed to enable I2C");
> +
> +	return 0;
> +}
> +
> +/* sets the I2C port mux and target address */
> +static int ufx_i2c_configure(struct ufx_data *dev)
> +{
> +	int status = ufx_reg_write(dev, 0x106C, 0x00);
> +	check_warn_return(status, "failed to disable I2C");
> +
> +	status = ufx_reg_write(dev, 0x3010, 0x00000000);
> +	check_warn_return(status, "failed to write 0x3010");
> +
> +	/* A0h is std for any EDID, right shifted by one */
> +	status = ufx_reg_clear_and_set_bits(dev, 0x1004, 0x3FF,	(0xA0 >> 1));
> +	check_warn_return(status, "failed to set TAR bits in 0x1004");
> +
> +	status = ufx_reg_write(dev, 0x106C, 0x01);
> +	check_warn_return(status, "failed to enable I2C");
> +
> +	return 0;
> +}
> +
> +/* wait for BUSY to clear, with a timeout of 50ms with 10ms sleeps. if no
> + * monitor is connected, there is no error except for timeout */
> +static int ufx_i2c_wait_busy(struct ufx_data *dev)
> +{
> +	u32 tmp;
> +	int i, status;
> +
> +	for (i = 0; i < 15; i++) {
> +		status = ufx_reg_read(dev, 0x1100, &tmp);
> +		check_warn_return(status, "0x1100 read failed");
> +
> +		/* if BUSY is clear, check for error */
> +		if ((tmp & 0x80000000) = 0) {
> +			if (tmp & 0x20000000) {
> +				pr_warn("I2C read failed, 0x1100=0x%08x", tmp);
> +				return -EIO;
> +			}
> +
> +			return 0;
> +		}
> +
> +		/* perform the first 10 retries without delay */
> +		if (i >= 10)
> +			msleep(10);
> +	}
> +
> +	pr_warn("I2C access timed out, resetting I2C hardware");
> +	status =  ufx_reg_write(dev, 0x1100, 0x40000000);
> +	check_warn_return(status, "0x1100 write failed");
> +
> +	return -ETIMEDOUT;
> +}
> +
> +/* reads a 128-byte EDID block from the currently selected port and TAR */
> +static int ufx_read_edid(struct ufx_data *dev, char *edid, int edid_len)
> +{
> +	int i, j, status;
> +	u32 *edid_u32 = (u32 *)edid;
> +
> +	BUG_ON(edid_len != EDID_LENGTH);
> +
> +	status = ufx_i2c_configure(dev);
> +	if (status < 0) {
> +		pr_err("ufx_i2c_configure failed");
> +		return status;
> +	}
> +
> +	memset(edid, 0xff, EDID_LENGTH);
> +
> +	/* Read the 128-byte EDID as 2 bursts of 64 bytes */
> +	for (i = 0; i < 2; i++) {
> +		u32 temp = 0x28070000 | (63 << 20) | (((u32)(i * 64)) << 8);
> +		status = ufx_reg_write(dev, 0x1100, temp);
> +		check_warn_return(status, "Failed to write 0x1100");
> +
> +		temp |= 0x80000000;
> +		status = ufx_reg_write(dev, 0x1100, temp);
> +		check_warn_return(status, "Failed to write 0x1100");
> +
> +		status = ufx_i2c_wait_busy(dev);
> +		check_warn_return(status, "Timeout waiting for I2C BUSY to clear");
> +
> +		for (j = 0; j < 16; j++) {
> +			u32 data_reg_addr = 0x1110 + (j * 4);
> +			status = ufx_reg_read(dev, data_reg_addr, edid_u32++);
> +			check_warn_return(status, "Error reading i2c data");
> +		}
> +	}
> +
> +	/* all FF's in the first 16 bytes indicates nothing is connected */
> +	for (i = 0; i < 16; i++) {
> +		if (edid[i] != 0xFF) {
> +			pr_debug("edid data read succesfully");
> +			return EDID_LENGTH;
> +		}
> +	}
> +
> +	pr_warn("edid data contains all 0xff");
> +	return -ETIMEDOUT;
> +}
> +
> +/* 1) use sw default
> + * 2) Parse into various fb_info structs
> + * 3) Allocate virtual framebuffer memory to back highest res mode
> + *
> + * Parses EDID into three places used by various parts of fbdev:
> + * fb_var_screeninfo contains the timing of the monitor's preferred mode
> + * fb_info.monspecs is full parsed EDID info, including monspecs.modedb
> + * fb_info.modelist is a linked list of all monitor & VESA modes which work
> + *
> + * If EDID is not readable/valid, then modelist is all VESA modes,
> + * monspecs is NULL, and fb_var_screeninfo is set to safe VESA mode
> + * Returns 0 if successful */
> +static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
> +	char *default_edid, size_t default_edid_size)
> +{
> +	const struct fb_videomode *default_vmode = NULL;
> +	char *edid;
> +	int i, result = 0, tries = 3;
> +
> +	if (info->dev) /* only use mutex if info has been registered */
> +		mutex_lock(&info->lock);
> +
> +	edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
> +	if (!edid) {
> +		result = -ENOMEM;
> +		goto error;
> +	}
> +
> +	fb_destroy_modelist(&info->modelist);
> +	memset(&info->monspecs, 0, sizeof(info->monspecs));
> +
> +	/* Try to (re)read EDID from hardware first
> +	 * EDID data may return, but not parse as valid
> +	 * Try again a few times, in case of e.g. analog cable noise */
> +	while (tries--) {
> +		i = ufx_read_edid(dev, edid, EDID_LENGTH);
> +
> +		if (i >= EDID_LENGTH)
> +			fb_edid_to_monspecs(edid, &info->monspecs);
> +
> +		if (info->monspecs.modedb_len > 0) {
> +			dev->edid = edid;
> +			dev->edid_size = i;
> +			break;
> +		}
> +	}
> +
> +	/* If that fails, use a previously returned EDID if available */
> +	if (info->monspecs.modedb_len = 0) {
> +		pr_err("Unable to get valid EDID from device/display\n");
> +
> +		if (dev->edid) {
> +			fb_edid_to_monspecs(dev->edid, &info->monspecs);
> +			if (info->monspecs.modedb_len > 0)
> +				pr_err("Using previously queried EDID\n");
> +		}
> +	}
> +
> +	/* If that fails, use the default EDID we were handed */
> +	if (info->monspecs.modedb_len = 0) {
> +		if (default_edid_size >= EDID_LENGTH) {
> +			fb_edid_to_monspecs(default_edid, &info->monspecs);
> +			if (info->monspecs.modedb_len > 0) {
> +				memcpy(edid, default_edid, default_edid_size);
> +				dev->edid = edid;
> +				dev->edid_size = default_edid_size;
> +				pr_err("Using default/backup EDID\n");
> +			}
> +		}
> +	}
> +
> +	/* If we've got modes, let's pick a best default mode */
> +	if (info->monspecs.modedb_len > 0) {
> +
> +		for (i = 0; i < info->monspecs.modedb_len; i++) {
> +			if (ufx_is_valid_mode(&info->monspecs.modedb[i], info))
> +				fb_add_videomode(&info->monspecs.modedb[i],
> +					&info->modelist);
> +			else /* if we've removed top/best mode */
> +				info->monspecs.misc &= ~FB_MISC_1ST_DETAIL;
> +		}
> +
> +		default_vmode = fb_find_best_display(&info->monspecs,
> +						     &info->modelist);
> +	}
> +
> +	/* If everything else has failed, fall back to safe default mode */
> +	if (default_vmode = NULL) {
> +
> +		struct fb_videomode fb_vmode = {0};
> +
> +		/* Add the standard VESA modes to our modelist
> +		 * Since we don't have EDID, there may be modes that
> +		 * overspec monitor and/or are incorrect aspect ratio, etc.
> +		 * But at least the user has a chance to choose
> +		 */
> +		for (i = 0; i < VESA_MODEDB_SIZE; i++) {
> +			if (ufx_is_valid_mode((struct fb_videomode *)
> +						&vesa_modes[i], info))
> +				fb_add_videomode(&vesa_modes[i],
> +						 &info->modelist);
> +		}
> +
> +		/* default to resolution safe for projectors
> +		 * (since they are most common case without EDID)
> +		 */
> +		fb_vmode.xres = 800;
> +		fb_vmode.yres = 600;
> +		fb_vmode.refresh = 60;
> +		default_vmode = fb_find_nearest_mode(&fb_vmode,
> +						     &info->modelist);
> +	}
> +
> +	/* If we have good mode and no active clients */
> +	if ((default_vmode != NULL) && (dev->fb_count = 0)) {
> +
> +		fb_videomode_to_var(&info->var, default_vmode);
> +		ufx_var_color_format(&info->var);
> +
> +		/* with mode size info, we can now alloc our framebuffer */
> +		memcpy(&info->fix, &ufx_fix, sizeof(ufx_fix));
> +		info->fix.line_length = info->var.xres *
> +			(info->var.bits_per_pixel / 8);
> +
> +		result = ufx_realloc_framebuffer(dev, info);
> +
> +	} else
> +		result = -EINVAL;
> +
> +error:
> +	if (edid && (dev->edid != edid))
> +		kfree(edid);
> +
> +	if (info->dev)
> +		mutex_unlock(&info->lock);
> +
> +	return result;
> +}
> +
> +static int ufx_usb_probe(struct usb_interface *interface,
> +			const struct usb_device_id *id)
> +{
> +	struct usb_device *usbdev;
> +	struct ufx_data *dev;
> +	struct fb_info *info = 0;
> +	int retval = -ENOMEM;
> +	u32 id_rev, fpga_rev;
> +
> +	/* usb initialization */
> +	usbdev = interface_to_usbdev(interface);
> +	BUG_ON(!usbdev);
> +
> +	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> +	if (dev = NULL) {
> +		dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n");
> +		goto error;
> +	}
> +
> +	/* we need to wait for both usb and fbdev to spin down on disconnect */
> +	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
> +	kref_get(&dev->kref); /* matching kref_put in free_framebuffer_work */
> +
> +	dev->udev = usbdev;
> +	dev->gdev = &usbdev->dev; /* our generic struct device * */
> +	usb_set_intfdata(interface, dev);
> +
> +	dev_dbg(dev->gdev, "%s %s - serial #%s\n",
> +		usbdev->manufacturer, usbdev->product, usbdev->serial);
> +	dev_dbg(dev->gdev, "vid_%04x&pid_%04x&rev_%04x driver's ufx_data struct at %p\n",
> +		usbdev->descriptor.idVendor, usbdev->descriptor.idProduct,
> +		usbdev->descriptor.bcdDevice, dev);
> +	dev_dbg(dev->gdev, "console enable=%d\n", console);
> +	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
> +
> +	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
> +		retval = -ENOMEM;
> +		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
> +		goto error;
> +	}
> +
> +	/* We don't register a new USB class. Our client interface is fbdev */
> +
> +	/* allocates framebuffer driver structure, not framebuffer memory */
> +	info = framebuffer_alloc(0, &usbdev->dev);
> +	if (!info) {
> +		retval = -ENOMEM;
> +		dev_err(dev->gdev, "framebuffer_alloc failed\n");
> +		goto error;
> +	}
> +
> +	dev->info = info;
> +	info->par = dev;
> +	info->pseudo_palette = dev->pseudo_palette;
> +	info->fbops = &ufx_ops;
> +
> +	retval = fb_alloc_cmap(&info->cmap, 256, 0);
> +	if (retval < 0) {
> +		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
> +		goto error;
> +	}
> +
> +	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
> +			  ufx_free_framebuffer_work);
> +
> +	INIT_LIST_HEAD(&info->modelist);
> +
> +	retval = ufx_reg_read(dev, 0x3000, &id_rev);
> +	check_warn_goto_error(retval, "error %d reading 0x3000 register from device", retval);
> +	dev_dbg(dev->gdev, "ID_REV register value 0x%08x", id_rev);
> +
> +	retval = ufx_reg_read(dev, 0x3004, &fpga_rev);
> +	check_warn_goto_error(retval, "error %d reading 0x3004 register from device", retval);
> +	dev_dbg(dev->gdev, "FPGA_REV register value 0x%08x", fpga_rev);
> +
> +	dev_dbg(dev->gdev, "resetting device");
> +	retval = ufx_lite_reset(dev);
> +	check_warn_goto_error(retval, "error %d resetting device", retval);
> +
> +	dev_dbg(dev->gdev, "configuring system clock");
> +	retval = ufx_config_sys_clk(dev);
> +	check_warn_goto_error(retval, "error %d configuring system clock", retval);
> +
> +	dev_dbg(dev->gdev, "configuring DDR2 controller");
> +	retval = ufx_config_ddr2(dev);
> +	check_warn_goto_error(retval, "error %d initialising DDR2 controller", retval);
> +
> +	dev_dbg(dev->gdev, "configuring I2C controller");
> +	retval = ufx_i2c_init(dev);
> +	check_warn_goto_error(retval, "error %d initialising I2C controller", retval);
> +
> +	dev_dbg(dev->gdev, "selecting display mode");
> +	retval = ufx_setup_modes(dev, info, NULL, 0);
> +	check_warn_goto_error(retval, "unable to find common mode for display and adapter");
> +
> +	retval = ufx_reg_set_bits(dev, 0x4000, 0x00000001);
> +	check_warn_goto_error(retval, "error %d enabling graphics engine", retval);
> +
> +	/* ready to begin using device */
> +	atomic_set(&dev->usb_active, 1);
> +
> +	dev_dbg(dev->gdev, "checking var");
> +	retval = ufx_ops_check_var(&info->var, info);
> +	check_warn_goto_error(retval, "error %d ufx_ops_check_var", retval);
> +
> +	dev_dbg(dev->gdev, "setting par");
> +	retval = ufx_ops_set_par(info);
> +	check_warn_goto_error(retval, "error %d ufx_ops_set_par", retval);
> +
> +	dev_dbg(dev->gdev, "registering framebuffer");
> +	retval = register_framebuffer(info);
> +	check_warn_goto_error(retval, "error %d register_framebuffer", retval);
> +
> +	dev_info(dev->gdev, "SMSC UDX USB device /dev/fb%d attached. %dx%d resolution."
> +		" Using %dK framebuffer memory\n", info->node,
> +		info->var.xres, info->var.yres, info->fix.smem_len >> 10);
> +
> +	return 0;
> +
> +error:
> +	if (dev) {
> +		if (info) {
> +			if (info->cmap.len != 0)
> +				fb_dealloc_cmap(&info->cmap);
> +			if (info->monspecs.modedb)
> +				fb_destroy_modedb(info->monspecs.modedb);
> +			if (info->screen_base)
> +				vfree(info->screen_base);
> +
> +			fb_destroy_modelist(&info->modelist);
> +
> +			framebuffer_release(info);
> +		}
> +
> +		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
> +		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
> +
> +		/* dev has been deallocated. Do not dereference */
> +	}
> +
> +	return retval;
> +}
> +
> +static void ufx_usb_disconnect(struct usb_interface *interface)
> +{
> +	struct ufx_data *dev;
> +	struct fb_info *info;
> +
> +	dev = usb_get_intfdata(interface);
> +	info = dev->info;
> +
> +	pr_debug("USB disconnect starting\n");
> +
> +	/* we virtualize until all fb clients release. Then we free */
> +	dev->virtualized = true;
> +
> +	/* When non-active we'll update virtual framebuffer, but no new urbs */
> +	atomic_set(&dev->usb_active, 0);
> +
> +	usb_set_intfdata(interface, NULL);
> +
> +	/* if clients still have us open, will be freed on last close */
> +	if (dev->fb_count = 0)
> +		schedule_delayed_work(&dev->free_framebuffer_work, 0);
> +
> +	/* release reference taken by kref_init in probe() */
> +	kref_put(&dev->kref, ufx_free);
> +
> +	/* consider ufx_data freed */
> +}
> +
> +static struct usb_driver ufx_driver = {
> +	.name = "smscufx",
> +	.probe = ufx_usb_probe,
> +	.disconnect = ufx_usb_disconnect,
> +	.id_table = id_table,
> +};
> +
> +static int __init ufx_module_init(void)
> +{
> +	int res;
> +
> +	res = usb_register(&ufx_driver);
> +	if (res)
> +		err("usb_register failed. Error number %d", res);
> +
> +	return res;
> +}
> +
> +static void __exit ufx_module_exit(void)
> +{
> +	usb_deregister(&ufx_driver);
> +}
> +
> +module_init(ufx_module_init);
> +module_exit(ufx_module_exit);
> +
> +static void ufx_urb_completion(struct urb *urb)
> +{
> +	struct urb_node *unode = urb->context;
> +	struct ufx_data *dev = unode->dev;
> +	unsigned long flags;
> +
> +	/* sync/async unlink faults aren't errors */
> +	if (urb->status) {
> +		if (!(urb->status = -ENOENT ||
> +		    urb->status = -ECONNRESET ||
> +		    urb->status = -ESHUTDOWN)) {
> +			pr_err("%s - nonzero write bulk status received: %d\n",
> +				__func__, urb->status);
> +			atomic_set(&dev->lost_pixels, 1);
> +		}
> +	}
> +
> +	urb->transfer_buffer_length = dev->urbs.size; /* reset to actual */
> +
> +	spin_lock_irqsave(&dev->urbs.lock, flags);
> +	list_add_tail(&unode->entry, &dev->urbs.list);
> +	dev->urbs.available++;
> +	spin_unlock_irqrestore(&dev->urbs.lock, flags);
> +
> +	/* When using fb_defio, we deadlock if up() is called
> +	 * while another is waiting. So queue to another process */
> +	if (fb_defio)
> +		schedule_delayed_work(&unode->release_urb_work, 0);
> +	else
> +		up(&dev->urbs.limit_sem);
> +}
> +
> +static void ufx_free_urb_list(struct ufx_data *dev)
> +{
> +	int count = dev->urbs.count;
> +	struct list_head *node;
> +	struct urb_node *unode;
> +	struct urb *urb;
> +	int ret;
> +	unsigned long flags;
> +
> +	pr_debug("Waiting for completes and freeing all render urbs\n");
> +
> +	/* keep waiting and freeing, until we've got 'em all */
> +	while (count--) {
> +		/* Getting interrupted means a leak, but ok at shutdown*/
> +		ret = down_interruptible(&dev->urbs.limit_sem);
> +		if (ret)
> +			break;
> +
> +		spin_lock_irqsave(&dev->urbs.lock, flags);
> +
> +		node = dev->urbs.list.next; /* have reserved one with sem */
> +		list_del_init(node);
> +
> +		spin_unlock_irqrestore(&dev->urbs.lock, flags);
> +
> +		unode = list_entry(node, struct urb_node, entry);
> +		urb = unode->urb;
> +
> +		/* Free each separately allocated piece */
> +		usb_free_coherent(urb->dev, dev->urbs.size,
> +				  urb->transfer_buffer, urb->transfer_dma);
> +		usb_free_urb(urb);
> +		kfree(node);
> +	}
> +}
> +
> +static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size)
> +{
> +	int i = 0;
> +	struct urb *urb;
> +	struct urb_node *unode;
> +	char *buf;
> +
> +	spin_lock_init(&dev->urbs.lock);
> +
> +	dev->urbs.size = size;
> +	INIT_LIST_HEAD(&dev->urbs.list);
> +
> +	while (i < count) {
> +		unode = kzalloc(sizeof(struct urb_node), GFP_KERNEL);
> +		if (!unode)
> +			break;
> +		unode->dev = dev;
> +
> +		INIT_DELAYED_WORK(&unode->release_urb_work,
> +			  ufx_release_urb_work);
> +
> +		urb = usb_alloc_urb(0, GFP_KERNEL);
> +		if (!urb) {
> +			kfree(unode);
> +			break;
> +		}
> +		unode->urb = urb;
> +
> +		buf = usb_alloc_coherent(dev->udev, size, GFP_KERNEL,
> +					 &urb->transfer_dma);
> +		if (!buf) {
> +			kfree(unode);
> +			usb_free_urb(urb);
> +			break;
> +		}
> +
> +		/* urb->transfer_buffer_length set to actual before submit */
> +		usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 1),
> +			buf, size, ufx_urb_completion, unode);
> +		urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
> +
> +		list_add_tail(&unode->entry, &dev->urbs.list);
> +
> +		i++;
> +	}
> +
> +	sema_init(&dev->urbs.limit_sem, i);
> +	dev->urbs.count = i;
> +	dev->urbs.available = i;
> +
> +	pr_debug("allocated %d %d byte urbs\n", i, (int) size);
> +
> +	return i;
> +}
> +
> +static struct urb *ufx_get_urb(struct ufx_data *dev)
> +{
> +	int ret = 0;
> +	struct list_head *entry;
> +	struct urb_node *unode;
> +	struct urb *urb = NULL;
> +	unsigned long flags;
> +
> +	/* Wait for an in-flight buffer to complete and get re-queued */
> +	ret = down_timeout(&dev->urbs.limit_sem, GET_URB_TIMEOUT);
> +	if (ret) {
> +		atomic_set(&dev->lost_pixels, 1);
> +		pr_warn("wait for urb interrupted: %x available: %d\n",
> +		       ret, dev->urbs.available);
> +		goto error;
> +	}
> +
> +	spin_lock_irqsave(&dev->urbs.lock, flags);
> +
> +	BUG_ON(list_empty(&dev->urbs.list)); /* reserved one with limit_sem */
> +	entry = dev->urbs.list.next;
> +	list_del_init(entry);
> +	dev->urbs.available--;
> +
> +	spin_unlock_irqrestore(&dev->urbs.lock, flags);
> +
> +	unode = list_entry(entry, struct urb_node, entry);
> +	urb = unode->urb;
> +
> +error:
> +	return urb;
> +}
> +
> +static int ufx_submit_urb(struct ufx_data *dev, struct urb *urb, size_t len)
> +{
> +	int ret;
> +
> +	BUG_ON(len > dev->urbs.size);
> +
> +	urb->transfer_buffer_length = len; /* set to actual payload len */
> +	ret = usb_submit_urb(urb, GFP_KERNEL);
> +	if (ret) {
> +		ufx_urb_completion(urb); /* because no one else will */
> +		atomic_set(&dev->lost_pixels, 1);
> +		pr_err("usb_submit_urb error %x\n", ret);
> +	}
> +	return ret;
> +}
> +
> +module_param(console, bool, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP);
> +MODULE_PARM_DESC(console, "Allow fbcon to be used on this display");
> +
> +module_param(fb_defio, bool, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP);
> +MODULE_PARM_DESC(fb_defio, "Enable fb_defio mmap support");
> +
> +MODULE_AUTHOR("Steve Glendinning <steve.glendinning@smsc.com>");
> +MODULE_DESCRIPTION("SMSC UFX kernel framebuffer driver");
> +MODULE_LICENSE("GPL");


^ permalink raw reply

* Re: [PATCH v2 0/8] sh_mobile_lcdc: Support format changes at runtime
From: Florian Tobias Schandinat @ 2011-09-05 17:19 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1314788459-31791-1-git-send-email-laurent.pinchart@ideasonboard.com>

Hi Laurent,

On 08/31/2011 11:00 AM, Laurent Pinchart wrote:
> Hi everybody,
> 
> Here's the second version of the .fb_set_par() support for the sh_mobile_lcdc
> driver patch set. It allows userspace to change the frame buffer format and
> size at runtime. The patches apply on top of Florian's fbdev-next branch
> available at git://github.com/schandinat/linux-2.6.git.
> 
> Compared to v1, this version includes an additional MERAM fix.
> 
> Frame buffer memory reallocation is currently not supported. You will need to
> make sure platform data sets the maximum size and bpp to high enough values
> for all formats and sizes you want to support at runtime.

As you've asked me in
	"[PULL] SH mobile LCDC cleanups and fixes"
I've applied this series as it looks okay to me.


Thanks,

Florian Tobias Schandinat

> 
> The patches have been tested with the fbdev-test utility
> (http://git.ideasonboard.org/?pûdev-test.git;a=summary) on a Mackerel board.
> 
> Laurent Pinchart (8):
>   sh_mobile_meram: Reset ICBs at unregistration time
>   fbdev: sh_mobile_lcdc: Adjust requested parameters in .fb_check_var
>   fbdev: sh_mobile_lcdc: Add support for format changes at runtime
>   fbdev: sh_mobile_lcdc: use display information in info for panning
>   fbdev: sh_mobile_lcdc: Update fix.line_length in .fb_set_par()
>   fbdev: sh_mobile_lcdc: Avoid forward declarations
>   fbdev: sh_mobile_lcdc: Split channel initialization from probe
>     function
>   fbdev: sh_mobile_lcdc: Remove sh_mobile_lcdc_set_bpp()
> 
>  drivers/video/sh_mobile_lcdcfb.c |  570 +++++++++++++++++++++-----------------
>  drivers/video/sh_mobile_meram.c  |    6 +-
>  2 files changed, 313 insertions(+), 263 deletions(-)
> 


^ permalink raw reply

* Re: [PATCH v2 0/8] sh_mobile_lcdc: Support format changes at runtime
From: Laurent Pinchart @ 2011-09-06  8:51 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <1314788459-31791-1-git-send-email-laurent.pinchart@ideasonboard.com>

Hi Florian,

On Monday 05 September 2011 19:19:08 Florian Tobias Schandinat wrote:
> On 08/31/2011 11:00 AM, Laurent Pinchart wrote:
> > Hi everybody,
> > 
> > Here's the second version of the .fb_set_par() support for the
> > sh_mobile_lcdc driver patch set. It allows userspace to change the frame
> > buffer format and size at runtime. The patches apply on top of Florian's
> > fbdev-next branch available at
> > git://github.com/schandinat/linux-2.6.git.
> > 
> > Compared to v1, this version includes an additional MERAM fix.
> > 
> > Frame buffer memory reallocation is currently not supported. You will
> > need to make sure platform data sets the maximum size and bpp to high
> > enough values for all formats and sizes you want to support at runtime.
> 
> As you've asked me in
> 	"[PULL] SH mobile LCDC cleanups and fixes"
> I've applied this series as it looks okay to me.

Thank you.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply

* Re: [PATCH 0/2] video: s3c-fb: Add window positioning support
From: Ajay kumar @ 2011-09-06 14:28 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <4E5FB69E.2060907@gmx.de>

Hi Florian,

On Thu, Sep 1, 2011 at 10:15 PM, Florian Tobias Schandinat
<FlorianSchandinat@gmx.de> wrote:
> Hi all,
>
> On 08/25/2011 07:51 PM, Ajay Kumar wrote:
>> Just as a note, there are many drivers like mx3fb.c, au1200fb.c and OMAP
>> seem to be doing window/plane positioning in their driver code.
>> Is it possible to have this window positioning support at a common place?
>
> Good point. Congratulations for figuring out that I like to standardize things.
> But I think your suggestion is far from being enough to be useful for userspace
> (which is our goal so that applications can be reused along drivers and don't
> need to know about individual drivers).

Thanks for considering the scenerio. Yes, you are right and we need to
start somewhere.

> So let me at first summarize how I understand you implemented those things after
> having a brief look at some of the drivers:
> Windows are rectangular screen areas whose pixel data come from other locations.
> The other locations are accessible via other framebuffer devices (e.g. fb1). So
> in this area the data of fb1 is shown and not the data of fb0 that would be
> normally shown.

Yes, thats right! The area not covered by the other framebuffer
device/window (e.g. fb1) will be transparent and the framebuffer
device/window below (e.g. fb0) will be visible.

> So in addition to your proposed positioning I think we should also have the
> following to give userspace a useful set of functionality:
>
> - a way to discover how the screen is composited (how many windows are there,
> how they are stacked and how to access those)

This will need more discussions, as the amount of information to be
exposed to the user-space might vary from controller-to-controller.

> - a way to enable/disable windows (make them (in)visible)

This is already present. Switching on/off any particular framebuffer
device/window can be done by calling ioctl with FBIOBLANK, from user
space.

> - reporting and selecting how the window content can be mixed with the root
> screen (overwrite, source or destination color keying)

Yes, thats a good point. This can be achieved by implementing ioctl call

> - things like window size and color format could be handled by the usual fb API
> used on the window. However there might be restrictions which cause them to be
> not 100% API compatible (for example when changing the color format if the
> windows are required to have the same format as the root screen)

This seems to be more to do with the property of the FB controller.
Moreover, the driver can always enforce checks on such hardware
restrictions.

> - do we need to worry about hardware (up/down) scaling of the window content?

The user application should take care of these functions, as this is
directly related to the window size. (Usually these operations are
handled by some separate hardware modules (post-processors) )

>
> So is that what you need for a standardized window implementation?
> Any additional things that were useful/needed in this context?
> Would you consider adding support for this API in your drivers? (as
> standardizing wouldn't be useful if nobody would implement it)

Yes, having these missing features will definitely give the user much
more control over the various available framebuffer devices/windows.
We would like to start with the fb window re-positioning feature and
add more features in coming days.

>
> Best regards,
>
> Florian Tobias Schandinat
>

Thanks for your review and suggestions. It was very helpful.

Best Regards,
Ajay Kumar

^ permalink raw reply

* [PATCH] smscufx: reduce number of casts in ufx_raw_rect
From: Steve Glendinning @ 2011-09-07  9:34 UTC (permalink / raw)
  To: linux-fbdev

Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
---
 drivers/video/smscufx.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
index c6b86e7..44c8cab 100644
--- a/drivers/video/smscufx.c
+++ b/drivers/video/smscufx.c
@@ -807,7 +807,7 @@ static int ufx_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)
 	return 0;
 }
 
-static void ufx_raw_rect(struct ufx_data *dev, char *cmd, int x, int y,
+static void ufx_raw_rect(struct ufx_data *dev, u16 *cmd, int x, int y,
 	int width, int height)
 {
 	size_t packed_line_len = ALIGN((width * 2), 4);
@@ -821,27 +821,27 @@ static void ufx_raw_rect(struct ufx_data *dev, char *cmd, int x, int y,
 	*((u32 *)&cmd[0]) = cpu_to_le32(0x01);
 
 	/* length word */
-	*((u32 *)&cmd[4]) = cpu_to_le32(packed_rect_len + 16);
+	*((u32 *)&cmd[2]) = cpu_to_le32(packed_rect_len + 16);
 
-	*((u16 *)&cmd[8]) = cpu_to_le16(x);
-	*((u16 *)&cmd[10]) = cpu_to_le16(y);
-	*((u16 *)&cmd[12]) = cpu_to_le16(width);
-	*((u16 *)&cmd[14]) = cpu_to_le16(height);
+	cmd[4] = cpu_to_le16(x);
+	cmd[5] = cpu_to_le16(y);
+	cmd[6] = cpu_to_le16(width);
+	cmd[7] = cpu_to_le16(height);
 
 	/* frame base address */
-	*((u32 *)&cmd[16]) = cpu_to_le32(0 & 0xffffff80);
+	*((u32 *)&cmd[8]) = cpu_to_le32(0);
 
 	/* color mode and horizontal resolution */
-	*((u16 *)&cmd[20]) = cpu_to_le16(0x4000 | dev->info->var.xres);
+	cmd[10] = cpu_to_le16(0x4000 | dev->info->var.xres);
 
 	/* vertical resolution */
-	*((u16 *)&cmd[22]) = cpu_to_le16(dev->info->var.yres);
+	cmd[11] = cpu_to_le16(dev->info->var.yres);
 
 	/* packed data */
 	for (line = 0; line < height; line++) {
 		const int line_offset = dev->info->fix.line_length * (y + line);
 		const int byte_offset = line_offset + (x * BPP);
-		memcpy(&cmd[24 + (packed_line_len * line)],
+		memcpy(&cmd[(24 + (packed_line_len * line)) / 2],
 			(char *)dev->info->fix.smem_start + byte_offset, width * BPP);
 	}
 }
-- 
1.7.2.5


^ permalink raw reply related

* Re: [PATCH 0/2] video: s3c-fb: Add window positioning support
From: Laurent Pinchart @ 2011-09-07 15:31 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <4E5FB69E.2060907@gmx.de>

Hi Florian,

On Thursday 01 September 2011 18:45:18 Florian Tobias Schandinat wrote:
> Hi all,
> 
> On 08/25/2011 07:51 PM, Ajay Kumar wrote:
> > Just as a note, there are many drivers like mx3fb.c, au1200fb.c and OMAP
> > seem to be doing window/plane positioning in their driver code.
> > Is it possible to have this window positioning support at a common place?
> 
> Good point. Congratulations for figuring out that I like to standardize
> things. But I think your suggestion is far from being enough to be useful
> for userspace (which is our goal so that applications can be reused along
> drivers and don't need to know about individual drivers).

Beside standardizing things, do you also like to take them one level higher to 
solve challenging issues ? I know the answer must be yes :-)

The problem at hand here is something we have solved in V4L2 (theoretically 
only for part of it) with the media controller API, the V4L2 subdevs and their 
pad-level format API.

In a nutshell, the media controller lets drivers model hardware as a graph of 
buliding blocks connected through their pads and expose that description to 
userspace applications. In V4L2 most of those blocks are V4L2 subdevs, which 
are abstract building blocks that implement sets of standard operations. Those 
operations are exposed to userspace through the V4L2 subdevs pad-level format 
API, allowing application to configure sizes and selection rectangles at all 
pads in the graph. Selection rectangles can be used to configure cropping and 
composing, which is exactly what the window positioning API needs to do.

Instead of creating a new fbdev-specific API to do the same, shouldn't we try 
to join forces ?

> So let me at first summarize how I understand you implemented those things
> after having a brief look at some of the drivers:
> Windows are rectangular screen areas whose pixel data come from other
> locations. The other locations are accessible via other framebuffer
> devices (e.g. fb1). So in this area the data of fb1 is shown and not the
> data of fb0 that would be normally shown.
> 
> So in addition to your proposed positioning I think we should also have the
> following to give userspace a useful set of functionality:
> 
> - a way to discover how the screen is composited (how many windows are
> there, how they are stacked and how to access those)
> 
> - a way to enable/disable windows (make them (in)visible)
> 
> - reporting and selecting how the window content can be mixed with the root
> screen (overwrite, source or destination color keying)
> 
> - things like window size and color format could be handled by the usual fb
> API used on the window. However there might be restrictions which cause
> them to be not 100% API compatible (for example when changing the color
> format if the windows are required to have the same format as the root
> screen)
> 
> - do we need to worry about hardware (up/down) scaling of the window
> content?
> 
> 
> So is that what you need for a standardized window implementation?
> Any additional things that were useful/needed in this context?
> Would you consider adding support for this API in your drivers? (as
> standardizing wouldn't be useful if nobody would implement it)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply

* Re: [RFC] fbdev: remove display subsystem
From: James Simmons @ 2011-09-07 15:40 UTC (permalink / raw)
  To: Florian Tobias Schandinat; +Cc: linux-fbdev, linux-kernel, Andrew Morton
In-Reply-To: <1315013768-3235-1-git-send-email-FlorianSchandinat@gmx.de>


> This four year old subsystem does not have a single in-tree user
> not even in staging and as far as I know also none out-of-tree.
> I think that justifies removing it which cleans the config up.

The idea was to provide a frame work for text lcd panels, like for example 
the CrystalFontz. Yes no one was interested so I guess having people write 
there own console driver will do.

> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
> Cc: James Simmons <jsimmons@infradead.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>

Ack-By: James Simmons <jsimmons@infradead.org>


^ permalink raw reply

* [PATCH] FB: add early fb blank feature.
From: Inki Dae @ 2011-09-09  5:03 UTC (permalink / raw)
  To: FlorianSchandinat, linux-fbdev
  Cc: akpm, linux-kernel, kyungmin.park, Inki Dae

this patch adds early fb blank feature that this is a callback of
lcd panel driver would be called prior to fb driver's one.
in case of MIPI-DSI based video mode LCD Panel, for lcd power off,
the power off commands should be transferred to lcd panel with display
and mipi-dsi controller enabled because the commands is set to lcd panel
at vsync porch period. on the other hand, in opposite case, the callback
of fb driver should be called prior to lcd panel driver's one because of
same issue. now we could handle call order to fb blank properly.

the order is as the following:

at fb_blank function of fbmem.c
  -> fb_early_notifier_call_chain()
     -> lcd panel driver's early_set_power()
  -> info->fbops->fb_blank()
     -> fb driver's fb_blank()
  -> fb_notifier_call_chain()
     -> lcd panel driver's set_power()

note that early fb blank mode is valid only if lcd_ops->early_blank_mode is 1.
if the value is 0 then early fb blank callback would be ignored.

this patch is based on git repository below:
git://github.com/schandinat/linux-2.6.git
branch: fbdev-next
commit-id: a67472ad1ae040f073e45048cbc5a01195f2e3f5

Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: KyungMin Park <kyungmin.park@samsung.com>
---
 drivers/video/backlight/lcd.c |   77 ++++++++++++++++++++++++++++++++++++++--
 drivers/video/fb_notify.c     |   31 ++++++++++++++++
 drivers/video/fbmem.c         |   25 +++++++------
 include/linux/fb.h            |    4 ++
 include/linux/lcd.h           |   61 ++++++++++++++++++++++++--------
 5 files changed, 167 insertions(+), 31 deletions(-)

diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 71a11ca..066d2bf 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -17,6 +17,37 @@
 
 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
 			   defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
+/* This callback gets called prior to framebuffer's one
+ * when something important happens inside a framebuffer driver.
+ * We're looking if that important event is blanking,
+ * and if it is, we're switching lcd power as well ...
+ */
+static int fb_notifier_early_callback(struct notifier_block *self,
+				 unsigned long event, void *data)
+{
+	struct lcd_device *ld;
+	struct fb_event *evdata = data;
+
+	/* skip all events except FB_EVENT_BLANK. */
+	if (event != FB_EVENT_BLANK)
+		return 0;
+
+	ld = container_of(self, struct lcd_device, fb_early_notif);
+	if (!ld->ops)
+		return 0;
+
+	mutex_lock(&ld->ops_lock);
+	if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) {
+		if (event = FB_EVENT_BLANK) {
+			if (ld->ops->early_set_power)
+				ld->ops->early_set_power(ld,
+						*(int *)evdata->data);
+		}
+	}
+	mutex_unlock(&ld->ops_lock);
+	return 0;
+}
+
 /* This callback gets called when something important happens inside a
  * framebuffer driver. We're looking if that important event is blanking,
  * and if it is, we're switching lcd power as well ...
@@ -55,6 +86,13 @@ static int fb_notifier_callback(struct notifier_block *self,
 	return 0;
 }
 
+static int lcd_register_early_fb(struct lcd_device *ld)
+{
+	memset(&ld->fb_early_notif, 0, sizeof(ld->fb_early_notif));
+	ld->fb_early_notif.notifier_call = fb_notifier_early_callback;
+	return fb_register_early_client(&ld->fb_early_notif);
+}
+
 static int lcd_register_fb(struct lcd_device *ld)
 {
 	memset(&ld->fb_notif, 0, sizeof(ld->fb_notif));
@@ -66,12 +104,26 @@ static void lcd_unregister_fb(struct lcd_device *ld)
 {
 	fb_unregister_client(&ld->fb_notif);
 }
+
+static void lcd_unregister_early_fb(struct lcd_device *ld)
+{
+	fb_unregister_early_client(&ld->fb_notif);
+}
 #else
+static int lcd_register_early_fb(struct lcd_device *ld)
+{
+	return 0;
+}
+
 static int lcd_register_fb(struct lcd_device *ld)
 {
 	return 0;
 }
 
+static inline void lcd_unregister_early_fb(struct lcd_device *ld)
+{
+}
+
 static inline void lcd_unregister_fb(struct lcd_device *ld)
 {
 }
@@ -218,15 +270,30 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
 		return ERR_PTR(rc);
 	}
 
-	rc = lcd_register_fb(new_ld);
-	if (rc) {
-		device_unregister(&new_ld->dev);
-		return ERR_PTR(rc);
+	if (ops->early_blank_mode) {
+		rc = lcd_register_early_fb(new_ld);
+		if (rc)
+			goto err_early_register;
 	}
 
+	rc = lcd_register_fb(new_ld);
+	if (rc)
+		goto err_register;
+
 	new_ld->ops = ops;
 
 	return new_ld;
+
+err_register:
+	if (ops->early_blank_mode)
+		lcd_unregister_early_fb(new_ld);
+
+err_early_register:
+	device_unregister(&new_ld->dev);
+	kfree(new_ld);
+
+	return ERR_PTR(rc);
+
 }
 EXPORT_SYMBOL(lcd_device_register);
 
@@ -242,6 +309,8 @@ void lcd_device_unregister(struct lcd_device *ld)
 		return;
 
 	mutex_lock(&ld->ops_lock);
+	if (ld->ops->early_blank_mode)
+		lcd_unregister_early_fb(ld);
 	ld->ops = NULL;
 	mutex_unlock(&ld->ops_lock);
 	lcd_unregister_fb(ld);
diff --git a/drivers/video/fb_notify.c b/drivers/video/fb_notify.c
index 8c02038..3930c7c 100644
--- a/drivers/video/fb_notify.c
+++ b/drivers/video/fb_notify.c
@@ -13,9 +13,20 @@
 #include <linux/fb.h>
 #include <linux/notifier.h>
 
+static BLOCKING_NOTIFIER_HEAD(fb_early_notifier_list);
 static BLOCKING_NOTIFIER_HEAD(fb_notifier_list);
 
 /**
+ *	fb_register_early_client - register a client early notifier
+ *	@nb: notifier block to callback on events
+ */
+int fb_register_early_client(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&fb_early_notifier_list, nb);
+}
+EXPORT_SYMBOL(fb_register_early_client);
+
+/**
  *	fb_register_client - register a client notifier
  *	@nb: notifier block to callback on events
  */
@@ -26,6 +37,16 @@ int fb_register_client(struct notifier_block *nb)
 EXPORT_SYMBOL(fb_register_client);
 
 /**
+ *	fb_unregister_early_client - unregister a client early notifier
+ *	@nb: notifier block to callback on events
+ */
+int fb_unregister_early_client(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&fb_early_notifier_list, nb);
+}
+EXPORT_SYMBOL(fb_unregister_early_client);
+
+/**
  *	fb_unregister_client - unregister a client notifier
  *	@nb: notifier block to callback on events
  */
@@ -36,6 +57,16 @@ int fb_unregister_client(struct notifier_block *nb)
 EXPORT_SYMBOL(fb_unregister_client);
 
 /**
+ * fb_early_notifier_call_chain - early notify clients of fb_events
+ *
+ */
+int fb_early_notifier_call_chain(unsigned long val, void *v)
+{
+	return blocking_notifier_call_chain(&fb_early_notifier_list, val, v);
+}
+EXPORT_SYMBOL_GPL(fb_early_notifier_call_chain);
+
+/**
  * fb_notifier_call_chain - notify clients of fb_events
  *
  */
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index ad93629..cf22516 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1031,24 +1031,25 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
 
 int
 fb_blank(struct fb_info *info, int blank)
-{	
- 	int ret = -EINVAL;
+{
+	struct fb_event event;
+	int ret = -EINVAL;
 
- 	if (blank > FB_BLANK_POWERDOWN)
- 		blank = FB_BLANK_POWERDOWN;
+	if (blank > FB_BLANK_POWERDOWN)
+		blank = FB_BLANK_POWERDOWN;
 
-	if (info->fbops->fb_blank)
- 		ret = info->fbops->fb_blank(blank, info);
+	event.info = info;
+	event.data = &blank;
 
- 	if (!ret) {
-		struct fb_event event;
+	fb_early_notifier_call_chain(FB_EVENT_BLANK, &event);
 
-		event.info = info;
-		event.data = &blank;
+	if (info->fbops->fb_blank)
+		ret = info->fbops->fb_blank(blank, info);
+
+	if (!ret)
 		fb_notifier_call_chain(FB_EVENT_BLANK, &event);
-	}
 
- 	return ret;
+	return ret;
 }
 
 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 1d6836c..1d7d995 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -562,6 +562,10 @@ struct fb_blit_caps {
 	u32 flags;
 };
 
+extern int fb_register_early_client(struct notifier_block *nb);
+extern int fb_unregister_early_client(struct notifier_block *nb);
+extern int fb_early_notifier_call_chain(unsigned long val, void *v);
+
 extern int fb_register_client(struct notifier_block *nb);
 extern int fb_unregister_client(struct notifier_block *nb);
 extern int fb_notifier_call_chain(unsigned long val, void *v);
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index 8877123..930d1cc 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -37,10 +37,21 @@ struct lcd_properties {
 };
 
 struct lcd_ops {
-	/* Get the LCD panel power status (0: full on, 1..3: controller
-	   power on, flat panel power off, 4: full off), see FB_BLANK_XXX */
+	/*
+	 * Get the LCD panel power status (0: full on, 1..3: controller
+	 * power on, flat panel power off, 4: full off), see FB_BLANK_XXX
+	 */
 	int (*get_power)(struct lcd_device *);
-	/* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */
+	/*
+	 * Get the current contrast setting (0-max_contrast) and
+	 * Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX)
+	 * this callback would be called proir to fb driver's fb_blank callback.
+	 */
+	int (*early_set_power)(struct lcd_device *, int power);
+	/*
+	 * Get the current contrast setting (0-max_contrast)
+	 * Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX)
+	 */
 	int (*set_power)(struct lcd_device *, int power);
 	/* Get the current contrast setting (0-max_contrast) */
 	int (*get_contrast)(struct lcd_device *);
@@ -48,21 +59,35 @@ struct lcd_ops {
         int (*set_contrast)(struct lcd_device *, int contrast);
 	/* Set LCD panel mode (resolutions ...) */
 	int (*set_mode)(struct lcd_device *, struct fb_videomode *);
-	/* Check if given framebuffer device is the one LCD is bound to;
-	   return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */
+	/*
+	 * Check if given framebuffer device is the one LCD is bound to;
+	 * return 0 if not, !=0 if it is. If NULL, lcd always matches the fb.
+	 */
 	int (*check_fb)(struct lcd_device *, struct fb_info *);
+
+	/*
+	 * indicate whether enabling early blank mode or not.
+	 * (0: disable; 1: enable);
+	 * if enabled, lcd blank callback would be called prior
+	 * to fb blank callback.
+	 */
+	unsigned int early_blank_mode;
 };
 
 struct lcd_device {
 	struct lcd_properties props;
-	/* This protects the 'ops' field. If 'ops' is NULL, the driver that
-	   registered this device has been unloaded, and if class_get_devdata()
-	   points to something in the body of that driver, it is also invalid. */
+	/*
+	 * This protects the 'ops' field. If 'ops' is NULL, the driver that
+	 * registered this device has been unloaded, and if class_get_devdata()
+	 * points to something in the body of that driver, it is also invalid.
+	 */
 	struct mutex ops_lock;
 	/* If this is NULL, the backing module is unloaded */
 	struct lcd_ops *ops;
 	/* Serialise access to set_power method */
 	struct mutex update_lock;
+	/* The framebuffer early notifier block */
+	struct notifier_block fb_early_notif;
 	/* The framebuffer notifier block */
 	struct notifier_block fb_notif;
 
@@ -72,16 +97,22 @@ struct lcd_device {
 struct lcd_platform_data {
 	/* reset lcd panel device. */
 	int (*reset)(struct lcd_device *ld);
-	/* on or off to lcd panel. if 'enable' is 0 then
-	   lcd power off and 1, lcd power on. */
+	/*
+	 * on or off to lcd panel. if 'enable' is 0 then
+	 * lcd power off and 1, lcd power on.
+	 */
 	int (*power_on)(struct lcd_device *ld, int enable);
 
-	/* it indicates whether lcd panel was enabled
-	   from bootloader or not. */
+	/*
+	 * it indicates whether lcd panel was enabled
+	 * from bootloader or not.
+	 */
 	int lcd_enabled;
-	/* it means delay for stable time when it becomes low to high
-	   or high to low that is dependent on whether reset gpio is
-	   low active or high active. */
+	/*
+	 * it means delay for stable time when it becomes low to high
+	 * or high to low that is dependent on whether reset gpio is
+	 * low active or high active.
+	 */
 	unsigned int reset_delay;
 	/* stable time needing to become lcd power on. */
 	unsigned int power_on_delay;
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH V4 RESEND 1/6] video: s3c-fb: Add S5P64X0 specific
From: Ajay Kumar @ 2011-09-09 12:01 UTC (permalink / raw)
  To: linux-arm-kernel

This patch:
	-- Adds s3c_fb_driverdata for S5P64X0, which supports 3 windows.
	-- Also, register "s5p64x0-fb" type driver_data.

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
---
 drivers/video/s3c-fb.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index 4aecf21..0fda252 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -1859,6 +1859,30 @@ static struct s3c_fb_driverdata s3c_fb_data_s3c2443 = {
 	},
 };
 
+static struct s3c_fb_driverdata s3c_fb_data_s5p64x0 = {
+	.variant = {
+		.nr_windows	= 3,
+		.vidtcon	= VIDTCON0,
+		.wincon		= WINCON(0),
+		.winmap		= WINxMAP(0),
+		.keycon		= WKEYCON,
+		.osd		= VIDOSD_BASE,
+		.osd_stride	= 16,
+		.buf_start	= VIDW_BUF_START(0),
+		.buf_size	= VIDW_BUF_SIZE(0),
+		.buf_end	= VIDW_BUF_END(0),
+
+		.palette = {
+			[0] = 0x2400,
+			[1] = 0x2800,
+			[2] = 0x2c00,
+		},
+	},
+	.win[0] = &s3c_fb_data_s5p_wins[0],
+	.win[1] = &s3c_fb_data_s5p_wins[1],
+	.win[2] = &s3c_fb_data_s5p_wins[2],
+};
+
 static struct platform_device_id s3c_fb_driver_ids[] = {
 	{
 		.name		= "s3c-fb",
@@ -1872,6 +1896,9 @@ static struct platform_device_id s3c_fb_driver_ids[] = {
 	}, {
 		.name		= "s3c2443-fb",
 		.driver_data	= (unsigned long)&s3c_fb_data_s3c2443,
+	}, {
+		.name		= "s5p64x0-fb",
+		.driver_data	= (unsigned long)&s3c_fb_data_s5p64x0,
 	},
 	{},
 };
-- 
1.7.0.4


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox