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> |
Tomi Valkeinen | 8dd2491 | 2012-10-10 10:26:45 +0300 | [diff] [blame] | 21 | #include <linux/module.h> |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 22 | #include <linux/slab.h> |
| 23 | #include <linux/spinlock.h> |
| 24 | #include <linux/jiffies.h> |
| 25 | |
| 26 | #include <video/omapdss.h> |
| 27 | |
| 28 | #include "dss.h" |
| 29 | #include "dss_features.h" |
| 30 | |
| 31 | /* |
| 32 | * We have 4 levels of cache for the dispc settings. First two are in SW and |
| 33 | * the latter two in HW. |
| 34 | * |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 35 | * set_info() |
| 36 | * v |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 37 | * +--------------------+ |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 38 | * | user_info | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 39 | * +--------------------+ |
| 40 | * v |
| 41 | * apply() |
| 42 | * v |
| 43 | * +--------------------+ |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 44 | * | info | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 45 | * +--------------------+ |
| 46 | * v |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 47 | * write_regs() |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 48 | * v |
| 49 | * +--------------------+ |
| 50 | * | shadow registers | |
| 51 | * +--------------------+ |
| 52 | * v |
| 53 | * VFP or lcd/digit_enable |
| 54 | * v |
| 55 | * +--------------------+ |
| 56 | * | registers | |
| 57 | * +--------------------+ |
| 58 | */ |
| 59 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 60 | struct ovl_priv_data { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 61 | |
| 62 | bool user_info_dirty; |
| 63 | struct omap_overlay_info user_info; |
| 64 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 65 | bool info_dirty; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 66 | struct omap_overlay_info info; |
| 67 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 68 | bool shadow_info_dirty; |
| 69 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 70 | bool extra_info_dirty; |
| 71 | bool shadow_extra_info_dirty; |
| 72 | |
| 73 | bool enabled; |
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 | 8dd2491 | 2012-10-10 10:26:45 +0300 | [diff] [blame] | 135 | static void apply_init_priv(void) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 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"); |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 417 | } |
| 418 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 419 | int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr) |
| 420 | { |
| 421 | unsigned long timeout = msecs_to_jiffies(500); |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 422 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 423 | u32 irq; |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 424 | unsigned long flags; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 425 | int r; |
| 426 | int i; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 427 | |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 428 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 429 | |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 430 | if (mgr_manual_update(mgr)) { |
| 431 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 432 | return 0; |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | if (!mp->enabled) { |
| 436 | spin_unlock_irqrestore(&data_lock, flags); |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 441 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 442 | r = dispc_runtime_get(); |
| 443 | if (r) |
| 444 | return r; |
| 445 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 446 | irq = dispc_mgr_get_vsync_irq(mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 447 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 448 | i = 0; |
| 449 | while (1) { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 450 | bool shadow_dirty, dirty; |
| 451 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 452 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 453 | dirty = mp->info_dirty; |
| 454 | shadow_dirty = mp->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 455 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 456 | |
| 457 | if (!dirty && !shadow_dirty) { |
| 458 | r = 0; |
| 459 | break; |
| 460 | } |
| 461 | |
| 462 | /* 4 iterations is the worst case: |
| 463 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 464 | * 2 - first VSYNC, dirty = true |
| 465 | * 3 - dirty = false, shadow_dirty = true |
| 466 | * 4 - shadow_dirty = false */ |
| 467 | if (i++ == 3) { |
| 468 | DSSERR("mgr(%d)->wait_for_go() not finishing\n", |
| 469 | mgr->id); |
| 470 | r = 0; |
| 471 | break; |
| 472 | } |
| 473 | |
| 474 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 475 | if (r == -ERESTARTSYS) |
| 476 | break; |
| 477 | |
| 478 | if (r) { |
| 479 | DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr->id); |
| 480 | break; |
| 481 | } |
| 482 | } |
| 483 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 484 | dispc_runtime_put(); |
| 485 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 486 | return r; |
| 487 | } |
| 488 | |
| 489 | int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl) |
| 490 | { |
| 491 | unsigned long timeout = msecs_to_jiffies(500); |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 492 | struct ovl_priv_data *op; |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 493 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 494 | u32 irq; |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 495 | unsigned long flags; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 496 | int r; |
| 497 | int i; |
| 498 | |
| 499 | if (!ovl->manager) |
| 500 | return 0; |
| 501 | |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 502 | mp = get_mgr_priv(ovl->manager); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 503 | |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 504 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 505 | |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 506 | if (ovl_manual_update(ovl)) { |
| 507 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 508 | return 0; |
Archit Taneja | fc22a84 | 2012-06-26 15:36:55 +0530 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | if (!mp->enabled) { |
| 512 | spin_unlock_irqrestore(&data_lock, flags); |
| 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 517 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 518 | r = dispc_runtime_get(); |
| 519 | if (r) |
| 520 | return r; |
| 521 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 522 | irq = dispc_mgr_get_vsync_irq(ovl->manager->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 523 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 524 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 525 | i = 0; |
| 526 | while (1) { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 527 | bool shadow_dirty, dirty; |
| 528 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 529 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 530 | dirty = op->info_dirty; |
| 531 | shadow_dirty = op->shadow_info_dirty; |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 532 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 533 | |
| 534 | if (!dirty && !shadow_dirty) { |
| 535 | r = 0; |
| 536 | break; |
| 537 | } |
| 538 | |
| 539 | /* 4 iterations is the worst case: |
| 540 | * 1 - initial iteration, dirty = true (between VFP and VSYNC) |
| 541 | * 2 - first VSYNC, dirty = true |
| 542 | * 3 - dirty = false, shadow_dirty = true |
| 543 | * 4 - shadow_dirty = false */ |
| 544 | if (i++ == 3) { |
| 545 | DSSERR("ovl(%d)->wait_for_go() not finishing\n", |
| 546 | ovl->id); |
| 547 | r = 0; |
| 548 | break; |
| 549 | } |
| 550 | |
| 551 | r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout); |
| 552 | if (r == -ERESTARTSYS) |
| 553 | break; |
| 554 | |
| 555 | if (r) { |
| 556 | DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl->id); |
| 557 | break; |
| 558 | } |
| 559 | } |
| 560 | |
Lajos Molnar | 21e56f7 | 2012-02-22 12:23:16 +0530 | [diff] [blame] | 561 | dispc_runtime_put(); |
| 562 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 563 | return r; |
| 564 | } |
| 565 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 566 | static void dss_ovl_write_regs(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 567 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 568 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 569 | struct omap_overlay_info *oi; |
Archit Taneja | 8050cbe | 2012-06-06 16:25:52 +0530 | [diff] [blame] | 570 | bool replication; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 571 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 572 | int r; |
| 573 | |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 574 | DSSDBG("writing ovl %d regs", ovl->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 575 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 576 | if (!op->enabled || !op->info_dirty) |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 577 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 578 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 579 | oi = &op->info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 580 | |
Archit Taneja | 81ab95b | 2012-05-08 15:53:20 +0530 | [diff] [blame] | 581 | mp = get_mgr_priv(ovl->manager); |
| 582 | |
Archit Taneja | 6c6f510 | 2012-06-25 14:58:48 +0530 | [diff] [blame] | 583 | replication = dss_ovl_use_replication(mp->lcd_config, oi->color_mode); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 584 | |
Archit Taneja | 8ba8530 | 2012-09-26 17:00:37 +0530 | [diff] [blame] | 585 | r = dispc_ovl_setup(ovl->id, oi, replication, &mp->timings, false); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 586 | if (r) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 587 | /* |
| 588 | * We can't do much here, as this function can be called from |
| 589 | * vsync interrupt. |
| 590 | */ |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 591 | DSSERR("dispc_ovl_setup failed for ovl %d\n", ovl->id); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 592 | |
| 593 | /* This will leave fifo configurations in a nonoptimal state */ |
| 594 | op->enabled = false; |
| 595 | dispc_ovl_enable(ovl->id, false); |
| 596 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 597 | } |
| 598 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 599 | op->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 600 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 601 | op->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 602 | } |
| 603 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 604 | static void dss_ovl_write_regs_extra(struct omap_overlay *ovl) |
| 605 | { |
| 606 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 607 | struct mgr_priv_data *mp; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 608 | |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 609 | DSSDBG("writing ovl %d regs extra", ovl->id); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 610 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 611 | if (!op->extra_info_dirty) |
| 612 | return; |
| 613 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 614 | /* note: write also when op->enabled == false, so that the ovl gets |
| 615 | * disabled */ |
| 616 | |
| 617 | dispc_ovl_enable(ovl->id, op->enabled); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 618 | 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] | 619 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 620 | mp = get_mgr_priv(ovl->manager); |
| 621 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 622 | op->extra_info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 623 | if (mp->updating) |
| 624 | op->shadow_extra_info_dirty = true; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 625 | } |
| 626 | |
Tomi Valkeinen | f6a5e08 | 2011-11-15 11:47:39 +0200 | [diff] [blame] | 627 | static void dss_mgr_write_regs(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 628 | { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 629 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 630 | struct omap_overlay *ovl; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 631 | |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 632 | DSSDBG("writing mgr %d regs", mgr->id); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 633 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 634 | if (!mp->enabled) |
| 635 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 636 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 637 | WARN_ON(mp->busy); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 638 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 639 | /* Commit overlay settings */ |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 640 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 641 | dss_ovl_write_regs(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 642 | dss_ovl_write_regs_extra(ovl); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 643 | } |
| 644 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 645 | if (mp->info_dirty) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 646 | dispc_mgr_setup(mgr->id, &mp->info); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 647 | |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 648 | mp->info_dirty = false; |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 649 | if (mp->updating) |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 650 | mp->shadow_info_dirty = true; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 651 | } |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 652 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 653 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 654 | static void dss_mgr_write_regs_extra(struct omap_overlay_manager *mgr) |
| 655 | { |
| 656 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 657 | |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 658 | DSSDBG("writing mgr %d regs extra", mgr->id); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 659 | |
| 660 | if (!mp->extra_info_dirty) |
| 661 | return; |
| 662 | |
| 663 | dispc_mgr_set_timings(mgr->id, &mp->timings); |
| 664 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 665 | /* lcd_config parameters */ |
Tomi Valkeinen | fb2cec1 | 2012-09-12 13:30:39 +0300 | [diff] [blame] | 666 | if (dss_mgr_is_lcd(mgr->id)) |
| 667 | dispc_mgr_set_lcd_config(mgr->id, &mp->lcd_config); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 668 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 669 | mp->extra_info_dirty = false; |
| 670 | if (mp->updating) |
| 671 | mp->shadow_extra_info_dirty = true; |
| 672 | } |
| 673 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 674 | static void dss_write_regs(void) |
| 675 | { |
| 676 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 677 | int i; |
| 678 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 679 | for (i = 0; i < num_mgrs; ++i) { |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 680 | struct omap_overlay_manager *mgr; |
| 681 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 682 | int r; |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 683 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 684 | mgr = omap_dss_get_overlay_manager(i); |
| 685 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 686 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 687 | if (!mp->enabled || mgr_manual_update(mgr) || mp->busy) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 688 | continue; |
| 689 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 690 | r = dss_check_settings(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 691 | if (r) { |
| 692 | DSSERR("cannot write registers for manager %s: " |
| 693 | "illegal configuration\n", mgr->name); |
| 694 | continue; |
| 695 | } |
| 696 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 697 | dss_mgr_write_regs(mgr); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 698 | dss_mgr_write_regs_extra(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 699 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 700 | } |
| 701 | |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 702 | static void dss_set_go_bits(void) |
| 703 | { |
| 704 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 705 | int i; |
| 706 | |
| 707 | for (i = 0; i < num_mgrs; ++i) { |
| 708 | struct omap_overlay_manager *mgr; |
| 709 | struct mgr_priv_data *mp; |
| 710 | |
| 711 | mgr = omap_dss_get_overlay_manager(i); |
| 712 | mp = get_mgr_priv(mgr); |
| 713 | |
| 714 | if (!mp->enabled || mgr_manual_update(mgr) || mp->busy) |
| 715 | continue; |
| 716 | |
| 717 | if (!need_go(mgr)) |
| 718 | continue; |
| 719 | |
| 720 | mp->busy = true; |
| 721 | |
| 722 | if (!dss_data.irq_enabled && need_isr()) |
| 723 | dss_register_vsync_isr(); |
| 724 | |
| 725 | dispc_mgr_go(mgr->id); |
| 726 | } |
| 727 | |
| 728 | } |
| 729 | |
Tomi Valkeinen | df01d53 | 2012-03-07 10:28:48 +0200 | [diff] [blame] | 730 | static void mgr_clear_shadow_dirty(struct omap_overlay_manager *mgr) |
| 731 | { |
| 732 | struct omap_overlay *ovl; |
| 733 | struct mgr_priv_data *mp; |
| 734 | struct ovl_priv_data *op; |
| 735 | |
| 736 | mp = get_mgr_priv(mgr); |
| 737 | mp->shadow_info_dirty = false; |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 738 | mp->shadow_extra_info_dirty = false; |
Tomi Valkeinen | df01d53 | 2012-03-07 10:28:48 +0200 | [diff] [blame] | 739 | |
| 740 | list_for_each_entry(ovl, &mgr->overlays, list) { |
| 741 | op = get_ovl_priv(ovl); |
| 742 | op->shadow_info_dirty = false; |
| 743 | op->shadow_extra_info_dirty = false; |
| 744 | } |
| 745 | } |
| 746 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 747 | void dss_mgr_start_update(struct omap_overlay_manager *mgr) |
| 748 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 749 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 750 | unsigned long flags; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 751 | int r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 752 | |
| 753 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 754 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 755 | WARN_ON(mp->updating); |
| 756 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 757 | r = dss_check_settings(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 758 | if (r) { |
| 759 | DSSERR("cannot start manual update: illegal configuration\n"); |
| 760 | spin_unlock_irqrestore(&data_lock, flags); |
| 761 | return; |
| 762 | } |
| 763 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 764 | dss_mgr_write_regs(mgr); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 765 | dss_mgr_write_regs_extra(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 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 | 3a979f8 | 2012-10-19 14:14:38 +0300 | [diff] [blame] | 772 | dispc_mgr_enable_sync(mgr->id); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 773 | |
| 774 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 775 | } |
| 776 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 777 | static void dss_apply_irq_handler(void *data, u32 mask); |
| 778 | |
| 779 | static void dss_register_vsync_isr(void) |
| 780 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 781 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 782 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 783 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 784 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 785 | mask = 0; |
| 786 | for (i = 0; i < num_mgrs; ++i) |
| 787 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 788 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 789 | for (i = 0; i < num_mgrs; ++i) |
| 790 | mask |= dispc_mgr_get_framedone_irq(i); |
| 791 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 792 | r = omap_dispc_register_isr(dss_apply_irq_handler, NULL, mask); |
| 793 | WARN_ON(r); |
| 794 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 795 | dss_data.irq_enabled = true; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | static void dss_unregister_vsync_isr(void) |
| 799 | { |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 800 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 801 | u32 mask; |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 802 | int r, i; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 803 | |
Tomi Valkeinen | bc1a951 | 2011-11-15 11:20:13 +0200 | [diff] [blame] | 804 | mask = 0; |
| 805 | for (i = 0; i < num_mgrs; ++i) |
| 806 | mask |= dispc_mgr_get_vsync_irq(i); |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 807 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 808 | for (i = 0; i < num_mgrs; ++i) |
| 809 | mask |= dispc_mgr_get_framedone_irq(i); |
| 810 | |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 811 | r = omap_dispc_unregister_isr(dss_apply_irq_handler, NULL, mask); |
| 812 | WARN_ON(r); |
| 813 | |
Tomi Valkeinen | d09c7aa | 2011-11-15 12:04:43 +0200 | [diff] [blame] | 814 | dss_data.irq_enabled = false; |
Tomi Valkeinen | dbce016 | 2011-11-15 11:18:12 +0200 | [diff] [blame] | 815 | } |
| 816 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 817 | static void dss_apply_irq_handler(void *data, u32 mask) |
| 818 | { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 819 | const int num_mgrs = dss_feat_get_num_mgrs(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 820 | int i; |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 821 | bool extra_updating; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 822 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 823 | spin_lock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 824 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 825 | /* clear busy, updating flags, shadow_dirty flags */ |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 826 | for (i = 0; i < num_mgrs; i++) { |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 827 | struct omap_overlay_manager *mgr; |
| 828 | struct mgr_priv_data *mp; |
| 829 | |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 830 | mgr = omap_dss_get_overlay_manager(i); |
| 831 | mp = get_mgr_priv(mgr); |
| 832 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 833 | if (!mp->enabled) |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 834 | continue; |
| 835 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 836 | mp->updating = dispc_mgr_is_enabled(i); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 837 | |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 838 | if (!mgr_manual_update(mgr)) { |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 839 | bool was_busy = mp->busy; |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 840 | mp->busy = dispc_mgr_go_busy(i); |
| 841 | |
Tomi Valkeinen | 5b21417 | 2011-11-25 17:27:45 +0200 | [diff] [blame] | 842 | if (was_busy && !mp->busy) |
Tomi Valkeinen | 7609893 | 2011-11-16 12:03:22 +0200 | [diff] [blame] | 843 | mgr_clear_shadow_dirty(mgr); |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 844 | } |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 845 | } |
| 846 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 847 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 848 | dss_set_go_bits(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 849 | |
Tomi Valkeinen | f1577ce | 2011-11-16 14:37:48 +0200 | [diff] [blame] | 850 | extra_updating = extra_info_update_ongoing(); |
| 851 | if (!extra_updating) |
| 852 | complete_all(&extra_updated_completion); |
| 853 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 854 | if (!need_isr()) |
| 855 | dss_unregister_vsync_isr(); |
Tomi Valkeinen | 43a972d | 2011-11-15 15:04:25 +0200 | [diff] [blame] | 856 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 857 | spin_unlock(&data_lock); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 858 | } |
| 859 | |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 860 | static void omap_dss_mgr_apply_ovl(struct omap_overlay *ovl) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 861 | { |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 862 | struct ovl_priv_data *op; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 863 | |
Tomi Valkeinen | c10c6f0 | 2011-11-15 11:56:57 +0200 | [diff] [blame] | 864 | op = get_ovl_priv(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 865 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 866 | if (!op->user_info_dirty) |
Tomi Valkeinen | 5738b63 | 2011-11-15 13:37:33 +0200 | [diff] [blame] | 867 | return; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 868 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 869 | op->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 870 | op->info_dirty = true; |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 871 | op->info = op->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | static void omap_dss_mgr_apply_mgr(struct omap_overlay_manager *mgr) |
| 875 | { |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 876 | struct mgr_priv_data *mp; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 877 | |
Tomi Valkeinen | af3d64b | 2011-11-15 12:02:03 +0200 | [diff] [blame] | 878 | mp = get_mgr_priv(mgr); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 879 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 880 | if (!mp->user_info_dirty) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 881 | return; |
| 882 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 883 | mp->user_info_dirty = false; |
Tomi Valkeinen | 0b53f17 | 2011-11-16 14:31:58 +0200 | [diff] [blame] | 884 | mp->info_dirty = true; |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 885 | mp->info = mp->user_info; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 886 | } |
| 887 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 888 | int omap_dss_mgr_apply(struct omap_overlay_manager *mgr) |
| 889 | { |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 890 | unsigned long flags; |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 891 | struct omap_overlay *ovl; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 892 | int r; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 893 | |
| 894 | DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name); |
| 895 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 896 | spin_lock_irqsave(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 897 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 898 | r = dss_check_settings_apply(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 899 | if (r) { |
| 900 | spin_unlock_irqrestore(&data_lock, flags); |
| 901 | DSSERR("failed to apply settings: illegal configuration.\n"); |
| 902 | return r; |
| 903 | } |
| 904 | |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 905 | /* Configure overlays */ |
Tomi Valkeinen | 07e327c | 2011-11-05 10:59:59 +0200 | [diff] [blame] | 906 | list_for_each_entry(ovl, &mgr->overlays, list) |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 907 | omap_dss_mgr_apply_ovl(ovl); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 908 | |
| 909 | /* Configure manager */ |
| 910 | omap_dss_mgr_apply_mgr(mgr); |
| 911 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 912 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 913 | dss_set_go_bits(); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 914 | |
Tomi Valkeinen | 063fd70 | 2011-11-15 12:04:10 +0200 | [diff] [blame] | 915 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 916 | |
Tomi Valkeinen | e70f98a | 2011-11-16 16:53:44 +0200 | [diff] [blame] | 917 | return 0; |
Tomi Valkeinen | 58f25548 | 2011-11-04 09:48:54 +0200 | [diff] [blame] | 918 | } |
| 919 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame] | 920 | static void dss_apply_ovl_enable(struct omap_overlay *ovl, bool enable) |
| 921 | { |
| 922 | struct ovl_priv_data *op; |
| 923 | |
| 924 | op = get_ovl_priv(ovl); |
| 925 | |
| 926 | if (op->enabled == enable) |
| 927 | return; |
| 928 | |
| 929 | op->enabled = enable; |
| 930 | op->extra_info_dirty = true; |
| 931 | } |
| 932 | |
Tomi Valkeinen | 04576d4 | 2011-11-26 14:39:16 +0200 | [diff] [blame] | 933 | static void dss_apply_ovl_fifo_thresholds(struct omap_overlay *ovl, |
| 934 | u32 fifo_low, u32 fifo_high) |
| 935 | { |
| 936 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 937 | |
| 938 | if (op->fifo_low == fifo_low && op->fifo_high == fifo_high) |
| 939 | return; |
| 940 | |
| 941 | op->fifo_low = fifo_low; |
| 942 | op->fifo_high = fifo_high; |
| 943 | op->extra_info_dirty = true; |
| 944 | } |
| 945 | |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 946 | static void dss_ovl_setup_fifo(struct omap_overlay *ovl) |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 947 | { |
| 948 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 949 | u32 fifo_low, fifo_high; |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 950 | bool use_fifo_merge = false; |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 951 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 952 | if (!op->enabled && !op->enabling) |
| 953 | return; |
| 954 | |
Tomi Valkeinen | 83fa2f2 | 2012-01-13 13:17:01 +0200 | [diff] [blame] | 955 | dispc_ovl_compute_fifo_thresholds(ovl->id, &fifo_low, &fifo_high, |
Tomi Valkeinen | 3568f2a | 2012-05-15 15:31:01 +0300 | [diff] [blame] | 956 | use_fifo_merge, ovl_manual_update(ovl)); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 957 | |
Tomi Valkeinen | 04576d4 | 2011-11-26 14:39:16 +0200 | [diff] [blame] | 958 | dss_apply_ovl_fifo_thresholds(ovl, fifo_low, fifo_high); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 959 | } |
| 960 | |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 961 | static void dss_mgr_setup_fifos(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 962 | { |
| 963 | struct omap_overlay *ovl; |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 964 | struct mgr_priv_data *mp; |
| 965 | |
| 966 | mp = get_mgr_priv(mgr); |
| 967 | |
| 968 | if (!mp->enabled) |
| 969 | return; |
| 970 | |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 971 | list_for_each_entry(ovl, &mgr->overlays, list) |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 972 | dss_ovl_setup_fifo(ovl); |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 973 | } |
| 974 | |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 975 | static void dss_setup_fifos(void) |
Tomi Valkeinen | 75ae118 | 2011-11-26 14:36:19 +0200 | [diff] [blame] | 976 | { |
| 977 | const int num_mgrs = omap_dss_get_num_overlay_managers(); |
| 978 | struct omap_overlay_manager *mgr; |
| 979 | int i; |
| 980 | |
| 981 | for (i = 0; i < num_mgrs; ++i) { |
| 982 | mgr = omap_dss_get_overlay_manager(i); |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 983 | dss_mgr_setup_fifos(mgr); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 984 | } |
| 985 | } |
| 986 | |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 987 | int dss_mgr_enable(struct omap_overlay_manager *mgr) |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 988 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 989 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 990 | unsigned long flags; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 991 | int r; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 992 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 993 | mutex_lock(&apply_lock); |
| 994 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 995 | if (mp->enabled) |
| 996 | goto out; |
| 997 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 998 | spin_lock_irqsave(&data_lock, flags); |
| 999 | |
| 1000 | mp->enabled = true; |
Tomi Valkeinen | a6b24f8 | 2011-11-26 14:29:39 +0200 | [diff] [blame] | 1001 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 1002 | r = dss_check_settings(mgr); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1003 | if (r) { |
| 1004 | DSSERR("failed to enable manager %d: check_settings failed\n", |
| 1005 | mgr->id); |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 1006 | goto err; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1007 | } |
| 1008 | |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 1009 | dss_setup_fifos(); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1010 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1011 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1012 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1013 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 1014 | if (!mgr_manual_update(mgr)) |
| 1015 | mp->updating = true; |
| 1016 | |
Tomi Valkeinen | d7b6b6b | 2012-08-10 14:17:47 +0300 | [diff] [blame] | 1017 | if (!dss_data.irq_enabled && need_isr()) |
| 1018 | dss_register_vsync_isr(); |
| 1019 | |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1020 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1021 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1022 | if (!mgr_manual_update(mgr)) |
Tomi Valkeinen | 3a979f8 | 2012-10-19 14:14:38 +0300 | [diff] [blame] | 1023 | dispc_mgr_enable_sync(mgr->id); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1024 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1025 | out: |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1026 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 1027 | |
| 1028 | return 0; |
| 1029 | |
| 1030 | err: |
Tomi Valkeinen | a6b24f8 | 2011-11-26 14:29:39 +0200 | [diff] [blame] | 1031 | mp->enabled = false; |
Tomi Valkeinen | 2a4ee7e | 2011-11-21 13:34:48 +0200 | [diff] [blame] | 1032 | spin_unlock_irqrestore(&data_lock, flags); |
| 1033 | mutex_unlock(&apply_lock); |
| 1034 | return r; |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | void dss_mgr_disable(struct omap_overlay_manager *mgr) |
| 1038 | { |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1039 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1040 | unsigned long flags; |
| 1041 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1042 | mutex_lock(&apply_lock); |
| 1043 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1044 | if (!mp->enabled) |
| 1045 | goto out; |
| 1046 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 1047 | if (!mgr_manual_update(mgr)) |
Tomi Valkeinen | 3a979f8 | 2012-10-19 14:14:38 +0300 | [diff] [blame] | 1048 | dispc_mgr_disable_sync(mgr->id); |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1049 | |
| 1050 | spin_lock_irqsave(&data_lock, flags); |
| 1051 | |
Tomi Valkeinen | 3486137 | 2011-11-18 15:43:29 +0200 | [diff] [blame] | 1052 | mp->updating = false; |
Tomi Valkeinen | bf21352 | 2011-11-15 14:43:53 +0200 | [diff] [blame] | 1053 | mp->enabled = false; |
| 1054 | |
| 1055 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1056 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1057 | out: |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1058 | mutex_unlock(&apply_lock); |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 1059 | } |
| 1060 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1061 | int dss_mgr_set_info(struct omap_overlay_manager *mgr, |
| 1062 | struct omap_overlay_manager_info *info) |
| 1063 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1064 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1065 | unsigned long flags; |
Tomi Valkeinen | f17d04f | 2011-11-17 14:31:09 +0200 | [diff] [blame] | 1066 | int r; |
| 1067 | |
| 1068 | r = dss_mgr_simple_check(mgr, info); |
| 1069 | if (r) |
| 1070 | return r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1071 | |
| 1072 | spin_lock_irqsave(&data_lock, flags); |
| 1073 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1074 | mp->user_info = *info; |
| 1075 | mp->user_info_dirty = true; |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1076 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1077 | spin_unlock_irqrestore(&data_lock, flags); |
| 1078 | |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1079 | return 0; |
| 1080 | } |
| 1081 | |
| 1082 | void dss_mgr_get_info(struct omap_overlay_manager *mgr, |
| 1083 | struct omap_overlay_manager_info *info) |
| 1084 | { |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1085 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1086 | unsigned long flags; |
| 1087 | |
| 1088 | spin_lock_irqsave(&data_lock, flags); |
| 1089 | |
Tomi Valkeinen | 388c4c6 | 2011-11-16 13:58:07 +0200 | [diff] [blame] | 1090 | *info = mp->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1091 | |
| 1092 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1093 | } |
| 1094 | |
Archit Taneja | 97f01b3 | 2012-09-26 16:42:39 +0530 | [diff] [blame] | 1095 | int dss_mgr_set_output(struct omap_overlay_manager *mgr, |
| 1096 | struct omap_dss_output *output) |
| 1097 | { |
| 1098 | int r; |
| 1099 | |
| 1100 | mutex_lock(&apply_lock); |
| 1101 | |
| 1102 | if (mgr->output) { |
| 1103 | DSSERR("manager %s is already connected to an output\n", |
| 1104 | mgr->name); |
| 1105 | r = -EINVAL; |
| 1106 | goto err; |
| 1107 | } |
| 1108 | |
| 1109 | if ((mgr->supported_outputs & output->id) == 0) { |
| 1110 | DSSERR("output does not support manager %s\n", |
| 1111 | mgr->name); |
| 1112 | r = -EINVAL; |
| 1113 | goto err; |
| 1114 | } |
| 1115 | |
| 1116 | output->manager = mgr; |
| 1117 | mgr->output = output; |
| 1118 | |
| 1119 | mutex_unlock(&apply_lock); |
| 1120 | |
| 1121 | return 0; |
| 1122 | err: |
| 1123 | mutex_unlock(&apply_lock); |
| 1124 | return r; |
| 1125 | } |
| 1126 | |
| 1127 | int dss_mgr_unset_output(struct omap_overlay_manager *mgr) |
| 1128 | { |
| 1129 | int r; |
| 1130 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1131 | unsigned long flags; |
| 1132 | |
| 1133 | mutex_lock(&apply_lock); |
| 1134 | |
| 1135 | if (!mgr->output) { |
| 1136 | DSSERR("failed to unset output, output not set\n"); |
| 1137 | r = -EINVAL; |
| 1138 | goto err; |
| 1139 | } |
| 1140 | |
| 1141 | spin_lock_irqsave(&data_lock, flags); |
| 1142 | |
| 1143 | if (mp->enabled) { |
| 1144 | DSSERR("output can't be unset when manager is enabled\n"); |
| 1145 | r = -EINVAL; |
| 1146 | goto err1; |
| 1147 | } |
| 1148 | |
| 1149 | spin_unlock_irqrestore(&data_lock, flags); |
| 1150 | |
| 1151 | mgr->output->manager = NULL; |
| 1152 | mgr->output = NULL; |
| 1153 | |
| 1154 | mutex_unlock(&apply_lock); |
| 1155 | |
| 1156 | return 0; |
| 1157 | err1: |
| 1158 | spin_unlock_irqrestore(&data_lock, flags); |
| 1159 | err: |
| 1160 | mutex_unlock(&apply_lock); |
| 1161 | |
| 1162 | return r; |
| 1163 | } |
| 1164 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1165 | static void dss_apply_mgr_timings(struct omap_overlay_manager *mgr, |
Archit Taneja | 27dfddc | 2012-07-19 13:51:14 +0530 | [diff] [blame] | 1166 | const struct omap_video_timings *timings) |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1167 | { |
| 1168 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1169 | |
| 1170 | mp->timings = *timings; |
| 1171 | mp->extra_info_dirty = true; |
| 1172 | } |
| 1173 | |
| 1174 | void dss_mgr_set_timings(struct omap_overlay_manager *mgr, |
Archit Taneja | 27dfddc | 2012-07-19 13:51:14 +0530 | [diff] [blame] | 1175 | const struct omap_video_timings *timings) |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1176 | { |
| 1177 | unsigned long flags; |
Tomi Valkeinen | fed62e5 | 2012-08-09 18:13:13 +0300 | [diff] [blame] | 1178 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1179 | |
| 1180 | spin_lock_irqsave(&data_lock, flags); |
| 1181 | |
Tomi Valkeinen | fed62e5 | 2012-08-09 18:13:13 +0300 | [diff] [blame] | 1182 | if (mp->updating) { |
| 1183 | DSSERR("cannot set timings for %s: manager needs to be disabled\n", |
| 1184 | mgr->name); |
| 1185 | goto out; |
| 1186 | } |
| 1187 | |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1188 | dss_apply_mgr_timings(mgr, timings); |
Tomi Valkeinen | fed62e5 | 2012-08-09 18:13:13 +0300 | [diff] [blame] | 1189 | out: |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1190 | spin_unlock_irqrestore(&data_lock, flags); |
Archit Taneja | 45324a2 | 2012-04-26 19:31:22 +0530 | [diff] [blame] | 1191 | } |
Tomi Valkeinen | eb70d73 | 2011-11-15 12:15:18 +0200 | [diff] [blame] | 1192 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1193 | static void dss_apply_mgr_lcd_config(struct omap_overlay_manager *mgr, |
| 1194 | const struct dss_lcd_mgr_config *config) |
| 1195 | { |
| 1196 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1197 | |
| 1198 | mp->lcd_config = *config; |
| 1199 | mp->extra_info_dirty = true; |
| 1200 | } |
| 1201 | |
| 1202 | void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr, |
| 1203 | const struct dss_lcd_mgr_config *config) |
| 1204 | { |
| 1205 | unsigned long flags; |
| 1206 | struct mgr_priv_data *mp = get_mgr_priv(mgr); |
| 1207 | |
Tomi Valkeinen | aba9657 | 2012-08-09 18:07:45 +0300 | [diff] [blame] | 1208 | spin_lock_irqsave(&data_lock, flags); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1209 | |
| 1210 | if (mp->enabled) { |
| 1211 | DSSERR("cannot apply lcd config for %s: manager needs to be disabled\n", |
| 1212 | mgr->name); |
| 1213 | goto out; |
| 1214 | } |
| 1215 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1216 | dss_apply_mgr_lcd_config(mgr, config); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1217 | out: |
Tomi Valkeinen | aba9657 | 2012-08-09 18:07:45 +0300 | [diff] [blame] | 1218 | spin_unlock_irqrestore(&data_lock, flags); |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 1219 | } |
| 1220 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1221 | int dss_ovl_set_info(struct omap_overlay *ovl, |
| 1222 | struct omap_overlay_info *info) |
| 1223 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1224 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1225 | unsigned long flags; |
Tomi Valkeinen | fcc764d | 2011-11-17 14:26:48 +0200 | [diff] [blame] | 1226 | int r; |
| 1227 | |
| 1228 | r = dss_ovl_simple_check(ovl, info); |
| 1229 | if (r) |
| 1230 | return r; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1231 | |
| 1232 | spin_lock_irqsave(&data_lock, flags); |
| 1233 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1234 | op->user_info = *info; |
| 1235 | op->user_info_dirty = true; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1236 | |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1237 | spin_unlock_irqrestore(&data_lock, flags); |
| 1238 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1239 | return 0; |
| 1240 | } |
| 1241 | |
| 1242 | void dss_ovl_get_info(struct omap_overlay *ovl, |
| 1243 | struct omap_overlay_info *info) |
| 1244 | { |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1245 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1246 | unsigned long flags; |
| 1247 | |
| 1248 | spin_lock_irqsave(&data_lock, flags); |
| 1249 | |
Tomi Valkeinen | c1a9feb | 2011-11-16 14:11:56 +0200 | [diff] [blame] | 1250 | *info = op->user_info; |
Tomi Valkeinen | e0a2aa5b | 2011-11-15 14:32:57 +0200 | [diff] [blame] | 1251 | |
| 1252 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | int dss_ovl_set_manager(struct omap_overlay *ovl, |
| 1256 | struct omap_overlay_manager *mgr) |
| 1257 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1258 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1259 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1260 | int r; |
| 1261 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1262 | if (!mgr) |
| 1263 | return -EINVAL; |
| 1264 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1265 | mutex_lock(&apply_lock); |
| 1266 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1267 | if (ovl->manager) { |
| 1268 | DSSERR("overlay '%s' already has a manager '%s'\n", |
| 1269 | ovl->name, ovl->manager->name); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1270 | r = -EINVAL; |
| 1271 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1272 | } |
| 1273 | |
Archit Taneja | 02b5ff1 | 2012-11-07 14:47:22 +0530 | [diff] [blame] | 1274 | r = dispc_runtime_get(); |
| 1275 | if (r) |
| 1276 | goto err; |
| 1277 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1278 | spin_lock_irqsave(&data_lock, flags); |
| 1279 | |
| 1280 | if (op->enabled) { |
| 1281 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1282 | DSSERR("overlay has to be disabled to change the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1283 | r = -EINVAL; |
Archit Taneja | 02b5ff1 | 2012-11-07 14:47:22 +0530 | [diff] [blame] | 1284 | goto err1; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1285 | } |
| 1286 | |
Archit Taneja | 02b5ff1 | 2012-11-07 14:47:22 +0530 | [diff] [blame] | 1287 | dispc_ovl_set_channel_out(ovl->id, mgr->id); |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 1288 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1289 | ovl->manager = mgr; |
| 1290 | list_add_tail(&ovl->list, &mgr->overlays); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1291 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1292 | spin_unlock_irqrestore(&data_lock, flags); |
| 1293 | |
Archit Taneja | 02b5ff1 | 2012-11-07 14:47:22 +0530 | [diff] [blame] | 1294 | dispc_runtime_put(); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1295 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1296 | mutex_unlock(&apply_lock); |
| 1297 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1298 | return 0; |
Archit Taneja | 02b5ff1 | 2012-11-07 14:47:22 +0530 | [diff] [blame] | 1299 | |
| 1300 | err1: |
| 1301 | dispc_runtime_put(); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1302 | err: |
| 1303 | mutex_unlock(&apply_lock); |
| 1304 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | int dss_ovl_unset_manager(struct omap_overlay *ovl) |
| 1308 | { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1309 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1310 | unsigned long flags; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1311 | int r; |
| 1312 | |
| 1313 | mutex_lock(&apply_lock); |
| 1314 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1315 | if (!ovl->manager) { |
| 1316 | DSSERR("failed to detach overlay: manager not set\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1317 | r = -EINVAL; |
| 1318 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1319 | } |
| 1320 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1321 | spin_lock_irqsave(&data_lock, flags); |
| 1322 | |
| 1323 | if (op->enabled) { |
| 1324 | spin_unlock_irqrestore(&data_lock, flags); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1325 | DSSERR("overlay has to be disabled to unset the manager\n"); |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1326 | r = -EINVAL; |
| 1327 | goto err; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1328 | } |
| 1329 | |
Tomi Valkeinen | b2f5976 | 2012-09-06 16:10:28 +0300 | [diff] [blame] | 1330 | spin_unlock_irqrestore(&data_lock, flags); |
| 1331 | |
| 1332 | /* wait for pending extra_info updates to ensure the ovl is disabled */ |
| 1333 | wait_pending_extra_info_updates(); |
| 1334 | |
Archit Taneja | 02b5ff1 | 2012-11-07 14:47:22 +0530 | [diff] [blame] | 1335 | /* |
| 1336 | * For a manual update display, there is no guarantee that the overlay |
| 1337 | * is really disabled in HW, we may need an extra update from this |
| 1338 | * manager before the configurations can go in. Return an error if the |
| 1339 | * overlay needed an update from the manager. |
| 1340 | * |
| 1341 | * TODO: Instead of returning an error, try to do a dummy manager update |
| 1342 | * here to disable the overlay in hardware. Use the *GATED fields in |
| 1343 | * the DISPC_CONFIG registers to do a dummy update. |
| 1344 | */ |
Tomi Valkeinen | b2f5976 | 2012-09-06 16:10:28 +0300 | [diff] [blame] | 1345 | spin_lock_irqsave(&data_lock, flags); |
| 1346 | |
Archit Taneja | 02b5ff1 | 2012-11-07 14:47:22 +0530 | [diff] [blame] | 1347 | if (ovl_manual_update(ovl) && op->extra_info_dirty) { |
| 1348 | spin_unlock_irqrestore(&data_lock, flags); |
| 1349 | DSSERR("need an update to change the manager\n"); |
| 1350 | r = -EINVAL; |
| 1351 | goto err; |
| 1352 | } |
Tomi Valkeinen | 5d5a97a | 2011-11-16 14:17:54 +0200 | [diff] [blame] | 1353 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1354 | ovl->manager = NULL; |
| 1355 | list_del(&ovl->list); |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1356 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1357 | spin_unlock_irqrestore(&data_lock, flags); |
| 1358 | |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1359 | mutex_unlock(&apply_lock); |
| 1360 | |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1361 | return 0; |
Tomi Valkeinen | 5558db3 | 2011-11-15 14:28:48 +0200 | [diff] [blame] | 1362 | err: |
| 1363 | mutex_unlock(&apply_lock); |
| 1364 | return r; |
Tomi Valkeinen | f77b307 | 2011-11-15 12:11:11 +0200 | [diff] [blame] | 1365 | } |
| 1366 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1367 | bool dss_ovl_is_enabled(struct omap_overlay *ovl) |
| 1368 | { |
| 1369 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1370 | unsigned long flags; |
| 1371 | bool e; |
| 1372 | |
| 1373 | spin_lock_irqsave(&data_lock, flags); |
| 1374 | |
| 1375 | e = op->enabled; |
| 1376 | |
| 1377 | spin_unlock_irqrestore(&data_lock, flags); |
| 1378 | |
| 1379 | return e; |
| 1380 | } |
| 1381 | |
| 1382 | int dss_ovl_enable(struct omap_overlay *ovl) |
| 1383 | { |
| 1384 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1385 | unsigned long flags; |
| 1386 | int r; |
| 1387 | |
| 1388 | mutex_lock(&apply_lock); |
| 1389 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1390 | if (op->enabled) { |
| 1391 | r = 0; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1392 | goto err1; |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1393 | } |
| 1394 | |
Archit Taneja | 0f0e4e3 | 2012-09-03 17:14:09 +0530 | [diff] [blame] | 1395 | if (ovl->manager == NULL || ovl->manager->output == NULL) { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1396 | r = -EINVAL; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1397 | goto err1; |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | spin_lock_irqsave(&data_lock, flags); |
| 1401 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1402 | op->enabling = true; |
| 1403 | |
Archit Taneja | 228b213 | 2012-04-27 01:22:28 +0530 | [diff] [blame] | 1404 | r = dss_check_settings(ovl->manager); |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1405 | if (r) { |
| 1406 | DSSERR("failed to enable overlay %d: check_settings failed\n", |
| 1407 | ovl->id); |
| 1408 | goto err2; |
| 1409 | } |
| 1410 | |
Tomi Valkeinen | b3e93cb | 2012-08-06 16:50:14 +0300 | [diff] [blame] | 1411 | dss_setup_fifos(); |
Tomi Valkeinen | 6dc802e | 2011-11-16 14:28:12 +0200 | [diff] [blame] | 1412 | |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1413 | op->enabling = false; |
| 1414 | dss_apply_ovl_enable(ovl, true); |
| 1415 | |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1416 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1417 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1418 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1419 | spin_unlock_irqrestore(&data_lock, flags); |
| 1420 | |
| 1421 | mutex_unlock(&apply_lock); |
| 1422 | |
| 1423 | return 0; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1424 | err2: |
Tomi Valkeinen | 82153ed | 2011-11-26 14:26:46 +0200 | [diff] [blame] | 1425 | op->enabling = false; |
Tomi Valkeinen | 3951835 | 2011-11-17 17:35:28 +0200 | [diff] [blame] | 1426 | spin_unlock_irqrestore(&data_lock, flags); |
| 1427 | err1: |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1428 | mutex_unlock(&apply_lock); |
| 1429 | return r; |
| 1430 | } |
| 1431 | |
| 1432 | int dss_ovl_disable(struct omap_overlay *ovl) |
| 1433 | { |
| 1434 | struct ovl_priv_data *op = get_ovl_priv(ovl); |
| 1435 | unsigned long flags; |
| 1436 | int r; |
| 1437 | |
| 1438 | mutex_lock(&apply_lock); |
| 1439 | |
Tomi Valkeinen | e4f7ad7 | 2011-11-16 16:01:33 +0200 | [diff] [blame] | 1440 | if (!op->enabled) { |
| 1441 | r = 0; |
| 1442 | goto err; |
| 1443 | } |
| 1444 | |
Archit Taneja | 0f0e4e3 | 2012-09-03 17:14:09 +0530 | [diff] [blame] | 1445 | if (ovl->manager == NULL || ovl->manager->output == NULL) { |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1446 | r = -EINVAL; |
| 1447 | goto err; |
| 1448 | } |
| 1449 | |
| 1450 | spin_lock_irqsave(&data_lock, flags); |
| 1451 | |
Tomi Valkeinen | 841c09c | 2011-11-16 15:25:53 +0200 | [diff] [blame] | 1452 | dss_apply_ovl_enable(ovl, false); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1453 | dss_write_regs(); |
Tomi Valkeinen | 3ab15b2 | 2011-11-25 17:32:20 +0200 | [diff] [blame] | 1454 | dss_set_go_bits(); |
Tomi Valkeinen | 75c9496 | 2011-11-15 18:25:23 +0200 | [diff] [blame] | 1455 | |
Tomi Valkeinen | aaa874a | 2011-11-15 16:37:53 +0200 | [diff] [blame] | 1456 | spin_unlock_irqrestore(&data_lock, flags); |
| 1457 | |
| 1458 | mutex_unlock(&apply_lock); |
| 1459 | |
| 1460 | return 0; |
| 1461 | |
| 1462 | err: |
| 1463 | mutex_unlock(&apply_lock); |
| 1464 | return r; |
| 1465 | } |
| 1466 | |
Tomi Valkeinen | 8dd2491 | 2012-10-10 10:26:45 +0300 | [diff] [blame] | 1467 | static int compat_refcnt; |
| 1468 | static DEFINE_MUTEX(compat_init_lock); |
| 1469 | |
| 1470 | int omapdss_compat_init(void) |
| 1471 | { |
Tomi Valkeinen | 23dfd1a | 2012-10-23 13:46:12 +0300 | [diff] [blame^] | 1472 | struct platform_device *pdev = dss_get_core_pdev(); |
| 1473 | |
Tomi Valkeinen | 8dd2491 | 2012-10-10 10:26:45 +0300 | [diff] [blame] | 1474 | mutex_lock(&compat_init_lock); |
| 1475 | |
| 1476 | if (compat_refcnt++ > 0) |
| 1477 | goto out; |
| 1478 | |
| 1479 | apply_init_priv(); |
| 1480 | |
Tomi Valkeinen | 23dfd1a | 2012-10-23 13:46:12 +0300 | [diff] [blame^] | 1481 | dss_init_overlay_managers(pdev); |
| 1482 | dss_init_overlays(pdev); |
| 1483 | |
Tomi Valkeinen | 8dd2491 | 2012-10-10 10:26:45 +0300 | [diff] [blame] | 1484 | out: |
| 1485 | mutex_unlock(&compat_init_lock); |
| 1486 | |
| 1487 | return 0; |
| 1488 | } |
| 1489 | EXPORT_SYMBOL(omapdss_compat_init); |
| 1490 | |
| 1491 | void omapdss_compat_uninit(void) |
| 1492 | { |
Tomi Valkeinen | 23dfd1a | 2012-10-23 13:46:12 +0300 | [diff] [blame^] | 1493 | struct platform_device *pdev = dss_get_core_pdev(); |
| 1494 | |
Tomi Valkeinen | 8dd2491 | 2012-10-10 10:26:45 +0300 | [diff] [blame] | 1495 | mutex_lock(&compat_init_lock); |
| 1496 | |
| 1497 | if (--compat_refcnt > 0) |
| 1498 | goto out; |
| 1499 | |
Tomi Valkeinen | 23dfd1a | 2012-10-23 13:46:12 +0300 | [diff] [blame^] | 1500 | dss_uninit_overlay_managers(pdev); |
| 1501 | dss_uninit_overlays(pdev); |
Tomi Valkeinen | 8dd2491 | 2012-10-10 10:26:45 +0300 | [diff] [blame] | 1502 | out: |
| 1503 | mutex_unlock(&compat_init_lock); |
| 1504 | } |
| 1505 | EXPORT_SYMBOL(omapdss_compat_uninit); |