diff options
| author | elektroschmock <elektroschmock78@googlemail.com> | 2019-05-20 07:24:30 +0200 |
|---|---|---|
| committer | Elektroschmock <elektroschmock78@googlemail.com> | 2019-05-20 19:00:42 +0200 |
| commit | 8b15f435226e1e78be0860c01a110ac721a5c7c3 (patch) | |
| tree | f832ed59ca9a7ef719455b6e79b879f01fe800b1 | |
| parent | 039906aba4aab1650f55189234a22a047e412274 (diff) | |
shamu: camera: Remove tests
Change-Id: Ia3868ca68efd3a79d35416c0fc41a478dc5949ec
26 files changed, 0 insertions, 17618 deletions
diff --git a/camera/QCamera2/Android.mk b/camera/QCamera2/Android.mk index f53a8a8c..61391c7d 100644 --- a/camera/QCamera2/Android.mk +++ b/camera/QCamera2/Android.mk @@ -94,6 +94,4 @@ LOCAL_MODULE_TAGS := optional LOCAL_32_BIT_ONLY := true include $(BUILD_SHARED_LIBRARY) -include $(LOCAL_PATH)/HAL/test/Android.mk - include $(call first-makefiles-under,$(LOCAL_PATH)) diff --git a/camera/QCamera2/HAL/test/Android.mk b/camera/QCamera2/HAL/test/Android.mk deleted file mode 100644 index c503de8a..00000000 --- a/camera/QCamera2/HAL/test/Android.mk +++ /dev/null @@ -1,44 +0,0 @@ -ifneq (,$(findstring $(PLATFORM_VERSION), 4.4 4.4.1 4.4.2)) -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := qcamera_test.cpp - -LOCAL_SHARED_LIBRARIES := \ - libdl \ - libui \ - libutils \ - libcutils \ - libbinder \ - libmedia \ - libui \ - libgui \ - libcamera_client \ - libskia \ - libstagefright \ - libstagefright_foundation - -LOCAL_C_INCLUDES += \ - frameworks/base/include/ui \ - frameworks/base/include/surfaceflinger \ - frameworks/base/include/camera \ - frameworks/base/include/media \ - external/skia/include/core \ - external/skia/include/images \ - $(call project-path-for,qcom-display)/libgralloc \ - frameworks/av/include/media/stagefright \ - frameworks/native/include/media/openmax - -LOCAL_MODULE := camera_test -LOCAL_MODULE_TAGS := tests - -LOCAL_CFLAGS += \ - -Wall \ - -fno-short-enums \ - -O0 - -LOCAL_32_BIT_ONLY := true -include $(BUILD_EXECUTABLE) - -endif diff --git a/camera/QCamera2/HAL/test/qcamera_test.cpp b/camera/QCamera2/HAL/test/qcamera_test.cpp deleted file mode 100644 index 733b697f..00000000 --- a/camera/QCamera2/HAL/test/qcamera_test.cpp +++ /dev/null @@ -1,3477 +0,0 @@ -/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <time.h> -#include <semaphore.h> -#include <pthread.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/wait.h> - -#include <ui/DisplayInfo.h> -#include <gui/Surface.h> -#include <gui/SurfaceComposerClient.h> -#include <gui/ISurfaceComposer.h> - -#include <system/camera.h> - -#include <camera/Camera.h> -#include <camera/CameraParameters.h> -#include <media/mediarecorder.h> - -#include <utils/RefBase.h> -#include <utils/Mutex.h> -#include <utils/Condition.h> -#include <binder/IPCThreadState.h> -#include <binder/ProcessState.h> -#include <binder/IServiceManager.h> -#include <cutils/properties.h> -#include <cutils/memory.h> -#include <SkImageDecoder.h> -#include <SkImageEncoder.h> -#include <MediaCodec.h> -#include <OMX_IVCommon.h> -#include <foundation/AMessage.h> -#include <media/ICrypto.h> -#include <MediaMuxer.h> -#include <foundation/ABuffer.h> -#include <MediaErrors.h> -#include <gralloc_priv.h> -#include <math.h> - -#include "qcamera_test.h" - -#define ERROR(format, ...) printf( \ - "%s[%d] : ERROR: "format"\n", __func__, __LINE__, ##__VA_ARGS__) -#define VIDEO_BUF_ALLIGN(size, allign) (((size) + (allign-1)) & (~(allign-1))) - -namespace qcamera { - -using namespace android; - -int CameraContext::JpegIdx = 0; -int CameraContext::mPiPIdx = 0; -SkBitmap *CameraContext::skBMtmp[2]; -sp<IMemory> CameraContext::PiPPtrTmp[2]; - -/*=========================================================================== - * FUNCTION : previewCallback - * - * DESCRIPTION: preview callback preview mesages are enabled - * - * PARAMETERS : - * @mem : preview buffer - * - * RETURN : None - *==========================================================================*/ -void CameraContext::previewCallback(const sp<IMemory>& mem) -{ - printf("PREVIEW Callback 0x%x", ( unsigned int ) mem->pointer()); - uint8_t *ptr = (uint8_t*) mem->pointer(); - printf("PRV_CB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", - ptr[0], - ptr[1], - ptr[2], - ptr[3], - ptr[4], - ptr[5], - ptr[6], - ptr[7], - ptr[8], - ptr[9]); -} - -/*=========================================================================== - * FUNCTION : useLock - * - * DESCRIPTION: Mutex lock for CameraContext - * - * PARAMETERS : none - * - * RETURN : none - *==========================================================================*/ -void CameraContext::useLock() -{ - Mutex::Autolock l(mLock); - if ( mInUse ) { - mCond.wait(mLock); - } else { - mInUse = true; - } -} - -/*=========================================================================== - * FUNCTION : signalFinished - * - * DESCRIPTION: Mutex unlock CameraContext - * - * PARAMETERS : none - * - * RETURN : none - *==========================================================================*/ -void CameraContext::signalFinished() -{ - Mutex::Autolock l(mLock); - mInUse = false; - mCond.signal(); -} - -/*=========================================================================== - * FUNCTION : mutexLock - * - * DESCRIPTION: Mutex lock for ViV Video - * - * PARAMETERS : none - * - * RETURN : none - *==========================================================================*/ -void CameraContext::mutexLock() -{ - Mutex::Autolock l(mViVLock); - if (mViVinUse ) { - mViVCond.wait(mViVLock); - } else { - mViVinUse = true; - } -} - -/*=========================================================================== - * FUNCTION : mutexUnLock - * - * DESCRIPTION: Mutex unlock for ViV Video - * - * PARAMETERS : none - * - * RETURN : none - *==========================================================================*/ -void CameraContext::mutexUnlock() -{ - Mutex::Autolock l(mViVLock); - mViVinUse = false; - mViVCond.signal(); -} - - - -/*=========================================================================== - * FUNCTION : saveFile - * - * DESCRIPTION: helper function for saving buffers on filesystem - * - * PARAMETERS : - * @mem : buffer to save to filesystem - * @path: File path - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::saveFile(const sp<IMemory>& mem, String8 path) -{ - unsigned char *buff = NULL; - int size; - int fd = -1; - - if (mem == NULL) { - return BAD_VALUE; - } - - fd = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0655); - if(fd < 0) { - printf("Unable to open file %s %s\n", path.string(), strerror(fd)); - return -errno; - } - - size = mem->size(); - if (size <= 0) { - printf("IMemory object is of zero size\n"); - close(fd); - return BAD_VALUE; - } - - buff = (unsigned char *)mem->pointer(); - if (!buff) { - printf("Buffer pointer is invalid\n"); - close(fd); - return BAD_VALUE; - } - - if ( size != write(fd, buff, size) ) { - printf("Bad Write error (%d)%s\n", - errno, - strerror(errno)); - close(fd); - return INVALID_OPERATION; - } - - printf("%s: buffer=%08X, size=%d stored at %s\n", - __FUNCTION__, (int)buff, size, path.string()); - - if (fd >= 0) - close(fd); - - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : PiPCopyToOneFile - * - * DESCRIPTION: Copy the smaller picture to the bigger one - * - * PARAMETERS : - * @bitmap0 : Decoded image buffer 0 - * @bitmap1 : Decoded image buffer 1 - * - * RETURN : decoded picture in picture in SkBitmap - *==========================================================================*/ -SkBitmap * CameraContext::PiPCopyToOneFile( - SkBitmap *bitmap0, SkBitmap *bitmap1) -{ - int size0; - int size1; - SkBitmap *src; - SkBitmap *dst; - unsigned int dstOffset; - unsigned int srcOffset; - - if (bitmap0 == NULL && bitmap1 == NULL) { - return NULL; - } - - size0 = bitmap0->getSize(); - if (size0 <= 0) { - printf("Decoded image 0 is of zero size\n"); - return NULL; - } - - size1 = bitmap1->getSize(); - if (size1 <= 0) { - printf("Decoded image 1 is of zero size\n"); - return NULL; - } - - if (size0 > size1) { - dst = bitmap0; - src = bitmap1; - } else if (size1 > size0){ - dst = bitmap1; - src = bitmap0; - } else { - printf("Picture size should be with different size!\n"); - return NULL; - } - - for(int i=0; i<src->height(); i++) { - dstOffset = i*(dst->width())*mfmtMultiplier; - srcOffset = i*(src->width())*mfmtMultiplier; - memcpy(((unsigned char *) dst->getPixels())+dstOffset, - ((unsigned char *) src->getPixels())+srcOffset, - src->width()*mfmtMultiplier); - } - - return dst; -} - -/*=========================================================================== - * FUNCTION : decodeJPEG - * - * DESCRIPTION: decode jpeg input buffer. - * - * PARAMETERS : - * @mem : buffer to decode - * - * RETURN : decoded picture in SkBitmap - - *==========================================================================*/ -SkBitmap *CameraContext::decodeJPEG(const sp<IMemory>& mem) -{ - SkBitmap *skBM; - skBM = new SkBitmap; //Deleted in encodeJPEG (skBMtmp[0] and skBMtmp[1]) - SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config; - const void *buff = NULL; - int size; - - buff = (const void *)mem->pointer(); - size= mem->size(); - - switch(prefConfig) { - case SkBitmap::kARGB_8888_Config: - { - mfmtMultiplier = 4; - } - break; - - case SkBitmap::kARGB_4444_Config: - { - mfmtMultiplier = 2; - } - break; - - case SkBitmap::kRGB_565_Config: - { - mfmtMultiplier = 2; - } - break; - - case SkBitmap::kIndex8_Config: - { - mfmtMultiplier = 4; - } - break; - - case SkBitmap::kA8_Config: - { - mfmtMultiplier = 4; - } - break; - - default: - { - mfmtMultiplier = 0; - printf("Decode format is not correct!\n"); - } - break; - } - - if (SkImageDecoder::DecodeMemory(buff, size, skBM, prefConfig, - SkImageDecoder::kDecodePixels_Mode) == false) { - printf("%s():%d:: Failed during jpeg decode\n",__FUNCTION__,__LINE__); - return NULL; - } - - return skBM; -} - -/*=========================================================================== - * FUNCTION : encodeJPEG - * - * DESCRIPTION: encode the decoded input buffer. - * - * PARAMETERS : - * @stream : SkWStream - * @bitmap : SkBitmap decoded image to encode - * @path : File path - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - - *==========================================================================*/ -status_t CameraContext::encodeJPEG(SkWStream * stream, - const SkBitmap *bitmap, String8 path) -{ - int qFactor = 100; - long len; - status_t ret; - unsigned char *buff; - unsigned char temp; - - skJpegEnc = SkImageEncoder::Create(SkImageEncoder::kJPEG_Type); - - if (skJpegEnc->encodeStream(stream, *bitmap, qFactor) == false) { - return BAD_VALUE; - } - printf("%s: buffer=%08X, size=%d stored at %s\n", - __FUNCTION__, (int)bitmap->getPixels(), - bitmap->getSize(), path.string()); - delete skBMtmp[0]; - delete skBMtmp[1]; - - FILE *fh = fopen(path.string(), "r+"); - if ( !fh ) { - printf("Could not open file %s\n", path.string()); - return BAD_VALUE; - } - - fseek(fh, 0, SEEK_END); - len = ftell(fh); - rewind(fh); - - if( !len ) { - printf("File %s is empty !\n", path.string()); - fclose(fh); - return BAD_VALUE; - } - - buff = (unsigned char*)malloc(len); - if (!buff) { - printf("Cannot allocate memory for buffer reading!\n"); - return BAD_VALUE; - } - - ret = fread(buff, 1, len, fh); - if (ret != len) { - printf("Reading error\n"); - return BAD_VALUE; - } - - ret = ReadSectionsFromBuffer(buff, len, READ_ALL); - if (ret != NO_ERROR) { - printf("Cannot read sections from buffer\n"); - DiscardData(); - DiscardSections(); - return BAD_VALUE; - } - free(buff); - rewind(fh); - - temp = 0xff; - ret = fwrite(&temp, sizeof(unsigned char), 1, fh); - if (ret != 1) { - printf("Writing error\n"); - } - temp = 0xd8; - fwrite(&temp, sizeof(unsigned char), 1, fh); - - for (int i=0; i<mSectionsRead; i++) { - switch((mSections[i].Type)) { - - case 0x123: - fwrite(mSections[i].Data, sizeof(unsigned char), - mSections[i].Size, fh); - break; - - case 0xe0: - temp = 0xff; - fwrite(&temp, sizeof(unsigned char), 1, fh); - temp = 0xe1; - fwrite(&temp, sizeof(unsigned char), 1, fh); - fwrite(mJEXIFSection.Data, sizeof(unsigned char), - mJEXIFSection.Size, fh); - break; - - default: - temp = 0xff; - fwrite(&temp, sizeof(unsigned char), 1, fh); - fwrite(&mSections[i].Type, sizeof(unsigned char), 1, fh); - fwrite(mSections[i].Data, sizeof(unsigned char), - mSections[i].Size, fh); - break; - } - } - free(mJEXIFSection.Data); - DiscardData(); - DiscardSections(); - fclose(fh); - - ret = NO_ERROR; - - return ret; -} - -/*=========================================================================== - * FUNCTION : readSectionsFromBuffer - * - * DESCRIPTION: read all jpeg sections of input buffer. - * - * PARAMETERS : - * @mem : buffer to read from Metadata Sections - * @buffer_size: buffer size - * @ReadMode: Read mode - all, jpeg or exif - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::ReadSectionsFromBuffer (unsigned char *buffer, - unsigned int buffer_size, ReadMode_t ReadMode) -{ - int a; - unsigned int pos = 0; - int HaveCom = 0; - mSectionsAllocated = 10; - - mSections = (Sections_t *)malloc(sizeof(Sections_t) * mSectionsAllocated); - - if (!buffer) { - printf("Input buffer is null\n"); - return BAD_VALUE; - } - - if (buffer_size < 1) { - printf("Input size is 0\n"); - return BAD_VALUE; - } - - a = (int) buffer[pos++]; - - if (a != 0xff || buffer[pos++] != M_SOI){ - printf("No valid image\n"); - return BAD_VALUE; - } - - for(;;){ - int itemlen; - int marker = 0; - int ll,lh; - unsigned char * Data; - - CheckSectionsAllocated(); - - for (a = 0; a <= 16; a++){ - marker = buffer[pos++]; - if (marker != 0xff) break; - - if (a >= 16){ - fprintf(stderr,"too many padding bytes\n"); - return BAD_VALUE; - } - } - - mSections[mSectionsRead].Type = marker; - - // Read the length of the section. - lh = buffer[pos++]; - ll = buffer[pos++]; - - itemlen = (lh << 8) | ll; - - if (itemlen < 2) { - ALOGE("invalid marker"); - return BAD_VALUE; - } - - mSections[mSectionsRead].Size = itemlen; - - Data = (unsigned char *)malloc(itemlen); - if (Data == NULL) { - ALOGE("Could not allocate memory"); - return NO_MEMORY; - } - mSections[mSectionsRead].Data = Data; - - // Store first two pre-read bytes. - Data[0] = (unsigned char)lh; - Data[1] = (unsigned char)ll; - - if (pos+itemlen-2 > buffer_size) { - ALOGE("Premature end of file?"); - return BAD_VALUE; - } - - memcpy(Data+2, buffer+pos, itemlen-2); // Read the whole section. - pos += itemlen-2; - - mSectionsRead += 1; - - switch(marker){ - - case M_SOS: // stop before hitting compressed data - // If reading entire image is requested, read the rest of the - // data. - if (ReadMode & READ_IMAGE){ - int size; - // Determine how much file is left. - size = buffer_size - pos; - - if (size < 1) { - ALOGE("could not read the rest of the image"); - return BAD_VALUE; - } - Data = (unsigned char *)malloc(size); - if (Data == NULL) { - ALOGE("%d: could not allocate data for entire " - "image size: %d", __LINE__, size); - return BAD_VALUE; - } - - memcpy(Data, buffer+pos, size); - - CheckSectionsAllocated(); - mSections[mSectionsRead].Data = Data; - mSections[mSectionsRead].Size = size; - mSections[mSectionsRead].Type = PSEUDO_IMAGE_MARKER; - mSectionsRead ++; - mHaveAll = 1; - } - return NO_ERROR; - - case M_EOI: // in case it's a tables-only JPEG stream - ALOGE("No image in jpeg!\n"); - return BAD_VALUE; - - case M_COM: // Comment section - if (HaveCom || ((ReadMode & READ_METADATA) == 0)){ - // Discard this section. - free(mSections[--mSectionsRead].Data); - } - break; - - case M_JFIF: - // Regular jpegs always have this tag, exif images have the - // exif marker instead, althogh ACDsee will write images - // with both markers. - // this program will re-create this marker on absence of exif - // marker. - // hence no need to keep the copy from the file. - if (ReadMode & READ_METADATA){ - if (memcmp(Data+2, "JFIF", 4) == 0) { - break; - } - free(mSections[--mSectionsRead].Data); - } - break; - - case M_EXIF: - // There can be different section using the same marker. - if (ReadMode & READ_METADATA){ - if (memcmp(Data+2, "Exif", 4) == 0){ - break; - }else if (memcmp(Data+2, "http:", 5) == 0){ - // Change tag for internal purposes. - mSections[mSectionsRead-1].Type = M_XMP; - break; - } - } - // Oterwise, discard this section. - free(mSections[--mSectionsRead].Data); - break; - - case M_IPTC: - if (ReadMode & READ_METADATA){ - // Note: We just store the IPTC section. - // Its relatively straightforward - // and we don't act on any part of it, - // so just display it at parse time. - }else{ - free(mSections[--mSectionsRead].Data); - } - break; - - case M_SOF0: - case M_SOF1: - case M_SOF2: - case M_SOF3: - case M_SOF5: - case M_SOF6: - case M_SOF7: - case M_SOF9: - case M_SOF10: - case M_SOF11: - case M_SOF13: - case M_SOF14: - case M_SOF15: - break; - default: - // Skip any other sections. - break; - } - } - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : CheckSectionsAllocated - * - * DESCRIPTION: Check allocated jpeg sections. - * - * PARAMETERS : none - * - * RETURN : none - - *==========================================================================*/ -void CameraContext::CheckSectionsAllocated(void) -{ - if (mSectionsRead > mSectionsAllocated){ - ALOGE("allocation screw up"); - } - if (mSectionsRead >= mSectionsAllocated){ - mSectionsAllocated += mSectionsAllocated +1; - mSections = (Sections_t *)realloc(mSections, - sizeof(Sections_t) * mSectionsAllocated); - if (mSections == NULL){ - ALOGE("could not allocate data for entire image"); - } - } -} - -/*=========================================================================== - * FUNCTION : findSection - * - * DESCRIPTION: find the desired Section of the JPEG buffer. - * - * PARAMETERS : - * @SectionType: Section type - * - * RETURN : return the found section - - *==========================================================================*/ -CameraContext::Sections_t *CameraContext::FindSection(int SectionType) -{ - int a; - - for (a = 0; a < mSectionsRead; a++){ - if (mSections[a].Type == SectionType){ - return &mSections[a]; - } - } - // Could not be found. - return NULL; -} - - -/*=========================================================================== - * FUNCTION : DiscardData - * - * DESCRIPTION: DiscardData - * - * PARAMETERS : none - * - * RETURN : none - - *==========================================================================*/ -void CameraContext::DiscardData() -{ - int a; - - for (a = 0; a < mSectionsRead; a++){ - free(mSections[a].Data); - } - - mSectionsRead = 0; - mHaveAll = 0; -} - -/*=========================================================================== - * FUNCTION : DiscardSections - * - * DESCRIPTION: Discard allocated sections - * - * PARAMETERS : none - * - * RETURN : none - - *==========================================================================*/ -void CameraContext::DiscardSections() -{ - free(mSections); - mSectionsAllocated = 0; - mHaveAll = 0; -} - -/*=========================================================================== - * FUNCTION : notify - * - * DESCRIPTION: notify callback - * - * PARAMETERS : - * @msgType : type of callback - * @ext1: extended parameters - * @ext2: extended parameters - * - * RETURN : None - *==========================================================================*/ -void CameraContext::notify(int32_t msgType, int32_t ext1, int32_t ext2) -{ - printf("Notify cb: %d %d %d\n", msgType, ext1, ext2); - - if (( msgType & CAMERA_MSG_PREVIEW_FRAME) && (ext1 == CAMERA_FRAME_DATA_FD)) { - int fd = dup(ext2); - printf("notify Preview Frame fd: %d dup fd: %d\n", ext2, fd); - close(fd); - } - - if ( msgType & CAMERA_MSG_FOCUS ) { - printf("AutoFocus %s \n", - (ext1) ? "OK" : "FAIL"); - } - - if ( msgType & CAMERA_MSG_SHUTTER ) { - printf("Shutter done \n"); - } - - if ( msgType & CAMERA_MSG_ERROR) { - printf("Camera Test CAMERA_MSG_ERROR\n"); - stopPreview(); - closeCamera(); - } -} - -/*=========================================================================== - * FUNCTION : postData - * - * DESCRIPTION: handles data callbacks - * - * PARAMETERS : - * @msgType : type of callback - * @dataPtr: buffer data - * @metadata: additional metadata where available - * - * RETURN : None - *==========================================================================*/ -void CameraContext::postData(int32_t msgType, - const sp<IMemory>& dataPtr, - camera_frame_metadata_t *metadata) -{ - Size currentPictureSize = mSupportedPictureSizes.itemAt( - mCurrentPictureSizeIdx); - unsigned char *buff = NULL; - int size; - status_t ret = 0; - - memset(&mJEXIFSection, 0, sizeof(mJEXIFSection)), - - printf("Data cb: %d\n", msgType); - - if ( msgType & CAMERA_MSG_PREVIEW_FRAME ) { - previewCallback(dataPtr); - } - - if ( msgType & CAMERA_MSG_RAW_IMAGE ) { - printf("RAW done \n"); - } - - if (msgType & CAMERA_MSG_POSTVIEW_FRAME) { - printf("Postview frame \n"); - } - - if (msgType & CAMERA_MSG_COMPRESSED_IMAGE ) { - String8 jpegPath; - jpegPath = jpegPath.format("/sdcard/img_%d.jpg", JpegIdx); - if (!mPiPCapture) { - // Normal capture case - printf("JPEG done\n"); - saveFile(dataPtr, jpegPath); - JpegIdx++; - } else { - // PiP capture case - SkFILEWStream *wStream; - skBMtmp[mPiPIdx] = decodeJPEG(dataPtr); - - mWidthTmp[mPiPIdx] = currentPictureSize.width; - mHeightTmp[mPiPIdx] = currentPictureSize.height; - PiPPtrTmp[mPiPIdx] = dataPtr; - // If there are two jpeg buffers - if (mPiPIdx == 1) { - printf("PiP done\n"); - - // Find the the capture with higher width and height and read - // its jpeg sections - if ((mWidthTmp[0]*mHeightTmp[0]) > - (mWidthTmp[1]*mHeightTmp[1])) { - buff = (unsigned char *)PiPPtrTmp[0]->pointer(); - size = PiPPtrTmp[0]->size(); - } else if ((mWidthTmp[0]*mHeightTmp[0]) < - (mWidthTmp[1]*mHeightTmp[1])) { - buff = (unsigned char *)PiPPtrTmp[1]->pointer(); - size = PiPPtrTmp[1]->size(); - } else { - printf("Cannot take PiP. Images are with the same width" - " and height size!!!\n"); - return; - } - - if (buff != NULL && size != 0) { - ret = ReadSectionsFromBuffer(buff, size, READ_ALL); - if (ret != NO_ERROR) { - printf("Cannot read sections from buffer\n"); - DiscardData(); - DiscardSections(); - return; - } - - mJEXIFTmp = FindSection(M_EXIF); - mJEXIFSection = *mJEXIFTmp; - mJEXIFSection.Data = - (unsigned char*)malloc(mJEXIFTmp->Size); - memcpy(mJEXIFSection.Data, - mJEXIFTmp->Data, mJEXIFTmp->Size); - DiscardData(); - DiscardSections(); - - wStream = new SkFILEWStream(jpegPath.string()); - skBMDec = PiPCopyToOneFile(skBMtmp[0], skBMtmp[1]); - if (encodeJPEG(wStream, skBMDec, jpegPath) != false) { - printf("%s():%d:: Failed during jpeg encode\n", - __FUNCTION__,__LINE__); - return; - } - mPiPIdx = 0; - JpegIdx++; - delete wStream; - } - } else { - mPiPIdx++; - } - disablePiPCapture(); - } - } - - if ( ( msgType & CAMERA_MSG_PREVIEW_METADATA ) && - ( NULL != metadata ) ) { - printf("Face detected %d \n", metadata->number_of_faces); - } - - signalFinished(); -} - -/*=========================================================================== - * FUNCTION : postDataTimestamp - * - * DESCRIPTION: handles recording callbacks - * - * PARAMETERS : - * @timestamp : timestamp of buffer - * @msgType : type of buffer - * @dataPtr : buffer data - * - * RETURN : None - *==========================================================================*/ -void CameraContext::postDataTimestamp(nsecs_t timestamp, - int32_t msgType, - const sp<IMemory>& dataPtr) -{ - printf("Recording cb: %d %lld %p\n", msgType, timestamp, dataPtr.get()); -} - -void CameraContext::postRecordingFrameHandleTimestamp(nsecs_t, native_handle_t*) { -} - -void CameraContext::recordingFrameHandleCallbackTimestamp(nsecs_t, native_handle_t*) { -} - -/*=========================================================================== - * FUNCTION : dataCallbackTimestamp - * - * DESCRIPTION: handles recording callbacks. Used for ViV recording - * - * PARAMETERS : - * @timestamp : timestamp of buffer - * @msgType : type of buffer - * @dataPtr : buffer data - * - * RETURN : None - *==========================================================================*/ -void CameraContext::dataCallbackTimestamp(nsecs_t timestamp, - int32_t msgType, - const sp<IMemory>& dataPtr) -{ - mutexLock(); - // Not needed check. Just avoiding warnings of not used variables. - if (timestamp > 0) - timestamp = 0; - // Not needed check. Just avoiding warnings of not used variables. - if (msgType > 0) - msgType = 0; - int i = 0; - void * srcBuff = NULL; - void * dstBuff = NULL; - - size_t srcYStride = 0, dstYStride = 0; - size_t srcUVStride = 0, dstUVStride = 0; - size_t srcYScanLines = 0, dstYScanLines = 0; - size_t srcUVScanLines = 0, dstUVScanLines = 0; - size_t srcOffset = 0, dstOffset = 0; - size_t srcBaseOffset = 0; - size_t dstBaseOffset = 0; - Size currentVideoSize = mSupportedVideoSizes.itemAt(mCurrentVideoSizeIdx); - status_t err = NO_ERROR; - ANativeWindowBuffer* anb = NULL; - - dstBuff = (void *) dataPtr->pointer(); - - if (mCameraIndex == mInterpr->mViVVid.sourceCameraID) { - srcYStride = calcStride(currentVideoSize.width); - srcUVStride = calcStride(currentVideoSize.width); - srcYScanLines = calcYScanLines(currentVideoSize.height); - srcUVScanLines = calcUVScanLines(currentVideoSize.height); - mInterpr->mViVBuff.srcWidth = currentVideoSize.width; - mInterpr->mViVBuff.srcHeight = currentVideoSize.height; - - - mInterpr->mViVBuff.YStride = srcYStride; - mInterpr->mViVBuff.UVStride = srcUVStride; - mInterpr->mViVBuff.YScanLines = srcYScanLines; - mInterpr->mViVBuff.UVScanLines = srcUVScanLines; - - memcpy( mInterpr->mViVBuff.buff, (void *) dataPtr->pointer(), - mInterpr->mViVBuff.buffSize); - - mInterpr->mViVVid.isBuffValid = true; - } else if (mCameraIndex == mInterpr->mViVVid.destinationCameraID) { - if(mInterpr->mViVVid.isBuffValid == true) { - dstYStride = calcStride(currentVideoSize.width); - dstUVStride = calcStride(currentVideoSize.width); - dstYScanLines = calcYScanLines(currentVideoSize.height); - dstUVScanLines = calcUVScanLines(currentVideoSize.height); - - srcYStride = mInterpr->mViVBuff.YStride; - srcUVStride = mInterpr->mViVBuff.UVStride; - srcYScanLines = mInterpr->mViVBuff.YScanLines; - srcUVScanLines = mInterpr->mViVBuff.UVScanLines; - - - for (i=0; i<(int) mInterpr->mViVBuff.srcHeight; i++) { - srcOffset = i*srcYStride; - dstOffset = i*dstYStride; - memcpy((unsigned char *) dstBuff + dstOffset, - (unsigned char *) mInterpr->mViVBuff.buff + - srcOffset, mInterpr->mViVBuff.srcWidth); - } - srcBaseOffset = srcYStride * srcYScanLines; - dstBaseOffset = dstYStride * dstYScanLines; - for (i=0;i<(int) mInterpr->mViVBuff.srcHeight/2;i++) { - srcOffset = i*srcUVStride + srcBaseOffset; - dstOffset = i*dstUVStride + dstBaseOffset; - memcpy((unsigned char *) dstBuff + dstOffset, - (unsigned char *) mInterpr->mViVBuff.buff + - srcOffset, mInterpr->mViVBuff.srcWidth); - } - - err = native_window_dequeue_buffer_and_wait( - mInterpr->mViVVid.ANW.get(),&anb); - if (err != NO_ERROR) { - printf("Cannot dequeue anb for sensor %d!!!\n", mCameraIndex); - return; - } - mInterpr->mViVVid.graphBuf = new GraphicBuffer(anb, false); - if(NULL == mInterpr->mViVVid.graphBuf.get()) { - printf("Invalid Graphic buffer\n"); - return; - } - err = mInterpr->mViVVid.graphBuf->lock( - GRALLOC_USAGE_SW_WRITE_OFTEN, - (void**)(&mInterpr->mViVVid.mappedBuff)); - if (err != NO_ERROR) { - printf("Graphic buffer could not be locked %d!!!\n", err); - return; - } - - srcYStride = dstYStride; - srcUVStride = dstUVStride; - srcYScanLines = dstYScanLines; - srcUVScanLines = dstUVScanLines; - srcBuff = dstBuff; - - for (i=0; i<(int) currentVideoSize.height; i++) { - srcOffset = i*srcYStride; - dstOffset = i*dstYStride; - memcpy((unsigned char *) mInterpr->mViVVid.mappedBuff + - dstOffset, (unsigned char *) srcBuff + - srcOffset, currentVideoSize.width); - } - - srcBaseOffset = srcYStride * srcYScanLines; - dstBaseOffset = dstUVStride * currentVideoSize.height; - - for (i=0;i<(int) currentVideoSize.height/2;i++) { - srcOffset = i*srcUVStride + srcBaseOffset; - dstOffset = i*dstUVStride + dstBaseOffset; - memcpy((unsigned char *) mInterpr->mViVVid.mappedBuff + - dstOffset, (unsigned char *) srcBuff + - srcOffset, currentVideoSize.width); - } - - - mInterpr->mViVVid.graphBuf->unlock(); - - err = mInterpr->mViVVid.ANW->queueBuffer( - mInterpr->mViVVid.ANW.get(), anb, -1); - if(err) - printf("Failed to enqueue buffer to recorder!!!\n"); - } - } - mCamera->releaseRecordingFrame(dataPtr); - - mutexUnlock(); -} - -/*=========================================================================== - * FUNCTION : ViVEncoderThread - * - * DESCRIPTION: Creates a separate thread for ViV recording - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -status_t Interpreter::ViVEncoderThread() -{ - int ret = NO_ERROR; - pthread_attr_t attr; - pthread_attr_init(&attr); - - ret = pthread_create(&mViVEncThread, &attr, ThreadWrapper, this); - ret = pthread_attr_destroy(&attr); - - return ret; -} - -/*=========================================================================== - * FUNCTION : ThreadWrapper - * - * DESCRIPTION: Helper function for for ViV recording thread - * - * PARAMETERS : Interpreter context - * - * RETURN : None - *==========================================================================*/ -void *Interpreter::ThreadWrapper(void *context) { - Interpreter *writer = static_cast<Interpreter *>(context); - writer->ViVEncode(); - return NULL; -} - -/*=========================================================================== - * FUNCTION : ViVEncode - * - * DESCRIPTION: Thread for ViV encode. Buffers from video codec are sent to - * muxer and saved in a file. - * - * PARAMETERS : Interpreter context - * - * RETURN : None - *==========================================================================*/ -void Interpreter::ViVEncode() -{ - status_t err = NO_ERROR; - ssize_t trackIdx = -1; - uint32_t debugNumFrames = 0; - - size_t bufIndex, offset, size; - int64_t ptsUsec; - uint32_t flags; - bool DoRecording = true; - - - err = mTestContext->mViVVid.codec->getOutputBuffers( - &mTestContext->mViVVid.buffers); - if (err != NO_ERROR) { - printf("Unable to get output buffers (err=%d)\n", err); - } - - while (DoRecording) { - err = mTestContext->mViVVid.codec->dequeueOutputBuffer( - &bufIndex, - &offset, - &size, - &ptsUsec, - &flags, -1); - - switch (err) { - - case NO_ERROR: - // got a buffer - if ((flags & MediaCodec::BUFFER_FLAG_CODECCONFIG) != 0) { - // ignore this -- we passed the CSD into MediaMuxer when - // we got the format change notification - size = 0; - } - if (size != 0) { - // If the virtual display isn't providing us with timestamps, - // use the current time. - if (ptsUsec == 0) { - ptsUsec = systemTime(SYSTEM_TIME_MONOTONIC) / 1000; - } - - // The MediaMuxer docs are unclear, but it appears that we - // need to pass either the full set of BufferInfo flags, or - // (flags & BUFFER_FLAG_SYNCFRAME). - err = mTestContext->mViVVid.muxer->writeSampleData( - mTestContext->mViVVid.buffers[bufIndex], - trackIdx, - ptsUsec, - flags); - if (err != NO_ERROR) { - fprintf(stderr, "Failed writing data to muxer (err=%d)\n", - err); - } - debugNumFrames++; - } - err = mTestContext->mViVVid.codec->releaseOutputBuffer(bufIndex); - if (err != NO_ERROR) { - fprintf(stderr, "Unable to release output buffer (err=%d)\n", - err); - } - if ((flags & MediaCodec::BUFFER_FLAG_EOS) != 0) { - // Not expecting EOS from SurfaceFlinger. Go with it. - printf("Received end-of-stream\n"); - //DoRecording = false; - } - break; - case -EAGAIN: // INFO_TRY_AGAIN_LATER - ALOGV("Got -EAGAIN, looping"); - break; - case INFO_FORMAT_CHANGED: // INFO_OUTPUT_FORMAT_CHANGED - { - // format includes CSD, which we must provide to muxer - sp<AMessage> newFormat; - mTestContext->mViVVid.codec->getOutputFormat(&newFormat); - trackIdx = mTestContext->mViVVid.muxer->addTrack(newFormat); - err = mTestContext->mViVVid.muxer->start(); - if (err != NO_ERROR) { - printf("Unable to start muxer (err=%d)\n", err); - } - } - break; - case INFO_OUTPUT_BUFFERS_CHANGED: // INFO_OUTPUT_BUFFERS_CHANGED - // not expected for an encoder; handle it anyway - ALOGV("Encoder buffers changed"); - err = mTestContext->mViVVid.codec->getOutputBuffers( - &mTestContext->mViVVid.buffers); - if (err != NO_ERROR) { - printf("Unable to get new output buffers (err=%d)\n", err); - } - break; - case INVALID_OPERATION: - DoRecording = false; - break; - default: - printf("Got weird result %d from dequeueOutputBuffer\n", err); - break; - } - } - - return; -} - - -/*=========================================================================== - * FUNCTION : calcBufferSize - * - * DESCRIPTION: Temp buffer size calculation. Temp buffer is used to store - * the buffer from the camera with smaller resolution. It is - * copied to the buffer from camera with higher resolution. - * - * PARAMETERS : - * @width : video size width - * @height : video size height - * - * RETURN : size_t - *==========================================================================*/ -size_t CameraContext::calcBufferSize(int width, int height) -{ - size_t size = 0; - size_t UVAlignment; - size_t YPlane, UVPlane, YStride, UVStride, YScanlines, UVScanlines; - if (!width || !height) { - return size; - } - UVAlignment = 4096; - YStride = calcStride(width); - UVStride = calcStride(width); - YScanlines = calcYScanLines(height); - UVScanlines = calcUVScanLines(height); - YPlane = YStride * YScanlines; - UVPlane = UVStride * UVScanlines + UVAlignment; - size = YPlane + UVPlane; - size = VIDEO_BUF_ALLIGN(size, 4096); - - return size; -} - -/*=========================================================================== - * FUNCTION : calcStride - * - * DESCRIPTION: Temp buffer stride calculation. - * - * PARAMETERS : - * @width : video size width - * - * RETURN : size_t - *==========================================================================*/ -size_t CameraContext::calcStride(int width) -{ - size_t alignment, stride = 0; - if (!width) { - return stride; - } - alignment = 128; - stride = VIDEO_BUF_ALLIGN(width, alignment); - - return stride; -} - -/*=========================================================================== - * FUNCTION : calcYScanLines - * - * DESCRIPTION: Temp buffer scanlines calculation for Y plane. - * - * PARAMETERS : - * @width : video size height - * - * RETURN : size_t - *==========================================================================*/ -size_t CameraContext::calcYScanLines(int height) -{ - size_t alignment, scanlines = 0; - if (!height) { - return scanlines; - } - alignment = 32; - scanlines = VIDEO_BUF_ALLIGN(height, alignment); - - return scanlines; -} - -/*=========================================================================== - * FUNCTION : calcUVScanLines - * - * DESCRIPTION: Temp buffer scanlines calculation for UV plane. - * - * PARAMETERS : - * @width : video size height - * - * RETURN : size_t - *==========================================================================*/ -size_t CameraContext::calcUVScanLines(int height) -{ - size_t alignment, scanlines = 0; - if (!height) { - return scanlines; - } - alignment = 16; - scanlines = VIDEO_BUF_ALLIGN(((height + 1) >> 1), alignment); - - return scanlines; -} - -/*=========================================================================== - * FUNCTION : printSupportedParams - * - * DESCRIPTION: dump common supported parameters - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -void CameraContext::printSupportedParams() -{ - printf("\n\r\tSupported Cameras: %s", - mParams.get("camera-indexes")? - mParams.get("camera-indexes") : "NULL"); - printf("\n\r\tSupported Picture Sizes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES)? - mParams.get( - CameraParameters::KEY_SUPPORTED_PICTURE_SIZES) : "NULL"); - printf("\n\r\tSupported Picture Formats: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS)? - mParams.get( - CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS) : "NULL"); - printf("\n\r\tSupported Preview Sizes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES)? - mParams.get( - CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES) : "NULL"); - printf("\n\r\tSupported Video Sizes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_VIDEO_SIZES)? - mParams.get( - CameraParameters::KEY_SUPPORTED_VIDEO_SIZES) : "NULL"); - printf("\n\r\tSupported Preview Formats: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS)? - mParams.get( - CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS) : "NULL"); - printf("\n\r\tSupported Preview Frame Rates: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES)? - mParams.get( - CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES) : "NULL"); - printf("\n\r\tSupported Thumbnail Sizes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES)? - mParams.get( - CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES) : "NULL"); - printf("\n\r\tSupported Whitebalance Modes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE)? - mParams.get( - CameraParameters::KEY_SUPPORTED_WHITE_BALANCE) : "NULL"); - printf("\n\r\tSupported Effects: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_EFFECTS)? - mParams.get(CameraParameters::KEY_SUPPORTED_EFFECTS) : "NULL"); - printf("\n\r\tSupported Scene Modes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_SCENE_MODES)? - mParams.get(CameraParameters::KEY_SUPPORTED_SCENE_MODES) : "NULL"); - printf("\n\r\tSupported Focus Modes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_FOCUS_MODES)? - mParams.get(CameraParameters::KEY_SUPPORTED_FOCUS_MODES) : "NULL"); - printf("\n\r\tSupported Antibanding Options: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_ANTIBANDING)? - mParams.get(CameraParameters::KEY_SUPPORTED_ANTIBANDING) : "NULL"); - printf("\n\r\tSupported Flash Modes: %s", - mParams.get(CameraParameters::KEY_SUPPORTED_FLASH_MODES)? - mParams.get(CameraParameters::KEY_SUPPORTED_FLASH_MODES) : "NULL"); - printf("\n\r\tSupported Focus Areas: %d", - mParams.getInt(CameraParameters::KEY_MAX_NUM_FOCUS_AREAS)); - printf("\n\r\tSupported FPS ranges : %s", - mParams.get(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE)? - mParams.get( - CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE) : "NULL"); - printf("\n\r\tFocus Distances: %s \n", - mParams.get(CameraParameters::KEY_FOCUS_DISTANCES)? - mParams.get(CameraParameters::KEY_FOCUS_DISTANCES) : "NULL"); -} - -/*=========================================================================== - * FUNCTION : createPreviewSurface - * - * DESCRIPTION: helper function for creating preview surfaces - * - * PARAMETERS : - * @width : preview width - * @height: preview height - * @pixFormat : surface pixelformat - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::createPreviewSurface(unsigned int width, - unsigned int height, - int32_t pixFormat) -{ - int ret = NO_ERROR; - DisplayInfo dinfo; - sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay( - ISurfaceComposer::eDisplayIdMain)); - SurfaceComposerClient::getDisplayInfo(display, &dinfo); - unsigned int previewWidth, previewHeight; - - if ( dinfo.w < width ) { - previewWidth = dinfo.w; - } else { - previewWidth = width; - } - - if ( dinfo.h < height ) { - previewHeight = dinfo.h; - } else { - previewHeight = height; - } - - mClient = new SurfaceComposerClient(); - - if ( NULL == mClient.get() ) { - printf("Unable to establish connection to Surface Composer \n"); - return NO_INIT; - } - - mSurfaceControl = mClient->createSurface(String8("QCamera_Test"), - previewWidth, - previewHeight, - pixFormat, - 0); - if ( NULL == mSurfaceControl.get() ) { - printf("Unable to create preview surface \n"); - return NO_INIT; - } - - mPreviewSurface = mSurfaceControl->getSurface(); - if ( NULL != mPreviewSurface.get() ) { - mClient->openGlobalTransaction(); - ret |= mSurfaceControl->setLayer(0x7fffffff); - if ( mCameraIndex == 0 ) - ret |= mSurfaceControl->setPosition(0, 0); - else - ret |= mSurfaceControl->setPosition( - dinfo.w - previewWidth, dinfo.h - previewHeight); - - ret |= mSurfaceControl->setSize(previewWidth, previewHeight); - ret |= mSurfaceControl->show(); - mClient->closeGlobalTransaction(); - - if ( NO_ERROR != ret ) { - printf("Preview surface configuration failed! \n"); - } - } else { - ret = NO_INIT; - } - - return ret; -} - -/*=========================================================================== - * FUNCTION : destroyPreviewSurface - * - * DESCRIPTION: closes previously open preview surface - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::destroyPreviewSurface() -{ - if ( NULL != mPreviewSurface.get() ) { - mPreviewSurface.clear(); - } - - if ( NULL != mSurfaceControl.get() ) { - mSurfaceControl->clear(); - mSurfaceControl.clear(); - } - - if ( NULL != mClient.get() ) { - mClient->dispose(); - mClient.clear(); - } - - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : CameraContext - * - * DESCRIPTION: camera context constructor - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -CameraContext::CameraContext(int cameraIndex) : - mCameraIndex(cameraIndex), - mResizePreview(true), - mHardwareActive(false), - mPreviewRunning(false), - mRecordRunning(false), - mVideoFd(-1), - mVideoIdx(0), - mRecordingHint(false), - mDoPrintMenu(true), - mPiPCapture(false), - mfmtMultiplier(1), - mSectionsRead(false), - mSectionsAllocated(false), - mSections(NULL), - mJEXIFTmp(NULL), - mHaveAll(false), - mViVinUse(false), - mCamera(NULL), - mClient(NULL), - mSurfaceControl(NULL), - mPreviewSurface(NULL), - mInUse(false) -{ - mRecorder = new MediaRecorder(); -} - -/*=========================================================================== - * FUNCTION : setTestCtxInstance - * - * DESCRIPTION : Sends TestContext instance to CameraContext - * - * PARAMETERS : - * @instance : TestContext instance - * - * RETURN : None - *==========================================================================*/ -void CameraContext::setTestCtxInstance(TestContext *instance) -{ - mInterpr = instance; -} - -/*=========================================================================== - * FUNCTION : setTestCtxInst - * - * DESCRIPTION : Sends TestContext instance to Interpreter - * - * PARAMETERS : - * @instance : TestContext instance - * - * RETURN : None - *==========================================================================*/ -void Interpreter::setTestCtxInst(TestContext *instance) -{ - mTestContext = instance; -} - -/*=========================================================================== - * FUNCTION : ~CameraContext - * - * DESCRIPTION: camera context destructor - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -CameraContext::~CameraContext() -{ - stopPreview(); - closeCamera(); -} - -/*=========================================================================== - * FUNCTION : openCamera - * - * DESCRIPTION: connects to and initializes camera - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::openCamera() -{ - useLock(); - - if ( NULL != mCamera.get() ) { - printf("Camera already open! \n"); - return NO_ERROR; - } - - printf("openCamera(camera_index=%d)\n", mCameraIndex); - -#ifndef USE_JB_MR1 - - String16 packageName("CameraTest"); - - mCamera = Camera::connect(mCameraIndex, - packageName, - Camera::USE_CALLING_UID); - -#else - - mCamera = Camera::connect(mCameraIndex); - -#endif - - if ( NULL == mCamera.get() ) { - printf("Unable to connect to CameraService\n"); - return NO_INIT; - } - - mParams = mCamera->getParameters(); - mParams.getSupportedPreviewSizes(mSupportedPreviewSizes); - mParams.getSupportedPictureSizes(mSupportedPictureSizes); - mParams.getSupportedVideoSizes(mSupportedVideoSizes); - - mCurrentPictureSizeIdx = mSupportedPictureSizes.size() / 2; - mCurrentPreviewSizeIdx = mSupportedPreviewSizes.size() / 2; - mCurrentVideoSizeIdx = mSupportedVideoSizes.size() / 2; - - mCamera->setListener(this); - mHardwareActive = true; - - mInterpr->setViVSize((Size) mSupportedVideoSizes.itemAt( - mCurrentVideoSizeIdx), - mCameraIndex); - - signalFinished(); - - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : onAsBinder - * - * DESCRIPTION: onAsBinder - * - * PARAMETERS : None - * - * RETURN : Pointer to IBinder - *==========================================================================*/ -IBinder* CameraContext::onAsBinder() { - return NULL; -} - -/*=========================================================================== - * FUNCTION : getNumberOfCameras - * - * DESCRIPTION: returns the number of supported camera by the system - * - * PARAMETERS : None - * - * RETURN : supported camera count - *==========================================================================*/ -int CameraContext::getNumberOfCameras() -{ - int ret = -1; - - if ( NULL != mCamera.get() ) { - ret = mCamera->getNumberOfCameras(); - } - - return ret; -} - -/*=========================================================================== - * FUNCTION : closeCamera - * - * DESCRIPTION: closes a previously the initialized camera reference - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::closeCamera() -{ - useLock(); - if ( NULL == mCamera.get() ) { - return NO_INIT; - } - - mCamera->disconnect(); - mCamera.clear(); - - mRecorder->init(); - mRecorder->close(); - mRecorder->release(); - mRecorder.clear(); - - mHardwareActive = false; - mPreviewRunning = false; - mRecordRunning = false; - - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : startPreview - * - * DESCRIPTION: starts camera preview - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::startPreview() -{ - useLock(); - - int ret = NO_ERROR; - int previewWidth, previewHeight; - Size calculatedPreviewSize; - Size currentPreviewSize = mSupportedPreviewSizes.itemAt( - mCurrentPreviewSizeIdx); - Size currentPictureSize = mSupportedPictureSizes.itemAt( - mCurrentPictureSizeIdx); - Size currentVideoSize = mSupportedVideoSizes.itemAt( - mCurrentVideoSizeIdx); - -#ifndef USE_JB_MR1 - - sp<IGraphicBufferProducer> gbp; - -#endif - - if (!mHardwareActive ) { - printf("Camera not active! \n"); - return NO_INIT; - } - - if (mPreviewRunning) { - printf("Preview is already running! \n"); - signalFinished(); - return NO_ERROR; - } - - if (mResizePreview) { - mPreviewRunning = false; - - if ( mRecordingHint ) { - calculatedPreviewSize = - getPreviewSizeFromVideoSizes(currentVideoSize); - previewWidth = calculatedPreviewSize.width; - previewHeight = calculatedPreviewSize.height; - } else { - previewWidth = currentPreviewSize.width; - previewHeight = currentPreviewSize.height; - } - - ret = createPreviewSurface(previewWidth, - previewHeight, - HAL_PIXEL_FORMAT_YCrCb_420_SP); - if ( NO_ERROR != ret ) { - printf("Error while creating preview surface\n"); - return ret; - } - - // set rdi mode if system prop is set for front camera - if (mCameraIndex == 1) { - char value[32]; - property_get("persist.camera.rdimode", value, "0"); - int rdimode = atoi(value); - printf("rdi mode = %d\n", rdimode); - if (rdimode == 1) { - mParams.set("rdi-mode", "enable"); - } else { - mParams.set("rdi-mode", "disable"); - } - } else { - mParams.set("rdi-mode", "disable"); - } - - //mParams.set("rdi-mode", "enable"); - mParams.set("recording-hint", "true"); - mParams.setPreviewSize(previewWidth, previewHeight); - mParams.setPictureSize(currentPictureSize.width, - currentPictureSize.height); - mParams.setVideoSize( - currentVideoSize.width, currentVideoSize.height); - - ret |= mCamera->setParameters(mParams.flatten()); - -#ifndef USE_JB_MR1 - - gbp = mPreviewSurface->getIGraphicBufferProducer(); - ret |= mCamera->setPreviewTarget(gbp); - -#else - - ret |= mCamera->setPreviewDisplay(mPreviewSurface); - -#endif - mResizePreview = false; - } - - if ( !mPreviewRunning ) { - ret |= mCamera->startPreview(); - if ( NO_ERROR != ret ) { - printf("Preview start failed! \n"); - return ret; - } - - mPreviewRunning = true; - } - - signalFinished(); - - return ret; -} - -/*=========================================================================== - * FUNCTION : getPreviewSizeFromVideoSizes - * - * DESCRIPTION: Get the preview size from video size. Find all resolutions with - * the same aspect ratio and choose the same or the closest - * from them. - * - * PARAMETERS : - * @currentVideoSize: current video size - - * - * RETURN : PreviewSize - *==========================================================================*/ -Size CameraContext::getPreviewSizeFromVideoSizes(Size currentVideoSize) -{ - - Size tmpPreviewSize; - Size PreviewSize; - Size PreviewSizes[mSupportedPreviewSizes.size()]; - float tolerance = 0.00001; - float videoRatio; - float previewRatio; - size_t i = 0; - size_t j = 0; - int delta; - - // Find all the resolutions with the same aspect ratio and choose the - // same or the closest resolution from them. Choose the closest resolution - // in case same aspect ratio is not found - if (currentVideoSize.width * currentVideoSize.height > 0 && - mSupportedPreviewSizes.size() > 0) { - videoRatio = (float)currentVideoSize.width / - (float)currentVideoSize.height; - for (i=0; i<mSupportedPreviewSizes.size(); i++) { - tmpPreviewSize = mSupportedPreviewSizes.itemAt(i); - previewRatio = (float)tmpPreviewSize.width / - (float)tmpPreviewSize.height; - if (fabs(videoRatio - previewRatio) < tolerance) { - PreviewSizes[j] = tmpPreviewSize; - j++; - } - } - - if ( j > 0 ) { - delta = abs((currentVideoSize.width *currentVideoSize.height)- - (PreviewSizes[0].width * PreviewSizes[0].height)); - PreviewSize = PreviewSizes[0]; - for (i=0; i<j; i++) { - if(abs(currentVideoSize.width * currentVideoSize.height) - - (PreviewSizes[i].width * PreviewSizes[i].height) < - delta) { - PreviewSize = PreviewSizes[i]; - delta = abs((currentVideoSize.width * - currentVideoSize.height) - - (PreviewSizes[i].width * PreviewSizes[i].height)); - } - } - } else { - // Choose the closest resolution in case same aspect ratio is - // not found - tmpPreviewSize = mSupportedPreviewSizes.itemAt(j); - PreviewSize = tmpPreviewSize; - delta = abs( - (currentVideoSize.width * currentVideoSize.height)- - (tmpPreviewSize.width * tmpPreviewSize.height)); - for (i=0; i<mSupportedPreviewSizes.size(); i++) { - tmpPreviewSize = mSupportedPreviewSizes.itemAt(i); - if(abs( - (currentVideoSize.width * currentVideoSize.height)- - (tmpPreviewSize.width * tmpPreviewSize.height)) < - delta) { - PreviewSize = tmpPreviewSize; - delta = abs( - (currentVideoSize.width * currentVideoSize.height)- - (tmpPreviewSize.width * tmpPreviewSize.height)); - } - } - } - } else { - memset(&PreviewSize, 0, sizeof(PreviewSize)); - } - return PreviewSize; -} - -/*=========================================================================== - * FUNCTION : autoFocus - * - * DESCRIPTION: Triggers autofocus - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::autoFocus() -{ - useLock(); - status_t ret = NO_ERROR; - - if ( mPreviewRunning ) { - ret = mCamera->autoFocus(); - } - - signalFinished(); - return ret; -} - -/*=========================================================================== - * FUNCTION : enablePreviewCallbacks - * - * DESCRIPTION: Enables preview callback messages - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::enablePreviewCallbacks() -{ - useLock(); - if ( mHardwareActive ) { - mCamera->setPreviewCallbackFlags( - CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK); - } - - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : takePicture - * - * DESCRIPTION: triggers image capture - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::takePicture() -{ - status_t ret = NO_ERROR; - - useLock(); // Unlocked in jpeg callback - - if ( mPreviewRunning ) { - ret = mCamera->takePicture( - CAMERA_MSG_COMPRESSED_IMAGE| - CAMERA_MSG_RAW_IMAGE); - if (!mRecordingHint) { - mPreviewRunning = false; - } - } else { - printf("Please resume/start the preview before taking a picture!\n"); - signalFinished(); //Unlock in case preview is not running - } - return ret; -} - -/*=========================================================================== - * FUNCTION : configureRecorder - * - * DESCRIPTION: Configure video recorder - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::configureRecorder() -{ - useLock(); - status_t ret = NO_ERROR; - - mResizePreview = true; - mParams.set("recording-hint", "true"); - mRecordingHint = true; - mCamera->setParameters(mParams.flatten()); - - Size videoSize = mSupportedVideoSizes.itemAt(mCurrentVideoSizeIdx); - ret = mRecorder->setParameters( - String8("video-param-encoding-bitrate=64000")); - if ( ret != NO_ERROR ) { - ERROR("Could not configure recorder (%d)", ret); - return ret; - } - - ret = mRecorder->setCamera( - mCamera->remote(), mCamera->getRecordingProxy()); - if ( ret != NO_ERROR ) { - ERROR("Could not set camera (%d)", ret); - return ret; - } - ret = mRecorder->setVideoSource(VIDEO_SOURCE_CAMERA); - if ( ret != NO_ERROR ) { - ERROR("Could not set video soruce (%d)", ret); - return ret; - } - ret = mRecorder->setAudioSource(AUDIO_SOURCE_DEFAULT); - if ( ret != NO_ERROR ) { - ERROR("Could not set audio source (%d)", ret); - return ret; - } - ret = mRecorder->setOutputFormat(OUTPUT_FORMAT_DEFAULT); - if ( ret != NO_ERROR ) { - ERROR("Could not set output format (%d)", ret); - return ret; - } - - ret = mRecorder->setVideoEncoder(VIDEO_ENCODER_DEFAULT); - if ( ret != NO_ERROR ) { - ERROR("Could not set video encoder (%d)", ret); - return ret; - } - - char fileName[100]; - - sprintf(fileName, "/sdcard/vid_cam%d_%dx%d_%d.mpeg", mCameraIndex, - videoSize.width, videoSize.height, mVideoIdx++); - - if ( mVideoFd < 0 ) { - mVideoFd = open(fileName, O_CREAT | O_RDWR ); - } - - if ( mVideoFd < 0 ) { - ERROR("Could not open video file for writing %s!", fileName); - return UNKNOWN_ERROR; - } - - ret = mRecorder->setOutputFile(mVideoFd, 0, 0); - if ( ret != NO_ERROR ) { - ERROR("Could not set output file (%d)", ret); - return ret; - } - - ret = mRecorder->setVideoSize(videoSize.width, videoSize.height); - if ( ret != NO_ERROR ) { - ERROR("Could not set video size %dx%d", videoSize.width, - videoSize.height); - return ret; - } - - ret = mRecorder->setVideoFrameRate(30); - if ( ret != NO_ERROR ) { - ERROR("Could not set video frame rate (%d)", ret); - return ret; - } - - ret = mRecorder->setAudioEncoder(AUDIO_ENCODER_DEFAULT); - if ( ret != NO_ERROR ) { - ERROR("Could not set audio encoder (%d)", ret); - return ret; - } - - signalFinished(); - return ret; -} - -/*=========================================================================== - * FUNCTION : unconfigureViVRecording - * - * DESCRIPTION: Unconfigures video in video recording - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::unconfigureRecorder() -{ - useLock(); - - if ( !mRecordRunning ) { - mResizePreview = true; - mParams.set("recording-hint", "false"); - mRecordingHint = false; - mCamera->setParameters(mParams.flatten()); - } - - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : configureViVRecording - * - * DESCRIPTION: Configures video in video recording - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::configureViVRecording() -{ - status_t ret = NO_ERROR; - - mResizePreview = true; - mParams.set("recording-hint", "true"); - mRecordingHint = true; - mCamera->setParameters(mParams.flatten()); - mCamera->setRecordingProxyListener(this); - - signalFinished(); - return ret; -} - -/*=========================================================================== - * FUNCTION : startRecording - * - * DESCRIPTION: triggers start recording - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::startRecording() -{ - useLock(); - status_t ret = NO_ERROR; - - - if ( mPreviewRunning ) { - - mCamera->unlock(); - - ret = mRecorder->prepare(); - if ( ret != NO_ERROR ) { - ERROR("Could not prepare recorder"); - return ret; - } - - ret = mRecorder->start(); - if ( ret != NO_ERROR ) { - ERROR("Could not start recorder"); - return ret; - } - - mRecordRunning = true; - } - signalFinished(); - return ret; -} - -/*=========================================================================== - * FUNCTION : stopRecording - * - * DESCRIPTION: triggers start recording - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::stopRecording() -{ - useLock(); - status_t ret = NO_ERROR; - - if ( mRecordRunning ) { - mRecorder->stop(); - close(mVideoFd); - mVideoFd = -1; - - mRecordRunning = false; - } - - signalFinished(); - - return ret; -} - -/*=========================================================================== - * FUNCTION : startViVRecording - * - * DESCRIPTION: Starts video in video recording - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::startViVRecording() -{ - useLock(); - status_t ret; - - if (mInterpr->mViVVid.VideoSizes[0].width * - mInterpr->mViVVid.VideoSizes[0].height >= - mInterpr->mViVVid.VideoSizes[1].width * - mInterpr->mViVVid.VideoSizes[1].height) { - mInterpr->mViVBuff.buffSize = calcBufferSize( - mInterpr->mViVVid.VideoSizes[1].width, - mInterpr->mViVVid.VideoSizes[1].height); - if (mInterpr->mViVBuff.buff == NULL) { - mInterpr->mViVBuff.buff = - (void *)malloc(mInterpr->mViVBuff.buffSize); - } - mInterpr->mViVVid.sourceCameraID = 1; - mInterpr->mViVVid.destinationCameraID = 0; - - } else { - mInterpr->mViVBuff.buffSize = calcBufferSize( - mInterpr->mViVVid.VideoSizes[0].width, - mInterpr->mViVVid.VideoSizes[0].height); - if (mInterpr->mViVBuff.buff == NULL) { - mInterpr->mViVBuff.buff = - (void *)malloc(mInterpr->mViVBuff.buffSize); - } - mInterpr->mViVVid.sourceCameraID = 0; - mInterpr->mViVVid.destinationCameraID = 1; - } - - ret = mCamera->startRecording(); - - signalFinished(); - return ret; -} - -/*=========================================================================== - * FUNCTION : stopViVRecording - * - * DESCRIPTION: Stops video in video recording - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::stopViVRecording() -{ - useLock(); - status_t ret = NO_ERROR; - - mCamera->stopRecording(); - - signalFinished(); - return ret; -} - -/*=========================================================================== - * FUNCTION : stopPreview - * - * DESCRIPTION: stops camera preview - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::stopPreview() -{ - useLock(); - status_t ret = NO_ERROR; - - if ( mHardwareActive ) { - mCamera->stopPreview(); - ret = destroyPreviewSurface(); - } - - mPreviewRunning = false; - mResizePreview = true; - - signalFinished(); - - return ret; -} - -/*=========================================================================== - * FUNCTION : resumePreview - * - * DESCRIPTION: resumes camera preview after image capture - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::resumePreview() -{ - useLock(); - status_t ret = NO_ERROR; - - if ( mHardwareActive ) { - ret = mCamera->startPreview(); - mPreviewRunning = true; - } else { - ret = NO_INIT; - } - - signalFinished(); - return ret; -} - -/*=========================================================================== - * FUNCTION : nextPreviewSize - * - * DESCRIPTION: Iterates through all supported preview sizes. - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::nextPreviewSize() -{ - useLock(); - if ( mHardwareActive ) { - mCurrentPreviewSizeIdx += 1; - mCurrentPreviewSizeIdx %= mSupportedPreviewSizes.size(); - Size previewSize = mSupportedPreviewSizes.itemAt( - mCurrentPreviewSizeIdx); - mParams.setPreviewSize(previewSize.width, - previewSize.height); - mResizePreview = true; - - if ( mPreviewRunning ) { - mCamera->stopPreview(); - mCamera->setParameters(mParams.flatten()); - mCamera->startPreview(); - } else { - mCamera->setParameters(mParams.flatten()); - } - } - - signalFinished(); - return NO_ERROR; -} - - -/*=========================================================================== - * FUNCTION : setPreviewSize - * - * DESCRIPTION: Sets exact preview size if supported - * - * PARAMETERS : format size in the form of WIDTHxHEIGHT - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::setPreviewSize(const char *format) -{ - useLock(); - if ( mHardwareActive ) { - int newHeight; - int newWidth; - sscanf(format, "%dx%d", &newWidth, &newHeight); - - unsigned int i; - for (i = 0; i < mSupportedPreviewSizes.size(); ++i) { - Size previewSize = mSupportedPreviewSizes.itemAt(i); - if ( newWidth == previewSize.width && - newHeight == previewSize.height ) - { - break; - } - - } - if ( i == mSupportedPreviewSizes.size()) - { - printf("Preview size %dx%d not supported !\n", - newWidth, newHeight); - return INVALID_OPERATION; - } - - mParams.setPreviewSize(newWidth, - newHeight); - mResizePreview = true; - - if ( mPreviewRunning ) { - mCamera->stopPreview(); - mCamera->setParameters(mParams.flatten()); - mCamera->startPreview(); - } else { - mCamera->setParameters(mParams.flatten()); - } - } - - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : getCurrentPreviewSize - * - * DESCRIPTION: queries the currently configured preview size - * - * PARAMETERS : - * @previewSize : preview size currently configured - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::getCurrentPreviewSize(Size &previewSize) -{ - useLock(); - if ( mHardwareActive ) { - previewSize = mSupportedPreviewSizes.itemAt(mCurrentPreviewSizeIdx); - } - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : nextPictureSize - * - * DESCRIPTION: Iterates through all supported picture sizes. - * - * PARAMETERS : None - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::nextPictureSize() -{ - useLock(); - if ( mHardwareActive ) { - mCurrentPictureSizeIdx += 1; - mCurrentPictureSizeIdx %= mSupportedPictureSizes.size(); - Size pictureSize = mSupportedPictureSizes.itemAt( - mCurrentPictureSizeIdx); - mParams.setPictureSize(pictureSize.width, - pictureSize.height); - mCamera->setParameters(mParams.flatten()); - } - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : setPictureSize - * - * DESCRIPTION: Sets exact preview size if supported - * - * PARAMETERS : format size in the form of WIDTHxHEIGHT - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::setPictureSize(const char *format) -{ - useLock(); - if ( mHardwareActive ) { - int newHeight; - int newWidth; - sscanf(format, "%dx%d", &newWidth, &newHeight); - - unsigned int i; - for (i = 0; i < mSupportedPictureSizes.size(); ++i) { - Size PictureSize = mSupportedPictureSizes.itemAt(i); - if ( newWidth == PictureSize.width && - newHeight == PictureSize.height ) - { - break; - } - - } - if ( i == mSupportedPictureSizes.size()) - { - printf("Preview size %dx%d not supported !\n", - newWidth, newHeight); - return INVALID_OPERATION; - } - - mParams.setPictureSize(newWidth, - newHeight); - mCamera->setParameters(mParams.flatten()); - } - - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : nextVideoSize - * - * DESCRIPTION: Select the next available video size - * - * PARAMETERS : none - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::nextVideoSize() -{ - useLock(); - if ( mHardwareActive ) { - mCurrentVideoSizeIdx += 1; - mCurrentVideoSizeIdx %= mSupportedVideoSizes.size(); - Size videoSize = mSupportedVideoSizes.itemAt(mCurrentVideoSizeIdx); - mParams.setVideoSize(videoSize.width, - videoSize.height); - mCamera->setParameters(mParams.flatten()); - mInterpr->setViVSize((Size) mSupportedVideoSizes.itemAt( - mCurrentVideoSizeIdx), mCameraIndex); - } - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : setVideoSize - * - * DESCRIPTION: Set video size - * - * PARAMETERS : - * @format : format - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::setVideoSize(const char *format) -{ - useLock(); - if ( mHardwareActive ) { - int newHeight; - int newWidth; - sscanf(format, "%dx%d", &newWidth, &newHeight); - - unsigned int i; - for (i = 0; i < mSupportedVideoSizes.size(); ++i) { - Size PictureSize = mSupportedVideoSizes.itemAt(i); - if ( newWidth == PictureSize.width && - newHeight == PictureSize.height ) - { - break; - } - - } - if ( i == mSupportedVideoSizes.size()) - { - printf("Preview size %dx%d not supported !\n", - newWidth, newHeight); - return INVALID_OPERATION; - } - - mParams.setVideoSize(newWidth, - newHeight); - mCamera->setParameters(mParams.flatten()); - } - - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : getCurrentVideoSize - * - * DESCRIPTION : Get current video size - * - * PARAMETERS : - * @videoSize: video Size - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::getCurrentVideoSize(Size &videoSize) -{ - useLock(); - if ( mHardwareActive ) { - videoSize = mSupportedVideoSizes.itemAt(mCurrentVideoSizeIdx); - } - signalFinished(); - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : getCurrentPictureSize - * - * DESCRIPTION: queries the currently configured picture size - * - * PARAMETERS : - * @pictureSize : picture size currently configured - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t CameraContext::getCurrentPictureSize(Size &pictureSize) -{ - useLock(); - if ( mHardwareActive ) { - pictureSize = mSupportedPictureSizes.itemAt(mCurrentPictureSizeIdx); - } - signalFinished(); - return NO_ERROR; -} - -}; //namespace qcamera ends here - -using namespace qcamera; - -/*=========================================================================== - * FUNCTION : printMenu - * - * DESCRIPTION: prints the available camera options - * - * PARAMETERS : - * @currentCamera : camera context currently being used - * - * RETURN : None - *==========================================================================*/ -void CameraContext::printMenu(sp<CameraContext> currentCamera) -{ - if ( !mDoPrintMenu ) return; - Size currentPictureSize, currentPreviewSize, currentVideoSize; - - assert(currentCamera.get()); - - currentCamera->getCurrentPictureSize(currentPictureSize); - currentCamera->getCurrentPreviewSize(currentPreviewSize); - currentCamera->getCurrentVideoSize(currentVideoSize); - - printf("\n\n=========== FUNCTIONAL TEST MENU ===================\n\n"); - - printf(" \n\nSTART / STOP / GENERAL SERVICES \n"); - printf(" -----------------------------\n"); - printf(" %c. Switch camera - Current Index: %d\n", - Interpreter::SWITCH_CAMERA_CMD, - currentCamera->getCameraIndex()); - printf(" %c. Resume Preview after capture \n", - Interpreter::RESUME_PREVIEW_CMD); - printf(" %c. Quit \n", - Interpreter::EXIT_CMD); - printf(" %c. Camera Capability Dump", - Interpreter::DUMP_CAPS_CMD); - - printf(" \n\n PREVIEW SUB MENU \n"); - printf(" -----------------------------\n"); - printf(" %c. Start Preview\n", - Interpreter::START_PREVIEW_CMD); - printf(" %c. Stop Preview\n", - Interpreter::STOP_PREVIEW_CMD); - printf(" %c. Preview size: %dx%d\n", - Interpreter::CHANGE_PREVIEW_SIZE_CMD, - currentPreviewSize.width, - currentPreviewSize.height); - printf(" %c. Video size: %dx%d\n", - Interpreter::CHANGE_VIDEO_SIZE_CMD, - currentVideoSize.width, - currentVideoSize.height); - printf(" %c. Start Recording\n", - Interpreter::START_RECORD_CMD); - printf(" %c. Stop Recording\n", - Interpreter::STOP_RECORD_CMD); - printf(" %c. Start ViV Recording\n", - Interpreter::START_VIV_RECORD_CMD); - printf(" %c. Stop ViV Recording\n", - Interpreter::STOP_VIV_RECORD_CMD); - printf(" %c. Enable preview frames\n", - Interpreter::ENABLE_PRV_CALLBACKS_CMD); - printf(" %c. Trigger autofocus \n", - Interpreter::AUTOFOCUS_CMD); - - printf(" \n\n IMAGE CAPTURE SUB MENU \n"); - printf(" -----------------------------\n"); - printf(" %c. Take picture/Full Press\n", - Interpreter::TAKEPICTURE_CMD); - printf(" %c. Take picture in picture\n", - Interpreter::TAKEPICTURE_IN_PICTURE_CMD); - printf(" %c. Picture size: %dx%d\n", - Interpreter::CHANGE_PICTURE_SIZE_CMD, - currentPictureSize.width, - currentPictureSize.height); - - printf("\n"); - printf(" Choice: "); -} - -/*=========================================================================== - * FUNCTION : enablePrintPreview - * - * DESCRIPTION: Enables printing the preview - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -void CameraContext::enablePrintPreview() -{ - mDoPrintMenu = true; -} - -/*=========================================================================== - * FUNCTION : disablePrintPreview - * - * DESCRIPTION: Disables printing the preview - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -void CameraContext::disablePrintPreview() -{ - mDoPrintMenu = false; -} - -/*=========================================================================== - * FUNCTION : enablePiPCapture - * - * DESCRIPTION: Enables picture in picture capture - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -void CameraContext::enablePiPCapture() -{ - mPiPCapture = true; -} - -/*=========================================================================== - * FUNCTION : disablePiPCapture - * - * DESCRIPTION: Disables picture in picture capture - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -void CameraContext::disablePiPCapture() -{ - mPiPCapture = false; -} - -/*=========================================================================== - * FUNCTION : configureViVCodec - * - * DESCRIPTION: Configures video in video codec - * - * PARAMETERS : none - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t Interpreter::configureViVCodec() -{ - status_t ret = NO_ERROR; - char fileName[100]; - sp<AMessage> format = new AMessage; - sp<ALooper> looper = new ALooper; - - if (mTestContext->mViVVid.VideoSizes[0].width * - mTestContext->mViVVid.VideoSizes[0].height >= - mTestContext->mViVVid.VideoSizes[1].width * - mTestContext->mViVVid.VideoSizes[1].height) { - sprintf(fileName, "/sdcard/ViV_vid_%dx%d_%d.mp4", - mTestContext->mViVVid.VideoSizes[0].width, - mTestContext->mViVVid.VideoSizes[0].height, - mTestContext->mViVVid.ViVIdx++); - format->setInt32("width", mTestContext->mViVVid.VideoSizes[0].width); - format->setInt32("height", mTestContext->mViVVid.VideoSizes[0].height); - } else { - sprintf(fileName, "/sdcard/ViV_vid_%dx%d_%d.mp4", - mTestContext->mViVVid.VideoSizes[1].width, - mTestContext->mViVVid.VideoSizes[1].height, - mTestContext->mViVVid.ViVIdx++); - format->setInt32("width", mTestContext->mViVVid.VideoSizes[1].width); - format->setInt32("height", mTestContext->mViVVid.VideoSizes[1].height); - } - mTestContext->mViVVid.muxer = new MediaMuxer( - fileName, MediaMuxer::OUTPUT_FORMAT_MPEG_4); - - format->setString("mime", "video/avc"); - format->setInt32("color-format", OMX_COLOR_FormatAndroidOpaque); - - format->setInt32("bitrate", 1000000); - format->setFloat("frame-rate", 30); - format->setInt32("i-frame-interval", 10); - - looper->setName("ViV_recording_looper"); - looper->start(); - ALOGV("Creating codec"); - mTestContext->mViVVid.codec = MediaCodec::CreateByType( - looper, "video/avc", true); - if (mTestContext->mViVVid.codec == NULL) { - fprintf(stderr, "ERROR: unable to create video/avc codec instance\n"); - return UNKNOWN_ERROR; - } - ret = mTestContext->mViVVid.codec->configure(format, NULL, NULL, - MediaCodec::CONFIGURE_FLAG_ENCODE); - if (ret != NO_ERROR) { - mTestContext->mViVVid.codec->release(); - mTestContext->mViVVid.codec.clear(); - - fprintf(stderr, "ERROR: unable to configure codec (err=%d)\n", ret); - return ret; - } - - ALOGV("Creating buffer producer"); - ret = mTestContext->mViVVid.codec->createInputSurface( - &mTestContext->mViVVid.bufferProducer); - if (ret != NO_ERROR) { - mTestContext->mViVVid.codec->release(); - mTestContext->mViVVid.codec.clear(); - - fprintf(stderr, - "ERROR: unable to create encoder input surface (err=%d)\n", ret); - return ret; - } - - ret = mTestContext->mViVVid.codec->start(); - if (ret != NO_ERROR) { - mTestContext->mViVVid.codec->release(); - mTestContext->mViVVid.codec.clear(); - - fprintf(stderr, "ERROR: unable to start codec (err=%d)\n", ret); - return ret; - } - ALOGV("Codec prepared"); - - mTestContext->mViVVid.surface = new Surface( - mTestContext->mViVVid.bufferProducer); - mTestContext->mViVVid.ANW = mTestContext->mViVVid.surface; - ret = native_window_api_connect(mTestContext->mViVVid.ANW.get(), - NATIVE_WINDOW_API_CPU); - if (mTestContext->mViVVid.VideoSizes[0].width * - mTestContext->mViVVid.VideoSizes[0].height >= - mTestContext->mViVVid.VideoSizes[1].width * - mTestContext->mViVVid.VideoSizes[1].height) { - native_window_set_buffers_geometry(mTestContext->mViVVid.ANW.get(), - mTestContext->mViVVid.VideoSizes[0].width, - mTestContext->mViVVid.VideoSizes[0].height, - HAL_PIXEL_FORMAT_NV12_ENCODEABLE); - } else { - native_window_set_buffers_geometry(mTestContext->mViVVid.ANW.get(), - mTestContext->mViVVid.VideoSizes[1].width, - mTestContext->mViVVid.VideoSizes[1].height, - HAL_PIXEL_FORMAT_NV12_ENCODEABLE); - } - native_window_set_usage(mTestContext->mViVVid.ANW.get(), - GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN); - native_window_set_buffer_count(mTestContext->mViVVid.ANW.get(), - mTestContext->mViVVid.buff_cnt); - - ViVEncoderThread(); - - return ret; -} - -/*=========================================================================== - * FUNCTION : unconfigureViVCodec - * - * DESCRIPTION: Unconfigures video in video codec - * - * PARAMETERS : none - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t Interpreter::unconfigureViVCodec() -{ - status_t ret = NO_ERROR; - - ret = native_window_api_disconnect(mTestContext->mViVVid.ANW.get(), - NATIVE_WINDOW_API_CPU); - mTestContext->mViVVid.bufferProducer = NULL; - mTestContext->mViVVid.codec->stop(); - pthread_join(mViVEncThread, NULL); - mTestContext->mViVVid.muxer->stop(); - mTestContext->mViVVid.codec->release(); - mTestContext->mViVVid.codec.clear(); - mTestContext->mViVVid.muxer.clear(); - mTestContext->mViVVid.surface.clear(); - return ret; -} - -/*=========================================================================== - * FUNCTION : Interpreter - * - * DESCRIPTION: Interpreter constructor - * - * PARAMETERS : none - * - * RETURN : none - *==========================================================================*/ -Interpreter::Interpreter(const char *file) - : mCmdIndex(0) - , mScript(NULL) -{ - if (!file){ - printf("no File Given\n"); - mUseScript = false; - return; - } - - FILE *fh = fopen(file, "r"); - if ( !fh ) { - printf("Could not open file %s\n", file); - mUseScript = false; - return; - } - - fseek(fh, 0, SEEK_END); - int len = ftell(fh); - rewind(fh); - - if( !len ) { - printf("Script file %s is empty !\n", file); - fclose(fh); - return; - } - - mScript = new char[len + 1]; - if ( !mScript ) { - fclose(fh); - return; - } - - fread(mScript, sizeof(char), len, fh); - mScript[len] = '\0'; // ensure null terminated; - fclose(fh); - - - char *p1; - char *p2; - p1 = p2 = mScript; - - do { - switch (*p1) { - case '\0': - case '|': - p1++; - break; - case SWITCH_CAMERA_CMD: - case RESUME_PREVIEW_CMD: - case START_PREVIEW_CMD: - case STOP_PREVIEW_CMD: - case CHANGE_PREVIEW_SIZE_CMD: - case CHANGE_PICTURE_SIZE_CMD: - case START_RECORD_CMD: - case STOP_RECORD_CMD: - case START_VIV_RECORD_CMD: - case STOP_VIV_RECORD_CMD: - case DUMP_CAPS_CMD: - case AUTOFOCUS_CMD: - case TAKEPICTURE_CMD: - case TAKEPICTURE_IN_PICTURE_CMD: - case ENABLE_PRV_CALLBACKS_CMD: - case EXIT_CMD: - case DELAY: - p2 = p1; - while( (p2 != (mScript + len)) && (*p2 != '|')) { - p2++; - } - *p2 = '\0'; - if (p2 == (p1 + 1)) - mCommands.push_back(Command( - static_cast<Interpreter::Commands_e>(*p1))); - else - mCommands.push_back(Command( - static_cast<Interpreter::Commands_e>(*p1), (p1 + 1))); - p1 = p2; - break; - default: - printf("Invalid cmd %c \n", *p1); - do { - p1++; - - } while(*p1 != '|' && p1 != (mScript + len)); - - } - } while(p1 != (mScript + len)); - mUseScript = true; -} - -/*=========================================================================== - * FUNCTION : ~Interpreter - * - * DESCRIPTION: Interpreter destructor - * - * PARAMETERS : none - * - * RETURN : none - *==========================================================================*/ -Interpreter::~Interpreter() -{ - if ( mScript ) - delete[] mScript; - - mCommands.clear(); -} - -/*=========================================================================== - * FUNCTION : getCommand - * - * DESCRIPTION : Get a command from interpreter - * - * PARAMETERS : - * @currentCamera: Current camera context - * - * RETURN : command - *==========================================================================*/ -Interpreter::Command Interpreter::getCommand( - sp<CameraContext> currentCamera) -{ - if( mUseScript ) { - return mCommands[mCmdIndex++]; - } else { - currentCamera->printMenu(currentCamera); - return Interpreter::Command( - static_cast<Interpreter::Commands_e>(getchar())); - } -} - -/*=========================================================================== - * FUNCTION : TestContext - * - * DESCRIPTION : TestContext constructor - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -TestContext::TestContext() -{ - sp<CameraContext> camera; - int i = 0; - mTestRunning = false; - mInterpreter = NULL; - mViVVid.ViVIdx = 0; - mViVVid.buff_cnt = 9; - mViVVid.graphBuf = 0; - mViVVid.mappedBuff = NULL; - mViVVid.isBuffValid = false; - mViVVid.sourceCameraID = -1; - mViVVid.destinationCameraID = -1; - memset(&mViVBuff, 0, sizeof(ViVBuff_t)); - - ProcessState::self()->startThreadPool(); - - do { - camera = new CameraContext(i); - if ( NULL == camera.get() ) { - break; - } - camera->setTestCtxInstance(this); - - status_t stat = camera->openCamera(); - if ( NO_ERROR != stat ) { - printf("Error encountered Openging camera id : %d\n", i); - break; - } - - mAvailableCameras.add(camera); - i++; - } while ( i < camera->getNumberOfCameras() ) ; - - if (i < camera->getNumberOfCameras() ) { - for (size_t j = 0; j < mAvailableCameras.size(); j++) { - camera = mAvailableCameras.itemAt(j); - camera->closeCamera(); - camera.clear(); - } - - mAvailableCameras.clear(); - } -} - -/*=========================================================================== - * FUNCTION : ~TestContext - * - * DESCRIPTION : TestContext destructor - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -TestContext::~TestContext() -{ - delete mInterpreter; - - for (size_t j = 0; j < mAvailableCameras.size(); j++) { - sp<CameraContext> camera = mAvailableCameras.itemAt(j); - camera->closeCamera(); - camera.clear(); - } - - mAvailableCameras.clear(); -} - -/*=========================================================================== - * FUNCTION : GetCamerasNum - * - * DESCRIPTION : Get the number of available cameras - * - * PARAMETERS : None - * - * RETURN : Number of cameras - *==========================================================================*/ -int32_t TestContext::GetCamerasNum() -{ - return mAvailableCameras.size(); -} - -/*=========================================================================== - * FUNCTION : AddScriptFromFile - * - * DESCRIPTION : Add script from file - * - * PARAMETERS : - * @scriptFile : Script file - * - * RETURN : status_t type of status - * NO_ERROR -- success - * none-zero failure code - *==========================================================================*/ -status_t TestContext::AddScriptFromFile(const char *scriptFile) -{ - mInterpreter = new Interpreter(scriptFile); - mInterpreter->setTestCtxInst(this); - - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : releasePiPBuff - * - * DESCRIPTION : Release video in video temp buffer - * - * PARAMETERS : None - * - * RETURN : None - *==========================================================================*/ -void Interpreter::releasePiPBuff() { - free(mTestContext->mViVBuff.buff); - mTestContext->mViVBuff.buff = NULL; -} - -/*=========================================================================== - * FUNCTION : functionalTest - * - * DESCRIPTION: queries and executes client supplied commands for testing a - * particular camera. - * - * PARAMETERS : - * @availableCameras : List with all cameras supported - * - * RETURN : status_t type of status - * NO_ERROR -- continue testing - * none-zero -- quit test - *==========================================================================*/ -status_t TestContext::FunctionalTest() -{ - status_t stat = NO_ERROR; - - assert(mAvailableCameras.size()); - - if ( !mInterpreter ) { - mInterpreter = new Interpreter(); - mInterpreter->setTestCtxInst(this); - } - - - mTestRunning = true; - - while (mTestRunning) { - sp<CameraContext> currentCamera = - mAvailableCameras.itemAt(mCurrentCameraIndex); - Interpreter::Command command = - mInterpreter->getCommand(currentCamera); - currentCamera->enablePrintPreview(); - - switch (command.cmd) { - case Interpreter::SWITCH_CAMERA_CMD: - { - mCurrentCameraIndex++; - mCurrentCameraIndex %= mAvailableCameras.size(); - currentCamera = mAvailableCameras.itemAt(mCurrentCameraIndex); - } - break; - - case Interpreter::RESUME_PREVIEW_CMD: - { - stat = currentCamera->resumePreview(); - } - break; - - case Interpreter::START_PREVIEW_CMD: - { - stat = currentCamera->startPreview(); - } - break; - - case Interpreter::STOP_PREVIEW_CMD: - { - stat = currentCamera->stopPreview(); - } - break; - - case Interpreter::CHANGE_VIDEO_SIZE_CMD: - { - if ( command.arg ) - stat = currentCamera->setVideoSize(command.arg); - else - stat = currentCamera->nextVideoSize(); - } - break; - - case Interpreter::CHANGE_PREVIEW_SIZE_CMD: - { - if ( command.arg ) - stat = currentCamera->setPreviewSize(command.arg); - else - stat = currentCamera->nextPreviewSize(); - } - break; - - case Interpreter::CHANGE_PICTURE_SIZE_CMD: - { - if ( command.arg ) - stat = currentCamera->setPictureSize(command.arg); - else - stat = currentCamera->nextPictureSize(); - } - break; - - case Interpreter::DUMP_CAPS_CMD: - { - currentCamera->printSupportedParams(); - } - break; - - case Interpreter::AUTOFOCUS_CMD: - { - stat = currentCamera->autoFocus(); - } - break; - - case Interpreter::TAKEPICTURE_CMD: - { - stat = currentCamera->takePicture(); - } - break; - - case Interpreter::TAKEPICTURE_IN_PICTURE_CMD: - { - if (mAvailableCameras.size() == 2) { - mSaveCurrentCameraIndex = mCurrentCameraIndex; - for (size_t i = 0; i < mAvailableCameras.size(); i++) { - mCurrentCameraIndex = i; - currentCamera = mAvailableCameras.itemAt( - mCurrentCameraIndex); - currentCamera->enablePiPCapture(); - stat = currentCamera->takePicture(); - } - mCurrentCameraIndex = mSaveCurrentCameraIndex; - } else { - printf("Number of available sensors should be 2\n"); - } - } - break; - - case Interpreter::ENABLE_PRV_CALLBACKS_CMD: - { - stat = currentCamera->enablePreviewCallbacks(); - } - break; - - case Interpreter::START_RECORD_CMD: - { - stat = currentCamera->stopPreview(); - stat = currentCamera->configureRecorder(); - stat = currentCamera->startPreview(); - stat = currentCamera->startRecording(); - } - break; - - case Interpreter::STOP_RECORD_CMD: - { - stat = currentCamera->stopRecording(); - - stat = currentCamera->stopPreview(); - stat = currentCamera->unconfigureRecorder(); - stat = currentCamera->startPreview(); - } - break; - - case Interpreter::START_VIV_RECORD_CMD: - { - - if (mAvailableCameras.size() == 2) { - mSaveCurrentCameraIndex = mCurrentCameraIndex; - stat = mInterpreter->configureViVCodec(); - for ( size_t i = 0; i < mAvailableCameras.size(); i++ ) { - mCurrentCameraIndex = i; - currentCamera = mAvailableCameras.itemAt( - mCurrentCameraIndex); - stat = currentCamera->stopPreview(); - stat = currentCamera->configureViVRecording(); - stat = currentCamera->startPreview(); - stat = currentCamera->startViVRecording(); - } - mCurrentCameraIndex = mSaveCurrentCameraIndex; - } else { - printf("Number of available sensors should be 2\n"); - } - - } - break; - - case Interpreter::STOP_VIV_RECORD_CMD: - { - if (mAvailableCameras.size() == 2) { - mSaveCurrentCameraIndex = mCurrentCameraIndex; - for ( size_t i = 0; i < mAvailableCameras.size(); i++ ) { - mCurrentCameraIndex = i; - currentCamera = mAvailableCameras.itemAt( - mCurrentCameraIndex); - stat = currentCamera->stopViVRecording(); - stat = currentCamera->stopPreview(); - stat = currentCamera->unconfigureRecorder(); - stat = currentCamera->startPreview(); - } - stat = mInterpreter->unconfigureViVCodec(); - mCurrentCameraIndex = mSaveCurrentCameraIndex; - - mInterpreter->releasePiPBuff(); - } else { - printf("Number of available sensors should be 2\n"); - } - } - break; - - case Interpreter::EXIT_CMD: - { - currentCamera->stopPreview(); - mTestRunning = false; - } - break; - case Interpreter::DELAY: - { - if ( command.arg ) - usleep(1000 * atoi(command.arg)); - } - break; - default: - { - currentCamera->disablePrintPreview(); - } - break; - } - printf("Command status 0x%x \n", stat); - } - - return NO_ERROR; -} - -/*=========================================================================== - * FUNCTION : setViVSize - * - * DESCRIPTION : Set video in video size - * - * PARAMETERS : - * @VideoSize : video size - * @camIndex : camera index - * - * RETURN : none - *==========================================================================*/ -void TestContext::setViVSize(Size VideoSize, int camIndex) -{ - mViVVid.VideoSizes[camIndex] = VideoSize; -} - -/*=========================================================================== - * FUNCTION : main - * - * DESCRIPTION : main function - * - * PARAMETERS : - * @argc : argc - * @argv : argv - * - * RETURN : int status - *==========================================================================*/ -int main(int argc, char *argv[]) -{ - TestContext ctx; - - if (argc > 1) { - if ( ctx.AddScriptFromFile((const char *)argv[1]) ) { - printf("Could not add script file... " - "continuing in normal menu mode! \n"); - } - } - - ctx.FunctionalTest(); - - return 0; -} diff --git a/camera/QCamera2/HAL/test/qcamera_test.h b/camera/QCamera2/HAL/test/qcamera_test.h deleted file mode 100644 index c909133a..00000000 --- a/camera/QCamera2/HAL/test/qcamera_test.h +++ /dev/null @@ -1,356 +0,0 @@ -/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef QCAMERA_TEST_H -#define QCAMERA_TEST_H - -#include <SkData.h> -#include <SkBitmap.h> -#include <SkStream.h> - -namespace qcamera { - -using namespace android; - -class TestContext; - -class CameraContext : public CameraListener, - public ICameraRecordingProxyListener{ -public: - typedef enum { - READ_METADATA = 1, - READ_IMAGE = 2, - READ_ALL = 3 - } ReadMode_t; - - // This structure is used to store jpeg file sections in memory. - typedef struct { - unsigned char * Data; - int Type; - unsigned Size; - } Sections_t; - -public: - - CameraContext(int cameraIndex); - virtual ~CameraContext(); - - - - status_t openCamera(); - status_t closeCamera(); - - status_t startPreview(); - status_t stopPreview(); - status_t resumePreview(); - status_t autoFocus(); - status_t enablePreviewCallbacks(); - status_t takePicture(); - status_t startRecording(); - status_t stopRecording(); - status_t startViVRecording(); - status_t stopViVRecording(); - status_t configureViVRecording(); - - status_t nextPreviewSize(); - status_t setPreviewSize(const char *format); - status_t getCurrentPreviewSize(Size &previewSize); - - status_t nextPictureSize(); - status_t getCurrentPictureSize(Size &pictureSize); - status_t setPictureSize(const char *format); - - status_t nextVideoSize(); - status_t setVideoSize(const char *format); - status_t getCurrentVideoSize(Size &videoSize); - status_t configureRecorder(); - status_t unconfigureRecorder(); - Sections_t *FindSection(int SectionType); - status_t ReadSectionsFromBuffer (unsigned char *buffer, - unsigned int buffer_size, ReadMode_t ReadMode); - virtual IBinder* onAsBinder(); - void setTestCtxInstance(TestContext *instance); - - void printMenu(sp<CameraContext> currentCamera); - void printSupportedParams(); - - - int getCameraIndex() { return mCameraIndex; } - int getNumberOfCameras(); - void enablePrintPreview(); - void disablePrintPreview(); - void enablePiPCapture(); - void disablePiPCapture(); - void CheckSectionsAllocated(); - void DiscardData(); - void DiscardSections(); - size_t calcBufferSize(int width, int height); - size_t calcStride(int width); - size_t calcYScanLines(int height); - size_t calcUVScanLines(int height); - - virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2); - virtual void postData(int32_t msgType, - const sp<IMemory>& dataPtr, - camera_frame_metadata_t *metadata); - - virtual void postDataTimestamp(nsecs_t timestamp, - int32_t msgType, - const sp<IMemory>& dataPtr); - virtual void dataCallbackTimestamp(nsecs_t timestamp, - int32_t msgType, - const sp<IMemory>& dataPtr); - virtual void postRecordingFrameHandleTimestamp(nsecs_t timestamp, - native_handle_t* handle); - virtual void recordingFrameHandleCallbackTimestamp(nsecs_t timestamp, - native_handle_t* handle); - -private: - - status_t createPreviewSurface(unsigned int width, - unsigned int height, - int32_t pixFormat); - status_t destroyPreviewSurface(); - - status_t saveFile(const sp<IMemory>& mem, String8 path); - SkBitmap * PiPCopyToOneFile(SkBitmap *bitmap0, SkBitmap *bitmap1); - SkBitmap *decodeJPEG(const sp<IMemory>& mem); - status_t encodeJPEG(SkWStream * stream, const SkBitmap *bitmap, - String8 path); - void previewCallback(const sp<IMemory>& mem); - - static int JpegIdx; - int mCameraIndex; - bool mResizePreview; - bool mHardwareActive; - bool mPreviewRunning; - bool mRecordRunning; - int mVideoFd; - int mVideoIdx; - bool mRecordingHint; - bool mDoPrintMenu; - bool mPiPCapture; - static int mPiPIdx; - int mfmtMultiplier; - int mWidthTmp[2]; - int mHeightTmp[2]; - int mSectionsRead; - int mSectionsAllocated; - Sections_t * mSections; - Sections_t * mJEXIFTmp; - Sections_t mJEXIFSection; - int mHaveAll; - TestContext *mInterpr; - Mutex mViVLock; - Condition mViVCond; - bool mViVinUse; - - - sp<Camera> mCamera; - sp<SurfaceComposerClient> mClient; - sp<SurfaceControl> mSurfaceControl; - sp<Surface> mPreviewSurface; - sp<MediaRecorder> mRecorder; - CameraParameters mParams; - SkBitmap *skBMDec; - SkImageEncoder* skJpegEnc; - static SkBitmap *skBMtmp[2]; - static sp<IMemory> PiPPtrTmp[2]; - - int mCurrentPreviewSizeIdx; - Size getPreviewSizeFromVideoSizes(Size currentVideoSize); - int mCurrentPictureSizeIdx; - int mCurrentVideoSizeIdx; - Vector<Size> mSupportedPreviewSizes; - Vector<Size> mSupportedPictureSizes; - Vector<Size> mSupportedVideoSizes; - - bool mInUse; - Mutex mLock; - Condition mCond; - - void useLock(); - void signalFinished(); - void mutexLock(); - void mutexUnlock(); - - //------------------------------------------------------------------------ - // JPEG markers consist of one or more 0xFF bytes, followed by a marker - // code byte (which is not an FF). Here are the marker codes of interest - // in this program. (See jdmarker.c for a more complete list.) - //------------------------------------------------------------------------ - #define M_SOF0 0xC0 // Start Of Frame N - #define M_SOF1 0xC1 // N indicates which compression process - #define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use - #define M_SOF3 0xC3 - #define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers - #define M_SOF6 0xC6 - #define M_SOF7 0xC7 - #define M_SOF9 0xC9 - #define M_SOF10 0xCA - #define M_SOF11 0xCB - #define M_SOF13 0xCD - #define M_SOF14 0xCE - #define M_SOF15 0xCF - #define M_SOI 0xD8 // Start Of Image (beginning of datastream) - #define M_EOI 0xD9 // End Of Image (end of datastream) - #define M_SOS 0xDA // Start Of Scan (begins compressed data) - #define M_JFIF 0xE0 // Jfif marker - #define M_EXIF 0xE1 // Exif marker. Also used for XMP data! - #define M_XMP 0x10E1 // Not a real tag same value as Exif! - #define M_COM 0xFE // COMment - #define M_DQT 0xDB - #define M_DHT 0xC4 - #define M_DRI 0xDD - #define M_IPTC 0xED // IPTC marker - #define PSEUDO_IMAGE_MARKER 0x123; // Extra value. -}; - -class Interpreter -{ -public: - enum Commands_e { - SWITCH_CAMERA_CMD = 'A', - RESUME_PREVIEW_CMD = '[', - START_PREVIEW_CMD = '1', - STOP_PREVIEW_CMD = '2', - CHANGE_VIDEO_SIZE_CMD = '3', - CHANGE_PREVIEW_SIZE_CMD = '4', - CHANGE_PICTURE_SIZE_CMD = '5', - START_RECORD_CMD = '6', - STOP_RECORD_CMD = '7', - START_VIV_RECORD_CMD = '8', - STOP_VIV_RECORD_CMD = '9', - DUMP_CAPS_CMD = 'E', - AUTOFOCUS_CMD = 'f', - TAKEPICTURE_CMD = 'p', - TAKEPICTURE_IN_PICTURE_CMD = 'P', - ENABLE_PRV_CALLBACKS_CMD = '&', - EXIT_CMD = 'q', - DELAY = 'd', - INVALID_CMD = '0' - }; - - struct Command { - Command( Commands_e cmd, char *arg = NULL) - : cmd(cmd) - , arg(arg) {} - Command() - : cmd(INVALID_CMD) - , arg(NULL) {} - Commands_e cmd; - char *arg; - }; - - /* API */ - Interpreter() - : mUseScript(false) - , mScript(NULL) {} - - Interpreter(const char *file); - ~Interpreter(); - - Command getCommand(sp<CameraContext> currentCamera); - void releasePiPBuff(); - status_t configureViVCodec(); - //status_t configureViVCodec(); - void setViVSize(Size VideoSize, int camIndex); - void setTestCtxInst(TestContext *instance); - status_t unconfigureViVCodec(); - status_t ViVEncoderThread(); - void ViVEncode(); - static void *ThreadWrapper(void *context); - -private: - static const int numberOfCommands; - - bool mUseScript; - int mCmdIndex; - char *mScript; - Vector<Command> mCommands; - TestContext *mTestContext; - pthread_t mViVEncThread; -}; - -class TestContext -{ - friend class CameraContext; - friend class Interpreter; -public: - TestContext(); - ~TestContext(); - - int32_t GetCamerasNum(); - status_t FunctionalTest(); - status_t AddScriptFromFile(const char *scriptFile); - void setViVSize(Size VideoSize, int camIndex); - -private: - char GetNextCmd(sp<qcamera::CameraContext> currentCamera); - int mCurrentCameraIndex; - int mSaveCurrentCameraIndex; - Vector< sp<qcamera::CameraContext> > mAvailableCameras; - bool mTestRunning; - Interpreter *mInterpreter; - - typedef struct ViVBuff_t{ - void *buff; - size_t buffSize; - size_t YStride; - size_t UVStride; - size_t YScanLines; - size_t UVScanLines; - size_t srcWidth; - size_t srcHeight; - } ViVBuff_t; - - typedef struct ViVVid_t{ - sp<IGraphicBufferProducer> bufferProducer; - sp<Surface> surface; - sp<MediaCodec> codec; - sp<MediaMuxer> muxer; - sp<ANativeWindow> ANW; - Vector<sp<ABuffer> > buffers; - Size VideoSizes[2]; - int ViVIdx; - size_t buff_cnt; - sp<GraphicBuffer> graphBuf; - void * mappedBuff; - bool isBuffValid; - int sourceCameraID; - int destinationCameraID; - } vidPiP_t; - - ViVVid_t mViVVid; - ViVBuff_t mViVBuff; -}; - -}; //namespace qcamera - -#endif diff --git a/camera/QCamera2/stack/Android.mk b/camera/QCamera2/stack/Android.mk index a357417c..bd1c3e66 100644 --- a/camera/QCamera2/stack/Android.mk +++ b/camera/QCamera2/stack/Android.mk @@ -1,5 +1,3 @@ LOCAL_PATH:= $(call my-dir) include $(LOCAL_PATH)/mm-camera-interface/Android.mk include $(LOCAL_PATH)/mm-jpeg-interface/Android.mk -include $(LOCAL_PATH)/mm-jpeg-interface/test/Android.mk -include $(LOCAL_PATH)/mm-camera-test/Android.mk diff --git a/camera/QCamera2/stack/mm-camera-test/Android.mk b/camera/QCamera2/stack/mm-camera-test/Android.mk deleted file mode 100644 index d970f430..00000000 --- a/camera/QCamera2/stack/mm-camera-test/Android.mk +++ /dev/null @@ -1,126 +0,0 @@ -OLD_LOCAL_PATH := $(LOCAL_PATH) -LOCAL_PATH := $(call my-dir) - -# Build command line test app: mm-qcamera-app -include $(CLEAR_VARS) - -LOCAL_CFLAGS := \ - -DAMSS_VERSION=$(AMSS_VERSION) \ - $(mmcamera_debug_defines) \ - $(mmcamera_debug_cflags) \ - $(USE_SERVER_TREE) \ - -DUSE_ION \ - -D_ANDROID_ - -# mm_qcamera_main_menu.c has implicit conversion from enum to enum. -LOCAL_CLANG_CFLAGS += \ - -Wno-error=enum-conversion - -LOCAL_SRC_FILES := \ - src/mm_qcamera_main_menu.c \ - src/mm_qcamera_app.c \ - src/mm_qcamera_unit_test.c \ - src/mm_qcamera_video.c \ - src/mm_qcamera_preview.c \ - src/mm_qcamera_snapshot.c \ - src/mm_qcamera_rdi.c \ - src/mm_qcamera_reprocess.c\ - src/mm_qcamera_queue.c \ - src/mm_qcamera_socket.c \ - src/mm_qcamera_commands.c - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc -LOCAL_C_INCLUDES += \ - frameworks/native/include/media/openmax \ - $(LOCAL_PATH)/../common \ - $(LOCAL_PATH)/../../../mm-image-codec/qexif \ - $(LOCAL_PATH)/../../../mm-image-codec/qomx_core - -LOCAL_C_INCLUDES+= $(kernel_includes) -LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) - -LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID -LOCAL_CFLAGS += -DCAMERA_GRALLOC_HEAP_ID=GRALLOC_USAGE_PRIVATE_IOMMU_HEAP -LOCAL_CFLAGS += -DCAMERA_GRALLOC_FALLBACK_HEAP_ID=GRALLOC_USAGE_PRIVATE_IOMMU_HEAP -LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID -LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 -LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 - -LOCAL_CFLAGS += \ - -Wall \ - -Werror - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libdl \ - libmmcamera_interface - -LOCAL_MODULE_TAGS := optional - -LOCAL_32_BIT_ONLY := true - -LOCAL_MODULE:= mm-qcamera-app - -include $(BUILD_EXECUTABLE) - -# Build tuning library -include $(CLEAR_VARS) - -LOCAL_CFLAGS := \ - -DAMSS_VERSION=$(AMSS_VERSION) \ - $(mmcamera_debug_defines) \ - $(mmcamera_debug_cflags) \ - $(USE_SERVER_TREE) \ - -DUSE_ION \ - -D_ANDROID_ - -# mm_qcamera_main_menu.c has implicit conversion from enum to enum. -LOCAL_CLANG_CFLAGS += \ - -Wno-error=enum-conversion - -LOCAL_SRC_FILES := \ - src/mm_qcamera_main_menu.c \ - src/mm_qcamera_app.c \ - src/mm_qcamera_unit_test.c \ - src/mm_qcamera_video.c \ - src/mm_qcamera_preview.c \ - src/mm_qcamera_snapshot.c \ - src/mm_qcamera_rdi.c \ - src/mm_qcamera_reprocess.c\ - src/mm_qcamera_queue.c \ - src/mm_qcamera_socket.c \ - src/mm_qcamera_commands.c - -LOCAL_C_INCLUDES:=$(LOCAL_PATH)/inc -LOCAL_C_INCLUDES+= \ - frameworks/native/include/media/openmax \ - $(LOCAL_PATH)/../common \ - $(LOCAL_PATH)/../../../mm-image-codec/qexif \ - $(LOCAL_PATH)/../../../mm-image-codec/qomx_core - -LOCAL_HEADER_LIBRARIES := generated_kernel_headers - -LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID -LOCAL_CFLAGS += -DCAMERA_GRALLOC_HEAP_ID=GRALLOC_USAGE_PRIVATE_IOMMU_HEAP -LOCAL_CFLAGS += -DCAMERA_GRALLOC_FALLBACK_HEAP_ID=GRALLOC_USAGE_PRIVATE_IOMMU_HEAP -LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID -LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 -LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 - -LOCAL_CFLAGS += \ - -Wall \ - -Werror - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libdl \ - libmmcamera_interface - -LOCAL_MODULE_TAGS := optional - -LOCAL_32_BIT_ONLY := true - -LOCAL_MODULE := libmm-qcamera -include $(BUILD_SHARED_LIBRARY) diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h deleted file mode 100644 index c23b4b12..00000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h +++ /dev/null @@ -1,519 +0,0 @@ -/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_APP_H__ -#define __MM_QCAMERA_APP_H__ - -#include <pthread.h> -#include <errno.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <poll.h> -#include <linux/fb.h> -#include <linux/msm_mdp.h> -#include <semaphore.h> - -#include "mm_camera_interface.h" -#include "mm_jpeg_interface.h" -#include "mm_qcamera_socket.h" - -#define MM_QCAMERA_APP_INTERATION 1 - -#define MM_APP_MAX_DUMP_FRAME_NUM 1000 - -#define PREVIEW_BUF_NUM 7 -#define VIDEO_BUF_NUM 7 -#define ISP_PIX_BUF_NUM 9 -#define STATS_BUF_NUM 4 -#define RDI_BUF_NUM 8 -#define CAPTURE_BUF_NUM 5 - -#define DEFAULT_PREVIEW_FORMAT CAM_FORMAT_YUV_420_NV21 -#define DEFAULT_PREVIEW_WIDTH 640 -#define DEFAULT_PREVIEW_HEIGHT 480 -#define DEFAULT_PREVIEW_PADDING CAM_PAD_TO_WORD -#define DEFAULT_VIDEO_FORMAT CAM_FORMAT_YUV_420_NV12 -#define DEFAULT_VIDEO_WIDTH 800 -#define DEFAULT_VIDEO_HEIGHT 480 -#define DEFAULT_VIDEO_PADDING CAM_PAD_TO_2K -#define DEFAULT_SNAPSHOT_FORMAT CAM_FORMAT_YUV_420_NV21 -#define DEFAULT_RAW_FORMAT CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG - -#define DEFAULT_SNAPSHOT_WIDTH 1024 -#define DEFAULT_SNAPSHOT_HEIGHT 768 -#define DEFAULT_SNAPSHOT_PADDING CAM_PAD_TO_WORD - -#define DEFAULT_OV_FORMAT MDP_Y_CRCB_H2V2 -#define DEFAULT_OV_FORMAT_BPP 3/2 -#define DEFAULT_CAMERA_FORMAT_BPP 3/2 -#define FB_PATH "/dev/graphics/fb0" -#define BACKLIGHT_CONTROL "/sys/class/leds/lcd-backlight/brightness" -#define BACKLIGHT_LEVEL "205" - -#define ENABLE_REPROCESSING 1 - -#define INVALID_KEY_PRESS 0 -#define BASE_OFFSET ('Z' - 'A' + 1) -#define BASE_OFFSET_NUM ('Z' - 'A' + 2) - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -typedef enum { - TUNE_CMD_INIT, - TUNE_CMD_GET_LIST, - TUNE_CMD_GET_PARAMS, - TUNE_CMD_SET_PARAMS, - TUNE_CMD_MISC, - TUNE_CMD_DEINIT, -} mm_camera_tune_cmd_t; - -typedef enum { - TUNE_PREVCMD_INIT, - TUNE_PREVCMD_SETDIM, - TUNE_PREVCMD_GETINFO, - TUNE_PREVCMD_GETCHUNKSIZE, - TUNE_PREVCMD_GETFRAME, - TUNE_PREVCMD_UNSUPPORTED, - TUNE_PREVCMD_DEINIT, -} mm_camera_tune_prevcmd_t; - -typedef void (*prev_callback) (mm_camera_buf_def_t *preview_frame); - -typedef struct { - char *send_buf; - uint32_t send_len; - void *next; -} eztune_prevcmd_rsp; - -typedef struct { - int (*command_process) (void *recv, mm_camera_tune_cmd_t cmd, - void *param, char *send_buf, uint32_t send_len); - int (*prevcommand_process) (void *recv, mm_camera_tune_prevcmd_t cmd, - void *param, char **send_buf, uint32_t *send_len); - void (*prevframe_callback) (mm_camera_buf_def_t *preview_frame); -} mm_camera_tune_func_t; - -typedef struct { - mm_camera_tune_func_t *func_tbl; - void *lib_handle; -}mm_camera_tuning_lib_params_t; - -typedef enum { - MM_CAMERA_OK, - MM_CAMERA_E_GENERAL, - MM_CAMERA_E_NO_MEMORY, - MM_CAMERA_E_NOT_SUPPORTED, - MM_CAMERA_E_INVALID_INPUT, - MM_CAMERA_E_INVALID_OPERATION, /* 5 */ - MM_CAMERA_E_ENCODE, - MM_CAMERA_E_BUFFER_REG, - MM_CAMERA_E_PMEM_ALLOC, - MM_CAMERA_E_CAPTURE_FAILED, - MM_CAMERA_E_CAPTURE_TIMEOUT, /* 10 */ -} mm_camera_status_type_t; - -typedef enum { - MM_CHANNEL_TYPE_ZSL, /* preview, and snapshot main */ - MM_CHANNEL_TYPE_CAPTURE, /* snapshot main, and postview */ - MM_CHANNEL_TYPE_PREVIEW, /* preview only */ - MM_CHANNEL_TYPE_SNAPSHOT, /* snapshot main only */ - MM_CHANNEL_TYPE_VIDEO, /* video only */ - MM_CHANNEL_TYPE_RDI, /* rdi only */ - MM_CHANNEL_TYPE_REPROCESS,/* offline reprocess */ - MM_CHANNEL_TYPE_MAX -} mm_camera_channel_type_t; - -typedef struct { - int fd; - int main_ion_fd; - ion_user_handle_t handle; - uint32_t size; - void * data; -} mm_camera_app_meminfo_t; - -typedef struct { - mm_camera_buf_def_t buf; - mm_camera_app_meminfo_t mem_info; -} mm_camera_app_buf_t; - -typedef struct { - uint32_t s_id; - mm_camera_stream_config_t s_config; - cam_frame_len_offset_t offset; - uint8_t num_of_bufs; - uint32_t multipleOf; - mm_camera_app_buf_t s_bufs[MM_CAMERA_MAX_NUM_FRAMES]; - mm_camera_app_buf_t s_info_buf; -} mm_camera_stream_t; - -typedef struct { - uint32_t ch_id; - uint8_t num_streams; - mm_camera_stream_t streams[MAX_STREAM_NUM_IN_BUNDLE]; -} mm_camera_channel_t; - -typedef void (*release_data_fn)(void* data, void *user_data); - -typedef struct { - struct cam_list list; - void* data; -} camera_q_node; - -typedef struct { - camera_q_node m_head; - int m_size; - pthread_mutex_t m_lock; - release_data_fn m_dataFn; - void * m_userData; -} mm_camera_queue_t; - -typedef struct { - uint16_t user_input_display_width; - uint16_t user_input_display_height; -} USER_INPUT_DISPLAY_T; - -typedef struct { - mm_camera_vtbl_t *cam; - uint8_t num_channels; - mm_camera_channel_t channels[MM_CHANNEL_TYPE_MAX]; - mm_jpeg_ops_t jpeg_ops; - uint32_t jpeg_hdl; - mm_camera_app_buf_t cap_buf; - mm_camera_app_buf_t parm_buf; - - uint32_t current_jpeg_sess_id; - mm_camera_super_buf_t* current_job_frames; - uint32_t current_job_id; - mm_camera_app_buf_t jpeg_buf; - - int fb_fd; - struct fb_var_screeninfo vinfo; - struct mdp_overlay data_overlay; - uint32_t slice_size; - uint32_t buffer_width, buffer_height; - uint32_t buffer_size; - cam_format_t buffer_format; - uint32_t frame_size; - uint32_t frame_count; - int encodeJpeg; - int zsl_enabled; - int8_t focus_supported; - prev_callback user_preview_cb; - parm_buffer_t *params_buffer; - USER_INPUT_DISPLAY_T preview_resolution; - - //Reprocess params&stream - int8_t enable_reproc; - int32_t reproc_sharpness; - cam_denoise_param_t reproc_wnr; - int8_t enable_CAC; - mm_camera_queue_t pp_frames; - mm_camera_stream_t *reproc_stream; - metadata_buffer_t *metadata; - int8_t is_chromatix_reload; - tune_chromatix_t tune_data; -} mm_camera_test_obj_t; - -typedef struct { - void *ptr; - void* ptr_jpeg; - - uint8_t (*get_num_of_cameras) (); - mm_camera_vtbl_t *(*mm_camera_open) (uint8_t camera_idx); - uint32_t (*jpeg_open) (mm_jpeg_ops_t *ops, mm_dimension picture_size); - -} hal_interface_lib_t; - -typedef struct { - uint8_t num_cameras; - hal_interface_lib_t hal_lib; -} mm_camera_app_t; - -typedef struct { - uint32_t width; - uint32_t height; -} mm_camera_lib_snapshot_params; - -typedef enum { - MM_CAMERA_LIB_NO_ACTION = 0, - MM_CAMERA_LIB_RAW_CAPTURE, - MM_CAMERA_LIB_JPEG_CAPTURE, - MM_CAMERA_LIB_SET_FOCUS_MODE, - MM_CAMERA_LIB_DO_AF, - MM_CAMERA_LIB_CANCEL_AF, - MM_CAMERA_LIB_LOCK_AE, - MM_CAMERA_LIB_UNLOCK_AE, - MM_CAMERA_LIB_LOCK_AWB, - MM_CAMERA_LIB_UNLOCK_AWB, - MM_CAMERA_LIB_GET_CHROMATIX, - MM_CAMERA_LIB_SET_RELOAD_CHROMATIX, - MM_CAMERA_LIB_GET_AFTUNE, - MM_CAMERA_LIB_SET_RELOAD_AFTUNE, - MM_CAMERA_LIB_SET_AUTOFOCUS_TUNING, - MM_CAMERA_LIB_ZSL_ENABLE, - MM_CAMERA_LIB_EV, - MM_CAMERA_LIB_ANTIBANDING, - MM_CAMERA_LIB_SET_VFE_COMMAND, - MM_CAMERA_LIB_SET_POSTPROC_COMMAND, - MM_CAMERA_LIB_SET_3A_COMMAND, - MM_CAMERA_LIB_AEC_ENABLE, - MM_CAMERA_LIB_AEC_DISABLE, - MM_CAMERA_LIB_AF_ENABLE, - MM_CAMERA_LIB_AF_DISABLE, - MM_CAMERA_LIB_AWB_ENABLE, - MM_CAMERA_LIB_AWB_DISABLE, - MM_CAMERA_LIB_AEC_FORCE_LC, - MM_CAMERA_LIB_AEC_FORCE_GAIN, - MM_CAMERA_LIB_AEC_FORCE_EXP, - MM_CAMERA_LIB_AEC_FORCE_SNAP_LC, - MM_CAMERA_LIB_AEC_FORCE_SNAP_GAIN, - MM_CAMERA_LIB_AEC_FORCE_SNAP_EXP, - MM_CAMERA_LIB_WB, - MM_CAMERA_LIB_EXPOSURE_METERING, - MM_CAMERA_LIB_BRIGHTNESS, - MM_CAMERA_LIB_CONTRAST, - MM_CAMERA_LIB_SATURATION, - MM_CAMERA_LIB_SHARPNESS, - MM_CAMERA_LIB_ISO, - MM_CAMERA_LIB_ZOOM, - MM_CAMERA_LIB_BESTSHOT, - MM_CAMERA_LIB_FLASH, - MM_CAMERA_LIB_FPS_RANGE, - MM_CAMERA_LIB_WNR_ENABLE, - MM_CAMERA_LIB_SET_TINTLESS, -} mm_camera_lib_commands; - -typedef struct { - int32_t stream_width, stream_height; - cam_focus_mode_type af_mode; -} mm_camera_lib_params; - -typedef struct { - tuneserver_protocol_t *proto; - int clientsocket_id; - prserver_protocol_t *pr_proto; - int pr_clientsocket_id; - mm_camera_tuning_lib_params_t tuning_params; -} tuningserver_t; - -typedef struct { - mm_camera_app_t app_ctx; - mm_camera_test_obj_t test_obj; - mm_camera_lib_params current_params; - int stream_running; - tuningserver_t tsctrl; -} mm_camera_lib_ctx; - -typedef mm_camera_lib_ctx mm_camera_lib_handle; - -typedef int (*mm_app_test_t) (mm_camera_app_t *cam_apps); -typedef struct { - mm_app_test_t f; - int r; -} mm_app_tc_t; - -extern int mm_app_unit_test_entry(mm_camera_app_t *cam_app); -extern int mm_app_dual_test_entry(mm_camera_app_t *cam_app); -extern void mm_app_dump_frame(mm_camera_buf_def_t *frame, - char *name, - char *ext, - int frame_idx); -extern void mm_app_dump_jpeg_frame(const void * data, - uint32_t size, - char* name, - char* ext, - int index); -extern int mm_camera_app_timedwait(uint8_t seconds); -extern int mm_camera_app_wait(); -extern void mm_camera_app_done(); -extern int mm_app_alloc_bufs(mm_camera_app_buf_t* app_bufs, - cam_frame_len_offset_t *frame_offset_info, - uint8_t num_bufs, - uint8_t is_streambuf, - size_t multipleOf); -extern int mm_app_release_bufs(uint8_t num_bufs, - mm_camera_app_buf_t* app_bufs); -extern int mm_app_stream_initbuf(cam_frame_len_offset_t *frame_offset_info, - uint8_t *num_bufs, - uint8_t **initial_reg_flag, - mm_camera_buf_def_t **bufs, - mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data); -extern int32_t mm_app_stream_deinitbuf(mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data); -extern int mm_app_cache_ops(mm_camera_app_meminfo_t *mem_info, - unsigned int cmd); -extern int32_t mm_app_stream_clean_invalidate_buf(int index, void *user_data); -extern int32_t mm_app_stream_invalidate_buf(int index, void *user_data); -extern int mm_app_open(mm_camera_app_t *cam_app, - uint8_t cam_id, - mm_camera_test_obj_t *test_obj); -extern int mm_app_close(mm_camera_test_obj_t *test_obj); -extern mm_camera_channel_t * mm_app_add_channel( - mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type, - mm_camera_channel_attr_t *attr, - mm_camera_buf_notify_t channel_cb, - void *userdata); -extern int mm_app_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern mm_camera_stream_t * mm_app_add_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern int mm_app_del_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream); -extern int mm_app_config_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream, - mm_camera_stream_config_t *config); -extern int mm_app_start_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern int mm_app_stop_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern mm_camera_channel_t *mm_app_get_channel_by_type( - mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type); - -extern int mm_app_start_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_preview_zsl(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_preview_zsl(mm_camera_test_obj_t *test_obj); -extern mm_camera_channel_t * mm_app_add_preview_channel( - mm_camera_test_obj_t *test_obj); -extern mm_camera_stream_t * mm_app_add_raw_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst); -extern int mm_app_stop_and_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern mm_camera_channel_t * mm_app_add_snapshot_channel( - mm_camera_test_obj_t *test_obj); -extern mm_camera_stream_t * mm_app_add_snapshot_stream( - mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst); -extern mm_camera_stream_t * mm_app_add_metadata_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs); -extern int mm_app_start_record_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_record_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_record(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_record(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_live_snapshot(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_live_snapshot(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_capture(mm_camera_test_obj_t *test_obj, - uint8_t num_snapshots); -extern int mm_app_stop_capture(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_capture_raw(mm_camera_test_obj_t *test_obj, uint8_t num_snapshots); -extern int mm_app_stop_capture_raw(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_rdi(mm_camera_test_obj_t *test_obj, uint8_t num_burst); -extern int mm_app_stop_rdi(mm_camera_test_obj_t *test_obj); -extern int mm_app_initialize_fb(mm_camera_test_obj_t *test_obj); -extern int mm_app_close_fb(mm_camera_test_obj_t *test_obj); -extern int mm_app_fb_write(mm_camera_test_obj_t *test_obj, char *buffer); -extern int mm_app_overlay_display(mm_camera_test_obj_t *test_obj, int bufferFd); -extern int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, int ion_type); -extern int mm_app_deallocate_ion_memory(mm_camera_app_buf_t *buf); -int mm_app_set_params(mm_camera_test_obj_t *test_obj, - cam_intf_parm_type_t param_type, - int32_t value); -/* JIG camera lib interface */ - -int mm_camera_lib_open(mm_camera_lib_handle *handle, int cam_id); -int mm_camera_lib_get_caps(mm_camera_lib_handle *handle, - cam_capability_t *caps); -int mm_camera_lib_start_stream(mm_camera_lib_handle *handle); -int mm_camera_lib_send_command(mm_camera_lib_handle *handle, - mm_camera_lib_commands cmd, - void *data, void *out_data); -int mm_camera_lib_stop_stream(mm_camera_lib_handle *handle); -int mm_camera_lib_number_of_cameras(mm_camera_lib_handle *handle); -int mm_camera_lib_close(mm_camera_lib_handle *handle); -int32_t mm_camera_load_tuninglibrary( - mm_camera_tuning_lib_params_t *tuning_param); -int mm_camera_lib_set_preview_usercb( - mm_camera_lib_handle *handle, prev_callback cb); -// - -int mm_app_start_regression_test(int run_tc); -int mm_app_load_hal(mm_camera_app_t *my_cam_app); - -extern int createEncodingSession(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *m_stream, - mm_camera_buf_def_t *m_frame); -extern int encodeData(mm_camera_test_obj_t *test_obj, mm_camera_super_buf_t* recvd_frame, - mm_camera_stream_t *m_stream); -extern int mm_app_take_picture(mm_camera_test_obj_t *test_obj, uint8_t); - -extern mm_camera_channel_t * mm_app_add_reprocess_channel(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *source_stream); -extern int mm_app_start_reprocess(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_reprocess(mm_camera_test_obj_t *test_obj); -extern int mm_app_do_reprocess(mm_camera_test_obj_t *test_obj, - mm_camera_buf_def_t *frame, - uint8_t meta_idx, - mm_camera_super_buf_t *super_buf, - mm_camera_stream_t *src_meta); -extern void mm_app_release_ppinput(void *data, void *user_data); - -extern int mm_camera_queue_init(mm_camera_queue_t *queue, - release_data_fn data_rel_fn, - void *user_data); -extern int mm_qcamera_queue_release(mm_camera_queue_t *queue); -extern int mm_qcamera_queue_isempty(mm_camera_queue_t *queue); -extern int mm_qcamera_queue_enqueue(mm_camera_queue_t *queue, void *data); -extern void* mm_qcamera_queue_dequeue(mm_camera_queue_t *queue, - int bFromHead); -extern void mm_qcamera_queue_flush(mm_camera_queue_t *queue); - -#endif /* __MM_QCAMERA_APP_H__ */ - - - - - - - - - diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_commands.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_commands.h deleted file mode 100644 index 1540c20c..00000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_commands.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_COMMANDS_H__ -#define __MM_QCAMERA_COMMANDS_H__ - -#include "mm_qcamera_socket.h" -#include "mm_qcamera_app.h" - -int tuneserver_close_cam(mm_camera_lib_handle *lib_handle); -int tuneserver_stop_cam(mm_camera_lib_handle *lib_handle); -int tuneserver_open_cam(mm_camera_lib_handle *lib_handle); - -int tuneserver_initialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len); -int tuneserver_deinitialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len); -int tuneserver_process_get_list_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); -int tuneserver_process_misc_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); -int tuneserver_process_get_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); -int tuneserver_process_set_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); - -int tuneserver_initialize_prevtuningp(void * ctrl, - int pr_client_socket_id, cam_dimension_t dimension, - char **send_buf, uint32_t *send_len); -int tuneserver_deinitialize_prevtuningp(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_getinfo(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_getchunksize(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_getframe(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_unsupported(void * ctrl, - char **send_buf, uint32_t *send_len); - -#endif /*__MM_QCAMERA_COMMANDS_H__*/ diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_dbg.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_dbg.h deleted file mode 100644 index bb5ab810..00000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_dbg.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_DBG_H__ -#define __MM_QCAMERA_DBG_H__ - -//#define LOG_DEBUG 1 - -#ifndef LOG_DEBUG - #ifdef _ANDROID_ - #undef LOG_NIDEBUG - #undef LOG_TAG - #define LOG_NIDEBUG 0 - #define LOG_TAG "mm-camera-test" - #include <utils/Log.h> - #else - #include <stdio.h> - #define ALOGE CDBG - #endif - #undef CDBG - #define CDBG(fmt, args...) do{}while(0) - #define CDBG_ERROR(fmt, args...) ALOGE(fmt, ##args) -#else - #ifdef _ANDROID_ - #undef LOG_NIDEBUG - #undef LOG_TAG - #define LOG_NIDEBUG 0 - #define LOG_TAG "mm-camera-test" - #include <utils/Log.h> - #define CDBG(fmt, args...) ALOGE(fmt, ##args) - #else - #include <stdio.h> - #define CDBG(fmt, args...) fprintf(stderr, fmt, ##args) - #define ALOGE(fmt, args...) fprintf(stderr, fmt, ##args) - #endif -#endif - -#ifdef _ANDROID_ - #define CDBG_HIGH(fmt, args...) ALOGE(fmt, ##args) - #define CDBG_ERROR(fmt, args...) ALOGE(fmt, ##args) -#else - #define CDBG_HIGH(fmt, args...) fprintf(stderr, fmt, ##args) - #define CDBG_ERROR(fmt, args...) fprintf(stderr, fmt, ##args) -#endif -#endif /* __MM_QCAMERA_DBG_H__ */ diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_main_menu.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_main_menu.h deleted file mode 100644 index 06e3827f..00000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_main_menu.h +++ /dev/null @@ -1,438 +0,0 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_MAIN_MENU_H__ -#define __MM_QCAMERA_MAIN_MENU_H__ - -#include "mm_camera_interface.h" -#include "mm_jpeg_interface.h" - -#define VIDEO_BUFFER_SIZE (PREVIEW_WIDTH * PREVIEW_HEIGHT * 3/2) -#define THUMBNAIL_BUFFER_SIZE (THUMBNAIL_WIDTH * THUMBNAIL_HEIGHT * 3/2) -#define SNAPSHOT_BUFFER_SIZE (PICTURE_WIDTH * PICTURE_HEIGHT * 3/2) - -/*=========================================================================== - * Macro - *===========================================================================*/ -#define PREVIEW_FRAMES_NUM 5 -#define VIDEO_FRAMES_NUM 5 -#define THUMBNAIL_FRAMES_NUM 1 -#define SNAPSHOT_FRAMES_NUM 1 -#define MAX_NUM_FORMAT 32 - -typedef enum -{ - START_PREVIEW, - STOP_PREVIEW, - SET_WHITE_BALANCE, - SET_TINTLESS_ENABLE, - SET_TINTLESS_DISABLE, - SET_EXP_METERING, - GET_CTRL_VALUE, - TOGGLE_AFR, - SET_ISO, - BRIGHTNESS_GOTO_SUBMENU, - CONTRAST_GOTO_SUBMENU, - EV_GOTO_SUBMENU, - SATURATION_GOTO_SUBMENU, - SET_ZOOM, - SET_SHARPNESS, - TAKE_JPEG_SNAPSHOT, - START_RECORDING, - STOP_RECORDING, - BEST_SHOT, - LIVE_SHOT, - FLASH_MODES, - TOGGLE_ZSL, - TAKE_RAW_SNAPSHOT, - SWITCH_SNAP_RESOLUTION, - TOGGLE_WNR, - EXIT -} Camera_main_menu_t; - -typedef enum -{ - ACTION_NO_ACTION, - ACTION_START_PREVIEW, - ACTION_STOP_PREVIEW, - ACTION_SET_WHITE_BALANCE, - ACTION_SET_TINTLESS_ENABLE, - ACTION_SET_TINTLESS_DISABLE, - ACTION_SET_EXP_METERING, - ACTION_GET_CTRL_VALUE, - ACTION_TOGGLE_AFR, - ACTION_SET_ISO, - ACTION_BRIGHTNESS_INCREASE, - ACTION_BRIGHTNESS_DECREASE, - ACTION_CONTRAST_INCREASE, - ACTION_CONTRAST_DECREASE, - ACTION_EV_INCREASE, - ACTION_EV_DECREASE, - ACTION_SATURATION_INCREASE, - ACTION_SATURATION_DECREASE, - ACTION_SET_ZOOM, - ACTION_SHARPNESS_INCREASE, - ACTION_SHARPNESS_DECREASE, - ACTION_TAKE_JPEG_SNAPSHOT, - ACTION_START_RECORDING, - ACTION_STOP_RECORDING, - ACTION_SET_BESTSHOT_MODE, - ACTION_TAKE_LIVE_SNAPSHOT, - ACTION_SET_FLASH_MODE, - ACTION_SWITCH_CAMERA, - ACTION_TOGGLE_ZSL, - ACTION_TAKE_RAW_SNAPSHOT, - ACTION_SWITCH_RESOLUTION, - ACTION_TOGGLE_WNR, - ACTION_EXIT -} camera_action_t; - -#define INVALID_KEY_PRESS 0 -#define BASE_OFFSET ('Z' - 'A' + 1) -#define BASE_OFFSET_NUM ('Z' - 'A' + 2) -#define PAD_TO_WORD(a) (((a)+3)&~3) - - -#define SQCIF_WIDTH 128 -#define SQCIF_HEIGHT 96 -#define QCIF_WIDTH 176 -#define QCIF_HEIGHT 144 -#define QVGA_WIDTH 320 -#define QVGA_HEIGHT 240 -#define HD_THUMBNAIL_WIDTH 256 -#define HD_THUMBNAIL_HEIGHT 144 -#define CIF_WIDTH 352 -#define CIF_HEIGHT 288 -#define VGA_WIDTH 640 -#define VGA_HEIGHT 480 -#define WVGA_WIDTH 800 -#define WVGA_HEIGHT 480 -#define WVGA_PLUS_WIDTH 960 -#define WVGA_PLUS_HEIGHT 720 - -#define MP1_WIDTH 1280 -#define MP1_HEIGHT 960 -#define MP2_WIDTH 1600 -#define MP2_HEIGHT 1200 -#define MP3_WIDTH 2048 -#define MP3_HEIGHT 1536 -#define MP5_WIDTH 2592 -#define MP5_HEIGHT 1944 -#define MP8_WIDTH 3264 -#define MP8_HEIGHT 2448 -#define MP12_WIDTH 4000 -#define MP12_HEIGHT 3000 - -#define SVGA_WIDTH 800 -#define SVGA_HEIGHT 600 -#define XGA_WIDTH 1024 -#define XGA_HEIGHT 768 -#define HD720_WIDTH 1280 -#define HD720_HEIGHT 720 -#define HD720_PLUS_WIDTH 1440 -#define HD720_PLUS_HEIGHT 1080 -#define WXGA_WIDTH 1280 -#define WXGA_HEIGHT 768 -#define HD1080_WIDTH 1920 -#define HD1080_HEIGHT 1080 - - -#define ONEMP_WIDTH 1280 -#define SXGA_WIDTH 1280 -#define UXGA_WIDTH 1600 -#define QXGA_WIDTH 2048 -#define FIVEMP_WIDTH 2560 - - -#define ONEMP_HEIGHT 960 -#define SXGA_HEIGHT 1024 -#define UXGA_HEIGHT 1200 -#define QXGA_HEIGHT 1536 -#define FIVEMP_HEIGHT 1920 - - -typedef enum -{ - RESOLUTION_MIN, - QCIF = RESOLUTION_MIN, - QVGA, - VGA, - WVGA, - WVGA_PLUS , - HD720, - HD720_PLUS, - HD1080, - RESOLUTION_PREVIEW_VIDEO_MAX = HD1080, - WXGA, - MP1, - MP2, - MP3, - MP5, - MP8, - MP12, - RESOLUTION_MAX = MP12, -} Camera_Resolution; - -typedef struct{ - uint16_t width; - uint16_t height; - char * name; - char * str_name; - int supported; -} DIMENSION_TBL_T; - -typedef enum { - WHITE_BALANCE_STATE, - WHITE_BALANCE_TEMPERATURE, - BRIGHTNESS_CTRL, - EV, - CONTRAST_CTRL, - SATURATION_CTRL, - SHARPNESS_CTRL -} Get_Ctrl_modes; - -typedef enum { - AUTO_EXP_FRAME_AVG, - AUTO_EXP_CENTER_WEIGHTED, - AUTO_EXP_SPOT_METERING, - AUTO_EXP_SMART_METERING, - AUTO_EXP_USER_METERING, - AUTO_EXP_SPOT_METERING_ADV, - AUTO_EXP_CENTER_WEIGHTED_ADV, - AUTO_EXP_MAX -} Exp_Metering_modes; - -typedef enum { - ISO_AUTO, - ISO_DEBLUR, - ISO_100, - ISO_200, - ISO_400, - ISO_800, - ISO_1600, - ISO_MAX -} ISO_modes; - -typedef enum { - BESTSHOT_AUTO, - BESTSHOT_ACTION, - BESTSHOT_PORTRAIT, - BESTSHOT_LANDSCAPE, - BESTSHOT_NIGHT, - BESTSHOT_NIGHT_PORTRAIT, - BESTSHOT_THEATRE, - BESTSHOT_BEACH, - BESTSHOT_SNOW, - BESTSHOT_SUNSET, - BESTSHOT_ANTISHAKE, - BESTSHOT_FIREWORKS, - BESTSHOT_SPORTS, - BESTSHOT_PARTY, - BESTSHOT_CANDLELIGHT, - BESTSHOT_ASD, - BESTSHOT_BACKLIGHT, - BESTSHOT_FLOWERS, - BESTSHOT_AR, - BESTSHOT_HDR, - BESTSHOT_MAX -}Bestshot_modes; - -typedef enum { - FLASH_MODE_OFF, - FLASH_MODE_AUTO, - FLASH_MODE_ON, - FLASH_MODE_TORCH, - FLASH_MODE_MAX, -}Flash_modes; - -typedef enum { - WB_AUTO, - WB_INCANDESCENT, - WB_FLUORESCENT, - WB_WARM_FLUORESCENT, - WB_DAYLIGHT, - WB_CLOUDY_DAYLIGHT, - WB_TWILIGHT, - WB_SHADE, - WB_MAX -} White_Balance_modes; - -typedef enum -{ - MENU_ID_MAIN, - MENU_ID_WHITEBALANCECHANGE, - MENU_ID_EXPMETERINGCHANGE, - MENU_ID_GET_CTRL_VALUE, - MENU_ID_TOGGLEAFR, - MENU_ID_ISOCHANGE, - MENU_ID_BRIGHTNESSCHANGE, - MENU_ID_CONTRASTCHANGE, - MENU_ID_EVCHANGE, - MENU_ID_SATURATIONCHANGE, - MENU_ID_ZOOMCHANGE, - MENU_ID_SHARPNESSCHANGE, - MENU_ID_BESTSHOT, - MENU_ID_FLASHMODE, - MENU_ID_SENSORS, - MENU_ID_SWITCH_RES, - MENU_ID_INVALID, -} menu_id_change_t; - -typedef enum -{ - DECREASE_ZOOM, - INCREASE_ZOOM, - INCREASE_STEP_ZOOM, - DECREASE_STEP_ZOOM, -} Camera_Zoom; - -typedef enum -{ - INC_CONTRAST, - DEC_CONTRAST, -} Camera_Contrast_changes; - -typedef enum -{ - INC_BRIGHTNESS, - DEC_BRIGHTNESS, -} Camera_Brightness_changes; - -typedef enum -{ - INCREASE_EV, - DECREASE_EV, -} Camera_EV_changes; - -typedef enum { - INC_SATURATION, - DEC_SATURATION, -} Camera_Saturation_changes; - -typedef enum -{ - INC_ISO, - DEC_ISO, -} Camera_ISO_changes; - -typedef enum -{ - INC_SHARPNESS, - DEC_SHARPNESS, -} Camera_Sharpness_changes; - -typedef enum { - ZOOM_IN, - ZOOM_OUT, -} Zoom_direction; - -typedef struct{ - Camera_main_menu_t main_menu; - char * menu_name; -} CAMERA_MAIN_MENU_TBL_T; - -typedef struct{ - char * menu_name; - int present; -} CAMERA_SENSOR_MENU_TLB_T; - -typedef struct{ - Camera_Resolution cs_id; - uint16_t width; - uint16_t height; - char * name; - char * str_name; -} PREVIEW_DIMENSION_TBL_T; - -typedef struct { - White_Balance_modes wb_id; - char * wb_name; -} WHITE_BALANCE_TBL_T; - -typedef struct { - Get_Ctrl_modes get_ctrl_id; - char * get_ctrl_name; -} GET_CTRL_TBL_T; - -typedef struct{ - Exp_Metering_modes exp_metering_id; - char * exp_metering_name; -} EXP_METERING_TBL_T; - -typedef struct { - Bestshot_modes bs_id; - char *name; -} BESTSHOT_MODE_TBT_T; - -typedef struct { - Flash_modes bs_id; - char *name; -} FLASH_MODE_TBL_T; - -typedef struct { - ISO_modes iso_modes; - char *iso_modes_name; -} ISO_TBL_T; - -typedef struct { - Zoom_direction zoom_direction; - char * zoom_direction_name; -} ZOOM_TBL_T; - -typedef struct { - Camera_Sharpness_changes sharpness_change; - char *sharpness_change_name; -} SHARPNESS_TBL_T; - -typedef struct { - Camera_Brightness_changes bc_id; - char * brightness_name; -} CAMERA_BRIGHTNESS_TBL_T; - -typedef struct { - Camera_Contrast_changes cc_id; - char * contrast_name; -} CAMERA_CONTRST_TBL_T; - -typedef struct { - Camera_EV_changes ec_id; - char * EV_name; -} CAMERA_EV_TBL_T; - -typedef struct { - Camera_Saturation_changes sc_id; - char * saturation_name; -} CAMERA_SATURATION_TBL_T; - -typedef struct { - Camera_Sharpness_changes bc_id; - char * sharpness_name; -} CAMERA_SHARPNESS_TBL_T; - -#endif /* __MM_QCAMERA_MAIN_MENU_H__ */ diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h deleted file mode 100644 index c054d63d..00000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_SOCKET_H__ -#define __MM_QCAMERA_SOCKET_H__ - -#include <stdint.h> -#include <pthread.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <termios.h> -#include <assert.h> -#include <stdlib.h> -#include <ctype.h> -#include <signal.h> -#include <errno.h> -#include <stdarg.h> -#include <sys/mman.h> -#include <sys/time.h> -#include <linux/socket.h> -#include <arpa/inet.h> -#include <utils/Log.h> - -#undef __FD_SET -#define __FD_SET(fd, fdsetp) \ - (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1<<((fd) & 31))) - -#undef __FD_CLR -#define __FD_CLR(fd, fdsetp) \ - (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1<<((fd) & 31))) - -#undef __FD_ISSET -#define __FD_ISSET(fd, fdsetp) \ - ((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1<<((fd) & 31))) != 0) - -#undef __FD_ZERO -#define __FD_ZERO(fdsetp) \ - (memset (fdsetp, 0, sizeof (*(fd_set *)(fdsetp)))) - -#define TUNESERVER_MAX_RECV 2048 -#define TUNESERVER_MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#define TUNESERVER_GET_LIST 1014 -#define TUNESERVER_GET_PARMS 1015 -#define TUNESERVER_SET_PARMS 1016 -#define TUNESERVER_MISC_CMDS 1021 - -#define TUNE_PREV_GET_INFO 0x0001 -#define TUNE_PREV_CH_CNK_SIZE 0x0002 -#define TUNE_PREV_GET_PREV_FRAME 0x0003 -#define TUNE_PREV_GET_JPG_SNAP 0x0004 -#define TUNE_PREV_GET_RAW_SNAP 0x0005 -#define TUNE_PREV_GET_RAW_PREV 0x0006 - -typedef struct { - char data[128]; -} tuneserver_misc_cmd; - -typedef enum { - TUNESERVER_RECV_COMMAND = 1, - TUNESERVER_RECV_PAYLOAD_SIZE, - TUNESERVER_RECV_PAYLOAD, - TUNESERVER_RECV_RESPONSE, - TUNESERVERER_RECV_INVALID, -} tuneserver_recv_cmd_t; - -typedef struct { - uint16_t current_cmd; - tuneserver_recv_cmd_t next_recv_code; - uint32_t next_recv_len; - void *recv_buf; - uint32_t recv_len; - uint32_t send_len; - void *send_buf; -} tuneserver_protocol_t; - -typedef enum { - TUNE_PREV_RECV_COMMAND = 1, - TUNE_PREV_RECV_NEWCNKSIZE, - TUNE_PREV_RECV_INVALID -} tune_prev_cmd_t; - -typedef struct _eztune_preview_protocol_t { - uint16_t current_cmd; - tune_prev_cmd_t next_recv_code; - uint32_t next_recv_len; - int32_t send_len; - char* send_buf; - uint32_t send_buf_size; - uint32_t new_cnk_size; - uint32_t new_cmd_available; -} prserver_protocol_t; - - -int eztune_server_start(void *lib_handle); - -#endif /*__MM_QCAMERA_SOCKET_H__*/ diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c deleted file mode 100644 index 3f968fea..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c +++ /dev/null @@ -1,2589 +0,0 @@ -/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <ctype.h> -#include <cutils/properties.h> -#include <fcntl.h> -#include <dlfcn.h> -#include <linux/msm_ion.h> -#include <sys/mman.h> - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -static pthread_mutex_t app_mutex; -static int thread_status = 0; -static pthread_cond_t app_cond_v; - -#define MM_QCAMERA_APP_NANOSEC_SCALE 1000000000 - -int mm_camera_app_timedwait(uint8_t seconds) -{ - int rc = 0; - pthread_mutex_lock(&app_mutex); - if(FALSE == thread_status) { - struct timespec tw; - memset(&tw, 0, sizeof tw); - tw.tv_sec = 0; - tw.tv_nsec = time(0) + seconds * MM_QCAMERA_APP_NANOSEC_SCALE; - - rc = pthread_cond_timedwait(&app_cond_v, &app_mutex,&tw); - thread_status = FALSE; - } - pthread_mutex_unlock(&app_mutex); - return rc; -} - -int mm_camera_app_wait() -{ - int rc = 0; - pthread_mutex_lock(&app_mutex); - if(FALSE == thread_status){ - pthread_cond_wait(&app_cond_v, &app_mutex); - } - thread_status = FALSE; - pthread_mutex_unlock(&app_mutex); - return rc; -} - -void mm_camera_app_done() -{ - pthread_mutex_lock(&app_mutex); - thread_status = TRUE; - pthread_cond_signal(&app_cond_v); - pthread_mutex_unlock(&app_mutex); -} - -int mm_app_load_hal(mm_camera_app_t *my_cam_app) -{ - memset(&my_cam_app->hal_lib, 0, sizeof(hal_interface_lib_t)); - my_cam_app->hal_lib.ptr = dlopen("libmmcamera_interface.so", RTLD_NOW); - my_cam_app->hal_lib.ptr_jpeg = dlopen("libmmjpeg_interface.so", RTLD_NOW); - if (!my_cam_app->hal_lib.ptr || !my_cam_app->hal_lib.ptr_jpeg) { - CDBG_ERROR("%s Error opening HAL library %s\n", __func__, dlerror()); - return -MM_CAMERA_E_GENERAL; - } - *(void **)&(my_cam_app->hal_lib.get_num_of_cameras) = - dlsym(my_cam_app->hal_lib.ptr, "get_num_of_cameras"); - *(void **)&(my_cam_app->hal_lib.mm_camera_open) = - dlsym(my_cam_app->hal_lib.ptr, "camera_open"); - *(void **)&(my_cam_app->hal_lib.jpeg_open) = - dlsym(my_cam_app->hal_lib.ptr_jpeg, "jpeg_open"); - - if (my_cam_app->hal_lib.get_num_of_cameras == NULL || - my_cam_app->hal_lib.mm_camera_open == NULL || - my_cam_app->hal_lib.jpeg_open == NULL) { - CDBG_ERROR("%s Error loading HAL sym %s\n", __func__, dlerror()); - return -MM_CAMERA_E_GENERAL; - } - - my_cam_app->num_cameras = my_cam_app->hal_lib.get_num_of_cameras(); - CDBG("%s: num_cameras = %d\n", __func__, my_cam_app->num_cameras); - - return MM_CAMERA_OK; -} - -int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, int ion_type) -{ - int rc = MM_CAMERA_OK; - struct ion_handle_data handle_data; - struct ion_allocation_data alloc; - struct ion_fd_data ion_info_fd; - int main_ion_fd = 0; - void *data = NULL; - - main_ion_fd = open("/dev/ion", O_RDONLY); - if (main_ion_fd <= 0) { - CDBG_ERROR("Ion dev open failed %s\n", strerror(errno)); - goto ION_OPEN_FAILED; - } - - memset(&alloc, 0, sizeof(alloc)); - alloc.len = buf->mem_info.size; - /* to make it page size aligned */ - alloc.len = (alloc.len + 4095) & (~4095); - alloc.align = 4096; - alloc.flags = ION_FLAG_CACHED; - alloc.heap_mask = ion_type; - rc = ioctl(main_ion_fd, ION_IOC_ALLOC, &alloc); - if (rc < 0) { - CDBG_ERROR("ION allocation failed\n"); - goto ION_ALLOC_FAILED; - } - - memset(&ion_info_fd, 0, sizeof(ion_info_fd)); - ion_info_fd.handle = alloc.handle; - rc = ioctl(main_ion_fd, ION_IOC_SHARE, &ion_info_fd); - if (rc < 0) { - CDBG_ERROR("ION map failed %s\n", strerror(errno)); - goto ION_MAP_FAILED; - } - - data = mmap(NULL, - alloc.len, - PROT_READ | PROT_WRITE, - MAP_SHARED, - ion_info_fd.fd, - 0); - - if (data == MAP_FAILED) { - CDBG_ERROR("ION_MMAP_FAILED: %s (%d)\n", strerror(errno), errno); - goto ION_MAP_FAILED; - } - buf->mem_info.main_ion_fd = main_ion_fd; - buf->mem_info.fd = ion_info_fd.fd; - buf->mem_info.handle = ion_info_fd.handle; - buf->mem_info.size = alloc.len; - buf->mem_info.data = data; - return MM_CAMERA_OK; - -ION_MAP_FAILED: - memset(&handle_data, 0, sizeof(handle_data)); - handle_data.handle = ion_info_fd.handle; - ioctl(main_ion_fd, ION_IOC_FREE, &handle_data); -ION_ALLOC_FAILED: - close(main_ion_fd); -ION_OPEN_FAILED: - return -MM_CAMERA_E_GENERAL; -} - -int mm_app_deallocate_ion_memory(mm_camera_app_buf_t *buf) -{ - struct ion_handle_data handle_data; - int rc = 0; - - rc = munmap(buf->mem_info.data, buf->mem_info.size); - - if (buf->mem_info.fd > 0) { - close(buf->mem_info.fd); - buf->mem_info.fd = 0; - } - - if (buf->mem_info.main_ion_fd > 0) { - memset(&handle_data, 0, sizeof(handle_data)); - handle_data.handle = buf->mem_info.handle; - ioctl(buf->mem_info.main_ion_fd, ION_IOC_FREE, &handle_data); - close(buf->mem_info.main_ion_fd); - buf->mem_info.main_ion_fd = 0; - } - return rc; -} - -/* cmd = ION_IOC_CLEAN_CACHES, ION_IOC_INV_CACHES, ION_IOC_CLEAN_INV_CACHES */ -int mm_app_cache_ops(mm_camera_app_meminfo_t *mem_info, - unsigned int cmd) -{ - struct ion_flush_data cache_inv_data; - struct ion_custom_data custom_data; - int ret = MM_CAMERA_OK; - -#ifdef USE_ION - if (NULL == mem_info) { - CDBG_ERROR("%s: mem_info is NULL, return here", __func__); - return -MM_CAMERA_E_GENERAL; - } - - memset(&cache_inv_data, 0, sizeof(cache_inv_data)); - memset(&custom_data, 0, sizeof(custom_data)); - cache_inv_data.vaddr = mem_info->data; - cache_inv_data.fd = mem_info->fd; - cache_inv_data.handle = mem_info->handle; - cache_inv_data.length = mem_info->size; - custom_data.cmd = cmd; - custom_data.arg = (unsigned long)&cache_inv_data; - - CDBG("addr = %p, fd = %d, handle = %p length = %d, ION Fd = %d", - cache_inv_data.vaddr, cache_inv_data.fd, - cache_inv_data.handle, cache_inv_data.length, - mem_info->main_ion_fd); - if(mem_info->main_ion_fd > 0) { - if(ioctl(mem_info->main_ion_fd, ION_IOC_CUSTOM, &custom_data) < 0) { - ALOGE("%s: Cache Invalidate failed\n", __func__); - ret = -MM_CAMERA_E_GENERAL; - } - } -#endif - - return ret; -} - -void mm_app_dump_frame(mm_camera_buf_def_t *frame, - char *name, - char *ext, - int frame_idx) -{ - char file_name[64]; - int file_fd; - int i; - int offset = 0; - if ( frame != NULL) { - snprintf(file_name, sizeof(file_name), "/data/test/%s_%04d.%s", name, frame_idx, ext); - file_fd = open(file_name, O_RDWR | O_CREAT, 0777); - if (file_fd < 0) { - CDBG_ERROR("%s: cannot open file %s \n", __func__, file_name); - } else { - for (i = 0; i < frame->num_planes; i++) { - CDBG("%s: saving file from address: 0x%x, data offset: %d, length: %d \n", __func__, - (uint32_t )frame->buffer, frame->planes[i].data_offset, frame->planes[i].length); - write(file_fd, - (uint8_t *)frame->buffer + offset, - frame->planes[i].length); - offset += frame->planes[i].length; - } - - close(file_fd); - CDBG("dump %s", file_name); - } - } -} - -void mm_app_dump_jpeg_frame(const void * data, uint32_t size, char* name, char* ext, int index) -{ - char buf[64]; - int file_fd; - if ( data != NULL) { - snprintf(buf, sizeof(buf), "/data/test/%s_%d.%s", name, index, ext); - CDBG("%s: %s size =%d, jobId=%d", __func__, buf, size, index); - file_fd = open(buf, O_RDWR | O_CREAT, 0777); - write(file_fd, data, size); - close(file_fd); - } -} - -int mm_app_alloc_bufs(mm_camera_app_buf_t* app_bufs, - cam_frame_len_offset_t *frame_offset_info, - uint8_t num_bufs, - uint8_t is_streambuf, - size_t multipleOf) -{ - int i, j; - int ion_type = 0x1 << CAMERA_ION_FALLBACK_HEAP_ID; - - if (is_streambuf) { - ion_type |= 0x1 << CAMERA_ION_HEAP_ID; - } - - for (i = 0; i < num_bufs ; i++) { - if ( 0 < multipleOf ) { - size_t m = frame_offset_info->frame_len / multipleOf; - if ( ( frame_offset_info->frame_len % multipleOf ) != 0 ) { - m++; - } - app_bufs[i].mem_info.size = m * multipleOf; - } else { - app_bufs[i].mem_info.size = frame_offset_info->frame_len; - } - mm_app_allocate_ion_memory(&app_bufs[i], ion_type); - - app_bufs[i].buf.buf_idx = i; - app_bufs[i].buf.num_planes = frame_offset_info->num_planes; - app_bufs[i].buf.fd = app_bufs[i].mem_info.fd; - app_bufs[i].buf.frame_len = app_bufs[i].mem_info.size; - app_bufs[i].buf.buffer = app_bufs[i].mem_info.data; - app_bufs[i].buf.mem_info = (void *)&app_bufs[i].mem_info; - - /* Plane 0 needs to be set seperately. Set other planes - * in a loop. */ - app_bufs[i].buf.planes[0].length = frame_offset_info->mp[0].len; - app_bufs[i].buf.planes[0].m.userptr = app_bufs[i].buf.fd; - app_bufs[i].buf.planes[0].data_offset = frame_offset_info->mp[0].offset; - app_bufs[i].buf.planes[0].reserved[0] = 0; - for (j = 1; j < frame_offset_info->num_planes; j++) { - app_bufs[i].buf.planes[j].length = frame_offset_info->mp[j].len; - app_bufs[i].buf.planes[j].m.userptr = app_bufs[i].buf.fd; - app_bufs[i].buf.planes[j].data_offset = frame_offset_info->mp[j].offset; - app_bufs[i].buf.planes[j].reserved[0] = - app_bufs[i].buf.planes[j-1].reserved[0] + - app_bufs[i].buf.planes[j-1].length; - } - } - CDBG("%s: X", __func__); - return MM_CAMERA_OK; -} - -int mm_app_release_bufs(uint8_t num_bufs, - mm_camera_app_buf_t* app_bufs) -{ - int i, rc = MM_CAMERA_OK; - - CDBG("%s: E", __func__); - - for (i = 0; i < num_bufs; i++) { - rc = mm_app_deallocate_ion_memory(&app_bufs[i]); - } - memset(app_bufs, 0, num_bufs * sizeof(mm_camera_app_buf_t)); - CDBG("%s: X", __func__); - return rc; -} - -int mm_app_stream_initbuf(cam_frame_len_offset_t *frame_offset_info, - uint8_t *num_bufs, - uint8_t **initial_reg_flag, - mm_camera_buf_def_t **bufs, - mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - mm_camera_buf_def_t *pBufs = NULL; - uint8_t *reg_flags = NULL; - int i, rc; - - stream->offset = *frame_offset_info; - - CDBG("%s: alloc buf for stream_id %d, len=%d, num planes: %d, offset: %d", - __func__, - stream->s_id, - frame_offset_info->frame_len, - frame_offset_info->num_planes, - frame_offset_info->mp[1].offset); - - pBufs = (mm_camera_buf_def_t *)malloc(sizeof(mm_camera_buf_def_t) * stream->num_of_bufs); - reg_flags = (uint8_t *)malloc(sizeof(uint8_t) * stream->num_of_bufs); - if (pBufs == NULL || reg_flags == NULL) { - CDBG_ERROR("%s: No mem for bufs", __func__); - if (pBufs != NULL) { - free(pBufs); - } - if (reg_flags != NULL) { - free(reg_flags); - } - return -1; - } - - rc = mm_app_alloc_bufs(&stream->s_bufs[0], - frame_offset_info, - stream->num_of_bufs, - 1, - stream->multipleOf); - - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_stream_alloc_bufs err = %d", __func__, rc); - free(pBufs); - free(reg_flags); - return rc; - } - - for (i = 0; i < stream->num_of_bufs; i++) { - /* mapping stream bufs first */ - pBufs[i] = stream->s_bufs[i].buf; - reg_flags[i] = 1; - rc = ops_tbl->map_ops(pBufs[i].buf_idx, - -1, - pBufs[i].fd, - pBufs[i].frame_len, - ops_tbl->userdata); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mapping buf[%d] err = %d", __func__, i, rc); - break; - } - } - - if (rc != MM_CAMERA_OK) { - int j; - for (j=0; j>i; j++) { - ops_tbl->unmap_ops(pBufs[j].buf_idx, -1, ops_tbl->userdata); - } - mm_app_release_bufs(stream->num_of_bufs, &stream->s_bufs[0]); - free(pBufs); - free(reg_flags); - return rc; - } - - *num_bufs = stream->num_of_bufs; - *bufs = pBufs; - *initial_reg_flag = reg_flags; - - CDBG("%s: X",__func__); - return rc; -} - -int32_t mm_app_stream_deinitbuf(mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - int i; - - for (i = 0; i < stream->num_of_bufs ; i++) { - /* mapping stream bufs first */ - ops_tbl->unmap_ops(stream->s_bufs[i].buf.buf_idx, -1, ops_tbl->userdata); - } - - mm_app_release_bufs(stream->num_of_bufs, &stream->s_bufs[0]); - - CDBG("%s: X",__func__); - return 0; -} - -int32_t mm_app_stream_clean_invalidate_buf(int index, void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - return mm_app_cache_ops(&stream->s_bufs[index].mem_info, - ION_IOC_CLEAN_INV_CACHES); -} - -int32_t mm_app_stream_invalidate_buf(int index, void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - return mm_app_cache_ops(&stream->s_bufs[index].mem_info, ION_IOC_INV_CACHES); -} - -static void notify_evt_cb(uint32_t camera_handle, - mm_camera_event_t *evt, - void *user_data) -{ - mm_camera_test_obj_t *test_obj = - (mm_camera_test_obj_t *)user_data; - if (test_obj == NULL || test_obj->cam->camera_handle != camera_handle) { - CDBG_ERROR("%s: Not a valid test obj", __func__); - return; - } - - CDBG("%s:E evt = %d", __func__, evt->server_event_type); - switch (evt->server_event_type) { - case CAM_EVENT_TYPE_AUTO_FOCUS_DONE: - CDBG("%s: rcvd auto focus done evt", __func__); - break; - case CAM_EVENT_TYPE_ZOOM_DONE: - CDBG("%s: rcvd zoom done evt", __func__); - break; - default: - break; - } - - CDBG("%s:X", __func__); -} - -int mm_app_open(mm_camera_app_t *cam_app, - uint8_t cam_id, - mm_camera_test_obj_t *test_obj) -{ - int32_t rc; - cam_frame_len_offset_t offset_info; - - CDBG("%s:BEGIN\n", __func__); - - test_obj->cam = cam_app->hal_lib.mm_camera_open(cam_id); - if(test_obj->cam == NULL) { - CDBG_ERROR("%s:dev open error\n", __func__); - return -MM_CAMERA_E_GENERAL; - } - - CDBG("Open Camera id = %d handle = %d", cam_id, test_obj->cam->camera_handle); - - /* alloc ion mem for capability buf */ - memset(&offset_info, 0, sizeof(offset_info)); - offset_info.frame_len = sizeof(cam_capability_t); - - rc = mm_app_alloc_bufs(&test_obj->cap_buf, - &offset_info, - 1, - 0, - 0); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:alloc buf for capability error\n", __func__); - goto error_after_cam_open; - } - - /* mapping capability buf */ - rc = test_obj->cam->ops->map_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_CAPABILITY, - test_obj->cap_buf.mem_info.fd, - test_obj->cap_buf.mem_info.size); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:map for capability error\n", __func__); - goto error_after_cap_buf_alloc; - } - - /* alloc ion mem for getparm buf */ - memset(&offset_info, 0, sizeof(offset_info)); - offset_info.frame_len = sizeof(parm_buffer_t); - rc = mm_app_alloc_bufs(&test_obj->parm_buf, - &offset_info, - 1, - 0, - 0); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:alloc buf for getparm_buf error\n", __func__); - goto error_after_cap_buf_map; - } - - /* mapping getparm buf */ - rc = test_obj->cam->ops->map_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_PARM_BUF, - test_obj->parm_buf.mem_info.fd, - test_obj->parm_buf.mem_info.size); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:map getparm_buf error\n", __func__); - goto error_after_getparm_buf_alloc; - } - test_obj->params_buffer = (parm_buffer_t*) test_obj->parm_buf.mem_info.data; - CDBG_HIGH("\n%s params_buffer=%p\n",__func__,test_obj->params_buffer); - - rc = test_obj->cam->ops->register_event_notify(test_obj->cam->camera_handle, - notify_evt_cb, - test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: failed register_event_notify", __func__); - rc = -MM_CAMERA_E_GENERAL; - goto error_after_getparm_buf_map; - } - - rc = test_obj->cam->ops->query_capability(test_obj->cam->camera_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: failed query_capability", __func__); - rc = -MM_CAMERA_E_GENERAL; - goto error_after_getparm_buf_map; - } - memset(&test_obj->jpeg_ops, 0, sizeof(mm_jpeg_ops_t)); - mm_dimension pic_size; - memset(&pic_size, 0, sizeof(mm_dimension)); - pic_size.w = 4000; - pic_size.h = 3000; - test_obj->jpeg_hdl = cam_app->hal_lib.jpeg_open(&test_obj->jpeg_ops,pic_size); - if (test_obj->jpeg_hdl == 0) { - CDBG_ERROR("%s: jpeg lib open err", __func__); - rc = -MM_CAMERA_E_GENERAL; - goto error_after_getparm_buf_map; - } - - return rc; - -error_after_getparm_buf_map: - test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_PARM_BUF); -error_after_getparm_buf_alloc: - mm_app_release_bufs(1, &test_obj->parm_buf); -error_after_cap_buf_map: - test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_CAPABILITY); -error_after_cap_buf_alloc: - mm_app_release_bufs(1, &test_obj->cap_buf); -error_after_cam_open: - test_obj->cam->ops->close_camera(test_obj->cam->camera_handle); - test_obj->cam = NULL; - return rc; -} - -int add_parm_entry_tobatch(parm_buffer_t *p_table, - cam_intf_parm_type_t paramType, - uint32_t paramLength, - void *paramValue) -{ - int rc = MM_CAMERA_OK; - void* dst; - - if (paramLength > get_size_of(paramType)) { - CDBG_ERROR("%s:Size of input larger than max entry size",__func__); - return -1; - } - dst = get_pointer_of(paramType, p_table); - if(dst){ - memcpy(dst, paramValue, paramLength); - p_table->is_valid[paramType] = 1; - } - return rc; -} - -int init_batch_update(parm_buffer_t *p_table) -{ - int rc = MM_CAMERA_OK; - CDBG_HIGH("\nEnter %s\n",__func__); - int32_t hal_version = CAM_HAL_V1; - - memset(p_table, 0, sizeof(parm_buffer_t)); - rc = add_parm_entry_tobatch(p_table, CAM_INTF_PARM_HAL_VERSION,sizeof(hal_version), &hal_version); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: add_parm_entry_tobatch failed !!", __func__); - } - return rc; -} - -int commit_set_batch(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int i = 0; - - for(i = 0; i < CAM_INTF_PARM_MAX; i++){ - if(test_obj->params_buffer->is_valid[i]) - break; - } - if (i < CAM_INTF_PARM_MAX) { - CDBG_HIGH("\n set_param p_buffer =%p\n",test_obj->params_buffer); - rc = test_obj->cam->ops->set_parms(test_obj->cam->camera_handle, test_obj->params_buffer); - } - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: cam->ops->set_parms failed !!", __func__); - } - return rc; -} - - -int mm_app_set_params(mm_camera_test_obj_t *test_obj, - cam_intf_parm_type_t param_type, - int32_t value) -{ - CDBG_HIGH("\nEnter mm_app_set_params!! param_type =%d & value =%d\n",param_type, value); - int rc = MM_CAMERA_OK; - rc = init_batch_update(test_obj->params_buffer); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: init_batch_update failed !!", __func__); - return rc; - } - rc = add_parm_entry_tobatch(test_obj->params_buffer, param_type, sizeof(value), &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: add_parm_entry_tobatch failed !!", __func__); - return rc; - } - rc = commit_set_batch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: commit_set_batch failed !!", __func__); - return rc; - } - return rc; -} - -int mm_app_close(mm_camera_test_obj_t *test_obj) -{ - uint32_t rc = MM_CAMERA_OK; - - if (test_obj == NULL || test_obj->cam ==NULL) { - CDBG_ERROR("%s: cam not opened", __func__); - return -MM_CAMERA_E_GENERAL; - } - - /* unmap capability buf */ - rc = test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_CAPABILITY); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: unmap capability buf failed, rc=%d", __func__, rc); - } - - /* unmap parm buf */ - rc = test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_PARM_BUF); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: unmap setparm buf failed, rc=%d", __func__, rc); - } - - rc = test_obj->cam->ops->close_camera(test_obj->cam->camera_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: close camera failed, rc=%d", __func__, rc); - } - test_obj->cam = NULL; - - /* close jpeg client */ - if (test_obj->jpeg_hdl && test_obj->jpeg_ops.close) { - rc = test_obj->jpeg_ops.close(test_obj->jpeg_hdl); - test_obj->jpeg_hdl = 0; - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: close jpeg failed, rc=%d", __func__, rc); - } - } - - /* dealloc capability buf */ - rc = mm_app_release_bufs(1, &test_obj->cap_buf); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: release capability buf failed, rc=%d", __func__, rc); - } - - /* dealloc parm buf */ - rc = mm_app_release_bufs(1, &test_obj->parm_buf); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: release setparm buf failed, rc=%d", __func__, rc); - } - - return MM_CAMERA_OK; -} - -mm_camera_channel_t * mm_app_add_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type, - mm_camera_channel_attr_t *attr, - mm_camera_buf_notify_t channel_cb, - void *userdata) -{ - uint32_t ch_id = 0; - mm_camera_channel_t *channel = NULL; - - ch_id = test_obj->cam->ops->add_channel(test_obj->cam->camera_handle, - attr, - channel_cb, - userdata); - if (ch_id == 0) { - CDBG_ERROR("%s: add channel failed", __func__); - return NULL; - } - channel = &test_obj->channels[ch_type]; - channel->ch_id = ch_id; - return channel; -} - -int mm_app_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - test_obj->cam->ops->delete_channel(test_obj->cam->camera_handle, - channel->ch_id); - memset(channel, 0, sizeof(mm_camera_channel_t)); - return MM_CAMERA_OK; -} - -mm_camera_stream_t * mm_app_add_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - mm_camera_stream_t *stream = NULL; - int rc = MM_CAMERA_OK; - cam_frame_len_offset_t offset_info; - - stream = &(channel->streams[channel->num_streams++]); - stream->s_id = test_obj->cam->ops->add_stream(test_obj->cam->camera_handle, - channel->ch_id); - if (stream->s_id == 0) { - CDBG_ERROR("%s: add stream failed", __func__); - return NULL; - } - - stream->multipleOf = test_obj->slice_size; - - /* alloc ion mem for stream_info buf */ - memset(&offset_info, 0, sizeof(offset_info)); - offset_info.frame_len = sizeof(cam_stream_info_t); - - rc = mm_app_alloc_bufs(&stream->s_info_buf, - &offset_info, - 1, - 0, - 0); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:alloc buf for stream_info error\n", __func__); - test_obj->cam->ops->delete_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id); - stream->s_id = 0; - return NULL; - } - - /* mapping streaminfo buf */ - rc = test_obj->cam->ops->map_stream_buf(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id, - CAM_MAPPING_BUF_TYPE_STREAM_INFO, - 0, - -1, - stream->s_info_buf.mem_info.fd, - stream->s_info_buf.mem_info.size); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:map setparm_buf error\n", __func__); - mm_app_deallocate_ion_memory(&stream->s_info_buf); - test_obj->cam->ops->delete_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id); - stream->s_id = 0; - return NULL; - } - - return stream; -} - -int mm_app_del_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream) -{ - test_obj->cam->ops->unmap_stream_buf(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id, - CAM_MAPPING_BUF_TYPE_STREAM_INFO, - 0, - -1); - mm_app_deallocate_ion_memory(&stream->s_info_buf); - test_obj->cam->ops->delete_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id); - memset(stream, 0, sizeof(mm_camera_stream_t)); - return MM_CAMERA_OK; -} - -mm_camera_channel_t *mm_app_get_channel_by_type(mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type) -{ - return &test_obj->channels[ch_type]; -} - -int mm_app_config_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream, - mm_camera_stream_config_t *config) -{ - return test_obj->cam->ops->config_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id, - config); -} - -int mm_app_start_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - return test_obj->cam->ops->start_channel(test_obj->cam->camera_handle, - channel->ch_id); -} - -int mm_app_stop_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - return test_obj->cam->ops->stop_channel(test_obj->cam->camera_handle, - channel->ch_id); -} - -int AddSetParmEntryToBatch(mm_camera_test_obj_t *test_obj, - cam_intf_parm_type_t paramType, - uint32_t paramLength, - void *paramValue) -{ - parm_buffer_t *p_table = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - void* dst; - /************************************************************************* - * Copy contents into entry * - *************************************************************************/ - - if (paramLength > get_size_of(paramType)) { - ALOGE("%s:Size of input larger than max entry size",__func__); - return MM_CAMERA_E_GENERAL; - } - dst = get_pointer_of(paramType,p_table); - if(dst){ - memcpy(dst, paramValue, paramLength); - p_table->is_valid[paramType] = 1; - } - return MM_CAMERA_OK; -} - -int initBatchUpdate(mm_camera_test_obj_t *test_obj) -{ - int32_t hal_version = CAM_HAL_V1; - - parm_buffer_t *parm_buf = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - memset(parm_buf, 0, sizeof(parm_buffer_t)); - AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_HAL_VERSION, - sizeof(hal_version), - &hal_version); - - return MM_CAMERA_OK; -} - -int ReadSetParmEntryToBatch(mm_camera_test_obj_t *test_obj, - cam_intf_parm_type_t paramType, - uint32_t paramLength, - void *paramValue) -{ - void* dst; - parm_buffer_t *p_table = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - dst = get_pointer_of(paramType,p_table); - if (NULL == dst) { - ALOGE("%s: dst is NULL for paramType: %d", __func__, paramType); - return MM_CAMERA_E_GENERAL; - } - memcpy(paramValue, dst, paramLength); - return MM_CAMERA_OK; -} - -int commitSetBatch(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int i = 0; - - parm_buffer_t *p_table = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - for(i = 0; i < CAM_INTF_PARM_MAX; i++){ - if(p_table->is_valid[i]) - break; - } - if (i < CAM_INTF_PARM_MAX) { - rc = test_obj->cam->ops->set_parms(test_obj->cam->camera_handle, p_table); - } - return rc; -} - - -int commitGetBatch(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int i = 0; - parm_buffer_t *p_table = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - for(i = 0; i < CAM_INTF_PARM_MAX; i++){ - if(p_table->is_valid[i]) - break; - } - if (i < CAM_INTF_PARM_MAX) { - rc = test_obj->cam->ops->get_parms(test_obj->cam->camera_handle, p_table); - } - return rc; -} - -int setAecLock(mm_camera_test_obj_t *test_obj, int value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_AEC_LOCK, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: AEC Lock parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - -ERROR: - return rc; -} - -int setAwbLock(mm_camera_test_obj_t *test_obj, int value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_AWB_LOCK, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: AWB Lock parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - -ERROR: - return rc; -} - - -int set3Acommand(mm_camera_test_obj_t *test_obj, cam_eztune_cmd_data_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_EZTUNE_CMD, - sizeof(cam_eztune_cmd_data_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: CAM_INTF_PARM_EZTUNE_CMD parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - -ERROR: - return rc; -} - -int getChromatix(mm_camera_test_obj_t *test_obj, tune_chromatix_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_GET_CHROMATIX, - sizeof(tune_chromatix_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: getChromatixPointer not added to batch\n", __func__); - goto ERROR; - } - - rc = commitGetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - rc = ReadSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_GET_CHROMATIX, - sizeof(tune_chromatix_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: getChromatixPointer not able to read\n", __func__); - goto ERROR; - } -ERROR: - return rc; -} - -int setReloadChromatix(mm_camera_test_obj_t *test_obj, tune_chromatix_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_SET_RELOAD_CHROMATIX, - sizeof(tune_chromatix_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: getChromatixPointer not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } -ERROR: - return rc; -} - -int getAutofocusParams(mm_camera_test_obj_t *test_obj, tune_autofocus_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_GET_AFTUNE, - sizeof(tune_autofocus_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: getChromatixPointer not added to batch\n", __func__); - goto ERROR; - } - - rc = commitGetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - rc = ReadSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_GET_AFTUNE, - sizeof(tune_autofocus_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: getAutofocusParams not able to read\n", __func__); - goto ERROR; - } -ERROR: - return rc; -} - -int setReloadAutofocusParams(mm_camera_test_obj_t *test_obj, tune_autofocus_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_SET_RELOAD_AFTUNE, - sizeof(tune_autofocus_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setReloadAutofocusParams not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } -ERROR: - return rc; -} - -int setAutoFocusTuning(mm_camera_test_obj_t *test_obj, tune_actuator_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_SET_AUTOFOCUSTUNING, - sizeof(tune_actuator_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: AutoFocus Tuning not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - -ERROR: - return rc; -} - -int setVfeCommand(mm_camera_test_obj_t *test_obj, tune_cmd_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_SET_VFE_COMMAND, - sizeof(tune_cmd_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: VFE Command not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - -ERROR: - return rc; -} - -int setPPCommand(mm_camera_test_obj_t *test_obj, tune_cmd_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_SET_PP_COMMAND, - sizeof(tune_cmd_t), - value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: PP Command not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - -ERROR: - return rc; -} - -int setFocusMode(mm_camera_test_obj_t *test_obj, cam_focus_mode_type mode) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - uint32_t value = mode; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_FOCUS_MODE, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Focus mode parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - -ERROR: - return rc; -} - -int setEVCompensation(mm_camera_test_obj_t *test_obj, int ev) -{ - int rc = MM_CAMERA_OK; - - cam_capability_t *camera_cap = NULL; - - camera_cap = (cam_capability_t *) test_obj->cap_buf.mem_info.data; - if ( (ev >= camera_cap->exposure_compensation_min) && - (ev <= camera_cap->exposure_compensation_max) ) { - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - uint32_t value = ev; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_EXPOSURE_COMPENSATION, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: EV compensation parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: EV compensation set to: %d", __func__, value); - } else { - CDBG_ERROR("%s: Invalid EV compensation", __func__); - return -EINVAL; - } - -ERROR: - return rc; -} - -int setAntibanding(mm_camera_test_obj_t *test_obj, cam_antibanding_mode_type antibanding) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - uint32_t value = antibanding; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_ANTIBANDING, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Antibanding parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Antibanding set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setWhiteBalance(mm_camera_test_obj_t *test_obj, cam_wb_mode_type mode) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - uint32_t value = mode; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_WHITE_BALANCE, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: White balance parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: White balance set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setExposureMetering(mm_camera_test_obj_t *test_obj, cam_auto_exposure_mode_type mode) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - uint32_t value = mode; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_EXPOSURE, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Exposure metering parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Exposure metering set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setBrightness(mm_camera_test_obj_t *test_obj, int brightness) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = brightness; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_BRIGHTNESS, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Brightness parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Brightness set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setContrast(mm_camera_test_obj_t *test_obj, int contrast) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = contrast; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_CONTRAST, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Contrast parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Contrast set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setTintless(mm_camera_test_obj_t *test_obj, int tintless) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = tintless; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_TINTLESS, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Contrast parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: set Tintless to: %d", __func__, value); - -ERROR: - return rc; -} - -int setSaturation(mm_camera_test_obj_t *test_obj, int saturation) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = saturation; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_SATURATION, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Saturation parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Saturation set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setSharpness(mm_camera_test_obj_t *test_obj, int sharpness) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = sharpness; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_SHARPNESS, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Sharpness parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - test_obj->reproc_sharpness = sharpness; - CDBG_ERROR("%s: Sharpness set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setISO(mm_camera_test_obj_t *test_obj, cam_iso_mode_type iso) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = iso; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_ISO, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: ISO parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: ISO set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setZoom(mm_camera_test_obj_t *test_obj, int zoom) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = zoom; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_ZOOM, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Zoom parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Zoom set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setFPSRange(mm_camera_test_obj_t *test_obj, cam_fps_range_t range) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_FPS_RANGE, - sizeof(cam_fps_range_t), - &range); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: FPS range parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: FPS Range set to: [%5.2f:%5.2f]", - __func__, - range.min_fps, - range.max_fps); - -ERROR: - return rc; -} - -int setScene(mm_camera_test_obj_t *test_obj, cam_scene_mode_type scene) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = scene; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_BESTSHOT_MODE, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Scene parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Scene set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setFlash(mm_camera_test_obj_t *test_obj, cam_flash_mode_t flash) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - int32_t value = flash; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_LED_MODE, - sizeof(value), - &value); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Flash parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - CDBG_ERROR("%s: Flash set to: %d", __func__, value); - -ERROR: - return rc; -} - -int setWNR(mm_camera_test_obj_t *test_obj, int enable) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch camera parameter update failed\n", __func__); - goto ERROR; - } - - cam_denoise_param_t param; - memset(¶m, 0, sizeof(cam_denoise_param_t)); - param.denoise_enable = enable; - param.process_plates = CAM_WAVELET_DENOISE_YCBCR_PLANE; - - rc = AddSetParmEntryToBatch(test_obj, - CAM_INTF_PARM_WAVELET_DENOISE, - sizeof(cam_denoise_param_t), - ¶m); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: WNR enabled parameter not added to batch\n", __func__); - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Batch parameters commit failed\n", __func__); - goto ERROR; - } - - - test_obj->reproc_wnr = param; - CDBG_ERROR("%s: WNR enabled: %d", __func__, enable); - -ERROR: - return rc; -} - - -/** tuneserver_capture - * @lib_handle: the camera handle object - * @dim: snapshot dimensions - * - * makes JPEG capture - * - * Return: >=0 on success, -1 on failure. - **/ -int tuneserver_capture(mm_camera_lib_handle *lib_handle, - mm_camera_lib_snapshot_params *dim) -{ - int rc = 0; - - printf("Take jpeg snapshot\n"); - if ( lib_handle->stream_running ) { - - if ( lib_handle->test_obj.zsl_enabled) { - if ( NULL != dim) { - if ( ( lib_handle->test_obj.buffer_width != dim->width) || - ( lib_handle->test_obj.buffer_height = dim->height ) ) { - - lib_handle->test_obj.buffer_width = dim->width; - lib_handle->test_obj.buffer_height = dim->height; - - rc = mm_camera_lib_stop_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_stop_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - - rc = mm_camera_lib_start_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_start_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - } - - } - - lib_handle->test_obj.encodeJpeg = 1; - - mm_camera_app_wait(); - } else { - // For standard 2D capture streaming has to be disabled first - rc = mm_camera_lib_stop_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_stop_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - - if ( NULL != dim ) { - lib_handle->test_obj.buffer_width = dim->width; - lib_handle->test_obj.buffer_height = dim->height; - } - rc = mm_app_start_capture(&lib_handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_capture() err=%d\n", - __func__, rc); - goto EXIT; - } - - mm_camera_app_wait(); - - rc = mm_app_stop_capture(&lib_handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_capture() err=%d\n", - __func__, rc); - goto EXIT; - } - - // Restart streaming after capture is done - rc = mm_camera_lib_start_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_start_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - } - } - -EXIT: - - return rc; -} - -int mm_app_start_regression_test(int run_tc) -{ - int rc = MM_CAMERA_OK; - mm_camera_app_t my_cam_app; - - CDBG("\nCamera Test Application\n"); - memset(&my_cam_app, 0, sizeof(mm_camera_app_t)); - - rc = mm_app_load_hal(&my_cam_app); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_load_hal failed !!", __func__); - return rc; - } - - if(run_tc) { - rc = mm_app_unit_test_entry(&my_cam_app); - return rc; - } -#if 0 - if(run_dual_tc) { - printf("\tRunning Dual camera test engine only\n"); - rc = mm_app_dual_test_entry(&my_cam_app); - printf("\t Dual camera engine. EXIT(%d)!!!\n", rc); - exit(rc); - } -#endif - return rc; -} - -int32_t mm_camera_load_tuninglibrary(mm_camera_tuning_lib_params_t *tuning_param) -{ - void *(*tuning_open_lib)(void) = NULL; - - CDBG("%s %d\n", __func__, __LINE__); - tuning_param->lib_handle = dlopen("libmmcamera_tuning.so", RTLD_NOW); - if (!tuning_param->lib_handle) { - CDBG_ERROR("%s Failed opening libmmcamera_tuning.so\n", __func__); - return -EINVAL; - } - - *(void **)&tuning_open_lib = dlsym(tuning_param->lib_handle, - "open_tuning_lib"); - if (!tuning_open_lib) { - CDBG_ERROR("%s Failed symbol libmmcamera_tuning.so\n", __func__); - return -EINVAL; - } - - if (tuning_param->func_tbl) { - CDBG_ERROR("%s already loaded tuninglib..", __func__); - return 0; - } - - tuning_param->func_tbl = (mm_camera_tune_func_t *)tuning_open_lib(); - if (!tuning_param->func_tbl) { - CDBG_ERROR("%s Failed opening library func table ptr\n", __func__); - return -EINVAL; - } - - CDBG("%s %d\n", __func__, __LINE__); - return 0; -} - -int mm_camera_lib_open(mm_camera_lib_handle *handle, int cam_id) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - CDBG_ERROR(" %s : Invalid handle", __func__); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - memset(handle, 0, sizeof(mm_camera_lib_handle)); - rc = mm_app_load_hal(&handle->app_ctx); - if( MM_CAMERA_OK != rc ) { - CDBG_ERROR("%s:mm_app_init err\n", __func__); - goto EXIT; - } - - handle->test_obj.buffer_width = DEFAULT_PREVIEW_WIDTH; - handle->test_obj.buffer_height = DEFAULT_PREVIEW_HEIGHT; - handle->test_obj.buffer_format = DEFAULT_SNAPSHOT_FORMAT; - handle->current_params.stream_width = DEFAULT_SNAPSHOT_WIDTH; - handle->current_params.stream_height = DEFAULT_SNAPSHOT_HEIGHT; - handle->current_params.af_mode = CAM_FOCUS_MODE_AUTO; // Default to auto focus mode - rc = mm_app_open(&handle->app_ctx, cam_id, &handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, cam_id, rc); - goto EXIT; - } - - //rc = mm_app_initialize_fb(&handle->test_obj); - rc = MM_CAMERA_OK; - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_initialize_fb() cam_idx=%d, err=%d\n", - __func__, cam_id, rc); - goto EXIT; - } - -EXIT: - - return rc; -} - -int mm_camera_lib_start_stream(mm_camera_lib_handle *handle) -{ - int rc = MM_CAMERA_OK; - cam_capability_t camera_cap; - - if ( NULL == handle ) { - CDBG_ERROR(" %s : Invalid handle", __func__); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - if ( handle->test_obj.zsl_enabled ) { - rc = mm_app_start_preview_zsl(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_preview_zsl() err=%d\n", - __func__, rc); - goto EXIT; - } - } else { - handle->test_obj.enable_reproc = ENABLE_REPROCESSING; - rc = mm_app_start_preview(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_preview() err=%d\n", - __func__, rc); - goto EXIT; - } - } - - // Configure focus mode after stream starts - rc = mm_camera_lib_get_caps(handle, &camera_cap); - if ( MM_CAMERA_OK != rc ) { - CDBG_ERROR("%s:mm_camera_lib_get_caps() err=%d\n", __func__, rc); - return -1; - } - if (camera_cap.supported_focus_modes_cnt == 1 && - camera_cap.supported_focus_modes[0] == CAM_FOCUS_MODE_FIXED) { - CDBG("focus not supported"); - handle->test_obj.focus_supported = 0; - handle->current_params.af_mode = CAM_FOCUS_MODE_FIXED; - } else { - handle->test_obj.focus_supported = 1; - } - rc = setFocusMode(&handle->test_obj, handle->current_params.af_mode); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:autofocus error\n", __func__); - goto EXIT; - } - handle->stream_running = 1; - -EXIT: - return rc; -} - -int mm_camera_lib_stop_stream(mm_camera_lib_handle *handle) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - CDBG_ERROR(" %s : Invalid handle", __func__); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - if ( handle->test_obj.zsl_enabled ) { - rc = mm_app_stop_preview_zsl(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_preview_zsl() err=%d\n", - __func__, rc); - goto EXIT; - } - } else { - rc = mm_app_stop_preview(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_preview() err=%d\n", - __func__, rc); - goto EXIT; - } - } - - handle->stream_running = 0; - -EXIT: - return rc; -} - -int mm_camera_lib_get_caps(mm_camera_lib_handle *handle, - cam_capability_t *caps) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - CDBG_ERROR(" %s : Invalid handle", __func__); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - if ( NULL == caps ) { - CDBG_ERROR(" %s : Invalid capabilities structure", __func__); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - *caps = *( (cam_capability_t *) handle->test_obj.cap_buf.mem_info.data ); - -EXIT: - - return rc; -} - - -int mm_camera_lib_send_command(mm_camera_lib_handle *handle, - mm_camera_lib_commands cmd, - void *in_data, void *out_data) -{ - int width, height; - int rc = MM_CAMERA_OK; - cam_capability_t *camera_cap = NULL; - mm_camera_lib_snapshot_params *dim = NULL; - - if ( NULL == handle ) { - CDBG_ERROR(" %s : Invalid handle", __func__); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - camera_cap = (cam_capability_t *) handle->test_obj.cap_buf.mem_info.data; - - switch(cmd) { - case MM_CAMERA_LIB_FPS_RANGE: - if ( NULL != in_data ) { - cam_fps_range_t range = *(( cam_fps_range_t * )in_data); - rc = setFPSRange(&handle->test_obj, range); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setFPSRange() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_FLASH: - if ( NULL != in_data ) { - cam_flash_mode_t flash = *(( int * )in_data); - rc = setFlash(&handle->test_obj, flash); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setFlash() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_BESTSHOT: - if ( NULL != in_data ) { - cam_scene_mode_type scene = *(( int * )in_data); - rc = setScene(&handle->test_obj, scene); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setScene() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ZOOM: - if ( NULL != in_data ) { - int zoom = *(( int * )in_data); - rc = setZoom(&handle->test_obj, zoom); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setZoom() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ISO: - if ( NULL != in_data ) { - cam_iso_mode_type iso = *(( int * )in_data); - rc = setISO(&handle->test_obj, iso); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setISO() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_SHARPNESS: - if ( NULL != in_data ) { - int sharpness = *(( int * )in_data); - rc = setSharpness(&handle->test_obj, sharpness); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setSharpness() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_SATURATION: - if ( NULL != in_data ) { - int saturation = *(( int * )in_data); - rc = setSaturation(&handle->test_obj, saturation); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setSaturation() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_CONTRAST: - if ( NULL != in_data ) { - int contrast = *(( int * )in_data); - rc = setContrast(&handle->test_obj, contrast); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setContrast() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_SET_TINTLESS: - if ( NULL != in_data ) { - int tintless = *(( int * )in_data); - rc = setTintless(&handle->test_obj, tintless); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: enlabe/disable:%d tintless() err=%d\n", - __func__, tintless, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_BRIGHTNESS: - if ( NULL != in_data ) { - int brightness = *(( int * )in_data); - rc = setBrightness(&handle->test_obj, brightness); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setBrightness() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_EXPOSURE_METERING: - if ( NULL != in_data ) { - cam_auto_exposure_mode_type exp = *(( int * )in_data); - rc = setExposureMetering(&handle->test_obj, exp); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setExposureMetering() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_WB: - if ( NULL != in_data ) { - cam_wb_mode_type wb = *(( int * )in_data); - rc = setWhiteBalance(&handle->test_obj, wb); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setWhiteBalance() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ANTIBANDING: - if ( NULL != in_data ) { - int antibanding = *(( int * )in_data); - rc = setAntibanding(&handle->test_obj, antibanding); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setAntibanding() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_EV: - if ( NULL != in_data ) { - int ev = *(( int * )in_data); - rc = setEVCompensation(&handle->test_obj, ev); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setEVCompensation() err=%d\n", - __func__, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ZSL_ENABLE: - if ( NULL != in_data) { - int enable_zsl = *(( int * )in_data); - if ( ( enable_zsl != handle->test_obj.zsl_enabled ) && - handle->stream_running ) { - rc = mm_camera_lib_stop_stream(handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_stop_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - handle->test_obj.zsl_enabled = enable_zsl; - rc = mm_camera_lib_start_stream(handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_start_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - } else { - handle->test_obj.zsl_enabled = enable_zsl; - } - } - break; - case MM_CAMERA_LIB_RAW_CAPTURE: - - if ( 0 == handle->stream_running ) { - CDBG_ERROR(" %s : Streaming is not enabled!", __func__); - rc = MM_CAMERA_E_INVALID_OPERATION; - goto EXIT; - } - - rc = mm_camera_lib_stop_stream(handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_stop_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - - width = handle->test_obj.buffer_width; - height = handle->test_obj.buffer_height; - handle->test_obj.buffer_width = camera_cap->raw_dim[0].width; - handle->test_obj.buffer_height = camera_cap->raw_dim[0].height; - handle->test_obj.buffer_format = DEFAULT_RAW_FORMAT; - CDBG_ERROR("%s: MM_CAMERA_LIB_RAW_CAPTURE %dx%d\n", - __func__, - camera_cap->raw_dim[0].width, - camera_cap->raw_dim[0].height); - rc = mm_app_start_capture_raw(&handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_capture() err=%d\n", - __func__, rc); - goto EXIT; - } - - mm_camera_app_wait(); - - rc = mm_app_stop_capture_raw(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_capture() err=%d\n", - __func__, rc); - goto EXIT; - } - - handle->test_obj.buffer_width = width; - handle->test_obj.buffer_height = height; - handle->test_obj.buffer_format = DEFAULT_SNAPSHOT_FORMAT; - rc = mm_camera_lib_start_stream(handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_camera_lib_start_stream() err=%d\n", - __func__, rc); - goto EXIT; - } - - break; - - case MM_CAMERA_LIB_JPEG_CAPTURE: - if ( 0 == handle->stream_running ) { - CDBG_ERROR(" %s : Streaming is not enabled!", __func__); - rc = MM_CAMERA_E_INVALID_OPERATION; - goto EXIT; - } - - if ( NULL != in_data ) { - dim = ( mm_camera_lib_snapshot_params * ) in_data; - } - - rc = tuneserver_capture(handle, dim); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:capture error %d\n", __func__, rc); - goto EXIT; - } - - if (handle->test_obj.is_chromatix_reload == TRUE) { - /**Re-load Chromatix is taken care to make sure Tuned data ** - ** is not lost when capture Snapshot **/ - rc = setReloadChromatix(&handle->test_obj, - (tune_chromatix_t *)&(handle->test_obj.tune_data)); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setReloadChromatix failed\n", __func__); - goto EXIT; - } - } - break; - - case MM_CAMERA_LIB_SET_FOCUS_MODE: { - cam_focus_mode_type mode = *((cam_focus_mode_type *)in_data); - handle->current_params.af_mode = mode; - rc = setFocusMode(&handle->test_obj, mode); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:autofocus error\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_DO_AF: - if (handle->test_obj.focus_supported) { - rc = handle->test_obj.cam->ops->do_auto_focus(handle->test_obj.cam->camera_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:autofocus error\n", __func__); - goto EXIT; - } - /*Waiting for Auto Focus Done Call Back*/ - mm_camera_app_wait(); - } - break; - - case MM_CAMERA_LIB_CANCEL_AF: - rc = handle->test_obj.cam->ops->cancel_auto_focus(handle->test_obj.cam->camera_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:autofocus error\n", __func__); - goto EXIT; - } - - break; - - case MM_CAMERA_LIB_LOCK_AWB: - rc = setAwbLock(&handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: AWB locking failed\n", __func__); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_UNLOCK_AWB: - rc = setAwbLock(&handle->test_obj, 0); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: AE unlocking failed\n", __func__); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_LOCK_AE: - rc = setAecLock(&handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: AE locking failed\n", __func__); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_UNLOCK_AE: - rc = setAecLock(&handle->test_obj, 0); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: AE unlocking failed\n", __func__); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_SET_3A_COMMAND: { - rc = set3Acommand(&handle->test_obj, (cam_eztune_cmd_data_t *)in_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:3A set command error\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_GET_CHROMATIX: { - rc = getChromatix(&handle->test_obj, - (tune_chromatix_t *)out_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: getChromatix failed\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_RELOAD_CHROMATIX: { - rc = setReloadChromatix(&handle->test_obj, - (tune_chromatix_t *)in_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setReloadChromatix failed\n", __func__); - goto EXIT; - } - handle->test_obj.is_chromatix_reload = TRUE; - memcpy((void *)&(handle->test_obj.tune_data), - (void *)in_data, sizeof(tune_chromatix_t)); - break; - } - - case MM_CAMERA_LIB_GET_AFTUNE: { - rc = getAutofocusParams(&handle->test_obj, - (tune_autofocus_t *)out_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: getAutofocusParams failed\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_RELOAD_AFTUNE: { - rc = setReloadAutofocusParams(&handle->test_obj, - (tune_autofocus_t *)in_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: setReloadAutofocusParams failed\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_AUTOFOCUS_TUNING: { - rc = setAutoFocusTuning(&handle->test_obj, in_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Set AF tuning failed\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_VFE_COMMAND: { - rc = setVfeCommand(&handle->test_obj, in_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Set vfe command failed\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_POSTPROC_COMMAND: { - rc = setPPCommand(&handle->test_obj, in_data); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Set pp command failed\n", __func__); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_WNR_ENABLE: { - int wnr_enable = *((uint8_t *)in_data); - rc = setWNR(&handle->test_obj, wnr_enable); - if ( rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: Set wnr enable failed\n", __func__); - goto EXIT; - } - } - - case MM_CAMERA_LIB_NO_ACTION: - default: - break; - }; - -EXIT: - - return rc; -} -int mm_camera_lib_number_of_cameras(mm_camera_lib_handle *handle) -{ - int rc = 0; - - if ( NULL == handle ) { - CDBG_ERROR(" %s : Invalid handle", __func__); - goto EXIT; - } - - rc = handle->app_ctx.num_cameras; - -EXIT: - - return rc; -} - -int mm_camera_lib_close(mm_camera_lib_handle *handle) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - CDBG_ERROR(" %s : Invalid handle", __func__); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - //rc = mm_app_close_fb(&handle->test_obj); - rc = MM_CAMERA_OK; - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close_fb() err=%d\n", - __func__, rc); - goto EXIT; - } - - rc = mm_app_close(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n", - __func__, rc); - goto EXIT; - } - -EXIT: - return rc; -} - -int mm_camera_lib_set_preview_usercb( - mm_camera_lib_handle *handle, prev_callback cb) -{ - if (handle->test_obj.user_preview_cb != NULL) { - CDBG_ERROR("%s, already set preview callbacks\n", __func__); - return -1; - } - handle->test_obj.user_preview_cb = *cb; - return 0; -} diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_commands.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_commands.c deleted file mode 100644 index 890a8cbe..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_commands.c +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#include <stdlib.h> -#include <cutils/properties.h> -#include <fcntl.h> -#include <dlfcn.h> -#include <mm_qcamera_app.h> -#include "mm_qcamera_commands.h" -#include "mm_qcamera_dbg.h" - -int tuneserver_initialize_prevtuningp(void * ctrl, - int pr_client_socket_id, cam_dimension_t dimension, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *) ctrl; - tuningserver_t *tctrl = &lib_handle->tsctrl; - - CDBG("%s %d\n", __func__, __LINE__); - if (tctrl->tuning_params.func_tbl->prevcommand_process == NULL) { - ALOGE("%s %d\n", __func__, __LINE__); - return -1; - } - - result = tctrl->tuning_params.func_tbl->prevcommand_process( - NULL, TUNE_PREVCMD_INIT, (void *)&pr_client_socket_id, - send_buf, send_len); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - NULL, TUNE_PREVCMD_SETDIM, (void *)&dimension, - send_buf, send_len); - - mm_camera_lib_set_preview_usercb(lib_handle, - (tctrl->tuning_params.func_tbl->prevframe_callback)); - - return result; -} - -int tuneserver_deinitialize_prevtuningp(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_DEINIT, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_preview_getinfo(void * ctrl, char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_GETINFO, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_preview_getchunksize(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_GETCHUNKSIZE, - (void *)&tctrl->pr_proto->new_cnk_size, send_buf, send_len); - - return result; -} - -int tuneserver_preview_getframe(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_GETFRAME, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_preview_unsupported(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_UNSUPPORTED, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_initialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len) -{ - int result = 0; - mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *) ctrl; - tuningserver_t *tctrl = &lib_handle->tsctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->command_process( - lib_handle, TUNE_CMD_INIT, &client_socket_id, send_buf, send_len); - - return result; -} - -int tuneserver_deinitialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - - result = tctrl->tuning_params.func_tbl->command_process( - NULL, TUNE_CMD_DEINIT, &client_socket_id, send_buf, send_len); - - return result; -} - -int tuneserver_process_get_list_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->command_process( - recv_cmd, TUNE_CMD_GET_LIST, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_process_get_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->command_process - (recv_cmd, TUNE_CMD_GET_PARAMS, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_process_set_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->command_process( - recv_cmd, TUNE_CMD_SET_PARAMS, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_process_misc_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - CDBG("%s %d\n", __func__, __LINE__); - result = tctrl->tuning_params.func_tbl->command_process( - recv_cmd, TUNE_CMD_MISC, NULL, send_buf, send_len); - - return result; -} - -/** tuneserver_close_cam - * @lib_handle: the camera handle object - * - * closes the camera - * - * Return: >=0 on success, -1 on failure. - **/ -int tuneserver_close_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - result = mm_camera_lib_close(lib_handle); - if (result < 0) { - printf("%s: Camera close failed\n", __func__); - } else { - printf("Camera is closed \n"); - } - return result; -} -#if 0 -/** tuneserver_start_cam - * @lib_handle: the camera handle object - * - * starts the camera - * - * Return: >=0 on success, -1 on failure. - **/ -static int tuneserver_start_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - result = mm_camera_lib_start_stream(lib_handle); - if (result < 0) { - printf("%s: Camera start failed\n", __func__); - goto error1; - } - return result; -error1: - mm_camera_lib_close(lib_handle); - return result; -} -#endif - -/** tuneserver_stop_cam - * @lib_handle: the camera handle object - * - * stops the camera - * - * Return: >=0 on success, -1 on failure. - **/ -int tuneserver_stop_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - result = mm_camera_lib_stop_stream(lib_handle); - if (result < 0) { - printf("%s: Camera stop failed\n", __func__); - } -// result = mm_camera_lib_close(lib_handle); - return result; -} - -/** tuneserver_open_cam - * @lib_handle: the camera handle object - * - * opens the camera - * - * Return: >=0 on success, -1 on failure. - **/ -#if 1 -int tuneserver_open_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - CDBG("%s %d\n", __func__, __LINE__); - result = mm_camera_load_tuninglibrary(&lib_handle->tsctrl.tuning_params); - if (result < 0) { - CDBG_ERROR("%s: tuning library open failed\n", __func__); - } - return result; -} -#endif diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_dual_test.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_dual_test.c deleted file mode 100644 index 6a3515c5..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_dual_test.c +++ /dev/null @@ -1,1936 +0,0 @@ -/* -Copyright (c) 2012, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include <pthread.h> -#include "mm_camera_dbg.h" -#include <errno.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <poll.h> -#include "mm_qcamera_unit_test.h" - -#define MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP 4 -#define MM_QCAM_APP_TEST_NUM 128 - -#define MM_QCAMERA_APP_WAIT_TIME 1000000000 - -extern int system_dimension_set(int cam_id); -extern int stopPreview(int cam_id); -extern int takePicture_yuv(int cam_id); -extern int takePicture_rdi(int cam_id); -extern int startRdi(int cam_id); -extern int stopRdi(int cam_id); -extern int startStats(int cam_id); -extern int stopStats(int cam_id); - - -/* -* 1. open back -* 2. open front -* 3. start back -* 4. start front -* 5. stop back -* 6. stop front -* 7. close back -* 8. close front -* 9. take picture -* a. start recording -* b. stop recording -* c. take picture rdi -*/ -static mm_app_tc_t mm_app_tc[MM_QCAM_APP_TEST_NUM]; -static int num_test_cases = 0; -struct test_case_params { - uint16_t launch; - uint16_t preview; - uint16_t recording; - uint16_t snapshot; -}; - -/* Test case 12436857 :*/ - -int mm_app_dtc_0(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 0...\n"); - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL stop camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - - CDBG_ERROR("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - sleep(1); - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case 12436587 :*/ - -int mm_app_dtc_1(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 1...\n"); - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - - CDBG_ERROR("DUAL stop camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case 12436578 :*/ - -int mm_app_dtc_2(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 2...\n"); - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - - CDBG_ERROR("DUAL stop camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case 241395768 : 1357 * 3, This is performed three times -* And for each iteration 9 is performed thrice */ - -int mm_app_dtc_3(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview and snapshot on back Camera and RDI on Front camera 3...\n"); - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() frontcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - usleep(10*1000); - - for (k = 0; k < MM_QCAMERA_APP_INTERATION ; k++) { - CDBG_ERROR("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - - for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - CDBG_ERROR("DUAL take picture for back \n"); - if ( MM_CAMERA_OK != (rc = takePicture_yuv(back_camera))) { - CDBG_ERROR("%s: TakePicture() err=%d\n", __func__, rc); - break; - } - mm_camera_app_wait(); - - } - usleep(10*1000); - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG_ERROR("%s: stopPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - - CDBG_ERROR("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - usleep(20*1000); - } - CDBG_ERROR("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG("%s: stopRdi() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case 2413ab5768 : 1357 * 3, This is performed three times -* And for each iteration ab is performed thrice */ - -int mm_app_dtc_4(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 4...\n"); - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() frontcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - - for (k = 0; k < MM_QCAMERA_APP_INTERATION ; k++){ - CDBG_ERROR("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - usleep(30*1000); - - for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - CDBG_ERROR("DUAL start camera record for back \n"); - if ( MM_CAMERA_OK != (rc = startRecording(back_camera))) { - CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc); - break; - } - - mm_camera_app_wait(); - usleep(15*1000); - CDBG_ERROR("DUAL stop camera record for back \n"); - if ( MM_CAMERA_OK != (rc = stopRecording(back_camera))) { - CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc); - break; - } - } - usleep(10*1000); - - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG_ERROR("%s: stopPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - - CDBG_ERROR("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - usleep(20*1000); - } - CDBG_ERROR("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG("%s: stopRdi() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case 24135768 : 1357 * 3, This is performed three times*/ - -int mm_app_dtc_5(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 5...\n"); - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() frontcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - for (k = 0; k < 4 ; k++) { - CDBG_ERROR("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG_ERROR("%s: stopPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - - CDBG_ERROR("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - sleep(1); - } - CDBG_ERROR("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG("%s: stopRdi() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case 13246857 : 2468 * 3, This is performed three times*/ - -int mm_app_dtc_6(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 6...\n"); - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - for (k = 0; k < 4 ; k++) { - CDBG_ERROR("DUAL open front camera %d \n",k); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL stop camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - - CDBG_ERROR("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - sleep(1); - } - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/*Multi Threaded Test Cases*/ -static void *front_thread(void *data) -{ - int front_camera = 1; - int rc = MM_CAMERA_OK; - int i,j,k,m; - struct test_case_params params - = *((struct test_case_params *)data); - for (i = 0; i < params.launch; i++) { - CDBG_ERROR("DUAL open front camera %d\n",i); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - for (j = 0; j < params.preview; j++) { - CDBG_ERROR("DUAL start camera Rdi for front %d ,%d \n",i,j); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - for (k = 0; k < params.snapshot; k++) { - CDBG_ERROR("DUAL take picture for front %d,%d,%d \n",i,j,k); - if ( MM_CAMERA_OK != (rc = takePicture_rdi(front_camera))) { - CDBG_ERROR("%s: TakePicture() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - usleep(30*1000); - } - CDBG_ERROR("DUAL stop camera Rdi for front %d,%d\n",i,j); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - } - - CDBG_ERROR("DUAL close front camera %d\n",i); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - } -end: - CDBG_ERROR("DUAL front thread close %d",rc); - return NULL; -} - -static void *back_thread(void *data) -{ - int rc = MM_CAMERA_OK; - int back_camera = 0; - int i,j,k,m; - struct test_case_params params - = *((struct test_case_params *)data); - for (i = 0; i < params.launch; i++) { - CDBG_ERROR("DUAL open back camera %d\n",i); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - for (j = 0; j < params.preview; j++) { - CDBG_ERROR("DUAL start camera Preview for back %d, %d\n",i,j); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - for (k = 0; k < params.snapshot; k++) { - CDBG_ERROR("DUAL take picture for back %d, %d, %d\n",i,j,k); - if ( MM_CAMERA_OK != (rc = takePicture_yuv(back_camera))) { - CDBG_ERROR("%s: TakePicture() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - usleep(30*1000); - } - - for (m = 0; m < params.recording; m++) { - CDBG_ERROR("DUAL start record for back %d, %d, %d\n",i,j,m); - if ( MM_CAMERA_OK != (rc = startRecording(back_camera))) { - CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc); - break; - } - - mm_camera_app_wait(); - usleep(10*1000); - CDBG_ERROR("DUAL stop camera record for back \n"); - if ( MM_CAMERA_OK != (rc = stopRecording(back_camera))) { - CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc); - break; - } - usleep(10*1000); - } - CDBG_ERROR("DUAL stop camera Preview for back %d, %d\n",i,j); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - } - - CDBG_ERROR("DUAL close back camera %d\n",i); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - } -end: - CDBG_ERROR("DUAL back thread close %d",rc); - return NULL; -} - -/* Test case m13572468 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_7(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - pthread_t back_thread_id, front_thread_id; - struct test_case_params params; - memset(¶ms, 0, sizeof(struct test_case_params)); - params.launch = 5; - params.preview = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 7...\n"); - - CDBG_ERROR("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, ¶ms); - CDBG_ERROR("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, ¶ms); - sleep(1); - CDBG_ERROR("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - CDBG_ERROR("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case m139572468 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_8(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.snapshot= 5; - fparams.launch = 5; - fparams.preview = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 8...\n"); - - CDBG_ERROR("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - CDBG_ERROR("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - CDBG_ERROR("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - CDBG_ERROR("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) - printf("\nPassed\n"); - else - printf("\nFailed\n"); - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case m1395724c68 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_9(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.snapshot= 5; - fparams.launch = 5; - fparams.preview = 5; - fparams.snapshot = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 9...\n"); - - CDBG_ERROR("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - CDBG_ERROR("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - CDBG_ERROR("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - CDBG_ERROR("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case m13ab572468 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_10(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.recording= 5; - fparams.launch = 5; - fparams.preview = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 10...\n"); - - CDBG_ERROR("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - CDBG_ERROR("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - CDBG_ERROR("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - CDBG_ERROR("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - CDBG_ERROR("DUAL end \n"); -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case m13ab5724c68 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_11(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.recording= 5; - fparams.launch = 5; - fparams.preview = 5; - fparams.snapshot = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 11...\n"); - - CDBG_ERROR("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - CDBG_ERROR("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - CDBG_ERROR("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - CDBG_ERROR("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case m1728 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_12(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 15; - fparams.launch = 15; - printf("\n Verifying Preview on back Camera and RDI on Front camera 12...\n"); - - CDBG_ERROR("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - CDBG_ERROR("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - CDBG_ERROR("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - CDBG_ERROR("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* Test case 2413(ab)5768 - * Test the dual camera usecase. We startPreview on front camera, - * but backend will allocate RDI buffers and start front camera in - * RDI streaming mode. It then diverts RDI frames, converts them into YUV 420 - * through C2D and generate preview data in the buffers allocated here. - * Back camera will use the pixel interface as usual. - */ - -int mm_app_dtc_13(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n 13. Verifying Preview + Recording on back Camera and Preview(through RDI) on Front camera\n"); - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = startPreview(front_camera))) { - CDBG_ERROR("%s: front camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - - for (k = 0; k < MM_QCAMERA_APP_INTERATION ; k++){ - CDBG_ERROR("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - usleep(30*1000); - - for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - CDBG_ERROR("DUAL start camera record for back Iteration %d \n", j); - if ( MM_CAMERA_OK != (rc = startRecording(back_camera))) { - CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc); - break; - } - - mm_camera_app_wait(); - usleep(10*1000*1000); - CDBG_ERROR("DUAL stop camera record for back Iteration %d\n", j); - if ( MM_CAMERA_OK != (rc = stopRecording(back_camera))) { - CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc); - break; - } - } - usleep(10*1000); - - CDBG_ERROR("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - CDBG_ERROR("%s: stopPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - - CDBG_ERROR("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - usleep(20*1000); - } - CDBG_ERROR("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopPreview(front_camera))) { - CDBG_ERROR("%s: stopPreview() frontcamera err=%d\n", __func__, rc); - goto end; - } - usleep(10*1000); - CDBG_ERROR("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/*Below 6 are reference test cases just to test the open path for dual camera*/ -int mm_app_dtc_1243(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_dtc_2134(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL start camera Rdi for back \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} -int mm_app_dtc_2143(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL start camera preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_dtc_2413(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_dtc_1234(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - CDBG_ERROR("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - CDBG_ERROR("DUAL start camera preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - CDBG_ERROR("DUAL start camera rdi for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_dtc_1324(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - CDBG_ERROR("DUAL start back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL start camera preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - //mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL start front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - CDBG_ERROR("DUAL start rdi preview \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - CDBG_ERROR("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/* single camera test cases*/ -int mm_app_dtc_s_0(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - - mm_camera_app_wait(); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() front camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - mm_camera_app_wait(); - - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - CDBG_ERROR("%s: startPreview() backcamera err=%d\n", __func__, rc); - goto end; - } - - if( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - goto end; - } - - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_dtc_s_1(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - - printf("\n Verifying Snapshot on front and back camera...\n"); - for(i = 0; i < cam_apps->num_cameras; i++) { - if( mm_app_open(i) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) { - CDBG_ERROR("%s: startPreview() err=%d\n", __func__, rc); - break; - } - for(j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - if( MM_CAMERA_OK != (rc = takePicture_yuv(my_cam_app.cam_open))) { - CDBG_ERROR("%s: TakePicture() err=%d\n", __func__, rc); - break; - } - /*if(mm_camera_app_timedwait() == ETIMEDOUT) { - CDBG_ERROR("%s: Snapshot/Preview Callback not received in time or qbuf Faile\n", __func__); - break; - }*/ - mm_camera_app_wait(); - result++; - } - if( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - break; - } - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(result != MM_QCAMERA_APP_INTERATION) { - printf("%s: Snapshot Start/Stop Fails for Camera %d in %d iteration", __func__, i,j); - rc = -1; - break; - } - - result = 0; - } -end: - if(rc == 0) { - printf("\t***Passed***\n"); - }else{ - printf("\t***Failed***\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_dtc_s_2(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - - printf("\n Verifying Video on front and back camera...\n"); - for(i = 0; i < cam_apps->num_cameras; i++) { - if( mm_app_open(i) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) { - CDBG_ERROR("%s: startPreview() err=%d\n", __func__, rc); - break; - } - for(j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - if( MM_CAMERA_OK != (rc = startRecording(my_cam_app.cam_open))) { - CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc); - break; - } - - /*if(mm_camera_app_timedwait() == ETIMEDOUT) { - CDBG_ERROR("%s: Video Callback not received in time\n", __func__); - break; - }*/ - mm_camera_app_wait(); - if( MM_CAMERA_OK != (rc = stopRecording(my_cam_app.cam_open))) { - CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc); - break; - } - result++; - } - if( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - break; - } - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(result != MM_QCAMERA_APP_INTERATION) { - printf("%s: Video Start/Stop Fails for Camera %d in %d iteration", __func__, i,j); - rc = -1; - break; - } - - result = 0; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_dtc_s_3(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - - printf("\n Verifying RDI Stream on front and back camera...\n"); - if(cam_apps->num_cameras == 0) { - CDBG_ERROR("%s:Query Failed: Num of cameras = %d\n",__func__, cam_apps->num_cameras); - rc = -1; - goto end; - } - for(i = 0; i < cam_apps->num_cameras; i++) { - if( mm_app_open(i) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - for(j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - if( MM_CAMERA_OK != (rc = startRdi(my_cam_app.cam_open))) { - CDBG_ERROR("%s: StartVideorecording() err=%d\n", __func__, rc); - break; - } - - /*if(mm_camera_app_timedwait() == ETIMEDOUT) { - CDBG_ERROR("%s: Video Callback not received in time\n", __func__); - break; - }*/ - mm_camera_app_wait(); - if( MM_CAMERA_OK != (rc = stopRdi(my_cam_app.cam_open))) { - CDBG_ERROR("%s: Stopvideorecording() err=%d\n", __func__, rc); - break; - } - result++; - } - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(result != MM_QCAMERA_APP_INTERATION) { - printf("%s: Video Start/Stop Fails for Camera %d in %d iteration", __func__, i,j); - rc = -1; - break; - } - - result = 0; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -/*Stats Test Case*/ -int mm_app_dtc_s_5(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() back camera err=%d\n",__func__, rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - CDBG_ERROR("%s:system_dimension_set() err=%d\n",__func__, rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startStats(back_camera))) { - CDBG_ERROR("%s: back camera startPreview() err=%d\n", __func__, rc); - goto end; - } - - mm_camera_app_wait(); - - if( MM_CAMERA_OK != (rc = stopStats(my_cam_app.cam_open))) { - CDBG("%s: startPreview() err=%d\n", __func__, rc); - goto end; - } - - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() err=%d\n",__func__, rc); - rc = -1; - goto end; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_gen_dual_test_cases() -{ - int tc = 0; - memset(mm_app_tc, 0, sizeof(mm_app_tc)); - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_0; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_1; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_2; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_3; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_4; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_5; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_6; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_7; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_8; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_9; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_10; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_11; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_12; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_13; - - return tc; -} - -int mm_app_dual_test_entry(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, tc = 0; - int cam_id = 0; - - tc = mm_app_gen_dual_test_cases(); - CDBG("Running %d test cases\n",tc); - for(i = 0; i < tc; i++) { - mm_app_tc[i].r = mm_app_tc[i].f(cam_app); - if(mm_app_tc[i].r != MM_CAMERA_OK) { - printf("%s: test case %d error = %d, abort unit testing engine!!!!\n", - __func__, i, mm_app_tc[i].r); - rc = mm_app_tc[i].r; - goto end; - } - } -end: - printf("nTOTAL_TSET_CASE = %d, NUM_TEST_RAN = %d, rc=%d\n", tc, i, rc); - return rc; -} - - - - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c deleted file mode 100644 index a276698f..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c +++ /dev/null @@ -1,2056 +0,0 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> -#include <ctype.h> -#include <inttypes.h> - -#include "mm_qcamera_main_menu.h" -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_socket.h" - -/*=========================================================================== - * Macro - *===========================================================================*/ -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) -#define VIDEO_BUFFER_SIZE (PREVIEW_WIDTH * PREVIEW_HEIGHT * 3/2) -#define THUMBNAIL_BUFFER_SIZE (THUMBNAIL_WIDTH * THUMBNAIL_HEIGHT * 3/2) -#define SNAPSHOT_BUFFER_SIZE (PICTURE_WIDTH * PICTURE_HEIGHT * 3/2) -//TODO:check this Macros with current app. - -/*=========================================================================== - * Defines - *===========================================================================*/ -//#define VIDEO_FRAMES_NUM 4 -#define THUMBNAIL_FRAMES_NUM 1 -#define SNAPSHOT_FRAMES_NUM 1 -#define MAX_NUM_FORMAT 32 -#define ZOOM_STEP 2 -#define ZOOM_MIN_VALUE 0 -#define EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR 12 -#define EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR -12 -#define EXPOSURE_COMPENSATION_DEFAULT_NUMERATOR 0 -#define EXPOSURE_COMPENSATION_DENOMINATOR 6 - -//TODO: find correct values of Contrast defines. -#define CAMERA_MIN_CONTRAST 0 -#define CAMERA_DEF_CONTRAST 5 -#define CAMERA_MAX_CONTRAST 10 -#define CAMERA_CONTRAST_STEP 1 - -//TODO: find correct values of Brightness defines. -#define CAMERA_MIN_BRIGHTNESS 0 -#define CAMERA_DEF_BRIGHTNESS 3 -#define CAMERA_MAX_BRIGHTNESS 6 -#define CAMERA_BRIGHTNESS_STEP 1 - -//TODO: find correct values of Saturation defines. -#define CAMERA_MIN_SATURATION 0 -#define CAMERA_DEF_SATURATION 5 -#define CAMERA_MAX_SATURATION 10 -#define CAMERA_SATURATION_STEP 1 - -#define CAMERA_MIN_SHARPNESS 0 -#define CAMERA_MAX_SHARPNESS 10 -#define CAMERA_DEF_SHARPNESS 5 -#define CAMERA_SHARPNESS_STEP 1 - -const CAMERA_MAIN_MENU_TBL_T camera_main_menu_tbl[] = { - {START_PREVIEW, "Start preview"}, - {STOP_PREVIEW, "Stop preview/video"}, - {SET_WHITE_BALANCE, "Set white balance mode"}, - {SET_TINTLESS_ENABLE, "Set Tintless Enable"}, - {SET_TINTLESS_DISABLE, "Set Tintless Disable"}, - {SET_EXP_METERING, "Set exposure metering mode"}, - {GET_CTRL_VALUE, "Get control value menu"}, - {TOGGLE_AFR, "Toggle auto frame rate. Default fixed frame rate"}, - {SET_ISO, "ISO changes."}, - {BRIGHTNESS_GOTO_SUBMENU, "Brightness changes."}, - {CONTRAST_GOTO_SUBMENU, "Contrast changes."}, - {EV_GOTO_SUBMENU, "EV changes."}, - {SATURATION_GOTO_SUBMENU, "Saturation changes."}, - {SET_ZOOM, "Set Digital Zoom."}, - {SET_SHARPNESS, "Set Sharpness."}, - {TAKE_JPEG_SNAPSHOT, "Take a snapshot"}, - {START_RECORDING, "Start RECORDING"}, - {STOP_RECORDING, "Stop RECORDING"}, - {BEST_SHOT, "Set best-shot mode"}, - {LIVE_SHOT, "Take a live snapshot"}, - {FLASH_MODES, "Set Flash modes"}, - {TOGGLE_ZSL, "Toggle ZSL On/Off"}, - {TAKE_RAW_SNAPSHOT, "Take RAW snapshot"}, - {SWITCH_SNAP_RESOLUTION, "Select Jpeg resolution"}, - {TOGGLE_WNR, "Toggle Wavelet Denoise"}, - {EXIT, "Exit"} -}; - -CAMERA_SENSOR_MENU_TLB_T sensor_tbl[] = { - {"Primary Camera", 0}, - {"Secondary Camera", 0}, - {"Camera Sensor 3", 0}, - {"Camera Sensor 4", 0} -}; - -const CAMERA_BRIGHTNESS_TBL_T brightness_change_tbl[] = { - {INC_BRIGHTNESS, "Increase Brightness by one step."}, - {DEC_BRIGHTNESS, "Decrease Brightness by one step."}, -}; - -const CAMERA_CONTRST_TBL_T contrast_change_tbl[] = { - {INC_CONTRAST, "Increase Contrast by one step."}, - {DEC_CONTRAST, "Decrease Contrast by one step."}, -}; - -const CAMERA_EV_TBL_T camera_EV_tbl[] = { - {INCREASE_EV, "Increase EV by one step."}, - {DECREASE_EV, "Decrease EV by one step."}, -}; - -const CAMERA_SATURATION_TBL_T camera_saturation_tbl[] = { - {INC_SATURATION, "Increase Satuation by one step."}, - {DEC_SATURATION, "Decrease Satuation by one step."}, -}; - -const CAMERA_SHARPNESS_TBL_T camera_sharpness_tbl[] = { - {INC_SHARPNESS, "Increase Sharpness."}, - {DEC_SHARPNESS, "Decrease Sharpness."}, -}; - -const WHITE_BALANCE_TBL_T white_balance_tbl[] = { - { WB_AUTO, "White Balance - Auto"}, - { WB_INCANDESCENT, "White Balance - Incandescent"}, - { WB_FLUORESCENT, "White Balance - Fluorescent"}, - { WB_WARM_FLUORESCENT, "White Balance - Warm Fluorescent"}, - { WB_DAYLIGHT, "White Balance - Daylight"}, - { WB_CLOUDY_DAYLIGHT, "White Balance - Cloudy Daylight"}, - { WB_TWILIGHT, "White Balance - Twilight"}, - { WB_SHADE, "White Balance - Shade"}, -}; - -const GET_CTRL_TBL_T get_ctrl_tbl[] = { - { WHITE_BALANCE_STATE, "Get white balance state (auto/off)"}, - { WHITE_BALANCE_TEMPERATURE, "Get white balance temperature"}, - { BRIGHTNESS_CTRL, "Get brightness value"}, - { EV, "Get exposure value"}, - { CONTRAST_CTRL, "Get contrast value"}, - { SATURATION_CTRL, "Get saturation value"}, - { SHARPNESS_CTRL, "Get sharpness value"}, -}; - -const EXP_METERING_TBL_T exp_metering_tbl[] = { - { AUTO_EXP_FRAME_AVG, "Exposure Metering - Frame Average"}, - { AUTO_EXP_CENTER_WEIGHTED, "Exposure Metering - Center Weighted"}, - { AUTO_EXP_SPOT_METERING, "Exposure Metering - Spot Metering"}, - { AUTO_EXP_SMART_METERING, "Exposure Metering - Smart Metering"}, - { AUTO_EXP_USER_METERING, "Exposure Metering - User Metering"}, - { AUTO_EXP_SPOT_METERING_ADV, "Exposure Metering - Spot Metering Adv"}, - { AUTO_EXP_CENTER_WEIGHTED_ADV,"Exposure Metering - Center Weighted Adv"}, -}; - -const ISO_TBL_T iso_tbl[] = { - { ISO_AUTO, "ISO: Auto"}, - { ISO_DEBLUR, "ISO: Deblur"}, - { ISO_100, "ISO: 100"}, - { ISO_200, "ISO: 200"}, - { ISO_400, "ISO: 400"}, - { ISO_800, "ISO: 800"}, - { ISO_1600, "ISO: 1600"}, -}; - -const ZOOM_TBL_T zoom_tbl[] = { - { ZOOM_IN, "Zoom In one step"}, - { ZOOM_OUT, "Zoom Out one step"}, -}; - -const BESTSHOT_MODE_TBT_T bestshot_mode_tbl[] = { - {BESTSHOT_AUTO, "Bestshot Mode: Auto"}, - {BESTSHOT_ACTION, "Bestshot Mode: Action"}, - {BESTSHOT_PORTRAIT, "Bestshot Mode: Portrait"}, - {BESTSHOT_LANDSCAPE, "Bestshot Mode: Landscape"}, - {BESTSHOT_NIGHT, "Bestshot Mode: Night"}, - {BESTSHOT_NIGHT_PORTRAIT, "Bestshot Mode: Night Portrait"}, - {BESTSHOT_THEATRE, "Bestshot Mode: Theatre"}, - {BESTSHOT_BEACH, "Bestshot Mode: Beach"}, - {BESTSHOT_SNOW, "Bestshot Mode: Snow"}, - {BESTSHOT_SUNSET, "Bestshot Mode: Sunset"}, - {BESTSHOT_ANTISHAKE, "Bestshot Mode: Antishake"}, - {BESTSHOT_FIREWORKS, "Bestshot Mode: Fireworks"}, - {BESTSHOT_SPORTS, "Bestshot Mode: Sports"}, - {BESTSHOT_PARTY, "Bestshot Mode: Party"}, - {BESTSHOT_CANDLELIGHT, "Bestshot Mode: Candlelight"}, - {BESTSHOT_ASD, "Bestshot Mode: ASD"}, - {BESTSHOT_BACKLIGHT, "Bestshot Mode: Backlight"}, - {BESTSHOT_FLOWERS, "Bestshot Mode: Flowers"}, - {BESTSHOT_AR, "Bestshot Mode: Augmented Reality"}, - {BESTSHOT_HDR, "Bestshot Mode: HDR"}, -}; - -const FLASH_MODE_TBL_T flashmodes_tbl[] = { - { FLASH_MODE_OFF, "Flash Mode Off"}, - { FLASH_MODE_AUTO, "Flash Mode Auto"}, - { FLASH_MODE_ON, "Flash Mode On"}, - { FLASH_MODE_TORCH, "Flash Mode Torch"}, -}; - -DIMENSION_TBL_T dimension_tbl[] = { -{VGA_WIDTH, VGA_HEIGHT, "VGA", "Size: VGA <640x480>" , 0}, -{MP1_WIDTH, MP1_HEIGHT, "1MP", "Size: 1MP <1280x960>" , 0}, -{MP5_WIDTH, MP5_HEIGHT, "5MP", "Size: 5MP <2592x1944>", 0}, -{MP8_WIDTH, MP8_HEIGHT, "8MP", "Size: 8MP <3264x2448>", 0}, -{MP12_WIDTH, MP12_HEIGHT, "12MP", "Size: 12MP <4000x3000>", 0}, -}; - -/*=========================================================================== - * Forward declarations - *===========================================================================*/ -//static void system_dimension_set(mm_camera_test_obj_t *test_obj); -/*=========================================================================== - * Static global variables - *===========================================================================*/ -USER_INPUT_DISPLAY_T input_display; -int preview_video_resolution_flag = 0; - -//TODO: default values. -#if 1 -int brightness = CAMERA_DEF_BRIGHTNESS; -int contrast = CAMERA_DEF_CONTRAST; -int saturation = CAMERA_DEF_SATURATION; -int sharpness = CAMERA_DEF_SHARPNESS; -#else -int brightness = 0; -int contrast = 0; -int saturation = 0; -int sharpness = 0; -#endif -//TODO: find new method to calculate ev. -//int32_t ev_numerator = EXPOSURE_COMPENSATION_DEFAULT_NUMERATOR; - -//TODO: -//fps_mode_t fps_mode = FPS_MODE_FIXED; -int zoom_level; -int zoom_max_value; -int cam_id; -int is_rec = 0; - - -static int submain(); - -/*=========================================================================== - * FUNCTION - keypress_to_event - - * - * DESCRIPTION: - *==========================================================================*/ -int keypress_to_event(char keypress) -{ - char out_buf = INVALID_KEY_PRESS; - if ((keypress >= 'A' && keypress <= 'Z') || - (keypress >= 'a' && keypress <= 'z')) { - out_buf = tolower(keypress); - out_buf = out_buf - 'a'; - } else if (keypress >= '0' && keypress <= '9') { - out_buf = keypress - '0'; - } - return out_buf; -} - -int next_menu(menu_id_change_t current_menu_id, char keypress, camera_action_t * action_id_ptr, int * action_param) -{ - char output_to_event; - menu_id_change_t next_menu_id = MENU_ID_INVALID; - * action_id_ptr = ACTION_NO_ACTION; - - output_to_event = keypress_to_event(keypress); - CDBG("current_menu_id=%d\n",current_menu_id); - printf("output_to_event=%d\n",output_to_event); - switch(current_menu_id) { - case MENU_ID_MAIN: - switch(output_to_event) { - case START_PREVIEW: - * action_id_ptr = ACTION_START_PREVIEW; - CDBG("START_PREVIEW\n"); - break; - case STOP_PREVIEW: - * action_id_ptr = ACTION_STOP_PREVIEW; - CDBG("STOP_PREVIEW\n"); - break; - - case SET_WHITE_BALANCE: - next_menu_id = MENU_ID_WHITEBALANCECHANGE; - CDBG("next_menu_id = MENU_ID_WHITEBALANCECHANGE = %d\n", next_menu_id); - break; - - case SET_TINTLESS_ENABLE: - * action_id_ptr = ACTION_SET_TINTLESS_ENABLE; - next_menu_id = MENU_ID_MAIN; - CDBG("next_menu_id = MENU_ID_TINTLESSENABLE = %d\n", next_menu_id); - break; - - case SET_TINTLESS_DISABLE: - * action_id_ptr = ACTION_SET_TINTLESS_DISABLE; - next_menu_id = MENU_ID_MAIN; - CDBG("next_menu_id = MENU_ID_TINTLESSDISABLE = %d\n", next_menu_id); - break; - - case SET_EXP_METERING: - next_menu_id = MENU_ID_EXPMETERINGCHANGE; - CDBG("next_menu_id = MENU_ID_EXPMETERINGCHANGE = %d\n", next_menu_id); - break; - - case GET_CTRL_VALUE: - next_menu_id = MENU_ID_GET_CTRL_VALUE; - CDBG("next_menu_id = MENU_ID_GET_CTRL_VALUE = %d\n", next_menu_id); - break; - - case BRIGHTNESS_GOTO_SUBMENU: - next_menu_id = MENU_ID_BRIGHTNESSCHANGE; - CDBG("next_menu_id = MENU_ID_BRIGHTNESSCHANGE = %d\n", next_menu_id); - break; - - case CONTRAST_GOTO_SUBMENU: - next_menu_id = MENU_ID_CONTRASTCHANGE; - break; - - case EV_GOTO_SUBMENU: - next_menu_id = MENU_ID_EVCHANGE; - break; - - case SATURATION_GOTO_SUBMENU: - next_menu_id = MENU_ID_SATURATIONCHANGE; - break; - - case TOGGLE_AFR: - * action_id_ptr = ACTION_TOGGLE_AFR; - CDBG("next_menu_id = MENU_ID_TOGGLEAFR = %d\n", next_menu_id); - break; - - case SET_ISO: - next_menu_id = MENU_ID_ISOCHANGE; - CDBG("next_menu_id = MENU_ID_ISOCHANGE = %d\n", next_menu_id); - break; - - case SET_ZOOM: - next_menu_id = MENU_ID_ZOOMCHANGE; - CDBG("next_menu_id = MENU_ID_ZOOMCHANGE = %d\n", next_menu_id); - break; - - case BEST_SHOT: - next_menu_id = MENU_ID_BESTSHOT; - CDBG("next_menu_id = MENU_ID_BESTSHOT = %d\n", next_menu_id); - break; - - case LIVE_SHOT: - * action_id_ptr = ACTION_TAKE_LIVE_SNAPSHOT; - CDBG("\nTaking Live snapshot\n"); - break; - - case FLASH_MODES: - next_menu_id = MENU_ID_FLASHMODE; - CDBG("next_menu_id = MENU_ID_FLASHMODE = %d\n", next_menu_id); - break; - - case SET_SHARPNESS: - next_menu_id = MENU_ID_SHARPNESSCHANGE; - CDBG("next_menu_id = MENU_ID_SHARPNESSCHANGE = %d\n", next_menu_id); - break; - - case SWITCH_SNAP_RESOLUTION: - next_menu_id = MENU_ID_SWITCH_RES; - CDBG("next_menu_id = MENU_ID_SWITCH_RES = %d\n", next_menu_id); - break; - - case TAKE_JPEG_SNAPSHOT: - * action_id_ptr = ACTION_TAKE_JPEG_SNAPSHOT; - printf("\n Taking JPEG snapshot\n"); - break; - - case START_RECORDING: - * action_id_ptr = ACTION_START_RECORDING; - CDBG("Start recording\n"); - break; - case STOP_RECORDING: - * action_id_ptr = ACTION_STOP_RECORDING; - CDBG("Stop recording\n"); - break; - case TOGGLE_ZSL: - * action_id_ptr = ACTION_TOGGLE_ZSL; - CDBG("Toggle ZSL\n"); - break; - case TAKE_RAW_SNAPSHOT: - * action_id_ptr = ACTION_TAKE_RAW_SNAPSHOT; - next_menu_id = MENU_ID_MAIN; - CDBG("Capture RAW\n"); - break; - case TOGGLE_WNR: - * action_id_ptr = ACTION_TOGGLE_WNR; - next_menu_id = MENU_ID_MAIN; - CDBG("Toggle WNR"); - break; - case EXIT: - * action_id_ptr = ACTION_EXIT; - CDBG("Exit \n"); - break; - default: - next_menu_id = MENU_ID_MAIN; - CDBG("next_menu_id = MENU_ID_MAIN = %d\n", next_menu_id); - break; - } - break; - - case MENU_ID_SWITCH_RES: - printf("MENU_ID_SWITCH_RES\n"); - *action_id_ptr = ACTION_SWITCH_RESOLUTION; - *action_param = output_to_event; - int available_sizes = sizeof(dimension_tbl)/sizeof(dimension_tbl[0]); - if ( ( *action_param >= 0 ) && - ( *action_param < available_sizes ) && - ( dimension_tbl[*action_param].supported )) { - next_menu_id = MENU_ID_MAIN; - } - else { - next_menu_id = current_menu_id; - } - break; - - case MENU_ID_SENSORS: - next_menu_id = MENU_ID_MAIN; - *action_id_ptr = ACTION_SWITCH_CAMERA; - *action_param = output_to_event; - break; - - case MENU_ID_WHITEBALANCECHANGE: - printf("MENU_ID_WHITEBALANCECHANGE\n"); - if (output_to_event >= WB_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_WHITE_BALANCE; - * action_param = output_to_event; - } - break; - - case MENU_ID_EXPMETERINGCHANGE: - printf("MENU_ID_EXPMETERINGCHANGE\n"); - if (output_to_event >= AUTO_EXP_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_EXP_METERING; - * action_param = output_to_event; - } - break; - - case MENU_ID_GET_CTRL_VALUE: - printf("MENU_ID_GET_CTRL_VALUE\n"); - * action_id_ptr = ACTION_GET_CTRL_VALUE; - if (output_to_event > 0 && - output_to_event <= sizeof(get_ctrl_tbl)/sizeof(get_ctrl_tbl[0])) { - next_menu_id = MENU_ID_MAIN; - * action_param = output_to_event; - } - else { - next_menu_id = current_menu_id; - } - break; - - case MENU_ID_BRIGHTNESSCHANGE: - switch (output_to_event) { - case INC_BRIGHTNESS: - * action_id_ptr = ACTION_BRIGHTNESS_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DEC_BRIGHTNESS: - * action_id_ptr = ACTION_BRIGHTNESS_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_BRIGHTNESSCHANGE; - break; - } - break; - - case MENU_ID_CONTRASTCHANGE: - switch (output_to_event) { - case INC_CONTRAST: - * action_id_ptr = ACTION_CONTRAST_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DEC_CONTRAST: - * action_id_ptr = ACTION_CONTRAST_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_CONTRASTCHANGE; - break; - } - break; - - case MENU_ID_EVCHANGE: - switch (output_to_event) { - case INCREASE_EV: - * action_id_ptr = ACTION_EV_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DECREASE_EV: - * action_id_ptr = ACTION_EV_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_EVCHANGE; - break; - } - break; - - case MENU_ID_SATURATIONCHANGE: - switch (output_to_event) { - case INC_SATURATION: - * action_id_ptr = ACTION_SATURATION_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DEC_SATURATION: - * action_id_ptr = ACTION_SATURATION_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_EVCHANGE; - break; - } - break; - - case MENU_ID_ISOCHANGE: - printf("MENU_ID_ISOCHANGE\n"); - if (output_to_event >= ISO_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_ISO; - * action_param = output_to_event; - } - break; - - case MENU_ID_ZOOMCHANGE: - * action_id_ptr = ACTION_SET_ZOOM; - if (output_to_event > 0 && - output_to_event <= sizeof(zoom_tbl)/sizeof(zoom_tbl[0])) { - next_menu_id = MENU_ID_MAIN; - * action_param = output_to_event; - } else { - next_menu_id = current_menu_id; - } - break; - - case MENU_ID_SHARPNESSCHANGE: - switch (output_to_event) { - case INC_SHARPNESS: - * action_id_ptr = ACTION_SHARPNESS_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - case DEC_SHARPNESS: - * action_id_ptr = ACTION_SHARPNESS_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - default: - next_menu_id = MENU_ID_SHARPNESSCHANGE; - break; - } - break; - - case MENU_ID_BESTSHOT: - if (output_to_event >= BESTSHOT_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_BESTSHOT_MODE; - * action_param = output_to_event; - } - break; - - case MENU_ID_FLASHMODE: - if (output_to_event >= FLASH_MODE_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_FLASH_MODE; - * action_param = output_to_event; - } - break; - - default: - CDBG("menu id is wrong: %d\n", current_menu_id); - break; - } - - return next_menu_id; -} - -/*=========================================================================== - * FUNCTION - print_menu_preview_video - - * - * DESCRIPTION: - * ===========================================================================*/ -static void print_menu_preview_video(void) { - unsigned int i; - if (!is_rec) { - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in preview/video mode now \n"); - printf("===========================================\n\n"); - } else { - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in RECORDING mode now \n"); - printf(" Press 'Q' To Stop Recording \n"); - printf(" Press 'S' To Take Live Snapshot \n"); - printf("===========================================\n\n"); - } - char menuNum = 'A'; - for (i = 0; i < sizeof(camera_main_menu_tbl)/sizeof(camera_main_menu_tbl[0]); i++) { - if (i == BASE_OFFSET) { - menuNum = '1'; - } - - printf("%c. %s\n", menuNum, camera_main_menu_tbl[i].menu_name); - menuNum++; - } - - printf("\nPlease enter your choice: "); - - return; -} - -static void camera_preview_video_wb_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in white balance change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(white_balance_tbl) / - sizeof(white_balance_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, white_balance_tbl[i].wb_name); - submenuNum++; - } - printf("\nPlease enter your choice for White Balance modes: "); - return; -} - -static void camera_preview_video_get_ctrl_value_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in get control value mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(get_ctrl_tbl) / - sizeof(get_ctrl_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, get_ctrl_tbl[i].get_ctrl_name); - submenuNum++; - } - printf("\nPlease enter your choice for control value you want to get: "); - return; -} - -static void camera_preview_video_exp_metering_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in exposure metering change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(exp_metering_tbl) / - sizeof(exp_metering_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, exp_metering_tbl[i].exp_metering_name); - submenuNum++; - } - printf("\nPlease enter your choice for exposure metering modes: "); - return; -} - -static void camera_contrast_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in change contrast resolution mode \n"); - printf("==========================================================\n\n"); - - char contrastmenuNum = 'A'; - for (i = 0; i < sizeof(contrast_change_tbl) / - sizeof(contrast_change_tbl[0]); i++) { - printf("%c. %s\n", contrastmenuNum, - contrast_change_tbl[i].contrast_name); - contrastmenuNum++; - } - - printf("\nPlease enter your choice for contrast Change: "); - return; -} - -static void camera_EV_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in EV change mode now \n"); - printf("===========================================\n\n"); - - char submenuNum = 'A'; - for (i = 0; i < sizeof(camera_EV_tbl)/sizeof(camera_EV_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, camera_EV_tbl[i].EV_name); - submenuNum++; - } - - printf("\nPlease enter your choice for EV changes: "); - return; -} - -static void camera_resolution_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in snapshot resolution mode \n"); - printf("==========================================================\n\n"); - - for (i = 0; i < sizeof(dimension_tbl) / - sizeof(dimension_tbl[0]); i++) { - if ( dimension_tbl[i].supported ) { - printf("%d. %s\n", i, - dimension_tbl[i].str_name); - } - } - - printf("\nPlease enter your choice for Resolution: "); - return; -} - -static void camera_preview_video_zoom_change_tbl(void) { - unsigned int i; - zoom_max_value = MAX_ZOOMS_CNT; - printf("\nCurrent Zoom Value = %d ,Max Zoom Value = %d\n",zoom_level,zoom_max_value); - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(zoom_tbl) / - sizeof(zoom_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, zoom_tbl[i].zoom_direction_name); - submenuNum++; - } - printf("\nPlease enter your choice for zoom change direction: "); - return; -} - -static void camera_brightness_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in change brightness mode \n"); - printf("==========================================================\n\n"); - - char brightnessmenuNum = 'A'; - for (i = 0; i < sizeof(brightness_change_tbl) / - sizeof(brightness_change_tbl[0]); i++) { - printf("%c. %s\n", brightnessmenuNum, - brightness_change_tbl[i].brightness_name); - brightnessmenuNum++; - } - - printf("\nPlease enter your choice for Brightness Change: "); - return; -} - -static void camera_saturation_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in change saturation mode \n"); - printf("==========================================================\n\n"); - - char saturationmenuNum = 'A'; - for (i = 0; i < sizeof(camera_saturation_tbl) / - sizeof(camera_saturation_tbl[0]); i++) { - printf("%c. %s\n", saturationmenuNum, - camera_saturation_tbl[i].saturation_name); - saturationmenuNum++; - } - - printf("\nPlease enter your choice for Saturation Change: "); - return; -} - -static void camera_preview_video_iso_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in ISO change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(iso_tbl) / - sizeof(iso_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, iso_tbl[i].iso_modes_name); - submenuNum++; - } - printf("\nPlease enter your choice for iso modes: "); - return; -} - -static void camera_preview_video_sharpness_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in sharpness change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(camera_sharpness_tbl) / - sizeof(camera_sharpness_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, camera_sharpness_tbl[i].sharpness_name); - submenuNum++; - } - printf("\nPlease enter your choice for sharpness modes: "); - return; -} - -static void camera_set_bestshot_tbl(void) -{ - unsigned int i; - - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in set besthot mode now \n"); - printf("===========================================\n\n"); - - - char bsmenuNum = 'A'; - for (i = 0; i < sizeof(bestshot_mode_tbl)/sizeof(bestshot_mode_tbl[0]); i++) { - printf("%c. %s\n", bsmenuNum, - bestshot_mode_tbl[i].name); - bsmenuNum++; - } - - printf("\nPlease enter your choice of Bestshot Mode: "); - return; -} - -static void camera_set_flashmode_tbl(void) -{ - unsigned int i; - - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in set flash mode now \n"); - printf("===========================================\n\n"); - - - char bsmenuNum = 'A'; - for (i = 0; i < sizeof(flashmodes_tbl)/sizeof(flashmodes_tbl[0]); i++) { - printf("%c. %s\n", bsmenuNum, - flashmodes_tbl[i].name); - bsmenuNum++; - } - - printf("\nPlease enter your choice of Bestshot Mode: "); - return; -} - -static void camera_sensors_tbl(void) -{ - unsigned int i; - size_t available_sensors = sizeof(sensor_tbl)/sizeof(sensor_tbl[0]); - - printf("\n"); - printf("===========================================\n"); - printf(" Camera Sensor to be used: \n"); - printf("===========================================\n\n"); - - - char bsmenuNum = 'A'; - for (i = 0; ( i < available_sensors ) && ( sensor_tbl[i].present ) ; i++) { - printf("%c. %s\n", bsmenuNum, - sensor_tbl[i].menu_name); - bsmenuNum++; - } - - printf("\nPlease enter your choice for sensor: "); - return; -} - -/*=========================================================================== - * FUNCTION - increase_contrast - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_contrast (mm_camera_lib_handle *lib_handle) { - contrast += CAMERA_CONTRAST_STEP; - if (contrast > CAMERA_MAX_CONTRAST) { - contrast = CAMERA_MAX_CONTRAST; - printf("Reached max CONTRAST. \n"); - } - printf("Increase Contrast to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_CONTRAST, - &contrast, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_contrast - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_contrast (mm_camera_lib_handle *lib_handle) { - contrast -= CAMERA_CONTRAST_STEP; - if (contrast < CAMERA_MIN_CONTRAST) { - contrast = CAMERA_MIN_CONTRAST; - printf("Reached min CONTRAST. \n"); - } - printf("Decrease Contrast to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_CONTRAST, - &contrast, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_brightness - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_brightness (mm_camera_lib_handle *lib_handle) { - brightness -= CAMERA_BRIGHTNESS_STEP; - if (brightness < CAMERA_MIN_BRIGHTNESS) { - brightness = CAMERA_MIN_BRIGHTNESS; - printf("Reached min BRIGHTNESS. \n"); - } - printf("Decrease Brightness to %d\n", brightness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_BRIGHTNESS, - &brightness, - NULL); -} - -/*=========================================================================== - * FUNCTION - increase_brightness - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_brightness (mm_camera_lib_handle *lib_handle) { - brightness += CAMERA_BRIGHTNESS_STEP; - if (brightness > CAMERA_MAX_BRIGHTNESS) { - brightness = CAMERA_MAX_BRIGHTNESS; - printf("Reached max BRIGHTNESS. \n"); - } - printf("Increase Brightness to %d\n", brightness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_BRIGHTNESS, - &brightness, - NULL); -} - -/*=========================================================================== - * FUNCTION - increase_EV - - * - * DESCRIPTION: - * ===========================================================================*/ - -int increase_EV (void) { -#if 0 - int rc = 0; - int32_t value = 0; - rc = cam_config_is_parm_supported(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION); - if(!rc) { - printf("MM_CAMERA_PARM_EXPOSURE_COMPENSATION mode is not supported for this sensor"); - return -1; - } - ev_numerator += 1; - if(ev_numerator >= EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR && - ev_numerator <= EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR){ - int16_t numerator16 = (int16_t)(ev_numerator & 0x0000ffff); - uint16_t denominator16 = EXPOSURE_COMPENSATION_DENOMINATOR; - value = numerator16 << 16 | denominator16; - } else { - printf("Reached max EV.\n"); - } - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION, value); -#endif - return 0; -} - -/*=========================================================================== - * FUNCTION - decrease_EV - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_EV (void) { -#if 0 - int rc = 0; - int32_t value = 0; - rc = cam_config_is_parm_supported(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION); - if(!rc) { - printf("MM_CAMERA_PARM_EXPOSURE_COMPENSATION mode is not supported for this sensor"); - return -1; - } - ev_numerator -= 1; - if(ev_numerator >= EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR && - ev_numerator <= EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR){ - int16_t numerator16 = (int16_t)(ev_numerator & 0x0000ffff); - uint16_t denominator16 = EXPOSURE_COMPENSATION_DENOMINATOR; - value = numerator16 << 16 | denominator16; - } else { - printf("Reached min EV.\n"); - } - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION, value); -#endif - return 0; -} - -/*=========================================================================== - * FUNCTION - increase_saturation - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_saturation (mm_camera_lib_handle *lib_handle) { -#if 0 - saturation += CAMERA_SATURATION_STEP; - if (saturation > CAMERA_MAX_SATURATION) { - saturation = CAMERA_MAX_SATURATION; - printf("Reached max saturation. \n"); - } - printf("Increase Saturation to %d\n", saturation); - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_SATURATION, saturation); -#endif - saturation += CAMERA_SATURATION_STEP; - if (saturation > CAMERA_MAX_SATURATION) { - saturation = CAMERA_MAX_SATURATION; - printf("Reached max saturation. \n"); - } - printf("Increase saturation to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SATURATION, - &saturation, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_saturation - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_saturation (mm_camera_lib_handle *lib_handle) { -#if 0 - saturation -= CAMERA_SATURATION_STEP; - if (saturation < CAMERA_MIN_SATURATION) { - saturation = CAMERA_MIN_SATURATION; - printf("Reached min saturation. \n"); - } - printf("Dcrease Saturation to %d\n", saturation); - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_SATURATION, saturation); -#endif - saturation -= CAMERA_SATURATION_STEP; - if (saturation < CAMERA_MIN_SATURATION) { - saturation = CAMERA_MIN_SATURATION; - printf("Reached min saturation. \n"); - } - printf("decrease saturation to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SATURATION, - &saturation, - NULL); -} - - -int take_jpeg_snapshot(mm_camera_test_obj_t *test_obj, int is_burst_mode) -{ - CDBG_HIGH("\nEnter take_jpeg_snapshot!!\n"); - int rc = MM_CAMERA_OK; - if(MM_CAMERA_OK != (rc = mm_app_take_picture(test_obj, is_burst_mode))) { - CDBG_ERROR("%s: mm_app_take_picture() err=%d\n", __func__, rc); - } - return rc; -} - -/*=========================================================================== - * FUNCTION - main - - * - * DESCRIPTION: - *==========================================================================*/ -int main() -{ - char tc_buf[3]; - int mode = 0; - int rc = 0; - - printf("Please Select Execution Mode:\n"); - printf("0: Menu Based 1: Regression\n"); - fgets(tc_buf, 3, stdin); - mode = tc_buf[0] - '0'; - if(mode == 0) { - printf("\nStarting Menu based!!\n"); - } else if(mode == 1) { - printf("Starting Regression testing!!\n"); - if(!mm_app_start_regression_test(1)) { - printf("\nRegressiion test passed!!\n"); - return 0; - } else { - printf("\nRegression test failed!!\n"); - exit(-1); - } - } else { - printf("\nPlease Enter 0 or 1\n"); - printf("\nExisting the App!!\n"); - exit(-1); - } - - - rc = submain(); - - printf("Exiting application\n"); - - return rc; -} - -/*=========================================================================== - * FUNCTION - set_whitebalance - - * - * DESCRIPTION: - * ===========================================================================*/ -int set_whitebalance (mm_camera_lib_handle *lib_handle, int wb_action_param) { - cam_wb_mode_type type = 0; - switch (wb_action_param) { - case WB_AUTO: - printf("\n WB_AUTO\n"); - type = CAM_WB_MODE_AUTO; - break; - case WB_INCANDESCENT: - printf("\n WB_INCANDESCENT\n"); - type = CAM_WB_MODE_INCANDESCENT; - break; - case WB_FLUORESCENT: - printf("\n WB_FLUORESCENT\n"); - type = CAM_WB_MODE_FLUORESCENT; - break; - case WB_WARM_FLUORESCENT: - printf("\n WB_WARM_FLUORESCENT\n"); - type = CAM_WB_MODE_WARM_FLUORESCENT; - break; - case WB_DAYLIGHT: - printf("\n WB_DAYLIGHT\n"); - type = CAM_WB_MODE_DAYLIGHT; - break; - case WB_CLOUDY_DAYLIGHT: - printf("\n WB_CLOUDY_DAYLIGHT\n"); - type = CAM_WB_MODE_CLOUDY_DAYLIGHT; - break; - case WB_TWILIGHT: - printf("\n WB_TWILIGHT\n"); - type = CAM_WB_MODE_TWILIGHT; - break; - case WB_SHADE: - printf("\n WB_SHADE\n"); - type = CAM_WB_MODE_SHADE; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_WB, - &type, - NULL); -} - - -/*=========================================================================== - * FUNCTION - set_exp_metering - - * - * DESCRIPTION: - * ===========================================================================*/ -int set_exp_metering (mm_camera_lib_handle *lib_handle, int exp_metering_action_param) { - cam_auto_exposure_mode_type type = 0; - switch (exp_metering_action_param) { - case AUTO_EXP_FRAME_AVG: - printf("\nAUTO_EXP_FRAME_AVG\n"); - type = CAM_AEC_MODE_FRAME_AVERAGE; - break; - case AUTO_EXP_CENTER_WEIGHTED: - printf("\n AUTO_EXP_CENTER_WEIGHTED\n"); - type = CAM_AEC_MODE_CENTER_WEIGHTED; - break; - case AUTO_EXP_SPOT_METERING: - printf("\n AUTO_EXP_SPOT_METERING\n"); - type = CAM_AEC_MODE_SPOT_METERING; - break; - case AUTO_EXP_SMART_METERING: - printf("\n AUTO_EXP_SMART_METERING\n"); - type = CAM_AEC_MODE_SMART_METERING; - break; - case AUTO_EXP_USER_METERING: - printf("\n AUTO_EXP_USER_METERING\n"); - type = CAM_AEC_MODE_USER_METERING; - break; - case AUTO_EXP_SPOT_METERING_ADV: - printf("\n AUTO_EXP_SPOT_METERING_ADV\n"); - type = CAM_AEC_MODE_SPOT_METERING_ADV; - break; - case AUTO_EXP_CENTER_WEIGHTED_ADV: - printf("\n AUTO_EXP_CENTER_WEIGHTED_ADV\n"); - type = CAM_AEC_MODE_CENTER_WEIGHTED_ADV; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_EXPOSURE_METERING, - &type, - NULL); -} - -int get_ctrl_value (int ctrl_value_mode_param){ -#if 0 - int rc = 0; - struct v4l2_control ctrl; - - if (ctrl_value_mode_param == WHITE_BALANCE_STATE) { - printf("You chose WHITE_BALANCE_STATE\n"); - ctrl.id = V4L2_CID_AUTO_WHITE_BALANCE; - } - else if (ctrl_value_mode_param == WHITE_BALANCE_TEMPERATURE) { - printf("You chose WHITE_BALANCE_TEMPERATURE\n"); - ctrl.id = V4L2_CID_WHITE_BALANCE_TEMPERATURE; - } - else if (ctrl_value_mode_param == BRIGHTNESS_CTRL) { - printf("You chose brightness value\n"); - ctrl.id = V4L2_CID_BRIGHTNESS; - } - else if (ctrl_value_mode_param == EV) { - printf("You chose exposure value\n"); - ctrl.id = V4L2_CID_EXPOSURE; - } - else if (ctrl_value_mode_param == CONTRAST_CTRL) { - printf("You chose contrast value\n"); - ctrl.id = V4L2_CID_CONTRAST; - } - else if (ctrl_value_mode_param == SATURATION_CTRL) { - printf("You chose saturation value\n"); - ctrl.id = V4L2_CID_SATURATION; - } else if (ctrl_value_mode_param == SHARPNESS_CTRL) { - printf("You chose sharpness value\n"); - ctrl.id = V4L2_CID_SHARPNESS; - } - - // rc = ioctl(camfd, VIDIOC_G_CTRL, &ctrl); - return rc; -#endif - return ctrl_value_mode_param; -} - -/*=========================================================================== - * FUNCTION - toggle_afr - - * - * DESCRIPTION: - * ===========================================================================*/ -int toggle_afr () { -#if 0 - if (fps_mode == FPS_MODE_AUTO) { - printf("\nSetting FPS_MODE_FIXED\n"); - fps_mode = FPS_MODE_FIXED; - } else { - printf("\nSetting FPS_MODE_AUTO\n"); - fps_mode = FPS_MODE_AUTO; - } - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_FPS_MODE, fps_mode); -#endif - return 0; -} - -int set_zoom (mm_camera_lib_handle *lib_handle, int zoom_action_param) { - - if (zoom_action_param == ZOOM_IN) { - zoom_level += ZOOM_STEP; - if (zoom_level > zoom_max_value) - zoom_level = zoom_max_value; - } else if (zoom_action_param == ZOOM_OUT) { - zoom_level -= ZOOM_STEP; - if (zoom_level < ZOOM_MIN_VALUE) - zoom_level = ZOOM_MIN_VALUE; - } else { - CDBG("%s: Invalid zoom_action_param value\n", __func__); - return -EINVAL; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_ZOOM, - &zoom_level, - NULL); -} - -/*=========================================================================== - * FUNCTION - set_iso - - * - * DESCRIPTION: - * ===========================================================================*/ -int set_iso (mm_camera_lib_handle *lib_handle, int iso_action_param) { - cam_iso_mode_type type = 0; - switch (iso_action_param) { - case ISO_AUTO: - printf("\n ISO_AUTO\n"); - type = CAM_ISO_MODE_AUTO; - break; - case ISO_DEBLUR: - printf("\n ISO_DEBLUR\n"); - type = CAM_ISO_MODE_DEBLUR; - break; - case ISO_100: - printf("\n ISO_100\n"); - type = CAM_ISO_MODE_100; - break; - case ISO_200: - printf("\n ISO_200\n"); - type = CAM_ISO_MODE_200; - break; - case ISO_400: - printf("\n ISO_400\n"); - type = CAM_ISO_MODE_400; - break; - case ISO_800: - printf("\n ISO_800\n"); - type = CAM_ISO_MODE_800; - break; - case ISO_1600: - printf("\n ISO_1600\n"); - type = CAM_ISO_MODE_1600; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_ISO, - &type, - NULL); -} - -/*=========================================================================== - * FUNCTION - increase_sharpness - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_sharpness (mm_camera_lib_handle *lib_handle) { - sharpness += CAMERA_SHARPNESS_STEP; - if (sharpness > CAMERA_MAX_SHARPNESS) { - sharpness = CAMERA_MAX_SHARPNESS; - printf("Reached max SHARPNESS. \n"); - } - printf("Increase Sharpness to %d\n", sharpness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SHARPNESS, - &sharpness, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_sharpness - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_sharpness (mm_camera_lib_handle *lib_handle) { - sharpness -= CAMERA_SHARPNESS_STEP; - if (sharpness < CAMERA_MIN_SHARPNESS) { - sharpness = CAMERA_MIN_SHARPNESS; - printf("Reached min SHARPNESS. \n"); - } - printf("Decrease Sharpness to %d\n", sharpness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SHARPNESS, - &sharpness, - NULL); -} - -int set_flash_mode (mm_camera_lib_handle *lib_handle, int action_param) { - cam_flash_mode_t type = 0; - switch (action_param) { - case FLASH_MODE_OFF: - printf("\n FLASH_MODE_OFF\n"); - type = CAM_FLASH_MODE_OFF; - break; - case FLASH_MODE_AUTO: - printf("\n FLASH_MODE_AUTO\n"); - type = CAM_FLASH_MODE_AUTO; - break; - case FLASH_MODE_ON: - printf("\n FLASH_MODE_ON\n"); - type = CAM_FLASH_MODE_ON; - break; - case FLASH_MODE_TORCH: - printf("\n FLASH_MODE_TORCH\n"); - type = CAM_ISO_MODE_100; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_FLASH, - &type, - NULL); -} - -int set_bestshot_mode(mm_camera_lib_handle *lib_handle, int action_param) { - cam_scene_mode_type type = 0; - switch (action_param) { - case BESTSHOT_AUTO: - printf("\n BEST SHOT AUTO\n"); - type = CAM_SCENE_MODE_OFF; - break; - case BESTSHOT_ACTION: - printf("\n BEST SHOT ACTION\n"); - type = CAM_SCENE_MODE_ACTION; - break; - case BESTSHOT_PORTRAIT: - printf("\n BEST SHOT PORTRAIT\n"); - type = CAM_SCENE_MODE_PORTRAIT; - break; - case BESTSHOT_LANDSCAPE: - printf("\n BEST SHOT LANDSCAPE\n"); - type = CAM_SCENE_MODE_LANDSCAPE; - break; - case BESTSHOT_NIGHT: - printf("\n BEST SHOT NIGHT\n"); - type = CAM_SCENE_MODE_NIGHT; - break; - case BESTSHOT_NIGHT_PORTRAIT: - printf("\n BEST SHOT NIGHT PORTRAIT\n"); - type = CAM_SCENE_MODE_NIGHT_PORTRAIT; - break; - case BESTSHOT_THEATRE: - printf("\n BEST SHOT THREATRE\n"); - type = CAM_SCENE_MODE_THEATRE; - break; - case BESTSHOT_BEACH: - printf("\n BEST SHOT BEACH\n"); - type = CAM_SCENE_MODE_BEACH; - break; - case BESTSHOT_SNOW: - printf("\n BEST SHOT SNOW\n"); - type = CAM_SCENE_MODE_SNOW; - break; - case BESTSHOT_SUNSET: - printf("\n BEST SHOT SUNSET\n"); - type = CAM_SCENE_MODE_SUNSET; - break; - case BESTSHOT_ANTISHAKE: - printf("\n BEST SHOT ANTISHAKE\n"); - type = CAM_SCENE_MODE_ANTISHAKE; - break; - case BESTSHOT_FIREWORKS: - printf("\n BEST SHOT FIREWORKS\n"); - type = CAM_SCENE_MODE_FIREWORKS; - break; - case BESTSHOT_SPORTS: - printf("\n BEST SHOT SPORTS\n"); - type = CAM_SCENE_MODE_SPORTS; - break; - case BESTSHOT_PARTY: - printf("\n BEST SHOT PARTY\n"); - type = CAM_SCENE_MODE_PARTY; - break; - case BESTSHOT_CANDLELIGHT: - printf("\n BEST SHOT CANDLELIGHT\n"); - type = CAM_SCENE_MODE_CANDLELIGHT; - break; - case BESTSHOT_ASD: - printf("\n BEST SHOT ASD\n"); - type = CAM_SCENE_MODE_AUTO; - break; - case BESTSHOT_BACKLIGHT: - printf("\n BEST SHOT BACKLIGHT\n"); - type = CAM_SCENE_MODE_BACKLIGHT; - break; - case BESTSHOT_FLOWERS: - printf("\n BEST SHOT FLOWERS\n"); - type = CAM_SCENE_MODE_FLOWERS; - break; - case BESTSHOT_AR: - printf("\n BEST SHOT AR\n"); - type = CAM_SCENE_MODE_AR; - break; - case BESTSHOT_HDR: - printf("\n BEST SHOT HDR\n"); - type = CAM_SCENE_MODE_OFF; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_BESTSHOT, - &type, - NULL); -} -/*=========================================================================== - * FUNCTION - print_current_menu - - * - * DESCRIPTION: - * ===========================================================================*/ -int print_current_menu (menu_id_change_t current_menu_id) { - if (current_menu_id == MENU_ID_MAIN) { - print_menu_preview_video (); - } else if (current_menu_id == MENU_ID_WHITEBALANCECHANGE) { - camera_preview_video_wb_change_tbl(); - } else if (current_menu_id == MENU_ID_EXPMETERINGCHANGE) { - camera_preview_video_exp_metering_change_tbl(); - } else if (current_menu_id == MENU_ID_GET_CTRL_VALUE) { - camera_preview_video_get_ctrl_value_tbl(); - } else if (current_menu_id == MENU_ID_ISOCHANGE) { - camera_preview_video_iso_change_tbl(); - } else if (current_menu_id == MENU_ID_BRIGHTNESSCHANGE) { - camera_brightness_change_tbl (); - } else if (current_menu_id == MENU_ID_CONTRASTCHANGE) { - camera_contrast_change_tbl (); - } else if (current_menu_id == MENU_ID_EVCHANGE) { - camera_EV_change_tbl (); - } else if (current_menu_id == MENU_ID_SATURATIONCHANGE) { - camera_saturation_change_tbl (); - } else if (current_menu_id == MENU_ID_ZOOMCHANGE) { - camera_preview_video_zoom_change_tbl(); - } else if (current_menu_id == MENU_ID_SHARPNESSCHANGE) { - camera_preview_video_sharpness_change_tbl(); - } else if (current_menu_id == MENU_ID_BESTSHOT) { - camera_set_bestshot_tbl(); - } else if (current_menu_id == MENU_ID_FLASHMODE) { - camera_set_flashmode_tbl(); - } else if (current_menu_id == MENU_ID_SENSORS ) { - camera_sensors_tbl(); - } else if (current_menu_id == MENU_ID_SWITCH_RES ) { - camera_resolution_change_tbl(); - } - - return 0; -} - -int filter_resolutions(mm_camera_lib_handle *lib_handle, - DIMENSION_TBL_T *tbl, - size_t tbl_size) -{ - size_t i, j; - cam_capability_t camera_cap; - int rc = 0; - - if ( ( NULL == lib_handle ) || ( NULL == tbl ) ) { - return -1; - } - - rc = mm_camera_lib_get_caps(lib_handle, &camera_cap); - if ( MM_CAMERA_OK != rc ) { - CDBG_ERROR("%s:mm_camera_lib_get_caps() err=%d\n", __func__, rc); - return -1; - } - - for( i = 0 ; i < tbl_size ; i++ ) { - for( j = 0; j < camera_cap.picture_sizes_tbl_cnt; j++ ) { - if ( ( tbl[i].width == camera_cap.picture_sizes_tbl[j].width ) && - ( tbl[i].height == camera_cap.picture_sizes_tbl[j].height ) ) { - tbl[i].supported = 1; - rc = i; - break; - } - } - } - - return rc; -} - -/*=========================================================================== - * FUNCTION : enableAFR - * - * DESCRIPTION: This function will go through the list - * of supported FPS ranges and select the - * one which has maximum range - * - * PARAMETERS : - * @lib_handle : camera test library handle - * - * RETURN : uint32_t type of stream handle - * MM_CAMERA_OK -- Success - * !=MM_CAMERA_OK -- Error status - *==========================================================================*/ -int enableAFR(mm_camera_lib_handle *lib_handle) -{ - size_t i, j; - float max_range = 0.0f; - cam_capability_t cap; - int rc = MM_CAMERA_OK; - - if ( NULL == lib_handle ) { - return MM_CAMERA_E_INVALID_INPUT; - } - - rc = mm_camera_lib_get_caps(lib_handle, &cap); - if ( MM_CAMERA_OK != rc ) { - CDBG_ERROR("%s:mm_camera_lib_get_caps() err=%d\n", __func__, rc); - return rc; - } - - for( i = 0, j = 0 ; i < cap.fps_ranges_tbl_cnt ; i++ ) { - if ( max_range < (cap.fps_ranges_tbl[i].max_fps - cap.fps_ranges_tbl[i].min_fps) ) { - j = i; - } - } - - rc = mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_FPS_RANGE, - &cap.fps_ranges_tbl[j], - NULL); - - CDBG_ERROR("%s : FPS range [%5.2f:%5.2f] rc = %d", - __func__, - cap.fps_ranges_tbl[j].min_fps, - cap.fps_ranges_tbl[j].max_fps, - rc); - - return rc; -} - -/*=========================================================================== - * FUNCTION - submain - - * - * DESCRIPTION: - * ===========================================================================*/ -static int submain() -{ - int rc = 0; - char tc_buf[3]; - menu_id_change_t current_menu_id = MENU_ID_MAIN, next_menu_id; - camera_action_t action_id; - int action_param; - int isZSL = 0; - uint8_t wnr_enabled = 0; - mm_camera_lib_handle lib_handle; - int num_cameras; - int available_sensors = sizeof(sensor_tbl) / sizeof(sensor_tbl[0]); - int available_snap_sizes = sizeof(dimension_tbl)/sizeof(dimension_tbl[0]); - int i,c; - mm_camera_lib_snapshot_params snap_dim; - snap_dim.width = DEFAULT_SNAPSHOT_WIDTH; - snap_dim.height = DEFAULT_SNAPSHOT_HEIGHT; - cam_scene_mode_type default_scene= CAM_SCENE_MODE_OFF; - int set_tintless= 0; - - mm_camera_test_obj_t test_obj; - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - - rc = mm_camera_lib_open(&lib_handle, 0); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_open() err=%d\n", __func__, rc); - return -1; - } - - num_cameras = mm_camera_lib_number_of_cameras(&lib_handle); - if ( 0 >= num_cameras ) { - CDBG_ERROR("%s: No camera sensors reported!", __func__); - rc = -1; - goto ERROR; - } else if ( 1 <= num_cameras ) { - c = MIN(num_cameras, available_sensors); - for ( i = 0 ; i < c ; i++ ) { - sensor_tbl[i].present = 1; - } - current_menu_id = MENU_ID_SENSORS; - } else { - i = filter_resolutions(&lib_handle, - dimension_tbl, - available_snap_sizes); - if ( ( i < 0 ) || ( i >= available_snap_sizes ) ) { - CDBG_ERROR("%s:filter_resolutions()\n", __func__); - goto ERROR; - } - snap_dim.width = dimension_tbl[i].width; - snap_dim.height = dimension_tbl[i].height; - - rc = enableAFR(&lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:enableAFR() err=%d\n", __func__, rc); - goto ERROR; - } - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_BESTSHOT, - &default_scene, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - } - /*start the eztune server*/ - CDBG_HIGH("Starting eztune Server \n"); - eztune_server_start(&lib_handle); - - do { - print_current_menu (current_menu_id); - fgets(tc_buf, 3, stdin); - - next_menu_id = next_menu(current_menu_id, tc_buf[0], & action_id, & action_param); - - if (next_menu_id != MENU_ID_INVALID) { - current_menu_id = next_menu_id; - } - if (action_id == ACTION_NO_ACTION) { - continue; - } - - switch(action_id) { - case ACTION_START_PREVIEW: - CDBG_ERROR("ACTION_START_PREVIEW \n"); - rc = mm_camera_lib_start_stream(&lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_start_stream() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_STOP_PREVIEW: - CDBG("ACTION_STOP_PREVIEW \n"); - rc = mm_camera_lib_stop_stream(&lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_stop_stream() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_SET_WHITE_BALANCE: - CDBG("Selection for the White Balance changes\n"); - set_whitebalance(&lib_handle, action_param); - break; - - case ACTION_SET_TINTLESS_ENABLE: - CDBG("Selection for the Tintless enable changes\n"); - set_tintless = 1; - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_SET_TINTLESS, - &set_tintless, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_SET_TINTLESS_DISABLE: - CDBG("Selection for the Tintless disable changes\n"); - set_tintless = 0; - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_SET_TINTLESS, - &set_tintless, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_SET_EXP_METERING: - CDBG("Selection for the Exposure Metering changes\n"); - set_exp_metering(&lib_handle, action_param); - break; - - case ACTION_GET_CTRL_VALUE: - CDBG("Selection for getting control value\n"); - get_ctrl_value(action_param); - break; - - case ACTION_BRIGHTNESS_INCREASE: - printf("Increase brightness\n"); - increase_brightness(&lib_handle); - break; - - case ACTION_BRIGHTNESS_DECREASE: - printf("Decrease brightness\n"); - decrease_brightness(&lib_handle); - break; - - case ACTION_CONTRAST_INCREASE: - CDBG("Selection for the contrast increase\n"); - increase_contrast (&lib_handle); - break; - - case ACTION_CONTRAST_DECREASE: - CDBG("Selection for the contrast decrease\n"); - decrease_contrast (&lib_handle); - break; - - case ACTION_EV_INCREASE: - CDBG("Selection for the EV increase\n"); - increase_EV (); - break; - - case ACTION_EV_DECREASE: - CDBG("Selection for the EV decrease\n"); - decrease_EV (); - break; - - case ACTION_SATURATION_INCREASE: - CDBG("Selection for the EV increase\n"); - increase_saturation (&lib_handle); - break; - - case ACTION_SATURATION_DECREASE: - CDBG("Selection for the EV decrease\n"); - decrease_saturation (&lib_handle); - break; - - case ACTION_TOGGLE_AFR: - CDBG("Select for auto frame rate toggling\n"); - toggle_afr(); - break; - - case ACTION_SET_ISO: - CDBG("Select for ISO changes\n"); - set_iso(&lib_handle, action_param); - break; - - case ACTION_SET_ZOOM: - CDBG("Selection for the zoom direction changes\n"); - set_zoom(&lib_handle, action_param); - break; - - case ACTION_SHARPNESS_INCREASE: - CDBG("Selection for sharpness increase\n"); - increase_sharpness(&lib_handle); - break; - - case ACTION_SHARPNESS_DECREASE: - CDBG("Selection for sharpness decrease\n"); - decrease_sharpness(&lib_handle); - break; - - case ACTION_SET_BESTSHOT_MODE: - CDBG("Selection for bestshot\n"); - set_bestshot_mode(&lib_handle, action_param); - break; - - case ACTION_SET_FLASH_MODE: - printf("\n Selection for flashmode\n"); - set_flash_mode(&lib_handle, action_param); - break; - - case ACTION_SWITCH_CAMERA: - rc = mm_camera_lib_close(&lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_close() err=%d\n", __func__, rc); - goto ERROR; - } - - rc = mm_camera_lib_open(&lib_handle, action_param); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_open() err=%d\n", __func__, rc); - goto ERROR; - } - - i = filter_resolutions(&lib_handle, - dimension_tbl, - sizeof(dimension_tbl)/sizeof(dimension_tbl[0])); - if ( ( i < 0 ) || ( i >= available_snap_sizes ) ) { - CDBG_ERROR("%s:filter_resolutions()\n", __func__); - goto ERROR; - } - snap_dim.width = dimension_tbl[i].width; - snap_dim.height = dimension_tbl[i].height; - - rc = enableAFR(&lib_handle); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:enableAFR() err=%d\n", __func__, rc); - goto ERROR; - } - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_BESTSHOT, - &default_scene, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_TOGGLE_ZSL: - printf("ZSL Toggle !!!\n"); - isZSL = !isZSL; - if ( isZSL ) { - printf("ZSL on !!!\n"); - } else { - printf("ZSL off !!!\n"); - } - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_ZSL_ENABLE, - &isZSL, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_TAKE_RAW_SNAPSHOT: - CDBG_HIGH("\n Take RAW snapshot\n"); - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_DO_AF, - NULL, - NULL); - - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_RAW_CAPTURE, - NULL, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_TAKE_JPEG_SNAPSHOT: - CDBG_HIGH("\n Take JPEG snapshot\n"); - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_DO_AF, - NULL, - NULL); - - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_JPEG_CAPTURE, - &snap_dim, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - break; - case ACTION_SWITCH_RESOLUTION: - printf("\n Switch snapshot resolution to %dx%d\n", - dimension_tbl[action_param].width, - dimension_tbl[action_param].height); - snap_dim.width = dimension_tbl[action_param].width; - snap_dim.height = dimension_tbl[action_param].height; - break; - - case ACTION_START_RECORDING: - CDBG("Start recording action\n"); -#if 0 - if (mm_app_start_video(cam_id) < 0) - goto ERROR; - is_rec = 1; -#endif - break; - case ACTION_STOP_RECORDING: - CDBG("Stop recording action\n"); -#if 0 - if(is_rec) { - if (mm_app_stop_video(cam_id) < 0) - goto ERROR; - is_rec = 0; - } -#endif - break; - case ACTION_TAKE_LIVE_SNAPSHOT: - printf("Selection for live shot\n"); -#if 0 - if(is_rec) - mm_app_take_live_snapshot(cam_id); - else - printf("\n !!! Use live snapshot option while recording only !!!\n"); -#endif - break; - - case ACTION_TOGGLE_WNR: - wnr_enabled = !wnr_enabled; - printf("WNR Enabled = %d\n", wnr_enabled); - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_WNR_ENABLE, - &wnr_enabled, - NULL); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_camera_lib_send_command() err=%d\n", __func__, rc); - goto ERROR; - } - break; - - case ACTION_EXIT: - printf("Exiting....\n"); - break; - case ACTION_NO_ACTION: - printf("Go back to main menu"); - break; - - default: - printf("\n\n!!!!!WRONG INPUT: %d!!!!\n", action_id); - break; - } - - usleep(1000 * 1000); - CDBG("action_id = %d\n", action_id); - - } while (action_id != ACTION_EXIT); - action_id = ACTION_NO_ACTION; - - mm_camera_lib_close(&lib_handle); - return 0; - -ERROR: - - mm_camera_lib_close(&lib_handle); - - return rc; -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c deleted file mode 100644 index 692f4dfb..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c +++ /dev/null @@ -1,965 +0,0 @@ -/* -Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" -#include <assert.h> -#include <sys/mman.h> -#include <semaphore.h> - -static void mm_app_metadata_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - int i = 0; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_buf_def_t *frame = bufs->bufs[0]; - metadata_buffer_t *pMetadata; - cam_auto_focus_data_t *focus_data; - - if (NULL == bufs || NULL == user_data) { - CDBG_ERROR("%s: bufs or user_data are not valid ", __func__); - return; - } - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - /* find preview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_METADATA) { - p_stream = &channel->streams[i]; - break; - } - } - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - frame = bufs->bufs[i]; - break; - } - } - - if (NULL == p_stream) { - CDBG_ERROR("%s: cannot find metadata stream", __func__); - return; - } - if (pme->metadata == NULL) { - /* The app will free the meta data, we don't need to bother here */ - pme->metadata = malloc(sizeof(metadata_buffer_t)); - if (NULL == pme->metadata) { - CDBG_ERROR("%s: Canot allocate metadata memory\n", __func__); - return; - } - } - memcpy(pme->metadata, frame->buffer, sizeof(metadata_buffer_t)); - - pMetadata = (metadata_buffer_t *)frame->buffer; - if (IS_META_AVAILABLE(CAM_INTF_META_AUTOFOCUS_DATA, pMetadata)) { - focus_data = (cam_auto_focus_data_t *) - POINTER_OF_META(CAM_INTF_META_AUTOFOCUS_DATA, pMetadata); - if (focus_data->focus_state == CAM_AF_FOCUSED || - focus_data->focus_state == CAM_AF_NOT_FOCUSED) { - CDBG_ERROR("%s: AutoFocus Done Call Back Received\n",__func__); - mm_camera_app_done(); - } else if (focus_data->focus_state == CAM_AF_NOT_FOCUSED) { - CDBG_ERROR("%s: AutoFocus failed\n",__func__); - mm_camera_app_done(); - } - } - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); -} - -static void mm_app_preview_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - int i = 0; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_buf_def_t *frame = bufs->bufs[0]; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - CDBG_ERROR("%s: BEGIN - length=%d, frame idx = %d\n", - __func__, frame->frame_len, frame->frame_idx); - - if (NULL == bufs || NULL == user_data) { - CDBG_ERROR("%s: bufs or user_data are not valid ", __func__); - return; - } - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - /* find preview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_PREVIEW) { - p_stream = &channel->streams[i]; - break; - } - } - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - frame = bufs->bufs[i]; - break; - } - } - - if (NULL == p_stream) { - CDBG_ERROR("%s: cannot find preview stream", __func__); - return; - } - - if ( 0 < pme->fb_fd ) { - mm_app_overlay_display(pme, frame->fd); - } -#ifdef DUMP_PRV_IN_FILE - { - char file_name[64]; - snprintf(file_name, sizeof(file_name), "P_C%d", pme->cam->camera_handle); - mm_app_dump_frame(frame, file_name, "yuv", frame->frame_idx); - } -#endif - if (pme->user_preview_cb) { - CDBG_ERROR("[DBG] %s, user defined own preview cb. calling it...", __func__); - pme->user_preview_cb(frame); - } - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - - CDBG("%s: END\n", __func__); -} - -static void mm_app_zsl_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - int rc = 0; - int i = 0; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_stream_t *md_stream = NULL; - mm_camera_buf_def_t *p_frame = NULL; - mm_camera_buf_def_t *m_frame = NULL; - mm_camera_buf_def_t *md_frame = NULL; - - CDBG("%s: BEGIN\n", __func__); - - if (NULL == bufs || NULL == user_data) { - CDBG_ERROR("%s: bufs or user_data are not valid ", __func__); - return; - } - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - CDBG_ERROR("%s: Wrong channel id (%d)", __func__, bufs->ch_id); - return; - } - - /* find preview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_PREVIEW) { - p_stream = &channel->streams[i]; - break; - } - } - if (NULL == p_stream) { - CDBG_ERROR("%s: cannot find preview stream", __func__); - return; - } - - /* find snapshot stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_SNAPSHOT) { - m_stream = &channel->streams[i]; - break; - } - } - if (NULL == m_stream) { - CDBG_ERROR("%s: cannot find snapshot stream", __func__); - return; - } - - /* find metadata stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_METADATA) { - md_stream = &channel->streams[i]; - break; - } - } - if (NULL == md_stream) { - CDBG_ERROR("%s: cannot find metadata stream", __func__); - } - - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - p_frame = bufs->bufs[i]; - break; - } - } - - if(md_stream) { - /* find metadata frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == md_stream->s_id) { - md_frame = bufs->bufs[i]; - break; - } - } - if (!pme->metadata) { - /* App will free the metadata */ - pme->metadata = malloc(sizeof(metadata_buffer_t)); - } - memcpy(pme->metadata , md_frame->buffer, sizeof(metadata_buffer_t)); - } - /* find snapshot frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == m_stream->s_id) { - m_frame = bufs->bufs[i]; - break; - } - } - - if (!m_frame || !p_frame) { - CDBG_ERROR("%s: cannot find preview/snapshot frame", __func__); - return; - } - - CDBG("%s: ZSL CB with fb_fd = %d, m_frame = 0x%x, p_frame = 0x%x \n", - __func__, - pme->fb_fd, - (uint32_t )m_frame, - (uint32_t )p_frame); - - if ( 0 < pme->fb_fd ) { - mm_app_overlay_display(pme, p_frame->fd); - }/* else { - mm_app_dump_frame(p_frame, "zsl_preview", "yuv", p_frame->frame_idx); - mm_app_dump_frame(m_frame, "zsl_main", "yuv", m_frame->frame_idx); - }*/ - - if ( pme->enable_reproc && ( NULL != pme->reproc_stream ) ) { - rc = mm_app_do_reprocess(pme, - m_frame, - md_frame->buf_idx, - bufs, - md_stream); - if (MM_CAMERA_OK != rc ) { - CDBG_ERROR("%s: reprocess failed rc = %d", __func__, rc); - } - - return; - } - - if ( pme->encodeJpeg ) { - pme->jpeg_buf.buf.buffer = (uint8_t *)malloc(m_frame->frame_len); - if ( NULL == pme->jpeg_buf.buf.buffer ) { - CDBG_ERROR("%s: error allocating jpeg output buffer", __func__); - goto exit; - } - - pme->jpeg_buf.buf.frame_len = m_frame->frame_len; - /* create a new jpeg encoding session */ - rc = createEncodingSession(pme, m_stream, m_frame); - if (0 != rc) { - CDBG_ERROR("%s: error creating jpeg session", __func__); - free(pme->jpeg_buf.buf.buffer); - goto exit; - } - - /* start jpeg encoding job */ - rc = encodeData(pme, bufs, m_stream); - pme->encodeJpeg = 0; - } else { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - m_frame)) { - CDBG_ERROR("%s: Failed in main Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)m_frame->mem_info, - ION_IOC_INV_CACHES); - } - -exit: - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - p_frame)) { - CDBG_ERROR("%s: Failed in preview Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)p_frame->mem_info, - ION_IOC_INV_CACHES); - - if(md_frame) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - md_frame)) { - CDBG_ERROR("%s: Failed in metadata Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)md_frame->mem_info, - ION_IOC_INV_CACHES); - } - - CDBG("%s: END\n", __func__); -} - -mm_camera_stream_t * mm_app_add_metadata_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_METADATA; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = DEFAULT_PREVIEW_FORMAT; - stream->s_config.stream_info->dim.width = sizeof(metadata_buffer_t); - stream->s_config.stream_info->dim.height = 1; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config preview stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -mm_camera_stream_t * mm_app_add_preview_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_PREVIEW; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = DEFAULT_PREVIEW_FORMAT; - - if ((test_obj->preview_resolution.user_input_display_width == 0) || - ( test_obj->preview_resolution.user_input_display_height == 0)) { - stream->s_config.stream_info->dim.width = DEFAULT_PREVIEW_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_PREVIEW_HEIGHT; - } else { - stream->s_config.stream_info->dim.width = test_obj->preview_resolution.user_input_display_width; - stream->s_config.stream_info->dim.height = test_obj->preview_resolution.user_input_display_height; - } - - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config preview stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -mm_camera_stream_t * mm_app_add_raw_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_RAW; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = test_obj->buffer_format; - if ( test_obj->buffer_width == 0 || test_obj->buffer_height == 0 ) { - stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT; - } else { - stream->s_config.stream_info->dim.width = test_obj->buffer_width; - stream->s_config.stream_info->dim.height = test_obj->buffer_height; - } - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config preview stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -mm_camera_stream_t * mm_app_add_snapshot_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_SNAPSHOT; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = DEFAULT_SNAPSHOT_FORMAT; - if ( test_obj->buffer_width == 0 || test_obj->buffer_height == 0 ) { - stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT; - } else { - stream->s_config.stream_info->dim.width = test_obj->buffer_width; - stream->s_config.stream_info->dim.height = test_obj->buffer_height; - } - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config preview stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_preview_channel(mm_camera_test_obj_t *test_obj) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_PREVIEW, - NULL, - NULL, - NULL); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return NULL; - } - - stream = mm_app_add_preview_stream(test_obj, - channel, - mm_app_preview_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - return channel; -} - -int mm_app_stop_and_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - uint8_t i; - - rc = mm_app_stop_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc); - } - - if (channel->num_streams <= MAX_STREAM_NUM_IN_BUNDLE) { - for (i = 0; i < channel->num_streams; i++) { - stream = &channel->streams[i]; - rc = mm_app_del_stream(test_obj, channel, stream); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:del stream(%d) failed rc=%d\n", __func__, i, rc); - } - } - } else { - CDBG_ERROR("%s: num_streams = %d. Should not be more than %d\n", - __func__, channel->num_streams, MAX_STREAM_NUM_IN_BUNDLE); - } - rc = mm_app_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:delete channel failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_start_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - mm_camera_stream_t *s_metadata = NULL; - uint8_t i; - - channel = mm_app_add_preview_channel(test_obj); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return -MM_CAMERA_E_GENERAL; - } - - s_metadata = mm_app_add_metadata_stream(test_obj, - channel, - mm_app_metadata_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == s_metadata) { - CDBG_ERROR("%s: add metadata stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start preview failed rc=%d\n", __func__, rc); - if (channel->num_streams <= MAX_STREAM_NUM_IN_BUNDLE) { - for (i = 0; i < channel->num_streams; i++) { - stream = &channel->streams[i]; - mm_app_del_stream(test_obj, channel, stream); - } - } - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - - mm_camera_channel_t *channel = - mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_PREVIEW); - - rc = mm_app_stop_and_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_start_preview_zsl(mm_camera_test_obj_t *test_obj) -{ - int32_t rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *s_preview = NULL; - mm_camera_stream_t *s_metadata = NULL; - mm_camera_stream_t *s_main = NULL; - mm_camera_channel_attr_t attr; - - memset(&attr, 0, sizeof(mm_camera_channel_attr_t)); - attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS; - attr.look_back = 2; - attr.post_frame_skip = 0; - attr.water_mark = 2; - attr.max_unmatched_frames = 3; - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_ZSL, - &attr, - mm_app_zsl_notify_cb, - test_obj); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return -MM_CAMERA_E_GENERAL; - } - - s_preview = mm_app_add_preview_stream(test_obj, - channel, - mm_app_preview_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == s_preview) { - CDBG_ERROR("%s: add preview stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return rc; - } - - s_metadata = mm_app_add_metadata_stream(test_obj, - channel, - mm_app_metadata_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == s_metadata) { - CDBG_ERROR("%s: add metadata stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return rc; - } - - s_main = mm_app_add_snapshot_stream(test_obj, - channel, - NULL, - NULL, - PREVIEW_BUF_NUM, - 0); - if (NULL == s_main) { - CDBG_ERROR("%s: add main snapshot stream failed\n", __func__); - mm_app_del_stream(test_obj, channel, s_preview); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start zsl failed rc=%d\n", __func__, rc); - mm_app_del_stream(test_obj, channel, s_preview); - mm_app_del_stream(test_obj, channel, s_metadata); - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - - if ( test_obj->enable_reproc ) { - if ( NULL == mm_app_add_reprocess_channel(test_obj, s_main) ) { - CDBG_ERROR("%s: Reprocess channel failed to initialize \n", __func__); - mm_app_del_stream(test_obj, channel, s_preview); -#ifdef USE_METADATA_STREAM - mm_app_del_stream(test_obj, channel, s_metadata); -#endif - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - rc = mm_app_start_reprocess(test_obj); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s: reprocess start failed rc=%d\n", __func__, rc); - mm_app_del_stream(test_obj, channel, s_preview); -#ifdef USE_METADATA_STREAM - mm_app_del_stream(test_obj, channel, s_metadata); -#endif - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - } - - return rc; -} - -int mm_app_stop_preview_zsl(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - - mm_camera_channel_t *channel = - mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_ZSL); - - rc = mm_app_stop_and_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc); - } - - if ( test_obj->enable_reproc ) { - rc |= mm_app_stop_reprocess(test_obj); - } - - return rc; -} - -int mm_app_initialize_fb(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int brightness_fd; - const char brightness_level[] = BACKLIGHT_LEVEL; - void *fb_base = NULL; - - assert( ( NULL != test_obj ) && ( 0 == test_obj->fb_fd ) ); - - test_obj->fb_fd = open(FB_PATH, O_RDWR); - if ( 0 > test_obj->fb_fd ) { - CDBG_ERROR("%s: FB device open failed rc=%d, %s\n", - __func__, - -errno, - strerror(errno)); - rc = -errno; - goto FAIL; - } - - rc = ioctl(test_obj->fb_fd, FBIOGET_VSCREENINFO, &test_obj->vinfo); - if ( MM_CAMERA_OK != rc ) { - CDBG_ERROR("%s: Can not retrieve screen info rc=%d, %s\n", - __func__, - -errno, - strerror(errno)); - rc = -errno; - goto FAIL; - } - - if ( ( 0 == test_obj->vinfo.yres_virtual ) || - ( 0 == test_obj->vinfo.yres ) || - ( test_obj->vinfo.yres > test_obj->vinfo.yres_virtual ) ) { - CDBG_ERROR("%s: Invalid FB virtual yres: %d, yres: %d\n", - __func__, - test_obj->vinfo.yres_virtual, - test_obj->vinfo.yres); - rc = MM_CAMERA_E_GENERAL; - goto FAIL; - } - - if ( ( 0 == test_obj->vinfo.xres_virtual ) || - ( 0 == test_obj->vinfo.xres ) || - ( test_obj->vinfo.xres > test_obj->vinfo.xres_virtual ) ) { - CDBG_ERROR("%s: Invalid FB virtual xres: %d, xres: %d\n", - __func__, - test_obj->vinfo.xres_virtual, - test_obj->vinfo.xres); - rc = MM_CAMERA_E_GENERAL; - goto FAIL; - } - - brightness_fd = open(BACKLIGHT_CONTROL, O_RDWR); - if ( brightness_fd >= 0 ) { - write(brightness_fd, brightness_level, strlen(brightness_level)); - close(brightness_fd); - } - - test_obj->slice_size = test_obj->vinfo.xres * ( test_obj->vinfo.yres - 1 ) * DEFAULT_OV_FORMAT_BPP; - memset(&test_obj->data_overlay, 0, sizeof(struct mdp_overlay)); - test_obj->data_overlay.src.width = test_obj->buffer_width; - test_obj->data_overlay.src.height = test_obj->buffer_height; - test_obj->data_overlay.src_rect.w = test_obj->buffer_width; - test_obj->data_overlay.src_rect.h = test_obj->buffer_height; - test_obj->data_overlay.dst_rect.w = test_obj->buffer_width; - test_obj->data_overlay.dst_rect.h = test_obj->buffer_height; - test_obj->data_overlay.src.format = DEFAULT_OV_FORMAT; - test_obj->data_overlay.src_rect.x = 0; - test_obj->data_overlay.src_rect.y = 0; - test_obj->data_overlay.dst_rect.x = 0; - test_obj->data_overlay.dst_rect.y = 0; - test_obj->data_overlay.z_order = 2; - test_obj->data_overlay.alpha = 0x80; - test_obj->data_overlay.transp_mask = 0xffe0; - test_obj->data_overlay.flags = MDP_FLIP_LR | MDP_FLIP_UD; - - // Map and clear FB portion - fb_base = mmap(0, - test_obj->slice_size, - PROT_WRITE, - MAP_SHARED, - test_obj->fb_fd, - 0); - if ( MAP_FAILED == fb_base ) { - CDBG_ERROR("%s: ( Error while memory mapping frame buffer %s", - __func__, - strerror(errno)); - rc = -errno; - goto FAIL; - } - - memset(fb_base, 0, test_obj->slice_size); - - if (ioctl(test_obj->fb_fd, FBIOPAN_DISPLAY, &test_obj->vinfo) < 0) { - CDBG_ERROR("%s : FBIOPAN_DISPLAY failed!", __func__); - rc = -errno; - goto FAIL; - } - - munmap(fb_base, test_obj->slice_size); - test_obj->data_overlay.id = MSMFB_NEW_REQUEST; - rc = ioctl(test_obj->fb_fd, MSMFB_OVERLAY_SET, &test_obj->data_overlay); - if (rc < 0) { - CDBG_ERROR("%s : MSMFB_OVERLAY_SET failed! err=%d\n", - __func__, - test_obj->data_overlay.id); - return MM_CAMERA_E_GENERAL; - } - CDBG_ERROR("%s: Overlay set with overlay id: %d", __func__, test_obj->data_overlay.id); - - return rc; - -FAIL: - - if ( 0 < test_obj->fb_fd ) { - close(test_obj->fb_fd); - } - - return rc; -} - -int mm_app_close_fb(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - - assert( ( NULL != test_obj ) && ( 0 < test_obj->fb_fd ) ); - - if (ioctl(test_obj->fb_fd, MSMFB_OVERLAY_UNSET, &test_obj->data_overlay.id)) { - CDBG_ERROR("\nERROR! MSMFB_OVERLAY_UNSET failed! (Line %d)\n", __LINE__); - } - - if (ioctl(test_obj->fb_fd, FBIOPAN_DISPLAY, &test_obj->vinfo) < 0) { - CDBG_ERROR("ERROR: FBIOPAN_DISPLAY failed! line=%d\n", __LINE__); - } - - close(test_obj->fb_fd); - test_obj->fb_fd = 0; - - return rc; -} - -void memset16(void *pDst, uint16_t value, int count) -{ - uint16_t *ptr = pDst; - while (count--) - *ptr++ = value; -} - -int mm_app_overlay_display(mm_camera_test_obj_t *test_obj, int bufferFd) -{ - int rc = MM_CAMERA_OK; - struct msmfb_overlay_data ovdata; - - - memset(&ovdata, 0, sizeof(struct msmfb_overlay_data)); - ovdata.id = test_obj->data_overlay.id; - ovdata.data.memory_id = bufferFd; - - if (ioctl(test_obj->fb_fd, MSMFB_OVERLAY_PLAY, &ovdata)) { - CDBG_ERROR("%s : MSMFB_OVERLAY_PLAY failed!", __func__); - return MM_CAMERA_E_GENERAL; - } - - if (ioctl(test_obj->fb_fd, FBIOPAN_DISPLAY, &test_obj->vinfo) < 0) { - CDBG_ERROR("%s : FBIOPAN_DISPLAY failed!", __func__); - return MM_CAMERA_E_GENERAL; - } - - return rc; -} diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_queue.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_queue.c deleted file mode 100644 index 0d496248..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_queue.c +++ /dev/null @@ -1,167 +0,0 @@ -/* Copyright (c) 2012, The Linux Foundataion. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -int mm_camera_queue_init(mm_camera_queue_t *queue, - release_data_fn data_rel_fn, - void *user_data) -{ - if ( NULL == queue ) { - return -1; - } - - pthread_mutex_init(&queue->m_lock, NULL); - cam_list_init(&queue->m_head.list); - queue->m_size = 0; - queue->m_dataFn = data_rel_fn; - queue->m_userData = user_data; - - return MM_CAMERA_OK; -} - -int mm_qcamera_queue_release(mm_camera_queue_t *queue) -{ - if ( NULL == queue ) { - return -1; - } - - mm_qcamera_queue_flush(queue); - pthread_mutex_destroy(&queue->m_lock); - - return MM_CAMERA_OK; -} - -int mm_qcamera_queue_isempty(mm_camera_queue_t *queue) -{ - if ( NULL == queue ) { - return 0; - } - - int flag = 1; - pthread_mutex_lock(&queue->m_lock); - if (queue->m_size > 0) { - flag = 0; - } - pthread_mutex_unlock(&queue->m_lock); - - return flag; -} - -int mm_qcamera_queue_enqueue(mm_camera_queue_t *queue, void *data) -{ - if ( NULL == queue ) { - return -1; - } - - camera_q_node *node = - (camera_q_node *)malloc(sizeof(camera_q_node)); - if (NULL == node) { - CDBG_ERROR("%s: No memory for camera_q_node", __func__); - return 0; - } - - memset(node, 0, sizeof(camera_q_node)); - node->data = data; - - pthread_mutex_lock(&queue->m_lock); - cam_list_add_tail_node(&node->list, &queue->m_head.list); - queue->m_size++; - pthread_mutex_unlock(&queue->m_lock); - - return 1; -} - -void* mm_qcamera_queue_dequeue(mm_camera_queue_t *queue, int bFromHead) -{ - if ( NULL == queue ) { - return NULL; - } - - camera_q_node* node = NULL; - void* data = NULL; - struct cam_list *head = NULL; - struct cam_list *pos = NULL; - - pthread_mutex_lock(&queue->m_lock); - head = &queue->m_head.list; - if (bFromHead) { - pos = head->next; - } else { - pos = head->prev; - } - if (pos != head) { - node = member_of(pos, camera_q_node, list); - cam_list_del_node(&node->list); - queue->m_size--; - } - pthread_mutex_unlock(&queue->m_lock); - - if (NULL != node) { - data = node->data; - free(node); - } - - return data; -} - -void mm_qcamera_queue_flush(mm_camera_queue_t *queue) -{ - camera_q_node* node = NULL; - struct cam_list *head = NULL; - struct cam_list *pos = NULL; - - if ( NULL == queue ) { - return; - } - - pthread_mutex_lock(&queue->m_lock); - head = &queue->m_head.list; - pos = head->next; - - while(pos != head) { - node = member_of(pos, camera_q_node, list); - pos = pos->next; - cam_list_del_node(&node->list); - queue->m_size--; - - if (NULL != node->data) { - if (queue->m_dataFn) { - queue->m_dataFn(node->data, queue->m_userData); - } - free(node->data); - } - free(node); - - } - queue->m_size = 0; - pthread_mutex_unlock(&queue->m_lock); -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c deleted file mode 100644 index 758406f7..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c +++ /dev/null @@ -1,315 +0,0 @@ -/* -Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -static uint32_t rdi_len = 0; - -static void mm_app_rdi_dump_frame(mm_camera_buf_def_t *frame, - char *name, - char *ext, - int frame_idx) -{ - char file_name[64]; - int file_fd; - int i; - - if (frame != NULL) { - - snprintf(file_name, sizeof(file_name), "/data/%s_%03d.%s", name, frame_idx, ext); - file_fd = open(file_name, O_RDWR | O_CREAT, 0777); - if (file_fd < 0) { - CDBG_ERROR("%s: cannot open file %s \n", __func__, file_name); - } else { - for (i = 0; i < frame->num_planes; i++) { - write(file_fd, - (uint8_t *)frame->buffer + frame->planes[i].data_offset, - rdi_len); - } - - close(file_fd); - CDBG("%s: dump rdi frame %s", __func__,file_name); - } - } -} - -static void mm_app_rdi_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - char file_name[64]; - mm_camera_buf_def_t *frame = bufs->bufs[0]; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - CDBG("%s: BEGIN - length=%d, frame idx = %d stream_id=%d\n", - __func__, frame->frame_len, frame->frame_idx, frame->stream_id); - snprintf(file_name, sizeof(file_name), "RDI_dump_%d", pme->cam->camera_handle); - mm_app_rdi_dump_frame(frame, file_name, "raw", frame->frame_idx); - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - CDBG_ERROR("%s: Failed in RDI Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - - CDBG("%s: END\n", __func__); -} - -mm_camera_stream_t * mm_app_add_rdi_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - int i; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - cam_format_t fmt = CAM_FORMAT_MAX; - cam_stream_buf_plane_info_t *buf_planes; - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - CDBG_ERROR("%s: raw_dim w:%d height:%d\n", __func__, cam_cap->raw_dim[0].width, cam_cap->raw_dim[0].height); - for (i = 0;i < cam_cap->supported_raw_fmt_cnt;i++) { - CDBG_ERROR("%s: supported_raw_fmts[%d]=%d\n", __func__, i, cam_cap->supported_raw_fmts[i]); - if (((CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG <= cam_cap->supported_raw_fmts[i]) && - (CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR >= cam_cap->supported_raw_fmts[i])) || - (cam_cap->supported_raw_fmts[i] == CAM_FORMAT_META_RAW_8BIT) || - (cam_cap->supported_raw_fmts[i] == CAM_FORMAT_JPEG_RAW_8BIT)) - { - fmt = cam_cap->supported_raw_fmts[i]; - CDBG_ERROR("%s: fmt=%d\n", __func__, fmt); - } - } - - if (CAM_FORMAT_MAX == fmt) { - CDBG_ERROR("%s: rdi format not supported\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_RAW; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = fmt; - CDBG("%s: RAW: w: %d, h: %d ", __func__, - cam_cap->raw_dim[0].width, cam_cap->raw_dim[0].height); - - stream->s_config.stream_info->dim.width = cam_cap->raw_dim[0].width; - stream->s_config.stream_info->dim.height = cam_cap->raw_dim[0].height; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config rdi stream err=%d\n", __func__, rc); - return NULL; - } - - buf_planes = &stream->s_config.stream_info->buf_planes; - rdi_len = buf_planes->plane_info.mp[0].len; - CDBG("%s: plane_info %dx%d len:%d frame_len:%d\n", __func__, - buf_planes->plane_info.mp[0].stride, buf_planes->plane_info.mp[0].scanline, - buf_planes->plane_info.mp[0].len, buf_planes->plane_info.frame_len); - - return stream; -} - -mm_camera_stream_t * mm_app_add_rdi_snapshot_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_SNAPSHOT; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = DEFAULT_SNAPSHOT_FORMAT; - stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config rdi stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_rdi_channel(mm_camera_test_obj_t *test_obj, uint8_t num_burst) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_RDI, - NULL, - NULL, - NULL); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return NULL; - } - - stream = mm_app_add_rdi_stream(test_obj, - channel, - mm_app_rdi_notify_cb, - (void *)test_obj, - RDI_BUF_NUM, - num_burst); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - CDBG("%s: channel=%d stream=%d\n", __func__, channel->ch_id, stream->s_id); - return channel; -} - -int mm_app_stop_and_del_rdi_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - uint8_t i; - - rc = mm_app_stop_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop RDI failed rc=%d\n", __func__, rc); - } - - if (channel->num_streams <= MAX_STREAM_NUM_IN_BUNDLE) { - for (i = 0; i < channel->num_streams; i++) { - stream = &channel->streams[i]; - rc = mm_app_del_stream(test_obj, channel, stream); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:del stream(%d) failed rc=%d\n", __func__, i, rc); - } - } - } else { - CDBG_ERROR("%s: num_streams = %d. Should not be more than %d\n", - __func__, channel->num_streams, MAX_STREAM_NUM_IN_BUNDLE); - } - - rc = mm_app_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:delete channel failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_start_rdi(mm_camera_test_obj_t *test_obj, uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - - channel = mm_app_add_rdi_channel(test_obj, num_burst); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return -MM_CAMERA_E_GENERAL; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start rdi failed rc=%d\n", __func__, rc); - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_rdi(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - - mm_camera_channel_t *channel = - mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_RDI); - - rc = mm_app_stop_and_del_rdi_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop RDI failed rc=%d\n", __func__, rc); - } - - return rc; -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c deleted file mode 100644 index 22a3cf8c..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c +++ /dev/null @@ -1,361 +0,0 @@ -/* -Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -static void mm_app_reprocess_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - mm_camera_buf_def_t *frame = bufs->bufs[0]; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_buf_def_t *m_frame = NULL; - mm_camera_super_buf_t *src_frame; - int i = 0; - int rc = 0; - - CDBG_ERROR("%s: BEGIN - length=%d, frame idx = %d\n", - __func__, frame->frame_len, frame->frame_idx); - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - CDBG_ERROR("%s: Wrong channel id (%d)", __func__, bufs->ch_id); - return; - } - - // We have only one stream and buffer - // in the reprocess channel. - m_stream = &channel->streams[0]; - m_frame = bufs->bufs[0]; - - if ( pme->encodeJpeg ) { - pme->jpeg_buf.buf.buffer = (uint8_t *)malloc(m_frame->frame_len); - if ( NULL == pme->jpeg_buf.buf.buffer ) { - CDBG_ERROR("%s: error allocating jpeg output buffer", __func__); - goto exit; - } - - pme->jpeg_buf.buf.frame_len = m_frame->frame_len; - /* create a new jpeg encoding session */ - rc = createEncodingSession(pme, m_stream, m_frame); - if (0 != rc) { - CDBG_ERROR("%s: error creating jpeg session", __func__); - free(pme->jpeg_buf.buf.buffer); - goto exit; - } - - /* start jpeg encoding job */ - CDBG_ERROR("Encoding reprocessed frame!!"); - rc = encodeData(pme, bufs, m_stream); - pme->encodeJpeg = 0; - } else { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - CDBG_ERROR("%s: Failed in Reprocess Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - } - -exit: - -// Release source frame - src_frame = ( mm_camera_super_buf_t * ) mm_qcamera_queue_dequeue(&pme->pp_frames, 1); - if ( NULL != src_frame ) { - mm_app_release_ppinput((void *) src_frame, (void *) pme); - } - - CDBG_ERROR("%s: END\n", __func__); -} - -mm_camera_stream_t * mm_app_add_reprocess_stream_from_source(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *source, - mm_camera_buf_notify_t stream_cb, - cam_pp_feature_config_t pp_config, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = NULL; - cam_stream_info_t *source_stream_info; - - if ( ( NULL == test_obj ) || - ( NULL == channel ) || - ( NULL == source ) ) { - CDBG_ERROR("%s: Invalid input\n", __func__); - return NULL; - } - - cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - source_stream_info = (cam_stream_info_t *) source->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_OFFLINE_PROC; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = source_stream_info->fmt; - stream->s_config.stream_info->dim = source_stream_info->dim; - stream->s_config.padding_info = cam_cap->padding_info; - - - stream->s_config.stream_info->reprocess_config.pp_type = CAM_ONLINE_REPROCESS_TYPE; - stream->s_config.stream_info->reprocess_config.online.input_stream_id = source->s_config.stream_info->stream_svr_id; - stream->s_config.stream_info->reprocess_config.online.input_stream_type = source->s_config.stream_info->stream_type; - stream->s_config.stream_info->reprocess_config.pp_feature_config = pp_config; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config preview stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_reprocess_channel(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *source_stream) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - if ( NULL == source_stream ) { - CDBG_ERROR("%s: add reprocess stream failed\n", __func__); - return NULL; - } - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_REPROCESS, - NULL, - NULL, - NULL); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return NULL; - } - - // pp feature config - cam_pp_feature_config_t pp_config; - memset(&pp_config, 0, sizeof(cam_pp_feature_config_t)); - - cam_capability_t *caps = ( cam_capability_t * ) ( test_obj->cap_buf.buf.buffer ); - if (caps->min_required_pp_mask & CAM_QCOM_FEATURE_SHARPNESS) { - pp_config.feature_mask |= CAM_QCOM_FEATURE_SHARPNESS; - pp_config.sharpness = test_obj->reproc_sharpness; - } - - if (test_obj->reproc_wnr.denoise_enable) { - pp_config.feature_mask |= CAM_QCOM_FEATURE_DENOISE2D; - pp_config.denoise2d = test_obj->reproc_wnr; - } - - if (test_obj->enable_CAC) { - pp_config.feature_mask |= CAM_QCOM_FEATURE_CAC; - } - - uint8_t minStreamBufNum = source_stream->num_of_bufs; - stream = mm_app_add_reprocess_stream_from_source(test_obj, - channel, - source_stream, - mm_app_reprocess_notify_cb, - pp_config, - (void *)test_obj, - minStreamBufNum); - if (NULL == stream) { - CDBG_ERROR("%s: add reprocess stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return NULL; - } - test_obj->reproc_stream = stream; - - return channel; -} - -int mm_app_start_reprocess(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *r_ch = NULL; - - mm_camera_queue_init(&test_obj->pp_frames, - mm_app_release_ppinput, - ( void * ) test_obj); - - r_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_REPROCESS); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s: No initialized reprocess channel d rc=%d\n", - __func__, - rc); - return rc; - } - - rc = mm_app_start_channel(test_obj, r_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start reprocess failed rc=%d\n", __func__, rc); - mm_app_del_channel(test_obj, r_ch); - return rc; - } - - return rc; -} - -int mm_app_stop_reprocess(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *r_ch = NULL; - - r_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_REPROCESS); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s: No initialized reprocess channel d rc=%d\n", - __func__, - rc); - return rc; - } - - rc = mm_app_stop_and_del_channel(test_obj, r_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc); - } - - mm_qcamera_queue_release(&test_obj->pp_frames); - test_obj->reproc_stream = NULL; - - return rc; -} - -int mm_app_do_reprocess(mm_camera_test_obj_t *test_obj, - mm_camera_buf_def_t *frame, - uint8_t meta_idx, - mm_camera_super_buf_t *super_buf, - mm_camera_stream_t *src_meta) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *r_ch = NULL; - mm_camera_super_buf_t *src_buf = NULL; - - if ( ( NULL == test_obj ) || - ( NULL == frame ) || - ( NULL == super_buf )) { - CDBG_ERROR("%s: Invalid input rc=%d\n", - __func__, - rc); - return rc; - } - - if ( NULL == test_obj->reproc_stream ) { - CDBG_ERROR("%s: No reprocess stream rc=%d\n", - __func__, - rc); - return rc; - } - - r_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_REPROCESS); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s: No reprocess channel rc=%d\n", - __func__, - rc); - return rc; - } - - src_buf = ( mm_camera_super_buf_t * ) malloc(sizeof(mm_camera_super_buf_t)); - if ( NULL == src_buf ) { - CDBG_ERROR("%s: No resources for src frame rc=%d\n", - __func__, - rc); - return -1; - } - memcpy(src_buf, super_buf, sizeof(mm_camera_super_buf_t)); - mm_qcamera_queue_enqueue(&test_obj->pp_frames, src_buf); - - cam_stream_parm_buffer_t param; - memset(¶m, 0, sizeof(cam_stream_parm_buffer_t)); - param.type = CAM_STREAM_PARAM_TYPE_DO_REPROCESS; - param.reprocess.buf_index = frame->buf_idx; - param.reprocess.frame_idx = frame->frame_idx; - if (src_meta != NULL) { - param.reprocess.meta_present = 1; - param.reprocess.meta_stream_handle = src_meta->s_config.stream_info->stream_svr_id; - param.reprocess.meta_buf_index = meta_idx; - } else { - CDBG_ERROR("%s: No metadata source stream rc=%d\n", - __func__, - rc); - } - - test_obj->reproc_stream->s_config.stream_info->parm_buf = param; - rc = test_obj->cam->ops->set_stream_parms(test_obj->cam->camera_handle, - r_ch->ch_id, - test_obj->reproc_stream->s_id, - &test_obj->reproc_stream->s_config.stream_info->parm_buf); - - return rc; -} - -void mm_app_release_ppinput(void *data, void *user_data) -{ - int i = 0; - mm_camera_super_buf_t *recvd_frame = ( mm_camera_super_buf_t * ) data; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - for ( i = 0 ; i < recvd_frame->num_bufs ; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle, - recvd_frame->ch_id, - recvd_frame->bufs[i])) { - CDBG_ERROR("%s: Failed in Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *) recvd_frame->bufs[i]->mem_info, - ION_IOC_INV_CACHES); - } -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c deleted file mode 100644 index fbd50fa0..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c +++ /dev/null @@ -1,689 +0,0 @@ -/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -/* This callback is received once the complete JPEG encoding is done */ -static void jpeg_encode_cb(jpeg_job_status_t status, - uint32_t client_hdl, - uint32_t jobId, - mm_jpeg_output_t *p_buf, - void *userData) -{ - int i = 0; - mm_camera_test_obj_t *pme = NULL; - CDBG("%s: BEGIN\n", __func__); - - pme = (mm_camera_test_obj_t *)userData; - if (pme->jpeg_hdl != client_hdl || - jobId != pme->current_job_id || - !pme->current_job_frames) { - CDBG_ERROR("%s: NULL current job frames or not matching job ID (%d, %d)", - __func__, jobId, pme->current_job_id); - return; - } - - /* dump jpeg img */ - CDBG_ERROR("%s: job %d, status=%d", __func__, jobId, status); - if (status == JPEG_JOB_STATUS_DONE && p_buf != NULL) { - mm_app_dump_jpeg_frame(p_buf->buf_vaddr, p_buf->buf_filled_len, "jpeg", "jpg", jobId); - } - - /* buf done current encoding frames */ - pme->current_job_id = 0; - for (i = 0; i < pme->current_job_frames->num_bufs; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->current_job_frames->camera_handle, - pme->current_job_frames->ch_id, - pme->current_job_frames->bufs[i])) { - CDBG_ERROR("%s: Failed in Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *) pme->current_job_frames->bufs[i]->mem_info, - ION_IOC_INV_CACHES); - } - - free(pme->jpeg_buf.buf.buffer); - free(pme->current_job_frames); - pme->current_job_frames = NULL; - - /* signal snapshot is done */ - mm_camera_app_done(); -} - -int encodeData(mm_camera_test_obj_t *test_obj, mm_camera_super_buf_t* recvd_frame, - mm_camera_stream_t *m_stream) -{ - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - int rc = -MM_CAMERA_E_GENERAL; - mm_jpeg_job_t job; - - /* remember current frames being encoded */ - test_obj->current_job_frames = - (mm_camera_super_buf_t *)malloc(sizeof(mm_camera_super_buf_t)); - if (!test_obj->current_job_frames) { - CDBG_ERROR("%s: No memory for current_job_frames", __func__); - return rc; - } - *(test_obj->current_job_frames) = *recvd_frame; - - memset(&job, 0, sizeof(job)); - job.job_type = JPEG_JOB_TYPE_ENCODE; - job.encode_job.session_id = test_obj->current_jpeg_sess_id; - - // TODO: Rotation should be set according to - // sensor&device orientation - job.encode_job.rotation = 0; - if (cam_cap->position == CAM_POSITION_BACK) { - job.encode_job.rotation = 270; - } - - /* fill in main src img encode param */ - job.encode_job.main_dim.src_dim = m_stream->s_config.stream_info->dim; - job.encode_job.main_dim.dst_dim = m_stream->s_config.stream_info->dim; - job.encode_job.src_index = 0; - - job.encode_job.thumb_dim.src_dim = m_stream->s_config.stream_info->dim; - job.encode_job.thumb_dim.dst_dim.width = DEFAULT_PREVIEW_WIDTH; - job.encode_job.thumb_dim.dst_dim.height = DEFAULT_PREVIEW_HEIGHT; - - /* fill in sink img param */ - job.encode_job.dst_index = 0; - - if (test_obj->metadata != NULL) { - job.encode_job.p_metadata = test_obj->metadata; - } else { - CDBG_ERROR("%s: Metadata null, not set for jpeg encoding", __func__); - } - - rc = test_obj->jpeg_ops.start_job(&job, &test_obj->current_job_id); - if ( 0 != rc ) { - free(test_obj->current_job_frames); - test_obj->current_job_frames = NULL; - } - - return rc; -} - -int createEncodingSession(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *m_stream, - mm_camera_buf_def_t *m_frame) -{ - mm_jpeg_encode_params_t encode_param; - - memset(&encode_param, 0, sizeof(mm_jpeg_encode_params_t)); - encode_param.jpeg_cb = jpeg_encode_cb; - encode_param.userdata = (void*)test_obj; - encode_param.encode_thumbnail = 0; - encode_param.quality = 85; - encode_param.color_format = MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2; - encode_param.thumb_color_format = MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2; - - /* fill in main src img encode param */ - encode_param.num_src_bufs = 1; - encode_param.src_main_buf[0].index = 0; - encode_param.src_main_buf[0].buf_size = m_frame->frame_len; - encode_param.src_main_buf[0].buf_vaddr = (uint8_t *)m_frame->buffer; - encode_param.src_main_buf[0].fd = m_frame->fd; - encode_param.src_main_buf[0].format = MM_JPEG_FMT_YUV; - encode_param.src_main_buf[0].offset = m_stream->offset; - - /* fill in sink img param */ - encode_param.num_dst_bufs = 1; - encode_param.dest_buf[0].index = 0; - encode_param.dest_buf[0].buf_size = test_obj->jpeg_buf.buf.frame_len; - encode_param.dest_buf[0].buf_vaddr = (uint8_t *)test_obj->jpeg_buf.buf.buffer; - encode_param.dest_buf[0].fd = test_obj->jpeg_buf.buf.fd; - encode_param.dest_buf[0].format = MM_JPEG_FMT_YUV; - - /* main dimension */ - encode_param.main_dim.src_dim = m_stream->s_config.stream_info->dim; - encode_param.main_dim.dst_dim = m_stream->s_config.stream_info->dim; - - return test_obj->jpeg_ops.create_session(test_obj->jpeg_hdl, - &encode_param, - &test_obj->current_jpeg_sess_id); -} - -/** mm_app_snapshot_metadata_notify_cb - * @bufs: Pointer to super buffer - * @user_data: Pointer to user data - * - * - **/ -static void mm_app_snapshot_metadata_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - int i = 0; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_buf_def_t *frame = bufs->bufs[0]; - metadata_buffer_t *pMetadata; - cam_auto_focus_data_t *focus_data; - - if (NULL == bufs || NULL == user_data) { - CDBG_ERROR("%s: bufs or user_data are not valid ", __func__); - return; - } - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - /* find meta stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_METADATA) { - p_stream = &channel->streams[i]; - break; - } - } - /* find meta frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - frame = bufs->bufs[i]; - break; - } - } - - if (NULL == p_stream) { - CDBG_ERROR("%s: cannot find metadata stream", __func__); - return; - } - if (!pme->metadata) { - /* The app will free the metadata, we don't need to bother here */ - pme->metadata = malloc(sizeof(metadata_buffer_t)); - } - memcpy(pme->metadata , frame->buffer, sizeof(metadata_buffer_t)); - - pMetadata = (metadata_buffer_t *)frame->buffer; - - if (IS_META_AVAILABLE(CAM_INTF_META_AUTOFOCUS_DATA, pMetadata)) { - focus_data = (cam_auto_focus_data_t *) - POINTER_OF_META(CAM_INTF_META_AUTOFOCUS_DATA, pMetadata); - if (focus_data->focus_state == CAM_AF_FOCUSED) { - CDBG_ERROR("%s: AutoFocus Done Call Back Received\n",__func__); - mm_camera_app_done(); - } else if (focus_data->focus_state == CAM_AF_NOT_FOCUSED) { - CDBG_ERROR("%s: AutoFocus failed\n",__func__); - mm_camera_app_done(); - } - } - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); -} - -static void mm_app_snapshot_notify_cb_raw(mm_camera_super_buf_t *bufs, - void *user_data) -{ - - int i = 0; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_buf_def_t *m_frame = NULL; - - CDBG("%s: BEGIN\n", __func__); - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - CDBG_ERROR("%s: Wrong channel id (%d)", __func__, bufs->ch_id); - goto EXIT; - } - - /* find snapshot stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_RAW) { - m_stream = &channel->streams[i]; - break; - } - } - if (NULL == m_stream) { - CDBG_ERROR("%s: cannot find snapshot stream", __func__); - goto EXIT; - } - - /* find snapshot frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == m_stream->s_id) { - m_frame = bufs->bufs[i]; - break; - } - } - if (NULL == m_frame) { - CDBG_ERROR("%s: main frame is NULL", __func__); - goto EXIT; - } - - mm_app_dump_frame(m_frame, "main", "raw", m_frame->frame_idx); - -EXIT: - for (i=0; i<bufs->num_bufs; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - bufs->bufs[i])) { - CDBG_ERROR("%s: Failed in Qbuf\n", __func__); - } - } - - mm_camera_app_done(); - - CDBG("%s: END\n", __func__); -} - -static void mm_app_snapshot_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - - int rc = 0; - int i = 0; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_buf_def_t *p_frame = NULL; - mm_camera_buf_def_t *m_frame = NULL; - - CDBG("%s: BEGIN\n", __func__); - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - CDBG_ERROR("%s: Wrong channel id (%d)", __func__, bufs->ch_id); - rc = -1; - goto error; - } - - /* find snapshot stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_SNAPSHOT) { - m_stream = &channel->streams[i]; - break; - } - } - if (NULL == m_stream) { - CDBG_ERROR("%s: cannot find snapshot stream", __func__); - rc = -1; - goto error; - } - - /* find snapshot frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == m_stream->s_id) { - m_frame = bufs->bufs[i]; - break; - } - } - if (NULL == m_frame) { - CDBG_ERROR("%s: main frame is NULL", __func__); - rc = -1; - goto error; - } - - mm_app_dump_frame(m_frame, "main", "yuv", m_frame->frame_idx); - - /* find postview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_POSTVIEW) { - p_stream = &channel->streams[i]; - break; - } - } - if (NULL != p_stream) { - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - p_frame = bufs->bufs[i]; - break; - } - } - if (NULL != p_frame) { - mm_app_dump_frame(p_frame, "postview", "yuv", p_frame->frame_idx); - } - } - - mm_app_cache_ops((mm_camera_app_meminfo_t *)m_frame->mem_info, - ION_IOC_CLEAN_INV_CACHES); - - pme->jpeg_buf.buf.buffer = (uint8_t *)malloc(m_frame->frame_len); - if ( NULL == pme->jpeg_buf.buf.buffer ) { - CDBG_ERROR("%s: error allocating jpeg output buffer", __func__); - goto error; - } - - pme->jpeg_buf.buf.frame_len = m_frame->frame_len; - /* create a new jpeg encoding session */ - rc = createEncodingSession(pme, m_stream, m_frame); - if (0 != rc) { - CDBG_ERROR("%s: error creating jpeg session", __func__); - free(pme->jpeg_buf.buf.buffer); - goto error; - } - - /* start jpeg encoding job */ - rc = encodeData(pme, bufs, m_stream); - if (0 != rc) { - CDBG_ERROR("%s: error creating jpeg session", __func__); - free(pme->jpeg_buf.buf.buffer); - goto error; - } - -error: - /* buf done rcvd frames in error case */ - if ( 0 != rc ) { - for (i=0; i<bufs->num_bufs; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - bufs->bufs[i])) { - CDBG_ERROR("%s: Failed in Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)bufs->bufs[i]->mem_info, - ION_IOC_INV_CACHES); - } - } - - CDBG("%s: END\n", __func__); -} - -mm_camera_channel_t * mm_app_add_snapshot_channel(mm_camera_test_obj_t *test_obj) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_SNAPSHOT, - NULL, - NULL, - NULL); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return NULL; - } - - stream = mm_app_add_snapshot_stream(test_obj, - channel, - mm_app_snapshot_notify_cb, - (void *)test_obj, - 1, - 1); - if (NULL == stream) { - CDBG_ERROR("%s: add snapshot stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - return channel; -} - -mm_camera_stream_t * mm_app_add_postview_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_POSTVIEW; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = DEFAULT_PREVIEW_FORMAT; - stream->s_config.stream_info->dim.width = DEFAULT_PREVIEW_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_PREVIEW_HEIGHT; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config preview stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -int mm_app_start_capture_raw(mm_camera_test_obj_t *test_obj, uint8_t num_snapshots) -{ - int32_t rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *s_main = NULL; - mm_camera_channel_attr_t attr; - - memset(&attr, 0, sizeof(mm_camera_channel_attr_t)); - attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_BURST; - attr.max_unmatched_frames = 3; - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_CAPTURE, - &attr, - mm_app_snapshot_notify_cb_raw, - test_obj); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return -MM_CAMERA_E_GENERAL; - } - - test_obj->buffer_format = DEFAULT_RAW_FORMAT; - s_main = mm_app_add_raw_stream(test_obj, - channel, - mm_app_snapshot_notify_cb_raw, - test_obj, - num_snapshots, - num_snapshots); - if (NULL == s_main) { - CDBG_ERROR("%s: add main snapshot stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start zsl failed rc=%d\n", __func__, rc); - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_capture_raw(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *ch = NULL; - int i; - - ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_CAPTURE); - - rc = mm_app_stop_channel(test_obj, ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:stop recording failed rc=%d\n", __func__, rc); - } - - for ( i = 0 ; i < ch->num_streams ; i++ ) { - mm_app_del_stream(test_obj, ch, &ch->streams[i]); - } - - mm_app_del_channel(test_obj, ch); - - return rc; -} - -int mm_app_start_capture(mm_camera_test_obj_t *test_obj, - uint8_t num_snapshots) -{ - int32_t rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *s_main = NULL; - mm_camera_stream_t *s_metadata = NULL; - mm_camera_channel_attr_t attr; - - memset(&attr, 0, sizeof(mm_camera_channel_attr_t)); - attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS; - attr.max_unmatched_frames = 3; - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_CAPTURE, - &attr, - mm_app_snapshot_notify_cb, - test_obj); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return -MM_CAMERA_E_GENERAL; - } - s_metadata = mm_app_add_metadata_stream(test_obj, - channel, - mm_app_snapshot_metadata_notify_cb, - (void *)test_obj, - CAPTURE_BUF_NUM); - if (NULL == s_metadata) { - CDBG_ERROR("%s: add metadata stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return -MM_CAMERA_E_GENERAL; - } - - s_main = mm_app_add_snapshot_stream(test_obj, - channel, - NULL, - NULL, - CAPTURE_BUF_NUM, - num_snapshots); - if (NULL == s_main) { - CDBG_ERROR("%s: add main snapshot stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start zsl failed rc=%d\n", __func__, rc); - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_stream(test_obj, channel, s_metadata); - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_capture(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *ch = NULL; - - ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_CAPTURE); - - rc = mm_app_stop_and_del_channel(test_obj, ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:stop capture channel failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_take_picture(mm_camera_test_obj_t *test_obj, uint8_t is_burst_mode) -{ - CDBG_HIGH("\nEnter %s!!\n",__func__); - int rc = MM_CAMERA_OK; - int num_snapshot = 1; - int num_rcvd_snapshot = 0; - - if (is_burst_mode) - num_snapshot = 6; - - //stop preview before starting capture. - rc = mm_app_stop_preview(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: stop preview failed before capture!!, err=%d\n",__func__, rc); - return rc; - } - - rc = mm_app_start_capture(test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_capture(), err=%d\n", __func__,rc); - return rc; - } - while (num_rcvd_snapshot < num_snapshot) { - CDBG_HIGH("\nWaiting mm_camera_app_wait !!\n"); - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_capture(), err=%d\n",__func__, rc); - return rc; - } - //start preview after capture. - rc = mm_app_start_preview(test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: start preview failed after capture!!, err=%d\n",__func__,rc); - } - return rc; -} diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c deleted file mode 100644 index 675d9c1a..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c +++ /dev/null @@ -1,864 +0,0 @@ -/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#include "mm_qcamera_socket.h" -#include "mm_qcamera_commands.h" -#include "mm_qcamera_dbg.h" - -#define IP_ADDR "127.0.0.1" -#define TUNING_CHROMATIX_PORT 55555 -#define TUNING_PREVIEW_PORT 55556 - -#define CURRENT_COMMAND_ACK_SUCCESS 1 -#define CURRENT_COMMAND_ACK_FAILURE 2 - -pthread_t eztune_thread_id; - -static int tuneserver_send_command_rsp(tuningserver_t *tsctrl, - char *send_buf, uint32_t send_len) -{ - int rc; - - /* send ack back to client upon req */ - if (send_len <= 0) { - ALOGE("%s:Invalid send len \n", __func__); - return -1; - } - if (send_buf == NULL) { - ALOGE("%s:Invalid send buf \n", __func__); - return -1; - } - - rc = send(tsctrl->clientsocket_id, send_buf, send_len, 0); - if (rc < 0) { - ALOGE("%s:RSP send returns error %s\n", __func__, strerror(errno)); - } else { - rc = 0; - } - - if (send_buf != NULL) { - free(send_buf); - send_buf = NULL; - } - return rc; -} - -static void release_eztune_prevcmd_rsp(eztune_prevcmd_rsp *pHead) -{ - if (pHead != NULL ) { - release_eztune_prevcmd_rsp((eztune_prevcmd_rsp *)pHead->next); - free(pHead); - } -} - -static int tuneserver_ack(uint16_t a, uint32_t b, tuningserver_t *tsctrl) -{ - int rc; - char ack_1[6]; - /*Ack the command here*/ - memcpy(ack_1, &a, 2); - memcpy(ack_1+2, &b, 4); - /* send echo back to client upon accept */ - rc = send(tsctrl->clientsocket_id, &ack_1, sizeof(ack_1), 0); - if (rc < 0) { - ALOGE("%s: eztune_server_run: send returns error %s\n", __func__, - strerror(errno)); - return rc; - } else if (rc < (int32_t)sizeof(ack_1)) { - /*Shouldn't hit this for packets <1K; need to re-send if we do*/ - } - return 0; -} - -static int tuneserver_send_command_ack( uint8_t ack, tuningserver_t *tsctrl) -{ - int rc; - /* send ack back to client upon req */ - rc = send(tsctrl->clientsocket_id, &ack, sizeof(ack), 0); - if (rc < 0) { - ALOGE("%s:ACK send returns error %s\n", __func__, strerror(errno)); - return rc; - } - return 0; -} - -/** tuneserver_process_command - * @tsctrl: the server control object - * - * Processes the command that the client sent - * - * Return: >=0 on success, -1 on failure. - **/ -static int32_t tuneserver_process_command(tuningserver_t *tsctrl, - char *send_buf, uint32_t send_len) -{ - tuneserver_protocol_t *p = tsctrl->proto; - int result = 0; - - CDBG("%s: Current command is %d\n", __func__, p->current_cmd); - switch (p->current_cmd) { - case TUNESERVER_GET_LIST: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - ALOGE("%s: Ack Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - result = tuneserver_process_get_list_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - ALOGE("%s: RSP processing Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - ALOGE("%s: RSP Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - break; - - case TUNESERVER_GET_PARMS: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - ALOGE("%s: Ack Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - result = tuneserver_process_get_params_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - ALOGE("%s: RSP processing Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - ALOGE("%s: RSP Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - break; - - case TUNESERVER_SET_PARMS: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - ALOGE("%s: Ack Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - result = tuneserver_process_set_params_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - ALOGE("%s: RSP processing Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - ALOGE("%s: RSP Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - break; - - case TUNESERVER_MISC_CMDS: { - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - ALOGE("%s: Ack Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - result = tuneserver_process_misc_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - ALOGE("%s: RSP processing Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - ALOGE("%s: RSP Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - break; - } - - default: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - ALOGE("%s: Ack Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - ALOGE("%s: p->current_cmd: default\n", __func__); - result = -1; - break; - } - - return result; -} - -/** tuneserver_process_client_message - * @recv_buffer: received message from the client - * @tsctrl: the server control object - * - * Processes the message from client and prepares for next - * message. - * - * Return: >=0 on success, -1 on failure. - **/ -static int32_t tuneserver_process_client_message(void *recv_buffer, - tuningserver_t *tsctrl) -{ - int rc = 0; - tuneserver_protocol_t *p = tsctrl->proto; - - switch (tsctrl->proto->next_recv_code) { - case TUNESERVER_RECV_COMMAND: - p->current_cmd = *(uint16_t *)recv_buffer; - p->next_recv_code = TUNESERVER_RECV_PAYLOAD_SIZE; - p->next_recv_len = sizeof(uint32_t); - break; - - case TUNESERVER_RECV_PAYLOAD_SIZE: - p->next_recv_code = TUNESERVER_RECV_PAYLOAD; - p->next_recv_len = *(uint32_t *)recv_buffer; - p->recv_len = p->next_recv_len; - if (p->next_recv_len > TUNESERVER_MAX_RECV) - return -1; - if (p->next_recv_len == 0) { - p->next_recv_code = TUNESERVER_RECV_RESPONSE; - p->next_recv_len = sizeof(uint32_t); - } - break; - - case TUNESERVER_RECV_PAYLOAD: - p->recv_buf = malloc(p->next_recv_len); - if (!p->recv_buf) { - ALOGE("%s:Error allocating memory for recv_buf %s\n", __func__, - strerror(errno)); - return -1; - } - memcpy(p->recv_buf, recv_buffer, p->next_recv_len); - p->next_recv_code = TUNESERVER_RECV_RESPONSE; - p->next_recv_len = sizeof(uint32_t); - /*Process current command at this point*/ - break; - - case TUNESERVER_RECV_RESPONSE: - p->next_recv_code = TUNESERVER_RECV_COMMAND; - p->next_recv_len = 2; - p->send_len = *(uint32_t *)recv_buffer; - p->send_buf = (char *)calloc(p->send_len, sizeof(char *)); - if (!p->send_buf) { - ALOGE("%s:Error allocating memory for send_buf %s\n", __func__, - strerror(errno)); - return -1; - } - rc = tuneserver_process_command(tsctrl, p->send_buf, p->send_len); - free(p->recv_buf); - p->recv_buf = NULL; - p->recv_len = 0; - break; - - default: - ALOGE("%s: p->next_recv_code: default\n", __func__); - rc = -1; - break; - } - - return rc; -} - -/** tuneserver_ack_onaccept_initprotocol - * @tsctrl: the server control object - * - * Acks a connection from the cient and sets up the - * protocol object to start receiving commands. - * - * Return: >=0 on success, -1 on failure. - **/ -static int32_t tuneserver_ack_onaccept_initprotocol(tuningserver_t *tsctrl) -{ - int32_t rc = 0; - uint32_t ack_status; - - ALOGE("%s starts\n", __func__); -/* - if(tsctrl->camera_running) { - ack_status = 1; - } else { - ack_status = 2; - } -*/ - ack_status = 1; - - rc = tuneserver_ack(1, ack_status, tsctrl); - - tsctrl->proto = malloc(sizeof(tuneserver_protocol_t)); - if (!tsctrl->proto) { - ALOGE("%s: malloc returns NULL with error %s\n", __func__, strerror(errno)); - return -1; - } - - tsctrl->proto->current_cmd = 0xFFFF; - tsctrl->proto->next_recv_code = TUNESERVER_RECV_COMMAND; - tsctrl->proto->next_recv_len = 2; - tsctrl->proto->recv_buf = NULL; - tsctrl->proto->send_buf = NULL; - - CDBG("%s end\n", __func__); - - return rc; -} - -/** tuneserver_check_status - * @tsctrl: the server control object - * - * Checks if camera is running and stops it. - * - * Return: >=0 on success, -1 on failure. - **/ -#if 0 -static void tuneserver_check_status(tuningserver_t *tsctrl) -{ - if (tsctrl->camera_running == 1) { - /*TODO: Stop camera here*/ - tuneserver_stop_cam(&tsctrl->lib_handle); - } - tsctrl->camera_running = 0; - - tuneserver_close_cam(&tsctrl->lib_handle); -} -#endif - -static int prevserver_send_command_rsp(tuningserver_t *tsctrl, - char *send_buf, uint32_t send_len) -{ - int rc; - - /* send ack back to client upon req */ - if (send_len <= 0) { - ALOGE("%s:Invalid send len \n", __func__); - return -1; - } - if (send_buf == NULL) { - ALOGE("%s:Invalid send buf \n", __func__); - return -1; - } - - rc = send(tsctrl->pr_clientsocket_id, send_buf, send_len, 0); - if (rc < 0) { - ALOGE("%s:RSP send returns error %s\n", __func__, strerror(errno)); - } else { - rc = 0; - } - if (send_buf != NULL) { - free(send_buf); - send_buf = NULL; - } - return rc; -} - -static void prevserver_init_protocol(tuningserver_t *tsctrl) -{ - tsctrl->pr_proto = malloc(sizeof(prserver_protocol_t)); - if (!tsctrl->pr_proto) { - ALOGE("%s: malloc returns NULL with error %s\n", - __func__, strerror(errno)); - return; - } - - tsctrl->pr_proto->current_cmd = 0xFFFF; - tsctrl->pr_proto->next_recv_code = TUNE_PREV_RECV_COMMAND; - tsctrl->pr_proto->next_recv_len = 2; -} - -static int32_t prevserver_process_command( - tuningserver_t *tsctrl, char **send_buf, uint32_t *send_len) -{ - prserver_protocol_t *p = tsctrl->pr_proto; - int result = 0; - eztune_prevcmd_rsp *rsp_ptr=NULL, *rspn_ptr=NULL, *head_ptr=NULL; - - CDBG("%s: Current command is %d\n", __func__, p->current_cmd); - switch (p->current_cmd) { - case TUNE_PREV_GET_INFO: - result = tuneserver_preview_getinfo(tsctrl, send_buf, send_len); - if (result < 0) { - ALOGE("%s: RSP processing Failed for cmd %d\n", __func__, - p->current_cmd); - return -1; - } - rsp_ptr = (eztune_prevcmd_rsp *)*send_buf; - if ((!rsp_ptr) || (!rsp_ptr->send_buf)) { - ALOGE("%s: RSP ptr is NULL %d\n", __func__, p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, - rsp_ptr->send_buf, rsp_ptr->send_len)) { - ALOGE("%s: RSP Failed for TUNE_PREV_GET_INFO ver cmd %d\n", __func__, - p->current_cmd); - return -1; - } - rspn_ptr = (eztune_prevcmd_rsp *)rsp_ptr->next; - if ((!rspn_ptr) || (!rspn_ptr->send_buf)) { - ALOGE("%s: RSP1 ptr is NULL %d\n", __func__, p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, - rspn_ptr->send_buf, rspn_ptr->send_len)) { - ALOGE("%s: RSP Failed for TUNE_PREV_GET_INFO caps cmd %d\n", __func__, - p->current_cmd); - return -1; - } - free(rspn_ptr); - free(rsp_ptr); - break; - - case TUNE_PREV_CH_CNK_SIZE: - result = tuneserver_preview_getchunksize(tsctrl, send_buf, send_len); - if (result < 0) { - ALOGE("%s: RSP processing Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, *send_buf, *send_len)) { - ALOGE("%s: RSP Failed for TUNE_PREV_CH_CNK_SIZE cmd %d\n", __func__, - p->current_cmd); - return -1; - } - break; - - case TUNE_PREV_GET_PREV_FRAME: - result = tuneserver_preview_getframe(tsctrl, send_buf, send_len); - if (result < 0) { - ALOGE("%s: RSP processing Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - rsp_ptr = (eztune_prevcmd_rsp *)*send_buf; - if ((!rsp_ptr) || (!rsp_ptr->send_buf)) { - ALOGE("%s: RSP ptr is NULL %d\n", __func__, p->current_cmd); - return -1; - } - head_ptr = rsp_ptr; - - while (rsp_ptr != NULL) { - if ((!rsp_ptr) || (!rsp_ptr->send_buf)) { - ALOGE("%s: RSP ptr is NULL %d\n", __func__, p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, - rsp_ptr->send_buf, rsp_ptr->send_len)) { - ALOGE("%s: RSP Failed for TUNE_PREV_GET_INFO ver cmd %d\n", __func__, - p->current_cmd); - return -1; - } - rsp_ptr = (eztune_prevcmd_rsp *)rsp_ptr->next; - } - release_eztune_prevcmd_rsp(head_ptr); - break; - - case TUNE_PREV_GET_JPG_SNAP: - case TUNE_PREV_GET_RAW_SNAP: - case TUNE_PREV_GET_RAW_PREV: - result = tuneserver_preview_unsupported(tsctrl, send_buf, send_len); - if (result < 0) { - ALOGE("%s:RSP processing Failed for cmd %d\n", __func__, p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, *send_buf, *send_len)) { - ALOGE("%s:RSP Failed for UNSUPPORTED cmd %d\n", __func__, p->current_cmd); - return -1; - } - break; - - default: - ALOGE("%s: p->current_cmd: default\n", __func__); - result = -1; - break; - } - - return result; -} - -/** previewserver_process_client_message - * @recv_buffer: received message from the client - * @tsctrl: the server control object - * - * Processes the message from client and prepares for next - * message. - * - * Return: >=0 on success, -1 on failure. - **/ -static int32_t prevserver_process_client_message(void *recv_buffer, - tuningserver_t *tsctrl) -{ - int rc = 0; - prserver_protocol_t *p = tsctrl->pr_proto; - - switch (p->next_recv_code) { - case TUNE_PREV_RECV_COMMAND: - CDBG("%s %d\n", __func__, __LINE__); - p->current_cmd = *(uint16_t *)recv_buffer; - if(p->current_cmd != TUNE_PREV_CH_CNK_SIZE) { - rc = prevserver_process_command(tsctrl, - &p->send_buf, (uint32_t *)&p->send_len); - break; - } - p->next_recv_code = TUNE_PREV_RECV_NEWCNKSIZE; - p->next_recv_len = sizeof(uint32_t); - CDBG("%s TUNE_PREV_COMMAND X\n", __func__); - break; - case TUNE_PREV_RECV_NEWCNKSIZE: - CDBG("%s %d\n", __func__, __LINE__); - p->new_cnk_size = *(uint32_t *)recv_buffer; - p->next_recv_code = TUNE_PREV_RECV_COMMAND; - p->next_recv_len = 2; - rc = prevserver_process_command(tsctrl, - &p->send_buf, (uint32_t *)&p->send_len); - break; - default: - ALOGE("%s prev_proc->next_recv_code: default\n", __func__); - rc = -1; - break; - } - - return rc; -} - -/** tunning_server_socket_listen - * @ip_addr: the ip addr to listen - * @port: the port to listen - * - * Setup a listen socket for eztune. - * - * Return: >0 on success, <=0 on failure. - **/ -int tunning_server_socket_listen(const char* ip_addr, uint16_t port) -{ - int sock_fd = -1; - struct sockaddr_in server_addr; - int result; - int option; - int socket_flag; - - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_port= htons(port); - server_addr.sin_addr.s_addr = inet_addr(ip_addr); - - if (server_addr.sin_addr.s_addr == INADDR_NONE) { - ALOGE("[ERR] %s invalid address.\n", __func__); - return -1; - } - - /* Create an AF_INET stream socket to receive incoming connection ON */ - sock_fd = socket(AF_INET, SOCK_STREAM, 0); - if (sock_fd < 0) { - ALOGE("[ERR] %s socket failed\n", __func__); - return sock_fd; - } - - // set listen socket to non-block, but why?? - socket_flag = fcntl(sock_fd, F_GETFL, 0); - fcntl(sock_fd, F_SETFL, socket_flag | O_NONBLOCK); - - /* reuse in case it is in timeout */ - option = 1; - result = setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, - &option, sizeof(option)); - - if (result < 0) { - ALOGE("eztune setsockopt failed"); - close(sock_fd); - sock_fd = -1; - return sock_fd; - } - - result = bind(sock_fd, (struct sockaddr*)&server_addr, sizeof(server_addr)); - if (result < 0) { - ALOGE("eztune socket bind failed"); - close(sock_fd); - sock_fd = -1; - return sock_fd; - } - - result = listen(sock_fd, 1); - if (result < 0) { - ALOGE("eztune socket listen failed"); - close(sock_fd); - sock_fd = -1; - return sock_fd; - } - - CDBG_HIGH("%s. sock_fd: %d, listen at port: %d\n", __func__, sock_fd, port); - - return sock_fd; -} - -/** main - * - * Creates the server, and starts waiting for - * connections/messages from a prospective - * client - * - **/ -void *eztune_proc(void *data) -{ - int server_socket = -1, client_socket = -1; - int prev_server_socket = -1, prev_client_socket = -1; - - struct sockaddr_in addr_client_inet; - socklen_t addr_client_len = sizeof(struct sockaddr_in); - int result; - fd_set tsfds; - int num_fds = 0; - int recv_bytes; - char buf[TUNESERVER_MAX_RECV]; - - mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *)data; - - ALOGE(">>> Starting tune server <<< \n"); - - // for eztune chromatix params - server_socket = tunning_server_socket_listen(IP_ADDR, TUNING_CHROMATIX_PORT); - if (server_socket <= 0) { - ALOGE("[ERR] fail to setup listen socket for eztune chromatix parms..."); - return NULL; - } - prev_server_socket = tunning_server_socket_listen(IP_ADDR, TUNING_PREVIEW_PORT); - if (prev_server_socket <= 0) { - ALOGE("[ERR] fail to setup listen socket for eztune preview...\n"); - return NULL; - } - num_fds = TUNESERVER_MAX(server_socket, prev_server_socket); - CDBG_HIGH("num_fds = %d\n", num_fds); - - do { - FD_ZERO(&tsfds); - FD_SET(server_socket, &tsfds); - FD_SET(prev_server_socket, &tsfds); - if (client_socket > 0) { - FD_SET(client_socket, &tsfds); - } - if (prev_client_socket > 0) { - FD_SET( prev_client_socket, &tsfds); - } - - /* no timeout */ - result = select(num_fds + 1, &tsfds, NULL, NULL, NULL); - if (result < 0) { - ALOGE("[ERR] select failed: %s\n", strerror(errno)); - continue; - } - - /* - ** (1) CHROMATIX SERVER - */ - if (FD_ISSET(server_socket, &tsfds)) { - CDBG("Receiving New client connection\n"); - - client_socket = accept(server_socket, - (struct sockaddr *)&addr_client_inet, &addr_client_len); - if (client_socket == -1) { - ALOGE("accept failed %s", strerror(errno)); - continue; - } - - ALOGE("accept a new connect on 55555, sd(%d)\n", client_socket); - num_fds = TUNESERVER_MAX(num_fds, client_socket); - - // open camera and get handle - this is needed to - // be able to set parameters without starting - // preview stream - /*if (!tsctrl.camera_running) { - result = tuneserver_open_cam(&tsctrl.lib_handle, &tsctrl); - if(result) { - printf("\n Camera Open Fail !!! \n"); - close(server_socket); - return EXIT_FAILURE; - } - }*/ - result = tuneserver_open_cam(lib_handle); - if(result) { - ALOGE("\n Tuning Library open failed!!!\n"); - close(server_socket); - return NULL; - } - lib_handle->tsctrl.clientsocket_id = client_socket; - if (tuneserver_ack_onaccept_initprotocol(&lib_handle->tsctrl) < 0) { - ALOGE("%s: Error while acking\n", __func__); - close(client_socket); - continue; - } - tuneserver_initialize_tuningp(lib_handle, client_socket, - lib_handle->tsctrl.proto->send_buf, lib_handle->tsctrl.proto->send_len); - } - - if (FD_ISSET(client_socket, &tsfds)) { - if (lib_handle->tsctrl.proto == NULL) { - ALOGE("%s: Cannot receive msg without connect\n", __func__); - continue; - } - - /*Receive message and process it*/ - recv_bytes = recv(client_socket, (void *)buf, - lib_handle->tsctrl.proto->next_recv_len, 0); - CDBG("Receive %d bytes \n", recv_bytes); - - if (recv_bytes == -1) { - ALOGE("%s: Receive failed with error %s\n", __func__, strerror(errno)); - //tuneserver_check_status(&tsctrl); - continue; - } else if (recv_bytes == 0) { - ALOGE("%s %d: connection has been terminated\n", __func__, __LINE__); - - tuneserver_deinitialize_tuningp(&lib_handle->tsctrl, client_socket, - lib_handle->tsctrl.proto->send_buf, - lib_handle->tsctrl.proto->send_len); - free(lib_handle->tsctrl.proto); - lib_handle->tsctrl.proto = NULL; - - close(client_socket); - client_socket = -1; - //tuneserver_check_status(&tsctrl); - } else { - CDBG("%s: Processing socket command\n", __func__); - - result = tuneserver_process_client_message(buf, &lib_handle->tsctrl); - - if (result < 0) { - ALOGE("%s %d Protocol violated\n", __func__, __LINE__); - - free(lib_handle->tsctrl.proto); - lib_handle->tsctrl.proto = NULL; - - close(client_socket); - client_socket = -1; - //tuneserver_check_status(&tsctrl); - continue; - } - } - } - - /* - ** (2) PREVIEW SERVER - */ - if (FD_ISSET(prev_server_socket, &tsfds)) { - CDBG("Receiving New Preview client connection\n"); - - prev_client_socket = accept(prev_server_socket, - (struct sockaddr *)&addr_client_inet, &addr_client_len); - if (prev_client_socket == -1) { - ALOGE("accept failed %s", strerror(errno)); - continue; - } - - lib_handle->tsctrl.pr_clientsocket_id = prev_client_socket; - - CDBG("Accepted a new connection, fd(%d)\n", prev_client_socket); - num_fds = TUNESERVER_MAX(num_fds, prev_client_socket); - - // start camera - /*if (!tsctrl.camera_running) { - result = 0; - result = tuneserver_open_cam(&tsctrl.lib_handle, &tsctrl); - if(result) { - printf("\n Camera Open Fail !!! \n"); - return EXIT_FAILURE; - } - }*/ - cam_dimension_t dim; - //dim.width = lib_handle->test_obj.buffer_width; - //dim.height = lib_handle->test_obj.buffer_height; - dim.width = DEFAULT_PREVIEW_WIDTH; - dim.height = DEFAULT_PREVIEW_HEIGHT; - - CDBG("preview dimension info: w(%d), h(%d)\n", dim.width, dim.height); - // we have to make sure that camera is running, before init connection, - // because we need to know the frame size for allocating the memory. - prevserver_init_protocol(&lib_handle->tsctrl); - - result = tuneserver_initialize_prevtuningp(lib_handle, prev_client_socket, - dim, (char **)&lib_handle->tsctrl.proto->send_buf, - &lib_handle->tsctrl.proto->send_len); - if (result < 0) { - ALOGE("tuneserver_initialize_prevtuningp error!"); - close(prev_client_socket); - prev_client_socket = -1; - } - } - - if (FD_ISSET(prev_client_socket, &tsfds)) { - recv_bytes = recv(prev_client_socket, (void *)buf, - lib_handle->tsctrl.pr_proto->next_recv_len, 0); - - CDBG("%s prev_client_socket=%d\n", __func__, prev_client_socket); - CDBG("%s next_recv_len=%d\n", __func__, *(uint16_t *)buf); - - if (recv_bytes <= 0) { - if (recv_bytes == 0) { - ALOGE("client close the connection.\n"); - } else { - ALOGE("receive error: %s\n", strerror(errno)); - } - - //tuneserver_check_status(&tsctrl); - // if recv error, we should close the connection, free the proto data, - // AND wait for a new connecton.. - // close_connection(); - // stop_camera() - // cleanup_proto_data(); - tuneserver_deinitialize_prevtuningp(&lib_handle->tsctrl, - (char **)&lib_handle->tsctrl.proto->send_buf, - &lib_handle->tsctrl.proto->send_len); - close(prev_client_socket); - prev_client_socket = -1; - } else { - result = prevserver_process_client_message((void *)buf, - &lib_handle->tsctrl); - if (result < 0) { - ALOGE("%s %d Protocol violated\n", __func__, __LINE__); - - //free(tsctrl->preivew_proto); - //free(tsctrl); - //max_fd = ezt_parms_listen_sd + 1; - tuneserver_deinitialize_prevtuningp(&lib_handle->tsctrl, - (char **)&lib_handle->tsctrl.proto->send_buf, - &lib_handle->tsctrl.proto->send_len); - close(prev_client_socket); - prev_client_socket = -1; - //tuneserver_check_status(&tsctrl); - } - //sleep(1); - } - } - } while (1); - - if (server_socket >= 0) { - close(server_socket); - } - if (client_socket >= 0) { - close(client_socket); - } - if (prev_server_socket >= 0) { - close(prev_server_socket); - } - if (prev_client_socket >= 0) { - close(prev_client_socket); - } - - return EXIT_SUCCESS; -} - -int eztune_server_start (void *lib_handle) -{ - return pthread_create(&eztune_thread_id, NULL, eztune_proc, lib_handle); -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_unit_test.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_unit_test.c deleted file mode 100644 index 51f4f5d6..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_unit_test.c +++ /dev/null @@ -1,694 +0,0 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -#define MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP 1 -#define MM_QCAMERA_APP_UTEST_OUTER_LOOP 1 -#define MM_QCAMERA_APP_UTEST_INNER_LOOP 1 -#define MM_QCAM_APP_TEST_NUM 128 - -static mm_app_tc_t mm_app_tc[MM_QCAM_APP_TEST_NUM]; - -int mm_app_tc_open_close(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying open/close cameras...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - sleep(1); - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_start_stop_preview(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop preview...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - sleep(1); - rc = mm_app_stop_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc |= mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_start_stop_zsl(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop preview...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < 1; j++) { - rc = mm_app_start_preview_zsl(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_preview_zsl() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - sleep(1); - rc = mm_app_stop_preview_zsl(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_preview_zsl() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_start_stop_video_preview(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop video preview...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_start_record_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - sleep(1); - rc = mm_app_stop_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_stop_record_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_start_stop_video_record(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop recording...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - rc = mm_app_start_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_start_record_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_record(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_start_record() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - sleep(1); - - rc = mm_app_stop_record(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_stop_record() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:start/stop record cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_stop_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_stop_record_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_start_stop_live_snapshot(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop live snapshot...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - rc = mm_app_start_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_start_record_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - rc = mm_app_start_record(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_start_record() cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_live_snapshot(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_start_live_snapshot() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - /* wait for jpeg is done */ - mm_camera_app_wait(); - - rc = mm_app_stop_live_snapshot(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_stop_live_snapshot() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:start/stop live snapshot cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_stop_record(&test_obj); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_stop_record(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_stop_record() cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - rc = mm_app_stop_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_stop_record_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_capture_raw(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - uint8_t num_snapshot = 1; - uint8_t num_rcvd_snapshot = 0; - - printf("\n Verifying raw capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_capture_raw(&test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_capture() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - while (num_rcvd_snapshot < num_snapshot) { - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture_raw(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_capture() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc |= mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_capture_regular(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - uint8_t num_snapshot = 1; - uint8_t num_rcvd_snapshot = 0; - - printf("\n Verifying capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_capture(&test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_capture() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - while (num_rcvd_snapshot < num_snapshot) { - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_capture() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_capture_burst(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - uint8_t num_snapshot = 3; - uint8_t num_rcvd_snapshot = 0; - - printf("\n Verifying capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_capture(&test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_capture() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - while (num_rcvd_snapshot < num_snapshot) { - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_capture() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_rdi_burst(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying rdi burst (3) capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_rdi(&test_obj, 3); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - sleep(1); - rc = mm_app_stop_rdi(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc2 = mm_app_close(&test_obj); - if (rc2 != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc2); - if (rc == MM_CAMERA_OK) { - rc = rc2; - } - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_tc_rdi_cont(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying rdi continuous capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_rdi(&test_obj, 0); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_start_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - sleep(1); - rc = mm_app_stop_rdi(&test_obj); - if (rc != MM_CAMERA_OK) { - CDBG_ERROR("%s: mm_app_stop_preview() cam_idx=%d, err=%d\n", - __func__, i, rc); - break; - } - } - - rc2 = mm_app_close(&test_obj); - if (rc2 != MM_CAMERA_OK) { - CDBG_ERROR("%s:mm_app_close() cam_idx=%d, err=%d\n", - __func__, i, rc2); - if (rc == MM_CAMERA_OK) { - rc = rc2; - } - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - CDBG("%s:END, rc = %d\n", __func__, rc); - return rc; -} - -int mm_app_gen_test_cases() -{ - int tc = 0; - memset(mm_app_tc, 0, sizeof(mm_app_tc)); - if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_open_close; - if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_preview; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_zsl; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_preview; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_record; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_live_snapshot; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_regular; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_burst; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_cont; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_burst; - - return tc; -} - -int mm_app_unit_test_entry(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j, tc = 0; - - tc = mm_app_gen_test_cases(); - CDBG("Running %d test cases\n",tc); - for (i = 0; i < tc; i++) { - for (j = 0; j < MM_QCAMERA_APP_UTEST_OUTER_LOOP; j++) { - mm_app_tc[i].r = mm_app_tc[i].f(cam_app); - if (mm_app_tc[i].r != MM_CAMERA_OK) { - printf("%s: test case %d (iteration %d) error = %d, abort unit testing engine!!!!\n", - __func__, i, j, mm_app_tc[i].r); - rc = mm_app_tc[i].r; - goto end; - } - } - } -end: - printf("nTOTAL_TSET_CASE = %d, NUM_TEST_RAN = %d, rc=%d\n", tc, i, rc); - return rc; -} - - - - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c deleted file mode 100644 index 136c8a83..00000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c +++ /dev/null @@ -1,256 +0,0 @@ -/* -Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -static void mm_app_video_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - char file_name[64]; - mm_camera_buf_def_t *frame = bufs->bufs[0]; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - CDBG("%s: BEGIN - length=%d, frame idx = %d\n", - __func__, frame->frame_len, frame->frame_idx); - snprintf(file_name, sizeof(file_name), "V_C%d", pme->cam->camera_handle); - mm_app_dump_frame(frame, file_name, "yuv", frame->frame_idx); - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - - CDBG("%s: END\n", __func__); -} - -mm_camera_stream_t * mm_app_add_video_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - CDBG_ERROR("%s: add stream failed\n", __func__); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_VIDEO; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = DEFAULT_VIDEO_FORMAT; - stream->s_config.stream_info->dim.width = DEFAULT_VIDEO_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_VIDEO_HEIGHT; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:config preview stream err=%d\n", __func__, rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_video_channel(mm_camera_test_obj_t *test_obj) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_VIDEO, - NULL, - NULL, - NULL); - if (NULL == channel) { - CDBG_ERROR("%s: add channel failed", __func__); - return NULL; - } - - stream = mm_app_add_video_stream(test_obj, - channel, - mm_app_video_notify_cb, - (void *)test_obj, - 1); - if (NULL == stream) { - CDBG_ERROR("%s: add video stream failed\n", __func__); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - return channel; -} - -int mm_app_start_record_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *p_ch = NULL; - mm_camera_channel_t *v_ch = NULL; - mm_camera_channel_t *s_ch = NULL; - - p_ch = mm_app_add_preview_channel(test_obj); - if (NULL == p_ch) { - CDBG_ERROR("%s: add preview channel failed", __func__); - return -MM_CAMERA_E_GENERAL; - } - - v_ch = mm_app_add_video_channel(test_obj); - if (NULL == v_ch) { - CDBG_ERROR("%s: add video channel failed", __func__); - mm_app_del_channel(test_obj, p_ch); - return -MM_CAMERA_E_GENERAL; - } - - s_ch = mm_app_add_snapshot_channel(test_obj); - if (NULL == s_ch) { - CDBG_ERROR("%s: add snapshot channel failed", __func__); - mm_app_del_channel(test_obj, p_ch); - mm_app_del_channel(test_obj, v_ch); - return -MM_CAMERA_E_GENERAL; - } - - rc = mm_app_start_channel(test_obj, p_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start preview failed rc=%d\n", __func__, rc); - mm_app_del_channel(test_obj, p_ch); - mm_app_del_channel(test_obj, v_ch); - mm_app_del_channel(test_obj, s_ch); - return rc; - } - - return rc; -} - -int mm_app_stop_record_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *p_ch = NULL; - mm_camera_channel_t *v_ch = NULL; - mm_camera_channel_t *s_ch = NULL; - - p_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_PREVIEW); - v_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_VIDEO); - s_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_SNAPSHOT); - - rc = mm_app_stop_and_del_channel(test_obj, p_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc); - } - - rc = mm_app_stop_and_del_channel(test_obj, v_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc); - } - - rc = mm_app_stop_and_del_channel(test_obj, s_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_start_record(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *v_ch = NULL; - - v_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_VIDEO); - - rc = mm_app_start_channel(test_obj, v_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start recording failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_stop_record(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *v_ch = NULL; - - v_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_VIDEO); - - rc = mm_app_stop_channel(test_obj, v_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:stop recording failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_start_live_snapshot(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *s_ch = NULL; - - s_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_SNAPSHOT); - - rc = mm_app_start_channel(test_obj, s_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:start recording failed rc=%d\n", __func__, rc); - } - - return rc; -} - -int mm_app_stop_live_snapshot(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *s_ch = NULL; - - s_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_SNAPSHOT); - - rc = mm_app_stop_channel(test_obj, s_ch); - if (MM_CAMERA_OK != rc) { - CDBG_ERROR("%s:stop recording failed rc=%d\n", __func__, rc); - } - - return rc; -} diff --git a/camera/QCamera2/stack/mm-jpeg-interface/test/Android.mk b/camera/QCamera2/stack/mm-jpeg-interface/test/Android.mk deleted file mode 100644 index ebe2e26e..00000000 --- a/camera/QCamera2/stack/mm-jpeg-interface/test/Android.mk +++ /dev/null @@ -1,83 +0,0 @@ -#encoder int test -OLD_LOCAL_PATH := $(LOCAL_PATH) -MM_JPEG_TEST_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_PATH := $(MM_JPEG_TEST_PATH) -LOCAL_MODULE_TAGS := optional - -LOCAL_CFLAGS := \ - -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID \ - -Werror -Wno-unused-parameter \ - -D_ANDROID_ \ - -DUSE_ION - -OMX_HEADER_DIR := frameworks/native/include/media/openmax -OMX_CORE_DIR := device/moto/shamu/camera/mm-image-codec - -LOCAL_C_INCLUDES := $(MM_JPEG_TEST_PATH) -LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../inc -LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../../common -LOCAL_C_INCLUDES += $(OMX_HEADER_DIR) -LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qexif -LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qomx_core - -LOCAL_HEADER_LIBRARIES := generated_kernel_headers - -LOCAL_SRC_FILES := mm_jpeg_test.c - -LOCAL_32_BIT_ONLY := true - -LOCAL_MODULE := \ - mm-jpeg-interface-test - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libdl \ - libmmjpeg_interface - -include $(BUILD_EXECUTABLE) - - - -#decoder int test - -include $(CLEAR_VARS) -LOCAL_PATH := $(MM_JPEG_TEST_PATH) -LOCAL_MODULE_TAGS := optional - -LOCAL_CFLAGS := \ - -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID \ - -Werror \ - -Wno-unused-parameter \ - -D_ANDROID_ \ - -DUSE_ION - -OMX_HEADER_DIR := frameworks/native/include/media/openmax -OMX_CORE_DIR := device/moto/shamu/camera/mm-image-codec - -LOCAL_C_INCLUDES := \ - $(MM_JPEG_TEST_PATH) \ - $(MM_JPEG_TEST_PATH)/../inc \ - $(MM_JPEG_TEST_PATH)/../../common \ - $(OMX_HEADER_DIR) \ - $(OMX_CORE_DIR)/qexif \ - $(OMX_CORE_DIR)/qomx_core - -LOCAL_HEADER_LIBRARIES := generated_kernel_headers - -LOCAL_SRC_FILES := mm_jpegdec_test.c - -LOCAL_32_BIT_ONLY := true -LOCAL_MODULE := mm-jpegdec-interface-test - -LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libdl \ - libmmjpeg_interface - -include $(BUILD_EXECUTABLE) - -LOCAL_PATH := $(OLD_LOCAL_PATH) diff --git a/camera/QCamera2/stack/mm-jpeg-interface/test/mm_jpeg_test.c b/camera/QCamera2/stack/mm-jpeg-interface/test/mm_jpeg_test.c deleted file mode 100644 index 97ac22c2..00000000 --- a/camera/QCamera2/stack/mm-jpeg-interface/test/mm_jpeg_test.c +++ /dev/null @@ -1,656 +0,0 @@ -/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "mm_jpeg_interface.h" -#include "mm_jpeg_ionbuf.h" -#include <sys/time.h> -#include <stdlib.h> - -#define MAX_NUM_BUFS (12) - -/** DUMP_TO_FILE: - * @filename: file name - * @p_addr: address of the buffer - * @len: buffer length - * - * dump the image to the file - **/ -#define DUMP_TO_FILE(filename, p_addr, len) ({ \ - FILE *fp = fopen(filename, "w+"); \ - if (fp) { \ - fwrite(p_addr, 1, len, fp); \ - fclose(fp); \ - } else { \ - CDBG_ERROR("%s:%d] cannot dump image", __func__, __LINE__); \ - } \ -}) - -static int g_count = 1, g_i; - -typedef struct { - mm_jpeg_color_format fmt; - float mult; - const char *str; -} mm_jpeg_intf_test_colfmt_t; - -typedef struct { - char *filename; - int width; - int height; - char *out_filename; - int burst_mode; - int min_out_bufs; - mm_jpeg_intf_test_colfmt_t col_fmt; - int encode_thumbnail; - int tmb_width; - int tmb_height; - int main_quality; - int thumb_quality; -} jpeg_test_input_t; - -/* Static constants */ -/* default Luma Qtable */ -const uint8_t DEFAULT_QTABLE_0[QUANT_SIZE] = { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68, 109, 103, 77, - 24, 35, 55, 64, 81, 104, 113, 92, - 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99 -}; - -/* default Chroma Qtable */ -const uint8_t DEFAULT_QTABLE_1[QUANT_SIZE] = { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 -}; - -typedef struct { - char *filename[MAX_NUM_BUFS]; - int width; - int height; - char *out_filename[MAX_NUM_BUFS]; - pthread_mutex_t lock; - pthread_cond_t cond; - buffer_t input[MAX_NUM_BUFS]; - buffer_t output[MAX_NUM_BUFS]; - int use_ion; - uint32_t handle; - mm_jpeg_ops_t ops; - uint32_t job_id[MAX_NUM_BUFS]; - mm_jpeg_encode_params_t params; - mm_jpeg_job_t job; - uint32_t session_id; - uint32_t num_bufs; - int min_out_bufs; - uint32_t buf_filled_len[MAX_NUM_BUFS]; -} mm_jpeg_intf_test_t; - - - -static const mm_jpeg_intf_test_colfmt_t color_formats[] = -{ - { MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2, 1.5, "YCRCBLP_H2V2" }, - { MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V2, 1.5, "YCBCRLP_H2V2" }, - { MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V1, 2.0, "YCRCBLP_H2V1" }, - { MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V1, 2.0, "YCBCRLP_H2V1" }, - { MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V2, 2.0, "YCRCBLP_H1V2" }, - { MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V2, 2.0, "YCBCRLP_H1V2" }, - { MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V1, 3.0, "YCRCBLP_H1V1" }, - { MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V1, 3.0, "YCBCRLP_H1V1" } -}; - -static jpeg_test_input_t jpeg_input[] = { - {"/data/test_1.yuv", 4000, 3008, "/data/test_1.jpg", 0, 0, - { MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2, 1.5, "YCRCBLP_H2V2" }, 0, 320, 240, 80, 80} -}; - -static void mm_jpeg_encode_callback(jpeg_job_status_t status, - uint32_t client_hdl, - uint32_t jobId, - mm_jpeg_output_t *p_output, - void *userData) -{ - mm_jpeg_intf_test_t *p_obj = (mm_jpeg_intf_test_t *)userData; - - pthread_mutex_lock(&p_obj->lock); - - if (status == JPEG_JOB_STATUS_ERROR) { - CDBG_ERROR("%s:%d] Encode error", __func__, __LINE__); - } else { - int i = 0; - for (i = 0; p_obj->job_id[i] && (jobId != p_obj->job_id[i]); i++) - ; - if (!p_obj->job_id[i]) { - CDBG_ERROR("%s:%d] Cannot find job ID!!!", __func__, __LINE__); - goto error; - } - CDBG_ERROR("%s:%d] Encode success addr %p len %d idx %d", - __func__, __LINE__, p_output->buf_vaddr, p_output->buf_filled_len, i); - - p_obj->buf_filled_len[i] = p_output->buf_filled_len; - if (p_obj->min_out_bufs) { - CDBG_ERROR("%s:%d] Saving file%s addr %p len %d", - __func__, __LINE__, p_obj->out_filename[i], - p_output->buf_vaddr, p_output->buf_filled_len); - - DUMP_TO_FILE(p_obj->out_filename[i], p_output->buf_vaddr, - p_output->buf_filled_len); - } - } - g_i++; - -error: - - if (g_i >= g_count) { - CDBG_ERROR("%s:%d] Signal the thread", __func__, __LINE__); - pthread_cond_signal(&p_obj->cond); - } - pthread_mutex_unlock(&p_obj->lock); -} - -int mm_jpeg_test_alloc(buffer_t *p_buffer, int use_pmem) -{ - int ret = 0; - /*Allocate buffers*/ - if (use_pmem) { - p_buffer->addr = (uint8_t *)buffer_allocate(p_buffer, 0); - if (NULL == p_buffer->addr) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - } else { - /* Allocate heap memory */ - p_buffer->addr = (uint8_t *)malloc(p_buffer->size); - if (NULL == p_buffer->addr) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - } - return ret; -} - -void mm_jpeg_test_free(buffer_t *p_buffer) -{ - if (p_buffer->addr == NULL) - return; - - if (p_buffer->p_pmem_fd > 0) - buffer_deallocate(p_buffer); - else - free(p_buffer->addr); - - memset(p_buffer, 0x0, sizeof(buffer_t)); -} - -int mm_jpeg_test_read(mm_jpeg_intf_test_t *p_obj, int idx) -{ - FILE *fp = NULL; - int file_size = 0; - fp = fopen(p_obj->filename[idx], "rb"); - if (!fp) { - CDBG_ERROR("%s:%d] error", __func__, __LINE__); - return -1; - } - fseek(fp, 0, SEEK_END); - file_size = ftell(fp); - fseek(fp, 0, SEEK_SET); - CDBG_ERROR("%s:%d] input file size is %d buf_size %ld", - __func__, __LINE__, file_size, p_obj->input[idx].size); - - if (p_obj->input[idx].size > file_size) { - CDBG_ERROR("%s:%d] error", __func__, __LINE__); - fclose(fp); - return -1; - } - fread(p_obj->input[idx].addr, 1, p_obj->input[idx].size, fp); - fclose(fp); - return 0; -} - -static int encode_init(jpeg_test_input_t *p_input, mm_jpeg_intf_test_t *p_obj) -{ - int rc = -1; - int size = p_input->width * p_input->height; - mm_jpeg_encode_params_t *p_params = &p_obj->params; - mm_jpeg_encode_job_t *p_job_params = &p_obj->job.encode_job; - int i = 0; - int burst_mode = p_input->burst_mode; - jpeg_test_input_t *p_in = p_input; - do { - p_obj->filename[i] = p_in->filename; - p_obj->width = p_input->width; - p_obj->height = p_input->height; - p_obj->out_filename[i] = p_in->out_filename; - p_obj->use_ion = 1; - p_obj->min_out_bufs = p_input->min_out_bufs; - - /* allocate buffers */ - p_obj->input[i].size = size * p_input->col_fmt.mult; - rc = mm_jpeg_test_alloc(&p_obj->input[i], p_obj->use_ion); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - - - rc = mm_jpeg_test_read(p_obj, i); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - - /* src buffer config*/ - p_params->src_main_buf[i].buf_size = p_obj->input[i].size; - p_params->src_main_buf[i].buf_vaddr = p_obj->input[i].addr; - p_params->src_main_buf[i].fd = p_obj->input[i].p_pmem_fd; - p_params->src_main_buf[i].index = i; - p_params->src_main_buf[i].format = MM_JPEG_FMT_YUV; - p_params->src_main_buf[i].offset.mp[0].len = size; - p_params->src_main_buf[i].offset.mp[0].stride = p_input->width; - p_params->src_main_buf[i].offset.mp[0].scanline = p_input->height; - p_params->src_main_buf[i].offset.mp[1].len = size >> 1; - - /* src buffer config*/ - p_params->src_thumb_buf[i].buf_size = p_obj->input[i].size; - p_params->src_thumb_buf[i].buf_vaddr = p_obj->input[i].addr; - p_params->src_thumb_buf[i].fd = p_obj->input[i].p_pmem_fd; - p_params->src_thumb_buf[i].index = i; - p_params->src_thumb_buf[i].format = MM_JPEG_FMT_YUV; - p_params->src_thumb_buf[i].offset.mp[0].len = size; - p_params->src_thumb_buf[i].offset.mp[0].stride = p_input->width; - p_params->src_thumb_buf[i].offset.mp[0].scanline = p_input->height; - p_params->src_thumb_buf[i].offset.mp[1].len = size >> 1; - - - i++; - } while((++p_in)->filename); - - p_obj->num_bufs = i; - - pthread_mutex_init(&p_obj->lock, NULL); - pthread_cond_init(&p_obj->cond, NULL); - - - /* set encode parameters */ - p_params->jpeg_cb = mm_jpeg_encode_callback; - p_params->userdata = p_obj; - p_params->color_format = p_input->col_fmt.fmt; - p_params->thumb_color_format = p_input->col_fmt.fmt; - - if (p_obj->min_out_bufs) { - p_params->num_dst_bufs = 2; - } else { - p_params->num_dst_bufs = p_obj->num_bufs; - } - - for (i = 0; i < (int)p_params->num_dst_bufs; i++) { - p_obj->output[i].size = size * 3/2; - rc = mm_jpeg_test_alloc(&p_obj->output[i], 0); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - /* dest buffer config */ - p_params->dest_buf[i].buf_size = p_obj->output[i].size; - p_params->dest_buf[i].buf_vaddr = p_obj->output[i].addr; - p_params->dest_buf[i].fd = p_obj->output[i].p_pmem_fd; - p_params->dest_buf[i].index = i; - } - - - p_params->num_src_bufs = p_obj->num_bufs; - p_params->num_tmb_bufs = 0; - g_count = p_params->num_src_bufs; - - p_params->encode_thumbnail = p_input->encode_thumbnail; - if (p_params->encode_thumbnail) { - p_params->num_tmb_bufs = p_obj->num_bufs; - } - p_params->quality = p_input->main_quality; - p_params->thumb_quality = p_input->thumb_quality; - - p_job_params->dst_index = 0; - p_job_params->src_index = 0; - p_job_params->rotation = 0; - - /* main dimension */ - p_job_params->main_dim.src_dim.width = p_obj->width; - p_job_params->main_dim.src_dim.height = p_obj->height; - p_job_params->main_dim.dst_dim.width = p_obj->width; - p_job_params->main_dim.dst_dim.height = p_obj->height; - p_job_params->main_dim.crop.top = 0; - p_job_params->main_dim.crop.left = 0; - p_job_params->main_dim.crop.width = p_obj->width; - p_job_params->main_dim.crop.height = p_obj->height; - - p_params->main_dim = p_job_params->main_dim; - - /* thumb dimension */ - p_job_params->thumb_dim.src_dim.width = p_obj->width; - p_job_params->thumb_dim.src_dim.height = p_obj->height; - p_job_params->thumb_dim.dst_dim.width = p_input->tmb_width; - p_job_params->thumb_dim.dst_dim.height = p_input->tmb_height; - p_job_params->thumb_dim.crop.top = 0; - p_job_params->thumb_dim.crop.left = 0; - p_job_params->thumb_dim.crop.width = 0; - p_job_params->thumb_dim.crop.height = 0; - - p_params->thumb_dim = p_job_params->thumb_dim; - - p_job_params->exif_info.numOfEntries = 0; - p_params->burst_mode = burst_mode; - - /* Qtable */ - p_job_params->qtable[0].eQuantizationTable = - OMX_IMAGE_QuantizationTableLuma; - p_job_params->qtable[1].eQuantizationTable = - OMX_IMAGE_QuantizationTableChroma; - p_job_params->qtable_set[0] = 1; - p_job_params->qtable_set[1] = 1; - - for (i = 0; i < QUANT_SIZE; i++) { - p_job_params->qtable[0].nQuantizationMatrix[i] = DEFAULT_QTABLE_0[i]; - p_job_params->qtable[1].nQuantizationMatrix[i] = DEFAULT_QTABLE_1[i]; - } - - return 0; -} - -static int encode_test(jpeg_test_input_t *p_input) -{ - int rc = 0; - mm_jpeg_intf_test_t jpeg_obj; - unsigned int i = 0; - - memset(&jpeg_obj, 0x0, sizeof(jpeg_obj)); - rc = encode_init(p_input, &jpeg_obj); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - - mm_dimension pic_size; - memset(&pic_size, 0, sizeof(mm_dimension)); - pic_size.w = p_input->width; - pic_size.h = p_input->height; - - jpeg_obj.handle = jpeg_open(&jpeg_obj.ops, pic_size); - if (jpeg_obj.handle == 0) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto end; - } - - rc = jpeg_obj.ops.create_session(jpeg_obj.handle, &jpeg_obj.params, - &jpeg_obj.job.encode_job.session_id); - if (jpeg_obj.job.encode_job.session_id == 0) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto end; - } - - for (i = 0; i < jpeg_obj.num_bufs; i++) { - jpeg_obj.job.job_type = JPEG_JOB_TYPE_ENCODE; - jpeg_obj.job.encode_job.src_index = i; - jpeg_obj.job.encode_job.dst_index = i; - jpeg_obj.job.encode_job.thumb_index = i; - - if (jpeg_obj.params.burst_mode && jpeg_obj.min_out_bufs) { - jpeg_obj.job.encode_job.dst_index = -1; - } - - rc = jpeg_obj.ops.start_job(&jpeg_obj.job, &jpeg_obj.job_id[i]); - - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto end; - } - } - jpeg_obj.job_id[i] = 0; - - /* - usleep(5); - jpeg_obj.ops.abort_job(jpeg_obj.job_id[0]); - */ - pthread_mutex_lock(&jpeg_obj.lock); - pthread_cond_wait(&jpeg_obj.cond, &jpeg_obj.lock); - pthread_mutex_unlock(&jpeg_obj.lock); - - - jpeg_obj.ops.destroy_session(jpeg_obj.job.encode_job.session_id); - jpeg_obj.ops.close(jpeg_obj.handle); - -end: - for (i = 0; i < jpeg_obj.num_bufs; i++) { - if (!jpeg_obj.min_out_bufs) { - // Save output files - CDBG_ERROR("%s:%d] Saving file%s addr %p len %d", - __func__, __LINE__,jpeg_obj.out_filename[i], - jpeg_obj.output[i].addr, jpeg_obj.buf_filled_len[i]); - - DUMP_TO_FILE(jpeg_obj.out_filename[i], jpeg_obj.output[i].addr, - jpeg_obj.buf_filled_len[i]); - } - mm_jpeg_test_free(&jpeg_obj.input[i]); - mm_jpeg_test_free(&jpeg_obj.output[i]); - } - return 0; -} - -#define MAX_FILE_CNT (20) -static int mm_jpeg_test_get_input(int argc, char *argv[], - jpeg_test_input_t *p_test) -{ - int c, in_file_cnt = 0, out_file_cnt = 0, i; - int idx = 0; - jpeg_test_input_t *p_test_base = p_test; - - char *in_files[MAX_FILE_CNT]; - char *out_files[MAX_FILE_CNT]; - - while ((c = getopt(argc, argv, "-I:O:W:H:F:BTx:y:Q:q:")) != -1) { - switch (c) { - case 'B': - fprintf(stderr, "%-25s\n", "Using burst mode"); - p_test->burst_mode = 1; - break; - case 'I': - for (idx = optind - 1; idx < argc; idx++) { - if (argv[idx][0] == '-') { - break; - } - in_files[in_file_cnt++] = argv[idx]; - } - optind = idx -1; - - break; - case 'O': - for (idx = optind - 1; idx < argc; idx++) { - if (argv[idx][0] == '-') { - break; - } - out_files[out_file_cnt++] = argv[idx]; - } - optind = idx -1; - - break; - case 'W': - p_test->width = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Width: ", p_test->width); - break; - case 'H': - p_test->height = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Height: ", p_test->height); - break; - case 'F': - p_test->col_fmt = color_formats[atoi(optarg)]; - fprintf(stderr, "%-25s%s\n", "Format: ", p_test->col_fmt.str); - break; - case 'M': - p_test->min_out_bufs = 1; - fprintf(stderr, "%-25s\n", "Using minimum number of output buffers"); - break; - case 'T': - p_test->encode_thumbnail = 1; - fprintf(stderr, "%-25s\n", "Encode thumbnail"); - break; - case 'x': - p_test->tmb_width = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Tmb Width: ", p_test->tmb_width); - break; - case 'y': - p_test->tmb_height = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Tmb Height: ", p_test->tmb_height); - break; - case 'Q': - p_test->main_quality = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Main quality: ", p_test->main_quality); - break; - case 'q': - p_test->thumb_quality = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Thumb quality: ", p_test->thumb_quality); - break; - default:; - } - } - fprintf(stderr, "Infiles: %d Outfiles: %d\n", in_file_cnt, out_file_cnt); - - if (in_file_cnt > out_file_cnt) { - fprintf(stderr, "%-25s\n", "Insufficient number of output files!"); - return 1; - } - - // Discard the extra out files - out_file_cnt = in_file_cnt; - - p_test = realloc(p_test, (in_file_cnt + 1) * sizeof(*p_test)); - if (!p_test) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return 1; - } - memset(p_test+1, 0, (in_file_cnt) * sizeof(*p_test)); - - for (i = 0; i < in_file_cnt; i++, p_test++) { - memcpy(p_test, p_test_base, sizeof(*p_test)); - p_test->filename = in_files[i]; - p_test->out_filename = out_files[i]; - fprintf(stderr, "Inf: %s Outf: %s\n", in_files[i], out_files[i]); - } - - - return 0; -} - -static void mm_jpeg_test_print_usage() -{ - fprintf(stderr, "Usage: program_name [options]\n"); - fprintf(stderr, "Mandatory options:\n"); - fprintf(stderr, " -I FILE1 [FILE2] [FILEN]\tList of input files\n"); - fprintf(stderr, " -O FILE1 [FILE2] [FILEN]\tList of output files\n"); - fprintf(stderr, " -W WIDTH\t\tOutput image width\n"); - fprintf(stderr, " -H HEIGHT\t\tOutput image height\n"); - fprintf(stderr, " -F \t\tColor format: \n"); - fprintf(stderr, "\t\t\t\t%s (0), %s (1), %s (2) %s (3)\n" - "\t\t\t\t%s (4), %s (5), %s (6) %s (7)\n ", - color_formats[0].str, color_formats[1].str, - color_formats[2].str, color_formats[3].str, - color_formats[4].str, color_formats[5].str, - color_formats[6].str, color_formats[7].str); - fprintf(stderr, "Optional:\n"); - fprintf(stderr, " -T \t\Encode thumbnail\n"); - fprintf(stderr, " -x TMB_WIDTH\t\tThumbnail width\n"); - fprintf(stderr, " -y TMB_HEIGHT\t\tThumbnail height\n"); - fprintf(stderr, " -Q MAIN_QUALITY\t\tMain image quality\n"); - fprintf(stderr, " -q TMB_QUALITY\t\tThumbnail image quality\n"); - fprintf(stderr, " -B \t\tBurst mode. Utilize both encoder engines on" - "supported targets\n"); - fprintf(stderr, " -M \t\tUse minimum number of output buffers \n"); - fprintf(stderr, "\n"); -} - -/** main: - * - * Arguments: - * @argc - * @argv - * - * Return: - * 0 or -ve values - * - * Description: - * main function - * - **/ -int main(int argc, char* argv[]) -{ - jpeg_test_input_t *p_test_input; - int ret = 0; - if (argc > 1) { - p_test_input = calloc(2, sizeof(*p_test_input)); - if (!p_test_input) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto exit; - } - memcpy(p_test_input, &jpeg_input[0], sizeof(*p_test_input)); - ret = mm_jpeg_test_get_input(argc, argv, p_test_input); - if (ret) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto exit; - } - } else { - mm_jpeg_test_print_usage(); - return 1; - } - ret = encode_test(p_test_input); - -exit: - if (!ret) { - fprintf(stderr, "%-25s\n", "Success!"); - } else { - fprintf(stderr, "%-25s\n", "Fail!"); - } - - if (argc > 1) { - if (p_test_input) { - free(p_test_input); - p_test_input = NULL; - } - } - - return ret; -} - - diff --git a/camera/QCamera2/stack/mm-jpeg-interface/test/mm_jpegdec_test.c b/camera/QCamera2/stack/mm-jpeg-interface/test/mm_jpegdec_test.c deleted file mode 100644 index 982b9cd7..00000000 --- a/camera/QCamera2/stack/mm-jpeg-interface/test/mm_jpegdec_test.c +++ /dev/null @@ -1,469 +0,0 @@ -/* Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "mm_jpeg_interface.h" -#include "mm_jpeg_ionbuf.h" -#include <sys/time.h> -#include <stdlib.h> - -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define CLAMP(x, min, max) x = MIN(MAX((x), (min)), (max)) - -#define TIME_IN_US(r) ((uint64_t)r.tv_sec * 1000000LL + r.tv_usec) -struct timeval dtime[2]; - - -/** DUMP_TO_FILE: - * @filename: file name - * @p_addr: address of the buffer - * @len: buffer length - * - * dump the image to the file - **/ -#define DUMP_TO_FILE(filename, p_addr, len) ({ \ - FILE *fp = fopen(filename, "w+"); \ - if (fp) { \ - fwrite(p_addr, 1, len, fp); \ - fclose(fp); \ - } else { \ - CDBG_ERROR("%s:%d] cannot dump image", __func__, __LINE__); \ - } \ -}) - -static int g_count = 1, g_i; - -typedef struct { - char *filename; - int width; - int height; - char *out_filename; - int format; -} jpeg_test_input_t; - -typedef struct { - char *filename; - int width; - int height; - char *out_filename; - pthread_mutex_t lock; - pthread_cond_t cond; - buffer_t input; - buffer_t output; - int use_ion; - uint32_t handle; - mm_jpegdec_ops_t ops; - uint32_t job_id[5]; - mm_jpeg_decode_params_t params; - mm_jpeg_job_t job; - uint32_t session_id; -} mm_jpegdec_intf_test_t; - -typedef struct { - char *format_str; - int eColorFormat; -} mm_jpegdec_col_fmt_t; - -#define ARR_SZ(a) (sizeof(a)/sizeof(a[0])) - -static const mm_jpegdec_col_fmt_t col_formats[] = -{ - { "YCRCBLP_H2V2", (int)MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2 }, - { "YCBCRLP_H2V2", (int)MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V2 }, - { "YCRCBLP_H2V1", (int)MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V1 }, - { "YCBCRLP_H2V1", (int)MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V1 }, - { "YCRCBLP_H1V2", (int)MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V2 }, - { "YCBCRLP_H1V2", (int)MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V2 }, - { "YCRCBLP_H1V1", (int)MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V1 }, - { "YCBCRLP_H1V1", (int)MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V1 } -}; - -static void mm_jpegdec_decode_callback(jpeg_job_status_t status, - uint32_t client_hdl, - uint32_t jobId, - mm_jpeg_output_t *p_output, - void *userData) -{ - mm_jpegdec_intf_test_t *p_obj = (mm_jpegdec_intf_test_t *)userData; - - if (status == JPEG_JOB_STATUS_ERROR) { - CDBG_ERROR("%s:%d] Decode error", __func__, __LINE__); - } else { - gettimeofday(&dtime[1], NULL); - CDBG_ERROR("%s:%d] Decode time %llu ms", - __func__, __LINE__, ((TIME_IN_US(dtime[1]) - TIME_IN_US(dtime[0]))/1000)); - - CDBG_ERROR("%s:%d] Decode success file%s addr %p len %d", - __func__, __LINE__, p_obj->out_filename, - p_output->buf_vaddr, p_output->buf_filled_len); - DUMP_TO_FILE(p_obj->out_filename, p_output->buf_vaddr, p_output->buf_filled_len); - } - g_i++; - if (g_i >= g_count) { - CDBG_ERROR("%s:%d] Signal the thread", __func__, __LINE__); - pthread_cond_signal(&p_obj->cond); - } -} - -int mm_jpegdec_test_alloc(buffer_t *p_buffer, int use_pmem) -{ - int ret = 0; - /*Allocate buffers*/ - if (use_pmem) { - p_buffer->addr = (uint8_t *)buffer_allocate(p_buffer, 0); - if (NULL == p_buffer->addr) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - } else { - /* Allocate heap memory */ - p_buffer->addr = (uint8_t *)malloc(p_buffer->size); - if (NULL == p_buffer->addr) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - } - return ret; -} - -void mm_jpegdec_test_free(buffer_t *p_buffer) -{ - if (p_buffer->addr == NULL) - return; - - if (p_buffer->p_pmem_fd > 0) - buffer_deallocate(p_buffer); - else - free(p_buffer->addr); - - memset(p_buffer, 0x0, sizeof(buffer_t)); -} - -int mm_jpegdec_test_read(mm_jpegdec_intf_test_t *p_obj) -{ - int rc = 0; - FILE *fp = NULL; - int file_size = 0; - fp = fopen(p_obj->filename, "rb"); - if (!fp) { - CDBG_ERROR("%s:%d] error", __func__, __LINE__); - return -1; - } - fseek(fp, 0, SEEK_END); - file_size = ftell(fp); - fseek(fp, 0, SEEK_SET); - - CDBG_ERROR("%s:%d] input file size is %d", - __func__, __LINE__, file_size); - - p_obj->input.size = file_size; - - /* allocate buffers */ - rc = mm_jpegdec_test_alloc(&p_obj->input, p_obj->use_ion); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - - fread(p_obj->input.addr, 1, p_obj->input.size, fp); - fclose(fp); - return 0; -} - -void chromaScale(mm_jpeg_color_format format, float *cScale) -{ - float scale; - - switch(format) { - case MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2: - case MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V2: - scale = 1.5; - break; - case MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V1: - case MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V1: - case MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V2: - case MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V2: - scale = 2.0; - break; - case MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V1: - case MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V1: - scale = 3.0; - break; - case MM_JPEG_COLOR_FORMAT_MONOCHROME: - scale = 1.0; - break; - default: - scale = 0; - CDBG_ERROR("%s:%d] color format Error",__func__, __LINE__); - } - - *cScale = scale; -} - -static int decode_init(jpeg_test_input_t *p_input, mm_jpegdec_intf_test_t *p_obj) -{ - int rc = -1; - int size = CEILING16(p_input->width) * CEILING16(p_input->height); - float cScale; - mm_jpeg_decode_params_t *p_params = &p_obj->params; - mm_jpeg_decode_job_t *p_job_params = &p_obj->job.decode_job; - - p_obj->filename = p_input->filename; - p_obj->width = p_input->width; - p_obj->height = p_input->height; - p_obj->out_filename = p_input->out_filename; - p_obj->use_ion = 1; - - pthread_mutex_init(&p_obj->lock, NULL); - pthread_cond_init(&p_obj->cond, NULL); - - chromaScale(p_input->format, &cScale); - p_obj->output.size = size * cScale; - rc = mm_jpegdec_test_alloc(&p_obj->output, p_obj->use_ion); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - - rc = mm_jpegdec_test_read(p_obj); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - - /* set encode parameters */ - p_params->jpeg_cb = mm_jpegdec_decode_callback; - p_params->userdata = p_obj; - p_params->color_format = p_input->format; - - /* dest buffer config */ - p_params->dest_buf[0].buf_size = p_obj->output.size; - p_params->dest_buf[0].buf_vaddr = p_obj->output.addr; - p_params->dest_buf[0].fd = p_obj->output.p_pmem_fd; - p_params->dest_buf[0].format = MM_JPEG_FMT_YUV; - p_params->dest_buf[0].offset.mp[0].len = size; - p_params->dest_buf[0].offset.mp[1].len = size * (cScale-1.0); - p_params->dest_buf[0].offset.mp[0].stride = CEILING16(p_input->width); - p_params->dest_buf[0].offset.mp[0].scanline = CEILING16(p_input->height); - p_params->dest_buf[0].offset.mp[1].stride = CEILING16(p_input->width); - p_params->dest_buf[0].offset.mp[1].scanline = CEILING16(p_input->height); - p_params->dest_buf[0].index = 0; - p_params->num_dst_bufs = 1; - - /* src buffer config*/ - p_params->src_main_buf[0].buf_size = p_obj->input.size; - p_params->src_main_buf[0].buf_vaddr = p_obj->input.addr; - p_params->src_main_buf[0].fd = p_obj->input.p_pmem_fd; - p_params->src_main_buf[0].index = 0; - p_params->src_main_buf[0].format = MM_JPEG_FMT_BITSTREAM; - /* - p_params->src_main_buf[0].offset.mp[0].len = size; - p_params->src_main_buf[0].offset.mp[1].len = size >> 1; - */ - p_params->num_src_bufs = 1; - - p_job_params->dst_index = 0; - p_job_params->src_index = 0; - p_job_params->rotation = 0; - - /* main dimension */ - p_job_params->main_dim.src_dim.width = p_obj->width; - p_job_params->main_dim.src_dim.height = p_obj->height; - p_job_params->main_dim.dst_dim.width = p_obj->width; - p_job_params->main_dim.dst_dim.height = p_obj->height; - p_job_params->main_dim.crop.top = 0; - p_job_params->main_dim.crop.left = 0; - p_job_params->main_dim.crop.width = p_obj->width; - p_job_params->main_dim.crop.height = p_obj->height; - - - return 0; -} - -void omx_test_dec_print_usage() -{ - fprintf(stderr, "Usage: program_name [options]\n"); - fprintf(stderr, "Mandatory options:\n"); - fprintf(stderr, " -I FILE\t\tPath to the input file.\n"); - fprintf(stderr, " -O FILE\t\tPath for the output file.\n"); - fprintf(stderr, " -W WIDTH\t\tOutput image width\n"); - fprintf(stderr, " -H HEIGHT\t\tOutput image height\n"); - fprintf(stderr, "Optional:\n"); - fprintf(stderr, " -F FORMAT\t\tDefault image format:\n"); - fprintf(stderr, "\t\t\t\t%s (0), %s (1), %s (2) %s (3)\n" - "%s (4), %s (5), %s (6) %s (7)\n", - col_formats[0].format_str, col_formats[1].format_str, - col_formats[2].format_str, col_formats[3].format_str, - col_formats[4].format_str, col_formats[5].format_str, - col_formats[6].format_str, col_formats[7].format_str - ); - - fprintf(stderr, "\n"); -} - -static int mm_jpegdec_test_get_input(int argc, char *argv[], - jpeg_test_input_t *p_test) -{ - int c; - - while ((c = getopt(argc, argv, "I:O:W:H:F:")) != -1) { - switch (c) { - case 'O': - p_test->out_filename = optarg; - fprintf(stderr, "%-25s%s\n", "Output image path", - p_test->out_filename); - break; - case 'I': - p_test->filename = optarg; - fprintf(stderr, "%-25s%s\n", "Input image path", p_test->filename); - break; - case 'W': - p_test->width = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Default width", p_test->width); - break; - case 'H': - p_test->height = atoi(optarg); - fprintf(stderr, "%-25s%d\n", "Default height", p_test->height); - break; - case 'F': { - int format = 0; - format = atoi(optarg); - int num_formats = ARR_SZ(col_formats); - CLAMP(format, 0, num_formats); - p_test->format = col_formats[format].eColorFormat; - fprintf(stderr, "%-25s%s\n", "Default image format", - col_formats[format].format_str); - break; - } - default:; - } - } - if (!p_test->filename || !p_test->filename || !p_test->width || - !p_test->height) { - fprintf(stderr, "Missing required arguments.\n"); - omx_test_dec_print_usage(); - return -1; - } - return 0; -} - -static int decode_test(jpeg_test_input_t *p_input) -{ - int rc = 0; - mm_jpegdec_intf_test_t jpeg_obj; - int i = 0; - - memset(&jpeg_obj, 0x0, sizeof(jpeg_obj)); - rc = decode_init(p_input, &jpeg_obj); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - return -1; - } - - jpeg_obj.handle = jpegdec_open(&jpeg_obj.ops); - if (jpeg_obj.handle == 0) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto end; - } - - rc = jpeg_obj.ops.create_session(jpeg_obj.handle, &jpeg_obj.params, - &jpeg_obj.job.decode_job.session_id); - if (jpeg_obj.job.decode_job.session_id == 0) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto end; - } - - for (i = 0; i < g_count; i++) { - jpeg_obj.job.job_type = JPEG_JOB_TYPE_DECODE; - - CDBG_ERROR("%s:%d] Starting decode job",__func__, __LINE__); - gettimeofday(&dtime[0], NULL); - - fprintf(stderr, "Starting decode of %s into %s outw %d outh %d\n\n", - p_input->filename, p_input->out_filename, - p_input->width, p_input->height); - rc = jpeg_obj.ops.start_job(&jpeg_obj.job, &jpeg_obj.job_id[i]); - if (rc) { - CDBG_ERROR("%s:%d] Error",__func__, __LINE__); - goto end; - } - } - - /* - usleep(5); - jpeg_obj.ops.abort_job(jpeg_obj.job_id[0]); - */ - pthread_mutex_lock(&jpeg_obj.lock); - pthread_cond_wait(&jpeg_obj.cond, &jpeg_obj.lock); - pthread_mutex_unlock(&jpeg_obj.lock); - - fprintf(stderr, "Decode time %llu ms\n", - ((TIME_IN_US(dtime[1]) - TIME_IN_US(dtime[0]))/1000)); - - - jpeg_obj.ops.destroy_session(jpeg_obj.job.decode_job.session_id); - - jpeg_obj.ops.close(jpeg_obj.handle); - - -end: - mm_jpegdec_test_free(&jpeg_obj.input); - mm_jpegdec_test_free(&jpeg_obj.output); - return 0; -} - -/** main: - * - * Arguments: - * @argc - * @argv - * - * Return: - * 0 or -ve values - * - * Description: - * main function - * - **/ -int main(int argc, char* argv[]) -{ - jpeg_test_input_t dec_test_input; - int ret; - - memset(&dec_test_input, 0, sizeof(dec_test_input)); - ret = mm_jpegdec_test_get_input(argc, argv, &dec_test_input); - - if (ret) { - return -1; - } - - return decode_test(&dec_test_input); -} - - |
