From 04b723e44751325ee5787924e2516f5bd82fb33b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 6 Apr 2019 12:18:05 -0600 Subject: [PATCH] Squashed commit of the following: include/nuttx/nx/nxcursor.h: Add a header file descrbing the implementation of an NX cursor interface. There is no implementation in place yet. include/nuttx/video/cursor.h: Separate out cursor definitions from fb.h. Other graphic interfaces other than a framebuffer may support a cursor, possible a software cursor. --- arch/arm/src/lpc17xx/lpc17_lcd.c | 4 +- arch/arm/src/lpc54xx/lpc54_lcd.c | 4 +- arch/arm/src/sama5/sam_lcd.c | 4 +- arch/sim/src/up_framebuffer.c | 4 +- drivers/lcd/Kconfig | 4 + graphics/Kconfig | 22 +++++ graphics/vnc/server/vnc_fbdev.c | 4 +- include/nuttx/nx/nxcursor.h | 162 +++++++++++++++++++++++++++++++ include/nuttx/video/cursor.h | 93 ++++++++++++++++++ include/nuttx/video/fb.h | 50 ++-------- 10 files changed, 300 insertions(+), 51 deletions(-) create mode 100644 include/nuttx/nx/nxcursor.h create mode 100644 include/nuttx/video/cursor.h diff --git a/arch/arm/src/lpc17xx/lpc17_lcd.c b/arch/arm/src/lpc17xx/lpc17_lcd.c index e7aebe109f..04a95d69c1 100644 --- a/arch/arm/src/lpc17xx/lpc17_lcd.c +++ b/arch/arm/src/lpc17xx/lpc17_lcd.c @@ -160,12 +160,12 @@ static const struct fb_planeinfo_s g_planeinfo = /* Current cursor position */ #ifdef CONFIG_FB_HWCURSOR -static struct fb_cursorpos_s g_cpos; +static struct cursor_pos_s g_cpos; /* Current cursor size */ #ifdef CONFIG_FB_HWCURSORSIZE -static struct fb_cursorsize_s g_csize; +static struct cursor_size_s g_csize; #endif #endif diff --git a/arch/arm/src/lpc54xx/lpc54_lcd.c b/arch/arm/src/lpc54xx/lpc54_lcd.c index 2b8b5aa262..adc0a30e21 100644 --- a/arch/arm/src/lpc54xx/lpc54_lcd.c +++ b/arch/arm/src/lpc54xx/lpc54_lcd.c @@ -147,12 +147,12 @@ static const struct fb_planeinfo_s g_planeinfo = /* Current cursor position */ #ifdef CONFIG_FB_HWCURSOR -static struct fb_cursorpos_s g_cpos; +static struct cursor_pos_s g_cpos; /* Current cursor size */ #ifdef CONFIG_FB_HWCURSORSIZE -static struct fb_cursorsize_s g_csize; +static struct cursor_size_s g_csize; #endif #endif diff --git a/arch/arm/src/sama5/sam_lcd.c b/arch/arm/src/sama5/sam_lcd.c index ed1f33c96a..2033e45861 100644 --- a/arch/arm/src/sama5/sam_lcd.c +++ b/arch/arm/src/sama5/sam_lcd.c @@ -645,9 +645,9 @@ struct sam_lcdc_s struct sam_layer_s layer[LCDC_NLAYERS]; #ifdef CONFIG_FB_HWCURSOR - struct fb_cursorpos_s cpos; /* Current cursor position */ + struct cursor_pos_s cpos; /* Current cursor position */ #ifdef CONFIG_FB_HWCURSORSIZE - struct fb_cursorsize_s csize; /* Current cursor size */ + struct cursor_size_s csize; /* Current cursor size */ #endif #endif diff --git a/arch/sim/src/up_framebuffer.c b/arch/sim/src/up_framebuffer.c index 8178c3994d..4510569258 100644 --- a/arch/sim/src/up_framebuffer.c +++ b/arch/sim/src/up_framebuffer.c @@ -152,12 +152,12 @@ static struct fb_planeinfo_s g_planeinfo; /* Current cursor position */ #ifdef CONFIG_FB_HWCURSOR -static struct fb_cursorpos_s g_cpos; +static struct cursor_pos_s g_cpos; /* Current cursor size */ #ifdef CONFIG_FB_HWCURSORSIZE -static struct fb_cursorsize_s g_csize; +static struct cursor_size_s g_csize; #endif #endif diff --git a/drivers/lcd/Kconfig b/drivers/lcd/Kconfig index bf18d09e74..52dd23352d 100644 --- a/drivers/lcd/Kconfig +++ b/drivers/lcd/Kconfig @@ -19,6 +19,10 @@ menuconfig LCD if LCD +config LCD_HWCURSOR + bool + default n + config LCD_PACKEDMSFIRST bool default n diff --git a/graphics/Kconfig b/graphics/Kconfig index 4b9f572342..c763bb10b2 100644 --- a/graphics/Kconfig +++ b/graphics/Kconfig @@ -68,6 +68,28 @@ config NX_RAMBACKED NOTE: A significant amount of RAM, usually external SDRAM, may be required to use per-window framebuffers. +choice + prompt "Cursor support" + default NX_NOCURSOR + +config NX_NOCURSOR + bool "No cursor support" + +config NX_SWCURSOR + bool "Software cursor support" + depends on NX_RAMBACKED && EXPERIMENTAL + +config NX_HWCURSOR + bool "Software cursor support" + depends on (FB_HWCURSOR || LCD_HWCURSOR) && EXPERIMENTAL + +endchoice # Cursor support + +config NX_HWCURSORIMAGE + bool "Support cursor images" + default n + depends on NX_HWCURSOR + config NX_BGCOLOR hex "Initial background color" default 0x0 diff --git a/graphics/vnc/server/vnc_fbdev.c b/graphics/vnc/server/vnc_fbdev.c index bfba6e0c0d..999b40f0b6 100644 --- a/graphics/vnc/server/vnc_fbdev.c +++ b/graphics/vnc/server/vnc_fbdev.c @@ -132,12 +132,12 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable, /* Current cursor position */ #ifdef CONFIG_FB_HWCURSOR -static struct fb_cursorpos_s g_cpos; +static struct cursor_pos_s g_cpos; /* Current cursor size */ #ifdef CONFIG_FB_HWCURSORSIZE -static struct fb_cursorsize_s g_csize; +static struct cursor_size_s g_csize; #endif #endif diff --git a/include/nuttx/nx/nxcursor.h b/include/nuttx/nx/nxcursor.h new file mode 100644 index 0000000000..638161992e --- /dev/null +++ b/include/nuttx/nx/nxcursor.h @@ -0,0 +1,162 @@ +/**************************************************************************** + * include/nuttx/nx/cursor.h + * + * Copyright (C) 2019 Gregory Nutt. All rights + * reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_NX_NXCURSOR_H +#define __INCLUDE_NUTTX_NX_NXCURSOR_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#ifndef defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxcursor_enable + * + * Description: + * Enable/disable presentation of the cursor + * + * Input Parameters: + * hnd - The server handle returned by nx_connect() + * enable - True: show the cursor, false: hide the cursor. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxcursor_enable(NXHANDLE hnd, bool enable); + +/**************************************************************************** + * Name: nxcursor_set_image + * + * Description: + * Set the cursor image + * + * Input Parameters: + * hnd - The server handle returned by nx_connect() + * image - Describes the cursor image in the expected format. For a + * software cursor, this is the format used with the display. The + * format may be different if a hardware cursor is used. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR) +void nxcursor_set_image(NXHANDLE hnd, FAR struct cursor_image_s *image); +#endif + +/**************************************************************************** + * Name: nxcursor_set_position + * + * Description: + * Move the cursor to the specified position + * + * Input Parameters: + * hnd - The server handle returned by nx_connect() + * pos - + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxcursor_set_position(NXHANDLE hnd, FAR const struct cursor_pos_s *pos); + +/**************************************************************************** + * Name: nxcursor_get_position + * + * Description: + * Return the current cursor position. + * + * CAUTION: The current cursor position is not updated until the display + * is actually changed. Due to asynchronies caused by queue, the new + * current cursor position may not match the cursor position set until + * the client and server are syncrhonized. + * + * Input Parameters: + * hnd - The server handle returned by nx_connect() + * pos - The location to return the cursor position + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxcursor_get_position(NXHANDLE hnd, FAR struct cursor_pos_s *pos); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* CONFIG_NX_SWCURSOR || CONFIG_NX_HWCURSOR */ +#endif /* __INCLUDE_NUTTX_NX_NXCURSOR_H */ + diff --git a/include/nuttx/video/cursor.h b/include/nuttx/video/cursor.h new file mode 100644 index 0000000000..6d2e73fb9c --- /dev/null +++ b/include/nuttx/video/cursor.h @@ -0,0 +1,93 @@ +/**************************************************************************** + * include/nuttx/video/cursor.h + * + * Copyright (C) 2008-2011, 2013, 2016-2019 Gregory Nutt. All rights + * reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_VIDIO_CURSOR_H +#define __INCLUDE_NUTTX_VIDIO_CURSOR_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Pre-processor definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* If any dimension of the display exceeds 65,536 pixels, then the following + * type will need to change. This should match the types of fb_coord_t and + * nxgl_coord_t. + */ + +typedef uint16_t cursor_coord_t; + +/* For cursor controllers that support custem cursor images, this structure + * is used to provide the cursor image. + */ + +struct cursor_image_s +{ + cursor_coord_t width; /* Width of the cursor image in pixels */ + cursor_coord_t height; /* Height of the cursor image in pixels */ + FAR const uint8_t *image; /* Pointer to image data */ +}; + +/* The following structure defines the cursor position */ + +struct cursor_pos_s +{ + cursor_coord_t x; /* X position in pixels */ + cursor_coord_t y; /* Y position in rows */ +}; + +/* If the hardware supports setting the cursor size, then this structure + * is used to provide the cursor size. + */ + +struct cursor_size_s +{ + cursor_coord_t h; /* Height in rows */ + cursor_coord_t w; /* Width in pixels */ +}; + +#endif /* __INCLUDE_NUTTX_VIDIO_CURSOR_H */ diff --git a/include/nuttx/video/fb.h b/include/nuttx/video/fb.h index 89403c7849..9a51c6eb96 100644 --- a/include/nuttx/video/fb.h +++ b/include/nuttx/video/fb.h @@ -45,7 +45,9 @@ #include #include + #include +#include /**************************************************************************** * Pre-processor definitions @@ -409,64 +411,30 @@ struct fb_cmap_s }; #endif -/* If the video controller hardware supports a hardware cursor and - * that hardware cursor supports user-provided images, then the - * following structure may be used to provide the cursor image - */ - #ifdef CONFIG_FB_HWCURSOR -#ifdef CONFIG_FB_HWCURSORIMAGE -struct fb_cursorimage_s -{ - fb_coord_t width; /* Width of the cursor image in pixels */ - fb_coord_t height /* Height of the cursor image in pixels */ - const uint8_t *image; /* Pointer to image data */ -}; -#endif - -/* The following structure defines the cursor position/size */ - -struct fb_cursorpos_s -{ - fb_coord_t x; /* X position in pixels */ - fb_coord_t y; /* Y position in rows */ -}; - -/* If the hardware supports setting the cursor size, then this structure - * is used to provide the size. - */ - -#ifdef CONFIG_FB_HWCURSORSIZE -struct fb_cursorsize_s -{ - fb_coord_t h; /* Height in rows */ - fb_coord_t w; /* Width in pixels */ -}; -#endif - -/* The following is used to get the cursor attributes */ +/* The following are used to get/get the cursor attributes via IOCTL command. */ struct fb_cursorattrib_s { #ifdef CONFIG_FB_HWCURSORIMAGE uint8_t fmt; /* Video format of cursor */ #endif - struct fb_cursorpos_s pos; /* Current cursor position */ + struct cursor_pos_s pos; /* Current cursor position */ #ifdef CONFIG_FB_HWCURSORSIZE - struct fb_cursorsize_s mxsize; /* Maximum cursor size */ - struct fb_cursorsize_s size; /* Current size */ + struct cursor_size_s mxsize; /* Maximum cursor size */ + struct cursor_size_s size; /* Current size */ #endif }; struct fb_setcursor_s { uint8_t flags; /* See FB_CUR_* definitions */ - struct fb_cursorpos_s pos; /* Cursor position */ + struct cursor_pos_s pos; /* Cursor position */ #ifdef CONFIG_FB_HWCURSORSIZE - struct fb_cursorsize_s size; /* Cursor size */ + struct cursor_size_s size; /* Cursor size */ #endif #ifdef CONFIG_FB_HWCURSORIMAGE - struct fb_cursorimage_s img; /* Cursor image */ + struct cursor_image_s img; /* Cursor image */ #endif }; #endif