Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Texas Instruments |
| 3 | * Author: Tomi Valkeinen <tomi.valkeinen@ti.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published by |
| 7 | * the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #define DSS_SUBSYS_NAME "APPLY" |
| 19 | |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/spinlock.h> |
| 23 | #include <linux/jiffies.h> |
| 24 | |
| 25 | #include <video/omapdss.h> |
| 26 | |
| 27 | #include "dss.h" |
| 28 | #include "dss_features.h" |
| 29 | |
| 30 | /* |
| 31 | * We have 4 levels of cache for the dispc settings. First two are in SW and |
| 32 | * the latter two in HW. |
| 33 | * |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 34 | * set_info() |
| 35 | * v |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 36 | * +--------------------+ |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 37 | * | user_info | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 38 | * +--------------------+ |
| 39 | * v |
| 40 | * apply() |
| 41 | * v |
| 42 | * +--------------------+ |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 43 | * | info | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 44 | * +--------------------+ |
| 45 | * v |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 46 | * write_regs() |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 47 | * v |
| 48 | * +--------------------+ |
| 49 | * | shadow registers | |
| 50 | * +--------------------+ |
| 51 | * v |
| 52 | * VFP or lcd/digit_enable |
| 53 | * v |
| 54 | * +--------------------+ |
| 55 | * | registers | |
| 56 | * +--------------------+ |
| 57 | */ |
| 58 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 59 | struct ovl_priv_data { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 60 | |
| 61 | bool user_info_dirty; |
| 62 | struct omap_overlay_info user_info; |
| 63 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 64 | bool info_dirty; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 65 | struct omap_overlay_info info; |
| 66 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 67 | bool shadow_info_dirty; |
| 68 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 69 | bool extra_info_dirty; |
| 70 | bool shadow_extra_info_dirty; |
| 71 | |
| 72 | bool enabled; |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 73 | enum omap_channel channel; |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 74 | u32 fifo_low, fifo_high; |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 75 | |
| 76 | /* |
| 77 | * True if overlay is to be enabled. Used to check and calculate configs |
| 78 | * for the overlay before it is enabled in the HW. |
| 79 | */ |
| 80 | bool enabling; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 81 | }; |
| 82 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 83 | struct mgr_priv_data { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 84 | |
| 85 | bool user_info_dirty; |
| 86 | struct omap_overlay_manager_info user_info; |
| 87 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 88 | bool info_dirty; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 89 | struct omap_overlay_manager_info info; |
| 90 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 91 | bool shadow_info_dirty; |
| 92 | |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 93 | /* If true, GO bit is up and shadow registers cannot be written. |
| 94 | * Never true for manual update displays */ |
| 95 | bool busy; |
| 96 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 97 | /* If true, dispc output is enabled */ |
| 98 | bool updating; |
| 99 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 100 | /* If true, a display is enabled using this manager */ |
| 101 | bool enabled; |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 102 | |
| 103 | bool extra_info_dirty; |
| 104 | bool shadow_extra_info_dirty; |
| 105 | |
| 106 | struct omap_video_timings timings; |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 107 | struct dss_lcd_mgr_config lcd_config; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | static struct { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 111 | struct ovl_priv_data ovl_priv_data_array[MAX_DSS_OVERLAYS]; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 112 | struct mgr_priv_data mgr_priv_data_array[MAX_DSS_MANAGERS]; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 113 | |
Tomi Valkeinen | fb01197 | 2011-11-16 15:00:22 +0200 | [diff] [blame] | 114 | bool fifo_merge_dirty; |
| 115 | bool fifo_merge; |
| 116 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 117 | bool irq_enabled; |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 118 | } dss_data; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 119 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 120 | /* protects dss_data */ |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 121 | static spinlock_t data_lock; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 122 | /* lock for blocking functions */ |
| 123 | static DEFINE_MUTEX(apply_lock); |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 124 | static DECLARE_COMPLETION(extra_updated_completion); |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 125 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 126 | static void dss_register_vsync_isr(void); |
| 127 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 128 | static struct ovl_priv_data *get_ovl_priv(struct omap_overlay *ovl) |
| 129 | { |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 130 | return &dss_data.ovl_priv_data_array[ovl->id]; |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 131 | } |
| 132 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 133 | static struct mgr_priv_data *get_mgr_priv(struct omap_overlay_manager *mgr) |
| 134 | { |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 135 | return &dss_data.mgr_priv_data_array[mgr->id]; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 136 | } |
| 137 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 138 | void dss_apply_init(void) |
| 139 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 140 | const int num_ovls = dss_feat_get_num_ovls(); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 141 | struct mgr_priv_data *mp; |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 142 | int i; |
| 143 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 144 | spin_lock_init(&data_lock); |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 145 | |
| 146 | for (i = 0; i < num_ovls; ++i) { |
| 147 | struct ovl_priv_data *op; |
| 148 | |
| 149 | op = &dss_data.ovl_priv_data_array[i]; |
| 150 | |
| 151 | op->info.global_alpha = 255; |
| 152 | |
| 153 | switch (i) { |
| 154 | case 0: |
| 155 | op->info.zorder = 0; |
| 156 | break; |
| 157 | case 1: |
| 158 | op->info.zorder = |
| 159 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 3 : 0; |
| 160 | break; |
| 161 | case 2: |
| 162 | op->info.zorder = |
| 163 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 2 : 0; |
| 164 | break; |
| 165 | case 3: |
| 166 | op->info.zorder = |
| 167 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 1 : 0; |
| 168 | break; |
| 169 | } |
| 170 | |
| 171 | op->user_info = op->info; |
| 172 | } |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 173 | |
| 174 | /* |
| 175 | * Initialize some of the lcd_config fields for TV manager, this lets |
| 176 | * us prevent checking if the manager is LCD or TV at some places |
| 177 | */ |
| 178 | mp = &dss_data.mgr_priv_data_array[OMAP_DSS_CHANNEL_DIGIT]; |
| 179 | |
| 180 | mp->lcd_config.video_port_width = 24; |
| 181 | mp->lcd_config.clock_info.lck_div = 1; |
| 182 | mp->lcd_config.clock_info.pck_div = 1; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 183 | } |
| 184 | |
Archit Taneja | 75bac5d | 2012-05-24 15:08:54 +0530 | [diff] [blame] | 185 | /* |
| 186 | * A LCD manager's stallmode decides whether it is in manual or auto update. TV |
| 187 | * manager is always auto update, stallmode field for TV manager is false by |
| 188 | * default |
| 189 | */ |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 190 | static bool ovl_manual_update(struct omap_overlay *ovl) |
| 191 | { |
Archit Taneja | 75bac5d | 2012-05-24 15:08:54 +0530 | [diff] [blame] | 192 | struct mgr_priv_data *mp = get_mgr_priv(ovl->manager); |
| 193 | |
| 194 | return mp->lcd_config.stallmode; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static bool mgr_manual_update(struct omap_overlay_manager *mgr) |
| 198 | { |
Archit Taneja | 75bac5d | 2012-05-24 15:08:54 +0530 | [diff] [blame] | 199 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 200 | |
| 201 | return mp->lcd_config.stallmode; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 202 | } |
| 203 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 204 | static int dss_check_settings_low(struct omap_overlay_manager *mgr, |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 205 | bool applying) |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 206 | { |
| 207 | struct omap_overlay_info *oi; |
| 208 | struct omap_overlay_manager_info *mi; |
| 209 | struct omap_overlay *ovl; |
| 210 | struct omap_overlay_info *ois[MAX_DSS_OVERLAYS]; |
| 211 | struct ovl_priv_data *op; |
| 212 | struct mgr_priv_data *mp; |
| 213 | |
| 214 | mp = get_mgr_priv(mgr); |
| 215 | |
Archit Taneja | 5dd747e | 2012-05-08 18:19:15 +0530 | [diff] [blame] | 216 | if (!mp->enabled) |
| 217 | return 0; |
| 218 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 219 | if (applying && mp->user_info_dirty) |
| 220 | mi = &mp->user_info; |
| 221 | else |
| 222 | mi = &mp->info; |
| 223 | |
| 224 | /* collect the infos to be tested into the array */ |
| 225 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 226 | op = get_ovl_priv(ovl); |
| 227 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 228 | if (!op->enabled && !op->enabling) |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 229 | oi = NULL; |
| 230 | else if (applying && op->user_info_dirty) |
| 231 | oi = &op->user_info; |
| 232 | else |
| 233 | oi = &op->info; |
| 234 | |
| 235 | ois[ovl->id] = oi; |
| 236 | } |
| 237 | |
Archit Taneja | 6e54359 | 2012-05-23 17:01:35 +0530 | [diff] [blame] | 238 | return dss_mgr_check(mgr, mi, &mp->timings, &mp->lcd_config, ois); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* |
| 242 | * check manager and overlay settings using overlay_info from data->info |
| 243 | */ |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 244 | static int dss_check_settings(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 245 | { |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 246 | return dss_check_settings_low(mgr, false); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | /* |
| 250 | * check manager and overlay settings using overlay_info from ovl->info if |
| 251 | * dirty and from data->info otherwise |
| 252 | */ |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 253 | static int dss_check_settings_apply(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 254 | { |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 255 | return dss_check_settings_low(mgr, true); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 256 | } |
| 257 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 258 | static bool need_isr(void) |
| 259 | { |
| 260 | const int num_mgrs = dss_feat_get_num_mgrs(); |
| 261 | int i; |
| 262 | |
| 263 | for (i = 0; i < num_mgrs; ++i) { |
| 264 | struct omap_overlay_manager *mgr; |
| 265 | struct mgr_priv_data *mp; |
| 266 | struct omap_overlay *ovl; |
| 267 | |
| 268 | mgr = omap_dss_get_overlay_manager(i); |
| 269 | mp = get_mgr_priv(mgr); |
| 270 | |
| 271 | if (!mp->enabled) |
| 272 | continue; |
| 273 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 274 | if (mgr_manual_update(mgr)) { |
| 275 | /* to catch FRAMEDONE */ |
| 276 | if (mp->updating) |
| 277 | return true; |
| 278 | } else { |
| 279 | /* to catch GO bit going down */ |
| 280 | if (mp->busy) |
| 281 | return true; |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 282 | |
| 283 | /* to write new values to registers */ |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 284 | if (mp->info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 285 | return true; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 286 | |
Tomi Valkeinen | 9f80895 | 2011-11-25 17:26:13 +0200 | [diff] [blame] | 287 | /* to set GO bit */ |
| 288 | if (mp->shadow_info_dirty) |
| 289 | return true; |
| 290 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 291 | /* |
| 292 | * NOTE: we don't check extra_info flags for disabled |
| 293 | * managers, once the manager is enabled, the extra_info |
| 294 | * related manager changes will be taken in by HW. |
| 295 | */ |
| 296 | |
| 297 | /* to write new values to registers */ |
| 298 | if (mp->extra_info_dirty) |
| 299 | return true; |
| 300 | |
| 301 | /* to set GO bit */ |
| 302 | if (mp->shadow_extra_info_dirty) |
| 303 | return true; |
| 304 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 305 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 306 | struct ovl_priv_data *op; |
| 307 | |
| 308 | op = get_ovl_priv(ovl); |
| 309 | |
Tomi Valkeinen | 9f80895 | 2011-11-25 17:26:13 +0200 | [diff] [blame] | 310 | /* |
| 311 | * NOTE: we check extra_info flags even for |
| 312 | * disabled overlays, as extra_infos need to be |
| 313 | * always written. |
| 314 | */ |
| 315 | |
| 316 | /* to write new values to registers */ |
| 317 | if (op->extra_info_dirty) |
| 318 | return true; |
| 319 | |
| 320 | /* to set GO bit */ |
| 321 | if (op->shadow_extra_info_dirty) |
| 322 | return true; |
| 323 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 324 | if (!op->enabled) |
| 325 | continue; |
| 326 | |
| 327 | /* to write new values to registers */ |
Tomi Valkeinen | 9f80895 | 2011-11-25 17:26:13 +0200 | [diff] [blame] | 328 | if (op->info_dirty) |
| 329 | return true; |
| 330 | |
| 331 | /* to set GO bit */ |
| 332 | if (op->shadow_info_dirty) |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 333 | return true; |
| 334 | } |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | |
| 338 | return false; |
| 339 | } |
| 340 | |
| 341 | static bool need_go(struct omap_overlay_manager *mgr) |
| 342 | { |
| 343 | struct omap_overlay *ovl; |
| 344 | struct mgr_priv_data *mp; |
| 345 | struct ovl_priv_data *op; |
| 346 | |
| 347 | mp = get_mgr_priv(mgr); |
| 348 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 349 | if (mp->shadow_info_dirty || mp->shadow_extra_info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 350 | return true; |
| 351 | |
| 352 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 353 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 354 | if (op->shadow_info_dirty || op->shadow_extra_info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 355 | return true; |
| 356 | } |
| 357 | |
| 358 | return false; |
| 359 | } |
| 360 | |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 361 | /* returns true if an extra_info field is currently being updated */ |
| 362 | static bool extra_info_update_ongoing(void) |
| 363 | { |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 364 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 365 | int i; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 366 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 367 | for (i = 0; i < num_mgrs; ++i) { |
| 368 | struct omap_overlay_manager *mgr; |
| 369 | struct omap_overlay *ovl; |
| 370 | struct mgr_priv_data *mp; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 371 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 372 | mgr = omap_dss_get_overlay_manager(i); |
| 373 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 374 | |
| 375 | if (!mp->enabled) |
| 376 | continue; |
| 377 | |
Tomi Valkeinen | 153b6e7 | 2011-11-25 17:35:35 +0200 | [diff] [blame] | 378 | if (!mp->updating) |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 379 | continue; |
| 380 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 381 | if (mp->extra_info_dirty || mp->shadow_extra_info_dirty) |
Tomi Valkeinen | 153b6e7 | 2011-11-25 17:35:35 +0200 | [diff] [blame] | 382 | return true; |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 383 | |
| 384 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 385 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 386 | |
| 387 | if (op->extra_info_dirty || op->shadow_extra_info_dirty) |
| 388 | return true; |
| 389 | } |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | return false; |
| 393 | } |
| 394 | |
| 395 | /* wait until no extra_info updates are pending */ |
| 396 | static void wait_pending_extra_info_updates(void) |
| 397 | { |
| 398 | bool updating; |
| 399 | unsigned long flags; |
| 400 | unsigned long t; |
Tomi Valkeinen | 4614679 | 2012-02-23 12:21:09 +0200 | [diff] [blame] | 401 | int r; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 402 | |
| 403 | spin_lock_irqsave(&data_lock, flags); |
| 404 | |
| 405 | updating = extra_info_update_ongoing(); |
| 406 | |
| 407 | if (!updating) { |
| 408 | spin_unlock_irqrestore(&data_lock, flags); |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | init_completion(&extra_updated_completion); |
| 413 | |
| 414 | spin_unlock_irqrestore(&data_lock, flags); |
| 415 | |
| 416 | t = msecs_to_jiffies(500); |
Tomi Valkeinen | 4614679 | 2012-02-23 12:21:09 +0200 | [diff] [blame] | 417 | r = wait_for_completion_timeout(&extra_updated_completion, t); |
| 418 | if (r == 0) |
| 419 | DSSWARN("timeout in wait_pending_extra_info_updates\n"); |
| 420 | else if (r < 0) |
| 421 | DSSERR("wait_pending_extra_info_updates failed: %d\n", r); |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 422 | } |
| 423 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 424 | int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr) |
| 425 | { |
| 426 | unsigned long timeout = msecs_to_jiffies(500); |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 427 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 428 | u32 irq; |
| 429 | int r; |
| 430 | int i; |
| 431 | struct omap_dss_device *dssdev = mgr->device; |
| 432 | |
| 433 | if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) |
| 434 | return 0; |
| 435 | |
| 436 | if (mgr_manual_update(mgr)) |
| 437 | return 0; |
| 438 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 439 | r = dispc_runtime_get(); |
| 440 | if (r) |
| 441 | return r; |
| 442 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 443 | irq = dispc_mgr_get_vsync_irq(mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 444 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 445 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 446 | i = 0; |
| 447 | while (1) { |
| 448 | unsigned long flags; |
| 449 | bool shadow_dirty, dirty; |
| 450 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 451 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 452 | dirty = mp->info_dirty; |
| 453 | shadow_dirty = mp->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 454 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 455 | |
| 456 | if (!dirty && !shadow_dirty) { |
| 457 | r = 0; |
| 458 | break; |
| 459 | } |
| 460 | |
| 461 | /* 4 iterations is the worst case: |
| 462 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 463 | * 2 - first VSYNC, dirty = true |
| 464 | * 3 - dirty = false, shadow_dirty = true |
| 465 | * 4 - shadow_dirty = false */ |
| 466 | if (i++ == 3) { |
| 467 | DSSERR("mgr(%d)->wait_for_go() not finishing\n", |
| 468 | mgr->id); |
| 469 | r = 0; |
| 470 | break; |
| 471 | } |
| 472 | |
| 473 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 474 | if (r == -ERESTARTSYS) |
| 475 | break; |
| 476 | |
| 477 | if (r) { |
| 478 | DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr->id); |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 483 | dispc_runtime_put(); |
| 484 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 485 | return r; |
| 486 | } |
| 487 | |
| 488 | int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl) |
| 489 | { |
| 490 | unsigned long timeout = msecs_to_jiffies(500); |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 491 | struct ovl_priv_data *op; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 492 | struct omap_dss_device *dssdev; |
| 493 | u32 irq; |
| 494 | int r; |
| 495 | int i; |
| 496 | |
| 497 | if (!ovl->manager) |
| 498 | return 0; |
| 499 | |
| 500 | dssdev = ovl->manager->device; |
| 501 | |
| 502 | if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) |
| 503 | return 0; |
| 504 | |
| 505 | if (ovl_manual_update(ovl)) |
| 506 | return 0; |
| 507 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 508 | r = dispc_runtime_get(); |
| 509 | if (r) |
| 510 | return r; |
| 511 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 512 | irq = dispc_mgr_get_vsync_irq(ovl->manager->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 513 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 514 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 515 | i = 0; |
| 516 | while (1) { |
| 517 | unsigned long flags; |
| 518 | bool shadow_dirty, dirty; |
| 519 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 520 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 521 | dirty = op->info_dirty; |
| 522 | shadow_dirty = op->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 523 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 524 | |
| 525 | if (!dirty && !shadow_dirty) { |
| 526 | r = 0; |
| 527 | break; |
| 528 | } |
| 529 | |
| 530 | /* 4 iterations is the worst case: |
| 531 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 532 | * 2 - first VSYNC, dirty = true |
| 533 | * 3 - dirty = false, shadow_dirty = true |
| 534 | * 4 - shadow_dirty = false */ |
| 535 | if (i++ == 3) { |
| 536 | DSSERR("ovl(%d)->wait_for_go() not finishing\n", |
| 537 | ovl->id); |
| 538 | r = 0; |
| 539 | break; |
| 540 | } |
| 541 | |
| 542 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 543 | if (r == -ERESTARTSYS) |
| 544 | break; |
| 545 | |
| 546 | if (r) { |
| 547 | DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl->id); |
| 548 | break; |
| 549 | } |
| 550 | } |
| 551 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 552 | dispc_runtime_put(); |
| 553 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 554 | return r; |
| 555 | } |
| 556 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 557 | static void dss_ovl_write_regs(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 558 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 559 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 560 | struct omap_overlay_info *oi; |
Archit Taneja | 8050cbe | 2012-06-06 16:25:52 +0530 | [diff] [blame] | 561 | bool replication; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 562 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 563 | int r; |
| 564 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 565 | DSSDBGF("%d", ovl->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 566 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 567 | if (!op->enabled || !op->info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 568 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 569 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 570 | oi = &op->info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 571 | |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 572 | mp = get_mgr_priv(ovl->manager); |
| 573 | |
Archit Taneja | 6c6f510 | 2012-06-25 14:58:48 +0530 | [diff] [blame] | 574 | replication = dss_ovl_use_replication(mp->lcd_config, oi->color_mode); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 575 | |
Archit Taneja | 8050cbe | 2012-06-06 16:25:52 +0530 | [diff] [blame] | 576 | r = dispc_ovl_setup(ovl->id, oi, replication, &mp->timings); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 577 | if (r) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 578 | /* |
| 579 | * We can't do much here, as this function can be called from |
| 580 | * vsync interrupt. |
| 581 | */ |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 582 | DSSERR("dispc_ovl_setup failed for ovl %d\n", ovl->id); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 583 | |
| 584 | /* This will leave fifo configurations in a nonoptimal state */ |
| 585 | op->enabled = false; |
| 586 | dispc_ovl_enable(ovl->id, false); |
| 587 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 588 | } |
| 589 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 590 | op->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 591 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 592 | op->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 593 | } |
| 594 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 595 | static void dss_ovl_write_regs_extra(struct omap_overlay *ovl) |
| 596 | { |
| 597 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 598 | struct mgr_priv_data *mp; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 599 | |
| 600 | DSSDBGF("%d", ovl->id); |
| 601 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 602 | if (!op->extra_info_dirty) |
| 603 | return; |
| 604 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 605 | /* note: write also when op->enabled == false, so that the ovl gets |
| 606 | * disabled */ |
| 607 | |
| 608 | dispc_ovl_enable(ovl->id, op->enabled); |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 609 | dispc_ovl_set_channel_out(ovl->id, op->channel); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 610 | dispc_ovl_set_fifo_threshold(ovl->id, op->fifo_low, op->fifo_high); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 611 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 612 | mp = get_mgr_priv(ovl->manager); |
| 613 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 614 | op->extra_info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 615 | if (mp->updating) |
| 616 | op->shadow_extra_info_dirty = true; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 617 | } |
| 618 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 619 | static void dss_mgr_write_regs(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 620 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 621 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 622 | struct omap_overlay *ovl; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 623 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 624 | DSSDBGF("%d", mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 625 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 626 | if (!mp->enabled) |
| 627 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 628 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 629 | WARN_ON(mp->busy); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 630 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 631 | /* Commit overlay settings */ |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 632 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 633 | dss_ovl_write_regs(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 634 | dss_ovl_write_regs_extra(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 635 | } |
| 636 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 637 | if (mp->info_dirty) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 638 | dispc_mgr_setup(mgr->id, &mp->info); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 639 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 640 | mp->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 641 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 642 | mp->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 643 | } |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 644 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 645 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 646 | static void dss_mgr_write_regs_extra(struct omap_overlay_manager *mgr) |
| 647 | { |
| 648 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 649 | |
| 650 | DSSDBGF("%d", mgr->id); |
| 651 | |
| 652 | if (!mp->extra_info_dirty) |
| 653 | return; |
| 654 | |
| 655 | dispc_mgr_set_timings(mgr->id, &mp->timings); |
| 656 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 657 | /* lcd_config parameters */ |
| 658 | if (dss_mgr_is_lcd(mgr->id)) { |
| 659 | dispc_mgr_set_io_pad_mode(mp->lcd_config.io_pad_mode); |
| 660 | |
| 661 | dispc_mgr_enable_stallmode(mgr->id, mp->lcd_config.stallmode); |
| 662 | dispc_mgr_enable_fifohandcheck(mgr->id, |
| 663 | mp->lcd_config.fifohandcheck); |
| 664 | |
| 665 | dispc_mgr_set_clock_div(mgr->id, &mp->lcd_config.clock_info); |
| 666 | |
| 667 | dispc_mgr_set_tft_data_lines(mgr->id, |
| 668 | mp->lcd_config.video_port_width); |
| 669 | |
| 670 | dispc_lcd_enable_signal_polarity(mp->lcd_config.lcden_sig_polarity); |
| 671 | |
| 672 | dispc_mgr_set_lcd_type_tft(mgr->id); |
| 673 | } |
| 674 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 675 | mp->extra_info_dirty = false; |
| 676 | if (mp->updating) |
| 677 | mp->shadow_extra_info_dirty = true; |
| 678 | } |
| 679 | |
Tomi Valkeinen | fb01197 | 2011-11-16 15:00:22 +0200 | [diff] [blame] | 680 | static void dss_write_regs_common(void) |
| 681 | { |
| 682 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 683 | int i; |
| 684 | |
| 685 | if (!dss_data.fifo_merge_dirty) |
| 686 | return; |
| 687 | |
| 688 | for (i = 0; i < num_mgrs; ++i) { |
| 689 | struct omap_overlay_manager *mgr; |
| 690 | struct mgr_priv_data *mp; |
| 691 | |
| 692 | mgr = omap_dss_get_overlay_manager(i); |
| 693 | mp = get_mgr_priv(mgr); |
| 694 | |
| 695 | if (mp->enabled) { |
| 696 | if (dss_data.fifo_merge_dirty) { |
| 697 | dispc_enable_fifomerge(dss_data.fifo_merge); |
| 698 | dss_data.fifo_merge_dirty = false; |
| 699 | } |
| 700 | |
| 701 | if (mp->updating) |
| 702 | mp->shadow_info_dirty = true; |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 707 | static void dss_write_regs(void) |
| 708 | { |
| 709 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 710 | int i; |
| 711 | |
Tomi Valkeinen | fb01197 | 2011-11-16 15:00:22 +0200 | [diff] [blame] | 712 | dss_write_regs_common(); |
| 713 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 714 | for (i = 0; i < num_mgrs; ++i) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 715 | struct omap_overlay_manager *mgr; |
| 716 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 717 | int r; |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 718 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 719 | mgr = omap_dss_get_overlay_manager(i); |
| 720 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 721 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 722 | if (!mp->enabled || mgr_manual_update(mgr) || mp->busy) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 723 | continue; |
| 724 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 725 | r = dss_check_settings(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 726 | if (r) { |
| 727 | DSSERR("cannot write registers for manager %s: " |
| 728 | "illegal configuration\n", mgr->name); |
| 729 | continue; |
| 730 | } |
| 731 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 732 | dss_mgr_write_regs(mgr); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 733 | dss_mgr_write_regs_extra(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 734 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 735 | } |
| 736 | |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 737 | static void dss_set_go_bits(void) |
| 738 | { |
| 739 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 740 | int i; |
| 741 | |
| 742 | for (i = 0; i < num_mgrs; ++i) { |
| 743 | struct omap_overlay_manager *mgr; |
| 744 | struct mgr_priv_data *mp; |
| 745 | |
| 746 | mgr = omap_dss_get_overlay_manager(i); |
| 747 | mp = get_mgr_priv(mgr); |
| 748 | |
| 749 | if (!mp->enabled || mgr_manual_update(mgr) || mp->busy) |
| 750 | continue; |
| 751 | |
| 752 | if (!need_go(mgr)) |
| 753 | continue; |
| 754 | |
| 755 | mp->busy = true; |
| 756 | |
| 757 | if (!dss_data.irq_enabled && need_isr()) |
| 758 | dss_register_vsync_isr(); |
| 759 | |
| 760 | dispc_mgr_go(mgr->id); |
| 761 | } |
| 762 | |
| 763 | } |
| 764 | |
Tomi Valkeinen | df01d53 | 2012-03-07 10:28:48 +0200 | [diff] [blame] | 765 | static void mgr_clear_shadow_dirty(struct omap_overlay_manager *mgr) |
| 766 | { |
| 767 | struct omap_overlay *ovl; |
| 768 | struct mgr_priv_data *mp; |
| 769 | struct ovl_priv_data *op; |
| 770 | |
| 771 | mp = get_mgr_priv(mgr); |
| 772 | mp->shadow_info_dirty = false; |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 773 | mp->shadow_extra_info_dirty = false; |
Tomi Valkeinen | df01d53 | 2012-03-07 10:28:48 +0200 | [diff] [blame] | 774 | |
| 775 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 776 | op = get_ovl_priv(ovl); |
| 777 | op->shadow_info_dirty = false; |
| 778 | op->shadow_extra_info_dirty = false; |
| 779 | } |
| 780 | } |
| 781 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 782 | void dss_mgr_start_update(struct omap_overlay_manager *mgr) |
| 783 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 784 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 785 | unsigned long flags; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 786 | int r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 787 | |
| 788 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 789 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 790 | WARN_ON(mp->updating); |
| 791 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 792 | r = dss_check_settings(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 793 | if (r) { |
| 794 | DSSERR("cannot start manual update: illegal configuration\n"); |
| 795 | spin_unlock_irqrestore(&data_lock, flags); |
| 796 | return; |
| 797 | } |
| 798 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 799 | dss_mgr_write_regs(mgr); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 800 | dss_mgr_write_regs_extra(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 801 | |
Tomi Valkeinen | fb01197 | 2011-11-16 15:00:22 +0200 | [diff] [blame] | 802 | dss_write_regs_common(); |
| 803 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 804 | mp->updating = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 805 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 806 | if (!dss_data.irq_enabled && need_isr()) |
| 807 | dss_register_vsync_isr(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 808 | |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 809 | dispc_mgr_enable(mgr->id, true); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 810 | |
Tomi Valkeinen | df01d53 | 2012-03-07 10:28:48 +0200 | [diff] [blame] | 811 | mgr_clear_shadow_dirty(mgr); |
| 812 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 813 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 814 | } |
| 815 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 816 | static void dss_apply_irq_handler(void *data, u32 mask); |
| 817 | |
| 818 | static void dss_register_vsync_isr(void) |
| 819 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 820 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 821 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 822 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 823 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 824 | mask = 0; |
| 825 | for (i = 0; i < num_mgrs; ++i) |
| 826 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 827 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 828 | for (i = 0; i < num_mgrs; ++i) |
| 829 | mask |= dispc_mgr_get_framedone_irq(i); |
| 830 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 831 | r = omap_dispc_register_isr(dss_apply_irq_handler, NULL, mask); |
| 832 | WARN_ON(r); |
| 833 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 834 | dss_data.irq_enabled = true; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | static void dss_unregister_vsync_isr(void) |
| 838 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 839 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 840 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 841 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 842 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 843 | mask = 0; |
| 844 | for (i = 0; i < num_mgrs; ++i) |
| 845 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 846 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 847 | for (i = 0; i < num_mgrs; ++i) |
| 848 | mask |= dispc_mgr_get_framedone_irq(i); |
| 849 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 850 | r = omap_dispc_unregister_isr(dss_apply_irq_handler, NULL, mask); |
| 851 | WARN_ON(r); |
| 852 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 853 | dss_data.irq_enabled = false; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 854 | } |
| 855 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 856 | static void dss_apply_irq_handler(void *data, u32 mask) |
| 857 | { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 858 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 859 | int i; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 860 | bool extra_updating; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 861 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 862 | spin_lock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 863 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 864 | /* clear busy, updating flags, shadow_dirty flags */ |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 865 | for (i = 0; i < num_mgrs; i++) { |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 866 | struct omap_overlay_manager *mgr; |
| 867 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 868 | bool was_updating; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 869 | |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 870 | mgr = omap_dss_get_overlay_manager(i); |
| 871 | mp = get_mgr_priv(mgr); |
| 872 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 873 | if (!mp->enabled) |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 874 | continue; |
| 875 | |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 876 | was_updating = mp->updating; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 877 | mp->updating = dispc_mgr_is_enabled(i); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 878 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 879 | if (!mgr_manual_update(mgr)) { |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 880 | bool was_busy = mp->busy; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 881 | mp->busy = dispc_mgr_go_busy(i); |
| 882 | |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 883 | if (was_busy && !mp->busy) |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 884 | mgr_clear_shadow_dirty(mgr); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 885 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 886 | } |
| 887 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 888 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 889 | dss_set_go_bits(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 890 | |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 891 | extra_updating = extra_info_update_ongoing(); |
| 892 | if (!extra_updating) |
| 893 | complete_all(&extra_updated_completion); |
| 894 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 895 | if (!need_isr()) |
| 896 | dss_unregister_vsync_isr(); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 897 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 898 | spin_unlock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 899 | } |
| 900 | |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 901 | static void omap_dss_mgr_apply_ovl(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 902 | { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 903 | struct ovl_priv_data *op; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 904 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 905 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 906 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 907 | if (!op->user_info_dirty) |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 908 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 909 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 910 | op->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 911 | op->info_dirty = true; |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 912 | op->info = op->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | static void omap_dss_mgr_apply_mgr(struct omap_overlay_manager *mgr) |
| 916 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 917 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 918 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 919 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 920 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 921 | if (!mp->user_info_dirty) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 922 | return; |
| 923 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 924 | mp->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 925 | mp->info_dirty = true; |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 926 | mp->info = mp->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 927 | } |
| 928 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 929 | int omap_dss_mgr_apply(struct omap_overlay_manager *mgr) |
| 930 | { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 931 | unsigned long flags; |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 932 | struct omap_overlay *ovl; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 933 | int r; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 934 | |
| 935 | DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name); |
| 936 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 937 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 938 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 939 | r = dss_check_settings_apply(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 940 | if (r) { |
| 941 | spin_unlock_irqrestore(&data_lock, flags); |
| 942 | DSSERR("failed to apply settings: illegal configuration.\n"); |
| 943 | return r; |
| 944 | } |
| 945 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 946 | /* Configure overlays */ |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 947 | list_for_each_entry(ovl, &mgr->overlays, list) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 948 | omap_dss_mgr_apply_ovl(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 949 | |
| 950 | /* Configure manager */ |
| 951 | omap_dss_mgr_apply_mgr(mgr); |
| 952 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 953 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 954 | dss_set_go_bits(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 955 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 956 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 957 | |
Tomi Valkeinen | e70f98a | 2011-11-16 16:53:44 +0200 | [diff] [blame] | 958 | return 0; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 959 | } |
| 960 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame] | 961 | static void dss_apply_ovl_enable(struct omap_overlay *ovl, bool enable) |
| 962 | { |
| 963 | struct ovl_priv_data *op; |
| 964 | |
| 965 | op = get_ovl_priv(ovl); |
| 966 | |
| 967 | if (op->enabled == enable) |
| 968 | return; |
| 969 | |
| 970 | op->enabled = enable; |
| 971 | op->extra_info_dirty = true; |
| 972 | } |
| 973 | |
Tomi Valkeinen | 04576d4 | 2011-11-26 14:39:16 +0200 | [diff] [blame] | 974 | static void dss_apply_ovl_fifo_thresholds(struct omap_overlay *ovl, |
| 975 | u32 fifo_low, u32 fifo_high) |
| 976 | { |
| 977 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 978 | |
| 979 | if (op->fifo_low == fifo_low && op->fifo_high == fifo_high) |
| 980 | return; |
| 981 | |
| 982 | op->fifo_low = fifo_low; |
| 983 | op->fifo_high = fifo_high; |
| 984 | op->extra_info_dirty = true; |
| 985 | } |
| 986 | |
Tomi Valkeinen | fb01197 | 2011-11-16 15:00:22 +0200 | [diff] [blame] | 987 | static void dss_apply_fifo_merge(bool use_fifo_merge) |
| 988 | { |
| 989 | if (dss_data.fifo_merge == use_fifo_merge) |
| 990 | return; |
| 991 | |
| 992 | dss_data.fifo_merge = use_fifo_merge; |
| 993 | dss_data.fifo_merge_dirty = true; |
| 994 | } |
| 995 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 996 | static void dss_ovl_setup_fifo(struct omap_overlay *ovl, |
| 997 | bool use_fifo_merge) |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 998 | { |
| 999 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1000 | u32 fifo_low, fifo_high; |
| 1001 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 1002 | if (!op->enabled && !op->enabling) |
| 1003 | return; |
| 1004 | |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 1005 | dispc_ovl_compute_fifo_thresholds(ovl->id, &fifo_low, &fifo_high, |
Tomi Valkeinen | 3568f2a | 2012-05-15 15:31:01 +0300 | [diff] [blame] | 1006 | use_fifo_merge, ovl_manual_update(ovl)); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1007 | |
Tomi Valkeinen | 04576d4 | 2011-11-26 14:39:16 +0200 | [diff] [blame] | 1008 | dss_apply_ovl_fifo_thresholds(ovl, fifo_low, fifo_high); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1009 | } |
| 1010 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1011 | static void dss_mgr_setup_fifos(struct omap_overlay_manager *mgr, |
| 1012 | bool use_fifo_merge) |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1013 | { |
| 1014 | struct omap_overlay *ovl; |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1015 | struct mgr_priv_data *mp; |
| 1016 | |
| 1017 | mp = get_mgr_priv(mgr); |
| 1018 | |
| 1019 | if (!mp->enabled) |
| 1020 | return; |
| 1021 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 1022 | list_for_each_entry(ovl, &mgr->overlays, list) |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1023 | dss_ovl_setup_fifo(ovl, use_fifo_merge); |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 1024 | } |
| 1025 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1026 | static void dss_setup_fifos(bool use_fifo_merge) |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 1027 | { |
| 1028 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 1029 | struct omap_overlay_manager *mgr; |
| 1030 | int i; |
| 1031 | |
| 1032 | for (i = 0; i < num_mgrs; ++i) { |
| 1033 | mgr = omap_dss_get_overlay_manager(i); |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1034 | dss_mgr_setup_fifos(mgr, use_fifo_merge); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1035 | } |
| 1036 | } |
| 1037 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1038 | static int get_num_used_managers(void) |
| 1039 | { |
| 1040 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 1041 | struct omap_overlay_manager *mgr; |
| 1042 | struct mgr_priv_data *mp; |
| 1043 | int i; |
| 1044 | int enabled_mgrs; |
| 1045 | |
| 1046 | enabled_mgrs = 0; |
| 1047 | |
| 1048 | for (i = 0; i < num_mgrs; ++i) { |
| 1049 | mgr = omap_dss_get_overlay_manager(i); |
| 1050 | mp = get_mgr_priv(mgr); |
| 1051 | |
| 1052 | if (!mp->enabled) |
| 1053 | continue; |
| 1054 | |
| 1055 | enabled_mgrs++; |
| 1056 | } |
| 1057 | |
| 1058 | return enabled_mgrs; |
| 1059 | } |
| 1060 | |
| 1061 | static int get_num_used_overlays(void) |
| 1062 | { |
| 1063 | const int num_ovls = omap_dss_get_num_overlays(); |
| 1064 | struct omap_overlay *ovl; |
| 1065 | struct ovl_priv_data *op; |
| 1066 | struct mgr_priv_data *mp; |
| 1067 | int i; |
| 1068 | int enabled_ovls; |
| 1069 | |
| 1070 | enabled_ovls = 0; |
| 1071 | |
| 1072 | for (i = 0; i < num_ovls; ++i) { |
| 1073 | ovl = omap_dss_get_overlay(i); |
| 1074 | op = get_ovl_priv(ovl); |
| 1075 | |
| 1076 | if (!op->enabled && !op->enabling) |
| 1077 | continue; |
| 1078 | |
| 1079 | mp = get_mgr_priv(ovl->manager); |
| 1080 | |
| 1081 | if (!mp->enabled) |
| 1082 | continue; |
| 1083 | |
| 1084 | enabled_ovls++; |
| 1085 | } |
| 1086 | |
| 1087 | return enabled_ovls; |
| 1088 | } |
| 1089 | |
| 1090 | static bool get_use_fifo_merge(void) |
| 1091 | { |
| 1092 | int enabled_mgrs = get_num_used_managers(); |
| 1093 | int enabled_ovls = get_num_used_overlays(); |
| 1094 | |
| 1095 | if (!dss_has_feature(FEAT_FIFO_MERGE)) |
| 1096 | return false; |
| 1097 | |
| 1098 | /* |
| 1099 | * In theory the only requirement for fifomerge is enabled_ovls <= 1. |
| 1100 | * However, if we have two managers enabled and set/unset the fifomerge, |
| 1101 | * we need to set the GO bits in particular sequence for the managers, |
| 1102 | * and wait in between. |
| 1103 | * |
| 1104 | * This is rather difficult as new apply calls can happen at any time, |
| 1105 | * so we simplify the problem by requiring also that enabled_mgrs <= 1. |
| 1106 | * In practice this shouldn't matter, because when only one overlay is |
| 1107 | * enabled, most likely only one output is enabled. |
| 1108 | */ |
| 1109 | |
| 1110 | return enabled_mgrs <= 1 && enabled_ovls <= 1; |
| 1111 | } |
| 1112 | |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 1113 | int dss_mgr_enable(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 1114 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1115 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1116 | unsigned long flags; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1117 | int r; |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1118 | bool fifo_merge; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1119 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1120 | mutex_lock(&apply_lock); |
| 1121 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1122 | if (mp->enabled) |
| 1123 | goto out; |
| 1124 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1125 | spin_lock_irqsave(&data_lock, flags); |
| 1126 | |
| 1127 | mp->enabled = true; |
Tomi Valkeinen | a6b24f8 | 2011-11-26 14:29:39 +0200 | [diff] [blame] | 1128 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 1129 | r = dss_check_settings(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1130 | if (r) { |
| 1131 | DSSERR("failed to enable manager %d: check_settings failed\n", |
| 1132 | mgr->id); |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 1133 | goto err; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1134 | } |
| 1135 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1136 | /* step 1: setup fifos/fifomerge before enabling the manager */ |
| 1137 | |
| 1138 | fifo_merge = get_use_fifo_merge(); |
| 1139 | dss_setup_fifos(fifo_merge); |
| 1140 | dss_apply_fifo_merge(fifo_merge); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1141 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1142 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1143 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1144 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1145 | spin_unlock_irqrestore(&data_lock, flags); |
| 1146 | |
| 1147 | /* wait until fifo config is in */ |
| 1148 | wait_pending_extra_info_updates(); |
| 1149 | |
| 1150 | /* step 2: enable the manager */ |
| 1151 | spin_lock_irqsave(&data_lock, flags); |
| 1152 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 1153 | if (!mgr_manual_update(mgr)) |
| 1154 | mp->updating = true; |
| 1155 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1156 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1157 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1158 | if (!mgr_manual_update(mgr)) |
| 1159 | dispc_mgr_enable(mgr->id, true); |
| 1160 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1161 | out: |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1162 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 1163 | |
| 1164 | return 0; |
| 1165 | |
| 1166 | err: |
Tomi Valkeinen | a6b24f8 | 2011-11-26 14:29:39 +0200 | [diff] [blame] | 1167 | mp->enabled = false; |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 1168 | spin_unlock_irqrestore(&data_lock, flags); |
| 1169 | mutex_unlock(&apply_lock); |
| 1170 | return r; |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 1171 | } |
| 1172 | |
| 1173 | void dss_mgr_disable(struct omap_overlay_manager *mgr) |
| 1174 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1175 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1176 | unsigned long flags; |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1177 | bool fifo_merge; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1178 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1179 | mutex_lock(&apply_lock); |
| 1180 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1181 | if (!mp->enabled) |
| 1182 | goto out; |
| 1183 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 1184 | if (!mgr_manual_update(mgr)) |
| 1185 | dispc_mgr_enable(mgr->id, false); |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1186 | |
| 1187 | spin_lock_irqsave(&data_lock, flags); |
| 1188 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 1189 | mp->updating = false; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1190 | mp->enabled = false; |
| 1191 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1192 | fifo_merge = get_use_fifo_merge(); |
| 1193 | dss_setup_fifos(fifo_merge); |
| 1194 | dss_apply_fifo_merge(fifo_merge); |
| 1195 | |
| 1196 | dss_write_regs(); |
| 1197 | dss_set_go_bits(); |
| 1198 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1199 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1200 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1201 | wait_pending_extra_info_updates(); |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1202 | out: |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1203 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 1204 | } |
| 1205 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1206 | int dss_mgr_set_info(struct omap_overlay_manager *mgr, |
| 1207 | struct omap_overlay_manager_info *info) |
| 1208 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1209 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1210 | unsigned long flags; |
Tomi Valkeinen | f17d04f | 2011-11-17 14:31:09 +0200 | [diff] [blame] | 1211 | int r; |
| 1212 | |
| 1213 | r = dss_mgr_simple_check(mgr, info); |
| 1214 | if (r) |
| 1215 | return r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1216 | |
| 1217 | spin_lock_irqsave(&data_lock, flags); |
| 1218 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1219 | mp->user_info = *info; |
| 1220 | mp->user_info_dirty = true; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1221 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1222 | spin_unlock_irqrestore(&data_lock, flags); |
| 1223 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1224 | return 0; |
| 1225 | } |
| 1226 | |
| 1227 | void dss_mgr_get_info(struct omap_overlay_manager *mgr, |
| 1228 | struct omap_overlay_manager_info *info) |
| 1229 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1230 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1231 | unsigned long flags; |
| 1232 | |
| 1233 | spin_lock_irqsave(&data_lock, flags); |
| 1234 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1235 | *info = mp->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1236 | |
| 1237 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | int dss_mgr_set_device(struct omap_overlay_manager *mgr, |
| 1241 | struct omap_dss_device *dssdev) |
| 1242 | { |
| 1243 | int r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1244 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1245 | mutex_lock(&apply_lock); |
| 1246 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1247 | if (dssdev->manager) { |
| 1248 | DSSERR("display '%s' already has a manager '%s'\n", |
| 1249 | dssdev->name, dssdev->manager->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1250 | r = -EINVAL; |
| 1251 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1252 | } |
| 1253 | |
| 1254 | if ((mgr->supported_displays & dssdev->type) == 0) { |
| 1255 | DSSERR("display '%s' does not support manager '%s'\n", |
| 1256 | dssdev->name, mgr->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1257 | r = -EINVAL; |
| 1258 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1259 | } |
| 1260 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1261 | dssdev->manager = mgr; |
| 1262 | mgr->device = dssdev; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1263 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1264 | mutex_unlock(&apply_lock); |
| 1265 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1266 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1267 | err: |
| 1268 | mutex_unlock(&apply_lock); |
| 1269 | return r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | int dss_mgr_unset_device(struct omap_overlay_manager *mgr) |
| 1273 | { |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1274 | int r; |
| 1275 | |
| 1276 | mutex_lock(&apply_lock); |
| 1277 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1278 | if (!mgr->device) { |
| 1279 | DSSERR("failed to unset display, display not set.\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1280 | r = -EINVAL; |
| 1281 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | /* |
| 1285 | * Don't allow currently enabled displays to have the overlay manager |
| 1286 | * pulled out from underneath them |
| 1287 | */ |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1288 | if (mgr->device->state != OMAP_DSS_DISPLAY_DISABLED) { |
| 1289 | r = -EINVAL; |
| 1290 | goto err; |
| 1291 | } |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1292 | |
| 1293 | mgr->device->manager = NULL; |
| 1294 | mgr->device = NULL; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1295 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1296 | mutex_unlock(&apply_lock); |
| 1297 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1298 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1299 | err: |
| 1300 | mutex_unlock(&apply_lock); |
| 1301 | return r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1302 | } |
| 1303 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1304 | static void dss_apply_mgr_timings(struct omap_overlay_manager *mgr, |
Archit Taneja | 27dfddc | 2012-07-19 13:51:14 +0530 | [diff] [blame] | 1305 | const struct omap_video_timings *timings) |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1306 | { |
| 1307 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1308 | |
| 1309 | mp->timings = *timings; |
| 1310 | mp->extra_info_dirty = true; |
| 1311 | } |
| 1312 | |
| 1313 | void dss_mgr_set_timings(struct omap_overlay_manager *mgr, |
Archit Taneja | 27dfddc | 2012-07-19 13:51:14 +0530 | [diff] [blame] | 1314 | const struct omap_video_timings *timings) |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1315 | { |
| 1316 | unsigned long flags; |
Tomi Valkeinen | fed62e5 | 2012-08-09 18:13:13 +0300 | [diff] [blame^] | 1317 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1318 | |
| 1319 | spin_lock_irqsave(&data_lock, flags); |
| 1320 | |
Tomi Valkeinen | fed62e5 | 2012-08-09 18:13:13 +0300 | [diff] [blame^] | 1321 | if (mp->updating) { |
| 1322 | DSSERR("cannot set timings for %s: manager needs to be disabled\n", |
| 1323 | mgr->name); |
| 1324 | goto out; |
| 1325 | } |
| 1326 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1327 | dss_apply_mgr_timings(mgr, timings); |
Tomi Valkeinen | fed62e5 | 2012-08-09 18:13:13 +0300 | [diff] [blame^] | 1328 | out: |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1329 | spin_unlock_irqrestore(&data_lock, flags); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1330 | } |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1331 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1332 | static void dss_apply_mgr_lcd_config(struct omap_overlay_manager *mgr, |
| 1333 | const struct dss_lcd_mgr_config *config) |
| 1334 | { |
| 1335 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1336 | |
| 1337 | mp->lcd_config = *config; |
| 1338 | mp->extra_info_dirty = true; |
| 1339 | } |
| 1340 | |
| 1341 | void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr, |
| 1342 | const struct dss_lcd_mgr_config *config) |
| 1343 | { |
| 1344 | unsigned long flags; |
| 1345 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1346 | |
Tomi Valkeinen | aba9657 | 2012-08-09 18:07:45 +0300 | [diff] [blame] | 1347 | spin_lock_irqsave(&data_lock, flags); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1348 | |
| 1349 | if (mp->enabled) { |
| 1350 | DSSERR("cannot apply lcd config for %s: manager needs to be disabled\n", |
| 1351 | mgr->name); |
| 1352 | goto out; |
| 1353 | } |
| 1354 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1355 | dss_apply_mgr_lcd_config(mgr, config); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1356 | out: |
Tomi Valkeinen | aba9657 | 2012-08-09 18:07:45 +0300 | [diff] [blame] | 1357 | spin_unlock_irqrestore(&data_lock, flags); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1358 | } |
| 1359 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1360 | int dss_ovl_set_info(struct omap_overlay *ovl, |
| 1361 | struct omap_overlay_info *info) |
| 1362 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1363 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1364 | unsigned long flags; |
Tomi Valkeinen | fcc764d | 2011-11-17 14:26:48 +0200 | [diff] [blame] | 1365 | int r; |
| 1366 | |
| 1367 | r = dss_ovl_simple_check(ovl, info); |
| 1368 | if (r) |
| 1369 | return r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1370 | |
| 1371 | spin_lock_irqsave(&data_lock, flags); |
| 1372 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1373 | op->user_info = *info; |
| 1374 | op->user_info_dirty = true; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1375 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1376 | spin_unlock_irqrestore(&data_lock, flags); |
| 1377 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1378 | return 0; |
| 1379 | } |
| 1380 | |
| 1381 | void dss_ovl_get_info(struct omap_overlay *ovl, |
| 1382 | struct omap_overlay_info *info) |
| 1383 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1384 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1385 | unsigned long flags; |
| 1386 | |
| 1387 | spin_lock_irqsave(&data_lock, flags); |
| 1388 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1389 | *info = op->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1390 | |
| 1391 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | int dss_ovl_set_manager(struct omap_overlay *ovl, |
| 1395 | struct omap_overlay_manager *mgr) |
| 1396 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1397 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1398 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1399 | int r; |
| 1400 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1401 | if (!mgr) |
| 1402 | return -EINVAL; |
| 1403 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1404 | mutex_lock(&apply_lock); |
| 1405 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1406 | if (ovl->manager) { |
| 1407 | DSSERR("overlay '%s' already has a manager '%s'\n", |
| 1408 | ovl->name, ovl->manager->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1409 | r = -EINVAL; |
| 1410 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1411 | } |
| 1412 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1413 | spin_lock_irqsave(&data_lock, flags); |
| 1414 | |
| 1415 | if (op->enabled) { |
| 1416 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1417 | DSSERR("overlay has to be disabled to change the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1418 | r = -EINVAL; |
| 1419 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1420 | } |
| 1421 | |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 1422 | op->channel = mgr->id; |
| 1423 | op->extra_info_dirty = true; |
| 1424 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1425 | ovl->manager = mgr; |
| 1426 | list_add_tail(&ovl->list, &mgr->overlays); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1427 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1428 | spin_unlock_irqrestore(&data_lock, flags); |
| 1429 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1430 | /* XXX: When there is an overlay on a DSI manual update display, and |
| 1431 | * the overlay is first disabled, then moved to tv, and enabled, we |
| 1432 | * seem to get SYNC_LOST_DIGIT error. |
| 1433 | * |
| 1434 | * Waiting doesn't seem to help, but updating the manual update display |
| 1435 | * after disabling the overlay seems to fix this. This hints that the |
| 1436 | * overlay is perhaps somehow tied to the LCD output until the output |
| 1437 | * is updated. |
| 1438 | * |
| 1439 | * Userspace workaround for this is to update the LCD after disabling |
| 1440 | * the overlay, but before moving the overlay to TV. |
| 1441 | */ |
| 1442 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1443 | mutex_unlock(&apply_lock); |
| 1444 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1445 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1446 | err: |
| 1447 | mutex_unlock(&apply_lock); |
| 1448 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1449 | } |
| 1450 | |
| 1451 | int dss_ovl_unset_manager(struct omap_overlay *ovl) |
| 1452 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1453 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1454 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1455 | int r; |
| 1456 | |
| 1457 | mutex_lock(&apply_lock); |
| 1458 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1459 | if (!ovl->manager) { |
| 1460 | DSSERR("failed to detach overlay: manager not set\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1461 | r = -EINVAL; |
| 1462 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1463 | } |
| 1464 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1465 | spin_lock_irqsave(&data_lock, flags); |
| 1466 | |
| 1467 | if (op->enabled) { |
| 1468 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1469 | DSSERR("overlay has to be disabled to unset the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1470 | r = -EINVAL; |
| 1471 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1472 | } |
| 1473 | |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 1474 | op->channel = -1; |
| 1475 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1476 | ovl->manager = NULL; |
| 1477 | list_del(&ovl->list); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1478 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1479 | spin_unlock_irqrestore(&data_lock, flags); |
| 1480 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1481 | mutex_unlock(&apply_lock); |
| 1482 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1483 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1484 | err: |
| 1485 | mutex_unlock(&apply_lock); |
| 1486 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1487 | } |
| 1488 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1489 | bool dss_ovl_is_enabled(struct omap_overlay *ovl) |
| 1490 | { |
| 1491 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1492 | unsigned long flags; |
| 1493 | bool e; |
| 1494 | |
| 1495 | spin_lock_irqsave(&data_lock, flags); |
| 1496 | |
| 1497 | e = op->enabled; |
| 1498 | |
| 1499 | spin_unlock_irqrestore(&data_lock, flags); |
| 1500 | |
| 1501 | return e; |
| 1502 | } |
| 1503 | |
| 1504 | int dss_ovl_enable(struct omap_overlay *ovl) |
| 1505 | { |
| 1506 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1507 | unsigned long flags; |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1508 | bool fifo_merge; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1509 | int r; |
| 1510 | |
| 1511 | mutex_lock(&apply_lock); |
| 1512 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1513 | if (op->enabled) { |
| 1514 | r = 0; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1515 | goto err1; |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1516 | } |
| 1517 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1518 | if (ovl->manager == NULL || ovl->manager->device == NULL) { |
| 1519 | r = -EINVAL; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1520 | goto err1; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | spin_lock_irqsave(&data_lock, flags); |
| 1524 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1525 | op->enabling = true; |
| 1526 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 1527 | r = dss_check_settings(ovl->manager); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1528 | if (r) { |
| 1529 | DSSERR("failed to enable overlay %d: check_settings failed\n", |
| 1530 | ovl->id); |
| 1531 | goto err2; |
| 1532 | } |
| 1533 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1534 | /* step 1: configure fifos/fifomerge for currently enabled ovls */ |
| 1535 | |
| 1536 | fifo_merge = get_use_fifo_merge(); |
| 1537 | dss_setup_fifos(fifo_merge); |
| 1538 | dss_apply_fifo_merge(fifo_merge); |
| 1539 | |
| 1540 | dss_write_regs(); |
| 1541 | dss_set_go_bits(); |
| 1542 | |
| 1543 | spin_unlock_irqrestore(&data_lock, flags); |
| 1544 | |
| 1545 | /* wait for fifo configs to go in */ |
| 1546 | wait_pending_extra_info_updates(); |
| 1547 | |
| 1548 | /* step 2: enable the overlay */ |
| 1549 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1550 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1551 | op->enabling = false; |
| 1552 | dss_apply_ovl_enable(ovl, true); |
| 1553 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1554 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1555 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1556 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1557 | spin_unlock_irqrestore(&data_lock, flags); |
| 1558 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1559 | /* wait for overlay to be enabled */ |
| 1560 | wait_pending_extra_info_updates(); |
| 1561 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1562 | mutex_unlock(&apply_lock); |
| 1563 | |
| 1564 | return 0; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1565 | err2: |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1566 | op->enabling = false; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1567 | spin_unlock_irqrestore(&data_lock, flags); |
| 1568 | err1: |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1569 | mutex_unlock(&apply_lock); |
| 1570 | return r; |
| 1571 | } |
| 1572 | |
| 1573 | int dss_ovl_disable(struct omap_overlay *ovl) |
| 1574 | { |
| 1575 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1576 | unsigned long flags; |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1577 | bool fifo_merge; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1578 | int r; |
| 1579 | |
| 1580 | mutex_lock(&apply_lock); |
| 1581 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1582 | if (!op->enabled) { |
| 1583 | r = 0; |
| 1584 | goto err; |
| 1585 | } |
| 1586 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1587 | if (ovl->manager == NULL || ovl->manager->device == NULL) { |
| 1588 | r = -EINVAL; |
| 1589 | goto err; |
| 1590 | } |
| 1591 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1592 | /* step 1: disable the overlay */ |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1593 | spin_lock_irqsave(&data_lock, flags); |
| 1594 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame] | 1595 | dss_apply_ovl_enable(ovl, false); |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1596 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1597 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1598 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1599 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1600 | spin_unlock_irqrestore(&data_lock, flags); |
| 1601 | |
Tomi Valkeinen | 1d71f42 | 2011-11-16 16:44:08 +0200 | [diff] [blame] | 1602 | /* wait for the overlay to be disabled */ |
| 1603 | wait_pending_extra_info_updates(); |
| 1604 | |
| 1605 | /* step 2: configure fifos/fifomerge */ |
| 1606 | spin_lock_irqsave(&data_lock, flags); |
| 1607 | |
| 1608 | fifo_merge = get_use_fifo_merge(); |
| 1609 | dss_setup_fifos(fifo_merge); |
| 1610 | dss_apply_fifo_merge(fifo_merge); |
| 1611 | |
| 1612 | dss_write_regs(); |
| 1613 | dss_set_go_bits(); |
| 1614 | |
| 1615 | spin_unlock_irqrestore(&data_lock, flags); |
| 1616 | |
| 1617 | /* wait for fifo config to go in */ |
| 1618 | wait_pending_extra_info_updates(); |
| 1619 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1620 | mutex_unlock(&apply_lock); |
| 1621 | |
| 1622 | return 0; |
| 1623 | |
| 1624 | err: |
| 1625 | mutex_unlock(&apply_lock); |
| 1626 | return r; |
| 1627 | } |
| 1628 | |