Ejemplo n.º 1
0
/*===========================================================================
 * FUNCTION    - test_vector_update_param -
 *
 * DESCRIPTION:
 *==========================================================================*/
vfe_status_t test_vector_update_param(vfe_test_vector_t *mod,
  const char* attribute, const char* value)
{
  vfe_status_t status = VFE_SUCCESS;
  vfe_ctrl_info_t *p_vfe_obj = (vfe_ctrl_info_t *)(mod->vfe_obj);
  vfe_params_t *params = &p_vfe_obj->vfe_params;

  if (!strcmp(AWB_R_GAIN, attribute)) {
    int data = atoi(value);
    CDBG("%s: AWB_r_gain %d", __func__, data);
    mod->params.awb_gains.r_gain = Q_TO_FLOAT(7, data);
  } else if (!strcmp(AWB_G_GAIN, attribute)) {
    int data = atoi(value);
    CDBG("%s: AWB_g_gain %d", __func__, data);
    mod->params.awb_gains.g_gain = Q_TO_FLOAT(7, data);
  } else if (!strcmp(AWB_B_GAIN, attribute)) {
    int data = atoi(value);
    CDBG("%s: AWB_b_gain %d", __func__, data);
    mod->params.awb_gains.b_gain = Q_TO_FLOAT(7, data);
  } else if (!strcmp(AWB_DECISION, attribute)) {
    CDBG("%s: AWB_decision %s", __func__, value);
  } else if (!strcmp(AWB_CCT, attribute)) {
    int data = atoi(value);
    CDBG("%s: AWB_CCT %d", __func__, data);
    mod->params.color_temp = data;
  } else if (!strcmp(LED_ENABLE, attribute)) {
    int data = VFE_TEST_VEC_IS_TRUE(value);
    CDBG("%s: LED_ENABLE %s %d", __func__, value, data);
    mod->params.flash_mode = (data == TRUE) ?
      VFE_FLASH_LED : VFE_FLASH_NONE;
  } else if (!strcmp(STROBE_ENABLE, attribute)) {
    int data = VFE_TEST_VEC_IS_TRUE(value);
    CDBG("%s: STROBE_ENABLE %s %d", __func__, value, data);
    mod->params.flash_mode = (data == TRUE) ?
      VFE_FLASH_STROBE : VFE_FLASH_NONE;
  } else if (!strcmp(LED_SENSITIVITY_OFF, attribute)) {
    float data = atof(value);
    CDBG("%s: LED_SENSITIVITY_OFF %f", __func__, data);
    mod->params.sensitivity_led_off = data;
  } else if (!strcmp(LED_SENSITIVITY_HIGH, attribute)) {
    float data = atof(value);
    CDBG("%s: LED_SENSITIVITY_HIGH %f", __func__, data);
    mod->params.sensitivity_led_hi = data;
  } else if (!strcmp(STROBE_SENSITIVITY_OFF, attribute)) {
    float data = atof(value);
    CDBG("%s: STROBE_SENSITIVITY_OFF %f", __func__, data);
    mod->params.sensitivity_led_off = data;
  } else if (!strcmp(STROBE_SENSITIVITY_HIGH, attribute)) {
    float data = atof(value);
    CDBG("%s: STROBE_SENSITIVITY_HIGH %f", __func__, data);
    mod->params.sensitivity_led_hi= data;
  } else if (!strcmp(LUX_INDEX, attribute)) {
    int data = atoi(value);
    mod->params.lux_idx = data;
    CDBG("%s: LUX_INDEX %d %f", __func__, data, mod->params.lux_idx);
  } else if (!strcmp(TOTAL_GAIN, attribute)) {
    int data = atoi(value);
    /* convert to float */
    CDBG("%s: TOTAL_GAIN %d", __func__, data);
    mod->params.cur_real_gain = Q_TO_FLOAT(8, data);
  } else if (!strcmp(DIGITAL_GAIN, attribute)) {
    int data = atoi(value);
    /* convert to float */
    mod->params.digital_gain = Q_TO_FLOAT(8, data);
    CDBG("%s: DIGITAL_GAIN %d", __func__, data);
  } else if (!strcmp(CAMIF_WIDTH, attribute)) {
    int data = atoi(value);
    CDBG("%s: CAMIF_WIDTH %d", __func__, data);
    mod->camif_size.width = data;
  } else if (!strcmp(CAMIF_HEIGHT, attribute)) {
    int data = atoi(value);
    CDBG("%s: CAMIF_HEIGHT %d", __func__, data);
    mod->camif_size.height = data;
  } else if (!strcmp(OUTPUT_WIDTH, attribute)) {
    int data = atoi(value);
    CDBG("%s: OUTPUT_WIDTH %d", __func__, data);
    mod->output_size.width = data;
  } else if (!strcmp(OUTPUT_HEIGHT, attribute)) {
    int data = atoi(value);
    CDBG("%s: OUTPUT_HEIGHT %d", __func__, data);
    mod->output_size.height = data;
  } else if (!strcmp(FULL_WIDTH, attribute)) {
    int data = atoi(value);
    CDBG("%s: FULL_WIDTH %d", __func__, data);
    mod->full_size.width = data;
  } else if (!strcmp(FULL_HEIGHT, attribute)) {
    int data = atoi(value);
    CDBG("%s: FULL_HEIGHT %d", __func__, data);
    mod->full_size.height = data;
  } else if (!strcmp(AEC_SETTLE, attribute)) {
    CDBG("%s: AEC_SETTLE %s", __func__, value);
  } else if (!strcmp(AEC_CONVERGENCE, attribute)) {
    CDBG("%s: AEC_CONVERGENCE %s", __func__, value);
  } else if (!strcmp(AEC_MAX, attribute)) {
    CDBG("%s: AEC_MAX %s", __func__, value);
  } else if (!strcmp(MODE, attribute)) {
    mod->snapshot_mode = strcmp(PREVIEW, value) ? 1 : 0;
    CDBG("%s: MODE %s %d", __func__, value, mod->snapshot_mode);
    /* change parse mode */
    mod->parse_mode = VFE_TEST_VEC_PARSE_OUTPUT;
  } else if (!strcmp(CASE_NAME, attribute)) {
    CDBG("%s: CASE_NAME %s", __func__, value);
  } else if (!strcmp(CASE_NUMBER, attribute)) {
    CDBG("%s: CASE_NUMBER %s", __func__, value);
  } else {
    CDBG("%s: invalid token %s %s", __func__, attribute, value);
  }
  return status;
}/*test_vector_update_param*/
Ejemplo n.º 2
0
/***** Start of main *****/
int main( int argc, char *argv[] )
{
  //
  // Variables
  //
  ufixed_t u_result;
  sfixed_t s_result;
  float u_f1 = 3.1415926f;
  float u_f2 = 12.3456f;
  float s_f1 = -25.3569f;
  float s_f2 = -234.23f;
  ufixed_t u_fixed1 = UQ_LITERAL( u_f1 );
  ufixed_t u_fixed2 = UQ_LITERAL( u_f2 );
  sfixed_t s_fixed1 = SQ_LITERAL( s_f1 );
  sfixed_t s_fixed2 = SQ_LITERAL( s_f2 );

  //
  // Print fixed point info
  //
  puts( "Fixed-point info: " QFORMAT_STR( IBITS, FBITS ) );
  puts("");
  
  //
  // Unsigned fixed point
  //
  puts( "Unsigned fixed point:" );
  printf( "  UQ_LITERAL(%f) = %u (0x%X.0x%X)\r\n", u_f1, u_fixed1, Q_TO_Z( u_fixed1 ), Q_FRAC( u_fixed1 ) );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", u_fixed1, Q_TO_FLOAT( u_fixed1 ) );
  puts("");

  //
  // Signed fixed point
  //
  puts( "Signed fixed point:" );
  printf( "  SQ_LITERAL(%f) = %u (0x%X.0x%X)\r\n", s_f1, s_fixed1, Q_TO_Z( s_fixed1 ), Q_FRAC( s_fixed1 ) );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_fixed1, Q_TO_FLOAT( s_fixed1 ) );
  puts("");

  //
  // Unsigned addition
  //
  puts( "Unsigned fixed point addition:" );
  u_result = q_uadd( u_fixed1, u_fixed2 );
  printf( "  q_uadd( UQ_LITERAL(%f), UQ_LITERAL(%f) ) = %u (%f)\r\n", u_f1, u_f2, u_result, u_f1 + u_f2 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", u_result, Q_TO_FLOAT( u_result ) );
  puts("");

  //
  // Signed addition
  //
  puts( "Signed fixed point addition:" );
  s_result = q_sadd( u_fixed1, s_fixed1 );
  printf( "  q_sadd( UQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u (%f)\r\n", u_f1, s_f1, s_result, u_f1 + s_f1 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
  puts("");

  //
  // Unsigned subtraction
  //
  puts( "Unsigned fixed point subtraction:" );
  u_result = q_usub( u_fixed2, u_fixed1 );
  printf( "  q_usub( UQ_LITERAL(%f), UQ_LITERAL(%f) ) = %u (%f)\r\n", u_f2, u_f1, u_result, u_f2 - u_f1 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", u_result, Q_TO_FLOAT( u_result ) );
  puts("");

  //
  // Signed subtraction
  //
  puts( "Signed fixed point subtraction:" );
  s_result = q_ssub( s_fixed2, s_fixed1 );
  printf( "  q_ssub( SQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u (%f)\r\n", s_f2, s_f1, s_result, s_f2 - s_f1 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
  puts("");

  //
  // Unsigned multiplication
  //
  puts( "Unsigned fixed point multiplication:" );
  u_result = q_umul( u_fixed1, u_fixed2 );
  printf( "  q_umul( UQ_LITERAL(%f), UQ_LITERAL(%f) ) = %u (%f)\r\n", u_f1, u_f2, u_result, u_f1 * u_f2 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", u_result, Q_TO_FLOAT( u_result ) );
  puts("");

  //
  // Signed multiplication
  //
  puts( "Signed fixed point multiplication:" );
  s_result = q_smul( u_fixed2, s_fixed2 );
  printf( "  q_smul( UQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u (%f)\r\n", u_f2, s_f2, s_result, u_f2 * s_f2 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
  puts("");

  //
  // Unsigned division
  //
  puts( "Unsigned fixed point division:" );
  u_result = q_udiv( u_fixed1, u_fixed2 );
  printf( "  q_udiv( UQ_LITERAL(%f), UQ_LITERAL(%f) ) = %u (%f)\r\n", u_f1, u_f2, u_result, u_f1 / u_f2 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", u_result, Q_TO_FLOAT( u_result ) );
  puts("");

  //
  // Signed division
  //
  puts( "Signed fixed point division:" );
  s_result = q_sdiv( u_fixed2, s_fixed2 );
  printf( "  q_sdiv( UQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u (%f)\r\n", u_f2, s_f2, s_result, u_f2 / s_f2 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
  s_result = q_sdiv( s_fixed2, s_fixed1 );
  printf( "  q_sdiv( SQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u (%f)\r\n", s_f2, s_f1, s_result, s_f2 / s_f1 );
  printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
  puts("");

#if ( defined FIXEDPOINT_INLINE_OP && FIXEDPOINT_INLINE_OP == 0 )
  // 
  // Perform overflow checks
  // 
  puts( "Overflow (unsigned fixed-point addition)" );
  u_result = q_uadd( UFIXED_MAX, u_fixed1 );
  if ( fixedpoint_get_error() == OVERFLOW_OCCURRED_ERROR )
  {
    printf( "  !!! OVERFLOW OCCURED !!!\r\n" );
    printf( "  q_uadd( UQ_LITERAL(%f), UQ_LITERAL(%f) ) = %u\r\n", Q_TO_FLOAT( UFIXED_MAX ), u_f1, u_result );
    printf( "  Q_TO_FLOAT(%u) = %f\r\n", u_result, Q_TO_FLOAT( u_result ) );
    fixedpoint_clear_error();
  }
  else
  {
    printf( "  q_uadd( UQ_LITERAL(%f), UQ_LITERAL(%f) ) = %u\r\n", Q_TO_FLOAT( UFIXED_MAX ), u_f1, u_result );
    printf( "  Q_TO_FLOAT(%u) = %f\r\n", u_result, Q_TO_FLOAT( u_result ) );
  }

  puts( "Overflow (signed fixed-point addition: two positive numbers)" );
  s_result = q_sadd( SFIXED_MAX, u_fixed1 );
  if ( fixedpoint_get_error() == OVERFLOW_OCCURRED_ERROR )
  {
    printf( "  !!! OVERFLOW OCCURED !!!\r\n" );
    printf( "  q_uadd( SQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u\r\n", Q_TO_FLOAT( SFIXED_MAX ), u_f1, s_result );
    printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
    fixedpoint_clear_error();
  }
  else
  {
    printf( "  q_uadd( SQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u\r\n", Q_TO_FLOAT( SFIXED_MAX ), s_f1, s_result );
    printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
  }

  puts( "Overflow (signed fixed-point addition: two negative numbers)" );
  s_result = q_sadd( SFIXED_MIN, s_fixed1 );
  if ( fixedpoint_get_error() == OVERFLOW_OCCURRED_ERROR )
  {
    printf( "  !!! OVERFLOW OCCURED !!!\r\n" );
    printf( "  q_uadd( SQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u\r\n", Q_TO_FLOAT( SFIXED_MIN ), s_f1, s_result );
    printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
    fixedpoint_clear_error();
  }
  else
  {
    printf( "  q_uadd( SQ_LITERAL(%f), SQ_LITERAL(%f) ) = %u\r\n", Q_TO_FLOAT( SFIXED_MIN ), s_f1, s_result );
    printf( "  Q_TO_FLOAT(%u) = %f\r\n", s_result, Q_TO_FLOAT( s_result ) );
  }
#endif

  //
  // Demo done!
  //
  return 0;
}