Adding support for MOXA ART SoC. Testing port of linux-2.6.32.60-moxart.
[linux-3.6.7-moxart.git] / drivers / media / video / davinci / vpif_capture.h
blob3511510f43ee32098732e0f480f1067579404a69
1 /*
2 * Copyright (C) 2009 Texas Instruments Inc
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef VPIF_CAPTURE_H
20 #define VPIF_CAPTURE_H
22 #ifdef __KERNEL__
24 /* Header files */
25 #include <linux/videodev2.h>
26 #include <media/v4l2-common.h>
27 #include <media/v4l2-device.h>
28 #include <media/videobuf-core.h>
29 #include <media/videobuf2-dma-contig.h>
30 #include <media/davinci/vpif_types.h>
32 #include "vpif.h"
34 /* Macros */
35 #define VPIF_CAPTURE_VERSION "0.0.2"
37 #define VPIF_VALID_FIELD(field) (((V4L2_FIELD_ANY == field) || \
38 (V4L2_FIELD_NONE == field)) || \
39 (((V4L2_FIELD_INTERLACED == field) || \
40 (V4L2_FIELD_SEQ_TB == field)) || \
41 (V4L2_FIELD_SEQ_BT == field)))
43 #define VPIF_CAPTURE_MAX_DEVICES 2
44 #define VPIF_VIDEO_INDEX 0
45 #define VPIF_NUMBER_OF_OBJECTS 1
47 /* Enumerated data type to give id to each device per channel */
48 enum vpif_channel_id {
49 VPIF_CHANNEL0_VIDEO = 0,
50 VPIF_CHANNEL1_VIDEO,
53 struct video_obj {
54 enum v4l2_field buf_field;
55 /* Currently selected or default standard */
56 v4l2_std_id stdid;
57 u32 dv_preset;
58 struct v4l2_bt_timings bt_timings;
59 /* This is to track the last input that is passed to application */
60 u32 input_idx;
63 struct vpif_cap_buffer {
64 struct vb2_buffer vb;
65 struct list_head list;
68 struct common_obj {
69 /* Pointer pointing to current v4l2_buffer */
70 struct vpif_cap_buffer *cur_frm;
71 /* Pointer pointing to current v4l2_buffer */
72 struct vpif_cap_buffer *next_frm;
74 * This field keeps track of type of buffer exchange mechanism
75 * user has selected
77 enum v4l2_memory memory;
78 /* Used to store pixel format */
79 struct v4l2_format fmt;
80 /* Buffer queue used in video-buf */
81 struct vb2_queue buffer_queue;
82 /* allocator-specific contexts for each plane */
83 struct vb2_alloc_ctx *alloc_ctx;
84 /* Queue of filled frames */
85 struct list_head dma_queue;
86 /* Used in video-buf */
87 spinlock_t irqlock;
88 /* lock used to access this structure */
89 struct mutex lock;
90 /* number of users performing IO */
91 u32 io_usrs;
92 /* Indicates whether streaming started */
93 u8 started;
94 /* Function pointer to set the addresses */
95 void (*set_addr) (unsigned long, unsigned long, unsigned long,
96 unsigned long);
97 /* offset where Y top starts from the starting of the buffer */
98 u32 ytop_off;
99 /* offset where Y bottom starts from the starting of the buffer */
100 u32 ybtm_off;
101 /* offset where C top starts from the starting of the buffer */
102 u32 ctop_off;
103 /* offset where C bottom starts from the starting of the buffer */
104 u32 cbtm_off;
105 /* Indicates width of the image data */
106 u32 width;
107 /* Indicates height of the image data */
108 u32 height;
111 struct channel_obj {
112 /* Identifies video device for this channel */
113 struct video_device *video_dev;
114 /* Used to keep track of state of the priority */
115 struct v4l2_prio_state prio;
116 /* number of open instances of the channel */
117 int usrs;
118 /* Indicates id of the field which is being displayed */
119 u32 field_id;
120 /* flag to indicate whether decoder is initialized */
121 u8 initialized;
122 /* Identifies channel */
123 enum vpif_channel_id channel_id;
124 /* index into sd table */
125 int curr_sd_index;
126 /* ptr to current sub device information */
127 struct vpif_subdev_info *curr_subdev_info;
128 /* vpif configuration params */
129 struct vpif_params vpifparams;
130 /* common object array */
131 struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
132 /* video object */
133 struct video_obj video;
136 /* File handle structure */
137 struct vpif_fh {
138 /* pointer to channel object for opened device */
139 struct channel_obj *channel;
140 /* Indicates whether this file handle is doing IO */
141 u8 io_allowed[VPIF_NUMBER_OF_OBJECTS];
142 /* Used to keep track priority of this instance */
143 enum v4l2_priority prio;
144 /* Used to indicate channel is initialize or not */
145 u8 initialized;
148 struct vpif_device {
149 struct v4l2_device v4l2_dev;
150 struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
151 struct v4l2_subdev **sd;
154 struct vpif_config_params {
155 u8 min_numbuffers;
156 u8 numbuffers[VPIF_CAPTURE_NUM_CHANNELS];
157 s8 device_type;
158 u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
159 u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
160 u8 default_device[VPIF_CAPTURE_NUM_CHANNELS];
161 u32 video_limit[VPIF_CAPTURE_NUM_CHANNELS];
162 u8 max_device_type;
164 /* Struct which keeps track of the line numbers for the sliced vbi service */
165 struct vpif_service_line {
166 u16 service_id;
167 u16 service_line[2];
169 #endif /* End of __KERNEL__ */
170 #endif /* VPIF_CAPTURE_H */