2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-14 16:23:51 +08:00

drm/exynos: use gem create function generically

this patch addes exynos_drm_gem_init() creating and initialzing a gem.
allocation functions could use this function to create new gem and
it changes size type of exynos_drm_gem_create structure to 64bit
and also corrects comments to exynos_drm_gem_create structure.

Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
This commit is contained in:
Inki Dae 2011-11-12 14:51:23 +09:00
parent b0e0f85631
commit f088d5a9c5
4 changed files with 59 additions and 41 deletions

View File

@ -165,9 +165,9 @@ exynos_drm_fb_init(struct drm_file *file_priv, struct drm_device *dev,
goto out;
} else {
exynos_gem_obj = exynos_drm_gem_create(file_priv, dev,
size,
&mode_cmd->handle);
exynos_gem_obj = exynos_drm_gem_create(dev, file_priv,
&mode_cmd->handle,
size);
if (IS_ERR(exynos_gem_obj)) {
ret = PTR_ERR(exynos_gem_obj);
goto err_buffer;

View File

@ -62,40 +62,28 @@ static unsigned int get_gem_mmap_offset(struct drm_gem_object *obj)
return (unsigned int)obj->map_list.hash.key << PAGE_SHIFT;
}
struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_file *file_priv,
struct drm_device *dev, unsigned int size,
unsigned int *handle)
static struct exynos_drm_gem_obj
*exynos_drm_gem_init(struct drm_device *drm_dev,
struct drm_file *file_priv, unsigned int *handle,
unsigned int size)
{
struct exynos_drm_gem_obj *exynos_gem_obj;
struct exynos_drm_buf_entry *entry;
struct drm_gem_object *obj;
int ret;
DRM_DEBUG_KMS("%s\n", __FILE__);
size = roundup(size, PAGE_SIZE);
exynos_gem_obj = kzalloc(sizeof(*exynos_gem_obj), GFP_KERNEL);
if (!exynos_gem_obj) {
DRM_ERROR("failed to allocate exynos gem object.\n");
return ERR_PTR(-ENOMEM);
}
/* allocate the new buffer object and memory region. */
entry = exynos_drm_buf_create(dev, size);
if (!entry) {
kfree(exynos_gem_obj);
return ERR_PTR(-ENOMEM);
}
exynos_gem_obj->entry = entry;
obj = &exynos_gem_obj->base;
ret = drm_gem_object_init(dev, obj, size);
ret = drm_gem_object_init(drm_dev, obj, size);
if (ret < 0) {
DRM_ERROR("failed to initailize gem object.\n");
goto err_obj_init;
DRM_ERROR("failed to initialize gem object.\n");
ret = -EINVAL;
goto err_object_init;
}
DRM_DEBUG_KMS("created file object = 0x%x\n", (unsigned int)obj->filp);
@ -127,24 +115,55 @@ err_handle_create:
err_create_mmap_offset:
drm_gem_object_release(obj);
err_obj_init:
exynos_drm_buf_destroy(dev, exynos_gem_obj->entry);
err_object_init:
kfree(exynos_gem_obj);
return ERR_PTR(ret);
}
struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
struct drm_file *file_priv,
unsigned int *handle, unsigned long size)
{
struct exynos_drm_gem_obj *exynos_gem_obj = NULL;
struct exynos_drm_buf_entry *entry;
int ret;
size = roundup(size, PAGE_SIZE);
DRM_DEBUG_KMS("%s: size = 0x%lx\n", __FILE__, size);
entry = exynos_drm_buf_create(dev, size);
if (!entry)
return ERR_PTR(-ENOMEM);
exynos_gem_obj = exynos_drm_gem_init(dev, file_priv, handle, size);
if (IS_ERR(exynos_gem_obj)) {
ret = PTR_ERR(exynos_gem_obj);
goto err_gem_init;
}
exynos_gem_obj->entry = entry;
return exynos_gem_obj;
err_gem_init:
exynos_drm_buf_destroy(dev, exynos_gem_obj->entry);
return ERR_PTR(ret);
}
int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
struct drm_file *file_priv)
{
struct drm_exynos_gem_create *args = data;
struct exynos_drm_gem_obj *exynos_gem_obj;
struct exynos_drm_gem_obj *exynos_gem_obj = NULL;
DRM_DEBUG_KMS("%s : size = 0x%x\n", __FILE__, args->size);
DRM_DEBUG_KMS("%s\n", __FILE__);
exynos_gem_obj = exynos_drm_gem_create(file_priv, dev, args->size,
&args->handle);
exynos_gem_obj = exynos_drm_gem_create(dev, file_priv,
&args->handle, args->size);
if (IS_ERR(exynos_gem_obj))
return PTR_ERR(exynos_gem_obj);
@ -302,8 +321,8 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
args->pitch = args->width * args->bpp >> 3;
args->size = args->pitch * args->height;
exynos_gem_obj = exynos_drm_gem_create(file_priv, dev, args->size,
&args->handle);
exynos_gem_obj = exynos_drm_gem_create(dev, file_priv, &args->handle,
args->size);
if (IS_ERR(exynos_gem_obj))
return PTR_ERR(exynos_gem_obj);

View File

@ -49,9 +49,9 @@ struct exynos_drm_gem_obj {
};
/* create a new buffer and get a new gem handle. */
struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_file *file_priv,
struct drm_device *dev, unsigned int size,
unsigned int *handle);
struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
struct drm_file *file_priv,
unsigned int *handle, unsigned long size);
/*
* request gem object creation and buffer allocation as the size

View File

@ -32,17 +32,16 @@
/**
* User-desired buffer creation information structure.
*
* @size: requested size for the object.
* @size: user-desired memory allocation size.
* - this size value would be page-aligned internally.
* @flags: user request for setting memory type or cache attributes.
* @handle: returned handle for the object.
* @pad: just padding to be 64-bit aligned.
* @handle: returned a handle to created gem object.
* - this handle will be set by gem module of kernel side.
*/
struct drm_exynos_gem_create {
unsigned int size;
uint64_t size;
unsigned int flags;
unsigned int handle;
unsigned int pad;
};
/**