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 | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 75 | }; |
| 76 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 77 | struct mgr_priv_data { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 78 | |
| 79 | bool user_info_dirty; |
| 80 | struct omap_overlay_manager_info user_info; |
| 81 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 82 | bool info_dirty; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 83 | struct omap_overlay_manager_info info; |
| 84 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 85 | bool shadow_info_dirty; |
| 86 | |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 87 | /* If true, GO bit is up and shadow registers cannot be written. |
| 88 | * Never true for manual update displays */ |
| 89 | bool busy; |
| 90 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 91 | /* If true, dispc output is enabled */ |
| 92 | bool updating; |
| 93 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 94 | /* If true, a display is enabled using this manager */ |
| 95 | bool enabled; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | static struct { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 99 | struct ovl_priv_data ovl_priv_data_array[MAX_DSS_OVERLAYS]; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 100 | struct mgr_priv_data mgr_priv_data_array[MAX_DSS_MANAGERS]; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 101 | |
| 102 | bool irq_enabled; |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 103 | } dss_data; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 104 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 105 | /* protects dss_data */ |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 106 | static spinlock_t data_lock; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 107 | /* lock for blocking functions */ |
| 108 | static DEFINE_MUTEX(apply_lock); |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 109 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 110 | static void dss_register_vsync_isr(void); |
| 111 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 112 | static struct ovl_priv_data *get_ovl_priv(struct omap_overlay *ovl) |
| 113 | { |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 114 | return &dss_data.ovl_priv_data_array[ovl->id]; |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 115 | } |
| 116 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 117 | static struct mgr_priv_data *get_mgr_priv(struct omap_overlay_manager *mgr) |
| 118 | { |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 119 | return &dss_data.mgr_priv_data_array[mgr->id]; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 120 | } |
| 121 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 122 | void dss_apply_init(void) |
| 123 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 124 | const int num_ovls = dss_feat_get_num_ovls(); |
| 125 | int i; |
| 126 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 127 | spin_lock_init(&data_lock); |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 128 | |
| 129 | for (i = 0; i < num_ovls; ++i) { |
| 130 | struct ovl_priv_data *op; |
| 131 | |
| 132 | op = &dss_data.ovl_priv_data_array[i]; |
| 133 | |
| 134 | op->info.global_alpha = 255; |
| 135 | |
| 136 | switch (i) { |
| 137 | case 0: |
| 138 | op->info.zorder = 0; |
| 139 | break; |
| 140 | case 1: |
| 141 | op->info.zorder = |
| 142 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 3 : 0; |
| 143 | break; |
| 144 | case 2: |
| 145 | op->info.zorder = |
| 146 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 2 : 0; |
| 147 | break; |
| 148 | case 3: |
| 149 | op->info.zorder = |
| 150 | dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 1 : 0; |
| 151 | break; |
| 152 | } |
| 153 | |
| 154 | op->user_info = op->info; |
| 155 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | static bool ovl_manual_update(struct omap_overlay *ovl) |
| 159 | { |
| 160 | return ovl->manager->device->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE; |
| 161 | } |
| 162 | |
| 163 | static bool mgr_manual_update(struct omap_overlay_manager *mgr) |
| 164 | { |
| 165 | return mgr->device->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE; |
| 166 | } |
| 167 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 168 | static bool need_isr(void) |
| 169 | { |
| 170 | const int num_mgrs = dss_feat_get_num_mgrs(); |
| 171 | int i; |
| 172 | |
| 173 | for (i = 0; i < num_mgrs; ++i) { |
| 174 | struct omap_overlay_manager *mgr; |
| 175 | struct mgr_priv_data *mp; |
| 176 | struct omap_overlay *ovl; |
| 177 | |
| 178 | mgr = omap_dss_get_overlay_manager(i); |
| 179 | mp = get_mgr_priv(mgr); |
| 180 | |
| 181 | if (!mp->enabled) |
| 182 | continue; |
| 183 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 184 | if (mgr_manual_update(mgr)) { |
| 185 | /* to catch FRAMEDONE */ |
| 186 | if (mp->updating) |
| 187 | return true; |
| 188 | } else { |
| 189 | /* to catch GO bit going down */ |
| 190 | if (mp->busy) |
| 191 | return true; |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 192 | |
| 193 | /* to write new values to registers */ |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 194 | if (mp->info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 195 | return true; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 196 | |
| 197 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 198 | struct ovl_priv_data *op; |
| 199 | |
| 200 | op = get_ovl_priv(ovl); |
| 201 | |
| 202 | if (!op->enabled) |
| 203 | continue; |
| 204 | |
| 205 | /* to write new values to registers */ |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 206 | if (op->info_dirty || op->extra_info_dirty) |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 207 | return true; |
| 208 | } |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | |
| 212 | return false; |
| 213 | } |
| 214 | |
| 215 | static bool need_go(struct omap_overlay_manager *mgr) |
| 216 | { |
| 217 | struct omap_overlay *ovl; |
| 218 | struct mgr_priv_data *mp; |
| 219 | struct ovl_priv_data *op; |
| 220 | |
| 221 | mp = get_mgr_priv(mgr); |
| 222 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 223 | if (mp->shadow_info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 224 | return true; |
| 225 | |
| 226 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 227 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 228 | if (op->shadow_info_dirty || op->shadow_extra_info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 229 | return true; |
| 230 | } |
| 231 | |
| 232 | return false; |
| 233 | } |
| 234 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 235 | int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr) |
| 236 | { |
| 237 | unsigned long timeout = msecs_to_jiffies(500); |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 238 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 239 | u32 irq; |
| 240 | int r; |
| 241 | int i; |
| 242 | struct omap_dss_device *dssdev = mgr->device; |
| 243 | |
| 244 | if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) |
| 245 | return 0; |
| 246 | |
| 247 | if (mgr_manual_update(mgr)) |
| 248 | return 0; |
| 249 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 250 | irq = dispc_mgr_get_vsync_irq(mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 251 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 252 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 253 | i = 0; |
| 254 | while (1) { |
| 255 | unsigned long flags; |
| 256 | bool shadow_dirty, dirty; |
| 257 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 258 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 259 | dirty = mp->info_dirty; |
| 260 | shadow_dirty = mp->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 261 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 262 | |
| 263 | if (!dirty && !shadow_dirty) { |
| 264 | r = 0; |
| 265 | break; |
| 266 | } |
| 267 | |
| 268 | /* 4 iterations is the worst case: |
| 269 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 270 | * 2 - first VSYNC, dirty = true |
| 271 | * 3 - dirty = false, shadow_dirty = true |
| 272 | * 4 - shadow_dirty = false */ |
| 273 | if (i++ == 3) { |
| 274 | DSSERR("mgr(%d)->wait_for_go() not finishing\n", |
| 275 | mgr->id); |
| 276 | r = 0; |
| 277 | break; |
| 278 | } |
| 279 | |
| 280 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 281 | if (r == -ERESTARTSYS) |
| 282 | break; |
| 283 | |
| 284 | if (r) { |
| 285 | DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr->id); |
| 286 | break; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | return r; |
| 291 | } |
| 292 | |
| 293 | int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl) |
| 294 | { |
| 295 | unsigned long timeout = msecs_to_jiffies(500); |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 296 | struct ovl_priv_data *op; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 297 | struct omap_dss_device *dssdev; |
| 298 | u32 irq; |
| 299 | int r; |
| 300 | int i; |
| 301 | |
| 302 | if (!ovl->manager) |
| 303 | return 0; |
| 304 | |
| 305 | dssdev = ovl->manager->device; |
| 306 | |
| 307 | if (!dssdev || dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) |
| 308 | return 0; |
| 309 | |
| 310 | if (ovl_manual_update(ovl)) |
| 311 | return 0; |
| 312 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 313 | irq = dispc_mgr_get_vsync_irq(ovl->manager->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 314 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 315 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 316 | i = 0; |
| 317 | while (1) { |
| 318 | unsigned long flags; |
| 319 | bool shadow_dirty, dirty; |
| 320 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 321 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 322 | dirty = op->info_dirty; |
| 323 | shadow_dirty = op->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 324 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 325 | |
| 326 | if (!dirty && !shadow_dirty) { |
| 327 | r = 0; |
| 328 | break; |
| 329 | } |
| 330 | |
| 331 | /* 4 iterations is the worst case: |
| 332 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 333 | * 2 - first VSYNC, dirty = true |
| 334 | * 3 - dirty = false, shadow_dirty = true |
| 335 | * 4 - shadow_dirty = false */ |
| 336 | if (i++ == 3) { |
| 337 | DSSERR("ovl(%d)->wait_for_go() not finishing\n", |
| 338 | ovl->id); |
| 339 | r = 0; |
| 340 | break; |
| 341 | } |
| 342 | |
| 343 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 344 | if (r == -ERESTARTSYS) |
| 345 | break; |
| 346 | |
| 347 | if (r) { |
| 348 | DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl->id); |
| 349 | break; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return r; |
| 354 | } |
| 355 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 356 | static void dss_ovl_write_regs(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 357 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 358 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 359 | struct omap_overlay_info *oi; |
| 360 | bool ilace, replication; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 361 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 362 | int r; |
| 363 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 364 | DSSDBGF("%d", ovl->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 365 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 366 | if (!op->enabled || !op->info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 367 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 368 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 369 | oi = &op->info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 370 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 371 | replication = dss_use_replication(ovl->manager->device, oi->color_mode); |
| 372 | |
| 373 | ilace = ovl->manager->device->type == OMAP_DISPLAY_TYPE_VENC; |
| 374 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 375 | r = dispc_ovl_setup(ovl->id, oi, ilace, replication); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 376 | if (r) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 377 | /* |
| 378 | * We can't do much here, as this function can be called from |
| 379 | * vsync interrupt. |
| 380 | */ |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 381 | DSSERR("dispc_ovl_setup failed for ovl %d\n", ovl->id); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 382 | |
| 383 | /* This will leave fifo configurations in a nonoptimal state */ |
| 384 | op->enabled = false; |
| 385 | dispc_ovl_enable(ovl->id, false); |
| 386 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 387 | } |
| 388 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 389 | mp = get_mgr_priv(ovl->manager); |
| 390 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 391 | op->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 392 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 393 | op->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 394 | } |
| 395 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 396 | static void dss_ovl_write_regs_extra(struct omap_overlay *ovl) |
| 397 | { |
| 398 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 399 | struct mgr_priv_data *mp; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 400 | |
| 401 | DSSDBGF("%d", ovl->id); |
| 402 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 403 | if (!op->extra_info_dirty) |
| 404 | return; |
| 405 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 406 | /* note: write also when op->enabled == false, so that the ovl gets |
| 407 | * disabled */ |
| 408 | |
| 409 | dispc_ovl_enable(ovl->id, op->enabled); |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 410 | dispc_ovl_set_channel_out(ovl->id, op->channel); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 411 | 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] | 412 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 413 | mp = get_mgr_priv(ovl->manager); |
| 414 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 415 | op->extra_info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 416 | if (mp->updating) |
| 417 | op->shadow_extra_info_dirty = true; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 418 | } |
| 419 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 420 | static void dss_mgr_write_regs(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 421 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 422 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 423 | struct omap_overlay *ovl; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 424 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 425 | DSSDBGF("%d", mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 426 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 427 | if (!mp->enabled) |
| 428 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 429 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 430 | WARN_ON(mp->busy); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 431 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 432 | /* Commit overlay settings */ |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 433 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 434 | dss_ovl_write_regs(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 435 | dss_ovl_write_regs_extra(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 436 | } |
| 437 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 438 | if (mp->info_dirty) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 439 | dispc_mgr_setup(mgr->id, &mp->info); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 440 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 441 | mp->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 442 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 443 | mp->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 444 | } |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 445 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 446 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 447 | static void dss_write_regs(void) |
| 448 | { |
| 449 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 450 | int i; |
| 451 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 452 | for (i = 0; i < num_mgrs; ++i) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 453 | struct omap_overlay_manager *mgr; |
| 454 | struct mgr_priv_data *mp; |
| 455 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 456 | mgr = omap_dss_get_overlay_manager(i); |
| 457 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 458 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 459 | if (!mp->enabled || mgr_manual_update(mgr) || mp->busy) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 460 | continue; |
| 461 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 462 | dss_mgr_write_regs(mgr); |
| 463 | |
| 464 | if (need_go(mgr)) { |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 465 | mp->busy = true; |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 466 | |
| 467 | if (!dss_data.irq_enabled && need_isr()) |
| 468 | dss_register_vsync_isr(); |
| 469 | |
| 470 | dispc_mgr_go(mgr->id); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 471 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 472 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | void dss_mgr_start_update(struct omap_overlay_manager *mgr) |
| 476 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 477 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 478 | unsigned long flags; |
| 479 | |
| 480 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 481 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 482 | WARN_ON(mp->updating); |
| 483 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 484 | dss_mgr_write_regs(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 485 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 486 | mp->updating = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 487 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 488 | if (!dss_data.irq_enabled && need_isr()) |
| 489 | dss_register_vsync_isr(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 490 | |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 491 | dispc_mgr_enable(mgr->id, true); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 492 | |
| 493 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 494 | } |
| 495 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 496 | static void dss_apply_irq_handler(void *data, u32 mask); |
| 497 | |
| 498 | static void dss_register_vsync_isr(void) |
| 499 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 500 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 501 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 502 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 503 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 504 | mask = 0; |
| 505 | for (i = 0; i < num_mgrs; ++i) |
| 506 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 507 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 508 | for (i = 0; i < num_mgrs; ++i) |
| 509 | mask |= dispc_mgr_get_framedone_irq(i); |
| 510 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 511 | r = omap_dispc_register_isr(dss_apply_irq_handler, NULL, mask); |
| 512 | WARN_ON(r); |
| 513 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 514 | dss_data.irq_enabled = true; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | static void dss_unregister_vsync_isr(void) |
| 518 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 519 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 520 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 521 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 522 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 523 | mask = 0; |
| 524 | for (i = 0; i < num_mgrs; ++i) |
| 525 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 526 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 527 | for (i = 0; i < num_mgrs; ++i) |
| 528 | mask |= dispc_mgr_get_framedone_irq(i); |
| 529 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 530 | r = omap_dispc_unregister_isr(dss_apply_irq_handler, NULL, mask); |
| 531 | WARN_ON(r); |
| 532 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 533 | dss_data.irq_enabled = false; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 534 | } |
| 535 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 536 | static void mgr_clear_shadow_dirty(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 537 | { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 538 | struct omap_overlay *ovl; |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 539 | struct mgr_priv_data *mp; |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 540 | struct ovl_priv_data *op; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 541 | |
| 542 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 543 | mp->shadow_info_dirty = false; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 544 | |
| 545 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 546 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 547 | op->shadow_info_dirty = false; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 548 | op->shadow_extra_info_dirty = false; |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | static void dss_apply_irq_handler(void *data, u32 mask) |
| 553 | { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 554 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 555 | int i; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 556 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 557 | spin_lock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 558 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 559 | /* clear busy, updating flags, shadow_dirty flags */ |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 560 | for (i = 0; i < num_mgrs; i++) { |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 561 | struct omap_overlay_manager *mgr; |
| 562 | struct mgr_priv_data *mp; |
| 563 | |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 564 | mgr = omap_dss_get_overlay_manager(i); |
| 565 | mp = get_mgr_priv(mgr); |
| 566 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 567 | if (!mp->enabled) |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 568 | continue; |
| 569 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 570 | mp->updating = dispc_mgr_is_enabled(i); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 571 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 572 | if (!mgr_manual_update(mgr)) { |
| 573 | mp->busy = dispc_mgr_go_busy(i); |
| 574 | |
| 575 | if (!mp->busy) |
| 576 | mgr_clear_shadow_dirty(mgr); |
| 577 | } else { |
| 578 | if (!mp->updating) |
| 579 | mgr_clear_shadow_dirty(mgr); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 580 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 581 | } |
| 582 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 583 | dss_write_regs(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 584 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 585 | if (!need_isr()) |
| 586 | dss_unregister_vsync_isr(); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 587 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 588 | spin_unlock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 589 | } |
| 590 | |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 591 | static void omap_dss_mgr_apply_ovl(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 592 | { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 593 | struct ovl_priv_data *op; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 594 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 595 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 596 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 597 | if (!op->user_info_dirty) |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 598 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 599 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 600 | op->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 601 | op->info_dirty = true; |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 602 | op->info = op->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | static void omap_dss_mgr_apply_mgr(struct omap_overlay_manager *mgr) |
| 606 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 607 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 608 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 609 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 610 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 611 | if (!mp->user_info_dirty) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 612 | return; |
| 613 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 614 | mp->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 615 | mp->info_dirty = true; |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 616 | mp->info = mp->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 617 | } |
| 618 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 619 | int omap_dss_mgr_apply(struct omap_overlay_manager *mgr) |
| 620 | { |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 621 | int r; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 622 | unsigned long flags; |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 623 | struct omap_overlay *ovl; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 624 | |
| 625 | DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name); |
| 626 | |
| 627 | r = dispc_runtime_get(); |
| 628 | if (r) |
| 629 | return r; |
| 630 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 631 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 632 | |
| 633 | /* Configure overlays */ |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 634 | list_for_each_entry(ovl, &mgr->overlays, list) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 635 | omap_dss_mgr_apply_ovl(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 636 | |
| 637 | /* Configure manager */ |
| 638 | omap_dss_mgr_apply_mgr(mgr); |
| 639 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 640 | dss_write_regs(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 641 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 642 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 643 | |
| 644 | dispc_runtime_put(); |
| 645 | |
| 646 | return r; |
| 647 | } |
| 648 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame^] | 649 | static void dss_apply_ovl_enable(struct omap_overlay *ovl, bool enable) |
| 650 | { |
| 651 | struct ovl_priv_data *op; |
| 652 | |
| 653 | op = get_ovl_priv(ovl); |
| 654 | |
| 655 | if (op->enabled == enable) |
| 656 | return; |
| 657 | |
| 658 | op->enabled = enable; |
| 659 | op->extra_info_dirty = true; |
| 660 | } |
| 661 | |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 662 | static void dss_ovl_setup_fifo(struct omap_overlay *ovl) |
| 663 | { |
| 664 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 665 | struct omap_dss_device *dssdev; |
| 666 | u32 size, burst_size; |
| 667 | u32 fifo_low, fifo_high; |
| 668 | |
| 669 | dssdev = ovl->manager->device; |
| 670 | |
| 671 | size = dispc_ovl_get_fifo_size(ovl->id); |
| 672 | |
| 673 | burst_size = dispc_ovl_get_burst_size(ovl->id); |
| 674 | |
| 675 | switch (dssdev->type) { |
| 676 | case OMAP_DISPLAY_TYPE_DPI: |
| 677 | case OMAP_DISPLAY_TYPE_DBI: |
| 678 | case OMAP_DISPLAY_TYPE_SDI: |
| 679 | case OMAP_DISPLAY_TYPE_VENC: |
| 680 | case OMAP_DISPLAY_TYPE_HDMI: |
| 681 | default_get_overlay_fifo_thresholds(ovl->id, size, |
| 682 | burst_size, &fifo_low, &fifo_high); |
| 683 | break; |
| 684 | #ifdef CONFIG_OMAP2_DSS_DSI |
| 685 | case OMAP_DISPLAY_TYPE_DSI: |
| 686 | dsi_get_overlay_fifo_thresholds(ovl->id, size, |
| 687 | burst_size, &fifo_low, &fifo_high); |
| 688 | break; |
| 689 | #endif |
| 690 | default: |
| 691 | BUG(); |
| 692 | } |
| 693 | |
| 694 | op->fifo_low = fifo_low; |
| 695 | op->fifo_high = fifo_high; |
| 696 | op->extra_info_dirty = true; |
| 697 | } |
| 698 | |
| 699 | static void dss_mgr_setup_fifos(struct omap_overlay_manager *mgr) |
| 700 | { |
| 701 | struct omap_overlay *ovl; |
| 702 | struct ovl_priv_data *op; |
| 703 | struct mgr_priv_data *mp; |
| 704 | |
| 705 | mp = get_mgr_priv(mgr); |
| 706 | |
| 707 | if (!mp->enabled) |
| 708 | return; |
| 709 | |
| 710 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 711 | op = get_ovl_priv(ovl); |
| 712 | |
| 713 | if (!op->enabled) |
| 714 | continue; |
| 715 | |
| 716 | dss_ovl_setup_fifo(ovl); |
| 717 | } |
| 718 | } |
| 719 | |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 720 | void dss_mgr_enable(struct omap_overlay_manager *mgr) |
| 721 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 722 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 723 | unsigned long flags; |
| 724 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 725 | mutex_lock(&apply_lock); |
| 726 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 727 | spin_lock_irqsave(&data_lock, flags); |
| 728 | |
| 729 | mp->enabled = true; |
| 730 | |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 731 | dss_mgr_setup_fifos(mgr); |
| 732 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 733 | dss_write_regs(); |
| 734 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 735 | if (!mgr_manual_update(mgr)) |
| 736 | mp->updating = true; |
| 737 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 738 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 739 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 740 | if (!mgr_manual_update(mgr)) |
| 741 | dispc_mgr_enable(mgr->id, true); |
| 742 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 743 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | void dss_mgr_disable(struct omap_overlay_manager *mgr) |
| 747 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 748 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 749 | unsigned long flags; |
| 750 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 751 | mutex_lock(&apply_lock); |
| 752 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 753 | if (!mgr_manual_update(mgr)) |
| 754 | dispc_mgr_enable(mgr->id, false); |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 755 | |
| 756 | spin_lock_irqsave(&data_lock, flags); |
| 757 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 758 | mp->updating = false; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 759 | mp->enabled = false; |
| 760 | |
| 761 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 762 | |
| 763 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 764 | } |
| 765 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 766 | int dss_mgr_set_info(struct omap_overlay_manager *mgr, |
| 767 | struct omap_overlay_manager_info *info) |
| 768 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 769 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 770 | unsigned long flags; |
| 771 | |
| 772 | spin_lock_irqsave(&data_lock, flags); |
| 773 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 774 | mp->user_info = *info; |
| 775 | mp->user_info_dirty = true; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 776 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 777 | spin_unlock_irqrestore(&data_lock, flags); |
| 778 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 779 | return 0; |
| 780 | } |
| 781 | |
| 782 | void dss_mgr_get_info(struct omap_overlay_manager *mgr, |
| 783 | struct omap_overlay_manager_info *info) |
| 784 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 785 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 786 | unsigned long flags; |
| 787 | |
| 788 | spin_lock_irqsave(&data_lock, flags); |
| 789 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 790 | *info = mp->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 791 | |
| 792 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | int dss_mgr_set_device(struct omap_overlay_manager *mgr, |
| 796 | struct omap_dss_device *dssdev) |
| 797 | { |
| 798 | int r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 799 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 800 | mutex_lock(&apply_lock); |
| 801 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 802 | if (dssdev->manager) { |
| 803 | DSSERR("display '%s' already has a manager '%s'\n", |
| 804 | dssdev->name, dssdev->manager->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 805 | r = -EINVAL; |
| 806 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | if ((mgr->supported_displays & dssdev->type) == 0) { |
| 810 | DSSERR("display '%s' does not support manager '%s'\n", |
| 811 | dssdev->name, mgr->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 812 | r = -EINVAL; |
| 813 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 814 | } |
| 815 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 816 | dssdev->manager = mgr; |
| 817 | mgr->device = dssdev; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 818 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 819 | mutex_unlock(&apply_lock); |
| 820 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 821 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 822 | err: |
| 823 | mutex_unlock(&apply_lock); |
| 824 | return r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | int dss_mgr_unset_device(struct omap_overlay_manager *mgr) |
| 828 | { |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 829 | int r; |
| 830 | |
| 831 | mutex_lock(&apply_lock); |
| 832 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 833 | if (!mgr->device) { |
| 834 | DSSERR("failed to unset display, display not set.\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 835 | r = -EINVAL; |
| 836 | goto err; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | /* |
| 840 | * Don't allow currently enabled displays to have the overlay manager |
| 841 | * pulled out from underneath them |
| 842 | */ |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 843 | if (mgr->device->state != OMAP_DSS_DISPLAY_DISABLED) { |
| 844 | r = -EINVAL; |
| 845 | goto err; |
| 846 | } |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 847 | |
| 848 | mgr->device->manager = NULL; |
| 849 | mgr->device = NULL; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 850 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 851 | mutex_unlock(&apply_lock); |
| 852 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 853 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 854 | err: |
| 855 | mutex_unlock(&apply_lock); |
| 856 | return r; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | |
| 860 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 861 | int dss_ovl_set_info(struct omap_overlay *ovl, |
| 862 | struct omap_overlay_info *info) |
| 863 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 864 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 865 | unsigned long flags; |
| 866 | |
| 867 | spin_lock_irqsave(&data_lock, flags); |
| 868 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 869 | op->user_info = *info; |
| 870 | op->user_info_dirty = true; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 871 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 872 | spin_unlock_irqrestore(&data_lock, flags); |
| 873 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | void dss_ovl_get_info(struct omap_overlay *ovl, |
| 878 | struct omap_overlay_info *info) |
| 879 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 880 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 881 | unsigned long flags; |
| 882 | |
| 883 | spin_lock_irqsave(&data_lock, flags); |
| 884 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 885 | *info = op->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 886 | |
| 887 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | int dss_ovl_set_manager(struct omap_overlay *ovl, |
| 891 | struct omap_overlay_manager *mgr) |
| 892 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 893 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 894 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 895 | int r; |
| 896 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 897 | if (!mgr) |
| 898 | return -EINVAL; |
| 899 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 900 | mutex_lock(&apply_lock); |
| 901 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 902 | if (ovl->manager) { |
| 903 | DSSERR("overlay '%s' already has a manager '%s'\n", |
| 904 | ovl->name, ovl->manager->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 905 | r = -EINVAL; |
| 906 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 907 | } |
| 908 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 909 | spin_lock_irqsave(&data_lock, flags); |
| 910 | |
| 911 | if (op->enabled) { |
| 912 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 913 | DSSERR("overlay has to be disabled to change the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 914 | r = -EINVAL; |
| 915 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 916 | } |
| 917 | |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 918 | op->channel = mgr->id; |
| 919 | op->extra_info_dirty = true; |
| 920 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 921 | ovl->manager = mgr; |
| 922 | list_add_tail(&ovl->list, &mgr->overlays); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 923 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 924 | spin_unlock_irqrestore(&data_lock, flags); |
| 925 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 926 | /* XXX: When there is an overlay on a DSI manual update display, and |
| 927 | * the overlay is first disabled, then moved to tv, and enabled, we |
| 928 | * seem to get SYNC_LOST_DIGIT error. |
| 929 | * |
| 930 | * Waiting doesn't seem to help, but updating the manual update display |
| 931 | * after disabling the overlay seems to fix this. This hints that the |
| 932 | * overlay is perhaps somehow tied to the LCD output until the output |
| 933 | * is updated. |
| 934 | * |
| 935 | * Userspace workaround for this is to update the LCD after disabling |
| 936 | * the overlay, but before moving the overlay to TV. |
| 937 | */ |
| 938 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 939 | mutex_unlock(&apply_lock); |
| 940 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 941 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 942 | err: |
| 943 | mutex_unlock(&apply_lock); |
| 944 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | int dss_ovl_unset_manager(struct omap_overlay *ovl) |
| 948 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 949 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 950 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 951 | int r; |
| 952 | |
| 953 | mutex_lock(&apply_lock); |
| 954 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 955 | if (!ovl->manager) { |
| 956 | DSSERR("failed to detach overlay: manager not set\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 957 | r = -EINVAL; |
| 958 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 959 | } |
| 960 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 961 | spin_lock_irqsave(&data_lock, flags); |
| 962 | |
| 963 | if (op->enabled) { |
| 964 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 965 | DSSERR("overlay has to be disabled to unset the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 966 | r = -EINVAL; |
| 967 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 968 | } |
| 969 | |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 970 | op->channel = -1; |
| 971 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 972 | ovl->manager = NULL; |
| 973 | list_del(&ovl->list); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 974 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 975 | spin_unlock_irqrestore(&data_lock, flags); |
| 976 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 977 | mutex_unlock(&apply_lock); |
| 978 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 979 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 980 | err: |
| 981 | mutex_unlock(&apply_lock); |
| 982 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 983 | } |
| 984 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 985 | bool dss_ovl_is_enabled(struct omap_overlay *ovl) |
| 986 | { |
| 987 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 988 | unsigned long flags; |
| 989 | bool e; |
| 990 | |
| 991 | spin_lock_irqsave(&data_lock, flags); |
| 992 | |
| 993 | e = op->enabled; |
| 994 | |
| 995 | spin_unlock_irqrestore(&data_lock, flags); |
| 996 | |
| 997 | return e; |
| 998 | } |
| 999 | |
| 1000 | int dss_ovl_enable(struct omap_overlay *ovl) |
| 1001 | { |
| 1002 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1003 | unsigned long flags; |
| 1004 | int r; |
| 1005 | |
| 1006 | mutex_lock(&apply_lock); |
| 1007 | |
| 1008 | if (ovl->manager == NULL || ovl->manager->device == NULL) { |
| 1009 | r = -EINVAL; |
| 1010 | goto err; |
| 1011 | } |
| 1012 | |
| 1013 | spin_lock_irqsave(&data_lock, flags); |
| 1014 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame^] | 1015 | dss_apply_ovl_enable(ovl, true); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1016 | |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1017 | dss_ovl_setup_fifo(ovl); |
| 1018 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1019 | dss_write_regs(); |
| 1020 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1021 | spin_unlock_irqrestore(&data_lock, flags); |
| 1022 | |
| 1023 | mutex_unlock(&apply_lock); |
| 1024 | |
| 1025 | return 0; |
| 1026 | err: |
| 1027 | mutex_unlock(&apply_lock); |
| 1028 | return r; |
| 1029 | } |
| 1030 | |
| 1031 | int dss_ovl_disable(struct omap_overlay *ovl) |
| 1032 | { |
| 1033 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1034 | unsigned long flags; |
| 1035 | int r; |
| 1036 | |
| 1037 | mutex_lock(&apply_lock); |
| 1038 | |
| 1039 | if (ovl->manager == NULL || ovl->manager->device == NULL) { |
| 1040 | r = -EINVAL; |
| 1041 | goto err; |
| 1042 | } |
| 1043 | |
| 1044 | spin_lock_irqsave(&data_lock, flags); |
| 1045 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame^] | 1046 | dss_apply_ovl_enable(ovl, false); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1047 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1048 | dss_write_regs(); |
| 1049 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1050 | spin_unlock_irqrestore(&data_lock, flags); |
| 1051 | |
| 1052 | mutex_unlock(&apply_lock); |
| 1053 | |
| 1054 | return 0; |
| 1055 | |
| 1056 | err: |
| 1057 | mutex_unlock(&apply_lock); |
| 1058 | return r; |
| 1059 | } |
| 1060 | |