Mailing List Archive

Driver - cfag12864b Crystalfontz 128x64 2-color Graphic LCD
Hi,

I have just finished a driver for the cfag12864b Crystalfontz 128x64
2-color Graphic LCD Series. You can check them at:
http://www.crystalfontz.com/products/12864b/

The drivers use the parallel port (data & control). Although the
company doesn't recommend it, they say the cfag12864b works fine that
way. The (unofficial) wiring is described at:
http://liquid-mp3.schijf.org/schematics/wiring_CFAG12864BTMIV.gif The
wiring as seen is used by Windows programs like LCDStudio, so although
it isn't official, it's the most popular, so I wrote the driver
expecting that wiring.

The driver works fine, the interface is easy (I think) and I have done
as many tests as I could. I have tried it on some computers, some
different kernel versions with two different LCDs and works well on
all configurations.

Because this kind of driver is unusual and I'm a newbie device driver
writer, I would like to receive some answers/help/suggestions:

1. The cfag12864b has two ks0108 controllers. Each one share the same
wiring, so you have to set one bit to tell the cfag12864b which
controller are you talking to. So I wrote a small driver for the
ks0108 controller, and then a more general cfag12864b driver which
depends on the ks0108 driver. This way, other programmers could use
the ks0108 driver and easily write more Graphic LCD drivers which uses
the same controller, instead of rewriting all the code: "Do one thing
and do it well.". I thought it was the right way to approach the
problem. Was it?

2. The driver right now is requesting ports using request_region at
init time. I know there are the parport_pc, parport and lp drivers. I
set the port as a module parameter, so you can change it easily. That
way, you can load both parport and cfag12864b modules. Still, I'm not
sure if it is the right approach. Should I use the parport interface
to request and use the ports, or leave the driver as is?

3. The module uses a external script to create the neccesary devices.
By now, I have just one device, some like /dev/cfag12864b0 where you
can write, and it will be printed on the screen. Although I have tried
to simplify it as much as possible, still you have to know the way the
LCD is going to print the data you send. Just reading the driver
documentation or doing two or three "echo hello > /dev/cfag12864b0"
you can figure out how your user-space application should write the
device. Still, I wrote a example function application that reads a
128x64 boolean matrix and writes a 1024 bytes vector (128*64/8)
properly that you can send to the device. I can easily write a new
device, like /dev/cfag12864b0matrix where you can write the 128x64
matrix directly, without worrying anything else. But, on the other
side, although it is simpler, I think it is worse, because you have to
wait until you receive all the boolean matrix before the driver can
start converting it to the cfag12864b format. If this makes no sense,
please tell me, I will explain it further.

4. I would like to release the driver to the public, GPL'ed. Has it
any possibility to enter in the mainstream kernel? Who can review it?
...?

It is my first attempt to write an useful Linux device driver, so I
expect this won't be a lame :-)

Thank you,

Miguel Ojeda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Driver - cfag12864b Crystalfontz 128x64 2-color Graphic LCD [ In reply to ]
Ar Gwe, 2006-09-08 am 19:10 +0200, ysgrifennodd Miguel Ojeda:
> sure if it is the right approach. Should I use the parport interface
> to request and use the ports, or leave the driver as is?

The parport interface exists precisely to generalise these uses of the
parport.

> wait until you receive all the boolean matrix before the driver can
> start converting it to the cfag12864b format. If this makes no sense,
> please tell me, I will explain it further.

You usually want format conversion done in user space as it is more
flexible that way. X has all the right framework for this so you could
even have fun with X11 on it ;)

> 4. I would like to release the driver to the public, GPL'ed. Has it
> any possibility to enter in the mainstream kernel? Who can review it?
> ...?

A good place to start is kernelnewbies.org, and when you are happy with
it post it somewhere for more general review.

Alan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Driver - cfag12864b Crystalfontz 128x64 2-color Graphic LCD [ In reply to ]
On 9/9/06, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> Ar Gwe, 2006-09-08 am 19:10 +0200, ysgrifennodd Miguel Ojeda:
<snip>
> > 4. I would like to release the driver to the public, GPL'ed. Has it
> > any possibility to enter in the mainstream kernel? Who can review it?
> > ...?
>
> A good place to start is kernelnewbies.org, and when you are happy with
> it post it somewhere for more general review.

You may also find it useful to post to kernel-mentors:
kernel-mentors@selenic.com (archived at:
http://www.selenic.com/pipermail/kernel-mentors/). It was created with
this kind of thing in mind, no?

Thanks,
Nish
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Driver - cfag12864b Crystalfontz 128x64 2-color Graphic LCD [ In reply to ]
On 9/9/06, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> The parport interface exists precisely to generalise these uses of the
> parport.

I have read the parport documentation (The Linux 2.4 Parallel Port
Subsystem), and they state that parport shares the port with other
devices using a standard (IEEE 1284). Here is where the problem comes:

Because the wiring of the LCD is completely practical (the parport was
used because it has many output lines that are enough for taking with
the LCD), it doesn't follow any kind of standard (like answering ACKs
and so on), so I am not sure the LCD is going to work well with the
parport driver and its "special signals" it sends to the data port. I
will check it.

Anyway, I have also thought this: If you load the cfag12864b driver
before parport, both will be fine: The LCD driver will use the port it
needs, and the parport will take care of all the others left. I have
already tried it and it works fine. cfag12864b requests 0x378 for
example, and then parport requests all the others, forgetting 0x378.

Still, I have found there is a flag in parport that is used to prevent
port just for one device:

parport_register_device() "The PARPORT_DEV_EXCL flag is for preventing
port sharing, and so should only be used when sharing the port with
other device drivers is impossible and would lead to incorrect
behaviour. Use it sparingly!"

I don't know what would be better, if use the parport interface and
such flag, or load my driver before parport requesting the port
directly with request_region. What do you think?


> You usually want format conversion done in user space as it is more
> flexible that way. X has all the right framework for this so you could
> even have fun with X11 on it ;)

Ok, easier that way. In fact, the conversion function takes just 20
lines... I can provide it as an example with the driver. Is the
Documentation/* the right place?


> A good place to start is kernelnewbies.org, and when you are happy with
> it post it somewhere for more general review.


I have checked it out and I have talked a little bit at
#kernelnewbies, and they told me also to check the
Documentation/Sending*.

I will send it to review to somewhere (still I don't know exactly to
whom, I thought this was the right place) and then to akpm, as
Doc/Sending* states.


Thank you for your time.

Miguel Ojeda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Driver - cfag12864b Crystalfontz 128x64 2-color Graphic LCD [ In reply to ]
On 9/9/06, Nish Aravamudan <nish.aravamudan@gmail.com> wrote:
>
> You may also find it useful to post to kernel-mentors:
> kernel-mentors@selenic.com (archived at:
> http://www.selenic.com/pipermail/kernel-mentors/). It was created with
> this kind of thing in mind, no?
>
> Thanks,
> Nish
>

I have checked it, and I'm subscribed to the list, but they seem to
don't have many activity: About 10 messages per month. Anyway, I will
try to get some review there if, as I see, lkml is not the right
place.

Thank you for you time.

Miguel Ojeda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Driver - cfag12864b Crystalfontz 128x64 2-color Graphic LCD [ In reply to ]
On 9/10/06, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> Ar Sul, 2006-09-10 am 01:14 +0200, ysgrifennodd Miguel Ojeda:
> > parport_register_device() "The PARPORT_DEV_EXCL flag is for preventing
> > port sharing, and so should only be used when sharing the port with
> > other device drivers is impossible and would lead to incorrect
> > behaviour. Use it sparingly!"
>
> This is the one you want. It's there for things like parallel port
> quickcams.

>
> > Ok, easier that way. In fact, the conversion function takes just 20
> > lines... I can provide it as an example with the driver. Is the
> > Documentation/* the right place?
>
> If its only 20 lines why not, in fact if its that short it might be fine
> in kernel too.
>

Fast and clear! Thank you so much.

Just a last question: The conversion function, should I code it as a
"exported function" via ioctl (copying the boolean matrix to kernel
space, converting it and sending it back to user space), or as a
second special device (like /dev/cfag..matrix)?

Because of the problems I explained of waiting for all the matrix to
start converting and sending it, I think the first option is better:
The user-space program can ask for the conversion via ioctl and then
send it to the normal device it whenever it wants.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: Driver - cfag12864b Crystalfontz 128x64 2-color Graphic LCD [ In reply to ]
Ar Sul, 2006-09-10 am 01:14 +0200, ysgrifennodd Miguel Ojeda:
> parport_register_device() "The PARPORT_DEV_EXCL flag is for preventing
> port sharing, and so should only be used when sharing the port with
> other device drivers is impossible and would lead to incorrect
> behaviour. Use it sparingly!"

This is the one you want. It's there for things like parallel port
quickcams.

> Ok, easier that way. In fact, the conversion function takes just 20
> lines... I can provide it as an example with the driver. Is the
> Documentation/* the right place?

If its only 20 lines why not, in fact if its that short it might be fine
in kernel too.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/