Page 1 of 1

ARM framebuffer

Posted: Sun Aug 14, 2011 12:24 pm
by bazhenovc
Hello.

Consider we have a VersatilePB board (QEMU emulated) with a screen.

The question is: how to put a pixel(or something more interesting) to the screen, using C or ARM assembly?

I`ve searched for a long time, but didn`t find anything useful :(

Re: ARM framebuffer

Posted: Sun Aug 14, 2011 1:55 pm
by jnc100
I believe its an ARM PL-110: http://infocenter.arm.com/help/index.js ... index.html although it has been changed to be modelled as a PL-111 in the latest qemu repository as of the end of July.

Regards,
John.

Re: ARM framebuffer

Posted: Sun Aug 14, 2011 2:04 pm
by diodesign
bazhenovc wrote:Hello.

Consider we have a VersatilePB board (QEMU emulated) with a screen. The question is: how to put a pixel(or something more interesting) to the screen, using C or ARM assembly? I`ve searched for a long time, but didn`t find anything useful :(
Read up on VersatilePB and ARM CLCDC PL110 documentation from ARM, it's all in there and just a google search away. The CLCD controller's registers start from 0x10120000. You need to program the following registers (one of which is a SoC clock control register)...

SYS_OSCCLK4 at 0x1000001C
CLCD_TIM0 at 0x10120000
CLCD_TIM1 at 0x10120004
CLCD_TIM2 at 0x10120008
CLCD frame buffer physical base address at 0x10120010
CLCD control bits at 0x10120018

This table has some useful numbers for you:
http://infocenter.arm.com/help/index.js ... hedgd.html

Let's say you want a SVGA (800x600) display. Look up the resolution you want in the table above and the magic numbers needed for the hardware, and check the manuals. This is the C code you'll end up with:

*(volatile unsigned int *)(0x1000001C) = 0x2CAC; /* timing magic for SVGA 800x600 */
*(volatile unsigned int *)(0x10120000) = 0x1313A4C4;
*(volatile unsigned int *)(0x10120004) = 0x0505F657;
*(volatile unsigned int *)(0x10120008) = 0x071F1800;
*(volatile unsigned int *)(0x10120010) = (1 * 1024 * 1024); /* base addr of frame buffer */
*(volatile unsigned int *)(0x10120018) = 0x82b; /* control bits */

From the LCD controller datasheet, you'll discover exactly how to control the hardware - I just lifted the above code from some really old crappy test I wrote to make sure the LCD controller was working on QEmu's VersatilePB support. It's horrible. After that, it's a case of writing pixel data to the frame buffer (I believe the default format is 0x00BBGGRR)

CLCD controller information: http://infocenter.arm.com/help/index.js ... 13915.html

VersatilePB programmer's guide:
http://infocenter.arm.com/help/index.js ... haagj.html

Hope this points you in the right direction.

Re: ARM framebuffer

Posted: Sun Aug 14, 2011 2:36 pm
by bazhenovc
jnc100, thank you, this is it.

diodesign, thank you so much! You saved my day :)