]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/media/platform/davinci/vpif_display.h
nfs: disintegrate UAPI for nfs
[karo-tx-linux.git] / drivers / media / platform / davinci / vpif_display.h
1 /*
2  * VPIF display header file
3  *
4  * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
5  *
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.
9  *
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.
14  */
15
16 #ifndef DAVINCIHD_DISPLAY_H
17 #define DAVINCIHD_DISPLAY_H
18
19 /* Header files */
20 #include <linux/videodev2.h>
21 #include <media/v4l2-common.h>
22 #include <media/v4l2-device.h>
23 #include <media/videobuf2-dma-contig.h>
24 #include <media/davinci/vpif_types.h>
25
26 #include "vpif.h"
27
28 /* Macros */
29 #define VPIF_DISPLAY_VERSION    "0.0.2"
30
31 #define VPIF_VALID_FIELD(field) \
32         (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \
33         (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \
34         (V4L2_FIELD_SEQ_BT == field)))
35
36 #define VPIF_DISPLAY_MAX_DEVICES        (2)
37 #define VPIF_SLICED_BUF_SIZE            (256)
38 #define VPIF_SLICED_MAX_SERVICES        (3)
39 #define VPIF_VIDEO_INDEX                (0)
40 #define VPIF_VBI_INDEX                  (1)
41 #define VPIF_HBI_INDEX                  (2)
42
43 /* Setting it to 1 as HBI/VBI support yet to be added , else 3*/
44 #define VPIF_NUMOBJECTS (1)
45
46 /* Macros */
47 #define ISALIGNED(a)    (0 == ((a) & 7))
48
49 /* enumerated data types */
50 /* Enumerated data type to give id to each device per channel */
51 enum vpif_channel_id {
52         VPIF_CHANNEL2_VIDEO = 0,        /* Channel2 Video */
53         VPIF_CHANNEL3_VIDEO,            /* Channel3 Video */
54 };
55
56 /* structures */
57
58 struct video_obj {
59         enum v4l2_field buf_field;
60         u32 latest_only;                /* indicate whether to return
61                                          * most recent displayed frame only */
62         v4l2_std_id stdid;              /* Currently selected or default
63                                          * standard */
64         struct v4l2_dv_timings dv_timings;
65         u32 output_id;                  /* Current output id */
66 };
67
68 struct vbi_obj {
69         int num_services;
70         struct vpif_vbi_params vbiparams;       /* vpif parameters for the raw
71                                                  * vbi data */
72 };
73
74 struct vpif_disp_buffer {
75         struct vb2_buffer vb;
76         struct list_head list;
77 };
78
79 struct common_obj {
80         /* Buffer specific parameters */
81         u8 *fbuffers[VIDEO_MAX_FRAME];          /* List of buffer pointers for
82                                                  * storing frames */
83         u32 numbuffers;                         /* number of buffers */
84         struct vpif_disp_buffer *cur_frm;       /* Pointer pointing to current
85                                                  * vb2_buffer */
86         struct vpif_disp_buffer *next_frm;      /* Pointer pointing to next
87                                                  * vb2_buffer */
88         enum v4l2_memory memory;                /* This field keeps track of
89                                                  * type of buffer exchange
90                                                  * method user has selected */
91         struct v4l2_format fmt;                 /* Used to store the format */
92         struct vb2_queue buffer_queue;          /* Buffer queue used in
93                                                  * video-buf */
94         /* allocator-specific contexts for each plane */
95         struct vb2_alloc_ctx *alloc_ctx;
96
97         struct list_head dma_queue;             /* Queue of filled frames */
98         spinlock_t irqlock;                     /* Used in video-buf */
99
100         /* channel specific parameters */
101         struct mutex lock;                      /* lock used to access this
102                                                  * structure */
103         u32 io_usrs;                            /* number of users performing
104                                                  * IO */
105         u8 started;                             /* Indicates whether streaming
106                                                  * started */
107         u32 ytop_off;                           /* offset of Y top from the
108                                                  * starting of the buffer */
109         u32 ybtm_off;                           /* offset of Y bottom from the
110                                                  * starting of the buffer */
111         u32 ctop_off;                           /* offset of C top from the
112                                                  * starting of the buffer */
113         u32 cbtm_off;                           /* offset of C bottom from the
114                                                  * starting of the buffer */
115         /* Function pointer to set the addresses */
116         void (*set_addr) (unsigned long, unsigned long,
117                                 unsigned long, unsigned long);
118         u32 height;
119         u32 width;
120 };
121
122 struct channel_obj {
123         /* V4l2 specific parameters */
124         struct video_device *video_dev; /* Identifies video device for
125                                          * this channel */
126         struct v4l2_prio_state prio;    /* Used to keep track of state of
127                                          * the priority */
128         atomic_t usrs;                  /* number of open instances of
129                                          * the channel */
130         u32 field_id;                   /* Indicates id of the field
131                                          * which is being displayed */
132         u8 initialized;                 /* flag to indicate whether
133                                          * encoder is initialized */
134
135         enum vpif_channel_id channel_id;/* Identifies channel */
136         struct vpif_params vpifparams;
137         struct common_obj common[VPIF_NUMOBJECTS];
138         struct video_obj video;
139         struct vbi_obj vbi;
140 };
141
142 /* File handle structure */
143 struct vpif_fh {
144         struct channel_obj *channel;    /* pointer to channel object for
145                                          * opened device */
146         u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle
147                                          * is doing IO */
148         enum v4l2_priority prio;        /* Used to keep track priority of
149                                          * this instance */
150         u8 initialized;                 /* Used to keep track of whether this
151                                          * file handle has initialized
152                                          * channel or not */
153 };
154
155 /* vpif device structure */
156 struct vpif_device {
157         struct v4l2_device v4l2_dev;
158         struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS];
159         struct v4l2_subdev **sd;
160
161 };
162
163 struct vpif_config_params {
164         u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
165         u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
166         u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
167         u32 video_limit[VPIF_DISPLAY_NUM_CHANNELS];
168         u8 min_numbuffers;
169 };
170
171 /* Struct which keeps track of the line numbers for the sliced vbi service */
172 struct vpif_service_line {
173         u16 service_id;
174         u16 service_line[2];
175         u16 enc_service_id;
176         u8 bytestowrite;
177 };
178
179 #endif                          /* DAVINCIHD_DISPLAY_H */