hardware: samsung_slsi: libcamera2: Apply pending JPEG count to in_progress

Apply the count of pending JPEG output to the result of
get_in_progress_count.

BUG: 7276954
Change-Id: I89aa1311618423d089c9572c9a292d90eb5de92d
Signed-off-by: Sungjoong Kang <sj3.kang@samsung.com>
diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp
index ecfd430..0975d7c 100644
--- a/libcamera2/ExynosCameraHWInterface2.cpp
+++ b/libcamera2/ExynosCameraHWInterface2.cpp
@@ -954,6 +954,7 @@
             m_afTriggerId(0),
             m_afPendingTriggerId(0),
             m_afModeWaitingCnt(0),
+            m_jpegEncodingCount(0),
             m_scpForceSuspended(false),
             m_halDevice(dev),
             m_nightCaptureCnt(0),
@@ -1609,8 +1610,9 @@
 int ExynosCameraHWInterface2::getInProgressCount()
 {
     int inProgressCount = m_requestManager->GetNumEntries();
-    ALOGV("DEBUG(%s): # of dequeued req (%d)", __FUNCTION__, inProgressCount);
-    return inProgressCount;
+    ALOGV("DEBUG(%s): # of dequeued req (%d) jpeg(%d) = (%d)", __FUNCTION__,
+        inProgressCount, m_jpegEncodingCount, (inProgressCount + m_jpegEncodingCount));
+    return (inProgressCount + m_jpegEncodingCount);
 }
 
 int ExynosCameraHWInterface2::flushCapturesInProgress()
@@ -4129,6 +4131,7 @@
 }
 int ExynosCameraHWInterface2::m_jpegCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp)
 {
+    Mutex::Autolock lock(m_jpegEncoderLock);
     stream_parameters_t     *selfStreamParms = &(selfThread->m_parameters);
     substream_parameters_t  *subParms        = &m_subStreams[STREAM_ID_JPEG];
     status_t    res;
@@ -4160,6 +4163,8 @@
         return 1;
     }
 
+    m_jpegEncodingCount++;
+
     m_getRatioSize(selfStreamParms->width, selfStreamParms->height,
                     m_streamThreads[0]->m_parameters.width, m_streamThreads[0]->m_parameters.height,
                     &srcCropX, &srcCropY,
@@ -4322,6 +4327,7 @@
                 subParms->svcBufIndex,  subParms->svcBufStatus[subParms->svcBufIndex]);
         }
     }
+    m_jpegEncodingCount--;
     return 0;
 }
 
diff --git a/libcamera2/ExynosCameraHWInterface2.h b/libcamera2/ExynosCameraHWInterface2.h
index d51cd25..59a808c 100644
--- a/libcamera2/ExynosCameraHWInterface2.h
+++ b/libcamera2/ExynosCameraHWInterface2.h
@@ -660,6 +660,8 @@
     int                                 m_vdisDupFrame;
 
     mutable Mutex                       m_qbufLock;
+    mutable Mutex                       m_jpegEncoderLock;
+    int                                 m_jpegEncodingCount;
 
     bool                                m_scpForceSuspended;
     int                                 m_afState;