Exemplo n.º 1
0
/*===========================================================================
 * FUNCTION    - vfe_client_parse_stats -
 *
 * DESCRIPTION:
 *==========================================================================*/
static int vfe_client_parse_stats(uint32_t handle,
  int isp_started, stats_type_t stats_type, void *stats, void *stats_output)
{
  vfe_ctrl_info_t *vfe_ctrl_obj;
  vfe_client_t *vfe_client;
  vfe_op_mode_t op_mode;
  int rc = 0;

  vfe_client = get_vfe_client_info(handle);
  if(!vfe_client) {
    CDBG_ERROR("%s: null vfe client",  __func__);
    return -1;
  }

  rc = vfe_client->vfe_ops.parse_stats(vfe_client, isp_started,
    stats_type, stats, stats_output);
  if(rc < 0) {
    CDBG_ERROR("%s: vfe process failed : %d ", __func__, rc);
    return -1;
  }
  return rc;
}
boolean cpp_module_util_free_buffer_info(void *d1, void *d2)
{
  cpp_module_buffer_info_t      *buffer_info =
    (cpp_module_buffer_info_t *)d1;
  cpp_module_stream_buff_info_t *stream_buff_info =
    (cpp_module_stream_buff_info_t *)d2;

  if (!buffer_info || !stream_buff_info) {
    CDBG_ERROR("%s:%d] error buffer_info:%p stream_buff_info:%p\n", __func__,
      __LINE__, buffer_info, stream_buff_info);
    return FALSE;
  }

  if (stream_buff_info->num_buffs == 0) {
    CDBG_ERROR("%s:%d] error in num of buffs\n", __func__, __LINE__);
    return FALSE;
  }

  free(buffer_info);
  stream_buff_info->num_buffs--;
  return TRUE;
}
Exemplo n.º 3
0
/** bhist_stats_open:
 *    @stats: isp module data
 *    @stats_type: statistic type
 *
 * Allocate instance private data for submodule.
 *
 * This function executes in ISP thread context
 *
 * Return pointer to struct which contain module operations.
 **/
isp_ops_t *bhist_stats32_open(isp_stats_mod_t *stats,
  enum msm_isp_stats_type stats_type)
{
  int rc = 0;
  isp_stats_entry_t *entry = NULL;
  ISP_StatsBhist_CfgCmdType *cmd = NULL;

  ISP_DBG(ISP_MOD_STATS, "%s: E\n", __func__);
  entry = malloc(sizeof(isp_stats_entry_t));
  if (!entry) {
    CDBG_ERROR("%s: no mem for aec\n", __func__);
    return NULL;
  }
  cmd = malloc(sizeof(ISP_StatsBhist_CfgCmdType));
  if (!cmd) {
    CDBG_ERROR("%s: no mem\n", __func__);
    free(entry);
    return NULL;
  }
  memset(entry, 0, sizeof(*entry));
  memset(cmd, 0, sizeof(*cmd));

  entry->len_parsed_stats_buf = sizeof(q3a_bhist_stats_t);
  entry->parsed_stats_buf = malloc(entry->len_parsed_stats_buf);
  if (entry->parsed_stats_buf == NULL) {
    CDBG_ERROR("%s: no mem\n", __func__);
    free(cmd);
    free(entry);
    return NULL;
  }
  entry->reg_cmd = cmd;
  entry->ops.ctrl = (void *)entry;
  entry->ops.init = bhist_stats_init;
  entry->ops.destroy = bhist_stats_destroy;
  entry->ops.set_params = bhist_stats_set_params;
  entry->ops.get_params = bhist_stats_get_params;
  entry->ops.action = bhist_stats_action;
  return &entry->ops;
}
int mm_app_take_picture(mm_camera_test_obj_t *test_obj, uint8_t is_burst_mode)
{
    CDBG_HIGH("\nEnter %s!!\n",__func__);
    int rc = MM_CAMERA_OK;
    int num_snapshot = 1;
    int num_rcvd_snapshot = 0;

    if (is_burst_mode)
       num_snapshot = 6;

    //stop preview before starting capture.
    rc = mm_app_stop_preview(test_obj);
    if (rc != MM_CAMERA_OK) {
        CDBG_ERROR("%s: stop preview failed before capture!!, err=%d\n",__func__, rc);
        return rc;
    }

    rc = mm_app_start_capture(test_obj, num_snapshot);
    if (rc != MM_CAMERA_OK) {
        CDBG_ERROR("%s: mm_app_start_capture(), err=%d\n", __func__,rc);
        return rc;
    }
    while (num_rcvd_snapshot < num_snapshot) {
        CDBG_HIGH("\nWaiting mm_camera_app_wait !!\n");
        mm_camera_app_wait();
        num_rcvd_snapshot++;
    }
    rc = mm_app_stop_capture(test_obj);
    if (rc != MM_CAMERA_OK) {
       CDBG_ERROR("%s: mm_app_stop_capture(), err=%d\n",__func__, rc);
       return rc;
    }
    //start preview after capture.
    rc = mm_app_start_preview(test_obj);
    if (rc != MM_CAMERA_OK) {
        CDBG_ERROR("%s: start preview failed after capture!!, err=%d\n",__func__,rc);
    }
    return rc;
}
Exemplo n.º 5
0
/*===========================================================================
 * FUNCTION    - vfe_af_stats_stop -
 *
 * DESCRIPTION:  Disable the af stats
 *==========================================================================*/
vfe_status_t vfe_af_stats_stop(af_stats_t *stats, vfe_params_t *params)
{
  vfe_status_t status = VFE_SUCCESS;

  CDBG("vfe_af_stats_stop\n");
  status = vfe_util_write_hw_cmd(params->camfd,
    CMD_GENERAL, 0, 0, VFE_CMD_STATS_AF_STOP);
  if (VFE_SUCCESS != status) {
    CDBG_ERROR("%s: failed %d", __func__, status);
    return VFE_ERROR_GENERAL;
  }
  return VFE_SUCCESS;
}
Exemplo n.º 6
0
/*===========================================================================
 * FUNCTION    - sensor_util_config -
 *
 * DESCRIPTION:
 *==========================================================================*/
int8_t sensor_util_config(void *sctrl)
{
  struct sensor_cfg_data cfg;
  sensor_ctrl_t *ctrl = (sensor_ctrl_t *) sctrl;
  CDBG("%s enter\n", __func__);

  if (ctrl->sfd <= 0) {
    CDBG_ERROR("%s failed %d\n", __func__, __LINE__);
    return -EINVAL;
  }

  cfg.cfgtype = CFG_SENSOR_INIT;
  cfg.mode = ctrl->sensor.cam_mode;
  cfg.cfg.init_info.prev_res = ctrl->sensor.mode_res[SENSOR_MODE_PREVIEW];
  cfg.cfg.init_info.pict_res = ctrl->sensor.mode_res[SENSOR_MODE_SNAPSHOT];
  if (ioctl(ctrl->sfd, MSM_CAM_IOCTL_SENSOR_IO_CFG, &cfg) < 0) {
    CDBG_ERROR("%s failed %d\n", __func__, __LINE__);
    return -EIO;
  }
  CDBG("%s exit\n", __func__);
  return 0;
}
Exemplo n.º 7
0
/** color_conversion_trigger_enable:
 *
 *    @mod:
 *    @enable:
 *    @in_param_size:
 *
 * enable color_conversion trigger update feature
 *
 **/
static int color_conversion_trigger_enable(isp_color_conversion_mod_t *mod,
  isp_mod_set_enable_t *enable, uint32_t in_param_size)
{
  if (in_param_size != sizeof(isp_mod_set_enable_t)) {
    CDBG_ERROR("%s: size mismatch, expecting = %d, received = %d",
      __func__, sizeof(isp_mod_set_enable_t), in_param_size);
    return -1;
  }

  mod->trigger_enable = enable->enable;

  return 0;
} /* color_conversion_trigger_enable */
int mm_app_start_preview_zsl(int cam_id)
{
    int rc = MM_CAMERA_OK;

    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    CDBG("pme = %p, pme->cam =%p, pme->cam->camera_handle = %d",
         pme,pme->cam,pme->cam->camera_handle);

    if (!my_cam_app.run_sanity) {
        if (MM_CAMERA_OK != initDisplay()) {
            CDBG_ERROR("%s : Could not initalize display",__func__);
            goto end;
        }
    }

    pme->mem_cam->get_buf = mm_stream_initbuf;
    pme->mem_cam->put_buf = mm_stream_deinitbuf;
    pme->mem_cam->user_data = pme;

    if (MM_CAMERA_OK != (rc = mm_app_prepare_preview_zsl(cam_id))) {
        CDBG_ERROR("%s:Prepare preview err=%d\n", __func__, rc);
        goto end;
    }

    if (MM_CAMERA_OK != (rc = mm_app_streamon_preview_zsl(cam_id))) {
        CDBG_ERROR("%s:stream on preview err=%d\n", __func__, rc);
        goto end;
    }

    /*if(MM_CAMERA_OK != (rc = mm_app_bundle_zsl_stream(cam_id))){
        CDBG_ERROR("%s: bundle and start of ZSl err=%d\n", __func__, rc);
        goto end;
    }*/

    end:
    CDBG("%s: END, rc=%d\n", __func__, rc); 
    return rc;
}
Exemplo n.º 9
0
/** sce_enable
 *
 * description: enable sce
 *
 **/
static int sce_enable(isp_sce_mod_t *sce,
                isp_mod_set_enable_t *enable,
                uint32_t in_param_size)
{
  if (in_param_size != sizeof(isp_mod_set_enable_t)) {
    CDBG_ERROR("%s: size mismatch, expecting = %d, received = %d",
      __func__, sizeof(isp_mod_set_enable_t), in_param_size);
    return -1;
  }
  sce->sce_enable = enable->enable;

  return 0;
}
Exemplo n.º 10
0
/*===========================================================================
 * FUNCTION    - vfe_bf_stats_config -
 *
 * DESCRIPTION:
 *==========================================================================*/
vfe_status_t vfe_bf_stats_config(int mod_id, void *stats, void *vparams)
{
  vfe_status_t status = VFE_SUCCESS;
  bf_stats_t *mod = (bf_stats_t *)stats;
  vfe_params_t *params = (vfe_params_t *)vparams;
  uint32_t camif_window_w_t, camif_window_h_t;
  if (!mod->enable) {
    CDBG("%s: BF not enabled", __func__);
    return status;
  }

  camif_window_w_t = params->sensor_parms.lastPixel -
    params->sensor_parms.firstPixel + 1;
  camif_window_h_t = params->sensor_parms.lastLine -
    params->sensor_parms.firstLine + 1;

  CDBG("%s:\n",__func__);
  CDBG("camif_window_w_t :%u\n", camif_window_w_t);
  CDBG("camif_window_h_t :%u\n", camif_window_h_t);

  mod->bf_stats_cmd.rgnHOffset = 8;//FLOOR2(camif_window_w_t%18);
  mod->bf_stats_cmd.rgnVOffset = 2;//FLOOR2(camif_window_h_t%14);
  mod->bf_stats_cmd.rgnWidth   = FLOOR2((camif_window_w_t - 8 )/18) - 1;
  mod->bf_stats_cmd.rgnHeight  = FLOOR2((camif_window_h_t - 2 )/14) - 1;
  mod->bf_stats_cmd.rgnHNum    = 17;
  mod->bf_stats_cmd.rgnVNum    = 13;
  mod->bf_stats_cmd.r_fv_min   = 10;
  mod->bf_stats_cmd.gr_fv_min  = 10;
  mod->bf_stats_cmd.b_fv_min   = 10;
  mod->bf_stats_cmd.gb_fv_min  = 10;
  mod->bf_stats_cmd.a00        = 0;
  mod->bf_stats_cmd.a01        = 0;
  mod->bf_stats_cmd.a02        = 5;
  mod->bf_stats_cmd.a03        = 0;
  mod->bf_stats_cmd.a04        = 0;
  mod->bf_stats_cmd.a10        = -2;
  mod->bf_stats_cmd.a11        = -2;
  mod->bf_stats_cmd.a12        = 3;
  mod->bf_stats_cmd.a13        = -2;
  mod->bf_stats_cmd.a14        = -2;

  vfe_bf_stats_debug(mod);
  status = vfe_util_write_hw_cmd(params->camfd, CMD_GENERAL,
    &(mod->bf_stats_cmd),
    sizeof(mod->bf_stats_cmd), VFE_CMD_STATS_BF_START);
  if (VFE_SUCCESS != status) {
    CDBG_ERROR("%s: failed %d", __func__, status);
    return status;
  }
  return status;
} /* vfe_bf_stats_config */
Exemplo n.º 11
0
/*===========================================================================
 * FUNCTION   : mm_camera_poll_fn
 *
 * DESCRIPTION: polling thread routine
 *
 * PARAMETERS :
 *   @poll_cb : ptr to poll thread object
 *
 * RETURN     : none
 *==========================================================================*/
static void *mm_camera_poll_fn(mm_camera_poll_thread_t *poll_cb)
{
    int rc = 0, i;

    if (NULL == poll_cb) {
        CDBG_ERROR("%s: poll_cb is NULL!\n", __func__);
        return NULL;
    }
    CDBG("%s: poll type = %d, num_fd = %d poll_cb = %p\n",
         __func__, poll_cb->poll_type, poll_cb->num_fds,poll_cb);
    do {
         for(i = 0; i < poll_cb->num_fds; i++) {
            poll_cb->poll_fds[i].events = POLLIN|POLLRDNORM|POLLPRI;
         }

         rc = poll(poll_cb->poll_fds, poll_cb->num_fds, poll_cb->timeoutms);
         if(rc > 0) {
            if ((poll_cb->poll_fds[0].revents & POLLIN) &&
                (poll_cb->poll_fds[0].revents & POLLRDNORM)) {
                /* if we have data on pipe, we only process pipe in this iteration */
                CDBG("%s: cmd received on pipe\n", __func__);
                mm_camera_poll_proc_pipe(poll_cb);
            } else {
                for(i=1; i<poll_cb->num_fds; i++) {
                    /* Checking for ctrl events */
                    if ((poll_cb->poll_type == MM_CAMERA_POLL_TYPE_EVT) &&
                        (poll_cb->poll_fds[i].revents & POLLPRI)) {
                        CDBG("%s: mm_camera_evt_notify\n", __func__);
                        if (NULL != poll_cb->poll_entries[i-1].notify_cb) {
                            poll_cb->poll_entries[i-1].notify_cb(poll_cb->poll_entries[i-1].user_data);
                        }
                    }

                    if ((MM_CAMERA_POLL_TYPE_DATA == poll_cb->poll_type) &&
                        (poll_cb->poll_fds[i].revents & POLLIN) &&
                        (poll_cb->poll_fds[i].revents & POLLRDNORM)) {
                        CDBG("%s: mm_stream_data_notify\n", __func__);
                        if (NULL != poll_cb->poll_entries[i-1].notify_cb) {
                            poll_cb->poll_entries[i-1].notify_cb(poll_cb->poll_entries[i-1].user_data);
                        }
                    }
                }
            }
        } else {
            /* in error case sleep 10 us and then continue. hard coded here */
            usleep(10);
            continue;
        }
    } while ((poll_cb != NULL) && (poll_cb->state == MM_CAMERA_POLL_TASK_STATE_POLL));
    return NULL;
}
Exemplo n.º 12
0
/*===========================================================================
 * FUNCTION    - isp_stats_config_stream -
 *
 * DESCRIPTION:
 *==========================================================================*/
int isp_stats_config_stats_stream(isp_stats_entry_t *entry, int num_bufs)
{
  int rc = 0;
  struct msm_vfe_stats_stream_request_cmd req_cmd;

  entry->num_bufs = num_bufs;
  memset(&req_cmd, 0, sizeof(req_cmd));
  req_cmd.session_id = entry->session_id;
  req_cmd.stream_id = isp_stats_get_stream_id(entry);
  req_cmd.stats_type = entry->stats_type;
  req_cmd.buffer_offset = entry->buf_offset;
  req_cmd.composite_flag = entry->comp_flag;

  switch (entry->hfr_mode) {
  case CAM_HFR_MODE_OFF:
    req_cmd.framedrop_pattern = NO_SKIP;
    break;
  case CAM_HFR_MODE_60FPS:
    req_cmd.framedrop_pattern = EVERY_2FRAME;
    break;
  case CAM_HFR_MODE_90FPS:
    req_cmd.framedrop_pattern = EVERY_3FRAME;
    break;
  case CAM_HFR_MODE_120FPS:
    req_cmd.framedrop_pattern = EVERY_4FRAME;
    break;
  case CAM_HFR_MODE_150FPS:
    req_cmd.framedrop_pattern = EVERY_5FRAME;
    break;
  default:
    req_cmd.framedrop_pattern = NO_SKIP;
  }

  rc = ioctl(entry->fd, VIDIOC_MSM_ISP_REQUEST_STATS_STREAM, &req_cmd);
  if (rc < 0) {
    CDBG_ERROR("%s: cannot request stream for stats 0x%x\n",
      __func__, entry->stats_type);
    return rc;
  }

  entry->stream_handle = req_cmd.stream_handle;
  rc = isp_stats_reg_buf(entry);
  if (rc < 0) {
     ISP_DBG(ISP_MOD_STATS, "%s: isp request buffer failed, rc = %d\n", __func__, rc);
    struct msm_vfe_stats_stream_release_cmd rel_cmd;
    rel_cmd.stream_handle = entry->stream_handle;
    ioctl(entry->fd, VIDIOC_MSM_ISP_RELEASE_STATS_STREAM, &rel_cmd);
  }

  return rc;
}
/*===========================================================================
 * FUNCTION    - isp_pix_pipeline_trigger_update -
 *
 * DESCRIPTION:
 *
 * DEPENDENCY: This function needs to be called after set_parms.
 *==========================================================================*/
int isp_pipeline_util_trigger_update(isp_pipeline_t *pix)
{
  int i, num, rc = 0;
  uint16_t *module_ids = NULL;
  isp_pix_params_t *params = &pix->pix_params;
  isp_pix_trigger_update_input_t *trigger_update_params =
    &params->cfg_and_3a_params;
  isp_stats_udpate_t *stats_update =
    &trigger_update_params->trigger_input.stats_update;
   uint8_t is_bayer_input = isp_pipeline_util_is_bayer_fmt(pix);

  if (!is_bayer_input) {
    return rc;
  }

  module_ids = pix->dep.mod_trigger_update_order_bayer;
  num = pix->dep.num_mod_trigger_update_order_bayer;
  if (stats_update->awb_update.color_temp == 0) {
    /* zero color temperature. no update needed */
    CDBG_ERROR("%s: zero color temperture. No update needed\n", __func__);
    return 0;
  }
  for (i = 0; i < num; i++) {
    if (((1 << module_ids[i]) & pix->pix_params.cur_module_mask) &&
        pix->mod_ops[module_ids[i]] && (module_ids[i] != ISP_MOD_STATS)) {
      rc = pix->mod_ops[module_ids[i]]->set_params(
             pix->mod_ops[module_ids[i]]->ctrl,
             ISP_HW_MOD_SET_TRIGGER_UPDATE,
             trigger_update_params,
             sizeof(isp_pix_trigger_update_input_t));
      if (rc < 0) {
        CDBG_ERROR("%s: module %d config failed\n", __func__, i);
        return rc;
      }
    }
  }
  return 0;
}
Exemplo n.º 14
0
/*===========================================================================
 * FUNCTION    - x -
 *
 * DESCRIPTION:
 *==========================================================================*/
static int8_t sensor_util_get_output_dimension_info(void *sctrl)
{
  struct sensor_cfg_data cfg;
  int index = 0;
  sensor_ctrl_t *ctrl = (sensor_ctrl_t *) sctrl;
  if (ctrl->sfd <= 0) {
    CDBG_ERROR("%s failed %d\n", __func__, __LINE__);
    return -EINVAL;
  }

  cfg.cfgtype = CFG_GET_OUTPUT_INFO;
  cfg.cfg.output_info.output_info = &ctrl->sensor.output_info[0];
  if (ioctl(ctrl->sfd, MSM_CAM_IOCTL_SENSOR_IO_CFG, &cfg) < 0) {
    CDBG_ERROR("%s failed %d\n", __func__, __LINE__);
    return -EIO;
  }
  ctrl->sensor.num_res = cfg.cfg.output_info.num_info;

  for (index = 0; index < ctrl->sensor.num_res; index++) {
    CDBG("%s: x_output[%d]: %d\n", __func__, index,
         ctrl->sensor.output_info[index].x_output);
    CDBG("%s: y_output[%d]: %d\n", __func__, index,
         ctrl->sensor.output_info[index].y_output);
    CDBG("%s: line_length_pclk[%d]: %d\n", __func__, index,
         ctrl->sensor.output_info[index].line_length_pclk);
    CDBG("%s: frame_length_lines[%d]: %d\n", __func__, index,
         ctrl->sensor.output_info[index].frame_length_lines);
    CDBG("%s: vt_pixel_clk[%d]: %d\n", __func__, index,
         ctrl->sensor.output_info[index].vt_pixel_clk);
    CDBG("%s: op_pixel_clk[%d]: %d\n", __func__, index,
         ctrl->sensor.output_info[index].op_pixel_clk);
    CDBG("%s: binning_factor[%d]: %d\n", __func__, index,
         ctrl->sensor.output_info[index].binning_factor);
  }

  CDBG("%s exit\n", __func__);
  return 0;
}
/** main:
 *
 *  Arguments:
 *    @argc
 *    @argv
 *
 *  Return:
 *       0 or -ve values
 *
 *  Description:
 *       main function
 *
 **/
int main(int argc, char* argv[])
{
  jpeg_test_input_t *p_test_input;
  int ret = 0;
  if (argc > 1) {
    p_test_input = calloc(2, sizeof(*p_test_input));
    if (!p_test_input) {
      CDBG_ERROR("%s:%d] Error",__func__, __LINE__);
      goto exit;
    }
    memcpy(p_test_input, &jpeg_input[0], sizeof(*p_test_input));
    ret = mm_jpeg_test_get_input(argc, argv, p_test_input);
    if (ret) {
      CDBG_ERROR("%s:%d] Error",__func__, __LINE__);
      goto exit;
    }
  } else {
    mm_jpeg_test_print_usage();
    return 1;
  }
  ret = encode_test(p_test_input);

exit:
  if (!ret) {
    fprintf(stderr, "%-25s\n", "Success!");
  } else {
    fprintf(stderr, "%-25s\n", "Fail!");
  }

  if (argc > 1) {
    if (p_test_input) {
      free(p_test_input);
      p_test_input = NULL;
    }
  }

  return ret;
}
Exemplo n.º 16
0
int mm_app_streamon_preview_zsl(int cam_id)
{
    int rc = MM_CAMERA_OK;
    mm_camera_bundle_attr_t attr;
    int stream[3];

    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);
    int op_mode = 0;


    stream[0] = pme->stream[MM_CAMERA_PREVIEW].id;
    stream[1] = pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id;

    attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_BURST;
    attr.burst_num = 1;
    attr.look_back = 2;
    attr.post_frame_skip = 0;
    attr.water_mark = 2;

    if (MM_CAMERA_OK != (rc = pme->cam->ops->init_stream_bundle(
                                                               pme->cam->camera_handle,pme->ch_id,mm_app_zsl_notify_cb,pme,&attr,2,stream))) {
        CDBG_ERROR("%s:init_stream_bundle err=%d\n", __func__, rc);
        rc = -1;
        goto end;
    }

    if (MM_CAMERA_OK != (rc = pme->cam->ops->start_streams(pme->cam->camera_handle,pme->ch_id,
                                                           2, stream))) {
        CDBG_ERROR("%s:start_streams err=%d\n", __func__, rc);
        rc = -1;
        goto end;
    }
    pme->cam_state = CAMERA_STATE_PREVIEW;
    end:
    CDBG("%s: END, rc=%d\n", __func__, rc); 
    return rc;

}
Exemplo n.º 17
0
int mm_camera_poll_thread_launch(mm_camera_obj_t * my_obj, int ch_type)
{
    int rc = MM_CAMERA_OK;
    mm_camera_poll_thread_t *poll_cb = &my_obj->poll_threads[ch_type];
    if(mm_camera_poll_ch_busy(my_obj, ch_type) > 0) {
        CDBG_ERROR("%s: err, poll thread of channel %d already running. cam_id=%d\n",
             __func__, ch_type, my_obj->my_id);
        return -MM_CAMERA_E_INVALID_OPERATION;
    }
    poll_cb->data.ch_type = ch_type;
    rc = pipe(poll_cb->data.pfds);
    if(rc < 0) {
        CDBG_ERROR("%s: camera_id = %d, pipe open rc=%d\n", __func__, my_obj->my_id, rc);
        rc = - MM_CAMERA_E_GENERAL;
    }
    CDBG("%s: ch = %d, poll_type = %d, read fd = %d, write fd = %d",
        __func__, ch_type, poll_cb->data.poll_type,
        poll_cb->data.pfds[0], poll_cb->data.pfds[1]);
    poll_cb->data.my_obj = my_obj;
    poll_cb->data.used = 0;
    poll_cb->data.timeoutms = -1;  /* Infinite seconds */

    if(ch_type < MM_CAMERA_CH_MAX) {
        poll_cb->data.poll_type = MM_CAMERA_POLL_TYPE_CH;
        mm_camera_ch_util_get_stream_objs(my_obj, ch_type,
                                      &poll_cb->data.poll_streams[0],
                                      &poll_cb->data.poll_streams[1]);
    } else{
        poll_cb->data.poll_type = MM_CAMERA_POLL_TYPE_EVT;
    }

    ALOGE("%s: ch_type = %d, poll_type = %d, read fd = %d, write fd = %d",
         __func__, ch_type, poll_cb->data.poll_type,
         poll_cb->data.pfds[0], poll_cb->data.pfds[1]);
    /* launch the thread */
    rc = mm_camera_poll_start(my_obj, poll_cb);
    return rc;
}
Exemplo n.º 18
0
/*===========================================================================
 * FUNCTION    - mm_camera_socket_create -
 *
 * DESCRIPTION: opens a domain socket tied to camera ID and socket type
 *                        int cam_id: camera ID
  *                       mm_camera_sock_type_t sock_type: socket type, TCP/UDP
 * retured fd related to the domain socket
 *==========================================================================*/
int mm_camera_socket_create(int cam_id, mm_camera_sock_type_t sock_type)
{
    int socket_fd;
    struct sockaddr_un sock_addr;
    int sktype;
    int rc;

    switch (sock_type)
    {
      case MM_CAMERA_SOCK_TYPE_UDP:
        sktype = SOCK_DGRAM;
        break;
      case MM_CAMERA_SOCK_TYPE_TCP:
        sktype = SOCK_STREAM;
        break;
      default:
        CDBG_ERROR("%s: unknown socket type =%d", __func__, sock_type);
        return -1;
    }
    socket_fd = socket(AF_UNIX, sktype, 0);
    if (socket_fd < 0) {
        CDBG_ERROR("%s: error create socket fd =%d", __func__, socket_fd);
        return socket_fd;
    }

    memset(&sock_addr, 0, sizeof(sock_addr));
    sock_addr.sun_family = AF_UNIX;
    snprintf(sock_addr.sun_path, UNIX_PATH_MAX, "/data/cam_socket%d", cam_id);
    if((rc = connect(socket_fd, (struct sockaddr *) &sock_addr,
      sizeof(sock_addr))) != 0) {
      close(socket_fd);
      socket_fd = -1;
      CDBG_ERROR("%s: socket_fd=%d %s ", __func__, socket_fd, strerror(errno));
    }

    CDBG("%s: socket_fd=%d %s", __func__, socket_fd, sock_addr.sun_path);
    return socket_fd;
}
Exemplo n.º 19
0
int mm_app_streamon_snapshot(int cam_id)
{
    int rc = MM_CAMERA_OK;
    uint32_t stream[2];
    mm_camera_bundle_attr_t attr;

    mm_camera_app_obj_t *pme = mm_app_get_cam_obj(cam_id);

    stream[0] = pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id;
    stream[1] = pme->stream[MM_CAMERA_SNAPSHOT_THUMBNAIL].id;

    attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_BURST;
    attr.burst_num = 1;
    attr.look_back = 2;
    attr.post_frame_skip = 0;
    attr.water_mark = 2;

    if (MM_CAMERA_OK != (rc = pme->cam->ops->init_stream_bundle(
                                  pme->cam->camera_handle,pme->ch_id,snapshot_yuv_cb,pme,&attr,2,stream))) {
        CDBG_ERROR("%s:init_stream_bundle err=%d\n", __func__, rc);
        goto end;
    }

    if (MM_CAMERA_OK != (rc = pme->cam->ops->start_streams(pme->cam->camera_handle,pme->ch_id,
                              2, stream))) {
        CDBG_ERROR("%s:start_streams err=%d\n", __func__, rc);
        goto end;
    }

    if (MM_CAMERA_OK != (rc =pme->cam->ops->request_super_buf(pme->cam->camera_handle,pme->ch_id, attr.burst_num))) {
        CDBG_ERROR("%s:request_super_buf err=%d\n", __func__, rc);
        goto end;
    }
    pme->cam_state = CAMERA_STATE_SNAPSHOT;
end:
    CDBG("%s: END, rc=%d\n", __func__, rc);
    return rc;
}
Exemplo n.º 20
0
/* This callback is received once the complete JPEG encoding is done */
static void snapshot_raw_cb(mm_camera_super_buf_t *bufs,
                            void *user_data)
{

    int rc;
    int i = 0;
    mm_camera_buf_def_t *main_frame = NULL;
    mm_camera_buf_def_t *thumb_frame = NULL;
    mm_camera_app_obj_t *pme = NULL;
    CDBG("%s: BEGIN\n", __func__);

    pme = (mm_camera_app_obj_t *)user_data;

    CDBG("%s : total streams = %d",__func__,bufs->num_bufs);
    main_frame = bufs->bufs[0];
    thumb_frame = bufs->bufs[1];

    CDBG("mainframe frame_idx = %d fd = %d frame length = %d",main_frame->frame_idx,main_frame->fd,main_frame->frame_len);
    CDBG("thumnail frame_idx = %d fd = %d frame length = %d",thumb_frame->frame_idx,thumb_frame->fd,thumb_frame->frame_len);

    //dumpFrameToFile(main_frame->frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1);
    //dumpFrameToFile(thumb_frame->frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1);

    dumpFrameToFile(main_frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1);
    dumpFrameToFile(thumb_frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1);

    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,main_frame)) {
        CDBG_ERROR("%s: Failed in thumbnail Qbuf\n", __func__);
    }
    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,thumb_frame)) {
        CDBG_ERROR("%s: Failed in thumbnail Qbuf\n", __func__);
    }

    mm_app_snapshot_done();
    CDBG("%s: END\n", __func__);


}
Exemplo n.º 21
0
int mm_app_stop_preview(mm_camera_test_obj_t *test_obj)
{
    int rc = MM_CAMERA_OK;

    mm_camera_channel_t *channel =
        mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_PREVIEW);

    rc = mm_app_stop_and_del_channel(test_obj, channel);
    if (MM_CAMERA_OK != rc) {
        CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc);
    }

    return rc;
}
Exemplo n.º 22
0
/*===========================================================================
 * FUNCTION      dsps_disconnect
 *
 * DESCRIPTION   Deregister an mctl client with the DSPS Thread
 *=========================================================================*/
int dsps_disconnect(void * sensor_config)
{
  int rc = 0;
  sensor1_config_t * dsps_config = (sensor1_config_t *)sensor_config;

  if (dsps_close(dsps_config) < 0) {
    CDBG_ERROR("%s Error in closing sensor connection", __func__);
    rc = -1;
  }
  dsps_cirq_deinit(dsps_config);
  pthread_mutex_destroy(&(dsps_config->data_mutex));

  return rc;
}
Exemplo n.º 23
0
/** color_xform_enable
 *    @mod: color_xform module control struct
 *    @enable: module enable/disable flag
 *
 *  color_xform module enable/disable method
 *
 * Return: 0 - success and negative value - failure
 **/
static int color_xform_enable(isp_color_xform_mod_t *mod,
  isp_mod_set_enable_t *enable, uint32_t in_param_size)
{
  if (in_param_size != sizeof(isp_mod_set_enable_t)) {
    /* size mismatch */
    CDBG_ERROR("%s: size mismatch, expecting = %d, received = %d",
      __func__, sizeof(isp_mod_set_enable_t), in_param_size);
    return -1;
  }
  mod->enable = enable->enable;
  if (!mod->enable)
    mod->hw_update_pending = 0;
  return 0;
} /* color_xform_enable */
Exemplo n.º 24
0
/** cpp_module_update_hfr_skip:
 *
 *  Description:
 *    Based on input and output fps, calculte the skip count
 *    according to this formula,
 *      count = floor(input/output) - 1, if input > output
 *            = 0, otherwise
 *
 **/
int32_t cpp_module_update_hfr_skip(cpp_module_stream_params_t *stream_params)
{
  if(!stream_params) {
    CDBG_ERROR("%s:%d, failed", __func__, __LINE__);
    return -EINVAL;
  }
  stream_params->hfr_skip_info.skip_count =
    floor(stream_params->hfr_skip_info.input_fps /
          stream_params->hfr_skip_info.output_fps) - 1;
  if(stream_params->hfr_skip_info.skip_count < 0) {
    stream_params->hfr_skip_info.skip_count = 0;
  }
  return 0;
}
Exemplo n.º 25
0
cam_streaming_mode_t cpp_module_get_streaming_mode(mct_module_t *module,
  uint32_t identity)
{
  if (!module) {
    CDBG_ERROR("%s:%d failed\n", __func__, __LINE__);
    return -EINVAL;
  }
  mct_port_t* port = cpp_module_find_port_with_identity(module, MCT_PORT_SINK,
                       identity);
  if (!port) {
    CDBG_ERROR("%s:%d port not found, identity=0x%x\n",
      __func__, __LINE__, identity);
    return -EINVAL;
  }
  cpp_port_data_t* port_data = (cpp_port_data_t*) MCT_OBJECT_PRIVATE(port);
  int i;
  for (i=0; i<CPP_MAX_STREAMS_PER_PORT; i++) {
    if (port_data->stream_data[i].identity == identity) {
      return port_data->stream_data[i].streaming_mode;
    }
  }
  return CAM_STREAMING_MODE_MAX;
}
/** mm_jpeg_intf_create_session:
 *
 *  Arguments:
 *    @client_hdl: client handle
 *    @p_params: encode parameters
 *    @p_session_id: session id
 *
 *  Return:
 *       0 success, failure otherwise
 *
 *  Description:
 *       Create new jpeg session
 *
 **/
static int32_t mm_jpeg_intf_create_session(uint32_t client_hdl,
    mm_jpeg_encode_params_t *p_params,
    uint32_t *p_session_id)
{
  int32_t rc = -1;

  if (0 == client_hdl || NULL == p_params || NULL == p_session_id) {
    CDBG_ERROR("%s:%d] invalid client_hdl or jobId", __func__, __LINE__);
    return rc;
  }

  pthread_mutex_lock(&g_intf_lock);
  if (NULL == g_jpeg_obj) {
    /* mm_jpeg obj not exists, return error */
    CDBG_ERROR("%s:%d] mm_jpeg is not opened yet", __func__, __LINE__);
    pthread_mutex_unlock(&g_intf_lock);
    return rc;
  }

 rc = mm_jpeg_create_session(g_jpeg_obj, client_hdl, p_params, p_session_id);
  pthread_mutex_unlock(&g_intf_lock);
  return rc;
}
Exemplo n.º 27
0
/*===========================================================================
 * FUNCTION    - sensor_util_power_up1 -
 *
 * DESCRIPTION:
 *==========================================================================*/
int8_t sensor_util_bayer_power_up(void *sctrl)
{
  struct sensor_cfg_data cfg;
  sensor_ctrl_t *ctrl = (sensor_ctrl_t *) sctrl;
  CDBG("%s enter\n", __func__);

  cfg.cfgtype = CFG_POWER_UP;
  if (ioctl(ctrl->sfd, MSM_CAM_IOCTL_SENSOR_IO_CFG, &cfg) < 0) {
    CDBG_ERROR("%s failed %d\n", __func__, __LINE__);
    return -EIO;
  }

  return 0;
}
int mm_app_stop_reprocess(mm_camera_test_obj_t *test_obj)
{
    int rc = MM_CAMERA_OK;
    mm_camera_channel_t *r_ch = NULL;

    r_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_REPROCESS);
    if (MM_CAMERA_OK != rc) {
        CDBG_ERROR("%s: No initialized reprocess channel d rc=%d\n",
                    __func__,
                    rc);
        return rc;
    }

    rc = mm_app_stop_and_del_channel(test_obj, r_ch);
    if (MM_CAMERA_OK != rc) {
        CDBG_ERROR("%s:Stop Preview failed rc=%d\n", __func__, rc);
    }

    mm_qcamera_queue_release(&test_obj->pp_frames);
    test_obj->reproc_stream = NULL;

    return rc;
}
Exemplo n.º 29
0
static int32_t mm_jpeg_intf_start_job(uint32_t client_hdl, mm_jpeg_job* job, uint32_t* jobId)
{
    int32_t rc = -1;

    if (0 == client_hdl ||
        NULL == job ||
        NULL == jobId) {
        CDBG_ERROR("%s: invalid parameters for client_hdl, job or jobId", __func__);
        return rc;
    }

    pthread_mutex_lock(&g_intf_lock);
    if (NULL == g_jpeg_obj) {
        /* mm_jpeg obj not exists, return error */
        CDBG_ERROR("%s: mm_jpeg is not opened yet", __func__);
        pthread_mutex_unlock(&g_intf_lock);
        return rc;
    }
    mm_jpeg_dump_job(job);
    rc = mm_jpeg_start_job(g_jpeg_obj, client_hdl, job, jobId);
    pthread_mutex_unlock(&g_intf_lock);
    return rc;
}
Exemplo n.º 30
0
/* ============================================================
 * function name: frame_skip_trigger_enable
 * description: enable trigger update feature
 * ============================================================*/
static int frame_skip_trigger_enable(isp_frame_skip_mod_t *fs,
                isp_mod_set_enable_t *enable,
                uint32_t in_param_size)
{
  if (in_param_size != sizeof(isp_mod_set_enable_t)) {
  /* size mismatch */
  CDBG_ERROR("%s: size mismatch, expecting = %d, received = %d",
         __func__, sizeof(isp_mod_set_enable_t), in_param_size);
  return -1;
  }
  fs->fs_trigger_enable = enable->enable;

  return 0;
}