Skip to content

Commit 7293fc1

Browse files
stefan11111metux
authored andcommitted
modesetting: map gbm bo's if possible
Signed-off-by: stefan11111 <[email protected]>
1 parent 9db422c commit 7293fc1

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

hw/xfree86/drivers/video/modesetting/drmmode_display.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,21 +1064,34 @@ drmmode_bo_get_handle(drmmode_bo *bo)
10641064
static void *
10651065
drmmode_bo_map(drmmode_ptr drmmode, drmmode_bo *bo)
10661066
{
1067-
int ret;
1067+
if (bo->map) {
1068+
return bo->map;
1069+
}
10681070

10691071
#ifdef GLAMOR_HAS_GBM
1070-
if (bo->gbm)
1071-
return NULL;
1072+
if (bo->gbm) {
1073+
/* We shouldn't read from gpu memory */
1074+
uint32_t stride;
1075+
void* unused;
1076+
void* map = gbm_bo_map(bo->gbm, 0, 0, bo->width, bo->height, GBM_BO_TRANSFER_WRITE, &stride, &unused);
1077+
if (map) {
1078+
bo->map = map;
1079+
return bo->map;
1080+
}
1081+
}
10721082
#endif
10731083

1074-
if (bo->dumb->ptr)
1075-
return bo->dumb->ptr;
1084+
if (bo->dumb) {
1085+
int ret = dumb_bo_map(drmmode->fd, bo->dumb);
1086+
if (ret) {
1087+
return NULL;
1088+
}
10761089

1077-
ret = dumb_bo_map(drmmode->fd, bo->dumb);
1078-
if (ret)
1079-
return NULL;
1090+
bo->map = bo->dumb->ptr;
1091+
return bo->map;
1092+
}
10801093

1081-
return bo->dumb->ptr;
1094+
return NULL;
10821095
}
10831096

10841097
int

hw/xfree86/drivers/video/modesetting/drmmode_display.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ typedef struct {
8585
Bool used_modifiers;
8686
struct gbm_bo *gbm;
8787
#endif
88+
void* map;
8889
} drmmode_bo;
8990

9091
typedef struct {

0 commit comments

Comments
 (0)