Skip to content

Commit

Permalink
camera: Add support for mediatek cameras
Browse files Browse the repository at this point in the history
Change-Id: I69ea758645922c433844ab191a737de2ff2e1491
  • Loading branch information
rmcc committed Mar 30, 2015
1 parent c29fb05 commit eb994da
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions services/camera/libcameraservice/api1/CameraClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ void CameraClient::disableMsgType(int32_t msgType) {

#define CHECK_MESSAGE_INTERVAL 10 // 10ms
bool CameraClient::lockIfMessageWanted(int32_t msgType) {
#ifdef MTK_HARDWARE
return true;
#endif
int sleepCount = 0;
while (mMsgEnabled & msgType) {
if ((msgType == CAMERA_MSG_PREVIEW_FRAME) &&
Expand Down Expand Up @@ -759,6 +762,18 @@ void CameraClient::notifyCallback(int32_t msgType, int32_t ext1,
int32_t ext2, void* user) {
LOG2("notifyCallback(%d)", msgType);

#ifdef MTK_HARDWARE
if (msgType == 0x40000000) { //MTK_CAMERA_MSG_EXT_NOTIFY
if (ext1 == 0x11) { //MTK_CAMERA_MSG_EXT_NOTIFY_SHUTTER
msgType = CAMERA_MSG_SHUTTER;
}
if (ext1 == 0x10) { //MTK_CAMERA_MSG_EXT_CAPTURE_DONE
return;
}
LOG2("MtknotifyCallback(0x%x, 0x%x)", ext1, ext2);
}
#endif

Mutex* lock = getClientLockFromCookie(user);
if (lock == NULL) return;
Mutex::Autolock alock(*lock);
Expand Down Expand Up @@ -799,6 +814,34 @@ void CameraClient::dataCallback(int32_t msgType,
return;
}

#ifdef MTK_HARDWARE
if (msgType == 0x80000000) { //MTK_CAMERA_MSG_EXT_DATA
struct DataHeader {
uint32_t extMsgType;
} dataHeader;
sp<IMemoryHeap> heap = 0;
ssize_t offset = 0;
size_t size = 0;

if (dataPtr.get()) {

heap = dataPtr->getMemory(&offset, &size);
if ( NULL != heap.get() && NULL != heap->base() )
::memcpy(&dataHeader, ((uint8_t*)heap->base()) + offset, sizeof(DataHeader));

if (dataHeader.extMsgType == 0x10) { //MTK_CAMERA_MSG_EXT_DATA_COMPRESSED_IMAGE
msgType = CAMERA_MSG_COMPRESSED_IMAGE;
sp<MemoryBase> image = new MemoryBase(heap,
(offset + sizeof(DataHeader) + sizeof(uint_t) * 1),
(size - sizeof(DataHeader) - sizeof(uint_t) * 1));
client->handleCompressedPicture(image);
return;
}
}
LOG2("MtkDataCallback(0x%x)", dataHeader.extMsgType);
}
#endif

switch (msgType & ~CAMERA_MSG_PREVIEW_METADATA) {
case CAMERA_MSG_PREVIEW_FRAME:
client->handlePreviewData(msgType, dataPtr, metadata);
Expand Down

0 comments on commit eb994da

Please sign in to comment.