blob: d863e5e8426d720ca367c936d496a5fa31f51a17 [file] [log] [blame]
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001/*
2 * Copyright (C) 2008-2009 Texas Instruments Inc
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef _VPFE_CAPTURE_H
20#define _VPFE_CAPTURE_H
21
22#ifdef __KERNEL__
23
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/davinci/vpfe_types.h>
33
34#define VPFE_CAPTURE_NUM_DECODERS 5
35
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)
43
44#define CAPTURE_DRV_NAME "vpfe-capture"
45
46struct vpfe_pixel_format {
47 struct v4l2_fmtdesc fmtdesc;
48 /* bytes per pixel */
49 int bpp;
50};
51
52struct vpfe_std_info {
53 int active_pixels;
54 int active_lines;
55 /* current frame format */
56 int frame_format;
57};
58
59struct vpfe_route {
60 u32 input;
61 u32 output;
62};
63
64struct vpfe_subdev_info {
65 /* Sub device name */
66 char name[32];
67 /* Sub device group id */
68 int grp_id;
69 /* Number of inputs supported */
70 int num_inputs;
71 /* inputs available at the sub device */
72 struct v4l2_input *inputs;
73 /* Sub dev routing information for each input */
74 struct vpfe_route *routes;
75 /* check if sub dev supports routing */
76 int can_route;
77 /* ccdc bus/interface configuration */
78 struct vpfe_hw_if_param ccdc_if_params;
79 /* i2c subdevice board info */
80 struct i2c_board_info board_info;
81};
82
83struct vpfe_config {
84 /* Number of sub devices connected to vpfe */
85 int num_subdevs;
Vaibhav Hiremathe53a70b2009-11-09 09:13:20 -030086 /* i2c bus adapter no */
87 int i2c_adapter_id;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -030088 /* information about each subdev */
89 struct vpfe_subdev_info *sub_devs;
90 /* evm card info */
91 char *card_name;
92 /* ccdc name */
93 char *ccdc;
94 /* vpfe clock */
95 struct clk *vpssclk;
96 struct clk *slaveclk;
97};
98
99struct vpfe_device {
100 /* V4l2 specific parameters */
101 /* Identifies video device for this channel */
102 struct video_device *video_dev;
103 /* sub devices */
104 struct v4l2_subdev **sd;
105 /* vpfe cfg */
106 struct vpfe_config *cfg;
107 /* V4l2 device */
108 struct v4l2_device v4l2_dev;
109 /* parent device */
110 struct device *pdev;
111 /* Used to keep track of state of the priority */
112 struct v4l2_prio_state prio;
113 /* number of open instances of the channel */
114 u32 usrs;
115 /* Indicates id of the field which is being displayed */
116 u32 field_id;
117 /* flag to indicate whether decoder is initialized */
118 u8 initialized;
119 /* current interface type */
120 struct vpfe_hw_if_param vpfe_if_params;
121 /* ptr to currently selected sub device */
122 struct vpfe_subdev_info *current_subdev;
123 /* current input at the sub device */
124 int current_input;
125 /* Keeps track of the information about the standard */
126 struct vpfe_std_info std_info;
127 /* std index into std table */
128 int std_index;
129 /* CCDC IRQs used when CCDC/ISIF output to SDRAM */
130 unsigned int ccdc_irq0;
131 unsigned int ccdc_irq1;
132 /* number of buffers in fbuffers */
133 u32 numbuffers;
134 /* List of buffer pointers for storing frames */
135 u8 *fbuffers[VIDEO_MAX_FRAME];
136 /* Pointer pointing to current v4l2_buffer */
137 struct videobuf_buffer *cur_frm;
138 /* Pointer pointing to next v4l2_buffer */
139 struct videobuf_buffer *next_frm;
140 /*
141 * This field keeps track of type of buffer exchange mechanism
142 * user has selected
143 */
144 enum v4l2_memory memory;
145 /* Used to store pixel format */
146 struct v4l2_format fmt;
147 /*
148 * used when IMP is chained to store the crop window which
149 * is different from the image window
150 */
151 struct v4l2_rect crop;
152 /* Buffer queue used in video-buf */
153 struct videobuf_queue buffer_queue;
154 /* Queue of filled frames */
155 struct list_head dma_queue;
156 /* Used in video-buf */
157 spinlock_t irqlock;
158 /* IRQ lock for DMA queue */
159 spinlock_t dma_queue_lock;
160 /* lock used to access this structure */
161 struct mutex lock;
162 /* number of users performing IO */
163 u32 io_usrs;
164 /* Indicates whether streaming started */
165 u8 started;
166 /*
167 * offset where second field starts from the starting of the
168 * buffer for field seperated YCbCr formats
169 */
170 u32 field_off;
171};
172
173/* File handle structure */
174struct vpfe_fh {
175 struct vpfe_device *vpfe_dev;
176 /* Indicates whether this file handle is doing IO */
177 u8 io_allowed;
178 /* Used to keep track priority of this instance */
179 enum v4l2_priority prio;
180};
181
182struct vpfe_config_params {
183 u8 min_numbuffers;
184 u8 numbuffers;
185 u32 min_bufsize;
186 u32 device_bufsize;
187};
188
189#endif /* End of __KERNEL__ */
190/**
191 * VPFE_CMD_S_CCDC_RAW_PARAMS - EXPERIMENTAL IOCTL to set raw capture params
192 * This can be used to configure modules such as defect pixel correction,
193 * color space conversion, culling etc. This is an experimental ioctl that
194 * will change in future kernels. So use this ioctl with care !
195 * TODO: This is to be split into multiple ioctls and also explore the
196 * possibility of extending the v4l2 api to include this
197 **/
198#define VPFE_CMD_S_CCDC_RAW_PARAMS _IOW('V', BASE_VIDIOC_PRIVATE + 1, \
199 void *)
200#endif /* _DAVINCI_VPFE_H */