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