summaryrefslogtreecommitdiff
authorSky Zhou <sky.zhou@amlogic.com>2017-03-29 02:47:19 (GMT)
committer sky zhou <sky.zhou@amlogic.com>2017-04-07 00:20:49 (GMT)
commit385859aa81aaf6d7f86fc63d69aaa3d7c3016344 (patch)
treea1074182122025a2f31a91fa12830bc2c1255d14
parent1eb1ef91a2f2c63620c6bca10cb574b7df976bc3 (diff)
downloadgralloc-385859aa81aaf6d7f86fc63d69aaa3d7c3016344.zip
gralloc-385859aa81aaf6d7f86fc63d69aaa3d7c3016344.tar.gz
gralloc-385859aa81aaf6d7f86fc63d69aaa3d7c3016344.tar.bz2
PD #140904: update framebuffer api to support post operation without buffer to osd.[1/2]
Change-Id: Ia0f6ffb9a1c916daf3658a0100e63437d08fc475
Diffstat
-rw-r--r--alloc_ion.cpp.rej159
-rw-r--r--framebuffer.cpp80
-rw-r--r--framebuffer.h4
3 files changed, 45 insertions, 198 deletions
diff --git a/alloc_ion.cpp.rej b/alloc_ion.cpp.rej
deleted file mode 100644
index 670c13e..0000000
--- a/alloc_ion.cpp.rej
+++ b/dev/null
@@ -1,159 +0,0 @@
---- alloc_ion.cpp
-+++ alloc_ion.cpp
-@@ -35,19 +35,70 @@
- #include <linux/ion.h>
- #include <ion/ion.h>
-
--int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle)
-+
-+static ion_user_handle_t alloc_from_ion_heap(int ion_fd, size_t size, unsigned int heap_mask,
-+ unsigned int flags, int *min_pgsz)
- {
-- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
-- ion_user_handle_t ion_hnd;
-- unsigned char *cpu_ptr = NULL;
-- int shared_fd;
-+ ion_user_handle_t ion_hnd = ION_INVALID_HANDLE;
- int ret;
-+
-+ if ((ion_fd < 0) || (size <= 0) || (heap_mask == 0) || (min_pgsz == NULL))
-+ return ION_INVALID_HANDLE;
-+
-+ ret = ion_alloc(ion_fd, size, 0, heap_mask, flags, &ion_hnd);
-+ if (ret != 0)
-+ {
-+ /* If everything else failed try system heap */
-+ flags = 0; /* Fallback option flags are not longer valid */
-+ ion_alloc(ion_fd, size, 0, ION_HEAP_SYSTEM_MASK, flags, &ion_hnd);
-+ }
-+
-+ if (ion_hnd > ION_INVALID_HANDLE)
-+ {
-+ switch (heap_mask)
-+ {
-+ case ION_HEAP_SYSTEM_MASK:
-+ *min_pgsz = SZ_4K;
-+ break;
-+ case ION_HEAP_SYSTEM_CONTIG_MASK:
-+ case ION_HEAP_CARVEOUT_MASK:
-+#ifdef ION_HEAP_TYPE_DMA_MASK
-+ case ION_HEAP_TYPE_DMA_MASK:
-+#endif
-+ *min_pgsz = size;
-+ break;
-+#ifdef ION_HEAP_CHUNK_MASK
-+ /* NOTE: if have this heap make sure your ION chunk size is 2M*/
-+ case ION_HEAP_CHUNK_MASK:
-+ *min_pgsz = SZ_2M;
-+ break;
-+#endif
-+#ifdef ION_HEAP_COMPOUND_PAGE_MASK
-+ case ION_HEAP_COMPOUND_PAGE_MASK:
-+ *min_pgsz = SZ_2M;
-+ break;
-+#endif
-+ /* If have customized heap please set the suitable pg type according to
-+ * the customized ION implementation
-+ */
-+#ifdef ION_HEAP_CUSTOM_MASK
-+ case ION_HEAP_CUSTOM_MASK:
-+ *min_pgsz = SZ_4K;
-+ break;
-+#endif
-+ default:
-+ *min_pgsz = SZ_4K;
-+ break;
-+ }
-+ }
-+
-+ return ion_hnd;
-+}
-+
-+unsigned int pick_ion_heap(int usage)
-+{
- unsigned int heap_mask;
-- int ion_flags = 0;
-- static int support_protected = 1; /* initially, assume we support protected memory */
-- int lock_state = 0;
-
-- /* Select heap type based on usage hints */
- if(usage & GRALLOC_USAGE_PROTECTED)
- {
- #if defined(ION_HEAP_SECURE_MASK)
-@@ -57,20 +108,71 @@
- return -1;
- #endif
- }
-+#if defined(ION_HEAP_TYPE_COMPOUND_PAGE_MASK) && GRALLOC_USE_ION_COMPOUND_PAGE_HEAP
-+ else if(usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER))
-+ {
-+ heap_mask = ION_HEAP_TYPE_COMPOUND_PAGE_MASK;
-+ }
-+#elif defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
-+ else if(usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER))
-+ {
-+ heap_mask = ION_HEAP_TYPE_DMA_MASK;
-+ }
-+#endif
- else
- {
- heap_mask = ION_HEAP_SYSTEM_MASK;
- }
-
-- if ( (usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN )
-+ return heap_mask;
-+}
-+
-+void set_ion_flags(unsigned int heap_mask, int usage, unsigned int *priv_heap_flag, int *ion_flags)
-+{
-+ if (priv_heap_flag)
-+ {
-+#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
-+ if (heap_mask == ION_HEAP_TYPE_DMA_MASK)
-+ {
-+ *priv_heap_flag = private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP;
-+ }
-+#endif
-+ }
-+
-+ if (ion_flags)
- {
-- ion_flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
-+#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
-+ if(heap_mask != ION_HEAP_TYPE_DMA_MASK)
-+ {
-+#endif
-+ if ( (usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN )
-+ {
-+ *ion_flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
-+ }
-+#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
-+ }
-+#endif
- }
-+}
-+
-+int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle)
-+{
-+ private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
-+ ion_user_handle_t ion_hnd;
-+ unsigned char *cpu_ptr = NULL;
-+ int shared_fd;
-+ int ret;
-+ unsigned int heap_mask, priv_heap_flag = 0;
-+ int ion_flags = 0;
-+ static int support_protected = 1; /* initially, assume we support protected memory */
-+ int lock_state = 0;
-+ int min_pgsz = 0;
-
-- ret = ion_alloc(m->ion_client, size, 0, heap_mask,
-- ion_flags, &ion_hnd );
-+ heap_mask = pick_ion_heap(usage);
-+ set_ion_flags(heap_mask, usage, &priv_heap_flag, &ion_flags);
-
-- if ( ret != 0)
-+ ion_hnd = alloc_from_ion_heap(m->ion_client, size, heap_mask, ion_flags, &min_pgsz);
-+ if (ion_hnd <= ION_INVALID_HANDLE)
- {
- AERR("Failed to ion_alloc from ion_client:%d", m->ion_client);
- return -1;
diff --git a/framebuffer.cpp b/framebuffer.cpp
index 4562936..7928ae8 100644
--- a/framebuffer.cpp
+++ b/framebuffer.cpp
@@ -535,45 +535,48 @@ int hwc_fb_post_with_fence_locked(
struct hwc_fb_sync_request_t* sync_req,
buffer_handle_t hnd)
{
-#define FBIOPUT_OSD_SYNC_RENDER_ADD 0x4519
- private_handle_t const* buffer = reinterpret_cast<private_handle_t const*>(hnd);
-
+ #define FBIOPUT_OSD_SYNC_RENDER_ADD 0x4519
sync_req->shared_fd = -1;
- switch (sync_req->type) {
- case GLES_COMPOSE_MODE:
- sync_req->xoffset = fbinfo->info.xoffset;
- sync_req->yoffset = buffer->offset / fbinfo->finfo.line_length;
- ALOGD( "GLES, req offset: %d",
- sync_req->yoffset);
- break;
- case DIRECT_COMPOSE_MODE:
- sync_req->format = buffer->format;
- sync_req->shared_fd = buffer->share_fd;
- sync_req->byte_stride = buffer->byte_stride;
- sync_req->stride = buffer->stride;
- ALOGD( "Direct, src: (%d, %d, %d, %d), dst: (%d, %d, %d, %d)",
- sync_req->xoffset,
- sync_req->yoffset,
- sync_req->width,
- sync_req->height,
- sync_req->dst_x,
- sync_req->dst_y,
- sync_req->dst_w,
- sync_req->dst_h);
- break;
- case GE2D_COMPOSE_MODE:
- sync_req->width = fbinfo->info.xres;
- sync_req->height = fbinfo->info.yres;
- sync_req->format = HAL_PIXEL_FORMAT_RGBA_8888;
- sync_req->yoffset = fbinfo->yOffset;
- sync_req->shared_fd = buffer->share_fd;
- ALOGD( "GE2D, width: %d, height: %d",
- sync_req->width,
- sync_req->height);
- break;
- default:
- ALOGE("unknown compose mode!!!");
- break;
+
+ if (hnd) {
+ private_handle_t const* buffer = reinterpret_cast<private_handle_t const*>(hnd);
+ switch (sync_req->type) {
+ case GLES_COMPOSE_MODE:
+ sync_req->xoffset = fbinfo->info.xoffset;
+ sync_req->yoffset = buffer->offset / fbinfo->finfo.line_length;
+ ALOGD( "GLES, req offset: %d",sync_req->yoffset);
+ break;
+ case DIRECT_COMPOSE_MODE:
+ sync_req->format = buffer->format;
+ sync_req->shared_fd = buffer->share_fd;
+ sync_req->byte_stride = buffer->byte_stride;
+ sync_req->stride = buffer->stride;
+ ALOGD( "Direct, src: (%d, %d, %d, %d), dst: (%d, %d, %d, %d)",
+ sync_req->xoffset,
+ sync_req->yoffset,
+ sync_req->width,
+ sync_req->height,
+ sync_req->dst_x,
+ sync_req->dst_y,
+ sync_req->dst_w,
+ sync_req->dst_h);
+ break;
+ case GE2D_COMPOSE_MODE:
+ sync_req->width = fbinfo->info.xres;
+ sync_req->height = fbinfo->info.yres;
+ sync_req->format = HAL_PIXEL_FORMAT_RGBA_8888;
+ sync_req->yoffset = fbinfo->yOffset;
+ sync_req->shared_fd = buffer->share_fd;
+ ALOGD( "GE2D, width: %d, height: %d",
+ sync_req->width,
+ sync_req->height);
+ break;
+ default:
+ ALOGE("unknown compose mode!!!");
+ break;
+ }
+ } else {
+ ALOGD("FB post blank without buffer.");
}
ALOGD( "format: %d, shared_fd: %d, op: 0x%x, byte_stride: %d, pixel_stride: %d",
sync_req->format,
@@ -582,7 +585,6 @@ int hwc_fb_post_with_fence_locked(
sync_req->byte_stride,
sync_req->stride);
ioctl(fbinfo->fd, FBIOPUT_OSD_SYNC_RENDER_ADD, sync_req);
-
return sync_req->out_fen_fd;
}
diff --git a/framebuffer.h b/framebuffer.h
index 4155351..a2dbe59 100644
--- a/framebuffer.h
+++ b/framebuffer.h
@@ -12,6 +12,10 @@ enum {
GE2D_COMPOSE_MODE = 2,
};
+enum {
+ OSD_BLANK_OP_BIT = 0x00000001,
+};
+
typedef struct framebuffer_info_t{
// gralloc module.
private_module_t *grallocModule;