summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm2/ecore_drm2_fb.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-07-21 15:48:40 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-08-09 14:56:58 -0500
commit8ff59b2c55a58331625b6d997918e64eddc84b10 (patch)
tree85a9d9398281b1aad159517e8e9bdee2c0adc3b8 /src/lib/ecore_drm2/ecore_drm2_fb.c
parentbe0af0ed00148c55e1eb519444ea48201677badb (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 '')
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_fb.c34
1 files changed, 18 insertions, 16 deletions
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
18EAPI Ecore_Drm2_Fb * 18EAPI Ecore_Drm2_Fb *
19ecore_drm2_fb_create(int fd, int width, int height, int depth, int bpp, unsigned int format) 19ecore_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
82map_err: 82map_err:
83 sym_drmModeRmFB(fd, fb->id); 83 sym_drmModeRmFB(dev->fd, fb->id);
84add_err: 84add_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);
88err: 88err:
89 free(fb); 89 free(fb);
90 return NULL; 90 return NULL;
91} 91}
92 92
93EAPI Ecore_Drm2_Fb * 93EAPI Ecore_Drm2_Fb *
94ecore_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) 94ecore_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
666EAPI Ecore_Drm2_Fb * 666EAPI Ecore_Drm2_Fb *
667ecore_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) 667ecore_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;