drm/tegra: 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 according to hardware requirements.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Thierry Reding <treding@nvidia.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
Link: https://lore.kernel.org/r/20250821081918.79786-21-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann
2025-08-21 10:17:27 +02:00
parent 42abd3e9aa
commit 6fd37c99b8

View File

@@ -16,6 +16,7 @@
#include <linux/vmalloc.h>
#include <drm/drm_drv.h>
#include <drm/drm_dumb_buffers.h>
#include <drm/drm_prime.h>
#include "drm.h"
@@ -542,12 +543,13 @@ void tegra_bo_free_object(struct drm_gem_object *gem)
int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
struct drm_mode_create_dumb *args)
{
unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
struct tegra_drm *tegra = drm->dev_private;
struct tegra_bo *bo;
int ret;
args->pitch = round_up(min_pitch, tegra->pitch_align);
args->size = args->pitch * args->height;
ret = drm_mode_size_dumb(drm, args, tegra->pitch_align, 0);
if (ret)
return ret;
bo = tegra_bo_create_with_handle(file, drm, args->size, 0,
&args->handle);