[PATCH v4] DRM: add drm gem CMA helper
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Jun 27 06:47:47 PDT 2012
Hi Sascha,
Thanks for the patch.
Just one small comment below.
On Wednesday 27 June 2012 15:30:18 Sascha Hauer wrote:
[snip]
> +/*
> + * drm_gem_cma_dumb_create - (struct drm_driver)->dumb_create callback
> + * function
> + *
> + * This aligns the pitch and size arguments to the minimum required. wrap
> + * this into your own function if you need bigger alignment.
> + */
> +int drm_gem_cma_dumb_create(struct drm_file *file_priv,
> + struct drm_device *dev, struct drm_mode_create_dumb *args)
> +{
> + struct drm_gem_cma_object *cma_obj;
> + int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
> +
> + if (args->pitch < min_pitch)
> + args->pitch = min_pitch;
args->pitch is unsigned, so I would make min_pitch an unsigned int.
> +
> + if (args->size < args->pitch * args->height)
> + args->size = args->pitch * args->height;
> +
> + cma_obj = drm_gem_cma_create_with_handle(file_priv, dev,
> + args->size, &args->handle);
> + if (IS_ERR(cma_obj))
> + return PTR_ERR(cma_obj);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create);
--
Regards,
Laurent Pinchart
More information about the dri-devel
mailing list