GDISP driver

Locked
inmarket
Posts: 89
Joined: Fri Jul 27, 2012 1:37 pm

Re: GDISP driver

Post by inmarket »

OK - sounds like I need to explain where my thoughts were heading on halext.

It started when I realised how much new hardware support and "capabilities" were going to have to be written for my own project.
The normal mechanism for handling this in any normal project is to create a library and then let the linker determine what needs to be included. Overtime as project mature it is common for libraries to become very interdependant thus causing the whole library to effectively get linked in thus causeing code size bloat (not good for our type of project where resources are very finite). Where there are choices with a common API - you select which library you add to your make.
With ChibiOS - this has been built without the use of any libraries and yet there are obviously choices being made between common API components eg. at a board and at an architecture level. How does this work? By using halconf.h to specify what gets included and then the make system assembling all the bits necessary to make that happen including getting the right hardware dependant version of include files are needed. Very elegant! Down side - careful thought has to be given to the structure to ensure the dependancies work, and every file in the dependance list gets compiled even if it results in no actual code. For a RTOS this compromise is well worth while as run-time performance is more important than compile time performance.
So, the thought behind HALEXT (nothing to do with GDISP yet) is to extend that structure to all the addon stuff that is being built that doesn't directly fit in ChibiOS itself. Components then get comiled in or out based on HAL_USE_XXX defines in halconf.h just like for ChibiOS itself. This greatly simplifies the task of creating a new application - just turn on those sub-systems you think you will need.
The 2nd advantage of doing this is that it allows "layered" drivers to be written that require a lower level driver to perform more "base" functions. In the traditional library and directory technique the dependancies can become hard to track particularly when you start putting in alternative implementations for different layers in the model. With the ChibiOS style implementation (that halext implements) all this is taken care of for you by the make system and the driver writers. Incompatible options can be compile time error'ed.
An example of the use of this layering is...
High Level Routines For Reading Bitmap Files (a driver for reading bitmaps)
-> GDISP (a general display driver)
-> GISP_LLD (an LCD hardware driver - many options)
Another more complex example
Tone Generator Driver
-> Audio Wave Mixer Driver
-> Audio Hardware driver eg. I2C Crystal Codec OR PWM Audio Driver
-> If using PWM Audio Driver this layers on the ChibiOS PWM driver
or -> If using I2C Crystal Codec this layers on the ChibiOS I2C driver
The same Tone Generator Driver may instead by built with this structure...
Tone Generator Driver
-> PWM Squarewave Audio Driver
-> ChibiOS PWM driver

The trick is in defining the interfaces between each layer and being able to turn on and off functionality in a higher level driver if the lower level driver doesn't support it. That controllable functionality is not easily possible in the standard seperate directory library type approach as you are effectively generating dependancies based on functionality between the layers. It could be done with "discover" type functions but this introduces extra run-time handling code and prevents the removal of dead code by the compiler.

Hence halext was born.

GDISP then becomes a graphics driver in the halext structure that layers its functionality on the gdisp_lld low level display drivers. In this case GDISP is currently quite thin containing a couple of string functions and a box function. All else is past to the low level drivers. Other things that GDISP will contain (but not yet)...
  • Multi-thread protection for the gdisp_lld low level drivers. This might be MUTEX style or Asynchronous Thread style (or maybe both with a user-selectable option).
  • Possibly a VMT implementation to allow one of a number of low level drivers to be selected at run-time by the presense or otherwise of particular hardware.
GDISP is also set up to allow the user to turn off functions they don't want and save on the code. For example, don't want bitmap text support - you can turn it off. Don't want multi-thread protection then turn it off.

The only other unusual factor in this is that the gdisp_lld low level drivers use this feature on/off capability to allow them to control how much functionality they want to render in hardware. If the hardware supports line drawing then the hardware does it. If not then an emulation routine is automatically turned on to provide this function for it. Some functions can't be emulated (like pixel read-back) and so if the hardware doesn't support it then the high level layer (GDISP) is told to turn off the use of that function in any functions it provides (in this case the high level pixel read-back routines are simply not compiled and are therefore not available to the application).

Hope that helps the thinking.
petr
Posts: 7
Joined: Mon Jul 30, 2012 8:54 pm

Re: GDISP driver

Post by petr »

Hello,
there is a syntax error in halext/src/gdisp.c since commit f4b63ebaf43c511aa90f829074ef40e00ed1370d.
@Tectu: Do you want error reports like this here or on github?
Petr
inmarket
Posts: 89
Joined: Fri Jul 27, 2012 1:37 pm

Re: GDISP driver

Post by inmarket »

petr wrote:Hello,
there is a syntax error in halext/src/gdisp.c since commit f4b63ebaf43c511aa90f829074ef40e00ed1370d.

Can you please provide the error line as mine seems to be compiling OK.
petr
Posts: 7
Joined: Mon Jul 30, 2012 8:54 pm

Re: GDISP driver

Post by petr »

Good evening,

Code: Select all

/Users/petr/projects/ChibiOS/os/halext/src/gdisp.c:104:7: error: expected ')' before '(' token
/Users/petr/projects/ChibiOS/os/halext/src/gdisp.c:195:7: error: conflicting types for 'gdispBlitArea'
In file included from /Users/petr/projects/ChibiOS/os/halext/src/gdisp.c:30:0:
/Users/petr/projects/ChibiOS/os/halext/include/gdisp.h:203:7: note: previous declaration of 'gdispBlitArea' was here
/Users/petr/projects/ChibiOS/os/halext/src/gdisp.c: In function 'gdispGetStringWidth':
/Users/petr/projects/ChibiOS/os/halext/src/gdisp.c:691:15: warning: variable 'h' set but not used [-Wunused-but-set-variable]
make: *** [build/obj/gdisp.o] Error 1

This is what I get when I try to build any revision after f4b63ebaf43c511aa90f829074ef40e00ed1370d.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: GDISP driver

Post by Tectu »

I can confirm that I have the same issues

inmarket, I'll think about your post and I'll write my thoughts soon.


~ Tectu
inmarket
Posts: 89
Joined: Fri Jul 27, 2012 1:37 pm

Re: GDISP driver

Post by inmarket »

Looks like GDISP_NEED_MULTITHREAD has been turned on which is not fully supported yet and hence why I missed the comile error.
I will push a correction out now for the errors listed however.
Multi-thread, Asynchronous Multi-Thread and VMT drivers are about a day away which will fix all the above problems anyway.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: GDISP driver

Post by Tectu »

placeholder - will repost


~ Tectu
User avatar
Badger
Posts: 346
Joined: Mon Apr 18, 2011 6:07 pm

Re: GDISP driver

Post by Badger »

I don't see how inmarket's work will cause the previous stuff to be 'thrown away'. Yes there is duplication of functionality, but as has been pointed out it is often easier to start from scratch using previous work as inspiration than 'tame a beast'. Let's be careful to not discourage contributions ;) what code can not be used with the GDISP driver? I guess you could be referring to the gui / touchpad stuff, but as far as I am concerned I am happy with the lld driver work I've done making its way into this much improved scheme. I'm guessing the console stuff hasn't been implemented (I should check, I've been too busy lately :oops: ), but as a high level set of code it would be trivial to do so.

@inmarket, thanks for the explanation. I agree with your concepts and goals, but I guess what concerns me with calling it 'halext' is that it implies that generic drivers can go in there, but if you were to have another halext for a different set of drivers you could not easily merge the two. I think some sort of automated tool would be useful in this instance!
inmarket
Posts: 89
Joined: Fri Jul 27, 2012 1:37 pm

Re: GDISP driver

Post by inmarket »

halext is just a name. AND I hope this repository to become the source of all things good with LOTS of contributors. :lol:

You idea of a tool to merge multiple different halext's is a nice idea and would be very simple.

Assuming there is no overlap in filenames you would dump one directory on top of the other and simply combine the makefile's. Trivial.
Or rename one of more of the makefiles and then add all the halext makefiles to your project.
Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm

Re: GDISP driver

Post by Abhishek »

I used scalable fonts the day they were added. To be very frank, they did work, but the quality wasn't very good. It was as like we were having pixelation in images. Though that was expected.

Inmarket,what's the status of VMT based low level drivers? Do we have a preview?

Abhishek
Locked