lcd drivers: Convert lcd_[remote_]framebuffer to a pointer

Change all lcd drivers to using a pointer to the static framebuffer
instead of directly accessing the static array. This will let us
later do fun things like dynamic framebuffer sizes (RaaA) or
ability to use different buffers for different layers (dynamic
skin backdrops!)

Change-Id: I0a4d58a9d7b55e6c932131b929e5d4c9f9414b06
This commit is contained in:
Jonathan Gordon 2012-02-22 21:18:05 +11:00
parent 15c69b8baf
commit b37e6bc8c1
65 changed files with 193 additions and 181 deletions

View file

@ -332,7 +332,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_write_cmd(R_WRITE_DATA_2_GRAM);
ptr = &lcd_framebuffer[y][x];
ptr = FBADDR(x,y);
do
{

View file

@ -273,7 +273,7 @@ void lcd_update(void)
lcd_write_command (LCD_CNTL_HIGHCOL | ((offset >> 4) & 0xf));
lcd_write_command (LCD_CNTL_LOWCOL | (offset & 0xf));
lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
lcd_write_data (FBADDR(0, y), LCD_WIDTH);
}
}
@ -304,6 +304,6 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_write_command (LCD_CNTL_HIGHCOL | (((x+offset) >> 4) & 0xf));
lcd_write_command (LCD_CNTL_LOWCOL | ((x+offset) & 0xf));
lcd_write_data (&lcd_framebuffer[y][x], width);
lcd_write_data (FBADDR(x,y), width);
}
}

View file

@ -426,7 +426,7 @@ void lcd_update_rect(int x, int y, int width, int height)
/* write to GRAM */
for (row = y; row < y_end; row++) {
lcd_write_data(&lcd_framebuffer[row][x], width);
lcd_write_data(FBADDR(x,row), width);
}
}

View file

@ -488,7 +488,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_window(x, y, x+width-1, y+height-1);
lcd_write_cmd(R_WRITE_DATA_2_GRAM);
ptr = &lcd_framebuffer[y][x];
ptr = FBADDR(x,y);
do
{

View file

@ -533,12 +533,12 @@ void lcd_update_rect(int x, int y, int w, int h)
*/
if(w == LCD_WIDTH)
{
memcpy((void *)FRAME, &lcd_framebuffer[y][x], w * h * sizeof(fb_data));
memcpy((void *)FRAME, FBADDR(x,y), w * h * sizeof(fb_data));
}
else
{
for(int i = 0; i < h; i++)
memcpy((fb_data *)FRAME + i * w, &lcd_framebuffer[y + i][x], w * sizeof(fb_data));
memcpy((fb_data *)FRAME + i * w, FBADDR(x,y + i), w * sizeof(fb_data));
}
/* WARNING The LCDIF has a limitation on the vertical count ! In 16-bit packed mode
* (which we used, ie 16-bit per pixel, 2 pixels per 32-bit words), the v_count
@ -599,10 +599,10 @@ void lcd_blit_yuv(unsigned char * const src[3],
linecounter = height >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
dst = &lcd_framebuffer[y][x];
dst = FBADDR(x,y);
row_end = dst + width;
#else
dst = &lcd_framebuffer[x][LCD_WIDTH - y - 1];
dst = FBADDR(LCD_WIDTH - y - 1,x);
row_end = dst + LCD_WIDTH * width;
#endif

View file

@ -280,7 +280,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_setup_drawing_region(x, y, width, height);
addr = (unsigned long*)&lcd_framebuffer[y][x];
addr = (unsigned long*)FBADDR(x, y);
while (height > 0) {
int r, h, pixels_to_write;

View file

@ -340,10 +340,10 @@ void lcd_update_rect(int x, int y, int width, int height)
#if defined(IPOD_MINI) || defined(IPOD_MINI2G)
if (pix_offset == -2)
lcd_write_data_shifted(&lcd_framebuffer[y][2*x], width);
lcd_write_data_shifted(FBADDR(2*x, y), width);
else
#endif
lcd_write_data(&lcd_framebuffer[y][2*x], width);
lcd_write_data(FBADDR(2*x, y), width);
}
}

View file

@ -410,7 +410,7 @@ void lcd_update_rect(int x, int y, int width, int height)
/* Prevent the tick from triggering BCM updates while we're writing. */
lcd_block_tick();
addr = &lcd_framebuffer[y][x];
addr = FBADDR(x, y);
bcmaddr = BCMA_CMDPARAM + (LCD_WIDTH*2) * y + (x << 1);
if (width == LCD_WIDTH)

View file

@ -527,7 +527,7 @@ void lcd_update_rect(int x0, int y0, int width, int height)
/* start drawing */
lcd_send_cmd(R_WRITE_DATA_2_GRAM);
addr = (unsigned short*)&lcd_framebuffer[y0][x0];
addr = (unsigned short*)FBADDR(x0,y0);
int c, r;

View file

@ -327,7 +327,7 @@ void lcd_update_rect(int x0, int y0, int width, int height)
/* start drawing */
lcd_send_cmd(R_WRITE_DATA_2_GRAM);
addr = (unsigned long*)&lcd_framebuffer[y0][x0];
addr = (unsigned long*)FBADDR(x0,y0);
while (height > 0) {
int c, r;

View file

@ -395,7 +395,7 @@ void lcd_update_rect(int x, int y, int width, int height)
if ((width <= 0) || (height <= 0))
return; /* Nothing left to do. */
addr = &lcd_framebuffer[y][x];
addr = FBADDR(x,y);
if (width <= 1) {
/* The X end address must be larger than the X start address, so we

View file

@ -303,7 +303,7 @@ void lcd_update(void)
lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf));
lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf));
lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
lcd_write_data (FBADDR(0, y), LCD_WIDTH);
}
}
@ -331,6 +331,6 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf));
lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
lcd_write_data (&lcd_framebuffer[y][x], width);
lcd_write_data (FBADDR(x,y), width);
}
}

View file

@ -239,7 +239,7 @@ void lcd_update(void)
lcd_write_command(cmd1);
lcd_write_command(cmd2);
lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
lcd_write_data (FBADDR(0, y), LCD_WIDTH);
}
}
@ -271,6 +271,6 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_write_command(cmd1);
lcd_write_command(cmd2);
lcd_write_data (&lcd_framebuffer[y][x], width);
lcd_write_data (FBADDR(x,y), width);
}
}

View file

@ -255,7 +255,7 @@ static void remote_update_lcd(void)
data[6] = (y + 1) << 3; /* y2 */
for (x = 0; x < RC_WIDTH; x++)
data[x + 7] = lcd_remote_framebuffer[y][x];
data[x + 7] = FBREMOTEADDR(x,y);
remote_tx(data, RC_WIDTH + 7);

View file

@ -483,7 +483,7 @@ void lcd_update_rect(int x0, int y0, int width, int height)
/* start drawing */
lcd_send_cmd(R_WRITE_DATA_2_GRAM);
addr = &lcd_framebuffer[y0][x0];
addr = FBADDR(x0, y0)
int c, r;
for (r = 0; r < height; r++)

View file

@ -373,7 +373,7 @@ void lcd_update_rect(int x, int y, int width, int height)
if ((width <= 0) || (height <= 0))
return; /* Nothing left to do. */
addr = &lcd_framebuffer[y][x];
addr = FBADDR(x,y);
lcd_send_cmd(CASET);
lcd_send_data(x);

View file

@ -285,7 +285,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_send_reg(LCD_REG_WRITE_DATA_2_GRAM);
addr = (unsigned long*)&lcd_framebuffer[y][x];
addr = (unsigned long*)FBADDR(x,y);
while (height > 0)
{

View file

@ -495,8 +495,8 @@ void lcd_update(void)
if (!display_on)
return;
addr = &lcd_framebuffer[0][0];
end = &lcd_framebuffer[LCD_HEIGHT - 1][LCD_WIDTH];
addr = FBADDR(0,0);
end = FBADDR(LCD_WIDTH,LCD_HEIGHT - 1);
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH - 1) << 8);
lcd_write_reg(R_VERT_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
@ -533,7 +533,7 @@ void lcd_update_rect(int x, int y, int width, int height)
if (height <= 0)
return; /* Nothing left to do. */
addr = &lcd_framebuffer[y][x];
addr = FBADDR(x,y);
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, ((x + width - 1) << 8) | x);
lcd_write_reg(R_VERT_RAM_ADDR_POS, ((y + height - 1) << 8) | y);

View file

@ -191,7 +191,7 @@ void lcd_update(void)
lcd_write_command (LCD_CNTL_HIGHCOL);
lcd_write_command (LCD_CNTL_LOWCOL | 4);
lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
lcd_write_data (FBADDR(0, y), LCD_WIDTH);
}
}
@ -219,6 +219,6 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_write_command (LCD_CNTL_HIGHCOL | (((x+4) >> 4) & 0xf));
lcd_write_command (LCD_CNTL_LOWCOL | ((x+4) & 0xf));
lcd_write_data (&lcd_framebuffer[y][x], width);
lcd_write_data (FBADDR(x,y), width);
}
}

View file

@ -162,7 +162,7 @@ void lcd_update_rect(int x, int y, int width, int height)
for (px=x; px<pxmax; px++)
for (py=y; py<pymax; py++)
lcd_data(lcd_framebuffer[py][px]);
lcd_data(FBADDR(px, py));
}
/* Blit a YUV bitmap directly to the LCD */

View file

@ -191,7 +191,7 @@ void lcd_update_rect(int x, int y, int width, int height)
for (py=y; py<pymax; py++)
{
for (px=x; px<pxmax; px++)
LCD_DATA = lcd_pixel_transform(lcd_framebuffer[py][px]);
LCD_DATA = lcd_pixel_transform(FBADDR(px,py));
}
}

View file

@ -394,7 +394,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_setup_drawing_region(x, y, width, height);
/* Copy display bitmap to hardware */
p = &lcd_framebuffer[y][x];
p = FBADDR(x,y);
if (LCD_WIDTH == width) {
/* Write all lines at once */
lcd_write_line(p, height*LCD_WIDTH, LCD_BASE);

View file

@ -295,7 +295,7 @@ void lcd_update(void)
LCD_WCMD = 0;
LCD_WCMD = 0x22;
}
for(p=&lcd_framebuffer[0][0], i=0;i<LCD_WIDTH*LCD_FBHEIGHT;++i, ++p) {
for(p=FBADDR(0,0), i=0;i<LCD_WIDTH*LCD_FBHEIGHT;++i, ++p) {
while (LCD_STATUS & STAT_FULL);
LCD_WDATA = RGB_UNPACK_RED(*p);
while (LCD_STATUS & STAT_FULL);

View file

@ -438,8 +438,8 @@ void lcd_init_device(void)
lcd_controller_init();
/* set framebuffer addresses */
fb = (uint32_t) &lcd_framebuffer[0][0];
fb_end = (uint32_t) &lcd_framebuffer[LCD_HEIGHT][0];
fb = (uint32_t) FBADDR(0,0);
fb_end = (uint32_t) FBADDR(0,LCD_HEIGHT);
window = 2 * LCD_WIDTH;
LCDB1SADDR1 = fb;

View file

@ -306,7 +306,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_set_position1(x, y);
for (h = 0; h < height; h++) {
p = &lcd_framebuffer[y][0];
p = FBADDR(0,y);
for (w = 0; w < LCD_WIDTH; w++) {
while (LCD_STATUS & 0x10);
LCD_WDATA = *p++;
@ -319,7 +319,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_set_position2(x, y);
for (h = 0; h < height; h++) {
p = &lcd_framebuffer[y][x];
p = FBADDR(x,y);
for (w = 0; w < width; w++) {
while (LCD_STATUS & 0x10);
LCD_WDATA = *p++;

View file

@ -428,7 +428,7 @@ void lcd_update_rect(int, int, int, int) ICODE_ATTR;
void lcd_update_rect(int x, int y, int width, int height)
{
int pixels = width * height;
fb_data* p = &lcd_framebuffer[y][x];
fb_data* p = FBADDR(x,y);
uint16_t* out = lcd_dblbuf[0];
#ifdef HAVE_LCD_SLEEP

View file

@ -347,7 +347,7 @@ void lcd_update_rect(int x, int y, int width, int height)
if ((width <= 0) || (height <= 0))
return; /* Nothing left to do. */
addr = &lcd_framebuffer[y][x];
addr = FBADDR(x,y);
if (width <= 1) {
lcd_send_command(R_ENTRY_MODE); /* The X end address must be larger */

View file

@ -259,7 +259,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_write_reg(LCD_CNTL_PAGE, y);
lcd_write_reg(LCD_CNTL_COLUMN, x);
addr = &lcd_framebuffer[y][x];
addr = FBADDR(x,y);
lcd_send_cmd(LCD_CNTL_DATA_WRITE);
lcd_write_data(addr, width);

View file

@ -639,7 +639,7 @@ void lcd_update_rect(int x0, int y0, int width, int height)
/* start drawing */
lcd_send_cmd(R_WRITE_DATA_2_GRAM);
addr = (unsigned short*)&lcd_framebuffer[y0][x0];
addr = (unsigned short*)FBADDR(x0,y0);
int c, r;

View file

@ -363,7 +363,7 @@ void lcd_update(void)
{
const fb_data *addr;
addr = &lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH];
addr = FBADDR(LCD_WIDTH,LCD_HEIGHT);
lcd_write_reg(0x20, 0x0);
lcd_write_reg(0x21, 0x0);

View file

@ -252,7 +252,7 @@ void lcd_update_rect(int x, int y, int width, int height)
if ((width <= 0) || (height <= 0))
return; /* Nothing left to do. */
addr = &lcd_framebuffer[y][x];
addr = FBADDR(x,y);
if (width <= 1) {
lcd_send_command(R_ENTRY_MODE); /* The X end address must be larger */

View file

@ -211,7 +211,7 @@ void lcd_update_rect(int sx, int sy, int width, int height)
fb_data c;
unsigned long color;
c = lcd_framebuffer[y][x];
c = FBADDR(x,y);
color =
((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) <<
2);

View file

@ -380,7 +380,7 @@ void lcd_update_rect(int x, int y, int width, int height)
#if CONFIG_ORIENTATION == SCREEN_PORTRAIT
dst = (fb_data *)FRAME + LCD_WIDTH*y + x;
src = &lcd_framebuffer[y][x];
src = FBADDR(x,y);
/* Copy part of the Rockbox framebuffer to the second framebuffer */
if (width < LCD_WIDTH)
@ -394,7 +394,7 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1);
}
#else
src = &lcd_framebuffer[y][x];
src = FBADDR(x,y);
register int xc, yc;
register fb_data *start=FRAME + LCD_HEIGHT*(LCD_WIDTH-x-1) + y + 1;
@ -419,7 +419,7 @@ void lcd_update(void)
if (!lcd_on || direct_fb_access)
return;
#if CONFIG_ORIENTATION == SCREEN_PORTRAIT
lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0],
lcd_copy_buffer_rect((fb_data *)FRAME, FBADDR(0,0),
LCD_WIDTH*LCD_HEIGHT, 1);
#else
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);

View file

@ -500,12 +500,12 @@ void lcd_update_rect(int x, int y, int width, int height)
if (width < LCD_WIDTH)
{
/* Not full width - do line-by-line */
lcd_copy_buffer_rect(dst, &lcd_framebuffer[y][x], width, height);
lcd_copy_buffer_rect(dst, FBADDR(x,y), width, height);
}
else
{
/* Full width - copy as one line */
lcd_copy_buffer_rect(dst, &lcd_framebuffer[y][x], LCD_WIDTH*height, 1);
lcd_copy_buffer_rect(dst, FBADDR(x,y), LCD_WIDTH*height, 1);
}
#endif
@ -519,7 +519,7 @@ void lcd_update_rect(int x, int y, int width, int height)
#else
fb_data *src;
fb_data *dst;
src = &lcd_framebuffer[0][0] + (x*LCD_HEIGHT + y);
src = FBADDR(0,0) + (x*LCD_HEIGHT + y);
dst = FRAME + (LCD_HEIGHT*(LCD_WIDTH-1) - x * LCD_HEIGHT + y);
while(width > 0) {
@ -532,7 +532,7 @@ void lcd_update_rect(int x, int y, int width, int height)
#else
register fb_data *dst, *src;
src = &lcd_framebuffer[y][x];
src = FBADDR(x,y);
dst=FRAME + (LCD_NATIVE_WIDTH*(LCD_NATIVE_HEIGHT-1))
- LCD_NATIVE_WIDTH*x + y ;

View file

@ -246,7 +246,7 @@ static void remote_tick(void)
for(i=7; i<remote_payload_size; i++)
{
remote_payload[i]=
lcd_remote_framebuffer[remote_payload[4]>>3][i+remote_draw_x-7];
FBREMOTEADDR(i+remote_draw_x-7, remote_payload[4]>>3);
}
}

View file

@ -167,7 +167,7 @@ static void dma_lcd_copy_buffer_rect(int x, int y, int width, int height)
/* Set source and destination addresses */
dst = (char*)(FRAME + LCD_WIDTH*y + x);
src = (char*)(&lcd_framebuffer[y][x]);
src = (char*)(FBADDR(x,y));
/* Flush cache to memory */
commit_dcache();