copybit: call blit ioctl before freeing intermediate buffer
Pass in buffer handle before it is freed to prevent blit operation
from failing while importing buffer.
Change-Id: I4a944e7b2c0f6e19b55ed5602eda49d14d5e78f0
diff --git a/libcopybit/copybit.cpp b/libcopybit/copybit.cpp
index 23b336c..c945665 100644
--- a/libcopybit/copybit.cpp
+++ b/libcopybit/copybit.cpp
@@ -516,12 +516,24 @@
list->count = 0;
}
}
+ if(yv12_handle) {
+ //Before freeing the buffer we need buffer passed through blit call
+ if (list->count != 0) {
+ status = msm_copybit(ctx, list);
+ if (ctx->relFence != -1) {
+ ctx->sync.acq_fen_fd_cnt = 1;
+ ctx->sync.acq_fen_fd[0] = ctx->relFence;
+ } else {
+ ctx->sync.acq_fen_fd_cnt = 0;
+ }
+ list->count = 0;
+ }
+ free_buffer(yv12_handle);
+ }
} else {
ALOGE ("%s : Invalid COPYBIT context", __FUNCTION__);
status = -EINVAL;
}
- if(yv12_handle)
- free_buffer(yv12_handle);
return status;
}
@@ -567,9 +579,9 @@
if (ret < 0)
ALOGE("%s: Blit call failed", __FUNCTION__);
list->count = 0;
- ctx->sync.acq_fen_fd_cnt = 0;
}
*fd = ctx->relFence;
+ ctx->sync.acq_fen_fd_cnt = 0;
ctx->relFence = -1;
return ret;
}