diff options
Diffstat (limited to 'isp')
| -rw-r--r-- | isp/omap3isp-priv.h | 12 | ||||
| -rw-r--r-- | isp/omap3isp.c | 153 | 
2 files changed, 88 insertions, 77 deletions
| diff --git a/isp/omap3isp-priv.h b/isp/omap3isp-priv.h index fe03d96..3e78acc 100644 --- a/isp/omap3isp-priv.h +++ b/isp/omap3isp-priv.h @@ -49,6 +49,14 @@ struct omap3_isp_video {  	bool running;  }; +/* + * struct omap3_isp_pipeline - OMAP3 pipeline + * @output: Video device at the output of the pipeline + */ +struct omap3_isp_pipeline { +	struct omap3_isp_video output; +}; +  struct omap3_isp_device {  	struct media_device *mdev; @@ -59,8 +67,8 @@ struct omap3_isp_device {  	struct v4l2_mbus_framefmt sensor_format; -	struct omap3_isp_video viewfinder; -	struct omap3_isp_video snapshot; +	struct omap3_isp_pipeline viewfinder; +	struct omap3_isp_pipeline snapshot;  	const struct omap3_isp_operations *ops;  }; diff --git a/isp/omap3isp.c b/isp/omap3isp.c index 19671c7..200cb9a 100644 --- a/isp/omap3isp.c +++ b/isp/omap3isp.c @@ -22,10 +22,12 @@  #include <errno.h>  #include <stdio.h> +#include <stdarg.h>  #include <stdlib.h>  #include <string.h>  #include "controls.h" +#include "list.h"  #include "omap3isp.h"  #include "omap3isp-priv.h"  #include "subdev.h" @@ -177,10 +179,10 @@ struct omap3_isp_device *omap3_isp_open(const char *devname,  	isp->sensor = entity; -	isp->viewfinder.scaler = OMAP3_ISP_SCALER_ISP; -	isp->viewfinder.subdev = isp->resizer; -	isp->viewfinder.node = entity_output_node(isp->resizer); -	if (isp->viewfinder.node == NULL) +	isp->viewfinder.output.scaler = OMAP3_ISP_SCALER_ISP; +	isp->viewfinder.output.subdev = isp->resizer; +	isp->viewfinder.output.node = entity_output_node(isp->resizer); +	if (isp->viewfinder.output.node == NULL)  		goto error;  	/* Retrieve the sensor default format. */ @@ -204,7 +206,7 @@ struct omap3_isp_device *omap3_isp_open(const char *devname,  	if (ret < 0)  		goto error; -	ret = setup_link(isp, isp->resizer, isp->viewfinder.node, +	ret = setup_link(isp, isp->resizer, isp->viewfinder.output.node,  			 MEDIA_LNK_FL_ENABLED);  	if (ret < 0)  		goto error; @@ -324,7 +326,7 @@ static int omap3_isp_viewfinder_setup_pipeline(struct omap3_isp_device *isp,  	int ret;  	/* Configure the formats on the pipeline. */ -	ret = omap3_isp_pipeline_set_format(isp, ofmt, isp->viewfinder.scaler, +	ret = omap3_isp_pipeline_set_format(isp, ofmt, isp->viewfinder.output.scaler,  					    V4L2_SUBDEV_FORMAT_ACTIVE);  	if (ret < 0) {  		printf("error: unable to configure formats on pipeline.\n"); @@ -346,10 +348,10 @@ int omap3_isp_viewfinder_setup(struct omap3_isp_device *isp,  		return ret;  	/* Open the V4L2 device. */ -	isp->viewfinder.video = v4l2_open(isp->viewfinder.node->devname); -	if (isp->viewfinder.video == NULL) { +	isp->viewfinder.output.video = v4l2_open(isp->viewfinder.output.node->devname); +	if (isp->viewfinder.output.video == NULL) {  		printf("error: unable to open video capture device %s\n", -			isp->viewfinder.node->devname); +			isp->viewfinder.output.node->devname);  		return -ENXIO;  	} @@ -359,11 +361,11 @@ int omap3_isp_viewfinder_setup(struct omap3_isp_device *isp,  	format.width = ofmt->width;  	format.height = ofmt->height; -	ret = v4l2_set_format(isp->viewfinder.video, &format); +	ret = v4l2_set_format(isp->viewfinder.output.video, &format);  	if (ret < 0)  		return ret; -	isp->viewfinder.format = *ofmt; +	isp->viewfinder.output.format = *ofmt;  	return 0;  } @@ -374,14 +376,14 @@ int omap3_isp_viewfinder_set_pool(struct omap3_isp_device *isp,  	int ret;  	/* Allocate video buffers. */ -	ret = v4l2_alloc_buffers(isp->viewfinder.video, pool, V4L2_MEMORY_USERPTR); +	ret = v4l2_alloc_buffers(isp->viewfinder.output.video, pool, V4L2_MEMORY_USERPTR);  	if (ret < 0) {  		printf("error: unable to allocate buffers for viewfinder.\n");  		return ret;  	} -	isp->viewfinder.dequeued = 0; -	isp->viewfinder.queued = 0; +	isp->viewfinder.output.dequeued = 0; +	isp->viewfinder.output.queued = 0;  	return 0;  } @@ -391,17 +393,17 @@ int omap3_isp_viewfinder_set_scaler(struct omap3_isp_device *isp,  	struct v4l2_mbus_framefmt format;  	int ret; -	if (isp->viewfinder.scaler == scaler) +	if (isp->viewfinder.output.scaler == scaler)  		return 0; -	isp->viewfinder.scaler = scaler; +	isp->viewfinder.output.scaler = scaler;  	/* If omap3_isp_viewfinder_setup() hasn't been called yet retur now. */ -	if (isp->viewfinder.format.width == 0 || -	    isp->viewfinder.format.height == 0) +	if (isp->viewfinder.output.format.width == 0 || +	    isp->viewfinder.output.format.height == 0)  		return 0; -	format = isp->viewfinder.format; +	format = isp->viewfinder.output.format;  	ret = omap3_isp_viewfinder_setup_pipeline(isp, &format);  	if (ret < 0)  		return ret; @@ -416,18 +418,18 @@ static void omap3_isp_viewfinder_event(void *priv)  	int ret;  	/* Dequeue the buffer */ -	ret = v4l2_dequeue_buffer(isp->viewfinder.video, &buffer); +	ret = v4l2_dequeue_buffer(isp->viewfinder.output.video, &buffer);  	if (ret < 0) {  		printf("error: unable to dequeue buffer: %s (%d)\n",  			strerror(-ret), ret);  		return;  	} -	isp->viewfinder.dequeued |= 1 << buffer.index; -	isp->viewfinder.queued--; +	isp->viewfinder.output.dequeued |= 1 << buffer.index; +	isp->viewfinder.output.queued--; -	if (isp->viewfinder.queued == 0) -		isp->ops->unwatch_fd(isp->viewfinder.video->fd); +	if (isp->viewfinder.output.queued == 0) +		isp->ops->unwatch_fd(isp->viewfinder.output.video->fd);  	isp->ops->viewfinder_ready(isp, &buffer);  } @@ -439,35 +441,36 @@ int omap3_isp_viewfinder_start(struct omap3_isp_device *isp)  	int ret;  	/* Queue all buffers for video capture. */ -	for (i = 0; i < isp->viewfinder.video->nbufs; ++i) { -		if (isp->viewfinder.dequeued & (1 << i)) +	for (i = 0; i < isp->viewfinder.output.video->nbufs; ++i) { +		if (isp->viewfinder.output.dequeued & (1 << i))  			continue;  		buffer.index = i; -		ret = v4l2_queue_buffer(isp->viewfinder.video, &buffer); +		ret = v4l2_queue_buffer(isp->viewfinder.output.video, &buffer);  		if (ret < 0) {  			printf("error: unable to queue buffer %u (%d)\n", i, ret);  			return -errno;  		} -		isp->viewfinder.queued++; +		isp->viewfinder.output.queued++;  	}  	if (isp->ops->prepare_streamon)  		isp->ops->prepare_streamon(isp);  	/* Watch the viewfinder file descriptor. */ -	isp->ops->watch_fd(isp->viewfinder.video->fd, OMAP3_ISP_EVENT_READ, -			   omap3_isp_viewfinder_event, isp); +	isp->ops->watch_fd(isp->viewfinder.output.video->fd, +			   OMAP3_ISP_EVENT_READ, omap3_isp_viewfinder_event, +			   isp); -	ret = v4l2_stream_on(isp->viewfinder.video); +	ret = v4l2_stream_on(isp->viewfinder.output.video);  	if (ret < 0) {  		printf("error: streamon failed for viewfinder\n");  		return ret;  	} -	isp->viewfinder.running = true; +	isp->viewfinder.output.running = true;  	return 0;  } @@ -476,34 +479,34 @@ int omap3_isp_viewfinder_stop(struct omap3_isp_device *isp)  {  	int ret; -	isp->ops->unwatch_fd(isp->viewfinder.video->fd); +	isp->ops->unwatch_fd(isp->viewfinder.output.video->fd); -	ret = v4l2_stream_off(isp->viewfinder.video); +	ret = v4l2_stream_off(isp->viewfinder.output.video);  	if (ret < 0) {  		printf("error: streamoff failed for viewfinder\n");  		return ret;  	} -	isp->viewfinder.queued = 0; -	isp->viewfinder.running = false; +	isp->viewfinder.output.queued = 0; +	isp->viewfinder.output.running = false;  	return 0;  }  int omap3_isp_viewfinder_put_buffer(struct omap3_isp_device *isp,  				    struct v4l2_video_buffer *buffer)  { -	isp->viewfinder.dequeued &= ~(1 << buffer->index); +	isp->viewfinder.output.dequeued &= ~(1 << buffer->index); -	if (!isp->viewfinder.running) +	if (!isp->viewfinder.output.running)  		return 0; -	if (isp->viewfinder.queued == 0) -		isp->ops->watch_fd(isp->viewfinder.video->fd, +	if (isp->viewfinder.output.queued == 0) +		isp->ops->watch_fd(isp->viewfinder.output.video->fd,  				   OMAP3_ISP_EVENT_READ,  				   omap3_isp_viewfinder_event, isp); -	isp->viewfinder.queued++; -	return v4l2_queue_buffer(isp->viewfinder.video, buffer); +	isp->viewfinder.output.queued++; +	return v4l2_queue_buffer(isp->viewfinder.output.video, buffer);  }  /* ----------------------------------------------------------------------------- @@ -517,13 +520,13 @@ static int omap3_isp_snapshot_restore_pipeline(struct omap3_isp_device *isp)  {  	int ret; -	ret = setup_link(isp, isp->snapshot.subdev, isp->snapshot.node, 0); +	ret = setup_link(isp, isp->snapshot.output.subdev, isp->snapshot.output.node, 0);  	if (ret < 0)  		return ret; -	if (isp->snapshot.format.code == V4L2_MBUS_FMT_UYVY8_1X16 || -	    isp->snapshot.format.code == V4L2_MBUS_FMT_YUYV8_1X16) -		ret = setup_link(isp, isp->viewfinder.subdev, isp->viewfinder.node, +	if (isp->snapshot.output.format.code == V4L2_MBUS_FMT_UYVY8_1X16 || +	    isp->snapshot.output.format.code == V4L2_MBUS_FMT_YUYV8_1X16) +		ret = setup_link(isp, isp->viewfinder.output.subdev, isp->viewfinder.output.node,  				 MEDIA_LNK_FL_ENABLED);  	else  		ret = setup_link(isp, isp->ccdc, isp->preview, MEDIA_LNK_FL_ENABLED); @@ -542,19 +545,19 @@ static int omap3_isp_snapshot_setup_pipeline(struct omap3_isp_device *isp,  	/*  Setup the links. */  	if (ofmt->code == V4L2_MBUS_FMT_UYVY8_1X16 ||  	    ofmt->code == V4L2_MBUS_FMT_YUYV8_1X16) -		ret = setup_link(isp, isp->viewfinder.subdev, isp->viewfinder.node, 0); +		ret = setup_link(isp, isp->viewfinder.output.subdev, isp->viewfinder.output.node, 0);  	else  		ret = setup_link(isp, isp->ccdc, isp->preview, 0);  	if (ret < 0)  		return ret; -	ret = setup_link(isp, isp->snapshot.subdev, isp->snapshot.node, +	ret = setup_link(isp, isp->snapshot.output.subdev, isp->snapshot.output.node,  			 MEDIA_LNK_FL_ENABLED);  	if (ret < 0)  		return ret;  	/* Configure the formats on the pipeline. */ -	ret = omap3_isp_pipeline_set_format(isp, ofmt, isp->snapshot.scaler, which); +	ret = omap3_isp_pipeline_set_format(isp, ofmt, isp->snapshot.output.scaler, which);  	if (ret < 0) {  		printf("error: unable to configure formats on pipeline.\n");  		return ret; @@ -585,10 +588,10 @@ int omap3_isp_snapshot_setup(struct omap3_isp_device *isp,  		break;  	} -	isp->snapshot.scaler = OMAP3_ISP_SCALER_ISP; -	isp->snapshot.subdev = entity; -	isp->snapshot.node = entity_output_node(entity); -	if (isp->snapshot.node == NULL) +	isp->snapshot.output.scaler = OMAP3_ISP_SCALER_ISP; +	isp->snapshot.output.subdev = entity; +	isp->snapshot.output.node = entity_output_node(entity); +	if (isp->snapshot.output.node == NULL)  		return -ENOENT;  	/* Try the format. */ @@ -596,17 +599,17 @@ int omap3_isp_snapshot_setup(struct omap3_isp_device *isp,  	if (ret < 0)  		return ret; -	isp->snapshot.format = *ofmt; +	isp->snapshot.output.format = *ofmt;  	ret = omap3_isp_snapshot_restore_pipeline(isp);  	if (ret < 0)  		return ret;  	/* Open the V4L2 device. */ -	isp->snapshot.video = v4l2_open(isp->snapshot.node->devname); -	if (isp->snapshot.video == NULL) { -		printf("error: unable to open snaphost capture device %s\n", -			isp->snapshot.node->devname); +	isp->snapshot.output.video = v4l2_open(isp->snapshot.output.node->devname); +	if (isp->snapshot.output.video == NULL) { +		printf("error: unable to open snapshot capture device %s\n", +			isp->snapshot.output.node->devname);  		return -ENODEV;  	} @@ -616,18 +619,18 @@ int omap3_isp_snapshot_setup(struct omap3_isp_device *isp,  	format.width = ofmt->width;  	format.height = ofmt->height; -	ret = v4l2_set_format(isp->snapshot.video, &format); +	ret = v4l2_set_format(isp->snapshot.output.video, &format);  	if (ret < 0)  		return ret;  	/* Pre-allocate capture buffers. */ -	isp->snapshot.pool = v4l2_buffers_pool_new(2); -	if (isp->snapshot.pool == NULL) { +	isp->snapshot.output.pool = v4l2_buffers_pool_new(2); +	if (isp->snapshot.output.pool == NULL) {  		printf("error: unable to allocate buffers pool for snapshot.\n");  		return -ENOMEM;  	} -	ret = v4l2_alloc_buffers(isp->snapshot.video, isp->snapshot.pool, +	ret = v4l2_alloc_buffers(isp->snapshot.output.video, isp->snapshot.output.pool,  				 V4L2_MEMORY_MMAP);  	if (ret < 0) {  		printf("error: unable to allocate buffers for snapshot.\n"); @@ -635,10 +638,10 @@ int omap3_isp_snapshot_setup(struct omap3_isp_device *isp,  	}  	/* Queue all buffers. */ -	for (i = 0; i < isp->snapshot.video->nbufs; ++i) { +	for (i = 0; i < isp->snapshot.output.video->nbufs; ++i) {  		buffer.index = i; -		ret = v4l2_queue_buffer(isp->snapshot.video, &buffer); +		ret = v4l2_queue_buffer(isp->snapshot.output.video, &buffer);  		if (ret < 0) {  			printf("error: unable to queue buffer %u\n", i);  			return -errno; @@ -657,21 +660,21 @@ static void omap3_isp_snapshot_event(void *priv)  	int ret;  	/* Dequeue a buffer, stop the stream and fire the snapshot event. */ -	ret = v4l2_dequeue_buffer(isp->snapshot.video, &buffer); +	ret = v4l2_dequeue_buffer(isp->snapshot.output.video, &buffer);  	if (ret < 0) {  		printf("error: unable to dequeue snapshot buffer.\n");  		return;  	} -	isp->ops->unwatch_fd(isp->snapshot.video->fd); +	isp->ops->unwatch_fd(isp->snapshot.output.video->fd); -	ret = v4l2_stream_off(isp->snapshot.video); +	ret = v4l2_stream_off(isp->snapshot.output.video);  	if (ret < 0) {  		printf("error: streamoff failed for snapshot\n");  		return;  	} -	isp->snapshot.running = false; +	isp->snapshot.output.running = false;  	isp->ops->snapshot_ready(isp, &buffer); @@ -680,7 +683,7 @@ static void omap3_isp_snapshot_event(void *priv)  	if (ret < 0)  		return; -	format = isp->viewfinder.format; +	format = isp->viewfinder.output.format;  	ret = omap3_isp_viewfinder_setup_pipeline(isp, &format);  	if (ret < 0)  		return; @@ -692,10 +695,10 @@ static void omap3_isp_snapshot_event(void *priv)  	}  	/* Queue all buffers for the next snapshot. */ -	for (i = 0; i < isp->snapshot.video->nbufs; ++i) { +	for (i = 0; i < isp->snapshot.output.video->nbufs; ++i) {  		buffer.index = i; -		ret = v4l2_queue_buffer(isp->snapshot.video, &buffer); +		ret = v4l2_queue_buffer(isp->snapshot.output.video, &buffer);  		if (ret < 0) {  			printf("error: unable to queue buffer %u\n", i);  			return; @@ -716,7 +719,7 @@ int omap3_isp_snapshot_capture(struct omap3_isp_device *isp)  	}  	/* Configure the pipeline. */ -	format = isp->snapshot.format; +	format = isp->snapshot.output.format;  	ret = omap3_isp_snapshot_setup_pipeline(isp, &format, V4L2_SUBDEV_FORMAT_ACTIVE);  	if (ret < 0) {  		printf("error: unable to setup snapshot pipeline.\n"); @@ -727,16 +730,16 @@ int omap3_isp_snapshot_capture(struct omap3_isp_device *isp)  		isp->ops->prepare_streamon(isp);  	/* Watch the snapshot file descriptor. */ -	isp->ops->watch_fd(isp->snapshot.video->fd, OMAP3_ISP_EVENT_READ, +	isp->ops->watch_fd(isp->snapshot.output.video->fd, OMAP3_ISP_EVENT_READ,  			   omap3_isp_snapshot_event, isp); -	ret = v4l2_stream_on(isp->snapshot.video); +	ret = v4l2_stream_on(isp->snapshot.output.video);  	if (ret < 0) {  		printf("error: streamon failed for snapshot\n");  		return ret;  	} -	isp->snapshot.running = true; +	isp->snapshot.output.running = true;  	return 0;  } | 
