blob: 3d3c1e5cd5d4c63c1eb23b61be1574296ab27885 [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>
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030028#include <media/videobuf2-dma-contig.h>
Manjunath Hadlie13c6922011-11-12 20:36:02 +053029#include <media/davinci/vpif_types.h>
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030030
31#include "vpif.h"
32
33/* Macros */
Mauro Carvalho Chehab64dc3c12011-06-25 11:28:37 -030034#define VPIF_CAPTURE_VERSION "0.0.2"
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030035
36#define VPIF_VALID_FIELD(field) (((V4L2_FIELD_ANY == field) || \
37 (V4L2_FIELD_NONE == field)) || \
38 (((V4L2_FIELD_INTERLACED == field) || \
39 (V4L2_FIELD_SEQ_TB == field)) || \
40 (V4L2_FIELD_SEQ_BT == field)))
41
42#define VPIF_CAPTURE_MAX_DEVICES 2
43#define VPIF_VIDEO_INDEX 0
44#define VPIF_NUMBER_OF_OBJECTS 1
45
46/* Enumerated data type to give id to each device per channel */
47enum vpif_channel_id {
48 VPIF_CHANNEL0_VIDEO = 0,
49 VPIF_CHANNEL1_VIDEO,
50};
51
52struct video_obj {
53 enum v4l2_field buf_field;
54 /* Currently selected or default standard */
55 v4l2_std_id stdid;
Hans Verkuil0598c172012-09-18 07:18:47 -030056 struct v4l2_dv_timings dv_timings;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030057};
58
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030059struct vpif_cap_buffer {
60 struct vb2_buffer vb;
61 struct list_head list;
62};
63
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030064struct common_obj {
65 /* Pointer pointing to current v4l2_buffer */
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030066 struct vpif_cap_buffer *cur_frm;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030067 /* Pointer pointing to current v4l2_buffer */
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030068 struct vpif_cap_buffer *next_frm;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030069 /*
70 * This field keeps track of type of buffer exchange mechanism
71 * user has selected
72 */
73 enum v4l2_memory memory;
74 /* Used to store pixel format */
75 struct v4l2_format fmt;
76 /* Buffer queue used in video-buf */
Lad, Prabhakar60aa38d2012-06-28 09:28:05 -030077 struct vb2_queue buffer_queue;
78 /* allocator-specific contexts for each plane */
79 struct vb2_alloc_ctx *alloc_ctx;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -030080 /* Queue of filled frames */
81 struct list_head dma_queue;
82 /* Used in video-buf */
83 spinlock_t irqlock;
84 /* lock used to access this structure */
85 struct mutex lock;
86 /* number of users performing IO */
87 u32 io_usrs;
88 /* Indicates whether streaming started */
89 u8 started;
90 /* Function pointer to set the addresses */
91 void (*set_addr) (unsigned long, unsigned long, unsigned long,
92 unsigned long);
93 /* offset where Y top starts from the starting of the buffer */
94 u32 ytop_off;
95 /* offset where Y bottom starts from the starting of the buffer */
96 u32 ybtm_off;
97 /* offset where C top starts from the starting of the buffer */
98 u32 ctop_off;
99 /* offset where C bottom starts from the starting of the buffer */
100 u32 cbtm_off;
101 /* Indicates width of the image data */
102 u32 width;
103 /* Indicates height of the image data */
104 u32 height;
105};
106
107struct channel_obj {
108 /* Identifies video device for this channel */
109 struct video_device *video_dev;
110 /* Used to keep track of state of the priority */
111 struct v4l2_prio_state prio;
112 /* number of open instances of the channel */
113 int usrs;
114 /* Indicates id of the field which is being displayed */
115 u32 field_id;
116 /* flag to indicate whether decoder is initialized */
117 u8 initialized;
118 /* Identifies channel */
119 enum vpif_channel_id channel_id;
Hans Verkuil6f47c6c2012-09-20 09:06:22 -0300120 /* Current input */
121 u32 input_idx;
Hans Verkuil178cce12012-09-20 09:06:30 -0300122 /* subdev corresponding to the current input, may be NULL */
123 struct v4l2_subdev *sd;
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -0300124 /* vpif configuration params */
125 struct vpif_params vpifparams;
126 /* common object array */
127 struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
128 /* video object */
129 struct video_obj video;
130};
131
132/* File handle structure */
133struct vpif_fh {
134 /* pointer to channel object for opened device */
135 struct channel_obj *channel;
136 /* Indicates whether this file handle is doing IO */
137 u8 io_allowed[VPIF_NUMBER_OF_OBJECTS];
138 /* Used to keep track priority of this instance */
139 enum v4l2_priority prio;
140 /* Used to indicate channel is initialize or not */
141 u8 initialized;
142};
143
144struct vpif_device {
145 struct v4l2_device v4l2_dev;
146 struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
147 struct v4l2_subdev **sd;
148};
149
150struct vpif_config_params {
151 u8 min_numbuffers;
152 u8 numbuffers[VPIF_CAPTURE_NUM_CHANNELS];
153 s8 device_type;
154 u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
155 u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
156 u8 default_device[VPIF_CAPTURE_NUM_CHANNELS];
Manjunath Hadli764af392012-04-13 04:49:34 -0300157 u32 video_limit[VPIF_CAPTURE_NUM_CHANNELS];
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -0300158 u8 max_device_type;
159};
Hans Verkuil822f0fd2012-09-20 09:06:20 -0300160
Muralidharan Karicheri6ffefff2009-09-16 14:31:10 -0300161#endif /* End of __KERNEL__ */
162#endif /* VPIF_CAPTURE_H */