コード例 #1
0
static int32_t mm_camera_ctrl_set_whitebalance (mm_camera_obj_t *my_obj, int mode) {

    int rc = 0, value;
    uint32_t id;

    switch(mode) {
    case MM_CAMERA_WHITE_BALANCE_AUTO:
        id = V4L2_CID_AUTO_WHITE_BALANCE;
        value = 1; /* TRUE */
        break;
    case MM_CAMERA_WHITE_BALANCE_OFF:
        id = V4L2_CID_AUTO_WHITE_BALANCE;
        value = 0; /* FALSE */
        break;
    default:
        id = V4L2_CID_WHITE_BALANCE_TEMPERATURE;
        if(mode == WHITE_BALANCE_DAYLIGHT) value = 6500;
        else if(mode == WHITE_BALANCE_INCANDESCENT) value = 2800;
        else if(mode == WHITE_BALANCE_FLUORESCENT ) value = 4200;
        else if(mode == WHITE_BALANCE_CLOUDY) value = 7500;
        else
            value = 4200;
    }
    if(0 != (rc =  mm_camera_util_s_ctrl(my_obj->ctrl_fd,
            id, value))){
        CDBG("%s: error, exp_metering_action_param=%d, rc = %d\n", __func__, value, rc);
        goto end;
    }
end:
    return rc;
}
コード例 #2
0
static int32_t mm_camera_ctrl_set_toggle_afr (mm_camera_obj_t *my_obj) {
    int rc = 0;
    int value = 0;
    if(0 != (rc =  mm_camera_util_g_ctrl(my_obj->ctrl_fd,
            V4L2_CID_EXPOSURE_AUTO, &value))){
        goto end;
    }
    /* V4L2_CID_EXPOSURE_AUTO needs to be AUTO or SHUTTER_PRIORITY */
    if (value != V4L2_EXPOSURE_AUTO && value != V4L2_EXPOSURE_SHUTTER_PRIORITY) {
    CDBG("%s: V4L2_CID_EXPOSURE_AUTO needs to be AUTO/SHUTTER_PRIORITY\n",
        __func__);
    return -1;
  }
    if(0 != (rc =  mm_camera_util_g_ctrl(my_obj->ctrl_fd,
            V4L2_CID_EXPOSURE_AUTO_PRIORITY, &value))){
        goto end;
    }
    value = !value;
    if(0 != (rc =  mm_camera_util_s_ctrl(my_obj->ctrl_fd,
            V4L2_CID_EXPOSURE_AUTO_PRIORITY, value))){
        goto end;
    }
end:
    return rc;
}
コード例 #3
0
static int32_t mm_camera_ctrl_set_auto_focus (mm_camera_obj_t *my_obj, int value)
{
    int rc = 0;
    struct v4l2_queryctrl queryctrl;

    memset (&queryctrl, 0, sizeof (queryctrl));
    queryctrl.id = V4L2_CID_FOCUS_AUTO;

    if(value != 0 && value != 1) {
        CDBG("%s:boolean required, invalid value = %d\n",__func__, value);
        return -MM_CAMERA_E_INVALID_INPUT;
    }
    if (-1 == ioctl (my_obj->ctrl_fd, VIDIOC_QUERYCTRL, &queryctrl)) {
        CDBG ("V4L2_CID_FOCUS_AUTO is not supported\n");
    } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
        CDBG ("%s:V4L2_CID_FOCUS_AUTO is not supported\n", __func__);
    } else {
        if(0 != (rc =  mm_camera_util_s_ctrl(my_obj->ctrl_fd,
                V4L2_CID_FOCUS_AUTO, value))){
            CDBG("%s: error, id=0x%x, value=%d, rc = %d\n",
                     __func__, V4L2_CID_FOCUS_AUTO, value, rc);
            rc = -1;
        }
    }
    return rc;
}
void mm_camera_histo_mmap(mm_camera_obj_t * my_obj, mm_camera_event_t *evt)
{
    int i, *ret;
    int rc = MM_CAMERA_OK;
    off_t offset = 0;

    CDBG("%s", __func__);
    if(!evt || evt->e.info.e.histo_mem_info.num == 0 || my_obj->hist_mem_map.num) {
        for(i = 0; i < my_obj->hist_mem_map.num; i++) {
            munmap((void *)my_obj->hist_mem_map.entry[i].vaddr,
            my_obj->hist_mem_map.entry[i].cookie.length);
        }
        memset(&my_obj->hist_mem_map, 0,
            sizeof(my_obj->hist_mem_map));
    }
    if(!evt)
        return;
    if (evt->e.info.e.histo_mem_info.num > 0) {
        for(i = 0; i < evt->e.info.e.histo_mem_info.num; i++) {
            my_obj->hist_mem_map.entry[i].cookie.cookie =
            evt->e.info.e.histo_mem_info.vaddr[i];
            my_obj->hist_mem_map.entry[i].cookie.length =
            evt->e.info.e.histo_mem_info.buf_len;
            my_obj->hist_mem_map.entry[i].cookie.mem_type =
            evt->e.info.e.histo_mem_info.pmem_type;
            rc = mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_MMAP_ENTRY,
                    (int)&my_obj->hist_mem_map.entry[i].cookie);
            if( rc < 0) {
                CDBG("%s: MSM_V4L2_PID_MMAP_ENTRY error", __func__);
                goto err;
            }
            ret = mmap(NULL, my_obj->hist_mem_map.entry[i].cookie.length,
                  (PROT_READ  | PROT_WRITE), MAP_SHARED, my_obj->ctrl_fd, offset);
            if(ret == MAP_FAILED) {
                CDBG("%s: mmap error at idx %d", __func__, i);
                goto err;
            }
            my_obj->hist_mem_map.entry[i].vaddr = (uint32_t)ret;
            my_obj->hist_mem_map.num++;
            CDBG("%s: mmap, idx=%d,cookie=0x%x,length=%d,pmem_type=%d,vaddr=0x%x",
                __func__, i,
                my_obj->hist_mem_map.entry[i].cookie.cookie,
                my_obj->hist_mem_map.entry[i].cookie.length,
                my_obj->hist_mem_map.entry[i].cookie.mem_type,
                my_obj->hist_mem_map.entry[i].vaddr);
        }
    }
    return;
err:
    for(i = 0; i < my_obj->hist_mem_map.num; i++) {
        munmap((void *)my_obj->hist_mem_map.entry[i].vaddr,
        my_obj->hist_mem_map.entry[i].cookie.length);
    }
    memset(&my_obj->hist_mem_map, 0,
    sizeof(my_obj->hist_mem_map));
}
コード例 #5
0
int32_t mm_camera_ch_fn(mm_camera_obj_t * my_obj, 
																	mm_camera_channel_type_t ch_type, 
																	mm_camera_state_evt_type_t evt, void *val)
{
	int32_t rc = MM_CAMERA_OK;

	CDBG("%s:ch = %d, evt=%d\n", __func__, ch_type, evt);
	switch(evt) {
	case MM_CAMERA_STATE_EVT_ACQUIRE:
		rc = mm_camera_ch_util_acquire(my_obj, ch_type);
		break;
	case MM_CAMERA_STATE_EVT_RELEASE:
		rc = mm_camera_ch_util_release(my_obj, ch_type, evt);
		break;
	case MM_CAMERA_STATE_EVT_ATTR:
		rc = mm_camera_ch_util_attr(my_obj, ch_type, 
																(mm_camera_channel_attr_t *)val);
		break;
	case MM_CAMERA_STATE_EVT_REG_BUF_CB:
		rc = mm_camera_ch_util_reg_buf_cb(my_obj, ch_type, 
																			(mm_camera_buf_cb_t *)val);
		break;
	case MM_CAMERA_STATE_EVT_SET_FMT:
		rc = mm_camera_ch_util_set_fmt(my_obj, ch_type, 
														(mm_camera_ch_image_fmt_parm_t *)val);
		break;
	case MM_CAMERA_STATE_EVT_REG_BUF:
		rc = mm_camera_ch_util_reg_buf(my_obj, ch_type, evt, val);
		break;
	case MM_CAMERA_STATE_EVT_UNREG_BUF:
		rc = mm_camera_ch_util_stream_null_val(my_obj, ch_type, evt, NULL);
		break;
	case MM_CAMERA_STATE_EVT_STREAM_ON:
		if(ch_type == MM_CAMERA_CH_RAW && 
			 my_obj->ch[ch_type].raw.mode == MM_CAMERA_RAW_STREAMING_CAPTURE_SINGLE) {
			if( MM_CAMERA_OK != (rc = mm_camera_util_s_ctrl(my_obj->ctrl_fd, 
				MSM_V4L2_PID_CAM_MODE, MSM_V4L2_CAM_OP_RAW))) {
				CDBG("%s:set MM_CAMERA_RAW_STREAMING_CAPTURE_SINGLE err=%d\n", __func__, rc);
				break;
			}
		}
		rc = mm_camera_ch_util_stream_null_val(my_obj, ch_type, evt, NULL);
		break;
	case MM_CAMERA_STATE_EVT_STREAM_OFF:
		rc = mm_camera_ch_util_stream_null_val(my_obj, ch_type, evt, NULL);
		break;
	case MM_CAMERA_STATE_EVT_QBUF:
		rc = mm_camera_ch_util_qbuf(my_obj, ch_type, evt, 
																(mm_camera_ch_data_buf_t *)val);
		break;
	default:
		break;
	}
	return rc;
}
コード例 #6
0
static int32_t mm_camera_send_native_ctrl_cmd(mm_camera_obj_t * my_obj,	
					cam_ctrl_type type, uint32_t length, void *value)
{
	int rc = -1;
	struct msm_ctrl_cmd ctrl_cmd;
	memset(&ctrl_cmd, 0, sizeof(ctrl_cmd));
	ctrl_cmd.type = type;
	ctrl_cmd.length = (uint16_t)length;
	ctrl_cmd.timeout_ms = 1000;
	ctrl_cmd.value = value;
	ctrl_cmd.status = CAM_CTRL_SUCCESS;
	rc = mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_CTRL_CMD, 
																			(int)&ctrl_cmd);
	CDBG("%s: type=%d, rc = %d, status = %d\n",
				__func__, type, rc, ctrl_cmd.status);

	if(rc != MM_CAMERA_OK || ctrl_cmd.status != 1) 
		rc = -1;
	return rc;
}
コード例 #7
0
static int32_t mm_camera_util_set_op_mode(mm_camera_obj_t * my_obj,
    mm_camera_op_mode_type_t *op_mode)
{
    int32_t rc = MM_CAMERA_OK;
    uint32_t v4l2_op_mode = MSM_V4L2_CAM_OP_DEFAULT;

    if (my_obj->op_mode == *op_mode)
        goto end;
    if(mm_camera_poll_busy(my_obj) == TRUE) {
        CDBG("%s: cannot change op_mode while stream on\n", __func__);
        rc = -MM_CAMERA_E_INVALID_OPERATION;
        goto end;
    }
    switch(*op_mode) {
    case MM_CAMERA_OP_MODE_ZSL:
        v4l2_op_mode = MSM_V4L2_CAM_OP_ZSL;
            break;
    case MM_CAMERA_OP_MODE_CAPTURE:
        v4l2_op_mode = MSM_V4L2_CAM_OP_CAPTURE;
            break;
    case MM_CAMERA_OP_MODE_VIDEO:
        v4l2_op_mode = MSM_V4L2_CAM_OP_VIDEO;
            break;
    default:
        rc = - MM_CAMERA_E_INVALID_INPUT;
        goto end;
        break;
    }
    if(0 != (rc =  mm_camera_util_s_ctrl(my_obj->ctrl_fd,
            MSM_V4L2_PID_CAM_MODE, v4l2_op_mode))){
        CDBG("%s: input op_mode=%d, s_ctrl rc=%d\n", __func__, *op_mode, rc);
        goto end;
    }
    /* if success update mode field */
    my_obj->op_mode = *op_mode;
end:
    CDBG("%s: op_mode=%d,rc=%d\n", __func__, *op_mode, rc);
    return rc;
}
コード例 #8
0
int32_t mm_camera_open(mm_camera_obj_t *my_obj, 
																						mm_camera_op_mode_type_t op_mode)
{
	char dev_name[MM_CAMERA_DEV_NAME_LEN];
	int32_t rc = MM_CAMERA_OK;

	if(my_obj->op_mode != MM_CAMERA_OP_MODE_NOTUSED) {
		CDBG("%s: not allowed in existing op mode %d\n", 
				 __func__, my_obj->op_mode); 
		return -MM_CAMERA_E_INVALID_OPERATION;
	}
	if(op_mode >= MM_CAMERA_OP_MODE_MAX) {
		CDBG("%s: invalid input %d\n", 
				 __func__, op_mode); 
		return -MM_CAMERA_E_INVALID_INPUT;		
	}
	sprintf(dev_name, "/dev/%s", mm_camera_util_get_dev_name(my_obj));
	//rc = mm_camera_dev_open(&my_obj->ctrl_fd, dev_name);
	my_obj->ctrl_fd = open(dev_name,
										O_RDWR | O_NONBLOCK);
	if (my_obj->ctrl_fd <= 0) {
		CDBG("%s: cannot open control fd of '%s'\n",
				 __func__, mm_camera_util_get_dev_name(my_obj)); 
		return -MM_CAMERA_E_GENERAL;
	}
	if(op_mode != MM_CAMERA_OP_MODE_NOTUSED) 
		rc =  mm_camera_util_s_ctrl(my_obj->ctrl_fd, 
							MSM_V4L2_PID_CAM_MODE, op_mode); 
	if(!rc)	{
		my_obj->op_mode = op_mode;
		my_obj->current_mode = CAMERA_MODE_2D; /* set geo mode to 2D by default */
	}
	CDBG("%s: '%s', ctrl_fd=%d,op_mode=%d,rc=%d\n", 
			 __func__, dev_name, my_obj->ctrl_fd, my_obj->op_mode, rc); 
	return rc;
}
コード例 #9
0
int32_t mm_camera_ch_fn(mm_camera_obj_t * my_obj,
        mm_camera_channel_type_t ch_type,
        mm_camera_state_evt_type_t evt, void *val)
{
    int32_t rc = MM_CAMERA_OK;

    CDBG("%s:ch = %d, evt=%d\n", __func__, ch_type, evt);
    switch(evt) {
    case MM_CAMERA_STATE_EVT_ACQUIRE:
        rc = mm_camera_ch_util_acquire(my_obj, ch_type);
        break;
    case MM_CAMERA_STATE_EVT_RELEASE:
      /* safe code in case no stream off before release. */
        //mm_camera_poll_thread_release(my_obj, ch_type);
        rc = mm_camera_ch_util_release(my_obj, ch_type, evt);
        break;
    case MM_CAMERA_STATE_EVT_ATTR:
        rc = mm_camera_ch_util_attr(my_obj, ch_type,
                                    (mm_camera_channel_attr_t *)val);
        break;
    case MM_CAMERA_STATE_EVT_REG_BUF_CB:
        rc = mm_camera_ch_util_reg_buf_cb(my_obj, ch_type,
                                          (mm_camera_buf_cb_t *)val);
        break;
    case MM_CAMERA_STATE_EVT_SET_FMT:
        rc = mm_camera_ch_util_set_fmt(my_obj, ch_type,
                                       (mm_camera_ch_image_fmt_parm_t *)val);
        break;
    case MM_CAMERA_STATE_EVT_REG_BUF:
    case MM_CAMERA_STATE_EVT_REQUEST_BUF:
    case MM_CAMERA_STATE_EVT_ENQUEUE_BUF:
        rc = mm_camera_ch_util_reg_buf(my_obj, ch_type, evt, val);
        break;
    case MM_CAMERA_STATE_EVT_UNREG_BUF:
        rc = mm_camera_ch_util_stream_null_val(my_obj, ch_type, evt, NULL);
        break;
    case MM_CAMERA_STATE_EVT_STREAM_ON: {
        if(ch_type == MM_CAMERA_CH_RAW &&
             my_obj->ch[ch_type].raw.mode == MM_CAMERA_RAW_STREAMING_CAPTURE_SINGLE) {
            if( MM_CAMERA_OK != (rc = mm_camera_util_s_ctrl(my_obj->ctrl_fd,
                MSM_V4L2_PID_CAM_MODE, MSM_V4L2_CAM_OP_RAW))) {
                CDBG("%s:set MM_CAMERA_RAW_STREAMING_CAPTURE_SINGLE err=%d\n", __func__, rc);
                break;
            }
        }
        mm_camera_poll_thread_add_ch(my_obj, ch_type);
        rc = mm_camera_ch_util_stream_null_val(my_obj, ch_type, evt, NULL);
        if(rc < 0) {
          CDBG_ERROR("%s: Failed in STREAM ON", __func__);
          mm_camera_poll_thread_release(my_obj, ch_type);
        }
        break;
    }
    case MM_CAMERA_STATE_EVT_STREAM_OFF: {
        mm_camera_poll_thread_del_ch(my_obj, ch_type);
        rc = mm_camera_ch_util_stream_null_val(my_obj, ch_type, evt, NULL);
        break;
    }
    case MM_CAMERA_STATE_EVT_QBUF:
        rc = mm_camera_ch_util_qbuf(my_obj, ch_type, evt,
                                    (mm_camera_ch_data_buf_t *)val);
        break;
    case MM_CAMERA_STATE_EVT_GET_CROP:
      rc = mm_camera_ch_util_get_crop(my_obj, ch_type, evt,
                                  (mm_camera_ch_crop_t *)val);
      break;
    case MM_CAMERA_STATE_EVT_DISPATCH_BUFFERED_FRAME:
      rc = mm_camera_ch_util_dispatch_buffered_frame(my_obj, ch_type);
      break;
    default:
        break;
    }
    return rc;
}
コード例 #10
0
int32_t mm_camera_open(mm_camera_obj_t *my_obj,
                    mm_camera_op_mode_type_t op_mode)
{
    char dev_name[MM_CAMERA_DEV_NAME_LEN];
    int32_t rc = MM_CAMERA_OK;
    int8_t n_try=MM_CAMERA_DEV_OPEN_TRIES;
    uint8_t sleep_msec=MM_CAMERA_DEV_OPEN_RETRY_SLEEP;
    uint8_t i;

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

    if(my_obj->op_mode != MM_CAMERA_OP_MODE_NOTUSED) {
        CDBG("%s: not allowed in existing op mode %d\n",
                 __func__, my_obj->op_mode);
        return -MM_CAMERA_E_INVALID_OPERATION;
    }
    if(op_mode >= MM_CAMERA_OP_MODE_MAX) {
        CDBG("%s: invalid input %d\n",
                 __func__, op_mode);
        return -MM_CAMERA_E_INVALID_INPUT;
    }
    snprintf(dev_name, sizeof(dev_name), "/dev/%s", mm_camera_util_get_dev_name(my_obj));
    //rc = mm_camera_dev_open(&my_obj->ctrl_fd, dev_name);
	CDBG("%s: mm_camera_dev_open rc = %d\n", __func__, rc);

    do{
        n_try--;
        my_obj->ctrl_fd = open(dev_name,O_RDWR | O_NONBLOCK);
		ALOGV("%s:  ctrl_fd = %d", __func__, my_obj->ctrl_fd);
        ALOGV("Errno:%d",errno);
        if((my_obj->ctrl_fd > 0) || (errno != EIO) || (n_try <= 0 )) {
			ALOGV("%s:  opened, break out while loop", __func__);

            break;
		}
        CDBG("%s:failed with I/O error retrying after %d milli-seconds",
             __func__,sleep_msec);
        usleep(sleep_msec*1000);
    }while(n_try>0);

	ALOGV("%s:  after while loop", __func__);
    if (my_obj->ctrl_fd <= 0) {
        CDBG("%s: cannot open control fd of '%s' Errno = %d\n",
                 __func__, mm_camera_util_get_dev_name(my_obj),errno);
        return -MM_CAMERA_E_GENERAL;
    }
	ALOGV("%s:  2\n", __func__);

    /* open domain socket*/
    n_try=MM_CAMERA_DEV_OPEN_TRIES;
    do{
        n_try--;
        my_obj->ds_fd = mm_camera_socket_create(my_obj->my_id, MM_CAMERA_SOCK_TYPE_UDP); // TODO: UDP for now, change to TCP
        ALOGV("%s:  ds_fd = %d", __func__, my_obj->ds_fd);
        ALOGV("Errno:%d",errno);
        if((my_obj->ds_fd > 0) || (n_try <= 0 )) {
            ALOGV("%s:  opened, break out while loop", __func__);
            break;
        }
        CDBG("%s:failed with I/O error retrying after %d milli-seconds",
             __func__,sleep_msec);
        usleep(sleep_msec*1000);
    }while(n_try>0);

    ALOGV("%s:  after while loop for domain socket open", __func__);
    if (my_obj->ds_fd <= 0) {
        CDBG_ERROR("%s: cannot open domain socket fd of '%s' Errno = %d\n",
                 __func__, mm_camera_util_get_dev_name(my_obj),errno);
        close(my_obj->ctrl_fd);
        my_obj->ctrl_fd = -1;
        return -MM_CAMERA_E_GENERAL;
    }

    /* set ctrl_fd to be the mem_mapping fd */
    rc =  mm_camera_util_s_ctrl(my_obj->ctrl_fd,
                        MSM_V4L2_PID_MMAP_INST, 0);
    if (rc != MM_CAMERA_OK) {
        CDBG_ERROR("error: ioctl VIDIOC_S_CTRL MSM_V4L2_PID_MMAP_INST failed: %s\n",
        strerror(errno));
        close(my_obj->ctrl_fd);
        close(my_obj->ds_fd);
        my_obj->ctrl_fd = -1;
        my_obj->ds_fd = -1;
        return -MM_CAMERA_E_GENERAL;
    }
    if(op_mode != MM_CAMERA_OP_MODE_NOTUSED)
        rc =  mm_camera_util_s_ctrl(my_obj->ctrl_fd,
                            MSM_V4L2_PID_CAM_MODE, op_mode);
    if(!rc) {
        my_obj->op_mode = op_mode;
        my_obj->current_mode = CAMERA_MODE_2D; /* set geo mode to 2D by default */
    }

    /* get camera capabilities */
    memset(&my_obj->properties, 0, sizeof(cam_prop_t));
    rc = mm_camera_send_native_ctrl_cmd(my_obj,
                                        CAMERA_GET_CAPABILITIES,
                                        sizeof(cam_prop_t),
                                        (void *)& my_obj->properties);
    if (rc != MM_CAMERA_OK) {
        CDBG_ERROR("%s: cannot get camera capabilities\n", __func__);
        close(my_obj->ctrl_fd);
        close(my_obj->ds_fd);
        my_obj->ctrl_fd = -1;
        my_obj->ds_fd = -1;
        return -MM_CAMERA_E_GENERAL;
    }

    mm_camera_poll_threads_init(my_obj);
    mm_camera_init_ch_stream_count(my_obj);
    CDBG("%s : Launch Threads in Cam Open",__func__);
    for(i = 0; i < MM_CAMERA_CH_MAX; i++) {
        mm_camera_poll_thread_launch(my_obj,(mm_camera_channel_type_t)i);
    }
    CDBG("%s: '%s', ctrl_fd=%d,op_mode=%d,rc=%d\n",
             __func__, dev_name, my_obj->ctrl_fd, my_obj->op_mode, rc);
    return rc;
}
コード例 #11
0
int32_t mm_camera_set_general_parm(mm_camera_obj_t * my_obj, mm_camera_parm_t *parm)
{
    int rc = -MM_CAMERA_E_NOT_SUPPORTED;
    int isZSL =0;

    switch(parm->parm_type)  {
    case MM_CAMERA_PARM_EXPOSURE:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd,
                                                                        MSM_V4L2_PID_EXP_METERING,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_SHARPNESS:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_SHARPNESS,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_CONTRAST:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_CONTRAST,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_SATURATION:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_SATURATION,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_BRIGHTNESS:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_BRIGHTNESS,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_WHITE_BALANCE:
        return mm_camera_ctrl_set_whitebalance (my_obj, *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_ISO:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_ISO,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_ZOOM:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_ZOOM_ABSOLUTE,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_LUMA_ADAPTATION:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_LUMA_ADAPTATION,
                                                                            *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_ANTIBANDING:
        return mm_camera_ctrl_set_antibanding (my_obj, *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_CONTINUOUS_AF:
        return mm_camera_ctrl_set_auto_focus(my_obj, *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_HJR:
        return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_HJR, *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_EFFECT:
        return mm_camera_ctrl_set_specialEffect (my_obj, *((int *)(parm->p_value)));
    case MM_CAMERA_PARM_FPS:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_FPS, sizeof(uint32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_FPS_MODE:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_FPS_MODE, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_EXPOSURE_COMPENSATION:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_EXPOSURE_COMPENSATION, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_LED_MODE:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_LED_MODE, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_ROLLOFF:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_ROLLOFF, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_MODE:
        my_obj->current_mode = *((camera_mode_t *)parm->p_value);
        break;
    case MM_CAMERA_PARM_FOCUS_RECT:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_FOCUS_RECT, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_AEC_ROI:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_AEC_ROI, sizeof(cam_set_aec_roi_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_AF_ROI:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_AF_ROI, sizeof(roi_info_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_FOCUS_MODE:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_AF_MODE, sizeof(int32_t), (void *)parm->p_value);
#if 0 //to be enabled later: @punits
    case MM_CAMERA_PARM_AF_MTR_AREA:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_AF_MTR_AREA, sizeof(af_mtr_area_t), (void *)parm->p_value);*/
    case MM_CAMERA_PARM_AEC_MTR_AREA:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_AEC_MTR_AREA, sizeof(aec_mtr_area_t), (void *)parm->p_value);
#endif
    case MM_CAMERA_PARM_CAF_ENABLE:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_CAF, sizeof(uint32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_BESTSHOT_MODE:
        CDBG("%s : MM_CAMERA_PARM_BESTSHOT_MODE value : %d",__func__,*((int *)(parm->p_value)));
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_BESTSHOT_MODE, sizeof(int32_t), (void *)parm->p_value);
        break;
    case MM_CAMERA_PARM_VIDEO_DIS:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_VIDEO_DIS_PARAMS, sizeof(video_dis_param_ctrl_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_VIDEO_ROT:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_VIDEO_ROT_PARAMS, sizeof(video_rotation_param_ctrl_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_SCE_FACTOR:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_SCE_FACTOR, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_FD:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_FD, sizeof(fd_set_parm_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_AEC_LOCK:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_AEC_LOCK, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_AWB_LOCK:
        return mm_camera_send_native_ctrl_cmd(my_obj,   CAMERA_SET_AWB_LOCK,
                                                     sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_MCE:
        return mm_camera_send_native_ctrl_cmd(my_obj,   CAMERA_SET_PARM_MCE,
                                                     sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_HORIZONTAL_VIEW_ANGLE:
        return mm_camera_send_native_ctrl_cmd(my_obj,   CAMERA_GET_PARM_HORIZONTAL_VIEW_ANGLE,
                                                     sizeof(focus_distances_info_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_VERTICAL_VIEW_ANGLE:
        return mm_camera_send_native_ctrl_cmd(my_obj,   CAMERA_GET_PARM_VERTICAL_VIEW_ANGLE,
                                                     sizeof(focus_distances_info_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_RESET_LENS_TO_INFINITY:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                            CAMERA_SET_PARM_RESET_LENS_TO_INFINITY,
                            0, NULL);
    case MM_CAMERA_PARM_SNAPSHOTDATA:
        return mm_camera_send_native_ctrl_cmd(my_obj,   CAMERA_GET_PARM_SNAPSHOTDATA,
                                                     sizeof(snapshotData_info_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_HFR:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_HFR, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_REDEYE_REDUCTION:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_REDEYE_REDUCTION, sizeof(int32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_WAVELET_DENOISE:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_WAVELET_DENOISE, sizeof(denoise_param_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_3D_DISPLAY_DISTANCE:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_3D_DISPLAY_DISTANCE, sizeof(float), (void *)parm->p_value);
    case MM_CAMERA_PARM_3D_VIEW_ANGLE:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_3D_VIEW_ANGLE, sizeof(uint32_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_ZOOM_RATIO:
        break;
    case MM_CAMERA_PARM_HISTOGRAM:
        return mm_camera_send_native_ctrl_cmd(my_obj,
                    CAMERA_SET_PARM_HISTOGRAM, sizeof(int8_t), (void *)parm->p_value);
    case MM_CAMERA_PARM_JPEG_ROTATION:
        if(my_obj->op_mode == MM_CAMERA_OP_MODE_ZSL){
           isZSL =1;
        }
        mm_jpeg_encoder_setRotation(*((int *)parm->p_value),isZSL);
        return MM_CAMERA_OK;

    case MM_CAMERA_PARM_ASD_ENABLE:
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_ASD_ENABLE, sizeof(uint32_t), (void *)parm->p_value);

    case MM_CAMERA_PARM_RECORDING_HINT:
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_RECORDING_HINT, sizeof(uint32_t), (void *)parm->p_value);

    case MM_CAMERA_PARM_PREVIEW_FORMAT:
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_PARM_PREVIEW_FORMAT, sizeof(uint32_t), (void *)parm->p_value);

    case MM_CAMERA_PARM_DIS_ENABLE:
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_DIS_ENABLE, sizeof(uint32_t), (void *)parm->p_value);

    case MM_CAMERA_PARM_FULL_LIVESHOT: {
      my_obj->full_liveshot = *((int *)(parm->p_value));
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_FULL_LIVESHOT, sizeof(uint32_t), (void *)parm->p_value);
    }

    case MM_CAMERA_PARM_LOW_POWER_MODE:
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_LOW_POWER_MODE, sizeof(uint32_t), (void *)parm->p_value);

    case MM_CAMERA_PARM_CAF_TYPE:
      CDBG("SM : %s : MM_CAMERA_PARM_CAF_TYPE value : %d",__func__,*((int *)(parm->p_value)));
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_PARM_CAF_TYPE, sizeof(int32_t), (void *)parm->p_value);

    case MM_CAMERA_PARM_HDR:
      return mm_camera_send_native_ctrl_cmd(my_obj,
                        CAMERA_SET_PARM_HDR, sizeof(exp_bracketing_t), (void *)parm->p_value);

    case MM_CAMERA_PARM_CAF_LOCK_CANCEL:
      return mm_camera_send_native_ctrl_cmd(my_obj,
                  CAMERA_SET_CAF_LOCK_CANCEL, sizeof(uint32_t), (void *)parm->p_value);

    default:
        CDBG("%s: default: parm %d not supported\n", __func__, parm->parm_type);
        break;
    }
    return rc;
}
コード例 #12
0
int32_t mm_camera_set_general_parm(mm_camera_obj_t * my_obj, mm_camera_parm_t *parm)
{
	int rc = -MM_CAMERA_E_NOT_SUPPORTED;

	switch(parm->parm_type)  {
	case MM_CAMERA_PARM_EXPOSURE:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd,  
																		MSM_V4L2_PID_EXP_METERING, 
																			*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_SHARPNESS:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_SHARPNESS, 
																			*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_CONTRAST:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_CONTRAST, 
																			*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_SATURATION:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_SATURATION, 
																			*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_BRIGHTNESS:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_BRIGHTNESS, 
																			*((int *)(parm->p_value)));
  case MM_CAMERA_PARM_WHITE_BALANCE:
		return mm_camera_ctrl_set_whitebalance (my_obj,	*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_ISO:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_ISO, 
																			*((int *)(parm->p_value)) -1);
	case MM_CAMERA_PARM_ZOOM:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, V4L2_CID_ZOOM_ABSOLUTE, 
																			*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_LUMA_ADAPTATION:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_LUMA_ADAPTATION, 
																			*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_ANTIBANDING:
		return mm_camera_ctrl_set_antibanding (my_obj, *((int *)(parm->p_value)));
  case MM_CAMERA_PARM_CONTINUOUS_AF:
		return mm_camera_ctrl_set_auto_focus(my_obj, *((int *)(parm->p_value)));
	case MM_CAMERA_PARM_HJR:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_HJR, 
																			*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_EFFECT:
		return mm_camera_ctrl_set_specialEffect (my_obj, *((int *)(parm->p_value)));
	case MM_CAMERA_PARM_FPS:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_FPS, sizeof(uint16_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_FPS_MODE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_FPS_MODE, sizeof(int32_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_EXPOSURE_COMPENSATION:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_EXPOSURE_COMPENSATION, sizeof(int32_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_LED_MODE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_LED_MODE, sizeof(int32_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_ROLLOFF:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_ROLLOFF, sizeof(int32_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_MODE:
		my_obj->current_mode = *((camera_mode_t *)parm->p_value);
		break;
	case MM_CAMERA_PARM_FOCUS_RECT:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_FOCUS_RECT, sizeof(int32_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_AEC_ROI:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_AEC_ROI, sizeof(cam_set_aec_roi_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_AF_ROI:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_AF_ROI, sizeof(roi_info_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_BL_DETECTION:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_BL_DETECTION, 
																				*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_SNOW_DETECTION:
		return mm_camera_util_s_ctrl(my_obj->ctrl_fd, MSM_V4L2_PID_SNOW_DETECTION, 
																				*((int *)(parm->p_value)));
	case MM_CAMERA_PARM_BESTSHOT_MODE:
		CDBG("%s : MM_CAMERA_PARM_BESTSHOT_MODE value : %d",__func__,*((int *)(parm->p_value)));
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_BESTSHOT_MODE, sizeof(int32_t), (void *)parm->p_value);
		break;
	case MM_CAMERA_PARM_VIDEO_DIS:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_VIDEO_DIS_PARAMS, sizeof(video_dis_param_ctrl_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_VIDEO_ROT:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_VIDEO_ROT_PARAMS, sizeof(video_rotation_param_ctrl_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_SCE_FACTOR:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_SCE_FACTOR, sizeof(int32_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_FD:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_FD, sizeof(int32_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_MCE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	CAMERA_SET_PARM_MCE,
													 sizeof(int32_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_HORIZONTAL_VIEW_ANGLE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	CAMERA_GET_PARM_HORIZONTAL_VIEW_ANGLE,
													 sizeof(focus_distances_info_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_VERTICAL_VIEW_ANGLE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	CAMERA_GET_PARM_VERTICAL_VIEW_ANGLE,
													 sizeof(focus_distances_info_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_RESET_LENS_TO_INFINITY:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
							CAMERA_SET_PARM_RESET_LENS_TO_INFINITY,
							0, NULL);
  case MM_CAMERA_PARM_SNAPSHOTDATA:
		return mm_camera_send_native_ctrl_cmd(my_obj,	CAMERA_GET_PARM_SNAPSHOTDATA,
													 sizeof(snapshotData_info_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_HFR:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_HFR, sizeof(int32_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_REDEYE_REDUCTION:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_REDEYE_REDUCTION, sizeof(int32_t), (void *)parm->p_value);
  case MM_CAMERA_PARM_WAVELET_DENOISE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_WAVELET_DENOISE, sizeof(int32_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_3D_DISPLAY_DISTANCE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_3D_DISPLAY_DISTANCE, sizeof(float), (void *)parm->p_value);
	case MM_CAMERA_PARM_3D_VIEW_ANGLE:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_3D_VIEW_ANGLE, sizeof(uint32_t), (void *)parm->p_value);
	case MM_CAMERA_PARM_ZOOM_RATIO:
		break;
	case MM_CAMERA_PARM_HISTOGRAM:
		return mm_camera_send_native_ctrl_cmd(my_obj,	
					CAMERA_SET_PARM_HISTOGRAM, sizeof(int8_t), (void *)parm->p_value);
	default:
		CDBG("%s:parm %d not supported\n", __func__, parm->parm_type);
		break; 
	}
	return rc;
}