/** process_meta_data_v1:
 *
 *  Arguments:
 *   @p_meta : ptr to metadata
 *   @exif_info: Exif info struct
 *
 *  Return     : int32_t type of status
 *               NO_ERROR  -- success
 *              none-zero failure code
 *
 *  Description:
 *       process awb debug info
 *
 **/
int process_meta_data_v1(cam_metadata_info_t *p_meta, QOMX_EXIF_INFO *exif_info,
  mm_jpeg_exif_params_t *p_cam_exif_params)
{
  int rc = 0;

  if (!p_meta) {
    ALOGE("%s %d:Meta data is NULL", __func__, __LINE__);
    return 0;
  }
  cam_ae_params_t *p_ae_params = p_meta->is_ae_params_valid ?
    &p_meta->ae_params : NULL;

  if (NULL != p_ae_params) {
    rc = process_3a_data(p_ae_params, exif_info);
    if (rc) {
      ALOGE("%s %d: Failed to extract 3a params", __func__, __LINE__);
    }
  }
  cam_sensor_params_t *p_sensor_params = p_meta->is_sensor_params_valid ?
    &p_meta->sensor_params : NULL;

  if (NULL != p_sensor_params) {
    rc = process_sensor_data(p_sensor_params, exif_info);
    if (rc) {
      ALOGE("%s %d: Failed to extract sensor params", __func__, __LINE__);
    }
  }
  return rc;
}
/** processMetaData:
 *
 *  Arguments:
 *   @p_meta : ptr to metadata
 *   @exif_info: Exif info struct
 *
 *  Return     : int32_t type of status
 *               NO_ERROR  -- success
 *              none-zero failure code
 *
 *  Description:
 *       process awb debug info
 *
 *  Notes: this needs to be filled for the metadata
 **/
int process_meta_data(cam_metadata_info_t *p_meta, QOMX_EXIF_INFO *exif_info,
  mm_jpeg_exif_params_t *p_cam_exif_params)
{
  int rc = 0;

  if (!p_meta) {
    ALOGE("%s %d:Meta data is NULL", __func__, __LINE__);
    return 0;
  }
  cam_ae_params_t *p_ae_params = p_meta->is_ae_params_valid ?
    &p_meta->ae_params : &p_cam_exif_params->ae_params;

  cam_awb_params_t *p_awb_params = p_meta->is_awb_params_valid ?
    &p_meta->awb_params : &p_cam_exif_params->awb_params;

  cam_auto_focus_data_t *p_focus_data = p_meta->is_focus_valid ?
    &p_meta->focus_data : &p_cam_exif_params->af_params;

  if(p_cam_exif_params->sensor_params.sens_type != CAM_SENSOR_YUV) {
      rc = process_3a_data(p_ae_params, p_awb_params, p_focus_data, exif_info);
      if (rc) {
        ALOGE("%s %d: Failed to extract 3a params", __func__, __LINE__);
      }
  }

  cam_sensor_params_t *p_sensor_params = p_meta->is_sensor_params_valid ?
    &p_meta->sensor_params : &p_cam_exif_params->sensor_params;

  if (NULL != p_sensor_params) {
    rc = process_sensor_data(p_sensor_params, exif_info, p_cam_exif_params);
    if (rc) {
      ALOGE("%s %d: Failed to extract sensor params", __func__, __LINE__);
    }
  }

  /* Scene Capture Type */
  short val_short;
  cam_auto_scene_t *scene_cap_type = p_meta->is_asd_decision_valid ?
          &p_meta->scene : &p_cam_exif_params->scene;
  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__);
  }
  return rc;
}
示例#3
0
/* Processes data packets received from the Gumstix
*/
void process_data_packet( void )
{
    uint8_t  packet[ COMM_BUF_SIZE ], size;
    uint16_t checksum;

    /* get data from serial or parallel interface */
    if( serial_get_data( packet ) )//&& parallel_get_data( packet ) )
    {
        return;
    }

    /* check for valid packet content */
    size = packet[1] + COMM_OVERHEAD - 2;
    checksum = (packet[ size-2 ] << 8) | packet[ size-1 ];
    size -= 2;

    /* iterate over payload */
    while( size-- )
    {
        checksum -= packet[ size ];
    }

    /* check for non-zero checksum */
    if( checksum )
    {
        return;
    }

    /* call packet-dependent function */
    switch( packet[0] )
    {
        case COMM_SENSOR_DATA:
            process_sensor_data( packet + 2, packet[1] );
            break;

        case COMM_MOTOR_SIGNALS:
            process_motor_signals( packet + 2, packet[1] );
            break;

        case COMM_SWITCH_STATE:
            process_state_switch( );
            break;

        case COMM_SHUT_DOWN:
            process_shut_down( );
            break;

        default:
            return;
    }
}
示例#4
0
/* Processes data packets received from Robostix 1
*/
void process_data_packet( void )
{
    uint8_t  packet[ COMM_BUF_SIZE ], size;
    uint16_t checksum;

    /* get data from parallel interface */
    if( parallel_get_data( packet ) )
    {
        return;
    }

    /* check for valid packet content */
    size = packet[1] + COMM_OVERHEAD - 2;
    checksum = (packet[ size-2 ] << 8) | packet[ size-1 ];
    size -= 2;

    /* iterate over payload */
    while( size-- )
    {
        checksum -= packet[ size ];
    }

    /* check for non-zero checksum */
    if( checksum )
    {
        return;
    }

    /* call packet-dependent function */
    switch( packet[0] )
    {
        case COMM_SENSOR_DATA:
            process_sensor_data( packet + 2, packet[1] );
            break;

        default:
            return;
    }
}
/** process_meta_data_v3:
 *
 *  Arguments:
 *   @p_meta : ptr to metadata
 *   @exif_info: Exif info struct
 *
 *  Return     : int32_t type of status
 *               NO_ERROR  -- success
 *              none-zero failure code
 *
 *  Description:
 *       Extract exif data from the metadata
 **/
int process_meta_data_v3(metadata_buffer_t *p_meta, QOMX_EXIF_INFO *exif_info,
  mm_jpeg_exif_params_t *p_cam_exif_params)
{
  int rc = 0;
  cam_sensor_params_t p_sensor_params;
  cam_ae_params_t p_ae_params;

  if (!p_meta) {
    ALOGE("%s %d:Meta data is NULL", __func__, __LINE__);
    return 0;
  }
  int32_t *iso =
    (int32_t *)POINTER_OF(CAM_INTF_META_SENSOR_SENSITIVITY, p_meta);

  int64_t *sensor_exposure_time =
    (int64_t *)POINTER_OF(CAM_INTF_META_SENSOR_EXPOSURE_TIME, p_meta);

  memset(&p_ae_params,  0,  sizeof(cam_ae_params_t));
  if (NULL != iso) {
    p_ae_params.iso_value= *iso;
  } else {
    ALOGE("%s: Cannot extract Iso value", __func__);
  }

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

  rc = process_3a_data(&p_ae_params, exif_info);
  if (rc) {
    ALOGE("%s %d: Failed to add 3a exif params", __func__, __LINE__);
  }

  float *aperture = (float *)POINTER_OF(CAM_INTF_META_LENS_APERTURE, p_meta);

  uint8_t *flash_mode = (uint8_t *) POINTER_OF(CAM_INTF_META_FLASH_MODE, p_meta);
  uint8_t *flash_state =
    (uint8_t *) POINTER_OF(CAM_INTF_META_FLASH_STATE, p_meta);

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

  if (NULL != aperture) {
     p_sensor_params.aperture_value = *aperture;
  } else {
    ALOGE("%s: Cannot extract Aperture value", __func__);
  }

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

  if (NULL != flash_state) {
    p_sensor_params.flash_state = *flash_state;
  } else {
    ALOGE("%s: Cannot extract flash state value", __func__);
  }

  rc = process_sensor_data(&p_sensor_params, exif_info);
  if (rc) {
      ALOGE("%s %d: Failed to extract sensor params", __func__, __LINE__);
  }

  return rc;
}
示例#6
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;
}