diff options
| -rw-r--r-- | stream.c | 21 | ||||
| -rw-r--r-- | stream.h | 5 | ||||
| -rw-r--r-- | uvc.c | 20 | ||||
| -rw-r--r-- | uvc.h | 1 | 
4 files changed, 30 insertions, 17 deletions
| @@ -167,29 +167,20 @@ void uvc_stream_enable(struct uvc_stream *stream, int enable)  	}  } -int uvc_stream_set_format(struct uvc_stream *stream) +int uvc_stream_set_format(struct uvc_stream *stream, +			  const struct v4l2_pix_format *format)  { -	struct v4l2_device *cap = stream->cap; -	struct uvc_device *dev = stream->uvc; -	struct v4l2_pix_format fmt; +	struct v4l2_pix_format fmt = *format;  	int ret;  	printf("Setting format to 0x%08x %ux%u\n", -		dev->fcc, dev->width, dev->height); - -	memset(&fmt, 0, sizeof fmt); -	fmt.width = dev->width; -	fmt.height = dev->height; -	fmt.pixelformat = dev->fcc; -	fmt.field = V4L2_FIELD_NONE; -	if (dev->fcc == V4L2_PIX_FMT_MJPEG) -		fmt.sizeimage = dev->maxsize * 1.5; +		format->pixelformat, format->width, format->height); -	ret = v4l2_set_format(dev->vdev, &fmt); +	ret = uvc_set_format(stream->uvc, &fmt);  	if (ret < 0)  		return ret; -	return v4l2_set_format(cap, &fmt); +	return v4l2_set_format(stream->cap, &fmt);  }  /* --------------------------------------------------------------------------- @@ -23,6 +23,7 @@  struct events;  struct uvc_function_config;  struct uvc_stream; +struct v4l2_pix_format;  /*   * uvc_stream_new - Create a new UVC stream @@ -87,13 +88,15 @@ void uvc_stream_delete(struct uvc_stream *stream);  /*   * uvc_stream_set_format - Set the active video format for the stream   * @stream: the UVC stream + * @format: the video stream format   *   * This function is called from the UVC protocol handler to configure the video   * format for the @stream. It must not be called directly by applications.   *   * Returns 0 on success, or a negative error code on failure.   */ -int uvc_stream_set_format(struct uvc_stream *stream); +int uvc_stream_set_format(struct uvc_stream *stream, +			  const struct v4l2_pix_format *format);  /*   * uvc_stream_enable - Turn on/off video streaming for the UVC stream @@ -260,6 +260,7 @@ uvc_events_process_data(struct uvc_device *dev,  	if (dev->control == UVC_VS_COMMIT_CONTROL) {  		const struct uvc_function_config_format *format;  		const struct uvc_function_config_frame *frame; +		struct v4l2_pix_format pixfmt;  		format = &dev->fc->streaming.formats[target->bFormatIndex-1];  		frame = &format->frames[target->bFrameIndex-1]; @@ -268,7 +269,15 @@ uvc_events_process_data(struct uvc_device *dev,  		dev->width = frame->width;  		dev->height = frame->height; -		uvc_stream_set_format(dev->stream); +		memset(&pixfmt, 0, sizeof pixfmt); +		pixfmt.width = frame->width; +		pixfmt.height = frame->height; +		pixfmt.pixelformat = format->fcc; +		pixfmt.field = V4L2_FIELD_NONE; +		if (format->fcc == V4L2_PIX_FMT_MJPEG) +			pixfmt.sizeimage = dev->maxsize * 1.5; + +		uvc_stream_set_format(dev->stream, &pixfmt);  	}  } @@ -320,6 +329,10 @@ static void uvc_events_process(void *d)  	}  } +/* --------------------------------------------------------------------------- + * Initialization and setup + */ +  void uvc_events_init(struct uvc_device *dev, struct events *events)  {  	struct v4l2_event_subscription sub; @@ -346,3 +359,8 @@ void uvc_set_config(struct uvc_device *dev, struct uvc_function_config *fc)  {  	dev->fc = fc;  } + +int uvc_set_format(struct uvc_device *dev, struct v4l2_pix_format *format) +{ +	return v4l2_set_format(dev->vdev, format); +} @@ -49,5 +49,6 @@ struct uvc_device *uvc_open(const char *devname, struct uvc_stream *stream);  void uvc_close(struct uvc_device *dev);  void uvc_events_init(struct uvc_device *dev, struct events *events);  void uvc_set_config(struct uvc_device *dev, struct uvc_function_config *fc); +int uvc_set_format(struct uvc_device *dev, struct v4l2_pix_format *format);  #endif /* __UVC_H__ */ | 
