/** sonyimx135_format_wbdata_internal:
 *    @e_ctrl: address of pointer to
 *                   chromatix struct
 *    @WB_START_OFFSET: start offset of page in eeprom memory
 *
 * Reads out White Balance calibration data from eeprom and calibrates sensor
 *  This function is called by sonyimx135_format_wbdata
 *
 * Return:
 * void
 **/
void sonyimx135_format_wbdata_internal( sensor_eeprom_data_t *e_ctrl,
        uint32_t WB_START_OFFSET )
{
  int index;
  float awb_r_over_gr, awb_b_over_gr, awb_gb_over_gr;
  bLscAwbValid = TRUE;

  awb_r_over_gr =(float)((float)
    ((uint16_t)((e_ctrl->eeprom_params.buffer[WB_START_OFFSET] << 8) |
    (e_ctrl->eeprom_params.buffer[WB_START_OFFSET+ 1])) ) / ((float) QVALUE));

  awb_b_over_gr = (float)((float)
    ((uint16_t)((e_ctrl->eeprom_params.buffer[WB_START_OFFSET + 2] << 8) |
    (e_ctrl->eeprom_params.buffer[WB_START_OFFSET+ 3])) ) / ((float) QVALUE));

  awb_gb_over_gr = (float)((float)
    ((uint16_t)((e_ctrl->eeprom_params.buffer[WB_START_OFFSET + 4] << 8) |
    (e_ctrl->eeprom_params.buffer[WB_START_OFFSET+ 5])) ));


  if ( awb_gb_over_gr != 0 ) {

    e_ctrl->eeprom_data.wbc.gr_over_gb = ((float) ((float) (QVALUE) /
      (float)awb_gb_over_gr));

  } else {

    e_ctrl->eeprom_data.wbc.gr_over_gb = 1.0f;

  }

  for ( index = 0; index < AGW_AWB_MAX_LIGHT; index++ ) {

    e_ctrl->eeprom_data.wbc.r_over_g[index] =
      (float) (awb_r_over_gr);

    e_ctrl->eeprom_data.wbc.b_over_g[index] =
      (float) (awb_b_over_gr);

  }

  SHIGH("r_over_g \tb_over_g\tgr_over_gb");

  for ( index = 0; index < AGW_AWB_MAX_LIGHT; index++ ) {
    SHIGH("R_G: %f\t\t B_G: %f\t\t GR_GB: %f",
      e_ctrl->eeprom_data.wbc.r_over_g[index],
      e_ctrl->eeprom_data.wbc.b_over_g[index],
      e_ctrl->eeprom_data.wbc.gr_over_gb);
  }
}
/** sonyimx135_get_calibration_items:
 *    @e_ctrl: address of pointer to
 *                   chromatix struct
 *
 * Loads data structure for enabling / disabling parameters that can be
 * calibrated
 *
 * Return:
 * void
 **/
void sonyimx135_get_calibration_items( void *e_ctrl )
{
  sensor_eeprom_data_t *ectrl = (sensor_eeprom_data_t *)e_ctrl;
  eeprom_calib_items_t *e_items = &(ectrl->eeprom_data.items);
  e_items->is_afc = TRUE;

  if(TRUE == bLscAwbValid){
    e_items->is_wbc = TRUE;
    e_items->is_lsc = TRUE;
    SHIGH("WBC and LSC Available and loaded");
  } else {
    e_items->is_wbc = FALSE;
    e_items->is_lsc = FALSE;
    SHIGH("WBC and LSC UNavailable and not loaded");
  }
  e_items->is_dpc = FALSE;
}
Пример #3
0
int main(void)
{
	short var = 0x1234;
	printf("low = %x\n", SLOW(var));
	printf("low = %#x\n", SLOW(var));
	printf("high = %#x\n", SHIGH(var));
	printf("SSWAP = %#x\n", SSWAP(var));

	return 0;
}
Пример #4
0
boolean sensor_init_probe(module_sensor_ctrl_t *module_ctrl)
{
    int32_t                     rc = 0, dev_fd = 0, sd_fd = 0;
    uint32_t                    i = 0;
    struct media_device_info    mdev_info;
    int32_t                     num_media_devices = 0;
    char                        dev_name[32];
    char                        subdev_name[32];
    struct sensor_init_cfg_data cfg;
    boolean                     ret = TRUE;

    while (1) {
        int32_t num_entities = 1;
        snprintf(dev_name, sizeof(dev_name), "/dev/media%d", num_media_devices);
        dev_fd = open(dev_name, O_RDWR | O_NONBLOCK);
        if (dev_fd < 0) {
            SLOW("Done enumerating media devices");
            break;
        }
        num_media_devices++;
        rc = ioctl(dev_fd, MEDIA_IOC_DEVICE_INFO, &mdev_info);
        if (rc < 0) {
            SLOW("Done enumerating media devices");
            close(dev_fd);
            break;
        }

        if (strncmp(mdev_info.model, "msm_config", sizeof(mdev_info.model) != 0)) {
            close(dev_fd);
            continue;
        }

        while (1) {
            struct media_entity_desc entity;
            memset(&entity, 0, sizeof(entity));
            entity.id = num_entities++;
            SLOW("entity id %d", entity.id);
            rc = ioctl(dev_fd, MEDIA_IOC_ENUM_ENTITIES, &entity);
            if (rc < 0) {
                SLOW("Done enumerating media entities");
                rc = 0;
                break;
            }
            SLOW("entity name %s type %d group id %d",
                 entity.name, entity.type, entity.group_id);
            if (entity.type == MEDIA_ENT_T_V4L2_SUBDEV &&
                    entity.group_id == MSM_CAMERA_SUBDEV_SENSOR_INIT) {
                snprintf(subdev_name, sizeof(dev_name), "/dev/%s", entity.name);
                break;
            }
        }
        close(dev_fd);
    }

    /* Open sensor_init subdev */
    sd_fd = open(subdev_name, O_RDWR);
    if (sd_fd < 0) {
        SHIGH("Open sensor_init subdev failed");
        return FALSE;
    }

    /* Open sensor libraries and get init information */
    for (i = 0; i < ARRAY_SIZE(sensor_libs); i++) {
        ret = sensor_probe(sd_fd, sensor_libs[i]);
        if (ret == FALSE) {
            SERR("failed: to load %s", sensor_libs[i]);
        }
    }

    cfg.cfgtype = CFG_SINIT_PROBE_DONE;
    if (ioctl(sd_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &cfg) < 0) {
        SERR("failed");
        ret = FALSE;
    }
    close(sd_fd);

    return TRUE;
}