sim_framebuffer: add double buffer for sim
support double framebuffer mode and adapter to the new vsync queue. Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
This commit is contained in:
parent
e578f3b20d
commit
479bfd5414
@ -355,6 +355,14 @@ config SIM_FBBPP
|
||||
If you use the X11 display emulation, the selected BPP must match the BPP
|
||||
of your graphics hardware (probably 32 bits). Default: 8
|
||||
|
||||
config SIM_FRAMEBUFFER_COUNT
|
||||
int "Framebuffer count"
|
||||
depends on SIM_FRAMEBUFFER
|
||||
default 2
|
||||
---help---
|
||||
Framebuffer count.
|
||||
Simulated frambuffer count. Default: 2
|
||||
|
||||
endmenu
|
||||
|
||||
choice
|
||||
|
@ -55,7 +55,7 @@ static XShmSegmentInfo g_xshminfo;
|
||||
static int g_xerror;
|
||||
#endif
|
||||
static XImage *g_image;
|
||||
static unsigned char *g_framebuffer;
|
||||
static char *g_framebuffer;
|
||||
static unsigned short g_fbpixelwidth;
|
||||
static unsigned short g_fbpixelheight;
|
||||
static int g_shmcheckpoint = 0;
|
||||
@ -206,6 +206,9 @@ static void sim_x11uninit(void)
|
||||
|
||||
if (g_shmcheckpoint > 1)
|
||||
{
|
||||
#ifdef CONFIG_SIM_X11NOSHM
|
||||
g_image->data = g_framebuffer;
|
||||
#endif
|
||||
XDestroyImage(g_image);
|
||||
}
|
||||
|
||||
@ -247,7 +250,8 @@ static void sim_x11uninitialize(void)
|
||||
****************************************************************************/
|
||||
|
||||
static inline int sim_x11mapsharedmem(Display *display,
|
||||
int depth, unsigned int fblen)
|
||||
int depth, unsigned int fblen,
|
||||
int fbcount)
|
||||
{
|
||||
#ifndef CONFIG_SIM_X11NOSHM
|
||||
Status result;
|
||||
@ -282,8 +286,9 @@ static inline int sim_x11mapsharedmem(Display *display,
|
||||
g_shmcheckpoint++;
|
||||
|
||||
g_xshminfo.shmid = shmget(IPC_PRIVATE,
|
||||
g_image->bytes_per_line * g_image->height,
|
||||
IPC_CREAT | 0777);
|
||||
g_image->bytes_per_line *
|
||||
g_image->height * fbcount,
|
||||
IPC_CREAT | 0777);
|
||||
if (g_xshminfo.shmid < 0)
|
||||
{
|
||||
sim_x11uninitialize();
|
||||
@ -312,7 +317,7 @@ static inline int sim_x11mapsharedmem(Display *display,
|
||||
goto shmerror;
|
||||
}
|
||||
|
||||
g_framebuffer = (unsigned char *)g_image->data;
|
||||
g_framebuffer = g_image->data;
|
||||
g_shmcheckpoint++;
|
||||
}
|
||||
else
|
||||
@ -324,10 +329,10 @@ shmerror:
|
||||
#endif
|
||||
b_useshm = 0;
|
||||
|
||||
g_framebuffer = malloc(fblen);
|
||||
g_framebuffer = malloc(fblen * fbcount);
|
||||
|
||||
g_image = XCreateImage(display, DefaultVisual(display, g_screen),
|
||||
depth, ZPixmap, 0, (char *)g_framebuffer,
|
||||
depth, ZPixmap, 0, g_framebuffer,
|
||||
g_fbpixelwidth, g_fbpixelheight,
|
||||
8, 0);
|
||||
|
||||
@ -357,7 +362,7 @@ shmerror:
|
||||
|
||||
int sim_x11initialize(unsigned short width, unsigned short height,
|
||||
void **fbmem, size_t *fblen, unsigned char *bpp,
|
||||
unsigned short *stride)
|
||||
unsigned short *stride, int fbcount)
|
||||
{
|
||||
XWindowAttributes windowattributes;
|
||||
Display *display;
|
||||
@ -397,7 +402,7 @@ int sim_x11initialize(unsigned short width, unsigned short height,
|
||||
|
||||
/* Map the window to shared memory */
|
||||
|
||||
sim_x11mapsharedmem(display, windowattributes.depth, *fblen);
|
||||
sim_x11mapsharedmem(display, windowattributes.depth, *fblen, fbcount);
|
||||
|
||||
*fbmem = (void *)g_framebuffer;
|
||||
g_display = display;
|
||||
@ -438,6 +443,22 @@ int sim_x11closewindow(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_x11setoffset
|
||||
****************************************************************************/
|
||||
|
||||
int sim_x11setoffset(unsigned int offset)
|
||||
{
|
||||
if (g_display == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
g_image->data = g_framebuffer + offset;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_x11cmap
|
||||
****************************************************************************/
|
||||
|
@ -421,10 +421,21 @@ void sim_x11loop(void)
|
||||
#ifdef CONFIG_SIM_X11FB
|
||||
static clock_t last;
|
||||
clock_t now = clock_systime_ticks();
|
||||
union fb_paninfo_u info;
|
||||
|
||||
if (now - last >= MSEC2TICK(16))
|
||||
{
|
||||
last = now;
|
||||
if (fb_paninfo_count(&g_fbobject, FB_NO_OVERLAY) > 1)
|
||||
{
|
||||
fb_remove_paninfo(&g_fbobject, FB_NO_OVERLAY);
|
||||
}
|
||||
|
||||
if (fb_peek_paninfo(&g_fbobject, &info, FB_NO_OVERLAY) == OK)
|
||||
{
|
||||
sim_x11setoffset(info.planeinfo.yoffset * info.planeinfo.stride);
|
||||
}
|
||||
|
||||
sim_x11update();
|
||||
}
|
||||
#endif
|
||||
@ -451,9 +462,12 @@ int up_fbinitialize(int display)
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_SIM_X11FB
|
||||
g_planeinfo.xres_virtual = CONFIG_SIM_FBWIDTH;
|
||||
g_planeinfo.yres_virtual = CONFIG_SIM_FBHEIGHT * CONFIG_SIM_FRAMEBUFFER_COUNT;
|
||||
ret = sim_x11initialize(CONFIG_SIM_FBWIDTH, CONFIG_SIM_FBHEIGHT,
|
||||
&g_planeinfo.fbmem, &g_planeinfo.fblen,
|
||||
&g_planeinfo.bpp, &g_planeinfo.stride);
|
||||
&g_planeinfo.bpp, &g_planeinfo.stride,
|
||||
CONFIG_SIM_FRAMEBUFFER_COUNT);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
@ -282,10 +282,11 @@ void sim_registerblockdevice(void);
|
||||
#ifdef CONFIG_SIM_X11FB
|
||||
int sim_x11initialize(unsigned short width, unsigned short height,
|
||||
void **fbmem, size_t *fblen, unsigned char *bpp,
|
||||
unsigned short *stride);
|
||||
unsigned short *stride, int fbcount);
|
||||
int sim_x11update(void);
|
||||
int sim_x11openwindow(void);
|
||||
int sim_x11closewindow(void);
|
||||
int sim_x11setoffset(unsigned int offset);
|
||||
#ifdef CONFIG_FB_CMAP
|
||||
int sim_x11cmap(unsigned short first, unsigned short len,
|
||||
unsigned char *red, unsigned char *green,
|
||||
|
@ -79,6 +79,10 @@
|
||||
# error "Unsupported BPP"
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_LCD_FBCOUNT)
|
||||
# define CONFIG_LCD_FBCOUNT 1
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definition
|
||||
****************************************************************************/
|
||||
@ -467,7 +471,7 @@ int board_lcd_initialize(void)
|
||||
#ifdef CONFIG_SIM_X11FB
|
||||
ret = sim_x11initialize(CONFIG_SIM_FBWIDTH, CONFIG_SIM_FBHEIGHT,
|
||||
(void**)&g_planeinfo.buffer, &g_fblen,
|
||||
&g_planeinfo.bpp, &g_stride);
|
||||
&g_planeinfo.bpp, &g_stride, CONFIG_LCD_FBCOUNT);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user