drivers: add LCD support
Subsystems (5)
PATCH 1/1 drivers: add LCD support
Andrew, here it is the complete patch again as you requested.
Paulo, I got the algorithm much faster, thanks you very much. (<2% CPU at 20 Hz on P4 3Ghz :).
---
miguelojeda-2.6.19-rc1-add-LCD-support.patch
Adds support for auxiliary displays, the ks0108 LCD controller, the cfag12864b LCD and adds a framebuffer device: cfag12864bfb.
Brief
-----
- Adds a "auxdisplay/" folder in "drivers/" for auxiliary display drivers.
- Adds support for the ks0108 LCD Controller as a device driver.
(uses parport interface)
- Adds support for the cfag12864b LCD as a device driver.
(uses ks0108 LCD Controller driver)
- Adds a framebuffer device called cfag12864bfb.
(uses cfag12864b LCD driver)
- Adds the usual Documentation, includes, Makefiles, Kconfigs, MAINTAINERS, CREDITS...
- Miguel Ojeda will maintain all the stuff above.
Patched files Index
-------------------
CREDITS | 10 Documentation/auxdisplay/cfag12864b | 98 +++++++ Documentation/auxdisplay/ks0108 | 59 ++++ MAINTAINERS | 24 + drivers/Kconfig | 2 drivers/Makefile | 1 drivers/auxdisplay/Kconfig | 112 ++++++++ drivers/auxdisplay/Makefile | 6 drivers/auxdisplay/cfag12864b.c | 328 ++++++++++++++++++++++++++ drivers/auxdisplay/cfag12864bfb.c | 165 +++++++++++++ drivers/auxdisplay/ks0108.c | 167 +++++++++++++ include/linux/cfag12864b.h | 41 +++ include/linux/ks0108.h | 36 ++ 13 files changed, 1049 insertions(+)
miguelojeda-2.6.19-rc1-add-LCD-support.patch
---
CREDITS +10 -0
@@ -2562,6 +2562,16 @@ S: Subiaco, 6008 S: Perth, Western Australia S: Australia +N: Miguel Ojeda Sandonis +E: [email protected] +D: Author: Auxiliary LCD Controller driver (ks0108) +D: Author: Auxiliary LCD driver (cfag12864b) +D: Author: Auxiliary LCD framebuffer driver (cfag12864bfb) +D: Maintainer: Auxiliary display drivers tree (drivers/auxdisplay/*) +S: C/ Mieses 20, 9-B +S: Valladolid 47009 +S: Spain + N: Greg Page E: [email protected] D: IPX development and support
Documentation/auxdisplay/cfag12864b +98 -0
98 lines not on this page · raw message
Documentation/auxdisplay/ks0108 +59 -0
59 lines not on this page · raw message
drivers/auxdisplay/cfag12864b.c +328 -0
328 lines not on this page · raw message
drivers/auxdisplay/cfag12864bfb.c +165 -0
165 lines not on this page · raw message
drivers/auxdisplay/Kconfig +112 -0
112 lines not on this page · raw message
drivers/auxdisplay/ks0108.c +167 -0
167 lines not on this page · raw message
drivers/auxdisplay/Makefile +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for the kernel auxiliary displays device drivers. +# + +obj-$(CONFIG_KS0108) += ks0108.o +obj-$(CONFIG_CFAG12864B) += cfag12864b.o cfag12864bfb.o
drivers/Kconfig +2 -0
@@ -76,4 +76,6 @@ source "drivers/rtc/Kconfig" source "drivers/dma/Kconfig" +source "drivers/auxdisplay/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -77,3 +77,4 @@ obj-$(CONFIG_CRYPTO) += crypto/ obj-$(CONFIG_SUPERH) += sh/ obj-$(CONFIG_GENERIC_TIME) += clocksource/ obj-$(CONFIG_DMA_ENGINE) += dma/ +obj-y += auxdisplay/
include/linux/cfag12864b.h +41 -0
41 lines not on this page · raw message
include/linux/ks0108.h +36 -0
@@ -0,0 +1,36 @@ +/* +* Filename: ks0108.h +* Version: 0.1.0 +* Description: ks0108 LCD Controller driver header +* License: GPLv2 +* +* Author: Copyright (C) Miguel Ojeda Sandonis <[email protected]> +* Date: 2006-10-04 +* +* 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 _KS0108_H_ +#define _KS0108_H_ + +extern void ks0108_writedata (unsigned char byte); +extern void ks0108_writecontrol (unsigned char byte); +extern void ks0108_displaystate (unsigned char state); +extern void ks0108_startline (unsigned char startline); +extern void ks0108_address (unsigned char address); +extern void ks0108_page (unsigned char page); + +#endif /* _KS0108_H_ */
MAINTAINERS +24 -0
@@ -441,6 +441,12 @@ W: http://people.redhat.com/sgrubb/audit T: git kernel.org:/pub/scm/linux/kernel/git/dwmw2/audit-2.6.git S: Maintained +AUXILIARY DISPLAY DRIVERS +P: Miguel Ojeda Sandonis +M: [email protected] +L: [email protected] +S: Maintained + AVR32 ARCHITECTURE P: Atmel AVR32 Support Team M: [email protected]
@@ -646,6 +652,18 @@ L: [email protected] L: [email protected] S: Maintained +CFAG12864B LCD DRIVER +P: Miguel Ojeda Sandonis +M: [email protected] +L: [email protected] +S: Maintained + +CFAG12864BFB LCD FRAMEBUFFER DRIVER +P: Miguel Ojeda Sandonis +M: [email protected] +L: [email protected] +S: Maintained + COMMON INTERNET FILE SYSTEM (CIFS) P: Steve French M: [email protected]
@@ -1736,6 +1754,12 @@ M: [email protected] L: [email protected] S: Maintained +KS0108 LCD CONTROLLER DRIVER +P: Miguel Ojeda Sandonis +M: [email protected] +L: [email protected] +S: Maintained + LAPB module L: [email protected] S: Orphan
Quoted 11 lines · Miguel Ojeda Sandonis
Andrew, here it is the complete patch again as you requested.
Paulo, I got the algorithm much faster, thanks you very much. (<2% CPU at 20 Hz on P4 3Ghz :).
---
miguelojeda-2.6.19-rc1-add-LCD-support.patchAdds support for auxiliary displays, the ks0108 LCD controller, the cfag12864b LCD and adds a framebuffer device: cfag12864bfb.
[...]Signed-off-by Miguel Ojeda Sandonis <[email protected]>
Signature · 1 line
Paulo Marques - www.grupopie.com
Hi
Quoted 2 lines · Miguel Ojeda Sandonis
Andrew, here it is the complete patch again as you requested.
sorry for coming lately, I just noticed your patch in -mm tree.
Did you took a look at drivers/video/arcfb.c driver ? It seems to be a fb driver for ks108 lcd controller. A lot of code is related to the platform though and the controller is driven through GPIO but have you tried to split the code for sharing controller specific code. Note, I don't say it's a good idea, it's just a question that comes in mind.
Also you create driver/auxdisplay directory whereas drivers such the one I mentioned previously is located in drivers/video. Why not putting your driver in driver/video ?
Franck
Quoted 15 lines · Franck Bui-Huu
Hi
Quoted 2 lines · Miguel Ojeda Sandonis
Andrew, here it is the complete patch again as you requested.
sorry for coming lately, I just noticed your patch in -mm tree.
Did you took a look at
drivers/video/arcfb.cdriver ? It seems to be a fb driver for ks108 lcd controller. A lot of code is related to the platform though and the controller is driven through GPIO but have you tried to split the code for sharing controller specific code. Note, I don't say it's a good idea, it's just a question that comes in mind.
Quoted 3 lines
Also you create driver/auxdisplay directory whereas drivers such the one I mentioned previously is located in
drivers/video. Why not putting your driver in driver/video ?
Is this driver is already no more maintained ?
Thanks,
Franck
Quoted 13 lines · Franck Bui-Huu
Quoted 12 lines · Franck Bui-Huu
Hi
sorry for coming lately, I just noticed your patch in -mm tree.
Did you took a look at
drivers/video/arcfb.cdriver ? It seems to be a fb driver for ks108 lcd controller. A lot of code is related to the platform though and the controller is driven through GPIO but have you tried to split the code for sharing controller specific code. Note, I don't say it's a good idea, it's just a question that comes in mind.
Quoted 6 lines
Quoted 3 lines
Also you create driver/auxdisplay directory whereas drivers such the one I mentioned previously is located in
drivers/video. Why not putting your driver in driver/video ?Is this driver is already no more maintained ?
The driver is waiting in the -mm tree (-mm2 right now) for being included in the mainline kernel sometime in the future. If it is included, I will maintain it as I coded it as it apears in the MAINTAINERS file. Why are you so worried about it if I can ask? Do you want some more features or something like that?
I missed the other two questions you wrote few days ago. About the second one, that was discussed a lot in the past and the people decided that (it wasn't my idea). About the first one, well, my ks0108 code is the one for the wiring of an auxiliary LCD, so if you read the discussion you will find the people wanted to split video things and other auxiliary displays, so I think it is better to split it. (Anyway, I'm answering quickly, I haven't checked the code you talk about, but I will anyway).
Thanks,
Miguel Ojeda
[ note I'm not familiar with lcds...just try to understand what you've
done ]
Quoted 8 lines · Miguel Ojeda
The driver is waiting in the -mm tree (-mm2 right now) for being included in the mainline kernel sometime in the future. If it is included, I will maintain it as I coded it as it apears in the
MAINTAINERSfile. Why are you so worried about it if I can ask? Do you want some more features or something like that?I missed the other two questions you wrote few days ago. About the second one, that was discussed a lot in the past and the people
yeah I found the thread and indeed it has been discussed very deeply ;)
Quoted 7 lines
decided that (it wasn't my idea). About the first one, well, my ks0108 code is the one for the wiring of an auxiliary LCD, so if you read the discussion you will find the people wanted to split video things and other auxiliary displays, so I think it is better to split it. (Anyway, I'm answering quickly, I haven't checked the code you talk about, but I will anyway).
What I was worry about is that you actually wrote a frame buffer driver, which are normally located in drivers/video, and put it in a new directory drivers/auxdisplay. So now we have two places for frame buffer drivers. It looks like, now some frame buffer drivers in drivers/video should be moved in drivers/auxdisplay, shouldn't it ?
Maybe just a stupid idea but why not restructuring the thing like:
drivers |-- display | |-- video | |-- aux | |-- fbmem.c | |-- ...
Another point: does the ks0108 controller is only used with the 'cfag' display ? If not, suppose I'm using the same controller with another lcd different from 'cfga'...Am I supposed to reuse your code in cfag12864b.c ?
BTW, did you try to mmap your fbdev ? Does it work ?
Thanks
Franck
Quoted 10 lines · Franck Bui-Huu
[ note I'm not familiar with lcds...just try to understand what you've
done ]What I was worry about is that you actually wrote a frame buffer driver, which are normally located in
drivers/video, and put it in a new directorydrivers/auxdisplay. So now we have two places for frame buffer drivers. It looks like, now some frame buffer drivers indrivers/videoshould be moved indrivers/auxdisplay, shouldn't it ?
Quoted 10 lines
Maybe just a stupid idea but why not restructuring the thing like:
drivers |-- display | |-- video | |-- aux | |-- fbmem.c | |-- ...
Yes, I got your idea in your first message, and well, that was discussed (however, not being a fbdev), and the people thought that putting them together will, maybe, cause confusion; so having them out from drivers/video should be better. Your idea, which merge them into a "drivers/display" could be a good one, but I don't think people will like to change such critical tree right now. Also, I'm not the one who maintain such tree, so my opinion won't make changes about that ;)
Quoted 6 lines
Another point: does the ks0108 controller is only used with the 'cfag' display ? If not, suppose I'm using the same controller with another lcd different from 'cfga'...Am I supposed to reuse your code in
cfag12864b.c?
No. You are supposed to _use_ the ks0108's exported functions: I split the code into the ks0108 and the cfag12864b because I thought it was the logical way, as the cfag12864b LCD just send the data through two different ks0108 controllers. The same way, you can use the ks0108's exported functions to create another whateverlcd.c which has one or more ks0108 controllers.
Quoted 3 lines
BTW, did you try to mmap your fbdev ? Does it work ?
Why it shouldn't? It doesn't work for you? AFAIK, it is a usual fbdev, and you can map any fbdev as they are simple character file devices.
Quoted 4 lines
Thanks
Franck
Thanks
Miguel Ojeda
Quoted 22 lines · Miguel Ojeda
Quoted 10 lines · Franck Bui-Huu
[ note I'm not familiar with lcds...just try to understand what you've
done ]What I was worry about is that you actually wrote a frame buffer driver, which are normally located in
drivers/video, and put it in a new directorydrivers/auxdisplay. So now we have two places for frame buffer drivers. It looks like, now some frame buffer drivers indrivers/videoshould be moved indrivers/auxdisplay, shouldn't it ?Quoted 10 lines
Maybe just a stupid idea but why not restructuring the thing like:
drivers |-- display | |-- video | |-- aux | |-- fbmem.c | |-- ...
Quoted 8 lines
Yes, I got your idea in your first message, and well, that was discussed (however, not being a fbdev), and the people thought that putting them together will, maybe, cause confusion; so having them out from
drivers/videoshould be better. Your idea, which merge them into a "drivers/display" could be a good one, but I don't think people will like to change such critical tree right now. Also, I'm not the one who maintain such tree, so my opinion won't make changes about that ;)
well, if it is the right thing to do, why not doing it. (note: I don't claim it's the right thing to do though). Futhermore such change is going to move a lot of files _but_ if after the move it compiles, then it works...
Quoted 7 lines
Quoted 6 lines
Another point: does the ks0108 controller is only used with the 'cfag' display ? If not, suppose I'm using the same controller with another lcd different from 'cfga'...Am I supposed to reuse your code in
cfag12864b.c?
Quoted 7 lines
No. You are supposed to _use_ the ks0108's exported functions: I split the code into the ks0108 and the cfag12864b because I thought it was the logical way, as the cfag12864b LCD just send the data through two different ks0108 controllers. The same way, you can use the ks0108's exported functions to create another
whateverlcd.cwhich has one or more ks0108 controllers.
So, to sum up, if I have a lcd named 'foo_lcd' which use 4 ks0108 controllers (256x128), and want to make your fb driver work on it, I need to copy your cfag12864b.c file, rename it to foo_lcd256128.c and just change the number of controllers, is that correct ?
Quoted 7 lines
Quoted 3 lines
BTW, did you try to mmap your fbdev ? Does it work ?
Why it shouldn't? It doesn't work for you? AFAIK, it is a usual fbdev, and you can map any fbdev as they are simple character file devices.
well you actually haven't answered to the initial question... I suspect it won't work since you haven't setup "info->fix.smem_start" anywhere. But I may be wrong since I don't know fb code.
Signature · 1 line
Franck
Quoted 52 lines · Franck Bui-Huu
Quoted 22 lines · Miguel Ojeda
Quoted 10 lines · Franck Bui-Huu
[ note I'm not familiar with lcds...just try to understand what you've
done ]What I was worry about is that you actually wrote a frame buffer driver, which are normally located in
drivers/video, and put it in a new directorydrivers/auxdisplay. So now we have two places for frame buffer drivers. It looks like, now some frame buffer drivers indrivers/videoshould be moved indrivers/auxdisplay, shouldn't it ?Quoted 10 lines
Maybe just a stupid idea but why not restructuring the thing like:
drivers |-- display | |-- video | |-- aux | |-- fbmem.c | |-- ...Quoted 8 lines
Yes, I got your idea in your first message, and well, that was discussed (however, not being a fbdev), and the people thought that putting them together will, maybe, cause confusion; so having them out from
drivers/videoshould be better. Your idea, which merge them into a "drivers/display" could be a good one, but I don't think people will like to change such critical tree right now. Also, I'm not the one who maintain such tree, so my opinion won't make changes about that ;)well, if it is the right thing to do, why not doing it. (note: I don't claim it's the right thing to do though). Futhermore such change is going to move a lot of files _but_ if after the move it compiles, then it works...
Quoted 7 lines
Quoted 6 lines
Another point: does the ks0108 controller is only used with the 'cfag' display ? If not, suppose I'm using the same controller with another lcd different from 'cfga'...Am I supposed to reuse your code in
cfag12864b.c?Quoted 7 lines
No. You are supposed to _use_ the ks0108's exported functions: I split the code into the ks0108 and the cfag12864b because I thought it was the logical way, as the cfag12864b LCD just send the data through two different ks0108 controllers. The same way, you can use the ks0108's exported functions to create another
whateverlcd.cwhich has one or more ks0108 controllers.
Quoted 5 lines
So, to sum up, if I have a lcd named '
foo_lcd' which use 4 ks0108 controllers (256x128), and want to make your fb driver work on it, I need to copy yourcfag12864b.cfile, rename it tofoo_lcd256128.cand just change the number of controllers, is that correct ?
No way. Each controller would have different wirings, pins, in-outs, specifications (...) You will need to code an almost whole new fbdev driver (althought maybe it will be so similar to cfag12864b so you only need to make few little changes, but that is unsure).
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
BTW, did you try to mmap your fbdev ? Does it work ?
Quoted 8 lines
Quoted 3 lines
Why it shouldn't? It doesn't work for you? AFAIK, it is a usual fbdev, and you can map any fbdev as they are simple character file devices.
well you actually haven't answered to the initial question... I suspect it won't work since you haven't setup "
info->fix.smem_start" anywhere. But I may be wrong since I don't know fb code.
Well, you were right about mmaping, but you weren't about "info->fix.smem_start". smem_start expects a physical address. RAM addresses can't be mmapped as usual, so I have made some changes and coded the nopage and mmap ops.
I'm sending the patch in a few moments. Thanks for pointing it: Now it can be mmaped as well.
Quoted 5 lines · Miguel Ojeda
No way. Each controller would have different wirings, pins, in-outs, specifications (...) You will need to code an almost whole new fbdev driver (althought maybe it will be so similar to cfag12864b so you only need to make few little changes, but that is unsure).
that's what I was trying to point out. I was wondering if you could make your driver a little more generic so another lcd could use your driver as is.
Quoted 3 lines
Well, you were right about mmaping, but you weren't about "
info->fix.smem_start".smem_startexpects a physical address. RAM addresses can't be mmapped as usual
Sorry I don't understand your last sentence. Can you explain please ?
Signature · 1 line
Franck
Quoted 11 lines · Franck Bui-Huu
Quoted 5 lines · Miguel Ojeda
No way. Each controller would have different wirings, pins, in-outs, specifications (...) You will need to code an almost whole new fbdev driver (althought maybe it will be so similar to cfag12864b so you only need to make few little changes, but that is unsure).
that's what I was trying to point out. I was wondering if you could make your driver a little more generic so another lcd could use your driver as is.
Hum... Others LCDs has different pinouts, different timings, different timings... It would be a really hard work, and maybe the result wouldn't be good.
I will think about it, but I think it would lead to a really complex generic driver (something like the fbdev API). Also, we would need many kinds of LCDs to know what can be a common factor between all of them, what can't, etc.
Really, I coded 2 drivers. The generic driver is ks0108, which it can be used with a lot more LCDs drivers. But the cfag12864b driver is really specific, as all the LCDs are different (as different as the user (wiring) and the builder (timings, pinout, commands...) wants). In the other hand, LCD controllers like ks0108 are industry-standard.
Quoted 6 lines
Quoted 3 lines
Well, you were right about mmaping, but you weren't about "
info->fix.smem_start".smem_startexpects a physical address. RAM addresses can't be mmapped as usualSorry I don't understand your last sentence. Can you explain please ?
Sorry, I meant: You can't mmap a RAM address using functions like the usual remap_pfn_range (as such functions doesn't like physical RAM addresses, they want I/O ports for example, like 0x378). So, you can't use smem_start. You need to code your own mmap & nopage function. (It is explained in LDD3 very well).
Quoted 3 lines
--
Franck
Quoted 7 lines · Miguel Ojeda
Sorry, I meant: You can't mmap a RAM address using functions like the usual
remap_pfn_range(as such functions doesn't like physical RAM addresses, they want I/O ports for example, like0x378). So, you can't usesmem_start. You need to code your own mmap & nopage function. (It is explained in LDD3 very well).
well I must admit that I don't understand why... I suppose you refered to that section in ldd3:
An interesting limitation of remap_pfn_range is that it gives access only to reserved pages and physical addresses above the top of physical memory.
I take a quick look at the implementation of remap_pfn_range() and there's no such limitation I can see (fortunately).
Franck
Quoted 12 lines · Franck Bui-Huu
Quoted 7 lines · Miguel Ojeda
Sorry, I meant: You can't mmap a RAM address using functions like the usual
remap_pfn_range(as such functions doesn't like physical RAM addresses, they want I/O ports for example, like0x378). So, you can't usesmem_start. You need to code your own mmap & nopage function. (It is explained in LDD3 very well).well I must admit that I don't understand why... I suppose you refered to that section in ldd3:
Quoted 9 lines
An interesting limitation of
remap_pfn_rangeis that it gives access only to reserved pages and physical addresses above the top of physical memory.I take a quick look at the implementation of
remap_pfn_range()and there's no such limitation I can see (fortunately).Franck
Read further ;-)
"Therefore, remap_pfn_range won't allow you to remap
conventional addresses, which include the ones you obtain by calling get_free_pages"
Because of such limitation, they teach you to remap RAM in other ways.
Quoted 5 lines · Miguel Ojeda
The driver is waiting in the -mm tree (-mm2 right now) for being included in the mainline kernel sometime in the future. If it is included, I will maintain it as I coded it as it apears in the
MAINTAINERSfile. Why are you so worried about it if I can ask? Do you want some more features or something like that?
Are you sure the patch you sent to Andrew is your latest patch version ? For example I can't found any locks in the patch that you normally added during the V6 patch version; auxlcddisplay.c doesn't no exist...
Franck
Quoted 7 lines · Franck Bui-Huu
Quoted 5 lines · Miguel Ojeda
The driver is waiting in the -mm tree (-mm2 right now) for being included in the mainline kernel sometime in the future. If it is included, I will maintain it as I coded it as it apears in the
MAINTAINERSfile. Why are you so worried about it if I can ask? Do you want some more features or something like that?
Quoted 7 lines
Are you sure the patch you sent to Andrew is your latest patch version ? For example I can't found any locks in the patch that you normally added during the V6 patch version;
auxlcddisplay.cdoesn't no exist...Franck
Yes, we are sure. AFAIK there is no need to lock when it is a fbdev. The older version were "alone" drivers: they needed to lock because they used fops and they exported functions.
Quoted 4 lines · Miguel Ojeda
Yes, we are sure. AFAIK there is no need to lock when it is a fbdev. The older version were "alone" drivers: they needed to lock because they used fops and they exported functions.
ok, so no other driver than fb could use 'cfag12864b_buffer'. Maybe I'm missing something but why did you split your fb driver into cfag12864b.c and cfag12864fb.c ?
BTW, 'cfag12864b_cache' could have been static...
Franck
Quoted 10 lines · Franck Bui-Huu
Quoted 4 lines · Miguel Ojeda
Yes, we are sure. AFAIK there is no need to lock when it is a fbdev. The older version were "alone" drivers: they needed to lock because they used fops and they exported functions.
ok, so no other driver than fb could use '
cfag12864b_buffer'. Maybe I'm missing something but why did you split your fb driver intocfag12864b.candcfag12864fb.c?
To be clearer. And you are wrong: you can write other modules which want to know what the LCD is showing, or use it; without worrying about framebuffer things. They can read / write "cfag12864b_buffer" as well as cfag12864bfb do. Why not?
The cfag12864b module is the real driver, which uses ks0108 module. The cfag12864bfb is just the framebuffer device.
Quoted 2 lines
BTW, '
cfag12864b_cache' could have been static...
Right, I saw that in the meantime I was adding the mmap feature. Thanks.
Quoted 3 lines
Franck
Quoted 5 lines · Miguel Ojeda
To be clearer. And you are wrong: you can write other modules which want to know what the LCD is showing, or use it; without worrying about framebuffer things. They can read / write "
cfag12864b_buffer" as well as cfag12864bfb do. Why not?
Suppose I'm writing a user space application which uses your frame buffer driver. I would naturaly mmap your device since it's the easiest way to use a frame buffer. Now I want to display as fast as possible a set of images. How am I sure that each image is sent to the lcd ? For example, suppose the application just finished to copy image A into the buffer, and now it starts to copy image B into the buffer but the work queue has not been scheduled yet...
Futhermore I'm not sure it's a common use case for such device, is it ? I would say that the usual case for such LCD is to display an image every now and then. If so do we really need to give the possibility to mmap the device ? Is a simple synchrone write() enough ?
BTW how can the application retrieve the refresh rate from the driver ?
Franck
Quoted 7 lines · Franck Bui-Huu
Quoted 5 lines · Miguel Ojeda
To be clearer. And you are wrong: you can write other modules which want to know what the LCD is showing, or use it; without worrying about framebuffer things. They can read / write "
cfag12864b_buffer" as well as cfag12864bfb do. Why not?
Quoted 8 lines
Suppose I'm writing a user space application which uses your frame buffer driver. I would naturaly mmap your device since it's the easiest way to use a frame buffer. Now I want to display as fast as possible a set of images. How am I sure that each image is sent to the lcd ? For example, suppose the application just finished to copy image A into the buffer, and now it starts to copy image B into the buffer but the work queue has not been scheduled yet...
Refresh rate is fixed in this driver (the user can change it to other value at Kconfig or at loading time as a module parameter).
An application should not refresh images so fast (the LCD controller can handle it, but the readability is pretty bad). Having a refresh rate like 10 Hz for example, the application can be sure all images are displayed. Anyway, an animation of 10 Hz wouldn't be fine at this kind of LCDs, so it is pointless which the refresh rate of the driver is, as it is not useful to display images as fast as the driver refresh the LCD.
(I don't know if I'm explaining myself...)
Quoted 6 lines
Futhermore I'm not sure it's a common use case for such device, is it ? I would say that the usual case for such LCD is to display an image every now and then. If so do we really need to give the possibility to mmap the device ? Is a simple synchrone
write()enough ?
Well, you can show a set of images, animations... althought it's not so useful. Usual cases:
1. Display a static image / info.
2. Display refreshed info every X seconds (like % usage of CPU and so on, the music you are listening to...)
3. Display, maybe, a animated graph (like the wave created by your music), althought this one is not so usual, as it changes much more quickly than [2]. Still, there are apps in other SOs that show such kind of info.
Well, mmaping is the best option, as it is the easiest and the fastest. Any use will be better using mmaping than doing synchrone write(). Yes, many uses just need a write() call, but other uses would need mmap.
Quoted 2 lines
BTW how can the application retrieve the refresh rate from the driver ?
Hum, right now one way is:
$ cat /sys/module/cfag12864b/parameters/cfag12864b_rate
Yes, a more generic option would be better. Do the fbdevices have some standard way to retrieve such kind of info (like the bits per pixel, width, height...)? If not, which would be a good to retrieve the refresh rate?
Anyway, a application which would like to use this LCD should know its specs and the user knows he shouldn't change the refresh rate without a good reason. If a user changes it to other value, he knows he can be breaking the apps, the same way you can break your kernel adding things you shouldn't; also the driver could stop working properly at higher rates.
Quoted 3 lines
Franck
Quoted 11 lines · Miguel Ojeda
Refresh rate is fixed in this driver (the user can change it to other value at
Kconfigor at loading time as a module parameter).An application should not refresh images so fast (the LCD controller can handle it, but the readability is pretty bad). Having a refresh rate like 10 Hz for example, the application can be sure all images are displayed. Anyway, an animation of 10 Hz wouldn't be fine at this kind of LCDs, so it is pointless which the refresh rate of the driver is, as it is not useful to display images as fast as the driver refresh the LCD.
An application might want to display quickly a set of images, not for doing animations but rather displaying 'fake' greyscale images.
Quoted 5 lines
Well, mmaping is the best option, as it is the easiest and the fastest. Any use will be better using mmaping than doing synchrone
write(). Yes, many uses just need awrite()call, but other uses would need mmap.
That's true for devices which have a frame buffer. But it's not your case. You _emulate_ this behaviour and I can see big drawbacks to this design:
- You need to keep synchrone your buffer and the display every 100ms. It makes your CPU busy even if nothing has been written in LCD for a while. Futhermore this kind of display is likely to run on embedded system where CPU speed can be less than 100MHz.
- All accesses to the device depend on the previous behaviour whereas write(), read() syscall could be synchrone and easier to use for fast writing of image sets. Actually the refresh stuff is really needed only if you mmap the device. And it seems not really used for now since it was broken on your last patch.
- Your driver _is_ a frame buffer driver by design, I think you don't need to seperate cfa12864cb.c and cfa12864cfb.c
So ok you code is very small with this design but IMHO it is not the most polyvalent if you want to address all needs. Why not starting the refresh stuff only if you mmap the device and keep the rest synch ?
Quoted 6 lines
$ cat /sys/module/cfag12864b/parameters/cfag12864b_rateYes, a more generic option would be better. Do the fbdevices have some standard way to retrieve such kind of info (like the bits per pixel, width, height...)? If not, which would be a good to retrieve the refresh rate?
maybe fb_ioctl() can return that. Or your driver can have its own ioctl() method which could return such specific info.
Franck
Quoted 9 lines · Franck Bui-Huu
Quoted 5 lines · Miguel Ojeda
[...]
Anyway, an animation of 10 Hz wouldn't be fine at this kind of LCDs, so it is pointless which the refresh rate of the driver is, as it is not useful to display images as fast as the driver refresh the LCD.An application might want to display quickly a set of images, not for doing animations but rather displaying 'fake' greyscale images.
To do "fake" greyscale you would need to synchronize with the actual refresh of the controller or you will have very ugly aliasing artifacts.
Since there is no hardware interface to know when the controller is refreshing, I don't think this is one viable usage scenario.
Quoted 5 lines
Quoted 4 lines
Well, mmaping is the best option, as it is the easiest and the fastest. Any use will be better using mmaping than doing synchrone
write(). Yes, many uses just need awrite()call, but other uses would need mmap.
Quoted 8 lines
That's true for devices which have a frame buffer. But it's not your case. You _emulate_ this behaviour and I can see big drawbacks to this design:
- You need to keep synchrone your buffer and the display every 100ms. It makes your CPU busy even if nothing has been written in LCD for a while. Futhermore this kind of display is likely to run on embedded system where CPU speed can be less than 100MHz.
It is not *that* bad. If nothing has changed, the driver only pays the cost of a 1024 bytes memcmp. Even more, there are no current users for anything other than a PC, so I think we shouldn't overdesign at this point.
Quoted 5 lines
- All accesses to the device depend on the previous behaviour whereas
write(),read()syscall could be synchrone and easier to use for fast writing of image sets. Actually the refresh stuff is really needed only if you mmap the device. And it seems not really used for now since it was broken on your last patch.
That is not entirely true. If a user-space application misbehaves and starts writing faster than what can actually be seen, not having a fixed refresh rate means that your CPU will be *very* busy writing garbage that the user won't be able to see.
A fixed refresh rate is a maximum CPU usage tunable that prevents applications (that are not aware that this is an external slow device) to write more than what they should.
This can be improved, however.
We could have the concept of a "dirty" buffer. Any write or nopage call would set the dirty flag and set a timer to refresh the display in one refresh period from now.
When doing the actual refresh, the "dirty" flag would be cleared and the buffer unmapped.
In this case, if nothing was ever written to the display, the CPU usage would be _zero_ (as it should), and it would work nicely with dynticks and such.
Anyway, I think that the driver is useful as is and fulfills its original goals: drive an LCD connected to a parelel port on a PC.
Since the actual userspace interface supports the suggested improvements, we can just merge now and improve it later to support different usage scenarios as they appear (or even before they appear).
Signature · 4 lines
Paulo Marques - www.grupopie.com "The face of a child can say it all, especially the mouth part of the face."
Quoted 4 lines · Paulo Marques
It is not *that* bad. If nothing has changed, the driver only pays the cost of a 1024 bytes memcmp. Even more, there are no current users for anything other than a PC, so I think we shouldn't overdesign at this point.
I really can't imagine a smartphone with a PC parallel port ;-)
Quoted 21 lines
Quoted 5 lines
- All accesses to the device depend on the previous behaviour whereas
write(),read()syscall could be synchrone and easier to use for fast writing of image sets. Actually the refresh stuff is really needed only if you mmap the device. And it seems not really used for now since it was broken on your last patch.That is not entirely true. If a user-space application misbehaves and starts writing faster than what can actually be seen, not having a fixed refresh rate means that your CPU will be *very* busy writing garbage that the user won't be able to see.
A fixed refresh rate is a maximum CPU usage tunable that prevents applications (that are not aware that this is an external slow device) to write more than what they should.
This can be improved, however.
We could have the concept of a "dirty" buffer. Any write or nopage call would set the dirty flag and set a timer to refresh the display in one refresh period from now.
Quoted 7 lines
When doing the actual refresh, the "dirty" flag would be cleared and the buffer unmapped.
In this case, if nothing was ever written to the display, the CPU usage would be _zero_ (as it should), and it would work nicely with dynticks and such.
Hum, interesting. But what happens if...
1. For example, the userspace app maps the fb (nopage is called, dirty flag set, timer created), and then the app doesn't use the fb. The timer will refresh the LCD, without anything new to refresh, so we are wasting CPU time. After refreshing, the driver clears the dirty flag and unmap the buffer.
2. After some seconds, the userspace app decides to write the buffer. As it is not mmaped anymore, it will simply get a segmentation fault, right? AFAIK nopage() is not called again because we have destroyed the mmapping information, and Linux can't know what are the nopage() ops to call to.
3. We mmap the device, timer is created, we start writing to the buffer, the timer calls our refreshing function but we didn't finish filling the buffer with our information: The LCD will have only some of the screen.
And so on, am I right?
Thanks,
Miguel Ojeda
Quoted 13 lines · Miguel Ojeda
[...]
Quoted 3 lines
In this case, if nothing was ever written to the display, the CPU usage would be _zero_ (as it should), and it would work nicely with dynticks and such.
Hum, interesting. But what happens if...
1. For example, the userspace app maps the fb (nopage is called, dirty flag set, timer created), and then the app doesn't use the fb. The timer will refresh the LCD, without anything new to refresh, so we are wasting CPU time. After refreshing, the driver clears the dirty flag and unmap the buffer.
Quoted 5 lines
2. After some seconds, the userspace app decides to write the buffer. As it is not mmaped anymore, it will simply get a segmentation fault, right? AFAIK
nopage()is not called again because we have destroyed the mmapping information, and Linux can't know what are thenopage()ops to call to.
No, this is not the sequence I thought of at all. I don't remember the exact API functions you need to call (I have to read LDD3 again ;), but if the hardware supports it, there must be a way. The plan is something like:
- at mmap time you return a pointer to something that is not actually
mapped, and do nothing else
- when userspace actually writes to that area, you get a page fault,
and nopage is called. At this point you map the page, and set the dirty state. All other writes from userspace until the timer completes are done without faulting.
- when the timer completes, you unmap the page so that the next access
will generate a fault again
As I said, I don't remember the exact details, but this should be doable.
Signature · 4 lines
Paulo Marques - www.grupopie.com "The face of a child can say it all, especially the mouth part of the face."
Quoted 14 lines · Paulo Marques
No, this is not the sequence I thought of at all. I don't remember the exact API functions you need to call (I have to read LDD3 again ;), but if the hardware supports it, there must be a way. The plan is something like:
- at mmap time you return a pointer to something that is not actually
mapped, and do nothing else- when userspace actually writes to that area, you get a page fault,
and nopage is called. At this point you map the page, and set the dirty state. All other writes from userspace until the timer completes are done without faulting.
Quoted 5 lines
- when the timer completes, you unmap the page so that the next access
will generate a fault againAs I said, I don't remember the exact details, but this should be doable.
Yes, I get the idea, you mean to "unmap" the page but don't remove the vma so a page fault is raised and nopage() op must be called again. May it decrease performance? (Linux /you must take care of a page fault calling nopage() each time you write/refresh the LCD, then actually use it).
Miguel Ojeda
Quoted 6 lines · Miguel Ojeda
[...]
Yes, I get the idea, you mean to "unmap" the page but don't remove the vma so a page fault is raised andnopage()op must be called again. May it decrease performance? (Linux /you must take care of a page fault callingnopage()each time you write/refresh the LCD, then actually use it).
Well, it's a trade-off: you pay a little extra when you write to the display, but you pay _zero_ when you leave the display alone. And this zero is an important concept for some applications like dynticks.
If you want to achieve deep sleep states on a laptop you might want to be able to let it sleep for extended periods. Having a thread that wakes up every 50 ms even when there is nothing to do is not so good in this situation.
If your refresh rate is 20Hz you pay *at most* 20 minor faults per second if the application is writing a lot to the display. That doesn't sound so bad.
Even more, the application still as the option of using seek/write instead of using mmap to avoid the page faults, but if you're writing a lot, it might be better to take just one page fault and then write at full speed than to pay the price of a seek/write every time.
I didn't include the locking in the description, though. If you're going this way, you need to make sure that some of this operations are atomic so that you don't mark the display as clean just as the userspace app is dirtying it, leaving the physical display inconsistent until the next refresh.
Signature · 4 lines
Paulo Marques - www.grupopie.com "The face of a child can say it all, especially the mouth part of the face."
Quoted 8 lines · Paulo Marques
Quoted 7 lines · Franck Bui-Huu
Quoted 5 lines · Miguel Ojeda
[...]
Anyway, an animation of 10 Hz wouldn't be fine at this kind of LCDs, so it is pointless which the refresh rate of the driver is, as it is not useful to display images as fast as the driver refresh the LCD.
Quoted 9 lines
Quoted 2 lines
An application might want to display quickly a set of images, not for doing animations but rather displaying 'fake' greyscale images.
To do "fake" greyscale you would need to synchronize with the actual refresh of the controller or you will have very ugly aliasing artifacts.
Since there is no hardware interface to know when the controller is refreshing, I don't think this is one viable usage scenario.
eh ?? Did you read my email before ? That was the point I was trying to raise... and starting the refresh stuff _only_ when the device is mmaped seems to me a good trade off.
Aynywas it seems that the discusion about the design is closed and won't lead to interesting things...
bye
Franck
Quoted 5 lines · Franck Bui-Huu
Paulo Marques wrote:
starting the refresh stuff _only_ when the device is mmaped seems to me a good trade off.
Well, if someone writes to /dev/fbX the LCD won't get updated. We would need also to start/stop at the write/release fbfops as well. Let me check.
Quoted 8 lines · Franck Bui-Huu
Quoted 7 lines · Paulo Marques
Quoted 2 lines · Franck Bui-Huu
An application might want to display quickly a set of images, not for doing animations but rather displaying 'fake' greyscale images.
To do "fake" greyscale you would need to synchronize with the actual refresh of the controller or you will have very ugly aliasing artifacts.
Quoted 6 lines
Quoted 2 lines
Since there is no hardware interface to know when the controller is refreshing, I don't think this is one viable usage scenario.
eh ?? Did you read my email before ? That was the point I was trying to raise... and starting the refresh stuff _only_ when the device is mmaped seems to me a good trade off.
I think we are violently agreeing about the optimal way of doing things.
But maybe I didn't explain my point about the "fake" greyscale in the best way, though.
There are two distinct "refresh"'s involved here: one is when the driver writes its software buffer into the display internal memory using the parallel port interface.
The other is when the actual display controller refresh that goes through all the common lines, etc., using the values on its internal memory to update the segment voltages.
The problem is that there is no way to know about the internal refresh that the controller does. So if you update its memory very frequently to try to produce a "fake" greyscale image, your updates will alias with the refresh rate of the actual display controller and you will see all sorts of strange effects on the display.
Quoted 2 lines
Aynywas it seems that the discusion about the design is closed and won't lead to interesting things...
Only because we're mostly in agreement about what should be done ;)
But if you have other interesting things to suggest, I haven't seen Miguel reject any suggestions by other developers, yet (very much on the contrary, to be honest).
Signature · 7 lines
Paulo Marques Software Development Department - Grupo PIE, S.A. Phone: +351 252 290600, Fax: +351 252 290601 Web: www.grupopie.com "The face of a child can say it all, especially the mouth part of the face."
Quoted 13 lines · Franck Bui-Huu
Quoted 11 lines · Miguel Ojeda
Refresh rate is fixed in this driver (the user can change it to other value at
Kconfigor at loading time as a module parameter).An application should not refresh images so fast (the LCD controller can handle it, but the readability is pretty bad). Having a refresh rate like 10 Hz for example, the application can be sure all images are displayed. Anyway, an animation of 10 Hz wouldn't be fine at this kind of LCDs, so it is pointless which the refresh rate of the driver is, as it is not useful to display images as fast as the driver refresh the LCD.
Quoted 3 lines
An application might want to display quickly a set of images, not for doing animations but rather displaying 'fake' greyscale images.
And what is the problem?
Quoted 6 lines
Quoted 5 lines
Well, mmaping is the best option, as it is the easiest and the fastest. Any use will be better using mmaping than doing synchrone
write(). Yes, many uses just need awrite()call, but other uses would need mmap.
Quoted 9 lines
That's true for devices which have a frame buffer. But it's not your case. You _emulate_ this behaviour and I can see big drawbacks to this design:
- You need to keep synchrone your buffer and the display every 100ms. It makes your CPU busy even if nothing has been written in LCD for a while. Futhermore this kind of display is likely to run on embedded system where CPU speed can be less than 100MHz.
No. Paulo pointed that and I added a cache so the CPU is doesn't waste much time. Less than 1% on a P4 3Ghz. The kernel do a lot more things, not only refreshing the LCD.
The driver is not intended for an embedded system, as they usually doesn't have a parallel port.
Quoted 6 lines
- All accesses to the device depend on the previous behaviour whereas
write(),read()syscall could be synchrone and easier to use for fast writing of image sets. Actually the refresh stuff is really needed only if you mmap the device. And it seems not really used for now since it was broken on your last patch.
I had the write() and read() syscalls coded. People like Pavel didn't like such behaviour, and he told me to recode it to be a framebuffer. Please read other threads before telling it is wrong when other people thought the opposite.
Quoted 3 lines
- Your driver _is_ a frame buffer driver by design, I think you don't need to seperate
cfa12864cb.candcfa12864cfb.c
Well, I think it's better to split it. I have already given reasons to you.
Quoted 4 lines
So ok you code is very small with this design but IMHO it is not the most polyvalent if you want to address all needs. Why not starting the refresh stuff only if you mmap the device and keep the rest synch ?
Because mmaping is better than read() write() in any case. I know, it waste a little more CPU, but get the point: If you only need to show static images, the driver won't update the LCD (that is what really waste the CPU time). If you really need performance, you can decrease the refresh rate if you don't need it. But 20 Hz is useful for everybody and doesn't waste a lot of time.
Also, if you want attach fbcon to the device, you need to refresh it constantly to behave like a framebuffer device, so it is a requirement.
Quoted 10 lines
Quoted 7 lines
$ cat /sys/module/cfag12864b/parameters/cfag12864b_rateYes, a more generic option would be better. Do the fbdevices have some standard way to retrieve such kind of info (like the bits per pixel, width, height...)? If not, which would be a good to retrieve the refresh rate?
maybe
fb_ioctl()can return that. Or your driver can have its ownioctl()method which could return such specific info.
No way. Please read previous threads. Greg KH doesn't want more ioctls in any way. The first versions used it, and he told me to remove them. Sorry.
Quoted 3 lines
Franck