Ejemplo n.º 1
0
void gst_imx_v4l2src_set_autofocus(GstPhotography *photo, gboolean on)
{
	GstImxV4l2VideoSrc *v4l2src = GST_IMX_V4L2SRC(photo);
	int locks;

	g_mutex_lock(&v4l2src->af_mutex);

	if (v4l2src->af_clock_id) {
		gst_clock_id_unschedule(v4l2src->af_clock_id);
		gst_clock_id_unref(v4l2src->af_clock_id);
		v4l2src->af_clock_id = NULL;
	}

	if (v4l2src->focus_mode == GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL) {

		if (v4l2_g_ctrl(v4l2src, V4L2_CID_3A_LOCK, &locks) == 0) {
			if (on && !(locks & V4L2_LOCK_FOCUS))
				v4l2_s_ctrl(v4l2src, V4L2_CID_3A_LOCK, locks | V4L2_LOCK_FOCUS);
			else if (!on && (locks & V4L2_LOCK_FOCUS))
				v4l2_s_ctrl(v4l2src, V4L2_CID_3A_LOCK, locks & ~V4L2_LOCK_FOCUS);
		}

	} else {

		if (on) {
			if (v4l2_s_ctrl(v4l2src, V4L2_CID_AUTO_FOCUS_START, 0) == 0)
				gst_imx_v4l2src_af_check_status(v4l2src);
		} else
			v4l2_s_ctrl(v4l2src, V4L2_CID_AUTO_FOCUS_STOP, 0);
	}

	g_mutex_unlock(&v4l2src->af_mutex);
}
Ejemplo n.º 2
0
bool BaseV4L2VideoCapture::SetExposure(uint32_t mode, int32_t value) {
  switch(mode){
    case CAMERA_FUNC_CTRL_EXPOSURE_AUTO :
      return v4l2_s_ctrl(V4L2_CID_EXPOSURE_AUTO, value);
      break;
    case CAMERA_FUNC_CTRL_EXPOSURE_ABSOLUTE :
      return v4l2_s_ctrl(V4L2_CID_EXPOSURE_ABSOLUTE, value);
      break;
    default:
      return false;
  }
  return true;
}
Ejemplo n.º 3
0
static void gst_imx_v4l2src_apply_focus_settings(GstImxV4l2VideoSrc *v4l2src,
		gboolean activate)
{
	int locks, range;

	/* even when activating, first ensure that it is not running */

	/* ensure that continuous autofocus is not running */
	v4l2_s_ctrl(v4l2src, V4L2_CID_FOCUS_AUTO, 0);
	/* ensure that single shot AF is not running */
	v4l2_s_ctrl(v4l2src, V4L2_CID_AUTO_FOCUS_STOP, 0);
	if (v4l2src->af_clock_id)
	{
		gst_clock_id_unschedule(v4l2src->af_clock_id);
		gst_clock_id_unref(v4l2src->af_clock_id);
		v4l2src->af_clock_id = NULL;
	}
	/* ensure that focus is not locked */
	if (v4l2_g_ctrl(v4l2src, V4L2_CID_3A_LOCK, &locks) == 0 && (locks & V4L2_LOCK_FOCUS))
		v4l2_s_ctrl(v4l2src, V4L2_CID_3A_LOCK, locks & ~V4L2_LOCK_FOCUS);

	if (activate)
	{
		/* set focus range */

		switch (v4l2src->focus_mode)
		{
			case GST_PHOTOGRAPHY_FOCUS_MODE_AUTO:
				range = V4L2_AUTO_FOCUS_RANGE_AUTO;
				break;
			case GST_PHOTOGRAPHY_FOCUS_MODE_MACRO:
				range = V4L2_AUTO_FOCUS_RANGE_MACRO;
				break;
			case GST_PHOTOGRAPHY_FOCUS_MODE_INFINITY:
				range = V4L2_AUTO_FOCUS_RANGE_INFINITY;
				break;
			default:
				range = V4L2_AUTO_FOCUS_RANGE_NORMAL;
				break;
		}

		v4l2_s_ctrl(v4l2src, V4L2_CID_AUTO_FOCUS_RANGE, range);

		/* enable continuous autofocus if requested */

		if (v4l2src->focus_mode == GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL)
			v4l2_s_ctrl(v4l2src, V4L2_CID_FOCUS_AUTO, 1);
	}
}
Ejemplo n.º 4
0
static int snd_cx18_mixer_tv_vol_put(struct snd_kcontrol *kctl,
				     struct snd_ctl_elem_value *uctl)
{
	struct snd_cx18_card *cxsc = snd_kcontrol_chip(kctl);
	struct cx18 *cx = to_cx18(cxsc->v4l2_dev);
	struct v4l2_control vctrl;
	int ret;

	vctrl.id = V4L2_CID_AUDIO_VOLUME;
	vctrl.value = dB_to_cx18_av_vol(uctl->value.integer.value[0]);

	snd_cx18_lock(cxsc);

	/* Fetch current state */
	ret = v4l2_g_ctrl(cx->sd_av->ctrl_handler, &vctrl);

	if (ret ||
	    (cx18_av_vol_to_dB(vctrl.value) != uctl->value.integer.value[0])) {

		/* Set, if needed */
		vctrl.value = dB_to_cx18_av_vol(uctl->value.integer.value[0]);
		ret = v4l2_s_ctrl(cx->sd_av->ctrl_handler, &vctrl);
		if (!ret)
			ret = 1; /* Indicate control was changed w/o error */
	}
	snd_cx18_unlock(cxsc);

	return ret;
}
Ejemplo n.º 5
0
bool BaseV4L2VideoCapture::SetGamma(int32_t value) {
  //return v4l2_s_ctrl(V4L2_CID_GAMMA, value);
  if(_pVideoCaptureFiltersCapability->VerifyGamma(value)){
    if(v4l2_s_ctrl(V4L2_CID_GAMMA, value)){
      _pVideoCaptureFilters->gamma = GetGamma();
      return true;
    }
    else
      return false;
  }
  else
    return false;
}
Ejemplo n.º 6
0
bool BaseV4L2VideoCapture::SetSharpness(int32_t value) {
  //return v4l2_s_ctrl(V4L2_CID_SHARPNESS, value);
  if(_pVideoCaptureFiltersCapability->VerifySharpness(value)){
    if(v4l2_s_ctrl(V4L2_CID_SHARPNESS, value)){
      _pVideoCaptureFilters->sharpness = GetSharpness();
      return true;
    }
    else
      return false;
  }
  else
    return false;
}
Ejemplo n.º 7
0
bool BaseV4L2VideoCapture::SetSaturation(int32_t value) {
  //return v4l2_s_ctrl(V4L2_CID_SATURATION, value);
  if(_pVideoCaptureFiltersCapability->VerifySaturation(value)){
    if(v4l2_s_ctrl(V4L2_CID_SATURATION, value)){
      _pVideoCaptureFilters->saturation = GetSaturation();
      return true;
    }
    else
      return false;
  }
  else
    return false;
}
Ejemplo n.º 8
0
bool BaseV4L2VideoCapture::SetHUE(int32_t value) {
  //return v4l2_s_ctrl(V4L2_CID_HUE, value);
  if(_pVideoCaptureFiltersCapability->VerifyHue(value)){
    if(v4l2_s_ctrl(V4L2_CID_HUE, value)){
      _pVideoCaptureFilters->hue = GetHUE();
      return true;
    }
    else
      return false;
  }
  else
    return false;
}
Ejemplo n.º 9
0
bool BaseV4L2VideoCapture::SetContrast(int32_t value) {
  //return v4l2_s_ctrl(V4L2_CID_CONTRAST, value);
  if(_pVideoCaptureFiltersCapability->VerifyContrast(value)){
    if(v4l2_s_ctrl(V4L2_CID_CONTRAST, value)){
      _pVideoCaptureFilters->contrast = GetContrast();
      return true;
    }
    else
      return false;
  }
  else
    return false;
}
Ejemplo n.º 10
0
bool BaseV4L2VideoCapture::SetBrightness(int32_t value) {
  //return v4l2_s_ctrl(V4L2_CID_BRIGHTNESS, value);
  if(_pVideoCaptureFiltersCapability->VerifyBrightness(value)){
    if(v4l2_s_ctrl(V4L2_CID_BRIGHTNESS, value)){
      _pVideoCaptureFilters->brightness = GetBrightness();
      return true;
    }
    else
      return false;
  }
  else
    return false;
}
Ejemplo n.º 11
0
bool BaseV4L2VideoCapture::SetBacklightCompensation(int32_t value) {
  //return v4l2_s_ctrl(V4L2_CID_BACKLIGHT_COMPENSATION, value);
  if(_pVideoCaptureFiltersCapability->VerifyBacklightCompensation(value)){
  if(v4l2_s_ctrl(V4L2_CID_BACKLIGHT_COMPENSATION, value)){
      _pVideoCaptureFilters->backlightCompensation = GetBacklightCompensation();
    return true;
    }
    else
      return false;
  }
  else
    return false;

}
Ejemplo n.º 12
0
static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
{
	struct video_device *vdev = video_devdata(file);
	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
	struct v4l2_fh *vfh = file->private_data;
#if defined(CPTCFG_VIDEO_V4L2_SUBDEV_API)
	struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
	int rval;
#endif

	switch (cmd) {
	case VIDIOC_QUERYCTRL:
		return v4l2_queryctrl(vfh->ctrl_handler, arg);

	case VIDIOC_QUERY_EXT_CTRL:
		return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);

	case VIDIOC_QUERYMENU:
		return v4l2_querymenu(vfh->ctrl_handler, arg);

	case VIDIOC_G_CTRL:
		return v4l2_g_ctrl(vfh->ctrl_handler, arg);

	case VIDIOC_S_CTRL:
		return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);

	case VIDIOC_G_EXT_CTRLS:
		return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);

	case VIDIOC_S_EXT_CTRLS:
		return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);

	case VIDIOC_TRY_EXT_CTRLS:
		return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);

	case VIDIOC_DQEVENT:
		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
			return -ENOIOCTLCMD;

		return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);

	case VIDIOC_SUBSCRIBE_EVENT:
		return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);

	case VIDIOC_UNSUBSCRIBE_EVENT:
		return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);

#ifdef CPTCFG_VIDEO_ADV_DEBUG
	case VIDIOC_DBG_G_REGISTER:
	{
		struct v4l2_dbg_register *p = arg;

		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		return v4l2_subdev_call(sd, core, g_register, p);
	}
	case VIDIOC_DBG_S_REGISTER:
	{
		struct v4l2_dbg_register *p = arg;

		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		return v4l2_subdev_call(sd, core, s_register, p);
	}
#endif

	case VIDIOC_LOG_STATUS: {
		int ret;

		pr_info("%s: =================  START STATUS  =================\n",
			sd->name);
		ret = v4l2_subdev_call(sd, core, log_status);
		pr_info("%s: ==================  END STATUS  ==================\n",
			sd->name);
		return ret;
	}

#if defined(CPTCFG_VIDEO_V4L2_SUBDEV_API)
	case VIDIOC_SUBDEV_G_FMT: {
		struct v4l2_subdev_format *format = arg;

		rval = check_format(sd, format);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
	}

	case VIDIOC_SUBDEV_S_FMT: {
		struct v4l2_subdev_format *format = arg;

		rval = check_format(sd, format);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
	}

	case VIDIOC_SUBDEV_G_CROP: {
		struct v4l2_subdev_crop *crop = arg;
		struct v4l2_subdev_selection sel;

		rval = check_crop(sd, crop);
		if (rval)
			return rval;

		memset(&sel, 0, sizeof(sel));
		sel.which = crop->which;
		sel.pad = crop->pad;
		sel.target = V4L2_SEL_TGT_CROP;

		rval = v4l2_subdev_call(
			sd, pad, get_selection, subdev_fh->pad, &sel);

		crop->rect = sel.r;

		return rval;
	}

	case VIDIOC_SUBDEV_S_CROP: {
		struct v4l2_subdev_crop *crop = arg;
		struct v4l2_subdev_selection sel;

		rval = check_crop(sd, crop);
		if (rval)
			return rval;

		memset(&sel, 0, sizeof(sel));
		sel.which = crop->which;
		sel.pad = crop->pad;
		sel.target = V4L2_SEL_TGT_CROP;
		sel.r = crop->rect;

		rval = v4l2_subdev_call(
			sd, pad, set_selection, subdev_fh->pad, &sel);

		crop->rect = sel.r;

		return rval;
	}

	case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
		struct v4l2_subdev_mbus_code_enum *code = arg;

		if (code->which != V4L2_SUBDEV_FORMAT_TRY &&
		    code->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (code->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
					code);
	}

	case VIDIOC_SUBDEV_ENUM_FRAME_SIZE: {
		struct v4l2_subdev_frame_size_enum *fse = arg;

		if (fse->which != V4L2_SUBDEV_FORMAT_TRY &&
		    fse->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (fse->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
					fse);
	}

	case VIDIOC_SUBDEV_G_FRAME_INTERVAL: {
		struct v4l2_subdev_frame_interval *fi = arg;

		if (fi->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, video, g_frame_interval, arg);
	}

	case VIDIOC_SUBDEV_S_FRAME_INTERVAL: {
		struct v4l2_subdev_frame_interval *fi = arg;

		if (fi->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, video, s_frame_interval, arg);
	}

	case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: {
		struct v4l2_subdev_frame_interval_enum *fie = arg;

		if (fie->which != V4L2_SUBDEV_FORMAT_TRY &&
		    fie->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (fie->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
					fie);
	}

	case VIDIOC_SUBDEV_G_SELECTION: {
		struct v4l2_subdev_selection *sel = arg;

		rval = check_selection(sd, sel);
		if (rval)
			return rval;

		return v4l2_subdev_call(
			sd, pad, get_selection, subdev_fh->pad, sel);
	}

	case VIDIOC_SUBDEV_S_SELECTION: {
		struct v4l2_subdev_selection *sel = arg;

		rval = check_selection(sd, sel);
		if (rval)
			return rval;

		return v4l2_subdev_call(
			sd, pad, set_selection, subdev_fh->pad, sel);
	}

	case VIDIOC_G_EDID: {
		struct v4l2_subdev_edid *edid = arg;

		rval = check_edid(sd, edid);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, get_edid, edid);
	}

	case VIDIOC_S_EDID: {
		struct v4l2_subdev_edid *edid = arg;

		rval = check_edid(sd, edid);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, set_edid, edid);
	}

	case VIDIOC_SUBDEV_DV_TIMINGS_CAP: {
		struct v4l2_dv_timings_cap *cap = arg;

		if (cap->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
	}

	case VIDIOC_SUBDEV_ENUM_DV_TIMINGS: {
		struct v4l2_enum_dv_timings *dvt = arg;

		if (dvt->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_dv_timings, dvt);
	}

	case VIDIOC_SUBDEV_QUERY_DV_TIMINGS:
		return v4l2_subdev_call(sd, video, query_dv_timings, arg);

	case VIDIOC_SUBDEV_G_DV_TIMINGS:
		return v4l2_subdev_call(sd, video, g_dv_timings, arg);

	case VIDIOC_SUBDEV_S_DV_TIMINGS:
		return v4l2_subdev_call(sd, video, s_dv_timings, arg);
#endif
	default:
		return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
	}

	return 0;
}
Ejemplo n.º 13
0
static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
{
	struct video_device *vdev = video_devdata(file);
	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
	struct v4l2_fh *vfh = file->private_data;
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
	struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
#endif

	switch (cmd) {
	case VIDIOC_QUERYCTRL:
		return v4l2_queryctrl(vfh->ctrl_handler, arg);

	case VIDIOC_QUERYMENU:
		return v4l2_querymenu(vfh->ctrl_handler, arg);

	case VIDIOC_G_CTRL:
		return v4l2_g_ctrl(vfh->ctrl_handler, arg);

	case VIDIOC_S_CTRL:
		return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);

	case VIDIOC_G_EXT_CTRLS:
		return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);

	case VIDIOC_S_EXT_CTRLS:
		return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);

	case VIDIOC_TRY_EXT_CTRLS:
		return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);

	case VIDIOC_DQEVENT:
		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
			return -ENOIOCTLCMD;

		return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);

	case VIDIOC_SUBSCRIBE_EVENT:
		return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);

	case VIDIOC_UNSUBSCRIBE_EVENT:
		return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);

#ifdef CONFIG_VIDEO_ADV_DEBUG
	case VIDIOC_DBG_G_REGISTER:
	{
		struct v4l2_dbg_register *p = arg;

		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		return v4l2_subdev_call(sd, core, g_register, p);
	}
	case VIDIOC_DBG_S_REGISTER:
	{
		struct v4l2_dbg_register *p = arg;

		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		return v4l2_subdev_call(sd, core, s_register, p);
	}
#endif

	case VIDIOC_LOG_STATUS:
		return v4l2_subdev_call(sd, core, log_status);

#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
	case VIDIOC_SUBDEV_G_FMT: {
		struct v4l2_subdev_format *format = arg;

		if (format->which != V4L2_SUBDEV_FORMAT_TRY &&
		    format->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (format->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh, format);
	}

	case VIDIOC_SUBDEV_S_FMT: {
		struct v4l2_subdev_format *format = arg;

		if (format->which != V4L2_SUBDEV_FORMAT_TRY &&
		    format->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (format->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh, format);
	}

	case VIDIOC_SUBDEV_G_CROP: {
		struct v4l2_subdev_crop *crop = arg;

		if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
		    crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (crop->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop);
	}

	case VIDIOC_SUBDEV_S_CROP: {
		struct v4l2_subdev_crop *crop = arg;

		if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
		    crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (crop->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop);
	}

	case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
		struct v4l2_subdev_mbus_code_enum *code = arg;

		if (code->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh,
					code);
	}

	case VIDIOC_SUBDEV_ENUM_FRAME_SIZE: {
		struct v4l2_subdev_frame_size_enum *fse = arg;

		if (fse->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh,
					fse);
	}

	case VIDIOC_SUBDEV_G_FRAME_INTERVAL:
		return v4l2_subdev_call(sd, video, g_frame_interval, arg);

	case VIDIOC_SUBDEV_S_FRAME_INTERVAL:
		return v4l2_subdev_call(sd, video, s_frame_interval, arg);

	case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: {
		struct v4l2_subdev_frame_interval_enum *fie = arg;

		if (fie->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh,
					fie);
	}
#endif
	default:
		return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
	}

	return 0;
}
Ejemplo n.º 14
0
bool BaseV4L2VideoCapture::SetZoom(int32_t value) {
  return v4l2_s_ctrl(V4L2_CID_ZOOM_ABSOLUTE, value);
}
Ejemplo n.º 15
0
bool BaseV4L2VideoCapture::SetGain(uint32_t mode, int32_t value) {
  return v4l2_s_ctrl(mode, value);
}
Ejemplo n.º 16
0
bool BaseV4L2VideoCapture::SetFlip(int8_t value) {
  return v4l2_s_ctrl(V4L2_CID_HFLIP, value);
}