Mercurial > ecos
changeset 1181:d11b31ef51cc
Add VNC support
| author | gthomas |
|---|---|
| date | Thu, 28 Aug 2003 10:30:33 +0000 |
| parents | f30dbfbd254c |
| children | 8c272f96c3ed |
| files | packages/services/gfx/mw/current/ChangeLog packages/services/gfx/mw/current/cdl/microwindows.cdl packages/services/gfx/mw/current/include/microwin/device.h packages/services/gfx/mw/current/src/drivers/kbd_vnc_ecos.c packages/services/gfx/mw/current/src/drivers/mou_vnc_ecos.c packages/services/gfx/mw/current/src/drivers/scr_vnc_ecos.c packages/services/gfx/mw/current/src/nanox/clientfb.c |
| diffstat | 7 files changed, 943 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/services/gfx/mw/current/ChangeLog +++ b/packages/services/gfx/mw/current/ChangeLog @@ -1,3 +1,21 @@ +2003-08-22 Chris Garry <cgarry@sweeneydesign.co.uk> + + * cdl/microwindows.cdl + Added support for VNC server. + + * src/include/device.h: + Remove COLOR2PIXEL555 hack for strongarm lcd when VNC server screen + driver is used. + + * src/nanox/clientfb.c: + Removed assumption that CYGPKG_HAL_ARM means target is a strongarm + lcd when VNC server is used. + + * src/drivers/kbd_vnc_ecos.c: + * src/drivers/mou_vnc_ecos.c: + * src/drivers/scr_vnc_ecos.c: + New keyboard, mouse and screen drivers for VNC server. + 2003-07-21 Chris Garry <cgarry@sweeneydesign.co.uk> * src/nanox/client.c
--- a/packages/services/gfx/mw/current/cdl/microwindows.cdl +++ b/packages/services/gfx/mw/current/cdl/microwindows.cdl @@ -143,6 +143,27 @@ cdl_package CYGPKG_MICROWINDOWS { compile ecos/ecos_init.c ecos/nanox_thread.c } + # eCos VNC server drivers + cdl_option CYGBLD_MICROWINDOWS_VNC_DRIVERS { + display "Build MicroWindows VNC server drivers" + default_value 0 + description \ + "This option builds the drivers for the VNC server. The VNC server + then provides a virtual screen, keyboard and mouse for MicroWindows." + + compile \ + drivers/scr_vnc_ecos.c \ + drivers/kbd_vnc_ecos.c \ + drivers/mou_vnc_ecos.c + + requires CYGBLD_MICROWINDOWS_ECOS + requires CYGBLD_MICROWINDOWS_NANOWM + requires CYGPKG_VNC_SERVER + requires !CYGBLD_MICROWINDOWS_ARM_DRIVERS + requires CYGPKG_VNC_SERVER_BUILD_MOUSE_DRIVER + requires CYGPKG_VNC_SERVER_BUILD_KEYBOARD_DRIVER + } + # eCos ARM drivers cdl_option CYGBLD_MICROWINDOWS_ARM_DRIVERS { display "Build MicroWindows ARM drivers" @@ -153,6 +174,7 @@ cdl_package CYGPKG_MICROWINDOWS { drivers/kbd_ipaq.c \ drivers/mou_ipaq.c + requires CYGBLD_MICROWINDOWS_ECOS requires CYGBLD_MICROWINDOWS_NANOWM requires CYGBLD_MICROWINDOWS_NXKBD @@ -167,7 +189,7 @@ cdl_package CYGPKG_MICROWINDOWS { cdl_component CYGPKG_MICROWINDOWS_PC { display "Build options for PC hardware" flavor none - active_if CYGPKG_HAL_I386_PCMB + active_if (CYGPKG_HAL_I386_PCMB && !CYGBLD_MICROWINDOWS_VNC_DRIVERS) compile drivers/ps2kbdmou_ecos.c requires CYGBLD_MICROWINDOWS_ECOS
--- a/packages/services/gfx/mw/current/include/microwin/device.h +++ b/packages/services/gfx/mw/current/include/microwin/device.h @@ -8,6 +8,7 @@ * Contents of this file are not for general export */ #include "mwtypes.h" /* public export typedefs*/ +#include <pkgconf/microwindows.h> /* CYGBLD_MICROWINDOWS_VNC_DRIVERS */ /* Changeable limits and options*/ #define ALPHABLEND 1 /* =1 to include blending code*/ @@ -291,10 +292,12 @@ typedef struct { ((((c) & 0xf8) << 8) | (((c) & 0xfc00) >> 5) | (((c) & 0xf80000) >> 19)) /* create 16 bit 5/5/5 format pixel from RGB colorval (0x00BBGGRR)*/ -#if 0 +#ifdef CYGBLD_MICROWINDOWS_VNC_DRIVERS + /* Real RGB555 data is required for VNC drivers */ #define COLOR2PIXEL555(c) \ ((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19)) #else + /* BGR555 data is required strongarm LCD */ #define COLOR2PIXEL555(c) \ ((((c) & 0xf8) >> (3-0)) | (((c) & 0xf800) >> (11-5)) | (((c) & 0xf80000) >> (19-10))) #endif
new file mode 100644 --- /dev/null +++ b/packages/services/gfx/mw/current/src/drivers/kbd_vnc_ecos.c @@ -0,0 +1,363 @@ +//========================================================================== +// +// kbd_vnc_ecos.c +// +// +// +//========================================================================== +//####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with eCos; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or inline functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. However the source code for this file must still be made available +// in accordance with section (3) of the GNU General Public License. +// +// This exception does not invalidate any other reasons why a work based on +// this file might be covered by the GNU General Public License. +// +// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. +// at http://sources.redhat.com/ecos/ecos-license/ +// ------------------------------------------- +//####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Chris Garry <cgarry@sweeneydesign.co.uk> +// Contributors: +// Date: 2003-08-22 +// Purpose: +// Description: Microwindows keyboard driver for VNC server on eCos +// +//####DESCRIPTIONEND#### +// +//========================================================================*/ + +#include <stdio.h> +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <pkgconf/vnc_server.h> /* CYGDAT_VNC_SERVER_KEYBOARD_NAME */ +#include "device.h" + +static int vnc_Open(KBDDEVICE *pkd); +static void vnc_Close(void); +static void vnc_GetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers); +static int vnc_Read(MWKEY *kbuf, MWKEYMOD *modifiers, MWSCANCODE *scancode); + +KBDDEVICE kbddev = { + vnc_Open, + vnc_Close, + vnc_GetModifierInfo, + vnc_Read, + NULL +}; + +static int kbd_fd; /* File descriptor for keyboard */ +static MWKEYMOD current_mods; /* Current keyboard modifiers */ + + +static int vnc_Open(KBDDEVICE *pkd) +{ + /* Open the keyboard and get it ready for use */ + kbd_fd = open(CYGDAT_VNC_SERVER_KEYBOARD_NAME, O_RDONLY | O_NONBLOCK); + + if (kbd_fd < 0) + { + EPRINTF("%s - Can't open keyboard!\n", __FUNCTION__); + return -1; + } + + current_mods = MWKMOD_NONE; /* Initialise the current modifiers */ + + /* Keyboard opened okay - return file descriptor */ + return(kbd_fd); +} + + +static void vnc_Close(void) +{ + /* Close the mouse device. */ + if (kbd_fd >= 0) + { + close(kbd_fd); + } + + kbd_fd = -1; +} + + +static void vnc_GetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers) +{ + if (modifiers) + { + *modifiers = MWKMOD_CTRL | MWKMOD_SHIFT | MWKMOD_ALT | MWKMOD_META + | MWKMOD_CAPS | MWKMOD_NUM | MWKMOD_SCR; + } + + *curmodifiers = current_mods; +} + + +/* + * This reads one keystroke from the keyboard, and the current state of + * the mode keys (ALT, SHIFT, CTRL). Returns -1 on error, 1 if key is + * pressed, and 0 if key was released. This is a non-blocking call. + */ +static int vnc_Read(MWKEY *kbuf, MWKEYMOD *modifiers, MWSCANCODE *scancode) +{ + cyg_uint8 keystroke_buff[4]; /* Smal buffer to hold data for 1 keystroke */ + int bytes_read; + + /* Try to read the data for 1 keystroke event from the keyboard device */ + bytes_read = read(kbd_fd, keystroke_buff, 4); + + /* Each keystroke event generates 4 x cyg_uint8 values in the queue + * 0: Padding - always zero + * 1: Key pressed (1 when key is pressed) + * 2: Keysym value MSB + * 3: Keysym value LSB + */ + + if (bytes_read != 4) + { + return 0; + } + + /* Log modifier bits and convert Keysym values to Unicode */ + switch(keystroke_buff[2]*256 + keystroke_buff[3]) + { + case 0x0000 ... 0x007F: /* Standard ASCII */ + *kbuf = keystroke_buff[3]; + break; + + case 0x0080 ... 0x00FF: /* Not so sure what to do with these - but it works for '£' */ + *kbuf = keystroke_buff[3]; + break; + + case 0xFF08: /* BACKSPACE */ + *kbuf = MWKEY_BACKSPACE; + break; + + case 0xFF09: /* TAB */ + *kbuf = MWKEY_TAB; + break; + + case 0xFF0D: /* ENTER */ + *kbuf = MWKEY_ENTER; + break; + + case 0xFF13: /* BREAK */ + *kbuf = MWKEY_BREAK; + break; + + case 0xFF14: /* Scroll lock */ + if (!keystroke_buff[0]) /* Key released */ + current_mods ^= MWKMOD_SCR; + /* Note we invert the Scroll lock bit on each Scroll lock release event */ + *kbuf = MWKEY_SCROLLOCK; + break; + + case 0xFF1B: /* ESC */ + *kbuf = MWKEY_ESCAPE; + break; + + case 0xFF50: /* HOME */ + *kbuf = MWKEY_HOME; + break; + + case 0xFF51: /* LEFT ARROW */ + *kbuf = MWKEY_LEFT; + break; + + case 0xFF52: /* UP ARROW */ + *kbuf = MWKEY_UP; + break; + + case 0xFF53: /* RIGHT ARROW */ + *kbuf = MWKEY_RIGHT; + break; + + case 0xFF54: /* DOWN ARROW */ + *kbuf = MWKEY_DOWN; + break; + + case 0xFF55: /* PAGE UP */ + *kbuf = MWKEY_PAGEUP; + break; + + case 0xFF56: /* PAGE DOWN */ + *kbuf = MWKEY_PAGEDOWN; + break; + + case 0xFF57: /* END */ + *kbuf = MWKEY_END; + break; + + case 0xFF61: /* PRINT SCREEN */ + *kbuf = MWKEY_PRINT; + break; + + case 0xFF63: /* INSERT */ + *kbuf = MWKEY_INSERT; + break; + + case 0xFF7F: /* NUM lock */ + if (!keystroke_buff[0]) /* Key released */ + current_mods ^= MWKMOD_NUM; + /* Note we invert the NUM lock bit on each NUN lock release event */ + + *kbuf = MWKEY_NUMLOCK; + break; + + case 0xFFAA: /* KEYPAD * */ + *kbuf = MWKEY_KP_MULTIPLY; + break; + + case 0xFFAB: /* KEYPAD + */ + *kbuf = MWKEY_KP_PLUS; + break; + + case 0xFFAD: /* KEYPAD - */ + *kbuf = MWKEY_KP_MINUS; + break; + + case 0xFFAE: /* KEYPAD . */ + *kbuf = MWKEY_KP_PERIOD; + break; + + case 0xFFAF: /* KEYPAD / */ + *kbuf = MWKEY_KP_DIVIDE; + break; + + case 0xFFB0 ... 0xFFB9: /* Numeric keypad 0 to 9 */ + /* We can calculate this since both the Keysym codes and unicodes are consecutive */ + *kbuf = MWKEY_KP0 + (keystroke_buff[2]*256 + keystroke_buff[3]) - 0xFFB0; + break; + + case 0xFFBE ... 0xFFC9: /* F1 to F12 */ + /* We can calculate this since both the Keysym codes and unicodes are consecutive */ + *kbuf = MWKEY_F1 + (keystroke_buff[2]*256 + keystroke_buff[3]) - 0xFFBE; + break; + + case 0xFFE1: /* SHIFT left*/ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_LSHIFT; /* Set SHIFT modifier bit */ + else + current_mods &= (0xFFFF ^ MWKMOD_LSHIFT); /* Clear SHIFT modifier bit */ + + *kbuf = MWKEY_LSHIFT; + break; + + case 0xFFE2: /* SHIFT right */ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_RSHIFT; /* Set SHIFT modifier bit */ + else + current_mods &= (0xFFFF ^ MWKMOD_RSHIFT); /* Clear SHIFT modifier bit */ + + *kbuf = MWKEY_RSHIFT; + break; + + case 0xFFE3: /* CTRL left */ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_LCTRL; /* Set CTRL modifier bit */ + else + { + /* Clear CTRL modifier bit */ + current_mods &= (0xFFFF ^ MWKMOD_LCTRL); + } + + *kbuf = MWKEY_LCTRL; + break; + + case 0xFFE4: /* CTRL right */ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_RCTRL; /* Set CTRL modifier bit */ + else + current_mods &= (0xFFFF ^ MWKMOD_RCTRL); /* Clear CTRL modifier bit */ + + *kbuf = MWKEY_RCTRL; + break; + + case 0xFFE5: /* CAPS lock */ + if (!keystroke_buff[0]) /* Key released */ + current_mods ^= MWKMOD_CAPS; + /* Note we invert the CAPS lock bit on each CAPS lock release event */ + + *kbuf = MWKEY_CAPSLOCK; + break; + + case 0xFFE7: /* META Left */ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_LMETA; /* Set META modifier bit */ + else + current_mods &= (0xFFFF ^ MWKMOD_LMETA); /* Clear META modifier bit */ + + *kbuf = MWKEY_LMETA; + break; + + case 0xFFE8: /* META Right */ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_RMETA; /* Set META modifier bit */ + else + current_mods &= (0xFFFF ^ MWKMOD_RMETA); /* Clear META modifier bit */ + + *kbuf = MWKEY_RMETA; + break; + + case 0xFFE9: /* ALT left */ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_LALT; /* Set ALT modifier bit */ + else + current_mods &= (0xFFFF ^ MWKMOD_LALT); /* Clear ALT modifier bit */ + + *kbuf = MWKEY_LALT; + break; + + case 0xFFEA: /* ALT right */ + if (keystroke_buff[1]) /* Key pressed */ + current_mods |= MWKMOD_RALT; /* Set ALT modifier bit */ + else + current_mods &= (0xFFFF ^ MWKMOD_RALT); /* Clear ALT modifier bit */ + + *kbuf = MWKEY_RALT; + break; + + case 0xFFFF: /* DELETE */ + *kbuf = MWKEY_DELETE; + break; + + default: + *kbuf = MWKEY_UNKNOWN; + } + + *modifiers = current_mods; + *scancode = 0; /* Scan code not supported because this is just a virtual device */ + + if (keystroke_buff[1]) + { + return 1; + } + else + { + return 0; + } +}
new file mode 100644 --- /dev/null +++ b/packages/services/gfx/mw/current/src/drivers/mou_vnc_ecos.c @@ -0,0 +1,179 @@ +//========================================================================== +// +// mou_vnc_ecos.c +// +// +// +//========================================================================== +//####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with eCos; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or inline functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. However the source code for this file must still be made available +// in accordance with section (3) of the GNU General Public License. +// +// This exception does not invalidate any other reasons why a work based on +// this file might be covered by the GNU General Public License. +// +// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. +// at http://sources.redhat.com/ecos/ecos-license/ +// ------------------------------------------- +//####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Chris Garry <cgarry@sweeneydesign.co.uk> +// Contributors: +// Date: 2003-08-22 +// Purpose: +// Description: Microwindows mouse driver for VNC server on eCos +// +//####DESCRIPTIONEND#### +// +//========================================================================*/ + + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <fcntl.h> +#include <math.h> +#include <sys/ioctl.h> +#include <pkgconf/vnc_server.h> /* CYGDAT_VNC_SERVER_MOUSE_NAME */ +#include "device.h" + +static int vnc_Open(MOUSEDEVICE *pmd); +static void vnc_Close(void); +static int vnc_GetButtonInfo(void); +static void vnc_GetDefaultAccel(int *pscale,int *pthresh); +static int vnc_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb); + +static int mouse_fd = -1; + +/* Hack extern to used when hiding the mouse cursor + * There needs to be a better way to do this +*/ +extern SCREENDEVICE scrdev; + +MOUSEDEVICE mousedev = { + vnc_Open, + vnc_Close, + vnc_GetButtonInfo, + vnc_GetDefaultAccel, + vnc_Read, + NULL +}; + + +static int vnc_Open(MOUSEDEVICE *pmd) +{ + mouse_fd = open(CYGDAT_VNC_SERVER_MOUSE_NAME, O_RDONLY | O_NONBLOCK); + if (mouse_fd < 0) + { + EPRINTF("Error %d opening VNC mouse\n", errno); + return -1; + } + +// GdHideCursor(&scrdev); + return mouse_fd; +} + +static void vnc_Close(void) +{ + /* Close the mouse device. */ + if (mouse_fd >= 0) + { + close(mouse_fd); + } + + mouse_fd = -1; +} + +static int vnc_GetButtonInfo(void) +{ + /* Get mouse buttons supported */ + return (MWBUTTON_L + MWBUTTON_R); +} + +static void vnc_GetDefaultAccel(int *pscale,int *pthresh) +{ + /* + * Get default mouse acceleration settings + * Just return something inconspicuous for now. + */ +// diag_printf("Mouse: vnc_GetDefaultAccel()\n"); + *pscale = 3; + *pthresh = 5; +} + +static int vnc_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb) +{ + /* Read a mouse event */ + cyg_uint8 data[8]; + int bytes_read; + + bytes_read = read(mouse_fd, data, 8); + + if (bytes_read != sizeof(data)) + { + if (errno == EINTR || errno == EAGAIN) + { + return 0; + } + /* + * kernel driver bug: select returns read available, + * but read returns -1 + * we return 0 here to avoid GsError above + */ + /*return -1;*/ + + return 0; + } + + *px = data[2]*256 + data[3]; + *py = data[4]*256 + data[5]; + *pb = 0; + if (data[1] & 0x01) + { + *pb += MWBUTTON_L; + } + if (data[1] & 0x04) + { + *pb += MWBUTTON_R; + } + + *pz = 0; + + return 2; + +#if 0 + if(! *pb ) + { + return 1; /* Don't have button data */ + } + else + { + return 2; /* Have full set of data */ + } +#endif + +}
new file mode 100644 --- /dev/null +++ b/packages/services/gfx/mw/current/src/drivers/scr_vnc_ecos.c @@ -0,0 +1,351 @@ +//========================================================================== +// +// scr_vnc_ecos.c +// +// +// +//========================================================================== +//####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with eCos; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or inline functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. However the source code for this file must still be made available +// in accordance with section (3) of the GNU General Public License. +// +// This exception does not invalidate any other reasons why a work based on +// this file might be covered by the GNU General Public License. +// +// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. +// at http://sources.redhat.com/ecos/ecos-license/ +// ------------------------------------------- +//####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Chris Garry <cgarry@sweeneydesign.co.uk> +// Contributors: +// Date: 2003-08-22 +// Purpose: +// Description: Microwindows screen driver for VNC server on eCos +// +//####DESCRIPTIONEND#### +// +//========================================================================*/ + + + +#define _GNU_SOURCE 1 + +#include <pkgconf/system.h> + +#include <assert.h> +#include <fcntl.h> +#include <limits.h> +#include <cyg/hal/drv_api.h> +#include <cyg/infra/diag.h> +#include <cyg/io/io.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> +#include "device.h" +#include "genfont.h" +#include "genmem.h" +#include <vnc-server.h> + +/* In genmem.c*/ +MWBOOL set_subdriver(PSD psd, PSUBDRIVER subdriver, MWBOOL init); + +/* Prototypes for driver functions */ +static int vnc_init(PSD psd); +static PSD vnc_open(PSD psd); +static void vnc_close(PSD psd); +static void vnc_getscreeninfo(PSD psd,PMWSCREENINFO psi); +static void vnc_drawpixel(PSD psd,MWCOORD x, MWCOORD y, MWPIXELVAL c); +static MWPIXELVAL vnc_readpixel(PSD psd,MWCOORD x, MWCOORD y); +static void vnc_drawhorizline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c); +static void vnc_drawvertline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c); +static void vnc_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, MWPIXELVAL c); +static void vnc_blit(PSD , MWCOORD, MWCOORD, MWCOORD, MWCOORD, PSD, MWCOORD, MWCOORD, long); +static void vnc_stretchblit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw, + MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, + MWCOORD srcw, MWCOORD srch, long op); +static void vnc_drawarea(PSD psd, driver_gc_t *gc, int op); +MWBOOL vnc_mapmemgc(PSD, MWCOORD, MWCOORD, int, int, int, int, void *); + + + +SCREENDEVICE scrdev = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, + vnc_open, + vnc_close, + vnc_getscreeninfo, + NULL, + vnc_drawpixel, /* DrawPixel subdriver*/ + vnc_readpixel, /* ReadPixel subdriver*/ + vnc_drawhorizline, /* DrawHorzLine subdriver*/ + vnc_drawvertline, /* DrawVertLine subdriver*/ + vnc_fillrect, /* FillRect subdriver*/ + gen_fonts, + vnc_blit, /* Blit subdriver*/ + NULL, /* PreSelect*/ + NULL, /* DrawArea subdriver*/ + NULL, /* SetIOPermissions*/ + gen_allocatememgc, + vnc_mapmemgc, + gen_freememgc, + vnc_stretchblit, /* StretchBlit subdriver*/ + NULL /* SetPortrait*/ +}; + +SUBDRIVER vnc_subdriver = { + vnc_init, + vnc_drawpixel, + vnc_readpixel, + vnc_drawhorizline, + vnc_drawvertline, + vnc_fillrect, + vnc_blit, + vnc_drawarea, + vnc_stretchblit +}; + +/* Static variables*/ +static int status; /* 0=never inited, 1=once inited, 2=inited. */ +static vnc_frame_format_t *frame_format; + +/* Calc linelen and mmap size, return 0 on fail*/ +static int vnc_init(PSD psd) +{ + if (!psd->size) + { + psd->size = psd->yres * psd->xres * psd->bpp / 8; + /* convert linelen from byte to pixel len for bpp 16, 24, 32*/ + psd->linelen = psd->xres; + } + + return 1; +} + +/* Initialise the VNC framebuffer */ +static PSD vnc_open(PSD psd) +{ + /* Get frame format details */ + frame_format = VncGetInfo(); + + psd->xres = psd->xvirtres = frame_format->frame_width; + psd->yres = psd->yvirtres = frame_format->frame_height; + psd->portrait = MWPORTRAIT_NONE; + psd->planes = 1; /* Should probably find out what this means */ + + if (frame_format->rgb332) + { + psd->bpp = 8; + psd->ncolors = 0xFF + 1; + psd->pixtype = MWPF_TRUECOLOR332; + } + else if (frame_format->rgb555) + { + psd->bpp = 16; + psd->ncolors = 0x7FFF + 1; + psd->pixtype = MWPF_TRUECOLOR555; + } + else if (frame_format->rgb565) + { + psd->bpp = 16; + psd->ncolors = 0xFFFF + 1; + psd->pixtype = MWPF_TRUECOLOR565; + } + else + { + EPRINTF("Unsupported display type\n"); + goto fail; + } + + psd->linelen = frame_format->frame_width * psd->bpp / 8;; /* What is linelen? - linelen in bytes for now...*/ + psd->size = psd->xres * psd->yres * psd->bpp / 8; + psd->flags = PSF_SCREEN | PSF_HAVEBLIT; + psd->addr = frame_format->frame_buffer; /* Test */ +// psd->addr = NULL; /* We do not want MW to access the frame buffer directly */ + + /* Initialise the frame buffer (white) */ + VncInit(VNC_WHITE); + + /* We always use our own subdriver */ + psd->orgsubdriver = &vnc_subdriver; + + + status = 2; + return psd; /* success*/ + + fail: + return NULL; +} + + +/* Close framebuffer*/ +static void vnc_close(PSD psd) +{ + printf("%s - NOT IMPLEMENTED\n", __FUNCTION__); +} + + +static void vnc_getscreeninfo(PSD psd,PMWSCREENINFO psi) +{ + psi->rows = psd->yvirtres; + psi->cols = psd->xvirtres; + psi->planes = psd->planes; + psi->bpp = psd->bpp; + psi->ncolors = psd->ncolors; + psi->pixtype = psd->pixtype; + psi->fonts = NUMBER_FONTS; + psi->portrait = psd->portrait; + psi->fbdriver = true; + + switch (psd->pixtype) { + case MWPF_TRUECOLOR332: + psi->rmask = 0xE0; + psi->gmask = 0x1C; + psi->bmask = 0x03; + break; + case MWPF_TRUECOLOR555: + psi->rmask = 0x7c00; + psi->gmask = 0x03e0; + psi->bmask = 0x001f; + break; + case MWPF_TRUECOLOR565: + psi->rmask = 0xf800; + psi->gmask = 0x07e0; + psi->bmask = 0x001f; + break; + default: + printf("%s - unsupported pixtype\n", __FUNCTION__); + psi->rmask = 0xff; + psi->gmask = 0xff; + psi->bmask = 0xff; + break; + } + + /* Need to figure out better values possibly */ + psi->xdpcm = 27; /* assumes screen width of 24 cm */ + psi->ydpcm = 27; /* assumes screen height of 18 cm */ +} + + +static void vnc_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c) +{ + VncDrawPixel(x, y, (vnc_colour_t)c); +} + + +static MWPIXELVAL vnc_readpixel(PSD psd, MWCOORD x, MWCOORD y) +{ + return VncReadPixel(x, y); +} + + +static void vnc_drawhorizline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c) +{ + VncDrawHorzLine(x1, x2, y, (vnc_colour_t)c); +} + + +static void vnc_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c) +{ + VncDrawVertLine(x, y1, y2, (vnc_colour_t)c); +} + + +static void vnc_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, MWPIXELVAL c) +{ + VncFillRect(x1, y1, x2, y2, (vnc_colour_t)c); +} + + +static void vnc_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h, + PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op) +{ + if (op != 0) + { + diag_printf("vnc_blit(): op = 0x%x not supported\n", op); + } + + if (srcpsd->addr == frame_format->frame_buffer && dstpsd->addr != frame_format->frame_buffer) + { + /* Copying rectangle from VNC frame buffer to supplied buffer */ + VncCopyRect2Buffer(srcx, srcy, w, h, dstpsd->addr, dstpsd->xres, dstpsd->yres, dstx, dsty); + } + else if (srcpsd->addr != frame_format->frame_buffer && dstpsd->addr == frame_format->frame_buffer) + { + /* Copying rectangle from a supplied buffer to the VNC frame buffer */ + VncCopyBuffer2Rect(srcpsd->addr, srcpsd->xres, srcpsd->yres, srcx, srcy, dstx, dsty, w, h); + } + else if (srcpsd->addr == frame_format->frame_buffer && dstpsd->addr == frame_format->frame_buffer) + { + /* Copying rectangle from VNC frame buffer to VNC frame buffer */ + VncCopyRect(srcx, srcy, w, h, dstx, dsty); + } + else + { + diag_printf("vnc_blit(): Error unsupported operation\n"); + } +} + +static void vnc_stretchblit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw, + MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, + MWCOORD srcw, MWCOORD srch, long op) +{ + diag_printf("vnc_stretch_blit() not implemented\n"); +} + +static void vnc_drawarea(PSD psd, driver_gc_t *gc, int op) +{ + diag_printf("vnc_drawarea() not implemented\n"); +} + + +/* + * Initialize memory device with passed parms, + * select suitable framebuffer subdriver, + * and set subdriver in memory device. + */ +MWBOOL vnc_mapmemgc(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,int linelen, + int size,void *addr) +{ + PSUBDRIVER subdriver; + + /* initialize mem screen driver*/ + initmemgc(mempsd, w, h, planes, bpp, linelen, size, addr); + + subdriver = &vnc_subdriver; + + /* set and initialize subdriver into mem screen driver*/ + if(!set_subdriver(mempsd, subdriver, TRUE)) + { + diag_printf("set_subdriver() failed\n"); + return 0; + } + + return 1; +}
--- a/packages/services/gfx/mw/current/src/nanox/clientfb.c +++ b/packages/services/gfx/mw/current/src/nanox/clientfb.c @@ -9,9 +9,12 @@ #include <fcntl.h> #ifdef __ECOS # include <pkgconf/system.h> +#include <pkgconf/microwindows.h> /* CYGBLD_MICROWINDOWS_VNC_DRIVERS */ +# ifndef CYGBLD_MICROWINDOWS_VNC_DRIVERS # ifdef CYGPKG_HAL_ARM # include <cyg/hal/lcd_support.h> # endif +# endif #else #include <sys/ioctl.h> #include <sys/mman.h> @@ -55,6 +58,7 @@ GrOpenClientFramebuffer(void) return NULL; #ifdef __ECOS +# ifndef CYGBLD_MICROWINDOWS_VNC_DRIVERS # ifdef CYGPKG_HAL_ARM { struct lcd_info li; @@ -69,6 +73,7 @@ GrOpenClientFramebuffer(void) return physpixels; } # endif +# endif #else /* * Try to open the framebuffer directly.
