summaryrefslogtreecommitdiffstats
path: root/src/newt/native/drm_gbm_legacy.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-07 08:33:48 +0100
committerSven Gothel <[email protected]>2019-12-07 08:33:48 +0100
commit6f750711fbcdf746451995e71165bbd119694269 (patch)
treec6f24d7d497650bce021a74f16851492ae1c813c /src/newt/native/drm_gbm_legacy.c
parentb992423477ea1a76fb28946e28959a3feea97680 (diff)
Bug 1156: DRM/GBM NEWT: Clarify drmModeSetCrtc(..)'s x/y parameter and earmark spanning across monitors
drmModeSetCrtc(..)'s x/y parameter are the surface's offset to be scanned out from one CRT!
Diffstat (limited to 'src/newt/native/drm_gbm_legacy.c')
-rw-r--r--src/newt/native/drm_gbm_legacy.c81
1 files changed, 31 insertions, 50 deletions
diff --git a/src/newt/native/drm_gbm_legacy.c b/src/newt/native/drm_gbm_legacy.c
index cec3297a8..9c4e19dc3 100644
--- a/src/newt/native/drm_gbm_legacy.c
+++ b/src/newt/native/drm_gbm_legacy.c
@@ -43,7 +43,6 @@ gbm_bo_get_offset(struct gbm_bo *bo, int plane);
typedef struct {
struct gbm_bo *bo;
uint32_t fb_id;
- uint32_t x, y;
} DRM_FB;
static void page_flip_handler(int fd, unsigned int frame,
@@ -180,11 +179,12 @@ static DRM_FB * drm_fb_get_from_bo(int drmFd, struct gbm_bo *bo)
}
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_FirstSwapSurface0
- (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id, jint jx, jint jy,
- jint jconnector_id, jobject jmode, jint jmode_byte_offset,
- jlong jgbmSurface, jint swapInterval)
+ (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id, jint jsurfaceOffsetX, jint jsurfaceOffsetY,
+ jint jconnector_id, jobject jmode, jint jmode_byte_offset, jlong jgbmSurface)
{
- uint32_t crtc_id = (uint32_t)jcrtc_id;
+ const uint32_t crtc_id = (uint32_t)jcrtc_id;
+ const uint32_t surfaceOffsetX = (uint32_t)jsurfaceOffsetX;
+ const uint32_t surfaceOffsetY = (uint32_t)jsurfaceOffsetY;
uint32_t connector_id = (uint32_t)jconnector_id;
drmModeModeInfo *drmMode = NULL;
struct gbm_surface *gbmSurface = (struct gbm_surface *) (intptr_t) jgbmSurface;
@@ -202,23 +202,34 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_FirstSwapSu
ERR_PRINT("Failed to get a new framebuffer BO (0)\n");
return 0;
}
- fb->x = (uint32_t)jx;
- fb->y = (uint32_t)jy;
/**
* Set Mode
*
* Fails with x/y != 0: -28 No space left on device
* drmModeSetCrtc.0 failed to set mode: fd 26, crtc_id 0x27, fb_id 0x54, pos 10/10, conn_id 0x4d, curMode 1920x1080: -28 No space left on device
+ *
+ * See https://lists.freedesktop.org/archives/dri-devel/2014-February/053826.html:
+ *
+ * - The X,Y in drmModeSetCrtc does in fact specify the "source" offset into
+ * your framebuffer (not the destination on the CRTC) which is what I was looking for.
+ *
+ * - We were able to allocate both a Dumb buffer, and a GBM buffer the size of
+ * 6 1920x1200 monitors in a 1x6 configuration, so basically we didn't have
+ * any memory issues with a single buffer that big.
+ *
+ * - drmModeSetCrtc worked with both Dumb and GBM buffers, and we didn't have
+ * to do anything special on our end, so it clearly is handling the tiling
+ * issues behind the scenes (woot).
*/
- ret = drmModeSetCrtc(drmFd, crtc_id, fb->fb_id, fb->x, fb->y,
+ ret = drmModeSetCrtc(drmFd, crtc_id, fb->fb_id, surfaceOffsetX, surfaceOffsetY,
&connector_id, 1, drmMode);
if (ret) {
- ERR_PRINT("drmModeSetCrtc.0 failed to set mode: fd %d, crtc_id 0x%x, fb_id 0x%x, pos %d/%d, conn_id 0x%x, curMode %s: %d %s\n",
- drmFd, crtc_id, fb->fb_id, jx, jy, connector_id, drmMode->name, ret, strerror(errno));
+ ERR_PRINT("drmModeSetCrtc.0 failed to set mode: fd %d, crtc_id 0x%x, fb_id 0x%x (offset %d/%d), conn_id 0x%x, curMode %s: %d %s\n",
+ drmFd, crtc_id, fb->fb_id, surfaceOffsetX, surfaceOffsetY, connector_id, drmMode->name, ret, strerror(errno));
return 0;
}
- DBG_PRINT( "EGL_GBM.Window FirstSwapSurface0 swapInterval %d, nextBO %p, fd %d, crtc_id 0x%x, fb_id 0x%x, pos %d/%d, conn_id 0x%x, curMode %s\n",
- swapInterval, nextBO, drmFd, crtc_id, fb->fb_id, jx, jy, connector_id, drmMode->name);
+ DBG_PRINT( "EGL_GBM.Window FirstSwapSurface0 nextBO %p, fd %d, crtc_id 0x%x, fb_id 0x%x (offset %d/%d), conn_id 0x%x, curMode %s\n",
+ nextBO, drmFd, crtc_id, fb->fb_id, surfaceOffsetX, surfaceOffsetY, connector_id, drmMode->name);
return (jlong) (intptr_t) nextBO;
}
@@ -227,17 +238,16 @@ static int nextSwapVerboseOnce = 1;
#endif
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSurface0
- (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id, jint jx, jint jy,
+ (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id,
jint jconnector_id, jobject jmode, jint jmode_byte_offset,
jlong jgbmSurface, jlong jlastBO, jint swapInterval)
{
- uint32_t crtc_id = (uint32_t)jcrtc_id;
- uint32_t x = (uint32_t)jx;
- uint32_t y = (uint32_t)jy;
- uint32_t connector_id = (uint32_t)jconnector_id;
+ const uint32_t crtc_id = (uint32_t)jcrtc_id;
+ const uint32_t connector_id = (uint32_t)jconnector_id;
drmModeModeInfo *drmMode = NULL;
struct gbm_surface *gbmSurface = (struct gbm_surface *) (intptr_t) jgbmSurface;
- struct gbm_bo *lastBO = (struct gbm_bo*) (intptr_t) jlastBO, *nextBO = NULL;
+ struct gbm_bo *lastBO = (struct gbm_bo*) (intptr_t) jlastBO;
+ struct gbm_bo *nextBO = NULL;
DRM_FB *fbNext = NULL;
int ret, waiting_for_flip = 1;
fd_set fds;
@@ -252,30 +262,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSur
ERR_PRINT("Failed to get a new framebuffer BO (1)\n");
return 0;
}
-#if 0
- if( fbNext->x != x || fbNext->y != y ) {
- // position changed, hard drmModeSetCrtc(..) w/o vsync
- fbNext->x = x;
- fbNext->y = y;
-
- /**
- * Set Mode
- *
- * Fails with x/y != 0: -28 No space left on device
- * drmModeSetCrtc.0 failed to set mode: fd 26, crtc_id 0x27, fb_id 0x54, pos 10/10, conn_id 0x4d, curMode 1920x1080: -28 No space left on device
- */
- ret = drmModeSetCrtc(drmFd, crtc_id, fbNext->fb_id, fbNext->x, fbNext->y,
- &connector_id, 1, drmMode);
-
- if (ret) {
- ERR_PRINT("drmModeSetCrtc.1 failed to set mode: fd %d, crtc_id 0x%x, fb_id 0x%x, pos %d/%d, conn_id 0x%x, curMode %s: %d %s\n",
- drmFd, crtc_id, fbNext->fb_id, jx, jy, connector_id, drmMode->name, ret, strerror(errno));
- return 0;
- }
- } else
-#endif
if( 0 != swapInterval) {
- // same position, use vsync
+ // https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset-vsync.c#L614
ret = drmModePageFlip(drmFd, crtc_id, fbNext->fb_id,
DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip);
if (ret) {
@@ -286,9 +274,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSur
while (waiting_for_flip) {
FD_ZERO(&fds);
-#if 0
- FD_SET(0, &fds); // STDIN_FILENO: We don't want to listen to
-#endif
FD_SET(drmFd, &fds);
ret = select(drmFd + 1, &fds, NULL, NULL, NULL);
@@ -298,10 +283,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSur
} else if (ret == 0) {
ERR_PRINT("drm.select: select timeout!\n");
return -1;
-#if 0
- } else if (FD_ISSET(0, &fds)) {
- DBG_PRINT("drm.select: stdin carriage return pressed!\n");
-#endif
}
drmHandleEvent(drmFd, &drm_event_ctx);
}
@@ -315,8 +296,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSur
#ifdef VERBOSE_ON
if( nextSwapVerboseOnce ) {
nextSwapVerboseOnce = 0;
- DBG_PRINT( "EGL_GBM.Window NextSwapSurface0 swapInterval %d, bo %p -> %p, fd %d, crtc_id 0x%x, fb_id 0x%x, pos %d/%d, conn_id 0x%x, curMode %s\n",
- swapInterval, lastBO, nextBO, drmFd, crtc_id, fbNext->fb_id, jx, jy, connector_id, drmMode->name);
+ DBG_PRINT( "EGL_GBM.Window NextSwapSurface0 swapInterval %d, bo %p -> %p, fd %d, crtc_id 0x%x, fb_id 0x%x, conn_id 0x%x, curMode %s\n",
+ swapInterval, lastBO, nextBO, drmFd, crtc_id, fbNext->fb_id, connector_id, drmMode->name);
}
#endif
return (jlong) (intptr_t) nextBO;