blob: 1b988ce87ad34b49e74e07f79b95fb6c4cc3a6ed [file] [log] [blame]
Sam Protsenkoce268502023-09-08 19:45:36 -05001/*
2**
3** Copyright 2017, Samsung Electronics Co. LTD
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18
19/* #define LOG_NDEBUG 0 */
20#define LOG_TAG "ExynosCameraActivityControl"
21
22#include "ExynosCameraActivityControl.h"
23
24namespace android {
25
26ExynosCameraActivityControl::ExynosCameraActivityControl(int cameraId)
27{
28 m_autofocusMgr = new ExynosCameraActivityAutofocus(cameraId);
29 m_flashMgr = new ExynosCameraActivityFlash(cameraId);
30 m_specialCaptureMgr = new ExynosCameraActivitySpecialCapture(cameraId);
31 m_uctlMgr = new ExynosCameraActivityUCTL(cameraId);
32
33 m_camId = cameraId;
34}
35
36ExynosCameraActivityControl::~ExynosCameraActivityControl()
37{
38 if (m_autofocusMgr != NULL) {
39 delete m_autofocusMgr;
40 m_autofocusMgr = NULL;
41 }
42
43 if (m_flashMgr != NULL) {
44 delete m_flashMgr;
45 m_flashMgr = NULL;
46 }
47
48 if (m_specialCaptureMgr != NULL) {
49 delete m_specialCaptureMgr;
50 m_specialCaptureMgr = NULL;
51 }
52
53 if (m_uctlMgr != NULL) {
54 delete m_uctlMgr;
55 m_uctlMgr = NULL;
56 }
57}
58
59#ifdef OIS_CAPTURE
60void ExynosCameraActivityControl::setOISCaptureMode(bool oisMode)
61{
62 if (oisMode)
63 m_specialCaptureMgr->setCaptureMode(ExynosCameraActivitySpecialCapture::SCAPTURE_MODE_OIS);
64 else
65 m_specialCaptureMgr->setCaptureMode(ExynosCameraActivitySpecialCapture::SCAPTURE_MODE_NONE);
66}
67#endif
68
69void ExynosCameraActivityControl::activityBeforeExecFunc(int pipeId, void *args)
70{
71 switch(pipeId) {
72 case PIPE_FLITE:
73 m_autofocusMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
74 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
75 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
76 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
77 break;
78 case PIPE_3AA:
79 if (m_checkSensorOnThisPipe(pipeId, args) == true) {
80 m_autofocusMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
81 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
82 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
83 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_BEFORE, args);
84 }
85
86 m_autofocusMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_3A_BEFORE_HAL3, args);
87 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_3A_BEFORE_HAL3, args);
88 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_3A_BEFORE_HAL3, args);
89 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_3A_BEFORE, args);
90 break;
91 case PIPE_ISP:
92 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_ISP_BEFORE, args);
93 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_ISP_BEFORE, args);
94 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_ISP_BEFORE, args);
95 break;
96 case PIPE_VRA:
97 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_VRA_BEFORE, args);
98 break;
99 default:
100 break;
101 }
102}
103
104void ExynosCameraActivityControl::activityAfterExecFunc(int pipeId, void *args)
105{
106 switch(pipeId) {
107 case PIPE_FLITE:
108 m_autofocusMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
109 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
110 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
111 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
112 break;
113 case PIPE_3AA:
114 if (m_checkSensorOnThisPipe(pipeId, args) == true) {
115 m_autofocusMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
116 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
117 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
118 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_SENSOR_AFTER, args);
119 }
120
121 m_autofocusMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_3A_AFTER, args);
122 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_3A_AFTER_HAL3, args);
123 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_3A_AFTER, args);
124 break;
125 case PIPE_ISP:
126 m_autofocusMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_ISP_AFTER, args);
127 m_flashMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_ISP_AFTER, args);
128 m_specialCaptureMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_ISP_AFTER, args);
129 m_uctlMgr->execFunction(ExynosCameraActivityBase::CALLBACK_TYPE_ISP_AFTER, args);
130 break;
131 default:
132 break;
133 }
134}
135
136ExynosCameraActivityFlash *ExynosCameraActivityControl::getFlashMgr(void)
137{
138 return m_flashMgr;
139}
140
141ExynosCameraActivitySpecialCapture *ExynosCameraActivityControl::getSpecialCaptureMgr(void)
142{
143 return m_specialCaptureMgr;
144}
145
146ExynosCameraActivityAutofocus*ExynosCameraActivityControl::getAutoFocusMgr(void)
147{
148 return m_autofocusMgr;
149}
150
151ExynosCameraActivityUCTL*ExynosCameraActivityControl::getUCTLMgr(void)
152{
153 return m_uctlMgr;
154}
155
156bool ExynosCameraActivityControl::m_checkSensorOnThisPipe(int pipeId, void *args)
157{
158 bool flagCheckSensor = false;
159
160 if (pipeId != PIPE_3AA) {
161 ALOGE("ERR(%s[%d]):pipeId(%d) != PIPE_3AA. so, fail", __FUNCTION__, __LINE__, pipeId);
162 return false;
163 }
164
165 if (args == NULL) {
166 ALOGE("ERR(%s[%d]):pipeId(%d), args == NULL. so, fail", __FUNCTION__, __LINE__, pipeId);
167 return false;
168 }
169
170 ExynosCameraBuffer *buf = (ExynosCameraBuffer *)args;
171 camera2_shot_ext *shot_ext = (struct camera2_shot_ext *)(buf->addr[buf->getMetaPlaneIndex()]);
172
173 if (shot_ext == NULL) {
174 ALOGE("ERR(%s[%d]):pipeId(%d), shot_ext == NULL. so, fail", __FUNCTION__, __LINE__, pipeId);
175 return false;
176 }
177
178 // we need to change to leader of sensor
179 switch (shot_ext->node_group.leader.vid) {
180 case FIMC_IS_VIDEO_SS0_NUM:
181 case FIMC_IS_VIDEO_SS1_NUM:
182 case FIMC_IS_VIDEO_SS2_NUM:
183 case FIMC_IS_VIDEO_SS3_NUM:
184 flagCheckSensor = true;
185 break;
186 default:
187 break;
188 }
189
190 return flagCheckSensor;
191}
192}; /* namespace android */
193