Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / drivers / media / video / davinci / vpif_display.h
blob56879d1a0684b3c6452b9f34c17b5f7261a5e99e
1 /*
2 * DM646x display header file
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
10 * This program is distributed .as is. WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef DAVINCIHD_DISPLAY_H
17 #define DAVINCIHD_DISPLAY_H
19 /* Header files */
20 #include <linux/videodev2.h>
21 #include <media/v4l2-common.h>
22 #include <media/v4l2-device.h>
23 #include <media/videobuf-core.h>
24 #include <media/videobuf-dma-contig.h>
25 #include <media/davinci/vpif_types.h>
27 #include "vpif.h"
29 /* Macros */
30 #define VPIF_DISPLAY_VERSION "0.0.2"
32 #define VPIF_VALID_FIELD(field) \
33 (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \
34 (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \
35 (V4L2_FIELD_SEQ_BT == field)))
37 #define VPIF_DISPLAY_MAX_DEVICES (2)
38 #define VPIF_SLICED_BUF_SIZE (256)
39 #define VPIF_SLICED_MAX_SERVICES (3)
40 #define VPIF_VIDEO_INDEX (0)
41 #define VPIF_VBI_INDEX (1)
42 #define VPIF_HBI_INDEX (2)
44 /* Setting it to 1 as HBI/VBI support yet to be added , else 3*/
45 #define VPIF_NUMOBJECTS (1)
47 /* Macros */
48 #define ISALIGNED(a) (0 == ((a) & 7))
50 /* enumerated data types */
51 /* Enumerated data type to give id to each device per channel */
52 enum vpif_channel_id {
53 VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */
54 VPIF_CHANNEL3_VIDEO, /* Channel3 Video */
57 /* structures */
59 struct video_obj {
60 enum v4l2_field buf_field;
61 u32 latest_only; /* indicate whether to return
62 * most recent displayed frame only */
63 v4l2_std_id stdid; /* Currently selected or default
64 * standard */
65 u32 dv_preset;
66 struct v4l2_bt_timings bt_timings;
67 u32 output_id; /* Current output id */
70 struct vbi_obj {
71 int num_services;
72 struct vpif_vbi_params vbiparams; /* vpif parameters for the raw
73 * vbi data */
76 struct common_obj {
77 /* Buffer specific parameters */
78 u8 *fbuffers[VIDEO_MAX_FRAME]; /* List of buffer pointers for
79 * storing frames */
80 u32 numbuffers; /* number of buffers */
81 struct videobuf_buffer *cur_frm; /* Pointer pointing to current
82 * videobuf_buffer */
83 struct videobuf_buffer *next_frm; /* Pointer pointing to next
84 * videobuf_buffer */
85 enum v4l2_memory memory; /* This field keeps track of
86 * type of buffer exchange
87 * method user has selected */
88 struct v4l2_format fmt; /* Used to store the format */
89 struct videobuf_queue buffer_queue; /* Buffer queue used in
90 * video-buf */
91 struct list_head dma_queue; /* Queue of filled frames */
92 spinlock_t irqlock; /* Used in video-buf */
94 /* channel specific parameters */
95 struct mutex lock; /* lock used to access this
96 * structure */
97 u32 io_usrs; /* number of users performing
98 * IO */
99 u8 started; /* Indicates whether streaming
100 * started */
101 u32 ytop_off; /* offset of Y top from the
102 * starting of the buffer */
103 u32 ybtm_off; /* offset of Y bottom from the
104 * starting of the buffer */
105 u32 ctop_off; /* offset of C top from the
106 * starting of the buffer */
107 u32 cbtm_off; /* offset of C bottom from the
108 * starting of the buffer */
109 /* Function pointer to set the addresses */
110 void (*set_addr) (unsigned long, unsigned long,
111 unsigned long, unsigned long);
112 u32 height;
113 u32 width;
116 struct channel_obj {
117 /* V4l2 specific parameters */
118 struct video_device *video_dev; /* Identifies video device for
119 * this channel */
120 struct v4l2_prio_state prio; /* Used to keep track of state of
121 * the priority */
122 atomic_t usrs; /* number of open instances of
123 * the channel */
124 u32 field_id; /* Indicates id of the field
125 * which is being displayed */
126 u8 initialized; /* flag to indicate whether
127 * encoder is initialized */
129 enum vpif_channel_id channel_id;/* Identifies channel */
130 struct vpif_params vpifparams;
131 struct common_obj common[VPIF_NUMOBJECTS];
132 struct video_obj video;
133 struct vbi_obj vbi;
136 /* File handle structure */
137 struct vpif_fh {
138 struct channel_obj *channel; /* pointer to channel object for
139 * opened device */
140 u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle
141 * is doing IO */
142 enum v4l2_priority prio; /* Used to keep track priority of
143 * this instance */
144 u8 initialized; /* Used to keep track of whether this
145 * file handle has initialized
146 * channel or not */
149 /* vpif device structure */
150 struct vpif_device {
151 struct v4l2_device v4l2_dev;
152 struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS];
153 struct v4l2_subdev **sd;
157 struct vpif_config_params {
158 u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
159 u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
160 u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
161 u8 min_numbuffers;
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];
168 u16 enc_service_id;
169 u8 bytestowrite;
172 #endif /* DAVINCIHD_DISPLAY_H */