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; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | static struct { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 105 | struct ovl_priv_data ovl_priv_data_array[MAX_DSS_OVERLAYS]; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 106 | struct mgr_priv_data mgr_priv_data_array[MAX_DSS_MANAGERS]; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 107 | |
| 108 | bool irq_enabled; |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 109 | } dss_data; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 110 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 111 | /* protects dss_data */ |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 112 | static spinlock_t data_lock; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 113 | /* lock for blocking functions */ |
| 114 | static DEFINE_MUTEX(apply_lock); |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 115 | static DECLARE_COMPLETION(extra_updated_completion); |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 116 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 117 | static void dss_register_vsync_isr(void); |
| 118 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 119 | static struct ovl_priv_data *get_ovl_priv(struct omap_overlay *ovl) |
| 120 | { |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 121 | return &dss_data.ovl_priv_data_array[ovl->id]; |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 122 | } |
| 123 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 124 | static struct mgr_priv_data *get_mgr_priv(struct omap_overlay_manager *mgr) |
| 125 | { |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 126 | return &dss_data.mgr_priv_data_array[mgr->id]; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 127 | } |
| 128 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 129 | void dss_apply_init(void) |
| 130 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 131 | const int num_ovls = dss_feat_get_num_ovls(); |
| 132 | int i; |
| 133 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 134 | spin_lock_init(&data_lock); |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 135 | |
| 136 | for (i = 0; i < num_ovls; ++i) { |
| 137 | struct ovl_priv_data *op; |
| 138 | |
| 139 | op = &dss_data.ovl_priv_data_array[i]; |
| 140 | |
| 141 | op->info.global_alpha = 255; |
| 142 | |
| 143 | switch (i) { |
| 144 | case 0: |
| 145 | op->info.zorder = 0; |
| 146 | break; |
| 147 | case 1: |
| 148 | op->info.zorder = |
| 149 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 3 : 0; |
| 150 | break; |
| 151 | case 2: |
| 152 | op->info.zorder = |
| 153 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 2 : 0; |
| 154 | break; |
| 155 | case 3: |
| 156 | op->info.zorder = |
| 157 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 1 : 0; |
| 158 | break; |
| 159 | } |
| 160 | |
| 161 | op->user_info = op->info; |
| 162 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | static bool ovl_manual_update(struct omap_overlay *ovl) |
| 166 | { |
| 167 | return ovl->manager->device->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE; |
| 168 | } |
| 169 | |
| 170 | static bool mgr_manual_update(struct omap_overlay_manager *mgr) |
| 171 | { |
| 172 | return mgr->device->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE; |
| 173 | } |
| 174 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 175 | static int dss_check_settings_low(struct omap_overlay_manager *mgr, |
| 176 | struct omap_dss_device *dssdev, bool applying) |
| 177 | { |
| 178 | struct omap_overlay_info *oi; |
| 179 | struct omap_overlay_manager_info *mi; |
| 180 | struct omap_overlay *ovl; |
| 181 | struct omap_overlay_info *ois[MAX_DSS_OVERLAYS]; |
| 182 | struct ovl_priv_data *op; |
| 183 | struct mgr_priv_data *mp; |
| 184 | |
| 185 | mp = get_mgr_priv(mgr); |
| 186 | |
| 187 | if (applying && mp->user_info_dirty) |
| 188 | mi = &mp->user_info; |
| 189 | else |
| 190 | mi = &mp->info; |
| 191 | |
| 192 | /* collect the infos to be tested into the array */ |
| 193 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 194 | op = get_ovl_priv(ovl); |
| 195 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 196 | if (!op->enabled && !op->enabling) |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 197 | oi = NULL; |
| 198 | else if (applying && op->user_info_dirty) |
| 199 | oi = &op->user_info; |
| 200 | else |
| 201 | oi = &op->info; |
| 202 | |
| 203 | ois[ovl->id] = oi; |
| 204 | } |
| 205 | |
| 206 | return dss_mgr_check(mgr, dssdev, mi, ois); |
| 207 | } |
| 208 | |
| 209 | /* |
| 210 | * check manager and overlay settings using overlay_info from data->info |
| 211 | */ |
| 212 | static int dss_check_settings(struct omap_overlay_manager *mgr, |
| 213 | struct omap_dss_device *dssdev) |
| 214 | { |
| 215 | return dss_check_settings_low(mgr, dssdev, false); |
| 216 | } |
| 217 | |
| 218 | /* |
| 219 | * check manager and overlay settings using overlay_info from ovl->info if |
| 220 | * dirty and from data->info otherwise |
| 221 | */ |
| 222 | static int dss_check_settings_apply(struct omap_overlay_manager *mgr, |
| 223 | struct omap_dss_device *dssdev) |
| 224 | { |
| 225 | return dss_check_settings_low(mgr, dssdev, true); |
| 226 | } |
| 227 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 228 | static bool need_isr(void) |
| 229 | { |
| 230 | const int num_mgrs = dss_feat_get_num_mgrs(); |
| 231 | int i; |
| 232 | |
| 233 | for (i = 0; i < num_mgrs; ++i) { |
| 234 | struct omap_overlay_manager *mgr; |
| 235 | struct mgr_priv_data *mp; |
| 236 | struct omap_overlay *ovl; |
| 237 | |
| 238 | mgr = omap_dss_get_overlay_manager(i); |
| 239 | mp = get_mgr_priv(mgr); |
| 240 | |
| 241 | if (!mp->enabled) |
| 242 | continue; |
| 243 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 244 | if (mgr_manual_update(mgr)) { |
| 245 | /* to catch FRAMEDONE */ |
| 246 | if (mp->updating) |
| 247 | return true; |
| 248 | } else { |
| 249 | /* to catch GO bit going down */ |
| 250 | if (mp->busy) |
| 251 | return true; |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 252 | |
| 253 | /* to write new values to registers */ |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 254 | if (mp->info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 255 | return true; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 256 | |
Tomi Valkeinen | 9f80895 | 2011-11-25 17:26:13 +0200 | [diff] [blame] | 257 | /* to set GO bit */ |
| 258 | if (mp->shadow_info_dirty) |
| 259 | return true; |
| 260 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 261 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 262 | struct ovl_priv_data *op; |
| 263 | |
| 264 | op = get_ovl_priv(ovl); |
| 265 | |
Tomi Valkeinen | 9f80895 | 2011-11-25 17:26:13 +0200 | [diff] [blame] | 266 | /* |
| 267 | * NOTE: we check extra_info flags even for |
| 268 | * disabled overlays, as extra_infos need to be |
| 269 | * always written. |
| 270 | */ |
| 271 | |
| 272 | /* to write new values to registers */ |
| 273 | if (op->extra_info_dirty) |
| 274 | return true; |
| 275 | |
| 276 | /* to set GO bit */ |
| 277 | if (op->shadow_extra_info_dirty) |
| 278 | return true; |
| 279 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 280 | if (!op->enabled) |
| 281 | continue; |
| 282 | |
| 283 | /* to write new values to registers */ |
Tomi Valkeinen | 9f80895 | 2011-11-25 17:26:13 +0200 | [diff] [blame] | 284 | if (op->info_dirty) |
| 285 | return true; |
| 286 | |
| 287 | /* to set GO bit */ |
| 288 | if (op->shadow_info_dirty) |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 289 | return true; |
| 290 | } |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | |
| 294 | return false; |
| 295 | } |
| 296 | |
| 297 | static bool need_go(struct omap_overlay_manager *mgr) |
| 298 | { |
| 299 | struct omap_overlay *ovl; |
| 300 | struct mgr_priv_data *mp; |
| 301 | struct ovl_priv_data *op; |
| 302 | |
| 303 | mp = get_mgr_priv(mgr); |
| 304 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 305 | if (mp->shadow_info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 306 | return true; |
| 307 | |
| 308 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 309 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 310 | if (op->shadow_info_dirty || op->shadow_extra_info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 311 | return true; |
| 312 | } |
| 313 | |
| 314 | return false; |
| 315 | } |
| 316 | |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 317 | /* returns true if an extra_info field is currently being updated */ |
| 318 | static bool extra_info_update_ongoing(void) |
| 319 | { |
| 320 | const int num_ovls = omap_dss_get_num_overlays(); |
| 321 | struct ovl_priv_data *op; |
| 322 | struct omap_overlay *ovl; |
| 323 | struct mgr_priv_data *mp; |
| 324 | int i; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 325 | |
| 326 | for (i = 0; i < num_ovls; ++i) { |
| 327 | ovl = omap_dss_get_overlay(i); |
| 328 | op = get_ovl_priv(ovl); |
| 329 | |
Rob Clark | 1f3f53a | 2011-12-17 13:28:52 -0600 | [diff] [blame] | 330 | if (!ovl->manager) |
| 331 | continue; |
| 332 | |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 333 | mp = get_mgr_priv(ovl->manager); |
| 334 | |
| 335 | if (!mp->enabled) |
| 336 | continue; |
| 337 | |
Tomi Valkeinen | 153b6e7 | 2011-11-25 17:35:35 +0200 | [diff] [blame] | 338 | if (!mp->updating) |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 339 | continue; |
| 340 | |
Tomi Valkeinen | 153b6e7 | 2011-11-25 17:35:35 +0200 | [diff] [blame] | 341 | if (op->extra_info_dirty || op->shadow_extra_info_dirty) |
| 342 | return true; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | return false; |
| 346 | } |
| 347 | |
| 348 | /* wait until no extra_info updates are pending */ |
| 349 | static void wait_pending_extra_info_updates(void) |
| 350 | { |
| 351 | bool updating; |
| 352 | unsigned long flags; |
| 353 | unsigned long t; |
| 354 | |
| 355 | spin_lock_irqsave(&data_lock, flags); |
| 356 | |
| 357 | updating = extra_info_update_ongoing(); |
| 358 | |
| 359 | if (!updating) { |
| 360 | spin_unlock_irqrestore(&data_lock, flags); |
| 361 | return; |
| 362 | } |
| 363 | |
| 364 | init_completion(&extra_updated_completion); |
| 365 | |
| 366 | spin_unlock_irqrestore(&data_lock, flags); |
| 367 | |
| 368 | t = msecs_to_jiffies(500); |
| 369 | wait_for_completion_timeout(&extra_updated_completion, t); |
| 370 | |
| 371 | updating = extra_info_update_ongoing(); |
| 372 | |
| 373 | WARN_ON(updating); |
| 374 | } |
| 375 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 376 | int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr) |
| 377 | { |
| 378 | unsigned long timeout = msecs_to_jiffies(500); |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 379 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 380 | u32 irq; |
| 381 | int r; |
| 382 | int i; |
| 383 | struct omap_dss_device *dssdev = mgr->device; |
| 384 | |
| 385 | if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) |
| 386 | return 0; |
| 387 | |
| 388 | if (mgr_manual_update(mgr)) |
| 389 | return 0; |
| 390 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 391 | irq = dispc_mgr_get_vsync_irq(mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 392 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 393 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 394 | i = 0; |
| 395 | while (1) { |
| 396 | unsigned long flags; |
| 397 | bool shadow_dirty, dirty; |
| 398 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 399 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 400 | dirty = mp->info_dirty; |
| 401 | shadow_dirty = mp->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 402 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 403 | |
| 404 | if (!dirty && !shadow_dirty) { |
| 405 | r = 0; |
| 406 | break; |
| 407 | } |
| 408 | |
| 409 | /* 4 iterations is the worst case: |
| 410 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 411 | * 2 - first VSYNC, dirty = true |
| 412 | * 3 - dirty = false, shadow_dirty = true |
| 413 | * 4 - shadow_dirty = false */ |
| 414 | if (i++ == 3) { |
| 415 | DSSERR("mgr(%d)->wait_for_go() not finishing\n", |
| 416 | mgr->id); |
| 417 | r = 0; |
| 418 | break; |
| 419 | } |
| 420 | |
| 421 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 422 | if (r == -ERESTARTSYS) |
| 423 | break; |
| 424 | |
| 425 | if (r) { |
| 426 | DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr->id); |
| 427 | break; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | return r; |
| 432 | } |
| 433 | |
| 434 | int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl) |
| 435 | { |
| 436 | unsigned long timeout = msecs_to_jiffies(500); |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 437 | struct ovl_priv_data *op; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 438 | struct omap_dss_device *dssdev; |
| 439 | u32 irq; |
| 440 | int r; |
| 441 | int i; |
| 442 | |
| 443 | if (!ovl->manager) |
| 444 | return 0; |
| 445 | |
| 446 | dssdev = ovl->manager->device; |
| 447 | |
| 448 | if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) |
| 449 | return 0; |
| 450 | |
| 451 | if (ovl_manual_update(ovl)) |
| 452 | return 0; |
| 453 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 454 | irq = dispc_mgr_get_vsync_irq(ovl->manager->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 455 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 456 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 457 | i = 0; |
| 458 | while (1) { |
| 459 | unsigned long flags; |
| 460 | bool shadow_dirty, dirty; |
| 461 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 462 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 463 | dirty = op->info_dirty; |
| 464 | shadow_dirty = op->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 465 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 466 | |
| 467 | if (!dirty && !shadow_dirty) { |
| 468 | r = 0; |
| 469 | break; |
| 470 | } |
| 471 | |
| 472 | /* 4 iterations is the worst case: |
| 473 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 474 | * 2 - first VSYNC, dirty = true |
| 475 | * 3 - dirty = false, shadow_dirty = true |
| 476 | * 4 - shadow_dirty = false */ |
| 477 | if (i++ == 3) { |
| 478 | DSSERR("ovl(%d)->wait_for_go() not finishing\n", |
| 479 | ovl->id); |
| 480 | r = 0; |
| 481 | break; |
| 482 | } |
| 483 | |
| 484 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 485 | if (r == -ERESTARTSYS) |
| 486 | break; |
| 487 | |
| 488 | if (r) { |
| 489 | DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl->id); |
| 490 | break; |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | return r; |
| 495 | } |
| 496 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 497 | static void dss_ovl_write_regs(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 498 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 499 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 500 | struct omap_overlay_info *oi; |
| 501 | bool ilace, replication; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 502 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 503 | int r; |
| 504 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 505 | DSSDBGF("%d", ovl->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 506 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 507 | if (!op->enabled || !op->info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 508 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 509 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 510 | oi = &op->info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 511 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 512 | replication = dss_use_replication(ovl->manager->device, oi->color_mode); |
| 513 | |
| 514 | ilace = ovl->manager->device->type == OMAP_DISPLAY_TYPE_VENC; |
| 515 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 516 | r = dispc_ovl_setup(ovl->id, oi, ilace, replication); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 517 | if (r) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 518 | /* |
| 519 | * We can't do much here, as this function can be called from |
| 520 | * vsync interrupt. |
| 521 | */ |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 522 | DSSERR("dispc_ovl_setup failed for ovl %d\n", ovl->id); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 523 | |
| 524 | /* This will leave fifo configurations in a nonoptimal state */ |
| 525 | op->enabled = false; |
| 526 | dispc_ovl_enable(ovl->id, false); |
| 527 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 528 | } |
| 529 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 530 | mp = get_mgr_priv(ovl->manager); |
| 531 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 532 | op->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 533 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 534 | op->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 535 | } |
| 536 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 537 | static void dss_ovl_write_regs_extra(struct omap_overlay *ovl) |
| 538 | { |
| 539 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 540 | struct mgr_priv_data *mp; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 541 | |
| 542 | DSSDBGF("%d", ovl->id); |
| 543 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 544 | if (!op->extra_info_dirty) |
| 545 | return; |
| 546 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 547 | /* note: write also when op->enabled == false, so that the ovl gets |
| 548 | * disabled */ |
| 549 | |
| 550 | dispc_ovl_enable(ovl->id, op->enabled); |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 551 | dispc_ovl_set_channel_out(ovl->id, op->channel); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 552 | 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] | 553 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 554 | mp = get_mgr_priv(ovl->manager); |
| 555 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 556 | op->extra_info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 557 | if (mp->updating) |
| 558 | op->shadow_extra_info_dirty = true; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 559 | } |
| 560 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 561 | static void dss_mgr_write_regs(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 562 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 563 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 564 | struct omap_overlay *ovl; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 565 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 566 | DSSDBGF("%d", mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 567 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 568 | if (!mp->enabled) |
| 569 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 570 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 571 | WARN_ON(mp->busy); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 572 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 573 | /* Commit overlay settings */ |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 574 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 575 | dss_ovl_write_regs(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 576 | dss_ovl_write_regs_extra(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 577 | } |
| 578 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 579 | if (mp->info_dirty) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 580 | dispc_mgr_setup(mgr->id, &mp->info); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 581 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 582 | mp->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 583 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 584 | mp->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 585 | } |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 586 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 587 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 588 | static void dss_write_regs(void) |
| 589 | { |
| 590 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 591 | int i; |
| 592 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 593 | for (i = 0; i < num_mgrs; ++i) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 594 | struct omap_overlay_manager *mgr; |
| 595 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 596 | int r; |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 597 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 598 | mgr = omap_dss_get_overlay_manager(i); |
| 599 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 600 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 601 | if (!mp->enabled || mgr_manual_update(mgr) || mp->busy) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 602 | continue; |
| 603 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 604 | r = dss_check_settings(mgr, mgr->device); |
| 605 | if (r) { |
| 606 | DSSERR("cannot write registers for manager %s: " |
| 607 | "illegal configuration\n", mgr->name); |
| 608 | continue; |
| 609 | } |
| 610 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 611 | dss_mgr_write_regs(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 612 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 613 | } |
| 614 | |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 615 | static void dss_set_go_bits(void) |
| 616 | { |
| 617 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 618 | int i; |
| 619 | |
| 620 | for (i = 0; i < num_mgrs; ++i) { |
| 621 | struct omap_overlay_manager *mgr; |
| 622 | struct mgr_priv_data *mp; |
| 623 | |
| 624 | mgr = omap_dss_get_overlay_manager(i); |
| 625 | mp = get_mgr_priv(mgr); |
| 626 | |
| 627 | if (!mp->enabled || mgr_manual_update(mgr) || mp->busy) |
| 628 | continue; |
| 629 | |
| 630 | if (!need_go(mgr)) |
| 631 | continue; |
| 632 | |
| 633 | mp->busy = true; |
| 634 | |
| 635 | if (!dss_data.irq_enabled && need_isr()) |
| 636 | dss_register_vsync_isr(); |
| 637 | |
| 638 | dispc_mgr_go(mgr->id); |
| 639 | } |
| 640 | |
| 641 | } |
| 642 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 643 | void dss_mgr_start_update(struct omap_overlay_manager *mgr) |
| 644 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 645 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 646 | unsigned long flags; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 647 | int r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 648 | |
| 649 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 650 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 651 | WARN_ON(mp->updating); |
| 652 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 653 | r = dss_check_settings(mgr, mgr->device); |
| 654 | if (r) { |
| 655 | DSSERR("cannot start manual update: illegal configuration\n"); |
| 656 | spin_unlock_irqrestore(&data_lock, flags); |
| 657 | return; |
| 658 | } |
| 659 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 660 | dss_mgr_write_regs(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 661 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 662 | mp->updating = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 663 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 664 | if (!dss_data.irq_enabled && need_isr()) |
| 665 | dss_register_vsync_isr(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 666 | |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 667 | dispc_mgr_enable(mgr->id, true); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 668 | |
| 669 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 670 | } |
| 671 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 672 | static void dss_apply_irq_handler(void *data, u32 mask); |
| 673 | |
| 674 | static void dss_register_vsync_isr(void) |
| 675 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 676 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 677 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 678 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 679 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 680 | mask = 0; |
| 681 | for (i = 0; i < num_mgrs; ++i) |
| 682 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 683 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 684 | for (i = 0; i < num_mgrs; ++i) |
| 685 | mask |= dispc_mgr_get_framedone_irq(i); |
| 686 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 687 | r = omap_dispc_register_isr(dss_apply_irq_handler, NULL, mask); |
| 688 | WARN_ON(r); |
| 689 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 690 | dss_data.irq_enabled = true; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | static void dss_unregister_vsync_isr(void) |
| 694 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 695 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 696 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 697 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 698 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 699 | mask = 0; |
| 700 | for (i = 0; i < num_mgrs; ++i) |
| 701 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 702 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 703 | for (i = 0; i < num_mgrs; ++i) |
| 704 | mask |= dispc_mgr_get_framedone_irq(i); |
| 705 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 706 | r = omap_dispc_unregister_isr(dss_apply_irq_handler, NULL, mask); |
| 707 | WARN_ON(r); |
| 708 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 709 | dss_data.irq_enabled = false; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 710 | } |
| 711 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 712 | static void mgr_clear_shadow_dirty(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 713 | { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 714 | struct omap_overlay *ovl; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 715 | struct mgr_priv_data *mp; |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 716 | struct ovl_priv_data *op; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 717 | |
| 718 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 719 | mp->shadow_info_dirty = false; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 720 | |
| 721 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 722 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 723 | op->shadow_info_dirty = false; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 724 | op->shadow_extra_info_dirty = false; |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | static void dss_apply_irq_handler(void *data, u32 mask) |
| 729 | { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 730 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 731 | int i; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 732 | bool extra_updating; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 733 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 734 | spin_lock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 735 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 736 | /* clear busy, updating flags, shadow_dirty flags */ |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 737 | for (i = 0; i < num_mgrs; i++) { |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 738 | struct omap_overlay_manager *mgr; |
| 739 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 740 | bool was_updating; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 741 | |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 742 | mgr = omap_dss_get_overlay_manager(i); |
| 743 | mp = get_mgr_priv(mgr); |
| 744 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 745 | if (!mp->enabled) |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 746 | continue; |
| 747 | |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 748 | was_updating = mp->updating; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 749 | mp->updating = dispc_mgr_is_enabled(i); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 750 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 751 | if (!mgr_manual_update(mgr)) { |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 752 | bool was_busy = mp->busy; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 753 | mp->busy = dispc_mgr_go_busy(i); |
| 754 | |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 755 | if (was_busy && !mp->busy) |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 756 | mgr_clear_shadow_dirty(mgr); |
| 757 | } else { |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 758 | if (was_updating && !mp->updating) |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 759 | mgr_clear_shadow_dirty(mgr); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 760 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 761 | } |
| 762 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 763 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 764 | dss_set_go_bits(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 765 | |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 766 | extra_updating = extra_info_update_ongoing(); |
| 767 | if (!extra_updating) |
| 768 | complete_all(&extra_updated_completion); |
| 769 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 770 | if (!need_isr()) |
| 771 | dss_unregister_vsync_isr(); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 772 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 773 | spin_unlock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 774 | } |
| 775 | |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 776 | static void omap_dss_mgr_apply_ovl(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 777 | { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 778 | struct ovl_priv_data *op; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 779 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 780 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 781 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 782 | if (!op->user_info_dirty) |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 783 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 784 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 785 | op->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 786 | op->info_dirty = true; |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 787 | op->info = op->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | static void omap_dss_mgr_apply_mgr(struct omap_overlay_manager *mgr) |
| 791 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 792 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 793 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 794 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 795 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 796 | if (!mp->user_info_dirty) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 797 | return; |
| 798 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 799 | mp->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 800 | mp->info_dirty = true; |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 801 | mp->info = mp->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 802 | } |
| 803 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 804 | int omap_dss_mgr_apply(struct omap_overlay_manager *mgr) |
| 805 | { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 806 | unsigned long flags; |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 807 | struct omap_overlay *ovl; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 808 | int r; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 809 | |
| 810 | DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name); |
| 811 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 812 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 813 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 814 | r = dss_check_settings_apply(mgr, mgr->device); |
| 815 | if (r) { |
| 816 | spin_unlock_irqrestore(&data_lock, flags); |
| 817 | DSSERR("failed to apply settings: illegal configuration.\n"); |
| 818 | return r; |
| 819 | } |
| 820 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 821 | /* Configure overlays */ |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 822 | list_for_each_entry(ovl, &mgr->overlays, list) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 823 | omap_dss_mgr_apply_ovl(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 824 | |
| 825 | /* Configure manager */ |
| 826 | omap_dss_mgr_apply_mgr(mgr); |
| 827 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 828 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 829 | dss_set_go_bits(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 830 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 831 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 832 | |
Tomi Valkeinen | e70f98a | 2011-11-16 16:53:44 +0200 | [diff] [blame] | 833 | return 0; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 834 | } |
| 835 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame] | 836 | static void dss_apply_ovl_enable(struct omap_overlay *ovl, bool enable) |
| 837 | { |
| 838 | struct ovl_priv_data *op; |
| 839 | |
| 840 | op = get_ovl_priv(ovl); |
| 841 | |
| 842 | if (op->enabled == enable) |
| 843 | return; |
| 844 | |
| 845 | op->enabled = enable; |
| 846 | op->extra_info_dirty = true; |
| 847 | } |
| 848 | |
Tomi Valkeinen | 04576d4 | 2011-11-26 14:39:16 +0200 | [diff] [blame] | 849 | static void dss_apply_ovl_fifo_thresholds(struct omap_overlay *ovl, |
| 850 | u32 fifo_low, u32 fifo_high) |
| 851 | { |
| 852 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 853 | |
| 854 | if (op->fifo_low == fifo_low && op->fifo_high == fifo_high) |
| 855 | return; |
| 856 | |
| 857 | op->fifo_low = fifo_low; |
| 858 | op->fifo_high = fifo_high; |
| 859 | op->extra_info_dirty = true; |
| 860 | } |
| 861 | |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 862 | static void dss_ovl_setup_fifo(struct omap_overlay *ovl) |
| 863 | { |
| 864 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 865 | struct omap_dss_device *dssdev; |
| 866 | u32 size, burst_size; |
| 867 | u32 fifo_low, fifo_high; |
| 868 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 869 | if (!op->enabled && !op->enabling) |
| 870 | return; |
| 871 | |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 872 | dssdev = ovl->manager->device; |
| 873 | |
| 874 | size = dispc_ovl_get_fifo_size(ovl->id); |
| 875 | |
| 876 | burst_size = dispc_ovl_get_burst_size(ovl->id); |
| 877 | |
| 878 | switch (dssdev->type) { |
| 879 | case OMAP_DISPLAY_TYPE_DPI: |
| 880 | case OMAP_DISPLAY_TYPE_DBI: |
| 881 | case OMAP_DISPLAY_TYPE_SDI: |
| 882 | case OMAP_DISPLAY_TYPE_VENC: |
| 883 | case OMAP_DISPLAY_TYPE_HDMI: |
| 884 | default_get_overlay_fifo_thresholds(ovl->id, size, |
| 885 | burst_size, &fifo_low, &fifo_high); |
| 886 | break; |
| 887 | #ifdef CONFIG_OMAP2_DSS_DSI |
| 888 | case OMAP_DISPLAY_TYPE_DSI: |
| 889 | dsi_get_overlay_fifo_thresholds(ovl->id, size, |
| 890 | burst_size, &fifo_low, &fifo_high); |
| 891 | break; |
| 892 | #endif |
| 893 | default: |
| 894 | BUG(); |
| 895 | } |
| 896 | |
Tomi Valkeinen | 04576d4 | 2011-11-26 14:39:16 +0200 | [diff] [blame] | 897 | dss_apply_ovl_fifo_thresholds(ovl, fifo_low, fifo_high); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | static void dss_mgr_setup_fifos(struct omap_overlay_manager *mgr) |
| 901 | { |
| 902 | struct omap_overlay *ovl; |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 903 | struct mgr_priv_data *mp; |
| 904 | |
| 905 | mp = get_mgr_priv(mgr); |
| 906 | |
| 907 | if (!mp->enabled) |
| 908 | return; |
| 909 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 910 | list_for_each_entry(ovl, &mgr->overlays, list) |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 911 | dss_ovl_setup_fifo(ovl); |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | static void dss_setup_fifos(void) |
| 915 | { |
| 916 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 917 | struct omap_overlay_manager *mgr; |
| 918 | int i; |
| 919 | |
| 920 | for (i = 0; i < num_mgrs; ++i) { |
| 921 | mgr = omap_dss_get_overlay_manager(i); |
| 922 | dss_mgr_setup_fifos(mgr); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 923 | } |
| 924 | } |
| 925 | |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 926 | int dss_mgr_enable(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 927 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 928 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 929 | unsigned long flags; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 930 | int r; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 931 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 932 | mutex_lock(&apply_lock); |
| 933 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 934 | if (mp->enabled) |
| 935 | goto out; |
| 936 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 937 | spin_lock_irqsave(&data_lock, flags); |
| 938 | |
| 939 | mp->enabled = true; |
Tomi Valkeinen | a6b24f8 | 2011-11-26 14:29:39 +0200 | [diff] [blame] | 940 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 941 | r = dss_check_settings(mgr, mgr->device); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 942 | if (r) { |
| 943 | DSSERR("failed to enable manager %d: check_settings failed\n", |
| 944 | mgr->id); |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 945 | goto err; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 946 | } |
| 947 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 948 | dss_setup_fifos(); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 949 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 950 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 951 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 952 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 953 | if (!mgr_manual_update(mgr)) |
| 954 | mp->updating = true; |
| 955 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 956 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 957 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 958 | if (!mgr_manual_update(mgr)) |
| 959 | dispc_mgr_enable(mgr->id, true); |
| 960 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 961 | out: |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 962 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 963 | |
| 964 | return 0; |
| 965 | |
| 966 | err: |
Tomi Valkeinen | a6b24f8 | 2011-11-26 14:29:39 +0200 | [diff] [blame] | 967 | mp->enabled = false; |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 968 | spin_unlock_irqrestore(&data_lock, flags); |
| 969 | mutex_unlock(&apply_lock); |
| 970 | return r; |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | void dss_mgr_disable(struct omap_overlay_manager *mgr) |
| 974 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 975 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 976 | unsigned long flags; |
| 977 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 978 | mutex_lock(&apply_lock); |
| 979 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 980 | if (!mp->enabled) |
| 981 | goto out; |
| 982 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 983 | if (!mgr_manual_update(mgr)) |
| 984 | dispc_mgr_enable(mgr->id, false); |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 985 | |
| 986 | spin_lock_irqsave(&data_lock, flags); |
| 987 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 988 | mp->updating = false; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 989 | mp->enabled = false; |
| 990 | |
| 991 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 992 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 993 | out: |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 994 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 995 | } |
| 996 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 997 | int dss_mgr_set_info(struct omap_overlay_manager *mgr, |
| 998 | struct omap_overlay_manager_info *info) |
| 999 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1000 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1001 | unsigned long flags; |
Tomi Valkeinen | f17d04f | 2011-11-17 14:31:09 +0200 | [diff] [blame] | 1002 | int r; |
| 1003 | |
| 1004 | r = dss_mgr_simple_check(mgr, info); |
| 1005 | if (r) |
| 1006 | return r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1007 | |
| 1008 | spin_lock_irqsave(&data_lock, flags); |
| 1009 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1010 | mp->user_info = *info; |
| 1011 | mp->user_info_dirty = true; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1012 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1013 | spin_unlock_irqrestore(&data_lock, flags); |
| 1014 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1015 | return 0; |
| 1016 | } |
| 1017 | |
| 1018 | void dss_mgr_get_info(struct omap_overlay_manager *mgr, |
| 1019 | struct omap_overlay_manager_info *info) |
| 1020 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1021 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1022 | unsigned long flags; |
| 1023 | |
| 1024 | spin_lock_irqsave(&data_lock, flags); |
| 1025 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1026 | *info = mp->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1027 | |
| 1028 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | int dss_mgr_set_device(struct omap_overlay_manager *mgr, |
| 1032 | struct omap_dss_device *dssdev) |
| 1033 | { |
| 1034 | int r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1035 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1036 | mutex_lock(&apply_lock); |
| 1037 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1038 | if (dssdev->manager) { |
| 1039 | DSSERR("display '%s' already has a manager '%s'\n", |
| 1040 | dssdev->name, dssdev->manager->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1041 | r = -EINVAL; |
| 1042 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1043 | } |
| 1044 | |
| 1045 | if ((mgr->supported_displays & dssdev->type) == 0) { |
| 1046 | DSSERR("display '%s' does not support manager '%s'\n", |
| 1047 | dssdev->name, mgr->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1048 | r = -EINVAL; |
| 1049 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1050 | } |
| 1051 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1052 | dssdev->manager = mgr; |
| 1053 | mgr->device = dssdev; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1054 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1055 | mutex_unlock(&apply_lock); |
| 1056 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1057 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1058 | err: |
| 1059 | mutex_unlock(&apply_lock); |
| 1060 | return r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | int dss_mgr_unset_device(struct omap_overlay_manager *mgr) |
| 1064 | { |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1065 | int r; |
| 1066 | |
| 1067 | mutex_lock(&apply_lock); |
| 1068 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1069 | if (!mgr->device) { |
| 1070 | DSSERR("failed to unset display, display not set.\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1071 | r = -EINVAL; |
| 1072 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | /* |
| 1076 | * Don't allow currently enabled displays to have the overlay manager |
| 1077 | * pulled out from underneath them |
| 1078 | */ |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1079 | if (mgr->device->state != OMAP_DSS_DISPLAY_DISABLED) { |
| 1080 | r = -EINVAL; |
| 1081 | goto err; |
| 1082 | } |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1083 | |
| 1084 | mgr->device->manager = NULL; |
| 1085 | mgr->device = NULL; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1086 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1087 | mutex_unlock(&apply_lock); |
| 1088 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1089 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1090 | err: |
| 1091 | mutex_unlock(&apply_lock); |
| 1092 | return r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1096 | int dss_ovl_set_info(struct omap_overlay *ovl, |
| 1097 | struct omap_overlay_info *info) |
| 1098 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1099 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1100 | unsigned long flags; |
Tomi Valkeinen | fcc764d | 2011-11-17 14:26:48 +0200 | [diff] [blame] | 1101 | int r; |
| 1102 | |
| 1103 | r = dss_ovl_simple_check(ovl, info); |
| 1104 | if (r) |
| 1105 | return r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1106 | |
| 1107 | spin_lock_irqsave(&data_lock, flags); |
| 1108 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1109 | op->user_info = *info; |
| 1110 | op->user_info_dirty = true; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1111 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1112 | spin_unlock_irqrestore(&data_lock, flags); |
| 1113 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1114 | return 0; |
| 1115 | } |
| 1116 | |
| 1117 | void dss_ovl_get_info(struct omap_overlay *ovl, |
| 1118 | struct omap_overlay_info *info) |
| 1119 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1120 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1121 | unsigned long flags; |
| 1122 | |
| 1123 | spin_lock_irqsave(&data_lock, flags); |
| 1124 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1125 | *info = op->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1126 | |
| 1127 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | int dss_ovl_set_manager(struct omap_overlay *ovl, |
| 1131 | struct omap_overlay_manager *mgr) |
| 1132 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1133 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1134 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1135 | int r; |
| 1136 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1137 | if (!mgr) |
| 1138 | return -EINVAL; |
| 1139 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1140 | mutex_lock(&apply_lock); |
| 1141 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1142 | if (ovl->manager) { |
| 1143 | DSSERR("overlay '%s' already has a manager '%s'\n", |
| 1144 | ovl->name, ovl->manager->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1145 | r = -EINVAL; |
| 1146 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1147 | } |
| 1148 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1149 | spin_lock_irqsave(&data_lock, flags); |
| 1150 | |
| 1151 | if (op->enabled) { |
| 1152 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1153 | DSSERR("overlay has to be disabled to change the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1154 | r = -EINVAL; |
| 1155 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1156 | } |
| 1157 | |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 1158 | op->channel = mgr->id; |
| 1159 | op->extra_info_dirty = true; |
| 1160 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1161 | ovl->manager = mgr; |
| 1162 | list_add_tail(&ovl->list, &mgr->overlays); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1163 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1164 | spin_unlock_irqrestore(&data_lock, flags); |
| 1165 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1166 | /* XXX: When there is an overlay on a DSI manual update display, and |
| 1167 | * the overlay is first disabled, then moved to tv, and enabled, we |
| 1168 | * seem to get SYNC_LOST_DIGIT error. |
| 1169 | * |
| 1170 | * Waiting doesn't seem to help, but updating the manual update display |
| 1171 | * after disabling the overlay seems to fix this. This hints that the |
| 1172 | * overlay is perhaps somehow tied to the LCD output until the output |
| 1173 | * is updated. |
| 1174 | * |
| 1175 | * Userspace workaround for this is to update the LCD after disabling |
| 1176 | * the overlay, but before moving the overlay to TV. |
| 1177 | */ |
| 1178 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1179 | mutex_unlock(&apply_lock); |
| 1180 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1181 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1182 | err: |
| 1183 | mutex_unlock(&apply_lock); |
| 1184 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | int dss_ovl_unset_manager(struct omap_overlay *ovl) |
| 1188 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1189 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1190 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1191 | int r; |
| 1192 | |
| 1193 | mutex_lock(&apply_lock); |
| 1194 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1195 | if (!ovl->manager) { |
| 1196 | DSSERR("failed to detach overlay: manager not set\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1197 | r = -EINVAL; |
| 1198 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1199 | } |
| 1200 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1201 | spin_lock_irqsave(&data_lock, flags); |
| 1202 | |
| 1203 | if (op->enabled) { |
| 1204 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1205 | DSSERR("overlay has to be disabled to unset the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1206 | r = -EINVAL; |
| 1207 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1208 | } |
| 1209 | |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 1210 | op->channel = -1; |
| 1211 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1212 | ovl->manager = NULL; |
| 1213 | list_del(&ovl->list); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1214 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1215 | spin_unlock_irqrestore(&data_lock, flags); |
| 1216 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1217 | mutex_unlock(&apply_lock); |
| 1218 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1219 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1220 | err: |
| 1221 | mutex_unlock(&apply_lock); |
| 1222 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1223 | } |
| 1224 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1225 | bool dss_ovl_is_enabled(struct omap_overlay *ovl) |
| 1226 | { |
| 1227 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1228 | unsigned long flags; |
| 1229 | bool e; |
| 1230 | |
| 1231 | spin_lock_irqsave(&data_lock, flags); |
| 1232 | |
| 1233 | e = op->enabled; |
| 1234 | |
| 1235 | spin_unlock_irqrestore(&data_lock, flags); |
| 1236 | |
| 1237 | return e; |
| 1238 | } |
| 1239 | |
| 1240 | int dss_ovl_enable(struct omap_overlay *ovl) |
| 1241 | { |
| 1242 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1243 | unsigned long flags; |
| 1244 | int r; |
| 1245 | |
| 1246 | mutex_lock(&apply_lock); |
| 1247 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1248 | if (op->enabled) { |
| 1249 | r = 0; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1250 | goto err1; |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1251 | } |
| 1252 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1253 | if (ovl->manager == NULL || ovl->manager->device == NULL) { |
| 1254 | r = -EINVAL; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1255 | goto err1; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1256 | } |
| 1257 | |
| 1258 | spin_lock_irqsave(&data_lock, flags); |
| 1259 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1260 | op->enabling = true; |
| 1261 | |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1262 | r = dss_check_settings(ovl->manager, ovl->manager->device); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1263 | if (r) { |
| 1264 | DSSERR("failed to enable overlay %d: check_settings failed\n", |
| 1265 | ovl->id); |
| 1266 | goto err2; |
| 1267 | } |
| 1268 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 1269 | dss_setup_fifos(); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1270 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1271 | op->enabling = false; |
| 1272 | dss_apply_ovl_enable(ovl, true); |
| 1273 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1274 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1275 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1276 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1277 | spin_unlock_irqrestore(&data_lock, flags); |
| 1278 | |
| 1279 | mutex_unlock(&apply_lock); |
| 1280 | |
| 1281 | return 0; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1282 | err2: |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1283 | op->enabling = false; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1284 | spin_unlock_irqrestore(&data_lock, flags); |
| 1285 | err1: |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1286 | mutex_unlock(&apply_lock); |
| 1287 | return r; |
| 1288 | } |
| 1289 | |
| 1290 | int dss_ovl_disable(struct omap_overlay *ovl) |
| 1291 | { |
| 1292 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1293 | unsigned long flags; |
| 1294 | int r; |
| 1295 | |
| 1296 | mutex_lock(&apply_lock); |
| 1297 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1298 | if (!op->enabled) { |
| 1299 | r = 0; |
| 1300 | goto err; |
| 1301 | } |
| 1302 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1303 | if (ovl->manager == NULL || ovl->manager->device == NULL) { |
| 1304 | r = -EINVAL; |
| 1305 | goto err; |
| 1306 | } |
| 1307 | |
| 1308 | spin_lock_irqsave(&data_lock, flags); |
| 1309 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame] | 1310 | dss_apply_ovl_enable(ovl, false); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1311 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1312 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1313 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1314 | spin_unlock_irqrestore(&data_lock, flags); |
| 1315 | |
| 1316 | mutex_unlock(&apply_lock); |
| 1317 | |
| 1318 | return 0; |
| 1319 | |
| 1320 | err: |
| 1321 | mutex_unlock(&apply_lock); |
| 1322 | return r; |
| 1323 | } |
| 1324 | |