Skip to contentSkip to conversation

FB deffered io: keep pagelist sorted

PATCH New Yauhen Kharuzhy 4 participants 12 messages Jul 11, 2008 – Sep 24, 2008

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

PATCH 1/1 FB deffered io: keep pagelist sorted

eInk display drivers will do less work if list of
changed pages will be sorted.

Apollo controller has 'Partial Update' feature --- updating only a part of a image, which can be done in small time.

---
 drivers/video/fb_defio.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/video/fb_defio.c +6 -1
index 24843fd..5517e51 100644
@@ -74,6 +74,7 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 {
 	struct fb_info *info = vma->vm_private_data;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
+	struct page *cur;
 
 	/* this is a callback we get when userspace first tries to
 	write to the page. we schedule a workqueue. that workqueue
@@ -83,7 +84,11 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 
 	/* protect against the workqueue changing the page list */
 	mutex_lock(&fbdefio->lock);
-	list_add(&page->lru, &fbdefio->pagelist);
+	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
+		if (cur->index > page->index)
+			break;
+	}
+	list_add(&page->lru, cur->lru.prev);
 	mutex_unlock(&fbdefio->lock);
 
 	/* come back after delay to process the deferred IO */
Signature · 8 lines
1.5.6


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
#1 lore raw

PATCH 1/1 eink_apollofb: new driver for Apollo eInk controller.

Add a new driver for eInk Apollo controller. This controller is used in various bookreaders with eInk displays.

The eink_apollofb driver supports many features of Apollo chip, in difference with the hecubafb driver:
2-bit color depth, partial picture loading, flash read/write.

The driver uses platform_device framework for platform-specific functions (set values of control lines, read/write data from/to bus etc.) and can be used on any platform.

This driver has been developed for the OpenInkpot
project (http://openinkpot.org/).

---
 drivers/video/Kconfig         |   17 +
 drivers/video/Makefile        |    1 +
 drivers/video/eink_apollofb.c |  969 +++++++++++++++++++++++++++++++++++++++++
 include/linux/eink_apollofb.h |   60 +++
 4 files changed, 1047 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/eink_apollofb.c
 create mode 100644 include/linux/eink_apollofb.h
drivers/video/Kconfig +17 -0
index e0c5f96..ad23464 100644
@@ -718,6 +718,23 @@ config FB_N411
          This enables support for the Apollo display controller in its
          Hecuba form using the n411 devkit.
 
+config FB_EINK_APOLLO
+       tristate "Apollo eInk display controller support"
+       depends on EXPERIMENTAL && FB && MMU
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select FB_SYS_FOPS
+       select FB_DEFERRED_IO
+       help
+         This enables support for Apollo eInk display controller.
+	 Includes support of deferred IO and 2-bit grayscale mode.
+
+	 Hardware-specific functions have been moved to platform data.
+
+	 To compile this driver as a module, choose M here: the
+	 module will be called eink_apollofb.
+
 config FB_HGA
 	tristate "Hercules mono graphics support"
 	depends on FB && X86
drivers/video/Makefile +1 -0
index 04bca35..2530f0c 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_FB_ATARI)            += atafb.o c2p.o atafb_mfb.o \
                                      atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o
 obj-$(CONFIG_FB_MAC)              += macfb.o
 obj-$(CONFIG_FB_HECUBA)           += hecubafb.o
+obj-$(CONFIG_FB_EINK_APOLLO)      += eink_apollofb.o
 obj-$(CONFIG_FB_HGA)              += hgafb.o
 obj-$(CONFIG_FB_XVR500)           += sunxvr500.o
 obj-$(CONFIG_FB_XVR2500)          += sunxvr2500.o
drivers/video/eink_apollofb.c new file +969 -0

969 lines not on this page · raw message

include/linux/eink_apollofb.h new file +60 -0

60 lines not on this page · raw message

Signature · 8 lines
1.5.6


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
#2 lore raw

PATCH 1/1 FB deffered io: keep pagelist sorted

In reply to Yauhen Kharuzhy

eInk display drivers will do less work if list of
changed pages will be sorted.

Apollo controller has 'Partial Update' feature --- updating only a part of a image, which can be done in small time.

---
 drivers/video/fb_defio.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/video/fb_defio.c +6 -1
index 24843fd..5517e51 100644
@@ -74,6 +74,7 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 {
 	struct fb_info *info = vma->vm_private_data;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
+	struct page *cur;
 
 	/* this is a callback we get when userspace first tries to
 	write to the page. we schedule a workqueue. that workqueue
@@ -83,7 +84,11 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 
 	/* protect against the workqueue changing the page list */
 	mutex_lock(&fbdefio->lock);
-	list_add(&page->lru, &fbdefio->pagelist);
+	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
+		if (cur->index > page->index)
+			break;
+	}
+	list_add(&page->lru, cur->lru.prev);
 	mutex_unlock(&fbdefio->lock);
 
 	/* come back after delay to process the deferred IO */
Signature · 8 lines
1.5.6


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
#3 lore raw

PATCH 1/1 eink_apollofb: new driver for Apollo eInk controller.

Add a new driver for eInk Apollo controller. This controller is used in various bookreaders with eInk displays.

The eink_apollofb driver supports many features of Apollo chip, in difference with the hecubafb driver:
2-bit color depth, partial picture loading, flash read/write.

The driver uses platform_device framework for platform-specific functions (set values of control lines, read/write data from/to bus etc.) and can be used on any platform.

This driver has been developed for the OpenInkpot
project (http://openinkpot.org/).

---
 drivers/video/Kconfig         |   17 +
 drivers/video/Makefile        |    1 +
 drivers/video/eink_apollofb.c |  969 +++++++++++++++++++++++++++++++++++++++++
 include/linux/eink_apollofb.h |   60 +++
 4 files changed, 1047 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/eink_apollofb.c
 create mode 100644 include/linux/eink_apollofb.h
drivers/video/Kconfig +17 -0
index e0c5f96..ad23464 100644
@@ -718,6 +718,23 @@ config FB_N411
          This enables support for the Apollo display controller in its
          Hecuba form using the n411 devkit.
 
+config FB_EINK_APOLLO
+       tristate "Apollo eInk display controller support"
+       depends on EXPERIMENTAL && FB && MMU
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select FB_SYS_FOPS
+       select FB_DEFERRED_IO
+       help
+         This enables support for Apollo eInk display controller.
+	 Includes support of deferred IO and 2-bit grayscale mode.
+
+	 Hardware-specific functions have been moved to platform data.
+
+	 To compile this driver as a module, choose M here: the
+	 module will be called eink_apollofb.
+
 config FB_HGA
 	tristate "Hercules mono graphics support"
 	depends on FB && X86
drivers/video/Makefile +1 -0
index 04bca35..2530f0c 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_FB_ATARI)            += atafb.o c2p.o atafb_mfb.o \
                                      atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o
 obj-$(CONFIG_FB_MAC)              += macfb.o
 obj-$(CONFIG_FB_HECUBA)           += hecubafb.o
+obj-$(CONFIG_FB_EINK_APOLLO)      += eink_apollofb.o
 obj-$(CONFIG_FB_HGA)              += hgafb.o
 obj-$(CONFIG_FB_XVR500)           += sunxvr500.o
 obj-$(CONFIG_FB_XVR2500)          += sunxvr2500.o
drivers/video/eink_apollofb.c new file +969 -0

969 lines not on this page · raw message

include/linux/eink_apollofb.h new file +60 -0

60 lines not on this page · raw message

Signature · 8 lines
1.5.6


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
#11 lore raw
In reply to Yauhen Kharuzhy
Quoted 27 lines · On Fri, 11 Jul 2008 17:54:30 +0300 Yauhen Kharuzhy <[email protected]> wrote:

eInk display drivers will do less work if list of
changed pages will be sorted.

Apollo controller has 'Partial Update' feature --- updating only a part of a image, which can be done in small time.

---
 drivers/video/fb_defio.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/video/fb_defio.c +1 -0
index 24843fd..5517e51 100644
@@ -74,6 +74,7 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 {
 	struct fb_info *info = vma->vm_private_data;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
+	struct page *cur;
 
 	/* this is a callback we get when userspace first tries to
 	write to the page. we schedule a workqueue. that workqueue
@@ -83,7 +84,11 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 
 	/* protect against the workqueue changing the page list */

drivers/video/fb_defio.c static int fb_deferred_io_mkwrite(struct vm_area_struct *vma, · line 94

Quoted 10 lines
drivers/video/fb_defio.c +5 -1
 	mutex_lock(&fbdefio->lock);
-	list_add(&page->lru, &fbdefio->pagelist);
+	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
+		if (cur->index > page->index)
+			break;
+	}
+	list_add(&page->lru, cur->lru.prev);
 	mutex_unlock(&fbdefio->lock);
 
 	/* come back after delay to process the deferred IO */

We just merged the below:

From: Jaya Kumar <[email protected]>

This patch is a bugfix for how defio handles multiple processes manipulating the same framebuffer.

Thanks to Bernard Blackham for identifying this bug.

It occurs when two applications mmap the same framebuffer and concurrently write to the same page. Normally, this doesn't occur since only a single process mmaps the framebuffer. The symptom of the bug is that the mapping applications will hang. The cause is that defio incorrectly tries to add the same page twice to the pagelist. The solution I have is to walk the pagelist and check for a duplicate before adding. Since I needed to walk the pagelist, I now also keep the pagelist in sorted order.

---

 drivers/video/fb_defio.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/video/fb_defio.c renamed from drivers/video/fb_defio.c~fbdev-bugfix-for-multiprocess-defio +19 -1
diff -puN drivers/video/fb_defio.c~fbdev-bugfix-for-multiprocess-defio drivers/video/fb_defio.c
@@ -74,6 +74,7 @@ static int fb_deferred_io_mkwrite(struct
 {
 	struct fb_info *info = vma->vm_private_data;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
+	struct page *cur;
 
 	/* this is a callback we get when userspace first tries to
 	write to the page. we schedule a workqueue. that workqueue
@@ -83,7 +84,24 @@ static int fb_deferred_io_mkwrite(struct
 
 	/* protect against the workqueue changing the page list */
 	mutex_lock(&fbdefio->lock);
-	list_add(&page->lru, &fbdefio->pagelist);
+
+	/* we loop through the pagelist before adding in order
+	to keep the pagelist sorted */
+	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
+		/* this check is to catch the case where a new
+		process could start writing to the same page
+		through a new pte. this new access can cause the
+		mkwrite even when the original ps's pte is marked
+		writable */
+		if (unlikely(cur == page))
+			goto page_already_added;
+		else if (cur->index > page->index)
+			break;
+	}
+
+	list_add_tail(&page->lru, &cur->lru);
+
+page_already_added:
 	mutex_unlock(&fbdefio->lock);
 
 	/* come back after delay to process the deferred IO */

_

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08

#4 lore raw

Re: [PATCH] eink_apollofb: new driver for Apollo eInk controller.

In reply to Yauhen Kharuzhy
Quoted 9 lines · On Fri, 11 Jul 2008 17:54:31 +0300 Yauhen Kharuzhy <[email protected]> wrote:

Add a new driver for eInk Apollo controller. This controller is used in various bookreaders with eInk displays.

The eink_apollofb driver supports many features of Apollo chip, in difference with the hecubafb driver:
2-bit color depth, partial picture loading, flash read/write.

Quoted 7 lines

The driver uses platform_device framework for platform-specific functions (set values of control lines, read/write data from/to bus etc.) and can be used on any platform.

This driver has been developed for the OpenInkpot project (http://openinkpot.org/).

Please copy linux-fbdev-devel on fbdev patches.

Please consider adding a MAINTAINERS record when adding new drivers.

checkpatch correctly warns:

WARNING: consider using strict_strtoul in preference to simple_strtoul #703: FILE: drivers/video/eink_apollofb.c:573:
+ unsigned long state = simple_strtoul(buf, &after, 10);

WARNING: consider using strict_strtoul in preference to simple_strtoul #734: FILE: drivers/video/eink_apollofb.c:604:
+ unsigned long state = simple_strtoul(buf, &after, 10);

WARNING: consider using strict_strtoul in preference to simple_strtoul #773: FILE: drivers/video/eink_apollofb.c:643:
+ unsigned long state = simple_strtoul(buf, &after, 10);

Quoted 9 lines
drivers/video/Kconfig +1 -0
index e0c5f96..ad23464 100644
@@ -718,6 +718,23 @@ config FB_N411
          This enables support for the Apollo display controller in its
          Hecuba form using the n411 devkit.
 
+config FB_EINK_APOLLO

drivers/video/Kconfig config FB_N411 · line 731

Quoted 10 lines
drivers/video/Kconfig +10 -0
+       tristate "Apollo eInk display controller support"
+       depends on EXPERIMENTAL && FB && MMU
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select FB_SYS_FOPS
+       select FB_DEFERRED_IO
+       help
+         This enables support for Apollo eInk display controller.
+	 Includes support of deferred IO and 2-bit grayscale mode.

Whitespace inconsistency there, which I will fix.

drivers/video/Kconfig

Quoted 8 lines

...

drivers/video/Kconfig +5 -0
+/* Display specific information */
+#define DPY_W 600
+#define DPY_H 800
+
+#define is_portrait(var) (!(var.rotate % 180))

Could be implemented in a C function.

Quoted 10 lines

...

drivers/video/Kconfig +7 -0
+static inline int apollo_wait_for_ack_value(struct apollofb_par *par,
+		unsigned int value)
+{
+	unsigned long timeout = jiffies + 2 * HZ;
+
+	while ((par->ops->get_ctl_pin(H_ACK) != value) &&
+			time_before(jiffies, timeout))

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+		schedule();
+
+	if (par->ops->get_ctl_pin(H_ACK) != value) {
+		printk(KERN_ERR "%s: Wait for H_ACK == %u, timeout\n",
+				__func__, value);
+		return 1;
+	}
+
+	return 0;
+}

Is a busy-wait unavoidable here?

Are you sure this function is never called from atomic context?

This function is far too large to inline. I'll fix that.

drivers/video/Kconfig

Quoted 2 lines
drivers/video/Kconfig +2 -0
+#define apollo_wait_for_ack(par)	apollo_wait_for_ack_value(par, 0)
+#define apollo_wait_for_ack_clear(par)	apollo_wait_for_ack_value(par, 1)

Could be implemented as C functions.

Quoted 4 lines
drivers/video/Kconfig +4 -0
+static int apollo_send_data(struct apollofb_par *par, unsigned char data)
+{
+	int res = 0;;
+

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+	par->ops->write_value(data);
+	par->ops->set_ctl_pin(H_DS, 0);
+	res = apollo_wait_for_ack(par);
+	par->ops->set_ctl_pin(H_DS, 1);
+	if (!res)
+		apollo_wait_for_ack_clear(par);
+	return res;
+}
+
+

extra newline

Quoted 19 lines

...

drivers/video/Kconfig +16 -0
+static void apollofb_apollo_update_part(struct apollofb_par *par,
+		unsigned int x1, unsigned int y1,
+		unsigned int x2, unsigned int y2)
+{
+	int i, j, k;
+	struct fb_info *info = par->info;
+	unsigned int width = is_portrait(info->var) ? info->var.xres :
+							info->var.yres;
+	unsigned int bpp = info->var.green.length;
+	unsigned int pixels_in_byte = 8 / bpp;
+	unsigned char *buf = (unsigned char __force *)info->screen_base;
+	unsigned char tmp, mask;
+
+	y1 -= y1 % 4;
+
+	if ((y2 + 1) % 4)

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+		y2 += 4 - ((y2 + 1) % 4);
+
+	x1 -= x1 % 4;
+
+	if ((x2 + 1) % 4)
+		x2 += 4 - ((x2 + 1) % 4);
+
+	mask = 0;
+	for (i = 0; i < bpp; i++)
+		mask = (mask << 1) | 1;

I think this is this equivalent to

	(1 << bpp) - 1
Quoted 42 lines
drivers/video/Kconfig +42 -0
+	mutex_lock(&par->lock);
+
+	if (par->current_mode == APOLLO_STATUS_MODE_SLEEP)
+		apollo_set_normal_mode(par);
+
+	if (par->options.manual_refresh)
+		apollo_send_command(par, APOLLO_MANUAL_REFRESH);
+
+	apollo_send_command(par, APOLLO_LOAD_PARTIAL_PICTURE);
+	apollo_send_data(par, (x1 >> 8) & 0xff);
+	apollo_send_data(par, x1 & 0xff);
+	apollo_send_data(par, (y1 >> 8) & 0xff);
+	apollo_send_data(par, y1 & 0xff);
+	apollo_send_data(par, (x2 >> 8) & 0xff);
+	apollo_send_data(par, x2 & 0xff);
+	apollo_send_data(par, (y2 >> 8) & 0xff);
+	apollo_send_data(par, y2 & 0xff);
+
+	k = 0;
+	tmp = 0;
+	for (i = y1; i <= y2; i++)
+		for (j = x1; j <= x2; j++) {
+			tmp = (tmp << bpp) | (buf[i * width + j] & mask);
+			k++;
+			if (k % pixels_in_byte == 0)
+				apollo_send_data(par, tmp);
+		}
+
+	apollo_send_command(par, APOLLO_STOP_LOADING);
+	apollo_send_command(par, APOLLO_DISPLAY_PARTIAL_PICTURE);
+
+	if (par->options.use_sleep_mode)
+		apollo_set_sleep_mode(par);
+
+	mutex_unlock(&par->lock);
+}
+
+/* this is called back from the deferred io workqueue */
+static void apollofb_dpy_deferred_io(struct fb_info *info,
+				struct list_head *pagelist)
+{
+

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+	struct apollofb_par *par = info->par;
+	unsigned int width = is_portrait(info->var) ? info->var.xres :
+							info->var.yres;
+	unsigned int height = is_portrait(info->var) ? info->var.yres :
+							info->var.xres;
+	unsigned long int start_page = -1, end_page = -1;
+	unsigned int y1 = 0, y2 = 0;
+	struct page *cur;
+
+

extra newline

Quoted 33 lines
drivers/video/Kconfig +30 -0
+	list_for_each_entry(cur, pagelist, lru) {
+		if (start_page == -1) {
+			start_page = cur->index;
+			end_page = cur->index;
+			continue;
+		}
+
+		if (cur->index == end_page + 1) {
+			end_page++;
+		} else {
+			y1 = start_page * PAGE_SIZE / width;
+			y2 = ((end_page + 1) * PAGE_SIZE - 1) / width;
+			if (y2 >= height)
+				y2 = height - 1;
+
+			apollofb_apollo_update_part(par, 0, y1, width - 1, y2);
+
+			start_page = cur->index;
+			end_page = cur->index;
+		}
+	}
+
+	y1 = start_page * PAGE_SIZE / width;
+	y2 = ((end_page + 1) * PAGE_SIZE - 1) / width;
+	if (y2 >= height)
+		y2 = height - 1;
+
+	apollofb_apollo_update_part(par, 0, y1,	width - 1, y2);
+}
+
 
...
 

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +9 -0
 
+static void apollofb_imageblit(struct fb_info *info,
+				const struct fb_image *image)
+{
+	struct apollofb_par *par = info->par;
+
+	sys_imageblit(info, image);
+
+	schedule_delayed_work(&par->deferred_work, info->fbdefio->delay);
+}

hrm. The sys_foo namespace is normally for system calls. Looks like the fbdev layer has been involved in a bit of namespace piracy.

drivers/video/Kconfig

Quoted 4 lines
drivers/video/Kconfig +4 -0
+int apollofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
+{
+	return 0;
+}

I made this static.

Quoted 16 lines
drivers/video/Kconfig +16 -0
+/*
+ * this is the slow path from userspace. they can seek and write to
+ * the fb. it's inefficient to do anything less than a full screen draw
+ */
+static ssize_t apollofb_write(struct fb_info *info, const char __user *buf,
+				size_t count, loff_t *ppos)
+{
+	unsigned long p;
+	int err = -EINVAL;
+	struct apollofb_par *par;
+	unsigned int xres;
+	unsigned int fbmemlength;
+
+	p = *ppos;
+	par = info->par;
+	xres = info->var.xres;

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+	fbmemlength = (xres * info->var.yres)/8 * info->var.bits_per_pixel;
+
+	if (p > fbmemlength)
+		return -ENOSPC;
+
+	err = 0;
+	if ((count + p) > fbmemlength) {
+		count = fbmemlength - p;
+		err = -ENOSPC;
+	}

ENOSPC is "ran out of disk space". It's a bit weird to use it here. EINVAL would make more sense?

Quoted 27 lines
drivers/video/Kconfig +24 -0
+	if (count) {
+		char *base_addr;
+
+		base_addr = (char __force *)info->screen_base;
+		count -= copy_from_user(base_addr + p, buf, count);
+		*ppos += count;
+		err = -EFAULT;
+	}
+
+	schedule_delayed_work(&par->deferred_work, info->fbdefio->delay);
+
+	if (count)
+		return count;
+
+	return err;
+}
+
 
...
 
+static ssize_t apollofb_temperature_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct fb_info *info = dev_get_drvdata(dev);
+	struct apollofb_par *par = info->par;
+	char temp;
+

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+	mutex_lock(&par->lock);
+
+	apollo_send_command(par, APOLLO_READ_TEMPERATURE);
+
+	temp = apollo_read_data(par);
+
+	mutex_unlock(&par->lock);
+
+	sprintf(buf, "%d\n", temp);
+	return strlen(buf) + 1;

I think

	return sprintf(buf, "%d\n", temp);

would work here. Not sure about the accounting of the trailing \0.

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+}
+
+static ssize_t apollofb_manual_refresh_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct fb_info *info = dev_get_drvdata(dev);
+	struct apollofb_par *par = info->par;
+
+	sprintf(buf, "%d\n", par->options.manual_refresh);
+	return strlen(buf) + 1;

ditto.

Quoted 21 lines
drivers/video/Kconfig +21 -0
+}
+
+static ssize_t apollofb_manual_refresh_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t size)
+{
+	struct fb_info *info = dev_get_drvdata(dev);
+	struct apollofb_par *par = info->par;
+	char *after;
+	unsigned long state = simple_strtoul(buf, &after, 10);
+	size_t count = after - buf;
+	ssize_t ret = -EINVAL;
+
+	if (*after && isspace(*after))
+		count++;
+
+	if ((count == size) && (state <= 1)) {
+		ret = count;
+		par->options.manual_refresh = state;
+	}
+
+	return ret;

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+}
+
+static ssize_t apollofb_use_sleep_mode_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct fb_info *info = dev_get_drvdata(dev);
+	struct apollofb_par *par = info->par;
+
+	sprintf(buf, "%d\n", par->options.use_sleep_mode);
+	return strlen(buf) + 1;

tritto

Quoted 22 lines
drivers/video/Kconfig +22 -0
+}
+
+static ssize_t apollofb_use_sleep_mode_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t size)
+{
+	struct fb_info *info = dev_get_drvdata(dev);
+	struct apollofb_par *par = info->par;
+	char *after;
+	unsigned long state = simple_strtoul(buf, &after, 10);
+	size_t count = after - buf;
+	ssize_t ret = -EINVAL;
+
+	if (*after && isspace(*after))
+		count++;
+
+	if ((count == size) && (state <= 1)) {
+		ret = count;
+		par->options.use_sleep_mode = state;
+
+		mutex_lock(&par->lock);
+
+		if (state)

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+			apollo_set_sleep_mode(par);
+		else
+			apollo_set_normal_mode(par);
+
+		mutex_unlock(&par->lock);
+
+	}
+
+	return ret;
+}

Is this usersapce interface documented anywhere?

drivers/video/Kconfig

Quoted 7 lines
drivers/video/Kconfig +7 -0
+static ssize_t apollofb_defio_delay_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct fb_info *info = dev_get_drvdata(dev);
+
+	sprintf(buf, "%lu\n", info->fbdefio->delay * 1000 / HZ);
+	return strlen(buf) + 1;

whatever comes after tritto ;)

Quoted 16 lines
drivers/video/Kconfig +16 -0
+}
+
+static ssize_t apollofb_defio_delay_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t size)
+{
+	struct fb_info *info = dev_get_drvdata(dev);
+	char *after;
+	unsigned long state = simple_strtoul(buf, &after, 10);
+	size_t count = after - buf;
+	ssize_t ret = -EINVAL;
+
+	if (*after && isspace(*after))
+		count++;
+
+	state = state * HZ / 1000;
+

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+	if (!state)
+		state = 1;
+
+	if (count == size) {
+		ret = count;
+		info->fbdefio->delay = state;
+	}
+
+	return ret;
+}

See, there might be simpler ways of doing all this string parsing. But there's no description of what it's doing and I can't be bothered reverse-engineering it.

drivers/video/Kconfig

Quoted 5 lines
drivers/video/Kconfig +5 -0
+static void apollofb_remove_chrdev(struct apollofb_par *par)
+{
+	cdev_del(&par->cdev);
+	unregister_chrdev_region(par->cdev.dev, 1);
+}

It creates a chardev as well? Please, these things must be documented _at least_ in the changelog. Fully.

Quoted 12 lines
drivers/video/Kconfig +10 -0
+static u16 red4[] __read_mostly = {
+    0x0000, 0x5555, 0xaaaa, 0xffff
+};
+static u16 green4[] __read_mostly = {
+    0x0000, 0x5555, 0xaaaa, 0xffff
+};
+static u16 blue4[] __read_mostly = {
+    0x0000, 0x5555, 0xaaaa, 0xffff
+};
+
 
...

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +9 -0
 
+static int __devexit apollofb_remove(struct platform_device *dev)
+{
+	struct fb_info *info = platform_get_drvdata(dev);
+	struct apollofb_par *par = info->par;
+
+	if (info) {
+		fb_deferred_io_cleanup(info);
+		cancel_delayed_work(&par->deferred_work);
+		flush_scheduled_work();

I suspect cancel_delayed_work_sync() would suffice here.

Quoted 29 lines
drivers/video/Kconfig +29 -0
+		device_remove_file(info->dev, &dev_attr_use_sleep_mode);
+		device_remove_file(info->dev, &dev_attr_manual_refresh);
+		device_remove_file(info->dev, &dev_attr_defio_delay);
+		device_remove_file(info->dev, &dev_attr_temperature);
+		unregister_framebuffer(info);
+		vfree((void __force *)info->screen_base);
+		apollofb_remove_chrdev(info->par);
+		framebuffer_release(info);
+	}
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int apollofb_suspend(struct platform_device *pdev, pm_message_t message)
+{
+	struct fb_info *info = platform_get_drvdata(pdev);
+	struct apollofb_par *par = info->par;
+
+	mutex_lock(&par->lock);
+	apollo_send_command(par, APOLLO_STANDBY_MODE);
+	par->current_mode = APOLLO_STATUS_MODE_SLEEP;
+	mutex_unlock(&par->lock);
+
+	return 0;
+}
+
+static int apollofb_resume(struct platform_device *pdev)
+{
+	struct fb_info *info = platform_get_drvdata(pdev);

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+	struct apollofb_par *par = info->par;
+
+	mutex_lock(&par->lock);
+	apollo_wakeup(par);
+	if (!par->options.use_sleep_mode)
+		apollo_set_normal_mode(par);
+	mutex_unlock(&par->lock);
+
+	return 0;
+}

Please put

#else
#define apollofb_suspend NULL
#define apollofb_resume NULL

here

Quoted 4 lines
drivers/video/Kconfig +4 -0
+#endif
+
+
+static struct platform_driver apollofb_driver = {

drivers/video/Kconfig

Quoted 10 lines
drivers/video/Kconfig +10 -0
+	.probe	= apollofb_probe,
+	.remove = apollofb_remove,
+	.driver	= {
+		.owner	= THIS_MODULE,
+		.name	= "eink-apollo",
+	},
+#ifdef CONFIG_PM
+	.suspend = apollofb_suspend,
+	.resume = apollofb_resume,
+#endif

and remove these ifdefs. For consistency, and it saves an ifdef.

drivers/video/Kconfig

Quoted 5 lines
drivers/video/Kconfig +5 -0
+};
+
+static int __init apollofb_init(void)
+{
+	int ret = 0;

Unneeded initialization

drivers/video/Kconfig

Quoted 5 lines
drivers/video/Kconfig +5 -0
+
+	ret = platform_driver_register(&apollofb_driver);
+
+	return ret;
+}

Plain old

	return platform_driver_register(&apollofb_driver);

would suffice?

drivers/video/Kconfig

Quoted 6 lines
drivers/video/Kconfig +6 -0
+static void __exit apollofb_exit(void)
+{
+	platform_driver_unregister(&apollofb_driver);
+}
+
+

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08

#5 lore raw

Re: [PATCH] eink_apollofb: new driver for Apollo eInk controller.

Quoted 4 lines · Andrew Morton
Quoted 2 lines · On Fri, 11 Jul 2008 17:54:31 +0300 Yauhen Kharuzhy <[email protected]> wrote:

This driver has been developed for the OpenInkpot
project (http://openinkpot.org/).

Hi Yauhen,

I'm excited to see openinkpot.org. Excellent efforts.

Quoted 3 lines

+ *
+ * This driver based on hecubafb driver code.
+ *

If possible, please also CC me, I'm the author of hecubafb, defio, and am always interested to know if people are finding it useful.

Quoted 4 lines

The eink_apollofb driver supports many features of Apollo chip, in difference with the hecubafb driver:
2-bit color depth, partial picture loading, flash read/write.

Yes, you've done good work here. I see the additions you've made as support for 2-bit, partial updates and also suspend/resume.

However, I should point out that hecubafb is a driver for this same apollo controller. There are several names for the Apollo controller including PVI-1006A, Hecuba among others. Looking at the diff between your work above and hecubafb, I think it should be feasible to add your code to hecubafb rather than to create a new driver. Please let me know if there's any problems achieving that, I'll be happy to help.

Thanks,
jaya

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08

#6 lore raw

Re: [PATCH] eink_apollofb: new driver for Apollo eInk controller.

Twas brillig at 11:02:29 13.07.2008 UTC+08 when [email protected] did gyre and gimble:

JK> However, I should point out that hecubafb is a driver for this same JK> apollo controller.

AFAICT from the diff, eink_apollofb already includes all the features of hecubafb, so that would be just renaming. Is it worth it?

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08

_______________________________________________
Linux-fbdev-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel

#7 lore raw

Re: [PATCH] eink_apollofb: new driver for Apollo eInk controller.

Quoted 10 lines · Mikhail Gusarov

Twas brillig at 11:02:29 13.07.2008 UTC+08 when [email protected] did gyre and gimble:

JK> However, I should point out that hecubafb is a driver for this same JK> apollo controller.

AFAICT from the diff, eink_apollofb already includes all the features of hecubafb, so that would be just renaming. Is it worth it?

--

Hi Mikhail,

Looking at the posted code, it is the same code as hecubafb, renamed, and with the 2-bit, partial update, and flash features added. The new features are good but basically, its a fork of hecubafb. I'm suggesting that rather than doing that, it would make more sense to add those features to the existing hecubafb code. If any help is needed in making that happen, please let me know, I'm happy to help.

Thanks,
jaya

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08

#8 lore raw

Re: [PATCH] eink_apollofb: new driver for Apollo eInk controller.

Quoted 10 lines · Jaya Kumar
Quoted 8 lines · Mikhail Gusarov

Twas brillig at 11:02:29 13.07.2008 UTC+08 when [email protected] did gyre and gimble:

JK> However, I should point out that hecubafb is a driver for this same JK> apollo controller.

AFAICT from the diff, eink_apollofb already includes all the features of hecubafb, so that would be just renaming. Is it worth it?

Quoted 7 lines
Quoted 2 lines

--

Hi Mikhail,

Looking at the posted code, it is the same code as hecubafb, renamed, and with the 2-bit, partial update, and flash features added.

Hardware abstraction layer (with platform_device framework) and rotation also :)

Quoted 5 lines

The new
features are good but basically, its a fork of hecubafb. I'm suggesting that rather than doing that, it would make more sense to add those features to the existing hecubafb code. If any help is needed in making that happen, please let me know, I'm happy to help.

I am agreed. I saw 'Apollo' name more frequently than any other, but it is not a matter of principe.

Signature · 11 lines
Yauhen Kharuzhy		jekhor _at_ gmail.com
			JID: [email protected]

A: No
Q: Should I quote below my post?

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
#9 lore raw

Re: [PATCH] eink_apollofb: new driver for Apollo eInk controller.

Quoted 20 lines · On Sun, 13 Jul 2008 22:19:28 +0300 Yauhen Kharuzhy <[email protected]> wrote:
Quoted 10 lines · Jaya Kumar
Quoted 8 lines · Mikhail Gusarov

Twas brillig at 11:02:29 13.07.2008 UTC+08 when [email protected] did gyre and gimble:

JK> However, I should point out that hecubafb is a driver for this same JK> apollo controller.

AFAICT from the diff, eink_apollofb already includes all the features of hecubafb, so that would be just renaming. Is it worth it?

Quoted 7 lines
Quoted 2 lines

--

Hi Mikhail,

Looking at the posted code, it is the same code as hecubafb, renamed, and with the 2-bit, partial update, and flash features added.

Hardware abstraction layer (with platform_device framework) and rotation also :)

Quoted 9 lines
Quoted 5 lines

The new
features are good but basically, its a fork of hecubafb. I'm suggesting that rather than doing that, it would make more sense to add those features to the existing hecubafb code. If any help is needed in making that happen, please let me know, I'm happy to help.

I am agreed. I saw 'Apollo' name more frequently than any other, but it is not a matter of principe.

I agree that having a separate-but-similar driver for the same hardware is most undesirable.

I presently have eink_apollofb-new-driver-for-apollo-eink-controller.patch on "hold" status, waiting for some resolution here.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

#10 lore raw

Re: [PATCH] eink_apollofb: new driver for Apollo eInk controller.

In reply to Yauhen Kharuzhy
Quoted 3 lines · On Fri, 11 Jul 2008 17:54:31 +0300 Yauhen Kharuzhy <[email protected]> wrote:

Add a new driver for eInk Apollo controller. This controller is used in various bookreaders with eInk displays.

I thought the consensus was that this functionality would be added to the hecubafb driver, but there doesn't seem to have been any movement along those lines?

The driver is causing some problems on arm:

drivers/video/eink_apollofb.c:36:32: asm/arch/regs-gpio.h: No such file or directory drivers/video/eink_apollofb.c:37:26: asm/hardware.h: No such file or directory

So I'll drop it.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/