2 * Copyright (C) 2012 Texas Instruments Inc
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Manjunath Hadli <manjunath.hadli@ti.com>
19 * Prabhakar Lad <prabhakar.lad@ti.com>
22 #ifndef _DAVINCI_VPFE_VIDEO_H
23 #define _DAVINCI_VPFE_VIDEO_H
25 #include <media/videobuf2-v4l2.h>
26 #include <media/videobuf2-dma-contig.h>
31 * struct vpfe_video_operations - VPFE video operations
32 * @queue: Resume streaming when a buffer is queued. Called on VIDIOC_QBUF
33 * if there was no buffer previously queued.
35 struct vpfe_video_operations {
36 int (*queue)(struct vpfe_device *vpfe_dev, unsigned long addr);
39 enum vpfe_pipeline_stream_state {
40 VPFE_PIPELINE_STREAM_STOPPED = 0,
41 VPFE_PIPELINE_STREAM_CONTINUOUS = 1,
42 VPFE_PIPELINE_STREAM_SINGLESHOT = 2,
45 enum vpfe_video_state {
46 /* indicates that buffer is not queued */
47 VPFE_VIDEO_BUFFER_NOT_QUEUED = 0,
48 /* indicates that buffer is queued */
49 VPFE_VIDEO_BUFFER_QUEUED = 1,
52 struct vpfe_pipeline {
54 struct media_pipeline *pipe;
55 /* state of the pipeline, continuous,
56 * single-shot or stopped
58 enum vpfe_pipeline_stream_state state;
59 /* number of active input video entities */
60 unsigned int input_num;
61 /* number of active output video entities */
62 unsigned int output_num;
63 /* input video nodes in case of single-shot mode */
64 struct vpfe_video_device *inputs[10];
65 /* capturing video nodes */
66 struct vpfe_video_device *outputs[10];
69 #define to_vpfe_pipeline(__e) \
70 container_of((__e)->pipe, struct vpfe_pipeline, pipe)
72 #define to_vpfe_video(vdev) \
73 container_of(vdev, struct vpfe_video_device, video_dev)
75 struct vpfe_cap_buffer {
76 struct vb2_v4l2_buffer vb;
77 struct list_head list;
80 struct vpfe_video_device {
82 struct vpfe_device *vpfe_dev;
84 struct video_device video_dev;
85 /* media pad of video entity */
87 /* video operations supported by video device */
88 const struct vpfe_video_operations *ops;
89 /* type of the video buffers used by user */
90 enum v4l2_buf_type type;
91 /* Indicates id of the field which is being captured */
93 /* pipeline for which video device is part of */
94 struct vpfe_pipeline pipe;
95 /* Indicates whether streaming started */
97 /* Indicates state of the stream */
99 /* current input at the sub device */
102 * This field keeps track of type of buffer exchange mechanism
105 enum v4l2_memory memory;
106 /* number of open instances of the channel */
108 /* flag to indicate whether decoder is initialized */
110 /* skip frame count */
112 /* skip frame count init value */
113 u8 skip_frame_count_init;
114 /* time per frame for skipping */
115 struct v4l2_fract timeperframe;
116 /* ptr to currently selected sub device */
117 struct vpfe_ext_subdev_info *current_ext_subdev;
118 /* Pointer pointing to current vpfe_cap_buffer */
119 struct vpfe_cap_buffer *cur_frm;
120 /* Pointer pointing to next vpfe_cap_buffer */
121 struct vpfe_cap_buffer *next_frm;
122 /* Used to store pixel format */
123 struct v4l2_format fmt;
124 struct vb2_queue buffer_queue;
125 /* allocator-specific contexts for each plane */
126 struct vb2_alloc_ctx *alloc_ctx;
127 /* Queue of filled frames */
128 struct list_head dma_queue;
130 /* IRQ lock for DMA queue */
131 spinlock_t dma_queue_lock;
132 /* lock used to access this structure */
134 /* number of users performing IO */
136 /* Currently selected or default standard */
139 * offset where second field starts from the starting of the
140 * buffer for field separated YCbCr formats
145 int vpfe_video_is_pipe_ready(struct vpfe_pipeline *pipe);
146 void vpfe_video_unregister(struct vpfe_video_device *video);
147 int vpfe_video_register(struct vpfe_video_device *video,
148 struct v4l2_device *vdev);
149 int vpfe_video_init(struct vpfe_video_device *video, const char *name);
150 void vpfe_video_process_buffer_complete(struct vpfe_video_device *video);
151 void vpfe_video_schedule_bottom_field(struct vpfe_video_device *video);
152 void vpfe_video_schedule_next_buffer(struct vpfe_video_device *video);
154 #endif /* _DAVINCI_VPFE_VIDEO_H */