History

drm/vc4: bo: Split out Dumb buffers fixup

The vc4_bo_dumb_create() both fixes up the allocation arguments to match the hardware constraints and actually performs the allocation. Since we're going to introduce a new function that uses a different allocator, let's split the arguments fixup to a separate function we will be able to reuse.

Maxime Ripard committed 4 years ago

Commit 3d763741 parent dd2dfd43 files · +17 −6Browse files

Unified · Split

3 files
  1. drivers/gpu/drm/vc4/vc4_bo.c +3 −6
  2. drivers/gpu/drm/vc4/vc4_drv.c +13 −0
  3. drivers/gpu/drm/vc4/vc4_drv.h +1 −0
drivers/gpu/drm/vc4/vc4_bo.c+3−6
@@ -475,15 +475,12 @@ int vc4_bo_dumb_create(struct drm_file *file_priv, · 474 unmodified lines
475 struct drm_device *dev,475 struct drm_device *dev,
476 struct drm_mode_create_dumb *args)476 struct drm_mode_create_dumb *args)
477{477{
478 int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
479 struct vc4_bo *bo = NULL;478 struct vc4_bo *bo = NULL;
480 int ret;479 int ret;
481 480
482 if (args->pitch < min_pitch)481 ret = vc4_dumb_fixup_args(args);
483 args->pitch = min_pitch;482 if (ret)
484 483 return ret;
485 if (args->size < args->pitch * args->height)
486 args->size = args->pitch * args->height;
487 484
488 bo = vc4_bo_create(dev, args->size, false, VC4_BO_TYPE_DUMB);485 bo = vc4_bo_create(dev, args->size, false, VC4_BO_TYPE_DUMB);
489 if (IS_ERR(bo))486 if (IS_ERR(bo))
drivers/gpu/drm/vc4/vc4_drv.c+13−0
@@ -63,6 +63,19 @@ void __iomem *vc4_ioremap_regs(struct platform_device *pdev, int index) · 62 unmodified lines
63 return map;63 return map;
64}64}
65 65
66int vc4_dumb_fixup_args(struct drm_mode_create_dumb *args)
67{
68 int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
69
70 if (args->pitch < min_pitch)
71 args->pitch = min_pitch;
72
73 if (args->size < args->pitch * args->height)
74 args->size = args->pitch * args->height;
75
76 return 0;
77}
78
66static int vc4_get_param_ioctl(struct drm_device *dev, void *data,79static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
67 struct drm_file *file_priv)80 struct drm_file *file_priv)
68{81{
drivers/gpu/drm/vc4/vc4_drv.h+1−0
@@ -885,6 +885,7 @@ static inline void vc4_debugfs_add_regset32(struct drm_device *drm, · 884 unmodified lines
885 885
886/* vc4_drv.c */886/* vc4_drv.c */
887void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);887void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
888int vc4_dumb_fixup_args(struct drm_mode_create_dumb *args);
888 889
889/* vc4_dpi.c */890/* vc4_dpi.c */
890extern struct platform_driver vc4_dpi_driver;891extern struct platform_driver vc4_dpi_driver;