示例#1
0
static int ivtv_prep_dev(struct ivtv *itv, int type)
{
	struct ivtv_stream *s = &itv->streams[type];
	int num_offset = ivtv_stream_info[type].num_offset;
	int num = itv->instance + ivtv_first_minor + num_offset;

	/* These four fields are always initialized. If vdev == NULL, then
	   this stream is not in use. In that case no other fields but these
	   four can be used. */
	s->vdev = NULL;
	s->itv = itv;
	s->type = type;
	s->name = ivtv_stream_info[type].name;

	/* Check whether the radio is supported */
	if (type == IVTV_ENC_STREAM_TYPE_RAD && !(itv->v4l2_cap & V4L2_CAP_RADIO))
		return 0;
	if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
		return 0;

	/* User explicitly selected 0 buffers for these streams, so don't
	   create them. */
	if (ivtv_stream_info[type].dma != PCI_DMA_NONE &&
	    itv->options.kilobytes[type] == 0) {
		IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name);
		return 0;
	}

	ivtv_stream_init(itv, type);

	/* allocate and initialize the v4l2 video device structure */
	s->vdev = video_device_alloc();
	if (s->vdev == NULL) {
		IVTV_ERR("Couldn't allocate v4l2 video_device for %s\n", s->name);
		return -ENOMEM;
	}

	snprintf(s->vdev->name, sizeof(s->vdev->name), "%s %s",
			itv->v4l2_dev.name, s->name);

	s->vdev->num = num;
	s->vdev->v4l2_dev = &itv->v4l2_dev;
	s->vdev->fops = ivtv_stream_info[type].fops;
	s->vdev->ctrl_handler = itv->v4l2_dev.ctrl_handler;
	s->vdev->release = video_device_release;
	s->vdev->tvnorms = V4L2_STD_ALL;
	s->vdev->lock = &itv->serialize_lock;
	/* Locking in file operations other than ioctl should be done
	   by the driver, not the V4L2 core.
	   This driver needs auditing so that this flag can be removed. */
	set_bit(V4L2_FL_LOCK_ALL_FOPS, &s->vdev->flags);
	set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev->flags);
	ivtv_set_funcs(s->vdev);
	return 0;
}
static int ivtv_prep_dev(struct ivtv *itv, int type)
{
	struct ivtv_stream *s = &itv->streams[type];
	int num_offset = ivtv_stream_info[type].num_offset;
	int num = itv->instance + ivtv_first_minor + num_offset;

	/*                                                                
                                                                     
                      */
	s->vdev = NULL;
	s->itv = itv;
	s->type = type;
	s->name = ivtv_stream_info[type].name;

	/*                                      */
	if (type == IVTV_ENC_STREAM_TYPE_RAD && !(itv->v4l2_cap & V4L2_CAP_RADIO))
		return 0;
	if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
		return 0;

	/*                                                               
                 */
	if (ivtv_stream_info[type].dma != PCI_DMA_NONE &&
	    itv->options.kilobytes[type] == 0) {
		IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name);
		return 0;
	}

	ivtv_stream_init(itv, type);

	/*                                                         */
	s->vdev = video_device_alloc();
	if (s->vdev == NULL) {
		IVTV_ERR("Couldn't allocate v4l2 video_device for %s\n", s->name);
		return -ENOMEM;
	}

	snprintf(s->vdev->name, sizeof(s->vdev->name), "%s %s",
			itv->v4l2_dev.name, s->name);

	s->vdev->num = num;
	s->vdev->v4l2_dev = &itv->v4l2_dev;
	s->vdev->fops = ivtv_stream_info[type].fops;
	s->vdev->ctrl_handler = itv->v4l2_dev.ctrl_handler;
	s->vdev->release = video_device_release;
	s->vdev->tvnorms = V4L2_STD_ALL;
	s->vdev->lock = &itv->serialize_lock;
	set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev->flags);
	ivtv_set_funcs(s->vdev);
	return 0;
}
示例#3
0
static int ivtv_prep_dev(struct ivtv *itv, int type)
{
	struct ivtv_stream *s = &itv->streams[type];
	int num_offset = ivtv_stream_info[type].num_offset;
	int num = itv->instance + ivtv_first_minor + num_offset;

	/* These four fields are always initialized. If v4l2dev == NULL, then
	   this stream is not in use. In that case no other fields but these
	   four can be used. */
	s->v4l2dev = NULL;
	s->itv = itv;
	s->type = type;
	s->name = ivtv_stream_info[type].name;

	/* Check whether the radio is supported */
	if (type == IVTV_ENC_STREAM_TYPE_RAD && !(itv->v4l2_cap & V4L2_CAP_RADIO))
		return 0;
	if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
		return 0;

	/* User explicitly selected 0 buffers for these streams, so don't
	   create them. */
	if (ivtv_stream_info[type].dma != PCI_DMA_NONE &&
	    itv->options.kilobytes[type] == 0) {
		IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name);
		return 0;
	}

	ivtv_stream_init(itv, type);

	/* allocate and initialize the v4l2 video device structure */
	s->v4l2dev = video_device_alloc();
	if (s->v4l2dev == NULL) {
		IVTV_ERR("Couldn't allocate v4l2 video_device for %s\n", s->name);
		return -ENOMEM;
	}

	snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "%s %s",
			itv->device.name, s->name);

	s->v4l2dev->num = num;
	s->v4l2dev->v4l2_dev = &itv->device;
	s->v4l2dev->fops = ivtv_stream_info[type].fops;
	s->v4l2dev->release = video_device_release;
	s->v4l2dev->tvnorms = V4L2_STD_ALL;
	ivtv_set_funcs(s->v4l2dev);
	return 0;
}
示例#4
0
static int ivtv_reg_dev(struct ivtv *itv, int type)
{
	struct ivtv_stream *s = &itv->streams[type];
	int vfl_type = ivtv_stream_info[type].vfl_type;
	int minor_offset = ivtv_stream_info[type].minor_offset;
	int minor;

	/* These four fields are always initialized. If v4l2dev == NULL, then
	   this stream is not in use. In that case no other fields but these
	   four can be used. */
	s->v4l2dev = NULL;
	s->itv = itv;
	s->type = type;
	s->name = ivtv_stream_info[type].name;

	/* Check whether the radio is supported */
	if (type == IVTV_ENC_STREAM_TYPE_RAD && !(itv->v4l2_cap & V4L2_CAP_RADIO))
		return 0;
	if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
		return 0;

	if (minor_offset >= 0)
		/* card number + user defined offset + device offset */
		minor = itv->num + ivtv_first_minor + minor_offset;
	else
		minor = -1;

	/* User explicitly selected 0 buffers for these streams, so don't
	   create them. */
	if (minor >= 0 && ivtv_stream_info[type].dma != PCI_DMA_NONE &&
	    itv->options.megabytes[type] == 0) {
		IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name);
		return 0;
	}

	ivtv_stream_init(itv, type);

	/* allocate and initialize the v4l2 video device structure */
	s->v4l2dev = video_device_alloc();
	if (s->v4l2dev == NULL) {
		IVTV_ERR("Couldn't allocate v4l2 video_device for %s\n", s->name);
		return -ENOMEM;
	}

	s->v4l2dev->type = VID_TYPE_CAPTURE | VID_TYPE_TUNER | VID_TYPE_TELETEXT |
		    VID_TYPE_CLIPPING | VID_TYPE_SCALES | VID_TYPE_MPEG_ENCODER;
	if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
		s->v4l2dev->type |= VID_TYPE_MPEG_DECODER;
	}
	snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "ivtv%d %s",
			itv->num, s->name);

	s->v4l2dev->minor = minor;
	s->v4l2dev->dev = &itv->dev->dev;
	s->v4l2dev->fops = ivtv_stream_info[type].fops;
	s->v4l2dev->release = video_device_release;

	if (minor >= 0) {
		/* Register device. First try the desired minor, then any free one. */
		if (video_register_device(s->v4l2dev, vfl_type, minor) &&
		    video_register_device(s->v4l2dev, vfl_type, -1)) {
			IVTV_ERR("Couldn't register v4l2 device for %s minor %d\n",
					s->name, minor);
			video_device_release(s->v4l2dev);
			s->v4l2dev = NULL;
			return -ENOMEM;
		}
	}
	else {
		/* Don't register a 'hidden' stream (OSD) */
		IVTV_INFO("Created framebuffer stream for %s\n", s->name);
		return 0;
	}

	switch (vfl_type) {
	case VFL_TYPE_GRABBER:
		IVTV_INFO("Registered device video%d for %s (%d MB)\n",
			s->v4l2dev->minor, s->name, itv->options.megabytes[type]);
		break;
	case VFL_TYPE_RADIO:
		IVTV_INFO("Registered device radio%d for %s\n",
			s->v4l2dev->minor - MINOR_VFL_TYPE_RADIO_MIN, s->name);
		break;
	case VFL_TYPE_VBI:
		if (itv->options.megabytes[type])
			IVTV_INFO("Registered device vbi%d for %s (%d MB)\n",
				s->v4l2dev->minor - MINOR_VFL_TYPE_VBI_MIN,
				s->name, itv->options.megabytes[type]);
		else
			IVTV_INFO("Registered device vbi%d for %s\n",
				s->v4l2dev->minor - MINOR_VFL_TYPE_VBI_MIN, s->name);
		break;
	}
	return 0;
}