audit: complex interfield comparison helper
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / gma500 / mdfld_dsi_dbi_dpu.h
blob42367ed48c0815068a5331ea6b58c94c5d1d2e96
1 /*
2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Authors:
24 * jim liu <jim.liu@intel.com>
25 * Jackie Li<yaodong.li@intel.com>
28 #ifndef __MDFLD_DSI_DBI_DPU_H__
29 #define __MDFLD_DSI_DBI_DPU_H__
31 #include "mdfld_dsi_dbi.h"
33 typedef enum {
34 MDFLD_PLANEA,
35 MDFLD_PLANEC,
36 MDFLD_CURSORA,
37 MDFLD_CURSORC,
38 MDFLD_OVERLAYA,
39 MDFLD_OVERLAYC,
40 MDFLD_PLANE_NUM,
41 } mdfld_plane_t;
43 #define MDFLD_PIPEA_PLANE_MASK 0x15
44 #define MDFLD_PIPEC_PLANE_MASK 0x2A
46 struct mdfld_cursor_info {
47 int x, y;
48 int size;
51 #define MDFLD_CURSOR_SIZE 64
54 * enter DSR mode if screen has no update for 2 frames.
56 #define MDFLD_MAX_IDLE_COUNT 2
58 struct mdfld_dbi_dpu_info {
59 struct drm_device *dev;
60 /* Lock */
61 spinlock_t dpu_update_lock;
63 /* Cursor postion */
64 struct mdfld_cursor_info cursors[2];
66 /* Damaged area for each plane */
67 struct psb_drm_dpu_rect damaged_rects[MDFLD_PLANE_NUM];
69 /* Final damaged area */
70 struct psb_drm_dpu_rect damage_pipea;
71 struct psb_drm_dpu_rect damage_pipec;
73 /* Pending */
74 u32 pending;
76 /* DPU timer */
77 struct timer_list dpu_timer;
78 spinlock_t dpu_timer_lock;
80 /* DPU idle count */
81 u32 idle_count;
83 /* DSI outputs */
84 struct mdfld_dsi_dbi_output *dbi_outputs[2];
85 int dbi_output_num;
88 static inline int mdfld_dpu_region_extent(struct psb_drm_dpu_rect *origin,
89 struct psb_drm_dpu_rect *rect)
91 int x1, y1, x2, y2;
93 x1 = origin->x + origin->width;
94 y1 = origin->y + origin->height;
96 x2 = rect->x + rect->width;
97 y2 = rect->y + rect->height;
99 origin->x = min(origin->x, rect->x);
100 origin->y = min(origin->y, rect->y);
101 origin->width = max(x1, x2) - origin->x;
102 origin->height = max(y1, y2) - origin->y;
104 return 0;
107 static inline void mdfld_check_boundary(struct mdfld_dbi_dpu_info *dpu_info,
108 struct psb_drm_dpu_rect *rect)
110 if (rect->x < 0)
111 rect->x = 0;
112 if (rect->y < 0)
113 rect->y = 0;
115 if (rect->x + rect->width > 864)
116 rect->width = 864 - rect->x;
117 if (rect->y + rect->height > 480)
118 rect->height = 480 - rect->height;
120 if (!rect->width)
121 rect->width = 1;
122 if (!rect->height)
123 rect->height = 1;
126 static inline void mdfld_dpu_init_damage(struct mdfld_dbi_dpu_info *dpu_info,
127 int pipe)
129 struct psb_drm_dpu_rect *rect;
131 if (pipe == 0)
132 rect = &dpu_info->damage_pipea;
133 else
134 rect = &dpu_info->damage_pipec;
136 rect->x = 864;
137 rect->y = 480;
138 rect->width = -864;
139 rect->height = -480;
142 extern int mdfld_dsi_dbi_dsr_off(struct drm_device *dev,
143 struct psb_drm_dpu_rect *rect);
144 extern int mdfld_dbi_dpu_report_damage(struct drm_device *dev,
145 mdfld_plane_t plane,
146 struct psb_drm_dpu_rect *rect);
147 extern int mdfld_dbi_dpu_report_fullscreen_damage(struct drm_device *dev);
148 extern int mdfld_dpu_exit_dsr(struct drm_device *dev);
149 extern void mdfld_dbi_dpu_timer_start(struct mdfld_dbi_dpu_info *dpu_info);
150 extern int mdfld_dbi_dpu_init(struct drm_device *dev);
151 extern void mdfld_dbi_dpu_exit(struct drm_device *dev);
152 extern void mdfld_dpu_update_panel(struct drm_device *dev);
154 #endif /*__MDFLD_DSI_DBI_DPU_H__*/