Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2008, The Android Open Source Project |
| 4 | ** Copyright 2012, Samsung Electronics Co. LTD |
| 5 | ** |
| 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | ** you may not use this file except in compliance with the License. |
| 8 | ** You may obtain a copy of the License at |
| 9 | ** |
| 10 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | ** |
| 12 | ** Unless required by applicable law or agreed to in writing, software |
| 13 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | ** See the License for the specific language governing permissions and |
| 16 | ** limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | /*! |
| 20 | * \file ExynosCameraHWInterface2.cpp |
| 21 | * \brief source file for Android Camera API 2.0 HAL |
| 22 | * \author Sungjoong Kang(sj3.kang@samsung.com) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 23 | * \date 2012/07/10 |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 24 | * |
| 25 | * <b>Revision History: </b> |
| 26 | * - 2012/05/31 : Sungjoong Kang(sj3.kang@samsung.com) \n |
| 27 | * Initial Release |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 28 | * |
| 29 | * - 2012/07/10 : Sungjoong Kang(sj3.kang@samsung.com) \n |
| 30 | * 2nd Release |
| 31 | * |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 32 | */ |
| 33 | |
| 34 | //#define LOG_NDEBUG 0 |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 35 | #define LOG_TAG "ExynosCameraHAL2" |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 36 | #include <utils/Log.h> |
| 37 | |
| 38 | #include "ExynosCameraHWInterface2.h" |
| 39 | #include "exynos_format.h" |
| 40 | |
| 41 | |
| 42 | |
| 43 | namespace android { |
| 44 | |
| 45 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 46 | void m_savePostView(const char *fname, uint8_t *buf, uint32_t size) |
| 47 | { |
| 48 | int nw; |
| 49 | int cnt = 0; |
| 50 | uint32_t written = 0; |
| 51 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 52 | ALOGV("opening file [%s], address[%x], size(%d)", fname, (unsigned int)buf, size); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 53 | int fd = open(fname, O_RDWR | O_CREAT, 0644); |
| 54 | if (fd < 0) { |
| 55 | ALOGE("failed to create file [%s]: %s", fname, strerror(errno)); |
| 56 | return; |
| 57 | } |
| 58 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 59 | ALOGV("writing %d bytes to file [%s]", size, fname); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 60 | while (written < size) { |
| 61 | nw = ::write(fd, buf + written, size - written); |
| 62 | if (nw < 0) { |
| 63 | ALOGE("failed to write to file %d [%s]: %s",written,fname, strerror(errno)); |
| 64 | break; |
| 65 | } |
| 66 | written += nw; |
| 67 | cnt++; |
| 68 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 69 | ALOGV("done writing %d bytes to file [%s] in %d passes",size, fname, cnt); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 70 | ::close(fd); |
| 71 | } |
| 72 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 73 | int get_pixel_depth(uint32_t fmt) |
| 74 | { |
| 75 | int depth = 0; |
| 76 | |
| 77 | switch (fmt) { |
| 78 | case V4L2_PIX_FMT_JPEG: |
| 79 | depth = 8; |
| 80 | break; |
| 81 | |
| 82 | case V4L2_PIX_FMT_NV12: |
| 83 | case V4L2_PIX_FMT_NV21: |
| 84 | case V4L2_PIX_FMT_YUV420: |
| 85 | case V4L2_PIX_FMT_YVU420M: |
| 86 | case V4L2_PIX_FMT_NV12M: |
| 87 | case V4L2_PIX_FMT_NV12MT: |
| 88 | depth = 12; |
| 89 | break; |
| 90 | |
| 91 | case V4L2_PIX_FMT_RGB565: |
| 92 | case V4L2_PIX_FMT_YUYV: |
| 93 | case V4L2_PIX_FMT_YVYU: |
| 94 | case V4L2_PIX_FMT_UYVY: |
| 95 | case V4L2_PIX_FMT_VYUY: |
| 96 | case V4L2_PIX_FMT_NV16: |
| 97 | case V4L2_PIX_FMT_NV61: |
| 98 | case V4L2_PIX_FMT_YUV422P: |
| 99 | case V4L2_PIX_FMT_SBGGR10: |
| 100 | case V4L2_PIX_FMT_SBGGR12: |
| 101 | case V4L2_PIX_FMT_SBGGR16: |
| 102 | depth = 16; |
| 103 | break; |
| 104 | |
| 105 | case V4L2_PIX_FMT_RGB32: |
| 106 | depth = 32; |
| 107 | break; |
| 108 | default: |
| 109 | ALOGE("Get depth failed(format : %d)", fmt); |
| 110 | break; |
| 111 | } |
| 112 | |
| 113 | return depth; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 114 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 115 | |
| 116 | int cam_int_s_fmt(node_info_t *node) |
| 117 | { |
| 118 | struct v4l2_format v4l2_fmt; |
| 119 | unsigned int framesize; |
| 120 | int ret; |
| 121 | |
| 122 | memset(&v4l2_fmt, 0, sizeof(struct v4l2_format)); |
| 123 | |
| 124 | v4l2_fmt.type = node->type; |
| 125 | framesize = (node->width * node->height * get_pixel_depth(node->format)) / 8; |
| 126 | |
| 127 | if (node->planes >= 1) { |
| 128 | v4l2_fmt.fmt.pix_mp.width = node->width; |
| 129 | v4l2_fmt.fmt.pix_mp.height = node->height; |
| 130 | v4l2_fmt.fmt.pix_mp.pixelformat = node->format; |
| 131 | v4l2_fmt.fmt.pix_mp.field = V4L2_FIELD_ANY; |
| 132 | } else { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 133 | ALOGE("%s:S_FMT, Out of bound : Number of element plane",__FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* Set up for capture */ |
| 137 | ret = exynos_v4l2_s_fmt(node->fd, &v4l2_fmt); |
| 138 | |
| 139 | if (ret < 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 140 | ALOGE("%s: exynos_v4l2_s_fmt fail (%d)",__FUNCTION__, ret); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 141 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 142 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 143 | return ret; |
| 144 | } |
| 145 | |
| 146 | int cam_int_reqbufs(node_info_t *node) |
| 147 | { |
| 148 | struct v4l2_requestbuffers req; |
| 149 | int ret; |
| 150 | |
| 151 | req.count = node->buffers; |
| 152 | req.type = node->type; |
| 153 | req.memory = node->memory; |
| 154 | |
| 155 | ret = exynos_v4l2_reqbufs(node->fd, &req); |
| 156 | |
| 157 | if (ret < 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 158 | ALOGE("%s: VIDIOC_REQBUFS (fd:%d) failed (%d)",__FUNCTION__,node->fd, ret); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 159 | |
| 160 | return req.count; |
| 161 | } |
| 162 | |
| 163 | int cam_int_qbuf(node_info_t *node, int index) |
| 164 | { |
| 165 | struct v4l2_buffer v4l2_buf; |
| 166 | struct v4l2_plane planes[VIDEO_MAX_PLANES]; |
| 167 | int i; |
| 168 | int ret = 0; |
| 169 | |
| 170 | v4l2_buf.m.planes = planes; |
| 171 | v4l2_buf.type = node->type; |
| 172 | v4l2_buf.memory = node->memory; |
| 173 | v4l2_buf.index = index; |
| 174 | v4l2_buf.length = node->planes; |
| 175 | |
| 176 | for(i = 0; i < node->planes; i++){ |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 177 | v4l2_buf.m.planes[i].m.fd = (int)(node->buffer[index].fd.extFd[i]); |
| 178 | v4l2_buf.m.planes[i].length = (unsigned long)(node->buffer[index].size.extS[i]); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | ret = exynos_v4l2_qbuf(node->fd, &v4l2_buf); |
| 182 | |
| 183 | if (ret < 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 184 | ALOGE("%s: cam_int_qbuf failed (index:%d)(ret:%d)",__FUNCTION__, index, ret); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 185 | |
| 186 | return ret; |
| 187 | } |
| 188 | |
| 189 | int cam_int_streamon(node_info_t *node) |
| 190 | { |
| 191 | enum v4l2_buf_type type = node->type; |
| 192 | int ret; |
| 193 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 194 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 195 | ret = exynos_v4l2_streamon(node->fd, type); |
| 196 | |
| 197 | if (ret < 0) |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 198 | ALOGE("%s: VIDIOC_STREAMON failed [%d] (%d)",__FUNCTION__, node->fd,ret); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 199 | |
| 200 | ALOGV("On streaming I/O... ... fd(%d)", node->fd); |
| 201 | |
| 202 | return ret; |
| 203 | } |
| 204 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 205 | int cam_int_streamoff(node_info_t *node) |
| 206 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 207 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 208 | int ret; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 209 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 210 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 211 | ALOGV("Off streaming I/O... fd(%d)", node->fd); |
| 212 | ret = exynos_v4l2_streamoff(node->fd, type); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 213 | |
| 214 | if (ret < 0) |
| 215 | ALOGE("%s: VIDIOC_STREAMOFF failed (%d)",__FUNCTION__, ret); |
| 216 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 217 | return ret; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 218 | } |
| 219 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 220 | int isp_int_streamoff(node_info_t *node) |
| 221 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 222 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 223 | int ret; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 224 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 225 | ALOGV("Off streaming I/O... fd(%d)", node->fd); |
| 226 | ret = exynos_v4l2_streamoff(node->fd, type); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 227 | |
| 228 | if (ret < 0) |
| 229 | ALOGE("%s: VIDIOC_STREAMOFF failed (%d)",__FUNCTION__, ret); |
| 230 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 231 | return ret; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 232 | } |
| 233 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 234 | int cam_int_dqbuf(node_info_t *node) |
| 235 | { |
| 236 | struct v4l2_buffer v4l2_buf; |
| 237 | struct v4l2_plane planes[VIDEO_MAX_PLANES]; |
| 238 | int ret; |
| 239 | |
| 240 | v4l2_buf.type = node->type; |
| 241 | v4l2_buf.memory = node->memory; |
| 242 | v4l2_buf.m.planes = planes; |
| 243 | v4l2_buf.length = node->planes; |
| 244 | |
| 245 | ret = exynos_v4l2_dqbuf(node->fd, &v4l2_buf); |
| 246 | if (ret < 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 247 | ALOGE("%s: VIDIOC_DQBUF failed (%d)",__FUNCTION__, ret); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 248 | |
| 249 | return v4l2_buf.index; |
| 250 | } |
| 251 | |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 252 | int cam_int_dqbuf(node_info_t *node, int num_plane) |
| 253 | { |
| 254 | struct v4l2_buffer v4l2_buf; |
| 255 | struct v4l2_plane planes[VIDEO_MAX_PLANES]; |
| 256 | int ret; |
| 257 | |
| 258 | v4l2_buf.type = node->type; |
| 259 | v4l2_buf.memory = node->memory; |
| 260 | v4l2_buf.m.planes = planes; |
| 261 | v4l2_buf.length = num_plane; |
| 262 | |
| 263 | ret = exynos_v4l2_dqbuf(node->fd, &v4l2_buf); |
| 264 | if (ret < 0) |
| 265 | ALOGE("%s: VIDIOC_DQBUF failed (%d)",__FUNCTION__, ret); |
| 266 | |
| 267 | return v4l2_buf.index; |
| 268 | } |
| 269 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 270 | int cam_int_s_input(node_info_t *node, int index) |
| 271 | { |
| 272 | int ret; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 273 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 274 | ret = exynos_v4l2_s_input(node->fd, index); |
| 275 | if (ret < 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 276 | ALOGE("%s: VIDIOC_S_INPUT failed (%d)",__FUNCTION__, ret); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 277 | |
| 278 | return ret; |
| 279 | } |
| 280 | |
| 281 | |
| 282 | gralloc_module_t const* ExynosCameraHWInterface2::m_grallocHal; |
| 283 | |
| 284 | RequestManager::RequestManager(SignalDrivenThread* main_thread): |
| 285 | m_numOfEntries(0), |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 286 | m_entryInsertionIndex(-1), |
| 287 | m_entryProcessingIndex(-1), |
| 288 | m_entryFrameOutputIndex(-1), |
Sungjoong Kang | 2bdec06 | 2012-08-17 15:47:56 -0700 | [diff] [blame] | 289 | m_lastAeMode(0), |
| 290 | m_lastAaMode(0), |
| 291 | m_lastAwbMode(0), |
| 292 | m_lastAeComp(0), |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 293 | m_frameIndex(-1) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 294 | { |
| 295 | m_metadataConverter = new MetadataConverter; |
| 296 | m_mainThread = main_thread; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 297 | for (int i=0 ; i<NUM_MAX_REQUEST_MGR_ENTRY; i++) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 298 | memset(&(entries[i]), 0x00, sizeof(request_manager_entry_t)); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 299 | entries[i].internal_shot.shot.ctl.request.frameCount = -1; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 300 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 301 | m_sensorPipelineSkipCnt = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 302 | return; |
| 303 | } |
| 304 | |
| 305 | RequestManager::~RequestManager() |
| 306 | { |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 307 | ALOGV("%s", __FUNCTION__); |
| 308 | if (m_metadataConverter != NULL) { |
| 309 | delete m_metadataConverter; |
| 310 | m_metadataConverter = NULL; |
| 311 | } |
| 312 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 313 | return; |
| 314 | } |
| 315 | |
| 316 | int RequestManager::GetNumEntries() |
| 317 | { |
| 318 | return m_numOfEntries; |
| 319 | } |
| 320 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 321 | void RequestManager::SetDefaultParameters(int cropX) |
| 322 | { |
| 323 | m_cropX = cropX; |
| 324 | } |
| 325 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 326 | bool RequestManager::IsRequestQueueFull() |
| 327 | { |
| 328 | Mutex::Autolock lock(m_requestMutex); |
| 329 | if (m_numOfEntries>=NUM_MAX_REQUEST_MGR_ENTRY) |
| 330 | return true; |
| 331 | else |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | void RequestManager::RegisterRequest(camera_metadata_t * new_request) |
| 336 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 337 | ALOGV("DEBUG(%s):", __FUNCTION__); |
| 338 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 339 | Mutex::Autolock lock(m_requestMutex); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 340 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 341 | request_manager_entry * newEntry = NULL; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 342 | int newInsertionIndex = GetNextIndex(m_entryInsertionIndex); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 343 | ALOGV("DEBUG(%s): got lock, new insertIndex(%d), cnt before reg(%d)", __FUNCTION__,newInsertionIndex,m_numOfEntries ); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 344 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 345 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 346 | newEntry = &(entries[newInsertionIndex]); |
| 347 | |
| 348 | if (newEntry->status!=EMPTY) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 349 | ALOGV("DEBUG(%s): Circular buffer abnormal ", __FUNCTION__); |
| 350 | return; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 351 | } |
| 352 | newEntry->status = REGISTERED; |
| 353 | newEntry->original_request = new_request; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 354 | memset(&(newEntry->internal_shot), 0, sizeof(struct camera2_shot_ext)); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 355 | m_metadataConverter->ToInternalShot(new_request, &(newEntry->internal_shot)); |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 356 | newEntry->output_stream_count = newEntry->internal_shot.shot.ctl.request.outputStreams[15]; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 357 | |
| 358 | m_numOfEntries++; |
| 359 | m_entryInsertionIndex = newInsertionIndex; |
| 360 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 361 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 362 | ALOGV("## RegisterReq DONE num(%d), insert(%d), processing(%d), frame(%d), (frameCnt(%d))", |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 363 | m_numOfEntries,m_entryInsertionIndex,m_entryProcessingIndex, m_entryFrameOutputIndex, newEntry->internal_shot.shot.ctl.request.frameCount); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | void RequestManager::DeregisterRequest(camera_metadata_t ** deregistered_request) |
| 367 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 368 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 369 | int frame_index; |
| 370 | request_manager_entry * currentEntry; |
| 371 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 372 | Mutex::Autolock lock(m_requestMutex); |
| 373 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 374 | frame_index = GetFrameIndex(); |
| 375 | currentEntry = &(entries[frame_index]); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 376 | if (currentEntry->status != CAPTURED) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 377 | ALOGV("DBG(%s): Circular buffer abnormal. processing(%d), frame(%d), status(%d) ", __FUNCTION__ |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 378 | , m_entryProcessingIndex, m_entryFrameOutputIndex,(int)(currentEntry->status)); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 379 | return; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 380 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 381 | if (deregistered_request) *deregistered_request = currentEntry->original_request; |
| 382 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 383 | currentEntry->status = EMPTY; |
| 384 | currentEntry->original_request = NULL; |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 385 | memset(&(currentEntry->internal_shot), 0, sizeof(struct camera2_shot_ext)); |
| 386 | currentEntry->internal_shot.shot.ctl.request.frameCount = -1; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 387 | currentEntry->output_stream_count = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 388 | currentEntry->dynamic_meta_vaild = false; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 389 | m_numOfEntries--; |
| 390 | ALOGV("## DeRegistReq DONE num(%d), insert(%d), processing(%d), frame(%d)", |
| 391 | m_numOfEntries,m_entryInsertionIndex,m_entryProcessingIndex, m_entryFrameOutputIndex); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 392 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 393 | return; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 396 | bool RequestManager::PrepareFrame(size_t* num_entries, size_t* frame_size, |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 397 | camera_metadata_t ** prepared_frame, int afState) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 398 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 399 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 400 | Mutex::Autolock lock(m_requestMutex); |
| 401 | status_t res = NO_ERROR; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 402 | int tempFrameOutputIndex = GetFrameIndex(); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 403 | request_manager_entry * currentEntry = &(entries[tempFrameOutputIndex]); |
| 404 | ALOGV("DEBUG(%s): processing(%d), frameOut(%d), insert(%d) recentlycompleted(%d)", __FUNCTION__, |
| 405 | m_entryProcessingIndex, m_entryFrameOutputIndex, m_entryInsertionIndex, m_completedIndex); |
| 406 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 407 | if (currentEntry->status != CAPTURED) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 408 | ALOGV("DBG(%s): Circular buffer abnormal status(%d)", __FUNCTION__, (int)(currentEntry->status)); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 409 | |
| 410 | return false; |
| 411 | } |
| 412 | m_entryFrameOutputIndex = tempFrameOutputIndex; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 413 | m_tempFrameMetadata = place_camera_metadata(m_tempFrameMetadataBuf, 2000, 20, 500); //estimated |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 414 | add_camera_metadata_entry(m_tempFrameMetadata, ANDROID_CONTROL_AF_STATE, &afState, 1); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 415 | res = m_metadataConverter->ToDynamicMetadata(&(currentEntry->internal_shot), |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 416 | m_tempFrameMetadata); |
| 417 | if (res!=NO_ERROR) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 418 | ALOGE("ERROR(%s): ToDynamicMetadata (%d) ", __FUNCTION__, res); |
| 419 | return false; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 420 | } |
| 421 | *num_entries = get_camera_metadata_entry_count(m_tempFrameMetadata); |
| 422 | *frame_size = get_camera_metadata_size(m_tempFrameMetadata); |
| 423 | *prepared_frame = m_tempFrameMetadata; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 424 | ALOGV("## PrepareFrame DONE: frameOut(%d) frameCnt-req(%d)", m_entryFrameOutputIndex, |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 425 | currentEntry->internal_shot.shot.ctl.request.frameCount); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 426 | // Dump(); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 427 | return true; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 430 | int RequestManager::MarkProcessingRequest(ExynosBuffer* buf, int *afMode) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 431 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 432 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 433 | Mutex::Autolock lock(m_requestMutex); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 434 | struct camera2_shot_ext * shot_ext; |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 435 | struct camera2_shot_ext * request_shot; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 436 | int targetStreamIndex = 0; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 437 | request_manager_entry * newEntry = NULL; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 438 | static int count = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 439 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 440 | if (m_numOfEntries == 0) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 441 | ALOGD("DEBUG(%s): Request Manager Empty ", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 442 | return -1; |
| 443 | } |
| 444 | |
| 445 | if ((m_entryProcessingIndex == m_entryInsertionIndex) |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 446 | && (entries[m_entryProcessingIndex].status == REQUESTED || entries[m_entryProcessingIndex].status == CAPTURED)) { |
Younghwan Joo | da7ca69 | 2012-09-03 20:47:21 -0700 | [diff] [blame] | 447 | ALOGV("## MarkProcReq skipping(request underrun) - num(%d), insert(%d), processing(%d), frame(%d)", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 448 | m_numOfEntries,m_entryInsertionIndex,m_entryProcessingIndex, m_entryFrameOutputIndex); |
| 449 | return -1; |
| 450 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 451 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 452 | int newProcessingIndex = GetNextIndex(m_entryProcessingIndex); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 453 | ALOGV("DEBUG(%s): index(%d)", __FUNCTION__, newProcessingIndex); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 454 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 455 | newEntry = &(entries[newProcessingIndex]); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 456 | request_shot = &(newEntry->internal_shot); |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 457 | *afMode = (int)(newEntry->internal_shot.shot.ctl.aa.afMode); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 458 | if (newEntry->status != REGISTERED) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 459 | ALOGD("DEBUG(%s)(%d): Circular buffer abnormal ", __FUNCTION__, newProcessingIndex); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 460 | return -1; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 461 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 462 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 463 | newEntry->status = REQUESTED; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 464 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 465 | shot_ext = (struct camera2_shot_ext *)buf->virt.extP[1]; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 466 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 467 | memset(shot_ext, 0x00, sizeof(struct camera2_shot_ext)); |
| 468 | shot_ext->shot.ctl.request.frameCount = request_shot->shot.ctl.request.frameCount; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 469 | shot_ext->request_sensor = 1; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 470 | shot_ext->dis_bypass = 1; |
| 471 | shot_ext->dnr_bypass = 1; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 472 | shot_ext->fd_bypass = 1; |
| 473 | shot_ext->setfile = 0; |
| 474 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 475 | for (int i = 0; i < newEntry->output_stream_count; i++) { |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 476 | targetStreamIndex = newEntry->internal_shot.shot.ctl.request.outputStreams[i]; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 477 | |
| 478 | if (targetStreamIndex==0) { |
| 479 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerP", __FUNCTION__, i); |
| 480 | shot_ext->request_scp = 1; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 481 | if (shot_ext->shot.ctl.stats.faceDetectMode != FACEDETECT_MODE_OFF) |
| 482 | shot_ext->fd_bypass = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 483 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 484 | else if (targetStreamIndex == 1) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 485 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerC", __FUNCTION__, i); |
| 486 | shot_ext->request_scc = 1; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 487 | } |
| 488 | else if (targetStreamIndex == 2) { |
| 489 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerP (record)", __FUNCTION__, i); |
| 490 | shot_ext->request_scp = 1; |
| 491 | shot_ext->shot.ctl.request.outputStreams[2] = 1; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 492 | if (shot_ext->shot.ctl.stats.faceDetectMode != FACEDETECT_MODE_OFF) |
| 493 | shot_ext->fd_bypass = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 494 | } |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 495 | else if (targetStreamIndex == 3) { |
| 496 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerP (previewCb)", __FUNCTION__, i); |
| 497 | shot_ext->request_scp = 1; |
| 498 | shot_ext->shot.ctl.request.outputStreams[3] = 1; |
| 499 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 500 | else { |
| 501 | ALOGV("DEBUG(%s): outputstreams(%d) has abnormal value(%d)", __FUNCTION__, i, targetStreamIndex); |
| 502 | } |
| 503 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 504 | |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 505 | if (count == 0){ |
| 506 | shot_ext->shot.ctl.aa.mode = AA_CONTROL_AUTO; |
| 507 | } else |
| 508 | shot_ext->shot.ctl.aa.mode = AA_CONTROL_NONE; |
| 509 | |
| 510 | count++; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 511 | shot_ext->shot.ctl.request.metadataMode = METADATA_MODE_FULL; |
| 512 | shot_ext->shot.ctl.stats.faceDetectMode = FACEDETECT_MODE_FULL; |
| 513 | shot_ext->shot.magicNumber = 0x23456789; |
| 514 | shot_ext->shot.ctl.sensor.exposureTime = 0; |
| 515 | shot_ext->shot.ctl.sensor.frameDuration = 33*1000*1000; |
| 516 | shot_ext->shot.ctl.sensor.sensitivity = 0; |
| 517 | |
Sungjoong Kang | e4657e3 | 2012-08-28 15:02:19 -0700 | [diff] [blame] | 518 | |
| 519 | shot_ext->shot.ctl.scaler.cropRegion[0] = newEntry->internal_shot.shot.ctl.scaler.cropRegion[0]; |
| 520 | shot_ext->shot.ctl.scaler.cropRegion[1] = newEntry->internal_shot.shot.ctl.scaler.cropRegion[1]; |
| 521 | shot_ext->shot.ctl.scaler.cropRegion[2] = newEntry->internal_shot.shot.ctl.scaler.cropRegion[2]; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 522 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 523 | m_entryProcessingIndex = newProcessingIndex; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 524 | return newProcessingIndex; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 525 | } |
| 526 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 527 | void RequestManager::NotifyStreamOutput(int frameCnt, int stream_id) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 528 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 529 | int index; |
| 530 | |
| 531 | ALOGV("DEBUG(%s): frameCnt(%d), stream_id(%d)", __FUNCTION__, frameCnt, stream_id); |
| 532 | |
| 533 | index = FindEntryIndexByFrameCnt(frameCnt); |
| 534 | if (index == -1) { |
| 535 | ALOGE("ERR(%s): Cannot find entry for frameCnt(%d)", __FUNCTION__, frameCnt); |
| 536 | return; |
| 537 | } |
| 538 | ALOGV("DEBUG(%s): frameCnt(%d), stream_id(%d) last cnt (%d)", __FUNCTION__, frameCnt, stream_id, entries[index].output_stream_count); |
| 539 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 540 | entries[index].output_stream_count--; //TODO : match stream id also |
| 541 | CheckCompleted(index); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 542 | return; |
| 543 | } |
| 544 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 545 | void RequestManager::CheckCompleted(int index) |
| 546 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 547 | ALOGV("DEBUG(%s): reqIndex(%d) current Count(%d)", __FUNCTION__, index, entries[index].output_stream_count); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 548 | SetFrameIndex(index); |
| 549 | m_mainThread->SetSignal(SIGNAL_MAIN_STREAM_OUTPUT_DONE); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 550 | return; |
| 551 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 552 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 553 | void RequestManager::SetFrameIndex(int index) |
| 554 | { |
| 555 | Mutex::Autolock lock(m_requestMutex); |
| 556 | m_frameIndex = index; |
| 557 | } |
| 558 | |
| 559 | int RequestManager::GetFrameIndex() |
| 560 | { |
| 561 | return m_frameIndex; |
| 562 | } |
| 563 | |
| 564 | void RequestManager::ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 565 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 566 | int index; |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 567 | struct camera2_shot_ext * request_shot; |
| 568 | nsecs_t timeStamp; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 569 | int i; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 570 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 571 | ALOGV("DEBUG(%s): frameCnt(%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 572 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 573 | for (i = 0 ; i < NUM_MAX_REQUEST_MGR_ENTRY ; i++) { |
| 574 | if((entries[i].internal_shot.shot.ctl.request.frameCount == shot_ext->shot.ctl.request.frameCount) |
| 575 | && (entries[i].status == CAPTURED)) |
| 576 | break; |
| 577 | } |
| 578 | |
| 579 | if (i == NUM_MAX_REQUEST_MGR_ENTRY){ |
| 580 | ALOGE("[%s] no entry found(framecount:%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 581 | return; |
| 582 | } |
| 583 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 584 | request_manager_entry * newEntry = &(entries[i]); |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 585 | request_shot = &(newEntry->internal_shot); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 586 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 587 | newEntry->dynamic_meta_vaild = true; |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 588 | timeStamp = request_shot->shot.dm.sensor.timeStamp; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 589 | memcpy(&(request_shot->shot.dm), &(shot_ext->shot.dm), sizeof(struct camera2_dm)); |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 590 | request_shot->shot.dm.sensor.timeStamp = timeStamp; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 591 | CheckCompleted(i); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | void RequestManager::DumpInfoWithIndex(int index) |
| 595 | { |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 596 | struct camera2_shot_ext * currMetadata = &(entries[index].internal_shot); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 597 | |
| 598 | ALOGV("#### frameCount(%d) exposureTime(%lld) ISO(%d)", |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 599 | currMetadata->shot.ctl.request.frameCount, |
| 600 | currMetadata->shot.ctl.sensor.exposureTime, |
| 601 | currMetadata->shot.ctl.sensor.sensitivity); |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 602 | if (currMetadata->shot.ctl.request.outputStreams[15] == 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 603 | ALOGV("#### No output stream selected"); |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 604 | else if (currMetadata->shot.ctl.request.outputStreams[15] == 1) |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 605 | ALOGV("#### OutputStreamId : %d", currMetadata->shot.ctl.request.outputStreams[0]); |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 606 | else if (currMetadata->shot.ctl.request.outputStreams[15] == 2) |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 607 | ALOGV("#### OutputStreamId : %d, %d", currMetadata->shot.ctl.request.outputStreams[0], |
| 608 | currMetadata->shot.ctl.request.outputStreams[1]); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 609 | else |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 610 | ALOGV("#### OutputStream num (%d) abnormal ", currMetadata->shot.ctl.request.outputStreams[15]); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 611 | } |
| 612 | |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 613 | void RequestManager::UpdateIspParameters(struct camera2_shot_ext *shot_ext, int frameCnt) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 614 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 615 | int index, targetStreamIndex; |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 616 | struct camera2_shot_ext * request_shot; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 617 | |
| 618 | ALOGV("DEBUG(%s): updating info with frameCnt(%d)", __FUNCTION__, frameCnt); |
| 619 | if (frameCnt < 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 620 | return; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 621 | |
| 622 | index = FindEntryIndexByFrameCnt(frameCnt); |
| 623 | if (index == -1) { |
| 624 | ALOGE("ERR(%s): Cannot find entry for frameCnt(%d)", __FUNCTION__, frameCnt); |
| 625 | return; |
| 626 | } |
| 627 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 628 | request_manager_entry * newEntry = &(entries[index]); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 629 | request_shot = &(newEntry->internal_shot); |
Sungjoong Kang | 2bdec06 | 2012-08-17 15:47:56 -0700 | [diff] [blame] | 630 | memcpy(&(shot_ext->shot.ctl), &(request_shot->shot.ctl), sizeof(struct camera2_ctl)); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 631 | shot_ext->request_sensor = 1; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 632 | shot_ext->dis_bypass = 1; |
| 633 | shot_ext->dnr_bypass = 1; |
| 634 | shot_ext->fd_bypass = 1; |
| 635 | shot_ext->setfile = 0; |
| 636 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 637 | shot_ext->request_scc = 0; |
| 638 | shot_ext->request_scp = 0; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 639 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 640 | shot_ext->shot.ctl.request.outputStreams[0] = 0; |
| 641 | shot_ext->shot.ctl.request.outputStreams[1] = 0; |
| 642 | shot_ext->shot.ctl.request.outputStreams[2] = 0; |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 643 | shot_ext->shot.ctl.request.outputStreams[3] = 0; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 644 | |
Sungjoong Kang | e4657e3 | 2012-08-28 15:02:19 -0700 | [diff] [blame] | 645 | shot_ext->shot.ctl.scaler.cropRegion[0] = request_shot->shot.ctl.scaler.cropRegion[0]; |
| 646 | shot_ext->shot.ctl.scaler.cropRegion[1] = request_shot->shot.ctl.scaler.cropRegion[1]; |
| 647 | shot_ext->shot.ctl.scaler.cropRegion[2] = request_shot->shot.ctl.scaler.cropRegion[2]; |
| 648 | |
Sungjoong Kang | 2bdec06 | 2012-08-17 15:47:56 -0700 | [diff] [blame] | 649 | if (m_lastAaMode == request_shot->shot.ctl.aa.mode) { |
| 650 | shot_ext->shot.ctl.aa.mode = (enum aa_mode)(0); |
| 651 | } |
| 652 | else { |
| 653 | shot_ext->shot.ctl.aa.mode = request_shot->shot.ctl.aa.mode; |
| 654 | m_lastAaMode = (int)(shot_ext->shot.ctl.aa.mode); |
| 655 | } |
| 656 | if (m_lastAeMode == request_shot->shot.ctl.aa.aeMode) { |
| 657 | shot_ext->shot.ctl.aa.aeMode = (enum aa_aemode)(0); |
| 658 | } |
| 659 | else { |
| 660 | shot_ext->shot.ctl.aa.aeMode = request_shot->shot.ctl.aa.aeMode; |
| 661 | m_lastAeMode = (int)(shot_ext->shot.ctl.aa.aeMode); |
| 662 | } |
| 663 | if (m_lastAwbMode == request_shot->shot.ctl.aa.awbMode) { |
| 664 | shot_ext->shot.ctl.aa.awbMode = (enum aa_awbmode)(0); |
| 665 | } |
| 666 | else { |
| 667 | shot_ext->shot.ctl.aa.awbMode = request_shot->shot.ctl.aa.awbMode; |
| 668 | m_lastAwbMode = (int)(shot_ext->shot.ctl.aa.awbMode); |
| 669 | } |
| 670 | if (m_lastAeComp == request_shot->shot.ctl.aa.aeExpCompensation) { |
| 671 | shot_ext->shot.ctl.aa.aeExpCompensation = 0; |
| 672 | } |
| 673 | else { |
| 674 | shot_ext->shot.ctl.aa.aeExpCompensation = request_shot->shot.ctl.aa.aeExpCompensation; |
| 675 | m_lastAeComp = (int)(shot_ext->shot.ctl.aa.aeExpCompensation); |
| 676 | } |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 677 | |
| 678 | shot_ext->shot.ctl.aa.afTrigger = 0; |
| 679 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 680 | for (int i = 0; i < newEntry->output_stream_count; i++) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 681 | targetStreamIndex = newEntry->internal_shot.shot.ctl.request.outputStreams[i]; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 682 | |
| 683 | if (targetStreamIndex==0) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 684 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerP", __FUNCTION__, i); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 685 | shot_ext->request_scp = 1; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 686 | if (shot_ext->shot.ctl.stats.faceDetectMode != FACEDETECT_MODE_OFF) |
| 687 | shot_ext->fd_bypass = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 688 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 689 | else if (targetStreamIndex == 1) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 690 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerC", __FUNCTION__, i); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 691 | shot_ext->request_scc = 1; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 692 | if (shot_ext->shot.ctl.stats.faceDetectMode != FACEDETECT_MODE_OFF) |
| 693 | shot_ext->fd_bypass = 0; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 694 | } |
| 695 | else if (targetStreamIndex == 2) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 696 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerP (record)", __FUNCTION__, i); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 697 | shot_ext->request_scp = 1; |
| 698 | shot_ext->shot.ctl.request.outputStreams[2] = 1; |
Sungjoong Kang | 2bdec06 | 2012-08-17 15:47:56 -0700 | [diff] [blame] | 699 | shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 30; |
| 700 | shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 701 | if (shot_ext->shot.ctl.stats.faceDetectMode != FACEDETECT_MODE_OFF) |
| 702 | shot_ext->fd_bypass = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 703 | } |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 704 | else if (targetStreamIndex == 3) { |
| 705 | ALOGV("DEBUG(%s): outputstreams(%d) is for scalerP (previewCb)", __FUNCTION__, i); |
| 706 | shot_ext->request_scp = 1; |
| 707 | shot_ext->shot.ctl.request.outputStreams[3] = 1; |
| 708 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 709 | else { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 710 | ALOGV("DEBUG(%s): outputstreams(%d) has abnormal value(%d)", __FUNCTION__, i, targetStreamIndex); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 711 | } |
| 712 | } |
Sungjoong Kang | 2bdec06 | 2012-08-17 15:47:56 -0700 | [diff] [blame] | 713 | ALOGV("(%s): applied aa(%d) aemode(%d) expComp(%d), awb(%d) afmode(%d), ", __FUNCTION__, |
| 714 | (int)(shot_ext->shot.ctl.aa.mode), (int)(shot_ext->shot.ctl.aa.aeMode), |
| 715 | (int)(shot_ext->shot.ctl.aa.aeExpCompensation), (int)(shot_ext->shot.ctl.aa.awbMode), |
| 716 | (int)(shot_ext->shot.ctl.aa.afMode)); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 717 | } |
| 718 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 719 | int RequestManager::FindEntryIndexByFrameCnt(int frameCnt) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 720 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 721 | for (int i = 0 ; i < NUM_MAX_REQUEST_MGR_ENTRY ; i++) { |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 722 | if (entries[i].internal_shot.shot.ctl.request.frameCount == frameCnt) |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 723 | return i; |
| 724 | } |
| 725 | return -1; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 726 | } |
| 727 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 728 | void RequestManager::RegisterTimestamp(int frameCnt, nsecs_t * frameTime) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 729 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 730 | int index = FindEntryIndexByFrameCnt(frameCnt); |
| 731 | if (index == -1) { |
| 732 | ALOGE("ERR(%s): Cannot find entry for frameCnt(%d)", __FUNCTION__, frameCnt); |
| 733 | return; |
| 734 | } |
| 735 | |
| 736 | request_manager_entry * currentEntry = &(entries[index]); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 737 | currentEntry->internal_shot.shot.dm.sensor.timeStamp = *((uint64_t*)frameTime); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 738 | ALOGV("DEBUG(%s): applied timestamp for reqIndex(%d) frameCnt(%d) (%lld)", __FUNCTION__, |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 739 | index, frameCnt, currentEntry->internal_shot.shot.dm.sensor.timeStamp); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 740 | } |
| 741 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 742 | uint64_t RequestManager::GetTimestamp(int index) |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 743 | { |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 744 | if (index < 0 || index >= NUM_MAX_REQUEST_MGR_ENTRY) { |
| 745 | ALOGE("ERR(%s): Request entry outside of bounds (%d)", __FUNCTION__, index); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 746 | return 0; |
| 747 | } |
| 748 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 749 | request_manager_entry * currentEntry = &(entries[index]); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 750 | uint64_t frameTime = currentEntry->internal_shot.shot.dm.sensor.timeStamp; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 751 | ALOGV("DEBUG(%s): Returning timestamp for reqIndex(%d) (%lld)", __FUNCTION__, index, frameTime); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 752 | return frameTime; |
| 753 | } |
| 754 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 755 | int RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext) |
| 756 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 757 | int i; |
| 758 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 759 | if (m_numOfEntries == 0) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 760 | ALOGV("(%s): No Entry found", __FUNCTION__); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 761 | return -1; |
| 762 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 763 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 764 | for (i = 0 ; i < NUM_MAX_REQUEST_MGR_ENTRY ; i++) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 765 | if(entries[i].internal_shot.shot.ctl.request.frameCount != shot_ext->shot.ctl.request.frameCount) |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 766 | continue; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 767 | |
| 768 | if (entries[i].status == REQUESTED) { |
| 769 | entries[i].status = CAPTURED; |
| 770 | return entries[i].internal_shot.shot.ctl.request.frameCount; |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 771 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 772 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 773 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 774 | |
| 775 | ALOGD("(%s): No Entry found", __FUNCTION__); |
| 776 | |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 777 | return -1; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 778 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 779 | |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 780 | void RequestManager::SetInitialSkip(int count) |
| 781 | { |
| 782 | ALOGV("(%s): Pipeline Restarting. setting cnt(%d) - current(%d)", __FUNCTION__, count, m_sensorPipelineSkipCnt); |
| 783 | if (count > m_sensorPipelineSkipCnt) |
| 784 | m_sensorPipelineSkipCnt = count; |
| 785 | } |
| 786 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 787 | int RequestManager::GetSkipCnt() |
| 788 | { |
| 789 | ALOGV("(%s): skip cnt(%d)", __FUNCTION__, m_sensorPipelineSkipCnt); |
| 790 | if (m_sensorPipelineSkipCnt == 0) |
| 791 | return m_sensorPipelineSkipCnt; |
| 792 | else |
| 793 | return --m_sensorPipelineSkipCnt; |
| 794 | } |
| 795 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 796 | void RequestManager::Dump(void) |
| 797 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 798 | int i = 0; |
| 799 | request_manager_entry * currentEntry; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 800 | ALOGD("## Dump totalentry(%d), insert(%d), processing(%d), frame(%d)", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 801 | m_numOfEntries,m_entryInsertionIndex,m_entryProcessingIndex, m_entryFrameOutputIndex); |
| 802 | |
| 803 | for (i = 0 ; i < NUM_MAX_REQUEST_MGR_ENTRY ; i++) { |
| 804 | currentEntry = &(entries[i]); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 805 | ALOGD("[%2d] status[%d] frameCnt[%3d] numOutput[%d] outstream[0]-%d outstream[1]-%d", i, |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 806 | currentEntry->status, currentEntry->internal_shot.shot.ctl.request.frameCount, |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 807 | currentEntry->output_stream_count, |
| 808 | currentEntry->internal_shot.shot.ctl.request.outputStreams[0], |
| 809 | currentEntry->internal_shot.shot.ctl.request.outputStreams[1]); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 810 | } |
| 811 | } |
| 812 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 813 | int RequestManager::GetNextIndex(int index) |
| 814 | { |
| 815 | index++; |
| 816 | if (index >= NUM_MAX_REQUEST_MGR_ENTRY) |
| 817 | index = 0; |
| 818 | |
| 819 | return index; |
| 820 | } |
| 821 | |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 822 | ExynosCameraHWInterface2::ExynosCameraHWInterface2(int cameraId, camera2_device_t *dev, ExynosCamera2 * camera, int *openInvalid): |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 823 | m_requestQueueOps(NULL), |
| 824 | m_frameQueueOps(NULL), |
| 825 | m_callbackCookie(NULL), |
| 826 | m_numOfRemainingReqInSvc(0), |
| 827 | m_isRequestQueuePending(false), |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 828 | m_isRequestQueueNull(true), |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 829 | m_isSensorThreadOn(false), |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 830 | m_isSensorStarted(false), |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 831 | m_isIspStarted(false), |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 832 | m_ionCameraClient(0), |
| 833 | m_initFlag1(false), |
| 834 | m_initFlag2(false), |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 835 | m_scp_flushing(false), |
| 836 | m_closing(false), |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 837 | m_recordingEnabled(false), |
| 838 | m_needsRecordBufferInit(false), |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 839 | m_needsPreviewCbBufferInit(false), |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 840 | lastFrameCnt(-1), |
hyeonmyeong Choi | 308291d | 2012-08-29 13:55:01 -0700 | [diff] [blame] | 841 | m_zoomRatio(1), |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 842 | m_scp_closing(false), |
| 843 | m_scp_closed(false), |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 844 | m_afState(HAL_AFSTATE_INACTIVE), |
| 845 | m_afMode(NO_CHANGE), |
| 846 | m_afMode2(NO_CHANGE), |
| 847 | m_IsAfModeUpdateRequired(false), |
| 848 | m_IsAfTriggerRequired(false), |
| 849 | m_IsAfLockRequired(false), |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 850 | m_wideAspect(false), |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 851 | m_aspectChanged(false), |
| 852 | m_scpOutputSignalCnt(0), |
| 853 | m_scpOutputImageCnt(0), |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 854 | m_afTriggerId(0), |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 855 | m_afPendingTriggerId(0), |
| 856 | m_afModeWaitingCnt(0), |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 857 | m_halDevice(dev), |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 858 | m_need_streamoff(0), |
Sungjoong Kang | a15b4e3 | 2012-08-28 12:55:39 -0700 | [diff] [blame] | 859 | m_nightCaptureCnt(0), |
Sungjoong Kang | 2d5e6ec | 2012-08-30 15:14:17 +0900 | [diff] [blame] | 860 | m_cameraId(cameraId), |
| 861 | m_thumbNailW(160), |
| 862 | m_thumbNailH(120) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 863 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 864 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 865 | int ret = 0; |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 866 | int res = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 867 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 868 | m_exynosPictureCSC = NULL; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 869 | m_exynosVideoCSC = NULL; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 870 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 871 | if (!m_grallocHal) { |
| 872 | ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&m_grallocHal); |
| 873 | if (ret) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 874 | ALOGE("ERR(%s):Fail on loading gralloc HAL", __FUNCTION__); |
| 875 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 876 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 877 | m_camera2 = camera; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 878 | m_ionCameraClient = createIonClient(m_ionCameraClient); |
| 879 | if(m_ionCameraClient == 0) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 880 | ALOGE("ERR(%s):Fail on ion_client_create", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 881 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 882 | |
| 883 | m_BayerManager = new BayerBufManager(); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 884 | m_mainThread = new MainThread(this); |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 885 | *openInvalid = InitializeISPChain(); |
| 886 | if (*openInvalid < 0) { |
| 887 | // clean process |
| 888 | // 1. close video nodes |
| 889 | // SCP |
| 890 | res = exynos_v4l2_close(m_fd_scp); |
| 891 | if (res != NO_ERROR ) { |
| 892 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
| 893 | } |
| 894 | // SCC |
| 895 | res = exynos_v4l2_close(m_camera_info.capture.fd); |
| 896 | if (res != NO_ERROR ) { |
| 897 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
| 898 | } |
| 899 | // Sensor |
| 900 | res = exynos_v4l2_close(m_camera_info.sensor.fd); |
| 901 | if (res != NO_ERROR ) { |
| 902 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
| 903 | } |
| 904 | // ISP |
| 905 | res = exynos_v4l2_close(m_camera_info.isp.fd); |
| 906 | if (res != NO_ERROR ) { |
| 907 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
| 908 | } |
| 909 | } else { |
| 910 | m_sensorThread = new SensorThread(this); |
| 911 | m_mainThread->Start("MainThread", PRIORITY_DEFAULT, 0); |
| 912 | ALOGV("DEBUG(%s): created sensorthread ################", __FUNCTION__); |
| 913 | m_requestManager = new RequestManager((SignalDrivenThread*)(m_mainThread.get())); |
| 914 | CSC_METHOD cscMethod = CSC_METHOD_HW; |
| 915 | m_exynosPictureCSC = csc_init(cscMethod); |
| 916 | if (m_exynosPictureCSC == NULL) |
| 917 | ALOGE("ERR(%s): csc_init() fail", __FUNCTION__); |
| 918 | csc_set_hw_property(m_exynosPictureCSC, CSC_HW_PROPERTY_FIXED_NODE, PICTURE_GSC_NODE_NUM); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 919 | |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 920 | m_exynosVideoCSC = csc_init(cscMethod); |
| 921 | if (m_exynosVideoCSC == NULL) |
| 922 | ALOGE("ERR(%s): csc_init() fail", __FUNCTION__); |
| 923 | csc_set_hw_property(m_exynosVideoCSC, CSC_HW_PROPERTY_FIXED_NODE, VIDEO_GSC_NODE_NUM); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 924 | |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 925 | m_setExifFixedAttribute(); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 926 | |
| 927 | // contol information clear |
| 928 | // flash |
| 929 | m_ctlInfo.flash.i_flashMode = AA_AEMODE_ON; |
| 930 | m_ctlInfo.flash.m_afFlashDoneFlg= false; |
| 931 | m_ctlInfo.flash.m_afFlashEnableFlg = false; |
| 932 | m_ctlInfo.flash.m_afFlashCnt = 0; |
| 933 | m_ctlInfo.flash.m_flashEnableFlg = false; |
| 934 | m_ctlInfo.flash.m_flashCaptured = false; |
| 935 | m_ctlInfo.flash.m_flashFrameCount = 0; |
| 936 | m_ctlInfo.flash.m_flashCnt = 0; |
| 937 | m_ctlInfo.flash.m_flashTimeOut = 0; |
| 938 | m_ctlInfo.flash.m_flashWaitCnt = 0; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 939 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 940 | m_ctlInfo.flash.m_flashTorchMode = false; |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 941 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | ExynosCameraHWInterface2::~ExynosCameraHWInterface2() |
| 945 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 946 | ALOGV("%s: ENTER", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 947 | this->release(); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 948 | ALOGV("%s: EXIT", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | void ExynosCameraHWInterface2::release() |
| 952 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 953 | int i, res; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 954 | ALOGD("%s: ENTER", __func__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 955 | m_closing = true; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 956 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 957 | if (m_streamThreads[1] != NULL) { |
| 958 | m_streamThreads[1]->release(); |
| 959 | m_streamThreads[1]->SetSignal(SIGNAL_THREAD_TERMINATE); |
| 960 | } |
| 961 | |
| 962 | if (m_streamThreads[0] != NULL) { |
| 963 | m_streamThreads[0]->release(); |
| 964 | m_streamThreads[0]->SetSignal(SIGNAL_THREAD_TERMINATE); |
| 965 | } |
| 966 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 967 | if (m_ispThread != NULL) { |
| 968 | m_ispThread->release(); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | if (m_sensorThread != NULL) { |
| 972 | m_sensorThread->release(); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 973 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 974 | |
| 975 | if (m_mainThread != NULL) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 976 | m_mainThread->release(); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 977 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 978 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 979 | if (m_exynosPictureCSC) |
| 980 | csc_deinit(m_exynosPictureCSC); |
| 981 | m_exynosPictureCSC = NULL; |
| 982 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 983 | if (m_exynosVideoCSC) |
| 984 | csc_deinit(m_exynosVideoCSC); |
| 985 | m_exynosVideoCSC = NULL; |
| 986 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 987 | if (m_streamThreads[1] != NULL) { |
| 988 | while (!m_streamThreads[1]->IsTerminated()) |
| 989 | { |
| 990 | ALOGD("Waiting for ISP thread is tetminated"); |
| 991 | usleep(100000); |
| 992 | } |
| 993 | m_streamThreads[1] = NULL; |
| 994 | } |
| 995 | |
| 996 | if (m_streamThreads[0] != NULL) { |
| 997 | while (!m_streamThreads[0]->IsTerminated()) |
| 998 | { |
| 999 | ALOGD("Waiting for sensor thread is tetminated"); |
| 1000 | usleep(100000); |
| 1001 | } |
| 1002 | m_streamThreads[0] = NULL; |
| 1003 | } |
| 1004 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1005 | if (m_ispThread != NULL) { |
| 1006 | while (!m_ispThread->IsTerminated()) |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1007 | { |
| 1008 | ALOGD("Waiting for isp thread is tetminated"); |
| 1009 | usleep(100000); |
| 1010 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1011 | m_ispThread = NULL; |
| 1012 | } |
| 1013 | |
| 1014 | if (m_sensorThread != NULL) { |
| 1015 | while (!m_sensorThread->IsTerminated()) |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1016 | { |
| 1017 | ALOGD("Waiting for sensor thread is tetminated"); |
| 1018 | usleep(100000); |
| 1019 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1020 | m_sensorThread = NULL; |
| 1021 | } |
| 1022 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1023 | if (m_mainThread != NULL) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1024 | while (!m_mainThread->IsTerminated()) |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1025 | { |
| 1026 | ALOGD("Waiting for main thread is tetminated"); |
| 1027 | usleep(100000); |
| 1028 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1029 | m_mainThread = NULL; |
| 1030 | } |
| 1031 | |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1032 | if (m_requestManager != NULL) { |
| 1033 | delete m_requestManager; |
| 1034 | m_requestManager = NULL; |
| 1035 | } |
| 1036 | |
| 1037 | if (m_BayerManager != NULL) { |
| 1038 | delete m_BayerManager; |
| 1039 | m_BayerManager = NULL; |
| 1040 | } |
| 1041 | // for(i = 0; i < m_camera_info.sensor.buffers; i++) |
| 1042 | for (i = 0; i < NUM_BAYER_BUFFERS; i++) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1043 | freeCameraMemory(&m_camera_info.sensor.buffer[i], m_camera_info.sensor.planes); |
| 1044 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1045 | for(i = 0; i < m_camera_info.capture.buffers; i++) |
| 1046 | freeCameraMemory(&m_camera_info.capture.buffer[i], m_camera_info.capture.planes); |
| 1047 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1048 | ALOGV("DEBUG(%s): calling exynos_v4l2_close - sensor", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1049 | res = exynos_v4l2_close(m_camera_info.sensor.fd); |
| 1050 | if (res != NO_ERROR ) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1051 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1052 | } |
| 1053 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1054 | ALOGV("DEBUG(%s): calling exynos_v4l2_close - isp", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1055 | res = exynos_v4l2_close(m_camera_info.isp.fd); |
| 1056 | if (res != NO_ERROR ) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1057 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1058 | } |
| 1059 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1060 | ALOGV("DEBUG(%s): calling exynos_v4l2_close - capture", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1061 | res = exynos_v4l2_close(m_camera_info.capture.fd); |
| 1062 | if (res != NO_ERROR ) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1063 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1064 | } |
| 1065 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1066 | ALOGV("DEBUG(%s): calling exynos_v4l2_close - scp", __FUNCTION__); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1067 | res = exynos_v4l2_close(m_fd_scp); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1068 | if (res != NO_ERROR ) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1069 | ALOGE("ERR(%s): exynos_v4l2_close failed(%d)",__FUNCTION__ , res); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1070 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1071 | ALOGV("DEBUG(%s): calling deleteIonClient", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1072 | deleteIonClient(m_ionCameraClient); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1073 | |
| 1074 | ALOGV("%s: EXIT", __func__); |
| 1075 | } |
| 1076 | |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 1077 | int ExynosCameraHWInterface2::InitializeISPChain() |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1078 | { |
| 1079 | char node_name[30]; |
| 1080 | int fd = 0; |
| 1081 | int i; |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 1082 | int ret = 0; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1083 | |
| 1084 | /* Open Sensor */ |
| 1085 | memset(&node_name, 0x00, sizeof(char[30])); |
| 1086 | sprintf(node_name, "%s%d", NODE_PREFIX, 40); |
| 1087 | fd = exynos_v4l2_open(node_name, O_RDWR, 0); |
| 1088 | |
| 1089 | if (fd < 0) { |
| 1090 | ALOGE("ERR(%s): failed to open sensor video node (%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1091 | } |
| 1092 | else { |
| 1093 | ALOGV("DEBUG(%s): sensor video node opened(%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1094 | } |
| 1095 | m_camera_info.sensor.fd = fd; |
| 1096 | |
| 1097 | /* Open ISP */ |
| 1098 | memset(&node_name, 0x00, sizeof(char[30])); |
| 1099 | sprintf(node_name, "%s%d", NODE_PREFIX, 41); |
| 1100 | fd = exynos_v4l2_open(node_name, O_RDWR, 0); |
| 1101 | |
| 1102 | if (fd < 0) { |
| 1103 | ALOGE("ERR(%s): failed to open isp video node (%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1104 | } |
| 1105 | else { |
| 1106 | ALOGV("DEBUG(%s): isp video node opened(%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1107 | } |
| 1108 | m_camera_info.isp.fd = fd; |
| 1109 | |
| 1110 | /* Open ScalerC */ |
| 1111 | memset(&node_name, 0x00, sizeof(char[30])); |
| 1112 | sprintf(node_name, "%s%d", NODE_PREFIX, 42); |
| 1113 | fd = exynos_v4l2_open(node_name, O_RDWR, 0); |
| 1114 | |
| 1115 | if (fd < 0) { |
| 1116 | ALOGE("ERR(%s): failed to open capture video node (%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1117 | } |
| 1118 | else { |
| 1119 | ALOGV("DEBUG(%s): capture video node opened(%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1120 | } |
| 1121 | m_camera_info.capture.fd = fd; |
| 1122 | |
| 1123 | /* Open ScalerP */ |
| 1124 | memset(&node_name, 0x00, sizeof(char[30])); |
| 1125 | sprintf(node_name, "%s%d", NODE_PREFIX, 44); |
| 1126 | fd = exynos_v4l2_open(node_name, O_RDWR, 0); |
| 1127 | if (fd < 0) { |
| 1128 | ALOGE("DEBUG(%s): failed to open preview video node (%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1129 | } |
| 1130 | else { |
| 1131 | ALOGV("DEBUG(%s): preview video node opened(%s) fd (%d)", __FUNCTION__,node_name, fd); |
| 1132 | } |
| 1133 | m_fd_scp = fd; |
| 1134 | |
| 1135 | if(m_cameraId == 0) |
| 1136 | m_camera_info.sensor_id = SENSOR_NAME_S5K4E5; |
| 1137 | else |
| 1138 | m_camera_info.sensor_id = SENSOR_NAME_S5K6A3; |
| 1139 | |
| 1140 | memset(&m_camera_info.dummy_shot, 0x00, sizeof(struct camera2_shot_ext)); |
| 1141 | m_camera_info.dummy_shot.shot.ctl.request.metadataMode = METADATA_MODE_FULL; |
| 1142 | m_camera_info.dummy_shot.shot.magicNumber = 0x23456789; |
| 1143 | |
| 1144 | m_camera_info.dummy_shot.dis_bypass = 1; |
| 1145 | m_camera_info.dummy_shot.dnr_bypass = 1; |
| 1146 | m_camera_info.dummy_shot.fd_bypass = 1; |
| 1147 | |
| 1148 | /*sensor setting*/ |
| 1149 | m_camera_info.dummy_shot.shot.ctl.sensor.exposureTime = 0; |
| 1150 | m_camera_info.dummy_shot.shot.ctl.sensor.frameDuration = 0; |
| 1151 | m_camera_info.dummy_shot.shot.ctl.sensor.sensitivity = 0; |
| 1152 | |
| 1153 | m_camera_info.dummy_shot.shot.ctl.scaler.cropRegion[0] = 0; |
| 1154 | m_camera_info.dummy_shot.shot.ctl.scaler.cropRegion[1] = 0; |
| 1155 | |
| 1156 | /*request setting*/ |
| 1157 | m_camera_info.dummy_shot.request_sensor = 1; |
| 1158 | m_camera_info.dummy_shot.request_scc = 0; |
| 1159 | m_camera_info.dummy_shot.request_scp = 0; |
| 1160 | m_camera_info.dummy_shot.shot.ctl.request.outputStreams[0] = 0; |
| 1161 | m_camera_info.dummy_shot.shot.ctl.request.outputStreams[1] = 0; |
| 1162 | m_camera_info.dummy_shot.shot.ctl.request.outputStreams[2] = 0; |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1163 | m_camera_info.dummy_shot.shot.ctl.request.outputStreams[3] = 0; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1164 | |
| 1165 | m_camera_info.sensor.width = m_camera2->getSensorRawW(); |
| 1166 | m_camera_info.sensor.height = m_camera2->getSensorRawH(); |
| 1167 | |
| 1168 | m_camera_info.sensor.format = V4L2_PIX_FMT_SBGGR16; |
| 1169 | m_camera_info.sensor.planes = 2; |
| 1170 | m_camera_info.sensor.buffers = NUM_BAYER_BUFFERS; |
| 1171 | m_camera_info.sensor.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1172 | m_camera_info.sensor.memory = V4L2_MEMORY_DMABUF; |
| 1173 | m_camera_info.sensor.ionClient = m_ionCameraClient; |
| 1174 | |
| 1175 | for(i = 0; i < m_camera_info.sensor.buffers; i++){ |
| 1176 | initCameraMemory(&m_camera_info.sensor.buffer[i], m_camera_info.sensor.planes); |
| 1177 | m_camera_info.sensor.buffer[i].size.extS[0] = m_camera_info.sensor.width*m_camera_info.sensor.height*2; |
| 1178 | m_camera_info.sensor.buffer[i].size.extS[1] = 8*1024; // HACK, driver use 8*1024, should be use predefined value |
Sungjoong Kang | 181e425 | 2012-08-29 02:11:07 -0700 | [diff] [blame] | 1179 | allocCameraMemory(m_camera_info.sensor.ionClient, &m_camera_info.sensor.buffer[i], m_camera_info.sensor.planes, 1<<1); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1180 | } |
| 1181 | |
| 1182 | m_camera_info.isp.width = m_camera_info.sensor.width; |
| 1183 | m_camera_info.isp.height = m_camera_info.sensor.height; |
| 1184 | m_camera_info.isp.format = m_camera_info.sensor.format; |
| 1185 | m_camera_info.isp.planes = m_camera_info.sensor.planes; |
| 1186 | m_camera_info.isp.buffers = m_camera_info.sensor.buffers; |
| 1187 | m_camera_info.isp.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| 1188 | m_camera_info.isp.memory = V4L2_MEMORY_DMABUF; |
| 1189 | m_camera_info.isp.ionClient = m_ionCameraClient; |
| 1190 | |
| 1191 | for(i = 0; i < m_camera_info.isp.buffers; i++){ |
| 1192 | initCameraMemory(&m_camera_info.isp.buffer[i], m_camera_info.isp.planes); |
| 1193 | m_camera_info.isp.buffer[i].size.extS[0] = m_camera_info.sensor.buffer[i].size.extS[0]; |
| 1194 | m_camera_info.isp.buffer[i].size.extS[1] = m_camera_info.sensor.buffer[i].size.extS[1]; |
| 1195 | m_camera_info.isp.buffer[i].fd.extFd[0] = m_camera_info.sensor.buffer[i].fd.extFd[0]; |
| 1196 | m_camera_info.isp.buffer[i].fd.extFd[1] = m_camera_info.sensor.buffer[i].fd.extFd[1]; |
| 1197 | m_camera_info.isp.buffer[i].virt.extP[0] = m_camera_info.sensor.buffer[i].virt.extP[0]; |
| 1198 | m_camera_info.isp.buffer[i].virt.extP[1] = m_camera_info.sensor.buffer[i].virt.extP[1]; |
| 1199 | }; |
| 1200 | |
| 1201 | /* init ISP */ |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 1202 | ret = cam_int_s_input(&(m_camera_info.isp), m_camera_info.sensor_id); |
| 1203 | if (ret < 0) { |
| 1204 | ALOGE("ERR(%s): cam_int_s_input(%d) failed!!!! ", __FUNCTION__, m_camera_info.sensor_id); |
| 1205 | return false; |
| 1206 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1207 | cam_int_s_fmt(&(m_camera_info.isp)); |
| 1208 | ALOGV("DEBUG(%s): isp calling reqbuf", __FUNCTION__); |
| 1209 | cam_int_reqbufs(&(m_camera_info.isp)); |
| 1210 | ALOGV("DEBUG(%s): isp calling querybuf", __FUNCTION__); |
| 1211 | ALOGV("DEBUG(%s): isp mem alloc done", __FUNCTION__); |
| 1212 | |
| 1213 | /* init Sensor */ |
| 1214 | cam_int_s_input(&(m_camera_info.sensor), m_camera_info.sensor_id); |
| 1215 | ALOGV("DEBUG(%s): sensor s_input done", __FUNCTION__); |
| 1216 | if (cam_int_s_fmt(&(m_camera_info.sensor))< 0) { |
| 1217 | ALOGE("ERR(%s): sensor s_fmt fail", __FUNCTION__); |
| 1218 | } |
| 1219 | ALOGV("DEBUG(%s): sensor s_fmt done", __FUNCTION__); |
| 1220 | cam_int_reqbufs(&(m_camera_info.sensor)); |
| 1221 | ALOGV("DEBUG(%s): sensor reqbuf done", __FUNCTION__); |
| 1222 | for (i = 0; i < m_camera_info.sensor.buffers; i++) { |
| 1223 | ALOGV("DEBUG(%s): sensor initial QBUF [%d]", __FUNCTION__, i); |
| 1224 | memcpy( m_camera_info.sensor.buffer[i].virt.extP[1], &(m_camera_info.dummy_shot), |
| 1225 | sizeof(struct camera2_shot_ext)); |
| 1226 | m_camera_info.dummy_shot.shot.ctl.sensor.frameDuration = 33*1000*1000; // apply from frame #1 |
| 1227 | m_camera_info.dummy_shot.shot.ctl.request.frameCount = -1; |
| 1228 | cam_int_qbuf(&(m_camera_info.sensor), i); |
| 1229 | } |
| 1230 | ALOGV("== stream_on :: .sensor"); |
| 1231 | cam_int_streamon(&(m_camera_info.sensor)); |
| 1232 | |
| 1233 | /* init Capture */ |
| 1234 | m_camera_info.capture.width = m_camera2->getSensorW(); |
| 1235 | m_camera_info.capture.height = m_camera2->getSensorH(); |
| 1236 | m_camera_info.capture.format = V4L2_PIX_FMT_YUYV; |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 1237 | #ifdef ENABLE_FRAME_SYNC |
| 1238 | m_camera_info.capture.planes = 2; |
| 1239 | #else |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1240 | m_camera_info.capture.planes = 1; |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 1241 | #endif |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1242 | m_camera_info.capture.buffers = 8; |
| 1243 | m_camera_info.capture.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1244 | m_camera_info.capture.memory = V4L2_MEMORY_DMABUF; |
| 1245 | m_camera_info.capture.ionClient = m_ionCameraClient; |
| 1246 | |
| 1247 | for(i = 0; i < m_camera_info.capture.buffers; i++){ |
| 1248 | initCameraMemory(&m_camera_info.capture.buffer[i], m_camera_info.capture.planes); |
| 1249 | m_camera_info.capture.buffer[i].size.extS[0] = m_camera_info.capture.width*m_camera_info.capture.height*2; |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 1250 | #ifdef ENABLE_FRAME_SYNC |
| 1251 | m_camera_info.capture.buffer[i].size.extS[1] = 4*1024; // HACK, driver use 4*1024, should be use predefined value |
| 1252 | #endif |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1253 | allocCameraMemory(m_camera_info.capture.ionClient, &m_camera_info.capture.buffer[i], m_camera_info.capture.planes); |
| 1254 | } |
| 1255 | |
| 1256 | cam_int_s_input(&(m_camera_info.capture), m_camera_info.sensor_id); |
| 1257 | cam_int_s_fmt(&(m_camera_info.capture)); |
| 1258 | ALOGV("DEBUG(%s): capture calling reqbuf", __FUNCTION__); |
| 1259 | cam_int_reqbufs(&(m_camera_info.capture)); |
| 1260 | ALOGV("DEBUG(%s): capture calling querybuf", __FUNCTION__); |
| 1261 | |
| 1262 | for (i = 0; i < m_camera_info.capture.buffers; i++) { |
| 1263 | ALOGV("DEBUG(%s): capture initial QBUF [%d]", __FUNCTION__, i); |
| 1264 | cam_int_qbuf(&(m_camera_info.capture), i); |
| 1265 | } |
| 1266 | |
| 1267 | ALOGV("== stream_on :: capture"); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1268 | if (cam_int_streamon(&(m_camera_info.capture)) < 0) { |
| 1269 | ALOGE("ERR(%s): capture stream on fail", __FUNCTION__); |
| 1270 | } else { |
| 1271 | m_camera_info.capture.status = true; |
| 1272 | } |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 1273 | |
| 1274 | return true; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | void ExynosCameraHWInterface2::StartISP() |
| 1278 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1279 | ALOGV("== stream_on :: isp"); |
| 1280 | cam_int_streamon(&(m_camera_info.isp)); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1281 | exynos_v4l2_s_ctrl(m_camera_info.sensor.fd, V4L2_CID_IS_S_STREAM, IS_ENABLE_STREAM); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1282 | } |
| 1283 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1284 | int ExynosCameraHWInterface2::getCameraId() const |
| 1285 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1286 | return m_cameraId; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1287 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1288 | |
| 1289 | int ExynosCameraHWInterface2::setRequestQueueSrcOps(const camera2_request_queue_src_ops_t *request_src_ops) |
| 1290 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1291 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1292 | if ((NULL != request_src_ops) && (NULL != request_src_ops->dequeue_request) |
| 1293 | && (NULL != request_src_ops->free_request) && (NULL != request_src_ops->request_count)) { |
| 1294 | m_requestQueueOps = (camera2_request_queue_src_ops_t*)request_src_ops; |
| 1295 | return 0; |
| 1296 | } |
| 1297 | else { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1298 | ALOGE("DEBUG(%s):setRequestQueueSrcOps : NULL arguments", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1299 | return 1; |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | int ExynosCameraHWInterface2::notifyRequestQueueNotEmpty() |
| 1304 | { |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1305 | ALOGV("DEBUG(%s):setting [SIGNAL_MAIN_REQ_Q_NOT_EMPTY] current(%d)", __FUNCTION__, m_requestManager->GetNumEntries()); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1306 | if ((NULL==m_frameQueueOps)|| (NULL==m_requestQueueOps)) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1307 | ALOGE("DEBUG(%s):queue ops NULL. ignoring request", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1308 | return 0; |
| 1309 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1310 | m_isRequestQueueNull = false; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 1311 | if (m_requestManager->GetNumEntries() == 0) |
| 1312 | m_requestManager->SetInitialSkip(5); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1313 | m_mainThread->SetSignal(SIGNAL_MAIN_REQ_Q_NOT_EMPTY); |
| 1314 | return 0; |
| 1315 | } |
| 1316 | |
| 1317 | int ExynosCameraHWInterface2::setFrameQueueDstOps(const camera2_frame_queue_dst_ops_t *frame_dst_ops) |
| 1318 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1319 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1320 | if ((NULL != frame_dst_ops) && (NULL != frame_dst_ops->dequeue_frame) |
| 1321 | && (NULL != frame_dst_ops->cancel_frame) && (NULL !=frame_dst_ops->enqueue_frame)) { |
| 1322 | m_frameQueueOps = (camera2_frame_queue_dst_ops_t *)frame_dst_ops; |
| 1323 | return 0; |
| 1324 | } |
| 1325 | else { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1326 | ALOGE("DEBUG(%s):setFrameQueueDstOps : NULL arguments", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1327 | return 1; |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | int ExynosCameraHWInterface2::getInProgressCount() |
| 1332 | { |
| 1333 | int inProgressCount = m_requestManager->GetNumEntries(); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1334 | ALOGV("DEBUG(%s): # of dequeued req (%d)", __FUNCTION__, inProgressCount); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1335 | return inProgressCount; |
| 1336 | } |
| 1337 | |
| 1338 | int ExynosCameraHWInterface2::flushCapturesInProgress() |
| 1339 | { |
| 1340 | return 0; |
| 1341 | } |
| 1342 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1343 | int ExynosCameraHWInterface2::constructDefaultRequest(int request_template, camera_metadata_t **request) |
| 1344 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1345 | ALOGV("DEBUG(%s): making template (%d) ", __FUNCTION__, request_template); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1346 | |
| 1347 | if (request == NULL) return BAD_VALUE; |
| 1348 | if (request_template < 0 || request_template >= CAMERA2_TEMPLATE_COUNT) { |
| 1349 | return BAD_VALUE; |
| 1350 | } |
| 1351 | status_t res; |
| 1352 | // Pass 1, calculate size and allocate |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 1353 | res = m_camera2->constructDefaultRequest(request_template, |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1354 | request, |
| 1355 | true); |
| 1356 | if (res != OK) { |
| 1357 | return res; |
| 1358 | } |
| 1359 | // Pass 2, build request |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 1360 | res = m_camera2->constructDefaultRequest(request_template, |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1361 | request, |
| 1362 | false); |
| 1363 | if (res != OK) { |
| 1364 | ALOGE("Unable to populate new request for template %d", |
| 1365 | request_template); |
| 1366 | } |
| 1367 | |
| 1368 | return res; |
| 1369 | } |
| 1370 | |
| 1371 | int ExynosCameraHWInterface2::allocateStream(uint32_t width, uint32_t height, int format, const camera2_stream_ops_t *stream_ops, |
| 1372 | uint32_t *stream_id, uint32_t *format_actual, uint32_t *usage, uint32_t *max_buffers) |
| 1373 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1374 | ALOGV("DEBUG(%s): allocate stream width(%d) height(%d) format(%x)", __FUNCTION__, width, height, format); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1375 | char node_name[30]; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1376 | int fd = 0, allocCase = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1377 | StreamThread *AllocatedStream; |
| 1378 | stream_parameters_t newParameters; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1379 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 1380 | if (format == CAMERA2_HAL_PIXEL_FORMAT_OPAQUE && |
| 1381 | m_camera2->isSupportedResolution(width, height)) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1382 | if (!(m_streamThreads[0].get())) { |
| 1383 | ALOGV("DEBUG(%s): stream 0 not exist", __FUNCTION__); |
| 1384 | allocCase = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1385 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1386 | else { |
Alex Ray | 6bbb593 | 2012-07-27 17:19:48 -0700 | [diff] [blame] | 1387 | if ((m_streamThreads[0].get())->m_activated == true) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1388 | ALOGV("DEBUG(%s): stream 0 exists and activated.", __FUNCTION__); |
| 1389 | allocCase = 1; |
| 1390 | } |
| 1391 | else { |
| 1392 | ALOGV("DEBUG(%s): stream 0 exists and deactivated.", __FUNCTION__); |
| 1393 | allocCase = 2; |
| 1394 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1395 | } |
hyeonmyeong Choi | a44c336 | 2012-08-30 19:01:25 -0700 | [diff] [blame] | 1396 | if ((width == 1920 && height == 1080) || (width == 1280 && height == 720) || (width == 720 && height == 480)) { |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1397 | m_wideAspect = true; |
| 1398 | } |
| 1399 | else { |
| 1400 | m_wideAspect = false; |
| 1401 | } |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 1402 | m_aspectChanged = true; |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1403 | ALOGV("DEBUG(%s): m_wideAspect (%d)", __FUNCTION__, m_wideAspect); |
| 1404 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1405 | if (allocCase == 0 || allocCase == 2) { |
| 1406 | *stream_id = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1407 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1408 | if (allocCase == 0) { |
| 1409 | m_streamThreads[0] = new StreamThread(this, *stream_id); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1410 | } |
| 1411 | AllocatedStream = (StreamThread*)(m_streamThreads[0].get()); |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1412 | m_scp_flushing = false; |
| 1413 | m_scp_closing = false; |
| 1414 | m_scp_closed = false; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1415 | usleep(100000); // TODO : guarantee the codes below will be run after readyToRunInternal() |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1416 | |
Rebecca Schultz Zavin | c853be7 | 2012-08-23 00:03:05 -0700 | [diff] [blame] | 1417 | *format_actual = HAL_PIXEL_FORMAT_EXYNOS_YV12; |
Alex Ray | 6bbb593 | 2012-07-27 17:19:48 -0700 | [diff] [blame] | 1418 | *usage = GRALLOC_USAGE_SW_WRITE_OFTEN; |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 1419 | *max_buffers = 6; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1420 | |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1421 | newParameters.streamType = STREAM_TYPE_DIRECT; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1422 | newParameters.outputWidth = width; |
| 1423 | newParameters.outputHeight = height; |
| 1424 | newParameters.nodeWidth = width; |
| 1425 | newParameters.nodeHeight = height; |
| 1426 | newParameters.outputFormat = *format_actual; |
| 1427 | newParameters.nodeFormat = HAL_PIXEL_FORMAT_2_V4L2_PIX(*format_actual); |
| 1428 | newParameters.streamOps = stream_ops; |
| 1429 | newParameters.usage = *usage; |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1430 | newParameters.numHwBuffers = 8; |
| 1431 | newParameters.numOwnSvcBuffers = *max_buffers; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1432 | newParameters.fd = m_fd_scp; |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1433 | newParameters.nodePlanes = NUM_PLANES(*format_actual); |
| 1434 | newParameters.svcPlanes = NUM_PLANES(*format_actual); |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 1435 | newParameters.metaPlanes = 1; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1436 | newParameters.halBuftype = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1437 | newParameters.memory = V4L2_MEMORY_DMABUF; |
| 1438 | newParameters.ionClient = m_ionCameraClient; |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1439 | newParameters.numSvcBufsInHal = 0; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1440 | AllocatedStream->m_index = *stream_id; |
| 1441 | AllocatedStream->setParameter(&newParameters); |
| 1442 | AllocatedStream->m_activated = true; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1443 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1444 | m_scp_flushing = false; |
| 1445 | m_scp_closing = false; |
| 1446 | m_scp_closed = false; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1447 | m_requestManager->SetDefaultParameters(m_camera2->getSensorW()); |
| 1448 | m_camera_info.dummy_shot.shot.ctl.scaler.cropRegion[2] = m_camera2->getSensorW(); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1449 | return 0; |
| 1450 | } |
| 1451 | else if (allocCase == 1) { |
| 1452 | record_parameters_t recordParameters; |
| 1453 | StreamThread *parentStream; |
| 1454 | parentStream = (StreamThread*)(m_streamThreads[0].get()); |
| 1455 | if (!parentStream) { |
| 1456 | return 1; |
| 1457 | // TODO |
| 1458 | } |
| 1459 | *stream_id = 2; |
| 1460 | usleep(100000); // TODO : guarantee the codes below will be run after readyToRunInternal() |
| 1461 | |
Sungjoong Kang | 804236a | 2012-08-05 10:36:19 -0700 | [diff] [blame] | 1462 | *format_actual = HAL_PIXEL_FORMAT_YCbCr_420_SP; // NV12M |
Alex Ray | 6bbb593 | 2012-07-27 17:19:48 -0700 | [diff] [blame] | 1463 | *usage = GRALLOC_USAGE_SW_WRITE_OFTEN; |
James Dong | 2630679 | 2012-08-24 14:42:26 -0700 | [diff] [blame] | 1464 | *max_buffers = 6; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1465 | |
| 1466 | recordParameters.outputWidth = width; |
| 1467 | recordParameters.outputHeight = height; |
| 1468 | recordParameters.outputFormat = *format_actual; |
Sungjoong Kang | 804236a | 2012-08-05 10:36:19 -0700 | [diff] [blame] | 1469 | recordParameters.svcPlanes = NUM_PLANES(*format_actual); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1470 | recordParameters.streamOps = stream_ops; |
| 1471 | recordParameters.usage = *usage; |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1472 | recordParameters.numOwnSvcBuffers = *max_buffers; |
| 1473 | recordParameters.numSvcBufsInHal = 0; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1474 | |
| 1475 | parentStream->setRecordingParameter(&recordParameters); |
| 1476 | m_scp_flushing = false; |
| 1477 | m_scp_closing = false; |
| 1478 | m_scp_closed = false; |
| 1479 | m_recordingEnabled = true; |
| 1480 | return 0; |
| 1481 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1482 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1483 | else if (format == HAL_PIXEL_FORMAT_BLOB |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 1484 | && m_camera2->isSupportedJpegResolution(width, height)) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1485 | |
| 1486 | *stream_id = 1; |
| 1487 | |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1488 | if (!(m_streamThreads[*stream_id].get())) { |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 1489 | ALOGV("DEBUG(%s): stream 1 not exist", __FUNCTION__); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1490 | m_streamThreads[1] = new StreamThread(this, *stream_id); |
| 1491 | allocCase = 0; |
| 1492 | } |
| 1493 | else { |
| 1494 | if ((m_streamThreads[*stream_id].get())->m_activated == true) { |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 1495 | ALOGV("DEBUG(%s): stream 1 exists and activated.", __FUNCTION__); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1496 | allocCase = 1; |
| 1497 | } |
| 1498 | else { |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 1499 | ALOGV("DEBUG(%s): stream 1 exists and deactivated.", __FUNCTION__); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1500 | allocCase = 2; |
| 1501 | } |
| 1502 | } |
| 1503 | |
| 1504 | AllocatedStream = (StreamThread*)(m_streamThreads[*stream_id].get()); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1505 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1506 | fd = m_camera_info.capture.fd; |
| 1507 | usleep(100000); // TODO : guarantee the codes below will be run after readyToRunInternal() |
| 1508 | |
| 1509 | *format_actual = HAL_PIXEL_FORMAT_BLOB; |
| 1510 | |
| 1511 | *usage = GRALLOC_USAGE_SW_WRITE_OFTEN; |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1512 | *max_buffers = 4; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1513 | |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1514 | newParameters.streamType = STREAM_TYPE_INDIRECT; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1515 | newParameters.outputWidth = width; |
| 1516 | newParameters.outputHeight = height; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1517 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 1518 | newParameters.nodeWidth = m_camera2->getSensorW(); |
| 1519 | newParameters.nodeHeight = m_camera2->getSensorH(); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1520 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1521 | newParameters.outputFormat = *format_actual; |
| 1522 | newParameters.nodeFormat = V4L2_PIX_FMT_YUYV; |
| 1523 | newParameters.streamOps = stream_ops; |
| 1524 | newParameters.usage = *usage; |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1525 | newParameters.numHwBuffers = 8; |
| 1526 | newParameters.numOwnSvcBuffers = *max_buffers; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1527 | newParameters.fd = fd; |
| 1528 | newParameters.nodePlanes = 1; |
| 1529 | newParameters.svcPlanes = 1; |
| 1530 | newParameters.halBuftype = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1531 | newParameters.memory = V4L2_MEMORY_DMABUF; |
| 1532 | newParameters.ionClient = m_ionCameraClient; |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1533 | newParameters.numSvcBufsInHal = 0; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1534 | AllocatedStream->m_index = *stream_id; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1535 | AllocatedStream->setParameter(&newParameters); |
| 1536 | return 0; |
| 1537 | } |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1538 | else if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP || format == HAL_PIXEL_FORMAT_YV12) { |
| 1539 | StreamThread *parentStream; |
| 1540 | callback_parameters_t callbackParameters; |
| 1541 | parentStream = (StreamThread*)(m_streamThreads[0].get()); |
| 1542 | if (!parentStream) { |
| 1543 | ALOGE("(%s): preview stream not exist", __FUNCTION__); |
| 1544 | return 1; |
| 1545 | } |
| 1546 | *stream_id = 3; |
| 1547 | |
| 1548 | *format_actual = format; |
| 1549 | *usage = GRALLOC_USAGE_SW_WRITE_OFTEN; |
| 1550 | *max_buffers = 4; |
| 1551 | if (width == parentStream->m_parameters.outputWidth |
| 1552 | && height == parentStream->m_parameters.outputHeight) { |
| 1553 | |
| 1554 | callbackParameters.outputWidth = width; |
| 1555 | callbackParameters.outputHeight = height; |
| 1556 | callbackParameters.outputFormat = *format_actual; |
| 1557 | callbackParameters.svcPlanes = NUM_PLANES(*format_actual); |
| 1558 | callbackParameters.streamOps = stream_ops; |
| 1559 | callbackParameters.usage = *usage; |
| 1560 | callbackParameters.numOwnSvcBuffers = *max_buffers; |
| 1561 | callbackParameters.numSvcBufsInHal = 0; |
| 1562 | if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) { |
| 1563 | callbackParameters.internalFormat = HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP; |
| 1564 | callbackParameters.internalPlanes = NUM_PLANES(HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP); |
| 1565 | } |
| 1566 | else { |
| 1567 | callbackParameters.internalFormat = HAL_PIXEL_FORMAT_EXYNOS_YV12; |
| 1568 | callbackParameters.internalPlanes = NUM_PLANES(HAL_PIXEL_FORMAT_EXYNOS_YV12); |
| 1569 | } |
| 1570 | |
| 1571 | parentStream->setCallbackParameter(&callbackParameters); |
| 1572 | m_previewCbEnabled = true; |
| 1573 | ALOGV("(%s): Enabling Previewcb - planes(%d)", __FUNCTION__, callbackParameters.svcPlanes); |
| 1574 | } |
| 1575 | return 0; |
| 1576 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1577 | ALOGE("DEBUG(%s): Unsupported Pixel Format", __FUNCTION__); |
| 1578 | return 1; // TODO : check proper error code |
| 1579 | } |
| 1580 | |
| 1581 | int ExynosCameraHWInterface2::registerStreamBuffers(uint32_t stream_id, |
| 1582 | int num_buffers, buffer_handle_t *registeringBuffers) |
| 1583 | { |
| 1584 | int i,j; |
| 1585 | void *virtAddr[3]; |
| 1586 | uint32_t plane_index = 0; |
| 1587 | stream_parameters_t *targetStreamParms; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1588 | record_parameters_t *targetRecordParms; |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1589 | callback_parameters_t *targetCallbackParms; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1590 | node_info_t *currentNode; |
| 1591 | |
| 1592 | struct v4l2_buffer v4l2_buf; |
| 1593 | struct v4l2_plane planes[VIDEO_MAX_PLANES]; |
| 1594 | |
| 1595 | ALOGV("DEBUG(%s): streamID (%d), num_buff(%d), handle(%x) ", __FUNCTION__, |
| 1596 | stream_id, num_buffers, (uint32_t)registeringBuffers); |
| 1597 | |
| 1598 | if (stream_id == 0) { |
| 1599 | targetStreamParms = &(m_streamThreads[0]->m_parameters); |
| 1600 | } |
| 1601 | else if (stream_id == 1) { |
| 1602 | targetStreamParms = &(m_streamThreads[1]->m_parameters); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1603 | // TODO : make clear stream off case |
| 1604 | m_need_streamoff = 0; |
| 1605 | |
| 1606 | if (m_camera_info.capture.status == false) { |
| 1607 | /* capture */ |
| 1608 | m_camera_info.capture.buffers = 8; |
| 1609 | cam_int_s_fmt(&(m_camera_info.capture)); |
| 1610 | cam_int_reqbufs(&(m_camera_info.capture)); |
| 1611 | for (i = 0; i < m_camera_info.capture.buffers; i++) { |
| 1612 | ALOGV("DEBUG(%s): capture initial QBUF [%d]", __FUNCTION__, i); |
| 1613 | cam_int_qbuf(&(m_camera_info.capture), i); |
| 1614 | } |
| 1615 | |
| 1616 | if (cam_int_streamon(&(m_camera_info.capture)) < 0) { |
| 1617 | ALOGE("ERR(%s): capture stream on fail", __FUNCTION__); |
| 1618 | } else { |
| 1619 | m_camera_info.capture.status = true; |
| 1620 | } |
| 1621 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1622 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1623 | else if (stream_id == 2) { |
| 1624 | targetRecordParms = &(m_streamThreads[0]->m_recordParameters); |
| 1625 | |
| 1626 | targetRecordParms->numSvcBuffers = num_buffers; |
| 1627 | |
| 1628 | for (i = 0 ; i<targetRecordParms->numSvcBuffers ; i++) { |
| 1629 | ALOGV("DEBUG(%s): registering Stream Buffers[%d] (%x) ", __FUNCTION__, |
| 1630 | i, (uint32_t)(registeringBuffers[i])); |
| 1631 | if (m_grallocHal) { |
| 1632 | if (m_grallocHal->lock(m_grallocHal, registeringBuffers[i], |
| 1633 | targetRecordParms->usage, 0, 0, |
| 1634 | targetRecordParms->outputWidth, targetRecordParms->outputHeight, virtAddr) != 0) { |
| 1635 | ALOGE("ERR(%s): could not obtain gralloc buffer", __FUNCTION__); |
| 1636 | } |
| 1637 | else { |
| 1638 | ExynosBuffer currentBuf; |
| 1639 | const private_handle_t *priv_handle = reinterpret_cast<const private_handle_t *>(registeringBuffers[i]); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1640 | currentBuf.fd.extFd[0] = priv_handle->fd; |
Alex Ray | 6bbb593 | 2012-07-27 17:19:48 -0700 | [diff] [blame] | 1641 | currentBuf.fd.extFd[1] = priv_handle->fd1; |
| 1642 | currentBuf.fd.extFd[2] = priv_handle->fd2; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1643 | for (plane_index=0 ; plane_index < targetRecordParms->svcPlanes ; plane_index++) { |
| 1644 | currentBuf.virt.extP[plane_index] = (char *)virtAddr[plane_index]; |
| 1645 | ALOGV("DEBUG(%s): plane(%d): fd(%d) addr(%x)", |
Sungjoong Kang | 804236a | 2012-08-05 10:36:19 -0700 | [diff] [blame] | 1646 | __FUNCTION__, plane_index, currentBuf.fd.extFd[plane_index], |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1647 | (unsigned int)currentBuf.virt.extP[plane_index]); |
| 1648 | } |
| 1649 | targetRecordParms->svcBufStatus[i] = ON_SERVICE; |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1650 | targetRecordParms->svcBuffers[i] = currentBuf; |
| 1651 | targetRecordParms->svcBufHandle[i] = registeringBuffers[i]; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1652 | } |
| 1653 | } |
| 1654 | } |
| 1655 | m_needsRecordBufferInit = true; |
| 1656 | return 0; |
| 1657 | } |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1658 | else if (stream_id == 3) { |
| 1659 | targetCallbackParms = &(m_streamThreads[0]->m_previewCbParameters); |
| 1660 | |
| 1661 | targetCallbackParms->numSvcBuffers = num_buffers; |
| 1662 | |
| 1663 | for (i = 0 ; i < targetCallbackParms->numSvcBuffers ; i++) { |
| 1664 | ALOGE("%s: registering Stream Buffers[%d] (%x) ", __FUNCTION__, |
| 1665 | i, (uint32_t)(registeringBuffers[i])); |
| 1666 | if (m_grallocHal) { |
| 1667 | if (m_grallocHal->lock(m_grallocHal, registeringBuffers[i], |
| 1668 | targetCallbackParms->usage, 0, 0, |
| 1669 | targetCallbackParms->outputWidth, targetCallbackParms->outputHeight, virtAddr) != 0) { |
| 1670 | ALOGE("ERR(%s): could not obtain gralloc buffer", __FUNCTION__); |
| 1671 | } |
| 1672 | else { |
| 1673 | ExynosBuffer currentBuf; |
| 1674 | const private_handle_t *priv_handle = reinterpret_cast<const private_handle_t *>(registeringBuffers[i]); |
| 1675 | currentBuf.fd.extFd[0] = priv_handle->fd; |
| 1676 | currentBuf.fd.extFd[1] = priv_handle->fd1; |
| 1677 | currentBuf.fd.extFd[2] = priv_handle->fd2; |
| 1678 | for (plane_index = 0 ; plane_index < targetCallbackParms->svcPlanes ; plane_index++) { |
| 1679 | currentBuf.virt.extP[plane_index] = (char *)virtAddr[plane_index]; |
| 1680 | } |
| 1681 | ALOGV("fd(%d) addr(%x) fd1(%d) fd2(%d)", priv_handle->fd, (unsigned int)currentBuf.virt.extP[plane_index], |
| 1682 | priv_handle->fd1, priv_handle->fd2); |
| 1683 | ALOGV("flags(%d) size(%d) offset(%d) stride(%d) vstride(%d)", |
| 1684 | priv_handle->flags, priv_handle->size, priv_handle->offset, |
| 1685 | priv_handle->stride, priv_handle->vstride); |
| 1686 | targetCallbackParms->svcBufStatus[i] = ON_SERVICE; |
| 1687 | targetCallbackParms->svcBuffers[i] = currentBuf; |
| 1688 | targetCallbackParms->svcBufHandle[i] = registeringBuffers[i]; |
| 1689 | } |
| 1690 | } |
| 1691 | } |
| 1692 | m_needsPreviewCbBufferInit = true; |
| 1693 | return 0; |
| 1694 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1695 | else { |
| 1696 | ALOGE("ERR(%s) unregisterd stream id (%d)", __FUNCTION__, stream_id); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1697 | return 1; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1698 | } |
| 1699 | |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1700 | if (targetStreamParms->streamType == STREAM_TYPE_DIRECT) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1701 | if (num_buffers < targetStreamParms->numHwBuffers) { |
| 1702 | ALOGE("ERR(%s) registering insufficient num of buffers (%d) < (%d)", |
| 1703 | __FUNCTION__, num_buffers, targetStreamParms->numHwBuffers); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1704 | return 1; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1705 | } |
| 1706 | } |
| 1707 | ALOGV("DEBUG(%s): format(%x) width(%d), height(%d) svcPlanes(%d)", |
| 1708 | __FUNCTION__, targetStreamParms->outputFormat, targetStreamParms->outputWidth, |
| 1709 | targetStreamParms->outputHeight, targetStreamParms->svcPlanes); |
| 1710 | |
| 1711 | targetStreamParms->numSvcBuffers = num_buffers; |
| 1712 | currentNode = &(targetStreamParms->node); // TO Remove |
| 1713 | |
| 1714 | currentNode->fd = targetStreamParms->fd; |
| 1715 | currentNode->width = targetStreamParms->nodeWidth; |
| 1716 | currentNode->height = targetStreamParms->nodeHeight; |
| 1717 | currentNode->format = targetStreamParms->nodeFormat; |
| 1718 | currentNode->planes = targetStreamParms->nodePlanes; |
| 1719 | currentNode->buffers = targetStreamParms->numHwBuffers; |
| 1720 | currentNode->type = targetStreamParms->halBuftype; |
| 1721 | currentNode->memory = targetStreamParms->memory; |
| 1722 | currentNode->ionClient = targetStreamParms->ionClient; |
| 1723 | |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1724 | if (targetStreamParms->streamType == STREAM_TYPE_DIRECT) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1725 | if(m_need_streamoff == 1) { |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1726 | if (m_sensorThread != NULL) { |
| 1727 | m_sensorThread->release(); |
| 1728 | /* TODO */ |
| 1729 | usleep(500000); |
| 1730 | } else { |
| 1731 | ALOGE("+++++++ sensor thread is NULL %d", __LINE__); |
| 1732 | } |
| 1733 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1734 | ALOGV("(%s): calling capture streamoff", __FUNCTION__); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1735 | if (cam_int_streamoff(&(m_camera_info.capture)) < 0) { |
| 1736 | ALOGE("ERR(%s): capture stream off fail", __FUNCTION__); |
| 1737 | } else { |
| 1738 | m_camera_info.capture.status = false; |
| 1739 | } |
| 1740 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1741 | ALOGV("(%s): calling capture streamoff done", __FUNCTION__); |
| 1742 | |
| 1743 | m_camera_info.capture.buffers = 0; |
| 1744 | ALOGV("DEBUG(%s): capture calling reqbuf 0 ", __FUNCTION__); |
| 1745 | cam_int_reqbufs(&(m_camera_info.capture)); |
| 1746 | ALOGV("DEBUG(%s): capture calling reqbuf 0 done", __FUNCTION__); |
| 1747 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1748 | m_isIspStarted = false; |
| 1749 | } |
| 1750 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1751 | if (m_need_streamoff == 1) { |
| 1752 | m_camera_info.sensor.buffers = NUM_BAYER_BUFFERS; |
| 1753 | m_camera_info.isp.buffers = m_camera_info.sensor.buffers; |
| 1754 | m_camera_info.capture.buffers = 8; |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1755 | /* isp */ |
| 1756 | cam_int_s_fmt(&(m_camera_info.isp)); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1757 | cam_int_reqbufs(&(m_camera_info.isp)); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1758 | /* sensor */ |
| 1759 | cam_int_s_fmt(&(m_camera_info.sensor)); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1760 | cam_int_reqbufs(&(m_camera_info.sensor)); |
| 1761 | |
| 1762 | for (i = 0; i < 8; i++) { |
| 1763 | ALOGV("DEBUG(%s): sensor initial QBUF [%d]", __FUNCTION__, i); |
| 1764 | memcpy( m_camera_info.sensor.buffer[i].virt.extP[1], &(m_camera_info.dummy_shot), |
| 1765 | sizeof(struct camera2_shot_ext)); |
| 1766 | m_camera_info.dummy_shot.shot.ctl.sensor.frameDuration = 33*1000*1000; // apply from frame #1 |
| 1767 | m_camera_info.dummy_shot.shot.ctl.request.frameCount = -1; |
| 1768 | cam_int_qbuf(&(m_camera_info.sensor), i); |
| 1769 | } |
| 1770 | |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1771 | /* capture */ |
| 1772 | cam_int_s_fmt(&(m_camera_info.capture)); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1773 | cam_int_reqbufs(&(m_camera_info.capture)); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1774 | for (i = 0; i < m_camera_info.capture.buffers; i++) { |
| 1775 | ALOGV("DEBUG(%s): capture initial QBUF [%d]", __FUNCTION__, i); |
| 1776 | cam_int_qbuf(&(m_camera_info.capture), i); |
| 1777 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1778 | |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1779 | } |
| 1780 | |
| 1781 | cam_int_s_input(currentNode, m_camera_info.sensor_id); |
| 1782 | cam_int_s_fmt(currentNode); |
| 1783 | cam_int_reqbufs(currentNode); |
| 1784 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1785 | } |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1786 | else if (targetStreamParms->streamType == STREAM_TYPE_INDIRECT) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1787 | for(i = 0; i < currentNode->buffers; i++){ |
| 1788 | memcpy(&(currentNode->buffer[i]), &(m_camera_info.capture.buffer[i]), sizeof(ExynosBuffer)); |
| 1789 | } |
| 1790 | } |
| 1791 | |
| 1792 | for (i = 0 ; i<targetStreamParms->numSvcBuffers ; i++) { |
| 1793 | ALOGV("DEBUG(%s): registering Stream Buffers[%d] (%x) ", __FUNCTION__, |
| 1794 | i, (uint32_t)(registeringBuffers[i])); |
| 1795 | if (m_grallocHal) { |
| 1796 | if (m_grallocHal->lock(m_grallocHal, registeringBuffers[i], |
| 1797 | targetStreamParms->usage, 0, 0, |
| 1798 | currentNode->width, currentNode->height, virtAddr) != 0) { |
| 1799 | ALOGE("ERR(%s): could not obtain gralloc buffer", __FUNCTION__); |
| 1800 | } |
| 1801 | else { |
| 1802 | v4l2_buf.m.planes = planes; |
| 1803 | v4l2_buf.type = currentNode->type; |
| 1804 | v4l2_buf.memory = currentNode->memory; |
| 1805 | v4l2_buf.index = i; |
| 1806 | v4l2_buf.length = currentNode->planes; |
| 1807 | |
| 1808 | ExynosBuffer currentBuf; |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 1809 | ExynosBuffer metaBuf; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1810 | const private_handle_t *priv_handle = reinterpret_cast<const private_handle_t *>(registeringBuffers[i]); |
| 1811 | |
| 1812 | m_getAlignedYUVSize(currentNode->format, |
| 1813 | currentNode->width, currentNode->height, ¤tBuf); |
Alex Ray | 2423122 | 2012-06-27 15:18:15 -0700 | [diff] [blame] | 1814 | |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1815 | ALOGV("DEBUG(%s): ion_size(%d), stride(%d), ", __FUNCTION__, priv_handle->size, priv_handle->stride); |
| 1816 | if (currentNode->planes == 1) { |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1817 | v4l2_buf.m.planes[0].m.fd = priv_handle->fd; |
| 1818 | currentBuf.fd.extFd[0] = priv_handle->fd; |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1819 | currentBuf.size.extS[0] = priv_handle->size; |
| 1820 | currentBuf.size.extS[1] = 0; |
| 1821 | currentBuf.size.extS[2] = 0; |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1822 | } else if (currentNode->planes == 2) { |
| 1823 | v4l2_buf.m.planes[0].m.fd = priv_handle->fd; |
| 1824 | v4l2_buf.m.planes[1].m.fd = priv_handle->fd1; |
| 1825 | currentBuf.fd.extFd[0] = priv_handle->fd; |
| 1826 | currentBuf.fd.extFd[1] = priv_handle->fd1; |
| 1827 | |
| 1828 | } else if (currentNode->planes == 3) { |
| 1829 | v4l2_buf.m.planes[0].m.fd = priv_handle->fd; |
| 1830 | v4l2_buf.m.planes[2].m.fd = priv_handle->fd1; |
| 1831 | v4l2_buf.m.planes[1].m.fd = priv_handle->fd2; |
| 1832 | currentBuf.fd.extFd[0] = priv_handle->fd; |
| 1833 | currentBuf.fd.extFd[2] = priv_handle->fd1; |
| 1834 | currentBuf.fd.extFd[1] = priv_handle->fd2; |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1835 | } |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1836 | for (plane_index = 0 ; plane_index < v4l2_buf.length ; plane_index++) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1837 | currentBuf.virt.extP[plane_index] = (char *)virtAddr[plane_index]; |
| 1838 | v4l2_buf.m.planes[plane_index].length = currentBuf.size.extS[plane_index]; |
| 1839 | ALOGV("DEBUG(%s): plane(%d): fd(%d) addr(%x), length(%d)", |
| 1840 | __FUNCTION__, plane_index, v4l2_buf.m.planes[plane_index].m.fd, |
| 1841 | (unsigned int)currentBuf.virt.extP[plane_index], |
| 1842 | v4l2_buf.m.planes[plane_index].length); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1843 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1844 | |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1845 | if (targetStreamParms->streamType == STREAM_TYPE_DIRECT) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1846 | if (i < currentNode->buffers) { |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 1847 | |
| 1848 | |
| 1849 | #ifdef ENABLE_FRAME_SYNC |
| 1850 | /* add plane for metadata*/ |
| 1851 | metaBuf.size.extS[0] = 4*1024; |
| 1852 | allocCameraMemory(targetStreamParms->ionClient , &metaBuf, 1); |
| 1853 | |
| 1854 | v4l2_buf.length += targetStreamParms->metaPlanes; |
| 1855 | v4l2_buf.m.planes[3].m.fd = metaBuf.fd.extFd[0]; |
| 1856 | v4l2_buf.m.planes[3].length = metaBuf.size.extS[0]; |
| 1857 | |
| 1858 | ALOGV("Qbuf metaBuf: fd(%d), length(%d) plane(%d)", metaBuf.fd.extFd[0], metaBuf.size.extS[0], v4l2_buf.length); |
| 1859 | #endif |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1860 | if (exynos_v4l2_qbuf(currentNode->fd, &v4l2_buf) < 0) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1861 | ALOGE("ERR(%s): stream id(%d) exynos_v4l2_qbuf() fail fd(%d)", |
| 1862 | __FUNCTION__, stream_id, currentNode->fd); |
| 1863 | //return false; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1864 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1865 | ALOGV("DEBUG(%s): stream id(%d) exynos_v4l2_qbuf() success fd(%d)", |
| 1866 | __FUNCTION__, stream_id, currentNode->fd); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1867 | targetStreamParms->svcBufStatus[i] = REQUIRES_DQ_FROM_SVC; |
| 1868 | } |
| 1869 | else { |
| 1870 | targetStreamParms->svcBufStatus[i] = ON_SERVICE; |
| 1871 | } |
| 1872 | } |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 1873 | else if (targetStreamParms->streamType == STREAM_TYPE_INDIRECT) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1874 | targetStreamParms->svcBufStatus[i] = ON_SERVICE; |
| 1875 | } |
| 1876 | targetStreamParms->svcBuffers[i] = currentBuf; |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 1877 | targetStreamParms->metaBuffers[i] = metaBuf; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1878 | targetStreamParms->svcBufHandle[i] = registeringBuffers[i]; |
| 1879 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1880 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1881 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1882 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1883 | ALOGV("DEBUG(%s): calling streamon", __FUNCTION__); |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1884 | if (targetStreamParms->streamType == STREAM_TYPE_DIRECT) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1885 | ALOGD("%s(%d), stream id = %d", __FUNCTION__, __LINE__, stream_id); |
| 1886 | cam_int_streamon(&(targetStreamParms->node)); |
| 1887 | } |
| 1888 | |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1889 | if (m_need_streamoff == 1) { |
| 1890 | if (cam_int_streamon(&(m_camera_info.capture)) < 0) { |
| 1891 | ALOGE("ERR(%s): capture stream on fail", __FUNCTION__); |
| 1892 | } else { |
| 1893 | m_camera_info.capture.status = true; |
| 1894 | } |
| 1895 | |
| 1896 | cam_int_streamon(&(m_camera_info.sensor)); |
| 1897 | } |
| 1898 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1899 | ALOGV("DEBUG(%s): calling streamon END", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1900 | ALOGV("DEBUG(%s): END registerStreamBuffers", __FUNCTION__); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1901 | |
| 1902 | if(!m_isIspStarted) { |
| 1903 | m_isIspStarted = true; |
| 1904 | StartISP(); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1905 | } |
| 1906 | |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1907 | if (m_need_streamoff == 1) { |
| 1908 | m_requestManager->SetInitialSkip(8); |
| 1909 | m_sensorThread->Start("SensorThread", PRIORITY_DEFAULT, 0); |
| 1910 | m_mainThread->SetSignal(SIGNAL_MAIN_REQ_Q_NOT_EMPTY); |
| 1911 | } |
| 1912 | m_need_streamoff = 1; |
| 1913 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1914 | return 0; |
| 1915 | } |
| 1916 | |
| 1917 | int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id) |
| 1918 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1919 | StreamThread *targetStream; |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 1920 | ALOGV("DEBUG(%s):stream id %d", __FUNCTION__, stream_id); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1921 | |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1922 | if (stream_id == 0) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1923 | targetStream = (StreamThread*)(m_streamThreads[0].get()); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1924 | m_scp_flushing = true; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1925 | } |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1926 | else if (stream_id == 1) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1927 | targetStream = (StreamThread*)(m_streamThreads[1].get()); |
| 1928 | } |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1929 | else if (stream_id == 2 && m_recordingEnabled) { |
| 1930 | m_recordingEnabled = false; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 1931 | m_needsRecordBufferInit = true; |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1932 | return 0; |
| 1933 | } |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 1934 | else if (stream_id == 3 && m_previewCbEnabled) { |
| 1935 | m_previewCbEnabled = false; |
| 1936 | m_needsPreviewCbBufferInit = true; |
| 1937 | return 0; |
| 1938 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1939 | else { |
| 1940 | ALOGE("ERR:(%s): wrong stream id (%d)", __FUNCTION__, stream_id); |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 1941 | return 1; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1942 | } |
| 1943 | |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 1944 | targetStream->m_releasing = true; |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 1945 | do { |
| 1946 | ALOGD("stream thread release %d", __LINE__); |
| 1947 | targetStream->release(); |
| 1948 | usleep(33000); |
| 1949 | } while (targetStream->m_releasing); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 1950 | targetStream->m_activated = false; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1951 | ALOGV("DEBUG(%s): DONE", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1952 | return 0; |
| 1953 | } |
| 1954 | |
| 1955 | int ExynosCameraHWInterface2::allocateReprocessStream( |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1956 | uint32_t width, uint32_t height, uint32_t format, |
| 1957 | const camera2_stream_in_ops_t *reprocess_stream_ops, |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1958 | uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers) |
| 1959 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1960 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1961 | return 0; |
| 1962 | } |
| 1963 | |
| 1964 | int ExynosCameraHWInterface2::releaseReprocessStream(uint32_t stream_id) |
| 1965 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 1966 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1967 | return 0; |
| 1968 | } |
| 1969 | |
| 1970 | int ExynosCameraHWInterface2::triggerAction(uint32_t trigger_id, int ext1, int ext2) |
| 1971 | { |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 1972 | ALOGV("DEBUG(%s): id(%x), %d, %d", __FUNCTION__, trigger_id, ext1, ext2); |
| 1973 | |
| 1974 | switch (trigger_id) { |
| 1975 | case CAMERA2_TRIGGER_AUTOFOCUS: |
| 1976 | ALOGV("DEBUG(%s):TRIGGER_AUTOFOCUS id(%d)", __FUNCTION__, ext1); |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 1977 | OnAfTriggerStart(ext1); |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 1978 | break; |
| 1979 | |
| 1980 | case CAMERA2_TRIGGER_CANCEL_AUTOFOCUS: |
| 1981 | ALOGV("DEBUG(%s):CANCEL_AUTOFOCUS id(%d)", __FUNCTION__, ext1); |
| 1982 | OnAfCancel(ext1); |
| 1983 | break; |
| 1984 | default: |
| 1985 | break; |
| 1986 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1987 | return 0; |
| 1988 | } |
| 1989 | |
| 1990 | int ExynosCameraHWInterface2::setNotifyCallback(camera2_notify_callback notify_cb, void *user) |
| 1991 | { |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 1992 | ALOGV("DEBUG(%s): cb_addr(%x)", __FUNCTION__, (unsigned int)notify_cb); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 1993 | m_notifyCb = notify_cb; |
| 1994 | m_callbackCookie = user; |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
| 1998 | int ExynosCameraHWInterface2::getMetadataVendorTagOps(vendor_tag_query_ops_t **ops) |
| 1999 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2000 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2001 | return 0; |
| 2002 | } |
| 2003 | |
| 2004 | int ExynosCameraHWInterface2::dump(int fd) |
| 2005 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2006 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2007 | return 0; |
| 2008 | } |
| 2009 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2010 | void ExynosCameraHWInterface2::m_getAlignedYUVSize(int colorFormat, int w, int h, ExynosBuffer *buf) |
| 2011 | { |
| 2012 | switch (colorFormat) { |
| 2013 | // 1p |
| 2014 | case V4L2_PIX_FMT_RGB565 : |
| 2015 | case V4L2_PIX_FMT_YUYV : |
| 2016 | case V4L2_PIX_FMT_UYVY : |
| 2017 | case V4L2_PIX_FMT_VYUY : |
| 2018 | case V4L2_PIX_FMT_YVYU : |
| 2019 | buf->size.extS[0] = FRAME_SIZE(V4L2_PIX_2_HAL_PIXEL_FORMAT(colorFormat), w, h); |
| 2020 | buf->size.extS[1] = 0; |
| 2021 | buf->size.extS[2] = 0; |
| 2022 | break; |
| 2023 | // 2p |
| 2024 | case V4L2_PIX_FMT_NV12 : |
| 2025 | case V4L2_PIX_FMT_NV12T : |
| 2026 | case V4L2_PIX_FMT_NV21 : |
| 2027 | buf->size.extS[0] = ALIGN(w, 16) * ALIGN(h, 16); |
| 2028 | buf->size.extS[1] = ALIGN(w/2, 16) * ALIGN(h/2, 16); |
| 2029 | buf->size.extS[2] = 0; |
| 2030 | break; |
| 2031 | case V4L2_PIX_FMT_NV12M : |
| 2032 | case V4L2_PIX_FMT_NV12MT_16X16 : |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2033 | case V4L2_PIX_FMT_NV21M: |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2034 | buf->size.extS[0] = ALIGN(w, 16) * ALIGN(h, 16); |
| 2035 | buf->size.extS[1] = ALIGN(buf->size.extS[0] / 2, 256); |
| 2036 | buf->size.extS[2] = 0; |
| 2037 | break; |
| 2038 | case V4L2_PIX_FMT_NV16 : |
| 2039 | case V4L2_PIX_FMT_NV61 : |
| 2040 | buf->size.extS[0] = ALIGN(w, 16) * ALIGN(h, 16); |
| 2041 | buf->size.extS[1] = ALIGN(w, 16) * ALIGN(h, 16); |
| 2042 | buf->size.extS[2] = 0; |
| 2043 | break; |
| 2044 | // 3p |
| 2045 | case V4L2_PIX_FMT_YUV420 : |
| 2046 | case V4L2_PIX_FMT_YVU420 : |
| 2047 | buf->size.extS[0] = (w * h); |
| 2048 | buf->size.extS[1] = (w * h) >> 2; |
| 2049 | buf->size.extS[2] = (w * h) >> 2; |
| 2050 | break; |
| 2051 | case V4L2_PIX_FMT_YUV420M: |
| 2052 | case V4L2_PIX_FMT_YVU420M : |
| 2053 | case V4L2_PIX_FMT_YUV422P : |
| 2054 | buf->size.extS[0] = ALIGN(w, 32) * ALIGN(h, 16); |
| 2055 | buf->size.extS[1] = ALIGN(w/2, 16) * ALIGN(h/2, 8); |
| 2056 | buf->size.extS[2] = ALIGN(w/2, 16) * ALIGN(h/2, 8); |
| 2057 | break; |
| 2058 | default: |
| 2059 | ALOGE("ERR(%s):unmatched colorFormat(%d)", __FUNCTION__, colorFormat); |
| 2060 | return; |
| 2061 | break; |
| 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | bool ExynosCameraHWInterface2::m_getRatioSize(int src_w, int src_h, |
| 2066 | int dst_w, int dst_h, |
| 2067 | int *crop_x, int *crop_y, |
| 2068 | int *crop_w, int *crop_h, |
| 2069 | int zoom) |
| 2070 | { |
| 2071 | *crop_w = src_w; |
| 2072 | *crop_h = src_h; |
| 2073 | |
| 2074 | if ( src_w != dst_w |
| 2075 | || src_h != dst_h) { |
| 2076 | float src_ratio = 1.0f; |
| 2077 | float dst_ratio = 1.0f; |
| 2078 | |
| 2079 | // ex : 1024 / 768 |
| 2080 | src_ratio = (float)src_w / (float)src_h; |
| 2081 | |
| 2082 | // ex : 352 / 288 |
| 2083 | dst_ratio = (float)dst_w / (float)dst_h; |
| 2084 | |
| 2085 | if (dst_w * dst_h < src_w * src_h) { |
| 2086 | if (dst_ratio <= src_ratio) { |
| 2087 | // shrink w |
| 2088 | *crop_w = src_h * dst_ratio; |
| 2089 | *crop_h = src_h; |
| 2090 | } else { |
| 2091 | // shrink h |
| 2092 | *crop_w = src_w; |
| 2093 | *crop_h = src_w / dst_ratio; |
| 2094 | } |
| 2095 | } else { |
| 2096 | if (dst_ratio <= src_ratio) { |
| 2097 | // shrink w |
| 2098 | *crop_w = src_h * dst_ratio; |
| 2099 | *crop_h = src_h; |
| 2100 | } else { |
| 2101 | // shrink h |
| 2102 | *crop_w = src_w; |
| 2103 | *crop_h = src_w / dst_ratio; |
| 2104 | } |
| 2105 | } |
| 2106 | } |
| 2107 | |
| 2108 | if (zoom != 0) { |
| 2109 | float zoomLevel = ((float)zoom + 10.0) / 10.0; |
| 2110 | *crop_w = (int)((float)*crop_w / zoomLevel); |
| 2111 | *crop_h = (int)((float)*crop_h / zoomLevel); |
| 2112 | } |
| 2113 | |
| 2114 | #define CAMERA_CROP_WIDTH_RESTRAIN_NUM (0x2) |
| 2115 | unsigned int w_align = (*crop_w & (CAMERA_CROP_WIDTH_RESTRAIN_NUM - 1)); |
| 2116 | if (w_align != 0) { |
| 2117 | if ( (CAMERA_CROP_WIDTH_RESTRAIN_NUM >> 1) <= w_align |
| 2118 | && *crop_w + (CAMERA_CROP_WIDTH_RESTRAIN_NUM - w_align) <= dst_w) { |
| 2119 | *crop_w += (CAMERA_CROP_WIDTH_RESTRAIN_NUM - w_align); |
| 2120 | } |
| 2121 | else |
| 2122 | *crop_w -= w_align; |
| 2123 | } |
| 2124 | |
| 2125 | #define CAMERA_CROP_HEIGHT_RESTRAIN_NUM (0x2) |
| 2126 | unsigned int h_align = (*crop_h & (CAMERA_CROP_HEIGHT_RESTRAIN_NUM - 1)); |
| 2127 | if (h_align != 0) { |
| 2128 | if ( (CAMERA_CROP_HEIGHT_RESTRAIN_NUM >> 1) <= h_align |
| 2129 | && *crop_h + (CAMERA_CROP_HEIGHT_RESTRAIN_NUM - h_align) <= dst_h) { |
| 2130 | *crop_h += (CAMERA_CROP_HEIGHT_RESTRAIN_NUM - h_align); |
| 2131 | } |
| 2132 | else |
| 2133 | *crop_h -= h_align; |
| 2134 | } |
| 2135 | |
| 2136 | *crop_x = (src_w - *crop_w) >> 1; |
| 2137 | *crop_y = (src_h - *crop_h) >> 1; |
| 2138 | |
| 2139 | if (*crop_x & (CAMERA_CROP_WIDTH_RESTRAIN_NUM >> 1)) |
| 2140 | *crop_x -= 1; |
| 2141 | |
| 2142 | if (*crop_y & (CAMERA_CROP_HEIGHT_RESTRAIN_NUM >> 1)) |
| 2143 | *crop_y -= 1; |
| 2144 | |
| 2145 | return true; |
| 2146 | } |
| 2147 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2148 | BayerBufManager::BayerBufManager() |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2149 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2150 | ALOGV("DEBUG(%s): ", __FUNCTION__); |
| 2151 | for (int i = 0; i < NUM_BAYER_BUFFERS ; i++) { |
| 2152 | entries[i].status = BAYER_ON_HAL_EMPTY; |
| 2153 | entries[i].reqFrameCnt = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2154 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2155 | sensorEnqueueHead = 0; |
| 2156 | sensorDequeueHead = 0; |
| 2157 | ispEnqueueHead = 0; |
| 2158 | ispDequeueHead = 0; |
| 2159 | numOnSensor = 0; |
| 2160 | numOnIsp = 0; |
| 2161 | numOnHalFilled = 0; |
| 2162 | numOnHalEmpty = NUM_BAYER_BUFFERS; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2163 | } |
| 2164 | |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 2165 | BayerBufManager::~BayerBufManager() |
| 2166 | { |
| 2167 | ALOGV("%s", __FUNCTION__); |
| 2168 | } |
| 2169 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2170 | int BayerBufManager::GetIndexForSensorEnqueue() |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2171 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2172 | int ret = 0; |
| 2173 | if (numOnHalEmpty == 0) |
| 2174 | ret = -1; |
| 2175 | else |
| 2176 | ret = sensorEnqueueHead; |
| 2177 | ALOGV("DEBUG(%s): returning (%d)", __FUNCTION__, ret); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2178 | return ret; |
| 2179 | } |
| 2180 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2181 | int BayerBufManager::MarkSensorEnqueue(int index) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2182 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2183 | ALOGV("DEBUG(%s) : BayerIndex[%d] ", __FUNCTION__, index); |
| 2184 | |
| 2185 | // sanity check |
| 2186 | if (index != sensorEnqueueHead) { |
| 2187 | ALOGV("DEBUG(%s) : Abnormal BayerIndex[%d] - expected[%d]", __FUNCTION__, index, sensorEnqueueHead); |
| 2188 | return -1; |
| 2189 | } |
| 2190 | if (entries[index].status != BAYER_ON_HAL_EMPTY) { |
| 2191 | ALOGV("DEBUG(%s) : Abnormal status in BayerIndex[%d] = (%d) expected (%d)", __FUNCTION__, |
| 2192 | index, entries[index].status, BAYER_ON_HAL_EMPTY); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2193 | return -1; |
| 2194 | } |
| 2195 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2196 | entries[index].status = BAYER_ON_SENSOR; |
| 2197 | entries[index].reqFrameCnt = 0; |
| 2198 | numOnHalEmpty--; |
| 2199 | numOnSensor++; |
| 2200 | sensorEnqueueHead = GetNextIndex(index); |
| 2201 | ALOGV("DEBUG(%s) END: HAL-e(%d) HAL-f(%d) Sensor(%d) ISP(%d) ", |
| 2202 | __FUNCTION__, numOnHalEmpty, numOnHalFilled, numOnSensor, numOnIsp); |
| 2203 | return 0; |
| 2204 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2205 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2206 | int BayerBufManager::MarkSensorDequeue(int index, int reqFrameCnt, nsecs_t *timeStamp) |
| 2207 | { |
| 2208 | ALOGV("DEBUG(%s) : BayerIndex[%d] reqFrameCnt(%d)", __FUNCTION__, index, reqFrameCnt); |
| 2209 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2210 | if (entries[index].status != BAYER_ON_SENSOR) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2211 | ALOGE("DEBUG(%s) : Abnormal status in BayerIndex[%d] = (%d) expected (%d)", __FUNCTION__, |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2212 | index, entries[index].status, BAYER_ON_SENSOR); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2213 | return -1; |
| 2214 | } |
| 2215 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2216 | entries[index].status = BAYER_ON_HAL_FILLED; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2217 | numOnHalFilled++; |
| 2218 | numOnSensor--; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2219 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2220 | return 0; |
| 2221 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2222 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2223 | int BayerBufManager::GetIndexForIspEnqueue(int *reqFrameCnt) |
| 2224 | { |
| 2225 | int ret = 0; |
| 2226 | if (numOnHalFilled == 0) |
| 2227 | ret = -1; |
| 2228 | else { |
| 2229 | *reqFrameCnt = entries[ispEnqueueHead].reqFrameCnt; |
| 2230 | ret = ispEnqueueHead; |
| 2231 | } |
| 2232 | ALOGV("DEBUG(%s): returning BayerIndex[%d]", __FUNCTION__, ret); |
| 2233 | return ret; |
| 2234 | } |
| 2235 | |
| 2236 | int BayerBufManager::GetIndexForIspDequeue(int *reqFrameCnt) |
| 2237 | { |
| 2238 | int ret = 0; |
| 2239 | if (numOnIsp == 0) |
| 2240 | ret = -1; |
| 2241 | else { |
| 2242 | *reqFrameCnt = entries[ispDequeueHead].reqFrameCnt; |
| 2243 | ret = ispDequeueHead; |
| 2244 | } |
| 2245 | ALOGV("DEBUG(%s): returning BayerIndex[%d]", __FUNCTION__, ret); |
| 2246 | return ret; |
| 2247 | } |
| 2248 | |
| 2249 | int BayerBufManager::MarkIspEnqueue(int index) |
| 2250 | { |
| 2251 | ALOGV("DEBUG(%s) : BayerIndex[%d] ", __FUNCTION__, index); |
| 2252 | |
| 2253 | // sanity check |
| 2254 | if (index != ispEnqueueHead) { |
| 2255 | ALOGV("DEBUG(%s) : Abnormal BayerIndex[%d] - expected[%d]", __FUNCTION__, index, ispEnqueueHead); |
| 2256 | return -1; |
| 2257 | } |
| 2258 | if (entries[index].status != BAYER_ON_HAL_FILLED) { |
| 2259 | ALOGV("DEBUG(%s) : Abnormal status in BayerIndex[%d] = (%d) expected (%d)", __FUNCTION__, |
| 2260 | index, entries[index].status, BAYER_ON_HAL_FILLED); |
| 2261 | return -1; |
| 2262 | } |
| 2263 | |
| 2264 | entries[index].status = BAYER_ON_ISP; |
| 2265 | numOnHalFilled--; |
| 2266 | numOnIsp++; |
| 2267 | ispEnqueueHead = GetNextIndex(index); |
| 2268 | ALOGV("DEBUG(%s) END: HAL-e(%d) HAL-f(%d) Sensor(%d) ISP(%d) ", |
| 2269 | __FUNCTION__, numOnHalEmpty, numOnHalFilled, numOnSensor, numOnIsp); |
| 2270 | return 0; |
| 2271 | } |
| 2272 | |
| 2273 | int BayerBufManager::MarkIspDequeue(int index) |
| 2274 | { |
| 2275 | ALOGV("DEBUG(%s) : BayerIndex[%d]", __FUNCTION__, index); |
| 2276 | |
| 2277 | // sanity check |
| 2278 | if (index != ispDequeueHead) { |
| 2279 | ALOGV("DEBUG(%s) : Abnormal BayerIndex[%d] - expected[%d]", __FUNCTION__, index, ispDequeueHead); |
| 2280 | return -1; |
| 2281 | } |
| 2282 | if (entries[index].status != BAYER_ON_ISP) { |
| 2283 | ALOGV("DEBUG(%s) : Abnormal status in BayerIndex[%d] = (%d) expected (%d)", __FUNCTION__, |
| 2284 | index, entries[index].status, BAYER_ON_ISP); |
| 2285 | return -1; |
| 2286 | } |
| 2287 | |
| 2288 | entries[index].status = BAYER_ON_HAL_EMPTY; |
| 2289 | entries[index].reqFrameCnt = 0; |
| 2290 | numOnHalEmpty++; |
| 2291 | numOnIsp--; |
| 2292 | ispDequeueHead = GetNextIndex(index); |
| 2293 | ALOGV("DEBUG(%s) END: HAL-e(%d) HAL-f(%d) Sensor(%d) ISP(%d) ", |
| 2294 | __FUNCTION__, numOnHalEmpty, numOnHalFilled, numOnSensor, numOnIsp); |
| 2295 | return 0; |
| 2296 | } |
| 2297 | |
| 2298 | int BayerBufManager::GetNumOnSensor() |
| 2299 | { |
| 2300 | return numOnSensor; |
| 2301 | } |
| 2302 | |
| 2303 | int BayerBufManager::GetNumOnHalFilled() |
| 2304 | { |
| 2305 | return numOnHalFilled; |
| 2306 | } |
| 2307 | |
| 2308 | int BayerBufManager::GetNumOnIsp() |
| 2309 | { |
| 2310 | return numOnIsp; |
| 2311 | } |
| 2312 | |
| 2313 | int BayerBufManager::GetNextIndex(int index) |
| 2314 | { |
| 2315 | index++; |
| 2316 | if (index >= NUM_BAYER_BUFFERS) |
| 2317 | index = 0; |
| 2318 | |
| 2319 | return index; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2320 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2321 | |
| 2322 | void ExynosCameraHWInterface2::m_mainThreadFunc(SignalDrivenThread * self) |
| 2323 | { |
| 2324 | camera_metadata_t *currentRequest = NULL; |
| 2325 | camera_metadata_t *currentFrame = NULL; |
| 2326 | size_t numEntries = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2327 | size_t frameSize = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2328 | camera_metadata_t * preparedFrame = NULL; |
| 2329 | camera_metadata_t *deregisteredRequest = NULL; |
| 2330 | uint32_t currentSignal = self->GetProcessingSignal(); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2331 | MainThread * selfThread = ((MainThread*)self); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2332 | int res = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2333 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2334 | int ret; |
| 2335 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2336 | ALOGV("DEBUG(%s): m_mainThreadFunc (%x)", __FUNCTION__, currentSignal); |
| 2337 | |
| 2338 | if (currentSignal & SIGNAL_THREAD_RELEASE) { |
| 2339 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE", __FUNCTION__); |
| 2340 | |
| 2341 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE DONE", __FUNCTION__); |
| 2342 | selfThread->SetSignal(SIGNAL_THREAD_TERMINATE); |
| 2343 | return; |
| 2344 | } |
| 2345 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2346 | if (currentSignal & SIGNAL_MAIN_REQ_Q_NOT_EMPTY) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2347 | ALOGV("DEBUG(%s): MainThread processing SIGNAL_MAIN_REQ_Q_NOT_EMPTY", __FUNCTION__); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2348 | if (m_requestManager->IsRequestQueueFull()==false) { |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2349 | m_requestQueueOps->dequeue_request(m_requestQueueOps, ¤tRequest); |
| 2350 | if (NULL == currentRequest) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2351 | ALOGE("DEBUG(%s)(0x%x): dequeue_request returned NULL ", __FUNCTION__, currentSignal); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2352 | m_isRequestQueueNull = true; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2353 | } |
| 2354 | else { |
| 2355 | m_requestManager->RegisterRequest(currentRequest); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2356 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2357 | m_numOfRemainingReqInSvc = m_requestQueueOps->request_count(m_requestQueueOps); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2358 | ALOGV("DEBUG(%s): remaining req cnt (%d)", __FUNCTION__, m_numOfRemainingReqInSvc); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2359 | if (m_requestManager->IsRequestQueueFull()==false) |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2360 | selfThread->SetSignal(SIGNAL_MAIN_REQ_Q_NOT_EMPTY); // dequeue repeatedly |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2361 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2362 | m_sensorThread->SetSignal(SIGNAL_SENSOR_START_REQ_PROCESSING); |
| 2363 | } |
| 2364 | } |
| 2365 | else { |
| 2366 | m_isRequestQueuePending = true; |
| 2367 | } |
| 2368 | } |
| 2369 | |
| 2370 | if (currentSignal & SIGNAL_MAIN_STREAM_OUTPUT_DONE) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2371 | ALOGV("DEBUG(%s): MainThread processing SIGNAL_MAIN_STREAM_OUTPUT_DONE", __FUNCTION__); |
| 2372 | /*while (1)*/ { |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 2373 | ret = m_requestManager->PrepareFrame(&numEntries, &frameSize, &preparedFrame, GetAfStateForService()); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2374 | if (ret == false) |
| 2375 | ALOGD("++++++ PrepareFrame ret = %d", ret); |
| 2376 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2377 | m_requestManager->DeregisterRequest(&deregisteredRequest); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2378 | |
| 2379 | ret = m_requestQueueOps->free_request(m_requestQueueOps, deregisteredRequest); |
| 2380 | if (ret < 0) |
| 2381 | ALOGD("++++++ free_request ret = %d", ret); |
| 2382 | |
| 2383 | ret = m_frameQueueOps->dequeue_frame(m_frameQueueOps, numEntries, frameSize, ¤tFrame); |
| 2384 | if (ret < 0) |
| 2385 | ALOGD("++++++ dequeue_frame ret = %d", ret); |
| 2386 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2387 | if (currentFrame==NULL) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2388 | ALOGV("DBG(%s): frame dequeue returned NULL",__FUNCTION__ ); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2389 | } |
| 2390 | else { |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 2391 | ALOGV("DEBUG(%s): frame dequeue done. numEntries(%d) frameSize(%d)",__FUNCTION__ , numEntries, frameSize); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2392 | } |
| 2393 | res = append_camera_metadata(currentFrame, preparedFrame); |
| 2394 | if (res==0) { |
| 2395 | ALOGV("DEBUG(%s): frame metadata append success",__FUNCTION__); |
| 2396 | m_frameQueueOps->enqueue_frame(m_frameQueueOps, currentFrame); |
| 2397 | } |
| 2398 | else { |
| 2399 | ALOGE("ERR(%s): frame metadata append fail (%d)",__FUNCTION__, res); |
| 2400 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2401 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2402 | if (!m_isRequestQueueNull) { |
| 2403 | selfThread->SetSignal(SIGNAL_MAIN_REQ_Q_NOT_EMPTY); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2404 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2405 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2406 | if (getInProgressCount()>0) { |
| 2407 | ALOGV("DEBUG(%s): STREAM_OUTPUT_DONE and signalling REQ_PROCESSING",__FUNCTION__); |
| 2408 | m_sensorThread->SetSignal(SIGNAL_SENSOR_START_REQ_PROCESSING); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2409 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2410 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2411 | ALOGV("DEBUG(%s): MainThread Exit", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2412 | return; |
| 2413 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2414 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 2415 | void ExynosCameraHWInterface2::m_sensorThreadInitialize(SignalDrivenThread * self) |
| 2416 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2417 | ALOGV("DEBUG(%s): ", __FUNCTION__ ); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2418 | /* will add */ |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2419 | return; |
| 2420 | } |
| 2421 | |
| 2422 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2423 | void ExynosCameraHWInterface2::DumpInfoWithShot(struct camera2_shot_ext * shot_ext) |
| 2424 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2425 | ALOGD("#### common Section"); |
| 2426 | ALOGD("#### magic(%x) ", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2427 | shot_ext->shot.magicNumber); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2428 | ALOGD("#### ctl Section"); |
| 2429 | ALOGD("#### meta(%d) aper(%f) exp(%lld) duration(%lld) ISO(%d) AWB(%d)", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2430 | shot_ext->shot.ctl.request.metadataMode, |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 2431 | shot_ext->shot.ctl.lens.aperture, |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2432 | shot_ext->shot.ctl.sensor.exposureTime, |
| 2433 | shot_ext->shot.ctl.sensor.frameDuration, |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 2434 | shot_ext->shot.ctl.sensor.sensitivity, |
| 2435 | shot_ext->shot.ctl.aa.awbMode); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2436 | |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 2437 | ALOGD("#### OutputStream Sensor(%d) SCP(%d) SCC(%d) pv(%d) rec(%d) previewCb(%d)", |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2438 | shot_ext->request_sensor, shot_ext->request_scp, shot_ext->request_scc, |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 2439 | shot_ext->shot.ctl.request.outputStreams[0], shot_ext->shot.ctl.request.outputStreams[2], |
| 2440 | shot_ext->shot.ctl.request.outputStreams[3]); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2441 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2442 | ALOGD("#### DM Section"); |
| 2443 | ALOGD("#### meta(%d) aper(%f) exp(%lld) duration(%lld) ISO(%d) timestamp(%lld) AWB(%d) cnt(%d)", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2444 | shot_ext->shot.dm.request.metadataMode, |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 2445 | shot_ext->shot.dm.lens.aperture, |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2446 | shot_ext->shot.dm.sensor.exposureTime, |
| 2447 | shot_ext->shot.dm.sensor.frameDuration, |
| 2448 | shot_ext->shot.dm.sensor.sensitivity, |
Sungjoong Kang | b56dcc0 | 2012-08-08 13:38:09 -0700 | [diff] [blame] | 2449 | shot_ext->shot.dm.sensor.timeStamp, |
| 2450 | shot_ext->shot.dm.aa.awbMode, |
| 2451 | shot_ext->shot.dm.request.frameCount ); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2452 | } |
| 2453 | |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2454 | void ExynosCameraHWInterface2::flashSetter(struct camera2_shot_ext * shot_ext) |
| 2455 | { |
| 2456 | // 1. AF Flash |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2457 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 2458 | switch (m_ctlInfo.flash.m_afFlashCnt) { |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2459 | case IS_FLASH_AF_ON: |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2460 | ALOGV("(%s): [AF Flash] IS_FLASH_ON", __FUNCTION__); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2461 | if (m_ctlInfo.flash.i_flashMode == AA_AEMODE_ON_ALWAYS_FLASH) { |
| 2462 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_ON_ALWAYS; |
| 2463 | m_ctlInfo.flash.m_flashWaitCnt = 0; |
| 2464 | } else |
| 2465 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_ON; |
| 2466 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_ON_START; |
| 2467 | break; |
| 2468 | case IS_FLASH_AF_AUTO_AE_AWB_LOCK: |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2469 | ALOGV("(%s): [AF Flash] IS_FLASH_AF_AUTO_AE_AWB_LOCK", __FUNCTION__); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2470 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_AUTO; |
| 2471 | shot_ext->shot.ctl.aa.awbMode = AA_AWBMODE_LOCKED; |
| 2472 | //shot_ext->shot.ctl.aa.aeMode = AA_AEMODE_LOCKED; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2473 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_AE_AWB_LOCK_WAIT; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2474 | break; |
| 2475 | case IF_FLASH_AF_OFF: |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2476 | ALOGV("(%s): [AF Flash] IS_FLASH_OFF and status clear", __FUNCTION__); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2477 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_OFF; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2478 | m_ctlInfo.flash.m_afFlashEnableFlg = false; |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2479 | m_ctlInfo.flash.m_afFlashDoneFlg = true; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2480 | m_ctlInfo.flash.m_afFlashCnt = 0; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2481 | break; |
| 2482 | } |
| 2483 | } |
| 2484 | |
| 2485 | // 2. Flash |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2486 | if (m_ctlInfo.flash.m_flashEnableFlg) { |
| 2487 | switch (m_ctlInfo.flash.m_flashCnt) { |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2488 | case IS_FLASH_ON: |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2489 | ALOGV("(%s): [Flash] Flash ON for Capture", __FUNCTION__); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2490 | if (m_ctlInfo.flash.i_flashMode == AA_AEMODE_ON_ALWAYS_FLASH) { |
| 2491 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_ON_ALWAYS; |
| 2492 | m_ctlInfo.flash.m_flashWaitCnt = 0; |
| 2493 | } else |
| 2494 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_ON; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2495 | shot_ext->request_scc = 0; |
| 2496 | shot_ext->request_scp = 0; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2497 | break; |
| 2498 | case IS_FLASH_ON_DONE: |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2499 | //shot_ext->shot.ctl.aa.aeMode = AA_AEMODE_LOCKED; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2500 | shot_ext->shot.ctl.aa.awbMode = AA_AWBMODE_LOCKED; |
| 2501 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_AUTO; |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2502 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_AE_AWB_LOCK_WAIT; // auto transition |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2503 | shot_ext->request_scc = 0; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2504 | shot_ext->request_scp = 0; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2505 | break; |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2506 | case IS_FLASH_AE_AWB_LOCK_WAIT: |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2507 | shot_ext->request_scc = 0; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2508 | shot_ext->request_scp = 0; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2509 | break; |
| 2510 | case IS_FLASH_CAPTURE: |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2511 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE_WAIT; |
| 2512 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_CAPTURE; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2513 | shot_ext->request_scc = 0; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2514 | shot_ext->request_scp = 0; |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2515 | ALOGV("(%s): [Flash] IS_FLASH_CAPTURE - %d", __FUNCTION__, shot_ext->shot.ctl.aa.aeflashMode); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2516 | break; |
| 2517 | case IS_FLASH_CAPTURE_WAIT: |
| 2518 | shot_ext->request_scc = 0; |
| 2519 | shot_ext->request_scp = 0; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2520 | break; |
| 2521 | case IS_FLASH_CAPTURE_JPEG: |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2522 | ALOGV("(%s): [Flash] Flash Capture !!!!!", __FUNCTION__); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2523 | shot_ext->request_scc = 1; |
| 2524 | shot_ext->request_scp = 1; |
| 2525 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE_END; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2526 | break; |
| 2527 | case IS_FLASH_CAPTURE_END: |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2528 | ALOGV("(%s): [Flash] Flash Capture END", __FUNCTION__); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2529 | shot_ext->request_scc = 0; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2530 | shot_ext->request_scp = 0; |
| 2531 | shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_OFF; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2532 | m_ctlInfo.flash.m_flashEnableFlg = false; |
| 2533 | m_ctlInfo.flash.m_flashCnt = 0; |
| 2534 | m_ctlInfo.flash.m_afFlashDoneFlg= false; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2535 | break; |
| 2536 | } |
| 2537 | } |
| 2538 | } |
| 2539 | |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2540 | void ExynosCameraHWInterface2::flashListenerSensor(struct camera2_shot_ext * shot_ext) |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2541 | { |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2542 | // 1. AF Flash |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2543 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2544 | switch (m_ctlInfo.flash.m_afFlashCnt) { |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2545 | case IS_FLASH_AF_AUTO_OFF_WAIT: |
| 2546 | if (m_ctlInfo.flash.m_flashDecisionResult) { |
| 2547 | if (shot_ext->shot.dm.flash.flashMode == CAM2_FLASH_MODE_OFF) { |
| 2548 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_END; |
| 2549 | ALOGV("(%s): [AF Flash] Lis : AUTO -> OFF (%d)", __FUNCTION__, shot_ext->shot.dm.flash.flashMode); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2550 | } else { |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2551 | ALOGV("(%s): [AF Flash] Waiting : AUTO -> OFF", __FUNCTION__); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2552 | } |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2553 | } else { |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2554 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_END; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2555 | } |
| 2556 | break; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2557 | } |
| 2558 | } |
| 2559 | |
| 2560 | // 2. Flash |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2561 | if (m_ctlInfo.flash.m_flashEnableFlg) { |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2562 | switch (m_ctlInfo.flash.m_flashCnt) { |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2563 | case IS_FLASH_AUTO_WAIT: |
| 2564 | if (m_ctlInfo.flash.m_flashDecisionResult) { |
| 2565 | if (shot_ext->shot.dm.flash.flashMode == CAM2_FLASH_MODE_OFF) { |
| 2566 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE; |
| 2567 | m_ctlInfo.flash.m_flashTimeOut = 10; |
| 2568 | ALOGV("(%s): [Flash] Lis : AUTO -> OFF (%d)", __FUNCTION__, shot_ext->shot.dm.flash.flashMode); |
| 2569 | } else { |
| 2570 | ALOGV("(%s): [Flash] Waiting : AUTO -> OFF", __FUNCTION__); |
| 2571 | } |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2572 | } else { |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2573 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE; |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2574 | m_ctlInfo.flash.m_flashTimeOut = 10; |
| 2575 | ALOGV("(%s): [Flash] Skip : FLASH_AUTO -> FLASH_MODE_OFF", __FUNCTION__); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2576 | } |
| 2577 | break; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2578 | } |
| 2579 | } |
| 2580 | |
| 2581 | } |
| 2582 | |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2583 | void ExynosCameraHWInterface2::flashListenerISP(struct camera2_shot_ext * shot_ext) |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2584 | { |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2585 | // 1. AF Flash |
| 2586 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 2587 | switch (m_ctlInfo.flash.m_afFlashCnt) { |
| 2588 | case IS_FLASH_AF_ON_START: |
| 2589 | if (shot_ext->shot.dm.flash.decision > 0) { |
| 2590 | // store decision result to skip capture sequenece |
| 2591 | if (shot_ext->shot.dm.flash.decision == 2) |
| 2592 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 2593 | else |
| 2594 | m_ctlInfo.flash.m_flashDecisionResult = true; |
| 2595 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_ON_DONE; |
| 2596 | ALOGV("(%s): [AF Flash] IS_FLASH_ON, decision - %d", __FUNCTION__, shot_ext->shot.dm.flash.decision); |
| 2597 | m_IsAfTriggerRequired = true; |
| 2598 | } else { |
| 2599 | if (m_ctlInfo.flash.m_flashTimeOut == 0) { |
| 2600 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_ON_DONE; |
| 2601 | ALOGE("(%s): [AF Flash] Timeout IS_FLASH_ON, decision is false setting", __FUNCTION__); |
| 2602 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 2603 | m_IsAfTriggerRequired = true; |
| 2604 | } else { |
| 2605 | m_ctlInfo.flash.m_flashTimeOut--; |
| 2606 | } |
| 2607 | } |
| 2608 | break; |
| 2609 | case IS_FLASH_AF_AUTO_AE_AWB_LOCK_WAIT: |
| 2610 | if (shot_ext->shot.dm.aa.awbMode == AA_AWBMODE_LOCKED) { |
| 2611 | ALOGV("(%s): [AF Flash] AUTO_AE_AWB_LOCK_WAIT - %d", __FUNCTION__, shot_ext->shot.dm.aa.awbMode); |
| 2612 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_OFF_WAIT; |
| 2613 | } else { |
| 2614 | ALOGV("(%s): [Flash] Waiting : AA_AWBMODE_LOCKED", __FUNCTION__); |
| 2615 | } |
| 2616 | break; |
| 2617 | } |
| 2618 | } |
| 2619 | |
| 2620 | // 2. Flash |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2621 | // firing stable field is valid at ISP meta output only. |
| 2622 | if (m_ctlInfo.flash.m_flashEnableFlg) { |
| 2623 | switch (m_ctlInfo.flash.m_flashCnt) { |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2624 | case IS_FLASH_ON: |
| 2625 | if (shot_ext->shot.dm.flash.decision > 0) { |
| 2626 | // store decision result to skip capture sequenece |
| 2627 | if (shot_ext->shot.dm.flash.decision == 2) |
| 2628 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 2629 | else |
| 2630 | m_ctlInfo.flash.m_flashDecisionResult = true; |
| 2631 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_ON_DONE; |
| 2632 | ALOGV("(%s): [Flash] IS_FLASH_ON, decision - %d", __FUNCTION__, shot_ext->shot.dm.flash.decision); |
| 2633 | } else { |
| 2634 | if (m_ctlInfo.flash.m_flashTimeOut == 0) { |
| 2635 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_ON_DONE; |
| 2636 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 2637 | ALOGE("(%s): [Flash] Timeout IS_FLASH_ON, decision is false setting", __FUNCTION__); |
| 2638 | } else { |
| 2639 | m_ctlInfo.flash.m_flashTimeOut--; |
| 2640 | } |
| 2641 | } |
| 2642 | break; |
| 2643 | case IS_FLASH_AE_AWB_LOCK_WAIT: |
| 2644 | if (shot_ext->shot.dm.aa.awbMode == AA_AWBMODE_LOCKED) { |
| 2645 | ALOGV("(%s): [Flash] FLASH_AUTO_AE_AWB_LOCK_WAIT - %d", __FUNCTION__, shot_ext->shot.dm.aa.awbMode); |
| 2646 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_AUTO_WAIT; |
| 2647 | } else { |
| 2648 | ALOGV("(%s): [Flash] Waiting : AA_AWBMODE_LOCKED", __FUNCTION__); |
| 2649 | } |
| 2650 | break; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2651 | case IS_FLASH_CAPTURE_WAIT: |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2652 | if (m_ctlInfo.flash.m_flashDecisionResult) { |
| 2653 | if (shot_ext->shot.dm.flash.firingStable) { |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2654 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE_JPEG; |
| 2655 | } else { |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2656 | if (m_ctlInfo.flash.m_flashTimeOut == 0) { |
| 2657 | ALOGE("(%s): [Flash] Wait firingStable time-out!!", __FUNCTION__); |
| 2658 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE_JPEG; |
| 2659 | } else { |
| 2660 | m_ctlInfo.flash.m_flashTimeOut--; |
| 2661 | } |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2662 | } |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2663 | } else { |
| 2664 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE_JPEG; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2665 | } |
| 2666 | break; |
| 2667 | } |
| 2668 | } |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2669 | } |
| 2670 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2671 | void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self) |
| 2672 | { |
| 2673 | uint32_t currentSignal = self->GetProcessingSignal(); |
| 2674 | SensorThread * selfThread = ((SensorThread*)self); |
| 2675 | int index; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2676 | int index_isp; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2677 | status_t res; |
| 2678 | nsecs_t frameTime; |
| 2679 | int bayersOnSensor = 0, bayersOnIsp = 0; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2680 | int j = 0; |
| 2681 | bool isCapture = false; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2682 | ALOGV("DEBUG(%s): m_sensorThreadFunc (%x)", __FUNCTION__, currentSignal); |
| 2683 | |
| 2684 | if (currentSignal & SIGNAL_THREAD_RELEASE) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2685 | ALOGV("(%s): ENTER processing SIGNAL_THREAD_RELEASE", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2686 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2687 | ALOGV("(%s): calling sensor streamoff", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2688 | cam_int_streamoff(&(m_camera_info.sensor)); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2689 | ALOGV("(%s): calling sensor streamoff done", __FUNCTION__); |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 2690 | |
| 2691 | m_camera_info.sensor.buffers = 0; |
| 2692 | ALOGV("DEBUG(%s): sensor calling reqbuf 0 ", __FUNCTION__); |
| 2693 | cam_int_reqbufs(&(m_camera_info.sensor)); |
| 2694 | ALOGV("DEBUG(%s): sensor calling reqbuf 0 done", __FUNCTION__); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2695 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2696 | ALOGV("(%s): calling ISP streamoff", __FUNCTION__); |
| 2697 | isp_int_streamoff(&(m_camera_info.isp)); |
| 2698 | ALOGV("(%s): calling ISP streamoff done", __FUNCTION__); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2699 | |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 2700 | m_camera_info.isp.buffers = 0; |
| 2701 | ALOGV("DEBUG(%s): isp calling reqbuf 0 ", __FUNCTION__); |
| 2702 | cam_int_reqbufs(&(m_camera_info.isp)); |
| 2703 | ALOGV("DEBUG(%s): isp calling reqbuf 0 done", __FUNCTION__); |
| 2704 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2705 | exynos_v4l2_s_ctrl(m_camera_info.sensor.fd, V4L2_CID_IS_S_STREAM, IS_DISABLE_STREAM); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2706 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2707 | ALOGV("(%s): EXIT processing SIGNAL_THREAD_RELEASE", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2708 | selfThread->SetSignal(SIGNAL_THREAD_TERMINATE); |
| 2709 | return; |
| 2710 | } |
| 2711 | |
| 2712 | if (currentSignal & SIGNAL_SENSOR_START_REQ_PROCESSING) |
| 2713 | { |
| 2714 | ALOGV("DEBUG(%s): SensorThread processing SIGNAL_SENSOR_START_REQ_PROCESSING", __FUNCTION__); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2715 | int targetStreamIndex = 0, i=0; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2716 | int matchedFrameCnt = -1, processingReqIndex; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2717 | struct camera2_shot_ext *shot_ext; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2718 | struct camera2_shot_ext *shot_ext_capture; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 2719 | bool triggered = false; |
| 2720 | int afMode; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2721 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2722 | /* dqbuf from sensor */ |
| 2723 | ALOGV("Sensor DQbuf start"); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 2724 | index = cam_int_dqbuf(&(m_camera_info.sensor)); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 2725 | shot_ext = (struct camera2_shot_ext *)(m_camera_info.sensor.buffer[index].virt.extP[1]); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2726 | |
| 2727 | m_recordOutput = shot_ext->shot.ctl.request.outputStreams[2]; |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 2728 | m_previewCbOutput = shot_ext->shot.ctl.request.outputStreams[3]; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2729 | |
Sungjoong Kang | a15b4e3 | 2012-08-28 12:55:39 -0700 | [diff] [blame] | 2730 | if (m_nightCaptureCnt != 0) { |
| 2731 | matchedFrameCnt = m_nightCaptureFrameCnt; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2732 | } else if (m_ctlInfo.flash.m_flashCnt != 0) { |
| 2733 | matchedFrameCnt = m_ctlInfo.flash.m_flashFrameCount; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2734 | ALOGV("Skip frame, request is fixed at %d", matchedFrameCnt); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2735 | } else { |
Sungjoong Kang | a15b4e3 | 2012-08-28 12:55:39 -0700 | [diff] [blame] | 2736 | matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext); |
| 2737 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2738 | |
Sungjoong Kang | a07cbd9 | 2012-07-27 12:03:29 -0700 | [diff] [blame] | 2739 | if (matchedFrameCnt != -1) { |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 2740 | frameTime = systemTime(); |
| 2741 | m_requestManager->RegisterTimestamp(matchedFrameCnt, &frameTime); |
| 2742 | m_requestManager->UpdateIspParameters(shot_ext, matchedFrameCnt); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2743 | |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2744 | // Mapping Flash UI mode from aeMode |
| 2745 | if (shot_ext->shot.ctl.aa.aeMode >= AA_AEMODE_ON) { |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2746 | m_ctlInfo.flash.i_flashMode = shot_ext->shot.ctl.aa.aeMode; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2747 | shot_ext->shot.ctl.aa.aeMode = AA_AEMODE_ON; |
| 2748 | } |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2749 | |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 2750 | if (m_afModeWaitingCnt != 0) { |
| 2751 | ALOGV("### Af Trigger pulled, waiting for mode change cnt(%d) ", m_afModeWaitingCnt); |
| 2752 | m_afModeWaitingCnt --; |
| 2753 | if (m_afModeWaitingCnt == 1) { |
Sungjoong Kang | cd13bb7 | 2012-08-28 13:05:01 -0700 | [diff] [blame] | 2754 | m_afModeWaitingCnt = 0; |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 2755 | OnAfTrigger(m_afPendingTriggerId); |
| 2756 | } |
| 2757 | } |
hyeonmyeong Choi | 308291d | 2012-08-29 13:55:01 -0700 | [diff] [blame] | 2758 | m_zoomRatio = (float)m_camera2->getSensorW() / (float)shot_ext->shot.ctl.scaler.cropRegion[2]; |
Sungjoong Kang | e4657e3 | 2012-08-28 15:02:19 -0700 | [diff] [blame] | 2759 | float zoomLeft, zoomTop, zoomWidth, zoomHeight; |
| 2760 | int crop_x = 0, crop_y = 0, crop_w = 0, crop_h = 0; |
| 2761 | |
| 2762 | m_getRatioSize(m_camera2->getSensorW(), m_camera2->getSensorH(), |
| 2763 | m_streamThreads[0]->m_parameters.outputWidth, m_streamThreads[0]->m_parameters.outputHeight, |
| 2764 | &crop_x, &crop_y, |
| 2765 | &crop_w, &crop_h, |
| 2766 | 0); |
| 2767 | |
| 2768 | if (m_streamThreads[0]->m_parameters.outputWidth >= m_streamThreads[0]->m_parameters.outputHeight) { |
hyeonmyeong Choi | 308291d | 2012-08-29 13:55:01 -0700 | [diff] [blame] | 2769 | zoomWidth = m_camera2->getSensorW() / m_zoomRatio; |
Sungjoong Kang | e4657e3 | 2012-08-28 15:02:19 -0700 | [diff] [blame] | 2770 | zoomHeight = zoomWidth * |
| 2771 | m_streamThreads[0]->m_parameters.outputHeight / m_streamThreads[0]->m_parameters.outputWidth; |
| 2772 | } else { |
hyeonmyeong Choi | 308291d | 2012-08-29 13:55:01 -0700 | [diff] [blame] | 2773 | zoomHeight = m_camera2->getSensorH() / m_zoomRatio; |
Sungjoong Kang | e4657e3 | 2012-08-28 15:02:19 -0700 | [diff] [blame] | 2774 | zoomWidth = zoomHeight * |
| 2775 | m_streamThreads[0]->m_parameters.outputWidth / m_streamThreads[0]->m_parameters.outputHeight; |
| 2776 | } |
| 2777 | zoomLeft = (crop_w - zoomWidth) / 2; |
| 2778 | zoomTop = (crop_h - zoomHeight) / 2; |
| 2779 | |
| 2780 | int32_t new_cropRegion[3] = { zoomLeft, zoomTop, zoomWidth }; |
| 2781 | |
hyeonmyeong Choi | 308291d | 2012-08-29 13:55:01 -0700 | [diff] [blame] | 2782 | if (new_cropRegion[0] * 2 + new_cropRegion[2] > m_camera2->getSensorW()) |
| 2783 | new_cropRegion[2]--; |
| 2784 | else if (new_cropRegion[0] * 2 + new_cropRegion[2] < m_camera2->getSensorW()) |
| 2785 | new_cropRegion[2]++; |
| 2786 | |
Sungjoong Kang | e4657e3 | 2012-08-28 15:02:19 -0700 | [diff] [blame] | 2787 | shot_ext->shot.ctl.scaler.cropRegion[0] = new_cropRegion[0]; |
| 2788 | shot_ext->shot.ctl.scaler.cropRegion[1] = new_cropRegion[1]; |
| 2789 | shot_ext->shot.ctl.scaler.cropRegion[2] = new_cropRegion[2]; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 2790 | if (m_IsAfModeUpdateRequired) { |
| 2791 | ALOGE("### AF Mode change(Mode %d) ", m_afMode); |
| 2792 | shot_ext->shot.ctl.aa.afMode = m_afMode; |
| 2793 | if (m_afMode == AA_AFMODE_CONTINUOUS_VIDEO || m_afMode == AA_AFMODE_CONTINUOUS_PICTURE) { |
| 2794 | ALOGE("### With Automatic triger for continuous modes"); |
| 2795 | m_afState = HAL_AFSTATE_STARTED; |
| 2796 | shot_ext->shot.ctl.aa.afTrigger = 1; |
| 2797 | triggered = true; |
| 2798 | } |
| 2799 | m_IsAfModeUpdateRequired = false; |
| 2800 | if (m_afMode2 != NO_CHANGE) { |
| 2801 | enum aa_afmode tempAfMode = m_afMode2; |
| 2802 | m_afMode2 = NO_CHANGE; |
| 2803 | SetAfMode(tempAfMode); |
| 2804 | } |
| 2805 | } |
| 2806 | else { |
| 2807 | shot_ext->shot.ctl.aa.afMode = NO_CHANGE; |
| 2808 | } |
| 2809 | if (m_IsAfTriggerRequired) { |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2810 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 2811 | if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_ON_DONE) { |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2812 | // Flash is enabled and start AF |
| 2813 | if (m_afState == HAL_AFSTATE_SCANNING) { |
| 2814 | ALOGE("(%s): restarting trigger ", __FUNCTION__); |
| 2815 | } else { |
| 2816 | if (m_afState != HAL_AFSTATE_NEEDS_COMMAND) |
| 2817 | ALOGE("(%s): wrong trigger state %d", __FUNCTION__, m_afState); |
| 2818 | else |
| 2819 | m_afState = HAL_AFSTATE_STARTED; |
| 2820 | } |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2821 | ALOGE("### AF Triggering with mode (%d)", m_afMode); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2822 | shot_ext->shot.ctl.aa.afTrigger = 1; |
| 2823 | shot_ext->shot.ctl.aa.afMode = m_afMode; |
| 2824 | m_IsAfTriggerRequired = false; |
| 2825 | } |
| 2826 | } else { |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2827 | ALOGE("### AF Triggering with mode (%d)", m_afMode); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2828 | if (m_afState == HAL_AFSTATE_SCANNING) { |
| 2829 | ALOGE("(%s): restarting trigger ", __FUNCTION__); |
| 2830 | } else { |
| 2831 | if (m_afState != HAL_AFSTATE_NEEDS_COMMAND) |
| 2832 | ALOGE("(%s): wrong trigger state %d", __FUNCTION__, m_afState); |
| 2833 | else |
| 2834 | m_afState = HAL_AFSTATE_STARTED; |
| 2835 | } |
| 2836 | shot_ext->shot.ctl.aa.afTrigger = 1; |
| 2837 | shot_ext->shot.ctl.aa.afMode = m_afMode; |
| 2838 | m_IsAfTriggerRequired = false; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 2839 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 2840 | } |
| 2841 | else { |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 2842 | shot_ext->shot.ctl.aa.afTrigger = 0; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 2843 | } |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 2844 | if (m_aspectChanged) { |
| 2845 | shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 15; |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 2846 | shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 2847 | m_aspectChanged = false; |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 2848 | } |
| 2849 | else { |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 2850 | if (m_wideAspect) { |
| 2851 | shot_ext->setfile = ISS_SUB_SCENARIO_VIDEO; |
| 2852 | shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 30; |
| 2853 | shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; |
| 2854 | } |
| 2855 | else { |
| 2856 | shot_ext->setfile = ISS_SUB_SCENARIO_STILL; |
| 2857 | } |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 2858 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 2859 | if (triggered) |
| 2860 | shot_ext->shot.ctl.aa.afTrigger = 1; |
| 2861 | |
| 2862 | // TODO : check collision with AFMode Update |
| 2863 | if (m_IsAfLockRequired) { |
| 2864 | shot_ext->shot.ctl.aa.afMode = AA_AFMODE_OFF; |
| 2865 | m_IsAfLockRequired = false; |
| 2866 | } |
Rebecca Schultz Zavin | 4ed2f10 | 2012-08-22 00:55:29 -0700 | [diff] [blame] | 2867 | ALOGV("### Isp Qbuf start(%d) count (%d), SCP(%d) SCC(%d) DIS(%d) shot_size(%d)", |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2868 | index, |
| 2869 | shot_ext->shot.ctl.request.frameCount, |
| 2870 | shot_ext->request_scp, |
| 2871 | shot_ext->request_scc, |
| 2872 | shot_ext->dis_bypass, sizeof(camera2_shot)); |
Sungjoong Kang | a15b4e3 | 2012-08-28 12:55:39 -0700 | [diff] [blame] | 2873 | ALOGV("### m_nightCaptureCnt (%d)", m_nightCaptureCnt); |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 2874 | if (0 == shot_ext->shot.ctl.aa.afRegions[0] && 0 == shot_ext->shot.ctl.aa.afRegions[1] |
| 2875 | && 0 == shot_ext->shot.ctl.aa.afRegions[2] && 0 == shot_ext->shot.ctl.aa.afRegions[3]) { |
| 2876 | ALOGV("(%s): AF region resetting", __FUNCTION__); |
| 2877 | lastAfRegion[0] = 0; |
| 2878 | lastAfRegion[1] = 0; |
| 2879 | lastAfRegion[2] = 0; |
| 2880 | lastAfRegion[3] = 0; |
| 2881 | } |
| 2882 | else { |
| 2883 | if (!(lastAfRegion[0] == shot_ext->shot.ctl.aa.afRegions[0] && lastAfRegion[1] == shot_ext->shot.ctl.aa.afRegions[1] |
| 2884 | && lastAfRegion[2] == shot_ext->shot.ctl.aa.afRegions[2] && lastAfRegion[3] == shot_ext->shot.ctl.aa.afRegions[3])) { |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2885 | ALOGE("(%s): AF region changed : triggering", __FUNCTION__); |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 2886 | shot_ext->shot.ctl.aa.afTrigger = 1; |
| 2887 | shot_ext->shot.ctl.aa.afMode = m_afMode; |
| 2888 | m_afState = HAL_AFSTATE_STARTED; |
| 2889 | lastAfRegion[0] = shot_ext->shot.ctl.aa.afRegions[0]; |
| 2890 | lastAfRegion[1] = shot_ext->shot.ctl.aa.afRegions[1]; |
| 2891 | lastAfRegion[2] = shot_ext->shot.ctl.aa.afRegions[2]; |
| 2892 | lastAfRegion[3] = shot_ext->shot.ctl.aa.afRegions[3]; |
| 2893 | } |
Younghwan Joo | da7ca69 | 2012-09-03 20:47:21 -0700 | [diff] [blame] | 2894 | // clear region infos in case of CAF mode |
| 2895 | if (m_afMode == AA_AFMODE_CONTINUOUS_VIDEO || m_afMode == AA_AFMODE_CONTINUOUS_PICTURE) { |
| 2896 | shot_ext->shot.ctl.aa.afRegions[0] = lastAfRegion[0] = 0; |
| 2897 | shot_ext->shot.ctl.aa.afRegions[1] = lastAfRegion[1] = 0; |
| 2898 | shot_ext->shot.ctl.aa.afRegions[2] = lastAfRegion[2] = 0; |
| 2899 | shot_ext->shot.ctl.aa.afRegions[3] = lastAfRegion[3] = 0; |
| 2900 | } |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 2901 | } |
Sungjoong Kang | a15b4e3 | 2012-08-28 12:55:39 -0700 | [diff] [blame] | 2902 | if (m_nightCaptureCnt == 0) { |
| 2903 | if (shot_ext->shot.ctl.aa.captureIntent == ANDROID_CONTROL_INTENT_STILL_CAPTURE |
| 2904 | && shot_ext->shot.ctl.aa.sceneMode == AA_SCENE_MODE_NIGHT) { |
| 2905 | shot_ext->shot.ctl.aa.sceneMode = AA_SCENE_MODE_NIGHT_CAPTURE; |
| 2906 | shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 2; |
| 2907 | shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; |
| 2908 | m_nightCaptureCnt = 4; |
| 2909 | m_nightCaptureFrameCnt = matchedFrameCnt; |
| 2910 | shot_ext->request_scc = 0; |
| 2911 | } |
| 2912 | } |
| 2913 | else if (m_nightCaptureCnt == 1) { |
| 2914 | shot_ext->shot.ctl.aa.sceneMode = AA_SCENE_MODE_NIGHT_CAPTURE; |
| 2915 | shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 2; |
| 2916 | shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; |
| 2917 | m_nightCaptureCnt--; |
| 2918 | shot_ext->request_scc = 1; |
| 2919 | } |
| 2920 | else if (m_nightCaptureCnt == 2 || m_nightCaptureCnt == 3 || m_nightCaptureCnt == 4) { |
| 2921 | shot_ext->shot.ctl.aa.sceneMode = AA_SCENE_MODE_NIGHT_CAPTURE; |
| 2922 | shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 2; |
| 2923 | shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; |
| 2924 | m_nightCaptureCnt--; |
| 2925 | shot_ext->request_scc = 0; |
| 2926 | } |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2927 | |
| 2928 | // Flash mode |
| 2929 | // Keep and Skip request_scc = 1 at flash enable mode to operate flash sequence |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2930 | if ((m_ctlInfo.flash.i_flashMode >= AA_AEMODE_ON_AUTO_FLASH) && (m_ctlInfo.flash.m_flashEnableFlg == false) |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2931 | && (m_cameraId == 0)) { |
| 2932 | if (shot_ext->shot.ctl.aa.captureIntent == ANDROID_CONTROL_INTENT_STILL_CAPTURE) { |
| 2933 | ALOGE("(%s): [Flash] Flash capture start : skip request scc 1#####", __FUNCTION__); |
| 2934 | shot_ext->request_scc = 0; |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2935 | m_ctlInfo.flash.m_flashFrameCount = matchedFrameCnt; |
| 2936 | m_ctlInfo.flash.m_flashEnableFlg = true; |
| 2937 | m_ctlInfo.flash.m_flashCaptured = false; |
| 2938 | if(m_ctlInfo.flash.m_afFlashDoneFlg) { |
| 2939 | ALOGD("(%s): [Flash] Flash capture start", __FUNCTION__); |
| 2940 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_CAPTURE; |
| 2941 | } else { |
| 2942 | ALOGD("(%s): [Flash] Flash ON start", __FUNCTION__); |
| 2943 | m_ctlInfo.flash.m_flashCnt = IS_FLASH_ON; |
| 2944 | } |
| 2945 | m_ctlInfo.flash.m_flashTimeOut = 3; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2946 | } |
| 2947 | } |
| 2948 | |
| 2949 | // TODO : set torch mode for video recording. need to find proper position. |
| 2950 | // m_wideAspect is will be changed to recording hint |
| 2951 | if ((shot_ext->shot.ctl.flash.flashMode == CAM2_FLASH_MODE_SINGLE) && m_wideAspect) { |
| 2952 | shot_ext->shot.ctl.flash.flashMode = CAM2_FLASH_MODE_TORCH; |
| 2953 | shot_ext->shot.ctl.flash.firingPower = 10; |
| 2954 | m_ctlInfo.flash.m_flashTorchMode = true; |
| 2955 | } else if (m_wideAspect){ |
| 2956 | shot_ext->shot.ctl.flash.flashMode = CAM2_FLASH_MODE_OFF; |
| 2957 | shot_ext->shot.ctl.flash.firingPower = 0; |
| 2958 | m_ctlInfo.flash.m_flashTorchMode = false; |
| 2959 | } else { |
| 2960 | if (m_ctlInfo.flash.m_flashTorchMode) { |
| 2961 | shot_ext->shot.ctl.flash.flashMode = CAM2_FLASH_MODE_OFF; |
| 2962 | shot_ext->shot.ctl.flash.firingPower = 0; |
| 2963 | m_ctlInfo.flash.m_flashTorchMode = false; |
| 2964 | } else { |
| 2965 | shot_ext->shot.ctl.flash.flashMode = CAM2_FLASH_MODE_NOP; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2966 | } |
| 2967 | } |
| 2968 | |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2969 | flashListenerSensor(shot_ext); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 2970 | flashSetter(shot_ext); |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 2971 | |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 2972 | ALOGV("(%s): queued aa(%d) aemode(%d) awb(%d) afmode(%d) trigger(%d)", __FUNCTION__, |
| 2973 | (int)(shot_ext->shot.ctl.aa.mode), (int)(shot_ext->shot.ctl.aa.aeMode), |
| 2974 | (int)(shot_ext->shot.ctl.aa.awbMode), (int)(shot_ext->shot.ctl.aa.afMode), |
| 2975 | (int)(shot_ext->shot.ctl.aa.afTrigger)); |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 2976 | |
| 2977 | int current_scp = shot_ext->request_scp; |
| 2978 | |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 2979 | if (shot_ext->shot.dm.request.frameCount == 0) { |
hyeonmyeong Choi | 2bbbf0c | 2012-09-09 11:50:21 -0700 | [diff] [blame] | 2980 | ALOGE("ERR(%s): dm.request.frameCount = %d", __FUNCTION__, shot_ext->shot.dm.request.frameCount); |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 2981 | } |
| 2982 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2983 | cam_int_qbuf(&(m_camera_info.isp), index); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2984 | |
| 2985 | usleep(10000); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2986 | |
| 2987 | ALOGV("### isp DQBUF start"); |
| 2988 | index_isp = cam_int_dqbuf(&(m_camera_info.isp)); |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 2989 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2990 | shot_ext = (struct camera2_shot_ext *)(m_camera_info.isp.buffer[index_isp].virt.extP[1]); |
| 2991 | |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 2992 | flashListenerISP(shot_ext); |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 2993 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 2994 | ALOGV("### Isp DQbuf done(%d) count (%d), SCP(%d) SCC(%d) shot_size(%d)", |
| 2995 | index, |
| 2996 | shot_ext->shot.ctl.request.frameCount, |
| 2997 | shot_ext->request_scp, |
| 2998 | shot_ext->request_scc, |
| 2999 | shot_ext->dis_bypass, sizeof(camera2_shot)); |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3000 | ALOGV("(%s): DM aa(%d) aemode(%d) awb(%d) afmode(%d)", __FUNCTION__, |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 3001 | (int)(shot_ext->shot.dm.aa.mode), (int)(shot_ext->shot.dm.aa.aeMode), |
| 3002 | (int)(shot_ext->shot.dm.aa.awbMode), |
| 3003 | (int)(shot_ext->shot.dm.aa.afMode)); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3004 | |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3005 | m_previewOutput = 0; |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 3006 | // HACK |
| 3007 | //if (shot_ext->request_scp && m_requestManager->GetNumEntries() > 1) { |
| 3008 | if (current_scp && m_requestManager->GetNumEntries() > 1) { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3009 | m_previewOutput = 1; |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 3010 | m_scpOutputSignalCnt++; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3011 | m_streamThreads[0]->SetSignal(SIGNAL_STREAM_DATA_COMING); |
| 3012 | } |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 3013 | |
| 3014 | if (current_scp != shot_ext->request_scp) { |
| 3015 | ALOGW("WARN(%s): scp frame drop1 request_scp(%d to %d)", |
| 3016 | __FUNCTION__, current_scp, shot_ext->request_scp); |
| 3017 | } |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 3018 | if (shot_ext->request_scc) { |
Sungjoong Kang | a15b4e3 | 2012-08-28 12:55:39 -0700 | [diff] [blame] | 3019 | ALOGV("### m_nightCaptureCnt (%d) request_scc true", m_nightCaptureCnt); |
| 3020 | memcpy(&m_jpegMetadata, &shot_ext->shot, sizeof(struct camera2_shot)); |
| 3021 | int shutterSpeed = (m_jpegMetadata.dm.sensor.exposureTime/1000); |
| 3022 | |
| 3023 | if (shutterSpeed < 0) { |
| 3024 | shutterSpeed = 100; |
| 3025 | } |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 3026 | m_streamThreads[1]->SetSignal(SIGNAL_STREAM_DATA_COMING); |
| 3027 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3028 | |
| 3029 | ALOGV("(%s): SCP_CLOSING check sensor(%d) scc(%d) scp(%d) ", __FUNCTION__, |
| 3030 | shot_ext->request_sensor, shot_ext->request_scc, shot_ext->request_scp); |
| 3031 | if (shot_ext->request_scc + shot_ext->request_scp + shot_ext->request_sensor == 0) { |
| 3032 | ALOGV("(%s): SCP_CLOSING check OK ", __FUNCTION__); |
| 3033 | m_scp_closed = true; |
| 3034 | } |
| 3035 | else |
| 3036 | m_scp_closed = false; |
| 3037 | |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 3038 | if (!shot_ext->fd_bypass) { |
| 3039 | /* FD orientation axis transformation */ |
| 3040 | for (int i=0; i < CAMERA2_MAX_FACES; i++) { |
| 3041 | if (shot_ext->shot.dm.stats.faceRectangles[i][0] > 0) |
| 3042 | shot_ext->shot.dm.stats.faceRectangles[i][0] = (m_camera2->m_curCameraInfo->sensorW |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3043 | * shot_ext->shot.dm.stats.faceRectangles[i][0]) |
| 3044 | / m_streamThreads[0].get()->m_parameters.outputWidth; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 3045 | if (shot_ext->shot.dm.stats.faceRectangles[i][1] > 0) |
| 3046 | shot_ext->shot.dm.stats.faceRectangles[i][1] = (m_camera2->m_curCameraInfo->sensorH |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3047 | * shot_ext->shot.dm.stats.faceRectangles[i][1]) |
| 3048 | / m_streamThreads[0].get()->m_parameters.outputHeight; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 3049 | if (shot_ext->shot.dm.stats.faceRectangles[i][2] > 0) |
| 3050 | shot_ext->shot.dm.stats.faceRectangles[i][2] = (m_camera2->m_curCameraInfo->sensorW |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3051 | * shot_ext->shot.dm.stats.faceRectangles[i][2]) |
| 3052 | / m_streamThreads[0].get()->m_parameters.outputWidth; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 3053 | if (shot_ext->shot.dm.stats.faceRectangles[i][3] > 0) |
| 3054 | shot_ext->shot.dm.stats.faceRectangles[i][3] = (m_camera2->m_curCameraInfo->sensorH |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3055 | * shot_ext->shot.dm.stats.faceRectangles[i][3]) |
| 3056 | / m_streamThreads[0].get()->m_parameters.outputHeight; |
Sungjoong Kang | fd2d78a | 2012-08-26 17:44:25 -0700 | [diff] [blame] | 3057 | } |
| 3058 | } |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 3059 | if (m_nightCaptureCnt == 0 && m_ctlInfo.flash.m_flashCnt == 0) { |
Sungjoong Kang | a15b4e3 | 2012-08-28 12:55:39 -0700 | [diff] [blame] | 3060 | m_requestManager->ApplyDynamicMetadata(shot_ext); |
| 3061 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 3062 | OnAfNotification(shot_ext->shot.dm.aa.afState); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3063 | } |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3064 | |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 3065 | processingReqIndex = m_requestManager->MarkProcessingRequest(&(m_camera_info.sensor.buffer[index]), &afMode); |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3066 | if (processingReqIndex != -1) |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 3067 | SetAfMode((enum aa_afmode)afMode); |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3068 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3069 | |
| 3070 | shot_ext = (struct camera2_shot_ext *)(m_camera_info.sensor.buffer[index].virt.extP[1]); |
| 3071 | if (m_scp_closing || m_scp_closed) { |
| 3072 | ALOGD("(%s): SCP_CLOSING(%d) SCP_CLOSED(%d)", __FUNCTION__, m_scp_closing, m_scp_closed); |
| 3073 | shot_ext->request_scc = 0; |
| 3074 | shot_ext->request_scp = 0; |
| 3075 | shot_ext->request_sensor = 0; |
| 3076 | } |
| 3077 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3078 | cam_int_qbuf(&(m_camera_info.sensor), index); |
| 3079 | ALOGV("### Sensor QBUF done"); |
| 3080 | |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3081 | if (!m_scp_closing |
| 3082 | && ((matchedFrameCnt == -1) || (processingReqIndex == -1))){ |
Younghwan Joo | da7ca69 | 2012-09-03 20:47:21 -0700 | [diff] [blame] | 3083 | ALOGV("make bubble shot: matchedFramcnt(%d) processingReqIndex(%d)", |
Sungjoong Kang | ef6f83c | 2012-08-28 22:59:48 +0900 | [diff] [blame] | 3084 | matchedFrameCnt, processingReqIndex); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3085 | selfThread->SetSignal(SIGNAL_SENSOR_START_REQ_PROCESSING); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3086 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3087 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3088 | return; |
| 3089 | } |
| 3090 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3091 | void ExynosCameraHWInterface2::m_ispThreadInitialize(SignalDrivenThread * self) |
| 3092 | { |
| 3093 | ALOGV("DEBUG(%s): ", __FUNCTION__ ); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3094 | /* will add */ |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3095 | return; |
| 3096 | } |
| 3097 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3098 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3099 | void ExynosCameraHWInterface2::m_ispThreadFunc(SignalDrivenThread * self) |
| 3100 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3101 | ALOGV("DEBUG(%s): ", __FUNCTION__ ); |
| 3102 | /* will add */ |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3103 | return; |
| 3104 | } |
| 3105 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3106 | void ExynosCameraHWInterface2::m_streamBufferInit(SignalDrivenThread *self) |
| 3107 | { |
| 3108 | uint32_t currentSignal = self->GetProcessingSignal(); |
| 3109 | StreamThread * selfThread = ((StreamThread*)self); |
| 3110 | stream_parameters_t *selfStreamParms = &(selfThread->m_parameters); |
| 3111 | record_parameters_t *selfRecordParms = &(selfThread->m_recordParameters); |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 3112 | callback_parameters_t *selfPreviewCbParms = &(selfThread->m_previewCbParameters); |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3113 | node_info_t *currentNode = &(selfStreamParms->node); |
| 3114 | |
| 3115 | buffer_handle_t * buf = NULL; |
| 3116 | status_t res; |
| 3117 | void *virtAddr[3]; |
| 3118 | int i, j; |
| 3119 | int index; |
| 3120 | nsecs_t timestamp; |
| 3121 | |
| 3122 | if (!(selfThread->m_isBufferInit)) |
| 3123 | { |
| 3124 | for ( i=0 ; i < selfStreamParms->numSvcBuffers; i++) { |
| 3125 | res = selfStreamParms->streamOps->dequeue_buffer(selfStreamParms->streamOps, &buf); |
| 3126 | if (res != NO_ERROR || buf == NULL) { |
| 3127 | ALOGE("ERR(%s): Init: unable to dequeue buffer : %d",__FUNCTION__ , res); |
| 3128 | return; |
| 3129 | } |
| 3130 | ALOGV("DEBUG(%s): got buf(%x) version(%d), numFds(%d), numInts(%d)", __FUNCTION__, (uint32_t)(*buf), |
| 3131 | ((native_handle_t*)(*buf))->version, ((native_handle_t*)(*buf))->numFds, ((native_handle_t*)(*buf))->numInts); |
| 3132 | |
| 3133 | if (m_grallocHal->lock(m_grallocHal, *buf, |
| 3134 | selfStreamParms->usage, |
| 3135 | 0, 0, selfStreamParms->outputWidth, selfStreamParms->outputHeight, virtAddr) != 0) { |
| 3136 | ALOGE("ERR(%s): could not obtain gralloc buffer", __FUNCTION__); |
| 3137 | return; |
| 3138 | } |
| 3139 | ALOGV("DEBUG(%s): locked img buf plane0(%x) plane1(%x) plane2(%x)", |
| 3140 | __FUNCTION__, (unsigned int)virtAddr[0], (unsigned int)virtAddr[1], (unsigned int)virtAddr[2]); |
| 3141 | |
| 3142 | index = selfThread->findBufferIndex(virtAddr[0]); |
| 3143 | if (index == -1) { |
| 3144 | ALOGE("ERR(%s): could not find buffer index", __FUNCTION__); |
| 3145 | } |
| 3146 | else { |
| 3147 | ALOGV("DEBUG(%s): found buffer index[%d] - status(%d)", |
| 3148 | __FUNCTION__, index, selfStreamParms->svcBufStatus[index]); |
| 3149 | if (selfStreamParms->svcBufStatus[index]== REQUIRES_DQ_FROM_SVC) |
| 3150 | selfStreamParms->svcBufStatus[index] = ON_DRIVER; |
| 3151 | else if (selfStreamParms->svcBufStatus[index]== ON_SERVICE) |
| 3152 | selfStreamParms->svcBufStatus[index] = ON_HAL; |
| 3153 | else { |
| 3154 | ALOGV("DBG(%s): buffer status abnormal (%d) " |
| 3155 | , __FUNCTION__, selfStreamParms->svcBufStatus[index]); |
| 3156 | } |
| 3157 | selfStreamParms->numSvcBufsInHal++; |
| 3158 | if (*buf != selfStreamParms->svcBufHandle[index]) |
| 3159 | ALOGV("DBG(%s): different buf_handle index ", __FUNCTION__); |
| 3160 | else |
| 3161 | ALOGV("DEBUG(%s): same buf_handle index", __FUNCTION__); |
| 3162 | } |
| 3163 | selfStreamParms->svcBufIndex = 0; |
| 3164 | } |
| 3165 | selfThread->m_isBufferInit = true; |
| 3166 | } |
| 3167 | |
| 3168 | if (m_recordingEnabled && m_needsRecordBufferInit) { |
| 3169 | ALOGV("DEBUG(%s): Recording Buffer Initialization numsvcbuf(%d)", |
| 3170 | __FUNCTION__, selfRecordParms->numSvcBuffers); |
| 3171 | int checkingIndex = 0; |
| 3172 | bool found = false; |
| 3173 | for ( i=0 ; i < selfRecordParms->numSvcBuffers; i++) { |
| 3174 | res = selfRecordParms->streamOps->dequeue_buffer(selfRecordParms->streamOps, &buf); |
| 3175 | if (res != NO_ERROR || buf == NULL) { |
| 3176 | ALOGE("ERR(%s): Init: unable to dequeue buffer : %d",__FUNCTION__ , res); |
| 3177 | return; |
| 3178 | } |
| 3179 | selfRecordParms->numSvcBufsInHal++; |
| 3180 | ALOGV("DEBUG(%s): [record] got buf(%x) bufInHal(%d) version(%d), numFds(%d), numInts(%d)", __FUNCTION__, (uint32_t)(*buf), |
| 3181 | selfRecordParms->numSvcBufsInHal, ((native_handle_t*)(*buf))->version, ((native_handle_t*)(*buf))->numFds, ((native_handle_t*)(*buf))->numInts); |
| 3182 | |
| 3183 | if (m_grallocHal->lock(m_grallocHal, *buf, |
| 3184 | selfRecordParms->usage, 0, 0, |
| 3185 | selfRecordParms->outputWidth, selfRecordParms->outputHeight, virtAddr) != 0) { |
| 3186 | ALOGE("ERR(%s): could not obtain gralloc buffer", __FUNCTION__); |
| 3187 | } |
| 3188 | else { |
| 3189 | ALOGV("DEBUG(%s): [record] locked img buf plane0(%x) plane1(%x) plane2(%x)", |
| 3190 | __FUNCTION__, (unsigned int)virtAddr[0], (unsigned int)virtAddr[1], (unsigned int)virtAddr[2]); |
| 3191 | } |
| 3192 | found = false; |
| 3193 | for (checkingIndex = 0; checkingIndex < selfRecordParms->numSvcBuffers ; checkingIndex++) { |
| 3194 | if (selfRecordParms->svcBufHandle[checkingIndex] == *buf ) { |
| 3195 | found = true; |
| 3196 | break; |
| 3197 | } |
| 3198 | } |
| 3199 | ALOGV("DEBUG(%s): [record] found(%d) - index[%d]", __FUNCTION__, found, checkingIndex); |
| 3200 | if (!found) break; |
| 3201 | |
| 3202 | index = checkingIndex; |
| 3203 | |
| 3204 | if (index == -1) { |
| 3205 | ALOGV("ERR(%s): could not find buffer index", __FUNCTION__); |
| 3206 | } |
| 3207 | else { |
| 3208 | ALOGV("DEBUG(%s): found buffer index[%d] - status(%d)", |
| 3209 | __FUNCTION__, index, selfRecordParms->svcBufStatus[index]); |
| 3210 | if (selfRecordParms->svcBufStatus[index]== ON_SERVICE) |
| 3211 | selfRecordParms->svcBufStatus[index] = ON_HAL; |
| 3212 | else { |
| 3213 | ALOGV("DBG(%s): buffer status abnormal (%d) " |
| 3214 | , __FUNCTION__, selfRecordParms->svcBufStatus[index]); |
| 3215 | } |
| 3216 | if (*buf != selfRecordParms->svcBufHandle[index]) |
| 3217 | ALOGV("DBG(%s): different buf_handle index ", __FUNCTION__); |
| 3218 | else |
| 3219 | ALOGV("DEBUG(%s): same buf_handle index", __FUNCTION__); |
| 3220 | } |
| 3221 | selfRecordParms->svcBufIndex = 0; |
| 3222 | } |
| 3223 | m_needsRecordBufferInit = false; |
| 3224 | } |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 3225 | if (m_previewCbEnabled && m_needsPreviewCbBufferInit) { |
| 3226 | ALOGV("DEBUG(%s): previewCb Buffer Initialization numsvcbuf(%d)", |
| 3227 | __FUNCTION__, selfPreviewCbParms->numSvcBuffers); |
| 3228 | int checkingIndex = 0; |
| 3229 | bool found = false; |
| 3230 | |
| 3231 | m_getAlignedYUVSize(HAL_PIXEL_FORMAT_2_V4L2_PIX(selfPreviewCbParms->internalFormat), selfPreviewCbParms->outputWidth, |
| 3232 | selfPreviewCbParms->outputHeight, &m_previewCbBuf); |
| 3233 | ALOGV("(%s): PreviewCb tempbuf size : %d %d %d", __FUNCTION__, m_previewCbBuf.size.extS[0], |
| 3234 | m_previewCbBuf.size.extS[1], m_previewCbBuf.size.extS[2]); |
| 3235 | |
| 3236 | if (allocCameraMemory(selfStreamParms->ionClient, &m_previewCbBuf, selfPreviewCbParms->internalPlanes) == -1) { |
| 3237 | ALOGE("ERR(%s): Failed to allocate previewcb buf", __FUNCTION__); |
| 3238 | } |
| 3239 | |
| 3240 | for ( i=0 ; i < selfPreviewCbParms->numSvcBuffers; i++) { |
| 3241 | res = selfPreviewCbParms->streamOps->dequeue_buffer(selfPreviewCbParms->streamOps, &buf); |
| 3242 | if (res != NO_ERROR || buf == NULL) { |
| 3243 | ALOGE("ERR(%s): Init: unable to dequeue buffer : %d",__FUNCTION__ , res); |
| 3244 | return; |
| 3245 | } |
| 3246 | selfPreviewCbParms->numSvcBufsInHal++; |
| 3247 | ALOGV("DEBUG(%s): [previewCb] got buf(%x) bufInHal(%d) version(%d), numFds(%d), numInts(%d)", __FUNCTION__, (uint32_t)(*buf), |
| 3248 | selfPreviewCbParms->numSvcBufsInHal, ((native_handle_t*)(*buf))->version, ((native_handle_t*)(*buf))->numFds, ((native_handle_t*)(*buf))->numInts); |
| 3249 | |
| 3250 | if (m_grallocHal->lock(m_grallocHal, *buf, |
| 3251 | selfPreviewCbParms->usage, 0, 0, |
| 3252 | selfPreviewCbParms->outputWidth, selfPreviewCbParms->outputHeight, virtAddr) != 0) { |
| 3253 | ALOGE("ERR(%s): could not obtain gralloc buffer", __FUNCTION__); |
| 3254 | } |
| 3255 | else { |
| 3256 | ALOGV("DEBUG(%s): [previewCb] locked img buf plane0(%x) plane1(%x) plane2(%x)", |
| 3257 | __FUNCTION__, (unsigned int)virtAddr[0], (unsigned int)virtAddr[1], (unsigned int)virtAddr[2]); |
| 3258 | } |
| 3259 | found = false; |
| 3260 | for (checkingIndex = 0; checkingIndex < selfPreviewCbParms->numSvcBuffers ; checkingIndex++) { |
| 3261 | if (selfPreviewCbParms->svcBufHandle[checkingIndex] == *buf ) { |
| 3262 | found = true; |
| 3263 | break; |
| 3264 | } |
| 3265 | } |
| 3266 | ALOGV("DEBUG(%s): [previewCb] found(%d) - index[%d]", __FUNCTION__, found, checkingIndex); |
| 3267 | if (!found) break; |
| 3268 | |
| 3269 | index = checkingIndex; |
| 3270 | |
| 3271 | if (index == -1) { |
| 3272 | ALOGV("ERR(%s): could not find buffer index", __FUNCTION__); |
| 3273 | } |
| 3274 | else { |
| 3275 | ALOGV("DEBUG(%s): found buffer index[%d] - status(%d)", |
| 3276 | __FUNCTION__, index, selfPreviewCbParms->svcBufStatus[index]); |
| 3277 | if (selfPreviewCbParms->svcBufStatus[index]== ON_SERVICE) |
| 3278 | selfPreviewCbParms->svcBufStatus[index] = ON_HAL; |
| 3279 | else { |
| 3280 | ALOGV("DBG(%s): buffer status abnormal (%d) " |
| 3281 | , __FUNCTION__, selfPreviewCbParms->svcBufStatus[index]); |
| 3282 | } |
| 3283 | if (*buf != selfPreviewCbParms->svcBufHandle[index]) |
| 3284 | ALOGV("DBG(%s): different buf_handle index ", __FUNCTION__); |
| 3285 | else |
| 3286 | ALOGV("DEBUG(%s): same buf_handle index", __FUNCTION__); |
| 3287 | } |
| 3288 | selfPreviewCbParms->svcBufIndex = 0; |
| 3289 | } |
| 3290 | m_needsPreviewCbBufferInit = false; |
| 3291 | } |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3292 | |
| 3293 | } |
| 3294 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3295 | void ExynosCameraHWInterface2::m_streamThreadInitialize(SignalDrivenThread * self) |
| 3296 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3297 | StreamThread * selfThread = ((StreamThread*)self); |
| 3298 | ALOGV("DEBUG(%s): ", __FUNCTION__ ); |
| 3299 | memset(&(selfThread->m_parameters), 0, sizeof(stream_parameters_t)); |
| 3300 | selfThread->m_isBufferInit = false; |
| 3301 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3302 | return; |
| 3303 | } |
| 3304 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3305 | void ExynosCameraHWInterface2::m_streamFunc0(SignalDrivenThread *self) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3306 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3307 | uint32_t currentSignal = self->GetProcessingSignal(); |
| 3308 | StreamThread * selfThread = ((StreamThread*)self); |
| 3309 | stream_parameters_t *selfStreamParms = &(selfThread->m_parameters); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3310 | record_parameters_t *selfRecordParms = &(selfThread->m_recordParameters); |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 3311 | callback_parameters_t *selfPreviewCbParms = &(selfThread->m_previewCbParameters); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3312 | node_info_t *currentNode = &(selfStreamParms->node); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3313 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3314 | if (currentSignal & SIGNAL_STREAM_CHANGE_PARAMETER) { |
| 3315 | ALOGV("DEBUG(%s): processing SIGNAL_STREAM_CHANGE_PARAMETER", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3316 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3317 | ALOGV("DEBUG(%s): processing SIGNAL_STREAM_CHANGE_PARAMETER DONE", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3318 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3319 | |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 3320 | if (currentSignal & SIGNAL_THREAD_RELEASE) { |
| 3321 | int i, index = -1, cnt_to_dq = 0; |
| 3322 | status_t res; |
| 3323 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE", __FUNCTION__); |
| 3324 | ALOGD("(%s):(%d) SIGNAL_THREAD_RELEASE", __FUNCTION__, selfStreamParms->streamType); |
| 3325 | |
| 3326 | if (selfThread->m_isBufferInit) { |
| 3327 | for ( i=0 ; i < selfStreamParms->numSvcBuffers; i++) { |
| 3328 | ALOGV("DEBUG(%s): checking buffer index[%d] - status(%d)", |
| 3329 | __FUNCTION__, i, selfStreamParms->svcBufStatus[i]); |
| 3330 | if (selfStreamParms->svcBufStatus[i] ==ON_DRIVER) cnt_to_dq++; |
| 3331 | } |
| 3332 | |
| 3333 | ALOGV("DEBUG(%s): calling stream(%d) streamoff (fd:%d)", __FUNCTION__, |
| 3334 | selfThread->m_index, selfStreamParms->fd); |
| 3335 | if (cam_int_streamoff(&(selfStreamParms->node)) < 0 ){ |
| 3336 | ALOGE("ERR(%s): stream off fail", __FUNCTION__); |
| 3337 | } else { |
| 3338 | m_scp_closing = true; |
| 3339 | } |
| 3340 | ALOGV("DEBUG(%s): calling stream(%d) streamoff done", __FUNCTION__, selfThread->m_index); |
| 3341 | ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 (fd:%d)", __FUNCTION__, |
| 3342 | selfThread->m_index, selfStreamParms->fd); |
| 3343 | currentNode->buffers = 0; |
| 3344 | cam_int_reqbufs(currentNode); |
| 3345 | ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 DONE(fd:%d)", __FUNCTION__, |
| 3346 | selfThread->m_index, selfStreamParms->fd); |
| 3347 | } |
| 3348 | #ifdef ENABLE_FRAME_SYNC |
| 3349 | // free metabuffers |
| 3350 | for(i = 0; i < NUM_MAX_CAMERA_BUFFERS; i++) |
| 3351 | if(selfStreamParms->metaBuffers[i].fd.extFd[0] != 0){ |
| 3352 | freeCameraMemory(&(selfStreamParms->metaBuffers[i]), 1); |
| 3353 | selfStreamParms->metaBuffers[i].fd.extFd[0] = 0; |
| 3354 | selfStreamParms->metaBuffers[i].size.extS[0] = 0; |
| 3355 | } |
| 3356 | #endif |
| 3357 | selfThread->m_isBufferInit = false; |
| 3358 | selfThread->m_index = 255; |
| 3359 | |
| 3360 | selfThread->m_releasing = false; |
| 3361 | |
| 3362 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE DONE", __FUNCTION__); |
| 3363 | |
| 3364 | return; |
| 3365 | } |
| 3366 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3367 | if (currentSignal & SIGNAL_STREAM_DATA_COMING) { |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3368 | buffer_handle_t * buf = NULL; |
| 3369 | status_t res; |
| 3370 | void *virtAddr[3]; |
| 3371 | int i, j; |
| 3372 | int index; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3373 | nsecs_t timestamp; |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 3374 | camera2_stream *frame; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3375 | |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 3376 | int numOfUndqbuf = 0; |
| 3377 | bool again = false; |
| 3378 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3379 | ALOGV("DEBUG(%s): stream(%d) processing SIGNAL_STREAM_DATA_COMING", |
| 3380 | __FUNCTION__,selfThread->m_index); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3381 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3382 | m_streamBufferInit(self); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3383 | |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3384 | do { |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3385 | ALOGV("DEBUG(%s): stream(%d) type(%d) DQBUF START ",__FUNCTION__, |
| 3386 | selfThread->m_index, selfStreamParms->streamType); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3387 | |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 3388 | #ifdef ENABLE_FRAME_SYNC |
| 3389 | index = cam_int_dqbuf(&(selfStreamParms->node), selfStreamParms->nodePlanes + selfStreamParms->metaPlanes); |
| 3390 | frame = (struct camera2_stream *)(selfStreamParms->metaBuffers[index].virt.extP[0]); |
| 3391 | ALOGD("frame count(SCP) : %d", frame->fcount); |
| 3392 | #else |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3393 | index = cam_int_dqbuf(&(selfStreamParms->node)); |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 3394 | #endif |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 3395 | m_scpOutputImageCnt++; |
| 3396 | ALOGV("DEBUG(%s): stream(%d) DQBUF done index(%d) sigcnt(%d) imgcnt(%d)",__FUNCTION__, |
| 3397 | selfThread->m_index, index, m_scpOutputSignalCnt, m_scpOutputImageCnt); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3398 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3399 | if (selfStreamParms->svcBufStatus[index] != ON_DRIVER) |
| 3400 | ALOGV("DBG(%s): DQed buffer status abnormal (%d) ", |
| 3401 | __FUNCTION__, selfStreamParms->svcBufStatus[index]); |
| 3402 | selfStreamParms->svcBufStatus[index] = ON_HAL; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3403 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3404 | if (m_recordOutput && m_recordingEnabled) { |
| 3405 | ALOGV("DEBUG(%s): Entering record frame creator, index(%d)",__FUNCTION__, selfRecordParms->svcBufIndex); |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 3406 | bool found = false; |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3407 | for (int i = 0 ; selfRecordParms->numSvcBuffers ; i++) { |
| 3408 | if (selfRecordParms->svcBufStatus[selfRecordParms->svcBufIndex] == ON_HAL) { |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 3409 | found = true; |
| 3410 | break; |
| 3411 | } |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3412 | selfRecordParms->svcBufIndex++; |
| 3413 | if (selfRecordParms->svcBufIndex >= selfRecordParms->numSvcBuffers) |
| 3414 | selfRecordParms->svcBufIndex = 0; |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 3415 | } |
| 3416 | if (!found) { |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3417 | ALOGE("(%s): cannot find free recording buffer", __FUNCTION__); |
| 3418 | selfRecordParms->svcBufIndex++; |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 3419 | break; |
| 3420 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3421 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3422 | if (m_exynosVideoCSC) { |
| 3423 | int videoW = selfRecordParms->outputWidth, videoH = selfRecordParms->outputHeight; |
| 3424 | int cropX, cropY, cropW, cropH = 0; |
| 3425 | int previewW = selfStreamParms->outputWidth, previewH = selfStreamParms->outputHeight; |
| 3426 | m_getRatioSize(previewW, previewH, |
| 3427 | videoW, videoH, |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3428 | &cropX, &cropY, |
| 3429 | &cropW, &cropH, |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3430 | 0); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3431 | |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3432 | ALOGV("DEBUG(%s):cropX = %d, cropY = %d, cropW = %d, cropH = %d", |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3433 | __FUNCTION__, cropX, cropY, cropW, cropH); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3434 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3435 | csc_set_src_format(m_exynosVideoCSC, |
| 3436 | previewW, previewH, |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3437 | cropX, cropY, cropW, cropH, |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 3438 | selfStreamParms->outputFormat, |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3439 | 0); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3440 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3441 | csc_set_dst_format(m_exynosVideoCSC, |
| 3442 | videoW, videoH, |
| 3443 | 0, 0, videoW, videoH, |
| 3444 | selfRecordParms->outputFormat, |
| 3445 | 1); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3446 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3447 | csc_set_src_buffer(m_exynosVideoCSC, |
| 3448 | (void **)(&(selfStreamParms->svcBuffers[index].fd.fd))); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3449 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3450 | csc_set_dst_buffer(m_exynosVideoCSC, |
| 3451 | (void **)(&(selfRecordParms->svcBuffers[selfRecordParms->svcBufIndex].fd.fd))); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3452 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3453 | if (csc_convert(m_exynosVideoCSC) != 0) { |
| 3454 | ALOGE("ERR(%s):csc_convert() fail", __FUNCTION__); |
| 3455 | } |
| 3456 | else { |
| 3457 | ALOGV("(%s):csc_convert() SUCCESS", __FUNCTION__); |
| 3458 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3459 | } |
| 3460 | else { |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3461 | ALOGE("ERR(%s):m_exynosVideoCSC == NULL", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3462 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3463 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3464 | res = selfRecordParms->streamOps->enqueue_buffer(selfRecordParms->streamOps, |
| 3465 | systemTime(), |
| 3466 | &(selfRecordParms->svcBufHandle[selfRecordParms->svcBufIndex])); |
| 3467 | ALOGV("DEBUG(%s): stream(%d) record enqueue_buffer to svc done res(%d)", __FUNCTION__, |
| 3468 | selfThread->m_index, res); |
Sungjoong Kang | 37e122d | 2012-08-08 11:13:48 -0700 | [diff] [blame] | 3469 | if (res == 0) { |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3470 | selfRecordParms->svcBufStatus[selfRecordParms->svcBufIndex] = ON_SERVICE; |
| 3471 | selfRecordParms->numSvcBufsInHal--; |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3472 | } |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3473 | } |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 3474 | |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 3475 | if (m_previewCbOutput && m_previewCbEnabled) { |
| 3476 | ALOGV("DEBUG(%s): Entering previewcb creator, index(%d)",__FUNCTION__, selfPreviewCbParms->svcBufIndex); |
| 3477 | |
| 3478 | bool found = false; |
| 3479 | for (int i = 0 ; selfPreviewCbParms->numSvcBuffers ; i++) { |
| 3480 | if (selfPreviewCbParms->svcBufStatus[selfPreviewCbParms->svcBufIndex] == ON_HAL) { |
| 3481 | found = true; |
| 3482 | break; |
| 3483 | } |
| 3484 | selfPreviewCbParms->svcBufIndex++; |
| 3485 | if (selfPreviewCbParms->svcBufIndex >= selfPreviewCbParms->numSvcBuffers) |
| 3486 | selfPreviewCbParms->svcBufIndex = 0; |
| 3487 | } |
| 3488 | if (!found) { |
| 3489 | ALOGE("(%s): cannot find free previewcb buffer", __FUNCTION__); |
| 3490 | selfPreviewCbParms->svcBufIndex++; |
| 3491 | break; |
| 3492 | } |
| 3493 | if (selfPreviewCbParms->outputFormat == HAL_PIXEL_FORMAT_YCrCb_420_SP) { |
| 3494 | if (m_exynosVideoCSC) { |
| 3495 | int previewCbW = selfPreviewCbParms->outputWidth, previewCbH = selfPreviewCbParms->outputHeight; |
| 3496 | int cropX, cropY, cropW, cropH = 0; |
| 3497 | int previewW = selfStreamParms->outputWidth, previewH = selfStreamParms->outputHeight; |
| 3498 | m_getRatioSize(previewW, previewH, |
| 3499 | previewCbW, previewCbH, |
| 3500 | &cropX, &cropY, |
| 3501 | &cropW, &cropH, |
| 3502 | 0); |
| 3503 | |
| 3504 | ALOGV("DEBUG(%s):cropX = %d, cropY = %d, cropW = %d, cropH = %d", |
| 3505 | __FUNCTION__, cropX, cropY, cropW, cropH); |
| 3506 | csc_set_src_format(m_exynosVideoCSC, |
| 3507 | previewW, previewH, |
| 3508 | cropX, cropY, cropW, cropH, |
| 3509 | selfStreamParms->outputFormat, |
| 3510 | 0); |
| 3511 | |
| 3512 | csc_set_dst_format(m_exynosVideoCSC, |
| 3513 | previewCbW, previewCbH, |
| 3514 | 0, 0, previewCbW, previewCbH, |
| 3515 | selfPreviewCbParms->internalFormat, |
| 3516 | 1); |
| 3517 | |
| 3518 | csc_set_src_buffer(m_exynosVideoCSC, |
| 3519 | (void **)(&(selfStreamParms->svcBuffers[index].fd.fd))); |
| 3520 | |
| 3521 | csc_set_dst_buffer(m_exynosVideoCSC, |
| 3522 | (void **)(&(m_previewCbBuf.fd.fd))); |
| 3523 | |
| 3524 | if (csc_convert(m_exynosVideoCSC) != 0) { |
| 3525 | ALOGE("ERR(%s):previewcb csc_convert() fail", __FUNCTION__); |
| 3526 | } |
| 3527 | else { |
| 3528 | ALOGV("(%s):previewcb csc_convert() SUCCESS", __FUNCTION__); |
| 3529 | } |
| 3530 | if (previewCbW == ALIGN(previewCbW, 16)) { |
| 3531 | ALOGV("(%s):previewcb %d = %d", __FUNCTION__, previewCbW, ALIGN(previewCbW, 16)); |
| 3532 | memcpy(selfPreviewCbParms->svcBuffers[selfPreviewCbParms->svcBufIndex].virt.extP[0], |
| 3533 | m_previewCbBuf.virt.extP[0], previewCbW * previewCbH); |
| 3534 | memcpy(selfPreviewCbParms->svcBuffers[selfPreviewCbParms->svcBufIndex].virt.extP[0] + previewCbW * previewCbH, |
| 3535 | m_previewCbBuf.virt.extP[1], previewCbW * previewCbH / 2 ); |
| 3536 | } |
| 3537 | else { |
| 3538 | // TODO : copy line by line ? |
| 3539 | } |
| 3540 | } |
| 3541 | else { |
| 3542 | ALOGE("ERR(%s):m_exynosVideoCSC == NULL", __FUNCTION__); |
| 3543 | } |
| 3544 | } |
| 3545 | else if (selfPreviewCbParms->outputFormat == HAL_PIXEL_FORMAT_YV12) { |
| 3546 | int previewCbW = selfPreviewCbParms->outputWidth, previewCbH = selfPreviewCbParms->outputHeight; |
| 3547 | int stride = ALIGN(previewCbW, 16); |
| 3548 | int c_stride = ALIGN(stride, 16); |
| 3549 | memcpy(selfPreviewCbParms->svcBuffers[selfPreviewCbParms->svcBufIndex].virt.extP[0], |
| 3550 | selfStreamParms->svcBuffers[index].virt.extP[0], stride * previewCbH); |
| 3551 | memcpy(selfPreviewCbParms->svcBuffers[selfPreviewCbParms->svcBufIndex].virt.extP[0] + stride * previewCbH, |
| 3552 | selfStreamParms->svcBuffers[index].virt.extP[1], c_stride * previewCbH / 2 ); |
| 3553 | memcpy(selfPreviewCbParms->svcBuffers[selfPreviewCbParms->svcBufIndex].virt.extP[0] + (stride * previewCbH) + (c_stride * previewCbH / 2), |
| 3554 | selfStreamParms->svcBuffers[index].virt.extP[2], c_stride * previewCbH / 2 ); |
| 3555 | |
| 3556 | } |
| 3557 | res = selfPreviewCbParms->streamOps->enqueue_buffer(selfPreviewCbParms->streamOps, |
| 3558 | systemTime(), |
| 3559 | &(selfPreviewCbParms->svcBufHandle[selfPreviewCbParms->svcBufIndex])); |
| 3560 | ALOGV("DEBUG(%s): stream(%d) previewcb enqueue_buffer[%d] to svc done res(%d)", __FUNCTION__, |
| 3561 | selfThread->m_index, index, res); |
| 3562 | if (res == 0) { |
| 3563 | selfPreviewCbParms->svcBufStatus[selfPreviewCbParms->svcBufIndex] = ON_SERVICE; |
| 3564 | selfPreviewCbParms->numSvcBufsInHal--; |
| 3565 | } |
| 3566 | } |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 3567 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3568 | if (m_previewOutput && m_requestManager->GetSkipCnt() <= 0) { |
| 3569 | |
| 3570 | ALOGV("** Display Preview(frameCnt:%d)", m_requestManager->GetFrameIndex()); |
| 3571 | res = selfStreamParms->streamOps->enqueue_buffer(selfStreamParms->streamOps, |
| 3572 | m_requestManager->GetTimestamp(m_requestManager->GetFrameIndex()), |
| 3573 | &(selfStreamParms->svcBufHandle[index])); |
| 3574 | |
| 3575 | ALOGV("DEBUG(%s): stream(%d) enqueue_buffer to svc done res(%d)", __FUNCTION__, selfThread->m_index, res); |
| 3576 | } |
| 3577 | else { |
| 3578 | res = selfStreamParms->streamOps->cancel_buffer(selfStreamParms->streamOps, |
| 3579 | &(selfStreamParms->svcBufHandle[index])); |
| 3580 | ALOGV("DEBUG(%s): stream(%d) cancel_buffer to svc done res(%d)", __FUNCTION__, selfThread->m_index, res); |
| 3581 | } |
| 3582 | if (res == 0) { |
| 3583 | selfStreamParms->svcBufStatus[index] = ON_SERVICE; |
| 3584 | selfStreamParms->numSvcBufsInHal--; |
| 3585 | } |
| 3586 | else { |
| 3587 | selfStreamParms->svcBufStatus[index] = ON_HAL; |
| 3588 | } |
| 3589 | |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 3590 | // HACK |
hyeonmyeong Choi | 2bbbf0c | 2012-09-09 11:50:21 -0700 | [diff] [blame] | 3591 | if (again == false && !(m_recordOutput && m_recordingEnabled)) { |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 3592 | if (exynos_v4l2_g_ctrl(currentNode->fd, V4L2_CID_IS_G_COMPLETES, &numOfUndqbuf)) { |
| 3593 | ALOGW("WARN(%s): Fail to get SCP completes, val = %d", __FUNCTION__, numOfUndqbuf); |
| 3594 | } else { |
| 3595 | again = (numOfUndqbuf > 0)?true:false; |
| 3596 | if (again) |
| 3597 | ALOGW("WARN(%s): Drain SCP buf, num of undqbuf = %d", __FUNCTION__, numOfUndqbuf); |
| 3598 | } |
| 3599 | } else { |
| 3600 | again = false; |
| 3601 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3602 | } |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 3603 | while(again); |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 3604 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3605 | if (m_recordOutput && m_recordingEnabled) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3606 | do { |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 3607 | ALOGV("DEBUG(%s): record currentBuf#(%d)", __FUNCTION__ , selfRecordParms->numSvcBufsInHal); |
| 3608 | if (selfRecordParms->numSvcBufsInHal >= 1) |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3609 | { |
| 3610 | ALOGV("DEBUG(%s): breaking", __FUNCTION__); |
| 3611 | break; |
| 3612 | } |
| 3613 | res = selfRecordParms->streamOps->dequeue_buffer(selfRecordParms->streamOps, &buf); |
| 3614 | if (res != NO_ERROR || buf == NULL) { |
| 3615 | ALOGV("DEBUG(%s): record stream(%d) dequeue_buffer fail res(%d)",__FUNCTION__ , selfThread->m_index, res); |
| 3616 | break; |
| 3617 | } |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 3618 | selfRecordParms->numSvcBufsInHal ++; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3619 | ALOGV("DEBUG(%s): record got buf(%x) numBufInHal(%d) version(%d), numFds(%d), numInts(%d)", __FUNCTION__, (uint32_t)(*buf), |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 3620 | selfRecordParms->numSvcBufsInHal, ((native_handle_t*)(*buf))->version, ((native_handle_t*)(*buf))->numFds, ((native_handle_t*)(*buf))->numInts); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3621 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3622 | const private_handle_t *priv_handle = reinterpret_cast<const private_handle_t *>(*buf); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3623 | bool found = false; |
| 3624 | int checkingIndex = 0; |
| 3625 | for (checkingIndex = 0; checkingIndex < selfRecordParms->numSvcBuffers ; checkingIndex++) { |
| 3626 | if (priv_handle->fd == selfRecordParms->svcBuffers[checkingIndex].fd.extFd[0] ) { |
| 3627 | found = true; |
| 3628 | break; |
| 3629 | } |
| 3630 | } |
| 3631 | ALOGV("DEBUG(%s): recording dequeueed_buffer found index(%d)", __FUNCTION__, found); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3632 | |
| 3633 | if (!found) { |
| 3634 | break; |
| 3635 | } |
| 3636 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3637 | index = checkingIndex; |
| 3638 | if (selfRecordParms->svcBufStatus[index] == ON_SERVICE) { |
| 3639 | selfRecordParms->svcBufStatus[index] = ON_HAL; |
| 3640 | } |
| 3641 | else { |
| 3642 | ALOGV("DEBUG(%s): record bufstatus abnormal [%d] status = %d", __FUNCTION__, |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 3643 | index, selfRecordParms->svcBufStatus[index]); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3644 | } |
| 3645 | } while (0); |
| 3646 | } |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 3647 | if (m_previewCbOutput && m_previewCbEnabled) { |
| 3648 | do { |
| 3649 | ALOGV("DEBUG(%s): previewCb currentBuf#(%d)", __FUNCTION__ , selfPreviewCbParms->numSvcBufsInHal); |
| 3650 | if (selfPreviewCbParms->numSvcBufsInHal >= 1) |
| 3651 | { |
| 3652 | ALOGV("DEBUG(%s): breaking", __FUNCTION__); |
| 3653 | break; |
| 3654 | } |
| 3655 | res = selfPreviewCbParms->streamOps->dequeue_buffer(selfPreviewCbParms->streamOps, &buf); |
| 3656 | if (res != NO_ERROR || buf == NULL) { |
| 3657 | ALOGV("DEBUG(%s): previewcb stream(%d) dequeue_buffer fail res(%d)",__FUNCTION__ , selfThread->m_index, res); |
| 3658 | break; |
| 3659 | } |
| 3660 | selfPreviewCbParms->numSvcBufsInHal ++; |
| 3661 | ALOGV("DEBUG(%s): previewcb got buf(%x) numBufInHal(%d) version(%d), numFds(%d), numInts(%d)", __FUNCTION__, (uint32_t)(*buf), |
| 3662 | selfPreviewCbParms->numSvcBufsInHal, ((native_handle_t*)(*buf))->version, ((native_handle_t*)(*buf))->numFds, ((native_handle_t*)(*buf))->numInts); |
| 3663 | |
| 3664 | const private_handle_t *priv_handle = reinterpret_cast<const private_handle_t *>(*buf); |
| 3665 | bool found = false; |
| 3666 | int checkingIndex = 0; |
| 3667 | for (checkingIndex = 0; checkingIndex < selfPreviewCbParms->numSvcBuffers ; checkingIndex++) { |
| 3668 | if (priv_handle->fd == selfPreviewCbParms->svcBuffers[checkingIndex].fd.extFd[0] ) { |
| 3669 | found = true; |
| 3670 | break; |
| 3671 | } |
| 3672 | } |
| 3673 | ALOGV("DEBUG(%s): previewcb dequeueed_buffer found index(%d)", __FUNCTION__, found); |
| 3674 | |
| 3675 | if (!found) { |
| 3676 | break; |
| 3677 | } |
| 3678 | |
| 3679 | index = checkingIndex; |
| 3680 | if (selfPreviewCbParms->svcBufStatus[index] == ON_SERVICE) { |
| 3681 | selfPreviewCbParms->svcBufStatus[index] = ON_HAL; |
| 3682 | } |
| 3683 | else { |
| 3684 | ALOGV("DEBUG(%s): previewcb bufstatus abnormal [%d] status = %d", __FUNCTION__, |
| 3685 | index, selfPreviewCbParms->svcBufStatus[index]); |
| 3686 | } |
| 3687 | } while (0); |
| 3688 | } |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3689 | |
Sungjoong Kang | b55ed66 | 2012-08-31 21:31:34 -0700 | [diff] [blame] | 3690 | while (selfStreamParms->numSvcBufsInHal < selfStreamParms->numOwnSvcBuffers - 1) { |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3691 | res = selfStreamParms->streamOps->dequeue_buffer(selfStreamParms->streamOps, &buf); |
| 3692 | if (res != NO_ERROR || buf == NULL) { |
| 3693 | ALOGV("DEBUG(%s): stream(%d) dequeue_buffer fail res(%d)",__FUNCTION__ , selfThread->m_index, res); |
| 3694 | break; |
| 3695 | } |
| 3696 | selfStreamParms->numSvcBufsInHal++; |
| 3697 | ALOGV("DEBUG(%s): stream(%d) got buf(%x) numInHal(%d) version(%d), numFds(%d), numInts(%d)", __FUNCTION__, |
| 3698 | selfThread->m_index, (uint32_t)(*buf), selfStreamParms->numSvcBufsInHal, |
| 3699 | ((native_handle_t*)(*buf))->version, ((native_handle_t*)(*buf))->numFds, ((native_handle_t*)(*buf))->numInts); |
| 3700 | const private_handle_t *priv_handle = reinterpret_cast<const private_handle_t *>(*buf); |
| 3701 | |
| 3702 | bool found = false; |
| 3703 | int checkingIndex = 0; |
| 3704 | for (checkingIndex = 0; checkingIndex < selfStreamParms->numSvcBuffers ; checkingIndex++) { |
| 3705 | if (priv_handle->fd == selfStreamParms->svcBuffers[checkingIndex].fd.extFd[0] ) { |
| 3706 | found = true; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3707 | break; |
| 3708 | } |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3709 | } |
hyeonmyeong Choi | c0b6e17 | 2012-09-05 00:51:31 -0700 | [diff] [blame] | 3710 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3711 | ALOGV("DEBUG(%s): post_dequeue_buffer found(%d)", __FUNCTION__, found); |
| 3712 | if (!found) break; |
| 3713 | ALOGV("DEBUG(%s): preparing to qbuf [%d]", __FUNCTION__, checkingIndex); |
| 3714 | index = checkingIndex; |
| 3715 | if (index < selfStreamParms->numHwBuffers) { |
| 3716 | uint32_t plane_index = 0; |
| 3717 | ExynosBuffer* currentBuf = &(selfStreamParms->svcBuffers[index]); |
| 3718 | struct v4l2_buffer v4l2_buf; |
| 3719 | struct v4l2_plane planes[VIDEO_MAX_PLANES]; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3720 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3721 | v4l2_buf.m.planes = planes; |
| 3722 | v4l2_buf.type = currentNode->type; |
| 3723 | v4l2_buf.memory = currentNode->memory; |
| 3724 | v4l2_buf.index = index; |
| 3725 | v4l2_buf.length = currentNode->planes; |
| 3726 | |
| 3727 | v4l2_buf.m.planes[0].m.fd = priv_handle->fd; |
| 3728 | v4l2_buf.m.planes[2].m.fd = priv_handle->fd1; |
| 3729 | v4l2_buf.m.planes[1].m.fd = priv_handle->fd2; |
| 3730 | for (plane_index=0 ; plane_index < v4l2_buf.length ; plane_index++) { |
| 3731 | v4l2_buf.m.planes[plane_index].length = currentBuf->size.extS[plane_index]; |
| 3732 | ALOGV("DEBUG(%s): plane(%d): fd(%d) length(%d)", |
| 3733 | __FUNCTION__, plane_index, v4l2_buf.m.planes[plane_index].m.fd, |
| 3734 | v4l2_buf.m.planes[plane_index].length); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3735 | } |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 3736 | #ifdef ENABLE_FRAME_SYNC |
| 3737 | /* add plane for metadata*/ |
| 3738 | v4l2_buf.length += selfStreamParms->metaPlanes; |
| 3739 | v4l2_buf.m.planes[3].m.fd = selfStreamParms->metaBuffers[index].fd.extFd[0]; |
| 3740 | v4l2_buf.m.planes[3].length = selfStreamParms->metaBuffers[index].size.extS[0]; |
| 3741 | #endif |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3742 | if (exynos_v4l2_qbuf(currentNode->fd, &v4l2_buf) < 0) { |
| 3743 | ALOGE("ERR(%s): stream id(%d) exynos_v4l2_qbuf() fail", |
| 3744 | __FUNCTION__, selfThread->m_index); |
| 3745 | return; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 3746 | } |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3747 | selfStreamParms->svcBufStatus[index] = ON_DRIVER; |
| 3748 | ALOGV("DEBUG(%s): stream id(%d) type0 QBUF done index(%d)", |
| 3749 | __FUNCTION__, selfThread->m_index, index); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3750 | } |
| 3751 | } |
Sungjoong Kang | be494d1 | 2012-08-04 15:36:56 -0700 | [diff] [blame] | 3752 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 3753 | ALOGV("DEBUG(%s): stream(%d) processing SIGNAL_STREAM_DATA_COMING DONE", |
| 3754 | __FUNCTION__,selfThread->m_index); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 3755 | } |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3756 | return; |
| 3757 | } |
| 3758 | |
| 3759 | void ExynosCameraHWInterface2::m_streamFunc1(SignalDrivenThread *self) |
| 3760 | { |
| 3761 | uint32_t currentSignal = self->GetProcessingSignal(); |
| 3762 | StreamThread * selfThread = ((StreamThread*)self); |
| 3763 | stream_parameters_t *selfStreamParms = &(selfThread->m_parameters); |
| 3764 | record_parameters_t *selfRecordParms = &(selfThread->m_recordParameters); |
| 3765 | node_info_t *currentNode = &(selfStreamParms->node); |
| 3766 | |
| 3767 | if (currentSignal & SIGNAL_STREAM_CHANGE_PARAMETER) { |
| 3768 | ALOGV("DEBUG(%s): processing SIGNAL_STREAM_CHANGE_PARAMETER", __FUNCTION__); |
| 3769 | |
| 3770 | m_resizeBuf.size.extS[0] = ALIGN(selfStreamParms->outputWidth, 16) * ALIGN(selfStreamParms->outputHeight, 16) * 2; |
| 3771 | m_resizeBuf.size.extS[1] = 0; |
| 3772 | m_resizeBuf.size.extS[2] = 0; |
| 3773 | |
| 3774 | if (allocCameraMemory(selfStreamParms->ionClient, &m_resizeBuf, 1) == -1) { |
| 3775 | ALOGE("ERR(%s): Failed to allocate resize buf", __FUNCTION__); |
| 3776 | } |
| 3777 | |
| 3778 | ALOGV("DEBUG(%s): processing SIGNAL_STREAM_CHANGE_PARAMETER DONE", __FUNCTION__); |
| 3779 | } |
| 3780 | |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 3781 | if (currentSignal & SIGNAL_THREAD_RELEASE) { |
| 3782 | int i, index = -1, cnt_to_dq = 0; |
| 3783 | status_t res; |
| 3784 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE", __FUNCTION__); |
| 3785 | ALOGD("(%s):(%d) SIGNAL_THREAD_RELEASE", __FUNCTION__, selfStreamParms->streamType); |
| 3786 | |
| 3787 | if (selfThread->m_isBufferInit) { |
| 3788 | for ( i=0 ; i < selfStreamParms->numSvcBuffers; i++) { |
| 3789 | ALOGV("DEBUG(%s): checking buffer index[%d] - status(%d)", |
| 3790 | __FUNCTION__, i, selfStreamParms->svcBufStatus[i]); |
| 3791 | if (selfStreamParms->svcBufStatus[i] ==ON_DRIVER) cnt_to_dq++; |
| 3792 | } |
| 3793 | |
| 3794 | ALOGV("DEBUG(%s): calling stream(%d) streamoff (fd:%d)", __FUNCTION__, |
| 3795 | selfThread->m_index, selfStreamParms->fd); |
| 3796 | if (cam_int_streamoff(&(selfStreamParms->node)) < 0 ){ |
| 3797 | ALOGE("ERR(%s): stream off fail", __FUNCTION__); |
| 3798 | } else { |
| 3799 | m_camera_info.capture.status = false; |
| 3800 | } |
| 3801 | ALOGV("DEBUG(%s): calling stream(%d) streamoff done", __FUNCTION__, selfThread->m_index); |
| 3802 | ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 (fd:%d)", __FUNCTION__, |
| 3803 | selfThread->m_index, selfStreamParms->fd); |
| 3804 | currentNode->buffers = 0; |
| 3805 | cam_int_reqbufs(currentNode); |
| 3806 | ALOGV("DEBUG(%s): calling stream(%d) reqbuf 0 DONE(fd:%d)", __FUNCTION__, |
| 3807 | selfThread->m_index, selfStreamParms->fd); |
| 3808 | } |
| 3809 | if (selfThread->m_index == 1 && m_resizeBuf.size.s != 0) { |
| 3810 | freeCameraMemory(&m_resizeBuf, 1); |
| 3811 | } |
| 3812 | selfThread->m_isBufferInit = false; |
| 3813 | selfThread->m_index = 255; |
| 3814 | |
| 3815 | selfThread->m_releasing = false; |
| 3816 | |
| 3817 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE DONE", __FUNCTION__); |
| 3818 | |
| 3819 | return; |
| 3820 | } |
| 3821 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3822 | if (currentSignal & SIGNAL_STREAM_DATA_COMING) { |
| 3823 | buffer_handle_t * buf = NULL; |
| 3824 | status_t res; |
| 3825 | void *virtAddr[3]; |
| 3826 | int i, j; |
| 3827 | int index; |
| 3828 | nsecs_t timestamp; |
| 3829 | |
| 3830 | ALOGV("DEBUG(%s): stream(%d) processing SIGNAL_STREAM_DATA_COMING", |
| 3831 | __FUNCTION__,selfThread->m_index); |
| 3832 | |
| 3833 | m_streamBufferInit(self); |
| 3834 | |
| 3835 | do { |
| 3836 | ExynosRect jpegRect; |
| 3837 | bool found = false; |
| 3838 | bool ret = false; |
| 3839 | int pictureW, pictureH, pictureFramesize = 0; |
| 3840 | int pictureFormat; |
| 3841 | int cropX, cropY, cropW, cropH = 0; |
| 3842 | ExynosBuffer resizeBufInfo; |
| 3843 | ExynosRect m_orgPictureRect; |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 3844 | camera2_stream *frame; |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3845 | |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 3846 | ALOGV("DEBUG(%s): stream(%d) type(%d) DQBUF START ",__FUNCTION__, |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3847 | selfThread->m_index, selfStreamParms->streamType); |
| 3848 | index = cam_int_dqbuf(&(selfStreamParms->node)); |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 3849 | ALOGV("DEBUG(%s): stream(%d) type(%d) DQBUF done index(%d)",__FUNCTION__, |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3850 | selfThread->m_index, selfStreamParms->streamType, index); |
| 3851 | |
Sungjoong Kang | feb7df4 | 2012-08-28 23:35:43 +0900 | [diff] [blame] | 3852 | #ifdef ENABLE_FRAME_SYNC |
| 3853 | frame = (struct camera2_stream *)(selfStreamParms->svcBuffers[index].virt.extP[selfStreamParms->nodePlanes -1]); |
| 3854 | ALOGD("frame count(SCC) : %d", frame->fcount); |
| 3855 | #endif |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3856 | for (int i = 0; i < selfStreamParms->numSvcBuffers ; i++) { |
| 3857 | if (selfStreamParms->svcBufStatus[selfStreamParms->svcBufIndex] == ON_HAL) { |
| 3858 | found = true; |
| 3859 | break; |
| 3860 | } |
| 3861 | selfStreamParms->svcBufIndex++; |
| 3862 | if (selfStreamParms->svcBufIndex >= selfStreamParms->numSvcBuffers) |
| 3863 | selfStreamParms->svcBufIndex = 0; |
| 3864 | } |
| 3865 | if (!found) { |
| 3866 | ALOGE("ERR(%s): NO free SVC buffer for JPEG", __FUNCTION__); |
| 3867 | break; |
| 3868 | } |
| 3869 | |
| 3870 | m_orgPictureRect.w = selfStreamParms->outputWidth; |
| 3871 | m_orgPictureRect.h = selfStreamParms->outputHeight; |
| 3872 | |
| 3873 | ExynosBuffer* m_pictureBuf = &(m_camera_info.capture.buffer[index]); |
| 3874 | |
Sungjoong Kang | e4657e3 | 2012-08-28 15:02:19 -0700 | [diff] [blame] | 3875 | m_getRatioSize(selfStreamParms->nodeWidth, selfStreamParms->nodeHeight, |
| 3876 | m_orgPictureRect.w, m_orgPictureRect.h, |
| 3877 | &cropX, &cropY, |
| 3878 | &pictureW, &pictureH, |
| 3879 | 0); |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3880 | pictureFormat = V4L2_PIX_FMT_YUYV; |
| 3881 | pictureFramesize = FRAME_SIZE(V4L2_PIX_2_HAL_PIXEL_FORMAT(pictureFormat), pictureW, pictureH); |
| 3882 | |
| 3883 | if (m_exynosPictureCSC) { |
hyeonmyeong Choi | 308291d | 2012-08-29 13:55:01 -0700 | [diff] [blame] | 3884 | float zoom_w = 0, zoom_h = 0; |
| 3885 | if (m_orgPictureRect.w >= m_orgPictureRect.h) { |
| 3886 | zoom_w = pictureW / m_zoomRatio; |
| 3887 | zoom_h = zoom_w * m_orgPictureRect.h / m_orgPictureRect.w; |
| 3888 | } else { |
| 3889 | zoom_h = pictureH / m_zoomRatio; |
| 3890 | zoom_w = zoom_h * m_orgPictureRect.w / m_orgPictureRect.h; |
| 3891 | } |
| 3892 | cropX = (pictureW - zoom_w) / 2; |
| 3893 | cropY = (pictureH - zoom_h) / 2; |
| 3894 | cropW = zoom_w; |
| 3895 | cropH = zoom_h; |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3896 | |
| 3897 | ALOGV("DEBUG(%s):cropX = %d, cropY = %d, cropW = %d, cropH = %d", |
| 3898 | __FUNCTION__, cropX, cropY, cropW, cropH); |
| 3899 | |
| 3900 | csc_set_src_format(m_exynosPictureCSC, |
| 3901 | ALIGN(pictureW, 16), ALIGN(pictureH, 16), |
| 3902 | cropX, cropY, cropW, cropH, |
| 3903 | V4L2_PIX_2_HAL_PIXEL_FORMAT(pictureFormat), |
| 3904 | 0); |
| 3905 | |
| 3906 | csc_set_dst_format(m_exynosPictureCSC, |
| 3907 | m_orgPictureRect.w, m_orgPictureRect.h, |
| 3908 | 0, 0, m_orgPictureRect.w, m_orgPictureRect.h, |
| 3909 | V4L2_PIX_2_HAL_PIXEL_FORMAT(V4L2_PIX_FMT_NV16), |
| 3910 | 0); |
| 3911 | csc_set_src_buffer(m_exynosPictureCSC, |
| 3912 | (void **)&m_pictureBuf->fd.fd); |
| 3913 | |
| 3914 | csc_set_dst_buffer(m_exynosPictureCSC, |
| 3915 | (void **)&m_resizeBuf.fd.fd); |
| 3916 | for (int i = 0 ; i < 3 ; i++) |
| 3917 | ALOGV("DEBUG(%s): m_resizeBuf.virt.extP[%d]=%d m_resizeBuf.size.extS[%d]=%d", |
| 3918 | __FUNCTION__, i, m_resizeBuf.fd.extFd[i], i, m_resizeBuf.size.extS[i]); |
| 3919 | |
| 3920 | if (csc_convert(m_exynosPictureCSC) != 0) |
| 3921 | ALOGE("ERR(%s): csc_convert() fail", __FUNCTION__); |
| 3922 | |
| 3923 | |
| 3924 | } |
| 3925 | else { |
| 3926 | ALOGE("ERR(%s): m_exynosPictureCSC == NULL", __FUNCTION__); |
| 3927 | } |
| 3928 | |
| 3929 | resizeBufInfo = m_resizeBuf; |
| 3930 | |
| 3931 | m_getAlignedYUVSize(V4L2_PIX_FMT_NV16, m_orgPictureRect.w, m_orgPictureRect.h, &m_resizeBuf); |
| 3932 | |
| 3933 | for (int i = 1; i < 3; i++) { |
| 3934 | if (m_resizeBuf.size.extS[i] != 0) |
| 3935 | m_resizeBuf.fd.extFd[i] = m_resizeBuf.fd.extFd[i-1] + m_resizeBuf.size.extS[i-1]; |
| 3936 | |
| 3937 | ALOGV("(%s): m_resizeBuf.size.extS[%d] = %d", __FUNCTION__, i, m_resizeBuf.size.extS[i]); |
| 3938 | } |
| 3939 | |
| 3940 | jpegRect.w = m_orgPictureRect.w; |
| 3941 | jpegRect.h = m_orgPictureRect.h; |
| 3942 | jpegRect.colorFormat = V4L2_PIX_FMT_NV16; |
| 3943 | |
| 3944 | if (yuv2Jpeg(&m_resizeBuf, &selfStreamParms->svcBuffers[selfStreamParms->svcBufIndex], &jpegRect) == false) |
| 3945 | ALOGE("ERR(%s):yuv2Jpeg() fail", __FUNCTION__); |
| 3946 | cam_int_qbuf(&(selfStreamParms->node), index); |
| 3947 | ALOGV("DEBUG(%s): stream(%d) type(%d) QBUF DONE ",__FUNCTION__, |
| 3948 | selfThread->m_index, selfStreamParms->streamType); |
| 3949 | |
| 3950 | m_resizeBuf = resizeBufInfo; |
| 3951 | |
| 3952 | res = selfStreamParms->streamOps->enqueue_buffer(selfStreamParms->streamOps, systemTime(), &(selfStreamParms->svcBufHandle[selfStreamParms->svcBufIndex])); |
| 3953 | |
| 3954 | ALOGV("DEBUG(%s): stream(%d) enqueue_buffer index(%d) to svc done res(%d)", |
| 3955 | __FUNCTION__, selfThread->m_index, selfStreamParms->svcBufIndex, res); |
| 3956 | if (res == 0) { |
| 3957 | selfStreamParms->svcBufStatus[selfStreamParms->svcBufIndex] = ON_SERVICE; |
| 3958 | selfStreamParms->numSvcBufsInHal--; |
| 3959 | } |
| 3960 | else { |
| 3961 | selfStreamParms->svcBufStatus[selfStreamParms->svcBufIndex] = ON_HAL; |
| 3962 | } |
| 3963 | } |
| 3964 | while (0); |
| 3965 | |
| 3966 | while (selfStreamParms->numSvcBufsInHal < selfStreamParms->numOwnSvcBuffers) { |
| 3967 | res = selfStreamParms->streamOps->dequeue_buffer(selfStreamParms->streamOps, &buf); |
| 3968 | if (res != NO_ERROR || buf == NULL) { |
| 3969 | ALOGV("DEBUG(%s): stream(%d) dequeue_buffer fail res(%d)",__FUNCTION__ , selfThread->m_index, res); |
| 3970 | break; |
| 3971 | } |
| 3972 | |
| 3973 | ALOGV("DEBUG(%s): stream(%d) got buf(%x) numInHal(%d) version(%d), numFds(%d), numInts(%d)", __FUNCTION__, |
| 3974 | selfThread->m_index, (uint32_t)(*buf), selfStreamParms->numSvcBufsInHal, |
| 3975 | ((native_handle_t*)(*buf))->version, ((native_handle_t*)(*buf))->numFds, ((native_handle_t*)(*buf))->numInts); |
| 3976 | |
| 3977 | const private_handle_t *priv_handle = reinterpret_cast<const private_handle_t *>(*buf); |
| 3978 | |
| 3979 | bool found = false; |
| 3980 | int checkingIndex = 0; |
| 3981 | for (checkingIndex = 0; checkingIndex < selfStreamParms->numSvcBuffers ; checkingIndex++) { |
| 3982 | if (priv_handle->fd == selfStreamParms->svcBuffers[checkingIndex].fd.extFd[0] ) { |
| 3983 | found = true; |
| 3984 | break; |
| 3985 | } |
| 3986 | } |
| 3987 | if (!found) break; |
| 3988 | selfStreamParms->svcBufStatus[checkingIndex] = ON_HAL; |
| 3989 | selfStreamParms->numSvcBufsInHal++; |
| 3990 | } |
| 3991 | |
| 3992 | ALOGV("DEBUG(%s): stream(%d) processing SIGNAL_STREAM_DATA_COMING DONE", |
| 3993 | __FUNCTION__,selfThread->m_index); |
| 3994 | } |
| 3995 | |
Sungjoong Kang | 86646da | 2012-08-28 17:29:11 +0900 | [diff] [blame] | 3996 | return; |
| 3997 | } |
| 3998 | |
| 3999 | |
| 4000 | void ExynosCameraHWInterface2::m_streamThreadFunc(SignalDrivenThread * self) |
| 4001 | { |
| 4002 | uint32_t currentSignal = self->GetProcessingSignal(); |
| 4003 | StreamThread * selfThread = ((StreamThread*)self); |
| 4004 | stream_parameters_t *selfStreamParms = &(selfThread->m_parameters); |
| 4005 | record_parameters_t *selfRecordParms = &(selfThread->m_recordParameters); |
| 4006 | node_info_t *currentNode = &(selfStreamParms->node); |
| 4007 | |
| 4008 | ALOGV("DEBUG(%s): m_streamThreadFunc[%d] (%x)", __FUNCTION__, selfThread->m_index, currentSignal); |
| 4009 | |
| 4010 | if (currentSignal & SIGNAL_STREAM_CHANGE_PARAMETER) { |
| 4011 | ALOGV("DEBUG(%s): processing SIGNAL_STREAM_CHANGE_PARAMETER", __FUNCTION__); |
| 4012 | |
| 4013 | //Do something in Parent thread handler |
| 4014 | selfThread->applyChange(); |
| 4015 | |
| 4016 | ALOGV("DEBUG(%s): processing SIGNAL_STREAM_CHANGE_PARAMETER DONE", __FUNCTION__); |
| 4017 | } |
| 4018 | |
| 4019 | // Do something in Child thread handler |
| 4020 | // Should change function to class that inherited StreamThread class to support dynamic stream allocation |
| 4021 | if (selfStreamParms->streamType == STREAM_TYPE_DIRECT) |
| 4022 | { |
| 4023 | m_streamFunc0(self); |
| 4024 | } |
| 4025 | else if (selfStreamParms->streamType == STREAM_TYPE_INDIRECT) |
| 4026 | { |
| 4027 | m_streamFunc1(self); |
| 4028 | } |
| 4029 | |
| 4030 | if (currentSignal & SIGNAL_THREAD_RELEASE) { |
| 4031 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE", __FUNCTION__); |
| 4032 | ALOGD("(%s):(%d) SIGNAL_THREAD_RELEASE", __FUNCTION__, selfStreamParms->streamType); |
| 4033 | |
| 4034 | //Do something in Parent thread handler |
| 4035 | |
| 4036 | ALOGV("DEBUG(%s): processing SIGNAL_THREAD_RELEASE DONE", __FUNCTION__); |
| 4037 | |
| 4038 | return; |
| 4039 | } |
| 4040 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 4041 | return; |
| 4042 | } |
| 4043 | |
Sungjoong Kang | 2d5e6ec | 2012-08-30 15:14:17 +0900 | [diff] [blame] | 4044 | bool ExynosCameraHWInterface2::m_checkThumbnailSize(int w, int h) |
| 4045 | { |
| 4046 | int sizeOfSupportList; |
| 4047 | |
| 4048 | //REAR Camera |
| 4049 | if(this->getCameraId() == 0) { |
| 4050 | sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_REAR_SIZE) / (sizeof(int)*2); |
| 4051 | |
| 4052 | for(int i = 0; i < sizeOfSupportList; i++) { |
| 4053 | if((SUPPORT_THUMBNAIL_REAR_SIZE[i][0] == w) &&(SUPPORT_THUMBNAIL_REAR_SIZE[i][1] == h)) |
| 4054 | return true; |
| 4055 | } |
| 4056 | |
| 4057 | } |
| 4058 | else { |
| 4059 | sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_FRONT_SIZE) / (sizeof(int)*2); |
| 4060 | |
| 4061 | for(int i = 0; i < sizeOfSupportList; i++) { |
| 4062 | if((SUPPORT_THUMBNAIL_FRONT_SIZE[i][0] == w) &&(SUPPORT_THUMBNAIL_FRONT_SIZE[i][1] == h)) |
| 4063 | return true; |
| 4064 | } |
| 4065 | } |
| 4066 | |
| 4067 | return false; |
| 4068 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4069 | bool ExynosCameraHWInterface2::yuv2Jpeg(ExynosBuffer *yuvBuf, |
| 4070 | ExynosBuffer *jpegBuf, |
| 4071 | ExynosRect *rect) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 4072 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4073 | unsigned char *addr; |
| 4074 | |
| 4075 | ExynosJpegEncoderForCamera jpegEnc; |
| 4076 | bool ret = false; |
| 4077 | int res = 0; |
| 4078 | |
| 4079 | unsigned int *yuvSize = yuvBuf->size.extS; |
| 4080 | |
| 4081 | if (jpegEnc.create()) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4082 | ALOGE("ERR(%s):jpegEnc.create() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4083 | goto jpeg_encode_done; |
| 4084 | } |
| 4085 | |
| 4086 | if (jpegEnc.setQuality(100)) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4087 | ALOGE("ERR(%s):jpegEnc.setQuality() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4088 | goto jpeg_encode_done; |
| 4089 | } |
| 4090 | |
| 4091 | if (jpegEnc.setSize(rect->w, rect->h)) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4092 | ALOGE("ERR(%s):jpegEnc.setSize() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4093 | goto jpeg_encode_done; |
| 4094 | } |
| 4095 | ALOGV("%s : width = %d , height = %d\n", __FUNCTION__, rect->w, rect->h); |
| 4096 | |
| 4097 | if (jpegEnc.setColorFormat(rect->colorFormat)) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4098 | ALOGE("ERR(%s):jpegEnc.setColorFormat() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4099 | goto jpeg_encode_done; |
| 4100 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4101 | |
| 4102 | if (jpegEnc.setJpegFormat(V4L2_PIX_FMT_JPEG_422)) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4103 | ALOGE("ERR(%s):jpegEnc.setJpegFormat() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4104 | goto jpeg_encode_done; |
| 4105 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4106 | |
Sungjoong Kang | 2d5e6ec | 2012-08-30 15:14:17 +0900 | [diff] [blame] | 4107 | if((m_jpegMetadata.ctl.jpeg.thumbnailSize[0] != 0) && (m_jpegMetadata.ctl.jpeg.thumbnailSize[1] != 0)) { |
| 4108 | mExifInfo.enableThumb = true; |
| 4109 | if(!m_checkThumbnailSize(m_jpegMetadata.ctl.jpeg.thumbnailSize[0], m_jpegMetadata.ctl.jpeg.thumbnailSize[1])) { |
| 4110 | //default value |
| 4111 | m_thumbNailW = SUPPORT_THUMBNAIL_REAR_SIZE[0][0]; |
| 4112 | m_thumbNailH = SUPPORT_THUMBNAIL_REAR_SIZE[0][1]; |
| 4113 | } else { |
| 4114 | m_thumbNailW = m_jpegMetadata.ctl.jpeg.thumbnailSize[0]; |
| 4115 | m_thumbNailH = m_jpegMetadata.ctl.jpeg.thumbnailSize[1]; |
| 4116 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4117 | |
Sungjoong Kang | 2d5e6ec | 2012-08-30 15:14:17 +0900 | [diff] [blame] | 4118 | ALOGV("(%s) m_thumbNailW = %d, m_thumbNailH = %d", __FUNCTION__, m_thumbNailW, m_thumbNailH); |
| 4119 | |
| 4120 | } else { |
| 4121 | mExifInfo.enableThumb = false; |
| 4122 | } |
| 4123 | |
| 4124 | if (jpegEnc.setThumbnailSize(m_thumbNailW, m_thumbNailH)) { |
| 4125 | ALOGE("ERR(%s):jpegEnc.setThumbnailSize(%d, %d) fail", __FUNCTION__, m_thumbNailH, m_thumbNailH); |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 4126 | goto jpeg_encode_done; |
| 4127 | } |
| 4128 | |
Sungjoong Kang | 2d5e6ec | 2012-08-30 15:14:17 +0900 | [diff] [blame] | 4129 | ALOGV("(%s):jpegEnc.setThumbnailSize(%d, %d) ", __FUNCTION__, m_thumbNailW, m_thumbNailW); |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 4130 | if (jpegEnc.setThumbnailQuality(50)) { |
| 4131 | ALOGE("ERR(%s):jpegEnc.setThumbnailQuality fail", __FUNCTION__); |
| 4132 | goto jpeg_encode_done; |
| 4133 | } |
| 4134 | |
| 4135 | m_setExifChangedAttribute(&mExifInfo, rect, &m_jpegMetadata); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4136 | ALOGV("DEBUG(%s):calling jpegEnc.setInBuf() yuvSize(%d)", __FUNCTION__, *yuvSize); |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 4137 | if (jpegEnc.setInBuf((int *)&(yuvBuf->fd.fd), &(yuvBuf->virt.p), (int *)yuvSize)) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4138 | ALOGE("ERR(%s):jpegEnc.setInBuf() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4139 | goto jpeg_encode_done; |
| 4140 | } |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 4141 | if (jpegEnc.setOutBuf(jpegBuf->fd.fd, jpegBuf->virt.p, jpegBuf->size.extS[0] + jpegBuf->size.extS[1] + jpegBuf->size.extS[2])) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4142 | ALOGE("ERR(%s):jpegEnc.setOutBuf() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4143 | goto jpeg_encode_done; |
| 4144 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4145 | |
| 4146 | if (jpegEnc.updateConfig()) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4147 | ALOGE("ERR(%s):jpegEnc.updateConfig() fail", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4148 | goto jpeg_encode_done; |
| 4149 | } |
| 4150 | |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 4151 | if (res = jpegEnc.encode((int *)&jpegBuf->size.s, &mExifInfo)) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 4152 | ALOGE("ERR(%s):jpegEnc.encode() fail ret(%d)", __FUNCTION__, res); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4153 | goto jpeg_encode_done; |
| 4154 | } |
| 4155 | |
| 4156 | ret = true; |
| 4157 | |
| 4158 | jpeg_encode_done: |
| 4159 | |
| 4160 | if (jpegEnc.flagCreate() == true) |
| 4161 | jpegEnc.destroy(); |
| 4162 | |
| 4163 | return ret; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 4164 | } |
| 4165 | |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4166 | void ExynosCameraHWInterface2::OnAfTriggerStart(int id) |
| 4167 | { |
| 4168 | m_afPendingTriggerId = id; |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 4169 | m_afModeWaitingCnt = 6; |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4170 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 4171 | |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4172 | void ExynosCameraHWInterface2::OnAfTrigger(int id) |
| 4173 | { |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4174 | m_afTriggerId = id; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 4175 | |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4176 | switch (m_afMode) { |
| 4177 | case AA_AFMODE_AUTO: |
| 4178 | case AA_AFMODE_MACRO: |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4179 | case AA_AFMODE_OFF: |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4180 | ALOGE("[AF] OnAfTrigger - AUTO,MACRO,OFF (Mode %d) ", m_afMode); |
| 4181 | // If flash is enable, Flash operation is executed before triggering AF |
| 4182 | if ((m_ctlInfo.flash.i_flashMode >= AA_AEMODE_ON_AUTO_FLASH) |
| 4183 | && (m_ctlInfo.flash.m_afFlashEnableFlg == false) |
| 4184 | && (m_cameraId == 0)) { |
| 4185 | ALOGE("[AF Flash] AF Flash start with Mode (%d)", m_afMode); |
| 4186 | m_ctlInfo.flash.m_afFlashEnableFlg = true; |
| 4187 | m_ctlInfo.flash.m_flashTimeOut = 3; |
| 4188 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_ON; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4189 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 4190 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4191 | OnAfTriggerAutoMacro(id); |
| 4192 | break; |
| 4193 | case AA_AFMODE_CONTINUOUS_VIDEO: |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4194 | ALOGE("[AF] OnAfTrigger - AA_AFMODE_CONTINUOUS_VIDEO (Mode %d) ", m_afMode); |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4195 | OnAfTriggerCAFVideo(id); |
| 4196 | break; |
| 4197 | case AA_AFMODE_CONTINUOUS_PICTURE: |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4198 | ALOGE("[AF] OnAfTrigger - AA_AFMODE_CONTINUOUS_PICTURE (Mode %d) ", m_afMode); |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4199 | OnAfTriggerCAFPicture(id); |
| 4200 | break; |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4201 | |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4202 | default: |
| 4203 | break; |
| 4204 | } |
| 4205 | } |
| 4206 | |
| 4207 | void ExynosCameraHWInterface2::OnAfTriggerAutoMacro(int id) |
| 4208 | { |
| 4209 | int nextState = NO_TRANSITION; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4210 | |
| 4211 | switch (m_afState) { |
| 4212 | case HAL_AFSTATE_INACTIVE: |
| 4213 | nextState = HAL_AFSTATE_NEEDS_COMMAND; |
| 4214 | m_IsAfTriggerRequired = true; |
| 4215 | break; |
| 4216 | case HAL_AFSTATE_NEEDS_COMMAND: |
| 4217 | nextState = NO_TRANSITION; |
| 4218 | break; |
| 4219 | case HAL_AFSTATE_STARTED: |
| 4220 | nextState = NO_TRANSITION; |
| 4221 | break; |
| 4222 | case HAL_AFSTATE_SCANNING: |
| 4223 | nextState = NO_TRANSITION; |
| 4224 | break; |
| 4225 | case HAL_AFSTATE_LOCKED: |
| 4226 | nextState = HAL_AFSTATE_NEEDS_COMMAND; |
| 4227 | m_IsAfTriggerRequired = true; |
| 4228 | break; |
| 4229 | case HAL_AFSTATE_FAILED: |
| 4230 | nextState = HAL_AFSTATE_NEEDS_COMMAND; |
| 4231 | m_IsAfTriggerRequired = true; |
| 4232 | break; |
| 4233 | default: |
| 4234 | break; |
| 4235 | } |
| 4236 | ALOGV("(%s): State (%d) -> (%d)", __FUNCTION__, m_afState, nextState); |
| 4237 | if (nextState != NO_TRANSITION) |
| 4238 | m_afState = nextState; |
| 4239 | } |
| 4240 | |
| 4241 | void ExynosCameraHWInterface2::OnAfTriggerCAFPicture(int id) |
| 4242 | { |
| 4243 | int nextState = NO_TRANSITION; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4244 | |
| 4245 | switch (m_afState) { |
| 4246 | case HAL_AFSTATE_INACTIVE: |
| 4247 | nextState = HAL_AFSTATE_FAILED; |
| 4248 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4249 | break; |
| 4250 | case HAL_AFSTATE_NEEDS_COMMAND: |
| 4251 | // not used |
| 4252 | break; |
| 4253 | case HAL_AFSTATE_STARTED: |
| 4254 | nextState = HAL_AFSTATE_NEEDS_DETERMINATION; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4255 | m_AfHwStateFailed = false; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4256 | // If flash is enable, Flash operation is executed before triggering AF |
| 4257 | if ((m_ctlInfo.flash.i_flashMode >= AA_AEMODE_ON_AUTO_FLASH) |
| 4258 | && (m_ctlInfo.flash.m_afFlashEnableFlg == false) |
| 4259 | && (m_cameraId == 0)) { |
| 4260 | ALOGE("[AF Flash] AF Flash start with Mode (%d) state (%d) id (%d)", m_afMode, m_afState, id); |
| 4261 | m_ctlInfo.flash.m_afFlashEnableFlg = true; |
| 4262 | m_ctlInfo.flash.m_flashTimeOut = 3; |
| 4263 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_ON; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4264 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 4265 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4266 | break; |
| 4267 | case HAL_AFSTATE_SCANNING: |
| 4268 | nextState = HAL_AFSTATE_NEEDS_DETERMINATION; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4269 | m_AfHwStateFailed = false; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4270 | // If flash is enable, Flash operation is executed before triggering AF |
| 4271 | if ((m_ctlInfo.flash.i_flashMode >= AA_AEMODE_ON_AUTO_FLASH) |
| 4272 | && (m_ctlInfo.flash.m_afFlashEnableFlg == false) |
| 4273 | && (m_cameraId == 0)) { |
| 4274 | ALOGE("[AF Flash] AF Flash start with Mode (%d) state (%d) id (%d)", m_afMode, m_afState, id); |
| 4275 | m_ctlInfo.flash.m_afFlashEnableFlg = true; |
| 4276 | m_ctlInfo.flash.m_flashTimeOut = 3; |
| 4277 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_ON; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4278 | m_ctlInfo.flash.m_flashDecisionResult = false; |
| 4279 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4280 | break; |
| 4281 | case HAL_AFSTATE_NEEDS_DETERMINATION: |
| 4282 | nextState = NO_TRANSITION; |
| 4283 | break; |
| 4284 | case HAL_AFSTATE_PASSIVE_FOCUSED: |
| 4285 | m_IsAfLockRequired = true; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4286 | if (m_AfHwStateFailed) { |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4287 | ALOGE("(%s): [CAF] LAST : fail", __FUNCTION__); |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4288 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4289 | nextState = HAL_AFSTATE_FAILED; |
| 4290 | } |
| 4291 | else { |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4292 | ALOGV("(%s): [CAF] LAST : success", __FUNCTION__); |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4293 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED); |
| 4294 | nextState = HAL_AFSTATE_LOCKED; |
| 4295 | } |
| 4296 | m_AfHwStateFailed = false; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4297 | break; |
| 4298 | case HAL_AFSTATE_LOCKED: |
| 4299 | nextState = NO_TRANSITION; |
| 4300 | break; |
| 4301 | case HAL_AFSTATE_FAILED: |
| 4302 | nextState = NO_TRANSITION; |
| 4303 | break; |
| 4304 | default: |
| 4305 | break; |
| 4306 | } |
| 4307 | ALOGV("(%s): State (%d) -> (%d)", __FUNCTION__, m_afState, nextState); |
| 4308 | if (nextState != NO_TRANSITION) |
| 4309 | m_afState = nextState; |
| 4310 | } |
| 4311 | |
| 4312 | |
| 4313 | void ExynosCameraHWInterface2::OnAfTriggerCAFVideo(int id) |
| 4314 | { |
| 4315 | int nextState = NO_TRANSITION; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4316 | |
| 4317 | switch (m_afState) { |
| 4318 | case HAL_AFSTATE_INACTIVE: |
| 4319 | nextState = HAL_AFSTATE_FAILED; |
| 4320 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4321 | break; |
| 4322 | case HAL_AFSTATE_NEEDS_COMMAND: |
| 4323 | // not used |
| 4324 | break; |
| 4325 | case HAL_AFSTATE_STARTED: |
| 4326 | m_IsAfLockRequired = true; |
| 4327 | nextState = HAL_AFSTATE_FAILED; |
| 4328 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4329 | break; |
| 4330 | case HAL_AFSTATE_SCANNING: |
| 4331 | m_IsAfLockRequired = true; |
| 4332 | nextState = HAL_AFSTATE_FAILED; |
| 4333 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4334 | break; |
| 4335 | case HAL_AFSTATE_NEEDS_DETERMINATION: |
| 4336 | // not used |
| 4337 | break; |
| 4338 | case HAL_AFSTATE_PASSIVE_FOCUSED: |
| 4339 | m_IsAfLockRequired = true; |
| 4340 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED); |
| 4341 | nextState = HAL_AFSTATE_LOCKED; |
| 4342 | break; |
| 4343 | case HAL_AFSTATE_LOCKED: |
| 4344 | nextState = NO_TRANSITION; |
| 4345 | break; |
| 4346 | case HAL_AFSTATE_FAILED: |
| 4347 | nextState = NO_TRANSITION; |
| 4348 | break; |
| 4349 | default: |
| 4350 | break; |
| 4351 | } |
| 4352 | ALOGV("(%s): State (%d) -> (%d)", __FUNCTION__, m_afState, nextState); |
| 4353 | if (nextState != NO_TRANSITION) |
| 4354 | m_afState = nextState; |
| 4355 | } |
| 4356 | |
| 4357 | void ExynosCameraHWInterface2::OnAfNotification(enum aa_afstate noti) |
| 4358 | { |
| 4359 | switch (m_afMode) { |
| 4360 | case AA_AFMODE_AUTO: |
| 4361 | case AA_AFMODE_MACRO: |
| 4362 | OnAfNotificationAutoMacro(noti); |
| 4363 | break; |
| 4364 | case AA_AFMODE_CONTINUOUS_VIDEO: |
| 4365 | OnAfNotificationCAFVideo(noti); |
| 4366 | break; |
| 4367 | case AA_AFMODE_CONTINUOUS_PICTURE: |
| 4368 | OnAfNotificationCAFPicture(noti); |
| 4369 | break; |
| 4370 | case AA_AFMODE_OFF: |
| 4371 | default: |
| 4372 | break; |
| 4373 | } |
| 4374 | } |
| 4375 | |
| 4376 | void ExynosCameraHWInterface2::OnAfNotificationAutoMacro(enum aa_afstate noti) |
| 4377 | { |
| 4378 | int nextState = NO_TRANSITION; |
| 4379 | bool bWrongTransition = false; |
| 4380 | |
| 4381 | if (m_afState == HAL_AFSTATE_INACTIVE || m_afState == HAL_AFSTATE_NEEDS_COMMAND) { |
| 4382 | switch (noti) { |
| 4383 | case AA_AFSTATE_INACTIVE: |
| 4384 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4385 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4386 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4387 | default: |
| 4388 | nextState = NO_TRANSITION; |
| 4389 | break; |
| 4390 | } |
| 4391 | } |
| 4392 | else if (m_afState == HAL_AFSTATE_STARTED) { |
| 4393 | switch (noti) { |
| 4394 | case AA_AFSTATE_INACTIVE: |
| 4395 | nextState = NO_TRANSITION; |
| 4396 | break; |
| 4397 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4398 | nextState = HAL_AFSTATE_SCANNING; |
| 4399 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN); |
| 4400 | break; |
| 4401 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4402 | nextState = NO_TRANSITION; |
| 4403 | break; |
| 4404 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4405 | nextState = NO_TRANSITION; |
| 4406 | break; |
| 4407 | default: |
| 4408 | bWrongTransition = true; |
| 4409 | break; |
| 4410 | } |
| 4411 | } |
| 4412 | else if (m_afState == HAL_AFSTATE_SCANNING) { |
| 4413 | switch (noti) { |
| 4414 | case AA_AFSTATE_INACTIVE: |
| 4415 | bWrongTransition = true; |
| 4416 | break; |
| 4417 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4418 | nextState = NO_TRANSITION; |
| 4419 | break; |
| 4420 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 4421 | // If Flash mode is enable, after AF execute pre-capture metering |
| 4422 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4423 | if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_ON_DONE) { |
| 4424 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_AE_AWB_LOCK; |
| 4425 | } else if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_AUTO_END) { |
| 4426 | nextState = HAL_AFSTATE_LOCKED; |
| 4427 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED); |
| 4428 | } else { |
| 4429 | nextState = NO_TRANSITION; |
| 4430 | } |
| 4431 | } else { |
| 4432 | nextState = HAL_AFSTATE_LOCKED; |
| 4433 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED); |
| 4434 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4435 | break; |
| 4436 | case AA_AFSTATE_AF_FAILED_FOCUS: |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 4437 | // If Flash mode is enable, after AF execute pre-capture metering |
| 4438 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4439 | if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_ON_DONE) { |
| 4440 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_AE_AWB_LOCK; |
| 4441 | } else if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_AUTO_END) { |
| 4442 | nextState = HAL_AFSTATE_FAILED; |
| 4443 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4444 | } else { |
| 4445 | nextState = NO_TRANSITION; |
| 4446 | } |
| 4447 | } else { |
| 4448 | nextState = HAL_AFSTATE_FAILED; |
| 4449 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4450 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4451 | break; |
| 4452 | default: |
| 4453 | bWrongTransition = true; |
| 4454 | break; |
| 4455 | } |
| 4456 | } |
| 4457 | else if (m_afState == HAL_AFSTATE_LOCKED) { |
| 4458 | switch (noti) { |
| 4459 | case AA_AFSTATE_INACTIVE: |
| 4460 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4461 | bWrongTransition = true; |
| 4462 | break; |
| 4463 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 4464 | // Flash off if flash mode is available. |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 4465 | if (m_ctlInfo.flash.m_afFlashEnableFlg) |
| 4466 | m_ctlInfo.flash.m_afFlashCnt = IF_FLASH_AF_OFF; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4467 | nextState = NO_TRANSITION; |
| 4468 | break; |
| 4469 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4470 | default: |
| 4471 | bWrongTransition = true; |
| 4472 | break; |
| 4473 | } |
| 4474 | } |
| 4475 | else if (m_afState == HAL_AFSTATE_FAILED) { |
| 4476 | switch (noti) { |
| 4477 | case AA_AFSTATE_INACTIVE: |
| 4478 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4479 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4480 | bWrongTransition = true; |
| 4481 | break; |
| 4482 | case AA_AFSTATE_AF_FAILED_FOCUS: |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 4483 | // Flash off if flash mode is available. |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 4484 | if (m_ctlInfo.flash.m_afFlashEnableFlg) |
| 4485 | m_ctlInfo.flash.m_afFlashCnt = IF_FLASH_AF_OFF; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4486 | nextState = NO_TRANSITION; |
| 4487 | break; |
| 4488 | default: |
| 4489 | bWrongTransition = true; |
| 4490 | break; |
| 4491 | } |
| 4492 | } |
| 4493 | if (bWrongTransition) { |
| 4494 | ALOGV("(%s): Wrong Transition state(%d) noti(%d)", __FUNCTION__, m_afState, noti); |
| 4495 | return; |
| 4496 | } |
| 4497 | ALOGV("(%s): State (%d) -> (%d) by (%d)", __FUNCTION__, m_afState, nextState, noti); |
| 4498 | if (nextState != NO_TRANSITION) |
| 4499 | m_afState = nextState; |
| 4500 | } |
| 4501 | |
| 4502 | void ExynosCameraHWInterface2::OnAfNotificationCAFPicture(enum aa_afstate noti) |
| 4503 | { |
| 4504 | int nextState = NO_TRANSITION; |
| 4505 | bool bWrongTransition = false; |
| 4506 | |
| 4507 | if (m_afState == HAL_AFSTATE_INACTIVE) { |
| 4508 | switch (noti) { |
| 4509 | case AA_AFSTATE_INACTIVE: |
| 4510 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4511 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4512 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4513 | default: |
| 4514 | nextState = NO_TRANSITION; |
| 4515 | break; |
| 4516 | } |
| 4517 | } |
| 4518 | else if (m_afState == HAL_AFSTATE_STARTED) { |
| 4519 | switch (noti) { |
| 4520 | case AA_AFSTATE_INACTIVE: |
| 4521 | nextState = NO_TRANSITION; |
| 4522 | break; |
| 4523 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4524 | nextState = HAL_AFSTATE_SCANNING; |
| 4525 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN); |
| 4526 | break; |
| 4527 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4528 | nextState = HAL_AFSTATE_PASSIVE_FOCUSED; |
| 4529 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED); |
| 4530 | break; |
| 4531 | case AA_AFSTATE_AF_FAILED_FOCUS: |
Sungjoong Kang | cd13bb7 | 2012-08-28 13:05:01 -0700 | [diff] [blame] | 4532 | //nextState = HAL_AFSTATE_FAILED; |
| 4533 | //SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4534 | nextState = NO_TRANSITION; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4535 | break; |
| 4536 | default: |
| 4537 | bWrongTransition = true; |
| 4538 | break; |
| 4539 | } |
| 4540 | } |
| 4541 | else if (m_afState == HAL_AFSTATE_SCANNING) { |
| 4542 | switch (noti) { |
| 4543 | case AA_AFSTATE_INACTIVE: |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4544 | nextState = NO_TRANSITION; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4545 | break; |
| 4546 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4547 | nextState = NO_TRANSITION; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4548 | m_AfHwStateFailed = false; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4549 | break; |
| 4550 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4551 | nextState = HAL_AFSTATE_PASSIVE_FOCUSED; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4552 | m_AfHwStateFailed = false; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4553 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED); |
| 4554 | break; |
| 4555 | case AA_AFSTATE_AF_FAILED_FOCUS: |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4556 | nextState = HAL_AFSTATE_PASSIVE_FOCUSED; |
| 4557 | m_AfHwStateFailed = true; |
| 4558 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED); |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4559 | break; |
| 4560 | default: |
| 4561 | bWrongTransition = true; |
| 4562 | break; |
| 4563 | } |
| 4564 | } |
| 4565 | else if (m_afState == HAL_AFSTATE_PASSIVE_FOCUSED) { |
| 4566 | switch (noti) { |
| 4567 | case AA_AFSTATE_INACTIVE: |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4568 | nextState = NO_TRANSITION; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4569 | break; |
| 4570 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4571 | nextState = HAL_AFSTATE_SCANNING; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4572 | m_AfHwStateFailed = false; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4573 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN); |
| 4574 | break; |
| 4575 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4576 | nextState = NO_TRANSITION; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4577 | m_AfHwStateFailed = false; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4578 | // Flash off if flash mode is available. |
| 4579 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4580 | ALOGD("[AF Flash] Off with Mode (%d) state (%d) noti (%d)", m_afMode, m_afState, (int)noti); |
| 4581 | m_ctlInfo.flash.m_afFlashCnt = IF_FLASH_AF_OFF; |
| 4582 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4583 | break; |
| 4584 | case AA_AFSTATE_AF_FAILED_FOCUS: |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4585 | nextState = NO_TRANSITION; |
| 4586 | m_AfHwStateFailed = true; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4587 | // Flash off if flash mode is available. |
| 4588 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4589 | ALOGD("[AF Flash] Off with Mode (%d) state (%d) noti (%d)", m_afMode, m_afState, (int)noti); |
| 4590 | m_ctlInfo.flash.m_afFlashCnt = IF_FLASH_AF_OFF; |
| 4591 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4592 | break; |
| 4593 | default: |
| 4594 | bWrongTransition = true; |
| 4595 | break; |
| 4596 | } |
| 4597 | } |
| 4598 | else if (m_afState == HAL_AFSTATE_NEEDS_DETERMINATION) { |
| 4599 | switch (noti) { |
| 4600 | case AA_AFSTATE_INACTIVE: |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4601 | nextState = NO_TRANSITION; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4602 | break; |
| 4603 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4604 | nextState = NO_TRANSITION; |
| 4605 | break; |
| 4606 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4607 | // If Flash mode is enable, after AF execute pre-capture metering |
| 4608 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4609 | ALOGD("[AF Flash] AUTO start with Mode (%d) state (%d) noti (%d)", m_afMode, m_afState, (int)noti); |
| 4610 | if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_ON_DONE) { |
| 4611 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_AE_AWB_LOCK; |
| 4612 | } else if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_AUTO_END) { |
| 4613 | m_IsAfLockRequired = true; |
| 4614 | nextState = HAL_AFSTATE_LOCKED; |
| 4615 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED); |
| 4616 | } else { |
| 4617 | nextState = NO_TRANSITION; |
| 4618 | } |
| 4619 | } else { |
| 4620 | m_IsAfLockRequired = true; |
| 4621 | nextState = HAL_AFSTATE_LOCKED; |
| 4622 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED); |
| 4623 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4624 | break; |
| 4625 | case AA_AFSTATE_AF_FAILED_FOCUS: |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4626 | // If Flash mode is enable, after AF execute pre-capture metering |
| 4627 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4628 | ALOGD("[AF Flash] AUTO start with Mode (%d) state (%d) noti (%d)", m_afMode, m_afState, (int)noti); |
| 4629 | if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_ON_DONE) { |
| 4630 | m_ctlInfo.flash.m_afFlashCnt = IS_FLASH_AF_AUTO_AE_AWB_LOCK; |
| 4631 | } else if (m_ctlInfo.flash.m_afFlashCnt == IS_FLASH_AF_AUTO_END) { |
| 4632 | m_IsAfLockRequired = true; |
| 4633 | nextState = HAL_AFSTATE_FAILED; |
| 4634 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4635 | } else { |
| 4636 | nextState = NO_TRANSITION; |
| 4637 | } |
| 4638 | } else { |
| 4639 | m_IsAfLockRequired = true; |
| 4640 | nextState = HAL_AFSTATE_FAILED; |
| 4641 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4642 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4643 | break; |
| 4644 | default: |
| 4645 | bWrongTransition = true; |
| 4646 | break; |
| 4647 | } |
| 4648 | } |
| 4649 | else if (m_afState == HAL_AFSTATE_LOCKED) { |
| 4650 | switch (noti) { |
| 4651 | case AA_AFSTATE_INACTIVE: |
| 4652 | nextState = NO_TRANSITION; |
| 4653 | break; |
| 4654 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4655 | bWrongTransition = true; |
| 4656 | break; |
| 4657 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4658 | nextState = NO_TRANSITION; |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4659 | // Flash off if flash mode is available. |
| 4660 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4661 | ALOGD("[AF Flash] Off with Mode (%d) state (%d) noti (%d)", m_afMode, m_afState, (int)noti); |
| 4662 | m_ctlInfo.flash.m_afFlashCnt = IF_FLASH_AF_OFF; |
| 4663 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4664 | break; |
| 4665 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4666 | default: |
| 4667 | bWrongTransition = true; |
| 4668 | break; |
| 4669 | } |
| 4670 | } |
| 4671 | else if (m_afState == HAL_AFSTATE_FAILED) { |
| 4672 | switch (noti) { |
| 4673 | case AA_AFSTATE_INACTIVE: |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4674 | bWrongTransition = true; |
| 4675 | break; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4676 | case AA_AFSTATE_ACTIVE_SCAN: |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4677 | nextState = HAL_AFSTATE_SCANNING; |
| 4678 | break; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4679 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4680 | bWrongTransition = true; |
| 4681 | break; |
| 4682 | case AA_AFSTATE_AF_FAILED_FOCUS: |
Younghwan Joo | caea49e | 2012-09-07 13:34:20 -0700 | [diff] [blame] | 4683 | // Flash off if flash mode is available. |
| 4684 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4685 | ALOGD("[AF Flash] Off with Mode (%d) state (%d) noti (%d)", m_afMode, m_afState, (int)noti); |
| 4686 | m_ctlInfo.flash.m_afFlashCnt = IF_FLASH_AF_OFF; |
| 4687 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4688 | nextState = NO_TRANSITION; |
| 4689 | break; |
| 4690 | default: |
| 4691 | bWrongTransition = true; |
| 4692 | break; |
| 4693 | } |
| 4694 | } |
| 4695 | if (bWrongTransition) { |
| 4696 | ALOGV("(%s): Wrong Transition state(%d) noti(%d)", __FUNCTION__, m_afState, noti); |
| 4697 | return; |
| 4698 | } |
| 4699 | ALOGV("(%s): State (%d) -> (%d) by (%d)", __FUNCTION__, m_afState, nextState, noti); |
| 4700 | if (nextState != NO_TRANSITION) |
| 4701 | m_afState = nextState; |
| 4702 | } |
| 4703 | |
| 4704 | void ExynosCameraHWInterface2::OnAfNotificationCAFVideo(enum aa_afstate noti) |
| 4705 | { |
| 4706 | int nextState = NO_TRANSITION; |
| 4707 | bool bWrongTransition = false; |
| 4708 | |
| 4709 | if (m_afState == HAL_AFSTATE_INACTIVE) { |
| 4710 | switch (noti) { |
| 4711 | case AA_AFSTATE_INACTIVE: |
| 4712 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4713 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4714 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4715 | default: |
| 4716 | nextState = NO_TRANSITION; |
| 4717 | break; |
| 4718 | } |
| 4719 | } |
| 4720 | else if (m_afState == HAL_AFSTATE_STARTED) { |
| 4721 | switch (noti) { |
| 4722 | case AA_AFSTATE_INACTIVE: |
| 4723 | nextState = NO_TRANSITION; |
| 4724 | break; |
| 4725 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4726 | nextState = HAL_AFSTATE_SCANNING; |
| 4727 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN); |
| 4728 | break; |
| 4729 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4730 | nextState = HAL_AFSTATE_PASSIVE_FOCUSED; |
| 4731 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED); |
| 4732 | break; |
| 4733 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4734 | nextState = HAL_AFSTATE_FAILED; |
| 4735 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4736 | break; |
| 4737 | default: |
| 4738 | bWrongTransition = true; |
| 4739 | break; |
| 4740 | } |
| 4741 | } |
| 4742 | else if (m_afState == HAL_AFSTATE_SCANNING) { |
| 4743 | switch (noti) { |
| 4744 | case AA_AFSTATE_INACTIVE: |
| 4745 | bWrongTransition = true; |
| 4746 | break; |
| 4747 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4748 | nextState = NO_TRANSITION; |
| 4749 | break; |
| 4750 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4751 | nextState = HAL_AFSTATE_PASSIVE_FOCUSED; |
| 4752 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED); |
| 4753 | break; |
| 4754 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4755 | nextState = NO_TRANSITION; |
Sungjoong Kang | 36c106c | 2012-08-23 17:38:20 -0700 | [diff] [blame] | 4756 | m_IsAfTriggerRequired = true; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4757 | break; |
| 4758 | default: |
| 4759 | bWrongTransition = true; |
| 4760 | break; |
| 4761 | } |
| 4762 | } |
| 4763 | else if (m_afState == HAL_AFSTATE_PASSIVE_FOCUSED) { |
| 4764 | switch (noti) { |
| 4765 | case AA_AFSTATE_INACTIVE: |
| 4766 | bWrongTransition = true; |
| 4767 | break; |
| 4768 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4769 | nextState = HAL_AFSTATE_SCANNING; |
| 4770 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN); |
| 4771 | break; |
| 4772 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4773 | nextState = NO_TRANSITION; |
| 4774 | break; |
| 4775 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4776 | nextState = HAL_AFSTATE_FAILED; |
| 4777 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4778 | // TODO : needs NO_TRANSITION ? |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4779 | break; |
| 4780 | default: |
| 4781 | bWrongTransition = true; |
| 4782 | break; |
| 4783 | } |
| 4784 | } |
| 4785 | else if (m_afState == HAL_AFSTATE_NEEDS_DETERMINATION) { |
| 4786 | switch (noti) { |
| 4787 | case AA_AFSTATE_INACTIVE: |
| 4788 | bWrongTransition = true; |
| 4789 | break; |
| 4790 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4791 | nextState = NO_TRANSITION; |
| 4792 | break; |
| 4793 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4794 | m_IsAfLockRequired = true; |
| 4795 | nextState = HAL_AFSTATE_LOCKED; |
| 4796 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED); |
| 4797 | break; |
| 4798 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4799 | nextState = HAL_AFSTATE_FAILED; |
| 4800 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED); |
| 4801 | break; |
| 4802 | default: |
| 4803 | bWrongTransition = true; |
| 4804 | break; |
| 4805 | } |
| 4806 | } |
| 4807 | else if (m_afState == HAL_AFSTATE_LOCKED) { |
| 4808 | switch (noti) { |
| 4809 | case AA_AFSTATE_INACTIVE: |
| 4810 | nextState = NO_TRANSITION; |
| 4811 | break; |
| 4812 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4813 | bWrongTransition = true; |
| 4814 | break; |
| 4815 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4816 | nextState = NO_TRANSITION; |
| 4817 | break; |
| 4818 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4819 | default: |
| 4820 | bWrongTransition = true; |
| 4821 | break; |
| 4822 | } |
| 4823 | } |
| 4824 | else if (m_afState == HAL_AFSTATE_FAILED) { |
| 4825 | switch (noti) { |
| 4826 | case AA_AFSTATE_INACTIVE: |
| 4827 | case AA_AFSTATE_ACTIVE_SCAN: |
| 4828 | case AA_AFSTATE_AF_ACQUIRED_FOCUS: |
| 4829 | bWrongTransition = true; |
| 4830 | break; |
| 4831 | case AA_AFSTATE_AF_FAILED_FOCUS: |
| 4832 | nextState = NO_TRANSITION; |
| 4833 | break; |
| 4834 | default: |
| 4835 | bWrongTransition = true; |
| 4836 | break; |
| 4837 | } |
| 4838 | } |
| 4839 | if (bWrongTransition) { |
| 4840 | ALOGV("(%s): Wrong Transition state(%d) noti(%d)", __FUNCTION__, m_afState, noti); |
| 4841 | return; |
| 4842 | } |
| 4843 | ALOGV("(%s): State (%d) -> (%d) by (%d)", __FUNCTION__, m_afState, nextState, noti); |
| 4844 | if (nextState != NO_TRANSITION) |
| 4845 | m_afState = nextState; |
| 4846 | } |
| 4847 | |
| 4848 | void ExynosCameraHWInterface2::OnAfCancel(int id) |
| 4849 | { |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4850 | m_afTriggerId = id; |
| 4851 | |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4852 | switch (m_afMode) { |
| 4853 | case AA_AFMODE_AUTO: |
| 4854 | case AA_AFMODE_MACRO: |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4855 | case AA_AFMODE_OFF: |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4856 | OnAfCancelAutoMacro(id); |
| 4857 | break; |
| 4858 | case AA_AFMODE_CONTINUOUS_VIDEO: |
| 4859 | OnAfCancelCAFVideo(id); |
| 4860 | break; |
| 4861 | case AA_AFMODE_CONTINUOUS_PICTURE: |
| 4862 | OnAfCancelCAFPicture(id); |
| 4863 | break; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4864 | default: |
| 4865 | break; |
| 4866 | } |
| 4867 | } |
| 4868 | |
| 4869 | void ExynosCameraHWInterface2::OnAfCancelAutoMacro(int id) |
| 4870 | { |
| 4871 | int nextState = NO_TRANSITION; |
| 4872 | m_afTriggerId = id; |
| 4873 | |
Younghwan Joo | 9a710a4 | 2012-09-05 17:52:08 -0700 | [diff] [blame] | 4874 | if (m_ctlInfo.flash.m_afFlashEnableFlg) { |
| 4875 | m_ctlInfo.flash.m_afFlashCnt = IF_FLASH_AF_OFF; |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 4876 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4877 | switch (m_afState) { |
| 4878 | case HAL_AFSTATE_INACTIVE: |
| 4879 | nextState = NO_TRANSITION; |
Sungjoong Kang | cd13bb7 | 2012-08-28 13:05:01 -0700 | [diff] [blame] | 4880 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_INACTIVE); |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4881 | break; |
| 4882 | case HAL_AFSTATE_NEEDS_COMMAND: |
| 4883 | case HAL_AFSTATE_STARTED: |
| 4884 | case HAL_AFSTATE_SCANNING: |
| 4885 | case HAL_AFSTATE_LOCKED: |
| 4886 | case HAL_AFSTATE_FAILED: |
| 4887 | SetAfMode(AA_AFMODE_OFF); |
| 4888 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_INACTIVE); |
| 4889 | nextState = HAL_AFSTATE_INACTIVE; |
| 4890 | break; |
| 4891 | default: |
| 4892 | break; |
| 4893 | } |
| 4894 | ALOGV("(%s): State (%d) -> (%d)", __FUNCTION__, m_afState, nextState); |
| 4895 | if (nextState != NO_TRANSITION) |
| 4896 | m_afState = nextState; |
| 4897 | } |
| 4898 | |
| 4899 | void ExynosCameraHWInterface2::OnAfCancelCAFPicture(int id) |
| 4900 | { |
| 4901 | int nextState = NO_TRANSITION; |
| 4902 | m_afTriggerId = id; |
| 4903 | |
| 4904 | switch (m_afState) { |
| 4905 | case HAL_AFSTATE_INACTIVE: |
| 4906 | nextState = NO_TRANSITION; |
| 4907 | break; |
| 4908 | case HAL_AFSTATE_NEEDS_COMMAND: |
| 4909 | case HAL_AFSTATE_STARTED: |
| 4910 | case HAL_AFSTATE_SCANNING: |
| 4911 | case HAL_AFSTATE_LOCKED: |
| 4912 | case HAL_AFSTATE_FAILED: |
| 4913 | case HAL_AFSTATE_NEEDS_DETERMINATION: |
| 4914 | case HAL_AFSTATE_PASSIVE_FOCUSED: |
| 4915 | SetAfMode(AA_AFMODE_OFF); |
| 4916 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_INACTIVE); |
| 4917 | SetAfMode(AA_AFMODE_CONTINUOUS_PICTURE); |
| 4918 | nextState = HAL_AFSTATE_INACTIVE; |
| 4919 | break; |
| 4920 | default: |
| 4921 | break; |
| 4922 | } |
| 4923 | ALOGV("(%s): State (%d) -> (%d)", __FUNCTION__, m_afState, nextState); |
| 4924 | if (nextState != NO_TRANSITION) |
| 4925 | m_afState = nextState; |
| 4926 | } |
| 4927 | |
| 4928 | void ExynosCameraHWInterface2::OnAfCancelCAFVideo(int id) |
| 4929 | { |
| 4930 | int nextState = NO_TRANSITION; |
| 4931 | m_afTriggerId = id; |
| 4932 | |
| 4933 | switch (m_afState) { |
| 4934 | case HAL_AFSTATE_INACTIVE: |
| 4935 | nextState = NO_TRANSITION; |
| 4936 | break; |
| 4937 | case HAL_AFSTATE_NEEDS_COMMAND: |
| 4938 | case HAL_AFSTATE_STARTED: |
| 4939 | case HAL_AFSTATE_SCANNING: |
| 4940 | case HAL_AFSTATE_LOCKED: |
| 4941 | case HAL_AFSTATE_FAILED: |
| 4942 | case HAL_AFSTATE_NEEDS_DETERMINATION: |
| 4943 | case HAL_AFSTATE_PASSIVE_FOCUSED: |
| 4944 | SetAfMode(AA_AFMODE_OFF); |
| 4945 | SetAfStateForService(ANDROID_CONTROL_AF_STATE_INACTIVE); |
| 4946 | SetAfMode(AA_AFMODE_CONTINUOUS_VIDEO); |
| 4947 | nextState = HAL_AFSTATE_INACTIVE; |
| 4948 | break; |
| 4949 | default: |
| 4950 | break; |
| 4951 | } |
| 4952 | ALOGV("(%s): State (%d) -> (%d)", __FUNCTION__, m_afState, nextState); |
| 4953 | if (nextState != NO_TRANSITION) |
| 4954 | m_afState = nextState; |
| 4955 | } |
| 4956 | |
| 4957 | void ExynosCameraHWInterface2::SetAfStateForService(int newState) |
| 4958 | { |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4959 | if (m_serviceAfState != newState || newState == 0) |
| 4960 | m_notifyCb(CAMERA2_MSG_AUTOFOCUS, newState, m_afTriggerId, 0, m_callbackCookie); |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4961 | m_serviceAfState = newState; |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4962 | } |
| 4963 | |
| 4964 | int ExynosCameraHWInterface2::GetAfStateForService() |
| 4965 | { |
| 4966 | return m_serviceAfState; |
| 4967 | } |
| 4968 | |
| 4969 | void ExynosCameraHWInterface2::SetAfMode(enum aa_afmode afMode) |
| 4970 | { |
| 4971 | if (m_afMode != afMode) { |
| 4972 | if (m_IsAfModeUpdateRequired) { |
| 4973 | m_afMode2 = afMode; |
| 4974 | ALOGV("(%s): pending(%d) and new(%d)", __FUNCTION__, m_afMode, afMode); |
| 4975 | } |
| 4976 | else { |
| 4977 | ALOGV("(%s): current(%d) new(%d)", __FUNCTION__, m_afMode, afMode); |
| 4978 | m_IsAfModeUpdateRequired = true; |
| 4979 | m_afMode = afMode; |
Sungjoong Kang | cd13bb7 | 2012-08-28 13:05:01 -0700 | [diff] [blame] | 4980 | if (m_afModeWaitingCnt != 0) { |
| 4981 | m_afModeWaitingCnt = 0; |
hyeonmyeong Choi | 7d0efb5 | 2012-09-02 16:02:13 -0700 | [diff] [blame] | 4982 | m_afState = HAL_AFSTATE_INACTIVE; |
Sungjoong Kang | cd13bb7 | 2012-08-28 13:05:01 -0700 | [diff] [blame] | 4983 | OnAfTrigger(m_afPendingTriggerId); |
| 4984 | } |
Sungjoong Kang | 8e2c2fd | 2012-08-27 00:02:22 -0700 | [diff] [blame] | 4985 | } |
Sungjoong Kang | 0f26b20 | 2012-08-17 15:43:12 -0700 | [diff] [blame] | 4986 | } |
| 4987 | } |
| 4988 | |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 4989 | void ExynosCameraHWInterface2::m_setExifFixedAttribute(void) |
| 4990 | { |
| 4991 | char property[PROPERTY_VALUE_MAX]; |
| 4992 | |
| 4993 | //2 0th IFD TIFF Tags |
Rebecca Schultz Zavin | 1b8ef18 | 2012-09-04 09:44:10 -0700 | [diff] [blame] | 4994 | #if 0 // STOPSHIP TODO(aray): remove before launch, but for now don't leak product data |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 4995 | //3 Maker |
| 4996 | property_get("ro.product.brand", property, EXIF_DEF_MAKER); |
| 4997 | strncpy((char *)mExifInfo.maker, property, |
| 4998 | sizeof(mExifInfo.maker) - 1); |
| 4999 | mExifInfo.maker[sizeof(mExifInfo.maker) - 1] = '\0'; |
| 5000 | //3 Model |
| 5001 | property_get("ro.product.model", property, EXIF_DEF_MODEL); |
| 5002 | strncpy((char *)mExifInfo.model, property, |
| 5003 | sizeof(mExifInfo.model) - 1); |
| 5004 | mExifInfo.model[sizeof(mExifInfo.model) - 1] = '\0'; |
| 5005 | //3 Software |
| 5006 | property_get("ro.build.id", property, EXIF_DEF_SOFTWARE); |
| 5007 | strncpy((char *)mExifInfo.software, property, |
| 5008 | sizeof(mExifInfo.software) - 1); |
| 5009 | mExifInfo.software[sizeof(mExifInfo.software) - 1] = '\0'; |
Alex Ray | 5a92f77 | 2012-08-27 17:23:41 -0700 | [diff] [blame] | 5010 | #endif |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 5011 | |
| 5012 | //3 YCbCr Positioning |
| 5013 | mExifInfo.ycbcr_positioning = EXIF_DEF_YCBCR_POSITIONING; |
| 5014 | |
| 5015 | //2 0th IFD Exif Private Tags |
| 5016 | //3 F Number |
| 5017 | mExifInfo.fnumber.num = EXIF_DEF_FNUMBER_NUM; |
| 5018 | mExifInfo.fnumber.den = EXIF_DEF_FNUMBER_DEN; |
| 5019 | //3 Exposure Program |
| 5020 | mExifInfo.exposure_program = EXIF_DEF_EXPOSURE_PROGRAM; |
| 5021 | //3 Exif Version |
| 5022 | memcpy(mExifInfo.exif_version, EXIF_DEF_EXIF_VERSION, sizeof(mExifInfo.exif_version)); |
| 5023 | //3 Aperture |
| 5024 | uint32_t av = APEX_FNUM_TO_APERTURE((double)mExifInfo.fnumber.num/mExifInfo.fnumber.den); |
| 5025 | mExifInfo.aperture.num = av*EXIF_DEF_APEX_DEN; |
| 5026 | mExifInfo.aperture.den = EXIF_DEF_APEX_DEN; |
| 5027 | //3 Maximum lens aperture |
| 5028 | mExifInfo.max_aperture.num = mExifInfo.aperture.num; |
| 5029 | mExifInfo.max_aperture.den = mExifInfo.aperture.den; |
| 5030 | //3 Lens Focal Length |
| 5031 | mExifInfo.focal_length.num = EXIF_DEF_FOCAL_LEN_NUM; |
| 5032 | mExifInfo.focal_length.den = EXIF_DEF_FOCAL_LEN_DEN; |
| 5033 | //3 User Comments |
| 5034 | strcpy((char *)mExifInfo.user_comment, EXIF_DEF_USERCOMMENTS); |
| 5035 | //3 Color Space information |
| 5036 | mExifInfo.color_space = EXIF_DEF_COLOR_SPACE; |
| 5037 | //3 Exposure Mode |
| 5038 | mExifInfo.exposure_mode = EXIF_DEF_EXPOSURE_MODE; |
| 5039 | |
| 5040 | //2 0th IFD GPS Info Tags |
| 5041 | unsigned char gps_version[4] = { 0x02, 0x02, 0x00, 0x00 }; |
| 5042 | memcpy(mExifInfo.gps_version_id, gps_version, sizeof(gps_version)); |
| 5043 | |
| 5044 | //2 1th IFD TIFF Tags |
| 5045 | mExifInfo.compression_scheme = EXIF_DEF_COMPRESSION; |
| 5046 | mExifInfo.x_resolution.num = EXIF_DEF_RESOLUTION_NUM; |
| 5047 | mExifInfo.x_resolution.den = EXIF_DEF_RESOLUTION_DEN; |
| 5048 | mExifInfo.y_resolution.num = EXIF_DEF_RESOLUTION_NUM; |
| 5049 | mExifInfo.y_resolution.den = EXIF_DEF_RESOLUTION_DEN; |
| 5050 | mExifInfo.resolution_unit = EXIF_DEF_RESOLUTION_UNIT; |
| 5051 | } |
| 5052 | |
| 5053 | void ExynosCameraHWInterface2::m_setExifChangedAttribute(exif_attribute_t *exifInfo, ExynosRect *rect, |
| 5054 | camera2_shot *currentEntry) |
| 5055 | { |
| 5056 | camera2_dm *dm = &(currentEntry->dm); |
| 5057 | camera2_ctl *ctl = &(currentEntry->ctl); |
| 5058 | |
| 5059 | ALOGV("(%s): framecnt(%d) exp(%lld) iso(%d)", __FUNCTION__, ctl->request.frameCount, dm->sensor.exposureTime,dm->aa.isoValue ); |
| 5060 | if (!ctl->request.frameCount) |
| 5061 | return; |
| 5062 | //2 0th IFD TIFF Tags |
| 5063 | //3 Width |
| 5064 | exifInfo->width = rect->w; |
| 5065 | //3 Height |
| 5066 | exifInfo->height = rect->h; |
| 5067 | //3 Orientation |
| 5068 | switch (ctl->jpeg.orientation) { |
| 5069 | case 90: |
| 5070 | exifInfo->orientation = EXIF_ORIENTATION_90; |
| 5071 | break; |
| 5072 | case 180: |
| 5073 | exifInfo->orientation = EXIF_ORIENTATION_180; |
| 5074 | break; |
| 5075 | case 270: |
| 5076 | exifInfo->orientation = EXIF_ORIENTATION_270; |
| 5077 | break; |
| 5078 | case 0: |
| 5079 | default: |
| 5080 | exifInfo->orientation = EXIF_ORIENTATION_UP; |
| 5081 | break; |
| 5082 | } |
| 5083 | |
| 5084 | //3 Date time |
| 5085 | time_t rawtime; |
| 5086 | struct tm *timeinfo; |
| 5087 | time(&rawtime); |
| 5088 | timeinfo = localtime(&rawtime); |
| 5089 | strftime((char *)exifInfo->date_time, 20, "%Y:%m:%d %H:%M:%S", timeinfo); |
| 5090 | |
| 5091 | //2 0th IFD Exif Private Tags |
| 5092 | //3 Exposure Time |
| 5093 | int shutterSpeed = (dm->sensor.exposureTime/1000); |
| 5094 | |
| 5095 | if (shutterSpeed < 0) { |
| 5096 | shutterSpeed = 100; |
| 5097 | } |
| 5098 | |
| 5099 | exifInfo->exposure_time.num = 1; |
| 5100 | // x us -> 1/x s */ |
| 5101 | //exifInfo->exposure_time.den = (uint32_t)(1000000 / shutterSpeed); |
| 5102 | exifInfo->exposure_time.den = (uint32_t)((double)1000000 / shutterSpeed); |
| 5103 | |
| 5104 | //3 ISO Speed Rating |
| 5105 | exifInfo->iso_speed_rating = dm->aa.isoValue; |
| 5106 | |
| 5107 | uint32_t av, tv, bv, sv, ev; |
| 5108 | av = APEX_FNUM_TO_APERTURE((double)exifInfo->fnumber.num / exifInfo->fnumber.den); |
| 5109 | tv = APEX_EXPOSURE_TO_SHUTTER((double)exifInfo->exposure_time.num / exifInfo->exposure_time.den); |
| 5110 | sv = APEX_ISO_TO_FILMSENSITIVITY(exifInfo->iso_speed_rating); |
| 5111 | bv = av + tv - sv; |
| 5112 | ev = av + tv; |
| 5113 | //ALOGD("Shutter speed=%d us, iso=%d", shutterSpeed, exifInfo->iso_speed_rating); |
| 5114 | ALOGD("AV=%d, TV=%d, SV=%d", av, tv, sv); |
| 5115 | |
| 5116 | //3 Shutter Speed |
| 5117 | exifInfo->shutter_speed.num = tv * EXIF_DEF_APEX_DEN; |
| 5118 | exifInfo->shutter_speed.den = EXIF_DEF_APEX_DEN; |
| 5119 | //3 Brightness |
| 5120 | exifInfo->brightness.num = bv*EXIF_DEF_APEX_DEN; |
| 5121 | exifInfo->brightness.den = EXIF_DEF_APEX_DEN; |
| 5122 | //3 Exposure Bias |
| 5123 | if (ctl->aa.sceneMode== AA_SCENE_MODE_BEACH|| |
| 5124 | ctl->aa.sceneMode== AA_SCENE_MODE_SNOW) { |
| 5125 | exifInfo->exposure_bias.num = EXIF_DEF_APEX_DEN; |
| 5126 | exifInfo->exposure_bias.den = EXIF_DEF_APEX_DEN; |
| 5127 | } else { |
| 5128 | exifInfo->exposure_bias.num = 0; |
| 5129 | exifInfo->exposure_bias.den = 0; |
| 5130 | } |
| 5131 | //3 Metering Mode |
| 5132 | /*switch (m_curCameraInfo->metering) { |
| 5133 | case METERING_MODE_CENTER: |
| 5134 | exifInfo->metering_mode = EXIF_METERING_CENTER; |
| 5135 | break; |
| 5136 | case METERING_MODE_MATRIX: |
| 5137 | exifInfo->metering_mode = EXIF_METERING_MULTISPOT; |
| 5138 | break; |
| 5139 | case METERING_MODE_SPOT: |
| 5140 | exifInfo->metering_mode = EXIF_METERING_SPOT; |
| 5141 | break; |
| 5142 | case METERING_MODE_AVERAGE: |
| 5143 | default: |
| 5144 | exifInfo->metering_mode = EXIF_METERING_AVERAGE; |
| 5145 | break; |
| 5146 | }*/ |
| 5147 | exifInfo->metering_mode = EXIF_METERING_CENTER; |
| 5148 | |
| 5149 | //3 Flash |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 5150 | /* |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 5151 | int flash = dm->flash.flashMode; |
| 5152 | if (dm->flash.flashMode == FLASH_MODE_OFF || flash < 0) |
| 5153 | exifInfo->flash = EXIF_DEF_FLASH; |
| 5154 | else |
| 5155 | exifInfo->flash = flash; |
Younghwan Joo | 9257e29 | 2012-09-08 21:11:18 -0700 | [diff] [blame^] | 5156 | */ |
| 5157 | if (m_ctlInfo.flash.m_flashDecisionResult) |
| 5158 | exifInfo->flash = 1; |
| 5159 | else |
| 5160 | exifInfo->flash = EXIF_DEF_FLASH; |
Sungjoong Kang | eed7ed1 | 2012-08-23 16:35:08 -0700 | [diff] [blame] | 5161 | |
| 5162 | //3 White Balance |
| 5163 | if (dm->aa.awbMode == AA_AWBMODE_WB_AUTO) |
| 5164 | exifInfo->white_balance = EXIF_WB_AUTO; |
| 5165 | else |
| 5166 | exifInfo->white_balance = EXIF_WB_MANUAL; |
| 5167 | |
| 5168 | //3 Scene Capture Type |
| 5169 | switch (ctl->aa.sceneMode) { |
| 5170 | case AA_SCENE_MODE_PORTRAIT: |
| 5171 | exifInfo->scene_capture_type = EXIF_SCENE_PORTRAIT; |
| 5172 | break; |
| 5173 | case AA_SCENE_MODE_LANDSCAPE: |
| 5174 | exifInfo->scene_capture_type = EXIF_SCENE_LANDSCAPE; |
| 5175 | break; |
| 5176 | case AA_SCENE_MODE_NIGHT_PORTRAIT: |
| 5177 | exifInfo->scene_capture_type = EXIF_SCENE_NIGHT; |
| 5178 | break; |
| 5179 | default: |
| 5180 | exifInfo->scene_capture_type = EXIF_SCENE_STANDARD; |
| 5181 | break; |
| 5182 | } |
| 5183 | |
| 5184 | //2 0th IFD GPS Info Tags |
| 5185 | if (ctl->jpeg.gpsCoordinates[0] != 0 && ctl->jpeg.gpsCoordinates[1] != 0) { |
| 5186 | |
| 5187 | if (ctl->jpeg.gpsCoordinates[0] > 0) |
| 5188 | strcpy((char *)exifInfo->gps_latitude_ref, "N"); |
| 5189 | else |
| 5190 | strcpy((char *)exifInfo->gps_latitude_ref, "S"); |
| 5191 | |
| 5192 | if (ctl->jpeg.gpsCoordinates[1] > 0) |
| 5193 | strcpy((char *)exifInfo->gps_longitude_ref, "E"); |
| 5194 | else |
| 5195 | strcpy((char *)exifInfo->gps_longitude_ref, "W"); |
| 5196 | |
| 5197 | if (ctl->jpeg.gpsCoordinates[2] > 0) |
| 5198 | exifInfo->gps_altitude_ref = 0; |
| 5199 | else |
| 5200 | exifInfo->gps_altitude_ref = 1; |
| 5201 | |
| 5202 | double latitude = fabs(ctl->jpeg.gpsCoordinates[0] / 10000.0); |
| 5203 | double longitude = fabs(ctl->jpeg.gpsCoordinates[1] / 10000.0); |
| 5204 | double altitude = fabs(ctl->jpeg.gpsCoordinates[2] / 100.0); |
| 5205 | |
| 5206 | exifInfo->gps_latitude[0].num = (uint32_t)latitude; |
| 5207 | exifInfo->gps_latitude[0].den = 1; |
| 5208 | exifInfo->gps_latitude[1].num = (uint32_t)((latitude - exifInfo->gps_latitude[0].num) * 60); |
| 5209 | exifInfo->gps_latitude[1].den = 1; |
| 5210 | exifInfo->gps_latitude[2].num = (uint32_t)((((latitude - exifInfo->gps_latitude[0].num) * 60) |
| 5211 | - exifInfo->gps_latitude[1].num) * 60); |
| 5212 | exifInfo->gps_latitude[2].den = 1; |
| 5213 | |
| 5214 | exifInfo->gps_longitude[0].num = (uint32_t)longitude; |
| 5215 | exifInfo->gps_longitude[0].den = 1; |
| 5216 | exifInfo->gps_longitude[1].num = (uint32_t)((longitude - exifInfo->gps_longitude[0].num) * 60); |
| 5217 | exifInfo->gps_longitude[1].den = 1; |
| 5218 | exifInfo->gps_longitude[2].num = (uint32_t)((((longitude - exifInfo->gps_longitude[0].num) * 60) |
| 5219 | - exifInfo->gps_longitude[1].num) * 60); |
| 5220 | exifInfo->gps_longitude[2].den = 1; |
| 5221 | |
| 5222 | exifInfo->gps_altitude.num = (uint32_t)altitude; |
| 5223 | exifInfo->gps_altitude.den = 1; |
| 5224 | |
| 5225 | struct tm tm_data; |
| 5226 | long timestamp; |
| 5227 | timestamp = (long)ctl->jpeg.gpsTimestamp; |
| 5228 | gmtime_r(×tamp, &tm_data); |
| 5229 | exifInfo->gps_timestamp[0].num = tm_data.tm_hour; |
| 5230 | exifInfo->gps_timestamp[0].den = 1; |
| 5231 | exifInfo->gps_timestamp[1].num = tm_data.tm_min; |
| 5232 | exifInfo->gps_timestamp[1].den = 1; |
| 5233 | exifInfo->gps_timestamp[2].num = tm_data.tm_sec; |
| 5234 | exifInfo->gps_timestamp[2].den = 1; |
| 5235 | snprintf((char*)exifInfo->gps_datestamp, sizeof(exifInfo->gps_datestamp), |
| 5236 | "%04d:%02d:%02d", tm_data.tm_year + 1900, tm_data.tm_mon + 1, tm_data.tm_mday); |
| 5237 | |
| 5238 | exifInfo->enableGps = true; |
| 5239 | } else { |
| 5240 | exifInfo->enableGps = false; |
| 5241 | } |
| 5242 | |
| 5243 | //2 1th IFD TIFF Tags |
| 5244 | exifInfo->widthThumb = ctl->jpeg.thumbnailSize[0]; |
| 5245 | exifInfo->heightThumb = ctl->jpeg.thumbnailSize[1]; |
| 5246 | } |
| 5247 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5248 | ExynosCameraHWInterface2::MainThread::~MainThread() |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5249 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5250 | ALOGV("(%s):", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5251 | } |
| 5252 | |
| 5253 | void ExynosCameraHWInterface2::MainThread::release() |
| 5254 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5255 | ALOGV("(%s):", __func__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5256 | SetSignal(SIGNAL_THREAD_RELEASE); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5257 | } |
| 5258 | |
| 5259 | ExynosCameraHWInterface2::SensorThread::~SensorThread() |
| 5260 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5261 | ALOGV("(%s):", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5262 | } |
| 5263 | |
| 5264 | void ExynosCameraHWInterface2::SensorThread::release() |
| 5265 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5266 | ALOGV("(%s):", __func__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5267 | SetSignal(SIGNAL_THREAD_RELEASE); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5268 | } |
| 5269 | |
| 5270 | ExynosCameraHWInterface2::IspThread::~IspThread() |
| 5271 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5272 | ALOGV("(%s):", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5273 | } |
| 5274 | |
| 5275 | void ExynosCameraHWInterface2::IspThread::release() |
| 5276 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5277 | ALOGV("(%s):", __func__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5278 | SetSignal(SIGNAL_THREAD_RELEASE); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5279 | } |
| 5280 | |
| 5281 | ExynosCameraHWInterface2::StreamThread::~StreamThread() |
| 5282 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5283 | ALOGV("(%s):", __FUNCTION__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5284 | } |
| 5285 | |
| 5286 | void ExynosCameraHWInterface2::StreamThread::setParameter(stream_parameters_t * new_parameters) |
| 5287 | { |
| 5288 | ALOGV("DEBUG(%s):", __FUNCTION__); |
| 5289 | |
| 5290 | m_tempParameters = new_parameters; |
| 5291 | |
| 5292 | SetSignal(SIGNAL_STREAM_CHANGE_PARAMETER); |
| 5293 | |
| 5294 | // TODO : return synchronously (after setting parameters asynchronously) |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5295 | usleep(2000); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5296 | } |
| 5297 | |
| 5298 | void ExynosCameraHWInterface2::StreamThread::applyChange() |
| 5299 | { |
| 5300 | memcpy(&m_parameters, m_tempParameters, sizeof(stream_parameters_t)); |
| 5301 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5302 | ALOGV("DEBUG(%s): Applying Stream paremeters width(%d), height(%d)", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5303 | __FUNCTION__, m_parameters.outputWidth, m_parameters.outputHeight); |
| 5304 | } |
| 5305 | |
| 5306 | void ExynosCameraHWInterface2::StreamThread::release() |
| 5307 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5308 | ALOGV("(%s):", __func__); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5309 | SetSignal(SIGNAL_THREAD_RELEASE); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5310 | } |
| 5311 | |
| 5312 | int ExynosCameraHWInterface2::StreamThread::findBufferIndex(void * bufAddr) |
| 5313 | { |
| 5314 | int index; |
| 5315 | for (index = 0 ; index < m_parameters.numSvcBuffers ; index++) { |
| 5316 | if (m_parameters.svcBuffers[index].virt.extP[0] == bufAddr) |
| 5317 | return index; |
| 5318 | } |
| 5319 | return -1; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5320 | } |
| 5321 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5322 | void ExynosCameraHWInterface2::StreamThread::setRecordingParameter(record_parameters_t * recordParm) |
| 5323 | { |
| 5324 | memcpy(&m_recordParameters, recordParm, sizeof(record_parameters_t)); |
| 5325 | } |
| 5326 | |
Sungjoong Kang | 74d78eb | 2012-08-29 13:25:46 -0700 | [diff] [blame] | 5327 | void ExynosCameraHWInterface2::StreamThread::setCallbackParameter(callback_parameters_t * callbackParm) |
| 5328 | { |
| 5329 | memcpy(&m_previewCbParameters, callbackParm, sizeof(callback_parameters_t)); |
| 5330 | } |
| 5331 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5332 | int ExynosCameraHWInterface2::createIonClient(ion_client ionClient) |
| 5333 | { |
| 5334 | if (ionClient == 0) { |
| 5335 | ionClient = ion_client_create(); |
| 5336 | if (ionClient < 0) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5337 | ALOGE("[%s]src ion client create failed, value = %d\n", __FUNCTION__, ionClient); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5338 | return 0; |
| 5339 | } |
| 5340 | } |
| 5341 | |
| 5342 | return ionClient; |
| 5343 | } |
| 5344 | |
| 5345 | int ExynosCameraHWInterface2::deleteIonClient(ion_client ionClient) |
| 5346 | { |
| 5347 | if (ionClient != 0) { |
| 5348 | if (ionClient > 0) { |
| 5349 | ion_client_destroy(ionClient); |
| 5350 | } |
| 5351 | ionClient = 0; |
| 5352 | } |
| 5353 | |
| 5354 | return ionClient; |
| 5355 | } |
| 5356 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5357 | int ExynosCameraHWInterface2::allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5358 | { |
Sungjoong Kang | 181e425 | 2012-08-29 02:11:07 -0700 | [diff] [blame] | 5359 | return allocCameraMemory(ionClient, buf, iMemoryNum, 0); |
| 5360 | } |
| 5361 | |
| 5362 | int ExynosCameraHWInterface2::allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum, int cacheFlag) |
| 5363 | { |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5364 | int ret = 0; |
| 5365 | int i = 0; |
Sungjoong Kang | 181e425 | 2012-08-29 02:11:07 -0700 | [diff] [blame] | 5366 | int flag = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5367 | |
| 5368 | if (ionClient == 0) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5369 | ALOGE("[%s] ionClient is zero (%d)\n", __FUNCTION__, ionClient); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5370 | return -1; |
| 5371 | } |
| 5372 | |
Sungjoong Kang | 181e425 | 2012-08-29 02:11:07 -0700 | [diff] [blame] | 5373 | for (i = 0 ; i < iMemoryNum ; i++) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5374 | if (buf->size.extS[i] == 0) { |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5375 | break; |
| 5376 | } |
Sungjoong Kang | 181e425 | 2012-08-29 02:11:07 -0700 | [diff] [blame] | 5377 | if (1 << i & cacheFlag) |
| 5378 | flag = ION_FLAG_CACHED; |
| 5379 | else |
| 5380 | flag = 0; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5381 | buf->fd.extFd[i] = ion_alloc(ionClient, \ |
Sungjoong Kang | 181e425 | 2012-08-29 02:11:07 -0700 | [diff] [blame] | 5382 | buf->size.extS[i], 0, ION_HEAP_EXYNOS_MASK, flag); |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5383 | if ((buf->fd.extFd[i] == -1) ||(buf->fd.extFd[i] == 0)) { |
| 5384 | ALOGE("[%s]ion_alloc(%d) failed\n", __FUNCTION__, buf->size.extS[i]); |
| 5385 | buf->fd.extFd[i] = -1; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5386 | freeCameraMemory(buf, iMemoryNum); |
| 5387 | return -1; |
| 5388 | } |
| 5389 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5390 | buf->virt.extP[i] = (char *)ion_map(buf->fd.extFd[i], \ |
| 5391 | buf->size.extS[i], 0); |
| 5392 | if ((buf->virt.extP[i] == (char *)MAP_FAILED) || (buf->virt.extP[i] == NULL)) { |
| 5393 | ALOGE("[%s]src ion map failed(%d)\n", __FUNCTION__, buf->size.extS[i]); |
| 5394 | buf->virt.extP[i] = (char *)MAP_FAILED; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5395 | freeCameraMemory(buf, iMemoryNum); |
| 5396 | return -1; |
| 5397 | } |
Sungjoong Kang | 181e425 | 2012-08-29 02:11:07 -0700 | [diff] [blame] | 5398 | ALOGV("allocCameraMem : [%d][0x%08x] size(%d) flag(%d)", i, (unsigned int)(buf->virt.extP[i]), buf->size.extS[i], flag); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5399 | } |
| 5400 | |
| 5401 | return ret; |
| 5402 | } |
| 5403 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5404 | void ExynosCameraHWInterface2::freeCameraMemory(ExynosBuffer *buf, int iMemoryNum) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5405 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5406 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5407 | int i =0 ; |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 5408 | int ret = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5409 | |
| 5410 | for (i=0;i<iMemoryNum;i++) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5411 | if (buf->fd.extFd[i] != -1) { |
| 5412 | if (buf->virt.extP[i] != (char *)MAP_FAILED) { |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 5413 | ret = ion_unmap(buf->virt.extP[i], buf->size.extS[i]); |
| 5414 | if (ret < 0) |
| 5415 | ALOGE("ERR(%s)", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5416 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5417 | ion_free(buf->fd.extFd[i]); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5418 | } |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5419 | buf->fd.extFd[i] = -1; |
| 5420 | buf->virt.extP[i] = (char *)MAP_FAILED; |
| 5421 | buf->size.extS[i] = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5422 | } |
| 5423 | } |
| 5424 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5425 | void ExynosCameraHWInterface2::initCameraMemory(ExynosBuffer *buf, int iMemoryNum) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5426 | { |
| 5427 | int i =0 ; |
| 5428 | for (i=0;i<iMemoryNum;i++) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5429 | buf->virt.extP[i] = (char *)MAP_FAILED; |
| 5430 | buf->fd.extFd[i] = -1; |
| 5431 | buf->size.extS[i] = 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5432 | } |
| 5433 | } |
| 5434 | |
| 5435 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5436 | |
| 5437 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5438 | static camera2_device_t *g_cam2_device = NULL; |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 5439 | static bool g_camera_vaild = false; |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 5440 | ExynosCamera2 * g_camera2[2] = { NULL, NULL }; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5441 | |
| 5442 | static int HAL2_camera_device_close(struct hw_device_t* device) |
| 5443 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5444 | ALOGV("%s: ENTER", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5445 | if (device) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5446 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5447 | camera2_device_t *cam_device = (camera2_device_t *)device; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5448 | ALOGV("cam_device(0x%08x):", (unsigned int)cam_device); |
| 5449 | ALOGV("g_cam2_device(0x%08x):", (unsigned int)g_cam2_device); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5450 | delete static_cast<ExynosCameraHWInterface2 *>(cam_device->priv); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5451 | g_cam2_device = NULL; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5452 | free(cam_device); |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 5453 | g_camera_vaild = false; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5454 | } |
Sungjoong Kang | 15fd823 | 2012-08-23 16:16:44 -0700 | [diff] [blame] | 5455 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5456 | ALOGV("%s: EXIT", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5457 | return 0; |
| 5458 | } |
| 5459 | |
| 5460 | static inline ExynosCameraHWInterface2 *obj(const struct camera2_device *dev) |
| 5461 | { |
| 5462 | return reinterpret_cast<ExynosCameraHWInterface2 *>(dev->priv); |
| 5463 | } |
| 5464 | |
| 5465 | static int HAL2_device_set_request_queue_src_ops(const struct camera2_device *dev, |
| 5466 | const camera2_request_queue_src_ops_t *request_src_ops) |
| 5467 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5468 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5469 | return obj(dev)->setRequestQueueSrcOps(request_src_ops); |
| 5470 | } |
| 5471 | |
| 5472 | static int HAL2_device_notify_request_queue_not_empty(const struct camera2_device *dev) |
| 5473 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5474 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5475 | return obj(dev)->notifyRequestQueueNotEmpty(); |
| 5476 | } |
| 5477 | |
| 5478 | static int HAL2_device_set_frame_queue_dst_ops(const struct camera2_device *dev, |
| 5479 | const camera2_frame_queue_dst_ops_t *frame_dst_ops) |
| 5480 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5481 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5482 | return obj(dev)->setFrameQueueDstOps(frame_dst_ops); |
| 5483 | } |
| 5484 | |
| 5485 | static int HAL2_device_get_in_progress_count(const struct camera2_device *dev) |
| 5486 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5487 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5488 | return obj(dev)->getInProgressCount(); |
| 5489 | } |
| 5490 | |
| 5491 | static int HAL2_device_flush_captures_in_progress(const struct camera2_device *dev) |
| 5492 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5493 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5494 | return obj(dev)->flushCapturesInProgress(); |
| 5495 | } |
| 5496 | |
| 5497 | static int HAL2_device_construct_default_request(const struct camera2_device *dev, |
| 5498 | int request_template, camera_metadata_t **request) |
| 5499 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5500 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5501 | return obj(dev)->constructDefaultRequest(request_template, request); |
| 5502 | } |
| 5503 | |
| 5504 | static int HAL2_device_allocate_stream( |
| 5505 | const struct camera2_device *dev, |
| 5506 | // inputs |
| 5507 | uint32_t width, |
| 5508 | uint32_t height, |
| 5509 | int format, |
| 5510 | const camera2_stream_ops_t *stream_ops, |
| 5511 | // outputs |
| 5512 | uint32_t *stream_id, |
| 5513 | uint32_t *format_actual, |
| 5514 | uint32_t *usage, |
| 5515 | uint32_t *max_buffers) |
| 5516 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5517 | ALOGV("(%s): ", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5518 | return obj(dev)->allocateStream(width, height, format, stream_ops, |
| 5519 | stream_id, format_actual, usage, max_buffers); |
| 5520 | } |
| 5521 | |
| 5522 | |
| 5523 | static int HAL2_device_register_stream_buffers(const struct camera2_device *dev, |
| 5524 | uint32_t stream_id, |
| 5525 | int num_buffers, |
| 5526 | buffer_handle_t *buffers) |
| 5527 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5528 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5529 | return obj(dev)->registerStreamBuffers(stream_id, num_buffers, buffers); |
| 5530 | } |
| 5531 | |
| 5532 | static int HAL2_device_release_stream( |
| 5533 | const struct camera2_device *dev, |
| 5534 | uint32_t stream_id) |
| 5535 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5536 | ALOGV("DEBUG(%s)(id: %d):", __FUNCTION__, stream_id); |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 5537 | if (!g_camera_vaild) |
| 5538 | return 0; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5539 | return obj(dev)->releaseStream(stream_id); |
| 5540 | } |
| 5541 | |
| 5542 | static int HAL2_device_allocate_reprocess_stream( |
| 5543 | const struct camera2_device *dev, |
| 5544 | uint32_t width, |
| 5545 | uint32_t height, |
| 5546 | uint32_t format, |
| 5547 | const camera2_stream_in_ops_t *reprocess_stream_ops, |
| 5548 | // outputs |
| 5549 | uint32_t *stream_id, |
| 5550 | uint32_t *consumer_usage, |
| 5551 | uint32_t *max_buffers) |
| 5552 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5553 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5554 | return obj(dev)->allocateReprocessStream(width, height, format, reprocess_stream_ops, |
| 5555 | stream_id, consumer_usage, max_buffers); |
| 5556 | } |
| 5557 | |
Eino-Ville Talvala | 2b0421d | 2012-09-04 13:41:55 -0700 | [diff] [blame] | 5558 | static int HAL2_device_allocate_reprocess_stream_from_stream( |
| 5559 | const struct camera2_device *dev, |
| 5560 | uint32_t output_stream_id, |
| 5561 | const camera2_stream_in_ops_t *reprocess_stream_ops, |
| 5562 | // outputs |
| 5563 | uint32_t *stream_id) |
| 5564 | { |
| 5565 | ALOGV("DEBUG(%s):", __FUNCTION__); |
| 5566 | // Temporary stub |
| 5567 | return 0; |
| 5568 | } |
| 5569 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5570 | static int HAL2_device_release_reprocess_stream( |
| 5571 | const struct camera2_device *dev, |
| 5572 | uint32_t stream_id) |
| 5573 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5574 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5575 | return obj(dev)->releaseReprocessStream(stream_id); |
| 5576 | } |
| 5577 | |
| 5578 | static int HAL2_device_trigger_action(const struct camera2_device *dev, |
| 5579 | uint32_t trigger_id, |
| 5580 | int ext1, |
| 5581 | int ext2) |
| 5582 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5583 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5584 | return obj(dev)->triggerAction(trigger_id, ext1, ext2); |
| 5585 | } |
| 5586 | |
| 5587 | static int HAL2_device_set_notify_callback(const struct camera2_device *dev, |
| 5588 | camera2_notify_callback notify_cb, |
| 5589 | void *user) |
| 5590 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5591 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5592 | return obj(dev)->setNotifyCallback(notify_cb, user); |
| 5593 | } |
| 5594 | |
| 5595 | static int HAL2_device_get_metadata_vendor_tag_ops(const struct camera2_device*dev, |
| 5596 | vendor_tag_query_ops_t **ops) |
| 5597 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5598 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5599 | return obj(dev)->getMetadataVendorTagOps(ops); |
| 5600 | } |
| 5601 | |
| 5602 | static int HAL2_device_dump(const struct camera2_device *dev, int fd) |
| 5603 | { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5604 | ALOGV("DEBUG(%s):", __FUNCTION__); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5605 | return obj(dev)->dump(fd); |
| 5606 | } |
| 5607 | |
| 5608 | |
| 5609 | |
| 5610 | |
| 5611 | |
| 5612 | static int HAL2_getNumberOfCameras() |
| 5613 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5614 | ALOGV("(%s): returning 2", __FUNCTION__); |
| 5615 | return 2; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5616 | } |
| 5617 | |
| 5618 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5619 | static int HAL2_getCameraInfo(int cameraId, struct camera_info *info) |
| 5620 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5621 | ALOGV("DEBUG(%s): cameraID: %d", __FUNCTION__, cameraId); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5622 | static camera_metadata_t * mCameraInfo[2] = {NULL, NULL}; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5623 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5624 | status_t res; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5625 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 5626 | if (cameraId == 0) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5627 | info->facing = CAMERA_FACING_BACK; |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 5628 | if (!g_camera2[0]) |
| 5629 | g_camera2[0] = new ExynosCamera2(0); |
| 5630 | } |
| 5631 | else if (cameraId == 1) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5632 | info->facing = CAMERA_FACING_FRONT; |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 5633 | if (!g_camera2[1]) |
| 5634 | g_camera2[1] = new ExynosCamera2(1); |
| 5635 | } |
| 5636 | else |
| 5637 | return BAD_VALUE; |
| 5638 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5639 | info->orientation = 0; |
| 5640 | info->device_version = HARDWARE_DEVICE_API_VERSION(2, 0); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5641 | if (mCameraInfo[cameraId] == NULL) { |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 5642 | res = g_camera2[cameraId]->constructStaticInfo(&(mCameraInfo[cameraId]), cameraId, true); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5643 | if (res != OK) { |
| 5644 | ALOGE("%s: Unable to allocate static info: %s (%d)", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5645 | __FUNCTION__, strerror(-res), res); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5646 | return res; |
| 5647 | } |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 5648 | res = g_camera2[cameraId]->constructStaticInfo(&(mCameraInfo[cameraId]), cameraId, false); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5649 | if (res != OK) { |
| 5650 | ALOGE("%s: Unable to fill in static info: %s (%d)", |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5651 | __FUNCTION__, strerror(-res), res); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5652 | return res; |
| 5653 | } |
| 5654 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5655 | info->static_camera_characteristics = mCameraInfo[cameraId]; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5656 | return NO_ERROR; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5657 | } |
| 5658 | |
| 5659 | #define SET_METHOD(m) m : HAL2_device_##m |
| 5660 | |
| 5661 | static camera2_device_ops_t camera2_device_ops = { |
| 5662 | SET_METHOD(set_request_queue_src_ops), |
| 5663 | SET_METHOD(notify_request_queue_not_empty), |
| 5664 | SET_METHOD(set_frame_queue_dst_ops), |
| 5665 | SET_METHOD(get_in_progress_count), |
| 5666 | SET_METHOD(flush_captures_in_progress), |
| 5667 | SET_METHOD(construct_default_request), |
| 5668 | SET_METHOD(allocate_stream), |
| 5669 | SET_METHOD(register_stream_buffers), |
| 5670 | SET_METHOD(release_stream), |
| 5671 | SET_METHOD(allocate_reprocess_stream), |
Eino-Ville Talvala | 2b0421d | 2012-09-04 13:41:55 -0700 | [diff] [blame] | 5672 | SET_METHOD(allocate_reprocess_stream_from_stream), |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5673 | SET_METHOD(release_reprocess_stream), |
| 5674 | SET_METHOD(trigger_action), |
| 5675 | SET_METHOD(set_notify_callback), |
| 5676 | SET_METHOD(get_metadata_vendor_tag_ops), |
| 5677 | SET_METHOD(dump), |
| 5678 | }; |
| 5679 | |
| 5680 | #undef SET_METHOD |
| 5681 | |
| 5682 | |
| 5683 | static int HAL2_camera_device_open(const struct hw_module_t* module, |
| 5684 | const char *id, |
| 5685 | struct hw_device_t** device) |
| 5686 | { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5687 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5688 | |
| 5689 | int cameraId = atoi(id); |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 5690 | int openInvalid = 0; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5691 | |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 5692 | g_camera_vaild = false; |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5693 | ALOGV("\n\n>>> I'm Samsung's CameraHAL_2(ID:%d) <<<\n\n", cameraId); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5694 | if (cameraId < 0 || cameraId >= HAL2_getNumberOfCameras()) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5695 | ALOGE("ERR(%s):Invalid camera ID %s", __FUNCTION__, id); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5696 | return -EINVAL; |
| 5697 | } |
| 5698 | |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5699 | ALOGV("g_cam2_device : 0x%08x", (unsigned int)g_cam2_device); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5700 | if (g_cam2_device) { |
| 5701 | if (obj(g_cam2_device)->getCameraId() == cameraId) { |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5702 | ALOGV("DEBUG(%s):returning existing camera ID %s", __FUNCTION__, id); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5703 | goto done; |
| 5704 | } else { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5705 | |
| 5706 | while (g_cam2_device) |
| 5707 | usleep(10000); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5708 | } |
| 5709 | } |
| 5710 | |
| 5711 | g_cam2_device = (camera2_device_t *)malloc(sizeof(camera2_device_t)); |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame] | 5712 | ALOGV("g_cam2_device : 0x%08x", (unsigned int)g_cam2_device); |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 5713 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5714 | if (!g_cam2_device) |
| 5715 | return -ENOMEM; |
| 5716 | |
| 5717 | g_cam2_device->common.tag = HARDWARE_DEVICE_TAG; |
| 5718 | g_cam2_device->common.version = CAMERA_DEVICE_API_VERSION_2_0; |
| 5719 | g_cam2_device->common.module = const_cast<hw_module_t *>(module); |
| 5720 | g_cam2_device->common.close = HAL2_camera_device_close; |
| 5721 | |
| 5722 | g_cam2_device->ops = &camera2_device_ops; |
| 5723 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5724 | ALOGV("DEBUG(%s):open camera2 %s", __FUNCTION__, id); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5725 | |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 5726 | g_cam2_device->priv = new ExynosCameraHWInterface2(cameraId, g_cam2_device, g_camera2[cameraId], &openInvalid); |
| 5727 | if (!openInvalid) { |
| 5728 | ALOGE("DEBUG(%s): ExynosCameraHWInterface2 creation failed(%d)", __FUNCTION__); |
Younghwan Joo | 6f19b6c | 2012-08-30 13:56:53 -0700 | [diff] [blame] | 5729 | return -ENODEV; |
Sungjoong Kang | 6044e50 | 2012-08-27 00:29:28 -0700 | [diff] [blame] | 5730 | } |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5731 | done: |
| 5732 | *device = (hw_device_t *)g_cam2_device; |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 5733 | ALOGV("DEBUG(%s):opened camera2 %s (%p)", __FUNCTION__, id, *device); |
Sungjoong Kang | b5237e6 | 2012-07-27 07:39:05 -0700 | [diff] [blame] | 5734 | g_camera_vaild = true; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 5735 | |
| 5736 | return 0; |
| 5737 | } |
| 5738 | |
| 5739 | |
| 5740 | static hw_module_methods_t camera_module_methods = { |
| 5741 | open : HAL2_camera_device_open |
| 5742 | }; |
| 5743 | |
| 5744 | extern "C" { |
| 5745 | struct camera_module HAL_MODULE_INFO_SYM = { |
| 5746 | common : { |
| 5747 | tag : HARDWARE_MODULE_TAG, |
| 5748 | module_api_version : CAMERA_MODULE_API_VERSION_2_0, |
| 5749 | hal_api_version : HARDWARE_HAL_API_VERSION, |
| 5750 | id : CAMERA_HARDWARE_MODULE_ID, |
| 5751 | name : "Exynos Camera HAL2", |
| 5752 | author : "Samsung Corporation", |
| 5753 | methods : &camera_module_methods, |
| 5754 | dso: NULL, |
| 5755 | reserved: {0}, |
| 5756 | }, |
| 5757 | get_number_of_cameras : HAL2_getNumberOfCameras, |
| 5758 | get_camera_info : HAL2_getCameraInfo |
| 5759 | }; |
| 5760 | } |
| 5761 | |
| 5762 | }; // namespace android |