blob: aa6d3daffda8be52c02ef6328834c42b7390874f [file] [log] [blame]
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -03001/*
2 * Copyright (C) 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 VPIF_CAPTURE_H
20#define VPIF_CAPTURE_H
21
22#ifdef __KERNEL__
23
24/* Header files */
25#include <linux/videodev2.h>
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030026#include <media/v4l2-common.h>
27#include <media/v4l2-device.h>
28#include <media/videobuf-core.h>
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030029#include <media/videobuf2-dma-contig.h>
Manjunath Hadlie13c6922011-11-12 20:36:02 +053030#include <media/davinci/vpif_types.h>
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030031
32#include "vpif.h"
33
34/* Macros */
Mauro Carvalho Chehab64dc3c12011-06-25 11:28:37 -030035#define VPIF_CAPTURE_VERSION "0.0.2"
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030036
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)))
42
43#define VPIF_CAPTURE_MAX_DEVICES 2
44#define VPIF_VIDEO_INDEX 0
45#define VPIF_NUMBER_OF_OBJECTS 1
46
47/* Enumerated data type to give id to each device per channel */
48enum vpif_channel_id {
49 VPIF_CHANNEL0_VIDEO = 0,
50 VPIF_CHANNEL1_VIDEO,
51};
52
53struct video_obj {
54 enum v4l2_field buf_field;
55 /* Currently selected or default standard */
56 v4l2_std_id stdid;
Hans Verkuil0598c172012-09-18 07:18:47 -030057 struct v4l2_dv_timings dv_timings;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030058 /* This is to track the last input that is passed to application */
59 u32 input_idx;
60};
61
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030062struct vpif_cap_buffer {
63 struct vb2_buffer vb;
64 struct list_head list;
65};
66
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030067struct common_obj {
68 /* Pointer pointing to current v4l2_buffer */
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030069 struct vpif_cap_buffer *cur_frm;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030070 /* Pointer pointing to current v4l2_buffer */
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030071 struct vpif_cap_buffer *next_frm;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030072 /*
73 * This field keeps track of type of buffer exchange mechanism
74 * user has selected
75 */
76 enum v4l2_memory memory;
77 /* Used to store pixel format */
78 struct v4l2_format fmt;
79 /* Buffer queue used in video-buf */
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030080 struct vb2_queue buffer_queue;
81 /* allocator-specific contexts for each plane */
82 struct vb2_alloc_ctx *alloc_ctx;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030083 /* Queue of filled frames */
84 struct list_head dma_queue;
85 /* Used in video-buf */
86 spinlock_t irqlock;
87 /* lock used to access this structure */
88 struct mutex lock;
89 /* number of users performing IO */
90 u32 io_usrs;
91 /* Indicates whether streaming started */
92 u8 started;
93 /* Function pointer to set the addresses */
94 void (*set_addr) (unsigned long, unsigned long, unsigned long,
95 unsigned long);
96 /* offset where Y top starts from the starting of the buffer */
97 u32 ytop_off;
98 /* offset where Y bottom starts from the starting of the buffer */
99 u32 ybtm_off;
100 /* offset where C top starts from the starting of the buffer */
101 u32 ctop_off;
102 /* offset where C bottom starts from the starting of the buffer */
103 u32 cbtm_off;
104 /* Indicates width of the image data */
105 u32 width;
106 /* Indicates height of the image data */
107 u32 height;
108};
109
110struct channel_obj {
111 /* Identifies video device for this channel */
112 struct video_device *video_dev;
113 /* Used to keep track of state of the priority */
114 struct v4l2_prio_state prio;
115 /* number of open instances of the channel */
116 int usrs;
117 /* Indicates id of the field which is being displayed */
118 u32 field_id;
119 /* flag to indicate whether decoder is initialized */
120 u8 initialized;
121 /* Identifies channel */
122 enum vpif_channel_id channel_id;
123 /* index into sd table */
124 int curr_sd_index;
125 /* ptr to current sub device information */
126 struct vpif_subdev_info *curr_subdev_info;
127 /* vpif configuration params */
128 struct vpif_params vpifparams;
129 /* common object array */
130 struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
131 /* video object */
132 struct video_obj video;
133};
134
135/* File handle structure */
136struct vpif_fh {
137 /* pointer to channel object for opened device */
138 struct channel_obj *channel;
139 /* Indicates whether this file handle is doing IO */
140 u8 io_allowed[VPIF_NUMBER_OF_OBJECTS];
141 /* Used to keep track priority of this instance */
142 enum v4l2_priority prio;
143 /* Used to indicate channel is initialize or not */
144 u8 initialized;
145};
146
147struct vpif_device {
148 struct v4l2_device v4l2_dev;
149 struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
150 struct v4l2_subdev **sd;
151};
152
153struct vpif_config_params {
154 u8 min_numbuffers;
155 u8 numbuffers[VPIF_CAPTURE_NUM_CHANNELS];
156 s8 device_type;
157 u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
158 u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
159 u8 default_device[VPIF_CAPTURE_NUM_CHANNELS];
Manjunath Hadli764af392012-04-13 04:49:34 -0300160 u32 video_limit[VPIF_CAPTURE_NUM_CHANNELS];
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -0300161 u8 max_device_type;
162};
163/* Struct which keeps track of the line numbers for the sliced vbi service */
164struct vpif_service_line {
165 u16 service_id;
166 u16 service_line[2];
167};
168#endif /* End of __KERNEL__ */
169#endif /* VPIF_CAPTURE_H */