summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@google.com>2017-05-08 12:50:36 -0700
committerChia-I Wu <olv@google.com>2017-05-24 08:57:00 -0700
commit5384c73453500a3f4c83cc7415269be17a4e6669 (patch)
tree2c060b72545d08313a6197de038947bccdbcca00
parent6f49e8b99b2b1b6db8dc0a1b0ffb018f30981221 (diff)
downloadhikey-5384c73453500a3f4c83cc7415269be17a4e6669.tar.gz
gralloc: make fbdev fd a shallow copy
We never free private_module_t::framebuffer once it is initialized. We can use a shallow copy of the fbdev dev. Bug: 37550237 Test: boots Change-Id: I552b40c0a59d9f4ec5442e3a284f115a88061c3e
-rw-r--r--gralloc/alloc_device.cpp6
-rw-r--r--gralloc/framebuffer_device.cpp24
-rw-r--r--gralloc/gralloc_priv.h8
3 files changed, 20 insertions, 18 deletions
diff --git a/gralloc/alloc_device.cpp b/gralloc/alloc_device.cpp
index 3ef099f2..3c4531bf 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -306,9 +306,10 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t *dev, size_t size, in
vaddr = (void *)((uintptr_t)vaddr + bufferSize);
}
+ int fbdev_fd = m->framebuffer->shallow_fbdev_fd;
// The entire framebuffer memory is already mapped, now create a buffer object for parts of this memory
private_handle_t *hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, usage, size, vaddr,
- 0, dup(m->framebuffer->fd), (uintptr_t)vaddr - (uintptr_t) m->framebuffer->base);
+ 0, fbdev_fd, (uintptr_t)vaddr - (uintptr_t) m->framebuffer->base);
#if GRALLOC_ARM_UMP_MODULE
hnd->ump_id = m->framebuffer->ump_id;
@@ -330,7 +331,7 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t *dev, size_t size, in
#ifdef FBIOGET_DMABUF
struct fb_dmabuf_export fb_dma_buf;
- if (ioctl(m->framebuffer->fd, FBIOGET_DMABUF, &fb_dma_buf) == 0)
+ if (ioctl(fbdev_fd, FBIOGET_DMABUF, &fb_dma_buf) == 0)
{
AINF("framebuffer accessed with dma buf (fd 0x%x)\n", (int)fb_dma_buf.fd);
hnd->share_fd = fb_dma_buf.fd;
@@ -518,7 +519,6 @@ static int alloc_device_free(alloc_device_t *dev, buffer_handle_t handle)
const size_t bufferSize = m->finfo.line_length * m->info.yres;
int index = ((uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base) / bufferSize;
m->bufferMask &= ~(1 << index);
- close(hnd->fd);
#if GRALLOC_ARM_UMP_MODULE
diff --git a/gralloc/framebuffer_device.cpp b/gralloc/framebuffer_device.cpp
index cfc480fa..3f74e8df 100644
--- a/gralloc/framebuffer_device.cpp
+++ b/gralloc/framebuffer_device.cpp
@@ -94,9 +94,11 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
#define S3CFB_SET_VSYNC_INT _IOW('F', 206, unsigned int)
- if (ioctl(m->framebuffer->fd, FBIOPAN_DISPLAY, &m->info) == -1)
+ int fbdev_fd = m->framebuffer->shallow_fbdev_fd;
+
+ if (ioctl(fbdev_fd, FBIOPAN_DISPLAY, &m->info) == -1)
{
- AERR("FBIOPAN_DISPLAY failed for fd: %d", m->framebuffer->fd);
+ AERR("FBIOPAN_DISPLAY failed for fd: %d", fbdev_fd);
m->base.unlock(&m->base, buffer);
return 0;
}
@@ -106,9 +108,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
// enable VSYNC
interrupt = 1;
- if (ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
+ if (ioctl(fbdev_fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
{
- // AERR("S3CFB_SET_VSYNC_INT enable failed for fd: %d", m->framebuffer->fd);
+ // AERR("S3CFB_SET_VSYNC_INT enable failed for fd: %d", fbdev_fd);
return 0;
}
@@ -118,9 +120,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
#endif
int crtc = 0;
- if (ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0)
+ if (ioctl(fbdev_fd, FBIO_WAITFORVSYNC, &crtc) < 0)
{
- AERR("FBIO_WAITFORVSYNC failed for fd: %d", m->framebuffer->fd);
+ AERR("FBIO_WAITFORVSYNC failed for fd: %d", fbdev_fd);
#ifdef MALI_VSYNC_EVENT_REPORT_ENABLE
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
#endif
@@ -133,9 +135,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
// disable VSYNC
interrupt = 0;
- if (ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
+ if (ioctl(fbdev_fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
{
- AERR("S3CFB_SET_VSYNC_INT disable failed for fd: %d", m->framebuffer->fd);
+ AERR("S3CFB_SET_VSYNC_INT disable failed for fd: %d", fbdev_fd);
return 0;
}
}
@@ -146,9 +148,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT);
#endif
- if (ioctl(m->framebuffer->fd, FBIOPUT_VSCREENINFO, &m->info) == -1)
+ if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &m->info) == -1)
{
- AERR("FBIOPUT_VSCREENINFO failed for fd: %d", m->framebuffer->fd);
+ AERR("FBIOPUT_VSCREENINFO failed for fd: %d", fbdev_fd);
#ifdef MALI_VSYNC_EVENT_REPORT_ENABLE
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
#endif
@@ -383,7 +385,7 @@ int init_frame_buffer_locked(struct private_module_t *module)
// Create a "fake" buffer object for the entire frame buffer memory, and store it in the module
module->framebuffer = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, 0, fbSize, vaddr,
- 0, dup(fd), 0);
+ 0, fd, 0);
module->numBuffers = info.yres_virtual / info.yres;
module->bufferMask = 0;
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 57977258..b931ac20 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -182,7 +182,7 @@ struct private_handle_t
#endif
// Following members is for framebuffer only
- int fd;
+ int shallow_fbdev_fd; // shallow copy, not dup'ed
int offset;
#if GRALLOC_ARM_DMA_BUF_MODULE
@@ -219,7 +219,7 @@ struct private_handle_t
yuv_info(MALI_YUV_NO_INFO),
ump_id((int)secure_id),
ump_mem_handle((int)handle),
- fd(0),
+ shallow_fbdev_fd(0),
offset(0)
#if GRALLOC_ARM_DMA_BUF_MODULE
,
@@ -253,7 +253,7 @@ struct private_handle_t
ump_id((int)UMP_INVALID_SECURE_ID),
ump_mem_handle((int)UMP_INVALID_MEMORY_HANDLE),
#endif
- fd(0),
+ shallow_fbdev_fd(0),
offset(0),
ion_hnd(ION_INVALID_HANDLE)
@@ -286,7 +286,7 @@ struct private_handle_t
ump_id((int)UMP_INVALID_SECURE_ID),
ump_mem_handle((int)UMP_INVALID_MEMORY_HANDLE),
#endif
- fd(fb_file),
+ shallow_fbdev_fd(fb_file),
offset(fb_offset)
#if GRALLOC_ARM_DMA_BUF_MODULE
,