Skip to content

Commit 6564c65

Browse files
Joonyoung Shimdaeinki
authored andcommitted
drm/exynos: add DRM_EXYNOS_GEM_MAP ioctl
The commit d931589 ("drm/exynos: remove DRM_EXYNOS_GEM_MAP_OFFSET ioctl") removed it same with the ioctl that this patch adds. The reason that removed DRM_EXYNOS_GEM_MAP_OFFSET was we could use DRM_IOCTL_MODE_MAP_DUMB. Both did exactly same thing. Now we again will revive it as DRM_EXYNOS_GEM_MAP because of render node. DRM_IOCTL_MODE_MAP_DUMB isn't permitted in render node. Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
1 parent 550e3b2 commit 6564c65

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

drivers/gpu/drm/exynos/exynos_drm_drv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
370370
static const struct drm_ioctl_desc exynos_ioctls[] = {
371371
DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
372372
DRM_AUTH | DRM_RENDER_ALLOW),
373+
DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
374+
DRM_AUTH | DRM_RENDER_ALLOW),
373375
DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
374376
DRM_RENDER_ALLOW),
375377
DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,

drivers/gpu/drm/exynos/exynos_drm_gem.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
280280
return 0;
281281
}
282282

283+
int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
284+
struct drm_file *file_priv)
285+
{
286+
struct drm_exynos_gem_map *args = data;
287+
288+
return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
289+
&args->offset);
290+
}
291+
283292
dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
284293
unsigned int gem_handle,
285294
struct drm_file *filp)

drivers/gpu/drm/exynos/exynos_drm_gem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
7171
int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
7272
struct drm_file *file_priv);
7373

74+
/* get fake-offset of gem object that can be used with mmap. */
75+
int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
76+
struct drm_file *file_priv);
77+
7478
/*
7579
* get dma address from gem handle and this function could be used for
7680
* other drivers such as 2d/3d acceleration drivers.

include/uapi/drm/exynos_drm.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ struct drm_exynos_gem_create {
3232
__u32 handle;
3333
};
3434

35+
/**
36+
* A structure for getting a fake-offset that can be used with mmap.
37+
*
38+
* @handle: handle of gem object.
39+
* @reserved: just padding to be 64-bit aligned.
40+
* @offset: a fake-offset of gem object.
41+
*/
42+
struct drm_exynos_gem_map {
43+
__u32 handle;
44+
__u32 reserved;
45+
__u64 offset;
46+
};
47+
3548
/**
3649
* A structure to gem information.
3750
*
@@ -284,6 +297,7 @@ struct drm_exynos_ipp_cmd_ctrl {
284297
};
285298

286299
#define DRM_EXYNOS_GEM_CREATE 0x00
300+
#define DRM_EXYNOS_GEM_MAP 0x01
287301
/* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
288302
#define DRM_EXYNOS_GEM_GET 0x04
289303
#define DRM_EXYNOS_VIDI_CONNECTION 0x07
@@ -301,7 +315,8 @@ struct drm_exynos_ipp_cmd_ctrl {
301315

302316
#define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \
303317
DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
304-
318+
#define DRM_IOCTL_EXYNOS_GEM_MAP DRM_IOWR(DRM_COMMAND_BASE + \
319+
DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
305320
#define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \
306321
DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info)
307322

0 commit comments

Comments
 (0)