| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * ispvideo.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * TI OMAP3 ISP - Generic video node | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2009-2010 Nokia Corporation | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 
					
						
							|  |  |  |  *	     Sakari Ailus <sakari.ailus@iki.fi> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License version 2 as | 
					
						
							|  |  |  |  * published by the Free Software Foundation. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef OMAP3_ISP_VIDEO_H
 | 
					
						
							|  |  |  | #define OMAP3_ISP_VIDEO_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/v4l2-mediabus.h>
 | 
					
						
							|  |  |  | #include <media/media-entity.h>
 | 
					
						
							|  |  |  | #include <media/v4l2-dev.h>
 | 
					
						
							|  |  |  | #include <media/v4l2-fh.h>
 | 
					
						
							| 
									
										
										
										
											2014-03-09 20:36:15 -03:00
										 |  |  | #include <media/videobuf2-core.h>
 | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define ISP_VIDEO_DRIVER_NAME		"ispvideo"
 | 
					
						
							| 
									
										
										
										
											2011-06-25 11:28:37 -03:00
										 |  |  | #define ISP_VIDEO_DRIVER_VERSION	"0.0.2"
 | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct isp_device; | 
					
						
							|  |  |  | struct isp_video; | 
					
						
							|  |  |  | struct v4l2_mbus_framefmt; | 
					
						
							|  |  |  | struct v4l2_pix_format; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * struct isp_format_info - ISP media bus format information | 
					
						
							|  |  |  |  * @code: V4L2 media bus format code | 
					
						
							|  |  |  |  * @truncated: V4L2 media bus format code for the same format truncated to 10 | 
					
						
							|  |  |  |  *	bits. Identical to @code if the format is 10 bits wide or less. | 
					
						
							|  |  |  |  * @uncompressed: V4L2 media bus format code for the corresponding uncompressed | 
					
						
							|  |  |  |  *	format. Identical to @code if the format is not DPCM compressed. | 
					
						
							| 
									
										
										
										
											2011-03-29 05:19:09 -03:00
										 |  |  |  * @flavor: V4L2 media bus format code for the same pixel layout but | 
					
						
							|  |  |  |  *	shifted to be 8 bits per pixel. =0 if format is not shiftable. | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  |  * @pixelformat: V4L2 pixel format FCC identifier | 
					
						
							| 
									
										
										
										
											2011-08-31 11:57:12 -03:00
										 |  |  |  * @width: Bits per pixel (when transferred over a bus) | 
					
						
							|  |  |  |  * @bpp: Bytes per pixel (when stored in memory) | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  |  */ | 
					
						
							|  |  |  | struct isp_format_info { | 
					
						
							|  |  |  | 	enum v4l2_mbus_pixelcode code; | 
					
						
							|  |  |  | 	enum v4l2_mbus_pixelcode truncated; | 
					
						
							|  |  |  | 	enum v4l2_mbus_pixelcode uncompressed; | 
					
						
							| 
									
										
										
										
											2011-03-29 05:19:09 -03:00
										 |  |  | 	enum v4l2_mbus_pixelcode flavor; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 	u32 pixelformat; | 
					
						
							| 
									
										
										
										
											2011-08-31 11:57:12 -03:00
										 |  |  | 	unsigned int width; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 	unsigned int bpp; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum isp_pipeline_stream_state { | 
					
						
							|  |  |  | 	ISP_PIPELINE_STREAM_STOPPED = 0, | 
					
						
							|  |  |  | 	ISP_PIPELINE_STREAM_CONTINUOUS = 1, | 
					
						
							|  |  |  | 	ISP_PIPELINE_STREAM_SINGLESHOT = 2, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum isp_pipeline_state { | 
					
						
							|  |  |  | 	/* The stream has been started on the input video node. */ | 
					
						
							|  |  |  | 	ISP_PIPELINE_STREAM_INPUT = 1, | 
					
						
							|  |  |  | 	/* The stream has been started on the output video node. */ | 
					
						
							|  |  |  | 	ISP_PIPELINE_STREAM_OUTPUT = 2, | 
					
						
							|  |  |  | 	/* At least one buffer is queued on the input video node. */ | 
					
						
							|  |  |  | 	ISP_PIPELINE_QUEUE_INPUT = 4, | 
					
						
							|  |  |  | 	/* At least one buffer is queued on the output video node. */ | 
					
						
							|  |  |  | 	ISP_PIPELINE_QUEUE_OUTPUT = 8, | 
					
						
							|  |  |  | 	/* The input entity is idle, ready to be started. */ | 
					
						
							|  |  |  | 	ISP_PIPELINE_IDLE_INPUT = 16, | 
					
						
							|  |  |  | 	/* The output entity is idle, ready to be started. */ | 
					
						
							|  |  |  | 	ISP_PIPELINE_IDLE_OUTPUT = 32, | 
					
						
							|  |  |  | 	/* The pipeline is currently streaming. */ | 
					
						
							|  |  |  | 	ISP_PIPELINE_STREAM = 64, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-07 08:34:50 -03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * struct isp_pipeline - An ISP hardware pipeline | 
					
						
							| 
									
										
										
										
											2014-05-19 16:37:38 -03:00
										 |  |  |  * @field: The field being processed by the pipeline | 
					
						
							| 
									
										
										
										
											2011-12-07 08:34:50 -03:00
										 |  |  |  * @error: A hardware error occurred during capture | 
					
						
							| 
									
										
										
										
											2011-11-18 11:28:24 -03:00
										 |  |  |  * @entities: Bitmask of entities in the pipeline (indexed by entity ID) | 
					
						
							| 
									
										
										
										
											2011-12-07 08:34:50 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | struct isp_pipeline { | 
					
						
							|  |  |  | 	struct media_pipeline pipe; | 
					
						
							|  |  |  | 	spinlock_t lock;		/* Pipeline state and queue flags */ | 
					
						
							|  |  |  | 	unsigned int state; | 
					
						
							|  |  |  | 	enum isp_pipeline_stream_state stream_state; | 
					
						
							|  |  |  | 	struct isp_video *input; | 
					
						
							|  |  |  | 	struct isp_video *output; | 
					
						
							| 
									
										
										
										
											2011-11-18 11:28:24 -03:00
										 |  |  | 	u32 entities; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 	unsigned long l3_ick; | 
					
						
							|  |  |  | 	unsigned int max_rate; | 
					
						
							| 
									
										
										
										
											2014-05-19 16:37:38 -03:00
										 |  |  | 	enum v4l2_field field; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 	atomic_t frame_number; | 
					
						
							|  |  |  | 	bool do_propagation; /* of frame number */ | 
					
						
							| 
									
										
										
										
											2011-12-07 08:34:50 -03:00
										 |  |  | 	bool error; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 	struct v4l2_fract max_timeperframe; | 
					
						
							| 
									
										
										
										
											2012-01-16 18:58:01 -03:00
										 |  |  | 	struct v4l2_subdev *external; | 
					
						
							|  |  |  | 	unsigned int external_rate; | 
					
						
							| 
									
										
										
										
											2011-08-31 11:57:12 -03:00
										 |  |  | 	unsigned int external_width; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define to_isp_pipeline(__e) \
 | 
					
						
							|  |  |  | 	container_of((__e)->pipe, struct isp_pipeline, pipe) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline int isp_pipeline_ready(struct isp_pipeline *pipe) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return pipe->state == (ISP_PIPELINE_STREAM_INPUT | | 
					
						
							|  |  |  | 			       ISP_PIPELINE_STREAM_OUTPUT | | 
					
						
							|  |  |  | 			       ISP_PIPELINE_QUEUE_INPUT | | 
					
						
							|  |  |  | 			       ISP_PIPELINE_QUEUE_OUTPUT | | 
					
						
							|  |  |  | 			       ISP_PIPELINE_IDLE_INPUT | | 
					
						
							|  |  |  | 			       ISP_PIPELINE_IDLE_OUTPUT); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-09 20:36:15 -03:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * struct isp_buffer - ISP video buffer | 
					
						
							|  |  |  |  * @vb: videobuf2 buffer | 
					
						
							| 
									
										
										
										
											2014-03-09 20:57:53 -03:00
										 |  |  |  * @irqlist: List head for insertion into IRQ queue | 
					
						
							| 
									
										
										
										
											2014-03-09 20:17:12 -03:00
										 |  |  |  * @dma: DMA address | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  |  */ | 
					
						
							|  |  |  | struct isp_buffer { | 
					
						
							| 
									
										
										
										
											2014-03-09 20:36:15 -03:00
										 |  |  | 	struct vb2_buffer vb; | 
					
						
							| 
									
										
										
										
											2014-03-09 20:57:53 -03:00
										 |  |  | 	struct list_head irqlist; | 
					
						
							| 
									
										
										
										
											2014-03-09 20:17:12 -03:00
										 |  |  | 	dma_addr_t dma; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-09 20:36:15 -03:00
										 |  |  | #define to_isp_buffer(buf)	container_of(buf, struct isp_buffer, vb)
 | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum isp_video_dmaqueue_flags { | 
					
						
							|  |  |  | 	/* Set if DMA queue becomes empty when ISP_PIPELINE_STREAM_CONTINUOUS */ | 
					
						
							|  |  |  | 	ISP_VIDEO_DMAQUEUE_UNDERRUN = (1 << 0), | 
					
						
							|  |  |  | 	/* Set when queuing buffer to an empty DMA queue */ | 
					
						
							|  |  |  | 	ISP_VIDEO_DMAQUEUE_QUEUED = (1 << 1), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define isp_video_dmaqueue_flags_clr(video)	\
 | 
					
						
							|  |  |  | 			({ (video)->dmaqueue_flags = 0; }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * struct isp_video_operations - ISP video operations | 
					
						
							|  |  |  |  * @queue:	Resume streaming when a buffer is queued. Called on VIDIOC_QBUF | 
					
						
							|  |  |  |  *		if there was no buffer previously queued. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | struct isp_video_operations { | 
					
						
							|  |  |  | 	int(*queue)(struct isp_video *video, struct isp_buffer *buffer); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct isp_video { | 
					
						
							|  |  |  | 	struct video_device video; | 
					
						
							|  |  |  | 	enum v4l2_buf_type type; | 
					
						
							|  |  |  | 	struct media_pad pad; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct mutex mutex;		/* format and crop settings */ | 
					
						
							|  |  |  | 	atomic_t active; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct isp_device *isp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	unsigned int capture_mem; | 
					
						
							|  |  |  | 	unsigned int bpl_alignment;	/* alignment value */ | 
					
						
							|  |  |  | 	unsigned int bpl_zero_padding;	/* whether the alignment is optional */ | 
					
						
							|  |  |  | 	unsigned int bpl_max;		/* maximum bytes per line value */ | 
					
						
							|  |  |  | 	unsigned int bpl_value;		/* bytes per line value */ | 
					
						
							|  |  |  | 	unsigned int bpl_padding;	/* padding at end of line */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Pipeline state */ | 
					
						
							|  |  |  | 	struct isp_pipeline pipe; | 
					
						
							|  |  |  | 	struct mutex stream_lock;	/* pipeline and stream states */ | 
					
						
							| 
									
										
										
										
											2013-12-09 11:36:51 -03:00
										 |  |  | 	bool error; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Video buffers queue */ | 
					
						
							| 
									
										
										
										
											2014-03-09 20:36:15 -03:00
										 |  |  | 	void *alloc_ctx; | 
					
						
							|  |  |  | 	struct vb2_queue *queue; | 
					
						
							| 
									
										
										
										
											2014-03-09 20:57:53 -03:00
										 |  |  | 	struct mutex queue_lock;	/* protects the queue */ | 
					
						
							| 
									
										
										
										
											2014-03-09 20:57:53 -03:00
										 |  |  | 	spinlock_t irqlock;		/* protects dmaqueue */ | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 	struct list_head dmaqueue; | 
					
						
							|  |  |  | 	enum isp_video_dmaqueue_flags dmaqueue_flags; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const struct isp_video_operations *ops; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define to_isp_video(vdev)	container_of(vdev, struct isp_video, video)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct isp_video_fh { | 
					
						
							|  |  |  | 	struct v4l2_fh vfh; | 
					
						
							|  |  |  | 	struct isp_video *video; | 
					
						
							| 
									
										
										
										
											2014-03-09 20:36:15 -03:00
										 |  |  | 	struct vb2_queue queue; | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | 	struct v4l2_format format; | 
					
						
							|  |  |  | 	struct v4l2_fract timeperframe; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define to_isp_video_fh(fh)	container_of(fh, struct isp_video_fh, vfh)
 | 
					
						
							|  |  |  | #define isp_video_queue_to_isp_video_fh(q) \
 | 
					
						
							|  |  |  | 				container_of(q, struct isp_video_fh, queue) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int omap3isp_video_init(struct isp_video *video, const char *name); | 
					
						
							| 
									
										
										
										
											2011-09-22 16:54:34 -03:00
										 |  |  | void omap3isp_video_cleanup(struct isp_video *video); | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | int omap3isp_video_register(struct isp_video *video, | 
					
						
							|  |  |  | 			    struct v4l2_device *vdev); | 
					
						
							|  |  |  | void omap3isp_video_unregister(struct isp_video *video); | 
					
						
							| 
									
										
										
										
											2011-12-07 08:34:50 -03:00
										 |  |  | struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video); | 
					
						
							| 
									
										
										
										
											2013-12-09 11:36:51 -03:00
										 |  |  | void omap3isp_video_cancel_stream(struct isp_video *video); | 
					
						
							| 
									
										
										
										
											2011-02-12 18:05:06 -03:00
										 |  |  | void omap3isp_video_resume(struct isp_video *video, int continuous); | 
					
						
							|  |  |  | struct media_pad *omap3isp_video_remote_pad(struct isp_video *video); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const struct isp_format_info * | 
					
						
							|  |  |  | omap3isp_video_format_info(enum v4l2_mbus_pixelcode code); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* OMAP3_ISP_VIDEO_H */
 |