diff --git a/documents/firmwares/root/bin/sdl_test.elf b/documents/firmwares/root/bin/sdl_test.elf new file mode 100644 index 0000000000000000000000000000000000000000..3fa06e6796bc803fb5a081d5af8bcfe6ce82b12c Binary files /dev/null and b/documents/firmwares/root/bin/sdl_test.elf differ diff --git a/documents/firmwares/root/bin/test.bmp b/documents/firmwares/root/bin/test.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a9a7eeaadb809869cc72c32d96f5f514604872cb Binary files /dev/null and b/documents/firmwares/root/bin/test.bmp differ diff --git a/userapps/gnu-apps/build.sh b/userapps/gnu-apps/build.sh index 19f022fcba1d9334e06ce02c2a5701559efe6cea..4c264e7447663759e55a96df6a83e78378146f71 100755 --- a/userapps/gnu-apps/build.sh +++ b/userapps/gnu-apps/build.sh @@ -1,7 +1,7 @@ #!/bin/bash -libs_arr=( "lua" "zlib" ) -apps_arr=("uhttpd" "sqlite" ) +libs_arr=( "lua" "zlib" "sdl") +apps_arr=("uhttpd" "sqlite") function usage(){ diff --git a/userapps/gnu-apps/conf.sh b/userapps/gnu-apps/conf.sh old mode 100644 new mode 100755 diff --git a/userapps/gnu-apps/sdl/3-porting-on-rtt.diff b/userapps/gnu-apps/sdl/3-porting-on-rtt.diff new file mode 100644 index 0000000000000000000000000000000000000000..ddf7f894167c6953e8976bda8de739d7edc8f6da --- /dev/null +++ b/userapps/gnu-apps/sdl/3-porting-on-rtt.diff @@ -0,0 +1,647 @@ +diff --git a/SDL2-2.0.14/configure.ac b/SDL2-2.0.14/configure.ac +index b7e519b..d07ae83 100755 +--- a/SDL2-2.0.14/configure.ac ++++ b/SDL2-2.0.14/configure.ac +@@ -2281,6 +2281,18 @@ AS_HELP_STRING([--enable-kmsdrm-shared], [dynamically load kmsdrm support [[defa + fi + } + ++CheckRttVideo() ++{ ++ AC_ARG_ENABLE(video-rtt, ++AS_HELP_STRING([--enable-video-rtt], [use rt-smart video driver [[default=yes]]]), ++ , enable_video_rtt=yes) ++ if test x$enable_video_rtt = xyes; then ++ AC_DEFINE(SDL_VIDEO_DRIVER_RTT, 1, [ ]) ++ SOURCES="$SOURCES $srcdir/src/video/rtt/*.c" ++ have_video=yes ++ fi ++} ++ + dnl rcg04172001 Set up the Null video driver. + CheckDummyVideo() + { +@@ -3536,6 +3548,7 @@ case "$host" in + CheckVisibilityHidden + CheckDeclarationAfterStatement + CheckDummyVideo ++ CheckRttVideo + CheckDiskAudio + CheckDummyAudio + CheckDLOPEN +diff --git a/SDL2-2.0.14/include/SDL_config.h.in b/SDL2-2.0.14/include/SDL_config.h.in +index 3a2a714..66da63e 100755 +--- a/SDL2-2.0.14/include/SDL_config.h.in ++++ b/SDL2-2.0.14/include/SDL_config.h.in +@@ -344,6 +344,7 @@ + #undef SDL_VIDEO_DRIVER_DIRECTFB + #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC + #undef SDL_VIDEO_DRIVER_DUMMY ++#undef SDL_VIDEO_DRIVER_RTT + #undef SDL_VIDEO_DRIVER_WINDOWS + #undef SDL_VIDEO_DRIVER_WAYLAND + #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH +diff --git a/SDL2-2.0.14/src/core/linux/SDL_evdev_capabilities.h b/SDL2-2.0.14/src/core/linux/SDL_evdev_capabilities.h +index e9c66c0..a0021cc 100755 +--- a/SDL2-2.0.14/src/core/linux/SDL_evdev_capabilities.h ++++ b/SDL2-2.0.14/src/core/linux/SDL_evdev_capabilities.h +@@ -25,7 +25,7 @@ + #ifndef SDL_evdev_capabilities_h_ + #define SDL_evdev_capabilities_h_ + +-#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) ++#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) || defined(SDL_HAPTIC_LINUX) + + #include + +diff --git a/SDL2-2.0.14/src/video/SDL_sysvideo.h b/SDL2-2.0.14/src/video/SDL_sysvideo.h +index c8c425b..38d3979 100755 +--- a/SDL2-2.0.14/src/video/SDL_sysvideo.h ++++ b/SDL2-2.0.14/src/video/SDL_sysvideo.h +@@ -439,6 +439,7 @@ extern VideoBootStrap QNX_bootstrap; + extern VideoBootStrap OFFSCREEN_bootstrap; + extern VideoBootStrap OS2DIVE_bootstrap; + extern VideoBootStrap OS2VMAN_bootstrap; ++extern VideoBootStrap RTT_bootstrap; + + extern SDL_VideoDevice *SDL_GetVideoDevice(void); + extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); +diff --git a/SDL2-2.0.14/src/video/SDL_video.c b/SDL2-2.0.14/src/video/SDL_video.c +index a0ca322..b999023 100755 +--- a/SDL2-2.0.14/src/video/SDL_video.c ++++ b/SDL2-2.0.14/src/video/SDL_video.c +@@ -119,6 +119,9 @@ static VideoBootStrap *bootstrap[] = { + #endif + #if SDL_VIDEO_DRIVER_DUMMY + &DUMMY_bootstrap, ++#endif ++#if SDL_VIDEO_DRIVER_RTT ++ &RTT_bootstrap, + #endif + NULL + }; +@@ -462,6 +465,7 @@ SDL_GetVideoDriver(int index) + return NULL; + } + ++ + /* + * Initialize the video and event subsystems -- determine native pixel format + */ +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.c b/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.c +new file mode 100755 +index 0000000..55c2c8c +--- /dev/null ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.c +@@ -0,0 +1,84 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++ ++#include "../SDL_sysvideo.h" ++#include "SDL_rttframebuffer.h" ++#include "SDL_rttvideo.h" ++ ++#define RTT_SURFACE "_SDL_RttSurface" ++ ++int SDL_RTT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) ++{ ++ SDL_Surface *surface; ++ const Uint32 surface_format = LCD_COLOR_SPACE; ++ int w, h; ++ int bpp; ++ Uint32 Rmask, Gmask, Bmask, Amask; ++ ++ /* Free the old framebuffer surface */ ++ surface = (SDL_Surface *) SDL_GetWindowData(window, RTT_SURFACE); ++ SDL_FreeSurface(surface); ++ ++ /* Create a new one */ ++ SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); ++ SDL_GetWindowSize(window, &w, &h); ++ surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); ++ if (!surface) { ++ return -1; ++ } ++ ++ /* Save the info and return! */ ++ SDL_SetWindowData(window, RTT_SURFACE, surface); ++ *format = surface_format; ++ *pixels = surface->pixels; ++ *pitch = surface->pitch; ++ return 0; ++} ++ ++ ++int SDL_RTT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) ++{ ++ static int frame_number; ++ SDL_Surface *surface; ++ ++ surface = (SDL_Surface *) SDL_GetWindowData(window, RTT_SURFACE); ++ if (!surface) { ++ return SDL_SetError("Couldn't find rtt surface for window"); ++ } ++ ++ /* Send the data to the display */ ++ if (SDL_getenv("SDL_VIDEO_RTT_SAVE_FRAMES")) { ++ char file[128]; ++ SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", ++ SDL_GetWindowID(window), ++frame_number); ++ SDL_SaveBMP(surface, file); ++ } ++ ++ RTT_surface2lcd(surface); ++ ++ return 0; ++} ++ ++void SDL_RTT_DestroyWindowFramebuffer(_THIS, SDL_Window * window) ++{ ++ SDL_Surface *surface; ++ ++ surface = (SDL_Surface *) SDL_SetWindowData(window, RTT_SURFACE, NULL); ++ SDL_FreeSurface(surface); ++} ++ ++#endif /* SDL_VIDEO_DRIVER_RTT */ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.h b/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.h +new file mode 100755 +index 0000000..bdaa4de +--- /dev/null ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.h +@@ -0,0 +1,18 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#ifndef SDL_RTTFRAMEBUFFER_H_ ++#define SDL_RTTFRAMEBUFFER_H_ ++ ++int SDL_RTT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); ++int SDL_RTT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); ++void SDL_RTT_DestroyWindowFramebuffer(_THIS, SDL_Window * window); ++ ++#endif +\ No newline at end of file +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c +new file mode 100755 +index 0000000..468206e +--- /dev/null ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c +@@ -0,0 +1,63 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#include "rtdef.h" ++#include "rt_lcd.h" ++#include "SDL_surface.h" ++#include "SDL_pixels.h" ++#include "SDL_rttlcd.h" ++ ++ ++#define LCD_BUF_SIZE (LCD_WIDTH * LCD_HEIGHT) ++ ++rt_uint16_t pixel_ptr[LCD_BUF_SIZE]; ++rt_device_t lcd = NULL; ++struct fb_fix_screeninfo f_info; ++struct fb_var_screeninfo v_info; ++ ++int RTT_surface2lcd(SDL_Surface *surface) ++{ ++ int index = 0; ++ int i; ++ if (lcd) ++ { ++ memcpy((void *)f_info.smem_start, (rt_uint16_t *)(surface->pixels), LCD_BUF_SIZE*2); ++ rt_thread_mdelay(100); ++ rt_device_control(lcd, RTGRAPHIC_CTRL_RECT_UPDATE, NULL); ++ } ++ ++ return 0; ++} ++ ++int RTT_lcdInit() ++{ ++ rt_err_t ret = -1; ++ lcd = rt_device_find("lcd"); ++ if(!lcd) return 1; ++ ret = rt_device_open(lcd, RT_DEVICE_OFLAG_RDWR); ++ if(-1 ==ret) return 1; ++ rt_device_control(lcd, FBIOGET_FSCREENINFO, &f_info); ++ printf("screen: %s - 0x%08x, size %d\n", f_info.id, (unsigned int)f_info.smem_start, f_info.smem_len); ++ ++ rt_device_control(lcd, FBIOGET_VSCREENINFO, &v_info); ++ printf("screen: bpp %d, width - %d, height - %d\n", v_info.bits_per_pixel, v_info.xres, v_info.yres); ++ return ret; ++} ++ ++int RTT_lcdQuit() ++{ ++ rt_err_t ret = -1; ++ if(lcd) ++ { ++ ret = rt_device_close(lcd); ++ lcd = NULL; ++ } ++ return ret; ++} +\ No newline at end of file +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h +new file mode 100755 +index 0000000..f3206d5 +--- /dev/null ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h +@@ -0,0 +1,24 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#ifndef SDL_RTTLCD_H_ ++#define SDL_RTTLCD_H_ ++ ++#define LCD_COLOR_SPACE SDL_PIXELFORMAT_RGB565 ++#define LCD_WIDTH 640 ++#define LCD_HEIGHT 480 ++ ++#define RTGRAPHIC_CTRL_RECT_UPDATE 0 ++ ++int RTT_surface2lcd(SDL_Surface *surface); ++int RTT_lcdInit(); ++int RTT_lcdQuit(); ++ ++#endif +\ No newline at end of file +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c +new file mode 100755 +index 0000000..c967d22 +--- /dev/null ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c +@@ -0,0 +1,155 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#if SDL_VIDEO_DRIVER_RTT ++ ++ ++/* ++* Poting SDL to rt-smart platform baseed on Dummy SDL video driver ; ++*/ ++ ++#include "SDL_video.h" ++#include "SDL_mouse.h" ++#include "../SDL_sysvideo.h" ++#include "../SDL_pixels_c.h" ++#include "../../events/SDL_events_c.h" ++#include "SDL_rttframebuffer.h" ++#include "SDL_rttvideo.h" ++ ++#define RTT_DRIVER_NAME "rtt" ++ ++static int RTT_VideoInit(_THIS); ++static int RTT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); ++static void RTT_VideoQuit(_THIS); ++ ++static int ++RTT_Available(void) ++{ ++ const char *envr = SDL_getenv("SDL_VIDEODRIVER"); ++ printf("envr: %s",envr); ++ if ((envr) && (SDL_strcmp(envr, RTT_DRIVER_NAME) == 0)) { ++ return (1); ++ } ++ ++ return (0); ++} ++ ++static void ++RTT_DeleteDevice(SDL_VideoDevice * device) ++{ ++ SDL_free(device); ++} ++ ++SDL_Window * Rtt_Window = NULL; ++ ++int RTT_CreateWindow(_THIS, SDL_Window * window) ++{ ++ if(Rtt_Window){ ++ SDL_SetError(" only supports one window"); ++ goto error; ++ } ++ ++ Rtt_Window = window; ++ window->x = 0; ++ window->y = 0; ++ window->w = WINDOW_WIDTH_MAX; ++ window->h = WINDOW_HEIGHT_MAX; ++ ++ window->flags &= ~SDL_WINDOW_HIDDEN; ++ window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */ ++ ++ return 0; ++ error: ++ return 1; ++} ++ ++void RTT_SetWindowTitle(_THIS, SDL_Window * window){ ++ //todo ++} ++ ++static SDL_VideoDevice * ++RTT_CreateDevice(int devindex) ++{ ++ SDL_VideoDevice *device; ++ ++ if (!RTT_Available()) { ++ return (0); ++ } ++ ++ /* Initialize all variables that we clean on shutdown */ ++ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); ++ if (!device) { ++ SDL_OutOfMemory(); ++ return (0); ++ } ++ device->is_dummy = SDL_TRUE; ++ ++ /* Set the function pointers */ ++ device->VideoInit = RTT_VideoInit; ++ device->VideoQuit = RTT_VideoQuit; ++ device->SetDisplayMode = RTT_SetDisplayMode; ++ device->CreateWindowFramebuffer = SDL_RTT_CreateWindowFramebuffer; ++ device->UpdateWindowFramebuffer = SDL_RTT_UpdateWindowFramebuffer; ++ device->DestroyWindowFramebuffer = SDL_RTT_DestroyWindowFramebuffer; ++ device->CreateSDLWindow = RTT_CreateWindow; ++ device->SetWindowTitle = RTT_SetWindowTitle; ++ ++ device->free = RTT_DeleteDevice; ++ return device; ++} ++ ++VideoBootStrap RTT_bootstrap = { ++ RTT_DRIVER_NAME, "rt-smart video driver", ++ RTT_CreateDevice ++}; ++ ++ ++int ++RTT_VideoInit(_THIS) ++{ ++ SDL_DisplayMode mode; ++ ++ /* Use a fake 32-bpp desktop mode */ ++ mode.format = LCD_COLOR_SPACE; ++ mode.w = LCD_WIDTH; ++ mode.h = LCD_HEIGHT; ++ mode.refresh_rate = 0; ++ mode.driverdata = NULL; ++ if (SDL_AddBasicVideoDisplay(&mode) < 0) { ++ return -1; ++ } ++ ++ SDL_zero(mode); ++ SDL_AddDisplayMode(&_this->displays[0], &mode); ++ ++ if(RTT_lcdInit() != 0) ++ { ++ return -1; ++ } ++ /* We're done! */ ++ return 0; ++} ++ ++static int ++RTT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) ++{ ++ return 0; ++} ++ ++void ++RTT_VideoQuit(_THIS) ++{ ++ RTT_lcdQuit(); ++} ++ ++ ++#endif /* SDL_VIDEO_DRIVER_RTT */ +\ No newline at end of file +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.h b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.h +new file mode 100755 +index 0000000..975d410 +--- /dev/null ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.h +@@ -0,0 +1,22 @@ ++/* ++ * Copyright (c) 2006-2021, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2021-1-14 eason The first version ++ */ ++ ++#include "../../SDL_internal.h" ++ ++#ifndef SDL_nullvideo_h_ ++#define SDL_nullvideo_h_ ++ ++#include "../SDL_sysvideo.h" ++#include "SDL_rttlcd.h" ++ ++#define WINDOW_WIDTH_MAX LCD_WIDTH ++#define WINDOW_HEIGHT_MAX LCD_HEIGHT ++ ++#endif /* SDL_nullvideo_h_ */ +\ No newline at end of file +diff --git a/SDL2-2.0.14/test/Makefile.in b/SDL2-2.0.14/test/Makefile.in +index 8c3bbf2..f3c65cb 100755 +--- a/SDL2-2.0.14/test/Makefile.in ++++ b/SDL2-2.0.14/test/Makefile.in +@@ -68,6 +68,7 @@ TARGETS = \ + testwm2$(EXE) \ + testyuv$(EXE) \ + torturethread$(EXE) \ ++ testrtt$(EXE) \ + + + @OPENGL_TARGETS@ += testgl2$(EXE) testshader$(EXE) +@@ -315,6 +316,8 @@ testvulkan$(EXE): $(srcdir)/testvulkan.c + testlocale$(EXE): $(srcdir)/testlocale.c + $(CC) -o $@ $? $(CFLAGS) $(LIBS) + ++testrtt$(EXE): $(srcdir)/testrtt.c ++ $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + + + clean: +diff --git a/SDL2-2.0.14/test/testrtt.c b/SDL2-2.0.14/test/testrtt.c +new file mode 100755 +index 0000000..a1df434 +--- /dev/null ++++ b/SDL2-2.0.14/test/testrtt.c +@@ -0,0 +1,123 @@ ++/* ++ * Copyright (c) 2006-2020, RT-Thread Development Team ++ * ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Change Logs: ++ * Date Author Notes ++ * 2020-1-6 eason The first version ++*/ ++#include ++#include ++ ++#define POINTS_COUNT 4 ++ ++const int SCREEN_WIDTH = 640; ++const int SCREEN_HEIGHT = 480; ++ ++static SDL_Point points[POINTS_COUNT] = { ++ {320, 200}, ++ {300, 240}, ++ {340, 240}, ++ {320, 200} ++}; ++ ++SDL_Rect rect = {0, 0, 320, 240}; ++ ++void usage(char * proc_name) ++{ ++ printf("\nUsage: %s option\n", proc_name); ++ printf( "\toption:\n" ++ "\t-l draw line\n" ++ "\t-r draw a rectangle\n" ++ "\t-t draw a rectangle with texture\n"); ++} ++ ++ ++int main( int argc, char* argv[] ) ++{ ++ //The window we'll be rendering to ++ SDL_Window* window = NULL; ++ ++ //The surface contained by the window ++ SDL_Surface* screenSurface = NULL; ++ SDL_Renderer *renderer; ++ SDL_Texture *texture; ++ ++ if( argc != 2 ) ++ { ++ usage(argv[0]); ++ return(1); ++ } ++ //use dummy video driver ++ SDL_setenv("SDL_VIDEODRIVER","rtt",1); ++ //Initialize SDL ++ if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) ++ { ++ printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); ++ return -1; ++ } ++ ++ ++ window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); ++ if( window == NULL ) ++ { ++ printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() ); ++ return -1; ++ } ++ ++ renderer = SDL_CreateRenderer(window, -1, 0); ++ ++ if(0 == strcmp("-l",argv[1])) ++ { ++ SDL_SetRenderDrawColor(renderer, 255, 0, 0, SDL_ALPHA_OPAQUE); ++ SDL_RenderDrawLine(renderer, 0, 0,320, 200); ++ ++ //SDL_RenderDrawLine(renderer, 320, 0, 320, 480); ++ SDL_RenderDrawLines(renderer, points, POINTS_COUNT); ++ } ++ else if(0 == strcmp("-r",argv[1])) ++ { ++ SDL_SetRenderDrawColor(renderer, 255, 0,0, 255); ++ SDL_Rect rect = {0, 0, 320, 240}; ++ SDL_RenderDrawRect(renderer, &rect); ++ // SDL_RenderFillRect(renderer, &rect); ++ } ++ else if(0 == strcmp("-t",argv[1])) ++ { ++ texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565,\ ++ SDL_TEXTUREACCESS_TARGET, 640, 480); ++ rect.w = 320;//rand()%500; ++ rect.h = 240;//rand()%500; ++ SDL_SetRenderTarget(renderer,texture); ++ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); ++ SDL_RenderClear(renderer); ++ SDL_RenderDrawRect(renderer, &rect); ++ ++ SDL_SetRenderDrawColor(renderer,255,0,0,0); ++ SDL_RenderFillRect(renderer,&rect); ++ ++ SDL_SetRenderTarget(renderer,NULL); ++ SDL_RenderCopy(renderer,texture,NULL,NULL); ++ } ++ else ++ { ++ usage(argv[0]); ++ } ++ ++ ++ SDL_RenderPresent(renderer); ++ SDL_Delay( 2000 ); ++ ++ //destory renderer ++ if (renderer) { ++ SDL_DestroyRenderer(renderer); ++ } ++ //Destroy window ++ SDL_DestroyWindow( window ); ++ ++ //Quit SDL subsystems ++ SDL_Quit(); ++ ++ return 0; ++} diff --git a/userapps/gnu-apps/sdl/4-draw-bmp.diff b/userapps/gnu-apps/sdl/4-draw-bmp.diff new file mode 100644 index 0000000000000000000000000000000000000000..d4803eb6a585ec3e40866cbbf64c4ecc33b3ce34 --- /dev/null +++ b/userapps/gnu-apps/sdl/4-draw-bmp.diff @@ -0,0 +1,42 @@ +diff --git a/SDL2-2.0.14/test/testrtt.c b/SDL2-2.0.14/test/testrtt.c +index a1df434..e5014d2 100755 +--- a/SDL2-2.0.14/test/testrtt.c ++++ b/SDL2-2.0.14/test/testrtt.c +@@ -30,7 +30,8 @@ void usage(char * proc_name) + printf( "\toption:\n" + "\t-l draw line\n" + "\t-r draw a rectangle\n" +- "\t-t draw a rectangle with texture\n"); ++ "\t-t draw a rectangle with texture\n" ++ "\t-p draw a bmp picture with texture\n"); + } + + +@@ -100,6 +101,18 @@ int main( int argc, char* argv[] ) + SDL_SetRenderTarget(renderer,NULL); + SDL_RenderCopy(renderer,texture,NULL,NULL); + } ++ else if(0 == strcmp("-p",argv[1])) ++ { ++ screenSurface = SDL_LoadBMP("/mnt/test.bmp"); ++ if(!screenSurface) ++ { ++ printf("SDL_LoadBMP failed\n"); ++ goto end; ++ } ++ texture = SDL_CreateTextureFromSurface(renderer, screenSurface); ++ SDL_SetRenderTarget(renderer,texture); ++ SDL_RenderCopy(renderer,texture,NULL,NULL); ++ } + else + { + usage(argv[0]); +@@ -108,7 +121,7 @@ int main( int argc, char* argv[] ) + + SDL_RenderPresent(renderer); + SDL_Delay( 2000 ); +- ++end: + //destory renderer + if (renderer) { + SDL_DestroyRenderer(renderer); diff --git a/userapps/gnu-apps/sdl/5-add-cconfig-h.diff b/userapps/gnu-apps/sdl/5-add-cconfig-h.diff new file mode 100644 index 0000000000000000000000000000000000000000..bb02410cdee93efc9d4f5d611b7582a8ccd413c8 --- /dev/null +++ b/userapps/gnu-apps/sdl/5-add-cconfig-h.diff @@ -0,0 +1,19 @@ +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c +index 468206e..0a0f0a4 100755 +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c +@@ -8,6 +8,7 @@ + * 2021-1-14 eason The first version + */ + ++#include "cconfig.h" + #include "rtdef.h" + #include "rt_lcd.h" + #include "SDL_surface.h" +@@ -60,4 +61,4 @@ int RTT_lcdQuit() + lcd = NULL; + } + return ret; +-} +\ No newline at end of file ++} diff --git a/userapps/gnu-apps/sdl/6-modify-lcd-config.diff b/userapps/gnu-apps/sdl/6-modify-lcd-config.diff new file mode 100644 index 0000000000000000000000000000000000000000..93c5ff95d0c2d7ae695663219c02c214921d7b4d --- /dev/null +++ b/userapps/gnu-apps/sdl/6-modify-lcd-config.diff @@ -0,0 +1,66 @@ +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h +index f3206d5..081ec86 100755 +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h +@@ -11,9 +11,9 @@ + #ifndef SDL_RTTLCD_H_ + #define SDL_RTTLCD_H_ + +-#define LCD_COLOR_SPACE SDL_PIXELFORMAT_RGB565 +-#define LCD_WIDTH 640 +-#define LCD_HEIGHT 480 ++#define LCD_COLOR_SPACE SDL_PIXELFORMAT_RGB555 ++#define LCD_WIDTH 1024 ++#define LCD_HEIGHT 600 + + #define RTGRAPHIC_CTRL_RECT_UPDATE 0 + +@@ -21,4 +21,4 @@ int RTT_surface2lcd(SDL_Surface *surface); + int RTT_lcdInit(); + int RTT_lcdQuit(); + +-#endif +\ No newline at end of file ++#endif +diff --git a/SDL2-2.0.14/test/testrtt.c b/SDL2-2.0.14/test/testrtt.c +index e5014d2..b96c489 100755 +--- a/SDL2-2.0.14/test/testrtt.c ++++ b/SDL2-2.0.14/test/testrtt.c +@@ -12,8 +12,8 @@ + + #define POINTS_COUNT 4 + +-const int SCREEN_WIDTH = 640; +-const int SCREEN_HEIGHT = 480; ++const int SCREEN_WIDTH = 1024; ++const int SCREEN_HEIGHT = 600; + + static SDL_Point points[POINTS_COUNT] = { + {320, 200}, +@@ -45,7 +45,7 @@ int main( int argc, char* argv[] ) + SDL_Renderer *renderer; + SDL_Texture *texture; + +- if( argc != 2 ) ++ if(( argc != 2 ) && (argc != 3)) + { + usage(argv[0]); + return(1); +@@ -87,7 +87,7 @@ int main( int argc, char* argv[] ) + else if(0 == strcmp("-t",argv[1])) + { + texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565,\ +- SDL_TEXTUREACCESS_TARGET, 640, 480); ++ SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT); + rect.w = 320;//rand()%500; + rect.h = 240;//rand()%500; + SDL_SetRenderTarget(renderer,texture); +@@ -103,7 +103,7 @@ int main( int argc, char* argv[] ) + } + else if(0 == strcmp("-p",argv[1])) + { +- screenSurface = SDL_LoadBMP("/mnt/test.bmp"); ++ screenSurface = SDL_LoadBMP(argv[2]); + if(!screenSurface) + { + printf("SDL_LoadBMP failed\n"); diff --git a/userapps/gnu-apps/sdl/7-modify-get-config.diff b/userapps/gnu-apps/sdl/7-modify-get-config.diff new file mode 100644 index 0000000000000000000000000000000000000000..f49b68c38e0fa751007cbbf9012d1214f58502b9 --- /dev/null +++ b/userapps/gnu-apps/sdl/7-modify-get-config.diff @@ -0,0 +1,249 @@ +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.c b/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.c +index 55c2c8c..374346a 100755 +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.c ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttframebuffer.c +@@ -18,11 +18,11 @@ + #include "SDL_rttvideo.h" + + #define RTT_SURFACE "_SDL_RttSurface" +- ++extern Uint32 rtt_lcd_pixel_format; + int SDL_RTT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) + { + SDL_Surface *surface; +- const Uint32 surface_format = LCD_COLOR_SPACE; ++ const Uint32 surface_format = rtt_lcd_pixel_format; + int w, h; + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c +index 0a0f0a4..6657cbe 100755 +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c +@@ -6,6 +6,7 @@ + * Change Logs: + * Date Author Notes + * 2021-1-14 eason The first version ++ * 2021-9-6 songchao modify for art-pi-samrt + */ + + #include "cconfig.h" +@@ -14,41 +15,67 @@ + #include "SDL_surface.h" + #include "SDL_pixels.h" + #include "SDL_rttlcd.h" ++#include "rtthread.h" + +- +-#define LCD_BUF_SIZE (LCD_WIDTH * LCD_HEIGHT) +- +-rt_uint16_t pixel_ptr[LCD_BUF_SIZE]; + rt_device_t lcd = NULL; + struct fb_fix_screeninfo f_info; + struct fb_var_screeninfo v_info; + + int RTT_surface2lcd(SDL_Surface *surface) + { +- int index = 0; +- int i; + if (lcd) + { +- memcpy((void *)f_info.smem_start, (rt_uint16_t *)(surface->pixels), LCD_BUF_SIZE*2); ++ memcpy((void *)f_info.smem_start, (rt_uint8_t *)(surface->pixels), f_info.smem_len); + rt_thread_mdelay(100); + rt_device_control(lcd, RTGRAPHIC_CTRL_RECT_UPDATE, NULL); + } +- + return 0; + } + +-int RTT_lcdInit() ++int RTT_lcdInit(struct rtt_lcd_config* config) + { + rt_err_t ret = -1; ++ ++ if(config == NULL) ++ { ++ return 1; ++ } ++ + lcd = rt_device_find("lcd"); +- if(!lcd) return 1; ++ if(!lcd) ++ { ++ return 1; ++ } + ret = rt_device_open(lcd, RT_DEVICE_OFLAG_RDWR); +- if(-1 ==ret) return 1; ++ if(-1 ==ret) ++ { ++ return 1; ++ } + rt_device_control(lcd, FBIOGET_FSCREENINFO, &f_info); + printf("screen: %s - 0x%08x, size %d\n", f_info.id, (unsigned int)f_info.smem_start, f_info.smem_len); +- + rt_device_control(lcd, FBIOGET_VSCREENINFO, &v_info); + printf("screen: bpp %d, width - %d, height - %d\n", v_info.bits_per_pixel, v_info.xres, v_info.yres); ++ config->lcd_width = v_info.xres; ++ config->lcd_height = v_info.yres; ++ config->lcd_bits_per_pixel = v_info.bits_per_pixel; ++ if(config->lcd_bits_per_pixel == 16) ++ { ++#if ART_PI_SMART ++ config->lcd_pixel_format = SDL_PIXELFORMAT_RGB555; ++#else ++ config->lcd_pixel_format = SDL_PIXELFORMAT_RGB565; ++#endif ++ } ++ else if(config->lcd_bits_per_pixel == 32) ++ { ++ config->lcd_pixel_format = SDL_PIXELFORMAT_RGB888; ++ } ++ else ++ { ++ printf("lcd_pixel_format %d not support\n",config->lcd_pixel_format); ++ return 1; ++ } ++ + return ret; + } + +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h +index 081ec86..7a678a1 100755 +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h +@@ -6,16 +6,22 @@ + * Change Logs: + * Date Author Notes + * 2021-1-14 eason The first version ++ * 2021-9-6 songchao modify for art-pi-smart + */ + + #ifndef SDL_RTTLCD_H_ + #define SDL_RTTLCD_H_ + +-#define LCD_COLOR_SPACE SDL_PIXELFORMAT_RGB555 +-#define LCD_WIDTH 1024 +-#define LCD_HEIGHT 600 +- + #define RTGRAPHIC_CTRL_RECT_UPDATE 0 ++#define ART_PI_SMART 1 ++ ++struct rtt_lcd_config ++{ ++ Uint32 lcd_width; ++ Uint32 lcd_height; ++ Uint32 lcd_bits_per_pixel; ++ Uint32 lcd_pixel_format; ++}; + + int RTT_surface2lcd(SDL_Surface *surface); + int RTT_lcdInit(); +diff --git a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c +index c967d22..718263d 100755 +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c +@@ -6,13 +6,13 @@ + * Change Logs: + * Date Author Notes + * 2021-1-14 eason The first version ++ * 2021-9-6 songchao modify for art-pi-smart + */ + + #include "../../SDL_internal.h" + + #if SDL_VIDEO_DRIVER_RTT + +- + /* + * Poting SDL to rt-smart platform baseed on Dummy SDL video driver ; + */ +@@ -31,6 +31,10 @@ static int RTT_VideoInit(_THIS); + static int RTT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); + static void RTT_VideoQuit(_THIS); + ++Uint32 rtt_screen_width; ++Uint32 rtt_screen_heigth; ++Uint32 rtt_lcd_pixel_format; ++ + static int + RTT_Available(void) + { +@@ -61,8 +65,8 @@ int RTT_CreateWindow(_THIS, SDL_Window * window) + Rtt_Window = window; + window->x = 0; + window->y = 0; +- window->w = WINDOW_WIDTH_MAX; +- window->h = WINDOW_HEIGHT_MAX; ++ window->w = rtt_screen_width; ++ window->h = rtt_screen_heigth; + + window->flags &= ~SDL_WINDOW_HIDDEN; + window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */ +@@ -117,11 +121,19 @@ int + RTT_VideoInit(_THIS) + { + SDL_DisplayMode mode; ++ struct rtt_lcd_config config; + ++ if(RTT_lcdInit(&config) != 0) ++ { ++ return -1; ++ } ++ rtt_screen_width = config.lcd_width; ++ rtt_screen_heigth = config.lcd_height; ++ rtt_lcd_pixel_format = config.lcd_pixel_format; + /* Use a fake 32-bpp desktop mode */ +- mode.format = LCD_COLOR_SPACE; +- mode.w = LCD_WIDTH; +- mode.h = LCD_HEIGHT; ++ mode.format = config.lcd_pixel_format; ++ mode.w = config.lcd_width; ++ mode.h = config.lcd_height; + mode.refresh_rate = 0; + mode.driverdata = NULL; + if (SDL_AddBasicVideoDisplay(&mode) < 0) { +@@ -131,10 +143,6 @@ RTT_VideoInit(_THIS) + SDL_zero(mode); + SDL_AddDisplayMode(&_this->displays[0], &mode); + +- if(RTT_lcdInit() != 0) +- { +- return -1; +- } + /* We're done! */ + return 0; + } +diff --git a/SDL2-2.0.14/test/testrtt.c b/SDL2-2.0.14/test/testrtt.c +index b96c489..648e60e 100755 +--- a/SDL2-2.0.14/test/testrtt.c ++++ b/SDL2-2.0.14/test/testrtt.c +@@ -12,8 +12,8 @@ + + #define POINTS_COUNT 4 + +-const int SCREEN_WIDTH = 1024; +-const int SCREEN_HEIGHT = 600; ++extern Uint32 rtt_screen_width; ++extern Uint32 rtt_screen_heigth; + + static SDL_Point points[POINTS_COUNT] = { + {320, 200}, +@@ -60,7 +60,7 @@ int main( int argc, char* argv[] ) + } + + +- window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); ++ window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, rtt_screen_width, rtt_screen_heigth, SDL_WINDOW_SHOWN ); + if( window == NULL ) + { + printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() ); +@@ -87,7 +87,7 @@ int main( int argc, char* argv[] ) + else if(0 == strcmp("-t",argv[1])) + { + texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565,\ +- SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT); ++ SDL_TEXTUREACCESS_TARGET, rtt_screen_width, rtt_screen_heigth); + rect.w = 320;//rand()%500; + rect.h = 240;//rand()%500; + SDL_SetRenderTarget(renderer,texture); diff --git a/userapps/gnu-apps/sdl/8-touch-event-support.diff b/userapps/gnu-apps/sdl/8-touch-event-support.diff new file mode 100644 index 0000000000000000000000000000000000000000..f811117f4bea6ac3d2bc7b7c013d53d91d013f11 --- /dev/null +++ b/userapps/gnu-apps/sdl/8-touch-event-support.diff @@ -0,0 +1,509 @@ +diff -Naur a/SDL2-2.0.14/src/events/SDL_quit.c b/SDL2-2.0.14/src/events/SDL_quit.c +--- a/SDL2-2.0.14/src/events/SDL_quit.c 2020-12-22 01:44:36.000000000 +0800 ++++ b/SDL2-2.0.14/src/events/SDL_quit.c 2021-09-17 16:32:21.230683701 +0800 +@@ -35,6 +35,8 @@ + #define HAVE_SIGNAL_SUPPORT 1 + #endif + ++#define SDL_FOREGROUNDING_SIGNAL 1 ++ + #ifdef HAVE_SIGNAL_SUPPORT + static SDL_bool disable_signals = SDL_FALSE; + static SDL_bool send_quit_pending = SDL_FALSE; +@@ -44,7 +46,7 @@ + #endif + + #ifdef SDL_FOREGROUNDING_SIGNAL +-static SDL_bool send_foregrounding_pending = SDL_FALSE; ++static SDL_bool send_foregrounding_pending = SDL_TRUE; + #endif + + static void +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.c b/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.c +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.c 1970-01-01 08:00:00.000000000 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.c 2021-09-17 10:17:52.406451938 +0800 +@@ -0,0 +1,84 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2018 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++#include "../../SDL_internal.h" ++ ++ ++//#include ++ ++#include "SDL_events.h" ++#include "SDL_log.h" ++#include "SDL_rttvideo.h" ++#include "SDL_rttkeyboard.h" ++#include "../../events/SDL_keyboard_c.h" ++ ++#define NUM_SCANCODES_RTT 68 ++static SDL_bool keystate[NUM_SCANCODES_RTT] = {0}; ++ ++void RTT_InitKeyboard(void) ++{ ++ ++} ++ ++__attribute__((weak)) int RTT_HeldKeyboardCode(int index) ++{ ++ return 0; ++} ++ ++__attribute__((weak)) int RTT_GetKeyboardCode(int keycode) ++{ ++ return 0; ++} ++ ++void RTT_PollKeyboard(void) ++{ ++ // We skip polling keyboard if no window is created ++ if (SDL_GetFocusWindow() == NULL) ++ { ++ return; ++ } ++ ++ for (int i = 0; i < NUM_SCANCODES_RTT; i++) ++ { ++ int press = RTT_HeldKeyboardCode(i); ++ int keyCode = RTT_GetKeyboardCode(i); ++ ++ if(press && !keystate[i]) ++ { ++ SDL_LogInfo(SDL_LOG_CATEGORY_INPUT, "keyCode = %d, Down\n", keyCode); ++ SDL_SendKeyboardKey(SDL_PRESSED, keyCode); ++ keystate[i] = SDL_TRUE; ++ } ++ else if(!press && keystate[i]) ++ { ++ SDL_LogInfo(SDL_LOG_CATEGORY_INPUT, "keyCode = %d, Up\n", keyCode); ++ SDL_SendKeyboardKey(SDL_RELEASED, keyCode); ++ keystate[i] = SDL_FALSE; ++ } ++ } ++} ++ ++void RTT_QuitKeyboard(void) ++{ ++ ++} ++ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.h b/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.h +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.h 1970-01-01 08:00:00.000000000 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttkeyboard.h 2021-09-17 10:17:52.406451938 +0800 +@@ -0,0 +1,34 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2018 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++ ++#ifndef _SDL_rttkeyboard_h ++#define _SDL_rttkeyboard_h ++ ++#include "../../SDL_internal.h" ++ ++/* Keyboard functions */ ++extern void RTT_InitKeyboard(void); ++extern void RTT_PollKeyboard(void); ++extern void RTT_QuitKeyboard(void); ++ ++#endif /* _SDL_keyboard_h */ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c 2021-09-17 16:35:31.939275736 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.c 2021-09-17 10:17:52.406451938 +0800 +@@ -15,7 +15,7 @@ + #include "SDL_surface.h" + #include "SDL_pixels.h" + #include "SDL_rttlcd.h" +-#include "rtthread.h" ++ + + rt_device_t lcd = NULL; + struct fb_fix_screeninfo f_info; +@@ -27,7 +27,7 @@ + { + memcpy((void *)f_info.smem_start, (rt_uint8_t *)(surface->pixels), f_info.smem_len); + rt_thread_mdelay(100); +- rt_device_control(lcd, RTGRAPHIC_CTRL_RECT_UPDATE, NULL); ++ rt_device_control(lcd, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL); + } + return 0; + } +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h 2021-09-17 16:35:31.939275736 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttlcd.h 2021-09-17 10:17:52.406451938 +0800 +@@ -12,9 +12,26 @@ + #ifndef SDL_RTTLCD_H_ + #define SDL_RTTLCD_H_ + ++#include + #define RTGRAPHIC_CTRL_RECT_UPDATE 0 + #define ART_PI_SMART 1 + ++#define RTGRAPHIC_CTRL_GET_INFO 3 ++extern void *RTT_GetWindowInfo(void); ++ ++struct rt_device_graphic_info ++{ ++ rt_uint8_t pixel_format; /**< graphic format */ ++ rt_uint8_t bits_per_pixel; /**< bits per pixel */ ++ rt_uint16_t reserved; /**< reserved field */ ++ ++ rt_uint16_t width; /**< width of graphic device */ ++ rt_uint16_t height; /**< height of graphic device */ ++ ++ rt_uint8_t *framebuffer; /**< frame buffer */ ++}; ++ ++ + struct rtt_lcd_config + { + Uint32 lcd_width; +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.c b/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.c +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.c 1970-01-01 08:00:00.000000000 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.c 2021-09-17 10:17:52.406451938 +0800 +@@ -0,0 +1,56 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2018 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++#include "../../SDL_internal.h" ++ ++ ++//#include ++ ++#include "SDL_timer.h" ++#include "SDL_events.h" ++#include "SDL_log.h" ++#include "SDL_mouse.h" ++#include "SDL_rttvideo.h" ++#include "SDL_rttmouse.h" ++#include "../../events/SDL_mouse_c.h" ++ ++static int RTT_SetRelativeMouseMode(SDL_bool enabled) ++{ ++ return 0; ++} ++ ++void RTT_InitMouse(void) ++{ ++ SDL_Mouse *mouse = SDL_GetMouse(); ++ ++ mouse->SetRelativeMouseMode = RTT_SetRelativeMouseMode; ++} ++ ++void RTT_PollMouse(void) ++{ ++ ++} ++ ++void RTT_QuitMouse(void) ++{ ++} ++ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.h b/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.h +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.h 1970-01-01 08:00:00.000000000 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttmouse.h 2021-09-17 10:17:52.406451938 +0800 +@@ -0,0 +1,34 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2018 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++ ++#ifndef _SDL_rttmouse_h ++#define _SDL_rttmouse_h ++ ++#include "../../SDL_internal.h" ++ ++/* mouse functions */ ++extern void RTT_InitMouse(void); ++extern void RTT_PollMouse(void); ++extern void RTT_QuitMouse(void); ++ ++#endif /* _SDL_rttmouse_h */ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.c b/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.c +--- a/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.c 1970-01-01 08:00:00.000000000 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.c 2021-09-17 10:17:52.406451938 +0800 +@@ -0,0 +1,103 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2017 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++#include "../../SDL_internal.h" ++ ++ ++#include ++ ++#include ++#include "SDL_hints.h" ++#include "SDL_rttvideo.h" ++#include "../../events/SDL_touch_c.h" ++#include "../../video/SDL_sysvideo.h" ++#include "rtthread.h" ++#include "SDL_rttlcd.h" ++ ++//static struct rt_touch_device *touch = NULL; ++static struct rt_device_t *touch = NULL; ++static struct rt_touch_data touch_data; ++ ++void RTT_InitTouch(void) ++{ ++ touch = rt_device_find("gt911"); ++ if(touch) ++ { ++ //rt_device_open(touch, RT_DEVICE_FLAG_RDONLY); ++ rt_device_open(touch, RT_DEVICE_FLAG_INT_RX); ++ rt_device_control(touch, RT_TOUCH_CTRL_ENABLE_INT, RT_NULL); ++ // SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Touch Type : %d", touch->info.type); ++ // SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Touch Vendor : %d", touch->info.vendor); ++ // SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Touch PointNum: %d", touch->info.point_num); ++ // SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Touch RangeX : %d", touch->info.range_x); ++ // SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Touch RangeY : %d", touch->info.range_y); ++ ++ SDL_AddTouch((SDL_TouchID) 0, SDL_TOUCH_DEVICE_DIRECT, "RTTTouch"); ++ SDL_SetHintWithPriority(SDL_HINT_TOUCH_MOUSE_EVENTS, "0", SDL_HINT_DEFAULT); ++ } ++} ++ ++void RTT_QuitTouch(void) ++{ ++ if(touch) ++ { ++ rt_device_close(touch); ++ touch = NULL; ++ } ++} ++ ++void RTT_PollTouch(void) ++{ ++ int width = 1024; ++ int height = 600; ++ if(touch) ++ { ++ SDL_Window *window = SDL_GetFocusWindow(); ++ if (window == NULL) ++ { ++ return; ++ } ++ ++ if (rt_device_read(touch, 0, &touch_data, 1) == 1) ++ { ++ if(touch_data.event == RT_TOUCH_EVENT_DOWN) ++ { ++ SDL_SendTouch(0, (SDL_FingerID) 0, window, SDL_TRUE, ++ (float)touch_data.x_coordinate/(float)width, ++ (float)touch_data.y_coordinate/(float)height, 1); ++ } ++ else if(touch_data.event == RT_TOUCH_EVENT_UP) ++ { ++ SDL_SendTouch(0, (SDL_FingerID) 0, window, SDL_FALSE, ++ (float)touch_data.x_coordinate/(float)width, ++ (float)touch_data.y_coordinate/(float)height, 1); ++ } ++ else if(touch_data.event == RT_TOUCH_EVENT_MOVE) ++ { ++ SDL_SendTouchMotion(0, (SDL_FingerID) 0, window, ++ (float)touch_data.x_coordinate/(float)width, ++ (float)touch_data.y_coordinate/(float)height, 1); ++ } ++ } ++ } ++} ++ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.h b/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.h +--- a/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.h 1970-01-01 08:00:00.000000000 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rtttouch.h 2021-09-17 10:17:52.406451938 +0800 +@@ -0,0 +1,34 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2017 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++ ++#ifndef _SDL_rtttouch_h ++#define _SDL_rtttouch_h ++ ++#include "../../SDL_internal.h" ++ ++/* Touch functions */ ++extern void RTT_InitTouch(void); ++extern void RTT_QuitTouch(void); ++extern void RTT_PollTouch(void); ++ ++#endif /* _SDL_rtttouch_h */ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c 2021-09-17 16:35:31.939275736 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.c 2021-09-17 16:32:08.466365781 +0800 +@@ -35,11 +35,18 @@ + Uint32 rtt_screen_heigth; + Uint32 rtt_lcd_pixel_format; + ++ ++void RTT_PumpEvents(_THIS) ++{ ++ RTT_PollTouch(); ++ RTT_PollKeyboard(); ++// RTT_PollMouse(); ++} ++ + static int + RTT_Available(void) + { + const char *envr = SDL_getenv("SDL_VIDEODRIVER"); +- printf("envr: %s",envr); + if ((envr) && (SDL_strcmp(envr, RTT_DRIVER_NAME) == 0)) { + return (1); + } +@@ -107,6 +114,8 @@ + device->CreateSDLWindow = RTT_CreateWindow; + device->SetWindowTitle = RTT_SetWindowTitle; + ++ device->PumpEvents = RTT_PumpEvents; ++ + device->free = RTT_DeleteDevice; + return device; + } +@@ -142,6 +151,7 @@ + + SDL_zero(mode); + SDL_AddDisplayMode(&_this->displays[0], &mode); ++ RTT_InitTouch(); + + /* We're done! */ + return 0; +@@ -157,7 +167,8 @@ + RTT_VideoQuit(_THIS) + { + RTT_lcdQuit(); ++ RTT_QuitTouch(); + } + + +-#endif /* SDL_VIDEO_DRIVER_RTT */ +\ 文件尾没有换行符 ++#endif /* SDL_VIDEO_DRIVER_RTT */ +diff -Naur a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.h b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.h +--- a/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.h 2021-09-17 16:35:31.935275642 +0800 ++++ b/SDL2-2.0.14/src/video/rtt/SDL_rttvideo.h 2021-09-17 10:17:52.406451938 +0800 +@@ -15,8 +15,11 @@ + + #include "../SDL_sysvideo.h" + #include "SDL_rttlcd.h" ++#include "SDL_rtttouch.h" ++#include "SDL_rttkeyboard.h" ++#include "SDL_rttmouse.h" + + #define WINDOW_WIDTH_MAX LCD_WIDTH + #define WINDOW_HEIGHT_MAX LCD_HEIGHT + +-#endif /* SDL_nullvideo_h_ */ +\ 文件尾没有换行符 ++#endif /* SDL_nullvideo_h_ */ diff --git a/userapps/gnu-apps/sdl/README.md b/userapps/gnu-apps/sdl/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6b19db0942f7cc319d985c7dc5623adbfe21ab30 --- /dev/null +++ b/userapps/gnu-apps/sdl/README.md @@ -0,0 +1,11 @@ +1.移植SDL2最新的2.0.14版本。暂不支持directfb,没有实现窗口系统。 + 默认视频驱动使用dummy,在qemu lcd屏上显示。可以绘制基本的线,三角形,矩形。 + 可以实现texture绘制。 +2.测试程序为test/testrtt.c +3.编译方法: + 工作目录:./gnu_apps/sdl + 编译sdl: + $ ./build_sdl.sh + 编译测试代码: + $ ./build_test.sh + diff --git a/userapps/gnu-apps/sdl/build_sdl.sh b/userapps/gnu-apps/sdl/build_sdl.sh new file mode 100755 index 0000000000000000000000000000000000000000..2ddcbcb3376a5aa41df08f099623eb123d0a873f --- /dev/null +++ b/userapps/gnu-apps/sdl/build_sdl.sh @@ -0,0 +1,176 @@ +#!/bin/bash + +# Get initial variables +BUILD_CONF="../conf.sh" +if [ ! -f ${BUILD_CONF} ]; then + echo "conf.sh file not exist!" + exit 1; +fi +source ${BUILD_CONF} $1 + +APP_NAME="SDL2" +VERSION="2.0.14" +APP_DIR=${APP_NAME}-${VERSION} + +LIB_DIR=${ROOTDIR}/sdk/lib +INC_DIR=${ROOTDIR}/sdk/include + +RT_DIR=${ROOTDIR}/sdk/rt-thread +RT_INC=" -I. -Iinclude -I${ROOTDIR} -I${RT_DIR}/include -I${RT_DIR}/components/dfs -I${RT_DIR}/components/drivers -I${RT_DIR}/components/finsh -I${RT_DIR}/components/net -I${INC_DIR} -DHAVE_CCONFIG_H" +RT_INC+=" -I${ROOTDIR}/../kernel/bsp/qemu-vexpress-a9/drivers/" + +export CPPFLAGS=${RT_INC} +export LDFLAGS="-L${LIB_DIR} " + +export LIBS="-T ${ROOTDIR}/linker_scripts/arm/cortex-a/link.lds -march=armv7-a -marm -msoft-float -L${RT_DIR}/lib -Wl,--whole-archive -lrtthread -Wl,--no-whole-archive -n -static -Wl,--start-group -lc -lgcc -lrtthread -Wl,--end-group" + +TagFile=".patched" +DbgFile=".dbg_patched" + +function usage() { + echo "=====================" + echo "Usage: $0 [options] [verbose]" + echo "" + echo " $0 - build without debug info and strip, if build option not same with the exist source dir, backup and re-unzip" + echo " $0 verbose - default build with detail log" + echo " $0 debug - build with debug info and not strip, if build option not same with the exist source dir, backup and re-unzip" + echo " $0 debug verbose - debug build with detail log" + echo " $0 help - show help info" + echo "=====================" +} + +# create tag file and do patch if has +function dopatch() { + if [ "$1" == "debug" ]; then + touch ${APP_DIR}/${DbgFile} + else + touch ${APP_DIR}/${TagFile} + fi + patch -Np1 -i 3-*.diff + patch -Np1 -i 4-*.diff + patch -Np1 -i 5-*.diff + patch -Np1 -i 6-*.diff + patch -Np1 -i 7-*.diff + patch -Np1 -i 8-*.diff +} + +function preparesrc() { + if [ ! -f ${APP_DIR}.tar.gz ]; then + echo "========= Downloading ${APP_DIR}.tar.gz =========" + wget http://117.143.63.254:9012/www/rt-smart/packages/${APP_DIR}.tar.gz + fi + tar xzf ${APP_DIR}.tar.gz +} + +# debug build +function builddbg() { + if [ -d ${APP_DIR} ] && [ -f ${APP_DIR}/${DbgFile} ]; then + echo "find ${APP_DIR}" + else + if [ -d ${APP_DIR} ]; then + # bank old source dir, default build + mv ${APP_DIR} ${APP_DIR}.$(date "+%Y%m%d%H%M%S") + fi + preparesrc + dopatch $1 + fi + + cd ${APP_DIR} + ./autogen.sh + ./configure \ + --prefix=${ROOTDIR}/build \ + --target=${CROSS_COMPILE} \ + --host=${CROSS_COMPILE} \ + --build=i686-pc-linux-gnu \ + --enable-joystick-virtual=no \ + --enable-render-d3d=no \ + --enable-sdl-dlopen=no \ + --enable-joystick=no \ + --enable-joystick-mfi=no \ + --enable-hidapi=no \ + --enable-hidapi-libusb=no \ + --enable-shared=no \ + --enable-threads=no \ + --enable-3dnow=no \ + --enable-jack-shared=no \ + --enable-pulseaudio-shared=no \ + --enable-pulseaudio=no \ + --enable-cpuinfo=no \ + --enable-video-directfb \ + --enable-directfb-shared=no + make clean + if [ "$2" == "verbose" ]; then + make V=1 + else + make + fi +} + +# default build +function builddef() { + if [ -d ${APP_DIR} ] && [ -f ${APP_DIR}/${TagFile} ]; then + echo "find ${APP_DIR}" + else + if [ -d ${APP_DIR} ]; then + # bank old source dir, debug build + mv ${APP_DIR} ${APP_DIR}.$(date "+%Y%m%d%H%M%S").dbg + fi + preparesrc + dopatch + fi + + cd ${APP_DIR} + ./autogen.sh + ./configure \ + --prefix=${ROOTDIR}/build \ + --target=${CROSS_COMPILE} \ + --host=${CROSS_COMPILE} \ + --build=i686-pc-linux-gnu \ + --enable-joystick-virtual=no \ + --enable-render-d3d=no \ + --enable-sdl-dlopen=no \ + --enable-joystick=no \ + --enable-joystick-mfi=no \ + --enable-hidapi=no \ + --enable-hidapi-libusb=no \ + --enable-shared=no \ + --enable-threads=no \ + --enable-3dnow=no \ + --enable-jack-shared=no \ + --enable-pulseaudio-shared=no \ + --enable-pulseaudio=no \ + --enable-cpuinfo=no \ + --enable-video-directfb \ + --enable-directfb-shared=no + make clean + if [ "$1" == "verbose" ]; then + make V=1 + else + make + fi +} + + +if [ "$1" == "help" ]; then + usage + exit 0 +elif [ "$1" == "debug" ]; then + builddbg $1 $2 +else + builddef $1 +fi + + +echo "========= Copy libSDL2.a and .h to sdk path =========" +test -d ${ROOTDIR}/sdk/include/sdl || mkdir -p ${ROOTDIR}/sdk/include/sdl +test -d ${ROOTDIR}/sdk/include || mkdir -p ${ROOTDIR}/sdk/include +test -d ${ROOTDIR}/sdk/lib || mkdir -p ${ROOTDIR}/sdk/lib + +cp include/*.h ${ROOTDIR}/sdk/include/sdl +cp ./build/.libs/libSDL2.a ${ROOTDIR}/sdk/lib +cp ./build/.libs/libSDL2_test.a ${ROOTDIR}/sdk/lib + +cd .. +./build_test.sh + +echo "========= sdl building finished. =========" diff --git a/userapps/gnu-apps/sdl/build_test.sh b/userapps/gnu-apps/sdl/build_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..720fcae8aae35d5f41b90112bc2818c23121e180 --- /dev/null +++ b/userapps/gnu-apps/sdl/build_test.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +# Get initial variables +BUILD_CONF="../conf.sh" +if [ ! -f ${BUILD_CONF} ]; then + echo "conf.sh file not exist!" + exit 1; +fi +source ${BUILD_CONF} $1 + +APP_NAME="SDL2" +VERSION="2.0.14" +APP_DIR=${APP_NAME}-${VERSION} + +LIB_DIR=${ROOTDIR}/sdk/lib +INC_DIR=${ROOTDIR}/sdk/include/sdl +RT_DIR=${ROOTDIR}/sdk/rt-thread + +RT_INC="-I${APP_DIR}/include -I${ROOTDIR}/apps/${APP_DIR} -I${RT_DIR}/include -I${RT_DIR}/components/dfs -I${RT_DIR}/components/drivers -I${RT_DIR}/components/finsh -I${RT_DIR}/components/net -I${INC_DIR}" + +export CFLAGS=${RT_INC} +export LIBS=" -L${LIB_DIR} ${RT_INC} -T ${ROOTDIR}/linker_scripts/arm/cortex-a/link.lds -march=armv7-a -marm -msoft-float -L${RT_DIR}/lib -Wl,--whole-archive -lrtthread -Wl,--no-whole-archive -n -static -Wl,--start-group -lc -lgcc -lrtthread -Wl,--end-group -lSDL2" + +TagFile=".patched" +DbgFile=".dbg_patched" + +function usage() { + echo "=====================" + echo "Usage: $0 [options] [verbose]" + echo "" + echo " $0 - build without debug info and strip, if build option not same with the exist source dir, backup and re-unzip" + echo " $0 verbose - default build with detail log" + echo " $0 debug - build with debug info and not strip, if build option not same with the exist source dir, backup and re-unzip" + echo " $0 debug verbose - debug build with detail log" + echo " $0 help - show help info" + echo "=====================" +} + +# create tag file and do patch if has +function dopatch() { + if [ "$1" == "debug" ]; then + touch "$DbgFile" + else + touch "$TagFile" + fi +} + +# debug build +function builddbg() { + if [ -d ${APP_DIR}/test ] && [ -f ${APP_DIR}/test/${DbgFile} ]; then + cd ${APP_DIR}/test + else + if [ -f ${APP_DIR}/test/${TagFile} ]; then + rm ${APP_DIR}/test/${TagFile} + fi + cd ${APP_DIR}/test + dopatch $1 + fi + + ./configure \ + --target=${CROSS_COMPILE} \ + --host=${CROSS_COMPILE} \ + --build=i686-pc-linux-gnu \ + --with-sdl-prefix=${LIB_DIR} + make clean + if [ "$2" == "verbose" ]; then + make V=1 + else + make + fi +} + +# default build +function builddef() { + if [ -d ${APP_DIR}/test ] && [ -f ${APP_DIR}/test/${TagFile} ]; then + cd ${APP_DIR}/test + else + if [ -f ${APP_DIR}/test/${DbgFile} ]; then + rm ${APP_DIR}/test/${DbgFile} + fi + cd ${APP_DIR}/test + dopatch + fi + + ./configure \ + --target=${CROSS_COMPILE} \ + --host=${CROSS_COMPILE} \ + --build=i686-pc-linux-gnu \ + --with-sdl-prefix=${LIB_DIR} + make clean + if [ "$1" == "verbose" ]; then + make V=1 + else + make + fi + # strip + arm-linux-musleabi-strip testrtt +} + + +if [ "$1" == "help" ]; then + usage + exit 0 +elif [ "$1" == "debug" ]; then + builddbg $1 $2 +else + builddef $1 +fi + +echo "========= Copy sdl_test.elf and test.bmp to ${ROOTDIR}/root/bin =========" +cp testrtt ${ROOTDIR}/root/bin/sdl_test.elf +cd ../.. +cp test.bmp ${ROOTDIR}/root/bin/ +echo "======== Finished building sdl_test ========" diff --git a/userapps/gnu-apps/sdl/test.bmp b/userapps/gnu-apps/sdl/test.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a9a7eeaadb809869cc72c32d96f5f514604872cb Binary files /dev/null and b/userapps/gnu-apps/sdl/test.bmp differ diff --git a/userapps/sdk/rt-thread/components/drivers/rt_lcd.h b/userapps/sdk/rt-thread/components/drivers/rt_lcd.h new file mode 100644 index 0000000000000000000000000000000000000000..c79400888410a2901c45f01d0cd5fd39de3ba408 --- /dev/null +++ b/userapps/sdk/rt-thread/components/drivers/rt_lcd.h @@ -0,0 +1,59 @@ +#ifndef RT_LCD_H__ +#define RT_LCD_H__ + + +/* ioctls + 0x46 is 'F' */ +#define FBIOGET_VSCREENINFO 0x4600 +#define FBIOPUT_VSCREENINFO 0x4601 +#define FBIOGET_FSCREENINFO 0x4602 +#define FBIOGETCMAP 0x4604 +#define FBIOPUTCMAP 0x4605 +#define FBIOPAN_DISPLAY 0x4606 +#define FBIO_CURSOR 0x4608 +/* #define FBIOGET_MONITORSPEC 0x460C */ +/* #define FBIOPUT_MONITORSPEC 0x460D */ +/* #define FBIOSWITCH_MONIBIT 0x460E */ +#define FBIOGET_CON2FBMAP 0x460F +#define FBIOPUT_CON2FBMAP 0x4610 +#define FBIOBLANK 0x4611 /* arg: 0 or vesa level + 1 */ +#define FBIOGET_VBLANK 0x4612 +#define FBIO_ALLOC 0x4613 +#define FBIO_FREE 0x4614 +#define FBIOGET_GLYPH 0x4615 +#define FBIOGET_HWCINFO 0x4616 +#define FBIOPUT_MODEINFO 0x4617 +#define FBIOGET_DISPINFO 0x4618 +#define FBIO_WAITFORVSYNC 0x4620 + +struct fb_bitfield +{ + uint32_t offset; /* beginning of bitfield */ + uint32_t length; /* length of bitfield */ + uint32_t msb_right; /* != 0 : Most significant bit is */ + /* right */ +}; + +struct fb_var_screeninfo +{ + uint32_t xres; + uint32_t yres; + + uint32_t bits_per_pixel; + + struct fb_bitfield red; /* bitfield in fb mem if true color, */ + struct fb_bitfield green; /* else only length is significant */ + struct fb_bitfield blue; + struct fb_bitfield transp; /* transparency */ +}; + +struct fb_fix_screeninfo +{ + char id[16]; + unsigned long smem_start; + uint32_t smem_len; + + uint32_t line_length; +}; + +#endif diff --git a/userapps/sdk/rt-thread/components/drivers/touch.h b/userapps/sdk/rt-thread/components/drivers/touch.h new file mode 100644 index 0000000000000000000000000000000000000000..dd7ee45d98e512c5d9218a57b384d6a9ff6691ff --- /dev/null +++ b/userapps/sdk/rt-thread/components/drivers/touch.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2019-05-20 tyustli the first version + */ + +#ifndef __TOUCH_H__ +#define __TOUCH_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RT_USING_RTC +#define rt_touch_get_ts() time(RT_NULL) /* API for the touch to get the timestamp */ +#else +#define rt_touch_get_ts() rt_tick_get() /* API for the touch to get the timestamp */ +#endif + +#define RT_PIN_NONE 0xFFFF /* RT PIN NONE */ + +/* Touch vendor types */ +#define RT_TOUCH_VENDOR_UNKNOWN (0) /* unknown */ +#define RT_TOUCH_VENDOR_GT (1) /* GTxx series */ +#define RT_TOUCH_VENDOR_FT (2) /* FTxx series */ + +/* Touch ic type*/ +#define RT_TOUCH_TYPE_NONE (0) /* touch ic none */ +#define RT_TOUCH_TYPE_CAPACITANCE (1) /* capacitance ic */ +#define RT_TOUCH_TYPE_RESISTANCE (2) /* resistance ic */ + +/* Touch control cmd types */ +#define RT_TOUCH_CTRL_GET_ID (0) /* Get device id */ +#define RT_TOUCH_CTRL_GET_INFO (1) /* Get touch info */ +#define RT_TOUCH_CTRL_SET_MODE (2) /* Set touch's work mode. ex. RT_TOUCH_MODE_POLLING,RT_TOUCH_MODE_INT */ +#define RT_TOUCH_CTRL_SET_X_RANGE (3) /* Set x coordinate range */ +#define RT_TOUCH_CTRL_SET_Y_RANGE (4) /* Set y coordinate range */ +#define RT_TOUCH_CTRL_SET_X_TO_Y (5) /* Set X Y coordinate exchange */ +#define RT_TOUCH_CTRL_DISABLE_INT (6) /* Disable interrupt */ +#define RT_TOUCH_CTRL_ENABLE_INT (7) /* Enable interrupt */ +#define RT_TOUCH_CTRL_POWER_ON (8) /* Touch Power On */ +#define RT_TOUCH_CTRL_POWER_OFF (9) /* Touch Power Off */ +#define RT_TOUCH_CTRL_GET_STATUS (10) /* Get Touch Power Status */ + +/* Touch event */ +#define RT_TOUCH_EVENT_NONE (0) /* Touch none */ +#define RT_TOUCH_EVENT_UP (1) /* Touch up event */ +#define RT_TOUCH_EVENT_DOWN (2) /* Touch down event */ +#define RT_TOUCH_EVENT_MOVE (3) /* Touch move event */ + +struct rt_touch_info +{ + rt_uint8_t type; /* The touch type */ + rt_uint8_t vendor; /* Vendor of touchs */ + rt_uint8_t point_num; /* Support point num */ + rt_int32_t range_x; /* X coordinate range */ + rt_int32_t range_y; /* Y coordinate range */ +}; + +struct rt_touch_config +{ + // struct rt_device_pin_mode irq_pin; /* Interrupt pin, The purpose of this pin is to notification read data */ + char *dev_name; /* The name of the communication device */ + void *user_data; +}; + +typedef struct rt_touch_device *rt_touch_t; +struct rt_touch_device +{ + struct rt_device parent; /* The standard device */ + struct rt_touch_info info; /* The touch info data */ + struct rt_touch_config config; /* The touch config data */ + + const struct rt_touch_ops *ops; /* The touch ops */ + rt_err_t (*irq_handle)(rt_touch_t touch); /* Called when an interrupt is generated, registered by the driver */ +}; + +struct rt_touch_data +{ + rt_uint8_t event; /* The touch event of the data */ + rt_uint8_t track_id; /* Track id of point */ + rt_uint8_t width; /* Point of width */ + rt_uint16_t x_coordinate; /* Point of x coordinate */ + rt_uint16_t y_coordinate; /* Point of y coordinate */ + rt_tick_t timestamp; /* The timestamp when the data was received */ +}; + +struct rt_touch_ops +{ + rt_size_t (*touch_readpoint)(struct rt_touch_device *touch, void *buf, rt_size_t touch_num); + rt_err_t (*touch_control)(struct rt_touch_device *touch, int cmd, void *arg); +}; + +int rt_hw_touch_register(rt_touch_t touch, + const char *name, + rt_uint32_t flag, + void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* __TOUCH_H__ */