]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - include/video/tegra_dc_ext.h
5ac7899bc6dd5abadca73cf6f3a511c6ced3f529
[linux-2.6.git] / include / video / tegra_dc_ext.h
1 /*
2  * Copyright (C) 2011, NVIDIA Corporation
3  *
4  * Author: Robert Morell <rmorell@nvidia.com>
5  * Some code based on fbdev extensions written by:
6  *      Erik Gilling <konkers@android.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  */
18
19 #ifndef __TEGRA_DC_EXT_H
20 #define __TEGRA_DC_EXT_H
21
22 #include <linux/types.h>
23 #include <linux/ioctl.h>
24 #if defined(__KERNEL__)
25 # include <linux/time.h>
26 #else
27 # include <time.h>
28 # include <unistd.h>
29 #endif
30
31 #define TEGRA_DC_EXT_FMT_P1             0
32 #define TEGRA_DC_EXT_FMT_P2             1
33 #define TEGRA_DC_EXT_FMT_P4             2
34 #define TEGRA_DC_EXT_FMT_P8             3
35 #define TEGRA_DC_EXT_FMT_B4G4R4A4       4
36 #define TEGRA_DC_EXT_FMT_B5G5R5A        5
37 #define TEGRA_DC_EXT_FMT_B5G6R5         6
38 #define TEGRA_DC_EXT_FMT_AB5G5R5        7
39 #define TEGRA_DC_EXT_FMT_B8G8R8A8       12
40 #define TEGRA_DC_EXT_FMT_R8G8B8A8       13
41 #define TEGRA_DC_EXT_FMT_B6x2G6x2R6x2A8 14
42 #define TEGRA_DC_EXT_FMT_R6x2G6x2B6x2A8 15
43 #define TEGRA_DC_EXT_FMT_YCbCr422       16
44 #define TEGRA_DC_EXT_FMT_YUV422         17
45 #define TEGRA_DC_EXT_FMT_YCbCr420P      18
46 #define TEGRA_DC_EXT_FMT_YUV420P        19
47 #define TEGRA_DC_EXT_FMT_YCbCr422P      20
48 #define TEGRA_DC_EXT_FMT_YUV422P        21
49 #define TEGRA_DC_EXT_FMT_YCbCr422R      22
50 #define TEGRA_DC_EXT_FMT_YUV422R        23
51 #define TEGRA_DC_EXT_FMT_YCbCr422RA     24
52 #define TEGRA_DC_EXT_FMT_YUV422RA       25
53
54 #define TEGRA_DC_EXT_BLEND_NONE         0
55 #define TEGRA_DC_EXT_BLEND_PREMULT      1
56 #define TEGRA_DC_EXT_BLEND_COVERAGE     2
57
58 struct tegra_dc_ext_flip_windowattr {
59         __s32   index;
60         __u32   buff_id;
61         __u32   blend;
62         __u32   offset;
63         __u32   offset_u;
64         __u32   offset_v;
65         __u32   stride;
66         __u32   stride_uv;
67         __u32   pixformat;
68         /*
69          * x, y, w, h are fixed-point: 20 bits of integer (MSB) and 12 bits of
70          * fractional (LSB)
71          */
72         __u32   x;
73         __u32   y;
74         __u32   w;
75         __u32   h;
76         __u32   out_x;
77         __u32   out_y;
78         __u32   out_w;
79         __u32   out_h;
80         __u32   z;
81         __u32   swap_interval;
82         struct timespec timestamp;
83         __u32   pre_syncpt_id;
84         __u32   pre_syncpt_val;
85         /* Leave some wiggle room for future expansion */
86         __u32   pad[8];
87 };
88
89 #define TEGRA_DC_EXT_FLIP_N_WINDOWS     3
90
91 struct tegra_dc_ext_flip {
92         struct tegra_dc_ext_flip_windowattr win[TEGRA_DC_EXT_FLIP_N_WINDOWS];
93         __u32   post_syncpt_id;
94         __u32   post_syncpt_val;
95 };
96
97 /*
98  * Cursor image format:
99  * - Tegra hardware supports two colors: foreground and background, specified
100  *   by the client in RGB8.
101  * - The image should be specified as two 1bpp bitmaps immediately following
102  *   each other in memory.  Each pixel in the final cursor will be constructed
103  *   from the bitmaps with the following logic:
104  *              bitmap1 bitmap0
105  *              (mask)  (color)
106  *                1        0    transparent
107  *                1        1    inverted
108  *                0        0    background color
109  *                0        1    foreground color
110  * - Exactly one of the SIZE flags must be specified.
111  */
112 #define TEGRA_DC_EXT_CURSOR_IMAGE_FLAGS_SIZE_32x32      1
113 #define TEGRA_DC_EXT_CURSOR_IMAGE_FLAGS_SIZE_64x64      2
114 struct tegra_dc_ext_cursor_image {
115         struct {
116                 __u8    r;
117                 __u8    g;
118                 __u8    b;
119         } foreground, background;
120         __u32   buff_id;
121         __u32   flags;
122 };
123
124 /* Possible flags for struct nvdc_cursor's flags field */
125 #define TEGRA_DC_EXT_CURSOR_FLAGS_VISIBLE       1
126
127 struct tegra_dc_ext_cursor {
128         __s16 x;
129         __s16 y;
130         __u32 flags;
131 };
132
133 /*
134  * Color conversion is performed as follows:
135  *
136  * r = sat(kyrgb * sat(y + yof) + kur * u + kvr * v)
137  * g = sat(kyrgb * sat(y + yof) + kug * u + kvg * v)
138  * b = sat(kyrgb * sat(y + yof) + kub * u + kvb * v)
139  *
140  * Coefficients should be specified as fixed-point values; the exact format
141  * varies for each coefficient.
142  * The format for each coefficient is listed below with the syntax:
143  * - A "s." prefix means that the coefficient has a sign bit (twos complement).
144  * - The first number is the number of bits in the integer component (not
145  *   including the optional sign bit).
146  * - The second number is the number of bits in the fractional component.
147  *
148  * All three fields should be tightly packed, justified to the LSB of the
149  * 16-bit value.  For example, the "s.2.8" value should be packed as:
150  * (MSB) 5 bits of 0, 1 bit of sign, 2 bits of integer, 8 bits of frac (LSB)
151  */
152 struct tegra_dc_ext_csc {
153         __u32 win_index;
154         __u16 yof;      /* s.7.0 */
155         __u16 kyrgb;    /*   2.8 */
156         __u16 kur;      /* s.2.8 */
157         __u16 kvr;      /* s.2.8 */
158         __u16 kug;      /* s.1.8 */
159         __u16 kvg;      /* s.1.8 */
160         __u16 kub;      /* s.2.8 */
161         __u16 kvb;      /* s.2.8 */
162 };
163
164 #define TEGRA_DC_EXT_SET_NVMAP_FD \
165         _IOW('D', 0x00, __s32)
166
167 #define TEGRA_DC_EXT_GET_WINDOW \
168         _IOW('D', 0x01, __u32)
169 #define TEGRA_DC_EXT_PUT_WINDOW \
170         _IOW('D', 0x02, __u32)
171
172 #define TEGRA_DC_EXT_FLIP \
173         _IOWR('D', 0x03, struct tegra_dc_ext_flip)
174
175 #define TEGRA_DC_EXT_GET_CURSOR \
176         _IO('D', 0x04)
177 #define TEGRA_DC_EXT_PUT_CURSOR \
178         _IO('D', 0x05)
179 #define TEGRA_DC_EXT_SET_CURSOR_IMAGE \
180         _IOW('D', 0x06, struct tegra_dc_ext_cursor_image)
181 #define TEGRA_DC_EXT_SET_CURSOR \
182         _IOW('D', 0x07, struct tegra_dc_ext_cursor)
183
184 #define TEGRA_DC_EXT_SET_CSC \
185         _IOW('D', 0x08, struct tegra_dc_ext_csc)
186
187 /*
188  * Returns the auto-incrementing vblank syncpoint for the head associated with
189  * this device node
190  */
191 #define TEGRA_DC_EXT_GET_VBLANK_SYNCPT \
192         _IOR('D', 0x09, __u32)
193
194
195 enum tegra_dc_ext_control_output_type {
196         TEGRA_DC_EXT_DSI,
197         TEGRA_DC_EXT_LVDS,
198         TEGRA_DC_EXT_VGA,
199         TEGRA_DC_EXT_HDMI,
200         TEGRA_DC_EXT_DVI,
201 };
202
203 /*
204  * Get the properties for a given output.
205  *
206  * handle (in): Which output to query
207  * type (out): Describes the type of the output
208  * connected (out): Non-zero iff the output is currently connected
209  * associated_head (out): The head number that the output is currently
210  *      bound to.  -1 iff the output is not associated with any head.
211  * head_mask (out): Bitmask of which heads the output may be bound to (some
212  *      outputs are permanently bound to a single head).
213  */
214 struct tegra_dc_ext_control_output_properties {
215         __u32 handle;
216         enum tegra_dc_ext_control_output_type type;
217         __u32 connected;
218         __s32 associated_head;
219         __u32 head_mask;
220 };
221
222 struct tegra_dc_ext_control_output_edid {
223         __u32 handle;
224         __u32 size;
225         void *data;
226 };
227
228 struct tegra_dc_ext_event {
229         __u32   type;
230         ssize_t data_size;
231         char    data[0];
232 };
233
234 #define TEGRA_DC_EXT_EVENT_HOTPLUG      0x1
235 struct tegra_dc_ext_control_event_hotplug {
236         __u32 handle;
237 };
238
239 #define TEGRA_DC_EXT_CONTROL_GET_NUM_OUTPUTS \
240         _IOR('C', 0x00, __u32)
241 #define TEGRA_DC_EXT_CONTROL_GET_OUTPUT_PROPERTIES \
242         _IOWR('C', 0x01, struct tegra_dc_ext_control_output_properties)
243 #define TEGRA_DC_EXT_CONTROL_GET_OUTPUT_EDID \
244         _IOWR('C', 0x02, struct tegra_dc_ext_control_output_edid)
245 #define TEGRA_DC_EXT_CONTROL_SET_EVENT_MASK \
246         _IOW('C', 0x03, __u32)
247
248 #endif /* __TEGRA_DC_EXT_H */