mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drm/gem-shmem: Compute dumb-buffer sizes with drm_mode_size_dumb()
Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and buffer size. Align the pitch to a multiple of 8. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Link: https://lore.kernel.org/r/20250821081918.79786-5-tzimmermann@suse.de
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <drm/drm.h>
|
||||
#include <drm/drm_device.h>
|
||||
#include <drm/drm_drv.h>
|
||||
#include <drm/drm_dumb_buffers.h>
|
||||
#include <drm/drm_gem_shmem_helper.h>
|
||||
#include <drm/drm_prime.h>
|
||||
#include <drm/drm_print.h>
|
||||
@@ -556,18 +557,11 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_purge_locked);
|
||||
int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
|
||||
struct drm_mode_create_dumb *args)
|
||||
{
|
||||
u32 min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
|
||||
int ret;
|
||||
|
||||
if (!args->pitch || !args->size) {
|
||||
args->pitch = min_pitch;
|
||||
args->size = PAGE_ALIGN(args->pitch * args->height);
|
||||
} else {
|
||||
/* ensure sane minimum values */
|
||||
if (args->pitch < min_pitch)
|
||||
args->pitch = min_pitch;
|
||||
if (args->size < args->pitch * args->height)
|
||||
args->size = PAGE_ALIGN(args->pitch * args->height);
|
||||
}
|
||||
ret = drm_mode_size_dumb(dev, args, SZ_8, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return drm_gem_shmem_create_with_handle(file, dev, args->size, &args->handle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user