static void mm_app_metadata_notify_cb(mm_camera_super_buf_t *bufs,
                                     void *user_data)
{
  int i = 0;
  mm_camera_channel_t *channel = NULL;
  mm_camera_stream_t *p_stream = NULL;
  mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data;
  mm_camera_buf_def_t *frame = bufs->bufs[0];
  metadata_buffer_t *pMetadata;
  cam_auto_focus_data_t *focus_data;

  if (NULL == bufs || NULL == user_data) {
      CDBG_ERROR("%s: bufs or user_data are not valid ", __func__);
      return;
  }

  /* find channel */
  for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) {
      if (pme->channels[i].ch_id == bufs->ch_id) {
          channel = &pme->channels[i];
          break;
      }
  }
  /* find preview stream */
  for (i = 0; i < channel->num_streams; i++) {
      if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_METADATA) {
          p_stream = &channel->streams[i];
          break;
      }
  }
  /* find preview frame */
  for (i = 0; i < bufs->num_bufs; i++) {
      if (bufs->bufs[i]->stream_id == p_stream->s_id) {
          frame = bufs->bufs[i];
          break;
      }
  }

  if (NULL == p_stream) {
      CDBG_ERROR("%s: cannot find metadata stream", __func__);
      return;
  }
  if (pme->metadata == NULL) {
    /* The app will free the meta data, we don't need to bother here */
    pme->metadata = malloc(sizeof(metadata_buffer_t));
    if (NULL == pme->metadata) {
        CDBG_ERROR("%s: Canot allocate metadata memory\n", __func__);
        return;
    }
  }
  memcpy(pme->metadata, frame->buffer, sizeof(metadata_buffer_t));

  pMetadata = (metadata_buffer_t *)frame->buffer;
  if (IS_META_AVAILABLE(CAM_INTF_META_AUTOFOCUS_DATA, pMetadata)) {
    focus_data = (cam_auto_focus_data_t *)
      POINTER_OF_META(CAM_INTF_META_AUTOFOCUS_DATA, pMetadata);
    if (focus_data->focus_state == CAM_AF_FOCUSED ||
      focus_data->focus_state == CAM_AF_NOT_FOCUSED) {
      CDBG_ERROR("%s: AutoFocus Done Call Back Received\n",__func__);
      mm_camera_app_done();
    } else if (focus_data->focus_state == CAM_AF_NOT_FOCUSED) {
      CDBG_ERROR("%s: AutoFocus failed\n",__func__);
      mm_camera_app_done();
    }
  }

  if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle,
                                          bufs->ch_id,
                                          frame)) {
      CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__);
  }
  mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info,
                   ION_IOC_INV_CACHES);
}
示例#2
0
void *get_pointer_of(cam_intf_parm_type_t meta_id,
        const metadata_buffer_t* metadata)
{
    switch(meta_id) {
        case CAM_INTF_META_HISTOGRAM:
            return POINTER_OF_META(CAM_INTF_META_HISTOGRAM, metadata);
        case CAM_INTF_META_FACE_DETECTION:
            return POINTER_OF_META(CAM_INTF_META_FACE_DETECTION, metadata);
        case CAM_INTF_META_AUTOFOCUS_DATA:
            return POINTER_OF_META(CAM_INTF_META_AUTOFOCUS_DATA, metadata);
        case CAM_INTF_PARM_UPDATE_DEBUG_LEVEL:
            return POINTER_OF_META(CAM_INTF_PARM_UPDATE_DEBUG_LEVEL, metadata);
        case CAM_INTF_META_CROP_DATA:
            return POINTER_OF_META(CAM_INTF_META_CROP_DATA, metadata);
        case CAM_INTF_META_PREP_SNAPSHOT_DONE:
            return POINTER_OF_META(CAM_INTF_META_PREP_SNAPSHOT_DONE, metadata);
        case CAM_INTF_META_GOOD_FRAME_IDX_RANGE:
            return POINTER_OF_META(CAM_INTF_META_GOOD_FRAME_IDX_RANGE, metadata);
        case CAM_INTF_META_ASD_HDR_SCENE_DATA:
            return POINTER_OF_META(CAM_INTF_META_ASD_HDR_SCENE_DATA, metadata);
        case CAM_INTF_META_ASD_SCENE_TYPE:
            return POINTER_OF_META(CAM_INTF_META_ASD_SCENE_TYPE, metadata);
        case CAM_INTF_META_CHROMATIX_LITE_ISP:
            return POINTER_OF_META(CAM_INTF_META_CHROMATIX_LITE_ISP, metadata);
        case CAM_INTF_META_CHROMATIX_LITE_PP:
            return POINTER_OF_META(CAM_INTF_META_CHROMATIX_LITE_PP, metadata);
        case CAM_INTF_META_CHROMATIX_LITE_AE:
            return POINTER_OF_META(CAM_INTF_META_CHROMATIX_LITE_AE, metadata);
        case CAM_INTF_META_CHROMATIX_LITE_AWB:
            return POINTER_OF_META(CAM_INTF_META_CHROMATIX_LITE_AWB, metadata);
        case CAM_INTF_META_CHROMATIX_LITE_AF:
            return POINTER_OF_META(CAM_INTF_META_CHROMATIX_LITE_AF, metadata);
        case CAM_INTF_META_CHROMATIX_LITE_ASD:
            return POINTER_OF_META(CAM_INTF_META_CHROMATIX_LITE_ASD, metadata);
        case CAM_INTF_BUF_DIVERT_INFO:
            return POINTER_OF_META(CAM_INTF_BUF_DIVERT_INFO, metadata);
        case CAM_INTF_META_FRAME_NUMBER_VALID:
            return POINTER_OF_META(CAM_INTF_META_FRAME_NUMBER_VALID, metadata);
        case CAM_INTF_META_URGENT_FRAME_NUMBER_VALID:
            return POINTER_OF_META(CAM_INTF_META_URGENT_FRAME_NUMBER_VALID, metadata);
        case CAM_INTF_META_FRAME_DROPPED:
            return POINTER_OF_META(CAM_INTF_META_FRAME_DROPPED, metadata);
        case CAM_INTF_META_FRAME_NUMBER:
            return POINTER_OF_META(CAM_INTF_META_FRAME_NUMBER, metadata);
        case CAM_INTF_META_URGENT_FRAME_NUMBER:
            return POINTER_OF_META(CAM_INTF_META_URGENT_FRAME_NUMBER, metadata);
        case CAM_INTF_META_COLOR_CORRECT_MODE:
            return POINTER_OF_META(CAM_INTF_META_COLOR_CORRECT_MODE, metadata);
        case CAM_INTF_META_COLOR_CORRECT_TRANSFORM:
            return POINTER_OF_META(CAM_INTF_META_COLOR_CORRECT_TRANSFORM, metadata);
        case CAM_INTF_META_COLOR_CORRECT_GAINS:
            return POINTER_OF_META(CAM_INTF_META_COLOR_CORRECT_GAINS, metadata);
        case CAM_INTF_META_PRED_COLOR_CORRECT_TRANSFORM:
            return POINTER_OF_META(CAM_INTF_META_PRED_COLOR_CORRECT_TRANSFORM, metadata);
        case CAM_INTF_META_PRED_COLOR_CORRECT_GAINS:
            return POINTER_OF_META(CAM_INTF_META_PRED_COLOR_CORRECT_GAINS, metadata);
        case CAM_INTF_META_AEC_ROI:
            return POINTER_OF_META(CAM_INTF_META_AEC_ROI, metadata);
        case CAM_INTF_META_AEC_STATE:
            return POINTER_OF_META(CAM_INTF_META_AEC_STATE, metadata);
        case CAM_INTF_PARM_FOCUS_MODE:
            return POINTER_OF_META(CAM_INTF_PARM_FOCUS_MODE, metadata);
        case CAM_INTF_PARM_MANUAL_FOCUS_POS:
            return POINTER_OF_META(CAM_INTF_PARM_MANUAL_FOCUS_POS, metadata);
        case CAM_INTF_META_AF_ROI:
            return POINTER_OF_META(CAM_INTF_META_AF_ROI, metadata);
        case CAM_INTF_META_AF_STATE:
            return POINTER_OF_META(CAM_INTF_META_AF_STATE, metadata);
        case CAM_INTF_PARM_WHITE_BALANCE:
            return POINTER_OF_META(CAM_INTF_PARM_WHITE_BALANCE, metadata);
        case CAM_INTF_META_AWB_REGIONS:
            return POINTER_OF_META(CAM_INTF_META_AWB_REGIONS, metadata);
        case CAM_INTF_META_AWB_STATE:
            return POINTER_OF_META(CAM_INTF_META_AWB_STATE, metadata);
        case CAM_INTF_META_BLACK_LEVEL_LOCK:
            return POINTER_OF_META(CAM_INTF_META_BLACK_LEVEL_LOCK, metadata);
        case CAM_INTF_META_MODE:
            return POINTER_OF_META(CAM_INTF_META_MODE, metadata);
        case CAM_INTF_META_EDGE_MODE:
            return POINTER_OF_META(CAM_INTF_META_EDGE_MODE, metadata);
        case CAM_INTF_META_FLASH_POWER:
            return POINTER_OF_META(CAM_INTF_META_FLASH_POWER, metadata);
        case CAM_INTF_META_FLASH_FIRING_TIME:
            return POINTER_OF_META(CAM_INTF_META_FLASH_FIRING_TIME, metadata);
        case CAM_INTF_META_FLASH_MODE:
            return POINTER_OF_META(CAM_INTF_META_FLASH_MODE, metadata);
        case CAM_INTF_META_FLASH_STATE:
            return POINTER_OF_META(CAM_INTF_META_FLASH_STATE, metadata);
        case CAM_INTF_META_HOTPIXEL_MODE:
            return POINTER_OF_META(CAM_INTF_META_HOTPIXEL_MODE, metadata);
        case CAM_INTF_META_LENS_APERTURE:
            return POINTER_OF_META(CAM_INTF_META_LENS_APERTURE, metadata);
        case CAM_INTF_META_LENS_FILTERDENSITY:
            return POINTER_OF_META(CAM_INTF_META_LENS_FILTERDENSITY, metadata);
        case CAM_INTF_META_LENS_FOCAL_LENGTH:
            return POINTER_OF_META(CAM_INTF_META_LENS_FOCAL_LENGTH, metadata);
        case CAM_INTF_META_LENS_FOCUS_DISTANCE:
            return POINTER_OF_META(CAM_INTF_META_LENS_FOCUS_DISTANCE, metadata);
        case CAM_INTF_META_LENS_FOCUS_RANGE:
            return POINTER_OF_META(CAM_INTF_META_LENS_FOCUS_RANGE, metadata);
        case CAM_INTF_META_LENS_STATE:
            return POINTER_OF_META(CAM_INTF_META_LENS_STATE, metadata);
        case CAM_INTF_META_LENS_OPT_STAB_MODE:
            return POINTER_OF_META(CAM_INTF_META_LENS_OPT_STAB_MODE, metadata);
        case CAM_INTF_META_NOISE_REDUCTION_MODE:
            return POINTER_OF_META(CAM_INTF_META_NOISE_REDUCTION_MODE, metadata);
        case CAM_INTF_META_NOISE_REDUCTION_STRENGTH:
            return POINTER_OF_META(CAM_INTF_META_NOISE_REDUCTION_STRENGTH, metadata);
        case CAM_INTF_META_SCALER_CROP_REGION:
            return POINTER_OF_META(CAM_INTF_META_SCALER_CROP_REGION, metadata);
        case CAM_INTF_META_SCENE_FLICKER:
            return POINTER_OF_META(CAM_INTF_META_SCENE_FLICKER, metadata);
        case CAM_INTF_META_SENSOR_EXPOSURE_TIME:
            return POINTER_OF_META(CAM_INTF_META_SENSOR_EXPOSURE_TIME, metadata);
        case CAM_INTF_META_SENSOR_FRAME_DURATION:
            return POINTER_OF_META(CAM_INTF_META_SENSOR_FRAME_DURATION, metadata);
        case CAM_INTF_META_SENSOR_SENSITIVITY:
            return POINTER_OF_META(CAM_INTF_META_SENSOR_SENSITIVITY, metadata);
        case CAM_INTF_META_SENSOR_TIMESTAMP:
            return POINTER_OF_META(CAM_INTF_META_SENSOR_TIMESTAMP, metadata);
        case CAM_INTF_META_SENSOR_ROLLING_SHUTTER_SKEW:
            return POINTER_OF_META(CAM_INTF_META_SENSOR_ROLLING_SHUTTER_SKEW, metadata);
        case CAM_INTF_META_SHADING_MODE:
            return POINTER_OF_META(CAM_INTF_META_SHADING_MODE, metadata);
        case CAM_INTF_META_STATS_FACEDETECT_MODE:
            return POINTER_OF_META(CAM_INTF_META_STATS_FACEDETECT_MODE, metadata);
        case CAM_INTF_META_STATS_HISTOGRAM_MODE:
            return POINTER_OF_META(CAM_INTF_META_STATS_HISTOGRAM_MODE, metadata);
        case CAM_INTF_META_STATS_SHARPNESS_MAP_MODE:
            return POINTER_OF_META(CAM_INTF_META_STATS_SHARPNESS_MAP_MODE, metadata);
        case CAM_INTF_META_STATS_SHARPNESS_MAP:
            return POINTER_OF_META(CAM_INTF_META_STATS_SHARPNESS_MAP, metadata);
        case CAM_INTF_META_TONEMAP_CURVES:
            return POINTER_OF_META(CAM_INTF_META_TONEMAP_CURVES, metadata);
        case CAM_INTF_META_LENS_SHADING_MAP:
            return POINTER_OF_META(CAM_INTF_META_LENS_SHADING_MAP, metadata);
        case CAM_INTF_META_AEC_INFO:
            return POINTER_OF_META(CAM_INTF_META_AEC_INFO, metadata);
        case CAM_INTF_META_SENSOR_INFO:
            return POINTER_OF_META(CAM_INTF_META_SENSOR_INFO, metadata);
        case CAM_INTF_META_ASD_SCENE_CAPTURE_TYPE:
            return POINTER_OF_META(CAM_INTF_META_ASD_SCENE_CAPTURE_TYPE, metadata);
        case CAM_INTF_PARM_EFFECT:
            return POINTER_OF_META(CAM_INTF_PARM_EFFECT, metadata);
        case CAM_INTF_META_PRIVATE_DATA:
            return POINTER_OF_META(CAM_INTF_META_PRIVATE_DATA, metadata);
        case CAM_INTF_PARM_HAL_VERSION:
            return POINTER_OF_META(CAM_INTF_PARM_HAL_VERSION, metadata);
        case CAM_INTF_PARM_ANTIBANDING:
            return POINTER_OF_META(CAM_INTF_PARM_ANTIBANDING, metadata);
        case CAM_INTF_PARM_EXPOSURE_COMPENSATION:
            return POINTER_OF_META(CAM_INTF_PARM_EXPOSURE_COMPENSATION, metadata);
        case CAM_INTF_PARM_EV_STEP:
            return POINTER_OF_META(CAM_INTF_PARM_EV_STEP, metadata);
        case CAM_INTF_PARM_AEC_LOCK:
            return POINTER_OF_META(CAM_INTF_PARM_AEC_LOCK, metadata);
        case CAM_INTF_PARM_FPS_RANGE:
            return POINTER_OF_META(CAM_INTF_PARM_FPS_RANGE, metadata);
        case CAM_INTF_PARM_AWB_LOCK:
            return POINTER_OF_META(CAM_INTF_PARM_AWB_LOCK, metadata);
        case CAM_INTF_PARM_BESTSHOT_MODE:
            return POINTER_OF_META(CAM_INTF_PARM_BESTSHOT_MODE, metadata);
        case CAM_INTF_PARM_DIS_ENABLE:
            return POINTER_OF_META(CAM_INTF_PARM_DIS_ENABLE, metadata);
        case CAM_INTF_PARM_LED_MODE:
            return POINTER_OF_META(CAM_INTF_PARM_LED_MODE, metadata);
        case CAM_INTF_META_LED_MODE_OVERRIDE:
            return POINTER_OF_META(CAM_INTF_META_LED_MODE_OVERRIDE, metadata);
        case CAM_INTF_PARM_SENSOR_HDR:
            return POINTER_OF_META(CAM_INTF_PARM_SENSOR_HDR, metadata);
        case CAM_INTF_PARM_QUERY_FLASH4SNAP:
            return POINTER_OF_META(CAM_INTF_PARM_QUERY_FLASH4SNAP, metadata);
        case CAM_INTF_PARM_EXPOSURE:
            return POINTER_OF_META(CAM_INTF_PARM_EXPOSURE, metadata);
        case CAM_INTF_PARM_SHARPNESS:
            return POINTER_OF_META(CAM_INTF_PARM_SHARPNESS, metadata);
        case CAM_INTF_PARM_CONTRAST:
            return POINTER_OF_META(CAM_INTF_PARM_CONTRAST, metadata);
        case CAM_INTF_PARM_SATURATION:
            return POINTER_OF_META(CAM_INTF_PARM_SATURATION, metadata);
        case CAM_INTF_PARM_BRIGHTNESS:
            return POINTER_OF_META(CAM_INTF_PARM_BRIGHTNESS, metadata);
        case CAM_INTF_PARM_ISO:
            return POINTER_OF_META(CAM_INTF_PARM_ISO, metadata);
        case CAM_INTF_PARM_EXPOSURE_TIME:
            return POINTER_OF_META(CAM_INTF_PARM_EXPOSURE_TIME, metadata);
        case CAM_INTF_PARM_ZOOM:
            return POINTER_OF_META(CAM_INTF_PARM_ZOOM, metadata);
        case CAM_INTF_PARM_ROLLOFF:
            return POINTER_OF_META(CAM_INTF_PARM_ROLLOFF, metadata);
        case CAM_INTF_PARM_MODE:
            return POINTER_OF_META(CAM_INTF_PARM_MODE, metadata);
        case CAM_INTF_PARM_AEC_ALGO_TYPE:
            return POINTER_OF_META(CAM_INTF_PARM_AEC_ALGO_TYPE, metadata);
        case CAM_INTF_PARM_FOCUS_ALGO_TYPE:
            return POINTER_OF_META(CAM_INTF_PARM_FOCUS_ALGO_TYPE, metadata);
        case CAM_INTF_PARM_AEC_ROI:
            return POINTER_OF_META(CAM_INTF_PARM_AEC_ROI, metadata);
        case CAM_INTF_PARM_AF_ROI:
            return POINTER_OF_META(CAM_INTF_PARM_AF_ROI, metadata);
        case CAM_INTF_PARM_SCE_FACTOR:
            return POINTER_OF_META(CAM_INTF_PARM_SCE_FACTOR, metadata);
        case CAM_INTF_PARM_FD:
            return POINTER_OF_META(CAM_INTF_PARM_FD, metadata);
        case CAM_INTF_PARM_MCE:
            return POINTER_OF_META(CAM_INTF_PARM_MCE, metadata);
        case CAM_INTF_PARM_HFR:
            return POINTER_OF_META(CAM_INTF_PARM_HFR, metadata);
        case CAM_INTF_PARM_REDEYE_REDUCTION:
            return POINTER_OF_META(CAM_INTF_PARM_REDEYE_REDUCTION, metadata);
        case CAM_INTF_PARM_WAVELET_DENOISE:
            return POINTER_OF_META(CAM_INTF_PARM_WAVELET_DENOISE, metadata);
        case CAM_INTF_PARM_TEMPORAL_DENOISE:
            return POINTER_OF_META(CAM_INTF_PARM_TEMPORAL_DENOISE, metadata);
        case CAM_INTF_PARM_HISTOGRAM:
            return POINTER_OF_META(CAM_INTF_PARM_HISTOGRAM, metadata);
        case CAM_INTF_PARM_ASD_ENABLE:
            return POINTER_OF_META(CAM_INTF_PARM_ASD_ENABLE, metadata);
        case CAM_INTF_PARM_RECORDING_HINT:
            return POINTER_OF_META(CAM_INTF_PARM_RECORDING_HINT, metadata);
        case CAM_INTF_PARM_HDR:
            return POINTER_OF_META(CAM_INTF_PARM_HDR, metadata);
        case CAM_INTF_PARM_FRAMESKIP:
            return POINTER_OF_META(CAM_INTF_PARM_FRAMESKIP, metadata);
        case CAM_INTF_PARM_ZSL_MODE:
            return POINTER_OF_META(CAM_INTF_PARM_ZSL_MODE, metadata);
        case CAM_INTF_PARM_HDR_NEED_1X:
            return POINTER_OF_META(CAM_INTF_PARM_HDR_NEED_1X, metadata);
        case CAM_INTF_PARM_LOCK_CAF:
            return POINTER_OF_META(CAM_INTF_PARM_LOCK_CAF, metadata);
        case CAM_INTF_PARM_VIDEO_HDR:
            return POINTER_OF_META(CAM_INTF_PARM_VIDEO_HDR, metadata);
        case CAM_INTF_PARM_VT:
            return POINTER_OF_META(CAM_INTF_PARM_VT, metadata);
        case CAM_INTF_PARM_GET_CHROMATIX:
            return POINTER_OF_META(CAM_INTF_PARM_GET_CHROMATIX, metadata);
        case CAM_INTF_PARM_SET_RELOAD_CHROMATIX:
            return POINTER_OF_META(CAM_INTF_PARM_SET_RELOAD_CHROMATIX, metadata);
        case CAM_INTF_PARM_GET_AFTUNE:
            return POINTER_OF_META(CAM_INTF_PARM_GET_AFTUNE, metadata);
        case CAM_INTF_PARM_SET_RELOAD_AFTUNE:
            return POINTER_OF_META(CAM_INTF_PARM_SET_RELOAD_AFTUNE, metadata);
        case CAM_INTF_PARM_SET_AUTOFOCUSTUNING:
            return POINTER_OF_META(CAM_INTF_PARM_SET_AUTOFOCUSTUNING, metadata);
        case CAM_INTF_PARM_SET_VFE_COMMAND:
            return POINTER_OF_META(CAM_INTF_PARM_SET_VFE_COMMAND, metadata);
        case CAM_INTF_PARM_SET_PP_COMMAND:
            return POINTER_OF_META(CAM_INTF_PARM_SET_PP_COMMAND, metadata);
        case CAM_INTF_PARM_MAX_DIMENSION:
            return POINTER_OF_META(CAM_INTF_PARM_MAX_DIMENSION, metadata);
        case CAM_INTF_PARM_RAW_DIMENSION:
            return POINTER_OF_META(CAM_INTF_PARM_RAW_DIMENSION, metadata);
        case CAM_INTF_PARM_TINTLESS:
            return POINTER_OF_META(CAM_INTF_PARM_TINTLESS, metadata);
        case CAM_INTF_PARM_WB_MANUAL:
            return POINTER_OF_META(CAM_INTF_PARM_WB_MANUAL, metadata);
        case CAM_INTF_PARM_EZTUNE_CMD:
            return POINTER_OF_META(CAM_INTF_PARM_EZTUNE_CMD, metadata);
        case CAM_INTF_PARM_INT_EVT:
            return POINTER_OF_META(CAM_INTF_PARM_INT_EVT, metadata);
        case CAM_INTF_PARM_RDI_MODE:
            return POINTER_OF_META(CAM_INTF_PARM_RDI_MODE, metadata);
        case CAM_INTF_PARM_BURST_NUM:
            return POINTER_OF_META(CAM_INTF_PARM_BURST_NUM, metadata);
        case CAM_INTF_PARM_RETRO_BURST_NUM:
            return POINTER_OF_META(CAM_INTF_PARM_RETRO_BURST_NUM, metadata);
        case CAM_INTF_PARM_BURST_LED_ON_PERIOD:
            return POINTER_OF_META(CAM_INTF_PARM_BURST_LED_ON_PERIOD, metadata);
        case CAM_INTF_PARM_LONGSHOT_ENABLE:
            return POINTER_OF_META(CAM_INTF_PARM_LONGSHOT_ENABLE, metadata);
        case CAM_INTF_META_STREAM_INFO:
            return POINTER_OF_META(CAM_INTF_META_STREAM_INFO, metadata);
        case CAM_INTF_META_AEC_MODE:
            return POINTER_OF_META(CAM_INTF_META_AEC_MODE, metadata);
        case CAM_INTF_META_AEC_PRECAPTURE_TRIGGER:
            return POINTER_OF_META(CAM_INTF_META_AEC_PRECAPTURE_TRIGGER, metadata);
        case CAM_INTF_META_AF_TRIGGER:
            return POINTER_OF_META(CAM_INTF_META_AF_TRIGGER, metadata);
        case CAM_INTF_META_CAPTURE_INTENT:
            return POINTER_OF_META(CAM_INTF_META_CAPTURE_INTENT, metadata);
        case CAM_INTF_META_DEMOSAIC:
            return POINTER_OF_META(CAM_INTF_META_DEMOSAIC, metadata);
        case CAM_INTF_META_SHARPNESS_STRENGTH:
            return POINTER_OF_META(CAM_INTF_META_SHARPNESS_STRENGTH, metadata);
        case CAM_INTF_META_GEOMETRIC_MODE:
            return POINTER_OF_META(CAM_INTF_META_GEOMETRIC_MODE, metadata);
        case CAM_INTF_META_GEOMETRIC_STRENGTH:
            return POINTER_OF_META(CAM_INTF_META_GEOMETRIC_STRENGTH, metadata);
        case CAM_INTF_META_LENS_SHADING_MAP_MODE:
            return POINTER_OF_META(CAM_INTF_META_LENS_SHADING_MAP_MODE, metadata);
        case CAM_INTF_META_SHADING_STRENGTH:
            return POINTER_OF_META(CAM_INTF_META_SHADING_STRENGTH, metadata);
        case CAM_INTF_META_TONEMAP_MODE:
            return POINTER_OF_META(CAM_INTF_META_TONEMAP_MODE, metadata);
        case CAM_INTF_META_AWB_INFO:
            return POINTER_OF_META(CAM_INTF_META_AWB_INFO, metadata);
        case CAM_INTF_META_FOCUS_POSITION:
            return POINTER_OF_META(CAM_INTF_META_FOCUS_POSITION, metadata);
        case CAM_INTF_META_STREAM_ID:
            return POINTER_OF_META(CAM_INTF_META_STREAM_ID, metadata);
        case CAM_INTF_PARM_STATS_DEBUG_MASK:
            return POINTER_OF_META(CAM_INTF_PARM_STATS_DEBUG_MASK, metadata);
        case CAM_INTF_PARM_STATS_AF_PAAF:
            return POINTER_OF_META(CAM_INTF_PARM_STATS_AF_PAAF, metadata);
        case CAM_INTF_PARM_FOCUS_BRACKETING:
            return POINTER_OF_META(CAM_INTF_PARM_FOCUS_BRACKETING, metadata);
        case CAM_INTF_PARM_FLASH_BRACKETING:
            return POINTER_OF_META(CAM_INTF_PARM_FLASH_BRACKETING, metadata);
        case CAM_INTF_META_JPEG_GPS_COORDINATES:
            return POINTER_OF_META(CAM_INTF_META_JPEG_GPS_COORDINATES, metadata);
        case CAM_INTF_META_JPEG_GPS_PROC_METHODS:
            return POINTER_OF_META(CAM_INTF_META_JPEG_GPS_PROC_METHODS, metadata);
        case CAM_INTF_META_JPEG_GPS_TIMESTAMP:
            return POINTER_OF_META(CAM_INTF_META_JPEG_GPS_TIMESTAMP, metadata);
        case CAM_INTF_META_JPEG_ORIENTATION:
            return POINTER_OF_META(CAM_INTF_META_JPEG_ORIENTATION, metadata);
        case CAM_INTF_META_JPEG_QUALITY:
            return POINTER_OF_META(CAM_INTF_META_JPEG_QUALITY, metadata);
        case CAM_INTF_META_JPEG_THUMB_QUALITY:
            return POINTER_OF_META(CAM_INTF_META_JPEG_THUMB_QUALITY, metadata);
        case CAM_INTF_META_JPEG_THUMB_SIZE:
            return POINTER_OF_META(CAM_INTF_META_JPEG_THUMB_SIZE, metadata);
        case CAM_INTF_META_TEST_PATTERN_DATA:
            return POINTER_OF_META(CAM_INTF_META_TEST_PATTERN_DATA, metadata);
        case CAM_INTF_META_PROFILE_TONE_CURVE:
            return POINTER_OF_META(CAM_INTF_META_PROFILE_TONE_CURVE, metadata);
        case CAM_INTF_META_OTP_WB_GRGB:
            return POINTER_OF_META(CAM_INTF_META_OTP_WB_GRGB, metadata);
        case CAM_INTF_PARM_CAC:
            return POINTER_OF_META(CAM_INTF_PARM_CAC, metadata);
        case CAM_INTF_META_NEUTRAL_COL_POINT:
            return POINTER_OF_META(CAM_INTF_META_NEUTRAL_COL_POINT, metadata);
        case CAM_INTF_PARM_CDS_MODE:
            return POINTER_OF_META(CAM_INTF_PARM_CDS_MODE, metadata);
        case CAM_INTF_PARM_ROTATION:
          return POINTER_OF_META(CAM_INTF_PARM_ROTATION, metadata);
        default:
            return NULL;
    }
}
/*===========================================================================
 * FUNCTION   : doReprocessOffline
 *
 * DESCRIPTION: request to do offline reprocess on the frame
 *
 * PARAMETERS :
 *   @frame   : frame to be performed a reprocess
 *
 * RETURN     : int32_t type of status
 *              NO_ERROR  -- success
 *              none-zero failure code
 *==========================================================================*/
int32_t QCameraReprocessChannel::doReprocessOffline(
                mm_camera_super_buf_t *frame)
{
    int32_t rc = 0;
    OfflineBuffer mappedBuffer;

    if (m_numStreams < 1) {
        ALOGE("%s: No reprocess stream is created", __func__);
        return -1;
    }
    if (m_pSrcChannel == NULL) {
        ALOGE("%s: No source channel for reprocess", __func__);
        return -1;
    }

    if (frame == NULL) {
        ALOGE("%s: Invalid source frame", __func__);
        return BAD_VALUE;
    }

    // find meta data stream and index of meta data frame in the superbuf
    uint8_t meta_buf_index = -1;
    mm_camera_buf_def_t *meta_buf = NULL;
    QCameraStream *pStream = NULL;
    for (int i = 0; i < frame->num_bufs; i++) {
        pStream = m_pSrcChannel->getStreamByHandle(frame->bufs[i]->stream_id);
        if (pStream != NULL) {
            if (pStream->isTypeOf(CAM_STREAM_TYPE_METADATA)) {
                meta_buf = frame->bufs[i];
                break;
            }
        }
    }

    for (int i = 0; i < frame->num_bufs; i++) {
        pStream = getStreamBySrouceHandle(frame->bufs[i]->stream_id);
        if (pStream != NULL) {
            if (pStream->isTypeOf(CAM_STREAM_TYPE_METADATA)) {
                continue;
            }

            meta_buf_index = 0;
            if (NULL != meta_buf) {
                rc = pStream->mapBuf(CAM_MAPPING_BUF_TYPE_OFFLINE_META_BUF,
                                     meta_buf_index,
                                     -1,
                                     meta_buf->fd,
                                     meta_buf->frame_len);
                if (NO_ERROR != rc ) {
                    ALOGE("%s : Error during metadata buffer mapping",
                          __func__);
                    break;
                }
            }
            mappedBuffer.index = meta_buf_index;
            mappedBuffer.stream = pStream;
            mappedBuffer.type = CAM_MAPPING_BUF_TYPE_OFFLINE_META_BUF;
            mOfflineBuffers.push_back(mappedBuffer);

            int buf_index = 1;
            rc = pStream->mapBuf(CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF,
                                 buf_index,
                                 -1,
                                 frame->bufs[i]->fd,
                                 frame->bufs[i]->frame_len);
            if (NO_ERROR != rc ) {
                ALOGE("%s : Error during reprocess input buffer mapping",
                      __func__);
                break;
            }
            mappedBuffer.index = buf_index;
            mappedBuffer.stream = pStream;
            mappedBuffer.type = CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF;
            mOfflineBuffers.push_back(mappedBuffer);

            cam_stream_parm_buffer_t param;
            memset(&param, 0, sizeof(cam_stream_parm_buffer_t));
            param.type = CAM_STREAM_PARAM_TYPE_DO_REPROCESS;
            param.reprocess.buf_index = buf_index;
            param.reprocess.frame_pp_config.uv_upsample =
                            frame->bufs[i]->is_uv_subsampled;
            if (NULL != meta_buf) {
                // we have meta data sent together with reprocess frame
                param.reprocess.meta_present = 1;
                param.reprocess.meta_buf_index = meta_buf_index;
                uint32_t stream_id = frame->bufs[i]->stream_id;
                QCameraStream *srcStream =
                        m_pSrcChannel->getStreamByHandle(stream_id);
                metadata_buffer_t *pMetaData =
                        (metadata_buffer_t *)meta_buf->buffer;
                if (NULL != pMetaData) {
                    cam_crop_data_t *crop = NULL;
                    if (IS_META_AVAILABLE(CAM_INTF_META_CROP_DATA, pMetaData)) {
                        crop = (cam_crop_data_t *)
                            POINTER_OF_META(CAM_INTF_META_CROP_DATA, pMetaData);
                    }

                    if ((NULL != crop) && (NULL != srcStream)) {
                        for (int j = 0; j < MAX_NUM_STREAMS; j++) {
                            if (crop->crop_info[j].stream_id ==
                                            srcStream->getMyServerID()) {
                                param.reprocess.frame_pp_config.crop.crop_enabled = 1;
                                param.reprocess.frame_pp_config.crop.input_crop =
                                        crop->crop_info[j].crop;
                                break;
                            }
                        }
                    }
                }
            }
            rc = pStream->setParameter(param);
            if (rc != NO_ERROR) {
                ALOGE("%s: stream setParameter for reprocess failed",
                      __func__);
                break;
            }
        }
    }
    return rc;
}
示例#4
0
/** process_meta_data
 *
 *  Arguments:
 *   @p_meta : ptr to metadata
 *   @exif_info: Exif info struct
 *   @mm_jpeg_exif_params: exif params
 *
 *  Return     : int32_t type of status
 *               NO_ERROR  -- success
 *              none-zero failure code
 *
 *  Description:
 *       Extract exif data from the metadata
 **/
int process_meta_data(metadata_buffer_t *p_meta, QOMX_EXIF_INFO *exif_info,
  mm_jpeg_exif_params_t *p_cam_exif_params, cam_hal_version_t hal_version)
{
  int rc = 0;
  cam_sensor_params_t p_sensor_params;
  cam_3a_params_t p_3a_params;
  cam_auto_scene_t *scene_cap_type;

  if (!p_meta) {
    ALOGE("%s %d:Meta data is NULL", __func__, __LINE__);
    return 0;
  }

  memset(&p_3a_params,  0,  sizeof(cam_3a_params_t));
  memset(&p_sensor_params, 0, sizeof(cam_sensor_params_t));

  if (hal_version == CAM_HAL_V1) {
    if (p_cam_exif_params) {
      p_sensor_params = p_cam_exif_params->sensor_params;
      p_3a_params = p_cam_exif_params->cam_3a_params;
    } else {
      p_sensor_params.focal_length = 0;
      p_sensor_params.f_number = 0;
      p_sensor_params.sensing_method = 1;
      p_sensor_params.crop_factor = 0;
      p_3a_params.exp_time = 0.0;
      p_3a_params.iso_value = 0;
      p_3a_params.metering_mode = 0;
      p_3a_params.exposure_program = 0;
      p_3a_params.exposure_mode = 255;
      p_3a_params.scenetype = 1;
      p_3a_params.brightness = 0.0;
    }

  } else {
    /* Process 3a data */
    int32_t *iso =
      (int32_t *)POINTER_OF_META(CAM_INTF_META_SENSOR_SENSITIVITY, p_meta);
    if (NULL != iso) {
      p_3a_params.iso_value= *iso;
    } else {
      ALOGE("%s: Cannot extract Iso value", __func__);
    }

    int64_t *sensor_exposure_time =
      (int64_t *)POINTER_OF_META(CAM_INTF_META_SENSOR_EXPOSURE_TIME, p_meta);
    if (NULL != sensor_exposure_time) {
      p_3a_params.exp_time = (double)(*sensor_exposure_time / 1000000000.0);
    } else {
      ALOGE("%s: Cannot extract Exp time value", __func__);
    }

    cam_wb_mode_type *wb_mode =
      (cam_wb_mode_type *)POINTER_OF_META(CAM_INTF_PARM_WHITE_BALANCE, p_meta);
    if (NULL != wb_mode) {
      p_3a_params.wb_mode = *wb_mode;
    } else {
      ALOGE("%s: Cannot extract white balance mode", __func__);
    }

    /* Process sensor data */
    float *aperture = (float *)POINTER_OF_META(CAM_INTF_META_LENS_APERTURE, p_meta);
    if (NULL != aperture) {
      p_sensor_params.aperture_value = *aperture;
    } else {
      ALOGE("%s: Cannot extract Aperture value", __func__);
    }

    uint8_t *flash_mode = (uint8_t *) POINTER_OF_META(CAM_INTF_META_FLASH_MODE, p_meta);
    if (NULL != flash_mode) {
      p_sensor_params.flash_mode = *flash_mode;
    } else {
      ALOGE("%s: Cannot extract flash mode value", __func__);
    }

    uint8_t *flash_state =
      (uint8_t *) POINTER_OF_META(CAM_INTF_META_FLASH_STATE, p_meta);
    if (NULL != flash_state) {
      p_sensor_params.flash_state = *flash_state;
    } else {
      ALOGE("%s: Cannot extract flash state value", __func__);
    }
  }
  rc = process_3a_data(&p_3a_params, exif_info);
  if (rc) {
    ALOGE("%s %d: Failed to add 3a exif params", __func__, __LINE__);
  }

  rc = process_sensor_data(&p_sensor_params, exif_info);
  if (rc) {
      ALOGE("%s %d: Failed to extract sensor params", __func__, __LINE__);
  }
  short val_short;
  scene_cap_type =
    (cam_auto_scene_t *)POINTER_OF_META(CAM_INTF_META_ASD_SCENE_CAPTURE_TYPE, p_meta);
  if(scene_cap_type != NULL)
  val_short = (short) *scene_cap_type;
  else val_short = 0;
  rc = addExifEntry(exif_info, EXIFTAGID_SCENE_CAPTURE_TYPE, EXIF_SHORT,
    sizeof(val_short)/2, &val_short);
  if (rc) {
    ALOGE("%s:%d]: Error adding ASD Exif Entry", __func__, __LINE__);
  }

  /* set orientation to ORIENTATION_UNDEFINED */
  int16_t orientation = 0;
  rc = addExifEntry(exif_info, EXIFTAGID_ORIENTATION,
                    EXIF_SHORT,
                    1,
                    (void *)&orientation);
  if (rc) {
    ALOGE("%s:%d]: Error adding Exif Entry Orientation",
      __func__, __LINE__);
  }

  return rc;
}