diff options
author | Derek Foreman <derekf@osg.samsung.com> | 2017-07-21 15:48:40 -0500 |
---|---|---|
committer | Derek Foreman <derekf@osg.samsung.com> | 2017-08-09 14:56:58 -0500 |
commit | 8ff59b2c55a58331625b6d997918e64eddc84b10 (patch) | |
tree | 85a9d9398281b1aad159517e8e9bdee2c0adc3b8 /src/lib/ecore_drm2 | |
parent | be0af0ed00148c55e1eb519444ea48201677badb (diff) |
ecore_drm2: Pass Ecore_Drm2_Device instead of fd to most functions
Intended to simplify the upcoming commit that merges device find and
device open into a single function that returns a device.
The fd is something callers shouldn't really need to get their hands on,
right now there are still a few places where it's needed, but those will
be gone soon too.
Diffstat (limited to 'src/lib/ecore_drm2')
-rw-r--r-- | src/lib/ecore_drm2/Ecore_Drm2.h | 26 | ||||
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2.c | 6 | ||||
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_device.c | 8 | ||||
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_fb.c | 34 |
4 files changed, 48 insertions, 26 deletions
diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h index 450f1faa0c..81c3ace6a8 100644 --- a/src/lib/ecore_drm2/Ecore_Drm2.h +++ b/src/lib/ecore_drm2/Ecore_Drm2.h | |||
@@ -144,7 +144,7 @@ EAPI int ecore_drm2_shutdown(void); | |||
144 | /** | 144 | /** |
145 | * Read and process pending Drm events | 145 | * Read and process pending Drm events |
146 | * | 146 | * |
147 | * @param fd drm file descriptor | 147 | * @param dev drm device |
148 | * @param ctx | 148 | * @param ctx |
149 | * | 149 | * |
150 | * @return 0 on success, -1 otherwise | 150 | * @return 0 on success, -1 otherwise |
@@ -156,7 +156,7 @@ EAPI int ecore_drm2_shutdown(void); | |||
156 | * @ingroup Ecore_Drm_Init_Group | 156 | * @ingroup Ecore_Drm_Init_Group |
157 | * @since 1.19 | 157 | * @since 1.19 |
158 | */ | 158 | */ |
159 | EAPI int ecore_drm2_event_handle(int fd, Ecore_Drm2_Context *drmctx); | 159 | EAPI int ecore_drm2_event_handle(Ecore_Drm2_Device *dev, Ecore_Drm2_Context *drmctx); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | * @defgroup Ecore_Drm2_Device_Group Drm device functions | 162 | * @defgroup Ecore_Drm2_Device_Group Drm device functions |
@@ -832,7 +832,7 @@ EAPI unsigned int ecore_drm2_output_subpixel_get(const Ecore_Drm2_Output *output | |||
832 | /** | 832 | /** |
833 | * Create a new framebuffer object | 833 | * Create a new framebuffer object |
834 | * | 834 | * |
835 | * @param fd | 835 | * @param dev |
836 | * @param width | 836 | * @param width |
837 | * @param height | 837 | * @param height |
838 | * @param depth | 838 | * @param depth |
@@ -844,9 +844,9 @@ EAPI unsigned int ecore_drm2_output_subpixel_get(const Ecore_Drm2_Output *output | |||
844 | * @ingroup Ecore_Drm2_Fb_Group | 844 | * @ingroup Ecore_Drm2_Fb_Group |
845 | * @since 1.18 | 845 | * @since 1.18 |
846 | */ | 846 | */ |
847 | EAPI Ecore_Drm2_Fb *ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned int format); | 847 | EAPI Ecore_Drm2_Fb *ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format); |
848 | 848 | ||
849 | EAPI Ecore_Drm2_Fb *ecore_drm2_fb_gbm_create(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int handle, unsigned int stride, void *bo); | 849 | EAPI Ecore_Drm2_Fb *ecore_drm2_fb_gbm_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, unsigned int handle, unsigned int stride, void *bo); |
850 | 850 | ||
851 | /** | 851 | /** |
852 | * Get a framebuffer's mmap'd data | 852 | * Get a framebuffer's mmap'd data |
@@ -971,7 +971,7 @@ EAPI void *ecore_drm2_fb_bo_get(Ecore_Drm2_Fb *fb); | |||
971 | /** | 971 | /** |
972 | * Import a dmabuf object as a Framebuffer | 972 | * Import a dmabuf object as a Framebuffer |
973 | * | 973 | * |
974 | * @param fd | 974 | * @param dev |
975 | * @param width | 975 | * @param width |
976 | * @param height | 976 | * @param height |
977 | * @param depth | 977 | * @param depth |
@@ -987,7 +987,7 @@ EAPI void *ecore_drm2_fb_bo_get(Ecore_Drm2_Fb *fb); | |||
987 | * @since 1.20 | 987 | * @since 1.20 |
988 | * | 988 | * |
989 | */ | 989 | */ |
990 | EAPI Ecore_Drm2_Fb *ecore_drm2_fb_dmabuf_import(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int dmabuf_fd_count); | 990 | EAPI Ecore_Drm2_Fb *ecore_drm2_fb_dmabuf_import(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int dmabuf_fd_count); |
991 | 991 | ||
992 | /** | 992 | /** |
993 | * Discard a framebuffer object | 993 | * Discard a framebuffer object |
@@ -1094,6 +1094,18 @@ EAPI void ecore_drm2_fb_status_handler_set(Ecore_Drm2_Fb *fb, Ecore_Drm2_Fb_Stat | |||
1094 | */ | 1094 | */ |
1095 | EAPI Eina_Bool ecore_drm2_output_blanktime_get(Ecore_Drm2_Output *output, int sequence, long *sec, long *usec); | 1095 | EAPI Eina_Bool ecore_drm2_output_blanktime_get(Ecore_Drm2_Output *output, int sequence, long *sec, long *usec); |
1096 | 1096 | ||
1097 | /** | ||
1098 | * Get the fd of an Ecore_Drm2_Device | ||
1099 | * | ||
1100 | * Query the fd of the device. | ||
1101 | * | ||
1102 | * @param device | ||
1103 | * | ||
1104 | * @since 1.20 | ||
1105 | */ | ||
1106 | |||
1107 | EAPI int ecore_drm2_device_fd_get(Ecore_Drm2_Device *device); | ||
1108 | |||
1097 | # endif | 1109 | # endif |
1098 | 1110 | ||
1099 | #endif | 1111 | #endif |
diff --git a/src/lib/ecore_drm2/ecore_drm2.c b/src/lib/ecore_drm2/ecore_drm2.c index 526ea4a523..a4ab72042d 100644 --- a/src/lib/ecore_drm2/ecore_drm2.c +++ b/src/lib/ecore_drm2/ecore_drm2.c | |||
@@ -219,16 +219,16 @@ ecore_drm2_shutdown(void) | |||
219 | } | 219 | } |
220 | 220 | ||
221 | EAPI int | 221 | EAPI int |
222 | ecore_drm2_event_handle(int fd, Ecore_Drm2_Context *drmctx) | 222 | ecore_drm2_event_handle(Ecore_Drm2_Device *dev, Ecore_Drm2_Context *drmctx) |
223 | { | 223 | { |
224 | drmEventContext ctx; | 224 | drmEventContext ctx; |
225 | 225 | ||
226 | EINA_SAFETY_ON_TRUE_RETURN_VAL((fd < 0), -1); | 226 | EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1); |
227 | 227 | ||
228 | memset(&ctx, 0, sizeof(ctx)); | 228 | memset(&ctx, 0, sizeof(ctx)); |
229 | ctx.version = 2; | 229 | ctx.version = 2; |
230 | ctx.page_flip_handler = drmctx->page_flip_handler; | 230 | ctx.page_flip_handler = drmctx->page_flip_handler; |
231 | ctx.vblank_handler = drmctx->vblank_handler; | 231 | ctx.vblank_handler = drmctx->vblank_handler; |
232 | 232 | ||
233 | return sym_drmHandleEvent(fd, &ctx); | 233 | return sym_drmHandleEvent(dev->fd, &ctx); |
234 | } | 234 | } |
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c index 3545d1a299..aa8917ce4e 100644 --- a/src/lib/ecore_drm2/ecore_drm2_device.c +++ b/src/lib/ecore_drm2/ecore_drm2_device.c | |||
@@ -885,6 +885,14 @@ ecore_drm2_device_prefer_shadow(Ecore_Drm2_Device *device) | |||
885 | return EINA_FALSE; | 885 | return EINA_FALSE; |
886 | } | 886 | } |
887 | 887 | ||
888 | EAPI int | ||
889 | ecore_drm2_device_fd_get(Ecore_Drm2_Device *device) | ||
890 | { | ||
891 | EINA_SAFETY_ON_NULL_RETURN_VAL(device, -1); | ||
892 | |||
893 | return device->fd; | ||
894 | } | ||
895 | |||
888 | /* prevent crashing with old apps compiled against these functions */ | 896 | /* prevent crashing with old apps compiled against these functions */ |
889 | EAPI void ecore_drm2_device_keyboard_cached_context_set(){}; | 897 | EAPI void ecore_drm2_device_keyboard_cached_context_set(){}; |
890 | EAPI void ecore_drm2_device_keyboard_cached_keymap_set(){}; | 898 | EAPI void ecore_drm2_device_keyboard_cached_keymap_set(){}; |
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c b/src/lib/ecore_drm2/ecore_drm2_fb.c index 3a13c3dbbb..85331aeaa2 100644 --- a/src/lib/ecore_drm2/ecore_drm2_fb.c +++ b/src/lib/ecore_drm2/ecore_drm2_fb.c | |||
@@ -16,7 +16,7 @@ _fb2_create(Ecore_Drm2_Fb *fb) | |||
16 | } | 16 | } |
17 | 17 | ||
18 | EAPI Ecore_Drm2_Fb * | 18 | EAPI Ecore_Drm2_Fb * |
19 | ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned int format) | 19 | ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format) |
20 | { | 20 | { |
21 | Ecore_Drm2_Fb *fb; | 21 | Ecore_Drm2_Fb *fb; |
22 | struct drm_mode_create_dumb carg; | 22 | struct drm_mode_create_dumb carg; |
@@ -24,12 +24,12 @@ ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned | |||
24 | struct drm_mode_map_dumb marg; | 24 | struct drm_mode_map_dumb marg; |
25 | int ret; | 25 | int ret; |
26 | 26 | ||
27 | EINA_SAFETY_ON_TRUE_RETURN_VAL((fd < 0), NULL); | 27 | EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL); |
28 | 28 | ||
29 | fb = calloc(1, sizeof(Ecore_Drm2_Fb)); | 29 | fb = calloc(1, sizeof(Ecore_Drm2_Fb)); |
30 | if (!fb) return NULL; | 30 | if (!fb) return NULL; |
31 | 31 | ||
32 | fb->fd = fd; | 32 | fb->fd = dev->fd; |
33 | fb->w = width; | 33 | fb->w = width; |
34 | fb->h = height; | 34 | fb->h = height; |
35 | fb->bpp = bpp; | 35 | fb->bpp = bpp; |
@@ -42,7 +42,7 @@ ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned | |||
42 | carg.width = width; | 42 | carg.width = width; |
43 | carg.height = height; | 43 | carg.height = height; |
44 | 44 | ||
45 | ret = sym_drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &carg); | 45 | ret = sym_drmIoctl(dev->fd, DRM_IOCTL_MODE_CREATE_DUMB, &carg); |
46 | if (ret) goto err; | 46 | if (ret) goto err; |
47 | 47 | ||
48 | fb->handles[0] = carg.handle; | 48 | fb->handles[0] = carg.handle; |
@@ -52,7 +52,7 @@ ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned | |||
52 | if (!_fb2_create(fb)) | 52 | if (!_fb2_create(fb)) |
53 | { | 53 | { |
54 | ret = | 54 | ret = |
55 | sym_drmModeAddFB(fd, width, height, depth, bpp, | 55 | sym_drmModeAddFB(dev->fd, width, height, depth, bpp, |
56 | fb->strides[0], fb->handles[0], &fb->id); | 56 | fb->strides[0], fb->handles[0], &fb->id); |
57 | if (ret) | 57 | if (ret) |
58 | { | 58 | { |
@@ -63,14 +63,14 @@ ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned | |||
63 | 63 | ||
64 | memset(&marg, 0, sizeof(struct drm_mode_map_dumb)); | 64 | memset(&marg, 0, sizeof(struct drm_mode_map_dumb)); |
65 | marg.handle = fb->handles[0]; | 65 | marg.handle = fb->handles[0]; |
66 | ret = sym_drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &marg); | 66 | ret = sym_drmIoctl(dev->fd, DRM_IOCTL_MODE_MAP_DUMB, &marg); |
67 | if (ret) | 67 | if (ret) |
68 | { | 68 | { |
69 | ERR("Could not map framebuffer: %m"); | 69 | ERR("Could not map framebuffer: %m"); |
70 | goto map_err; | 70 | goto map_err; |
71 | } | 71 | } |
72 | 72 | ||
73 | fb->mmap = mmap(NULL, fb->sizes[0], PROT_WRITE, MAP_SHARED, fd, marg.offset); | 73 | fb->mmap = mmap(NULL, fb->sizes[0], PROT_WRITE, MAP_SHARED, dev->fd, marg.offset); |
74 | if (fb->mmap == MAP_FAILED) | 74 | if (fb->mmap == MAP_FAILED) |
75 | { | 75 | { |
76 | ERR("Could not mmap framebuffer memory: %m"); | 76 | ERR("Could not mmap framebuffer memory: %m"); |
@@ -80,22 +80,22 @@ ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned | |||
80 | return fb; | 80 | return fb; |
81 | 81 | ||
82 | map_err: | 82 | map_err: |
83 | sym_drmModeRmFB(fd, fb->id); | 83 | sym_drmModeRmFB(dev->fd, fb->id); |
84 | add_err: | 84 | add_err: |
85 | memset(&darg, 0, sizeof(struct drm_mode_destroy_dumb)); | 85 | memset(&darg, 0, sizeof(struct drm_mode_destroy_dumb)); |
86 | darg.handle = fb->handles[0]; | 86 | darg.handle = fb->handles[0]; |
87 | sym_drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &darg); | 87 | sym_drmIoctl(dev->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &darg); |
88 | err: | 88 | err: |
89 | free(fb); | 89 | free(fb); |
90 | return NULL; | 90 | return NULL; |
91 | } | 91 | } |
92 | 92 | ||
93 | EAPI Ecore_Drm2_Fb * | 93 | EAPI Ecore_Drm2_Fb * |
94 | ecore_drm2_fb_gbm_create(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int handle, unsigned int stride, void *bo) | 94 | ecore_drm2_fb_gbm_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, unsigned int handle, unsigned int stride, void *bo) |
95 | { | 95 | { |
96 | Ecore_Drm2_Fb *fb; | 96 | Ecore_Drm2_Fb *fb; |
97 | 97 | ||
98 | EINA_SAFETY_ON_TRUE_RETURN_VAL((fd < 0), NULL); | 98 | EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL); |
99 | 99 | ||
100 | fb = calloc(1, sizeof(Ecore_Drm2_Fb)); | 100 | fb = calloc(1, sizeof(Ecore_Drm2_Fb)); |
101 | if (!fb) return NULL; | 101 | if (!fb) return NULL; |
@@ -103,7 +103,7 @@ ecore_drm2_fb_gbm_create(int fd, int width, int height, int depth, int bpp, unsi | |||
103 | fb->gbm = EINA_TRUE; | 103 | fb->gbm = EINA_TRUE; |
104 | fb->gbm_bo = bo; | 104 | fb->gbm_bo = bo; |
105 | 105 | ||
106 | fb->fd = fd; | 106 | fb->fd = dev->fd; |
107 | fb->w = width; | 107 | fb->w = width; |
108 | fb->h = height; | 108 | fb->h = height; |
109 | fb->bpp = bpp; | 109 | fb->bpp = bpp; |
@@ -116,7 +116,7 @@ ecore_drm2_fb_gbm_create(int fd, int width, int height, int depth, int bpp, unsi | |||
116 | 116 | ||
117 | if (!_fb2_create(fb)) | 117 | if (!_fb2_create(fb)) |
118 | { | 118 | { |
119 | if (sym_drmModeAddFB(fd, width, height, depth, bpp, | 119 | if (sym_drmModeAddFB(dev->fd, width, height, depth, bpp, |
120 | fb->strides[0], fb->handles[0], &fb->id)) | 120 | fb->strides[0], fb->handles[0], &fb->id)) |
121 | { | 121 | { |
122 | ERR("Could not add framebuffer: %m"); | 122 | ERR("Could not add framebuffer: %m"); |
@@ -664,20 +664,22 @@ ecore_drm2_fb_bo_get(Ecore_Drm2_Fb *fb) | |||
664 | } | 664 | } |
665 | 665 | ||
666 | EAPI Ecore_Drm2_Fb * | 666 | EAPI Ecore_Drm2_Fb * |
667 | ecore_drm2_fb_dmabuf_import(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int dmabuf_fd_count) | 667 | ecore_drm2_fb_dmabuf_import(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int dmabuf_fd_count) |
668 | { | 668 | { |
669 | int i; | 669 | int i; |
670 | Ecore_Drm2_Fb *fb; | 670 | Ecore_Drm2_Fb *fb; |
671 | 671 | ||
672 | EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL); | ||
673 | |||
672 | fb = calloc(1, sizeof(Ecore_Drm2_Fb)); | 674 | fb = calloc(1, sizeof(Ecore_Drm2_Fb)); |
673 | if (!fb) return NULL; | 675 | if (!fb) return NULL; |
674 | 676 | ||
675 | for (i = 0; i < dmabuf_fd_count; i++) | 677 | for (i = 0; i < dmabuf_fd_count; i++) |
676 | if (sym_drmPrimeFDToHandle(fd, dmabuf_fd[i], &fb->handles[i])) | 678 | if (sym_drmPrimeFDToHandle(dev->fd, dmabuf_fd[i], &fb->handles[i])) |
677 | goto fail; | 679 | goto fail; |
678 | 680 | ||
679 | fb->dmabuf = EINA_TRUE; | 681 | fb->dmabuf = EINA_TRUE; |
680 | fb->fd = fd; | 682 | fb->fd = dev->fd; |
681 | fb->w = width; | 683 | fb->w = width; |
682 | fb->h = height; | 684 | fb->h = height; |
683 | fb->bpp = bpp; | 685 | fb->bpp = bpp; |