[okl4-developer] lcd-server-support - question regarding one of the tutorials

Nelson Tam nelson at ok-labs.com
Mon Aug 4 09:40:59 EST 2008


Hi Dennis,

On 01/08/2008, at 6:39 PM, Dennis Gessner wrote:

> 1)
>
> In the tutorial it is said, that ig_lcd should be defined as the  
> following:
>
> ---
> struct ig_lcd
> {
>        server_t        server;
>        device_t        handle;
>
>        memsection_ref_t                ms;
>        uintptr_t                       ms_base;
>        struct  lcd_control_block       *control;
> };
> ---
>
> but in the later code an ig_lcd->obj is often used. What is right?
> Inserting an "objref_t  obj;" in the struct, or just rename the handle
> reference to the virtual device instance from "handle" to "obj" (and
> also change every call of "handle" to "obj" in the rest of the  
> program)?

The "handle" member of ig_lcd used to be called "obj".  You should  
replace "obj" with "handle" in the code examples that you see  
(unfortunately it seems like the document you have is a bit  
outdated).  That is because we've abstracted the way devices are  
accessed, instead of a direct pointer, we now use an opaque integer  
handle.

>
> 2)
> Whatever I do to solve problem 1 - the printf done with:
>
>        printf("LCD Mode is %ldx%ld@%lx\n", lcd->control->xres,
>                       lcd->control->yres,lcd->control->bpp);
>
> in the function "static int init_lcd(struct ig_lcd *lcd)" produces:
>
> "LCD Mode is -530571520x-16773136 at 10d000" which of course is totally
> "not-initialized-value". So I tried to find out why the xres, yres and
> bpp are not filled out with data and realized that it looks like, he
> just do not enter the function "void virtual_lcd_get_mode_impl" inside
> the lcd_server.c (I put an printf in this function and it does not
> appear). Maybe I am a bit blind to see my mistake(s)?

So the lcd->control structure is initialised when you call  
virtual_lcd_get_mode(), using the appropriate server and handle.  You  
should make that call before doing printf on the structure.

> 3)
> If problem 1 and 2 are solved - It should be possible to write data to
> the framebuffer with - for example:
>
> ---
>        uintptr_t       fb_base;
>        struct lcd_control_block *ctrl = lcd->control;
>
>        virtual_lcd_get_fb(lcd->server, lcd->obj, &fb_base, NULL);
>
>        virtual_lcd_get_mode(lcd->server, lcd->obj,
> 			&ctrl->xres,&ctrl->yres,&ctrl->bpp, NULL);
>
>
>        int i = 0, x, y;
>        char r, g, b;
>        uint16_t col, *fbp = (uint16_t*) fb_base;
>
>        for (x=0; x < ctrl->yres; x++)
>        {
>                for (y = 0; y < ctrl->yres; y++)
>                {
>                        r = (x<y)?0:255;
>                        g = (x<(ctrl->xres/2))?0:255;
>                        b = (y<(ctrl->yres/2))?0:255;
>
>                        col = (r&0x1f) |
>                                  ((g&0x3f)<<5) |
>                                  ((b&0x1f)<<11);
>
>                        fbp[i++] = col;
>                }
>        }
> ---
>
>        // of course a memcpy should also be possible
>        // something like: memcpy(fb_base,data,(480*640*3));
>
> Am I right with this?

That is correct.

> Is there any working example I can see/download? I really would like  
> to
> know what I am doing wrong.

If you take a look at this wiki page (http://wiki.ok-labs.com/DriverFramework 
), the updated instructions there should give you an idea of what  
needs to be done.

Please let us know if you have any other questions.

--
(nt)

Nelson Tam




More information about the Developer mailing list