G2A Many GEOs
SHARE
TWEET

Untitled

ShantiGilbert Mar 7th, 2020 13 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -r 0f7577d28c6c src/video/kmsdrm/SDL_kmsdrmopengles.c
  2. --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c Wed Jan 01 08:13:40 2020 -0800
  3. +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c Tue Mar 03 20:21:22 2020 +0100
  4. @@ -33,6 +33,9 @@
  5.  #define EGL_PLATFORM_GBM_MESA 0x31D7
  6.  #endif
  7.  
  8. +extern rga_info_t src_info;
  9. +extern rga_info_t dst_info;
  10. +
  11.  /* EGL implementation of SDL OpenGL support */
  12.  
  13.  int
  14. @@ -97,6 +100,7 @@
  15.      SDL_VideoData *vdata = ((SDL_VideoData *)_this->driverdata);
  16.      KMSDRM_FBInfo *fb_info;
  17.      int ret;
  18. +    struct gbm_bo* rga_buffer = NULL;
  19.  
  20.      /* Do we still need to wait for a flip? */
  21.      int timeout = 0;
  22. @@ -116,7 +120,7 @@
  23.          wdata->next_bo = NULL;
  24.      }
  25.  
  26. -    if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) {
  27. +     if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) {
  28.          SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed.");
  29.          return 0;
  30.      }
  31. @@ -136,10 +140,22 @@
  32.          SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Locked GBM surface %p", (void *)wdata->next_bo); */
  33.      }
  34.  
  35. -    fb_info = KMSDRM_FBFromBO(_this, wdata->next_bo);
  36. +    src_info.fd = KMSDRM_gbm_bo_get_fd(wdata->next_bo);
  37. +    dst_info.fd = vdata->rga_buffer_prime_fds[vdata->rga_buffer_index];
  38. +    if (c_RkRgaBlit(&src_info, &dst_info, NULL) < 0) {
  39. +        SDL_LogError(SDL_LOG_CATEGORY_VIDEO,
  40. +                        "Failed to rga blit\n");
  41. +    }
  42. +    close(src_info.fd);
  43. +
  44. +    rga_buffer = vdata->rga_buffers[vdata->rga_buffer_index];
  45. +    fb_info = KMSDRM_FBFromBO(_this, rga_buffer);
  46.      if (fb_info == NULL) {
  47.          return 0;
  48.      }
  49. +    
  50. +    vdata->rga_buffer_index = (vdata->rga_buffer_index + 1) % RGA_BUFFERS_MAX;
  51. +    
  52.      if (_this->egl_data->egl_swapinterval == 0) {
  53.          /* Swap buffers instantly, possible tearing */
  54.          /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "drmModeSetCrtc(%d, %u, %u, 0, 0, &%u, 1, &%ux%u@%u)",
  55. --- a/src/video/kmsdrm/SDL_kmsdrmsym.h
  56. +++ b/src/video/kmsdrm/SDL_kmsdrmsym.h
  57. @@ -88,6 +88,7 @@
  58.  SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf))
  59.  SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf))
  60.  SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo))
  61. +SDL_KMSDRM_SYM(int,gbm_bo_get_fd,(struct gbm_bo *bo))
  62.  
  63.  
  64.  #undef SDL_KMSDRM_MODULE
  65. diff -r 0f7577d28c6c src/video/kmsdrm/SDL_kmsdrmvideo.c
  66. --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c    Wed Jan 01 08:13:40 2020 -0800
  67. +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c    Tue Mar 03 20:21:22 2020 +0100
  68. @@ -41,11 +41,15 @@
  69.  #include "SDL_kmsdrmopengles.h"
  70.  #include "SDL_kmsdrmmouse.h"
  71.  #include "SDL_kmsdrmdyn.h"
  72. +#include <sys/ioctl.h>
  73.  #include <sys/stat.h>
  74.  #include <dirent.h>
  75.  #include <errno.h>
  76.  
  77.  #define KMSDRM_DRI_PATH "/dev/dri/"
  78. +
  79. +rga_info_t src_info = {0};
  80. +rga_info_t dst_info = {0};
  81.  
  82.  static int
  83.  check_modestting(int devindex)
  84. @@ -252,6 +256,38 @@
  85.      free(fb_info);
  86.  }
  87.  
  88. +static void
  89. +KMSDRM_InitRotateBuffer(_THIS, int frameWidth, int frameHeight)
  90. +{
  91. +    // acquire new DRM PRIME buffer for rotate screen
  92. +    int ret;
  93. +    SDL_VideoData *vdata = ((SDL_VideoData *)_this->driverdata);
  94. +
  95. +    for (int i = 0; i < RGA_BUFFERS_MAX; ++i)
  96. +    {
  97. +        vdata->rga_buffers[i] = KMSDRM_gbm_bo_create(vdata->gbm,
  98. +              frameWidth, frameHeight,
  99. +              GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
  100. +        assert(vdata->rga_buffers[i]);
  101. +
  102. +    vdata->rga_buffer_prime_fds[i] = KMSDRM_gbm_bo_get_fd(vdata->rga_buffers[i]);
  103. +    }
  104. +    vdata->rga_buffer_index = 0;
  105. +    
  106. +    // setup rotation
  107. +    c_RkRgaInit();
  108. +    src_info.mmuFlag = 1;
  109. +    src_info.rotation = HAL_TRANSFORM_ROT_270;
  110. +
  111. +    // swap width and height here because our source buffer is 480x320
  112. +    rga_set_rect(&src_info.rect, 0, 0, frameHeight, frameWidth, frameHeight, frameWidth, RK_FORMAT_BGRA_8888);
  113. +
  114. +    dst_info.fd = -1; //dph.fd;
  115. +    dst_info.mmuFlag = 1;
  116. +
  117. +    rga_set_rect(&dst_info.rect, 0, 0, frameWidth, frameHeight, frameWidth, frameHeight, RK_FORMAT_BGRA_8888);
  118. +}
  119. +
  120.  KMSDRM_FBInfo *
  121.  KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
  122.  {
  123. @@ -437,8 +473,8 @@
  124.  
  125.      SDL_zero(current_mode);
  126.  
  127. -    current_mode.w = vdata->saved_crtc->mode.hdisplay;
  128. -    current_mode.h = vdata->saved_crtc->mode.vdisplay;
  129. +    current_mode.w = data->cur_mode.vdisplay;
  130. +    current_mode.h = data->cur_mode.hdisplay;
  131.      current_mode.refresh_rate = vdata->saved_crtc->mode.vrefresh;
  132.  
  133.      /* FIXME ?
  134. @@ -553,6 +589,7 @@
  135.  {
  136.      SDL_WindowData *wdata;
  137.      SDL_VideoDisplay *display;
  138. +    SDL_DisplayData *data;
  139.      SDL_VideoData *vdata = ((SDL_VideoData *)_this->driverdata);
  140.      Uint32 surface_fmt, surface_flags;
  141.  
  142. @@ -615,6 +652,10 @@
  143.      SDL_SetKeyboardFocus(window);
  144.  
  145.      /* Window has been successfully created */
  146. +
  147. +    data = display->driverdata;
  148. +    KMSDRM_InitRotateBuffer(_this, data->cur_mode.hdisplay, data->cur_mode.vdisplay);
  149. +
  150.      return 0;
  151.  
  152.  error:
  153. @@ -661,6 +702,7 @@
  154.          }
  155.          SDL_free(data);
  156.          window->driverdata = NULL;
  157. +        c_RkRgaDeInit();
  158.      }
  159.  }
  160.  
  161. --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
  162. +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
  163. @@ -35,6 +35,10 @@
  164.  #if SDL_VIDEO_OPENGL_EGL
  165.  #include <EGL/egl.h>
  166.  #endif
  167. +#include <rga/RgaApi.h>
  168. +#include <assert.h>
  169. +
  170. +#define RGA_BUFFERS_MAX (3)
  171.  
  172.  typedef struct SDL_VideoData
  173.  {
  174. @@ -46,6 +50,10 @@
  175.      drmModeCrtc *saved_crtc;    /* Saved CRTC to restore on quit */
  176.      uint32_t saved_conn_id;     /* Saved DRM connector ID */
  177.      uint32_t crtc_id;           /* CRTC in use */
  178. +    int rotPrime_fd;            /* dest rotate prime file descriptor */
  179. +    struct gbm_bo* rga_buffers[RGA_BUFFERS_MAX];
  180. +    int rga_buffer_prime_fds[RGA_BUFFERS_MAX];
  181. +    int rga_buffer_index;
  182.  } SDL_VideoData;
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top