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

Dennis Gessner d.gessner at sirrix.com
Fri Aug 1 18:39:09 EST 2008


Hello everyone,
hello Nelson,

I have some problems implementing my little lcd-application.

Here is, what I did:

Using okl4 2.1.1 patch 9, I implemented a small application (without
wombat) like it is said in the tutorial: "Using A Virtual Device" (also
in "Writing a Device Driver"). As environment, I use an emulated (qemu)
gta01 device.

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)?

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)?

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?

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

Thanks a lot and best regards,
Dennis



More information about the Developer mailing list