0df413a6056d07d155ef99bfeb37099eefa60fbf
[profile/ivi/intel-emgd-kmod.git] / emgd / video / overlay / tnc / ovl_tnc_cache.h
1 /*
2  *----------------------------------------------------------------------------
3  * Filename: ovl_tnc_cache.h
4  * $Revision: 1.5 $
5  *-----------------------------------------------------------------------------
6  * Copyright (c) 2002-2010, Intel Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *-----------------------------------------------------------------------------
26  * Description:
27  *  This is the internal header file for overlay caching. It should be not be
28  *  by any other module besides the overlay module itself.
29  *-----------------------------------------------------------------------------
30  */
31 #ifndef _OVL_TNC_CACHE_H
32 #define _OVL_TNC_CACHE_H
33
34 #include <rb.h>
35 #include "ovl_regs_tnc.h"
36 #include "ovl2_regs_tnc.h"
37
38 /* Turns the overlay cache on and off. */
39 #define OVL_TNC_CACHE_QUICK_SWAP
40
41
42 /*
43  * In order to cache the overlay registers we need a structure
44  * that defines and wraps them.  We already have one for the primary
45  * display, called ovl_reg_image_tnc_t.
46  * Here we define a structure for the secondary display
47  */
48
49 typedef struct _ovl2_reg_tnc_cache{
50         unsigned long control;
51         unsigned long start;
52         unsigned long plane_control;
53         unsigned long plane_start;
54         unsigned long linear_offset;
55         unsigned long tiled_offset;
56
57         unsigned long pitch;
58         unsigned long dest_rect_x1y1;
59         unsigned long dest_rect_w_h;
60         unsigned long cont_bright;
61         unsigned long satn_hue;
62         unsigned long gamma_regs[OVL2_TOTAL_GAMMA_REG];
63         unsigned long colorkey_hw;
64         unsigned long colorkey_mask;
65         unsigned long ckey_high;
66         unsigned long ckey_low;
67         unsigned long ckey_enable;
68 } ovl2_reg_tnc_cache_t;
69
70 #define MMIO_OFFSET_TNC2_CONTROL        0x72180
71 #define MMIO_OFFSET_TNC2_LINEAR_OFF     0x72184
72 #define MMIO_OFFSET_TNC2_PITCH          0x72188
73 #define MMIO_OFFSET_TNC2_DEST_RECT_X1Y1 0x7218C
74 #define MMIO_OFFSET_TNC2_DEST_RECT_W_H  0x72190
75 #define MMIO_OFFSET_TNC2_CKEY_LOW       0x72194
76 #define MMIO_OFFSET_TNC2_CKEY_ENABLE    0x72198
77 #define MMIO_OFFSET_TNC2_SURF_ADDR      0x7219C
78 #define MMIO_OFFSET_TNC2_CKEY_HIGH      0x721A0
79 #define MMIO_OFFSET_TNC2_DSPC_TILE_OFF  0x721A4
80 #define MMIO_OFFSET_TNC2_CONT_BRIGHT    0x721D0
81 #define MMIO_OFFSET_TNC2_SATN_HUE       0x721D4
82 #define MMIO_OFFSET_TNC2_COLORKEY_HW    0x14
83 #define MMIO_OFFSET_TNC2_COLORKEY_MASK  0x18
84
85 /*
86  * This stucture caches the overlay state, so we don't have to
87  * re-program everything for every single frame
88  */
89 typedef struct _ovl_tnc_cache {
90         igd_surface_t        src_surf;
91         igd_rect_t           src_rect;
92         igd_rect_t           dest_rect;
93         igd_ovl_info_t       ovl_info;
94         unsigned long        flags;
95         ovl_reg_image_tnc_t  ovl_regs;
96         ovl2_reg_tnc_cache_t ovl2_regs;
97 } ovl_tnc_cache_t, *povl_tnc_cache_t;
98
99
100 /* Flags for things that might have changed in the cache */
101 #define IGD_OVL_TNC_UPDATE_DEST     (1 << 0)
102 #define IGD_OVL_TNC_UPDATE_SRC      (1 << 1)
103 #define IGD_OVL_TNC_UPDATE_SURF     (1 << 2)
104 #define IGD_OVL_TNC_UPDATE_INFO     (1 << 3)
105 #define IGD_OVL_TNC_UPDATE_FLAGS    (1 << 4)
106 #define IGD_OVL_TNC_UPDATE_VQ       (1 << 5)
107 #define IGD_OVL_TNC_UPDATE_GAMMA    (1 << 6)
108 #define IGD_OVL_TNC_UPDATE_COLORKEY (1 << 7)
109
110
111 /*
112  * Caching helper functions.  Implemented in ovl_tnc.c, but used by
113  * the ovl2 and micro_ovl modules as well.
114  */
115
116 /* Tells if a rectangle has changed */
117 int is_changed_rect(igd_rect_t *old_rect, igd_rect_t *new_rect);
118
119 /* Tells if a surface has changed */
120 int is_changed_surf(igd_surface_t *old_surf, igd_surface_t *new_surf);
121
122 /* Tells if the color key has changed */
123 int is_changed_color_key(igd_ovl_info_t *old_info, igd_ovl_info_t *new_info);
124
125 /* Tells if the video quality has changed */
126 int is_changed_vq(igd_ovl_info_t *old_info, igd_ovl_info_t *new_info);
127
128 /* Tells if the gamma has changed */
129 int is_changed_gamma(igd_ovl_info_t *old_info, igd_ovl_info_t *new_info);
130
131 /* Copies a source rectangle to the cache */
132 void copy_src_rect_tnc(igd_rect_t *src_rect, povl_tnc_cache_t ovl_cache);
133
134 /* Copies a dest rectangle to the cache */
135 void copy_dest_rect_tnc( igd_rect_t *dest_rect, povl_tnc_cache_t ovl_cache);
136
137 /* Copies a surface to the cache */
138 void copy_surf_tnc(igd_surface_t *src_surf, povl_tnc_cache_t ovl_cache);
139
140 /* Copies the color key to the cache */
141 void copy_color_key_tnc( igd_ovl_info_t *ovl_info, povl_tnc_cache_t ovl_cache);
142
143 /* Copies the video quality info to the cache */
144 void copy_vq_tnc(igd_ovl_info_t *ovl_info, povl_tnc_cache_t ovl_cache);
145
146 /* Copies the gamma to the cache */
147 void copy_gamma_tnc(igd_ovl_info_t *ovl_info, povl_tnc_cache_t ovl_cache);
148
149 /* Checks to see what, if anything has changed.
150  * Clears bits in the command and config register that are invalid.
151  * Returns a set of flags telling what changed */
152 unsigned int get_cache_changes_tnc(
153         igd_surface_t  *src_surf,
154         igd_rect_t     *src_rect,
155         igd_rect_t     *dest_rect,
156         igd_ovl_info_t *ovl_info,
157         unsigned int    flags,
158         povl_tnc_cache_t ovl_cache);
159
160
161
162 #endif /* _OVL_TNC_CACHE_H */