From 9af084283aa8dc29581ffc469123af3f41132f77 Mon Sep 17 00:00:00 2001 From: Andrew Sutherland Date: Sun, 3 Jun 2012 14:26:37 -0500 Subject: [PATCH] Revert "Revert "Revert "libgenlock: add support for genlock_write_to_read locking semantics""" This reverts commit 5e6e965be7c0564eb5c4f35a9c829ef76c87be1a. --- libgenlock/genlock.cpp | 44 ++++-------------------------------------- libgenlock/genlock.h | 9 --------- 2 files changed, 4 insertions(+), 49 deletions(-) diff --git a/libgenlock/genlock.cpp b/libgenlock/genlock.cpp index 6400994..429b467 100644 --- a/libgenlock/genlock.cpp +++ b/libgenlock/genlock.cpp @@ -62,7 +62,7 @@ namespace { /* Internal function to perform the actual lock/unlock operations */ genlock_status_t perform_lock_unlock_operation(native_handle_t *buffer_handle, - int lockType, int timeout, int flags) + int lockType, int timeout) { if (private_handle_t::validate(buffer_handle)) { LOGE("%s: handle is invalid", __FUNCTION__); @@ -79,21 +79,10 @@ namespace { genlock_lock lock; lock.op = lockType; - lock.flags = flags; + lock.flags = 0; lock.timeout = timeout; lock.fd = hnd->genlockHandle; -#ifdef GENLOCK_IOC_DREADLOCK - if (ioctl(hnd->genlockPrivFd, GENLOCK_IOC_DREADLOCK, &lock)) { - LOGE("%s: GENLOCK_IOC_DREADLOCK failed (lockType0x%x, err=%s fd=%d)", __FUNCTION__, - lockType, strerror(errno), hnd->fd); - if (ETIMEDOUT == errno) - return GENLOCK_TIMEDOUT; - - return GENLOCK_FAILURE; - } -#else - // depreciated if (ioctl(hnd->genlockPrivFd, GENLOCK_IOC_LOCK, &lock)) { LOGE("%s: GENLOCK_IOC_LOCK failed (lockType0x%x, err=%s fd=%d)", __FUNCTION__, lockType, strerror(errno), hnd->fd); @@ -102,7 +91,6 @@ namespace { return GENLOCK_FAILURE; } -#endif } return GENLOCK_NO_ERROR; } @@ -281,7 +269,7 @@ genlock_status_t genlock_lock_buffer(native_handle_t *buffer_handle, LOGW("%s: trying to lock a buffer with timeout = 0", __FUNCTION__); } // Call the private function to perform the lock operation specified. - ret = perform_lock_unlock_operation(buffer_handle, kLockType, timeout, 0); + ret = perform_lock_unlock_operation(buffer_handle, kLockType, timeout); #endif return ret; } @@ -299,7 +287,7 @@ genlock_status_t genlock_unlock_buffer(native_handle_t *buffer_handle) #ifdef USE_GENLOCK // Do the unlock operation by setting the unlock flag. Timeout is always // 0 in this case. - ret = perform_lock_unlock_operation(buffer_handle, GENLOCK_UNLOCK, 0, 0); + ret = perform_lock_unlock_operation(buffer_handle, GENLOCK_UNLOCK, 0); #endif return ret; } @@ -339,27 +327,3 @@ genlock_status_t genlock_wait(native_handle_t *buffer_handle, int timeout) { #endif return GENLOCK_NO_ERROR; } - -/* - * Convert a write lock that we own to a read lock - * - * @param: handle of the buffer - * @param: timeout value for the wait. - * return: error status. - */ -genlock_status_t genlock_write_to_read(native_handle_t *buffer_handle, int timeout) { - genlock_status_t ret = GENLOCK_NO_ERROR; -#ifdef USE_GENLOCK - if (0 == timeout) { - LOGW("%s: trying to lock a buffer with timeout = 0", __FUNCTION__); - } - // Call the private function to perform the lock operation specified. -#ifdef GENLOCK_IOC_DREADLOCK - ret = perform_lock_unlock_operation(buffer_handle, GENLOCK_RDLOCK, timeout, GENLOCK_WRITE_TO_READ); -#else - // depreciated - ret = perform_lock_unlock_operation(buffer_handle, GENLOCK_RDLOCK, timeout, 0); -#endif -#endif - return ret; -} diff --git a/libgenlock/genlock.h b/libgenlock/genlock.h index d8bb1d9..b394410 100644 --- a/libgenlock/genlock.h +++ b/libgenlock/genlock.h @@ -111,15 +111,6 @@ genlock_status_t genlock_unlock_buffer(native_handle_t *buffer_handle); */ genlock_status_t genlock_wait(native_handle_t *buffer_handle, int timeout); -/* - * Convert a write lock that we own to a read lock - * - * @param: handle of the buffer - * @param: timeout value for the wait. - * return: error status. - */ -genlock_status_t genlock_write_to_read(native_handle_t *buffer_handle, int timeout); - #ifdef __cplusplus } #endif