aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorInki Dae <inki.dae@samsung.com>2011-11-12 00:51:23 -0500
committerInki Dae <inki.dae@samsung.com>2011-11-15 00:58:46 -0500
commitf088d5a9c5dd22b6559fa3f3939973bc374c977b (patch)
tree5824150df0e92bb21a7e171e3bdcc26f7303d2a2 /drivers/gpu/drm
parentb0e0f85631f9d905095d2896a952430f5eb0aba1 (diff)
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>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fb.c6
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.c79
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.h6
3 files changed, 55 insertions, 36 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 7d91a542c756..8d0f66224045 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -165,9 +165,9 @@ exynos_drm_fb_init(struct drm_file *file_priv, struct drm_device *dev,
165 165
166 goto out; 166 goto out;
167 } else { 167 } else {
168 exynos_gem_obj = exynos_drm_gem_create(file_priv, dev, 168 exynos_gem_obj = exynos_drm_gem_create(dev, file_priv,
169 size, 169 &mode_cmd->handle,
170 &mode_cmd->handle); 170 size);
171 if (IS_ERR(exynos_gem_obj)) { 171 if (IS_ERR(exynos_gem_obj)) {
172 ret = PTR_ERR(exynos_gem_obj); 172 ret = PTR_ERR(exynos_gem_obj);
173 goto err_buffer; 173 goto err_buffer;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index a8e7a88906ed..bd6ede83b684 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -62,40 +62,28 @@ static unsigned int get_gem_mmap_offset(struct drm_gem_object *obj)
62 return (unsigned int)obj->map_list.hash.key << PAGE_SHIFT; 62 return (unsigned int)obj->map_list.hash.key << PAGE_SHIFT;
63} 63}
64 64
65struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_file *file_priv, 65static struct exynos_drm_gem_obj
66 struct drm_device *dev, unsigned int size, 66 *exynos_drm_gem_init(struct drm_device *drm_dev,
67 unsigned int *handle) 67 struct drm_file *file_priv, unsigned int *handle,
68 unsigned int size)
68{ 69{
69 struct exynos_drm_gem_obj *exynos_gem_obj; 70 struct exynos_drm_gem_obj *exynos_gem_obj;
70 struct exynos_drm_buf_entry *entry;
71 struct drm_gem_object *obj; 71 struct drm_gem_object *obj;
72 int ret; 72 int ret;
73 73
74 DRM_DEBUG_KMS("%s\n", __FILE__);
75
76 size = roundup(size, PAGE_SIZE);
77
78 exynos_gem_obj = kzalloc(sizeof(*exynos_gem_obj), GFP_KERNEL); 74 exynos_gem_obj = kzalloc(sizeof(*exynos_gem_obj), GFP_KERNEL);
79 if (!exynos_gem_obj) { 75 if (!exynos_gem_obj) {
80 DRM_ERROR("failed to allocate exynos gem object.\n"); 76 DRM_ERROR("failed to allocate exynos gem object.\n");
81 return ERR_PTR(-ENOMEM); 77 return ERR_PTR(-ENOMEM);
82 } 78 }
83 79
84 /* allocate the new buffer object and memory region. */
85 entry = exynos_drm_buf_create(dev, size);
86 if (!entry) {
87 kfree(exynos_gem_obj);
88 return ERR_PTR(-ENOMEM);
89 }
90
91 exynos_gem_obj->entry = entry;
92
93 obj = &exynos_gem_obj->base; 80 obj = &exynos_gem_obj->base;
94 81
95 ret = drm_gem_object_init(dev, obj, size); 82 ret = drm_gem_object_init(drm_dev, obj, size);
96 if (ret < 0) { 83 if (ret < 0) {
97 DRM_ERROR("failed to initailize gem object.\n"); 84 DRM_ERROR("failed to initialize gem object.\n");
98 goto err_obj_init; 85 ret = -EINVAL;
86 goto err_object_init;
99 } 87 }
100 88
101 DRM_DEBUG_KMS("created file object = 0x%x\n", (unsigned int)obj->filp); 89 DRM_DEBUG_KMS("created file object = 0x%x\n", (unsigned int)obj->filp);
@@ -127,24 +115,55 @@ err_handle_create:
127err_create_mmap_offset: 115err_create_mmap_offset:
128 drm_gem_object_release(obj); 116 drm_gem_object_release(obj);
129 117
130err_obj_init: 118err_object_init:
131 exynos_drm_buf_destroy(dev, exynos_gem_obj->entry);
132
133 kfree(exynos_gem_obj); 119 kfree(exynos_gem_obj);
134 120
135 return ERR_PTR(ret); 121 return ERR_PTR(ret);
136} 122}
137 123
124struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
125 struct drm_file *file_priv,
126 unsigned int *handle, unsigned long size)
127{
128
129 struct exynos_drm_gem_obj *exynos_gem_obj = NULL;
130 struct exynos_drm_buf_entry *entry;
131 int ret;
132
133 size = roundup(size, PAGE_SIZE);
134
135 DRM_DEBUG_KMS("%s: size = 0x%lx\n", __FILE__, size);
136
137 entry = exynos_drm_buf_create(dev, size);
138 if (!entry)
139 return ERR_PTR(-ENOMEM);
140
141 exynos_gem_obj = exynos_drm_gem_init(dev, file_priv, handle, size);
142 if (IS_ERR(exynos_gem_obj)) {
143 ret = PTR_ERR(exynos_gem_obj);
144 goto err_gem_init;
145 }
146
147 exynos_gem_obj->entry = entry;
148
149 return exynos_gem_obj;
150
151err_gem_init:
152 exynos_drm_buf_destroy(dev, exynos_gem_obj->entry);
153
154 return ERR_PTR(ret);
155}
156
138int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data, 157int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
139 struct drm_file *file_priv) 158 struct drm_file *file_priv)
140{ 159{
141 struct drm_exynos_gem_create *args = data; 160 struct drm_exynos_gem_create *args = data;
142 struct exynos_drm_gem_obj *exynos_gem_obj; 161 struct exynos_drm_gem_obj *exynos_gem_obj = NULL;
143 162
144 DRM_DEBUG_KMS("%s : size = 0x%x\n", __FILE__, args->size); 163 DRM_DEBUG_KMS("%s\n", __FILE__);
145 164
146 exynos_gem_obj = exynos_drm_gem_create(file_priv, dev, args->size, 165 exynos_gem_obj = exynos_drm_gem_create(dev, file_priv,
147 &args->handle); 166 &args->handle, args->size);
148 if (IS_ERR(exynos_gem_obj)) 167 if (IS_ERR(exynos_gem_obj))
149 return PTR_ERR(exynos_gem_obj); 168 return PTR_ERR(exynos_gem_obj);
150 169
@@ -302,8 +321,8 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
302 args->pitch = args->width * args->bpp >> 3; 321 args->pitch = args->width * args->bpp >> 3;
303 args->size = args->pitch * args->height; 322 args->size = args->pitch * args->height;
304 323
305 exynos_gem_obj = exynos_drm_gem_create(file_priv, dev, args->size, 324 exynos_gem_obj = exynos_drm_gem_create(dev, file_priv, &args->handle,
306 &args->handle); 325 args->size);
307 if (IS_ERR(exynos_gem_obj)) 326 if (IS_ERR(exynos_gem_obj))
308 return PTR_ERR(exynos_gem_obj); 327 return PTR_ERR(exynos_gem_obj);
309 328
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
index e5fc0148277b..213838d9606e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
@@ -49,9 +49,9 @@ struct exynos_drm_gem_obj {
49}; 49};
50 50
51/* create a new buffer and get a new gem handle. */ 51/* create a new buffer and get a new gem handle. */
52struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_file *file_priv, 52struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
53 struct drm_device *dev, unsigned int size, 53 struct drm_file *file_priv,
54 unsigned int *handle); 54 unsigned int *handle, unsigned long size);
55 55
56/* 56/*
57 * request gem object creation and buffer allocation as the size 57 * request gem object creation and buffer allocation as the size