Full support for Ginger Console
[linux-ginger.git] / include / media / ti-media / vpfe_capture.h
blob44d1d35fb41b0855d67aa514b7da4ea818076211
1 /*
2 * Copyright (C) 2008-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 _VPFE_CAPTURE_H
20 #define _VPFE_CAPTURE_H
22 #ifdef __KERNEL__
24 /* Header files */
25 #include <media/v4l2-dev.h>
26 #include <linux/videodev2.h>
27 #include <linux/clk.h>
28 #include <linux/i2c.h>
29 #include <media/v4l2-ioctl.h>
30 #include <media/v4l2-device.h>
31 #include <media/videobuf-dma-contig.h>
32 #include <media/ti-media/vpfe_types.h>
34 #define VPFE_CAPTURE_NUM_DECODERS 5
36 /* Macros */
37 #define VPFE_MAJOR_RELEASE 0
38 #define VPFE_MINOR_RELEASE 0
39 #define VPFE_BUILD 1
40 #define VPFE_CAPTURE_VERSION_CODE ((VPFE_MAJOR_RELEASE << 16) | \
41 (VPFE_MINOR_RELEASE << 8) | \
42 VPFE_BUILD)
44 #define CAPTURE_DRV_NAME "vpfe-capture"
46 struct vpfe_pixel_format {
47 struct v4l2_fmtdesc fmtdesc;
48 /* bytes per pixel */
49 int bpp;
50 /* decoder format */
51 u32 subdev_pix_fmt;
54 struct vpfe_std_info {
55 int active_pixels;
56 int active_lines;
57 /* current frame format */
58 int frame_format;
61 struct vpfe_route {
62 u32 input;
63 u32 output;
66 enum vpfe_subdev_id {
67 VPFE_SUBDEV_TVP5146 = 1,
68 VPFE_SUBDEV_MT9T031 = 2
71 struct vpfe_subdev_info {
72 /* Sub device module name */
73 char module_name[32];
74 /* Sub device group id */
75 int grp_id;
76 /* Number of inputs supported */
77 int num_inputs;
78 /* inputs available at the sub device */
79 struct v4l2_input *inputs;
80 /* Sub dev routing information for each input */
81 struct vpfe_route *routes;
82 /* ccdc bus/interface configuration */
83 struct vpfe_hw_if_param ccdc_if_params;
84 /* i2c subdevice board info */
85 struct i2c_board_info board_info;
86 /* Is this a camera sub device ? */
87 unsigned is_camera:1;
88 /* check if sub dev supports routing */
89 unsigned can_route:1;
90 /* registered ? */
91 unsigned registered:1;
94 struct vpfe_config {
95 /* Number of sub devices connected to vpfe */
96 int num_subdevs;
97 /* I2C Bus adapter no */
98 int i2c_adapter_id;
99 /* information about each subdev */
100 struct vpfe_subdev_info *sub_devs;
101 /* evm card info */
102 char *card_name;
103 /* ccdc name */
104 char *ccdc;
105 /* setup function for the input path */
106 int (*setup_input)(enum vpfe_subdev_id id);
107 /* Function for Clearing the interrupt */
108 void (*clr_intr)(int vdint);
109 /* number of clocks */
110 int num_clocks;
111 /* clocks used for vpfe capture */
112 char *clocks[];
115 struct vpfe_device {
116 /* V4l2 specific parameters */
117 /* Identifies video device for this channel */
118 struct video_device *video_dev;
119 /* sub devices */
120 struct v4l2_subdev **sd;
121 /* vpfe cfg */
122 struct vpfe_config *cfg;
123 /* clock ptrs for vpfe capture */
124 struct clk **clks;
125 /* V4l2 device */
126 struct v4l2_device v4l2_dev;
127 /* parent device */
128 struct device *pdev;
129 /* Used to keep track of state of the priority */
130 struct v4l2_prio_state prio;
131 /* number of open instances of the channel */
132 u32 usrs;
133 /* Indicates id of the field which is being displayed */
134 u32 field_id;
135 /* flag to indicate whether decoder is initialized */
136 u8 initialized;
137 /* current interface type */
138 struct vpfe_hw_if_param vpfe_if_params;
139 /* ptr to currently selected sub device */
140 struct vpfe_subdev_info *current_subdev;
141 /* current input at the sub device */
142 int current_input;
143 /* Keeps track of the information about the standard */
144 struct vpfe_std_info std_info;
145 /* std index into std table */
146 int std_index;
147 /* CCDC IRQs used when CCDC/ISIF output to SDRAM */
148 unsigned int ccdc_irq0;
149 unsigned int ccdc_irq1;
150 /* number of buffers in fbuffers */
151 u32 numbuffers;
152 /* List of buffer pointers for storing frames */
153 u8 *fbuffers[VIDEO_MAX_FRAME];
154 /* Pointer pointing to current v4l2_buffer */
155 struct videobuf_buffer *cur_frm;
156 /* Pointer pointing to next v4l2_buffer */
157 struct videobuf_buffer *next_frm;
159 * This field keeps track of type of buffer exchange mechanism
160 * user has selected
162 enum v4l2_memory memory;
163 /* Used to store pixel format */
164 struct v4l2_format fmt;
166 * used when IMP is chained to store the crop window which
167 * is different from the image window
169 struct v4l2_rect crop;
170 /* Buffer queue used in video-buf */
171 struct videobuf_queue buffer_queue;
172 /* Queue of filled frames */
173 struct list_head dma_queue;
174 /* Used in video-buf */
175 spinlock_t irqlock;
176 /* IRQ lock for DMA queue */
177 spinlock_t dma_queue_lock;
178 /* lock used to access this structure */
179 struct mutex lock;
180 /* number of users performing IO */
181 u32 io_usrs;
182 /* Indicates whether streaming started */
183 u8 started;
185 * offset where second field starts from the starting of the
186 * buffer for field seperated YCbCr formats
188 u32 field_off;
191 /* File handle structure */
192 struct vpfe_fh {
193 struct vpfe_device *vpfe_dev;
194 /* Indicates whether this file handle is doing IO */
195 u8 io_allowed;
196 /* Used to keep track priority of this instance */
197 enum v4l2_priority prio;
200 struct vpfe_config_params {
201 u8 min_numbuffers;
202 u8 numbuffers;
203 u32 min_bufsize;
204 u32 device_bufsize;
207 #endif /* End of __KERNEL__ */
209 * VPFE_CMD_S_CCDC_RAW_PARAMS - EXPERIMENTAL IOCTL to set raw capture params
210 * This can be used to configure modules such as defect pixel correction,
211 * color space conversion, culling etc. This is an experimental ioctl that
212 * will change in future kernels. So use this ioctl with care !
213 * TODO: This is to be split into multiple ioctls and also explore the
214 * possibility of extending the v4l2 api to include this
216 #define VPFE_CMD_S_CCDC_RAW_PARAMS _IOW('V', BASE_VIDIOC_PRIVATE + 1, \
217 void *)
218 #endif /* _DAVINCI_VPFE_H */