drivers/video: Refine the update region notification mechanism

1.Expose the notification through fb_vtable_s::updatearea
2.Incorporate old nx_notify_rectangle into the new updatearea callback
3.Migrate the calle of nx_notify_rectangle to fb_vtable_s::updatearea

Change-Id: Ia3d1f73e8757b2d381586d76ec6adc16c810018d
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2020-06-04 10:35:50 +08:00 committed by Alin Jerpelea
parent 154852acb5
commit fd78f83e02
24 changed files with 425 additions and 316 deletions

View File

@ -46,8 +46,6 @@
#include <nuttx/clock.h>
#include <nuttx/wqueue.h>
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/video/fb.h>
#include "up_internal.h"
@ -461,25 +459,3 @@ FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane)
void up_fbuninitialize(int display)
{
}
/****************************************************************************
* Name: nx_notify_rectangle
*
* Description:
* Must be provided if CONFIG_NX_UPDATE is enabled
*
* Input Parameters:
* display - In the case of hardware with multiple displays, this
* specifies the display. Normally this is zero.
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect)
{
}
#endif

View File

@ -22,17 +22,12 @@ config LCD_PACKEDMSFIRST
bool
default n
config LCD_UPDATE
bool
default n
select NX_UPDATE if NX
comment "Common Graphic LCD Settings"
config LCD_FRAMEBUFFER
bool "LCD framebuffer front end"
default n
select LCD_UPDATE
select FB_UPDATE
---help---
Enable a "front end" that converts an sequential LCD driver into a
standard, NuttX frame buffer driver.

View File

@ -47,8 +47,6 @@
#include <nuttx/board.h>
#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/lcd/lcd.h>
#include <nuttx/video/fb.h>
@ -88,8 +86,8 @@ struct lcdfb_dev_s
/* Update the LCD when there is a change to the framebuffer */
static int lcdfb_update(FAR struct lcdfb_dev_s *priv,
FAR const struct nxgl_rect_s *rect);
static int lcdfb_updateearea(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area);
/* Get information about the video controller configuration and the
* configuration of each color plane.
@ -167,16 +165,17 @@ static FAR struct lcdfb_dev_s *lcdfb_find(int display)
}
/****************************************************************************
* Name: lcdfb_update
* Name: lcdfb_updateearea
*
* Description:
* Update the LCD when there is a change to the framebuffer.
*
****************************************************************************/
static int lcdfb_update(FAR struct lcdfb_dev_s *priv,
FAR const struct nxgl_rect_s *rect)
static int lcdfb_updateearea(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area)
{
FAR struct lcdfb_dev_s *priv = (FAR struct lcdfb_dev_s *)vtable;
FAR struct lcd_planeinfo_s *pinfo = &priv->pinfo;
FAR uint8_t *run;
fb_coord_t row;
@ -187,27 +186,31 @@ static int lcdfb_update(FAR struct lcdfb_dev_s *priv,
fb_coord_t endy;
int ret;
DEBUGASSERT(area != NULL);
DEBUGASSERT(area->w >= 1);
DEBUGASSERT(area->h >= 1);
/* Clip to fit in the framebuffer */
startx = rect->pt1.x;
startx = area->x;
if (startx < 0)
{
startx = 0;
}
endx = rect->pt2.x;
endx = startx + area->w - 1;
if (endx >= priv->xres)
{
endx = priv->xres - 1;
}
starty = rect->pt1.y;
starty = area->y;
if (starty < 0)
{
starty = 0;
}
endy = rect->pt2.y;
endy = starty + area->h - 1;
if (endy >= priv->yres)
{
endy = priv->yres - 1;
@ -473,7 +476,7 @@ int up_fbinitialize(int display)
FAR struct lcdfb_dev_s *priv;
FAR struct lcd_dev_s *lcd;
struct fb_videoinfo_s vinfo;
struct nxgl_rect_s rect;
struct fb_area_s area;
int ret;
lcdinfo("display=%d\n", display);
@ -502,6 +505,7 @@ int up_fbinitialize(int display)
priv->vtable.getcursor = lcdfb_getcursor,
priv->vtable.setcursor = lcdfb_setcursor,
#endif
priv->vtable.updatearea = lcdfb_updateearea,
#ifdef CONFIG_LCD_EXTERNINIT
/* Use external graphics driver initialization */
@ -577,12 +581,12 @@ int up_fbinitialize(int display)
/* Write the entire framebuffer to the LCD */
rect.pt1.x = 0;
rect.pt1.y = 0;
rect.pt2.x = priv->xres - 1;
rect.pt2.y = priv->yres - 1;
area.x = 0;
area.y = 0;
area.w = priv->xres;
area.h = priv->yres;
ret = lcdfb_update(priv, &rect);
ret = lcdfb_updateearea(&priv->vtable, &area);
if (ret < 0)
{
lcderr("FB update failed: %d\n", ret);
@ -700,57 +704,4 @@ void up_fbuninitialize(int display)
}
}
/****************************************************************************
* Name: nx_notify_rectangle
*
* Description:
* When CONFIG_LCD_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
* NOTE: This function is also required for use with the LCD framebuffer
* driver front end when CONFIG_LCD_UPDATE=y, although that use does not
* depend on CONFIG_NX (and this function seems misnamed in that case).
*
****************************************************************************/
#if defined(CONFIG_LCD_UPDATE) || defined(CONFIG_NX_UPDATE)
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect)
{
FAR struct fb_planeinfo_s *fpinfo = (FAR struct fb_planeinfo_s *)pinfo;
FAR struct lcdfb_dev_s *priv;
int ret;
DEBUGASSERT(fpinfo != NULL && rect != NULL);
/* Look up the LCD framebuffer state structure for this display.
*
* REVISIT: If many LCD framebuffers are used, then this lookup would be
* a performance issue.
*/
priv = lcdfb_find(fpinfo->display);
if (priv != NULL)
{
ret = lcdfb_update(priv, rect);
if (ret < 0)
{
lcderr("FB update failed: %d\n", ret);
}
}
}
#endif
#endif /* CONFIG_LCD_FRAMEBUFFER */

View File

@ -3,6 +3,37 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
config FB_CMAP
bool
default n
---help---
Set by driver-specific configuration to indicate support for color
mapping. Not directly user selectable.
config FB_TRANSPARENCY
bool
default n
---help---
Set by driver-specific configuration to indicate support for color
transparency. Not directly user selectable.
config FB_UPDATE
bool
default n
config FB_SYNC
bool "Hardware signals vertical sync"
default n
config FB_OVERLAY
bool "Framebuffer overlay support"
default n
config FB_OVERLAY_BLIT
bool "Framebuffer overlay blit support"
depends on FB_OVERLAY
default n
menuconfig DRIVERS_VIDEO
bool "Video Device Support"
default n
@ -15,37 +46,6 @@ config VIDEO_FB
bool "Framebuffer character driver"
default n
config FB_CMAP
bool
depends on VIDEO_FB
default n
---help---
Set by driver-specific configuration to indicate support for color
mapping. Not directly user selectable.
config FB_TRANSPARENCY
bool
depends on VIDEO_FB
default n
---help---
Set by driver-specific configuration to indicate support for color
transparency. Not directly user selectable.
config FB_SYNC
bool "Hardware signals vertical sync"
depends on VIDEO_FB
default n
config FB_OVERLAY
bool "Framebuffer overlay support"
depends on VIDEO_FB
default n
config FB_OVERLAY_BLIT
bool "Framebuffer overlay blit support"
depends on FB_OVERLAY
default n
config VIDEO_STREAM
bool "Video Stream Support"
default n

View File

@ -49,8 +49,6 @@
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/video/fb.h>
/****************************************************************************
@ -402,20 +400,13 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break;
#endif
#ifdef CONFIG_LCD_UPDATE
case FBIO_UPDATE: /* Update the LCD with the modified framebuffer data */
#ifdef CONFIG_FB_UPDATE
case FBIO_UPDATE: /* Update the modified framebuffer data */
{
FAR struct nxgl_rect_s *rect =
(FAR struct nxgl_rect_s *)((uintptr_t)arg);
struct fb_planeinfo_s pinfo;
struct fb_area_s *area = (FAR struct fb_area_s *)((uintptr_t)arg);
DEBUGASSERT(fb->vtable != NULL &&
fb->vtable->getplaneinfo != NULL);
ret = fb->vtable->getplaneinfo(fb->vtable, fb->plane, &pinfo);
if (ret >= 0)
{
nx_notify_rectangle((FAR NX_PLANEINFOTYPE *)&pinfo, rect);
}
DEBUGASSERT(fb->vtable != NULL && fb->vtable->updatearea != NULL);
ret = fb->vtable->updatearea(fb->vtable, area);
}
break;
#endif

View File

@ -143,7 +143,7 @@ config NX_WRITEONLY
config NX_UPDATE
bool "Display update hooks"
default n
default FB_UPDATE && !NX_LCDDRIVER
---help---
Enable a callout to inform some external module that the display has
been updated. This would be useful in a couple for cases.
@ -158,8 +158,11 @@ config NX_UPDATE
When this feature is enabled, some external logic must provide this
interface:
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect);
fb_vtable_s
{
int (*updatearea)(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area);
};
That is the function that will handle the notification. It
receives the rectangular region that was updated in the provided

View File

@ -50,6 +50,10 @@ else ifeq ($(CONFIG_NX_HWCURSOR),y)
CSRCS += nxbe_cursor.c
endif
ifeq ($(CONFIG_NX_UPDATE),y)
CSRCS += nxbe_notify_rectangle.c
endif
DEPPATH += --dep-path nxbe
CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)/graphics/nxbe}
VPATH += :nxbe

View File

@ -189,6 +189,7 @@ struct nxbe_plane_s
/* Framebuffer plane info describing destination video plane */
NX_DRIVERTYPE *driver;
NX_PLANEINFOTYPE pinfo;
};
@ -252,9 +253,9 @@ struct nxbe_state_s
FAR struct nxbe_window_s *topwnd; /* The window at the top of the display */
struct nxbe_window_s bkgd; /* The background window is always at the bottom */
/* At present, only a solid colored background is supported for refills. The
* following provides the background color. It would be nice to support
* background bitmap images as well.
/* At present, only a solid colored background is supported for refills.
* The following provides the background color. It would be nice to
* support background bitmap images as well.
*/
nxgl_mxpixel_t bgcolor[CONFIG_NX_NPLANES];
@ -279,13 +280,14 @@ struct nxbe_state_s
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
@ -300,6 +302,32 @@ extern "C" {
int nxbe_colormap(FAR NX_DRIVERTYPE *dev);
#endif
/****************************************************************************
* Name: nxbe_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nxbe_notify_rectangle(FAR NX_DRIVERTYPE *dev,
FAR const struct nxgl_rect_s *rect);
#endif
/****************************************************************************
* Name: nx_configure
*
@ -523,8 +551,8 @@ void nxbe_setvisibility(FAR struct nxbe_window_s *wnd, bool hide);
* Name: nxbe_setpixel
*
* Description:
* Set a single pixel in the window to the specified color. This is simply
* a degenerate case of nxbe_fill(), but may be optimized in some architectures.
* Set a single pixel in the window to the specified color. This is simply a
* degenerate case of nxbe_fill, but may be optimized in some architectures.
*
* Input Parameters:
* wnd - The window structure reference

View File

@ -67,8 +67,8 @@ struct nx_bitmap_s
* Name: bitmap_clipcopy
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
* Called from nxbe_clipper() to performed the fill operation on visible
* portions of the rectangle.
*
****************************************************************************/
@ -86,7 +86,7 @@ static void bitmap_clipcopy(FAR struct nxbe_clipops_s *cops,
#ifdef CONFIG_NX_UPDATE
/* Notify external logic that the display has been updated */
nx_notify_rectangle(&plane->pinfo, rect);
nxbe_notify_rectangle(plane->driver, rect);
#endif
}
@ -340,8 +340,8 @@ void nxbe_bitmap(FAR struct nxbe_window_s *wnd,
nxbe_bitmap_dev(wnd, dest, src, origin, stride);
#ifdef CONFIG_NX_SWCURSOR
/* Update cursor backup memory and redraw the cursor in the modified window
* region.
/* Update cursor backup memory and redraw the cursor in the modified
* window region.
*/
nxbe_cursor_backupdraw_all(wnd, dest);

View File

@ -107,11 +107,6 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
CONFIG_NX_NPLANES, be->vinfo.nplanes);
return -E2BIG;
}
else if (be->vinfo.nplanes < CONFIG_NX_NPLANES)
{
gwarn("WARNING: NX configured for %d planes, controller only needs %d\n",
CONFIG_NX_NPLANES, be->vinfo.nplanes);
}
#endif
/* Then get information about each color plane */
@ -125,6 +120,8 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
return ret;
}
be->plane[i].driver = dev;
/* Select rasterizers to match the BPP reported for this plane.
* NOTE that there are configuration options to eliminate support
* for unused BPP values. If the unused BPP values are not suppressed
@ -309,5 +306,6 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
return -ENOSYS;
}
}
return OK;
}

View File

@ -83,7 +83,7 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops,
#ifdef CONFIG_NX_UPDATE
/* Notify external logic that the display has been updated */
nx_notify_rectangle(&plane->pinfo, rect);
nxbe_notify_rectangle(plane->driver, rect);
#endif
}
@ -168,8 +168,8 @@ static inline void nxbe_fill_pwfb(FAR struct nxbe_window_s *wnd,
DEBUGASSERT(wnd->be->plane[0].pwfb.fillrectangle != NULL);
/* The rectangle that we receive here is in absolute device coordinates. We
* need to restore this to windows relative coordinates.
/* The rectangle that we receive here is in absolute device coordinates.
* We need to restore this to windows relative coordinates.
*/
nxgl_rectoffset(&relrect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y);

View File

@ -78,8 +78,8 @@ struct nxbe_filltrap_s
* Name: nxbe_clipfilltrapezoid
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
* Called from nxbe_clipper() to performed the fill operation on visible
* portions of the rectangle.
*
****************************************************************************/
@ -107,7 +107,7 @@ static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops,
MIN(fillinfo->trap.bot.x2, rect->pt2.x));
update.pt2.y = MIN(fillinfo->trap.bot.y, rect->pt2.y);
nx_notify_rectangle(&plane->pinfo, &update);
nxbe_notify_rectangle(plane->driver, &update);
#endif
}
@ -129,7 +129,8 @@ static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops,
*
****************************************************************************/
static inline void nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd,
static inline void
nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *bounds,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
@ -190,7 +191,8 @@ static inline void nxbe_filltrapezoid_dev(FAR struct nxbe_window_s *wnd,
****************************************************************************/
#ifdef CONFIG_NX_RAMBACKED
static inline void nxbe_filltrapezoid_pwfb(FAR struct nxbe_window_s *wnd,
static inline void
nxbe_filltrapezoid_pwfb(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *bounds,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])

View File

@ -69,8 +69,8 @@ struct nxbe_move_s
* Name: nxbe_clipmovesrc
*
* Description:
* Called from nxbe_clipper() to performed the move operation on visible regions
* of the rectangle.
* Called from nxbe_clipper() to performed the move operation on visible
* regions of the rectangle.
*
****************************************************************************/
@ -92,7 +92,9 @@ static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
offset.x = rect->pt1.x + info->offset.x;
offset.y = rect->pt1.y + info->offset.y;
/* Move the source rectangle to the destination position in the device */
/* Move the source rectangle to the destination position in the
* device
*/
plane->dev.moverectangle(&plane->pinfo, rect, &offset);
@ -109,7 +111,7 @@ static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
* rectangle has changed.
*/
nx_notify_rectangle(&plane->pinfo, &update);
nxbe_notify_rectangle(plane->driver, &update);
#endif
}
}
@ -118,8 +120,8 @@ static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
* Name: nxbe_clipmoveobscured
*
* Description:
* Called from nxbe_clipper() to performed the move operation on obsrured regions
* of the rectangle.
* Called from nxbe_clipper() to performed the move operation on obsrured
* regions of the rectangle.
*
****************************************************************************/
@ -336,8 +338,8 @@ static inline void nxbe_move_pwfb(FAR struct nxbe_window_s *wnd,
struct nxgl_rect_s destrect;
unsigned int bpp;
/* The rectangle that we receive here is in absolute device coordinates. We
* need to restore this to windows relative coordinates.
/* The rectangle that we receive here is in absolute device coordinates.
* We need to restore this to windows relative coordinates.
*/
nxgl_rectoffset(&srcrect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y);
@ -457,7 +459,9 @@ void nxbe_move(FAR struct nxbe_window_s *wnd,
if (!nxgl_nullrect(&srcrect))
{
#ifdef CONFIG_NX_RAMBACKED
/* Update the pre-window framebuffer first, then the device memory. */
/* Update the pre-window framebuffer first, then the device
* memory.
*/
if (NXBE_ISRAMBACKED(wnd))
{

View File

@ -0,0 +1,65 @@
/****************************************************************************
* graphics/nxbe/nxbe_notify_rectangle.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/nx/nxglib.h>
#include "nxbe.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nxbe_notify_rectangle(FAR NX_DRIVERTYPE *dev,
FAR const struct nxgl_rect_s *rect)
{
struct fb_area_s area;
nxgl_rect2area(&area, rect);
dev->updatearea(dev, &area);
}
#endif

View File

@ -64,8 +64,8 @@ struct nxbe_setpixel_s
* Name: nxbe_clipfill
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
* Called from nxbe_clipper() to performed the fill operation on visible
* portions of the rectangle.
*
****************************************************************************/
@ -82,7 +82,7 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops,
#ifdef CONFIG_NX_UPDATE
/* Notify external logic that the display has been updated */
nx_notify_rectangle(&plane->pinfo, rect);
nxbe_notify_rectangle(plane->driver, rect);
#endif
}
@ -189,7 +189,8 @@ void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
#ifdef CONFIG_NX_RAMBACKED
/* If this window supports a pre-window frame buffer then shadow the full,
* unclipped bitmap in that framebuffer.
* REVISIT: The logic to set a pixel in the per-window frame buffer is missing
* REVISIT: The logic to set a pixel in the per-window frame buffer is
* missing
*/
DEBUGASSERT(!NXBE_ISRAMBACKED(wnd));

View File

@ -7,7 +7,7 @@ menuconfig VNCSERVER
bool "VNC server"
default n
depends on NET_TCP && !NX_LCDDRIVER
select NX_UPDATE
select FB_UPDATE
---help---
Enable support for a VNC Remote Frame Buffer (RFB) server.

View File

@ -109,6 +109,11 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
FAR struct fb_setcursor_s *settings);
#endif
/* Update the host window when there is a change to the framebuffer */
static int up_updateearea(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area);
/****************************************************************************
* Private Data
****************************************************************************/
@ -403,6 +408,44 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
}
#endif
/****************************************************************************
* Name: up_updateearea
****************************************************************************/
static int up_updateearea(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area)
{
FAR struct vnc_fbinfo_s *fbinfo = (FAR struct vnc_fbinfo_s *)vtable;
FAR struct vnc_session_s *session;
struct nxgl_rect_s rect;
int ret = OK;
DEBUGASSERT(fbinfo != NULL && area != NULL);
/* Recover the session information from the display number in the planeinfo
* structure.
*/
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
/* Verify that the session is still valid */
if (session != NULL && session->state == VNCSERVER_RUNNING)
{
/* Queue the rectangular update */
nxgl_area2rect(&rect, area);
ret = vnc_update_rectangle(session, &rect, true);
if (ret < 0)
{
gerr("ERROR: vnc_update_rectangle failed: %d\n", ret);
}
}
return ret;
}
/****************************************************************************
* Name: vnc_start_server
*
@ -774,6 +817,7 @@ FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane)
fbinfo->vtable.getcursor = up_getcursor,
fbinfo->vtable.setcursor = up_setcursor,
#endif
fbinfo->vtable.updatearea = up_updateearea,
fbinfo->display = display;
fbinfo->initialized = true;
}
@ -821,55 +865,3 @@ void up_fbuninitialize(int display)
}
#endif
}
/****************************************************************************
* Name: nx_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect)
{
FAR struct vnc_session_s *session;
int ret;
DEBUGASSERT(pinfo != NULL && rect != NULL);
/* Recover the session information from the display number in the planeinfo
* structure.
*/
DEBUGASSERT(pinfo->display >= 0 && pinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[pinfo->display];
/* Verify that the session is still valid */
if (session != NULL && session->state == VNCSERVER_RUNNING)
{
/* Queue the rectangular update */
ret = vnc_update_rectangle(session, rect, true);
if (ret < 0)
{
gerr("ERROR: vnc_update_rectangle failed: %d\n", ret);
}
}
}
#endif

View File

@ -60,10 +60,6 @@
/* Configuration */
#ifndef CONFIG_NX_UPDATE
# error CONFIG_NX_UPDATE must be set to use VNC
#endif
#if !defined(CONFIG_VNCSERVER_PROTO3p3) && !defined(CONFIG_VNCSERVER_PROTO3p8)
# error No VNC protocol selected
#endif

View File

@ -205,7 +205,8 @@ struct nx_callback_s
**************************************************************************/
#ifdef CONFIG_NX_KBD
void (*kbdin)(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, FAR void *arg);
void (*kbdin)(NXWINDOW hwnd, uint8_t nch,
FAR const uint8_t *ch, FAR void *arg);
#endif
/**************************************************************************
@ -270,7 +271,7 @@ extern "C"
#endif
/****************************************************************************
* Public Functions
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
@ -383,8 +384,8 @@ int nx_eventhandler(NXHANDLE handle);
* client can then call nv_eventhandler() only when incoming events are
* available.
*
* Only one such event is issued. Upon receipt of the signal, if the client
* wishes further notifications, it must call nx_eventnotify again.
* Only one such event is issued. Upon receipt of the signal, if the
* client wishes further notifications, it must call nx_eventnotify again.
*
* Input Parameters:
* handle - the handle returned by nx_connect
@ -726,7 +727,7 @@ bool nx_ishidden(NXWINDOW hwnd);
*
* Description:
* Set a single pixel in the window to the specified color. This is simply
* a degenerate case of nx_fill(), but may be optimized in some architectures.
* a degenerate case of nx_fill but may be optimized in some architectures.
*
* Input Parameters:
* wnd - The window structure reference
@ -794,7 +795,8 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
* Name: nx_filltrapezoid
*
* Description:
* Fill the specified trapezoidal region in the window with the specified color
* Fill the specified trapezoidal region in the window with the specified
* color
*
* Input Parameters:
* hwnd - The window handle
@ -943,36 +945,6 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin, unsigned int stride);
/****************************************************************************
* Name: nx_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
* NOTE: This function is also required for use with the LCD framebuffer
* driver front end when CONFIG_LCD_UPDATE=y, although that use does not
* depend on CONFIG_NX (and this function seems misnamed in that case).
*
****************************************************************************/
#if defined(CONFIG_NX_UPDATE) || defined(CONFIG_LCD_UPDATE)
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect);
#endif
/****************************************************************************
* Name: nx_kbdin
*
@ -999,7 +971,8 @@ int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch);
****************************************************************************/
#ifdef CONFIG_NX_XYINPUT
int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons);
int nx_mousein(NXHANDLE handle, nxgl_coord_t x,
nxgl_coord_t y, uint8_t buttons);
#endif
/****************************************************************************
@ -1033,7 +1006,7 @@ void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect);
* Name: nx_constructwindow
*
* Description:
* This function is the same a nx_openwindow EXCEPT that the client provides
* This function is the same as nx_openwindow EXCEPT the client provides
* the window structure instance. nx_constructwindow will initialize the
* the pre-allocated window structure for use by NX. This function is
* provided in addition to nx_openwindow in order to support a kind of
@ -1041,7 +1014,7 @@ void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect);
* are not visible to NX.
*
* NOTE: hwnd must have been allocated using a user-space allocator that
* permits user access to the window. Once provided to nx_constructwindow()
* permits user access to the window. Once provided to nx_constructwindow
* that memory is owned and managed by NX. On certain error conditions or
* when the window is closed, NX will free the window.
*

View File

@ -65,6 +65,7 @@
#endif
/* Driver Selection *********************************************************/
/* NX_DRIVERTYPE selects either the framebuffer or LCD driver;
* NX_PLANINFO_TYPE hides the difference in the framebuffer and LCD driver
* plane types. defines are used instead of a typedefs to avoid type
@ -80,6 +81,7 @@
#endif
/* NXGL Macros **************************************************************/
/* Mnemonics for indices */
#define NX_TOP_NDX (0)
@ -144,6 +146,28 @@ void nxgl_rgb2yuv(uint8_t r, uint8_t g, uint8_t b,
void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v,
uint8_t *r, uint8_t *g, uint8_t *b);
/****************************************************************************
* Name: nxgl_area2rect
*
* Description:
* Convert nxgl_rect_s to fb_area_s.
*
****************************************************************************/
void nxgl_area2rect(FAR struct nxgl_rect_s *dest,
FAR const struct fb_area_s *src);
/****************************************************************************
* Name: nxgl_rect2area
*
* Description:
* Convert nxgl_rect_s to fb_area_s.
*
****************************************************************************/
void nxgl_rect2area(FAR struct fb_area_s *dest,
FAR const struct nxgl_rect_s *src);
/****************************************************************************
* Name: nxgl_rectcopy
*
@ -184,7 +208,8 @@ void nxgl_vectoradd(FAR struct nxgl_point_s *dest,
* Name: nxgl_vectsubtract
*
* Description:
* Add subtract vector v2 from vector v1 and return the result in vector dest
* Add subtract vector v2 from vector v1 and return the result in vector
* dest
*
****************************************************************************/
@ -196,7 +221,7 @@ void nxgl_vectsubtract(FAR struct nxgl_point_s *dest,
* Name: nxgl_rectintersect
*
* Description:
* Return the rectangle representing the intersection of the two rectangles.
* Return the rectangle representing the intersection of the two rectangles
*
****************************************************************************/

View File

@ -245,11 +245,11 @@
* fb_setcursor_s */
#endif
#ifdef CONFIG_LCD_UPDATE
#ifdef CONFIG_FB_UPDATE
# define FBIO_UPDATE _FBIOC(0x0007) /* Update a rectangular region in
* the framebuffer
* Argument: read-only struct
* nxgl_rect_s */
* fb_area_s */
#endif
#ifdef CONFIG_FB_SYNC
@ -324,15 +324,6 @@ struct fb_planeinfo_s
uint8_t bpp; /* Bits per pixel */
};
#ifdef CONFIG_FB_OVERLAY
/* This structure describes the transparency. */
struct fb_transp_s
{
uint8_t transp; /* Transparency */
uint8_t transp_mode; /* Transparency mode */
};
/* This structure describes an area. */
struct fb_area_s
@ -343,6 +334,15 @@ struct fb_area_s
fb_coord_t h; /* Height of the area */
};
#ifdef CONFIG_FB_OVERLAY
/* This structure describes the transparency. */
struct fb_transp_s
{
uint8_t transp; /* Transparency */
uint8_t transp_mode; /* Transparency mode */
};
/* This structure describes one overlay. */
struct fb_overlayinfo_s
@ -511,6 +511,15 @@ struct fb_vtable_s
FAR struct fb_setcursor_s *settings);
#endif
#ifdef CONFIG_FB_UPDATE
/* The following are provided only if the video hardware need extera
* notification to update display content.
*/
int (*updatearea)(FAR struct fb_vtable_s *vtable,
FAR const struct fb_area_s *area);
#endif
#ifdef CONFIG_FB_SYNC
/* The following are provided only if the video hardware signals
* vertical sync.

View File

@ -44,11 +44,11 @@ CSRCS += nxglib_rgbblend.c
# Files needed only by NX
ifeq ($(CONFIG_NX),y)
CSRCS += nxglib_circlepts.c nxglib_circletraps.c nxglib_intersecting.c
CSRCS += nxglib_nonintersecting.c nxglib_nullrect.c nxglib_rectadd.c
CSRCS += nxglib_rectcopy.c nxglib_rectinside.c nxglib_rectintersect.c
CSRCS += nxglib_rectoffset.c nxglib_rectoverlap.c nxglib_rectsize.c
CSRCS += nxglib_rectunion.c nxglib_rgb2yuv.c
CSRCS += nxgl_area2rect.c nxglib_circlepts.c nxglib_circletraps.c
CSRCS += nxglib_intersecting.c nxglib_nonintersecting.c nxglib_nullrect.c
CSRCS += nxgl_rect2area.c nxglib_rectadd.c nxglib_rectcopy.c nxglib_rectinside.c
CSRCS += nxglib_rectintersect.c nxglib_rectoffset.c nxglib_rectoverlap.c
CSRCS += nxglib_rectsize.c nxglib_rectunion.c nxglib_rgb2yuv.c
CSRCS += nxglib_runcopy.c nxglib_runoffset.c nxglib_splitline.c
CSRCS += nxglib_trapcopy.c nxglib_trapoffset.c nxglib_vectoradd.c
CSRCS += nxglib_vectsubtract.c nxglib_yuv2rgb.c

View File

@ -0,0 +1,48 @@
/****************************************************************************
* libs/libnx/nxglib/nxgl_area2rect.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/nx/nxglib.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxgl_area2rect
*
* Description:
* Convert fb_area_s to nxgl_rect_s.
*
****************************************************************************/
void nxgl_area2rect(FAR struct nxgl_rect_s *dest,
FAR const struct fb_area_s *src)
{
dest->pt1.x = src->x;
dest->pt1.y = src->y;
dest->pt2.x = src->x + src->w - 1;
dest->pt2.y = src->y + src->h - 1;
}

View File

@ -0,0 +1,48 @@
/****************************************************************************
* libs/libnx/nxglib/nxgl_rect2area.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/nx/nxglib.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxgl_rect2area
*
* Description:
* Convert nxgl_rect_s to fb_area_s.
*
****************************************************************************/
void nxgl_rect2area(FAR struct fb_area_s *dest,
FAR const struct nxgl_rect_s *src)
{
dest->x = src->pt1.x;
dest->y = src->pt1.y;
dest->w = src->pt2.x - src->pt1.x + 1;
dest->h = src->pt2.y - src->pt1.y + 1;
}