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