summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2022-07-17 10:42:40 -0400
committerManuel Stoeckl <code@mstoeckl.com>2022-07-17 10:42:40 -0400
commit6f4e6f5d21419aa83887de56911984128a4b19f8 (patch)
treed439ec41518c4a224d2c9dc4bb6dea52b6c5ec65
parent024e33686542b75db328de8ddfdcc92d1795f241 (diff)
Remove unused path from make_dmabuf
-rw-r--r--src/dmabuf.c27
-rw-r--r--src/dmabuf.h7
-rw-r--r--src/shadow.c9
-rw-r--r--test/fd_mirror.c4
-rw-r--r--test/protocol_control.c2
5 files changed, 14 insertions, 35 deletions
diff --git a/src/dmabuf.c b/src/dmabuf.c
index f51fcd1..57957fd 100644
--- a/src/dmabuf.c
+++ b/src/dmabuf.c
@@ -155,7 +155,7 @@ void cleanup_render_data(struct render_data *data)
static bool dmabuf_info_valid(const struct dmabuf_slice_data *info)
{
if (info->height > (1u << 24) || info->width > (1u << 24) ||
- info->num_planes > 4) {
+ info->num_planes > 4 || info->num_planes == 0) {
wp_error("Invalid DMABUF slice data: height " PRIu32
" width " PRIu32 " num_planes " PRIu32,
info->height, info->width, info->num_planes);
@@ -180,11 +180,6 @@ struct gbm_bo *import_dmabuf(struct render_data *rd, int fd, size_t *size,
data.modifier = info->modifier;
data.num_fds = 0;
uint32_t simple_format = 0;
- if (info->num_planes > 4) {
- wp_error("Failed to import dmabuf: too many planes (%d)",
- info->num_planes);
- return NULL;
- }
for (int i = 0; i < info->num_planes; i++) {
if (info->using_planes[i]) {
@@ -239,28 +234,16 @@ int get_unique_dmabuf_handle(
return handle;
}
-struct gbm_bo *make_dmabuf(struct render_data *rd, size_t size,
- const struct dmabuf_slice_data *info)
+struct gbm_bo *make_dmabuf(
+ struct render_data *rd, const struct dmabuf_slice_data *info)
{
struct gbm_bo *bo;
- if (info && !dmabuf_info_valid(info)) {
+ if (!dmabuf_info_valid(info)) {
return NULL;
}
retry:
- if (!info || info->num_planes == 0) {
- uint32_t width = 512;
- uint32_t height =
- (uint32_t)(size + 4 * width - 1) / (4 * width);
- uint32_t format = GBM_FORMAT_XRGB8888;
- /* Set modifiers to linear, the most likely/portable format */
- bo = gbm_bo_create(rd->dev, width, height, format,
- GBM_BO_USE_LINEAR | GBM_BO_USE_RENDERING);
- if (!bo) {
- wp_error("Failed to make dmabuf: %s", strerror(errno));
- return NULL;
- }
- } else if (!rd->supports_modifiers ||
+ if (!rd->supports_modifiers ||
info->modifier == DRM_FORMAT_MOD_INVALID) {
uint32_t simple_format = dmabuf_get_simple_format_for_plane(
info->format, 0);
diff --git a/src/dmabuf.h b/src/dmabuf.h
index c5f8f7a..6050701 100644
--- a/src/dmabuf.h
+++ b/src/dmabuf.h
@@ -70,11 +70,10 @@ static_assert(sizeof(struct dmabuf_slice_data) == 64, "size check");
int init_render_data(struct render_data *);
void cleanup_render_data(struct render_data *);
-struct gbm_bo *make_dmabuf(struct render_data *rd, size_t size,
- const struct dmabuf_slice_data *info);
+struct gbm_bo *make_dmabuf(
+ struct render_data *rd, const struct dmabuf_slice_data *info);
int export_dmabuf(struct gbm_bo *bo);
-/** Import DMABUF to a GBM buffer object; if `read_modifier` is true, then
- * the `info->modifier` will be overwritten with whatever the modifier is */
+/** Import DMABUF to a GBM buffer object. */
struct gbm_bo *import_dmabuf(struct render_data *rd, int fd, size_t *size,
const struct dmabuf_slice_data *info);
void destroy_dmabuf(struct gbm_bo *bo);
diff --git a/src/shadow.c b/src/shadow.c
index cf326d2..7afd01f 100644
--- a/src/shadow.c
+++ b/src/shadow.c
@@ -1572,8 +1572,7 @@ int apply_update(struct fd_translation_map *map, struct thread_pool *threads,
return 0;
}
- sfd->dmabuf_bo = make_dmabuf(
- render, sfd->buffer_size, &sfd->dmabuf_info);
+ sfd->dmabuf_bo = make_dmabuf(render, &sfd->dmabuf_info);
if (!sfd->dmabuf_bo) {
sfd->fd_local = -1;
return 0;
@@ -1635,8 +1634,7 @@ int apply_update(struct fd_translation_map *map, struct thread_pool *threads,
sfd->fd_local = -1;
return 0;
}
- sfd->dmabuf_bo = make_dmabuf(
- render, sfd->buffer_size, &sfd->dmabuf_info);
+ sfd->dmabuf_bo = make_dmabuf(render, &sfd->dmabuf_info);
if (!sfd->dmabuf_bo) {
wp_error("FDC_DMAVID_IW: RID=%d make_dmabuf failure, sz=%d (%d)",
sfd->remote_id, (int)sfd->buffer_size,
@@ -1706,8 +1704,7 @@ int apply_update(struct fd_translation_map *map, struct thread_pool *threads,
return 0;
}
- sfd->dmabuf_bo = make_dmabuf(
- render, sfd->buffer_size, &sfd->dmabuf_info);
+ sfd->dmabuf_bo = make_dmabuf(render, &sfd->dmabuf_info);
if (!sfd->dmabuf_bo) {
wp_error("FDC_DMAVID_IR: RID=%d make_dmabuf failure",
sfd->remote_id);
diff --git a/test/fd_mirror.c b/test/fd_mirror.c
index cd4a4a1..4acd55a 100644
--- a/test/fd_mirror.c
+++ b/test/fd_mirror.c
@@ -453,8 +453,8 @@ int main(int argc, char **argv)
all_success &= pass;
if (has_dmabuf) {
- struct gbm_bo *bo = make_dmabuf(rd,
- test_size, &slice_data);
+ struct gbm_bo *bo = make_dmabuf(
+ rd, &slice_data);
if (!bo) {
has_dmabuf = false;
continue;
diff --git a/test/protocol_control.c b/test/protocol_control.c
index 991b22f..ff7616a 100644
--- a/test/protocol_control.c
+++ b/test/protocol_control.c
@@ -382,7 +382,7 @@ static int create_dmabuf(void)
if (init_render_data(&rd) == -1) {
return -1;
}
- struct gbm_bo *bo = make_dmabuf(&rd, test_size, &slice_data);
+ struct gbm_bo *bo = make_dmabuf(&rd, &slice_data);
if (!bo) {
goto end;
}