⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 camsensor_ov9650.c

📁 OV9650 settings on Qualcomm
💻 C
📖 第 1 页 / 共 5 页
字号:
  camsensor_params->epoch_line = 10000;
#endif

  return TRUE;

} /* camsensor_ov9650_snapshot_config */

/*===========================================================================

FUNCTION      CAMSENSOR_OV9650_RAW_SNAPSHOT_CONFIG

DESCRIPTION
              Configure the camera sensor and the VFE_CAMIF for
              raw snapshot mode

DEPENDENCIES
  None

RETURN VALUE
  TRUE if successful
  FALSE otherwise

SIDE EFFECTS
  None

===========================================================================*/

boolean camsensor_ov9650_raw_snapshot_config
(
  camsensor_static_params_type *camsensor_params /* Other config params */
) 
{
  /* Select discard first frame. */
  camsensor_params->discardFirstFrame = TRUE;

  /* CAMIF frame */
  camsensor_params->camif_frame_config.pixelsPerLine = camsensor_params->full_size_width;
  camsensor_params->camif_frame_config.linesPerFrame = camsensor_params->full_size_height;

  /* CAMIF window */
  camsensor_params->camif_window_width_config.firstPixel = 0;
  camsensor_params->camif_window_width_config.lastPixel  = camsensor_params->camif_frame_config.pixelsPerLine - 1;
  camsensor_params->camif_window_height_config.firstLine = 0;
  camsensor_params->camif_window_height_config.lastLine  = camsensor_params->camif_frame_config.linesPerFrame - 1;

#ifdef FEATURE_STROBE_FLASH  
  camsensor_params->camif_epoch_intr.epoch_line = 1192;
#else
  /* Disable the Epoch Interrupt by setting more
   * number of lines than in a frame */
  camsensor_params->epoch_line = 10000;
#endif

  return TRUE;
} /* camsensor_ov9650_raw_snapshot_config */


/*===========================================================================

FUNCTION      CAMSENSOR_OV9650_VIDEO_CONFIG

DESCRIPTION
              Configure the camera sensor and the camera interface
              for Preview mode.

DEPENDENCIES
  None

RETURN VALUE
  TRUE if successful
  FALSE otherwise

SIDE EFFECTS
  None

===========================================================================*/

boolean camsensor_ov9650_video_config
(
  camsensor_static_params_type *camsensor_params  /* Other config params             */
)
{
  /* Sensor output data format */
  camsensor_params->format = CAMIF_BAYER_B_G;

  /* Select 3x3 luma filter */
  camsensor_params->f3x3LumaFilter.enable = TRUE;
 
  /* CAMIF frame */
  camsensor_params->camif_frame_config.linesPerFrame = camsensor_params->camsensor_height;
  camsensor_params->camif_frame_config.pixelsPerLine = camsensor_params->camsensor_width;

  /* CAMIF window */
  camsensor_params->camif_window_width_config.firstPixel = 0;
  camsensor_params->camif_window_width_config.lastPixel  = camsensor_params->camif_frame_config.pixelsPerLine - 1;
  camsensor_params->camif_window_height_config.firstLine = 0;
  camsensor_params->camif_window_height_config.lastLine  = camsensor_params->camif_frame_config.linesPerFrame - 1; 

  /* Disable the Epoch Interrupt by setting more
   * number of lines than in a frame */
  camsensor_params->epoch_line = 10000;

  return TRUE;
} /* camsensor_ov9650_video_config */


/*===========================================================================

FUNCTION      CAMSENSOR_OV9650_POWER_UP

DESCRIPTION
              Power up the sensor.

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None

===========================================================================*/

void camsensor_ov9650_power_up(void)
{
} /* camsensor_ov9650_power_up */


/*===========================================================================

FUNCTION      camsensor_ov9650_POWER_DOWN

DESCRIPTION
              Power down the sensor, using I2C driver.

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None

===========================================================================*/

void camsensor_ov9650_power_down(void)
{
  boolean rc;

  rc = TRUE;

  rc = rc && ov9650_write_register(OFON_REG_ADDRESS, OFON_REG_LINE_BUFFER_PWDN_VALUE);
  rc = rc && ov9650_write_register(COM2_REG_ADDRESS, COM2_REG_SOFT_SLEEP_MODE_VALUE);

  if (rc == FALSE)
  {
    MSG_HIGH("I2C write failure while powering down the OV9650 sensor", 0, 0, 0);
  }
  
  /* Wait for the sensor to get into power saving state. */
  camera_timed_wait(SENSOR_STANDBY_DELAY_MSECS);  
  
  /*
   * Shut off the sensor clock.
   */
  camsensor_unconfig_camclk_po();

} /* camsensor_ov9650_power_down */



/*===========================================================================

FUNCTION      CAMSENSOR_OV9650_WRITE_EXPOSURE_GAIN

DESCRIPTION   Update exposure gain on sensor

DEPENDENCIES
  None

INPUT
  uint16 gain - New sensor gain value
  uint32 line - New sensor exposure time in multiples of line time.
  
RETURN VALUE
  CAMERA_SUCCESS - if no error comes back from I2C
  CAMERA_FAILED  - if I2C reported an error

SIDE EFFECTS
  None

COMMENTS:
  The sensor's exposure time is 16 bits long, so only the lower 16 bits of
  the 'line' parameter are considered. The rest are ignored.

  The sensor 10-bit gain value is stored the following registers:
    Bits [7:0] - In the GAIN register.
    Bits [9:8] - In the VREF register, bits [7:6].

  The sensor 16-bit exposure time value is stored in the follwing registers:
    Bits [1:0]   - In the COM1 register, bits [1:0].
    Bits [9:2]   - In the AECH register.
    Bits [15:10] - In the AECHM register, bits [5:0].

===========================================================================*/
camera_ret_code_type camsensor_ov9650_write_exposure_gain(uint16 gain, uint32 line)
{
  float real_gain, temp_const;

  MSG_HIGH("OV9650 Exposure Gain - before: gain=%d, line=%d", gain, line, 0);

  //
  // The OV9650 sensor drops frames when the current line number is more 
  // than 15 than the previous line number. The following algorithm prevent line from 
  // increasing in a more than 15 step. It changes the gain for compensation.
  //
  if (line > (previous_line + MAX_LINE_STEP))
  {
	  // 1. Find out the real gain:
      real_gain = camsensor_ov9650_register_to_real_gain(gain);
	  
	  // 2. real_gain * line = a temporary constant:
	  temp_const = real_gain * (float)line;
	  
	  // 3. Now change the line according to the maximum step allowed:
	  line = previous_line + MAX_LINE_STEP;

	  // 4. Recall: real_gain * line = a temporary constant, therefore:
	  real_gain = temp_const/((float)line);

	  // 5. Now compensate the gain:
	  gain = camsensor_ov9650_real_to_register_gain(real_gain);
  }

  //
  // Now write the gain and line:
  //
  MSG_HIGH("OV9650 Exposure Gain - after: gain=%d, line=%d", gain, line, 0);
  
  /* Write sensor gain value */
  if (ov9650_write_register(GAIN_REG_ADDRESS, gain & 0x00FF) == FALSE)
  {
    return CAMERA_FAILED;
  }

  if (ov9650_write_register_bit_section(VREF_REG_ADDRESS, gain, 8, 6, 2) == FALSE)
  {
    return CAMERA_FAILED;
  }

  /* Write sensor exposure value */
  if (ov9650_write_register_bit_section(AECH_REG_ADDRESS , line,  2, 0, 8) == FALSE)
  {
    return CAMERA_FAILED;
  }

  if (ov9650_write_register_bit_section(AECHM_REG_ADDRESS, line, 10, 0, 6) == FALSE)
  {
    return CAMERA_FAILED;
  }

  if (ov9650_write_register_bit_section(COM1_REG_ADDRESS , line,  0, 0, 2) == FALSE)
  {
    return CAMERA_FAILED;
  }

  previous_line = line;

  return CAMERA_SUCCESS;
} /* camsensor_ov9650_write_exposure_gain */


/*===========================================================================

FUNCTION      CAMSENSOR_OV9650_SET_DEFAULT_FOCUS

DESCRIPTION
  Move focus to location best suited to any subject: at the nearest 
  point where infinity is still in focus.
  specified.

  This API is currently not supported by this sensor.

DEPENDENCIES
  None

RETURN VALUE
  CAMERA_SUCCESS              - if no error comes back from I2C
  CAMERA_FOCUS_SENSOR_FAILED  - if I2C reported an error

SIDE EFFECTS
  None

===========================================================================*/

camera_ret_code_type camsensor_ov9650_set_default_focus(void)
{

   camera_ret_code_type  ret_val = CAMERA_NOT_SUPPORTED;

   return ret_val;
} /* camsensor_ov9650_set_default_focus */


/*===========================================================================

FUNCTION      CAMSENSOR_OV9650_MOVE_FOCUS

DESCRIPTION
  Move focus either near or toward infinity the number of steps
  specified.

  This API is currently not supported by this sensor.

DEPENDENCIES
  None

INPUT
  camsensor_move_focus_enum_type: - either of the two following

    CAMSENSOR_MOVE_FOCUS_NEAR - moves to near end for closer objects
    CAMSENSOR_MOVE_FOCUS_FAR - moves to the far end for more distant objs

  int32 num_steps - Number of steps to move focal motor

RETURN VALUE
  CAMERA_SUCCESS             - if no error comes back from I2C
  CAMERA_FOCUS_SENSOR_FAILED - if I2C reported an error

SIDE EFFECTS
  None

===========================================================================*/
/*lint -save -e715 This drevier does not support this feature */
camera_ret_code_type camsensor_ov9650_move_focus(camsensor_move_focus_enum_type direction, int32 num_steps)
{
   return CAMERA_NOT_SUPPORTED;
} /* camsensor_ov9650_move_focus */
/*lint -restore */

/*===========================================================================

FUNCTION   CAMSENSOR_OV9650_REGISTER 

DESCRIPTION  
  Exports the sensor specific functions to SENSOR

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None

===========================================================================*/
LOCAL void camsensor_ov9650_register (camsensor_function_table_type *camsensor_function_table_ptr)
{
  camsensor_function_table_ptr->camsensor_start                 = camsensor_ov9650_start;
  camsensor_function_table_ptr->camsensor_video_config          = camsensor_ov9650_video_config;
  camsensor_function_table_ptr->camsensor_raw_snapshot_config   = camsensor_ov9650_raw_snapshot_config;
  camsensor_function_table_ptr->camsensor_snapshot_config       = camsensor_ov9650_snapshot_config;
  camsensor_function_table_ptr->camsensor_power_up              = camsensor_ov9650_power_up;
  camsensor_function_table_ptr->camsensor_power_down            = camsensor_ov9650_power_down;
  camsensor_function_table_ptr->camsensor_write_exposure_gain   = camsensor_ov9650_write_exposure_gain;
  camsensor_function_table_ptr->camsensor_set_default_focus     = camsensor_ov9650_set_default_focus;
  camsensor_function_table_ptr->camsensor_move_focus            = camsensor_ov9650_move_focus;
  camsensor_function_table_ptr->camsensor_register_to_real_gain = camsensor_ov9650_register_to_real_gain;
  camsensor_function_table_ptr->camsensor_real_to_register_gain = camsensor_ov9650_real_to_register_gain;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -