]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - arch/arm/mach-tegra/include/mach/dc.h
video: tegra: add hotplug display support
[linux-2.6.git] / arch / arm / mach-tegra / include / mach / dc.h
1 /*
2  * arch/arm/mach-tegra/include/mach/dc.h
3  *
4  * Copyright (C) 2010 Google, Inc.
5  *
6  * Author:
7  *      Erik Gilling <konkers@google.com>
8  *
9  * This software is licensed under the terms of the GNU General Public
10  * License version 2, as published by the Free Software Foundation, and
11  * may be copied, distributed, and modified under those terms.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  */
19
20 #ifndef __MACH_TEGRA_DC_H
21 #define __MACH_TEGRA_DC_H
22
23 #include <linux/pm.h>
24
25 #define TEGRA_MAX_DC            2
26 #define DC_N_WINDOWS            3
27
28 struct tegra_dc_blend {
29         u32     nokey;
30         u32     one_win;
31         u32     two_win_x;
32         u32     two_win_y;
33         u32     three_win_xy;
34 };
35
36 #define BLEND(key, control, weight0, weight1)                           \
37         (CKEY_ ## key | BLEND_CONTROL_ ## control |                     \
38          BLEND_WEIGHT0(weight0) | BLEND_WEIGHT0(weight1))
39
40 struct tegra_dc_mode {
41         int     pclk;
42         int     h_ref_to_sync;
43         int     v_ref_to_sync;
44         int     h_sync_width;
45         int     v_sync_width;
46         int     h_back_porch;
47         int     v_back_porch;
48         int     h_active;
49         int     v_active;
50         int     h_front_porch;
51         int     v_front_porch;
52 };
53
54 enum {
55         TEGRA_DC_OUT_RGB,
56 };
57
58 struct tegra_dc_out {
59         int                     type;
60         unsigned                flags;
61
62         int                     dcc_bus;
63         int                     hotplug_gpio;
64
65         unsigned                order;
66         unsigned                align;
67
68         struct tegra_dc_mode    *modes;
69         int                     n_modes;
70
71         int     (*enable)(void);
72         int     (*disable)(void);
73 };
74
75 #define TEGRA_DC_OUT_HOTPLUG_HIGH       (0 << 1)
76 #define TEGRA_DC_OUT_HOTPLUG_LOW        (1 << 1)
77 #define TEGRA_DC_OUT_HOTPLUG_MASK       (1 << 1)
78
79 #define TEGRA_DC_ALIGN_MSB              0
80 #define TEGRA_DC_ALIGN_LSB              1
81
82 #define TEGRA_DC_ORDER_RED_BLUE         0
83 #define TEGRA_DC_ORDER_BLUE_RED         1
84
85 struct tegra_dc;
86
87 struct tegra_dc_win {
88         u8                      idx;
89         u8                      fmt;
90         u32                     flags;
91
92         void                    *virt_addr;
93         dma_addr_t              phys_addr;
94         unsigned                x;
95         unsigned                y;
96         unsigned                w;
97         unsigned                h;
98         unsigned                out_w;
99         unsigned                out_h;
100
101         int                     dirty;
102         struct tegra_dc         *dc;
103 };
104
105 #define TEGRA_WIN_FLAG_ENABLED          (1 << 0)
106 #define TEGRA_WIN_FLAG_COLOR_EXPAND     (1 << 1)
107
108 /* Note: These are the actual values written to the DC_WIN_COLOR_DEPTH register
109  * and may change in new tegra architectures.
110  */
111 #define TEGRA_WIN_FMT_P1                0
112 #define TEGRA_WIN_FMT_P2                1
113 #define TEGRA_WIN_FMT_P4                2
114 #define TEGRA_WIN_FMT_P8                3
115 #define TEGRA_WIN_FMT_B4G4R4A4          4
116 #define TEGRA_WIN_FMT_B5G5R5A           5
117 #define TEGRA_WIN_FMT_B5G6R5            6
118 #define TEGRA_WIN_FMT_AB5G5R5           7
119 #define TEGRA_WIN_FMT_B8G8R8A8          12
120 #define TEGRA_WIN_FMT_R8G8B8A8          13
121 #define TEGRA_WIN_FMT_B6x2G6x2R6x2A8    14
122 #define TEGRA_WIN_FMT_R6x2G6x2B6x2A8    15
123 #define TEGRA_WIN_FMT_YCbCr422          16
124 #define TEGRA_WIN_FMT_YUV422            17
125 #define TEGRA_WIN_FMT_YCbCr420P         18
126 #define TEGRA_WIN_FMT_YUV420P           19
127 #define TEGRA_WIN_FMT_YCbCr422P         20
128 #define TEGRA_WIN_FMT_YUV422P           21
129 #define TEGRA_WIN_FMT_YCbCr422R         22
130 #define TEGRA_WIN_FMT_YUV422R           23
131 #define TEGRA_WIN_FMT_YCbCr422RA        24
132 #define TEGRA_WIN_FMT_YUV422RA          25
133
134 struct tegra_fb_data {
135         int             win;
136
137         int             xres;
138         int             yres;
139         int             bits_per_pixel;
140 };
141
142 struct tegra_dc_platform_data {
143         unsigned long           flags;
144         struct tegra_dc_out     *default_out;
145         struct tegra_fb_data    *fb;
146 };
147
148 #define TEGRA_DC_FLAG_ENABLED           (1 << 0)
149
150 struct tegra_dc *tegra_dc_get_dc(unsigned idx);
151 struct tegra_dc_win *tegra_dc_get_window(struct tegra_dc *dc, unsigned win);
152
153 void tegra_dc_enable(struct tegra_dc *dc);
154 void tegra_dc_disable(struct tegra_dc *dc);
155
156 /* tegra_dc_update_windows and tegra_dc_sync_windows do not support windows
157  * with differenct dcs in one call
158  */
159 int tegra_dc_update_windows(struct tegra_dc_win *windows[], int n);
160 int tegra_dc_sync_windows(struct tegra_dc_win *windows[], int n);
161
162 /* will probably be replaced with an interface describing the window order */
163 void tegra_dc_set_blending(struct tegra_dc *dc, struct tegra_dc_blend *blend);
164
165 int tegra_dc_set_mode(struct tegra_dc *dc, const struct tegra_dc_mode *mode);
166
167 #endif