Merge tag 'docs-4.11-fixes' of git://git.lwn.net/linux
[sfrench/cifs-2.6.git] / drivers / media / platform / davinci / vpif_capture.h
1 /*
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
15 #ifndef VPIF_CAPTURE_H
16 #define VPIF_CAPTURE_H
17
18 /* Header files */
19 #include <media/videobuf2-dma-contig.h>
20 #include <media/v4l2-device.h>
21
22 #include "vpif.h"
23
24 /* Macros */
25 #define VPIF_CAPTURE_VERSION            "0.0.2"
26
27 #define VPIF_VALID_FIELD(field)         (((V4L2_FIELD_ANY == field) || \
28         (V4L2_FIELD_NONE == field)) || \
29         (((V4L2_FIELD_INTERLACED == field) || \
30         (V4L2_FIELD_SEQ_TB == field)) || \
31         (V4L2_FIELD_SEQ_BT == field)))
32
33 #define VPIF_CAPTURE_MAX_DEVICES        2
34 #define VPIF_VIDEO_INDEX                0
35 #define VPIF_NUMBER_OF_OBJECTS          1
36
37 /* Enumerated data type to give id to each device per channel */
38 enum vpif_channel_id {
39         VPIF_CHANNEL0_VIDEO = 0,
40         VPIF_CHANNEL1_VIDEO,
41 };
42
43 struct video_obj {
44         enum v4l2_field buf_field;
45         /* Currently selected or default standard */
46         v4l2_std_id stdid;
47         struct v4l2_dv_timings dv_timings;
48 };
49
50 struct vpif_cap_buffer {
51         struct vb2_v4l2_buffer vb;
52         struct list_head list;
53 };
54
55 struct common_obj {
56         /* Pointer pointing to current v4l2_buffer */
57         struct vpif_cap_buffer *cur_frm;
58         /* Pointer pointing to current v4l2_buffer */
59         struct vpif_cap_buffer *next_frm;
60         /* Used to store pixel format */
61         struct v4l2_format fmt;
62         /* Buffer queue used in video-buf */
63         struct vb2_queue buffer_queue;
64         /* Queue of filled frames */
65         struct list_head dma_queue;
66         /* Protects the dma_queue field */
67         spinlock_t irqlock;
68         /* lock used to access this structure */
69         struct mutex lock;
70         /* Function pointer to set the addresses */
71         void (*set_addr) (unsigned long, unsigned long, unsigned long,
72                           unsigned long);
73         /* offset where Y top starts from the starting of the buffer */
74         u32 ytop_off;
75         /* offset where Y bottom starts from the starting of the buffer */
76         u32 ybtm_off;
77         /* offset where C top starts from the starting of the buffer */
78         u32 ctop_off;
79         /* offset where C bottom starts from the starting of the buffer */
80         u32 cbtm_off;
81         /* Indicates width of the image data */
82         u32 width;
83         /* Indicates height of the image data */
84         u32 height;
85 };
86
87 struct channel_obj {
88         /* Identifies video device for this channel */
89         struct video_device video_dev;
90         /* Indicates id of the field which is being displayed */
91         u32 field_id;
92         /* flag to indicate whether decoder is initialized */
93         u8 initialized;
94         /* Identifies channel */
95         enum vpif_channel_id channel_id;
96         /* Current input */
97         u32 input_idx;
98         /* subdev corresponding to the current input, may be NULL */
99         struct v4l2_subdev *sd;
100         /* vpif configuration params */
101         struct vpif_params vpifparams;
102         /* common object array */
103         struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
104         /* video object */
105         struct video_obj video;
106 };
107
108 struct vpif_device {
109         struct v4l2_device v4l2_dev;
110         struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
111         struct v4l2_subdev **sd;
112         struct v4l2_async_notifier notifier;
113         struct vpif_capture_config *config;
114 };
115
116 #endif                          /* VPIF_CAPTURE_H */